reactivity.cjs.js 53 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061
  1. /**
  2. * @vue/reactivity v3.5.43
  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. if (isShallow(array)) return raw;
  773. if (!isReadonly(array)) return raw.map(toReactive);
  774. return isReactive(array) ? raw.map((item) => toReadonly(toReactive(item))) : raw.map(toReadonly);
  775. }
  776. function shallowReadArray(arr) {
  777. track(arr = toRaw(arr), "iterate", ARRAY_ITERATE_KEY);
  778. return arr;
  779. }
  780. function toWrapped(target, item) {
  781. if (isReadonly(target)) {
  782. return isReactive(target) ? toReadonly(toReactive(item)) : toReadonly(item);
  783. }
  784. return toReactive(item);
  785. }
  786. const arrayInstrumentations = {
  787. __proto__: null,
  788. [Symbol.iterator]() {
  789. return iterator(this, Symbol.iterator, (item) => toWrapped(this, item));
  790. },
  791. concat(...args) {
  792. return reactiveReadArray(this).concat(
  793. ...args.map((x) => shared.isArray(x) ? reactiveReadArray(x) : x)
  794. );
  795. },
  796. entries() {
  797. return iterator(this, "entries", (value) => {
  798. value[1] = toWrapped(this, value[1]);
  799. return value;
  800. });
  801. },
  802. every(fn, thisArg) {
  803. return apply(this, "every", fn, thisArg, void 0, arguments);
  804. },
  805. filter(fn, thisArg) {
  806. return apply(
  807. this,
  808. "filter",
  809. fn,
  810. thisArg,
  811. (v) => v.map((item) => toWrapped(this, item)),
  812. arguments
  813. );
  814. },
  815. find(fn, thisArg) {
  816. return apply(
  817. this,
  818. "find",
  819. fn,
  820. thisArg,
  821. (item) => toWrapped(this, item),
  822. arguments
  823. );
  824. },
  825. findIndex(fn, thisArg) {
  826. return apply(this, "findIndex", fn, thisArg, void 0, arguments);
  827. },
  828. findLast(fn, thisArg) {
  829. return apply(
  830. this,
  831. "findLast",
  832. fn,
  833. thisArg,
  834. (item) => toWrapped(this, item),
  835. arguments
  836. );
  837. },
  838. findLastIndex(fn, thisArg) {
  839. return apply(this, "findLastIndex", fn, thisArg, void 0, arguments);
  840. },
  841. // flat, flatMap could benefit from ARRAY_ITERATE but are not straight-forward to implement
  842. forEach(fn, thisArg) {
  843. return apply(this, "forEach", fn, thisArg, void 0, arguments);
  844. },
  845. includes(...args) {
  846. return searchProxy(this, "includes", args);
  847. },
  848. indexOf(...args) {
  849. return searchProxy(this, "indexOf", args);
  850. },
  851. join(separator) {
  852. return reactiveReadArray(this).join(separator);
  853. },
  854. // keys() iterator only reads `length`, no optimization required
  855. lastIndexOf(...args) {
  856. return searchProxy(this, "lastIndexOf", args);
  857. },
  858. map(fn, thisArg) {
  859. return apply(this, "map", fn, thisArg, void 0, arguments);
  860. },
  861. pop() {
  862. return noTracking(this, "pop");
  863. },
  864. push(...args) {
  865. return noTracking(this, "push", args);
  866. },
  867. reduce(fn, ...args) {
  868. return reduce(this, "reduce", fn, args);
  869. },
  870. reduceRight(fn, ...args) {
  871. return reduce(this, "reduceRight", fn, args);
  872. },
  873. shift() {
  874. return noTracking(this, "shift");
  875. },
  876. // slice could use ARRAY_ITERATE but also seems to beg for range tracking
  877. some(fn, thisArg) {
  878. return apply(this, "some", fn, thisArg, void 0, arguments);
  879. },
  880. splice(...args) {
  881. return noTracking(this, "splice", args);
  882. },
  883. toReversed() {
  884. return reactiveReadArray(this).toReversed();
  885. },
  886. toSorted(comparer) {
  887. return reactiveReadArray(this).toSorted(comparer);
  888. },
  889. toSpliced(...args) {
  890. return reactiveReadArray(this).toSpliced(...args);
  891. },
  892. unshift(...args) {
  893. return noTracking(this, "unshift", args);
  894. },
  895. values() {
  896. return iterator(this, "values", (item) => toWrapped(this, item));
  897. }
  898. };
  899. function iterator(self, method, wrapValue) {
  900. const arr = shallowReadArray(self);
  901. const iter = arr[method]();
  902. if (arr !== self && !isShallow(self)) {
  903. iter._next = iter.next;
  904. iter.next = () => {
  905. const result = iter._next();
  906. if (!result.done) {
  907. result.value = wrapValue(result.value);
  908. }
  909. return result;
  910. };
  911. }
  912. return iter;
  913. }
  914. const arrayProto = Array.prototype;
  915. function apply(self, method, fn, thisArg, wrappedRetFn, args) {
  916. const arr = shallowReadArray(self);
  917. const needsWrap = arr !== self && !isShallow(self);
  918. const methodFn = arr[method];
  919. if (methodFn !== arrayProto[method]) {
  920. const result2 = methodFn.apply(self, args);
  921. return needsWrap ? toReactive(result2) : result2;
  922. }
  923. let wrappedFn = fn;
  924. if (arr !== self) {
  925. if (needsWrap) {
  926. wrappedFn = function(item, index) {
  927. return fn.call(this, toWrapped(self, item), index, self);
  928. };
  929. } else if (fn.length > 2) {
  930. wrappedFn = function(item, index) {
  931. return fn.call(this, item, index, self);
  932. };
  933. }
  934. }
  935. const result = methodFn.call(arr, wrappedFn, thisArg);
  936. return needsWrap && wrappedRetFn ? wrappedRetFn(result) : result;
  937. }
  938. function reduce(self, method, fn, args) {
  939. const arr = shallowReadArray(self);
  940. const needsWrap = arr !== self && !isShallow(self);
  941. let wrappedFn = fn;
  942. let wrapInitialAccumulator = false;
  943. if (arr !== self) {
  944. if (needsWrap) {
  945. wrapInitialAccumulator = args.length === 0;
  946. wrappedFn = function(acc, item, index) {
  947. if (wrapInitialAccumulator) {
  948. wrapInitialAccumulator = false;
  949. acc = toWrapped(self, acc);
  950. }
  951. return fn.call(this, acc, toWrapped(self, item), index, self);
  952. };
  953. } else if (fn.length > 3) {
  954. wrappedFn = function(acc, item, index) {
  955. return fn.call(this, acc, item, index, self);
  956. };
  957. }
  958. }
  959. const result = arr[method](wrappedFn, ...args);
  960. return wrapInitialAccumulator ? toWrapped(self, result) : result;
  961. }
  962. function searchProxy(self, method, args) {
  963. const arr = toRaw(self);
  964. track(arr, "iterate", ARRAY_ITERATE_KEY);
  965. const res = arr[method](...args);
  966. if ((res === -1 || res === false) && isProxy(args[0])) {
  967. args[0] = toRaw(args[0]);
  968. return arr[method](...args);
  969. }
  970. return res;
  971. }
  972. function noTracking(self, method, args = []) {
  973. pauseTracking();
  974. startBatch();
  975. const res = toRaw(self)[method].apply(self, args);
  976. endBatch();
  977. resetTracking();
  978. return res;
  979. }
  980. const isNonTrackableKeys = /* @__PURE__ */ shared.makeMap(`__proto__,__v_isRef,__isVue`);
  981. const builtInSymbols = new Set(
  982. /* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(shared.isSymbol)
  983. );
  984. function hasOwnProperty(key) {
  985. if (!shared.isSymbol(key)) key = String(key);
  986. const obj = toRaw(this);
  987. track(obj, "has", key);
  988. return obj.hasOwnProperty(key);
  989. }
  990. class BaseReactiveHandler {
  991. constructor(_isReadonly = false, _isShallow = false) {
  992. this._isReadonly = _isReadonly;
  993. this._isShallow = _isShallow;
  994. }
  995. get(target, key, receiver) {
  996. if (key === "__v_skip") return target["__v_skip"];
  997. const isReadonly2 = this._isReadonly, isShallow2 = this._isShallow;
  998. if (key === "__v_isReactive") {
  999. return !isReadonly2;
  1000. } else if (key === "__v_isReadonly") {
  1001. return isReadonly2;
  1002. } else if (key === "__v_isShallow") {
  1003. return isShallow2;
  1004. } else if (key === "__v_raw") {
  1005. if (receiver === (isReadonly2 ? isShallow2 ? shallowReadonlyMap : readonlyMap : isShallow2 ? shallowReactiveMap : reactiveMap).get(target) || // receiver is not the reactive proxy, but has the same prototype
  1006. // this means the receiver is a user proxy of the reactive proxy
  1007. Object.getPrototypeOf(target) === Object.getPrototypeOf(receiver)) {
  1008. return target;
  1009. }
  1010. return;
  1011. }
  1012. const targetIsArray = shared.isArray(target);
  1013. if (!isReadonly2) {
  1014. let fn;
  1015. if (targetIsArray && (fn = arrayInstrumentations[key])) {
  1016. return fn;
  1017. }
  1018. if (key === "hasOwnProperty") {
  1019. return hasOwnProperty;
  1020. }
  1021. }
  1022. const res = Reflect.get(
  1023. target,
  1024. key,
  1025. // if this is a proxy wrapping a ref, return methods using the raw ref
  1026. // as receiver so that we don't have to call `toRaw` on the ref in all
  1027. // its class methods
  1028. isRef(target) ? target : receiver
  1029. );
  1030. if (shared.isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
  1031. return res;
  1032. }
  1033. if (!isReadonly2) {
  1034. track(target, "get", key);
  1035. }
  1036. if (isShallow2) {
  1037. return res;
  1038. }
  1039. if (isRef(res)) {
  1040. const value = targetIsArray && shared.isIntegerKey(key) ? res : res.value;
  1041. return isReadonly2 && shared.isObject(value) ? readonly(value) : value;
  1042. }
  1043. if (shared.isObject(res)) {
  1044. return isReadonly2 ? readonly(res) : reactive(res);
  1045. }
  1046. return res;
  1047. }
  1048. }
  1049. class MutableReactiveHandler extends BaseReactiveHandler {
  1050. constructor(isShallow2 = false) {
  1051. super(false, isShallow2);
  1052. }
  1053. set(target, key, value, receiver) {
  1054. let oldValue = target[key];
  1055. const isArrayWithIntegerKey = shared.isArray(target) && shared.isIntegerKey(key);
  1056. if (!this._isShallow) {
  1057. const isOldValueReadonly = isReadonly(oldValue);
  1058. if (!isShallow(value) && !isReadonly(value)) {
  1059. oldValue = toRaw(oldValue);
  1060. value = toRaw(value);
  1061. }
  1062. if (!isArrayWithIntegerKey && isRef(oldValue) && !isRef(value)) {
  1063. if (isOldValueReadonly) {
  1064. {
  1065. warn(
  1066. `Set operation on key "${String(key)}" failed: target is readonly.`,
  1067. target[key]
  1068. );
  1069. }
  1070. return true;
  1071. } else {
  1072. oldValue.value = value;
  1073. return true;
  1074. }
  1075. }
  1076. }
  1077. const hadKey = isArrayWithIntegerKey ? Number(key) < target.length : shared.hasOwn(target, key);
  1078. const result = Reflect.set(
  1079. target,
  1080. key,
  1081. value,
  1082. isRef(target) ? target : receiver
  1083. );
  1084. if (target === toRaw(receiver) && result) {
  1085. if (!hadKey) {
  1086. trigger(target, "add", key, value);
  1087. } else if (shared.hasChanged(value, oldValue)) {
  1088. trigger(target, "set", key, value, oldValue);
  1089. }
  1090. }
  1091. return result;
  1092. }
  1093. deleteProperty(target, key) {
  1094. const hadKey = shared.hasOwn(target, key);
  1095. const oldValue = target[key];
  1096. const result = Reflect.deleteProperty(target, key);
  1097. if (result && hadKey) {
  1098. trigger(target, "delete", key, void 0, oldValue);
  1099. }
  1100. return result;
  1101. }
  1102. has(target, key) {
  1103. const result = Reflect.has(target, key);
  1104. if (!shared.isSymbol(key) || !builtInSymbols.has(key)) {
  1105. track(target, "has", key);
  1106. }
  1107. return result;
  1108. }
  1109. ownKeys(target) {
  1110. track(
  1111. target,
  1112. "iterate",
  1113. shared.isArray(target) ? "length" : ITERATE_KEY
  1114. );
  1115. return Reflect.ownKeys(target);
  1116. }
  1117. }
  1118. class ReadonlyReactiveHandler extends BaseReactiveHandler {
  1119. constructor(isShallow2 = false) {
  1120. super(true, isShallow2);
  1121. }
  1122. set(target, key) {
  1123. {
  1124. warn(
  1125. `Set operation on key "${String(key)}" failed: target is readonly.`,
  1126. target
  1127. );
  1128. }
  1129. return true;
  1130. }
  1131. deleteProperty(target, key) {
  1132. {
  1133. warn(
  1134. `Delete operation on key "${String(key)}" failed: target is readonly.`,
  1135. target
  1136. );
  1137. }
  1138. return true;
  1139. }
  1140. }
  1141. const mutableHandlers = /* @__PURE__ */ new MutableReactiveHandler();
  1142. const readonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler();
  1143. const shallowReactiveHandlers = /* @__PURE__ */ new MutableReactiveHandler(true);
  1144. const shallowReadonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler(true);
  1145. const toShallow = (value) => value;
  1146. const getProto = (v) => Reflect.getPrototypeOf(v);
  1147. function createIterableMethod(method, isReadonly2, isShallow2) {
  1148. return function(...args) {
  1149. const target = this["__v_raw"];
  1150. const rawTarget = toRaw(target);
  1151. const targetIsMap = shared.isMap(rawTarget);
  1152. const isPair = method === "entries" || method === Symbol.iterator && targetIsMap;
  1153. const isKeyOnly = method === "keys" && targetIsMap;
  1154. const innerIterator = target[method](...args);
  1155. const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
  1156. !isReadonly2 && track(
  1157. rawTarget,
  1158. "iterate",
  1159. isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY
  1160. );
  1161. return shared.extend(
  1162. // inheriting all iterator properties
  1163. Object.create(innerIterator),
  1164. {
  1165. // iterator protocol
  1166. next() {
  1167. const { value, done } = innerIterator.next();
  1168. return done ? { value, done } : {
  1169. value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
  1170. done
  1171. };
  1172. }
  1173. }
  1174. );
  1175. };
  1176. }
  1177. function createReadonlyMethod(type) {
  1178. return function(...args) {
  1179. {
  1180. const key = args[0] ? `on key "${args[0]}" ` : ``;
  1181. warn(
  1182. `${shared.capitalize(type)} operation ${key}failed: target is readonly.`,
  1183. toRaw(this)
  1184. );
  1185. }
  1186. return type === "delete" ? false : type === "clear" ? void 0 : this;
  1187. };
  1188. }
  1189. function createInstrumentations(readonly, shallow) {
  1190. const instrumentations = {
  1191. get(key) {
  1192. const target = this["__v_raw"];
  1193. const rawTarget = toRaw(target);
  1194. const rawKey = toRaw(key);
  1195. if (!readonly) {
  1196. if (shared.hasChanged(key, rawKey)) {
  1197. track(rawTarget, "get", key);
  1198. }
  1199. track(rawTarget, "get", rawKey);
  1200. }
  1201. const { has } = getProto(rawTarget);
  1202. const wrap = shallow ? toShallow : readonly ? toReadonly : toReactive;
  1203. if (has.call(rawTarget, key)) {
  1204. return wrap(target.get(key));
  1205. } else if (has.call(rawTarget, rawKey)) {
  1206. return wrap(target.get(rawKey));
  1207. } else if (target !== rawTarget) {
  1208. target.get(key);
  1209. }
  1210. },
  1211. get size() {
  1212. const target = this["__v_raw"];
  1213. !readonly && track(toRaw(target), "iterate", ITERATE_KEY);
  1214. return target.size;
  1215. },
  1216. has(key) {
  1217. const target = this["__v_raw"];
  1218. const rawTarget = toRaw(target);
  1219. const rawKey = toRaw(key);
  1220. if (!readonly) {
  1221. if (shared.hasChanged(key, rawKey)) {
  1222. track(rawTarget, "has", key);
  1223. }
  1224. track(rawTarget, "has", rawKey);
  1225. }
  1226. return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey);
  1227. },
  1228. forEach(callback, thisArg) {
  1229. const observed = this;
  1230. const target = observed["__v_raw"];
  1231. const rawTarget = toRaw(target);
  1232. const wrap = shallow ? toShallow : readonly ? toReadonly : toReactive;
  1233. !readonly && track(rawTarget, "iterate", ITERATE_KEY);
  1234. return target.forEach((value, key) => {
  1235. return callback.call(thisArg, wrap(value), wrap(key), observed);
  1236. });
  1237. }
  1238. };
  1239. shared.extend(
  1240. instrumentations,
  1241. readonly ? {
  1242. add: createReadonlyMethod("add"),
  1243. set: createReadonlyMethod("set"),
  1244. delete: createReadonlyMethod("delete"),
  1245. clear: createReadonlyMethod("clear")
  1246. } : {
  1247. add(value) {
  1248. const target = toRaw(this);
  1249. const proto = getProto(target);
  1250. const rawValue = toRaw(value);
  1251. const valueToAdd = !shallow && !isShallow(value) && !isReadonly(value) ? rawValue : value;
  1252. const hadKey = proto.has.call(target, valueToAdd) || shared.hasChanged(value, valueToAdd) && proto.has.call(target, value) || shared.hasChanged(rawValue, valueToAdd) && proto.has.call(target, rawValue);
  1253. if (!hadKey) {
  1254. target.add(valueToAdd);
  1255. trigger(target, "add", valueToAdd, valueToAdd);
  1256. }
  1257. return this;
  1258. },
  1259. set(key, value) {
  1260. if (!shallow && !isShallow(value) && !isReadonly(value)) {
  1261. value = toRaw(value);
  1262. }
  1263. const target = toRaw(this);
  1264. const { has, get } = getProto(target);
  1265. let hadKey = has.call(target, key);
  1266. if (!hadKey) {
  1267. key = toRaw(key);
  1268. hadKey = has.call(target, key);
  1269. } else {
  1270. checkIdentityKeys(target, has, key);
  1271. }
  1272. const oldValue = get.call(target, key);
  1273. target.set(key, value);
  1274. if (!hadKey) {
  1275. trigger(target, "add", key, value);
  1276. } else if (shared.hasChanged(value, oldValue)) {
  1277. trigger(target, "set", key, value, oldValue);
  1278. }
  1279. return this;
  1280. },
  1281. delete(key) {
  1282. const target = toRaw(this);
  1283. const { has, get } = getProto(target);
  1284. let hadKey = has.call(target, key);
  1285. if (!hadKey) {
  1286. key = toRaw(key);
  1287. hadKey = has.call(target, key);
  1288. } else {
  1289. checkIdentityKeys(target, has, key);
  1290. }
  1291. const oldValue = get ? get.call(target, key) : void 0;
  1292. const result = target.delete(key);
  1293. if (hadKey) {
  1294. trigger(target, "delete", key, void 0, oldValue);
  1295. }
  1296. return result;
  1297. },
  1298. clear() {
  1299. const target = toRaw(this);
  1300. const hadItems = target.size !== 0;
  1301. const oldTarget = shared.isMap(target) ? new Map(target) : new Set(target) ;
  1302. const result = target.clear();
  1303. if (hadItems) {
  1304. trigger(
  1305. target,
  1306. "clear",
  1307. void 0,
  1308. void 0,
  1309. oldTarget
  1310. );
  1311. }
  1312. return result;
  1313. }
  1314. }
  1315. );
  1316. const iteratorMethods = [
  1317. "keys",
  1318. "values",
  1319. "entries",
  1320. Symbol.iterator
  1321. ];
  1322. iteratorMethods.forEach((method) => {
  1323. instrumentations[method] = createIterableMethod(method, readonly, shallow);
  1324. });
  1325. return instrumentations;
  1326. }
  1327. function createInstrumentationGetter(isReadonly2, shallow) {
  1328. const instrumentations = createInstrumentations(isReadonly2, shallow);
  1329. return (target, key, receiver) => {
  1330. if (key === "__v_isReactive") {
  1331. return !isReadonly2;
  1332. } else if (key === "__v_isReadonly") {
  1333. return isReadonly2;
  1334. } else if (key === "__v_raw") {
  1335. return target;
  1336. }
  1337. return Reflect.get(
  1338. shared.hasOwn(instrumentations, key) && key in target ? instrumentations : target,
  1339. key,
  1340. receiver
  1341. );
  1342. };
  1343. }
  1344. const mutableCollectionHandlers = {
  1345. get: /* @__PURE__ */ createInstrumentationGetter(false, false)
  1346. };
  1347. const shallowCollectionHandlers = {
  1348. get: /* @__PURE__ */ createInstrumentationGetter(false, true)
  1349. };
  1350. const readonlyCollectionHandlers = {
  1351. get: /* @__PURE__ */ createInstrumentationGetter(true, false)
  1352. };
  1353. const shallowReadonlyCollectionHandlers = {
  1354. get: /* @__PURE__ */ createInstrumentationGetter(true, true)
  1355. };
  1356. function checkIdentityKeys(target, has, key) {
  1357. const rawKey = toRaw(key);
  1358. if (rawKey !== key && has.call(target, rawKey)) {
  1359. const type = shared.toRawType(target);
  1360. warn(
  1361. `Reactive ${type} contains both the raw and reactive versions of the same object${type === `Map` ? ` as keys` : ``}, which can lead to inconsistencies. Avoid differentiating between the raw and reactive versions of an object and only use the reactive version if possible.`
  1362. );
  1363. }
  1364. }
  1365. const reactiveMap = /* @__PURE__ */ new WeakMap();
  1366. const shallowReactiveMap = /* @__PURE__ */ new WeakMap();
  1367. const readonlyMap = /* @__PURE__ */ new WeakMap();
  1368. const shallowReadonlyMap = /* @__PURE__ */ new WeakMap();
  1369. function targetTypeMap(rawType) {
  1370. switch (rawType) {
  1371. case "Object":
  1372. case "Array":
  1373. return 1 /* COMMON */;
  1374. case "Map":
  1375. case "Set":
  1376. case "WeakMap":
  1377. case "WeakSet":
  1378. return 2 /* COLLECTION */;
  1379. default:
  1380. return 0 /* INVALID */;
  1381. }
  1382. }
  1383. // @__NO_SIDE_EFFECTS__
  1384. function reactive(target) {
  1385. if (/* @__PURE__ */ isReadonly(target)) {
  1386. return target;
  1387. }
  1388. return createReactiveObject(
  1389. target,
  1390. false,
  1391. mutableHandlers,
  1392. mutableCollectionHandlers,
  1393. reactiveMap
  1394. );
  1395. }
  1396. // @__NO_SIDE_EFFECTS__
  1397. function shallowReactive(target) {
  1398. return createReactiveObject(
  1399. target,
  1400. false,
  1401. shallowReactiveHandlers,
  1402. shallowCollectionHandlers,
  1403. shallowReactiveMap
  1404. );
  1405. }
  1406. // @__NO_SIDE_EFFECTS__
  1407. function readonly(target) {
  1408. return createReactiveObject(
  1409. target,
  1410. true,
  1411. readonlyHandlers,
  1412. readonlyCollectionHandlers,
  1413. readonlyMap
  1414. );
  1415. }
  1416. // @__NO_SIDE_EFFECTS__
  1417. function shallowReadonly(target) {
  1418. return createReactiveObject(
  1419. target,
  1420. true,
  1421. shallowReadonlyHandlers,
  1422. shallowReadonlyCollectionHandlers,
  1423. shallowReadonlyMap
  1424. );
  1425. }
  1426. function createReactiveObject(target, isReadonly2, baseHandlers, collectionHandlers, proxyMap) {
  1427. if (!shared.isObject(target)) {
  1428. {
  1429. warn(
  1430. `value cannot be made ${isReadonly2 ? "readonly" : "reactive"}: ${String(
  1431. target
  1432. )}`
  1433. );
  1434. }
  1435. return target;
  1436. }
  1437. if (target["__v_raw"] && !(isReadonly2 && target["__v_isReactive"])) {
  1438. return target;
  1439. }
  1440. if (target["__v_skip"] || !Object.isExtensible(target)) {
  1441. return target;
  1442. }
  1443. const existingProxy = proxyMap.get(target);
  1444. if (existingProxy) {
  1445. return existingProxy;
  1446. }
  1447. const targetType = targetTypeMap(shared.toRawType(target));
  1448. if (targetType === 0 /* INVALID */) {
  1449. return target;
  1450. }
  1451. const proxy = new Proxy(
  1452. target,
  1453. targetType === 2 /* COLLECTION */ ? collectionHandlers : baseHandlers
  1454. );
  1455. proxyMap.set(target, proxy);
  1456. return proxy;
  1457. }
  1458. // @__NO_SIDE_EFFECTS__
  1459. function isReactive(value) {
  1460. if (/* @__PURE__ */ isReadonly(value)) {
  1461. return /* @__PURE__ */ isReactive(value["__v_raw"]);
  1462. }
  1463. return !!(value && value["__v_isReactive"]);
  1464. }
  1465. // @__NO_SIDE_EFFECTS__
  1466. function isReadonly(value) {
  1467. return !!(value && value["__v_isReadonly"]);
  1468. }
  1469. // @__NO_SIDE_EFFECTS__
  1470. function isShallow(value) {
  1471. return !!(value && value["__v_isShallow"]);
  1472. }
  1473. // @__NO_SIDE_EFFECTS__
  1474. function isProxy(value) {
  1475. return value ? !!value["__v_raw"] : false;
  1476. }
  1477. // @__NO_SIDE_EFFECTS__
  1478. function toRaw(observed) {
  1479. const raw = observed && observed["__v_raw"];
  1480. return raw ? /* @__PURE__ */ toRaw(raw) : observed;
  1481. }
  1482. function markRaw(value) {
  1483. if (!shared.hasOwn(value, "__v_skip") && Object.isExtensible(value)) {
  1484. shared.def(value, "__v_skip", true);
  1485. }
  1486. return value;
  1487. }
  1488. const toReactive = (value) => shared.isObject(value) ? /* @__PURE__ */ reactive(value) : value;
  1489. const toReadonly = (value) => shared.isObject(value) ? /* @__PURE__ */ readonly(value) : value;
  1490. // @__NO_SIDE_EFFECTS__
  1491. function isRef(r) {
  1492. return r ? r["__v_isRef"] === true : false;
  1493. }
  1494. // @__NO_SIDE_EFFECTS__
  1495. function ref(value) {
  1496. return createRef(value, false);
  1497. }
  1498. // @__NO_SIDE_EFFECTS__
  1499. function shallowRef(value) {
  1500. return createRef(value, true);
  1501. }
  1502. function createRef(rawValue, shallow) {
  1503. if (/* @__PURE__ */ isRef(rawValue)) {
  1504. return rawValue;
  1505. }
  1506. return new RefImpl(rawValue, shallow);
  1507. }
  1508. class RefImpl {
  1509. constructor(value, isShallow2) {
  1510. this.dep = new Dep();
  1511. this["__v_isRef"] = true;
  1512. this["__v_isShallow"] = false;
  1513. this._rawValue = isShallow2 ? value : toRaw(value);
  1514. this._value = isShallow2 ? value : toReactive(value);
  1515. this["__v_isShallow"] = isShallow2;
  1516. }
  1517. get value() {
  1518. {
  1519. this.dep.track({
  1520. target: this,
  1521. type: "get",
  1522. key: "value"
  1523. });
  1524. }
  1525. return this._value;
  1526. }
  1527. set value(newValue) {
  1528. const oldValue = this._rawValue;
  1529. const useDirectValue = this["__v_isShallow"] || isShallow(newValue) || isReadonly(newValue);
  1530. newValue = useDirectValue ? newValue : toRaw(newValue);
  1531. if (shared.hasChanged(newValue, oldValue)) {
  1532. this._rawValue = newValue;
  1533. this._value = useDirectValue ? newValue : toReactive(newValue);
  1534. {
  1535. this.dep.trigger({
  1536. target: this,
  1537. type: "set",
  1538. key: "value",
  1539. newValue,
  1540. oldValue
  1541. });
  1542. }
  1543. }
  1544. }
  1545. }
  1546. function triggerRef(ref2) {
  1547. if (ref2.dep) {
  1548. {
  1549. ref2.dep.trigger({
  1550. target: ref2,
  1551. type: "set",
  1552. key: "value",
  1553. newValue: ref2._value
  1554. });
  1555. }
  1556. }
  1557. }
  1558. function unref(ref2) {
  1559. return /* @__PURE__ */ isRef(ref2) ? ref2.value : ref2;
  1560. }
  1561. function toValue(source) {
  1562. return shared.isFunction(source) ? source() : unref(source);
  1563. }
  1564. const shallowUnwrapHandlers = {
  1565. get: (target, key, receiver) => key === "__v_raw" ? target : unref(Reflect.get(target, key, receiver)),
  1566. set: (target, key, value, receiver) => {
  1567. const oldValue = target[key];
  1568. if (/* @__PURE__ */ isRef(oldValue) && !/* @__PURE__ */ isRef(value)) {
  1569. oldValue.value = value;
  1570. return true;
  1571. } else {
  1572. return Reflect.set(target, key, value, receiver);
  1573. }
  1574. }
  1575. };
  1576. function proxyRefs(objectWithRefs) {
  1577. return isReactive(objectWithRefs) ? objectWithRefs : new Proxy(objectWithRefs, shallowUnwrapHandlers);
  1578. }
  1579. class CustomRefImpl {
  1580. constructor(factory) {
  1581. this["__v_isRef"] = true;
  1582. this._value = void 0;
  1583. const dep = this.dep = new Dep();
  1584. const { get, set } = factory(dep.track.bind(dep), dep.trigger.bind(dep));
  1585. this._get = get;
  1586. this._set = set;
  1587. }
  1588. get value() {
  1589. return this._value = this._get();
  1590. }
  1591. set value(newVal) {
  1592. this._set(newVal);
  1593. }
  1594. }
  1595. function customRef(factory) {
  1596. return new CustomRefImpl(factory);
  1597. }
  1598. // @__NO_SIDE_EFFECTS__
  1599. function toRefs(object) {
  1600. if (!isProxy(object)) {
  1601. warn(`toRefs() expects a reactive object but received a plain one.`);
  1602. }
  1603. const ret = shared.isArray(object) ? new Array(object.length) : {};
  1604. for (const key in object) {
  1605. ret[key] = propertyToRef(object, key);
  1606. }
  1607. return ret;
  1608. }
  1609. class ObjectRefImpl {
  1610. constructor(_object, key, _defaultValue) {
  1611. this._object = _object;
  1612. this._defaultValue = _defaultValue;
  1613. this["__v_isRef"] = true;
  1614. this._value = void 0;
  1615. this._key = shared.isSymbol(key) ? key : String(key);
  1616. this._raw = toRaw(_object);
  1617. let shallow = true;
  1618. let obj = _object;
  1619. if (!shared.isArray(_object) || shared.isSymbol(this._key) || !shared.isIntegerKey(this._key)) {
  1620. do {
  1621. shallow = !isProxy(obj) || isShallow(obj);
  1622. } while (shallow && (obj = obj["__v_raw"]));
  1623. }
  1624. this._shallow = shallow;
  1625. }
  1626. get value() {
  1627. let val = this._object[this._key];
  1628. if (this._shallow) {
  1629. val = unref(val);
  1630. }
  1631. return this._value = val === void 0 ? this._defaultValue : val;
  1632. }
  1633. set value(newVal) {
  1634. if (this._shallow && /* @__PURE__ */ isRef(this._raw[this._key])) {
  1635. const nestedRef = this._object[this._key];
  1636. if (/* @__PURE__ */ isRef(nestedRef)) {
  1637. nestedRef.value = newVal;
  1638. return;
  1639. }
  1640. }
  1641. this._object[this._key] = newVal;
  1642. }
  1643. get dep() {
  1644. return getDepFromReactive(this._raw, this._key);
  1645. }
  1646. }
  1647. class GetterRefImpl {
  1648. constructor(_getter) {
  1649. this._getter = _getter;
  1650. this["__v_isRef"] = true;
  1651. this["__v_isReadonly"] = true;
  1652. this._value = void 0;
  1653. }
  1654. get value() {
  1655. return this._value = this._getter();
  1656. }
  1657. }
  1658. // @__NO_SIDE_EFFECTS__
  1659. function toRef(source, key, defaultValue) {
  1660. if (/* @__PURE__ */ isRef(source)) {
  1661. return source;
  1662. } else if (shared.isFunction(source)) {
  1663. return new GetterRefImpl(source);
  1664. } else if (shared.isObject(source) && arguments.length > 1) {
  1665. return propertyToRef(source, key, defaultValue);
  1666. } else {
  1667. return /* @__PURE__ */ ref(source);
  1668. }
  1669. }
  1670. function propertyToRef(source, key, defaultValue) {
  1671. return new ObjectRefImpl(source, key, defaultValue);
  1672. }
  1673. class ComputedRefImpl {
  1674. constructor(fn, setter, isSSR) {
  1675. this.fn = fn;
  1676. this.setter = setter;
  1677. /**
  1678. * @internal
  1679. */
  1680. this._value = void 0;
  1681. /**
  1682. * @internal
  1683. */
  1684. this.dep = new Dep(this);
  1685. /**
  1686. * @internal
  1687. */
  1688. this.__v_isRef = true;
  1689. // TODO isolatedDeclarations "__v_isReadonly"
  1690. // A computed is also a subscriber that tracks other deps
  1691. /**
  1692. * @internal
  1693. */
  1694. this.deps = void 0;
  1695. /**
  1696. * @internal
  1697. */
  1698. this.depsTail = void 0;
  1699. /**
  1700. * @internal
  1701. */
  1702. this.flags = 16;
  1703. /**
  1704. * @internal
  1705. */
  1706. this.globalVersion = globalVersion - 1;
  1707. /**
  1708. * @internal
  1709. */
  1710. this.next = void 0;
  1711. // for backwards compat
  1712. this.effect = this;
  1713. this["__v_isReadonly"] = !setter;
  1714. this.isSSR = isSSR;
  1715. }
  1716. /**
  1717. * @internal
  1718. */
  1719. notify() {
  1720. this.flags |= 16;
  1721. if (!(this.flags & 8) && // avoid infinite self recursion
  1722. activeSub !== this) {
  1723. batch(this, true);
  1724. return true;
  1725. }
  1726. }
  1727. get value() {
  1728. const link = this.dep.track({
  1729. target: this,
  1730. type: "get",
  1731. key: "value"
  1732. }) ;
  1733. refreshComputed(this);
  1734. if (link) {
  1735. link.version = this.dep.version;
  1736. }
  1737. return this._value;
  1738. }
  1739. set value(newValue) {
  1740. if (this.setter) {
  1741. this.setter(newValue);
  1742. } else {
  1743. warn("Write operation failed: computed value is readonly");
  1744. }
  1745. }
  1746. }
  1747. // @__NO_SIDE_EFFECTS__
  1748. function computed(getterOrOptions, debugOptions, isSSR = false) {
  1749. let getter;
  1750. let setter;
  1751. if (shared.isFunction(getterOrOptions)) {
  1752. getter = getterOrOptions;
  1753. } else {
  1754. getter = getterOrOptions.get;
  1755. setter = getterOrOptions.set;
  1756. }
  1757. const cRef = new ComputedRefImpl(getter, setter, isSSR);
  1758. if (debugOptions && !isSSR) {
  1759. cRef.onTrack = debugOptions.onTrack;
  1760. cRef.onTrigger = debugOptions.onTrigger;
  1761. }
  1762. return cRef;
  1763. }
  1764. const TrackOpTypes = {
  1765. "GET": "get",
  1766. "HAS": "has",
  1767. "ITERATE": "iterate"
  1768. };
  1769. const TriggerOpTypes = {
  1770. "SET": "set",
  1771. "ADD": "add",
  1772. "DELETE": "delete",
  1773. "CLEAR": "clear"
  1774. };
  1775. const ReactiveFlags = {
  1776. "SKIP": "__v_skip",
  1777. "IS_REACTIVE": "__v_isReactive",
  1778. "IS_READONLY": "__v_isReadonly",
  1779. "IS_SHALLOW": "__v_isShallow",
  1780. "RAW": "__v_raw",
  1781. "IS_REF": "__v_isRef"
  1782. };
  1783. const WatchErrorCodes = {
  1784. "WATCH_GETTER": 2,
  1785. "2": "WATCH_GETTER",
  1786. "WATCH_CALLBACK": 3,
  1787. "3": "WATCH_CALLBACK",
  1788. "WATCH_CLEANUP": 4,
  1789. "4": "WATCH_CLEANUP"
  1790. };
  1791. const INITIAL_WATCHER_VALUE = {};
  1792. const cleanupMap = /* @__PURE__ */ new WeakMap();
  1793. let activeWatcher = void 0;
  1794. function getCurrentWatcher() {
  1795. return activeWatcher;
  1796. }
  1797. function onWatcherCleanup(cleanupFn, failSilently = false, owner = activeWatcher) {
  1798. if (owner) {
  1799. let cleanups = cleanupMap.get(owner);
  1800. if (!cleanups) cleanupMap.set(owner, cleanups = []);
  1801. cleanups.push(cleanupFn);
  1802. } else if (!failSilently) {
  1803. warn(
  1804. `onWatcherCleanup() was called when there was no active watcher to associate with.`
  1805. );
  1806. }
  1807. }
  1808. function watch(source, cb, options = shared.EMPTY_OBJ) {
  1809. const { immediate, deep, once, scheduler, augmentJob, call } = options;
  1810. const warnInvalidSource = (s) => {
  1811. (options.onWarn || warn)(
  1812. `Invalid watch source: `,
  1813. s,
  1814. `A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`
  1815. );
  1816. };
  1817. const reactiveGetter = (source2) => {
  1818. if (deep) return source2;
  1819. if (isShallow(source2) || deep === false || deep === 0)
  1820. return traverse(source2, 1);
  1821. return traverse(source2);
  1822. };
  1823. let effect;
  1824. let getter;
  1825. let cleanup;
  1826. let boundCleanup;
  1827. let forceTrigger = false;
  1828. let isMultiSource = false;
  1829. if (isRef(source)) {
  1830. getter = () => source.value;
  1831. forceTrigger = isShallow(source);
  1832. } else if (isReactive(source)) {
  1833. getter = () => reactiveGetter(source);
  1834. forceTrigger = true;
  1835. } else if (shared.isArray(source)) {
  1836. isMultiSource = true;
  1837. forceTrigger = source.some((s) => isReactive(s) || isShallow(s));
  1838. getter = () => source.map((s) => {
  1839. if (isRef(s)) {
  1840. return s.value;
  1841. } else if (isReactive(s)) {
  1842. return reactiveGetter(s);
  1843. } else if (shared.isFunction(s)) {
  1844. return call ? call(s, 2) : s();
  1845. } else {
  1846. warnInvalidSource(s);
  1847. }
  1848. });
  1849. } else if (shared.isFunction(source)) {
  1850. if (cb) {
  1851. getter = call ? () => call(source, 2) : source;
  1852. } else {
  1853. getter = () => {
  1854. if (cleanup) {
  1855. pauseTracking();
  1856. try {
  1857. cleanup();
  1858. } finally {
  1859. resetTracking();
  1860. }
  1861. }
  1862. const currentEffect = activeWatcher;
  1863. activeWatcher = effect;
  1864. try {
  1865. return call ? call(source, 3, [boundCleanup]) : source(boundCleanup);
  1866. } finally {
  1867. activeWatcher = currentEffect;
  1868. }
  1869. };
  1870. }
  1871. } else {
  1872. getter = shared.NOOP;
  1873. warnInvalidSource(source);
  1874. }
  1875. if (cb && deep) {
  1876. const baseGetter = getter;
  1877. const depth = deep === true ? Infinity : deep;
  1878. getter = () => traverse(baseGetter(), depth);
  1879. }
  1880. const scope = getCurrentScope();
  1881. const watchHandle = () => {
  1882. effect.stop();
  1883. if (scope && scope.active) {
  1884. shared.remove(scope.effects, effect);
  1885. }
  1886. };
  1887. if (once && cb) {
  1888. const _cb = cb;
  1889. cb = (...args) => {
  1890. const res = _cb(...args);
  1891. watchHandle();
  1892. return res;
  1893. };
  1894. }
  1895. let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
  1896. const job = (immediateFirstRun) => {
  1897. if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) {
  1898. return;
  1899. }
  1900. if (cb) {
  1901. const newValue = effect.run();
  1902. if (immediateFirstRun || deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => shared.hasChanged(v, oldValue[i])) : shared.hasChanged(newValue, oldValue))) {
  1903. if (cleanup) {
  1904. cleanup();
  1905. }
  1906. const currentWatcher = activeWatcher;
  1907. activeWatcher = effect;
  1908. try {
  1909. const args = [
  1910. newValue,
  1911. // pass undefined as the old value when it's changed for the first time
  1912. oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
  1913. boundCleanup
  1914. ];
  1915. oldValue = newValue;
  1916. call ? call(cb, 3, args) : (
  1917. // @ts-expect-error
  1918. cb(...args)
  1919. );
  1920. } finally {
  1921. activeWatcher = currentWatcher;
  1922. }
  1923. }
  1924. } else {
  1925. effect.run();
  1926. }
  1927. };
  1928. if (augmentJob) {
  1929. augmentJob(job);
  1930. }
  1931. effect = new ReactiveEffect(getter);
  1932. effect.scheduler = scheduler ? () => scheduler(job, false) : job;
  1933. boundCleanup = (fn) => onWatcherCleanup(fn, false, effect);
  1934. cleanup = effect.onStop = () => {
  1935. const cleanups = cleanupMap.get(effect);
  1936. if (cleanups) {
  1937. if (call) {
  1938. call(cleanups, 4);
  1939. } else {
  1940. for (const cleanup2 of cleanups) cleanup2();
  1941. }
  1942. cleanupMap.delete(effect);
  1943. }
  1944. };
  1945. {
  1946. effect.onTrack = options.onTrack;
  1947. effect.onTrigger = options.onTrigger;
  1948. }
  1949. if (cb) {
  1950. if (immediate) {
  1951. job(true);
  1952. } else {
  1953. oldValue = effect.run();
  1954. }
  1955. } else if (scheduler) {
  1956. scheduler(job.bind(null, true), true);
  1957. } else {
  1958. effect.run();
  1959. }
  1960. watchHandle.pause = effect.pause.bind(effect);
  1961. watchHandle.resume = effect.resume.bind(effect);
  1962. watchHandle.stop = watchHandle;
  1963. return watchHandle;
  1964. }
  1965. function traverse(value, depth = Infinity, seen) {
  1966. if (depth <= 0 || !shared.isObject(value) || value["__v_skip"]) {
  1967. return value;
  1968. }
  1969. seen = seen || /* @__PURE__ */ new Map();
  1970. if ((seen.get(value) || 0) >= depth) {
  1971. return value;
  1972. }
  1973. seen.set(value, depth);
  1974. depth--;
  1975. if (isRef(value)) {
  1976. traverse(value.value, depth, seen);
  1977. } else if (shared.isArray(value)) {
  1978. for (let i = 0; i < value.length; i++) {
  1979. traverse(value[i], depth, seen);
  1980. }
  1981. } else if (shared.isSet(value) || shared.isMap(value)) {
  1982. value.forEach((v) => {
  1983. traverse(v, depth, seen);
  1984. });
  1985. } else if (shared.isPlainObject(value)) {
  1986. for (const key in value) {
  1987. traverse(value[key], depth, seen);
  1988. }
  1989. for (const key of Object.getOwnPropertySymbols(value)) {
  1990. if (Object.prototype.propertyIsEnumerable.call(value, key)) {
  1991. traverse(value[key], depth, seen);
  1992. }
  1993. }
  1994. }
  1995. return value;
  1996. }
  1997. exports.ARRAY_ITERATE_KEY = ARRAY_ITERATE_KEY;
  1998. exports.EffectFlags = EffectFlags;
  1999. exports.EffectScope = EffectScope;
  2000. exports.ITERATE_KEY = ITERATE_KEY;
  2001. exports.MAP_KEY_ITERATE_KEY = MAP_KEY_ITERATE_KEY;
  2002. exports.ReactiveEffect = ReactiveEffect;
  2003. exports.ReactiveFlags = ReactiveFlags;
  2004. exports.TrackOpTypes = TrackOpTypes;
  2005. exports.TriggerOpTypes = TriggerOpTypes;
  2006. exports.WatchErrorCodes = WatchErrorCodes;
  2007. exports.computed = computed;
  2008. exports.customRef = customRef;
  2009. exports.effect = effect;
  2010. exports.effectScope = effectScope;
  2011. exports.enableTracking = enableTracking;
  2012. exports.getCurrentScope = getCurrentScope;
  2013. exports.getCurrentWatcher = getCurrentWatcher;
  2014. exports.isProxy = isProxy;
  2015. exports.isReactive = isReactive;
  2016. exports.isReadonly = isReadonly;
  2017. exports.isRef = isRef;
  2018. exports.isShallow = isShallow;
  2019. exports.markRaw = markRaw;
  2020. exports.onEffectCleanup = onEffectCleanup;
  2021. exports.onScopeDispose = onScopeDispose;
  2022. exports.onWatcherCleanup = onWatcherCleanup;
  2023. exports.pauseTracking = pauseTracking;
  2024. exports.proxyRefs = proxyRefs;
  2025. exports.reactive = reactive;
  2026. exports.reactiveReadArray = reactiveReadArray;
  2027. exports.readonly = readonly;
  2028. exports.ref = ref;
  2029. exports.resetTracking = resetTracking;
  2030. exports.shallowReactive = shallowReactive;
  2031. exports.shallowReadArray = shallowReadArray;
  2032. exports.shallowReadonly = shallowReadonly;
  2033. exports.shallowRef = shallowRef;
  2034. exports.stop = stop;
  2035. exports.toRaw = toRaw;
  2036. exports.toReactive = toReactive;
  2037. exports.toReadonly = toReadonly;
  2038. exports.toRef = toRef;
  2039. exports.toRefs = toRefs;
  2040. exports.toValue = toValue;
  2041. exports.track = track;
  2042. exports.traverse = traverse;
  2043. exports.trigger = trigger;
  2044. exports.triggerRef = triggerRef;
  2045. exports.unref = unref;
  2046. exports.watch = watch;