reactivity.esm-bundler.js 53 KB

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