reactivity.global.js 58 KB

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