reactivity.esm-bundler.js 53 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016
  1. /**
  2. * @vue/reactivity v3.5.42
  3. * (c) 2018-present Yuxi (Evan) You and Vue contributors
  4. * @license MIT
  5. **/
  6. import { extend, hasChanged, isArray, isIntegerKey, isSymbol, isMap, hasOwn, isObject, makeMap, capitalize, toRawType, def, isFunction, EMPTY_OBJ, isSet, isPlainObject, remove, NOOP } from '@vue/shared';
  7. function warn(msg, ...args) {
  8. console.warn(`[Vue warn] ${msg}`, ...args);
  9. }
  10. let activeEffectScope;
  11. class EffectScope {
  12. // TODO isolatedDeclarations "__v_skip"
  13. constructor(detached = false) {
  14. this.detached = detached;
  15. /**
  16. * @internal
  17. */
  18. this._active = true;
  19. /**
  20. * @internal track `on` calls, allow `on` call multiple times
  21. */
  22. this._on = 0;
  23. /**
  24. * @internal
  25. */
  26. this.effects = [];
  27. /**
  28. * @internal
  29. */
  30. this.cleanups = [];
  31. this._isPaused = false;
  32. this._warnOnRun = true;
  33. this.__v_skip = true;
  34. if (!detached && activeEffectScope) {
  35. if (activeEffectScope.active) {
  36. this.parent = activeEffectScope;
  37. this.index = (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(
  38. this
  39. ) - 1;
  40. } else {
  41. this._active = false;
  42. this._warnOnRun = false;
  43. }
  44. }
  45. }
  46. get active() {
  47. return this._active;
  48. }
  49. pause() {
  50. if (this._active) {
  51. this._isPaused = true;
  52. let i, l;
  53. if (this.scopes) {
  54. const scopes = this.scopes.slice();
  55. for (i = 0, l = scopes.length; i < l; i++) {
  56. scopes[i].pause();
  57. }
  58. }
  59. for (i = 0, l = this.effects.length; i < l; i++) {
  60. this.effects[i].pause();
  61. }
  62. }
  63. }
  64. /**
  65. * Resumes the effect scope, including all child scopes and effects.
  66. */
  67. resume() {
  68. if (this._active) {
  69. if (this._isPaused) {
  70. this._isPaused = false;
  71. let i, l;
  72. if (this.scopes) {
  73. const scopes = this.scopes.slice();
  74. for (i = 0, l = scopes.length; i < l; i++) {
  75. scopes[i].resume();
  76. }
  77. }
  78. const effects = this.effects.slice();
  79. for (i = 0, l = effects.length; i < l; i++) {
  80. effects[i].resume();
  81. }
  82. }
  83. }
  84. }
  85. run(fn) {
  86. if (this._active) {
  87. const currentEffectScope = activeEffectScope;
  88. try {
  89. activeEffectScope = this;
  90. return fn();
  91. } finally {
  92. activeEffectScope = currentEffectScope;
  93. }
  94. } else if (!!(process.env.NODE_ENV !== "production") && this._warnOnRun) {
  95. warn(`cannot run an inactive effect scope.`);
  96. }
  97. }
  98. /**
  99. * This should only be called on non-detached scopes
  100. * @internal
  101. */
  102. on() {
  103. if (++this._on === 1) {
  104. this.prevScope = activeEffectScope;
  105. activeEffectScope = this;
  106. }
  107. }
  108. /**
  109. * This should only be called on non-detached scopes
  110. * @internal
  111. */
  112. off() {
  113. if (this._on > 0 && --this._on === 0) {
  114. if (activeEffectScope === this) {
  115. activeEffectScope = this.prevScope;
  116. } else {
  117. let current = activeEffectScope;
  118. while (current) {
  119. if (current.prevScope === this) {
  120. current.prevScope = this.prevScope;
  121. break;
  122. }
  123. current = current.prevScope;
  124. }
  125. }
  126. this.prevScope = void 0;
  127. }
  128. }
  129. stop(fromParent) {
  130. if (this._active) {
  131. this._active = false;
  132. let i, l;
  133. for (i = 0, l = this.effects.length; i < l; i++) {
  134. this.effects[i].stop();
  135. }
  136. this.effects.length = 0;
  137. for (i = 0, l = this.cleanups.length; i < l; i++) {
  138. this.cleanups[i]();
  139. }
  140. this.cleanups.length = 0;
  141. if (this.scopes) {
  142. const scopes = this.scopes.slice();
  143. for (i = 0, l = scopes.length; i < l; i++) {
  144. scopes[i].stop(true);
  145. }
  146. this.scopes.length = 0;
  147. }
  148. if (!this.detached && this.parent && !fromParent) {
  149. const last = this.parent.scopes.pop();
  150. if (last && last !== this) {
  151. this.parent.scopes[this.index] = last;
  152. last.index = this.index;
  153. }
  154. }
  155. this.parent = void 0;
  156. }
  157. }
  158. }
  159. function effectScope(detached) {
  160. return new EffectScope(detached);
  161. }
  162. function getCurrentScope() {
  163. return activeEffectScope;
  164. }
  165. function onScopeDispose(fn, failSilently = false) {
  166. if (activeEffectScope) {
  167. activeEffectScope.cleanups.push(fn);
  168. } else if (!!(process.env.NODE_ENV !== "production") && !failSilently) {
  169. warn(
  170. `onScopeDispose() is called when there is no active effect scope to be associated with.`
  171. );
  172. }
  173. }
  174. let activeSub;
  175. const EffectFlags = {
  176. "ACTIVE": 1,
  177. "1": "ACTIVE",
  178. "RUNNING": 2,
  179. "2": "RUNNING",
  180. "TRACKING": 4,
  181. "4": "TRACKING",
  182. "NOTIFIED": 8,
  183. "8": "NOTIFIED",
  184. "DIRTY": 16,
  185. "16": "DIRTY",
  186. "ALLOW_RECURSE": 32,
  187. "32": "ALLOW_RECURSE",
  188. "PAUSED": 64,
  189. "64": "PAUSED",
  190. "EVALUATED": 128,
  191. "128": "EVALUATED"
  192. };
  193. const pausedQueueEffects = /* @__PURE__ */ new WeakSet();
  194. class ReactiveEffect {
  195. constructor(fn) {
  196. this.fn = fn;
  197. /**
  198. * @internal
  199. */
  200. this.deps = void 0;
  201. /**
  202. * @internal
  203. */
  204. this.depsTail = void 0;
  205. /**
  206. * @internal
  207. */
  208. this.flags = 1 | 4;
  209. /**
  210. * @internal
  211. */
  212. this.next = void 0;
  213. /**
  214. * @internal
  215. */
  216. this.cleanup = void 0;
  217. this.scheduler = void 0;
  218. if (activeEffectScope) {
  219. if (activeEffectScope.active) {
  220. activeEffectScope.effects.push(this);
  221. } else {
  222. this.flags &= -2;
  223. }
  224. }
  225. }
  226. pause() {
  227. this.flags |= 64;
  228. }
  229. resume() {
  230. if (this.flags & 64) {
  231. this.flags &= -65;
  232. if (pausedQueueEffects.has(this)) {
  233. pausedQueueEffects.delete(this);
  234. this.trigger();
  235. }
  236. }
  237. }
  238. /**
  239. * @internal
  240. */
  241. notify() {
  242. if (this.flags & 2 && !(this.flags & 32)) {
  243. return;
  244. }
  245. if (!(this.flags & 8)) {
  246. batch(this);
  247. }
  248. }
  249. run() {
  250. if (!(this.flags & 1)) {
  251. return this.fn();
  252. }
  253. this.flags |= 2;
  254. cleanupEffect(this);
  255. prepareDeps(this);
  256. const prevEffect = activeSub;
  257. const prevShouldTrack = shouldTrack;
  258. activeSub = this;
  259. shouldTrack = true;
  260. try {
  261. return this.fn();
  262. } finally {
  263. if (!!(process.env.NODE_ENV !== "production") && activeSub !== this) {
  264. warn(
  265. "Active effect was not restored correctly - this is likely a Vue internal bug."
  266. );
  267. }
  268. cleanupDeps(this);
  269. activeSub = prevEffect;
  270. shouldTrack = prevShouldTrack;
  271. this.flags &= -3;
  272. }
  273. }
  274. stop() {
  275. if (this.flags & 1) {
  276. for (let link = this.deps; link; link = link.nextDep) {
  277. removeSub(link);
  278. }
  279. this.deps = this.depsTail = void 0;
  280. cleanupEffect(this);
  281. this.onStop && this.onStop();
  282. this.flags &= -2;
  283. }
  284. }
  285. trigger() {
  286. if (this.flags & 64) {
  287. pausedQueueEffects.add(this);
  288. } else if (this.scheduler) {
  289. this.scheduler();
  290. } else {
  291. this.runIfDirty();
  292. }
  293. }
  294. /**
  295. * @internal
  296. */
  297. runIfDirty() {
  298. if (isDirty(this)) {
  299. this.run();
  300. }
  301. }
  302. get dirty() {
  303. return isDirty(this);
  304. }
  305. }
  306. let batchDepth = 0;
  307. let batchedSub;
  308. let batchedComputed;
  309. function batch(sub, isComputed = false) {
  310. sub.flags |= 8;
  311. if (isComputed) {
  312. sub.next = batchedComputed;
  313. batchedComputed = sub;
  314. return;
  315. }
  316. sub.next = batchedSub;
  317. batchedSub = sub;
  318. }
  319. function startBatch() {
  320. batchDepth++;
  321. }
  322. function endBatch() {
  323. if (--batchDepth > 0) {
  324. return;
  325. }
  326. if (batchedComputed) {
  327. let e = batchedComputed;
  328. batchedComputed = void 0;
  329. while (e) {
  330. const next = e.next;
  331. e.next = void 0;
  332. e.flags &= -9;
  333. e = next;
  334. }
  335. }
  336. let error;
  337. while (batchedSub) {
  338. let e = batchedSub;
  339. batchedSub = void 0;
  340. while (e) {
  341. const next = e.next;
  342. e.next = void 0;
  343. e.flags &= -9;
  344. if (e.flags & 1) {
  345. try {
  346. ;
  347. e.trigger();
  348. } catch (err) {
  349. if (!error) error = err;
  350. }
  351. }
  352. e = next;
  353. }
  354. }
  355. if (error) throw error;
  356. }
  357. function prepareDeps(sub) {
  358. for (let link = sub.deps; link; link = link.nextDep) {
  359. link.version = -1;
  360. link.prevActiveLink = link.dep.activeLink;
  361. link.dep.activeLink = link;
  362. }
  363. }
  364. function cleanupDeps(sub) {
  365. let head;
  366. let tail = sub.depsTail;
  367. let link = tail;
  368. while (link) {
  369. const prev = link.prevDep;
  370. if (link.version === -1) {
  371. if (link === tail) tail = prev;
  372. removeSub(link);
  373. removeDep(link);
  374. } else {
  375. head = link;
  376. }
  377. link.dep.activeLink = link.prevActiveLink;
  378. link.prevActiveLink = void 0;
  379. link = prev;
  380. }
  381. sub.deps = head;
  382. sub.depsTail = tail;
  383. }
  384. function isDirty(sub) {
  385. for (let link = sub.deps; link; link = link.nextDep) {
  386. if (link.dep.version !== link.version || link.dep.computed && (refreshComputed(link.dep.computed) || link.dep.version !== link.version)) {
  387. return true;
  388. }
  389. }
  390. if (sub._dirty) {
  391. return true;
  392. }
  393. return false;
  394. }
  395. function refreshComputed(computed) {
  396. if (computed.flags & 4 && !(computed.flags & 16)) {
  397. return;
  398. }
  399. computed.flags &= -17;
  400. if (computed.globalVersion === globalVersion) {
  401. return;
  402. }
  403. computed.globalVersion = globalVersion;
  404. if (!computed.isSSR && computed.flags & 128 && (!computed.deps && !computed._dirty || !isDirty(computed))) {
  405. return;
  406. }
  407. computed.flags |= 2;
  408. const dep = computed.dep;
  409. const prevSub = activeSub;
  410. const prevShouldTrack = shouldTrack;
  411. activeSub = computed;
  412. shouldTrack = true;
  413. try {
  414. prepareDeps(computed);
  415. const value = computed.fn(computed._value);
  416. if (dep.version === 0 || hasChanged(value, computed._value)) {
  417. computed.flags |= 128;
  418. computed._value = value;
  419. dep.version++;
  420. }
  421. } catch (err) {
  422. dep.version++;
  423. throw err;
  424. } finally {
  425. activeSub = prevSub;
  426. shouldTrack = prevShouldTrack;
  427. cleanupDeps(computed);
  428. computed.flags &= -3;
  429. }
  430. }
  431. function removeSub(link, soft = false) {
  432. const { dep, prevSub, nextSub } = link;
  433. if (prevSub) {
  434. prevSub.nextSub = nextSub;
  435. link.prevSub = void 0;
  436. }
  437. if (nextSub) {
  438. nextSub.prevSub = prevSub;
  439. link.nextSub = void 0;
  440. }
  441. if (!!(process.env.NODE_ENV !== "production") && dep.subsHead === link) {
  442. dep.subsHead = nextSub;
  443. }
  444. if (dep.subs === link) {
  445. dep.subs = prevSub;
  446. if (!prevSub && dep.computed) {
  447. dep.computed.flags &= -5;
  448. for (let l = dep.computed.deps; l; l = l.nextDep) {
  449. removeSub(l, true);
  450. }
  451. }
  452. }
  453. if (!soft && !--dep.sc && dep.map) {
  454. dep.map.delete(dep.key);
  455. }
  456. }
  457. function removeDep(link) {
  458. const { prevDep, nextDep } = link;
  459. if (prevDep) {
  460. prevDep.nextDep = nextDep;
  461. link.prevDep = void 0;
  462. }
  463. if (nextDep) {
  464. nextDep.prevDep = prevDep;
  465. link.nextDep = void 0;
  466. }
  467. }
  468. function effect(fn, options) {
  469. if (fn.effect instanceof ReactiveEffect) {
  470. fn = fn.effect.fn;
  471. }
  472. const e = new ReactiveEffect(fn);
  473. if (options) {
  474. extend(e, options);
  475. }
  476. try {
  477. e.run();
  478. } catch (err) {
  479. e.stop();
  480. throw err;
  481. }
  482. const runner = e.run.bind(e);
  483. runner.effect = e;
  484. return runner;
  485. }
  486. function stop(runner) {
  487. runner.effect.stop();
  488. }
  489. let shouldTrack = true;
  490. const trackStack = [];
  491. function pauseTracking() {
  492. trackStack.push(shouldTrack);
  493. shouldTrack = false;
  494. }
  495. function enableTracking() {
  496. trackStack.push(shouldTrack);
  497. shouldTrack = true;
  498. }
  499. function resetTracking() {
  500. const last = trackStack.pop();
  501. shouldTrack = last === void 0 ? true : last;
  502. }
  503. function onEffectCleanup(fn, failSilently = false) {
  504. if (activeSub instanceof ReactiveEffect) {
  505. activeSub.cleanup = fn;
  506. } else if (!!(process.env.NODE_ENV !== "production") && !failSilently) {
  507. warn(
  508. `onEffectCleanup() was called when there was no active effect to associate with.`
  509. );
  510. }
  511. }
  512. function cleanupEffect(e) {
  513. const { cleanup } = e;
  514. e.cleanup = void 0;
  515. if (cleanup) {
  516. const prevSub = activeSub;
  517. activeSub = void 0;
  518. try {
  519. cleanup();
  520. } finally {
  521. activeSub = prevSub;
  522. }
  523. }
  524. }
  525. let globalVersion = 0;
  526. class Link {
  527. constructor(sub, dep) {
  528. this.sub = sub;
  529. this.dep = dep;
  530. this.version = dep.version;
  531. this.nextDep = this.prevDep = this.nextSub = this.prevSub = this.prevActiveLink = void 0;
  532. }
  533. }
  534. class Dep {
  535. // TODO isolatedDeclarations "__v_skip"
  536. constructor(computed) {
  537. this.computed = computed;
  538. this.version = 0;
  539. /**
  540. * Link between this dep and the current active effect
  541. */
  542. this.activeLink = void 0;
  543. /**
  544. * Doubly linked list representing the subscribing effects (tail)
  545. */
  546. this.subs = void 0;
  547. /**
  548. * For object property deps cleanup
  549. */
  550. this.map = void 0;
  551. this.key = void 0;
  552. /**
  553. * Subscriber counter
  554. */
  555. this.sc = 0;
  556. /**
  557. * @internal
  558. */
  559. this.__v_skip = true;
  560. if (!!(process.env.NODE_ENV !== "production")) {
  561. this.subsHead = void 0;
  562. }
  563. }
  564. track(debugInfo) {
  565. if (!activeSub || !shouldTrack || activeSub === this.computed) {
  566. return;
  567. }
  568. let link = this.activeLink;
  569. if (link === void 0 || link.sub !== activeSub) {
  570. link = this.activeLink = new Link(activeSub, this);
  571. if (!activeSub.deps) {
  572. activeSub.deps = activeSub.depsTail = link;
  573. } else {
  574. link.prevDep = activeSub.depsTail;
  575. activeSub.depsTail.nextDep = link;
  576. activeSub.depsTail = link;
  577. }
  578. addSub(link);
  579. } else if (link.version === -1) {
  580. link.version = this.version;
  581. if (link.nextDep) {
  582. const next = link.nextDep;
  583. next.prevDep = link.prevDep;
  584. if (link.prevDep) {
  585. link.prevDep.nextDep = next;
  586. }
  587. link.prevDep = activeSub.depsTail;
  588. link.nextDep = void 0;
  589. activeSub.depsTail.nextDep = link;
  590. activeSub.depsTail = link;
  591. if (activeSub.deps === link) {
  592. activeSub.deps = next;
  593. }
  594. }
  595. }
  596. if (!!(process.env.NODE_ENV !== "production") && activeSub.onTrack) {
  597. activeSub.onTrack(
  598. extend(
  599. {
  600. effect: activeSub
  601. },
  602. debugInfo
  603. )
  604. );
  605. }
  606. return link;
  607. }
  608. trigger(debugInfo) {
  609. this.version++;
  610. globalVersion++;
  611. this.notify(debugInfo);
  612. }
  613. notify(debugInfo) {
  614. startBatch();
  615. try {
  616. if (!!(process.env.NODE_ENV !== "production")) {
  617. for (let head = this.subsHead; head; head = head.nextSub) {
  618. if (head.sub.onTrigger && !(head.sub.flags & 8)) {
  619. head.sub.onTrigger(
  620. extend(
  621. {
  622. effect: head.sub
  623. },
  624. debugInfo
  625. )
  626. );
  627. }
  628. }
  629. }
  630. for (let link = this.subs; link; link = link.prevSub) {
  631. if (link.sub.notify()) {
  632. ;
  633. link.sub.dep.notify();
  634. }
  635. }
  636. } finally {
  637. endBatch();
  638. }
  639. }
  640. }
  641. function addSub(link) {
  642. link.dep.sc++;
  643. if (link.sub.flags & 4) {
  644. const computed = link.dep.computed;
  645. if (computed && !link.dep.subs) {
  646. computed.flags |= 4 | 16;
  647. for (let l = computed.deps; l; l = l.nextDep) {
  648. addSub(l);
  649. }
  650. }
  651. const currentTail = link.dep.subs;
  652. if (currentTail !== link) {
  653. link.prevSub = currentTail;
  654. if (currentTail) currentTail.nextSub = link;
  655. }
  656. if (!!(process.env.NODE_ENV !== "production") && link.dep.subsHead === void 0) {
  657. link.dep.subsHead = link;
  658. }
  659. link.dep.subs = link;
  660. }
  661. }
  662. const targetMap = /* @__PURE__ */ new WeakMap();
  663. const ITERATE_KEY = /* @__PURE__ */ Symbol(
  664. !!(process.env.NODE_ENV !== "production") ? "Object iterate" : ""
  665. );
  666. const MAP_KEY_ITERATE_KEY = /* @__PURE__ */ Symbol(
  667. !!(process.env.NODE_ENV !== "production") ? "Map keys iterate" : ""
  668. );
  669. const ARRAY_ITERATE_KEY = /* @__PURE__ */ Symbol(
  670. !!(process.env.NODE_ENV !== "production") ? "Array iterate" : ""
  671. );
  672. function track(target, type, key) {
  673. if (shouldTrack && activeSub) {
  674. let depsMap = targetMap.get(target);
  675. if (!depsMap) {
  676. targetMap.set(target, depsMap = /* @__PURE__ */ new Map());
  677. }
  678. let dep = depsMap.get(key);
  679. if (!dep) {
  680. depsMap.set(key, dep = new Dep());
  681. dep.map = depsMap;
  682. dep.key = key;
  683. }
  684. if (!!(process.env.NODE_ENV !== "production")) {
  685. dep.track({
  686. target,
  687. type,
  688. key
  689. });
  690. } else {
  691. dep.track();
  692. }
  693. }
  694. }
  695. function trigger(target, type, key, newValue, oldValue, oldTarget) {
  696. const depsMap = targetMap.get(target);
  697. if (!depsMap) {
  698. globalVersion++;
  699. return;
  700. }
  701. const run = (dep) => {
  702. if (dep) {
  703. if (!!(process.env.NODE_ENV !== "production")) {
  704. dep.trigger({
  705. target,
  706. type,
  707. key,
  708. newValue,
  709. oldValue,
  710. oldTarget
  711. });
  712. } else {
  713. dep.trigger();
  714. }
  715. }
  716. };
  717. startBatch();
  718. if (type === "clear") {
  719. depsMap.forEach(run);
  720. } else {
  721. const targetIsArray = isArray(target);
  722. const isArrayIndex = targetIsArray && isIntegerKey(key);
  723. if (targetIsArray && key === "length") {
  724. const newLength = Number(newValue);
  725. depsMap.forEach((dep, key2) => {
  726. if (key2 === "length" || key2 === ARRAY_ITERATE_KEY || !isSymbol(key2) && key2 >= newLength) {
  727. run(dep);
  728. }
  729. });
  730. } else {
  731. if (key !== void 0 || depsMap.has(void 0)) {
  732. run(depsMap.get(key));
  733. }
  734. if (isArrayIndex) {
  735. run(depsMap.get(ARRAY_ITERATE_KEY));
  736. }
  737. switch (type) {
  738. case "add":
  739. if (!targetIsArray) {
  740. run(depsMap.get(ITERATE_KEY));
  741. if (isMap(target)) {
  742. run(depsMap.get(MAP_KEY_ITERATE_KEY));
  743. }
  744. } else if (isArrayIndex) {
  745. run(depsMap.get("length"));
  746. }
  747. break;
  748. case "delete":
  749. if (!targetIsArray) {
  750. run(depsMap.get(ITERATE_KEY));
  751. if (isMap(target)) {
  752. run(depsMap.get(MAP_KEY_ITERATE_KEY));
  753. }
  754. }
  755. break;
  756. case "set":
  757. if (isMap(target)) {
  758. run(depsMap.get(ITERATE_KEY));
  759. }
  760. break;
  761. }
  762. }
  763. }
  764. endBatch();
  765. }
  766. function getDepFromReactive(object, key) {
  767. const depMap = targetMap.get(object);
  768. return depMap && depMap.get(key);
  769. }
  770. function reactiveReadArray(array) {
  771. const raw = toRaw(array);
  772. if (raw === array) return raw;
  773. track(raw, "iterate", ARRAY_ITERATE_KEY);
  774. return isShallow(array) ? raw : raw.map(toReactive);
  775. }
  776. function shallowReadArray(arr) {
  777. track(arr = toRaw(arr), "iterate", ARRAY_ITERATE_KEY);
  778. return arr;
  779. }
  780. function toWrapped(target, item) {
  781. if (isReadonly(target)) {
  782. return isReactive(target) ? toReadonly(toReactive(item)) : toReadonly(item);
  783. }
  784. return toReactive(item);
  785. }
  786. const arrayInstrumentations = {
  787. __proto__: null,
  788. [Symbol.iterator]() {
  789. return iterator(this, Symbol.iterator, (item) => toWrapped(this, item));
  790. },
  791. concat(...args) {
  792. return reactiveReadArray(this).concat(
  793. ...args.map((x) => isArray(x) ? reactiveReadArray(x) : x)
  794. );
  795. },
  796. entries() {
  797. return iterator(this, "entries", (value) => {
  798. value[1] = toWrapped(this, value[1]);
  799. return value;
  800. });
  801. },
  802. every(fn, thisArg) {
  803. return apply(this, "every", fn, thisArg, void 0, arguments);
  804. },
  805. filter(fn, thisArg) {
  806. return apply(
  807. this,
  808. "filter",
  809. fn,
  810. thisArg,
  811. (v) => v.map((item) => toWrapped(this, item)),
  812. arguments
  813. );
  814. },
  815. find(fn, thisArg) {
  816. return apply(
  817. this,
  818. "find",
  819. fn,
  820. thisArg,
  821. (item) => toWrapped(this, item),
  822. arguments
  823. );
  824. },
  825. findIndex(fn, thisArg) {
  826. return apply(this, "findIndex", fn, thisArg, void 0, arguments);
  827. },
  828. findLast(fn, thisArg) {
  829. return apply(
  830. this,
  831. "findLast",
  832. fn,
  833. thisArg,
  834. (item) => toWrapped(this, item),
  835. arguments
  836. );
  837. },
  838. findLastIndex(fn, thisArg) {
  839. return apply(this, "findLastIndex", fn, thisArg, void 0, arguments);
  840. },
  841. // flat, flatMap could benefit from ARRAY_ITERATE but are not straight-forward to implement
  842. forEach(fn, thisArg) {
  843. return apply(this, "forEach", fn, thisArg, void 0, arguments);
  844. },
  845. includes(...args) {
  846. return searchProxy(this, "includes", args);
  847. },
  848. indexOf(...args) {
  849. return searchProxy(this, "indexOf", args);
  850. },
  851. join(separator) {
  852. return reactiveReadArray(this).join(separator);
  853. },
  854. // keys() iterator only reads `length`, no optimization required
  855. lastIndexOf(...args) {
  856. return searchProxy(this, "lastIndexOf", args);
  857. },
  858. map(fn, thisArg) {
  859. return apply(this, "map", fn, thisArg, void 0, arguments);
  860. },
  861. pop() {
  862. return noTracking(this, "pop");
  863. },
  864. push(...args) {
  865. return noTracking(this, "push", args);
  866. },
  867. reduce(fn, ...args) {
  868. return reduce(this, "reduce", fn, args);
  869. },
  870. reduceRight(fn, ...args) {
  871. return reduce(this, "reduceRight", fn, args);
  872. },
  873. shift() {
  874. return noTracking(this, "shift");
  875. },
  876. // slice could use ARRAY_ITERATE but also seems to beg for range tracking
  877. some(fn, thisArg) {
  878. return apply(this, "some", fn, thisArg, void 0, arguments);
  879. },
  880. splice(...args) {
  881. return noTracking(this, "splice", args);
  882. },
  883. toReversed() {
  884. return reactiveReadArray(this).toReversed();
  885. },
  886. toSorted(comparer) {
  887. return reactiveReadArray(this).toSorted(comparer);
  888. },
  889. toSpliced(...args) {
  890. return reactiveReadArray(this).toSpliced(...args);
  891. },
  892. unshift(...args) {
  893. return noTracking(this, "unshift", args);
  894. },
  895. values() {
  896. return iterator(this, "values", (item) => toWrapped(this, item));
  897. }
  898. };
  899. function iterator(self, method, wrapValue) {
  900. const arr = shallowReadArray(self);
  901. const iter = arr[method]();
  902. if (arr !== self && !isShallow(self)) {
  903. iter._next = iter.next;
  904. iter.next = () => {
  905. const result = iter._next();
  906. if (!result.done) {
  907. result.value = wrapValue(result.value);
  908. }
  909. return result;
  910. };
  911. }
  912. return iter;
  913. }
  914. const arrayProto = Array.prototype;
  915. function apply(self, method, fn, thisArg, wrappedRetFn, args) {
  916. const arr = shallowReadArray(self);
  917. const needsWrap = arr !== self && !isShallow(self);
  918. const methodFn = arr[method];
  919. if (methodFn !== arrayProto[method]) {
  920. const result2 = methodFn.apply(self, args);
  921. return needsWrap ? toReactive(result2) : result2;
  922. }
  923. let wrappedFn = fn;
  924. if (arr !== self) {
  925. if (needsWrap) {
  926. wrappedFn = function(item, index) {
  927. return fn.call(this, toWrapped(self, item), index, self);
  928. };
  929. } else if (fn.length > 2) {
  930. wrappedFn = function(item, index) {
  931. return fn.call(this, item, index, self);
  932. };
  933. }
  934. }
  935. const result = methodFn.call(arr, wrappedFn, thisArg);
  936. return needsWrap && wrappedRetFn ? wrappedRetFn(result) : result;
  937. }
  938. function reduce(self, method, fn, args) {
  939. const arr = shallowReadArray(self);
  940. const needsWrap = arr !== self && !isShallow(self);
  941. let wrappedFn = fn;
  942. let wrapInitialAccumulator = false;
  943. if (arr !== self) {
  944. if (needsWrap) {
  945. wrapInitialAccumulator = args.length === 0;
  946. wrappedFn = function(acc, item, index) {
  947. if (wrapInitialAccumulator) {
  948. wrapInitialAccumulator = false;
  949. acc = toWrapped(self, acc);
  950. }
  951. return fn.call(this, acc, toWrapped(self, item), index, self);
  952. };
  953. } else if (fn.length > 3) {
  954. wrappedFn = function(acc, item, index) {
  955. return fn.call(this, acc, item, index, self);
  956. };
  957. }
  958. }
  959. const result = arr[method](wrappedFn, ...args);
  960. return wrapInitialAccumulator ? toWrapped(self, result) : result;
  961. }
  962. function searchProxy(self, method, args) {
  963. const arr = toRaw(self);
  964. track(arr, "iterate", ARRAY_ITERATE_KEY);
  965. const res = arr[method](...args);
  966. if ((res === -1 || res === false) && isProxy(args[0])) {
  967. args[0] = toRaw(args[0]);
  968. return arr[method](...args);
  969. }
  970. return res;
  971. }
  972. function noTracking(self, method, args = []) {
  973. pauseTracking();
  974. startBatch();
  975. const res = toRaw(self)[method].apply(self, args);
  976. endBatch();
  977. resetTracking();
  978. return res;
  979. }
  980. const isNonTrackableKeys = /* @__PURE__ */ makeMap(`__proto__,__v_isRef,__isVue`);
  981. const builtInSymbols = new Set(
  982. /* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol)
  983. );
  984. function hasOwnProperty(key) {
  985. if (!isSymbol(key)) key = String(key);
  986. const obj = toRaw(this);
  987. track(obj, "has", key);
  988. return obj.hasOwnProperty(key);
  989. }
  990. class BaseReactiveHandler {
  991. constructor(_isReadonly = false, _isShallow = false) {
  992. this._isReadonly = _isReadonly;
  993. this._isShallow = _isShallow;
  994. }
  995. get(target, key, receiver) {
  996. if (key === "__v_skip") return target["__v_skip"];
  997. const isReadonly2 = this._isReadonly, isShallow2 = this._isShallow;
  998. if (key === "__v_isReactive") {
  999. return !isReadonly2;
  1000. } else if (key === "__v_isReadonly") {
  1001. return isReadonly2;
  1002. } else if (key === "__v_isShallow") {
  1003. return isShallow2;
  1004. } else if (key === "__v_raw") {
  1005. if (receiver === (isReadonly2 ? isShallow2 ? shallowReadonlyMap : readonlyMap : isShallow2 ? shallowReactiveMap : reactiveMap).get(target) || // receiver is not the reactive proxy, but has the same prototype
  1006. // this means the receiver is a user proxy of the reactive proxy
  1007. Object.getPrototypeOf(target) === Object.getPrototypeOf(receiver)) {
  1008. return target;
  1009. }
  1010. return;
  1011. }
  1012. const targetIsArray = isArray(target);
  1013. if (!isReadonly2) {
  1014. let fn;
  1015. if (targetIsArray && (fn = arrayInstrumentations[key])) {
  1016. return fn;
  1017. }
  1018. if (key === "hasOwnProperty") {
  1019. return hasOwnProperty;
  1020. }
  1021. }
  1022. const res = Reflect.get(
  1023. target,
  1024. key,
  1025. // if this is a proxy wrapping a ref, return methods using the raw ref
  1026. // as receiver so that we don't have to call `toRaw` on the ref in all
  1027. // its class methods
  1028. isRef(target) ? target : receiver
  1029. );
  1030. if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
  1031. return res;
  1032. }
  1033. if (!isReadonly2) {
  1034. track(target, "get", key);
  1035. }
  1036. if (isShallow2) {
  1037. return res;
  1038. }
  1039. if (isRef(res)) {
  1040. const value = targetIsArray && isIntegerKey(key) ? res : res.value;
  1041. return isReadonly2 && isObject(value) ? readonly(value) : value;
  1042. }
  1043. if (isObject(res)) {
  1044. return isReadonly2 ? readonly(res) : reactive(res);
  1045. }
  1046. return res;
  1047. }
  1048. }
  1049. class MutableReactiveHandler extends BaseReactiveHandler {
  1050. constructor(isShallow2 = false) {
  1051. super(false, isShallow2);
  1052. }
  1053. set(target, key, value, receiver) {
  1054. let oldValue = target[key];
  1055. const isArrayWithIntegerKey = isArray(target) && isIntegerKey(key);
  1056. if (!this._isShallow) {
  1057. const isOldValueReadonly = isReadonly(oldValue);
  1058. if (!isShallow(value) && !isReadonly(value)) {
  1059. oldValue = toRaw(oldValue);
  1060. value = toRaw(value);
  1061. }
  1062. if (!isArrayWithIntegerKey && isRef(oldValue) && !isRef(value)) {
  1063. if (isOldValueReadonly) {
  1064. if (!!(process.env.NODE_ENV !== "production")) {
  1065. warn(
  1066. `Set operation on key "${String(key)}" failed: target is readonly.`,
  1067. target[key]
  1068. );
  1069. }
  1070. return true;
  1071. } else {
  1072. oldValue.value = value;
  1073. return true;
  1074. }
  1075. }
  1076. }
  1077. const hadKey = isArrayWithIntegerKey ? Number(key) < target.length : hasOwn(target, key);
  1078. const result = Reflect.set(
  1079. target,
  1080. key,
  1081. value,
  1082. isRef(target) ? target : receiver
  1083. );
  1084. if (target === toRaw(receiver) && result) {
  1085. if (!hadKey) {
  1086. trigger(target, "add", key, value);
  1087. } else if (hasChanged(value, oldValue)) {
  1088. trigger(target, "set", key, value, oldValue);
  1089. }
  1090. }
  1091. return result;
  1092. }
  1093. deleteProperty(target, key) {
  1094. const hadKey = hasOwn(target, key);
  1095. const oldValue = target[key];
  1096. const result = Reflect.deleteProperty(target, key);
  1097. if (result && hadKey) {
  1098. trigger(target, "delete", key, void 0, oldValue);
  1099. }
  1100. return result;
  1101. }
  1102. has(target, key) {
  1103. const result = Reflect.has(target, key);
  1104. if (!isSymbol(key) || !builtInSymbols.has(key)) {
  1105. track(target, "has", key);
  1106. }
  1107. return result;
  1108. }
  1109. ownKeys(target) {
  1110. track(
  1111. target,
  1112. "iterate",
  1113. isArray(target) ? "length" : ITERATE_KEY
  1114. );
  1115. return Reflect.ownKeys(target);
  1116. }
  1117. }
  1118. class ReadonlyReactiveHandler extends BaseReactiveHandler {
  1119. constructor(isShallow2 = false) {
  1120. super(true, isShallow2);
  1121. }
  1122. set(target, key) {
  1123. if (!!(process.env.NODE_ENV !== "production")) {
  1124. warn(
  1125. `Set operation on key "${String(key)}" failed: target is readonly.`,
  1126. target
  1127. );
  1128. }
  1129. return true;
  1130. }
  1131. deleteProperty(target, key) {
  1132. if (!!(process.env.NODE_ENV !== "production")) {
  1133. warn(
  1134. `Delete operation on key "${String(key)}" failed: target is readonly.`,
  1135. target
  1136. );
  1137. }
  1138. return true;
  1139. }
  1140. }
  1141. const mutableHandlers = /* @__PURE__ */ new MutableReactiveHandler();
  1142. const readonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler();
  1143. const shallowReactiveHandlers = /* @__PURE__ */ new MutableReactiveHandler(true);
  1144. const shallowReadonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler(true);
  1145. const toShallow = (value) => value;
  1146. const getProto = (v) => Reflect.getPrototypeOf(v);
  1147. function createIterableMethod(method, isReadonly2, isShallow2) {
  1148. return function(...args) {
  1149. const target = this["__v_raw"];
  1150. const rawTarget = toRaw(target);
  1151. const targetIsMap = isMap(rawTarget);
  1152. const isPair = method === "entries" || method === Symbol.iterator && targetIsMap;
  1153. const isKeyOnly = method === "keys" && targetIsMap;
  1154. const innerIterator = target[method](...args);
  1155. const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
  1156. !isReadonly2 && track(
  1157. rawTarget,
  1158. "iterate",
  1159. isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY
  1160. );
  1161. return extend(
  1162. // inheriting all iterator properties
  1163. Object.create(innerIterator),
  1164. {
  1165. // iterator protocol
  1166. next() {
  1167. const { value, done } = innerIterator.next();
  1168. return done ? { value, done } : {
  1169. value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
  1170. done
  1171. };
  1172. }
  1173. }
  1174. );
  1175. };
  1176. }
  1177. function createReadonlyMethod(type) {
  1178. return function(...args) {
  1179. if (!!(process.env.NODE_ENV !== "production")) {
  1180. const key = args[0] ? `on key "${args[0]}" ` : ``;
  1181. warn(
  1182. `${capitalize(type)} operation ${key}failed: target is readonly.`,
  1183. toRaw(this)
  1184. );
  1185. }
  1186. return type === "delete" ? false : type === "clear" ? void 0 : this;
  1187. };
  1188. }
  1189. function createInstrumentations(readonly, shallow) {
  1190. const instrumentations = {
  1191. get(key) {
  1192. const target = this["__v_raw"];
  1193. const rawTarget = toRaw(target);
  1194. const rawKey = toRaw(key);
  1195. if (!readonly) {
  1196. if (hasChanged(key, rawKey)) {
  1197. track(rawTarget, "get", key);
  1198. }
  1199. track(rawTarget, "get", rawKey);
  1200. }
  1201. const { has } = getProto(rawTarget);
  1202. const wrap = shallow ? toShallow : readonly ? toReadonly : toReactive;
  1203. if (has.call(rawTarget, key)) {
  1204. return wrap(target.get(key));
  1205. } else if (has.call(rawTarget, rawKey)) {
  1206. return wrap(target.get(rawKey));
  1207. } else if (target !== rawTarget) {
  1208. target.get(key);
  1209. }
  1210. },
  1211. get size() {
  1212. const target = this["__v_raw"];
  1213. !readonly && track(toRaw(target), "iterate", ITERATE_KEY);
  1214. return target.size;
  1215. },
  1216. has(key) {
  1217. const target = this["__v_raw"];
  1218. const rawTarget = toRaw(target);
  1219. const rawKey = toRaw(key);
  1220. if (!readonly) {
  1221. if (hasChanged(key, rawKey)) {
  1222. track(rawTarget, "has", key);
  1223. }
  1224. track(rawTarget, "has", rawKey);
  1225. }
  1226. return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey);
  1227. },
  1228. forEach(callback, thisArg) {
  1229. const observed = this;
  1230. const target = observed["__v_raw"];
  1231. const rawTarget = toRaw(target);
  1232. const wrap = shallow ? toShallow : readonly ? toReadonly : toReactive;
  1233. !readonly && track(rawTarget, "iterate", ITERATE_KEY);
  1234. return target.forEach((value, key) => {
  1235. return callback.call(thisArg, wrap(value), wrap(key), observed);
  1236. });
  1237. }
  1238. };
  1239. extend(
  1240. instrumentations,
  1241. readonly ? {
  1242. add: createReadonlyMethod("add"),
  1243. set: createReadonlyMethod("set"),
  1244. delete: createReadonlyMethod("delete"),
  1245. clear: createReadonlyMethod("clear")
  1246. } : {
  1247. add(value) {
  1248. const target = toRaw(this);
  1249. const proto = getProto(target);
  1250. const rawValue = toRaw(value);
  1251. const valueToAdd = !shallow && !isShallow(value) && !isReadonly(value) ? rawValue : value;
  1252. const hadKey = proto.has.call(target, valueToAdd) || hasChanged(value, valueToAdd) && proto.has.call(target, value) || hasChanged(rawValue, valueToAdd) && proto.has.call(target, rawValue);
  1253. if (!hadKey) {
  1254. target.add(valueToAdd);
  1255. trigger(target, "add", valueToAdd, valueToAdd);
  1256. }
  1257. return this;
  1258. },
  1259. set(key, value) {
  1260. if (!shallow && !isShallow(value) && !isReadonly(value)) {
  1261. value = toRaw(value);
  1262. }
  1263. const target = toRaw(this);
  1264. const { has, get } = getProto(target);
  1265. let hadKey = has.call(target, key);
  1266. if (!hadKey) {
  1267. key = toRaw(key);
  1268. hadKey = has.call(target, key);
  1269. } else if (!!(process.env.NODE_ENV !== "production")) {
  1270. checkIdentityKeys(target, has, key);
  1271. }
  1272. const oldValue = get.call(target, key);
  1273. target.set(key, value);
  1274. if (!hadKey) {
  1275. trigger(target, "add", key, value);
  1276. } else if (hasChanged(value, oldValue)) {
  1277. trigger(target, "set", key, value, oldValue);
  1278. }
  1279. return this;
  1280. },
  1281. delete(key) {
  1282. const target = toRaw(this);
  1283. const { has, get } = getProto(target);
  1284. let hadKey = has.call(target, key);
  1285. if (!hadKey) {
  1286. key = toRaw(key);
  1287. hadKey = has.call(target, key);
  1288. } else if (!!(process.env.NODE_ENV !== "production")) {
  1289. checkIdentityKeys(target, has, key);
  1290. }
  1291. const oldValue = get ? get.call(target, key) : void 0;
  1292. const result = target.delete(key);
  1293. if (hadKey) {
  1294. trigger(target, "delete", key, void 0, oldValue);
  1295. }
  1296. return result;
  1297. },
  1298. clear() {
  1299. const target = toRaw(this);
  1300. const hadItems = target.size !== 0;
  1301. const oldTarget = !!(process.env.NODE_ENV !== "production") ? isMap(target) ? new Map(target) : new Set(target) : void 0;
  1302. const result = target.clear();
  1303. if (hadItems) {
  1304. trigger(
  1305. target,
  1306. "clear",
  1307. void 0,
  1308. void 0,
  1309. oldTarget
  1310. );
  1311. }
  1312. return result;
  1313. }
  1314. }
  1315. );
  1316. const iteratorMethods = [
  1317. "keys",
  1318. "values",
  1319. "entries",
  1320. Symbol.iterator
  1321. ];
  1322. iteratorMethods.forEach((method) => {
  1323. instrumentations[method] = createIterableMethod(method, readonly, shallow);
  1324. });
  1325. return instrumentations;
  1326. }
  1327. function createInstrumentationGetter(isReadonly2, shallow) {
  1328. const instrumentations = createInstrumentations(isReadonly2, shallow);
  1329. return (target, key, receiver) => {
  1330. if (key === "__v_isReactive") {
  1331. return !isReadonly2;
  1332. } else if (key === "__v_isReadonly") {
  1333. return isReadonly2;
  1334. } else if (key === "__v_raw") {
  1335. return target;
  1336. }
  1337. return Reflect.get(
  1338. hasOwn(instrumentations, key) && key in target ? instrumentations : target,
  1339. key,
  1340. receiver
  1341. );
  1342. };
  1343. }
  1344. const mutableCollectionHandlers = {
  1345. get: /* @__PURE__ */ createInstrumentationGetter(false, false)
  1346. };
  1347. const shallowCollectionHandlers = {
  1348. get: /* @__PURE__ */ createInstrumentationGetter(false, true)
  1349. };
  1350. const readonlyCollectionHandlers = {
  1351. get: /* @__PURE__ */ createInstrumentationGetter(true, false)
  1352. };
  1353. const shallowReadonlyCollectionHandlers = {
  1354. get: /* @__PURE__ */ createInstrumentationGetter(true, true)
  1355. };
  1356. function checkIdentityKeys(target, has, key) {
  1357. const rawKey = toRaw(key);
  1358. if (rawKey !== key && has.call(target, rawKey)) {
  1359. const type = toRawType(target);
  1360. warn(
  1361. `Reactive ${type} contains both the raw and reactive versions of the same object${type === `Map` ? ` as keys` : ``}, which can lead to inconsistencies. Avoid differentiating between the raw and reactive versions of an object and only use the reactive version if possible.`
  1362. );
  1363. }
  1364. }
  1365. const reactiveMap = /* @__PURE__ */ new WeakMap();
  1366. const shallowReactiveMap = /* @__PURE__ */ new WeakMap();
  1367. const readonlyMap = /* @__PURE__ */ new WeakMap();
  1368. const shallowReadonlyMap = /* @__PURE__ */ new WeakMap();
  1369. function targetTypeMap(rawType) {
  1370. switch (rawType) {
  1371. case "Object":
  1372. case "Array":
  1373. return 1 /* COMMON */;
  1374. case "Map":
  1375. case "Set":
  1376. case "WeakMap":
  1377. case "WeakSet":
  1378. return 2 /* COLLECTION */;
  1379. default:
  1380. return 0 /* INVALID */;
  1381. }
  1382. }
  1383. // @__NO_SIDE_EFFECTS__
  1384. function reactive(target) {
  1385. if (/* @__PURE__ */ isReadonly(target)) {
  1386. return target;
  1387. }
  1388. return createReactiveObject(
  1389. target,
  1390. false,
  1391. mutableHandlers,
  1392. mutableCollectionHandlers,
  1393. reactiveMap
  1394. );
  1395. }
  1396. // @__NO_SIDE_EFFECTS__
  1397. function shallowReactive(target) {
  1398. return createReactiveObject(
  1399. target,
  1400. false,
  1401. shallowReactiveHandlers,
  1402. shallowCollectionHandlers,
  1403. shallowReactiveMap
  1404. );
  1405. }
  1406. // @__NO_SIDE_EFFECTS__
  1407. function readonly(target) {
  1408. return createReactiveObject(
  1409. target,
  1410. true,
  1411. readonlyHandlers,
  1412. readonlyCollectionHandlers,
  1413. readonlyMap
  1414. );
  1415. }
  1416. // @__NO_SIDE_EFFECTS__
  1417. function shallowReadonly(target) {
  1418. return createReactiveObject(
  1419. target,
  1420. true,
  1421. shallowReadonlyHandlers,
  1422. shallowReadonlyCollectionHandlers,
  1423. shallowReadonlyMap
  1424. );
  1425. }
  1426. function createReactiveObject(target, isReadonly2, baseHandlers, collectionHandlers, proxyMap) {
  1427. if (!isObject(target)) {
  1428. if (!!(process.env.NODE_ENV !== "production")) {
  1429. warn(
  1430. `value cannot be made ${isReadonly2 ? "readonly" : "reactive"}: ${String(
  1431. target
  1432. )}`
  1433. );
  1434. }
  1435. return target;
  1436. }
  1437. if (target["__v_raw"] && !(isReadonly2 && target["__v_isReactive"])) {
  1438. return target;
  1439. }
  1440. if (target["__v_skip"] || !Object.isExtensible(target)) {
  1441. return target;
  1442. }
  1443. const existingProxy = proxyMap.get(target);
  1444. if (existingProxy) {
  1445. return existingProxy;
  1446. }
  1447. const targetType = targetTypeMap(toRawType(target));
  1448. if (targetType === 0 /* INVALID */) {
  1449. return target;
  1450. }
  1451. const proxy = new Proxy(
  1452. target,
  1453. targetType === 2 /* COLLECTION */ ? collectionHandlers : baseHandlers
  1454. );
  1455. proxyMap.set(target, proxy);
  1456. return proxy;
  1457. }
  1458. // @__NO_SIDE_EFFECTS__
  1459. function isReactive(value) {
  1460. if (/* @__PURE__ */ isReadonly(value)) {
  1461. return /* @__PURE__ */ isReactive(value["__v_raw"]);
  1462. }
  1463. return !!(value && value["__v_isReactive"]);
  1464. }
  1465. // @__NO_SIDE_EFFECTS__
  1466. function isReadonly(value) {
  1467. return !!(value && value["__v_isReadonly"]);
  1468. }
  1469. // @__NO_SIDE_EFFECTS__
  1470. function isShallow(value) {
  1471. return !!(value && value["__v_isShallow"]);
  1472. }
  1473. // @__NO_SIDE_EFFECTS__
  1474. function isProxy(value) {
  1475. return value ? !!value["__v_raw"] : false;
  1476. }
  1477. // @__NO_SIDE_EFFECTS__
  1478. function toRaw(observed) {
  1479. const raw = observed && observed["__v_raw"];
  1480. return raw ? /* @__PURE__ */ toRaw(raw) : observed;
  1481. }
  1482. function markRaw(value) {
  1483. if (!hasOwn(value, "__v_skip") && Object.isExtensible(value)) {
  1484. def(value, "__v_skip", true);
  1485. }
  1486. return value;
  1487. }
  1488. const toReactive = (value) => isObject(value) ? /* @__PURE__ */ reactive(value) : value;
  1489. const toReadonly = (value) => isObject(value) ? /* @__PURE__ */ readonly(value) : value;
  1490. // @__NO_SIDE_EFFECTS__
  1491. function isRef(r) {
  1492. return r ? r["__v_isRef"] === true : false;
  1493. }
  1494. // @__NO_SIDE_EFFECTS__
  1495. function ref(value) {
  1496. return createRef(value, false);
  1497. }
  1498. // @__NO_SIDE_EFFECTS__
  1499. function shallowRef(value) {
  1500. return createRef(value, true);
  1501. }
  1502. function createRef(rawValue, shallow) {
  1503. if (/* @__PURE__ */ isRef(rawValue)) {
  1504. return rawValue;
  1505. }
  1506. return new RefImpl(rawValue, shallow);
  1507. }
  1508. class RefImpl {
  1509. constructor(value, isShallow2) {
  1510. this.dep = new Dep();
  1511. this["__v_isRef"] = true;
  1512. this["__v_isShallow"] = false;
  1513. this._rawValue = isShallow2 ? value : toRaw(value);
  1514. this._value = isShallow2 ? value : toReactive(value);
  1515. this["__v_isShallow"] = isShallow2;
  1516. }
  1517. get value() {
  1518. if (!!(process.env.NODE_ENV !== "production")) {
  1519. this.dep.track({
  1520. target: this,
  1521. type: "get",
  1522. key: "value"
  1523. });
  1524. } else {
  1525. this.dep.track();
  1526. }
  1527. return this._value;
  1528. }
  1529. set value(newValue) {
  1530. const oldValue = this._rawValue;
  1531. const useDirectValue = this["__v_isShallow"] || isShallow(newValue) || isReadonly(newValue);
  1532. newValue = useDirectValue ? newValue : toRaw(newValue);
  1533. if (hasChanged(newValue, oldValue)) {
  1534. this._rawValue = newValue;
  1535. this._value = useDirectValue ? newValue : toReactive(newValue);
  1536. if (!!(process.env.NODE_ENV !== "production")) {
  1537. this.dep.trigger({
  1538. target: this,
  1539. type: "set",
  1540. key: "value",
  1541. newValue,
  1542. oldValue
  1543. });
  1544. } else {
  1545. this.dep.trigger();
  1546. }
  1547. }
  1548. }
  1549. }
  1550. function triggerRef(ref2) {
  1551. if (ref2.dep) {
  1552. if (!!(process.env.NODE_ENV !== "production")) {
  1553. ref2.dep.trigger({
  1554. target: ref2,
  1555. type: "set",
  1556. key: "value",
  1557. newValue: ref2._value
  1558. });
  1559. } else {
  1560. ref2.dep.trigger();
  1561. }
  1562. }
  1563. }
  1564. function unref(ref2) {
  1565. return /* @__PURE__ */ isRef(ref2) ? ref2.value : ref2;
  1566. }
  1567. function toValue(source) {
  1568. return isFunction(source) ? source() : unref(source);
  1569. }
  1570. const shallowUnwrapHandlers = {
  1571. get: (target, key, receiver) => key === "__v_raw" ? target : unref(Reflect.get(target, key, receiver)),
  1572. set: (target, key, value, receiver) => {
  1573. const oldValue = target[key];
  1574. if (/* @__PURE__ */ isRef(oldValue) && !/* @__PURE__ */ isRef(value)) {
  1575. oldValue.value = value;
  1576. return true;
  1577. } else {
  1578. return Reflect.set(target, key, value, receiver);
  1579. }
  1580. }
  1581. };
  1582. function proxyRefs(objectWithRefs) {
  1583. return isReactive(objectWithRefs) ? objectWithRefs : new Proxy(objectWithRefs, shallowUnwrapHandlers);
  1584. }
  1585. class CustomRefImpl {
  1586. constructor(factory) {
  1587. this["__v_isRef"] = true;
  1588. this._value = void 0;
  1589. const dep = this.dep = new Dep();
  1590. const { get, set } = factory(dep.track.bind(dep), dep.trigger.bind(dep));
  1591. this._get = get;
  1592. this._set = set;
  1593. }
  1594. get value() {
  1595. return this._value = this._get();
  1596. }
  1597. set value(newVal) {
  1598. this._set(newVal);
  1599. }
  1600. }
  1601. function customRef(factory) {
  1602. return new CustomRefImpl(factory);
  1603. }
  1604. // @__NO_SIDE_EFFECTS__
  1605. function toRefs(object) {
  1606. if (!!(process.env.NODE_ENV !== "production") && !isProxy(object)) {
  1607. warn(`toRefs() expects a reactive object but received a plain one.`);
  1608. }
  1609. const ret = isArray(object) ? new Array(object.length) : {};
  1610. for (const key in object) {
  1611. ret[key] = propertyToRef(object, key);
  1612. }
  1613. return ret;
  1614. }
  1615. class ObjectRefImpl {
  1616. constructor(_object, key, _defaultValue) {
  1617. this._object = _object;
  1618. this._defaultValue = _defaultValue;
  1619. this["__v_isRef"] = true;
  1620. this._value = void 0;
  1621. this._key = isSymbol(key) ? key : String(key);
  1622. this._raw = toRaw(_object);
  1623. let shallow = true;
  1624. let obj = _object;
  1625. if (!isArray(_object) || isSymbol(this._key) || !isIntegerKey(this._key)) {
  1626. do {
  1627. shallow = !isProxy(obj) || isShallow(obj);
  1628. } while (shallow && (obj = obj["__v_raw"]));
  1629. }
  1630. this._shallow = shallow;
  1631. }
  1632. get value() {
  1633. let val = this._object[this._key];
  1634. if (this._shallow) {
  1635. val = unref(val);
  1636. }
  1637. return this._value = val === void 0 ? this._defaultValue : val;
  1638. }
  1639. set value(newVal) {
  1640. if (this._shallow && /* @__PURE__ */ isRef(this._raw[this._key])) {
  1641. const nestedRef = this._object[this._key];
  1642. if (/* @__PURE__ */ isRef(nestedRef)) {
  1643. nestedRef.value = newVal;
  1644. return;
  1645. }
  1646. }
  1647. this._object[this._key] = newVal;
  1648. }
  1649. get dep() {
  1650. return getDepFromReactive(this._raw, this._key);
  1651. }
  1652. }
  1653. class GetterRefImpl {
  1654. constructor(_getter) {
  1655. this._getter = _getter;
  1656. this["__v_isRef"] = true;
  1657. this["__v_isReadonly"] = true;
  1658. this._value = void 0;
  1659. }
  1660. get value() {
  1661. return this._value = this._getter();
  1662. }
  1663. }
  1664. // @__NO_SIDE_EFFECTS__
  1665. function toRef(source, key, defaultValue) {
  1666. if (/* @__PURE__ */ isRef(source)) {
  1667. return source;
  1668. } else if (isFunction(source)) {
  1669. return new GetterRefImpl(source);
  1670. } else if (isObject(source) && arguments.length > 1) {
  1671. return propertyToRef(source, key, defaultValue);
  1672. } else {
  1673. return /* @__PURE__ */ ref(source);
  1674. }
  1675. }
  1676. function propertyToRef(source, key, defaultValue) {
  1677. return new ObjectRefImpl(source, key, defaultValue);
  1678. }
  1679. class ComputedRefImpl {
  1680. constructor(fn, setter, isSSR) {
  1681. this.fn = fn;
  1682. this.setter = setter;
  1683. /**
  1684. * @internal
  1685. */
  1686. this._value = void 0;
  1687. /**
  1688. * @internal
  1689. */
  1690. this.dep = new Dep(this);
  1691. /**
  1692. * @internal
  1693. */
  1694. this.__v_isRef = true;
  1695. // TODO isolatedDeclarations "__v_isReadonly"
  1696. // A computed is also a subscriber that tracks other deps
  1697. /**
  1698. * @internal
  1699. */
  1700. this.deps = void 0;
  1701. /**
  1702. * @internal
  1703. */
  1704. this.depsTail = void 0;
  1705. /**
  1706. * @internal
  1707. */
  1708. this.flags = 16;
  1709. /**
  1710. * @internal
  1711. */
  1712. this.globalVersion = globalVersion - 1;
  1713. /**
  1714. * @internal
  1715. */
  1716. this.next = void 0;
  1717. // for backwards compat
  1718. this.effect = this;
  1719. this["__v_isReadonly"] = !setter;
  1720. this.isSSR = isSSR;
  1721. }
  1722. /**
  1723. * @internal
  1724. */
  1725. notify() {
  1726. this.flags |= 16;
  1727. if (!(this.flags & 8) && // avoid infinite self recursion
  1728. activeSub !== this) {
  1729. batch(this, true);
  1730. return true;
  1731. } else if (!!(process.env.NODE_ENV !== "production")) ;
  1732. }
  1733. get value() {
  1734. const link = !!(process.env.NODE_ENV !== "production") ? this.dep.track({
  1735. target: this,
  1736. type: "get",
  1737. key: "value"
  1738. }) : this.dep.track();
  1739. refreshComputed(this);
  1740. if (link) {
  1741. link.version = this.dep.version;
  1742. }
  1743. return this._value;
  1744. }
  1745. set value(newValue) {
  1746. if (this.setter) {
  1747. this.setter(newValue);
  1748. } else if (!!(process.env.NODE_ENV !== "production")) {
  1749. warn("Write operation failed: computed value is readonly");
  1750. }
  1751. }
  1752. }
  1753. // @__NO_SIDE_EFFECTS__
  1754. function computed(getterOrOptions, debugOptions, isSSR = false) {
  1755. let getter;
  1756. let setter;
  1757. if (isFunction(getterOrOptions)) {
  1758. getter = getterOrOptions;
  1759. } else {
  1760. getter = getterOrOptions.get;
  1761. setter = getterOrOptions.set;
  1762. }
  1763. const cRef = new ComputedRefImpl(getter, setter, isSSR);
  1764. if (!!(process.env.NODE_ENV !== "production") && debugOptions && !isSSR) {
  1765. cRef.onTrack = debugOptions.onTrack;
  1766. cRef.onTrigger = debugOptions.onTrigger;
  1767. }
  1768. return cRef;
  1769. }
  1770. const TrackOpTypes = {
  1771. "GET": "get",
  1772. "HAS": "has",
  1773. "ITERATE": "iterate"
  1774. };
  1775. const TriggerOpTypes = {
  1776. "SET": "set",
  1777. "ADD": "add",
  1778. "DELETE": "delete",
  1779. "CLEAR": "clear"
  1780. };
  1781. const ReactiveFlags = {
  1782. "SKIP": "__v_skip",
  1783. "IS_REACTIVE": "__v_isReactive",
  1784. "IS_READONLY": "__v_isReadonly",
  1785. "IS_SHALLOW": "__v_isShallow",
  1786. "RAW": "__v_raw",
  1787. "IS_REF": "__v_isRef"
  1788. };
  1789. const WatchErrorCodes = {
  1790. "WATCH_GETTER": 2,
  1791. "2": "WATCH_GETTER",
  1792. "WATCH_CALLBACK": 3,
  1793. "3": "WATCH_CALLBACK",
  1794. "WATCH_CLEANUP": 4,
  1795. "4": "WATCH_CLEANUP"
  1796. };
  1797. const INITIAL_WATCHER_VALUE = {};
  1798. const cleanupMap = /* @__PURE__ */ new WeakMap();
  1799. let activeWatcher = void 0;
  1800. function getCurrentWatcher() {
  1801. return activeWatcher;
  1802. }
  1803. function onWatcherCleanup(cleanupFn, failSilently = false, owner = activeWatcher) {
  1804. if (owner) {
  1805. let cleanups = cleanupMap.get(owner);
  1806. if (!cleanups) cleanupMap.set(owner, cleanups = []);
  1807. cleanups.push(cleanupFn);
  1808. } else if (!!(process.env.NODE_ENV !== "production") && !failSilently) {
  1809. warn(
  1810. `onWatcherCleanup() was called when there was no active watcher to associate with.`
  1811. );
  1812. }
  1813. }
  1814. function watch(source, cb, options = EMPTY_OBJ) {
  1815. const { immediate, deep, once, scheduler, augmentJob, call } = options;
  1816. const warnInvalidSource = (s) => {
  1817. (options.onWarn || warn)(
  1818. `Invalid watch source: `,
  1819. s,
  1820. `A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`
  1821. );
  1822. };
  1823. const reactiveGetter = (source2) => {
  1824. if (deep) return source2;
  1825. if (isShallow(source2) || deep === false || deep === 0)
  1826. return traverse(source2, 1);
  1827. return traverse(source2);
  1828. };
  1829. let effect;
  1830. let getter;
  1831. let cleanup;
  1832. let boundCleanup;
  1833. let forceTrigger = false;
  1834. let isMultiSource = false;
  1835. if (isRef(source)) {
  1836. getter = () => source.value;
  1837. forceTrigger = isShallow(source);
  1838. } else if (isReactive(source)) {
  1839. getter = () => reactiveGetter(source);
  1840. forceTrigger = true;
  1841. } else if (isArray(source)) {
  1842. isMultiSource = true;
  1843. forceTrigger = source.some((s) => isReactive(s) || isShallow(s));
  1844. getter = () => source.map((s) => {
  1845. if (isRef(s)) {
  1846. return s.value;
  1847. } else if (isReactive(s)) {
  1848. return reactiveGetter(s);
  1849. } else if (isFunction(s)) {
  1850. return call ? call(s, 2) : s();
  1851. } else {
  1852. !!(process.env.NODE_ENV !== "production") && warnInvalidSource(s);
  1853. }
  1854. });
  1855. } else if (isFunction(source)) {
  1856. if (cb) {
  1857. getter = call ? () => call(source, 2) : source;
  1858. } else {
  1859. getter = () => {
  1860. if (cleanup) {
  1861. pauseTracking();
  1862. try {
  1863. cleanup();
  1864. } finally {
  1865. resetTracking();
  1866. }
  1867. }
  1868. const currentEffect = activeWatcher;
  1869. activeWatcher = effect;
  1870. try {
  1871. return call ? call(source, 3, [boundCleanup]) : source(boundCleanup);
  1872. } finally {
  1873. activeWatcher = currentEffect;
  1874. }
  1875. };
  1876. }
  1877. } else {
  1878. getter = NOOP;
  1879. !!(process.env.NODE_ENV !== "production") && warnInvalidSource(source);
  1880. }
  1881. if (cb && deep) {
  1882. const baseGetter = getter;
  1883. const depth = deep === true ? Infinity : deep;
  1884. getter = () => traverse(baseGetter(), depth);
  1885. }
  1886. const scope = getCurrentScope();
  1887. const watchHandle = () => {
  1888. effect.stop();
  1889. if (scope && scope.active) {
  1890. remove(scope.effects, effect);
  1891. }
  1892. };
  1893. if (once && cb) {
  1894. const _cb = cb;
  1895. cb = (...args) => {
  1896. const res = _cb(...args);
  1897. watchHandle();
  1898. return res;
  1899. };
  1900. }
  1901. let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
  1902. const job = (immediateFirstRun) => {
  1903. if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) {
  1904. return;
  1905. }
  1906. if (cb) {
  1907. const newValue = effect.run();
  1908. if (immediateFirstRun || deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue))) {
  1909. if (cleanup) {
  1910. cleanup();
  1911. }
  1912. const currentWatcher = activeWatcher;
  1913. activeWatcher = effect;
  1914. try {
  1915. const args = [
  1916. newValue,
  1917. // pass undefined as the old value when it's changed for the first time
  1918. oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
  1919. boundCleanup
  1920. ];
  1921. oldValue = newValue;
  1922. call ? call(cb, 3, args) : (
  1923. // @ts-expect-error
  1924. cb(...args)
  1925. );
  1926. } finally {
  1927. activeWatcher = currentWatcher;
  1928. }
  1929. }
  1930. } else {
  1931. effect.run();
  1932. }
  1933. };
  1934. if (augmentJob) {
  1935. augmentJob(job);
  1936. }
  1937. effect = new ReactiveEffect(getter);
  1938. effect.scheduler = scheduler ? () => scheduler(job, false) : job;
  1939. boundCleanup = (fn) => onWatcherCleanup(fn, false, effect);
  1940. cleanup = effect.onStop = () => {
  1941. const cleanups = cleanupMap.get(effect);
  1942. if (cleanups) {
  1943. if (call) {
  1944. call(cleanups, 4);
  1945. } else {
  1946. for (const cleanup2 of cleanups) cleanup2();
  1947. }
  1948. cleanupMap.delete(effect);
  1949. }
  1950. };
  1951. if (!!(process.env.NODE_ENV !== "production")) {
  1952. effect.onTrack = options.onTrack;
  1953. effect.onTrigger = options.onTrigger;
  1954. }
  1955. if (cb) {
  1956. if (immediate) {
  1957. job(true);
  1958. } else {
  1959. oldValue = effect.run();
  1960. }
  1961. } else if (scheduler) {
  1962. scheduler(job.bind(null, true), true);
  1963. } else {
  1964. effect.run();
  1965. }
  1966. watchHandle.pause = effect.pause.bind(effect);
  1967. watchHandle.resume = effect.resume.bind(effect);
  1968. watchHandle.stop = watchHandle;
  1969. return watchHandle;
  1970. }
  1971. function traverse(value, depth = Infinity, seen) {
  1972. if (depth <= 0 || !isObject(value) || value["__v_skip"]) {
  1973. return value;
  1974. }
  1975. seen = seen || /* @__PURE__ */ new Map();
  1976. if ((seen.get(value) || 0) >= depth) {
  1977. return value;
  1978. }
  1979. seen.set(value, depth);
  1980. depth--;
  1981. if (isRef(value)) {
  1982. traverse(value.value, depth, seen);
  1983. } else if (isArray(value)) {
  1984. for (let i = 0; i < value.length; i++) {
  1985. traverse(value[i], depth, seen);
  1986. }
  1987. } else if (isSet(value) || isMap(value)) {
  1988. value.forEach((v) => {
  1989. traverse(v, depth, seen);
  1990. });
  1991. } else if (isPlainObject(value)) {
  1992. for (const key in value) {
  1993. traverse(value[key], depth, seen);
  1994. }
  1995. for (const key of Object.getOwnPropertySymbols(value)) {
  1996. if (Object.prototype.propertyIsEnumerable.call(value, key)) {
  1997. traverse(value[key], depth, seen);
  1998. }
  1999. }
  2000. }
  2001. return value;
  2002. }
  2003. export { ARRAY_ITERATE_KEY, EffectFlags, EffectScope, ITERATE_KEY, MAP_KEY_ITERATE_KEY, ReactiveEffect, ReactiveFlags, TrackOpTypes, TriggerOpTypes, WatchErrorCodes, computed, customRef, effect, effectScope, enableTracking, getCurrentScope, getCurrentWatcher, isProxy, isReactive, isReadonly, isRef, isShallow, markRaw, onEffectCleanup, onScopeDispose, onWatcherCleanup, pauseTracking, proxyRefs, reactive, reactiveReadArray, readonly, ref, resetTracking, shallowReactive, shallowReadArray, shallowReadonly, shallowRef, stop, toRaw, toReactive, toReadonly, toRef, toRefs, toValue, track, traverse, trigger, triggerRef, unref, watch };