reactivity.cjs.js 53 KB

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