reactivity.global.js 58 KB

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