@yiin/reactive-proxy-state 1.0.28 → 1.0.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +2549 -69
- package/dist/index.js +2552 -69
- package/dist/integrations/vue3.d.ts +5 -1
- package/dist/utils.d.ts +6 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,20 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
1
3
|
var __defProp = Object.defineProperty;
|
|
2
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __toESM = (mod, isNodeMode, target) => {
|
|
8
|
+
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
9
|
+
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
10
|
+
for (let key of __getOwnPropNames(mod))
|
|
11
|
+
if (!__hasOwnProp.call(to, key))
|
|
12
|
+
__defProp(to, key, {
|
|
13
|
+
get: () => mod[key],
|
|
14
|
+
enumerable: true
|
|
15
|
+
});
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
5
18
|
var __moduleCache = /* @__PURE__ */ new WeakMap;
|
|
6
19
|
var __toCommonJS = (from) => {
|
|
7
20
|
var entry = __moduleCache.get(from), desc;
|
|
@@ -16,6 +29,7 @@ var __toCommonJS = (from) => {
|
|
|
16
29
|
__moduleCache.set(from, entry);
|
|
17
30
|
return entry;
|
|
18
31
|
};
|
|
32
|
+
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
19
33
|
var __export = (target, all) => {
|
|
20
34
|
for (var name in all)
|
|
21
35
|
__defProp(target, name, {
|
|
@@ -24,7 +38,2291 @@ var __export = (target, all) => {
|
|
|
24
38
|
configurable: true,
|
|
25
39
|
set: (newValue) => all[name] = () => newValue
|
|
26
40
|
});
|
|
27
|
-
};
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// node_modules/@vue/shared/dist/shared.cjs.js
|
|
44
|
+
var require_shared_cjs = __commonJS((exports2) => {
|
|
45
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
46
|
+
/*! #__NO_SIDE_EFFECTS__ */
|
|
47
|
+
function makeMap(str) {
|
|
48
|
+
const map = /* @__PURE__ */ Object.create(null);
|
|
49
|
+
for (const key of str.split(","))
|
|
50
|
+
map[key] = 1;
|
|
51
|
+
return (val) => (val in map);
|
|
52
|
+
}
|
|
53
|
+
var EMPTY_OBJ = Object.freeze({});
|
|
54
|
+
var EMPTY_ARR = Object.freeze([]);
|
|
55
|
+
var NOOP = () => {};
|
|
56
|
+
var NO = () => false;
|
|
57
|
+
var isOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && (key.charCodeAt(2) > 122 || key.charCodeAt(2) < 97);
|
|
58
|
+
var isModelListener = (key) => key.startsWith("onUpdate:");
|
|
59
|
+
var extend = Object.assign;
|
|
60
|
+
var remove = (arr, el) => {
|
|
61
|
+
const i = arr.indexOf(el);
|
|
62
|
+
if (i > -1) {
|
|
63
|
+
arr.splice(i, 1);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
67
|
+
var hasOwn = (val, key) => hasOwnProperty.call(val, key);
|
|
68
|
+
var isArray = Array.isArray;
|
|
69
|
+
var isMap = (val) => toTypeString(val) === "[object Map]";
|
|
70
|
+
var isSet = (val) => toTypeString(val) === "[object Set]";
|
|
71
|
+
var isDate = (val) => toTypeString(val) === "[object Date]";
|
|
72
|
+
var isRegExp = (val) => toTypeString(val) === "[object RegExp]";
|
|
73
|
+
var isFunction = (val) => typeof val === "function";
|
|
74
|
+
var isString = (val) => typeof val === "string";
|
|
75
|
+
var isSymbol = (val) => typeof val === "symbol";
|
|
76
|
+
var isObject4 = (val) => val !== null && typeof val === "object";
|
|
77
|
+
var isPromise = (val) => {
|
|
78
|
+
return (isObject4(val) || isFunction(val)) && isFunction(val.then) && isFunction(val.catch);
|
|
79
|
+
};
|
|
80
|
+
var objectToString = Object.prototype.toString;
|
|
81
|
+
var toTypeString = (value) => objectToString.call(value);
|
|
82
|
+
var toRawType = (value) => {
|
|
83
|
+
return toTypeString(value).slice(8, -1);
|
|
84
|
+
};
|
|
85
|
+
var isPlainObject = (val) => toTypeString(val) === "[object Object]";
|
|
86
|
+
var isIntegerKey = (key) => isString(key) && key !== "NaN" && key[0] !== "-" && "" + parseInt(key, 10) === key;
|
|
87
|
+
var isReservedProp = /* @__PURE__ */ makeMap(",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted");
|
|
88
|
+
var isBuiltInDirective = /* @__PURE__ */ makeMap("bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo");
|
|
89
|
+
var cacheStringFunction = (fn) => {
|
|
90
|
+
const cache = /* @__PURE__ */ Object.create(null);
|
|
91
|
+
return (str) => {
|
|
92
|
+
const hit = cache[str];
|
|
93
|
+
return hit || (cache[str] = fn(str));
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
var camelizeRE = /-(\w)/g;
|
|
97
|
+
var camelize = cacheStringFunction((str) => {
|
|
98
|
+
return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : "");
|
|
99
|
+
});
|
|
100
|
+
var hyphenateRE = /\B([A-Z])/g;
|
|
101
|
+
var hyphenate = cacheStringFunction((str) => str.replace(hyphenateRE, "-$1").toLowerCase());
|
|
102
|
+
var capitalize = cacheStringFunction((str) => {
|
|
103
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
104
|
+
});
|
|
105
|
+
var toHandlerKey = cacheStringFunction((str) => {
|
|
106
|
+
const s = str ? `on${capitalize(str)}` : ``;
|
|
107
|
+
return s;
|
|
108
|
+
});
|
|
109
|
+
var hasChanged = (value, oldValue) => !Object.is(value, oldValue);
|
|
110
|
+
var invokeArrayFns = (fns, ...arg) => {
|
|
111
|
+
for (let i = 0;i < fns.length; i++) {
|
|
112
|
+
fns[i](...arg);
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
var def = (obj, key, value, writable = false) => {
|
|
116
|
+
Object.defineProperty(obj, key, {
|
|
117
|
+
configurable: true,
|
|
118
|
+
enumerable: false,
|
|
119
|
+
writable,
|
|
120
|
+
value
|
|
121
|
+
});
|
|
122
|
+
};
|
|
123
|
+
var looseToNumber = (val) => {
|
|
124
|
+
const n = parseFloat(val);
|
|
125
|
+
return isNaN(n) ? val : n;
|
|
126
|
+
};
|
|
127
|
+
var toNumber = (val) => {
|
|
128
|
+
const n = isString(val) ? Number(val) : NaN;
|
|
129
|
+
return isNaN(n) ? val : n;
|
|
130
|
+
};
|
|
131
|
+
var _globalThis;
|
|
132
|
+
var getGlobalThis = () => {
|
|
133
|
+
return _globalThis || (_globalThis = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : {});
|
|
134
|
+
};
|
|
135
|
+
var identRE = /^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/;
|
|
136
|
+
function genPropsAccessExp(name) {
|
|
137
|
+
return identRE.test(name) ? `__props.${name}` : `__props[${JSON.stringify(name)}]`;
|
|
138
|
+
}
|
|
139
|
+
function genCacheKey(source, options) {
|
|
140
|
+
return source + JSON.stringify(options, (_, val) => typeof val === "function" ? val.toString() : val);
|
|
141
|
+
}
|
|
142
|
+
var PatchFlags = {
|
|
143
|
+
TEXT: 1,
|
|
144
|
+
"1": "TEXT",
|
|
145
|
+
CLASS: 2,
|
|
146
|
+
"2": "CLASS",
|
|
147
|
+
STYLE: 4,
|
|
148
|
+
"4": "STYLE",
|
|
149
|
+
PROPS: 8,
|
|
150
|
+
"8": "PROPS",
|
|
151
|
+
FULL_PROPS: 16,
|
|
152
|
+
"16": "FULL_PROPS",
|
|
153
|
+
NEED_HYDRATION: 32,
|
|
154
|
+
"32": "NEED_HYDRATION",
|
|
155
|
+
STABLE_FRAGMENT: 64,
|
|
156
|
+
"64": "STABLE_FRAGMENT",
|
|
157
|
+
KEYED_FRAGMENT: 128,
|
|
158
|
+
"128": "KEYED_FRAGMENT",
|
|
159
|
+
UNKEYED_FRAGMENT: 256,
|
|
160
|
+
"256": "UNKEYED_FRAGMENT",
|
|
161
|
+
NEED_PATCH: 512,
|
|
162
|
+
"512": "NEED_PATCH",
|
|
163
|
+
DYNAMIC_SLOTS: 1024,
|
|
164
|
+
"1024": "DYNAMIC_SLOTS",
|
|
165
|
+
DEV_ROOT_FRAGMENT: 2048,
|
|
166
|
+
"2048": "DEV_ROOT_FRAGMENT",
|
|
167
|
+
CACHED: -1,
|
|
168
|
+
"-1": "CACHED",
|
|
169
|
+
BAIL: -2,
|
|
170
|
+
"-2": "BAIL"
|
|
171
|
+
};
|
|
172
|
+
var PatchFlagNames = {
|
|
173
|
+
[1]: `TEXT`,
|
|
174
|
+
[2]: `CLASS`,
|
|
175
|
+
[4]: `STYLE`,
|
|
176
|
+
[8]: `PROPS`,
|
|
177
|
+
[16]: `FULL_PROPS`,
|
|
178
|
+
[32]: `NEED_HYDRATION`,
|
|
179
|
+
[64]: `STABLE_FRAGMENT`,
|
|
180
|
+
[128]: `KEYED_FRAGMENT`,
|
|
181
|
+
[256]: `UNKEYED_FRAGMENT`,
|
|
182
|
+
[512]: `NEED_PATCH`,
|
|
183
|
+
[1024]: `DYNAMIC_SLOTS`,
|
|
184
|
+
[2048]: `DEV_ROOT_FRAGMENT`,
|
|
185
|
+
[-1]: `HOISTED`,
|
|
186
|
+
[-2]: `BAIL`
|
|
187
|
+
};
|
|
188
|
+
var ShapeFlags = {
|
|
189
|
+
ELEMENT: 1,
|
|
190
|
+
"1": "ELEMENT",
|
|
191
|
+
FUNCTIONAL_COMPONENT: 2,
|
|
192
|
+
"2": "FUNCTIONAL_COMPONENT",
|
|
193
|
+
STATEFUL_COMPONENT: 4,
|
|
194
|
+
"4": "STATEFUL_COMPONENT",
|
|
195
|
+
TEXT_CHILDREN: 8,
|
|
196
|
+
"8": "TEXT_CHILDREN",
|
|
197
|
+
ARRAY_CHILDREN: 16,
|
|
198
|
+
"16": "ARRAY_CHILDREN",
|
|
199
|
+
SLOTS_CHILDREN: 32,
|
|
200
|
+
"32": "SLOTS_CHILDREN",
|
|
201
|
+
TELEPORT: 64,
|
|
202
|
+
"64": "TELEPORT",
|
|
203
|
+
SUSPENSE: 128,
|
|
204
|
+
"128": "SUSPENSE",
|
|
205
|
+
COMPONENT_SHOULD_KEEP_ALIVE: 256,
|
|
206
|
+
"256": "COMPONENT_SHOULD_KEEP_ALIVE",
|
|
207
|
+
COMPONENT_KEPT_ALIVE: 512,
|
|
208
|
+
"512": "COMPONENT_KEPT_ALIVE",
|
|
209
|
+
COMPONENT: 6,
|
|
210
|
+
"6": "COMPONENT"
|
|
211
|
+
};
|
|
212
|
+
var SlotFlags = {
|
|
213
|
+
STABLE: 1,
|
|
214
|
+
"1": "STABLE",
|
|
215
|
+
DYNAMIC: 2,
|
|
216
|
+
"2": "DYNAMIC",
|
|
217
|
+
FORWARDED: 3,
|
|
218
|
+
"3": "FORWARDED"
|
|
219
|
+
};
|
|
220
|
+
var slotFlagsText = {
|
|
221
|
+
[1]: "STABLE",
|
|
222
|
+
[2]: "DYNAMIC",
|
|
223
|
+
[3]: "FORWARDED"
|
|
224
|
+
};
|
|
225
|
+
var GLOBALS_ALLOWED = "Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,console,Error,Symbol";
|
|
226
|
+
var isGloballyAllowed = /* @__PURE__ */ makeMap(GLOBALS_ALLOWED);
|
|
227
|
+
var isGloballyWhitelisted = isGloballyAllowed;
|
|
228
|
+
var range = 2;
|
|
229
|
+
function generateCodeFrame(source, start = 0, end = source.length) {
|
|
230
|
+
start = Math.max(0, Math.min(start, source.length));
|
|
231
|
+
end = Math.max(0, Math.min(end, source.length));
|
|
232
|
+
if (start > end)
|
|
233
|
+
return "";
|
|
234
|
+
let lines = source.split(/(\r?\n)/);
|
|
235
|
+
const newlineSequences = lines.filter((_, idx) => idx % 2 === 1);
|
|
236
|
+
lines = lines.filter((_, idx) => idx % 2 === 0);
|
|
237
|
+
let count = 0;
|
|
238
|
+
const res = [];
|
|
239
|
+
for (let i = 0;i < lines.length; i++) {
|
|
240
|
+
count += lines[i].length + (newlineSequences[i] && newlineSequences[i].length || 0);
|
|
241
|
+
if (count >= start) {
|
|
242
|
+
for (let j = i - range;j <= i + range || end > count; j++) {
|
|
243
|
+
if (j < 0 || j >= lines.length)
|
|
244
|
+
continue;
|
|
245
|
+
const line = j + 1;
|
|
246
|
+
res.push(`${line}${" ".repeat(Math.max(3 - String(line).length, 0))}| ${lines[j]}`);
|
|
247
|
+
const lineLength = lines[j].length;
|
|
248
|
+
const newLineSeqLength = newlineSequences[j] && newlineSequences[j].length || 0;
|
|
249
|
+
if (j === i) {
|
|
250
|
+
const pad = start - (count - (lineLength + newLineSeqLength));
|
|
251
|
+
const length = Math.max(1, end > count ? lineLength - pad : end - start);
|
|
252
|
+
res.push(` | ` + " ".repeat(pad) + "^".repeat(length));
|
|
253
|
+
} else if (j > i) {
|
|
254
|
+
if (end > count) {
|
|
255
|
+
const length = Math.max(Math.min(end - count, lineLength), 1);
|
|
256
|
+
res.push(` | ` + "^".repeat(length));
|
|
257
|
+
}
|
|
258
|
+
count += lineLength + newLineSeqLength;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
break;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
return res.join(`
|
|
265
|
+
`);
|
|
266
|
+
}
|
|
267
|
+
function normalizeStyle(value) {
|
|
268
|
+
if (isArray(value)) {
|
|
269
|
+
const res = {};
|
|
270
|
+
for (let i = 0;i < value.length; i++) {
|
|
271
|
+
const item = value[i];
|
|
272
|
+
const normalized = isString(item) ? parseStringStyle(item) : normalizeStyle(item);
|
|
273
|
+
if (normalized) {
|
|
274
|
+
for (const key in normalized) {
|
|
275
|
+
res[key] = normalized[key];
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
return res;
|
|
280
|
+
} else if (isString(value) || isObject4(value)) {
|
|
281
|
+
return value;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
var listDelimiterRE = /;(?![^(]*\))/g;
|
|
285
|
+
var propertyDelimiterRE = /:([^]+)/;
|
|
286
|
+
var styleCommentRE = /\/\*[^]*?\*\//g;
|
|
287
|
+
function parseStringStyle(cssText) {
|
|
288
|
+
const ret = {};
|
|
289
|
+
cssText.replace(styleCommentRE, "").split(listDelimiterRE).forEach((item) => {
|
|
290
|
+
if (item) {
|
|
291
|
+
const tmp = item.split(propertyDelimiterRE);
|
|
292
|
+
tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
return ret;
|
|
296
|
+
}
|
|
297
|
+
function stringifyStyle(styles) {
|
|
298
|
+
if (!styles)
|
|
299
|
+
return "";
|
|
300
|
+
if (isString(styles))
|
|
301
|
+
return styles;
|
|
302
|
+
let ret = "";
|
|
303
|
+
for (const key in styles) {
|
|
304
|
+
const value = styles[key];
|
|
305
|
+
if (isString(value) || typeof value === "number") {
|
|
306
|
+
const normalizedKey = key.startsWith(`--`) ? key : hyphenate(key);
|
|
307
|
+
ret += `${normalizedKey}:${value};`;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
return ret;
|
|
311
|
+
}
|
|
312
|
+
function normalizeClass(value) {
|
|
313
|
+
let res = "";
|
|
314
|
+
if (isString(value)) {
|
|
315
|
+
res = value;
|
|
316
|
+
} else if (isArray(value)) {
|
|
317
|
+
for (let i = 0;i < value.length; i++) {
|
|
318
|
+
const normalized = normalizeClass(value[i]);
|
|
319
|
+
if (normalized) {
|
|
320
|
+
res += normalized + " ";
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
} else if (isObject4(value)) {
|
|
324
|
+
for (const name in value) {
|
|
325
|
+
if (value[name]) {
|
|
326
|
+
res += name + " ";
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
return res.trim();
|
|
331
|
+
}
|
|
332
|
+
function normalizeProps(props) {
|
|
333
|
+
if (!props)
|
|
334
|
+
return null;
|
|
335
|
+
let { class: klass, style } = props;
|
|
336
|
+
if (klass && !isString(klass)) {
|
|
337
|
+
props.class = normalizeClass(klass);
|
|
338
|
+
}
|
|
339
|
+
if (style) {
|
|
340
|
+
props.style = normalizeStyle(style);
|
|
341
|
+
}
|
|
342
|
+
return props;
|
|
343
|
+
}
|
|
344
|
+
var HTML_TAGS = "html,body,base,head,link,meta,style,title,address,article,aside,footer,header,hgroup,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,output,progress,select,textarea,details,dialog,menu,summary,template,blockquote,iframe,tfoot";
|
|
345
|
+
var SVG_TAGS = "svg,animate,animateMotion,animateTransform,circle,clipPath,color-profile,defs,desc,discard,ellipse,feBlend,feColorMatrix,feComponentTransfer,feComposite,feConvolveMatrix,feDiffuseLighting,feDisplacementMap,feDistantLight,feDropShadow,feFlood,feFuncA,feFuncB,feFuncG,feFuncR,feGaussianBlur,feImage,feMerge,feMergeNode,feMorphology,feOffset,fePointLight,feSpecularLighting,feSpotLight,feTile,feTurbulence,filter,foreignObject,g,hatch,hatchpath,image,line,linearGradient,marker,mask,mesh,meshgradient,meshpatch,meshrow,metadata,mpath,path,pattern,polygon,polyline,radialGradient,rect,set,solidcolor,stop,switch,symbol,text,textPath,title,tspan,unknown,use,view";
|
|
346
|
+
var MATH_TAGS = "annotation,annotation-xml,maction,maligngroup,malignmark,math,menclose,merror,mfenced,mfrac,mfraction,mglyph,mi,mlabeledtr,mlongdiv,mmultiscripts,mn,mo,mover,mpadded,mphantom,mprescripts,mroot,mrow,ms,mscarries,mscarry,msgroup,msline,mspace,msqrt,msrow,mstack,mstyle,msub,msubsup,msup,mtable,mtd,mtext,mtr,munder,munderover,none,semantics";
|
|
347
|
+
var VOID_TAGS = "area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr";
|
|
348
|
+
var isHTMLTag = /* @__PURE__ */ makeMap(HTML_TAGS);
|
|
349
|
+
var isSVGTag = /* @__PURE__ */ makeMap(SVG_TAGS);
|
|
350
|
+
var isMathMLTag = /* @__PURE__ */ makeMap(MATH_TAGS);
|
|
351
|
+
var isVoidTag = /* @__PURE__ */ makeMap(VOID_TAGS);
|
|
352
|
+
var specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
|
|
353
|
+
var isSpecialBooleanAttr = /* @__PURE__ */ makeMap(specialBooleanAttrs);
|
|
354
|
+
var isBooleanAttr = /* @__PURE__ */ makeMap(specialBooleanAttrs + `,async,autofocus,autoplay,controls,default,defer,disabled,hidden,inert,loop,open,required,reversed,scoped,seamless,checked,muted,multiple,selected`);
|
|
355
|
+
function includeBooleanAttr(value) {
|
|
356
|
+
return !!value || value === "";
|
|
357
|
+
}
|
|
358
|
+
var unsafeAttrCharRE = /[>/="'\u0009\u000a\u000c\u0020]/;
|
|
359
|
+
var attrValidationCache = {};
|
|
360
|
+
function isSSRSafeAttrName(name) {
|
|
361
|
+
if (attrValidationCache.hasOwnProperty(name)) {
|
|
362
|
+
return attrValidationCache[name];
|
|
363
|
+
}
|
|
364
|
+
const isUnsafe = unsafeAttrCharRE.test(name);
|
|
365
|
+
if (isUnsafe) {
|
|
366
|
+
console.error(`unsafe attribute name: ${name}`);
|
|
367
|
+
}
|
|
368
|
+
return attrValidationCache[name] = !isUnsafe;
|
|
369
|
+
}
|
|
370
|
+
var propsToAttrMap = {
|
|
371
|
+
acceptCharset: "accept-charset",
|
|
372
|
+
className: "class",
|
|
373
|
+
htmlFor: "for",
|
|
374
|
+
httpEquiv: "http-equiv"
|
|
375
|
+
};
|
|
376
|
+
var isKnownHtmlAttr = /* @__PURE__ */ makeMap(`accept,accept-charset,accesskey,action,align,allow,alt,async,autocapitalize,autocomplete,autofocus,autoplay,background,bgcolor,border,buffered,capture,challenge,charset,checked,cite,class,code,codebase,color,cols,colspan,content,contenteditable,contextmenu,controls,coords,crossorigin,csp,data,datetime,decoding,default,defer,dir,dirname,disabled,download,draggable,dropzone,enctype,enterkeyhint,for,form,formaction,formenctype,formmethod,formnovalidate,formtarget,headers,height,hidden,high,href,hreflang,http-equiv,icon,id,importance,inert,integrity,ismap,itemprop,keytype,kind,label,lang,language,loading,list,loop,low,manifest,max,maxlength,minlength,media,min,multiple,muted,name,novalidate,open,optimum,pattern,ping,placeholder,poster,preload,radiogroup,readonly,referrerpolicy,rel,required,reversed,rows,rowspan,sandbox,scope,scoped,selected,shape,size,sizes,slot,span,spellcheck,src,srcdoc,srclang,srcset,start,step,style,summary,tabindex,target,title,translate,type,usemap,value,width,wrap`);
|
|
377
|
+
var isKnownSvgAttr = /* @__PURE__ */ makeMap(`xmlns,accent-height,accumulate,additive,alignment-baseline,alphabetic,amplitude,arabic-form,ascent,attributeName,attributeType,azimuth,baseFrequency,baseline-shift,baseProfile,bbox,begin,bias,by,calcMode,cap-height,class,clip,clipPathUnits,clip-path,clip-rule,color,color-interpolation,color-interpolation-filters,color-profile,color-rendering,contentScriptType,contentStyleType,crossorigin,cursor,cx,cy,d,decelerate,descent,diffuseConstant,direction,display,divisor,dominant-baseline,dur,dx,dy,edgeMode,elevation,enable-background,end,exponent,fill,fill-opacity,fill-rule,filter,filterRes,filterUnits,flood-color,flood-opacity,font-family,font-size,font-size-adjust,font-stretch,font-style,font-variant,font-weight,format,from,fr,fx,fy,g1,g2,glyph-name,glyph-orientation-horizontal,glyph-orientation-vertical,glyphRef,gradientTransform,gradientUnits,hanging,height,href,hreflang,horiz-adv-x,horiz-origin-x,id,ideographic,image-rendering,in,in2,intercept,k,k1,k2,k3,k4,kernelMatrix,kernelUnitLength,kerning,keyPoints,keySplines,keyTimes,lang,lengthAdjust,letter-spacing,lighting-color,limitingConeAngle,local,marker-end,marker-mid,marker-start,markerHeight,markerUnits,markerWidth,mask,maskContentUnits,maskUnits,mathematical,max,media,method,min,mode,name,numOctaves,offset,opacity,operator,order,orient,orientation,origin,overflow,overline-position,overline-thickness,panose-1,paint-order,path,pathLength,patternContentUnits,patternTransform,patternUnits,ping,pointer-events,points,pointsAtX,pointsAtY,pointsAtZ,preserveAlpha,preserveAspectRatio,primitiveUnits,r,radius,referrerPolicy,refX,refY,rel,rendering-intent,repeatCount,repeatDur,requiredExtensions,requiredFeatures,restart,result,rotate,rx,ry,scale,seed,shape-rendering,slope,spacing,specularConstant,specularExponent,speed,spreadMethod,startOffset,stdDeviation,stemh,stemv,stitchTiles,stop-color,stop-opacity,strikethrough-position,strikethrough-thickness,string,stroke,stroke-dasharray,stroke-dashoffset,stroke-linecap,stroke-linejoin,stroke-miterlimit,stroke-opacity,stroke-width,style,surfaceScale,systemLanguage,tabindex,tableValues,target,targetX,targetY,text-anchor,text-decoration,text-rendering,textLength,to,transform,transform-origin,type,u1,u2,underline-position,underline-thickness,unicode,unicode-bidi,unicode-range,units-per-em,v-alphabetic,v-hanging,v-ideographic,v-mathematical,values,vector-effect,version,vert-adv-y,vert-origin-x,vert-origin-y,viewBox,viewTarget,visibility,width,widths,word-spacing,writing-mode,x,x-height,x1,x2,xChannelSelector,xlink:actuate,xlink:arcrole,xlink:href,xlink:role,xlink:show,xlink:title,xlink:type,xmlns:xlink,xml:base,xml:lang,xml:space,y,y1,y2,yChannelSelector,z,zoomAndPan`);
|
|
378
|
+
var isKnownMathMLAttr = /* @__PURE__ */ makeMap(`accent,accentunder,actiontype,align,alignmentscope,altimg,altimg-height,altimg-valign,altimg-width,alttext,bevelled,close,columnsalign,columnlines,columnspan,denomalign,depth,dir,display,displaystyle,encoding,equalcolumns,equalrows,fence,fontstyle,fontweight,form,frame,framespacing,groupalign,height,href,id,indentalign,indentalignfirst,indentalignlast,indentshift,indentshiftfirst,indentshiftlast,indextype,justify,largetop,largeop,lquote,lspace,mathbackground,mathcolor,mathsize,mathvariant,maxsize,minlabelspacing,mode,other,overflow,position,rowalign,rowlines,rowspan,rquote,rspace,scriptlevel,scriptminsize,scriptsizemultiplier,selection,separator,separators,shift,side,src,stackalign,stretchy,subscriptshift,superscriptshift,symmetric,voffset,width,widths,xlink:href,xlink:show,xlink:type,xmlns`);
|
|
379
|
+
function isRenderableAttrValue(value) {
|
|
380
|
+
if (value == null) {
|
|
381
|
+
return false;
|
|
382
|
+
}
|
|
383
|
+
const type = typeof value;
|
|
384
|
+
return type === "string" || type === "number" || type === "boolean";
|
|
385
|
+
}
|
|
386
|
+
var escapeRE = /["'&<>]/;
|
|
387
|
+
function escapeHtml(string) {
|
|
388
|
+
const str = "" + string;
|
|
389
|
+
const match = escapeRE.exec(str);
|
|
390
|
+
if (!match) {
|
|
391
|
+
return str;
|
|
392
|
+
}
|
|
393
|
+
let html = "";
|
|
394
|
+
let escaped;
|
|
395
|
+
let index;
|
|
396
|
+
let lastIndex = 0;
|
|
397
|
+
for (index = match.index;index < str.length; index++) {
|
|
398
|
+
switch (str.charCodeAt(index)) {
|
|
399
|
+
case 34:
|
|
400
|
+
escaped = """;
|
|
401
|
+
break;
|
|
402
|
+
case 38:
|
|
403
|
+
escaped = "&";
|
|
404
|
+
break;
|
|
405
|
+
case 39:
|
|
406
|
+
escaped = "'";
|
|
407
|
+
break;
|
|
408
|
+
case 60:
|
|
409
|
+
escaped = "<";
|
|
410
|
+
break;
|
|
411
|
+
case 62:
|
|
412
|
+
escaped = ">";
|
|
413
|
+
break;
|
|
414
|
+
default:
|
|
415
|
+
continue;
|
|
416
|
+
}
|
|
417
|
+
if (lastIndex !== index) {
|
|
418
|
+
html += str.slice(lastIndex, index);
|
|
419
|
+
}
|
|
420
|
+
lastIndex = index + 1;
|
|
421
|
+
html += escaped;
|
|
422
|
+
}
|
|
423
|
+
return lastIndex !== index ? html + str.slice(lastIndex, index) : html;
|
|
424
|
+
}
|
|
425
|
+
var commentStripRE = /^-?>|<!--|-->|--!>|<!-$/g;
|
|
426
|
+
function escapeHtmlComment(src) {
|
|
427
|
+
return src.replace(commentStripRE, "");
|
|
428
|
+
}
|
|
429
|
+
var cssVarNameEscapeSymbolsRE = /[ !"#$%&'()*+,./:;<=>?@[\\\]^`{|}~]/g;
|
|
430
|
+
function getEscapedCssVarName(key, doubleEscape) {
|
|
431
|
+
return key.replace(cssVarNameEscapeSymbolsRE, (s) => doubleEscape ? s === '"' ? "\\\\\\\"" : `\\\\${s}` : `\\${s}`);
|
|
432
|
+
}
|
|
433
|
+
function looseCompareArrays(a, b) {
|
|
434
|
+
if (a.length !== b.length)
|
|
435
|
+
return false;
|
|
436
|
+
let equal = true;
|
|
437
|
+
for (let i = 0;equal && i < a.length; i++) {
|
|
438
|
+
equal = looseEqual(a[i], b[i]);
|
|
439
|
+
}
|
|
440
|
+
return equal;
|
|
441
|
+
}
|
|
442
|
+
function looseEqual(a, b) {
|
|
443
|
+
if (a === b)
|
|
444
|
+
return true;
|
|
445
|
+
let aValidType = isDate(a);
|
|
446
|
+
let bValidType = isDate(b);
|
|
447
|
+
if (aValidType || bValidType) {
|
|
448
|
+
return aValidType && bValidType ? a.getTime() === b.getTime() : false;
|
|
449
|
+
}
|
|
450
|
+
aValidType = isSymbol(a);
|
|
451
|
+
bValidType = isSymbol(b);
|
|
452
|
+
if (aValidType || bValidType) {
|
|
453
|
+
return a === b;
|
|
454
|
+
}
|
|
455
|
+
aValidType = isArray(a);
|
|
456
|
+
bValidType = isArray(b);
|
|
457
|
+
if (aValidType || bValidType) {
|
|
458
|
+
return aValidType && bValidType ? looseCompareArrays(a, b) : false;
|
|
459
|
+
}
|
|
460
|
+
aValidType = isObject4(a);
|
|
461
|
+
bValidType = isObject4(b);
|
|
462
|
+
if (aValidType || bValidType) {
|
|
463
|
+
if (!aValidType || !bValidType) {
|
|
464
|
+
return false;
|
|
465
|
+
}
|
|
466
|
+
const aKeysCount = Object.keys(a).length;
|
|
467
|
+
const bKeysCount = Object.keys(b).length;
|
|
468
|
+
if (aKeysCount !== bKeysCount) {
|
|
469
|
+
return false;
|
|
470
|
+
}
|
|
471
|
+
for (const key in a) {
|
|
472
|
+
const aHasKey = a.hasOwnProperty(key);
|
|
473
|
+
const bHasKey = b.hasOwnProperty(key);
|
|
474
|
+
if (aHasKey && !bHasKey || !aHasKey && bHasKey || !looseEqual(a[key], b[key])) {
|
|
475
|
+
return false;
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
return String(a) === String(b);
|
|
480
|
+
}
|
|
481
|
+
function looseIndexOf(arr, val) {
|
|
482
|
+
return arr.findIndex((item) => looseEqual(item, val));
|
|
483
|
+
}
|
|
484
|
+
var isRef3 = (val) => {
|
|
485
|
+
return !!(val && val["__v_isRef"] === true);
|
|
486
|
+
};
|
|
487
|
+
var toDisplayString = (val) => {
|
|
488
|
+
return isString(val) ? val : val == null ? "" : isArray(val) || isObject4(val) && (val.toString === objectToString || !isFunction(val.toString)) ? isRef3(val) ? toDisplayString(val.value) : JSON.stringify(val, replacer, 2) : String(val);
|
|
489
|
+
};
|
|
490
|
+
var replacer = (_key, val) => {
|
|
491
|
+
if (isRef3(val)) {
|
|
492
|
+
return replacer(_key, val.value);
|
|
493
|
+
} else if (isMap(val)) {
|
|
494
|
+
return {
|
|
495
|
+
[`Map(${val.size})`]: [...val.entries()].reduce((entries, [key, val2], i) => {
|
|
496
|
+
entries[stringifySymbol(key, i) + " =>"] = val2;
|
|
497
|
+
return entries;
|
|
498
|
+
}, {})
|
|
499
|
+
};
|
|
500
|
+
} else if (isSet(val)) {
|
|
501
|
+
return {
|
|
502
|
+
[`Set(${val.size})`]: [...val.values()].map((v) => stringifySymbol(v))
|
|
503
|
+
};
|
|
504
|
+
} else if (isSymbol(val)) {
|
|
505
|
+
return stringifySymbol(val);
|
|
506
|
+
} else if (isObject4(val) && !isArray(val) && !isPlainObject(val)) {
|
|
507
|
+
return String(val);
|
|
508
|
+
}
|
|
509
|
+
return val;
|
|
510
|
+
};
|
|
511
|
+
var stringifySymbol = (v, i = "") => {
|
|
512
|
+
var _a;
|
|
513
|
+
return isSymbol(v) ? `Symbol(${(_a = v.description) != null ? _a : i})` : v;
|
|
514
|
+
};
|
|
515
|
+
exports2.EMPTY_ARR = EMPTY_ARR;
|
|
516
|
+
exports2.EMPTY_OBJ = EMPTY_OBJ;
|
|
517
|
+
exports2.NO = NO;
|
|
518
|
+
exports2.NOOP = NOOP;
|
|
519
|
+
exports2.PatchFlagNames = PatchFlagNames;
|
|
520
|
+
exports2.PatchFlags = PatchFlags;
|
|
521
|
+
exports2.ShapeFlags = ShapeFlags;
|
|
522
|
+
exports2.SlotFlags = SlotFlags;
|
|
523
|
+
exports2.camelize = camelize;
|
|
524
|
+
exports2.capitalize = capitalize;
|
|
525
|
+
exports2.cssVarNameEscapeSymbolsRE = cssVarNameEscapeSymbolsRE;
|
|
526
|
+
exports2.def = def;
|
|
527
|
+
exports2.escapeHtml = escapeHtml;
|
|
528
|
+
exports2.escapeHtmlComment = escapeHtmlComment;
|
|
529
|
+
exports2.extend = extend;
|
|
530
|
+
exports2.genCacheKey = genCacheKey;
|
|
531
|
+
exports2.genPropsAccessExp = genPropsAccessExp;
|
|
532
|
+
exports2.generateCodeFrame = generateCodeFrame;
|
|
533
|
+
exports2.getEscapedCssVarName = getEscapedCssVarName;
|
|
534
|
+
exports2.getGlobalThis = getGlobalThis;
|
|
535
|
+
exports2.hasChanged = hasChanged;
|
|
536
|
+
exports2.hasOwn = hasOwn;
|
|
537
|
+
exports2.hyphenate = hyphenate;
|
|
538
|
+
exports2.includeBooleanAttr = includeBooleanAttr;
|
|
539
|
+
exports2.invokeArrayFns = invokeArrayFns;
|
|
540
|
+
exports2.isArray = isArray;
|
|
541
|
+
exports2.isBooleanAttr = isBooleanAttr;
|
|
542
|
+
exports2.isBuiltInDirective = isBuiltInDirective;
|
|
543
|
+
exports2.isDate = isDate;
|
|
544
|
+
exports2.isFunction = isFunction;
|
|
545
|
+
exports2.isGloballyAllowed = isGloballyAllowed;
|
|
546
|
+
exports2.isGloballyWhitelisted = isGloballyWhitelisted;
|
|
547
|
+
exports2.isHTMLTag = isHTMLTag;
|
|
548
|
+
exports2.isIntegerKey = isIntegerKey;
|
|
549
|
+
exports2.isKnownHtmlAttr = isKnownHtmlAttr;
|
|
550
|
+
exports2.isKnownMathMLAttr = isKnownMathMLAttr;
|
|
551
|
+
exports2.isKnownSvgAttr = isKnownSvgAttr;
|
|
552
|
+
exports2.isMap = isMap;
|
|
553
|
+
exports2.isMathMLTag = isMathMLTag;
|
|
554
|
+
exports2.isModelListener = isModelListener;
|
|
555
|
+
exports2.isObject = isObject4;
|
|
556
|
+
exports2.isOn = isOn;
|
|
557
|
+
exports2.isPlainObject = isPlainObject;
|
|
558
|
+
exports2.isPromise = isPromise;
|
|
559
|
+
exports2.isRegExp = isRegExp;
|
|
560
|
+
exports2.isRenderableAttrValue = isRenderableAttrValue;
|
|
561
|
+
exports2.isReservedProp = isReservedProp;
|
|
562
|
+
exports2.isSSRSafeAttrName = isSSRSafeAttrName;
|
|
563
|
+
exports2.isSVGTag = isSVGTag;
|
|
564
|
+
exports2.isSet = isSet;
|
|
565
|
+
exports2.isSpecialBooleanAttr = isSpecialBooleanAttr;
|
|
566
|
+
exports2.isString = isString;
|
|
567
|
+
exports2.isSymbol = isSymbol;
|
|
568
|
+
exports2.isVoidTag = isVoidTag;
|
|
569
|
+
exports2.looseEqual = looseEqual;
|
|
570
|
+
exports2.looseIndexOf = looseIndexOf;
|
|
571
|
+
exports2.looseToNumber = looseToNumber;
|
|
572
|
+
exports2.makeMap = makeMap;
|
|
573
|
+
exports2.normalizeClass = normalizeClass;
|
|
574
|
+
exports2.normalizeProps = normalizeProps;
|
|
575
|
+
exports2.normalizeStyle = normalizeStyle;
|
|
576
|
+
exports2.objectToString = objectToString;
|
|
577
|
+
exports2.parseStringStyle = parseStringStyle;
|
|
578
|
+
exports2.propsToAttrMap = propsToAttrMap;
|
|
579
|
+
exports2.remove = remove;
|
|
580
|
+
exports2.slotFlagsText = slotFlagsText;
|
|
581
|
+
exports2.stringifyStyle = stringifyStyle;
|
|
582
|
+
exports2.toDisplayString = toDisplayString;
|
|
583
|
+
exports2.toHandlerKey = toHandlerKey;
|
|
584
|
+
exports2.toNumber = toNumber;
|
|
585
|
+
exports2.toRawType = toRawType;
|
|
586
|
+
exports2.toTypeString = toTypeString;
|
|
587
|
+
});
|
|
588
|
+
|
|
589
|
+
// node_modules/@vue/reactivity/dist/reactivity.cjs.js
|
|
590
|
+
var require_reactivity_cjs = __commonJS((exports2) => {
|
|
591
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
592
|
+
var shared = require_shared_cjs();
|
|
593
|
+
function warn(msg, ...args) {
|
|
594
|
+
console.warn(`[Vue warn] ${msg}`, ...args);
|
|
595
|
+
}
|
|
596
|
+
var activeEffectScope;
|
|
597
|
+
|
|
598
|
+
class EffectScope {
|
|
599
|
+
constructor(detached = false) {
|
|
600
|
+
this.detached = detached;
|
|
601
|
+
this._active = true;
|
|
602
|
+
this.effects = [];
|
|
603
|
+
this.cleanups = [];
|
|
604
|
+
this._isPaused = false;
|
|
605
|
+
this.parent = activeEffectScope;
|
|
606
|
+
if (!detached && activeEffectScope) {
|
|
607
|
+
this.index = (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(this) - 1;
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
get active() {
|
|
611
|
+
return this._active;
|
|
612
|
+
}
|
|
613
|
+
pause() {
|
|
614
|
+
if (this._active) {
|
|
615
|
+
this._isPaused = true;
|
|
616
|
+
let i, l;
|
|
617
|
+
if (this.scopes) {
|
|
618
|
+
for (i = 0, l = this.scopes.length;i < l; i++) {
|
|
619
|
+
this.scopes[i].pause();
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
for (i = 0, l = this.effects.length;i < l; i++) {
|
|
623
|
+
this.effects[i].pause();
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
resume() {
|
|
628
|
+
if (this._active) {
|
|
629
|
+
if (this._isPaused) {
|
|
630
|
+
this._isPaused = false;
|
|
631
|
+
let i, l;
|
|
632
|
+
if (this.scopes) {
|
|
633
|
+
for (i = 0, l = this.scopes.length;i < l; i++) {
|
|
634
|
+
this.scopes[i].resume();
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
for (i = 0, l = this.effects.length;i < l; i++) {
|
|
638
|
+
this.effects[i].resume();
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
run(fn) {
|
|
644
|
+
if (this._active) {
|
|
645
|
+
const currentEffectScope = activeEffectScope;
|
|
646
|
+
try {
|
|
647
|
+
activeEffectScope = this;
|
|
648
|
+
return fn();
|
|
649
|
+
} finally {
|
|
650
|
+
activeEffectScope = currentEffectScope;
|
|
651
|
+
}
|
|
652
|
+
} else {
|
|
653
|
+
warn(`cannot run an inactive effect scope.`);
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
on() {
|
|
657
|
+
activeEffectScope = this;
|
|
658
|
+
}
|
|
659
|
+
off() {
|
|
660
|
+
activeEffectScope = this.parent;
|
|
661
|
+
}
|
|
662
|
+
stop(fromParent) {
|
|
663
|
+
if (this._active) {
|
|
664
|
+
this._active = false;
|
|
665
|
+
let i, l;
|
|
666
|
+
for (i = 0, l = this.effects.length;i < l; i++) {
|
|
667
|
+
this.effects[i].stop();
|
|
668
|
+
}
|
|
669
|
+
this.effects.length = 0;
|
|
670
|
+
for (i = 0, l = this.cleanups.length;i < l; i++) {
|
|
671
|
+
this.cleanups[i]();
|
|
672
|
+
}
|
|
673
|
+
this.cleanups.length = 0;
|
|
674
|
+
if (this.scopes) {
|
|
675
|
+
for (i = 0, l = this.scopes.length;i < l; i++) {
|
|
676
|
+
this.scopes[i].stop(true);
|
|
677
|
+
}
|
|
678
|
+
this.scopes.length = 0;
|
|
679
|
+
}
|
|
680
|
+
if (!this.detached && this.parent && !fromParent) {
|
|
681
|
+
const last = this.parent.scopes.pop();
|
|
682
|
+
if (last && last !== this) {
|
|
683
|
+
this.parent.scopes[this.index] = last;
|
|
684
|
+
last.index = this.index;
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
this.parent = undefined;
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
function effectScope(detached) {
|
|
692
|
+
return new EffectScope(detached);
|
|
693
|
+
}
|
|
694
|
+
function getCurrentScope() {
|
|
695
|
+
return activeEffectScope;
|
|
696
|
+
}
|
|
697
|
+
function onScopeDispose(fn, failSilently = false) {
|
|
698
|
+
if (activeEffectScope) {
|
|
699
|
+
activeEffectScope.cleanups.push(fn);
|
|
700
|
+
} else if (!failSilently) {
|
|
701
|
+
warn(`onScopeDispose() is called when there is no active effect scope to be associated with.`);
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
var activeSub;
|
|
705
|
+
var EffectFlags = {
|
|
706
|
+
ACTIVE: 1,
|
|
707
|
+
"1": "ACTIVE",
|
|
708
|
+
RUNNING: 2,
|
|
709
|
+
"2": "RUNNING",
|
|
710
|
+
TRACKING: 4,
|
|
711
|
+
"4": "TRACKING",
|
|
712
|
+
NOTIFIED: 8,
|
|
713
|
+
"8": "NOTIFIED",
|
|
714
|
+
DIRTY: 16,
|
|
715
|
+
"16": "DIRTY",
|
|
716
|
+
ALLOW_RECURSE: 32,
|
|
717
|
+
"32": "ALLOW_RECURSE",
|
|
718
|
+
PAUSED: 64,
|
|
719
|
+
"64": "PAUSED"
|
|
720
|
+
};
|
|
721
|
+
var pausedQueueEffects = /* @__PURE__ */ new WeakSet;
|
|
722
|
+
|
|
723
|
+
class ReactiveEffect {
|
|
724
|
+
constructor(fn) {
|
|
725
|
+
this.fn = fn;
|
|
726
|
+
this.deps = undefined;
|
|
727
|
+
this.depsTail = undefined;
|
|
728
|
+
this.flags = 1 | 4;
|
|
729
|
+
this.next = undefined;
|
|
730
|
+
this.cleanup = undefined;
|
|
731
|
+
this.scheduler = undefined;
|
|
732
|
+
if (activeEffectScope && activeEffectScope.active) {
|
|
733
|
+
activeEffectScope.effects.push(this);
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
pause() {
|
|
737
|
+
this.flags |= 64;
|
|
738
|
+
}
|
|
739
|
+
resume() {
|
|
740
|
+
if (this.flags & 64) {
|
|
741
|
+
this.flags &= ~64;
|
|
742
|
+
if (pausedQueueEffects.has(this)) {
|
|
743
|
+
pausedQueueEffects.delete(this);
|
|
744
|
+
this.trigger();
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
notify() {
|
|
749
|
+
if (this.flags & 2 && !(this.flags & 32)) {
|
|
750
|
+
return;
|
|
751
|
+
}
|
|
752
|
+
if (!(this.flags & 8)) {
|
|
753
|
+
batch(this);
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
run() {
|
|
757
|
+
if (!(this.flags & 1)) {
|
|
758
|
+
return this.fn();
|
|
759
|
+
}
|
|
760
|
+
this.flags |= 2;
|
|
761
|
+
cleanupEffect3(this);
|
|
762
|
+
prepareDeps(this);
|
|
763
|
+
const prevEffect = activeSub;
|
|
764
|
+
const prevShouldTrack = shouldTrack;
|
|
765
|
+
activeSub = this;
|
|
766
|
+
shouldTrack = true;
|
|
767
|
+
try {
|
|
768
|
+
return this.fn();
|
|
769
|
+
} finally {
|
|
770
|
+
if (activeSub !== this) {
|
|
771
|
+
warn("Active effect was not restored correctly - this is likely a Vue internal bug.");
|
|
772
|
+
}
|
|
773
|
+
cleanupDeps(this);
|
|
774
|
+
activeSub = prevEffect;
|
|
775
|
+
shouldTrack = prevShouldTrack;
|
|
776
|
+
this.flags &= ~2;
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
stop() {
|
|
780
|
+
if (this.flags & 1) {
|
|
781
|
+
for (let link = this.deps;link; link = link.nextDep) {
|
|
782
|
+
removeSub(link);
|
|
783
|
+
}
|
|
784
|
+
this.deps = this.depsTail = undefined;
|
|
785
|
+
cleanupEffect3(this);
|
|
786
|
+
this.onStop && this.onStop();
|
|
787
|
+
this.flags &= ~1;
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
trigger() {
|
|
791
|
+
if (this.flags & 64) {
|
|
792
|
+
pausedQueueEffects.add(this);
|
|
793
|
+
} else if (this.scheduler) {
|
|
794
|
+
this.scheduler();
|
|
795
|
+
} else {
|
|
796
|
+
this.runIfDirty();
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
runIfDirty() {
|
|
800
|
+
if (isDirty(this)) {
|
|
801
|
+
this.run();
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
get dirty() {
|
|
805
|
+
return isDirty(this);
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
var batchDepth = 0;
|
|
809
|
+
var batchedSub;
|
|
810
|
+
var batchedComputed;
|
|
811
|
+
function batch(sub, isComputed2 = false) {
|
|
812
|
+
sub.flags |= 8;
|
|
813
|
+
if (isComputed2) {
|
|
814
|
+
sub.next = batchedComputed;
|
|
815
|
+
batchedComputed = sub;
|
|
816
|
+
return;
|
|
817
|
+
}
|
|
818
|
+
sub.next = batchedSub;
|
|
819
|
+
batchedSub = sub;
|
|
820
|
+
}
|
|
821
|
+
function startBatch() {
|
|
822
|
+
batchDepth++;
|
|
823
|
+
}
|
|
824
|
+
function endBatch() {
|
|
825
|
+
if (--batchDepth > 0) {
|
|
826
|
+
return;
|
|
827
|
+
}
|
|
828
|
+
if (batchedComputed) {
|
|
829
|
+
let e = batchedComputed;
|
|
830
|
+
batchedComputed = undefined;
|
|
831
|
+
while (e) {
|
|
832
|
+
const next = e.next;
|
|
833
|
+
e.next = undefined;
|
|
834
|
+
e.flags &= ~8;
|
|
835
|
+
e = next;
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
let error;
|
|
839
|
+
while (batchedSub) {
|
|
840
|
+
let e = batchedSub;
|
|
841
|
+
batchedSub = undefined;
|
|
842
|
+
while (e) {
|
|
843
|
+
const next = e.next;
|
|
844
|
+
e.next = undefined;
|
|
845
|
+
e.flags &= ~8;
|
|
846
|
+
if (e.flags & 1) {
|
|
847
|
+
try {
|
|
848
|
+
e.trigger();
|
|
849
|
+
} catch (err) {
|
|
850
|
+
if (!error)
|
|
851
|
+
error = err;
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
e = next;
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
if (error)
|
|
858
|
+
throw error;
|
|
859
|
+
}
|
|
860
|
+
function prepareDeps(sub) {
|
|
861
|
+
for (let link = sub.deps;link; link = link.nextDep) {
|
|
862
|
+
link.version = -1;
|
|
863
|
+
link.prevActiveLink = link.dep.activeLink;
|
|
864
|
+
link.dep.activeLink = link;
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
function cleanupDeps(sub) {
|
|
868
|
+
let head;
|
|
869
|
+
let tail = sub.depsTail;
|
|
870
|
+
let link = tail;
|
|
871
|
+
while (link) {
|
|
872
|
+
const prev = link.prevDep;
|
|
873
|
+
if (link.version === -1) {
|
|
874
|
+
if (link === tail)
|
|
875
|
+
tail = prev;
|
|
876
|
+
removeSub(link);
|
|
877
|
+
removeDep(link);
|
|
878
|
+
} else {
|
|
879
|
+
head = link;
|
|
880
|
+
}
|
|
881
|
+
link.dep.activeLink = link.prevActiveLink;
|
|
882
|
+
link.prevActiveLink = undefined;
|
|
883
|
+
link = prev;
|
|
884
|
+
}
|
|
885
|
+
sub.deps = head;
|
|
886
|
+
sub.depsTail = tail;
|
|
887
|
+
}
|
|
888
|
+
function isDirty(sub) {
|
|
889
|
+
for (let link = sub.deps;link; link = link.nextDep) {
|
|
890
|
+
if (link.dep.version !== link.version || link.dep.computed && (refreshComputed(link.dep.computed) || link.dep.version !== link.version)) {
|
|
891
|
+
return true;
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
if (sub._dirty) {
|
|
895
|
+
return true;
|
|
896
|
+
}
|
|
897
|
+
return false;
|
|
898
|
+
}
|
|
899
|
+
function refreshComputed(computed3) {
|
|
900
|
+
if (computed3.flags & 4 && !(computed3.flags & 16)) {
|
|
901
|
+
return;
|
|
902
|
+
}
|
|
903
|
+
computed3.flags &= ~16;
|
|
904
|
+
if (computed3.globalVersion === globalVersion) {
|
|
905
|
+
return;
|
|
906
|
+
}
|
|
907
|
+
computed3.globalVersion = globalVersion;
|
|
908
|
+
const dep = computed3.dep;
|
|
909
|
+
computed3.flags |= 2;
|
|
910
|
+
if (dep.version > 0 && !computed3.isSSR && computed3.deps && !isDirty(computed3)) {
|
|
911
|
+
computed3.flags &= ~2;
|
|
912
|
+
return;
|
|
913
|
+
}
|
|
914
|
+
const prevSub = activeSub;
|
|
915
|
+
const prevShouldTrack = shouldTrack;
|
|
916
|
+
activeSub = computed3;
|
|
917
|
+
shouldTrack = true;
|
|
918
|
+
try {
|
|
919
|
+
prepareDeps(computed3);
|
|
920
|
+
const value = computed3.fn(computed3._value);
|
|
921
|
+
if (dep.version === 0 || shared.hasChanged(value, computed3._value)) {
|
|
922
|
+
computed3._value = value;
|
|
923
|
+
dep.version++;
|
|
924
|
+
}
|
|
925
|
+
} catch (err) {
|
|
926
|
+
dep.version++;
|
|
927
|
+
throw err;
|
|
928
|
+
} finally {
|
|
929
|
+
activeSub = prevSub;
|
|
930
|
+
shouldTrack = prevShouldTrack;
|
|
931
|
+
cleanupDeps(computed3);
|
|
932
|
+
computed3.flags &= ~2;
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
function removeSub(link, soft = false) {
|
|
936
|
+
const { dep, prevSub, nextSub } = link;
|
|
937
|
+
if (prevSub) {
|
|
938
|
+
prevSub.nextSub = nextSub;
|
|
939
|
+
link.prevSub = undefined;
|
|
940
|
+
}
|
|
941
|
+
if (nextSub) {
|
|
942
|
+
nextSub.prevSub = prevSub;
|
|
943
|
+
link.nextSub = undefined;
|
|
944
|
+
}
|
|
945
|
+
if (dep.subsHead === link) {
|
|
946
|
+
dep.subsHead = nextSub;
|
|
947
|
+
}
|
|
948
|
+
if (dep.subs === link) {
|
|
949
|
+
dep.subs = prevSub;
|
|
950
|
+
if (!prevSub && dep.computed) {
|
|
951
|
+
dep.computed.flags &= ~4;
|
|
952
|
+
for (let l = dep.computed.deps;l; l = l.nextDep) {
|
|
953
|
+
removeSub(l, true);
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
if (!soft && !--dep.sc && dep.map) {
|
|
958
|
+
dep.map.delete(dep.key);
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
function removeDep(link) {
|
|
962
|
+
const { prevDep, nextDep } = link;
|
|
963
|
+
if (prevDep) {
|
|
964
|
+
prevDep.nextDep = nextDep;
|
|
965
|
+
link.prevDep = undefined;
|
|
966
|
+
}
|
|
967
|
+
if (nextDep) {
|
|
968
|
+
nextDep.prevDep = prevDep;
|
|
969
|
+
link.nextDep = undefined;
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
function effect(fn, options) {
|
|
973
|
+
if (fn.effect instanceof ReactiveEffect) {
|
|
974
|
+
fn = fn.effect.fn;
|
|
975
|
+
}
|
|
976
|
+
const e = new ReactiveEffect(fn);
|
|
977
|
+
if (options) {
|
|
978
|
+
shared.extend(e, options);
|
|
979
|
+
}
|
|
980
|
+
try {
|
|
981
|
+
e.run();
|
|
982
|
+
} catch (err) {
|
|
983
|
+
e.stop();
|
|
984
|
+
throw err;
|
|
985
|
+
}
|
|
986
|
+
const runner = e.run.bind(e);
|
|
987
|
+
runner.effect = e;
|
|
988
|
+
return runner;
|
|
989
|
+
}
|
|
990
|
+
function stop(runner) {
|
|
991
|
+
runner.effect.stop();
|
|
992
|
+
}
|
|
993
|
+
var shouldTrack = true;
|
|
994
|
+
var trackStack = [];
|
|
995
|
+
function pauseTracking() {
|
|
996
|
+
trackStack.push(shouldTrack);
|
|
997
|
+
shouldTrack = false;
|
|
998
|
+
}
|
|
999
|
+
function enableTracking() {
|
|
1000
|
+
trackStack.push(shouldTrack);
|
|
1001
|
+
shouldTrack = true;
|
|
1002
|
+
}
|
|
1003
|
+
function resetTracking() {
|
|
1004
|
+
const last = trackStack.pop();
|
|
1005
|
+
shouldTrack = last === undefined ? true : last;
|
|
1006
|
+
}
|
|
1007
|
+
function onEffectCleanup(fn, failSilently = false) {
|
|
1008
|
+
if (activeSub instanceof ReactiveEffect) {
|
|
1009
|
+
activeSub.cleanup = fn;
|
|
1010
|
+
} else if (!failSilently) {
|
|
1011
|
+
warn(`onEffectCleanup() was called when there was no active effect to associate with.`);
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
function cleanupEffect3(e) {
|
|
1015
|
+
const { cleanup } = e;
|
|
1016
|
+
e.cleanup = undefined;
|
|
1017
|
+
if (cleanup) {
|
|
1018
|
+
const prevSub = activeSub;
|
|
1019
|
+
activeSub = undefined;
|
|
1020
|
+
try {
|
|
1021
|
+
cleanup();
|
|
1022
|
+
} finally {
|
|
1023
|
+
activeSub = prevSub;
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
var globalVersion = 0;
|
|
1028
|
+
|
|
1029
|
+
class Link {
|
|
1030
|
+
constructor(sub, dep) {
|
|
1031
|
+
this.sub = sub;
|
|
1032
|
+
this.dep = dep;
|
|
1033
|
+
this.version = dep.version;
|
|
1034
|
+
this.nextDep = this.prevDep = this.nextSub = this.prevSub = this.prevActiveLink = undefined;
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
class Dep {
|
|
1039
|
+
constructor(computed3) {
|
|
1040
|
+
this.computed = computed3;
|
|
1041
|
+
this.version = 0;
|
|
1042
|
+
this.activeLink = undefined;
|
|
1043
|
+
this.subs = undefined;
|
|
1044
|
+
this.map = undefined;
|
|
1045
|
+
this.key = undefined;
|
|
1046
|
+
this.sc = 0;
|
|
1047
|
+
{
|
|
1048
|
+
this.subsHead = undefined;
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
track(debugInfo) {
|
|
1052
|
+
if (!activeSub || !shouldTrack || activeSub === this.computed) {
|
|
1053
|
+
return;
|
|
1054
|
+
}
|
|
1055
|
+
let link = this.activeLink;
|
|
1056
|
+
if (link === undefined || link.sub !== activeSub) {
|
|
1057
|
+
link = this.activeLink = new Link(activeSub, this);
|
|
1058
|
+
if (!activeSub.deps) {
|
|
1059
|
+
activeSub.deps = activeSub.depsTail = link;
|
|
1060
|
+
} else {
|
|
1061
|
+
link.prevDep = activeSub.depsTail;
|
|
1062
|
+
activeSub.depsTail.nextDep = link;
|
|
1063
|
+
activeSub.depsTail = link;
|
|
1064
|
+
}
|
|
1065
|
+
addSub(link);
|
|
1066
|
+
} else if (link.version === -1) {
|
|
1067
|
+
link.version = this.version;
|
|
1068
|
+
if (link.nextDep) {
|
|
1069
|
+
const next = link.nextDep;
|
|
1070
|
+
next.prevDep = link.prevDep;
|
|
1071
|
+
if (link.prevDep) {
|
|
1072
|
+
link.prevDep.nextDep = next;
|
|
1073
|
+
}
|
|
1074
|
+
link.prevDep = activeSub.depsTail;
|
|
1075
|
+
link.nextDep = undefined;
|
|
1076
|
+
activeSub.depsTail.nextDep = link;
|
|
1077
|
+
activeSub.depsTail = link;
|
|
1078
|
+
if (activeSub.deps === link) {
|
|
1079
|
+
activeSub.deps = next;
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
if (activeSub.onTrack) {
|
|
1084
|
+
activeSub.onTrack(shared.extend({
|
|
1085
|
+
effect: activeSub
|
|
1086
|
+
}, debugInfo));
|
|
1087
|
+
}
|
|
1088
|
+
return link;
|
|
1089
|
+
}
|
|
1090
|
+
trigger(debugInfo) {
|
|
1091
|
+
this.version++;
|
|
1092
|
+
globalVersion++;
|
|
1093
|
+
this.notify(debugInfo);
|
|
1094
|
+
}
|
|
1095
|
+
notify(debugInfo) {
|
|
1096
|
+
startBatch();
|
|
1097
|
+
try {
|
|
1098
|
+
if (true) {
|
|
1099
|
+
for (let head = this.subsHead;head; head = head.nextSub) {
|
|
1100
|
+
if (head.sub.onTrigger && !(head.sub.flags & 8)) {
|
|
1101
|
+
head.sub.onTrigger(shared.extend({
|
|
1102
|
+
effect: head.sub
|
|
1103
|
+
}, debugInfo));
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
for (let link = this.subs;link; link = link.prevSub) {
|
|
1108
|
+
if (link.sub.notify()) {
|
|
1109
|
+
link.sub.dep.notify();
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
} finally {
|
|
1113
|
+
endBatch();
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
function addSub(link) {
|
|
1118
|
+
link.dep.sc++;
|
|
1119
|
+
if (link.sub.flags & 4) {
|
|
1120
|
+
const computed3 = link.dep.computed;
|
|
1121
|
+
if (computed3 && !link.dep.subs) {
|
|
1122
|
+
computed3.flags |= 4 | 16;
|
|
1123
|
+
for (let l = computed3.deps;l; l = l.nextDep) {
|
|
1124
|
+
addSub(l);
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
const currentTail = link.dep.subs;
|
|
1128
|
+
if (currentTail !== link) {
|
|
1129
|
+
link.prevSub = currentTail;
|
|
1130
|
+
if (currentTail)
|
|
1131
|
+
currentTail.nextSub = link;
|
|
1132
|
+
}
|
|
1133
|
+
if (link.dep.subsHead === undefined) {
|
|
1134
|
+
link.dep.subsHead = link;
|
|
1135
|
+
}
|
|
1136
|
+
link.dep.subs = link;
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1139
|
+
var targetMap2 = /* @__PURE__ */ new WeakMap;
|
|
1140
|
+
var ITERATE_KEY = Symbol("Object iterate");
|
|
1141
|
+
var MAP_KEY_ITERATE_KEY = Symbol("Map keys iterate");
|
|
1142
|
+
var ARRAY_ITERATE_KEY = Symbol("Array iterate");
|
|
1143
|
+
function track2(target, type, key) {
|
|
1144
|
+
if (shouldTrack && activeSub) {
|
|
1145
|
+
let depsMap = targetMap2.get(target);
|
|
1146
|
+
if (!depsMap) {
|
|
1147
|
+
targetMap2.set(target, depsMap = /* @__PURE__ */ new Map);
|
|
1148
|
+
}
|
|
1149
|
+
let dep = depsMap.get(key);
|
|
1150
|
+
if (!dep) {
|
|
1151
|
+
depsMap.set(key, dep = new Dep);
|
|
1152
|
+
dep.map = depsMap;
|
|
1153
|
+
dep.key = key;
|
|
1154
|
+
}
|
|
1155
|
+
{
|
|
1156
|
+
dep.track({
|
|
1157
|
+
target,
|
|
1158
|
+
type,
|
|
1159
|
+
key
|
|
1160
|
+
});
|
|
1161
|
+
}
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1164
|
+
function trigger2(target, type, key, newValue, oldValue, oldTarget) {
|
|
1165
|
+
const depsMap = targetMap2.get(target);
|
|
1166
|
+
if (!depsMap) {
|
|
1167
|
+
globalVersion++;
|
|
1168
|
+
return;
|
|
1169
|
+
}
|
|
1170
|
+
const run = (dep) => {
|
|
1171
|
+
if (dep) {
|
|
1172
|
+
{
|
|
1173
|
+
dep.trigger({
|
|
1174
|
+
target,
|
|
1175
|
+
type,
|
|
1176
|
+
key,
|
|
1177
|
+
newValue,
|
|
1178
|
+
oldValue,
|
|
1179
|
+
oldTarget
|
|
1180
|
+
});
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1183
|
+
};
|
|
1184
|
+
startBatch();
|
|
1185
|
+
if (type === "clear") {
|
|
1186
|
+
depsMap.forEach(run);
|
|
1187
|
+
} else {
|
|
1188
|
+
const targetIsArray = shared.isArray(target);
|
|
1189
|
+
const isArrayIndex = targetIsArray && shared.isIntegerKey(key);
|
|
1190
|
+
if (targetIsArray && key === "length") {
|
|
1191
|
+
const newLength = Number(newValue);
|
|
1192
|
+
depsMap.forEach((dep, key2) => {
|
|
1193
|
+
if (key2 === "length" || key2 === ARRAY_ITERATE_KEY || !shared.isSymbol(key2) && key2 >= newLength) {
|
|
1194
|
+
run(dep);
|
|
1195
|
+
}
|
|
1196
|
+
});
|
|
1197
|
+
} else {
|
|
1198
|
+
if (key !== undefined || depsMap.has(undefined)) {
|
|
1199
|
+
run(depsMap.get(key));
|
|
1200
|
+
}
|
|
1201
|
+
if (isArrayIndex) {
|
|
1202
|
+
run(depsMap.get(ARRAY_ITERATE_KEY));
|
|
1203
|
+
}
|
|
1204
|
+
switch (type) {
|
|
1205
|
+
case "add":
|
|
1206
|
+
if (!targetIsArray) {
|
|
1207
|
+
run(depsMap.get(ITERATE_KEY));
|
|
1208
|
+
if (shared.isMap(target)) {
|
|
1209
|
+
run(depsMap.get(MAP_KEY_ITERATE_KEY));
|
|
1210
|
+
}
|
|
1211
|
+
} else if (isArrayIndex) {
|
|
1212
|
+
run(depsMap.get("length"));
|
|
1213
|
+
}
|
|
1214
|
+
break;
|
|
1215
|
+
case "delete":
|
|
1216
|
+
if (!targetIsArray) {
|
|
1217
|
+
run(depsMap.get(ITERATE_KEY));
|
|
1218
|
+
if (shared.isMap(target)) {
|
|
1219
|
+
run(depsMap.get(MAP_KEY_ITERATE_KEY));
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
break;
|
|
1223
|
+
case "set":
|
|
1224
|
+
if (shared.isMap(target)) {
|
|
1225
|
+
run(depsMap.get(ITERATE_KEY));
|
|
1226
|
+
}
|
|
1227
|
+
break;
|
|
1228
|
+
}
|
|
1229
|
+
}
|
|
1230
|
+
}
|
|
1231
|
+
endBatch();
|
|
1232
|
+
}
|
|
1233
|
+
function getDepFromReactive(object, key) {
|
|
1234
|
+
const depMap = targetMap2.get(object);
|
|
1235
|
+
return depMap && depMap.get(key);
|
|
1236
|
+
}
|
|
1237
|
+
function reactiveReadArray(array) {
|
|
1238
|
+
const raw = toRaw2(array);
|
|
1239
|
+
if (raw === array)
|
|
1240
|
+
return raw;
|
|
1241
|
+
track2(raw, "iterate", ARRAY_ITERATE_KEY);
|
|
1242
|
+
return isShallow(array) ? raw : raw.map(toReactive);
|
|
1243
|
+
}
|
|
1244
|
+
function shallowReadArray(arr) {
|
|
1245
|
+
track2(arr = toRaw2(arr), "iterate", ARRAY_ITERATE_KEY);
|
|
1246
|
+
return arr;
|
|
1247
|
+
}
|
|
1248
|
+
var arrayInstrumentations = {
|
|
1249
|
+
__proto__: null,
|
|
1250
|
+
[Symbol.iterator]() {
|
|
1251
|
+
return iterator(this, Symbol.iterator, toReactive);
|
|
1252
|
+
},
|
|
1253
|
+
concat(...args) {
|
|
1254
|
+
return reactiveReadArray(this).concat(...args.map((x) => shared.isArray(x) ? reactiveReadArray(x) : x));
|
|
1255
|
+
},
|
|
1256
|
+
entries() {
|
|
1257
|
+
return iterator(this, "entries", (value) => {
|
|
1258
|
+
value[1] = toReactive(value[1]);
|
|
1259
|
+
return value;
|
|
1260
|
+
});
|
|
1261
|
+
},
|
|
1262
|
+
every(fn, thisArg) {
|
|
1263
|
+
return apply(this, "every", fn, thisArg, undefined, arguments);
|
|
1264
|
+
},
|
|
1265
|
+
filter(fn, thisArg) {
|
|
1266
|
+
return apply(this, "filter", fn, thisArg, (v) => v.map(toReactive), arguments);
|
|
1267
|
+
},
|
|
1268
|
+
find(fn, thisArg) {
|
|
1269
|
+
return apply(this, "find", fn, thisArg, toReactive, arguments);
|
|
1270
|
+
},
|
|
1271
|
+
findIndex(fn, thisArg) {
|
|
1272
|
+
return apply(this, "findIndex", fn, thisArg, undefined, arguments);
|
|
1273
|
+
},
|
|
1274
|
+
findLast(fn, thisArg) {
|
|
1275
|
+
return apply(this, "findLast", fn, thisArg, toReactive, arguments);
|
|
1276
|
+
},
|
|
1277
|
+
findLastIndex(fn, thisArg) {
|
|
1278
|
+
return apply(this, "findLastIndex", fn, thisArg, undefined, arguments);
|
|
1279
|
+
},
|
|
1280
|
+
forEach(fn, thisArg) {
|
|
1281
|
+
return apply(this, "forEach", fn, thisArg, undefined, arguments);
|
|
1282
|
+
},
|
|
1283
|
+
includes(...args) {
|
|
1284
|
+
return searchProxy(this, "includes", args);
|
|
1285
|
+
},
|
|
1286
|
+
indexOf(...args) {
|
|
1287
|
+
return searchProxy(this, "indexOf", args);
|
|
1288
|
+
},
|
|
1289
|
+
join(separator) {
|
|
1290
|
+
return reactiveReadArray(this).join(separator);
|
|
1291
|
+
},
|
|
1292
|
+
lastIndexOf(...args) {
|
|
1293
|
+
return searchProxy(this, "lastIndexOf", args);
|
|
1294
|
+
},
|
|
1295
|
+
map(fn, thisArg) {
|
|
1296
|
+
return apply(this, "map", fn, thisArg, undefined, arguments);
|
|
1297
|
+
},
|
|
1298
|
+
pop() {
|
|
1299
|
+
return noTracking(this, "pop");
|
|
1300
|
+
},
|
|
1301
|
+
push(...args) {
|
|
1302
|
+
return noTracking(this, "push", args);
|
|
1303
|
+
},
|
|
1304
|
+
reduce(fn, ...args) {
|
|
1305
|
+
return reduce(this, "reduce", fn, args);
|
|
1306
|
+
},
|
|
1307
|
+
reduceRight(fn, ...args) {
|
|
1308
|
+
return reduce(this, "reduceRight", fn, args);
|
|
1309
|
+
},
|
|
1310
|
+
shift() {
|
|
1311
|
+
return noTracking(this, "shift");
|
|
1312
|
+
},
|
|
1313
|
+
some(fn, thisArg) {
|
|
1314
|
+
return apply(this, "some", fn, thisArg, undefined, arguments);
|
|
1315
|
+
},
|
|
1316
|
+
splice(...args) {
|
|
1317
|
+
return noTracking(this, "splice", args);
|
|
1318
|
+
},
|
|
1319
|
+
toReversed() {
|
|
1320
|
+
return reactiveReadArray(this).toReversed();
|
|
1321
|
+
},
|
|
1322
|
+
toSorted(comparer) {
|
|
1323
|
+
return reactiveReadArray(this).toSorted(comparer);
|
|
1324
|
+
},
|
|
1325
|
+
toSpliced(...args) {
|
|
1326
|
+
return reactiveReadArray(this).toSpliced(...args);
|
|
1327
|
+
},
|
|
1328
|
+
unshift(...args) {
|
|
1329
|
+
return noTracking(this, "unshift", args);
|
|
1330
|
+
},
|
|
1331
|
+
values() {
|
|
1332
|
+
return iterator(this, "values", toReactive);
|
|
1333
|
+
}
|
|
1334
|
+
};
|
|
1335
|
+
function iterator(self2, method, wrapValue) {
|
|
1336
|
+
const arr = shallowReadArray(self2);
|
|
1337
|
+
const iter = arr[method]();
|
|
1338
|
+
if (arr !== self2 && !isShallow(self2)) {
|
|
1339
|
+
iter._next = iter.next;
|
|
1340
|
+
iter.next = () => {
|
|
1341
|
+
const result = iter._next();
|
|
1342
|
+
if (result.value) {
|
|
1343
|
+
result.value = wrapValue(result.value);
|
|
1344
|
+
}
|
|
1345
|
+
return result;
|
|
1346
|
+
};
|
|
1347
|
+
}
|
|
1348
|
+
return iter;
|
|
1349
|
+
}
|
|
1350
|
+
var arrayProto = Array.prototype;
|
|
1351
|
+
function apply(self2, method, fn, thisArg, wrappedRetFn, args) {
|
|
1352
|
+
const arr = shallowReadArray(self2);
|
|
1353
|
+
const needsWrap = arr !== self2 && !isShallow(self2);
|
|
1354
|
+
const methodFn = arr[method];
|
|
1355
|
+
if (methodFn !== arrayProto[method]) {
|
|
1356
|
+
const result2 = methodFn.apply(self2, args);
|
|
1357
|
+
return needsWrap ? toReactive(result2) : result2;
|
|
1358
|
+
}
|
|
1359
|
+
let wrappedFn = fn;
|
|
1360
|
+
if (arr !== self2) {
|
|
1361
|
+
if (needsWrap) {
|
|
1362
|
+
wrappedFn = function(item, index) {
|
|
1363
|
+
return fn.call(this, toReactive(item), index, self2);
|
|
1364
|
+
};
|
|
1365
|
+
} else if (fn.length > 2) {
|
|
1366
|
+
wrappedFn = function(item, index) {
|
|
1367
|
+
return fn.call(this, item, index, self2);
|
|
1368
|
+
};
|
|
1369
|
+
}
|
|
1370
|
+
}
|
|
1371
|
+
const result = methodFn.call(arr, wrappedFn, thisArg);
|
|
1372
|
+
return needsWrap && wrappedRetFn ? wrappedRetFn(result) : result;
|
|
1373
|
+
}
|
|
1374
|
+
function reduce(self2, method, fn, args) {
|
|
1375
|
+
const arr = shallowReadArray(self2);
|
|
1376
|
+
let wrappedFn = fn;
|
|
1377
|
+
if (arr !== self2) {
|
|
1378
|
+
if (!isShallow(self2)) {
|
|
1379
|
+
wrappedFn = function(acc, item, index) {
|
|
1380
|
+
return fn.call(this, acc, toReactive(item), index, self2);
|
|
1381
|
+
};
|
|
1382
|
+
} else if (fn.length > 3) {
|
|
1383
|
+
wrappedFn = function(acc, item, index) {
|
|
1384
|
+
return fn.call(this, acc, item, index, self2);
|
|
1385
|
+
};
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1388
|
+
return arr[method](wrappedFn, ...args);
|
|
1389
|
+
}
|
|
1390
|
+
function searchProxy(self2, method, args) {
|
|
1391
|
+
const arr = toRaw2(self2);
|
|
1392
|
+
track2(arr, "iterate", ARRAY_ITERATE_KEY);
|
|
1393
|
+
const res = arr[method](...args);
|
|
1394
|
+
if ((res === -1 || res === false) && isProxy(args[0])) {
|
|
1395
|
+
args[0] = toRaw2(args[0]);
|
|
1396
|
+
return arr[method](...args);
|
|
1397
|
+
}
|
|
1398
|
+
return res;
|
|
1399
|
+
}
|
|
1400
|
+
function noTracking(self2, method, args = []) {
|
|
1401
|
+
pauseTracking();
|
|
1402
|
+
startBatch();
|
|
1403
|
+
const res = toRaw2(self2)[method].apply(self2, args);
|
|
1404
|
+
endBatch();
|
|
1405
|
+
resetTracking();
|
|
1406
|
+
return res;
|
|
1407
|
+
}
|
|
1408
|
+
var isNonTrackableKeys = /* @__PURE__ */ shared.makeMap(`__proto__,__v_isRef,__isVue`);
|
|
1409
|
+
var builtInSymbols = new Set(/* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(shared.isSymbol));
|
|
1410
|
+
function hasOwnProperty(key) {
|
|
1411
|
+
if (!shared.isSymbol(key))
|
|
1412
|
+
key = String(key);
|
|
1413
|
+
const obj = toRaw2(this);
|
|
1414
|
+
track2(obj, "has", key);
|
|
1415
|
+
return obj.hasOwnProperty(key);
|
|
1416
|
+
}
|
|
1417
|
+
|
|
1418
|
+
class BaseReactiveHandler {
|
|
1419
|
+
constructor(_isReadonly = false, _isShallow = false) {
|
|
1420
|
+
this._isReadonly = _isReadonly;
|
|
1421
|
+
this._isShallow = _isShallow;
|
|
1422
|
+
}
|
|
1423
|
+
get(target, key, receiver) {
|
|
1424
|
+
if (key === "__v_skip")
|
|
1425
|
+
return target["__v_skip"];
|
|
1426
|
+
const isReadonly2 = this._isReadonly, isShallow2 = this._isShallow;
|
|
1427
|
+
if (key === "__v_isReactive") {
|
|
1428
|
+
return !isReadonly2;
|
|
1429
|
+
} else if (key === "__v_isReadonly") {
|
|
1430
|
+
return isReadonly2;
|
|
1431
|
+
} else if (key === "__v_isShallow") {
|
|
1432
|
+
return isShallow2;
|
|
1433
|
+
} else if (key === "__v_raw") {
|
|
1434
|
+
if (receiver === (isReadonly2 ? isShallow2 ? shallowReadonlyMap : readonlyMap : isShallow2 ? shallowReactiveMap : reactiveMap).get(target) || Object.getPrototypeOf(target) === Object.getPrototypeOf(receiver)) {
|
|
1435
|
+
return target;
|
|
1436
|
+
}
|
|
1437
|
+
return;
|
|
1438
|
+
}
|
|
1439
|
+
const targetIsArray = shared.isArray(target);
|
|
1440
|
+
if (!isReadonly2) {
|
|
1441
|
+
let fn;
|
|
1442
|
+
if (targetIsArray && (fn = arrayInstrumentations[key])) {
|
|
1443
|
+
return fn;
|
|
1444
|
+
}
|
|
1445
|
+
if (key === "hasOwnProperty") {
|
|
1446
|
+
return hasOwnProperty;
|
|
1447
|
+
}
|
|
1448
|
+
}
|
|
1449
|
+
const res = Reflect.get(target, key, isRef3(target) ? target : receiver);
|
|
1450
|
+
if (shared.isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
|
|
1451
|
+
return res;
|
|
1452
|
+
}
|
|
1453
|
+
if (!isReadonly2) {
|
|
1454
|
+
track2(target, "get", key);
|
|
1455
|
+
}
|
|
1456
|
+
if (isShallow2) {
|
|
1457
|
+
return res;
|
|
1458
|
+
}
|
|
1459
|
+
if (isRef3(res)) {
|
|
1460
|
+
return targetIsArray && shared.isIntegerKey(key) ? res : res.value;
|
|
1461
|
+
}
|
|
1462
|
+
if (shared.isObject(res)) {
|
|
1463
|
+
return isReadonly2 ? readonly(res) : reactive2(res);
|
|
1464
|
+
}
|
|
1465
|
+
return res;
|
|
1466
|
+
}
|
|
1467
|
+
}
|
|
1468
|
+
|
|
1469
|
+
class MutableReactiveHandler extends BaseReactiveHandler {
|
|
1470
|
+
constructor(isShallow2 = false) {
|
|
1471
|
+
super(false, isShallow2);
|
|
1472
|
+
}
|
|
1473
|
+
set(target, key, value, receiver) {
|
|
1474
|
+
let oldValue = target[key];
|
|
1475
|
+
if (!this._isShallow) {
|
|
1476
|
+
const isOldValueReadonly = isReadonly(oldValue);
|
|
1477
|
+
if (!isShallow(value) && !isReadonly(value)) {
|
|
1478
|
+
oldValue = toRaw2(oldValue);
|
|
1479
|
+
value = toRaw2(value);
|
|
1480
|
+
}
|
|
1481
|
+
if (!shared.isArray(target) && isRef3(oldValue) && !isRef3(value)) {
|
|
1482
|
+
if (isOldValueReadonly) {
|
|
1483
|
+
return false;
|
|
1484
|
+
} else {
|
|
1485
|
+
oldValue.value = value;
|
|
1486
|
+
return true;
|
|
1487
|
+
}
|
|
1488
|
+
}
|
|
1489
|
+
}
|
|
1490
|
+
const hadKey = shared.isArray(target) && shared.isIntegerKey(key) ? Number(key) < target.length : shared.hasOwn(target, key);
|
|
1491
|
+
const result = Reflect.set(target, key, value, isRef3(target) ? target : receiver);
|
|
1492
|
+
if (target === toRaw2(receiver)) {
|
|
1493
|
+
if (!hadKey) {
|
|
1494
|
+
trigger2(target, "add", key, value);
|
|
1495
|
+
} else if (shared.hasChanged(value, oldValue)) {
|
|
1496
|
+
trigger2(target, "set", key, value, oldValue);
|
|
1497
|
+
}
|
|
1498
|
+
}
|
|
1499
|
+
return result;
|
|
1500
|
+
}
|
|
1501
|
+
deleteProperty(target, key) {
|
|
1502
|
+
const hadKey = shared.hasOwn(target, key);
|
|
1503
|
+
const oldValue = target[key];
|
|
1504
|
+
const result = Reflect.deleteProperty(target, key);
|
|
1505
|
+
if (result && hadKey) {
|
|
1506
|
+
trigger2(target, "delete", key, undefined, oldValue);
|
|
1507
|
+
}
|
|
1508
|
+
return result;
|
|
1509
|
+
}
|
|
1510
|
+
has(target, key) {
|
|
1511
|
+
const result = Reflect.has(target, key);
|
|
1512
|
+
if (!shared.isSymbol(key) || !builtInSymbols.has(key)) {
|
|
1513
|
+
track2(target, "has", key);
|
|
1514
|
+
}
|
|
1515
|
+
return result;
|
|
1516
|
+
}
|
|
1517
|
+
ownKeys(target) {
|
|
1518
|
+
track2(target, "iterate", shared.isArray(target) ? "length" : ITERATE_KEY);
|
|
1519
|
+
return Reflect.ownKeys(target);
|
|
1520
|
+
}
|
|
1521
|
+
}
|
|
1522
|
+
|
|
1523
|
+
class ReadonlyReactiveHandler extends BaseReactiveHandler {
|
|
1524
|
+
constructor(isShallow2 = false) {
|
|
1525
|
+
super(true, isShallow2);
|
|
1526
|
+
}
|
|
1527
|
+
set(target, key) {
|
|
1528
|
+
{
|
|
1529
|
+
warn(`Set operation on key "${String(key)}" failed: target is readonly.`, target);
|
|
1530
|
+
}
|
|
1531
|
+
return true;
|
|
1532
|
+
}
|
|
1533
|
+
deleteProperty(target, key) {
|
|
1534
|
+
{
|
|
1535
|
+
warn(`Delete operation on key "${String(key)}" failed: target is readonly.`, target);
|
|
1536
|
+
}
|
|
1537
|
+
return true;
|
|
1538
|
+
}
|
|
1539
|
+
}
|
|
1540
|
+
var mutableHandlers = /* @__PURE__ */ new MutableReactiveHandler;
|
|
1541
|
+
var readonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler;
|
|
1542
|
+
var shallowReactiveHandlers = /* @__PURE__ */ new MutableReactiveHandler(true);
|
|
1543
|
+
var shallowReadonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler(true);
|
|
1544
|
+
var toShallow = (value) => value;
|
|
1545
|
+
var getProto = (v) => Reflect.getPrototypeOf(v);
|
|
1546
|
+
function createIterableMethod(method, isReadonly2, isShallow2) {
|
|
1547
|
+
return function(...args) {
|
|
1548
|
+
const target = this["__v_raw"];
|
|
1549
|
+
const rawTarget = toRaw2(target);
|
|
1550
|
+
const targetIsMap = shared.isMap(rawTarget);
|
|
1551
|
+
const isPair = method === "entries" || method === Symbol.iterator && targetIsMap;
|
|
1552
|
+
const isKeyOnly = method === "keys" && targetIsMap;
|
|
1553
|
+
const innerIterator = target[method](...args);
|
|
1554
|
+
const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
|
|
1555
|
+
!isReadonly2 && track2(rawTarget, "iterate", isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY);
|
|
1556
|
+
return {
|
|
1557
|
+
next() {
|
|
1558
|
+
const { value, done } = innerIterator.next();
|
|
1559
|
+
return done ? { value, done } : {
|
|
1560
|
+
value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
|
|
1561
|
+
done
|
|
1562
|
+
};
|
|
1563
|
+
},
|
|
1564
|
+
[Symbol.iterator]() {
|
|
1565
|
+
return this;
|
|
1566
|
+
}
|
|
1567
|
+
};
|
|
1568
|
+
};
|
|
1569
|
+
}
|
|
1570
|
+
function createReadonlyMethod(type) {
|
|
1571
|
+
return function(...args) {
|
|
1572
|
+
{
|
|
1573
|
+
const key = args[0] ? `on key "${args[0]}" ` : ``;
|
|
1574
|
+
warn(`${shared.capitalize(type)} operation ${key}failed: target is readonly.`, toRaw2(this));
|
|
1575
|
+
}
|
|
1576
|
+
return type === "delete" ? false : type === "clear" ? undefined : this;
|
|
1577
|
+
};
|
|
1578
|
+
}
|
|
1579
|
+
function createInstrumentations(readonly2, shallow) {
|
|
1580
|
+
const instrumentations = {
|
|
1581
|
+
get(key) {
|
|
1582
|
+
const target = this["__v_raw"];
|
|
1583
|
+
const rawTarget = toRaw2(target);
|
|
1584
|
+
const rawKey = toRaw2(key);
|
|
1585
|
+
if (!readonly2) {
|
|
1586
|
+
if (shared.hasChanged(key, rawKey)) {
|
|
1587
|
+
track2(rawTarget, "get", key);
|
|
1588
|
+
}
|
|
1589
|
+
track2(rawTarget, "get", rawKey);
|
|
1590
|
+
}
|
|
1591
|
+
const { has } = getProto(rawTarget);
|
|
1592
|
+
const wrap = shallow ? toShallow : readonly2 ? toReadonly : toReactive;
|
|
1593
|
+
if (has.call(rawTarget, key)) {
|
|
1594
|
+
return wrap(target.get(key));
|
|
1595
|
+
} else if (has.call(rawTarget, rawKey)) {
|
|
1596
|
+
return wrap(target.get(rawKey));
|
|
1597
|
+
} else if (target !== rawTarget) {
|
|
1598
|
+
target.get(key);
|
|
1599
|
+
}
|
|
1600
|
+
},
|
|
1601
|
+
get size() {
|
|
1602
|
+
const target = this["__v_raw"];
|
|
1603
|
+
!readonly2 && track2(toRaw2(target), "iterate", ITERATE_KEY);
|
|
1604
|
+
return Reflect.get(target, "size", target);
|
|
1605
|
+
},
|
|
1606
|
+
has(key) {
|
|
1607
|
+
const target = this["__v_raw"];
|
|
1608
|
+
const rawTarget = toRaw2(target);
|
|
1609
|
+
const rawKey = toRaw2(key);
|
|
1610
|
+
if (!readonly2) {
|
|
1611
|
+
if (shared.hasChanged(key, rawKey)) {
|
|
1612
|
+
track2(rawTarget, "has", key);
|
|
1613
|
+
}
|
|
1614
|
+
track2(rawTarget, "has", rawKey);
|
|
1615
|
+
}
|
|
1616
|
+
return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey);
|
|
1617
|
+
},
|
|
1618
|
+
forEach(callback, thisArg) {
|
|
1619
|
+
const observed = this;
|
|
1620
|
+
const target = observed["__v_raw"];
|
|
1621
|
+
const rawTarget = toRaw2(target);
|
|
1622
|
+
const wrap = shallow ? toShallow : readonly2 ? toReadonly : toReactive;
|
|
1623
|
+
!readonly2 && track2(rawTarget, "iterate", ITERATE_KEY);
|
|
1624
|
+
return target.forEach((value, key) => {
|
|
1625
|
+
return callback.call(thisArg, wrap(value), wrap(key), observed);
|
|
1626
|
+
});
|
|
1627
|
+
}
|
|
1628
|
+
};
|
|
1629
|
+
shared.extend(instrumentations, readonly2 ? {
|
|
1630
|
+
add: createReadonlyMethod("add"),
|
|
1631
|
+
set: createReadonlyMethod("set"),
|
|
1632
|
+
delete: createReadonlyMethod("delete"),
|
|
1633
|
+
clear: createReadonlyMethod("clear")
|
|
1634
|
+
} : {
|
|
1635
|
+
add(value) {
|
|
1636
|
+
if (!shallow && !isShallow(value) && !isReadonly(value)) {
|
|
1637
|
+
value = toRaw2(value);
|
|
1638
|
+
}
|
|
1639
|
+
const target = toRaw2(this);
|
|
1640
|
+
const proto = getProto(target);
|
|
1641
|
+
const hadKey = proto.has.call(target, value);
|
|
1642
|
+
if (!hadKey) {
|
|
1643
|
+
target.add(value);
|
|
1644
|
+
trigger2(target, "add", value, value);
|
|
1645
|
+
}
|
|
1646
|
+
return this;
|
|
1647
|
+
},
|
|
1648
|
+
set(key, value) {
|
|
1649
|
+
if (!shallow && !isShallow(value) && !isReadonly(value)) {
|
|
1650
|
+
value = toRaw2(value);
|
|
1651
|
+
}
|
|
1652
|
+
const target = toRaw2(this);
|
|
1653
|
+
const { has, get } = getProto(target);
|
|
1654
|
+
let hadKey = has.call(target, key);
|
|
1655
|
+
if (!hadKey) {
|
|
1656
|
+
key = toRaw2(key);
|
|
1657
|
+
hadKey = has.call(target, key);
|
|
1658
|
+
} else {
|
|
1659
|
+
checkIdentityKeys(target, has, key);
|
|
1660
|
+
}
|
|
1661
|
+
const oldValue = get.call(target, key);
|
|
1662
|
+
target.set(key, value);
|
|
1663
|
+
if (!hadKey) {
|
|
1664
|
+
trigger2(target, "add", key, value);
|
|
1665
|
+
} else if (shared.hasChanged(value, oldValue)) {
|
|
1666
|
+
trigger2(target, "set", key, value, oldValue);
|
|
1667
|
+
}
|
|
1668
|
+
return this;
|
|
1669
|
+
},
|
|
1670
|
+
delete(key) {
|
|
1671
|
+
const target = toRaw2(this);
|
|
1672
|
+
const { has, get } = getProto(target);
|
|
1673
|
+
let hadKey = has.call(target, key);
|
|
1674
|
+
if (!hadKey) {
|
|
1675
|
+
key = toRaw2(key);
|
|
1676
|
+
hadKey = has.call(target, key);
|
|
1677
|
+
} else {
|
|
1678
|
+
checkIdentityKeys(target, has, key);
|
|
1679
|
+
}
|
|
1680
|
+
const oldValue = get ? get.call(target, key) : undefined;
|
|
1681
|
+
const result = target.delete(key);
|
|
1682
|
+
if (hadKey) {
|
|
1683
|
+
trigger2(target, "delete", key, undefined, oldValue);
|
|
1684
|
+
}
|
|
1685
|
+
return result;
|
|
1686
|
+
},
|
|
1687
|
+
clear() {
|
|
1688
|
+
const target = toRaw2(this);
|
|
1689
|
+
const hadItems = target.size !== 0;
|
|
1690
|
+
const oldTarget = shared.isMap(target) ? new Map(target) : new Set(target);
|
|
1691
|
+
const result = target.clear();
|
|
1692
|
+
if (hadItems) {
|
|
1693
|
+
trigger2(target, "clear", undefined, undefined, oldTarget);
|
|
1694
|
+
}
|
|
1695
|
+
return result;
|
|
1696
|
+
}
|
|
1697
|
+
});
|
|
1698
|
+
const iteratorMethods = [
|
|
1699
|
+
"keys",
|
|
1700
|
+
"values",
|
|
1701
|
+
"entries",
|
|
1702
|
+
Symbol.iterator
|
|
1703
|
+
];
|
|
1704
|
+
iteratorMethods.forEach((method) => {
|
|
1705
|
+
instrumentations[method] = createIterableMethod(method, readonly2, shallow);
|
|
1706
|
+
});
|
|
1707
|
+
return instrumentations;
|
|
1708
|
+
}
|
|
1709
|
+
function createInstrumentationGetter(isReadonly2, shallow) {
|
|
1710
|
+
const instrumentations = createInstrumentations(isReadonly2, shallow);
|
|
1711
|
+
return (target, key, receiver) => {
|
|
1712
|
+
if (key === "__v_isReactive") {
|
|
1713
|
+
return !isReadonly2;
|
|
1714
|
+
} else if (key === "__v_isReadonly") {
|
|
1715
|
+
return isReadonly2;
|
|
1716
|
+
} else if (key === "__v_raw") {
|
|
1717
|
+
return target;
|
|
1718
|
+
}
|
|
1719
|
+
return Reflect.get(shared.hasOwn(instrumentations, key) && key in target ? instrumentations : target, key, receiver);
|
|
1720
|
+
};
|
|
1721
|
+
}
|
|
1722
|
+
var mutableCollectionHandlers = {
|
|
1723
|
+
get: /* @__PURE__ */ createInstrumentationGetter(false, false)
|
|
1724
|
+
};
|
|
1725
|
+
var shallowCollectionHandlers = {
|
|
1726
|
+
get: /* @__PURE__ */ createInstrumentationGetter(false, true)
|
|
1727
|
+
};
|
|
1728
|
+
var readonlyCollectionHandlers = {
|
|
1729
|
+
get: /* @__PURE__ */ createInstrumentationGetter(true, false)
|
|
1730
|
+
};
|
|
1731
|
+
var shallowReadonlyCollectionHandlers = {
|
|
1732
|
+
get: /* @__PURE__ */ createInstrumentationGetter(true, true)
|
|
1733
|
+
};
|
|
1734
|
+
function checkIdentityKeys(target, has, key) {
|
|
1735
|
+
const rawKey = toRaw2(key);
|
|
1736
|
+
if (rawKey !== key && has.call(target, rawKey)) {
|
|
1737
|
+
const type = shared.toRawType(target);
|
|
1738
|
+
warn(`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.`);
|
|
1739
|
+
}
|
|
1740
|
+
}
|
|
1741
|
+
var reactiveMap = /* @__PURE__ */ new WeakMap;
|
|
1742
|
+
var shallowReactiveMap = /* @__PURE__ */ new WeakMap;
|
|
1743
|
+
var readonlyMap = /* @__PURE__ */ new WeakMap;
|
|
1744
|
+
var shallowReadonlyMap = /* @__PURE__ */ new WeakMap;
|
|
1745
|
+
function targetTypeMap(rawType) {
|
|
1746
|
+
switch (rawType) {
|
|
1747
|
+
case "Object":
|
|
1748
|
+
case "Array":
|
|
1749
|
+
return 1;
|
|
1750
|
+
case "Map":
|
|
1751
|
+
case "Set":
|
|
1752
|
+
case "WeakMap":
|
|
1753
|
+
case "WeakSet":
|
|
1754
|
+
return 2;
|
|
1755
|
+
default:
|
|
1756
|
+
return 0;
|
|
1757
|
+
}
|
|
1758
|
+
}
|
|
1759
|
+
function getTargetType(value) {
|
|
1760
|
+
return value["__v_skip"] || !Object.isExtensible(value) ? 0 : targetTypeMap(shared.toRawType(value));
|
|
1761
|
+
}
|
|
1762
|
+
function reactive2(target) {
|
|
1763
|
+
if (isReadonly(target)) {
|
|
1764
|
+
return target;
|
|
1765
|
+
}
|
|
1766
|
+
return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers, reactiveMap);
|
|
1767
|
+
}
|
|
1768
|
+
function shallowReactive(target) {
|
|
1769
|
+
return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers, shallowReactiveMap);
|
|
1770
|
+
}
|
|
1771
|
+
function readonly(target) {
|
|
1772
|
+
return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers, readonlyMap);
|
|
1773
|
+
}
|
|
1774
|
+
function shallowReadonly(target) {
|
|
1775
|
+
return createReactiveObject(target, true, shallowReadonlyHandlers, shallowReadonlyCollectionHandlers, shallowReadonlyMap);
|
|
1776
|
+
}
|
|
1777
|
+
function createReactiveObject(target, isReadonly2, baseHandlers, collectionHandlers, proxyMap) {
|
|
1778
|
+
if (!shared.isObject(target)) {
|
|
1779
|
+
{
|
|
1780
|
+
warn(`value cannot be made ${isReadonly2 ? "readonly" : "reactive"}: ${String(target)}`);
|
|
1781
|
+
}
|
|
1782
|
+
return target;
|
|
1783
|
+
}
|
|
1784
|
+
if (target["__v_raw"] && !(isReadonly2 && target["__v_isReactive"])) {
|
|
1785
|
+
return target;
|
|
1786
|
+
}
|
|
1787
|
+
const existingProxy = proxyMap.get(target);
|
|
1788
|
+
if (existingProxy) {
|
|
1789
|
+
return existingProxy;
|
|
1790
|
+
}
|
|
1791
|
+
const targetType = getTargetType(target);
|
|
1792
|
+
if (targetType === 0) {
|
|
1793
|
+
return target;
|
|
1794
|
+
}
|
|
1795
|
+
const proxy = new Proxy(target, targetType === 2 ? collectionHandlers : baseHandlers);
|
|
1796
|
+
proxyMap.set(target, proxy);
|
|
1797
|
+
return proxy;
|
|
1798
|
+
}
|
|
1799
|
+
function isReactive2(value) {
|
|
1800
|
+
if (isReadonly(value)) {
|
|
1801
|
+
return isReactive2(value["__v_raw"]);
|
|
1802
|
+
}
|
|
1803
|
+
return !!(value && value["__v_isReactive"]);
|
|
1804
|
+
}
|
|
1805
|
+
function isReadonly(value) {
|
|
1806
|
+
return !!(value && value["__v_isReadonly"]);
|
|
1807
|
+
}
|
|
1808
|
+
function isShallow(value) {
|
|
1809
|
+
return !!(value && value["__v_isShallow"]);
|
|
1810
|
+
}
|
|
1811
|
+
function isProxy(value) {
|
|
1812
|
+
return value ? !!value["__v_raw"] : false;
|
|
1813
|
+
}
|
|
1814
|
+
function toRaw2(observed) {
|
|
1815
|
+
const raw = observed && observed["__v_raw"];
|
|
1816
|
+
return raw ? toRaw2(raw) : observed;
|
|
1817
|
+
}
|
|
1818
|
+
function markRaw2(value) {
|
|
1819
|
+
if (!shared.hasOwn(value, "__v_skip") && Object.isExtensible(value)) {
|
|
1820
|
+
shared.def(value, "__v_skip", true);
|
|
1821
|
+
}
|
|
1822
|
+
return value;
|
|
1823
|
+
}
|
|
1824
|
+
var toReactive = (value) => shared.isObject(value) ? reactive2(value) : value;
|
|
1825
|
+
var toReadonly = (value) => shared.isObject(value) ? readonly(value) : value;
|
|
1826
|
+
function isRef3(r) {
|
|
1827
|
+
return r ? r["__v_isRef"] === true : false;
|
|
1828
|
+
}
|
|
1829
|
+
function ref2(value) {
|
|
1830
|
+
return createRef2(value, false);
|
|
1831
|
+
}
|
|
1832
|
+
function shallowRef(value) {
|
|
1833
|
+
return createRef2(value, true);
|
|
1834
|
+
}
|
|
1835
|
+
function createRef2(rawValue, shallow) {
|
|
1836
|
+
if (isRef3(rawValue)) {
|
|
1837
|
+
return rawValue;
|
|
1838
|
+
}
|
|
1839
|
+
return new RefImpl(rawValue, shallow);
|
|
1840
|
+
}
|
|
1841
|
+
|
|
1842
|
+
class RefImpl {
|
|
1843
|
+
constructor(value, isShallow2) {
|
|
1844
|
+
this.dep = new Dep;
|
|
1845
|
+
this["__v_isRef"] = true;
|
|
1846
|
+
this["__v_isShallow"] = false;
|
|
1847
|
+
this._rawValue = isShallow2 ? value : toRaw2(value);
|
|
1848
|
+
this._value = isShallow2 ? value : toReactive(value);
|
|
1849
|
+
this["__v_isShallow"] = isShallow2;
|
|
1850
|
+
}
|
|
1851
|
+
get value() {
|
|
1852
|
+
{
|
|
1853
|
+
this.dep.track({
|
|
1854
|
+
target: this,
|
|
1855
|
+
type: "get",
|
|
1856
|
+
key: "value"
|
|
1857
|
+
});
|
|
1858
|
+
}
|
|
1859
|
+
return this._value;
|
|
1860
|
+
}
|
|
1861
|
+
set value(newValue) {
|
|
1862
|
+
const oldValue = this._rawValue;
|
|
1863
|
+
const useDirectValue = this["__v_isShallow"] || isShallow(newValue) || isReadonly(newValue);
|
|
1864
|
+
newValue = useDirectValue ? newValue : toRaw2(newValue);
|
|
1865
|
+
if (shared.hasChanged(newValue, oldValue)) {
|
|
1866
|
+
this._rawValue = newValue;
|
|
1867
|
+
this._value = useDirectValue ? newValue : toReactive(newValue);
|
|
1868
|
+
{
|
|
1869
|
+
this.dep.trigger({
|
|
1870
|
+
target: this,
|
|
1871
|
+
type: "set",
|
|
1872
|
+
key: "value",
|
|
1873
|
+
newValue,
|
|
1874
|
+
oldValue
|
|
1875
|
+
});
|
|
1876
|
+
}
|
|
1877
|
+
}
|
|
1878
|
+
}
|
|
1879
|
+
}
|
|
1880
|
+
function triggerRef2(ref22) {
|
|
1881
|
+
if (ref22.dep) {
|
|
1882
|
+
{
|
|
1883
|
+
ref22.dep.trigger({
|
|
1884
|
+
target: ref22,
|
|
1885
|
+
type: "set",
|
|
1886
|
+
key: "value",
|
|
1887
|
+
newValue: ref22._value
|
|
1888
|
+
});
|
|
1889
|
+
}
|
|
1890
|
+
}
|
|
1891
|
+
}
|
|
1892
|
+
function unref3(ref22) {
|
|
1893
|
+
return isRef3(ref22) ? ref22.value : ref22;
|
|
1894
|
+
}
|
|
1895
|
+
function toValue(source) {
|
|
1896
|
+
return shared.isFunction(source) ? source() : unref3(source);
|
|
1897
|
+
}
|
|
1898
|
+
var shallowUnwrapHandlers = {
|
|
1899
|
+
get: (target, key, receiver) => key === "__v_raw" ? target : unref3(Reflect.get(target, key, receiver)),
|
|
1900
|
+
set: (target, key, value, receiver) => {
|
|
1901
|
+
const oldValue = target[key];
|
|
1902
|
+
if (isRef3(oldValue) && !isRef3(value)) {
|
|
1903
|
+
oldValue.value = value;
|
|
1904
|
+
return true;
|
|
1905
|
+
} else {
|
|
1906
|
+
return Reflect.set(target, key, value, receiver);
|
|
1907
|
+
}
|
|
1908
|
+
}
|
|
1909
|
+
};
|
|
1910
|
+
function proxyRefs(objectWithRefs) {
|
|
1911
|
+
return isReactive2(objectWithRefs) ? objectWithRefs : new Proxy(objectWithRefs, shallowUnwrapHandlers);
|
|
1912
|
+
}
|
|
1913
|
+
|
|
1914
|
+
class CustomRefImpl {
|
|
1915
|
+
constructor(factory) {
|
|
1916
|
+
this["__v_isRef"] = true;
|
|
1917
|
+
this._value = undefined;
|
|
1918
|
+
const dep = this.dep = new Dep;
|
|
1919
|
+
const { get, set } = factory(dep.track.bind(dep), dep.trigger.bind(dep));
|
|
1920
|
+
this._get = get;
|
|
1921
|
+
this._set = set;
|
|
1922
|
+
}
|
|
1923
|
+
get value() {
|
|
1924
|
+
return this._value = this._get();
|
|
1925
|
+
}
|
|
1926
|
+
set value(newVal) {
|
|
1927
|
+
this._set(newVal);
|
|
1928
|
+
}
|
|
1929
|
+
}
|
|
1930
|
+
function customRef(factory) {
|
|
1931
|
+
return new CustomRefImpl(factory);
|
|
1932
|
+
}
|
|
1933
|
+
function toRefs2(object) {
|
|
1934
|
+
if (!isProxy(object)) {
|
|
1935
|
+
warn(`toRefs() expects a reactive object but received a plain one.`);
|
|
1936
|
+
}
|
|
1937
|
+
const ret = shared.isArray(object) ? new Array(object.length) : {};
|
|
1938
|
+
for (const key in object) {
|
|
1939
|
+
ret[key] = propertyToRef(object, key);
|
|
1940
|
+
}
|
|
1941
|
+
return ret;
|
|
1942
|
+
}
|
|
1943
|
+
|
|
1944
|
+
class ObjectRefImpl {
|
|
1945
|
+
constructor(_object, _key, _defaultValue) {
|
|
1946
|
+
this._object = _object;
|
|
1947
|
+
this._key = _key;
|
|
1948
|
+
this._defaultValue = _defaultValue;
|
|
1949
|
+
this["__v_isRef"] = true;
|
|
1950
|
+
this._value = undefined;
|
|
1951
|
+
}
|
|
1952
|
+
get value() {
|
|
1953
|
+
const val = this._object[this._key];
|
|
1954
|
+
return this._value = val === undefined ? this._defaultValue : val;
|
|
1955
|
+
}
|
|
1956
|
+
set value(newVal) {
|
|
1957
|
+
this._object[this._key] = newVal;
|
|
1958
|
+
}
|
|
1959
|
+
get dep() {
|
|
1960
|
+
return getDepFromReactive(toRaw2(this._object), this._key);
|
|
1961
|
+
}
|
|
1962
|
+
}
|
|
1963
|
+
|
|
1964
|
+
class GetterRefImpl {
|
|
1965
|
+
constructor(_getter) {
|
|
1966
|
+
this._getter = _getter;
|
|
1967
|
+
this["__v_isRef"] = true;
|
|
1968
|
+
this["__v_isReadonly"] = true;
|
|
1969
|
+
this._value = undefined;
|
|
1970
|
+
}
|
|
1971
|
+
get value() {
|
|
1972
|
+
return this._value = this._getter();
|
|
1973
|
+
}
|
|
1974
|
+
}
|
|
1975
|
+
function toRef2(source, key, defaultValue) {
|
|
1976
|
+
if (isRef3(source)) {
|
|
1977
|
+
return source;
|
|
1978
|
+
} else if (shared.isFunction(source)) {
|
|
1979
|
+
return new GetterRefImpl(source);
|
|
1980
|
+
} else if (shared.isObject(source) && arguments.length > 1) {
|
|
1981
|
+
return propertyToRef(source, key, defaultValue);
|
|
1982
|
+
} else {
|
|
1983
|
+
return ref2(source);
|
|
1984
|
+
}
|
|
1985
|
+
}
|
|
1986
|
+
function propertyToRef(source, key, defaultValue) {
|
|
1987
|
+
const val = source[key];
|
|
1988
|
+
return isRef3(val) ? val : new ObjectRefImpl(source, key, defaultValue);
|
|
1989
|
+
}
|
|
1990
|
+
|
|
1991
|
+
class ComputedRefImpl {
|
|
1992
|
+
constructor(fn, setter, isSSR) {
|
|
1993
|
+
this.fn = fn;
|
|
1994
|
+
this.setter = setter;
|
|
1995
|
+
this._value = undefined;
|
|
1996
|
+
this.dep = new Dep(this);
|
|
1997
|
+
this.__v_isRef = true;
|
|
1998
|
+
this.deps = undefined;
|
|
1999
|
+
this.depsTail = undefined;
|
|
2000
|
+
this.flags = 16;
|
|
2001
|
+
this.globalVersion = globalVersion - 1;
|
|
2002
|
+
this.next = undefined;
|
|
2003
|
+
this.effect = this;
|
|
2004
|
+
this["__v_isReadonly"] = !setter;
|
|
2005
|
+
this.isSSR = isSSR;
|
|
2006
|
+
}
|
|
2007
|
+
notify() {
|
|
2008
|
+
this.flags |= 16;
|
|
2009
|
+
if (!(this.flags & 8) && activeSub !== this) {
|
|
2010
|
+
batch(this, true);
|
|
2011
|
+
return true;
|
|
2012
|
+
}
|
|
2013
|
+
}
|
|
2014
|
+
get value() {
|
|
2015
|
+
const link = this.dep.track({
|
|
2016
|
+
target: this,
|
|
2017
|
+
type: "get",
|
|
2018
|
+
key: "value"
|
|
2019
|
+
});
|
|
2020
|
+
refreshComputed(this);
|
|
2021
|
+
if (link) {
|
|
2022
|
+
link.version = this.dep.version;
|
|
2023
|
+
}
|
|
2024
|
+
return this._value;
|
|
2025
|
+
}
|
|
2026
|
+
set value(newValue) {
|
|
2027
|
+
if (this.setter) {
|
|
2028
|
+
this.setter(newValue);
|
|
2029
|
+
} else {
|
|
2030
|
+
warn("Write operation failed: computed value is readonly");
|
|
2031
|
+
}
|
|
2032
|
+
}
|
|
2033
|
+
}
|
|
2034
|
+
function computed2(getterOrOptions, debugOptions, isSSR = false) {
|
|
2035
|
+
let getter;
|
|
2036
|
+
let setter;
|
|
2037
|
+
if (shared.isFunction(getterOrOptions)) {
|
|
2038
|
+
getter = getterOrOptions;
|
|
2039
|
+
} else {
|
|
2040
|
+
getter = getterOrOptions.get;
|
|
2041
|
+
setter = getterOrOptions.set;
|
|
2042
|
+
}
|
|
2043
|
+
const cRef = new ComputedRefImpl(getter, setter, isSSR);
|
|
2044
|
+
if (debugOptions && !isSSR) {
|
|
2045
|
+
cRef.onTrack = debugOptions.onTrack;
|
|
2046
|
+
cRef.onTrigger = debugOptions.onTrigger;
|
|
2047
|
+
}
|
|
2048
|
+
return cRef;
|
|
2049
|
+
}
|
|
2050
|
+
var TrackOpTypes = {
|
|
2051
|
+
GET: "get",
|
|
2052
|
+
HAS: "has",
|
|
2053
|
+
ITERATE: "iterate"
|
|
2054
|
+
};
|
|
2055
|
+
var TriggerOpTypes = {
|
|
2056
|
+
SET: "set",
|
|
2057
|
+
ADD: "add",
|
|
2058
|
+
DELETE: "delete",
|
|
2059
|
+
CLEAR: "clear"
|
|
2060
|
+
};
|
|
2061
|
+
var ReactiveFlags2 = {
|
|
2062
|
+
SKIP: "__v_skip",
|
|
2063
|
+
IS_REACTIVE: "__v_isReactive",
|
|
2064
|
+
IS_READONLY: "__v_isReadonly",
|
|
2065
|
+
IS_SHALLOW: "__v_isShallow",
|
|
2066
|
+
RAW: "__v_raw",
|
|
2067
|
+
IS_REF: "__v_isRef"
|
|
2068
|
+
};
|
|
2069
|
+
var WatchErrorCodes = {
|
|
2070
|
+
WATCH_GETTER: 2,
|
|
2071
|
+
"2": "WATCH_GETTER",
|
|
2072
|
+
WATCH_CALLBACK: 3,
|
|
2073
|
+
"3": "WATCH_CALLBACK",
|
|
2074
|
+
WATCH_CLEANUP: 4,
|
|
2075
|
+
"4": "WATCH_CLEANUP"
|
|
2076
|
+
};
|
|
2077
|
+
var INITIAL_WATCHER_VALUE = {};
|
|
2078
|
+
var cleanupMap = /* @__PURE__ */ new WeakMap;
|
|
2079
|
+
var activeWatcher = undefined;
|
|
2080
|
+
function getCurrentWatcher() {
|
|
2081
|
+
return activeWatcher;
|
|
2082
|
+
}
|
|
2083
|
+
function onWatcherCleanup(cleanupFn, failSilently = false, owner = activeWatcher) {
|
|
2084
|
+
if (owner) {
|
|
2085
|
+
let cleanups = cleanupMap.get(owner);
|
|
2086
|
+
if (!cleanups)
|
|
2087
|
+
cleanupMap.set(owner, cleanups = []);
|
|
2088
|
+
cleanups.push(cleanupFn);
|
|
2089
|
+
} else if (!failSilently) {
|
|
2090
|
+
warn(`onWatcherCleanup() was called when there was no active watcher to associate with.`);
|
|
2091
|
+
}
|
|
2092
|
+
}
|
|
2093
|
+
function watch2(source, cb, options = shared.EMPTY_OBJ) {
|
|
2094
|
+
const { immediate, deep, once, scheduler, augmentJob, call } = options;
|
|
2095
|
+
const warnInvalidSource = (s) => {
|
|
2096
|
+
(options.onWarn || warn)(`Invalid watch source: `, s, `A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`);
|
|
2097
|
+
};
|
|
2098
|
+
const reactiveGetter = (source2) => {
|
|
2099
|
+
if (deep)
|
|
2100
|
+
return source2;
|
|
2101
|
+
if (isShallow(source2) || deep === false || deep === 0)
|
|
2102
|
+
return traverse2(source2, 1);
|
|
2103
|
+
return traverse2(source2);
|
|
2104
|
+
};
|
|
2105
|
+
let effect2;
|
|
2106
|
+
let getter;
|
|
2107
|
+
let cleanup;
|
|
2108
|
+
let boundCleanup;
|
|
2109
|
+
let forceTrigger = false;
|
|
2110
|
+
let isMultiSource = false;
|
|
2111
|
+
if (isRef3(source)) {
|
|
2112
|
+
getter = () => source.value;
|
|
2113
|
+
forceTrigger = isShallow(source);
|
|
2114
|
+
} else if (isReactive2(source)) {
|
|
2115
|
+
getter = () => reactiveGetter(source);
|
|
2116
|
+
forceTrigger = true;
|
|
2117
|
+
} else if (shared.isArray(source)) {
|
|
2118
|
+
isMultiSource = true;
|
|
2119
|
+
forceTrigger = source.some((s) => isReactive2(s) || isShallow(s));
|
|
2120
|
+
getter = () => source.map((s) => {
|
|
2121
|
+
if (isRef3(s)) {
|
|
2122
|
+
return s.value;
|
|
2123
|
+
} else if (isReactive2(s)) {
|
|
2124
|
+
return reactiveGetter(s);
|
|
2125
|
+
} else if (shared.isFunction(s)) {
|
|
2126
|
+
return call ? call(s, 2) : s();
|
|
2127
|
+
} else {
|
|
2128
|
+
warnInvalidSource(s);
|
|
2129
|
+
}
|
|
2130
|
+
});
|
|
2131
|
+
} else if (shared.isFunction(source)) {
|
|
2132
|
+
if (cb) {
|
|
2133
|
+
getter = call ? () => call(source, 2) : source;
|
|
2134
|
+
} else {
|
|
2135
|
+
getter = () => {
|
|
2136
|
+
if (cleanup) {
|
|
2137
|
+
pauseTracking();
|
|
2138
|
+
try {
|
|
2139
|
+
cleanup();
|
|
2140
|
+
} finally {
|
|
2141
|
+
resetTracking();
|
|
2142
|
+
}
|
|
2143
|
+
}
|
|
2144
|
+
const currentEffect = activeWatcher;
|
|
2145
|
+
activeWatcher = effect2;
|
|
2146
|
+
try {
|
|
2147
|
+
return call ? call(source, 3, [boundCleanup]) : source(boundCleanup);
|
|
2148
|
+
} finally {
|
|
2149
|
+
activeWatcher = currentEffect;
|
|
2150
|
+
}
|
|
2151
|
+
};
|
|
2152
|
+
}
|
|
2153
|
+
} else {
|
|
2154
|
+
getter = shared.NOOP;
|
|
2155
|
+
warnInvalidSource(source);
|
|
2156
|
+
}
|
|
2157
|
+
if (cb && deep) {
|
|
2158
|
+
const baseGetter = getter;
|
|
2159
|
+
const depth = deep === true ? Infinity : deep;
|
|
2160
|
+
getter = () => traverse2(baseGetter(), depth);
|
|
2161
|
+
}
|
|
2162
|
+
const scope = getCurrentScope();
|
|
2163
|
+
const watchHandle = () => {
|
|
2164
|
+
effect2.stop();
|
|
2165
|
+
if (scope && scope.active) {
|
|
2166
|
+
shared.remove(scope.effects, effect2);
|
|
2167
|
+
}
|
|
2168
|
+
};
|
|
2169
|
+
if (once && cb) {
|
|
2170
|
+
const _cb = cb;
|
|
2171
|
+
cb = (...args) => {
|
|
2172
|
+
_cb(...args);
|
|
2173
|
+
watchHandle();
|
|
2174
|
+
};
|
|
2175
|
+
}
|
|
2176
|
+
let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
|
|
2177
|
+
const job = (immediateFirstRun) => {
|
|
2178
|
+
if (!(effect2.flags & 1) || !effect2.dirty && !immediateFirstRun) {
|
|
2179
|
+
return;
|
|
2180
|
+
}
|
|
2181
|
+
if (cb) {
|
|
2182
|
+
const newValue = effect2.run();
|
|
2183
|
+
if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => shared.hasChanged(v, oldValue[i])) : shared.hasChanged(newValue, oldValue))) {
|
|
2184
|
+
if (cleanup) {
|
|
2185
|
+
cleanup();
|
|
2186
|
+
}
|
|
2187
|
+
const currentWatcher = activeWatcher;
|
|
2188
|
+
activeWatcher = effect2;
|
|
2189
|
+
try {
|
|
2190
|
+
const args = [
|
|
2191
|
+
newValue,
|
|
2192
|
+
oldValue === INITIAL_WATCHER_VALUE ? undefined : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
|
|
2193
|
+
boundCleanup
|
|
2194
|
+
];
|
|
2195
|
+
call ? call(cb, 3, args) : cb(...args);
|
|
2196
|
+
oldValue = newValue;
|
|
2197
|
+
} finally {
|
|
2198
|
+
activeWatcher = currentWatcher;
|
|
2199
|
+
}
|
|
2200
|
+
}
|
|
2201
|
+
} else {
|
|
2202
|
+
effect2.run();
|
|
2203
|
+
}
|
|
2204
|
+
};
|
|
2205
|
+
if (augmentJob) {
|
|
2206
|
+
augmentJob(job);
|
|
2207
|
+
}
|
|
2208
|
+
effect2 = new ReactiveEffect(getter);
|
|
2209
|
+
effect2.scheduler = scheduler ? () => scheduler(job, false) : job;
|
|
2210
|
+
boundCleanup = (fn) => onWatcherCleanup(fn, false, effect2);
|
|
2211
|
+
cleanup = effect2.onStop = () => {
|
|
2212
|
+
const cleanups = cleanupMap.get(effect2);
|
|
2213
|
+
if (cleanups) {
|
|
2214
|
+
if (call) {
|
|
2215
|
+
call(cleanups, 4);
|
|
2216
|
+
} else {
|
|
2217
|
+
for (const cleanup2 of cleanups)
|
|
2218
|
+
cleanup2();
|
|
2219
|
+
}
|
|
2220
|
+
cleanupMap.delete(effect2);
|
|
2221
|
+
}
|
|
2222
|
+
};
|
|
2223
|
+
{
|
|
2224
|
+
effect2.onTrack = options.onTrack;
|
|
2225
|
+
effect2.onTrigger = options.onTrigger;
|
|
2226
|
+
}
|
|
2227
|
+
if (cb) {
|
|
2228
|
+
if (immediate) {
|
|
2229
|
+
job(true);
|
|
2230
|
+
} else {
|
|
2231
|
+
oldValue = effect2.run();
|
|
2232
|
+
}
|
|
2233
|
+
} else if (scheduler) {
|
|
2234
|
+
scheduler(job.bind(null, true), true);
|
|
2235
|
+
} else {
|
|
2236
|
+
effect2.run();
|
|
2237
|
+
}
|
|
2238
|
+
watchHandle.pause = effect2.pause.bind(effect2);
|
|
2239
|
+
watchHandle.resume = effect2.resume.bind(effect2);
|
|
2240
|
+
watchHandle.stop = watchHandle;
|
|
2241
|
+
return watchHandle;
|
|
2242
|
+
}
|
|
2243
|
+
function traverse2(value, depth = Infinity, seen) {
|
|
2244
|
+
if (depth <= 0 || !shared.isObject(value) || value["__v_skip"]) {
|
|
2245
|
+
return value;
|
|
2246
|
+
}
|
|
2247
|
+
seen = seen || /* @__PURE__ */ new Set;
|
|
2248
|
+
if (seen.has(value)) {
|
|
2249
|
+
return value;
|
|
2250
|
+
}
|
|
2251
|
+
seen.add(value);
|
|
2252
|
+
depth--;
|
|
2253
|
+
if (isRef3(value)) {
|
|
2254
|
+
traverse2(value.value, depth, seen);
|
|
2255
|
+
} else if (shared.isArray(value)) {
|
|
2256
|
+
for (let i = 0;i < value.length; i++) {
|
|
2257
|
+
traverse2(value[i], depth, seen);
|
|
2258
|
+
}
|
|
2259
|
+
} else if (shared.isSet(value) || shared.isMap(value)) {
|
|
2260
|
+
value.forEach((v) => {
|
|
2261
|
+
traverse2(v, depth, seen);
|
|
2262
|
+
});
|
|
2263
|
+
} else if (shared.isPlainObject(value)) {
|
|
2264
|
+
for (const key in value) {
|
|
2265
|
+
traverse2(value[key], depth, seen);
|
|
2266
|
+
}
|
|
2267
|
+
for (const key of Object.getOwnPropertySymbols(value)) {
|
|
2268
|
+
if (Object.prototype.propertyIsEnumerable.call(value, key)) {
|
|
2269
|
+
traverse2(value[key], depth, seen);
|
|
2270
|
+
}
|
|
2271
|
+
}
|
|
2272
|
+
}
|
|
2273
|
+
return value;
|
|
2274
|
+
}
|
|
2275
|
+
exports2.ARRAY_ITERATE_KEY = ARRAY_ITERATE_KEY;
|
|
2276
|
+
exports2.EffectFlags = EffectFlags;
|
|
2277
|
+
exports2.EffectScope = EffectScope;
|
|
2278
|
+
exports2.ITERATE_KEY = ITERATE_KEY;
|
|
2279
|
+
exports2.MAP_KEY_ITERATE_KEY = MAP_KEY_ITERATE_KEY;
|
|
2280
|
+
exports2.ReactiveEffect = ReactiveEffect;
|
|
2281
|
+
exports2.ReactiveFlags = ReactiveFlags2;
|
|
2282
|
+
exports2.TrackOpTypes = TrackOpTypes;
|
|
2283
|
+
exports2.TriggerOpTypes = TriggerOpTypes;
|
|
2284
|
+
exports2.WatchErrorCodes = WatchErrorCodes;
|
|
2285
|
+
exports2.computed = computed2;
|
|
2286
|
+
exports2.customRef = customRef;
|
|
2287
|
+
exports2.effect = effect;
|
|
2288
|
+
exports2.effectScope = effectScope;
|
|
2289
|
+
exports2.enableTracking = enableTracking;
|
|
2290
|
+
exports2.getCurrentScope = getCurrentScope;
|
|
2291
|
+
exports2.getCurrentWatcher = getCurrentWatcher;
|
|
2292
|
+
exports2.isProxy = isProxy;
|
|
2293
|
+
exports2.isReactive = isReactive2;
|
|
2294
|
+
exports2.isReadonly = isReadonly;
|
|
2295
|
+
exports2.isRef = isRef3;
|
|
2296
|
+
exports2.isShallow = isShallow;
|
|
2297
|
+
exports2.markRaw = markRaw2;
|
|
2298
|
+
exports2.onEffectCleanup = onEffectCleanup;
|
|
2299
|
+
exports2.onScopeDispose = onScopeDispose;
|
|
2300
|
+
exports2.onWatcherCleanup = onWatcherCleanup;
|
|
2301
|
+
exports2.pauseTracking = pauseTracking;
|
|
2302
|
+
exports2.proxyRefs = proxyRefs;
|
|
2303
|
+
exports2.reactive = reactive2;
|
|
2304
|
+
exports2.reactiveReadArray = reactiveReadArray;
|
|
2305
|
+
exports2.readonly = readonly;
|
|
2306
|
+
exports2.ref = ref2;
|
|
2307
|
+
exports2.resetTracking = resetTracking;
|
|
2308
|
+
exports2.shallowReactive = shallowReactive;
|
|
2309
|
+
exports2.shallowReadArray = shallowReadArray;
|
|
2310
|
+
exports2.shallowReadonly = shallowReadonly;
|
|
2311
|
+
exports2.shallowRef = shallowRef;
|
|
2312
|
+
exports2.stop = stop;
|
|
2313
|
+
exports2.toRaw = toRaw2;
|
|
2314
|
+
exports2.toReactive = toReactive;
|
|
2315
|
+
exports2.toReadonly = toReadonly;
|
|
2316
|
+
exports2.toRef = toRef2;
|
|
2317
|
+
exports2.toRefs = toRefs2;
|
|
2318
|
+
exports2.toValue = toValue;
|
|
2319
|
+
exports2.track = track2;
|
|
2320
|
+
exports2.traverse = traverse2;
|
|
2321
|
+
exports2.trigger = trigger2;
|
|
2322
|
+
exports2.triggerRef = triggerRef2;
|
|
2323
|
+
exports2.unref = unref3;
|
|
2324
|
+
exports2.watch = watch2;
|
|
2325
|
+
});
|
|
28
2326
|
|
|
29
2327
|
// src/index.ts
|
|
30
2328
|
var exports_src = {};
|
|
@@ -163,6 +2461,22 @@ function setInPathCache(root, pathKey, value) {
|
|
|
163
2461
|
cache.set(pathKey, value);
|
|
164
2462
|
cleanupPathCache(root);
|
|
165
2463
|
}
|
|
2464
|
+
function evictDescendantsFromPathCache(root, pathKey) {
|
|
2465
|
+
const cache = pathCache.get(root);
|
|
2466
|
+
if (!cache)
|
|
2467
|
+
return;
|
|
2468
|
+
const prefix = pathKey + ".";
|
|
2469
|
+
let evicted = 0;
|
|
2470
|
+
for (const key of cache.keys()) {
|
|
2471
|
+
if (key.startsWith(prefix)) {
|
|
2472
|
+
cache.delete(key);
|
|
2473
|
+
evicted++;
|
|
2474
|
+
}
|
|
2475
|
+
}
|
|
2476
|
+
if (evicted > 0) {
|
|
2477
|
+
pathCacheSize.set(root, (pathCacheSize.get(root) ?? cache.size) - evicted);
|
|
2478
|
+
}
|
|
2479
|
+
}
|
|
166
2480
|
function getPathConcat(path) {
|
|
167
2481
|
const result = pathConcatCache.get(path);
|
|
168
2482
|
if (result !== undefined) {
|
|
@@ -467,6 +2781,10 @@ function updateState(root, event) {
|
|
|
467
2781
|
return;
|
|
468
2782
|
}
|
|
469
2783
|
handler(targetForHandler, keyForHandler, event);
|
|
2784
|
+
if (action === "set" && event.newValue != null && typeof event.newValue === "object") {
|
|
2785
|
+
const fullPathKey = path.join(".");
|
|
2786
|
+
evictDescendantsFromPathCache(root, fullPathKey);
|
|
2787
|
+
}
|
|
470
2788
|
}
|
|
471
2789
|
// src/watch-effect.ts
|
|
472
2790
|
var activeEffect = null;
|
|
@@ -1660,103 +3978,265 @@ function markRaw(obj) {
|
|
|
1660
3978
|
}
|
|
1661
3979
|
// src/integrations/vue3.ts
|
|
1662
3980
|
var import_vue = require("vue");
|
|
3981
|
+
var import_reactivity = __toESM(require_reactivity_cjs(), 1);
|
|
1663
3982
|
function trackVueReactiveEvents(vueState, emit, options = {}) {
|
|
1664
3983
|
const { emitInitialReplace = true } = options;
|
|
1665
|
-
function isObject4(v) {
|
|
1666
|
-
return v && typeof v === "object";
|
|
1667
|
-
}
|
|
1668
3984
|
if (emitInitialReplace) {
|
|
1669
3985
|
try {
|
|
1670
3986
|
emit({ action: "replace", path: [], newValue: deepClone(vueState) });
|
|
1671
3987
|
} catch (e) {}
|
|
1672
3988
|
}
|
|
1673
|
-
|
|
1674
|
-
const
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
3989
|
+
const prev = {};
|
|
3990
|
+
const pathStack = [];
|
|
3991
|
+
const keyStops = new Map;
|
|
3992
|
+
for (const k of Object.keys(vueState)) {
|
|
3993
|
+
prev[k] = deepClone(vueState[k]);
|
|
3994
|
+
}
|
|
3995
|
+
function createKeyEffect(k) {
|
|
3996
|
+
const stop = import_vue.watchEffect(() => {
|
|
3997
|
+
if (!(k in vueState))
|
|
3998
|
+
return;
|
|
3999
|
+
const currVal = vueState[k];
|
|
4000
|
+
pathStack.push(k);
|
|
4001
|
+
try {
|
|
4002
|
+
const result = diffAndClone(currVal, prev[k], pathStack, emit);
|
|
4003
|
+
if (result !== prev[k]) {
|
|
4004
|
+
prev[k] = result;
|
|
4005
|
+
}
|
|
4006
|
+
} catch (e) {
|
|
4007
|
+
pathStack.length = 0;
|
|
4008
|
+
prev[k] = deepClone(vueState[k]);
|
|
4009
|
+
return;
|
|
4010
|
+
}
|
|
4011
|
+
pathStack.pop();
|
|
4012
|
+
}, { flush: "sync" });
|
|
4013
|
+
keyStops.set(k, stop);
|
|
4014
|
+
}
|
|
4015
|
+
for (const k of Object.keys(prev)) {
|
|
4016
|
+
createKeyEffect(k);
|
|
4017
|
+
}
|
|
4018
|
+
const stopRoot = import_vue.watchEffect(() => {
|
|
4019
|
+
const currKeys = Object.keys(vueState);
|
|
4020
|
+
const currKeySet = new Set(currKeys);
|
|
4021
|
+
const prevKeySet = new Set(Object.keys(prev));
|
|
4022
|
+
for (const k of currKeys) {
|
|
4023
|
+
if (!prevKeySet.has(k)) {
|
|
4024
|
+
import_reactivity.pauseTracking();
|
|
4025
|
+
const cloned = deepClone(vueState[k]);
|
|
4026
|
+
import_reactivity.resetTracking();
|
|
4027
|
+
pathStack.push(k);
|
|
4028
|
+
emit({ action: "set", path: pathStack.slice(), newValue: cloned });
|
|
4029
|
+
pathStack.pop();
|
|
4030
|
+
prev[k] = cloned;
|
|
4031
|
+
createKeyEffect(k);
|
|
1685
4032
|
}
|
|
1686
|
-
return;
|
|
1687
4033
|
}
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
4034
|
+
for (const k of prevKeySet) {
|
|
4035
|
+
if (!currKeySet.has(k)) {
|
|
4036
|
+
pathStack.push(k);
|
|
4037
|
+
emit({ action: "delete", path: pathStack.slice(), oldValue: prev[k] });
|
|
4038
|
+
pathStack.pop();
|
|
4039
|
+
delete prev[k];
|
|
4040
|
+
keyStops.get(k)?.();
|
|
4041
|
+
keyStops.delete(k);
|
|
4042
|
+
}
|
|
1691
4043
|
}
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
4044
|
+
}, { flush: "sync" });
|
|
4045
|
+
return () => {
|
|
4046
|
+
stopRoot();
|
|
4047
|
+
for (const stop of keyStops.values())
|
|
4048
|
+
stop();
|
|
4049
|
+
keyStops.clear();
|
|
4050
|
+
};
|
|
4051
|
+
}
|
|
4052
|
+
function typeTag(v) {
|
|
4053
|
+
if (v === null || typeof v !== "object")
|
|
4054
|
+
return "primitive";
|
|
4055
|
+
if (Array.isArray(v))
|
|
4056
|
+
return "array";
|
|
4057
|
+
if (v instanceof Map)
|
|
4058
|
+
return "map";
|
|
4059
|
+
if (v instanceof Set)
|
|
4060
|
+
return "set";
|
|
4061
|
+
if (v instanceof Date)
|
|
4062
|
+
return "date";
|
|
4063
|
+
return "object";
|
|
4064
|
+
}
|
|
4065
|
+
function diffAndClone(curr, old, pathStack, emit) {
|
|
4066
|
+
if (curr === null || typeof curr !== "object") {
|
|
4067
|
+
if (curr !== old) {
|
|
4068
|
+
emit({ action: "set", path: pathStack.slice(), oldValue: old, newValue: curr });
|
|
1695
4069
|
}
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
4070
|
+
return curr;
|
|
4071
|
+
}
|
|
4072
|
+
if (typeTag(curr) !== typeTag(old)) {
|
|
4073
|
+
emit({ action: "set", path: pathStack.slice(), oldValue: old, newValue: deepClone(curr) });
|
|
4074
|
+
return deepClone(curr);
|
|
4075
|
+
}
|
|
4076
|
+
if (curr instanceof Date) {
|
|
4077
|
+
if (!(old instanceof Date) || +curr !== +old) {
|
|
4078
|
+
emit({ action: "set", path: pathStack.slice(), oldValue: old, newValue: new Date(+curr) });
|
|
4079
|
+
return new Date(+curr);
|
|
1699
4080
|
}
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
4081
|
+
return old;
|
|
4082
|
+
}
|
|
4083
|
+
if (Array.isArray(curr)) {
|
|
4084
|
+
return diffAndCloneArray(curr, old, pathStack, emit);
|
|
4085
|
+
}
|
|
4086
|
+
if (curr instanceof Map) {
|
|
4087
|
+
return diffAndCloneMap(curr, old, pathStack, emit);
|
|
4088
|
+
}
|
|
4089
|
+
if (curr instanceof Set) {
|
|
4090
|
+
return diffAndCloneSet(curr, old, pathStack, emit);
|
|
4091
|
+
}
|
|
4092
|
+
return diffAndCloneObject(curr, old, pathStack, emit);
|
|
4093
|
+
}
|
|
4094
|
+
function diffAndCloneObject(curr, old, pathStack, emit) {
|
|
4095
|
+
const currKeys = Object.keys(curr);
|
|
4096
|
+
const oldKeys = Object.keys(old);
|
|
4097
|
+
let changed = false;
|
|
4098
|
+
let result = null;
|
|
4099
|
+
for (let i = 0;i < oldKeys.length; i++) {
|
|
4100
|
+
const k = oldKeys[i];
|
|
4101
|
+
if (!(k in curr)) {
|
|
4102
|
+
if (!changed) {
|
|
4103
|
+
changed = true;
|
|
4104
|
+
result = { ...old };
|
|
4105
|
+
}
|
|
4106
|
+
pathStack.push(k);
|
|
4107
|
+
emit({ action: "delete", path: pathStack.slice(), oldValue: old[k] });
|
|
4108
|
+
pathStack.pop();
|
|
4109
|
+
delete result[k];
|
|
1703
4110
|
}
|
|
1704
|
-
|
|
1705
|
-
|
|
4111
|
+
}
|
|
4112
|
+
for (let i = 0;i < currKeys.length; i++) {
|
|
4113
|
+
const k = currKeys[i];
|
|
4114
|
+
if (!(k in old)) {
|
|
4115
|
+
if (!changed) {
|
|
4116
|
+
changed = true;
|
|
4117
|
+
result = { ...old };
|
|
4118
|
+
}
|
|
4119
|
+
pathStack.push(k);
|
|
4120
|
+
emit({ action: "set", path: pathStack.slice(), newValue: deepClone(curr[k]) });
|
|
4121
|
+
pathStack.pop();
|
|
4122
|
+
result[k] = deepClone(curr[k]);
|
|
4123
|
+
} else {
|
|
4124
|
+
pathStack.push(k);
|
|
4125
|
+
const childResult = diffAndClone(curr[k], old[k], pathStack, emit);
|
|
4126
|
+
pathStack.pop();
|
|
4127
|
+
if (childResult !== old[k]) {
|
|
4128
|
+
if (!changed) {
|
|
4129
|
+
changed = true;
|
|
4130
|
+
result = { ...old };
|
|
4131
|
+
}
|
|
4132
|
+
result[k] = childResult;
|
|
4133
|
+
}
|
|
1706
4134
|
}
|
|
1707
4135
|
}
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
4136
|
+
return changed ? result : old;
|
|
4137
|
+
}
|
|
4138
|
+
function diffAndCloneArray(curr, old, pathStack, emit) {
|
|
4139
|
+
const min = Math.min(curr.length, old.length);
|
|
4140
|
+
let changed = false;
|
|
4141
|
+
let result = null;
|
|
4142
|
+
for (let i = 0;i < min; i++) {
|
|
4143
|
+
pathStack.push(i);
|
|
4144
|
+
const childResult = diffAndClone(curr[i], old[i], pathStack, emit);
|
|
4145
|
+
pathStack.pop();
|
|
4146
|
+
if (childResult !== old[i]) {
|
|
4147
|
+
if (!changed) {
|
|
4148
|
+
changed = true;
|
|
4149
|
+
result = old.slice();
|
|
1718
4150
|
}
|
|
4151
|
+
result[i] = childResult;
|
|
1719
4152
|
}
|
|
1720
4153
|
}
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
4154
|
+
if (curr.length > old.length) {
|
|
4155
|
+
if (!changed) {
|
|
4156
|
+
changed = true;
|
|
4157
|
+
result = old.slice();
|
|
1725
4158
|
}
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
emit({ action: "set", path:
|
|
4159
|
+
pathStack.push("length");
|
|
4160
|
+
emit({ action: "set", path: pathStack.slice(), newValue: curr.length, oldValue: old.length });
|
|
4161
|
+
pathStack.pop();
|
|
4162
|
+
result.length = curr.length;
|
|
4163
|
+
for (let i = old.length;i < curr.length; i++) {
|
|
4164
|
+
pathStack.push(i);
|
|
4165
|
+
emit({ action: "set", path: pathStack.slice(), newValue: deepClone(curr[i]) });
|
|
4166
|
+
pathStack.pop();
|
|
4167
|
+
result[i] = deepClone(curr[i]);
|
|
1733
4168
|
}
|
|
4169
|
+
} else if (curr.length < old.length) {
|
|
4170
|
+
if (!changed) {
|
|
4171
|
+
changed = true;
|
|
4172
|
+
result = old.slice();
|
|
4173
|
+
}
|
|
4174
|
+
pathStack.push("length");
|
|
4175
|
+
emit({ action: "set", path: pathStack.slice(), newValue: curr.length, oldValue: old.length });
|
|
4176
|
+
pathStack.pop();
|
|
4177
|
+
result.length = curr.length;
|
|
1734
4178
|
}
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
4179
|
+
return changed ? result : old;
|
|
4180
|
+
}
|
|
4181
|
+
function diffAndCloneMap(curr, old, pathStack, emit) {
|
|
4182
|
+
let changed = false;
|
|
4183
|
+
let result = null;
|
|
4184
|
+
const path = pathStack.slice();
|
|
4185
|
+
for (const [k, v] of old.entries()) {
|
|
4186
|
+
if (!curr.has(k)) {
|
|
4187
|
+
if (!changed) {
|
|
4188
|
+
changed = true;
|
|
4189
|
+
result = new Map(old);
|
|
1739
4190
|
}
|
|
4191
|
+
emit({ action: "map-delete", path, key: k, oldValue: v });
|
|
4192
|
+
result.delete(k);
|
|
1740
4193
|
}
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
4194
|
+
}
|
|
4195
|
+
for (const [k, v] of curr.entries()) {
|
|
4196
|
+
const vClone = deepClone(v);
|
|
4197
|
+
if (!old.has(k)) {
|
|
4198
|
+
if (!changed) {
|
|
4199
|
+
changed = true;
|
|
4200
|
+
result = new Map(old);
|
|
4201
|
+
}
|
|
4202
|
+
emit({ action: "map-set", path, key: k, newValue: vClone });
|
|
4203
|
+
result.set(k, vClone);
|
|
4204
|
+
} else if (!deepEqual(vClone, old.get(k), new WeakMap)) {
|
|
4205
|
+
if (!changed) {
|
|
4206
|
+
changed = true;
|
|
4207
|
+
result = new Map(old);
|
|
1746
4208
|
}
|
|
4209
|
+
emit({ action: "map-set", path, key: k, newValue: vClone, oldValue: old.get(k) });
|
|
4210
|
+
result.set(k, vClone);
|
|
1747
4211
|
}
|
|
1748
4212
|
}
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
4213
|
+
return changed ? result : old;
|
|
4214
|
+
}
|
|
4215
|
+
function diffAndCloneSet(curr, old, pathStack, emit) {
|
|
4216
|
+
let changed = false;
|
|
4217
|
+
let result = null;
|
|
4218
|
+
const path = pathStack.slice();
|
|
4219
|
+
for (const v of old.values()) {
|
|
4220
|
+
if (!curr.has(v)) {
|
|
4221
|
+
if (!changed) {
|
|
4222
|
+
changed = true;
|
|
4223
|
+
result = new Set(old);
|
|
4224
|
+
}
|
|
4225
|
+
emit({ action: "set-delete", path, value: v, oldValue: v });
|
|
4226
|
+
result.delete(v);
|
|
1753
4227
|
}
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
4228
|
+
}
|
|
4229
|
+
for (const v of curr.values()) {
|
|
4230
|
+
if (!old.has(v)) {
|
|
4231
|
+
if (!changed) {
|
|
4232
|
+
changed = true;
|
|
4233
|
+
result = new Set(old);
|
|
4234
|
+
}
|
|
4235
|
+
emit({ action: "set-add", path, value: deepClone(v) });
|
|
4236
|
+
result.add(deepClone(v));
|
|
1757
4237
|
}
|
|
1758
4238
|
}
|
|
1759
|
-
return
|
|
4239
|
+
return changed ? result : old;
|
|
1760
4240
|
}
|
|
1761
4241
|
// src/integrations/electron-bridge.ts
|
|
1762
4242
|
function makeTx() {
|