Node-Red configuration
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

reactivity.esm-bundler.js 35KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250
  1. /**
  2. * @vue/reactivity v3.4.38
  3. * (c) 2018-present Yuxi (Evan) You and Vue contributors
  4. * @license MIT
  5. **/
  6. import { NOOP, extend, isArray, isSymbol, isMap, isIntegerKey, hasOwn, hasChanged, isObject, makeMap, capitalize, toRawType, def, isFunction } from '@vue/shared';
  7. function warn(msg, ...args) {
  8. console.warn(`[Vue warn] ${msg}`, ...args);
  9. }
  10. let activeEffectScope;
  11. class EffectScope {
  12. constructor(detached = false) {
  13. this.detached = detached;
  14. /**
  15. * @internal
  16. */
  17. this._active = true;
  18. /**
  19. * @internal
  20. */
  21. this.effects = [];
  22. /**
  23. * @internal
  24. */
  25. this.cleanups = [];
  26. this.parent = activeEffectScope;
  27. if (!detached && activeEffectScope) {
  28. this.index = (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(
  29. this
  30. ) - 1;
  31. }
  32. }
  33. get active() {
  34. return this._active;
  35. }
  36. run(fn) {
  37. if (this._active) {
  38. const currentEffectScope = activeEffectScope;
  39. try {
  40. activeEffectScope = this;
  41. return fn();
  42. } finally {
  43. activeEffectScope = currentEffectScope;
  44. }
  45. } else if (!!(process.env.NODE_ENV !== "production")) {
  46. warn(`cannot run an inactive effect scope.`);
  47. }
  48. }
  49. /**
  50. * This should only be called on non-detached scopes
  51. * @internal
  52. */
  53. on() {
  54. activeEffectScope = this;
  55. }
  56. /**
  57. * This should only be called on non-detached scopes
  58. * @internal
  59. */
  60. off() {
  61. activeEffectScope = this.parent;
  62. }
  63. stop(fromParent) {
  64. if (this._active) {
  65. let i, l;
  66. for (i = 0, l = this.effects.length; i < l; i++) {
  67. this.effects[i].stop();
  68. }
  69. for (i = 0, l = this.cleanups.length; i < l; i++) {
  70. this.cleanups[i]();
  71. }
  72. if (this.scopes) {
  73. for (i = 0, l = this.scopes.length; i < l; i++) {
  74. this.scopes[i].stop(true);
  75. }
  76. }
  77. if (!this.detached && this.parent && !fromParent) {
  78. const last = this.parent.scopes.pop();
  79. if (last && last !== this) {
  80. this.parent.scopes[this.index] = last;
  81. last.index = this.index;
  82. }
  83. }
  84. this.parent = void 0;
  85. this._active = false;
  86. }
  87. }
  88. }
  89. function effectScope(detached) {
  90. return new EffectScope(detached);
  91. }
  92. function recordEffectScope(effect, scope = activeEffectScope) {
  93. if (scope && scope.active) {
  94. scope.effects.push(effect);
  95. }
  96. }
  97. function getCurrentScope() {
  98. return activeEffectScope;
  99. }
  100. function onScopeDispose(fn) {
  101. if (activeEffectScope) {
  102. activeEffectScope.cleanups.push(fn);
  103. } else if (!!(process.env.NODE_ENV !== "production")) {
  104. warn(
  105. `onScopeDispose() is called when there is no active effect scope to be associated with.`
  106. );
  107. }
  108. }
  109. let activeEffect;
  110. class ReactiveEffect {
  111. constructor(fn, trigger, scheduler, scope) {
  112. this.fn = fn;
  113. this.trigger = trigger;
  114. this.scheduler = scheduler;
  115. this.active = true;
  116. this.deps = [];
  117. /**
  118. * @internal
  119. */
  120. this._dirtyLevel = 4;
  121. /**
  122. * @internal
  123. */
  124. this._trackId = 0;
  125. /**
  126. * @internal
  127. */
  128. this._runnings = 0;
  129. /**
  130. * @internal
  131. */
  132. this._shouldSchedule = false;
  133. /**
  134. * @internal
  135. */
  136. this._depsLength = 0;
  137. recordEffectScope(this, scope);
  138. }
  139. get dirty() {
  140. if (this._dirtyLevel === 2 || this._dirtyLevel === 3) {
  141. this._dirtyLevel = 1;
  142. pauseTracking();
  143. for (let i = 0; i < this._depsLength; i++) {
  144. const dep = this.deps[i];
  145. if (dep.computed) {
  146. triggerComputed(dep.computed);
  147. if (this._dirtyLevel >= 4) {
  148. break;
  149. }
  150. }
  151. }
  152. if (this._dirtyLevel === 1) {
  153. this._dirtyLevel = 0;
  154. }
  155. resetTracking();
  156. }
  157. return this._dirtyLevel >= 4;
  158. }
  159. set dirty(v) {
  160. this._dirtyLevel = v ? 4 : 0;
  161. }
  162. run() {
  163. this._dirtyLevel = 0;
  164. if (!this.active) {
  165. return this.fn();
  166. }
  167. let lastShouldTrack = shouldTrack;
  168. let lastEffect = activeEffect;
  169. try {
  170. shouldTrack = true;
  171. activeEffect = this;
  172. this._runnings++;
  173. preCleanupEffect(this);
  174. return this.fn();
  175. } finally {
  176. postCleanupEffect(this);
  177. this._runnings--;
  178. activeEffect = lastEffect;
  179. shouldTrack = lastShouldTrack;
  180. }
  181. }
  182. stop() {
  183. if (this.active) {
  184. preCleanupEffect(this);
  185. postCleanupEffect(this);
  186. this.onStop && this.onStop();
  187. this.active = false;
  188. }
  189. }
  190. }
  191. function triggerComputed(computed) {
  192. return computed.value;
  193. }
  194. function preCleanupEffect(effect2) {
  195. effect2._trackId++;
  196. effect2._depsLength = 0;
  197. }
  198. function postCleanupEffect(effect2) {
  199. if (effect2.deps.length > effect2._depsLength) {
  200. for (let i = effect2._depsLength; i < effect2.deps.length; i++) {
  201. cleanupDepEffect(effect2.deps[i], effect2);
  202. }
  203. effect2.deps.length = effect2._depsLength;
  204. }
  205. }
  206. function cleanupDepEffect(dep, effect2) {
  207. const trackId = dep.get(effect2);
  208. if (trackId !== void 0 && effect2._trackId !== trackId) {
  209. dep.delete(effect2);
  210. if (dep.size === 0) {
  211. dep.cleanup();
  212. }
  213. }
  214. }
  215. function effect(fn, options) {
  216. if (fn.effect instanceof ReactiveEffect) {
  217. fn = fn.effect.fn;
  218. }
  219. const _effect = new ReactiveEffect(fn, NOOP, () => {
  220. if (_effect.dirty) {
  221. _effect.run();
  222. }
  223. });
  224. if (options) {
  225. extend(_effect, options);
  226. if (options.scope) recordEffectScope(_effect, options.scope);
  227. }
  228. if (!options || !options.lazy) {
  229. _effect.run();
  230. }
  231. const runner = _effect.run.bind(_effect);
  232. runner.effect = _effect;
  233. return runner;
  234. }
  235. function stop(runner) {
  236. runner.effect.stop();
  237. }
  238. let shouldTrack = true;
  239. let pauseScheduleStack = 0;
  240. const trackStack = [];
  241. function pauseTracking() {
  242. trackStack.push(shouldTrack);
  243. shouldTrack = false;
  244. }
  245. function enableTracking() {
  246. trackStack.push(shouldTrack);
  247. shouldTrack = true;
  248. }
  249. function resetTracking() {
  250. const last = trackStack.pop();
  251. shouldTrack = last === void 0 ? true : last;
  252. }
  253. function pauseScheduling() {
  254. pauseScheduleStack++;
  255. }
  256. function resetScheduling() {
  257. pauseScheduleStack--;
  258. while (!pauseScheduleStack && queueEffectSchedulers.length) {
  259. queueEffectSchedulers.shift()();
  260. }
  261. }
  262. function trackEffect(effect2, dep, debuggerEventExtraInfo) {
  263. var _a;
  264. if (dep.get(effect2) !== effect2._trackId) {
  265. dep.set(effect2, effect2._trackId);
  266. const oldDep = effect2.deps[effect2._depsLength];
  267. if (oldDep !== dep) {
  268. if (oldDep) {
  269. cleanupDepEffect(oldDep, effect2);
  270. }
  271. effect2.deps[effect2._depsLength++] = dep;
  272. } else {
  273. effect2._depsLength++;
  274. }
  275. if (!!(process.env.NODE_ENV !== "production")) {
  276. (_a = effect2.onTrack) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo));
  277. }
  278. }
  279. }
  280. const queueEffectSchedulers = [];
  281. function triggerEffects(dep, dirtyLevel, debuggerEventExtraInfo) {
  282. var _a;
  283. pauseScheduling();
  284. for (const effect2 of dep.keys()) {
  285. let tracking;
  286. if (effect2._dirtyLevel < dirtyLevel && (tracking != null ? tracking : tracking = dep.get(effect2) === effect2._trackId)) {
  287. effect2._shouldSchedule || (effect2._shouldSchedule = effect2._dirtyLevel === 0);
  288. effect2._dirtyLevel = dirtyLevel;
  289. }
  290. if (effect2._shouldSchedule && (tracking != null ? tracking : tracking = dep.get(effect2) === effect2._trackId)) {
  291. if (!!(process.env.NODE_ENV !== "production")) {
  292. (_a = effect2.onTrigger) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo));
  293. }
  294. effect2.trigger();
  295. if ((!effect2._runnings || effect2.allowRecurse) && effect2._dirtyLevel !== 2) {
  296. effect2._shouldSchedule = false;
  297. if (effect2.scheduler) {
  298. queueEffectSchedulers.push(effect2.scheduler);
  299. }
  300. }
  301. }
  302. }
  303. resetScheduling();
  304. }
  305. const createDep = (cleanup, computed) => {
  306. const dep = /* @__PURE__ */ new Map();
  307. dep.cleanup = cleanup;
  308. dep.computed = computed;
  309. return dep;
  310. };
  311. const targetMap = /* @__PURE__ */ new WeakMap();
  312. const ITERATE_KEY = Symbol(!!(process.env.NODE_ENV !== "production") ? "iterate" : "");
  313. const MAP_KEY_ITERATE_KEY = Symbol(!!(process.env.NODE_ENV !== "production") ? "Map key iterate" : "");
  314. function track(target, type, key) {
  315. if (shouldTrack && activeEffect) {
  316. let depsMap = targetMap.get(target);
  317. if (!depsMap) {
  318. targetMap.set(target, depsMap = /* @__PURE__ */ new Map());
  319. }
  320. let dep = depsMap.get(key);
  321. if (!dep) {
  322. depsMap.set(key, dep = createDep(() => depsMap.delete(key)));
  323. }
  324. trackEffect(
  325. activeEffect,
  326. dep,
  327. !!(process.env.NODE_ENV !== "production") ? {
  328. target,
  329. type,
  330. key
  331. } : void 0
  332. );
  333. }
  334. }
  335. function trigger(target, type, key, newValue, oldValue, oldTarget) {
  336. const depsMap = targetMap.get(target);
  337. if (!depsMap) {
  338. return;
  339. }
  340. let deps = [];
  341. if (type === "clear") {
  342. deps = [...depsMap.values()];
  343. } else if (key === "length" && isArray(target)) {
  344. const newLength = Number(newValue);
  345. depsMap.forEach((dep, key2) => {
  346. if (key2 === "length" || !isSymbol(key2) && key2 >= newLength) {
  347. deps.push(dep);
  348. }
  349. });
  350. } else {
  351. if (key !== void 0) {
  352. deps.push(depsMap.get(key));
  353. }
  354. switch (type) {
  355. case "add":
  356. if (!isArray(target)) {
  357. deps.push(depsMap.get(ITERATE_KEY));
  358. if (isMap(target)) {
  359. deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
  360. }
  361. } else if (isIntegerKey(key)) {
  362. deps.push(depsMap.get("length"));
  363. }
  364. break;
  365. case "delete":
  366. if (!isArray(target)) {
  367. deps.push(depsMap.get(ITERATE_KEY));
  368. if (isMap(target)) {
  369. deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
  370. }
  371. }
  372. break;
  373. case "set":
  374. if (isMap(target)) {
  375. deps.push(depsMap.get(ITERATE_KEY));
  376. }
  377. break;
  378. }
  379. }
  380. pauseScheduling();
  381. for (const dep of deps) {
  382. if (dep) {
  383. triggerEffects(
  384. dep,
  385. 4,
  386. !!(process.env.NODE_ENV !== "production") ? {
  387. target,
  388. type,
  389. key,
  390. newValue,
  391. oldValue,
  392. oldTarget
  393. } : void 0
  394. );
  395. }
  396. }
  397. resetScheduling();
  398. }
  399. function getDepFromReactive(object, key) {
  400. const depsMap = targetMap.get(object);
  401. return depsMap && depsMap.get(key);
  402. }
  403. const isNonTrackableKeys = /* @__PURE__ */ makeMap(`__proto__,__v_isRef,__isVue`);
  404. const builtInSymbols = new Set(
  405. /* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol)
  406. );
  407. const arrayInstrumentations = /* @__PURE__ */ createArrayInstrumentations();
  408. function createArrayInstrumentations() {
  409. const instrumentations = {};
  410. ["includes", "indexOf", "lastIndexOf"].forEach((key) => {
  411. instrumentations[key] = function(...args) {
  412. const arr = toRaw(this);
  413. for (let i = 0, l = this.length; i < l; i++) {
  414. track(arr, "get", i + "");
  415. }
  416. const res = arr[key](...args);
  417. if (res === -1 || res === false) {
  418. return arr[key](...args.map(toRaw));
  419. } else {
  420. return res;
  421. }
  422. };
  423. });
  424. ["push", "pop", "shift", "unshift", "splice"].forEach((key) => {
  425. instrumentations[key] = function(...args) {
  426. pauseTracking();
  427. pauseScheduling();
  428. const res = toRaw(this)[key].apply(this, args);
  429. resetScheduling();
  430. resetTracking();
  431. return res;
  432. };
  433. });
  434. return instrumentations;
  435. }
  436. function hasOwnProperty(key) {
  437. if (!isSymbol(key)) key = String(key);
  438. const obj = toRaw(this);
  439. track(obj, "has", key);
  440. return obj.hasOwnProperty(key);
  441. }
  442. class BaseReactiveHandler {
  443. constructor(_isReadonly = false, _isShallow = false) {
  444. this._isReadonly = _isReadonly;
  445. this._isShallow = _isShallow;
  446. }
  447. get(target, key, receiver) {
  448. const isReadonly2 = this._isReadonly, isShallow2 = this._isShallow;
  449. if (key === "__v_isReactive") {
  450. return !isReadonly2;
  451. } else if (key === "__v_isReadonly") {
  452. return isReadonly2;
  453. } else if (key === "__v_isShallow") {
  454. return isShallow2;
  455. } else if (key === "__v_raw") {
  456. if (receiver === (isReadonly2 ? isShallow2 ? shallowReadonlyMap : readonlyMap : isShallow2 ? shallowReactiveMap : reactiveMap).get(target) || // receiver is not the reactive proxy, but has the same prototype
  457. // this means the receiver is a user proxy of the reactive proxy
  458. Object.getPrototypeOf(target) === Object.getPrototypeOf(receiver)) {
  459. return target;
  460. }
  461. return;
  462. }
  463. const targetIsArray = isArray(target);
  464. if (!isReadonly2) {
  465. if (targetIsArray && hasOwn(arrayInstrumentations, key)) {
  466. return Reflect.get(arrayInstrumentations, key, receiver);
  467. }
  468. if (key === "hasOwnProperty") {
  469. return hasOwnProperty;
  470. }
  471. }
  472. const res = Reflect.get(target, key, receiver);
  473. if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
  474. return res;
  475. }
  476. if (!isReadonly2) {
  477. track(target, "get", key);
  478. }
  479. if (isShallow2) {
  480. return res;
  481. }
  482. if (isRef(res)) {
  483. return targetIsArray && isIntegerKey(key) ? res : res.value;
  484. }
  485. if (isObject(res)) {
  486. return isReadonly2 ? readonly(res) : reactive(res);
  487. }
  488. return res;
  489. }
  490. }
  491. class MutableReactiveHandler extends BaseReactiveHandler {
  492. constructor(isShallow2 = false) {
  493. super(false, isShallow2);
  494. }
  495. set(target, key, value, receiver) {
  496. let oldValue = target[key];
  497. if (!this._isShallow) {
  498. const isOldValueReadonly = isReadonly(oldValue);
  499. if (!isShallow(value) && !isReadonly(value)) {
  500. oldValue = toRaw(oldValue);
  501. value = toRaw(value);
  502. }
  503. if (!isArray(target) && isRef(oldValue) && !isRef(value)) {
  504. if (isOldValueReadonly) {
  505. return false;
  506. } else {
  507. oldValue.value = value;
  508. return true;
  509. }
  510. }
  511. }
  512. const hadKey = isArray(target) && isIntegerKey(key) ? Number(key) < target.length : hasOwn(target, key);
  513. const result = Reflect.set(target, key, value, receiver);
  514. if (target === toRaw(receiver)) {
  515. if (!hadKey) {
  516. trigger(target, "add", key, value);
  517. } else if (hasChanged(value, oldValue)) {
  518. trigger(target, "set", key, value, oldValue);
  519. }
  520. }
  521. return result;
  522. }
  523. deleteProperty(target, key) {
  524. const hadKey = hasOwn(target, key);
  525. const oldValue = target[key];
  526. const result = Reflect.deleteProperty(target, key);
  527. if (result && hadKey) {
  528. trigger(target, "delete", key, void 0, oldValue);
  529. }
  530. return result;
  531. }
  532. has(target, key) {
  533. const result = Reflect.has(target, key);
  534. if (!isSymbol(key) || !builtInSymbols.has(key)) {
  535. track(target, "has", key);
  536. }
  537. return result;
  538. }
  539. ownKeys(target) {
  540. track(
  541. target,
  542. "iterate",
  543. isArray(target) ? "length" : ITERATE_KEY
  544. );
  545. return Reflect.ownKeys(target);
  546. }
  547. }
  548. class ReadonlyReactiveHandler extends BaseReactiveHandler {
  549. constructor(isShallow2 = false) {
  550. super(true, isShallow2);
  551. }
  552. set(target, key) {
  553. if (!!(process.env.NODE_ENV !== "production")) {
  554. warn(
  555. `Set operation on key "${String(key)}" failed: target is readonly.`,
  556. target
  557. );
  558. }
  559. return true;
  560. }
  561. deleteProperty(target, key) {
  562. if (!!(process.env.NODE_ENV !== "production")) {
  563. warn(
  564. `Delete operation on key "${String(key)}" failed: target is readonly.`,
  565. target
  566. );
  567. }
  568. return true;
  569. }
  570. }
  571. const mutableHandlers = /* @__PURE__ */ new MutableReactiveHandler();
  572. const readonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler();
  573. const shallowReactiveHandlers = /* @__PURE__ */ new MutableReactiveHandler(
  574. true
  575. );
  576. const shallowReadonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler(true);
  577. const toShallow = (value) => value;
  578. const getProto = (v) => Reflect.getPrototypeOf(v);
  579. function get(target, key, isReadonly2 = false, isShallow2 = false) {
  580. target = target["__v_raw"];
  581. const rawTarget = toRaw(target);
  582. const rawKey = toRaw(key);
  583. if (!isReadonly2) {
  584. if (hasChanged(key, rawKey)) {
  585. track(rawTarget, "get", key);
  586. }
  587. track(rawTarget, "get", rawKey);
  588. }
  589. const { has: has2 } = getProto(rawTarget);
  590. const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
  591. if (has2.call(rawTarget, key)) {
  592. return wrap(target.get(key));
  593. } else if (has2.call(rawTarget, rawKey)) {
  594. return wrap(target.get(rawKey));
  595. } else if (target !== rawTarget) {
  596. target.get(key);
  597. }
  598. }
  599. function has(key, isReadonly2 = false) {
  600. const target = this["__v_raw"];
  601. const rawTarget = toRaw(target);
  602. const rawKey = toRaw(key);
  603. if (!isReadonly2) {
  604. if (hasChanged(key, rawKey)) {
  605. track(rawTarget, "has", key);
  606. }
  607. track(rawTarget, "has", rawKey);
  608. }
  609. return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey);
  610. }
  611. function size(target, isReadonly2 = false) {
  612. target = target["__v_raw"];
  613. !isReadonly2 && track(toRaw(target), "iterate", ITERATE_KEY);
  614. return Reflect.get(target, "size", target);
  615. }
  616. function add(value, _isShallow = false) {
  617. if (!_isShallow && !isShallow(value) && !isReadonly(value)) {
  618. value = toRaw(value);
  619. }
  620. const target = toRaw(this);
  621. const proto = getProto(target);
  622. const hadKey = proto.has.call(target, value);
  623. if (!hadKey) {
  624. target.add(value);
  625. trigger(target, "add", value, value);
  626. }
  627. return this;
  628. }
  629. function set(key, value, _isShallow = false) {
  630. if (!_isShallow && !isShallow(value) && !isReadonly(value)) {
  631. value = toRaw(value);
  632. }
  633. const target = toRaw(this);
  634. const { has: has2, get: get2 } = getProto(target);
  635. let hadKey = has2.call(target, key);
  636. if (!hadKey) {
  637. key = toRaw(key);
  638. hadKey = has2.call(target, key);
  639. } else if (!!(process.env.NODE_ENV !== "production")) {
  640. checkIdentityKeys(target, has2, key);
  641. }
  642. const oldValue = get2.call(target, key);
  643. target.set(key, value);
  644. if (!hadKey) {
  645. trigger(target, "add", key, value);
  646. } else if (hasChanged(value, oldValue)) {
  647. trigger(target, "set", key, value, oldValue);
  648. }
  649. return this;
  650. }
  651. function deleteEntry(key) {
  652. const target = toRaw(this);
  653. const { has: has2, get: get2 } = getProto(target);
  654. let hadKey = has2.call(target, key);
  655. if (!hadKey) {
  656. key = toRaw(key);
  657. hadKey = has2.call(target, key);
  658. } else if (!!(process.env.NODE_ENV !== "production")) {
  659. checkIdentityKeys(target, has2, key);
  660. }
  661. const oldValue = get2 ? get2.call(target, key) : void 0;
  662. const result = target.delete(key);
  663. if (hadKey) {
  664. trigger(target, "delete", key, void 0, oldValue);
  665. }
  666. return result;
  667. }
  668. function clear() {
  669. const target = toRaw(this);
  670. const hadItems = target.size !== 0;
  671. const oldTarget = !!(process.env.NODE_ENV !== "production") ? isMap(target) ? new Map(target) : new Set(target) : void 0;
  672. const result = target.clear();
  673. if (hadItems) {
  674. trigger(target, "clear", void 0, void 0, oldTarget);
  675. }
  676. return result;
  677. }
  678. function createForEach(isReadonly2, isShallow2) {
  679. return function forEach(callback, thisArg) {
  680. const observed = this;
  681. const target = observed["__v_raw"];
  682. const rawTarget = toRaw(target);
  683. const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
  684. !isReadonly2 && track(rawTarget, "iterate", ITERATE_KEY);
  685. return target.forEach((value, key) => {
  686. return callback.call(thisArg, wrap(value), wrap(key), observed);
  687. });
  688. };
  689. }
  690. function createIterableMethod(method, isReadonly2, isShallow2) {
  691. return function(...args) {
  692. const target = this["__v_raw"];
  693. const rawTarget = toRaw(target);
  694. const targetIsMap = isMap(rawTarget);
  695. const isPair = method === "entries" || method === Symbol.iterator && targetIsMap;
  696. const isKeyOnly = method === "keys" && targetIsMap;
  697. const innerIterator = target[method](...args);
  698. const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
  699. !isReadonly2 && track(
  700. rawTarget,
  701. "iterate",
  702. isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY
  703. );
  704. return {
  705. // iterator protocol
  706. next() {
  707. const { value, done } = innerIterator.next();
  708. return done ? { value, done } : {
  709. value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
  710. done
  711. };
  712. },
  713. // iterable protocol
  714. [Symbol.iterator]() {
  715. return this;
  716. }
  717. };
  718. };
  719. }
  720. function createReadonlyMethod(type) {
  721. return function(...args) {
  722. if (!!(process.env.NODE_ENV !== "production")) {
  723. const key = args[0] ? `on key "${args[0]}" ` : ``;
  724. warn(
  725. `${capitalize(type)} operation ${key}failed: target is readonly.`,
  726. toRaw(this)
  727. );
  728. }
  729. return type === "delete" ? false : type === "clear" ? void 0 : this;
  730. };
  731. }
  732. function createInstrumentations() {
  733. const mutableInstrumentations2 = {
  734. get(key) {
  735. return get(this, key);
  736. },
  737. get size() {
  738. return size(this);
  739. },
  740. has,
  741. add,
  742. set,
  743. delete: deleteEntry,
  744. clear,
  745. forEach: createForEach(false, false)
  746. };
  747. const shallowInstrumentations2 = {
  748. get(key) {
  749. return get(this, key, false, true);
  750. },
  751. get size() {
  752. return size(this);
  753. },
  754. has,
  755. add(value) {
  756. return add.call(this, value, true);
  757. },
  758. set(key, value) {
  759. return set.call(this, key, value, true);
  760. },
  761. delete: deleteEntry,
  762. clear,
  763. forEach: createForEach(false, true)
  764. };
  765. const readonlyInstrumentations2 = {
  766. get(key) {
  767. return get(this, key, true);
  768. },
  769. get size() {
  770. return size(this, true);
  771. },
  772. has(key) {
  773. return has.call(this, key, true);
  774. },
  775. add: createReadonlyMethod("add"),
  776. set: createReadonlyMethod("set"),
  777. delete: createReadonlyMethod("delete"),
  778. clear: createReadonlyMethod("clear"),
  779. forEach: createForEach(true, false)
  780. };
  781. const shallowReadonlyInstrumentations2 = {
  782. get(key) {
  783. return get(this, key, true, true);
  784. },
  785. get size() {
  786. return size(this, true);
  787. },
  788. has(key) {
  789. return has.call(this, key, true);
  790. },
  791. add: createReadonlyMethod("add"),
  792. set: createReadonlyMethod("set"),
  793. delete: createReadonlyMethod("delete"),
  794. clear: createReadonlyMethod("clear"),
  795. forEach: createForEach(true, true)
  796. };
  797. const iteratorMethods = [
  798. "keys",
  799. "values",
  800. "entries",
  801. Symbol.iterator
  802. ];
  803. iteratorMethods.forEach((method) => {
  804. mutableInstrumentations2[method] = createIterableMethod(method, false, false);
  805. readonlyInstrumentations2[method] = createIterableMethod(method, true, false);
  806. shallowInstrumentations2[method] = createIterableMethod(method, false, true);
  807. shallowReadonlyInstrumentations2[method] = createIterableMethod(
  808. method,
  809. true,
  810. true
  811. );
  812. });
  813. return [
  814. mutableInstrumentations2,
  815. readonlyInstrumentations2,
  816. shallowInstrumentations2,
  817. shallowReadonlyInstrumentations2
  818. ];
  819. }
  820. const [
  821. mutableInstrumentations,
  822. readonlyInstrumentations,
  823. shallowInstrumentations,
  824. shallowReadonlyInstrumentations
  825. ] = /* @__PURE__ */ createInstrumentations();
  826. function createInstrumentationGetter(isReadonly2, shallow) {
  827. const instrumentations = shallow ? isReadonly2 ? shallowReadonlyInstrumentations : shallowInstrumentations : isReadonly2 ? readonlyInstrumentations : mutableInstrumentations;
  828. return (target, key, receiver) => {
  829. if (key === "__v_isReactive") {
  830. return !isReadonly2;
  831. } else if (key === "__v_isReadonly") {
  832. return isReadonly2;
  833. } else if (key === "__v_raw") {
  834. return target;
  835. }
  836. return Reflect.get(
  837. hasOwn(instrumentations, key) && key in target ? instrumentations : target,
  838. key,
  839. receiver
  840. );
  841. };
  842. }
  843. const mutableCollectionHandlers = {
  844. get: /* @__PURE__ */ createInstrumentationGetter(false, false)
  845. };
  846. const shallowCollectionHandlers = {
  847. get: /* @__PURE__ */ createInstrumentationGetter(false, true)
  848. };
  849. const readonlyCollectionHandlers = {
  850. get: /* @__PURE__ */ createInstrumentationGetter(true, false)
  851. };
  852. const shallowReadonlyCollectionHandlers = {
  853. get: /* @__PURE__ */ createInstrumentationGetter(true, true)
  854. };
  855. function checkIdentityKeys(target, has2, key) {
  856. const rawKey = toRaw(key);
  857. if (rawKey !== key && has2.call(target, rawKey)) {
  858. const type = toRawType(target);
  859. warn(
  860. `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.`
  861. );
  862. }
  863. }
  864. const reactiveMap = /* @__PURE__ */ new WeakMap();
  865. const shallowReactiveMap = /* @__PURE__ */ new WeakMap();
  866. const readonlyMap = /* @__PURE__ */ new WeakMap();
  867. const shallowReadonlyMap = /* @__PURE__ */ new WeakMap();
  868. function targetTypeMap(rawType) {
  869. switch (rawType) {
  870. case "Object":
  871. case "Array":
  872. return 1 /* COMMON */;
  873. case "Map":
  874. case "Set":
  875. case "WeakMap":
  876. case "WeakSet":
  877. return 2 /* COLLECTION */;
  878. default:
  879. return 0 /* INVALID */;
  880. }
  881. }
  882. function getTargetType(value) {
  883. return value["__v_skip"] || !Object.isExtensible(value) ? 0 /* INVALID */ : targetTypeMap(toRawType(value));
  884. }
  885. function reactive(target) {
  886. if (isReadonly(target)) {
  887. return target;
  888. }
  889. return createReactiveObject(
  890. target,
  891. false,
  892. mutableHandlers,
  893. mutableCollectionHandlers,
  894. reactiveMap
  895. );
  896. }
  897. function shallowReactive(target) {
  898. return createReactiveObject(
  899. target,
  900. false,
  901. shallowReactiveHandlers,
  902. shallowCollectionHandlers,
  903. shallowReactiveMap
  904. );
  905. }
  906. function readonly(target) {
  907. return createReactiveObject(
  908. target,
  909. true,
  910. readonlyHandlers,
  911. readonlyCollectionHandlers,
  912. readonlyMap
  913. );
  914. }
  915. function shallowReadonly(target) {
  916. return createReactiveObject(
  917. target,
  918. true,
  919. shallowReadonlyHandlers,
  920. shallowReadonlyCollectionHandlers,
  921. shallowReadonlyMap
  922. );
  923. }
  924. function createReactiveObject(target, isReadonly2, baseHandlers, collectionHandlers, proxyMap) {
  925. if (!isObject(target)) {
  926. if (!!(process.env.NODE_ENV !== "production")) {
  927. warn(
  928. `value cannot be made ${isReadonly2 ? "readonly" : "reactive"}: ${String(
  929. target
  930. )}`
  931. );
  932. }
  933. return target;
  934. }
  935. if (target["__v_raw"] && !(isReadonly2 && target["__v_isReactive"])) {
  936. return target;
  937. }
  938. const existingProxy = proxyMap.get(target);
  939. if (existingProxy) {
  940. return existingProxy;
  941. }
  942. const targetType = getTargetType(target);
  943. if (targetType === 0 /* INVALID */) {
  944. return target;
  945. }
  946. const proxy = new Proxy(
  947. target,
  948. targetType === 2 /* COLLECTION */ ? collectionHandlers : baseHandlers
  949. );
  950. proxyMap.set(target, proxy);
  951. return proxy;
  952. }
  953. function isReactive(value) {
  954. if (isReadonly(value)) {
  955. return isReactive(value["__v_raw"]);
  956. }
  957. return !!(value && value["__v_isReactive"]);
  958. }
  959. function isReadonly(value) {
  960. return !!(value && value["__v_isReadonly"]);
  961. }
  962. function isShallow(value) {
  963. return !!(value && value["__v_isShallow"]);
  964. }
  965. function isProxy(value) {
  966. return value ? !!value["__v_raw"] : false;
  967. }
  968. function toRaw(observed) {
  969. const raw = observed && observed["__v_raw"];
  970. return raw ? toRaw(raw) : observed;
  971. }
  972. function markRaw(value) {
  973. if (Object.isExtensible(value)) {
  974. def(value, "__v_skip", true);
  975. }
  976. return value;
  977. }
  978. const toReactive = (value) => isObject(value) ? reactive(value) : value;
  979. const toReadonly = (value) => isObject(value) ? readonly(value) : value;
  980. const COMPUTED_SIDE_EFFECT_WARN = `Computed is still dirty after getter evaluation, likely because a computed is mutating its own dependency in its getter. State mutations in computed getters should be avoided. Check the docs for more details: https://vuejs.org/guide/essentials/computed.html#getters-should-be-side-effect-free`;
  981. class ComputedRefImpl {
  982. constructor(getter, _setter, isReadonly, isSSR) {
  983. this.getter = getter;
  984. this._setter = _setter;
  985. this.dep = void 0;
  986. this.__v_isRef = true;
  987. this["__v_isReadonly"] = false;
  988. this.effect = new ReactiveEffect(
  989. () => getter(this._value),
  990. () => triggerRefValue(
  991. this,
  992. this.effect._dirtyLevel === 2 ? 2 : 3
  993. )
  994. );
  995. this.effect.computed = this;
  996. this.effect.active = this._cacheable = !isSSR;
  997. this["__v_isReadonly"] = isReadonly;
  998. }
  999. get value() {
  1000. const self = toRaw(this);
  1001. if ((!self._cacheable || self.effect.dirty) && hasChanged(self._value, self._value = self.effect.run())) {
  1002. triggerRefValue(self, 4);
  1003. }
  1004. trackRefValue(self);
  1005. if (self.effect._dirtyLevel >= 2) {
  1006. if (!!(process.env.NODE_ENV !== "production") && this._warnRecursive) {
  1007. warn(COMPUTED_SIDE_EFFECT_WARN, `
  1008. getter: `, this.getter);
  1009. }
  1010. triggerRefValue(self, 2);
  1011. }
  1012. return self._value;
  1013. }
  1014. set value(newValue) {
  1015. this._setter(newValue);
  1016. }
  1017. // #region polyfill _dirty for backward compatibility third party code for Vue <= 3.3.x
  1018. get _dirty() {
  1019. return this.effect.dirty;
  1020. }
  1021. set _dirty(v) {
  1022. this.effect.dirty = v;
  1023. }
  1024. // #endregion
  1025. }
  1026. function computed(getterOrOptions, debugOptions, isSSR = false) {
  1027. let getter;
  1028. let setter;
  1029. const onlyGetter = isFunction(getterOrOptions);
  1030. if (onlyGetter) {
  1031. getter = getterOrOptions;
  1032. setter = !!(process.env.NODE_ENV !== "production") ? () => {
  1033. warn("Write operation failed: computed value is readonly");
  1034. } : NOOP;
  1035. } else {
  1036. getter = getterOrOptions.get;
  1037. setter = getterOrOptions.set;
  1038. }
  1039. const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
  1040. if (!!(process.env.NODE_ENV !== "production") && debugOptions && !isSSR) {
  1041. cRef.effect.onTrack = debugOptions.onTrack;
  1042. cRef.effect.onTrigger = debugOptions.onTrigger;
  1043. }
  1044. return cRef;
  1045. }
  1046. function trackRefValue(ref2) {
  1047. var _a;
  1048. if (shouldTrack && activeEffect) {
  1049. ref2 = toRaw(ref2);
  1050. trackEffect(
  1051. activeEffect,
  1052. (_a = ref2.dep) != null ? _a : ref2.dep = createDep(
  1053. () => ref2.dep = void 0,
  1054. ref2 instanceof ComputedRefImpl ? ref2 : void 0
  1055. ),
  1056. !!(process.env.NODE_ENV !== "production") ? {
  1057. target: ref2,
  1058. type: "get",
  1059. key: "value"
  1060. } : void 0
  1061. );
  1062. }
  1063. }
  1064. function triggerRefValue(ref2, dirtyLevel = 4, newVal, oldVal) {
  1065. ref2 = toRaw(ref2);
  1066. const dep = ref2.dep;
  1067. if (dep) {
  1068. triggerEffects(
  1069. dep,
  1070. dirtyLevel,
  1071. !!(process.env.NODE_ENV !== "production") ? {
  1072. target: ref2,
  1073. type: "set",
  1074. key: "value",
  1075. newValue: newVal,
  1076. oldValue: oldVal
  1077. } : void 0
  1078. );
  1079. }
  1080. }
  1081. function isRef(r) {
  1082. return !!(r && r.__v_isRef === true);
  1083. }
  1084. function ref(value) {
  1085. return createRef(value, false);
  1086. }
  1087. function shallowRef(value) {
  1088. return createRef(value, true);
  1089. }
  1090. function createRef(rawValue, shallow) {
  1091. if (isRef(rawValue)) {
  1092. return rawValue;
  1093. }
  1094. return new RefImpl(rawValue, shallow);
  1095. }
  1096. class RefImpl {
  1097. constructor(value, __v_isShallow) {
  1098. this.__v_isShallow = __v_isShallow;
  1099. this.dep = void 0;
  1100. this.__v_isRef = true;
  1101. this._rawValue = __v_isShallow ? value : toRaw(value);
  1102. this._value = __v_isShallow ? value : toReactive(value);
  1103. }
  1104. get value() {
  1105. trackRefValue(this);
  1106. return this._value;
  1107. }
  1108. set value(newVal) {
  1109. const useDirectValue = this.__v_isShallow || isShallow(newVal) || isReadonly(newVal);
  1110. newVal = useDirectValue ? newVal : toRaw(newVal);
  1111. if (hasChanged(newVal, this._rawValue)) {
  1112. const oldVal = this._rawValue;
  1113. this._rawValue = newVal;
  1114. this._value = useDirectValue ? newVal : toReactive(newVal);
  1115. triggerRefValue(this, 4, newVal, oldVal);
  1116. }
  1117. }
  1118. }
  1119. function triggerRef(ref2) {
  1120. triggerRefValue(ref2, 4, !!(process.env.NODE_ENV !== "production") ? ref2.value : void 0);
  1121. }
  1122. function unref(ref2) {
  1123. return isRef(ref2) ? ref2.value : ref2;
  1124. }
  1125. function toValue(source) {
  1126. return isFunction(source) ? source() : unref(source);
  1127. }
  1128. const shallowUnwrapHandlers = {
  1129. get: (target, key, receiver) => unref(Reflect.get(target, key, receiver)),
  1130. set: (target, key, value, receiver) => {
  1131. const oldValue = target[key];
  1132. if (isRef(oldValue) && !isRef(value)) {
  1133. oldValue.value = value;
  1134. return true;
  1135. } else {
  1136. return Reflect.set(target, key, value, receiver);
  1137. }
  1138. }
  1139. };
  1140. function proxyRefs(objectWithRefs) {
  1141. return isReactive(objectWithRefs) ? objectWithRefs : new Proxy(objectWithRefs, shallowUnwrapHandlers);
  1142. }
  1143. class CustomRefImpl {
  1144. constructor(factory) {
  1145. this.dep = void 0;
  1146. this.__v_isRef = true;
  1147. const { get, set } = factory(
  1148. () => trackRefValue(this),
  1149. () => triggerRefValue(this)
  1150. );
  1151. this._get = get;
  1152. this._set = set;
  1153. }
  1154. get value() {
  1155. return this._get();
  1156. }
  1157. set value(newVal) {
  1158. this._set(newVal);
  1159. }
  1160. }
  1161. function customRef(factory) {
  1162. return new CustomRefImpl(factory);
  1163. }
  1164. function toRefs(object) {
  1165. if (!!(process.env.NODE_ENV !== "production") && !isProxy(object)) {
  1166. warn(`toRefs() expects a reactive object but received a plain one.`);
  1167. }
  1168. const ret = isArray(object) ? new Array(object.length) : {};
  1169. for (const key in object) {
  1170. ret[key] = propertyToRef(object, key);
  1171. }
  1172. return ret;
  1173. }
  1174. class ObjectRefImpl {
  1175. constructor(_object, _key, _defaultValue) {
  1176. this._object = _object;
  1177. this._key = _key;
  1178. this._defaultValue = _defaultValue;
  1179. this.__v_isRef = true;
  1180. }
  1181. get value() {
  1182. const val = this._object[this._key];
  1183. return val === void 0 ? this._defaultValue : val;
  1184. }
  1185. set value(newVal) {
  1186. this._object[this._key] = newVal;
  1187. }
  1188. get dep() {
  1189. return getDepFromReactive(toRaw(this._object), this._key);
  1190. }
  1191. }
  1192. class GetterRefImpl {
  1193. constructor(_getter) {
  1194. this._getter = _getter;
  1195. this.__v_isRef = true;
  1196. this.__v_isReadonly = true;
  1197. }
  1198. get value() {
  1199. return this._getter();
  1200. }
  1201. }
  1202. function toRef(source, key, defaultValue) {
  1203. if (isRef(source)) {
  1204. return source;
  1205. } else if (isFunction(source)) {
  1206. return new GetterRefImpl(source);
  1207. } else if (isObject(source) && arguments.length > 1) {
  1208. return propertyToRef(source, key, defaultValue);
  1209. } else {
  1210. return ref(source);
  1211. }
  1212. }
  1213. function propertyToRef(source, key, defaultValue) {
  1214. const val = source[key];
  1215. return isRef(val) ? val : new ObjectRefImpl(source, key, defaultValue);
  1216. }
  1217. const deferredComputed = computed;
  1218. const TrackOpTypes = {
  1219. "GET": "get",
  1220. "HAS": "has",
  1221. "ITERATE": "iterate"
  1222. };
  1223. const TriggerOpTypes = {
  1224. "SET": "set",
  1225. "ADD": "add",
  1226. "DELETE": "delete",
  1227. "CLEAR": "clear"
  1228. };
  1229. const ReactiveFlags = {
  1230. "SKIP": "__v_skip",
  1231. "IS_REACTIVE": "__v_isReactive",
  1232. "IS_READONLY": "__v_isReadonly",
  1233. "IS_SHALLOW": "__v_isShallow",
  1234. "RAW": "__v_raw"
  1235. };
  1236. export { EffectScope, ITERATE_KEY, ReactiveEffect, ReactiveFlags, TrackOpTypes, TriggerOpTypes, computed, customRef, deferredComputed, effect, effectScope, enableTracking, getCurrentScope, isProxy, isReactive, isReadonly, isRef, isShallow, markRaw, onScopeDispose, pauseScheduling, pauseTracking, proxyRefs, reactive, readonly, ref, resetScheduling, resetTracking, shallowReactive, shallowReadonly, shallowRef, stop, toRaw, toRef, toRefs, toValue, track, trigger, triggerRef, unref };