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-browser.js 35KB

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