reactivity.cjs.js 52 KB

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