@yiin/reactive-proxy-state 2.0.0 → 3.0.0

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.js CHANGED
@@ -1,2304 +1,3 @@
1
- var __create = Object.create;
2
- var __getProtoOf = Object.getPrototypeOf;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __toESM = (mod, isNodeMode, target) => {
7
- target = mod != null ? __create(__getProtoOf(mod)) : {};
8
- const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
9
- for (let key of __getOwnPropNames(mod))
10
- if (!__hasOwnProp.call(to, key))
11
- __defProp(to, key, {
12
- get: () => mod[key],
13
- enumerable: true
14
- });
15
- return to;
16
- };
17
- var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
18
-
19
- // node_modules/@vue/shared/dist/shared.cjs.js
20
- var require_shared_cjs = __commonJS((exports) => {
21
- Object.defineProperty(exports, "__esModule", { value: true });
22
- /*! #__NO_SIDE_EFFECTS__ */
23
- function makeMap(str) {
24
- const map = /* @__PURE__ */ Object.create(null);
25
- for (const key of str.split(","))
26
- map[key] = 1;
27
- return (val) => (val in map);
28
- }
29
- var EMPTY_OBJ = Object.freeze({});
30
- var EMPTY_ARR = Object.freeze([]);
31
- var NOOP = () => {};
32
- var NO = () => false;
33
- var isOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && (key.charCodeAt(2) > 122 || key.charCodeAt(2) < 97);
34
- var isModelListener = (key) => key.startsWith("onUpdate:");
35
- var extend = Object.assign;
36
- var remove = (arr, el) => {
37
- const i = arr.indexOf(el);
38
- if (i > -1) {
39
- arr.splice(i, 1);
40
- }
41
- };
42
- var hasOwnProperty = Object.prototype.hasOwnProperty;
43
- var hasOwn2 = (val, key) => hasOwnProperty.call(val, key);
44
- var isArray = Array.isArray;
45
- var isMap = (val) => toTypeString(val) === "[object Map]";
46
- var isSet = (val) => toTypeString(val) === "[object Set]";
47
- var isDate = (val) => toTypeString(val) === "[object Date]";
48
- var isRegExp = (val) => toTypeString(val) === "[object RegExp]";
49
- var isFunction = (val) => typeof val === "function";
50
- var isString = (val) => typeof val === "string";
51
- var isSymbol = (val) => typeof val === "symbol";
52
- var isObject7 = (val) => val !== null && typeof val === "object";
53
- var isPromise = (val) => {
54
- return (isObject7(val) || isFunction(val)) && isFunction(val.then) && isFunction(val.catch);
55
- };
56
- var objectToString = Object.prototype.toString;
57
- var toTypeString = (value) => objectToString.call(value);
58
- var toRawType = (value) => {
59
- return toTypeString(value).slice(8, -1);
60
- };
61
- var isPlainObject = (val) => toTypeString(val) === "[object Object]";
62
- var isIntegerKey = (key) => isString(key) && key !== "NaN" && key[0] !== "-" && "" + parseInt(key, 10) === key;
63
- var isReservedProp = /* @__PURE__ */ makeMap(",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted");
64
- var isBuiltInDirective = /* @__PURE__ */ makeMap("bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo");
65
- var cacheStringFunction = (fn) => {
66
- const cache = /* @__PURE__ */ Object.create(null);
67
- return (str) => {
68
- const hit = cache[str];
69
- return hit || (cache[str] = fn(str));
70
- };
71
- };
72
- var camelizeRE = /-(\w)/g;
73
- var camelize = cacheStringFunction((str) => {
74
- return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : "");
75
- });
76
- var hyphenateRE = /\B([A-Z])/g;
77
- var hyphenate = cacheStringFunction((str) => str.replace(hyphenateRE, "-$1").toLowerCase());
78
- var capitalize = cacheStringFunction((str) => {
79
- return str.charAt(0).toUpperCase() + str.slice(1);
80
- });
81
- var toHandlerKey = cacheStringFunction((str) => {
82
- const s = str ? `on${capitalize(str)}` : ``;
83
- return s;
84
- });
85
- var hasChanged = (value, oldValue) => !Object.is(value, oldValue);
86
- var invokeArrayFns = (fns, ...arg) => {
87
- for (let i = 0;i < fns.length; i++) {
88
- fns[i](...arg);
89
- }
90
- };
91
- var def = (obj, key, value, writable = false) => {
92
- Object.defineProperty(obj, key, {
93
- configurable: true,
94
- enumerable: false,
95
- writable,
96
- value
97
- });
98
- };
99
- var looseToNumber = (val) => {
100
- const n = parseFloat(val);
101
- return isNaN(n) ? val : n;
102
- };
103
- var toNumber = (val) => {
104
- const n = isString(val) ? Number(val) : NaN;
105
- return isNaN(n) ? val : n;
106
- };
107
- var _globalThis;
108
- var getGlobalThis = () => {
109
- return _globalThis || (_globalThis = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : {});
110
- };
111
- var identRE = /^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/;
112
- function genPropsAccessExp(name) {
113
- return identRE.test(name) ? `__props.${name}` : `__props[${JSON.stringify(name)}]`;
114
- }
115
- function genCacheKey(source, options) {
116
- return source + JSON.stringify(options, (_, val) => typeof val === "function" ? val.toString() : val);
117
- }
118
- var PatchFlags = {
119
- TEXT: 1,
120
- "1": "TEXT",
121
- CLASS: 2,
122
- "2": "CLASS",
123
- STYLE: 4,
124
- "4": "STYLE",
125
- PROPS: 8,
126
- "8": "PROPS",
127
- FULL_PROPS: 16,
128
- "16": "FULL_PROPS",
129
- NEED_HYDRATION: 32,
130
- "32": "NEED_HYDRATION",
131
- STABLE_FRAGMENT: 64,
132
- "64": "STABLE_FRAGMENT",
133
- KEYED_FRAGMENT: 128,
134
- "128": "KEYED_FRAGMENT",
135
- UNKEYED_FRAGMENT: 256,
136
- "256": "UNKEYED_FRAGMENT",
137
- NEED_PATCH: 512,
138
- "512": "NEED_PATCH",
139
- DYNAMIC_SLOTS: 1024,
140
- "1024": "DYNAMIC_SLOTS",
141
- DEV_ROOT_FRAGMENT: 2048,
142
- "2048": "DEV_ROOT_FRAGMENT",
143
- CACHED: -1,
144
- "-1": "CACHED",
145
- BAIL: -2,
146
- "-2": "BAIL"
147
- };
148
- var PatchFlagNames = {
149
- [1]: `TEXT`,
150
- [2]: `CLASS`,
151
- [4]: `STYLE`,
152
- [8]: `PROPS`,
153
- [16]: `FULL_PROPS`,
154
- [32]: `NEED_HYDRATION`,
155
- [64]: `STABLE_FRAGMENT`,
156
- [128]: `KEYED_FRAGMENT`,
157
- [256]: `UNKEYED_FRAGMENT`,
158
- [512]: `NEED_PATCH`,
159
- [1024]: `DYNAMIC_SLOTS`,
160
- [2048]: `DEV_ROOT_FRAGMENT`,
161
- [-1]: `HOISTED`,
162
- [-2]: `BAIL`
163
- };
164
- var ShapeFlags = {
165
- ELEMENT: 1,
166
- "1": "ELEMENT",
167
- FUNCTIONAL_COMPONENT: 2,
168
- "2": "FUNCTIONAL_COMPONENT",
169
- STATEFUL_COMPONENT: 4,
170
- "4": "STATEFUL_COMPONENT",
171
- TEXT_CHILDREN: 8,
172
- "8": "TEXT_CHILDREN",
173
- ARRAY_CHILDREN: 16,
174
- "16": "ARRAY_CHILDREN",
175
- SLOTS_CHILDREN: 32,
176
- "32": "SLOTS_CHILDREN",
177
- TELEPORT: 64,
178
- "64": "TELEPORT",
179
- SUSPENSE: 128,
180
- "128": "SUSPENSE",
181
- COMPONENT_SHOULD_KEEP_ALIVE: 256,
182
- "256": "COMPONENT_SHOULD_KEEP_ALIVE",
183
- COMPONENT_KEPT_ALIVE: 512,
184
- "512": "COMPONENT_KEPT_ALIVE",
185
- COMPONENT: 6,
186
- "6": "COMPONENT"
187
- };
188
- var SlotFlags = {
189
- STABLE: 1,
190
- "1": "STABLE",
191
- DYNAMIC: 2,
192
- "2": "DYNAMIC",
193
- FORWARDED: 3,
194
- "3": "FORWARDED"
195
- };
196
- var slotFlagsText = {
197
- [1]: "STABLE",
198
- [2]: "DYNAMIC",
199
- [3]: "FORWARDED"
200
- };
201
- 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";
202
- var isGloballyAllowed = /* @__PURE__ */ makeMap(GLOBALS_ALLOWED);
203
- var isGloballyWhitelisted = isGloballyAllowed;
204
- var range = 2;
205
- function generateCodeFrame(source, start = 0, end = source.length) {
206
- start = Math.max(0, Math.min(start, source.length));
207
- end = Math.max(0, Math.min(end, source.length));
208
- if (start > end)
209
- return "";
210
- let lines = source.split(/(\r?\n)/);
211
- const newlineSequences = lines.filter((_, idx) => idx % 2 === 1);
212
- lines = lines.filter((_, idx) => idx % 2 === 0);
213
- let count = 0;
214
- const res = [];
215
- for (let i = 0;i < lines.length; i++) {
216
- count += lines[i].length + (newlineSequences[i] && newlineSequences[i].length || 0);
217
- if (count >= start) {
218
- for (let j = i - range;j <= i + range || end > count; j++) {
219
- if (j < 0 || j >= lines.length)
220
- continue;
221
- const line = j + 1;
222
- res.push(`${line}${" ".repeat(Math.max(3 - String(line).length, 0))}| ${lines[j]}`);
223
- const lineLength = lines[j].length;
224
- const newLineSeqLength = newlineSequences[j] && newlineSequences[j].length || 0;
225
- if (j === i) {
226
- const pad = start - (count - (lineLength + newLineSeqLength));
227
- const length = Math.max(1, end > count ? lineLength - pad : end - start);
228
- res.push(` | ` + " ".repeat(pad) + "^".repeat(length));
229
- } else if (j > i) {
230
- if (end > count) {
231
- const length = Math.max(Math.min(end - count, lineLength), 1);
232
- res.push(` | ` + "^".repeat(length));
233
- }
234
- count += lineLength + newLineSeqLength;
235
- }
236
- }
237
- break;
238
- }
239
- }
240
- return res.join(`
241
- `);
242
- }
243
- function normalizeStyle(value) {
244
- if (isArray(value)) {
245
- const res = {};
246
- for (let i = 0;i < value.length; i++) {
247
- const item = value[i];
248
- const normalized = isString(item) ? parseStringStyle(item) : normalizeStyle(item);
249
- if (normalized) {
250
- for (const key in normalized) {
251
- res[key] = normalized[key];
252
- }
253
- }
254
- }
255
- return res;
256
- } else if (isString(value) || isObject7(value)) {
257
- return value;
258
- }
259
- }
260
- var listDelimiterRE = /;(?![^(]*\))/g;
261
- var propertyDelimiterRE = /:([^]+)/;
262
- var styleCommentRE = /\/\*[^]*?\*\//g;
263
- function parseStringStyle(cssText) {
264
- const ret = {};
265
- cssText.replace(styleCommentRE, "").split(listDelimiterRE).forEach((item) => {
266
- if (item) {
267
- const tmp = item.split(propertyDelimiterRE);
268
- tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
269
- }
270
- });
271
- return ret;
272
- }
273
- function stringifyStyle(styles) {
274
- if (!styles)
275
- return "";
276
- if (isString(styles))
277
- return styles;
278
- let ret = "";
279
- for (const key in styles) {
280
- const value = styles[key];
281
- if (isString(value) || typeof value === "number") {
282
- const normalizedKey = key.startsWith(`--`) ? key : hyphenate(key);
283
- ret += `${normalizedKey}:${value};`;
284
- }
285
- }
286
- return ret;
287
- }
288
- function normalizeClass(value) {
289
- let res = "";
290
- if (isString(value)) {
291
- res = value;
292
- } else if (isArray(value)) {
293
- for (let i = 0;i < value.length; i++) {
294
- const normalized = normalizeClass(value[i]);
295
- if (normalized) {
296
- res += normalized + " ";
297
- }
298
- }
299
- } else if (isObject7(value)) {
300
- for (const name in value) {
301
- if (value[name]) {
302
- res += name + " ";
303
- }
304
- }
305
- }
306
- return res.trim();
307
- }
308
- function normalizeProps(props) {
309
- if (!props)
310
- return null;
311
- let { class: klass, style } = props;
312
- if (klass && !isString(klass)) {
313
- props.class = normalizeClass(klass);
314
- }
315
- if (style) {
316
- props.style = normalizeStyle(style);
317
- }
318
- return props;
319
- }
320
- 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";
321
- 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";
322
- 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";
323
- var VOID_TAGS = "area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr";
324
- var isHTMLTag = /* @__PURE__ */ makeMap(HTML_TAGS);
325
- var isSVGTag = /* @__PURE__ */ makeMap(SVG_TAGS);
326
- var isMathMLTag = /* @__PURE__ */ makeMap(MATH_TAGS);
327
- var isVoidTag = /* @__PURE__ */ makeMap(VOID_TAGS);
328
- var specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
329
- var isSpecialBooleanAttr = /* @__PURE__ */ makeMap(specialBooleanAttrs);
330
- var isBooleanAttr = /* @__PURE__ */ makeMap(specialBooleanAttrs + `,async,autofocus,autoplay,controls,default,defer,disabled,hidden,inert,loop,open,required,reversed,scoped,seamless,checked,muted,multiple,selected`);
331
- function includeBooleanAttr(value) {
332
- return !!value || value === "";
333
- }
334
- var unsafeAttrCharRE = /[>/="'\u0009\u000a\u000c\u0020]/;
335
- var attrValidationCache = {};
336
- function isSSRSafeAttrName(name) {
337
- if (attrValidationCache.hasOwnProperty(name)) {
338
- return attrValidationCache[name];
339
- }
340
- const isUnsafe = unsafeAttrCharRE.test(name);
341
- if (isUnsafe) {
342
- console.error(`unsafe attribute name: ${name}`);
343
- }
344
- return attrValidationCache[name] = !isUnsafe;
345
- }
346
- var propsToAttrMap = {
347
- acceptCharset: "accept-charset",
348
- className: "class",
349
- htmlFor: "for",
350
- httpEquiv: "http-equiv"
351
- };
352
- 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`);
353
- 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`);
354
- 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`);
355
- function isRenderableAttrValue(value) {
356
- if (value == null) {
357
- return false;
358
- }
359
- const type = typeof value;
360
- return type === "string" || type === "number" || type === "boolean";
361
- }
362
- var escapeRE = /["'&<>]/;
363
- function escapeHtml(string) {
364
- const str = "" + string;
365
- const match = escapeRE.exec(str);
366
- if (!match) {
367
- return str;
368
- }
369
- let html = "";
370
- let escaped;
371
- let index;
372
- let lastIndex = 0;
373
- for (index = match.index;index < str.length; index++) {
374
- switch (str.charCodeAt(index)) {
375
- case 34:
376
- escaped = "&quot;";
377
- break;
378
- case 38:
379
- escaped = "&amp;";
380
- break;
381
- case 39:
382
- escaped = "&#39;";
383
- break;
384
- case 60:
385
- escaped = "&lt;";
386
- break;
387
- case 62:
388
- escaped = "&gt;";
389
- break;
390
- default:
391
- continue;
392
- }
393
- if (lastIndex !== index) {
394
- html += str.slice(lastIndex, index);
395
- }
396
- lastIndex = index + 1;
397
- html += escaped;
398
- }
399
- return lastIndex !== index ? html + str.slice(lastIndex, index) : html;
400
- }
401
- var commentStripRE = /^-?>|<!--|-->|--!>|<!-$/g;
402
- function escapeHtmlComment(src) {
403
- return src.replace(commentStripRE, "");
404
- }
405
- var cssVarNameEscapeSymbolsRE = /[ !"#$%&'()*+,./:;<=>?@[\\\]^`{|}~]/g;
406
- function getEscapedCssVarName(key, doubleEscape) {
407
- return key.replace(cssVarNameEscapeSymbolsRE, (s) => doubleEscape ? s === '"' ? "\\\\\\\"" : `\\\\${s}` : `\\${s}`);
408
- }
409
- function looseCompareArrays(a, b) {
410
- if (a.length !== b.length)
411
- return false;
412
- let equal = true;
413
- for (let i = 0;equal && i < a.length; i++) {
414
- equal = looseEqual(a[i], b[i]);
415
- }
416
- return equal;
417
- }
418
- function looseEqual(a, b) {
419
- if (a === b)
420
- return true;
421
- let aValidType = isDate(a);
422
- let bValidType = isDate(b);
423
- if (aValidType || bValidType) {
424
- return aValidType && bValidType ? a.getTime() === b.getTime() : false;
425
- }
426
- aValidType = isSymbol(a);
427
- bValidType = isSymbol(b);
428
- if (aValidType || bValidType) {
429
- return a === b;
430
- }
431
- aValidType = isArray(a);
432
- bValidType = isArray(b);
433
- if (aValidType || bValidType) {
434
- return aValidType && bValidType ? looseCompareArrays(a, b) : false;
435
- }
436
- aValidType = isObject7(a);
437
- bValidType = isObject7(b);
438
- if (aValidType || bValidType) {
439
- if (!aValidType || !bValidType) {
440
- return false;
441
- }
442
- const aKeysCount = Object.keys(a).length;
443
- const bKeysCount = Object.keys(b).length;
444
- if (aKeysCount !== bKeysCount) {
445
- return false;
446
- }
447
- for (const key in a) {
448
- const aHasKey = a.hasOwnProperty(key);
449
- const bHasKey = b.hasOwnProperty(key);
450
- if (aHasKey && !bHasKey || !aHasKey && bHasKey || !looseEqual(a[key], b[key])) {
451
- return false;
452
- }
453
- }
454
- }
455
- return String(a) === String(b);
456
- }
457
- function looseIndexOf(arr, val) {
458
- return arr.findIndex((item) => looseEqual(item, val));
459
- }
460
- var isRef3 = (val) => {
461
- return !!(val && val["__v_isRef"] === true);
462
- };
463
- var toDisplayString = (val) => {
464
- return isString(val) ? val : val == null ? "" : isArray(val) || isObject7(val) && (val.toString === objectToString || !isFunction(val.toString)) ? isRef3(val) ? toDisplayString(val.value) : JSON.stringify(val, replacer, 2) : String(val);
465
- };
466
- var replacer = (_key, val) => {
467
- if (isRef3(val)) {
468
- return replacer(_key, val.value);
469
- } else if (isMap(val)) {
470
- return {
471
- [`Map(${val.size})`]: [...val.entries()].reduce((entries, [key, val2], i) => {
472
- entries[stringifySymbol(key, i) + " =>"] = val2;
473
- return entries;
474
- }, {})
475
- };
476
- } else if (isSet(val)) {
477
- return {
478
- [`Set(${val.size})`]: [...val.values()].map((v) => stringifySymbol(v))
479
- };
480
- } else if (isSymbol(val)) {
481
- return stringifySymbol(val);
482
- } else if (isObject7(val) && !isArray(val) && !isPlainObject(val)) {
483
- return String(val);
484
- }
485
- return val;
486
- };
487
- var stringifySymbol = (v, i = "") => {
488
- var _a;
489
- return isSymbol(v) ? `Symbol(${(_a = v.description) != null ? _a : i})` : v;
490
- };
491
- exports.EMPTY_ARR = EMPTY_ARR;
492
- exports.EMPTY_OBJ = EMPTY_OBJ;
493
- exports.NO = NO;
494
- exports.NOOP = NOOP;
495
- exports.PatchFlagNames = PatchFlagNames;
496
- exports.PatchFlags = PatchFlags;
497
- exports.ShapeFlags = ShapeFlags;
498
- exports.SlotFlags = SlotFlags;
499
- exports.camelize = camelize;
500
- exports.capitalize = capitalize;
501
- exports.cssVarNameEscapeSymbolsRE = cssVarNameEscapeSymbolsRE;
502
- exports.def = def;
503
- exports.escapeHtml = escapeHtml;
504
- exports.escapeHtmlComment = escapeHtmlComment;
505
- exports.extend = extend;
506
- exports.genCacheKey = genCacheKey;
507
- exports.genPropsAccessExp = genPropsAccessExp;
508
- exports.generateCodeFrame = generateCodeFrame;
509
- exports.getEscapedCssVarName = getEscapedCssVarName;
510
- exports.getGlobalThis = getGlobalThis;
511
- exports.hasChanged = hasChanged;
512
- exports.hasOwn = hasOwn2;
513
- exports.hyphenate = hyphenate;
514
- exports.includeBooleanAttr = includeBooleanAttr;
515
- exports.invokeArrayFns = invokeArrayFns;
516
- exports.isArray = isArray;
517
- exports.isBooleanAttr = isBooleanAttr;
518
- exports.isBuiltInDirective = isBuiltInDirective;
519
- exports.isDate = isDate;
520
- exports.isFunction = isFunction;
521
- exports.isGloballyAllowed = isGloballyAllowed;
522
- exports.isGloballyWhitelisted = isGloballyWhitelisted;
523
- exports.isHTMLTag = isHTMLTag;
524
- exports.isIntegerKey = isIntegerKey;
525
- exports.isKnownHtmlAttr = isKnownHtmlAttr;
526
- exports.isKnownMathMLAttr = isKnownMathMLAttr;
527
- exports.isKnownSvgAttr = isKnownSvgAttr;
528
- exports.isMap = isMap;
529
- exports.isMathMLTag = isMathMLTag;
530
- exports.isModelListener = isModelListener;
531
- exports.isObject = isObject7;
532
- exports.isOn = isOn;
533
- exports.isPlainObject = isPlainObject;
534
- exports.isPromise = isPromise;
535
- exports.isRegExp = isRegExp;
536
- exports.isRenderableAttrValue = isRenderableAttrValue;
537
- exports.isReservedProp = isReservedProp;
538
- exports.isSSRSafeAttrName = isSSRSafeAttrName;
539
- exports.isSVGTag = isSVGTag;
540
- exports.isSet = isSet;
541
- exports.isSpecialBooleanAttr = isSpecialBooleanAttr;
542
- exports.isString = isString;
543
- exports.isSymbol = isSymbol;
544
- exports.isVoidTag = isVoidTag;
545
- exports.looseEqual = looseEqual;
546
- exports.looseIndexOf = looseIndexOf;
547
- exports.looseToNumber = looseToNumber;
548
- exports.makeMap = makeMap;
549
- exports.normalizeClass = normalizeClass;
550
- exports.normalizeProps = normalizeProps;
551
- exports.normalizeStyle = normalizeStyle;
552
- exports.objectToString = objectToString;
553
- exports.parseStringStyle = parseStringStyle;
554
- exports.propsToAttrMap = propsToAttrMap;
555
- exports.remove = remove;
556
- exports.slotFlagsText = slotFlagsText;
557
- exports.stringifyStyle = stringifyStyle;
558
- exports.toDisplayString = toDisplayString;
559
- exports.toHandlerKey = toHandlerKey;
560
- exports.toNumber = toNumber;
561
- exports.toRawType = toRawType;
562
- exports.toTypeString = toTypeString;
563
- });
564
-
565
- // node_modules/@vue/reactivity/dist/reactivity.cjs.js
566
- var require_reactivity_cjs = __commonJS((exports) => {
567
- Object.defineProperty(exports, "__esModule", { value: true });
568
- var shared = require_shared_cjs();
569
- function warn(msg, ...args) {
570
- console.warn(`[Vue warn] ${msg}`, ...args);
571
- }
572
- var activeEffectScope;
573
-
574
- class EffectScope {
575
- constructor(detached = false) {
576
- this.detached = detached;
577
- this._active = true;
578
- this.effects = [];
579
- this.cleanups = [];
580
- this._isPaused = false;
581
- this.parent = activeEffectScope;
582
- if (!detached && activeEffectScope) {
583
- this.index = (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(this) - 1;
584
- }
585
- }
586
- get active() {
587
- return this._active;
588
- }
589
- pause() {
590
- if (this._active) {
591
- this._isPaused = true;
592
- let i, l;
593
- if (this.scopes) {
594
- for (i = 0, l = this.scopes.length;i < l; i++) {
595
- this.scopes[i].pause();
596
- }
597
- }
598
- for (i = 0, l = this.effects.length;i < l; i++) {
599
- this.effects[i].pause();
600
- }
601
- }
602
- }
603
- resume() {
604
- if (this._active) {
605
- if (this._isPaused) {
606
- this._isPaused = false;
607
- let i, l;
608
- if (this.scopes) {
609
- for (i = 0, l = this.scopes.length;i < l; i++) {
610
- this.scopes[i].resume();
611
- }
612
- }
613
- for (i = 0, l = this.effects.length;i < l; i++) {
614
- this.effects[i].resume();
615
- }
616
- }
617
- }
618
- }
619
- run(fn) {
620
- if (this._active) {
621
- const currentEffectScope = activeEffectScope;
622
- try {
623
- activeEffectScope = this;
624
- return fn();
625
- } finally {
626
- activeEffectScope = currentEffectScope;
627
- }
628
- } else {
629
- warn(`cannot run an inactive effect scope.`);
630
- }
631
- }
632
- on() {
633
- activeEffectScope = this;
634
- }
635
- off() {
636
- activeEffectScope = this.parent;
637
- }
638
- stop(fromParent) {
639
- if (this._active) {
640
- this._active = false;
641
- let i, l;
642
- for (i = 0, l = this.effects.length;i < l; i++) {
643
- this.effects[i].stop();
644
- }
645
- this.effects.length = 0;
646
- for (i = 0, l = this.cleanups.length;i < l; i++) {
647
- this.cleanups[i]();
648
- }
649
- this.cleanups.length = 0;
650
- if (this.scopes) {
651
- for (i = 0, l = this.scopes.length;i < l; i++) {
652
- this.scopes[i].stop(true);
653
- }
654
- this.scopes.length = 0;
655
- }
656
- if (!this.detached && this.parent && !fromParent) {
657
- const last = this.parent.scopes.pop();
658
- if (last && last !== this) {
659
- this.parent.scopes[this.index] = last;
660
- last.index = this.index;
661
- }
662
- }
663
- this.parent = undefined;
664
- }
665
- }
666
- }
667
- function effectScope(detached) {
668
- return new EffectScope(detached);
669
- }
670
- function getCurrentScope() {
671
- return activeEffectScope;
672
- }
673
- function onScopeDispose(fn, failSilently = false) {
674
- if (activeEffectScope) {
675
- activeEffectScope.cleanups.push(fn);
676
- } else if (!failSilently) {
677
- warn(`onScopeDispose() is called when there is no active effect scope to be associated with.`);
678
- }
679
- }
680
- var activeSub;
681
- var EffectFlags = {
682
- ACTIVE: 1,
683
- "1": "ACTIVE",
684
- RUNNING: 2,
685
- "2": "RUNNING",
686
- TRACKING: 4,
687
- "4": "TRACKING",
688
- NOTIFIED: 8,
689
- "8": "NOTIFIED",
690
- DIRTY: 16,
691
- "16": "DIRTY",
692
- ALLOW_RECURSE: 32,
693
- "32": "ALLOW_RECURSE",
694
- PAUSED: 64,
695
- "64": "PAUSED"
696
- };
697
- var pausedQueueEffects = /* @__PURE__ */ new WeakSet;
698
-
699
- class ReactiveEffect {
700
- constructor(fn) {
701
- this.fn = fn;
702
- this.deps = undefined;
703
- this.depsTail = undefined;
704
- this.flags = 1 | 4;
705
- this.next = undefined;
706
- this.cleanup = undefined;
707
- this.scheduler = undefined;
708
- if (activeEffectScope && activeEffectScope.active) {
709
- activeEffectScope.effects.push(this);
710
- }
711
- }
712
- pause() {
713
- this.flags |= 64;
714
- }
715
- resume() {
716
- if (this.flags & 64) {
717
- this.flags &= ~64;
718
- if (pausedQueueEffects.has(this)) {
719
- pausedQueueEffects.delete(this);
720
- this.trigger();
721
- }
722
- }
723
- }
724
- notify() {
725
- if (this.flags & 2 && !(this.flags & 32)) {
726
- return;
727
- }
728
- if (!(this.flags & 8)) {
729
- batch(this);
730
- }
731
- }
732
- run() {
733
- if (!(this.flags & 1)) {
734
- return this.fn();
735
- }
736
- this.flags |= 2;
737
- cleanupEffect3(this);
738
- prepareDeps(this);
739
- const prevEffect = activeSub;
740
- const prevShouldTrack = shouldTrack;
741
- activeSub = this;
742
- shouldTrack = true;
743
- try {
744
- return this.fn();
745
- } finally {
746
- if (activeSub !== this) {
747
- warn("Active effect was not restored correctly - this is likely a Vue internal bug.");
748
- }
749
- cleanupDeps(this);
750
- activeSub = prevEffect;
751
- shouldTrack = prevShouldTrack;
752
- this.flags &= ~2;
753
- }
754
- }
755
- stop() {
756
- if (this.flags & 1) {
757
- for (let link = this.deps;link; link = link.nextDep) {
758
- removeSub(link);
759
- }
760
- this.deps = this.depsTail = undefined;
761
- cleanupEffect3(this);
762
- this.onStop && this.onStop();
763
- this.flags &= ~1;
764
- }
765
- }
766
- trigger() {
767
- if (this.flags & 64) {
768
- pausedQueueEffects.add(this);
769
- } else if (this.scheduler) {
770
- this.scheduler();
771
- } else {
772
- this.runIfDirty();
773
- }
774
- }
775
- runIfDirty() {
776
- if (isDirty(this)) {
777
- this.run();
778
- }
779
- }
780
- get dirty() {
781
- return isDirty(this);
782
- }
783
- }
784
- var batchDepth = 0;
785
- var batchedSub;
786
- var batchedComputed;
787
- function batch(sub, isComputed2 = false) {
788
- sub.flags |= 8;
789
- if (isComputed2) {
790
- sub.next = batchedComputed;
791
- batchedComputed = sub;
792
- return;
793
- }
794
- sub.next = batchedSub;
795
- batchedSub = sub;
796
- }
797
- function startBatch() {
798
- batchDepth++;
799
- }
800
- function endBatch() {
801
- if (--batchDepth > 0) {
802
- return;
803
- }
804
- if (batchedComputed) {
805
- let e = batchedComputed;
806
- batchedComputed = undefined;
807
- while (e) {
808
- const next = e.next;
809
- e.next = undefined;
810
- e.flags &= ~8;
811
- e = next;
812
- }
813
- }
814
- let error;
815
- while (batchedSub) {
816
- let e = batchedSub;
817
- batchedSub = undefined;
818
- while (e) {
819
- const next = e.next;
820
- e.next = undefined;
821
- e.flags &= ~8;
822
- if (e.flags & 1) {
823
- try {
824
- e.trigger();
825
- } catch (err) {
826
- if (!error)
827
- error = err;
828
- }
829
- }
830
- e = next;
831
- }
832
- }
833
- if (error)
834
- throw error;
835
- }
836
- function prepareDeps(sub) {
837
- for (let link = sub.deps;link; link = link.nextDep) {
838
- link.version = -1;
839
- link.prevActiveLink = link.dep.activeLink;
840
- link.dep.activeLink = link;
841
- }
842
- }
843
- function cleanupDeps(sub) {
844
- let head;
845
- let tail = sub.depsTail;
846
- let link = tail;
847
- while (link) {
848
- const prev = link.prevDep;
849
- if (link.version === -1) {
850
- if (link === tail)
851
- tail = prev;
852
- removeSub(link);
853
- removeDep(link);
854
- } else {
855
- head = link;
856
- }
857
- link.dep.activeLink = link.prevActiveLink;
858
- link.prevActiveLink = undefined;
859
- link = prev;
860
- }
861
- sub.deps = head;
862
- sub.depsTail = tail;
863
- }
864
- function isDirty(sub) {
865
- for (let link = sub.deps;link; link = link.nextDep) {
866
- if (link.dep.version !== link.version || link.dep.computed && (refreshComputed(link.dep.computed) || link.dep.version !== link.version)) {
867
- return true;
868
- }
869
- }
870
- if (sub._dirty) {
871
- return true;
872
- }
873
- return false;
874
- }
875
- function refreshComputed(computed3) {
876
- if (computed3.flags & 4 && !(computed3.flags & 16)) {
877
- return;
878
- }
879
- computed3.flags &= ~16;
880
- if (computed3.globalVersion === globalVersion) {
881
- return;
882
- }
883
- computed3.globalVersion = globalVersion;
884
- const dep = computed3.dep;
885
- computed3.flags |= 2;
886
- if (dep.version > 0 && !computed3.isSSR && computed3.deps && !isDirty(computed3)) {
887
- computed3.flags &= ~2;
888
- return;
889
- }
890
- const prevSub = activeSub;
891
- const prevShouldTrack = shouldTrack;
892
- activeSub = computed3;
893
- shouldTrack = true;
894
- try {
895
- prepareDeps(computed3);
896
- const value = computed3.fn(computed3._value);
897
- if (dep.version === 0 || shared.hasChanged(value, computed3._value)) {
898
- computed3._value = value;
899
- dep.version++;
900
- }
901
- } catch (err) {
902
- dep.version++;
903
- throw err;
904
- } finally {
905
- activeSub = prevSub;
906
- shouldTrack = prevShouldTrack;
907
- cleanupDeps(computed3);
908
- computed3.flags &= ~2;
909
- }
910
- }
911
- function removeSub(link, soft = false) {
912
- const { dep, prevSub, nextSub } = link;
913
- if (prevSub) {
914
- prevSub.nextSub = nextSub;
915
- link.prevSub = undefined;
916
- }
917
- if (nextSub) {
918
- nextSub.prevSub = prevSub;
919
- link.nextSub = undefined;
920
- }
921
- if (dep.subsHead === link) {
922
- dep.subsHead = nextSub;
923
- }
924
- if (dep.subs === link) {
925
- dep.subs = prevSub;
926
- if (!prevSub && dep.computed) {
927
- dep.computed.flags &= ~4;
928
- for (let l = dep.computed.deps;l; l = l.nextDep) {
929
- removeSub(l, true);
930
- }
931
- }
932
- }
933
- if (!soft && !--dep.sc && dep.map) {
934
- dep.map.delete(dep.key);
935
- }
936
- }
937
- function removeDep(link) {
938
- const { prevDep, nextDep } = link;
939
- if (prevDep) {
940
- prevDep.nextDep = nextDep;
941
- link.prevDep = undefined;
942
- }
943
- if (nextDep) {
944
- nextDep.prevDep = prevDep;
945
- link.nextDep = undefined;
946
- }
947
- }
948
- function effect(fn, options) {
949
- if (fn.effect instanceof ReactiveEffect) {
950
- fn = fn.effect.fn;
951
- }
952
- const e = new ReactiveEffect(fn);
953
- if (options) {
954
- shared.extend(e, options);
955
- }
956
- try {
957
- e.run();
958
- } catch (err) {
959
- e.stop();
960
- throw err;
961
- }
962
- const runner = e.run.bind(e);
963
- runner.effect = e;
964
- return runner;
965
- }
966
- function stop(runner) {
967
- runner.effect.stop();
968
- }
969
- var shouldTrack = true;
970
- var trackStack = [];
971
- function pauseTracking() {
972
- trackStack.push(shouldTrack);
973
- shouldTrack = false;
974
- }
975
- function enableTracking() {
976
- trackStack.push(shouldTrack);
977
- shouldTrack = true;
978
- }
979
- function resetTracking() {
980
- const last = trackStack.pop();
981
- shouldTrack = last === undefined ? true : last;
982
- }
983
- function onEffectCleanup(fn, failSilently = false) {
984
- if (activeSub instanceof ReactiveEffect) {
985
- activeSub.cleanup = fn;
986
- } else if (!failSilently) {
987
- warn(`onEffectCleanup() was called when there was no active effect to associate with.`);
988
- }
989
- }
990
- function cleanupEffect3(e) {
991
- const { cleanup } = e;
992
- e.cleanup = undefined;
993
- if (cleanup) {
994
- const prevSub = activeSub;
995
- activeSub = undefined;
996
- try {
997
- cleanup();
998
- } finally {
999
- activeSub = prevSub;
1000
- }
1001
- }
1002
- }
1003
- var globalVersion = 0;
1004
-
1005
- class Link {
1006
- constructor(sub, dep) {
1007
- this.sub = sub;
1008
- this.dep = dep;
1009
- this.version = dep.version;
1010
- this.nextDep = this.prevDep = this.nextSub = this.prevSub = this.prevActiveLink = undefined;
1011
- }
1012
- }
1013
-
1014
- class Dep {
1015
- constructor(computed3) {
1016
- this.computed = computed3;
1017
- this.version = 0;
1018
- this.activeLink = undefined;
1019
- this.subs = undefined;
1020
- this.map = undefined;
1021
- this.key = undefined;
1022
- this.sc = 0;
1023
- {
1024
- this.subsHead = undefined;
1025
- }
1026
- }
1027
- track(debugInfo) {
1028
- if (!activeSub || !shouldTrack || activeSub === this.computed) {
1029
- return;
1030
- }
1031
- let link = this.activeLink;
1032
- if (link === undefined || link.sub !== activeSub) {
1033
- link = this.activeLink = new Link(activeSub, this);
1034
- if (!activeSub.deps) {
1035
- activeSub.deps = activeSub.depsTail = link;
1036
- } else {
1037
- link.prevDep = activeSub.depsTail;
1038
- activeSub.depsTail.nextDep = link;
1039
- activeSub.depsTail = link;
1040
- }
1041
- addSub(link);
1042
- } else if (link.version === -1) {
1043
- link.version = this.version;
1044
- if (link.nextDep) {
1045
- const next = link.nextDep;
1046
- next.prevDep = link.prevDep;
1047
- if (link.prevDep) {
1048
- link.prevDep.nextDep = next;
1049
- }
1050
- link.prevDep = activeSub.depsTail;
1051
- link.nextDep = undefined;
1052
- activeSub.depsTail.nextDep = link;
1053
- activeSub.depsTail = link;
1054
- if (activeSub.deps === link) {
1055
- activeSub.deps = next;
1056
- }
1057
- }
1058
- }
1059
- if (activeSub.onTrack) {
1060
- activeSub.onTrack(shared.extend({
1061
- effect: activeSub
1062
- }, debugInfo));
1063
- }
1064
- return link;
1065
- }
1066
- trigger(debugInfo) {
1067
- this.version++;
1068
- globalVersion++;
1069
- this.notify(debugInfo);
1070
- }
1071
- notify(debugInfo) {
1072
- startBatch();
1073
- try {
1074
- if (true) {
1075
- for (let head = this.subsHead;head; head = head.nextSub) {
1076
- if (head.sub.onTrigger && !(head.sub.flags & 8)) {
1077
- head.sub.onTrigger(shared.extend({
1078
- effect: head.sub
1079
- }, debugInfo));
1080
- }
1081
- }
1082
- }
1083
- for (let link = this.subs;link; link = link.prevSub) {
1084
- if (link.sub.notify()) {
1085
- link.sub.dep.notify();
1086
- }
1087
- }
1088
- } finally {
1089
- endBatch();
1090
- }
1091
- }
1092
- }
1093
- function addSub(link) {
1094
- link.dep.sc++;
1095
- if (link.sub.flags & 4) {
1096
- const computed3 = link.dep.computed;
1097
- if (computed3 && !link.dep.subs) {
1098
- computed3.flags |= 4 | 16;
1099
- for (let l = computed3.deps;l; l = l.nextDep) {
1100
- addSub(l);
1101
- }
1102
- }
1103
- const currentTail = link.dep.subs;
1104
- if (currentTail !== link) {
1105
- link.prevSub = currentTail;
1106
- if (currentTail)
1107
- currentTail.nextSub = link;
1108
- }
1109
- if (link.dep.subsHead === undefined) {
1110
- link.dep.subsHead = link;
1111
- }
1112
- link.dep.subs = link;
1113
- }
1114
- }
1115
- var targetMap2 = /* @__PURE__ */ new WeakMap;
1116
- var ITERATE_KEY = Symbol("Object iterate");
1117
- var MAP_KEY_ITERATE_KEY = Symbol("Map keys iterate");
1118
- var ARRAY_ITERATE_KEY = Symbol("Array iterate");
1119
- function track2(target, type, key) {
1120
- if (shouldTrack && activeSub) {
1121
- let depsMap = targetMap2.get(target);
1122
- if (!depsMap) {
1123
- targetMap2.set(target, depsMap = /* @__PURE__ */ new Map);
1124
- }
1125
- let dep = depsMap.get(key);
1126
- if (!dep) {
1127
- depsMap.set(key, dep = new Dep);
1128
- dep.map = depsMap;
1129
- dep.key = key;
1130
- }
1131
- {
1132
- dep.track({
1133
- target,
1134
- type,
1135
- key
1136
- });
1137
- }
1138
- }
1139
- }
1140
- function trigger2(target, type, key, newValue, oldValue, oldTarget) {
1141
- const depsMap = targetMap2.get(target);
1142
- if (!depsMap) {
1143
- globalVersion++;
1144
- return;
1145
- }
1146
- const run = (dep) => {
1147
- if (dep) {
1148
- {
1149
- dep.trigger({
1150
- target,
1151
- type,
1152
- key,
1153
- newValue,
1154
- oldValue,
1155
- oldTarget
1156
- });
1157
- }
1158
- }
1159
- };
1160
- startBatch();
1161
- if (type === "clear") {
1162
- depsMap.forEach(run);
1163
- } else {
1164
- const targetIsArray = shared.isArray(target);
1165
- const isArrayIndex = targetIsArray && shared.isIntegerKey(key);
1166
- if (targetIsArray && key === "length") {
1167
- const newLength = Number(newValue);
1168
- depsMap.forEach((dep, key2) => {
1169
- if (key2 === "length" || key2 === ARRAY_ITERATE_KEY || !shared.isSymbol(key2) && key2 >= newLength) {
1170
- run(dep);
1171
- }
1172
- });
1173
- } else {
1174
- if (key !== undefined || depsMap.has(undefined)) {
1175
- run(depsMap.get(key));
1176
- }
1177
- if (isArrayIndex) {
1178
- run(depsMap.get(ARRAY_ITERATE_KEY));
1179
- }
1180
- switch (type) {
1181
- case "add":
1182
- if (!targetIsArray) {
1183
- run(depsMap.get(ITERATE_KEY));
1184
- if (shared.isMap(target)) {
1185
- run(depsMap.get(MAP_KEY_ITERATE_KEY));
1186
- }
1187
- } else if (isArrayIndex) {
1188
- run(depsMap.get("length"));
1189
- }
1190
- break;
1191
- case "delete":
1192
- if (!targetIsArray) {
1193
- run(depsMap.get(ITERATE_KEY));
1194
- if (shared.isMap(target)) {
1195
- run(depsMap.get(MAP_KEY_ITERATE_KEY));
1196
- }
1197
- }
1198
- break;
1199
- case "set":
1200
- if (shared.isMap(target)) {
1201
- run(depsMap.get(ITERATE_KEY));
1202
- }
1203
- break;
1204
- }
1205
- }
1206
- }
1207
- endBatch();
1208
- }
1209
- function getDepFromReactive(object, key) {
1210
- const depMap = targetMap2.get(object);
1211
- return depMap && depMap.get(key);
1212
- }
1213
- function reactiveReadArray(array) {
1214
- const raw = toRaw2(array);
1215
- if (raw === array)
1216
- return raw;
1217
- track2(raw, "iterate", ARRAY_ITERATE_KEY);
1218
- return isShallow(array) ? raw : raw.map(toReactive);
1219
- }
1220
- function shallowReadArray(arr) {
1221
- track2(arr = toRaw2(arr), "iterate", ARRAY_ITERATE_KEY);
1222
- return arr;
1223
- }
1224
- var arrayInstrumentations = {
1225
- __proto__: null,
1226
- [Symbol.iterator]() {
1227
- return iterator(this, Symbol.iterator, toReactive);
1228
- },
1229
- concat(...args) {
1230
- return reactiveReadArray(this).concat(...args.map((x) => shared.isArray(x) ? reactiveReadArray(x) : x));
1231
- },
1232
- entries() {
1233
- return iterator(this, "entries", (value) => {
1234
- value[1] = toReactive(value[1]);
1235
- return value;
1236
- });
1237
- },
1238
- every(fn, thisArg) {
1239
- return apply(this, "every", fn, thisArg, undefined, arguments);
1240
- },
1241
- filter(fn, thisArg) {
1242
- return apply(this, "filter", fn, thisArg, (v) => v.map(toReactive), arguments);
1243
- },
1244
- find(fn, thisArg) {
1245
- return apply(this, "find", fn, thisArg, toReactive, arguments);
1246
- },
1247
- findIndex(fn, thisArg) {
1248
- return apply(this, "findIndex", fn, thisArg, undefined, arguments);
1249
- },
1250
- findLast(fn, thisArg) {
1251
- return apply(this, "findLast", fn, thisArg, toReactive, arguments);
1252
- },
1253
- findLastIndex(fn, thisArg) {
1254
- return apply(this, "findLastIndex", fn, thisArg, undefined, arguments);
1255
- },
1256
- forEach(fn, thisArg) {
1257
- return apply(this, "forEach", fn, thisArg, undefined, arguments);
1258
- },
1259
- includes(...args) {
1260
- return searchProxy(this, "includes", args);
1261
- },
1262
- indexOf(...args) {
1263
- return searchProxy(this, "indexOf", args);
1264
- },
1265
- join(separator) {
1266
- return reactiveReadArray(this).join(separator);
1267
- },
1268
- lastIndexOf(...args) {
1269
- return searchProxy(this, "lastIndexOf", args);
1270
- },
1271
- map(fn, thisArg) {
1272
- return apply(this, "map", fn, thisArg, undefined, arguments);
1273
- },
1274
- pop() {
1275
- return noTracking(this, "pop");
1276
- },
1277
- push(...args) {
1278
- return noTracking(this, "push", args);
1279
- },
1280
- reduce(fn, ...args) {
1281
- return reduce(this, "reduce", fn, args);
1282
- },
1283
- reduceRight(fn, ...args) {
1284
- return reduce(this, "reduceRight", fn, args);
1285
- },
1286
- shift() {
1287
- return noTracking(this, "shift");
1288
- },
1289
- some(fn, thisArg) {
1290
- return apply(this, "some", fn, thisArg, undefined, arguments);
1291
- },
1292
- splice(...args) {
1293
- return noTracking(this, "splice", args);
1294
- },
1295
- toReversed() {
1296
- return reactiveReadArray(this).toReversed();
1297
- },
1298
- toSorted(comparer) {
1299
- return reactiveReadArray(this).toSorted(comparer);
1300
- },
1301
- toSpliced(...args) {
1302
- return reactiveReadArray(this).toSpliced(...args);
1303
- },
1304
- unshift(...args) {
1305
- return noTracking(this, "unshift", args);
1306
- },
1307
- values() {
1308
- return iterator(this, "values", toReactive);
1309
- }
1310
- };
1311
- function iterator(self2, method, wrapValue) {
1312
- const arr = shallowReadArray(self2);
1313
- const iter = arr[method]();
1314
- if (arr !== self2 && !isShallow(self2)) {
1315
- iter._next = iter.next;
1316
- iter.next = () => {
1317
- const result = iter._next();
1318
- if (result.value) {
1319
- result.value = wrapValue(result.value);
1320
- }
1321
- return result;
1322
- };
1323
- }
1324
- return iter;
1325
- }
1326
- var arrayProto = Array.prototype;
1327
- function apply(self2, method, fn, thisArg, wrappedRetFn, args) {
1328
- const arr = shallowReadArray(self2);
1329
- const needsWrap = arr !== self2 && !isShallow(self2);
1330
- const methodFn = arr[method];
1331
- if (methodFn !== arrayProto[method]) {
1332
- const result2 = methodFn.apply(self2, args);
1333
- return needsWrap ? toReactive(result2) : result2;
1334
- }
1335
- let wrappedFn = fn;
1336
- if (arr !== self2) {
1337
- if (needsWrap) {
1338
- wrappedFn = function(item, index) {
1339
- return fn.call(this, toReactive(item), index, self2);
1340
- };
1341
- } else if (fn.length > 2) {
1342
- wrappedFn = function(item, index) {
1343
- return fn.call(this, item, index, self2);
1344
- };
1345
- }
1346
- }
1347
- const result = methodFn.call(arr, wrappedFn, thisArg);
1348
- return needsWrap && wrappedRetFn ? wrappedRetFn(result) : result;
1349
- }
1350
- function reduce(self2, method, fn, args) {
1351
- const arr = shallowReadArray(self2);
1352
- let wrappedFn = fn;
1353
- if (arr !== self2) {
1354
- if (!isShallow(self2)) {
1355
- wrappedFn = function(acc, item, index) {
1356
- return fn.call(this, acc, toReactive(item), index, self2);
1357
- };
1358
- } else if (fn.length > 3) {
1359
- wrappedFn = function(acc, item, index) {
1360
- return fn.call(this, acc, item, index, self2);
1361
- };
1362
- }
1363
- }
1364
- return arr[method](wrappedFn, ...args);
1365
- }
1366
- function searchProxy(self2, method, args) {
1367
- const arr = toRaw2(self2);
1368
- track2(arr, "iterate", ARRAY_ITERATE_KEY);
1369
- const res = arr[method](...args);
1370
- if ((res === -1 || res === false) && isProxy(args[0])) {
1371
- args[0] = toRaw2(args[0]);
1372
- return arr[method](...args);
1373
- }
1374
- return res;
1375
- }
1376
- function noTracking(self2, method, args = []) {
1377
- pauseTracking();
1378
- startBatch();
1379
- const res = toRaw2(self2)[method].apply(self2, args);
1380
- endBatch();
1381
- resetTracking();
1382
- return res;
1383
- }
1384
- var isNonTrackableKeys = /* @__PURE__ */ shared.makeMap(`__proto__,__v_isRef,__isVue`);
1385
- var builtInSymbols = new Set(/* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(shared.isSymbol));
1386
- function hasOwnProperty(key) {
1387
- if (!shared.isSymbol(key))
1388
- key = String(key);
1389
- const obj = toRaw2(this);
1390
- track2(obj, "has", key);
1391
- return obj.hasOwnProperty(key);
1392
- }
1393
-
1394
- class BaseReactiveHandler {
1395
- constructor(_isReadonly = false, _isShallow = false) {
1396
- this._isReadonly = _isReadonly;
1397
- this._isShallow = _isShallow;
1398
- }
1399
- get(target, key, receiver) {
1400
- if (key === "__v_skip")
1401
- return target["__v_skip"];
1402
- const isReadonly2 = this._isReadonly, isShallow2 = this._isShallow;
1403
- if (key === "__v_isReactive") {
1404
- return !isReadonly2;
1405
- } else if (key === "__v_isReadonly") {
1406
- return isReadonly2;
1407
- } else if (key === "__v_isShallow") {
1408
- return isShallow2;
1409
- } else if (key === "__v_raw") {
1410
- if (receiver === (isReadonly2 ? isShallow2 ? shallowReadonlyMap : readonlyMap : isShallow2 ? shallowReactiveMap : reactiveMap).get(target) || Object.getPrototypeOf(target) === Object.getPrototypeOf(receiver)) {
1411
- return target;
1412
- }
1413
- return;
1414
- }
1415
- const targetIsArray = shared.isArray(target);
1416
- if (!isReadonly2) {
1417
- let fn;
1418
- if (targetIsArray && (fn = arrayInstrumentations[key])) {
1419
- return fn;
1420
- }
1421
- if (key === "hasOwnProperty") {
1422
- return hasOwnProperty;
1423
- }
1424
- }
1425
- const res = Reflect.get(target, key, isRef3(target) ? target : receiver);
1426
- if (shared.isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
1427
- return res;
1428
- }
1429
- if (!isReadonly2) {
1430
- track2(target, "get", key);
1431
- }
1432
- if (isShallow2) {
1433
- return res;
1434
- }
1435
- if (isRef3(res)) {
1436
- return targetIsArray && shared.isIntegerKey(key) ? res : res.value;
1437
- }
1438
- if (shared.isObject(res)) {
1439
- return isReadonly2 ? readonly(res) : reactive2(res);
1440
- }
1441
- return res;
1442
- }
1443
- }
1444
-
1445
- class MutableReactiveHandler extends BaseReactiveHandler {
1446
- constructor(isShallow2 = false) {
1447
- super(false, isShallow2);
1448
- }
1449
- set(target, key, value, receiver) {
1450
- let oldValue = target[key];
1451
- if (!this._isShallow) {
1452
- const isOldValueReadonly = isReadonly(oldValue);
1453
- if (!isShallow(value) && !isReadonly(value)) {
1454
- oldValue = toRaw2(oldValue);
1455
- value = toRaw2(value);
1456
- }
1457
- if (!shared.isArray(target) && isRef3(oldValue) && !isRef3(value)) {
1458
- if (isOldValueReadonly) {
1459
- return false;
1460
- } else {
1461
- oldValue.value = value;
1462
- return true;
1463
- }
1464
- }
1465
- }
1466
- const hadKey = shared.isArray(target) && shared.isIntegerKey(key) ? Number(key) < target.length : shared.hasOwn(target, key);
1467
- const result = Reflect.set(target, key, value, isRef3(target) ? target : receiver);
1468
- if (target === toRaw2(receiver)) {
1469
- if (!hadKey) {
1470
- trigger2(target, "add", key, value);
1471
- } else if (shared.hasChanged(value, oldValue)) {
1472
- trigger2(target, "set", key, value, oldValue);
1473
- }
1474
- }
1475
- return result;
1476
- }
1477
- deleteProperty(target, key) {
1478
- const hadKey = shared.hasOwn(target, key);
1479
- const oldValue = target[key];
1480
- const result = Reflect.deleteProperty(target, key);
1481
- if (result && hadKey) {
1482
- trigger2(target, "delete", key, undefined, oldValue);
1483
- }
1484
- return result;
1485
- }
1486
- has(target, key) {
1487
- const result = Reflect.has(target, key);
1488
- if (!shared.isSymbol(key) || !builtInSymbols.has(key)) {
1489
- track2(target, "has", key);
1490
- }
1491
- return result;
1492
- }
1493
- ownKeys(target) {
1494
- track2(target, "iterate", shared.isArray(target) ? "length" : ITERATE_KEY);
1495
- return Reflect.ownKeys(target);
1496
- }
1497
- }
1498
-
1499
- class ReadonlyReactiveHandler extends BaseReactiveHandler {
1500
- constructor(isShallow2 = false) {
1501
- super(true, isShallow2);
1502
- }
1503
- set(target, key) {
1504
- {
1505
- warn(`Set operation on key "${String(key)}" failed: target is readonly.`, target);
1506
- }
1507
- return true;
1508
- }
1509
- deleteProperty(target, key) {
1510
- {
1511
- warn(`Delete operation on key "${String(key)}" failed: target is readonly.`, target);
1512
- }
1513
- return true;
1514
- }
1515
- }
1516
- var mutableHandlers = /* @__PURE__ */ new MutableReactiveHandler;
1517
- var readonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler;
1518
- var shallowReactiveHandlers = /* @__PURE__ */ new MutableReactiveHandler(true);
1519
- var shallowReadonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler(true);
1520
- var toShallow = (value) => value;
1521
- var getProto = (v) => Reflect.getPrototypeOf(v);
1522
- function createIterableMethod(method, isReadonly2, isShallow2) {
1523
- return function(...args) {
1524
- const target = this["__v_raw"];
1525
- const rawTarget = toRaw2(target);
1526
- const targetIsMap = shared.isMap(rawTarget);
1527
- const isPair = method === "entries" || method === Symbol.iterator && targetIsMap;
1528
- const isKeyOnly = method === "keys" && targetIsMap;
1529
- const innerIterator = target[method](...args);
1530
- const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
1531
- !isReadonly2 && track2(rawTarget, "iterate", isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY);
1532
- return {
1533
- next() {
1534
- const { value, done } = innerIterator.next();
1535
- return done ? { value, done } : {
1536
- value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
1537
- done
1538
- };
1539
- },
1540
- [Symbol.iterator]() {
1541
- return this;
1542
- }
1543
- };
1544
- };
1545
- }
1546
- function createReadonlyMethod(type) {
1547
- return function(...args) {
1548
- {
1549
- const key = args[0] ? `on key "${args[0]}" ` : ``;
1550
- warn(`${shared.capitalize(type)} operation ${key}failed: target is readonly.`, toRaw2(this));
1551
- }
1552
- return type === "delete" ? false : type === "clear" ? undefined : this;
1553
- };
1554
- }
1555
- function createInstrumentations(readonly2, shallow) {
1556
- const instrumentations = {
1557
- get(key) {
1558
- const target = this["__v_raw"];
1559
- const rawTarget = toRaw2(target);
1560
- const rawKey = toRaw2(key);
1561
- if (!readonly2) {
1562
- if (shared.hasChanged(key, rawKey)) {
1563
- track2(rawTarget, "get", key);
1564
- }
1565
- track2(rawTarget, "get", rawKey);
1566
- }
1567
- const { has } = getProto(rawTarget);
1568
- const wrap = shallow ? toShallow : readonly2 ? toReadonly : toReactive;
1569
- if (has.call(rawTarget, key)) {
1570
- return wrap(target.get(key));
1571
- } else if (has.call(rawTarget, rawKey)) {
1572
- return wrap(target.get(rawKey));
1573
- } else if (target !== rawTarget) {
1574
- target.get(key);
1575
- }
1576
- },
1577
- get size() {
1578
- const target = this["__v_raw"];
1579
- !readonly2 && track2(toRaw2(target), "iterate", ITERATE_KEY);
1580
- return Reflect.get(target, "size", target);
1581
- },
1582
- has(key) {
1583
- const target = this["__v_raw"];
1584
- const rawTarget = toRaw2(target);
1585
- const rawKey = toRaw2(key);
1586
- if (!readonly2) {
1587
- if (shared.hasChanged(key, rawKey)) {
1588
- track2(rawTarget, "has", key);
1589
- }
1590
- track2(rawTarget, "has", rawKey);
1591
- }
1592
- return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey);
1593
- },
1594
- forEach(callback, thisArg) {
1595
- const observed = this;
1596
- const target = observed["__v_raw"];
1597
- const rawTarget = toRaw2(target);
1598
- const wrap = shallow ? toShallow : readonly2 ? toReadonly : toReactive;
1599
- !readonly2 && track2(rawTarget, "iterate", ITERATE_KEY);
1600
- return target.forEach((value, key) => {
1601
- return callback.call(thisArg, wrap(value), wrap(key), observed);
1602
- });
1603
- }
1604
- };
1605
- shared.extend(instrumentations, readonly2 ? {
1606
- add: createReadonlyMethod("add"),
1607
- set: createReadonlyMethod("set"),
1608
- delete: createReadonlyMethod("delete"),
1609
- clear: createReadonlyMethod("clear")
1610
- } : {
1611
- add(value) {
1612
- if (!shallow && !isShallow(value) && !isReadonly(value)) {
1613
- value = toRaw2(value);
1614
- }
1615
- const target = toRaw2(this);
1616
- const proto = getProto(target);
1617
- const hadKey = proto.has.call(target, value);
1618
- if (!hadKey) {
1619
- target.add(value);
1620
- trigger2(target, "add", value, value);
1621
- }
1622
- return this;
1623
- },
1624
- set(key, value) {
1625
- if (!shallow && !isShallow(value) && !isReadonly(value)) {
1626
- value = toRaw2(value);
1627
- }
1628
- const target = toRaw2(this);
1629
- const { has, get } = getProto(target);
1630
- let hadKey = has.call(target, key);
1631
- if (!hadKey) {
1632
- key = toRaw2(key);
1633
- hadKey = has.call(target, key);
1634
- } else {
1635
- checkIdentityKeys(target, has, key);
1636
- }
1637
- const oldValue = get.call(target, key);
1638
- target.set(key, value);
1639
- if (!hadKey) {
1640
- trigger2(target, "add", key, value);
1641
- } else if (shared.hasChanged(value, oldValue)) {
1642
- trigger2(target, "set", key, value, oldValue);
1643
- }
1644
- return this;
1645
- },
1646
- delete(key) {
1647
- const target = toRaw2(this);
1648
- const { has, get } = getProto(target);
1649
- let hadKey = has.call(target, key);
1650
- if (!hadKey) {
1651
- key = toRaw2(key);
1652
- hadKey = has.call(target, key);
1653
- } else {
1654
- checkIdentityKeys(target, has, key);
1655
- }
1656
- const oldValue = get ? get.call(target, key) : undefined;
1657
- const result = target.delete(key);
1658
- if (hadKey) {
1659
- trigger2(target, "delete", key, undefined, oldValue);
1660
- }
1661
- return result;
1662
- },
1663
- clear() {
1664
- const target = toRaw2(this);
1665
- const hadItems = target.size !== 0;
1666
- const oldTarget = shared.isMap(target) ? new Map(target) : new Set(target);
1667
- const result = target.clear();
1668
- if (hadItems) {
1669
- trigger2(target, "clear", undefined, undefined, oldTarget);
1670
- }
1671
- return result;
1672
- }
1673
- });
1674
- const iteratorMethods = [
1675
- "keys",
1676
- "values",
1677
- "entries",
1678
- Symbol.iterator
1679
- ];
1680
- iteratorMethods.forEach((method) => {
1681
- instrumentations[method] = createIterableMethod(method, readonly2, shallow);
1682
- });
1683
- return instrumentations;
1684
- }
1685
- function createInstrumentationGetter(isReadonly2, shallow) {
1686
- const instrumentations = createInstrumentations(isReadonly2, shallow);
1687
- return (target, key, receiver) => {
1688
- if (key === "__v_isReactive") {
1689
- return !isReadonly2;
1690
- } else if (key === "__v_isReadonly") {
1691
- return isReadonly2;
1692
- } else if (key === "__v_raw") {
1693
- return target;
1694
- }
1695
- return Reflect.get(shared.hasOwn(instrumentations, key) && key in target ? instrumentations : target, key, receiver);
1696
- };
1697
- }
1698
- var mutableCollectionHandlers = {
1699
- get: /* @__PURE__ */ createInstrumentationGetter(false, false)
1700
- };
1701
- var shallowCollectionHandlers = {
1702
- get: /* @__PURE__ */ createInstrumentationGetter(false, true)
1703
- };
1704
- var readonlyCollectionHandlers = {
1705
- get: /* @__PURE__ */ createInstrumentationGetter(true, false)
1706
- };
1707
- var shallowReadonlyCollectionHandlers = {
1708
- get: /* @__PURE__ */ createInstrumentationGetter(true, true)
1709
- };
1710
- function checkIdentityKeys(target, has, key) {
1711
- const rawKey = toRaw2(key);
1712
- if (rawKey !== key && has.call(target, rawKey)) {
1713
- const type = shared.toRawType(target);
1714
- 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.`);
1715
- }
1716
- }
1717
- var reactiveMap = /* @__PURE__ */ new WeakMap;
1718
- var shallowReactiveMap = /* @__PURE__ */ new WeakMap;
1719
- var readonlyMap = /* @__PURE__ */ new WeakMap;
1720
- var shallowReadonlyMap = /* @__PURE__ */ new WeakMap;
1721
- function targetTypeMap(rawType) {
1722
- switch (rawType) {
1723
- case "Object":
1724
- case "Array":
1725
- return 1;
1726
- case "Map":
1727
- case "Set":
1728
- case "WeakMap":
1729
- case "WeakSet":
1730
- return 2;
1731
- default:
1732
- return 0;
1733
- }
1734
- }
1735
- function getTargetType(value) {
1736
- return value["__v_skip"] || !Object.isExtensible(value) ? 0 : targetTypeMap(shared.toRawType(value));
1737
- }
1738
- function reactive2(target) {
1739
- if (isReadonly(target)) {
1740
- return target;
1741
- }
1742
- return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers, reactiveMap);
1743
- }
1744
- function shallowReactive(target) {
1745
- return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers, shallowReactiveMap);
1746
- }
1747
- function readonly(target) {
1748
- return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers, readonlyMap);
1749
- }
1750
- function shallowReadonly(target) {
1751
- return createReactiveObject(target, true, shallowReadonlyHandlers, shallowReadonlyCollectionHandlers, shallowReadonlyMap);
1752
- }
1753
- function createReactiveObject(target, isReadonly2, baseHandlers, collectionHandlers, proxyMap) {
1754
- if (!shared.isObject(target)) {
1755
- {
1756
- warn(`value cannot be made ${isReadonly2 ? "readonly" : "reactive"}: ${String(target)}`);
1757
- }
1758
- return target;
1759
- }
1760
- if (target["__v_raw"] && !(isReadonly2 && target["__v_isReactive"])) {
1761
- return target;
1762
- }
1763
- const existingProxy = proxyMap.get(target);
1764
- if (existingProxy) {
1765
- return existingProxy;
1766
- }
1767
- const targetType = getTargetType(target);
1768
- if (targetType === 0) {
1769
- return target;
1770
- }
1771
- const proxy = new Proxy(target, targetType === 2 ? collectionHandlers : baseHandlers);
1772
- proxyMap.set(target, proxy);
1773
- return proxy;
1774
- }
1775
- function isReactive2(value) {
1776
- if (isReadonly(value)) {
1777
- return isReactive2(value["__v_raw"]);
1778
- }
1779
- return !!(value && value["__v_isReactive"]);
1780
- }
1781
- function isReadonly(value) {
1782
- return !!(value && value["__v_isReadonly"]);
1783
- }
1784
- function isShallow(value) {
1785
- return !!(value && value["__v_isShallow"]);
1786
- }
1787
- function isProxy(value) {
1788
- return value ? !!value["__v_raw"] : false;
1789
- }
1790
- function toRaw2(observed) {
1791
- const raw = observed && observed["__v_raw"];
1792
- return raw ? toRaw2(raw) : observed;
1793
- }
1794
- function markRaw2(value) {
1795
- if (!shared.hasOwn(value, "__v_skip") && Object.isExtensible(value)) {
1796
- shared.def(value, "__v_skip", true);
1797
- }
1798
- return value;
1799
- }
1800
- var toReactive = (value) => shared.isObject(value) ? reactive2(value) : value;
1801
- var toReadonly = (value) => shared.isObject(value) ? readonly(value) : value;
1802
- function isRef3(r) {
1803
- return r ? r["__v_isRef"] === true : false;
1804
- }
1805
- function ref2(value) {
1806
- return createRef2(value, false);
1807
- }
1808
- function shallowRef(value) {
1809
- return createRef2(value, true);
1810
- }
1811
- function createRef2(rawValue, shallow) {
1812
- if (isRef3(rawValue)) {
1813
- return rawValue;
1814
- }
1815
- return new RefImpl(rawValue, shallow);
1816
- }
1817
-
1818
- class RefImpl {
1819
- constructor(value, isShallow2) {
1820
- this.dep = new Dep;
1821
- this["__v_isRef"] = true;
1822
- this["__v_isShallow"] = false;
1823
- this._rawValue = isShallow2 ? value : toRaw2(value);
1824
- this._value = isShallow2 ? value : toReactive(value);
1825
- this["__v_isShallow"] = isShallow2;
1826
- }
1827
- get value() {
1828
- {
1829
- this.dep.track({
1830
- target: this,
1831
- type: "get",
1832
- key: "value"
1833
- });
1834
- }
1835
- return this._value;
1836
- }
1837
- set value(newValue) {
1838
- const oldValue = this._rawValue;
1839
- const useDirectValue = this["__v_isShallow"] || isShallow(newValue) || isReadonly(newValue);
1840
- newValue = useDirectValue ? newValue : toRaw2(newValue);
1841
- if (shared.hasChanged(newValue, oldValue)) {
1842
- this._rawValue = newValue;
1843
- this._value = useDirectValue ? newValue : toReactive(newValue);
1844
- {
1845
- this.dep.trigger({
1846
- target: this,
1847
- type: "set",
1848
- key: "value",
1849
- newValue,
1850
- oldValue
1851
- });
1852
- }
1853
- }
1854
- }
1855
- }
1856
- function triggerRef2(ref22) {
1857
- if (ref22.dep) {
1858
- {
1859
- ref22.dep.trigger({
1860
- target: ref22,
1861
- type: "set",
1862
- key: "value",
1863
- newValue: ref22._value
1864
- });
1865
- }
1866
- }
1867
- }
1868
- function unref3(ref22) {
1869
- return isRef3(ref22) ? ref22.value : ref22;
1870
- }
1871
- function toValue(source) {
1872
- return shared.isFunction(source) ? source() : unref3(source);
1873
- }
1874
- var shallowUnwrapHandlers = {
1875
- get: (target, key, receiver) => key === "__v_raw" ? target : unref3(Reflect.get(target, key, receiver)),
1876
- set: (target, key, value, receiver) => {
1877
- const oldValue = target[key];
1878
- if (isRef3(oldValue) && !isRef3(value)) {
1879
- oldValue.value = value;
1880
- return true;
1881
- } else {
1882
- return Reflect.set(target, key, value, receiver);
1883
- }
1884
- }
1885
- };
1886
- function proxyRefs(objectWithRefs) {
1887
- return isReactive2(objectWithRefs) ? objectWithRefs : new Proxy(objectWithRefs, shallowUnwrapHandlers);
1888
- }
1889
-
1890
- class CustomRefImpl {
1891
- constructor(factory) {
1892
- this["__v_isRef"] = true;
1893
- this._value = undefined;
1894
- const dep = this.dep = new Dep;
1895
- const { get, set } = factory(dep.track.bind(dep), dep.trigger.bind(dep));
1896
- this._get = get;
1897
- this._set = set;
1898
- }
1899
- get value() {
1900
- return this._value = this._get();
1901
- }
1902
- set value(newVal) {
1903
- this._set(newVal);
1904
- }
1905
- }
1906
- function customRef(factory) {
1907
- return new CustomRefImpl(factory);
1908
- }
1909
- function toRefs2(object) {
1910
- if (!isProxy(object)) {
1911
- warn(`toRefs() expects a reactive object but received a plain one.`);
1912
- }
1913
- const ret = shared.isArray(object) ? new Array(object.length) : {};
1914
- for (const key in object) {
1915
- ret[key] = propertyToRef(object, key);
1916
- }
1917
- return ret;
1918
- }
1919
-
1920
- class ObjectRefImpl {
1921
- constructor(_object, _key, _defaultValue) {
1922
- this._object = _object;
1923
- this._key = _key;
1924
- this._defaultValue = _defaultValue;
1925
- this["__v_isRef"] = true;
1926
- this._value = undefined;
1927
- }
1928
- get value() {
1929
- const val = this._object[this._key];
1930
- return this._value = val === undefined ? this._defaultValue : val;
1931
- }
1932
- set value(newVal) {
1933
- this._object[this._key] = newVal;
1934
- }
1935
- get dep() {
1936
- return getDepFromReactive(toRaw2(this._object), this._key);
1937
- }
1938
- }
1939
-
1940
- class GetterRefImpl {
1941
- constructor(_getter) {
1942
- this._getter = _getter;
1943
- this["__v_isRef"] = true;
1944
- this["__v_isReadonly"] = true;
1945
- this._value = undefined;
1946
- }
1947
- get value() {
1948
- return this._value = this._getter();
1949
- }
1950
- }
1951
- function toRef2(source, key, defaultValue) {
1952
- if (isRef3(source)) {
1953
- return source;
1954
- } else if (shared.isFunction(source)) {
1955
- return new GetterRefImpl(source);
1956
- } else if (shared.isObject(source) && arguments.length > 1) {
1957
- return propertyToRef(source, key, defaultValue);
1958
- } else {
1959
- return ref2(source);
1960
- }
1961
- }
1962
- function propertyToRef(source, key, defaultValue) {
1963
- const val = source[key];
1964
- return isRef3(val) ? val : new ObjectRefImpl(source, key, defaultValue);
1965
- }
1966
-
1967
- class ComputedRefImpl {
1968
- constructor(fn, setter, isSSR) {
1969
- this.fn = fn;
1970
- this.setter = setter;
1971
- this._value = undefined;
1972
- this.dep = new Dep(this);
1973
- this.__v_isRef = true;
1974
- this.deps = undefined;
1975
- this.depsTail = undefined;
1976
- this.flags = 16;
1977
- this.globalVersion = globalVersion - 1;
1978
- this.next = undefined;
1979
- this.effect = this;
1980
- this["__v_isReadonly"] = !setter;
1981
- this.isSSR = isSSR;
1982
- }
1983
- notify() {
1984
- this.flags |= 16;
1985
- if (!(this.flags & 8) && activeSub !== this) {
1986
- batch(this, true);
1987
- return true;
1988
- }
1989
- }
1990
- get value() {
1991
- const link = this.dep.track({
1992
- target: this,
1993
- type: "get",
1994
- key: "value"
1995
- });
1996
- refreshComputed(this);
1997
- if (link) {
1998
- link.version = this.dep.version;
1999
- }
2000
- return this._value;
2001
- }
2002
- set value(newValue) {
2003
- if (this.setter) {
2004
- this.setter(newValue);
2005
- } else {
2006
- warn("Write operation failed: computed value is readonly");
2007
- }
2008
- }
2009
- }
2010
- function computed2(getterOrOptions, debugOptions, isSSR = false) {
2011
- let getter;
2012
- let setter;
2013
- if (shared.isFunction(getterOrOptions)) {
2014
- getter = getterOrOptions;
2015
- } else {
2016
- getter = getterOrOptions.get;
2017
- setter = getterOrOptions.set;
2018
- }
2019
- const cRef = new ComputedRefImpl(getter, setter, isSSR);
2020
- if (debugOptions && !isSSR) {
2021
- cRef.onTrack = debugOptions.onTrack;
2022
- cRef.onTrigger = debugOptions.onTrigger;
2023
- }
2024
- return cRef;
2025
- }
2026
- var TrackOpTypes = {
2027
- GET: "get",
2028
- HAS: "has",
2029
- ITERATE: "iterate"
2030
- };
2031
- var TriggerOpTypes = {
2032
- SET: "set",
2033
- ADD: "add",
2034
- DELETE: "delete",
2035
- CLEAR: "clear"
2036
- };
2037
- var ReactiveFlags2 = {
2038
- SKIP: "__v_skip",
2039
- IS_REACTIVE: "__v_isReactive",
2040
- IS_READONLY: "__v_isReadonly",
2041
- IS_SHALLOW: "__v_isShallow",
2042
- RAW: "__v_raw",
2043
- IS_REF: "__v_isRef"
2044
- };
2045
- var WatchErrorCodes = {
2046
- WATCH_GETTER: 2,
2047
- "2": "WATCH_GETTER",
2048
- WATCH_CALLBACK: 3,
2049
- "3": "WATCH_CALLBACK",
2050
- WATCH_CLEANUP: 4,
2051
- "4": "WATCH_CLEANUP"
2052
- };
2053
- var INITIAL_WATCHER_VALUE = {};
2054
- var cleanupMap = /* @__PURE__ */ new WeakMap;
2055
- var activeWatcher = undefined;
2056
- function getCurrentWatcher() {
2057
- return activeWatcher;
2058
- }
2059
- function onWatcherCleanup(cleanupFn, failSilently = false, owner = activeWatcher) {
2060
- if (owner) {
2061
- let cleanups = cleanupMap.get(owner);
2062
- if (!cleanups)
2063
- cleanupMap.set(owner, cleanups = []);
2064
- cleanups.push(cleanupFn);
2065
- } else if (!failSilently) {
2066
- warn(`onWatcherCleanup() was called when there was no active watcher to associate with.`);
2067
- }
2068
- }
2069
- function watch2(source, cb, options = shared.EMPTY_OBJ) {
2070
- const { immediate, deep, once, scheduler, augmentJob, call } = options;
2071
- const warnInvalidSource = (s) => {
2072
- (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.`);
2073
- };
2074
- const reactiveGetter = (source2) => {
2075
- if (deep)
2076
- return source2;
2077
- if (isShallow(source2) || deep === false || deep === 0)
2078
- return traverse2(source2, 1);
2079
- return traverse2(source2);
2080
- };
2081
- let effect2;
2082
- let getter;
2083
- let cleanup;
2084
- let boundCleanup;
2085
- let forceTrigger = false;
2086
- let isMultiSource = false;
2087
- if (isRef3(source)) {
2088
- getter = () => source.value;
2089
- forceTrigger = isShallow(source);
2090
- } else if (isReactive2(source)) {
2091
- getter = () => reactiveGetter(source);
2092
- forceTrigger = true;
2093
- } else if (shared.isArray(source)) {
2094
- isMultiSource = true;
2095
- forceTrigger = source.some((s) => isReactive2(s) || isShallow(s));
2096
- getter = () => source.map((s) => {
2097
- if (isRef3(s)) {
2098
- return s.value;
2099
- } else if (isReactive2(s)) {
2100
- return reactiveGetter(s);
2101
- } else if (shared.isFunction(s)) {
2102
- return call ? call(s, 2) : s();
2103
- } else {
2104
- warnInvalidSource(s);
2105
- }
2106
- });
2107
- } else if (shared.isFunction(source)) {
2108
- if (cb) {
2109
- getter = call ? () => call(source, 2) : source;
2110
- } else {
2111
- getter = () => {
2112
- if (cleanup) {
2113
- pauseTracking();
2114
- try {
2115
- cleanup();
2116
- } finally {
2117
- resetTracking();
2118
- }
2119
- }
2120
- const currentEffect = activeWatcher;
2121
- activeWatcher = effect2;
2122
- try {
2123
- return call ? call(source, 3, [boundCleanup]) : source(boundCleanup);
2124
- } finally {
2125
- activeWatcher = currentEffect;
2126
- }
2127
- };
2128
- }
2129
- } else {
2130
- getter = shared.NOOP;
2131
- warnInvalidSource(source);
2132
- }
2133
- if (cb && deep) {
2134
- const baseGetter = getter;
2135
- const depth = deep === true ? Infinity : deep;
2136
- getter = () => traverse2(baseGetter(), depth);
2137
- }
2138
- const scope = getCurrentScope();
2139
- const watchHandle = () => {
2140
- effect2.stop();
2141
- if (scope && scope.active) {
2142
- shared.remove(scope.effects, effect2);
2143
- }
2144
- };
2145
- if (once && cb) {
2146
- const _cb = cb;
2147
- cb = (...args) => {
2148
- _cb(...args);
2149
- watchHandle();
2150
- };
2151
- }
2152
- let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
2153
- const job = (immediateFirstRun) => {
2154
- if (!(effect2.flags & 1) || !effect2.dirty && !immediateFirstRun) {
2155
- return;
2156
- }
2157
- if (cb) {
2158
- const newValue = effect2.run();
2159
- if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => shared.hasChanged(v, oldValue[i])) : shared.hasChanged(newValue, oldValue))) {
2160
- if (cleanup) {
2161
- cleanup();
2162
- }
2163
- const currentWatcher = activeWatcher;
2164
- activeWatcher = effect2;
2165
- try {
2166
- const args = [
2167
- newValue,
2168
- oldValue === INITIAL_WATCHER_VALUE ? undefined : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
2169
- boundCleanup
2170
- ];
2171
- call ? call(cb, 3, args) : cb(...args);
2172
- oldValue = newValue;
2173
- } finally {
2174
- activeWatcher = currentWatcher;
2175
- }
2176
- }
2177
- } else {
2178
- effect2.run();
2179
- }
2180
- };
2181
- if (augmentJob) {
2182
- augmentJob(job);
2183
- }
2184
- effect2 = new ReactiveEffect(getter);
2185
- effect2.scheduler = scheduler ? () => scheduler(job, false) : job;
2186
- boundCleanup = (fn) => onWatcherCleanup(fn, false, effect2);
2187
- cleanup = effect2.onStop = () => {
2188
- const cleanups = cleanupMap.get(effect2);
2189
- if (cleanups) {
2190
- if (call) {
2191
- call(cleanups, 4);
2192
- } else {
2193
- for (const cleanup2 of cleanups)
2194
- cleanup2();
2195
- }
2196
- cleanupMap.delete(effect2);
2197
- }
2198
- };
2199
- {
2200
- effect2.onTrack = options.onTrack;
2201
- effect2.onTrigger = options.onTrigger;
2202
- }
2203
- if (cb) {
2204
- if (immediate) {
2205
- job(true);
2206
- } else {
2207
- oldValue = effect2.run();
2208
- }
2209
- } else if (scheduler) {
2210
- scheduler(job.bind(null, true), true);
2211
- } else {
2212
- effect2.run();
2213
- }
2214
- watchHandle.pause = effect2.pause.bind(effect2);
2215
- watchHandle.resume = effect2.resume.bind(effect2);
2216
- watchHandle.stop = watchHandle;
2217
- return watchHandle;
2218
- }
2219
- function traverse2(value, depth = Infinity, seen) {
2220
- if (depth <= 0 || !shared.isObject(value) || value["__v_skip"]) {
2221
- return value;
2222
- }
2223
- seen = seen || /* @__PURE__ */ new Set;
2224
- if (seen.has(value)) {
2225
- return value;
2226
- }
2227
- seen.add(value);
2228
- depth--;
2229
- if (isRef3(value)) {
2230
- traverse2(value.value, depth, seen);
2231
- } else if (shared.isArray(value)) {
2232
- for (let i = 0;i < value.length; i++) {
2233
- traverse2(value[i], depth, seen);
2234
- }
2235
- } else if (shared.isSet(value) || shared.isMap(value)) {
2236
- value.forEach((v) => {
2237
- traverse2(v, depth, seen);
2238
- });
2239
- } else if (shared.isPlainObject(value)) {
2240
- for (const key in value) {
2241
- traverse2(value[key], depth, seen);
2242
- }
2243
- for (const key of Object.getOwnPropertySymbols(value)) {
2244
- if (Object.prototype.propertyIsEnumerable.call(value, key)) {
2245
- traverse2(value[key], depth, seen);
2246
- }
2247
- }
2248
- }
2249
- return value;
2250
- }
2251
- exports.ARRAY_ITERATE_KEY = ARRAY_ITERATE_KEY;
2252
- exports.EffectFlags = EffectFlags;
2253
- exports.EffectScope = EffectScope;
2254
- exports.ITERATE_KEY = ITERATE_KEY;
2255
- exports.MAP_KEY_ITERATE_KEY = MAP_KEY_ITERATE_KEY;
2256
- exports.ReactiveEffect = ReactiveEffect;
2257
- exports.ReactiveFlags = ReactiveFlags2;
2258
- exports.TrackOpTypes = TrackOpTypes;
2259
- exports.TriggerOpTypes = TriggerOpTypes;
2260
- exports.WatchErrorCodes = WatchErrorCodes;
2261
- exports.computed = computed2;
2262
- exports.customRef = customRef;
2263
- exports.effect = effect;
2264
- exports.effectScope = effectScope;
2265
- exports.enableTracking = enableTracking;
2266
- exports.getCurrentScope = getCurrentScope;
2267
- exports.getCurrentWatcher = getCurrentWatcher;
2268
- exports.isProxy = isProxy;
2269
- exports.isReactive = isReactive2;
2270
- exports.isReadonly = isReadonly;
2271
- exports.isRef = isRef3;
2272
- exports.isShallow = isShallow;
2273
- exports.markRaw = markRaw2;
2274
- exports.onEffectCleanup = onEffectCleanup;
2275
- exports.onScopeDispose = onScopeDispose;
2276
- exports.onWatcherCleanup = onWatcherCleanup;
2277
- exports.pauseTracking = pauseTracking;
2278
- exports.proxyRefs = proxyRefs;
2279
- exports.reactive = reactive2;
2280
- exports.reactiveReadArray = reactiveReadArray;
2281
- exports.readonly = readonly;
2282
- exports.ref = ref2;
2283
- exports.resetTracking = resetTracking;
2284
- exports.shallowReactive = shallowReactive;
2285
- exports.shallowReadArray = shallowReadArray;
2286
- exports.shallowReadonly = shallowReadonly;
2287
- exports.shallowRef = shallowRef;
2288
- exports.stop = stop;
2289
- exports.toRaw = toRaw2;
2290
- exports.toReactive = toReactive;
2291
- exports.toReadonly = toReadonly;
2292
- exports.toRef = toRef2;
2293
- exports.toRefs = toRefs2;
2294
- exports.toValue = toValue;
2295
- exports.track = track2;
2296
- exports.traverse = traverse2;
2297
- exports.trigger = trigger2;
2298
- exports.triggerRef = triggerRef2;
2299
- exports.unref = unref3;
2300
- exports.watch = watch2;
2301
- });
2302
1
  // src/utils.ts
2303
2
  function toRaw(observed) {
2304
3
  let value = observed;
@@ -6339,104 +4038,424 @@ function markRaw(obj) {
6339
4038
  return obj;
6340
4039
  }
6341
4040
  // src/integrations/vue3.ts
6342
- var import_reactivity = __toESM(require_reactivity_cjs(), 1);
6343
- import { watchEffect as watchEffect2 } from "vue";
4041
+ import {
4042
+ ReactiveEffect,
4043
+ effectScope,
4044
+ isProxy,
4045
+ isReactive as isReactive2,
4046
+ isReadonly,
4047
+ isShallow,
4048
+ pauseTracking,
4049
+ reactive as reactive2,
4050
+ resetTracking,
4051
+ shallowReactive,
4052
+ toRaw as toRaw2
4053
+ } from "@vue/reactivity";
6344
4054
  function trackVueReactiveEvents(vueState, emit, options = {}) {
6345
4055
  const { emitInitialReplace = true, onDiffError } = options;
4056
+ assertSameVueCopy(vueState);
6346
4057
  if (emitInitialReplace) {
6347
4058
  try {
6348
4059
  emit({ action: "replace", path: [], newValue: deepClone(vueState) });
6349
4060
  } catch (e) {}
6350
4061
  }
6351
- const prev = {};
6352
- const pathStack = [];
6353
- const keyStops = new Map;
6354
- let rootStop = null;
6355
- for (const k of Object.keys(vueState)) {
6356
- prev[k] = deepClone(vueState[k]);
4062
+ const tracker = new Tracker(emit, onDiffError);
4063
+ const root = createNode(tracker, null, null, vueState).start();
4064
+ function warnStopped(method) {
4065
+ console.warn(`[reactive-proxy-state] trackVueReactiveEvents: ${method}() after stop() does nothing. stop() is final; create a new tracker to track again.`);
6357
4066
  }
6358
- function createKeyEffect(k) {
6359
- const stop = watchEffect2(() => {
6360
- if (!(k in vueState))
6361
- return;
6362
- const currVal = vueState[k];
6363
- pathStack.push(k);
6364
- try {
6365
- const result = diffAndClone(currVal, prev[k], pathStack, emit);
6366
- if (result !== prev[k]) {
6367
- prev[k] = result;
6368
- }
6369
- } catch (e) {
6370
- const errorPath = pathStack.slice();
6371
- pathStack.length = 0;
6372
- prev[k] = deepClone(vueState[k]);
6373
- if (onDiffError) {
6374
- onDiffError({ key: k, path: errorPath, error: e });
6375
- }
4067
+ return {
4068
+ stop() {
4069
+ if (tracker.stopped)
6376
4070
  return;
4071
+ tracker.stopped = true;
4072
+ tracker.emitting = false;
4073
+ root.dispose();
4074
+ tracker.scope.stop();
4075
+ },
4076
+ pause() {
4077
+ if (tracker.stopped)
4078
+ warnStopped("pause");
4079
+ else
4080
+ tracker.emitting = false;
4081
+ },
4082
+ resume() {
4083
+ if (tracker.stopped)
4084
+ warnStopped("resume");
4085
+ else
4086
+ tracker.emitting = true;
4087
+ }
4088
+ };
4089
+ }
4090
+ function assertSameVueCopy(state) {
4091
+ if (isProxy(state)) {
4092
+ if (isReadonly(state))
4093
+ return;
4094
+ const raw = toRaw2(state);
4095
+ if ((isShallow(state) ? shallowReactive(raw) : reactive2(raw)) === state)
4096
+ return;
4097
+ }
4098
+ throw new TypeError("trackVueReactiveEvents: the state is not a reactive() object of the @vue/reactivity copy this library imports. " + "Pass the object Vue's reactive() returned. If it is one, the app loads two copies of @vue/reactivity: " + "dedupe 'vue' and '@vue/reactivity' in the bundler.");
4099
+ }
4100
+ var hasOwn2 = Object.prototype.hasOwnProperty;
4101
+ var NO_CHILDREN = new Map;
4102
+
4103
+ class Tracker {
4104
+ listener;
4105
+ onDiffError;
4106
+ scope = effectScope(true);
4107
+ emitting = true;
4108
+ stopped = false;
4109
+ scans = 0;
4110
+ constructor(listener, onDiffError) {
4111
+ this.listener = listener;
4112
+ this.onDiffError = onDiffError;
4113
+ }
4114
+ emit(event) {
4115
+ pauseTracking();
4116
+ try {
4117
+ this.listener(event);
4118
+ } catch (error) {
4119
+ this.report(event.path, error);
4120
+ } finally {
4121
+ resetTracking();
4122
+ }
4123
+ }
4124
+ report(path, error) {
4125
+ if (this.onDiffError === undefined)
4126
+ return;
4127
+ pauseTracking();
4128
+ try {
4129
+ this.onDiffError({ key: path.length > 0 ? String(path[0]) : "", path, error });
4130
+ } finally {
4131
+ resetTracking();
4132
+ }
4133
+ }
4134
+ }
4135
+ function scanNode() {
4136
+ this.scan();
4137
+ }
4138
+ function rerunNode() {
4139
+ if (this.disposed)
4140
+ return;
4141
+ this.run();
4142
+ if (!this.disposed && this.dirty)
4143
+ this.run();
4144
+ }
4145
+ function createNode(tracker, parent, key, proxy) {
4146
+ const node = tracker.scope.run(() => new TrackedNode(tracker, parent, key, proxy));
4147
+ const effects = tracker.scope.effects;
4148
+ if (effects[effects.length - 1] === node)
4149
+ effects.pop();
4150
+ return node;
4151
+ }
4152
+
4153
+ class TrackedNode extends ReactiveEffect {
4154
+ tracker;
4155
+ parent;
4156
+ key;
4157
+ proxy;
4158
+ raw;
4159
+ kind;
4160
+ shadow;
4161
+ children;
4162
+ pending;
4163
+ rawIndex;
4164
+ claim;
4165
+ started;
4166
+ disposed;
4167
+ constructor(tracker, parent, key, proxy) {
4168
+ super(scanNode);
4169
+ this.scheduler = rerunNode;
4170
+ this.tracker = tracker;
4171
+ this.parent = parent;
4172
+ this.key = key;
4173
+ this.proxy = proxy;
4174
+ this.raw = toRaw2(proxy);
4175
+ this.kind = nodeKind(this.raw);
4176
+ this.shadow = undefined;
4177
+ this.children = NO_CHILDREN;
4178
+ this.pending = null;
4179
+ this.rawIndex = null;
4180
+ this.claim = 0;
4181
+ this.started = false;
4182
+ this.disposed = false;
4183
+ }
4184
+ start() {
4185
+ this.run();
4186
+ this.started = true;
4187
+ return this;
4188
+ }
4189
+ path() {
4190
+ const path = [];
4191
+ for (let node = this;node.parent !== null; node = node.parent)
4192
+ path.push(node.key);
4193
+ return path.reverse();
4194
+ }
4195
+ dispose() {
4196
+ if (this.disposed)
4197
+ return;
4198
+ this.disposed = true;
4199
+ this.stop();
4200
+ for (const child of this.children.values())
4201
+ child.dispose();
4202
+ this.children = NO_CHILDREN;
4203
+ this.shadow = undefined;
4204
+ }
4205
+ attachShadow() {
4206
+ const parent = this.parent;
4207
+ if (this.disposed || parent === null || parent.shadow === undefined)
4208
+ return;
4209
+ parent.shadow[this.key] = this.shadow;
4210
+ }
4211
+ scan() {
4212
+ try {
4213
+ if (this.shadow === undefined) {
4214
+ this.firstScan();
4215
+ if (this.started)
4216
+ this.attachShadow();
4217
+ } else if (this.kind === "map" || this.kind === "set") {
4218
+ this.scanCollection();
4219
+ } else {
4220
+ this.scanEntries();
6377
4221
  }
6378
- pathStack.pop();
6379
- }, { flush: "sync" });
6380
- keyStops.set(k, stop);
6381
- }
6382
- function createRootEffect() {
6383
- rootStop = watchEffect2(() => {
6384
- const currKeys = Object.keys(vueState);
6385
- const currKeySet = new Set(currKeys);
6386
- const prevKeySet = new Set(Object.keys(prev));
6387
- for (const k of currKeys) {
6388
- if (!prevKeySet.has(k)) {
6389
- import_reactivity.pauseTracking();
6390
- const cloned = deepClone(vueState[k]);
6391
- import_reactivity.resetTracking();
6392
- pathStack.push(k);
6393
- emit({ action: "set", path: pathStack.slice(), newValue: cloned });
6394
- pathStack.pop();
6395
- prev[k] = cloned;
6396
- createKeyEffect(k);
4222
+ } catch (error) {
4223
+ this.fail(error);
4224
+ }
4225
+ }
4226
+ firstScan() {
4227
+ const proxy = this.proxy;
4228
+ if (this.kind === "map" || this.kind === "set") {
4229
+ this.shadow = deepClone(proxy);
4230
+ return;
4231
+ }
4232
+ if (this.kind === "array") {
4233
+ const length = proxy.length;
4234
+ const shadow2 = new Array(length);
4235
+ this.shadow = shadow2;
4236
+ for (let index = 0;index < length; index++)
4237
+ shadow2[index] = this.adopt(index, proxy[index]);
4238
+ return;
4239
+ }
4240
+ const keys = Object.keys(proxy);
4241
+ const shadow = {};
4242
+ this.shadow = shadow;
4243
+ for (let index = 0;index < keys.length; index++) {
4244
+ const key = keys[index];
4245
+ shadow[key] = this.adopt(key, proxy[key]);
4246
+ }
4247
+ }
4248
+ adopt(key, value) {
4249
+ if (!isNodeValue(value))
4250
+ return copyValue(value);
4251
+ const child = this.createChild(key, value);
4252
+ if (this.children === NO_CHILDREN)
4253
+ this.children = new Map;
4254
+ this.children.set(key, child);
4255
+ return child.shadow;
4256
+ }
4257
+ createChild(key, value) {
4258
+ const raw = toRaw2(value);
4259
+ for (let node = this;node !== null; node = node.parent) {
4260
+ if (node.raw === raw) {
4261
+ throw new Error(`trackVueReactiveEvents: the state holds a cycle at ${[...this.path(), key].join(".")}`);
4262
+ }
4263
+ }
4264
+ return createNode(this.tracker, this, key, value).start();
4265
+ }
4266
+ scanCollection() {
4267
+ const current = deepClone(this.proxy);
4268
+ if (this.tracker.emitting)
4269
+ diffCollection(current, this.shadow, this.path(), this.tracker);
4270
+ if (this.disposed)
4271
+ return;
4272
+ this.shadow = current;
4273
+ this.attachShadow();
4274
+ }
4275
+ scanEntries() {
4276
+ const proxy = this.proxy;
4277
+ const isArray = this.kind === "array";
4278
+ const keys = isArray ? null : Object.keys(proxy);
4279
+ const length = isArray ? proxy.length : keys.length;
4280
+ const values = new Array(length);
4281
+ if (isArray)
4282
+ for (let index = 0;index < length; index++)
4283
+ values[index] = proxy[index];
4284
+ else
4285
+ for (let index = 0;index < length; index++)
4286
+ values[index] = proxy[keys[index]];
4287
+ const scanId = ++this.tracker.scans;
4288
+ const oldChildren = this.children;
4289
+ let children = null;
4290
+ let nodes2 = null;
4291
+ for (let index = 0;index < length; index++) {
4292
+ const value = values[index];
4293
+ if (!isNodeValue(value))
4294
+ continue;
4295
+ const key = isArray ? index : keys[index];
4296
+ const child = this.resolveChild(key, value, oldChildren, scanId);
4297
+ if (children === null) {
4298
+ children = new Map;
4299
+ this.pending = children;
4300
+ nodes2 = new Array(length);
4301
+ }
4302
+ children.set(key, child);
4303
+ nodes2[index] = child;
4304
+ }
4305
+ this.rawIndex = null;
4306
+ for (const child of oldChildren.values())
4307
+ if (child.claim !== scanId)
4308
+ child.dispose();
4309
+ if (isArray)
4310
+ this.diffArray(values, nodes2, oldChildren);
4311
+ else
4312
+ this.diffObject(keys, values, nodes2, oldChildren, scanId);
4313
+ this.pending = null;
4314
+ if (this.disposed) {
4315
+ if (children !== null)
4316
+ for (const child of children.values())
4317
+ child.dispose();
4318
+ return;
4319
+ }
4320
+ this.children = children ?? NO_CHILDREN;
4321
+ }
4322
+ resolveChild(key, value, oldChildren, scanId) {
4323
+ const raw = toRaw2(value);
4324
+ const same = oldChildren.get(key);
4325
+ if (same !== undefined && same.raw === raw && same.claim !== scanId) {
4326
+ same.claim = scanId;
4327
+ return same;
4328
+ }
4329
+ if (oldChildren !== NO_CHILDREN) {
4330
+ this.rawIndex ??= indexByRaw(oldChildren);
4331
+ const candidates = this.rawIndex.get(raw);
4332
+ if (candidates !== undefined) {
4333
+ for (const candidate of candidates) {
4334
+ if (candidate.claim === scanId)
4335
+ continue;
4336
+ candidate.claim = scanId;
4337
+ candidate.key = key;
4338
+ return candidate;
6397
4339
  }
6398
4340
  }
6399
- for (const k of prevKeySet) {
6400
- if (!currKeySet.has(k)) {
6401
- pathStack.push(k);
6402
- emit({ action: "delete", path: pathStack.slice(), oldValue: prev[k] });
6403
- pathStack.pop();
6404
- delete prev[k];
6405
- keyStops.get(k)?.();
6406
- keyStops.delete(k);
6407
- }
4341
+ }
4342
+ return this.createChild(key, value);
4343
+ }
4344
+ diffArray(values, nodes2, oldChildren) {
4345
+ const tracker = this.tracker;
4346
+ const shadow = this.shadow;
4347
+ const emitting = tracker.emitting;
4348
+ const path = emitting ? this.path() : null;
4349
+ const length = values.length;
4350
+ const oldLength = shadow.length;
4351
+ for (let index = 0;index < length; index++) {
4352
+ const child = nodes2 === null ? undefined : nodes2[index];
4353
+ const existed = index < oldLength;
4354
+ const before = shadow[index];
4355
+ const after = child !== undefined ? child.shadow : copyValue(values[index]);
4356
+ if (emitting && !(existed && (child !== undefined ? oldChildren.get(index) === child : before === after))) {
4357
+ path.push(index);
4358
+ if (existed)
4359
+ diffPlain(after, before, path, tracker);
4360
+ else
4361
+ tracker.emit({ action: "set", path: path.slice(), newValue: copyValue(after) });
4362
+ path.pop();
6408
4363
  }
6409
- }, { flush: "sync" });
6410
- }
6411
- function stopAll() {
6412
- rootStop?.();
6413
- rootStop = null;
6414
- for (const stop of keyStops.values())
6415
- stop();
6416
- keyStops.clear();
6417
- }
6418
- function startAll() {
6419
- for (const k of Object.keys(prev)) {
6420
- createKeyEffect(k);
4364
+ shadow[index] = after;
6421
4365
  }
6422
- createRootEffect();
6423
- }
6424
- startAll();
6425
- return {
6426
- stop: stopAll,
6427
- pause: stopAll,
6428
- resume() {
6429
- const currentKeys = new Set(Object.keys(vueState));
6430
- for (const k of Object.keys(prev)) {
6431
- if (!currentKeys.has(k))
6432
- delete prev[k];
4366
+ if (length < oldLength) {
4367
+ if (emitting) {
4368
+ path.push("length");
4369
+ tracker.emit({ action: "set", path: path.slice(), newValue: length, oldValue: oldLength });
4370
+ path.pop();
6433
4371
  }
6434
- for (const k of currentKeys) {
6435
- prev[k] = deepClone(vueState[k]);
4372
+ shadow.length = length;
4373
+ }
4374
+ }
4375
+ diffObject(keys, values, nodes2, oldChildren, scanId) {
4376
+ const tracker = this.tracker;
4377
+ const raw = this.raw;
4378
+ const shadow = this.shadow;
4379
+ const emitting = tracker.emitting;
4380
+ const path = emitting ? this.path() : null;
4381
+ for (const key of Object.keys(shadow)) {
4382
+ if (hasOwn2.call(raw, key))
4383
+ continue;
4384
+ if (emitting) {
4385
+ const gone = oldChildren.get(key);
4386
+ const oldValue = gone !== undefined && gone.claim !== scanId ? shadow[key] : copyValue(shadow[key]);
4387
+ path.push(key);
4388
+ tracker.emit({ action: "delete", path: path.slice(), oldValue });
4389
+ path.pop();
4390
+ }
4391
+ delete shadow[key];
4392
+ }
4393
+ for (let index = 0;index < keys.length; index++) {
4394
+ const key = keys[index];
4395
+ const child = nodes2 === null ? undefined : nodes2[index];
4396
+ const existed = hasOwn2.call(shadow, key);
4397
+ const before = shadow[key];
4398
+ const after = child !== undefined ? child.shadow : copyValue(values[index]);
4399
+ if (emitting && !(existed && (child !== undefined ? oldChildren.get(key) === child : before === after))) {
4400
+ path.push(key);
4401
+ if (existed)
4402
+ diffPlain(after, before, path, tracker);
4403
+ else
4404
+ tracker.emit({ action: "set", path: path.slice(), newValue: copyValue(after) });
4405
+ path.pop();
6436
4406
  }
6437
- startAll();
4407
+ shadow[key] = after;
6438
4408
  }
6439
- };
4409
+ }
4410
+ fail(error) {
4411
+ this.discardChildren();
4412
+ if (this.disposed)
4413
+ return;
4414
+ const path = this.path();
4415
+ this.shadow = undefined;
4416
+ try {
4417
+ this.firstScan();
4418
+ } catch {
4419
+ this.discardChildren();
4420
+ this.shadow = undefined;
4421
+ }
4422
+ if (this.started)
4423
+ this.attachShadow();
4424
+ this.tracker.report(path, error);
4425
+ }
4426
+ discardChildren() {
4427
+ for (const child of this.children.values())
4428
+ child.dispose();
4429
+ if (this.pending !== null)
4430
+ for (const child of this.pending.values())
4431
+ child.dispose();
4432
+ this.children = NO_CHILDREN;
4433
+ this.pending = null;
4434
+ this.rawIndex = null;
4435
+ }
4436
+ }
4437
+ function nodeKind(raw) {
4438
+ if (Array.isArray(raw))
4439
+ return "array";
4440
+ if (raw instanceof Map)
4441
+ return "map";
4442
+ if (raw instanceof Set)
4443
+ return "set";
4444
+ return "object";
4445
+ }
4446
+ function isNodeValue(value) {
4447
+ return value !== null && typeof value === "object" && isReactive2(value);
4448
+ }
4449
+ function indexByRaw(children) {
4450
+ const byRaw = new Map;
4451
+ for (const child of children.values()) {
4452
+ const list = byRaw.get(child.raw);
4453
+ if (list)
4454
+ list.push(child);
4455
+ else
4456
+ byRaw.set(child.raw, [child]);
4457
+ }
4458
+ return byRaw;
6440
4459
  }
6441
4460
  function typeTag(v) {
6442
4461
  if (v === null || typeof v !== "object")
@@ -6451,178 +4470,161 @@ function typeTag(v) {
6451
4470
  return "date";
6452
4471
  return "object";
6453
4472
  }
6454
- function diffAndClone(curr, old, pathStack, emit) {
6455
- if (curr === null || typeof curr !== "object") {
6456
- if (curr !== old) {
6457
- emit({ action: "set", path: pathStack.slice(), oldValue: old, newValue: curr });
6458
- }
6459
- return curr;
4473
+ function copyValue(value) {
4474
+ if (value === null || typeof value !== "object")
4475
+ return value;
4476
+ const raw = toRaw2(value);
4477
+ if (raw instanceof Date)
4478
+ return new Date(raw.getTime());
4479
+ if (Array.isArray(raw)) {
4480
+ const length = raw.length;
4481
+ const copy2 = new Array(length);
4482
+ for (let index = 0;index < length; index++)
4483
+ copy2[index] = copyValue(raw[index]);
4484
+ return copy2;
4485
+ }
4486
+ if (raw instanceof Map) {
4487
+ const copy2 = new Map;
4488
+ raw.forEach((entry, key) => copy2.set(copyValue(key), copyValue(entry)));
4489
+ return copy2;
6460
4490
  }
6461
- if (typeTag(curr) !== typeTag(old)) {
6462
- emit({ action: "set", path: pathStack.slice(), oldValue: old, newValue: deepClone(curr) });
6463
- return deepClone(curr);
4491
+ if (raw instanceof Set) {
4492
+ const copy2 = new Set;
4493
+ raw.forEach((entry) => copy2.add(copyValue(entry)));
4494
+ return copy2;
6464
4495
  }
6465
- if (curr instanceof Date) {
6466
- if (!(old instanceof Date) || +curr !== +old) {
6467
- emit({ action: "set", path: pathStack.slice(), oldValue: old, newValue: new Date(+curr) });
6468
- return new Date(+curr);
4496
+ const copy = {};
4497
+ const keys = Object.keys(raw);
4498
+ for (let index = 0;index < keys.length; index++)
4499
+ copy[keys[index]] = copyValue(raw[keys[index]]);
4500
+ return copy;
4501
+ }
4502
+ function diffPlain(curr, old, path, tracker) {
4503
+ if (curr === null || typeof curr !== "object") {
4504
+ if (curr !== old && !(curr !== curr && old !== old)) {
4505
+ tracker.emit({ action: "set", path: path.slice(), oldValue: copyValue(old), newValue: curr });
6469
4506
  }
6470
- return old;
4507
+ return;
6471
4508
  }
6472
- if (Array.isArray(curr)) {
6473
- return diffAndCloneArray(curr, old, pathStack, emit);
4509
+ const tag = typeTag(curr);
4510
+ if (tag !== typeTag(old)) {
4511
+ tracker.emit({ action: "set", path: path.slice(), oldValue: copyValue(old), newValue: copyValue(curr) });
4512
+ return;
6474
4513
  }
6475
- if (curr instanceof Map) {
6476
- return diffAndCloneMap(curr, old, pathStack, emit);
6477
- }
6478
- if (curr instanceof Set) {
6479
- return diffAndCloneSet(curr, old, pathStack, emit);
6480
- }
6481
- return diffAndCloneObject(curr, old, pathStack, emit);
6482
- }
6483
- function diffAndCloneObject(curr, old, pathStack, emit) {
6484
- const currKeys = Object.keys(curr);
6485
- const oldKeys = Object.keys(old);
6486
- let changed = false;
6487
- let result = null;
6488
- for (let i = 0;i < oldKeys.length; i++) {
6489
- const k = oldKeys[i];
6490
- if (!(k in curr)) {
6491
- if (!changed) {
6492
- changed = true;
6493
- result = { ...old };
6494
- }
6495
- pathStack.push(k);
6496
- emit({ action: "delete", path: pathStack.slice(), oldValue: old[k] });
6497
- pathStack.pop();
6498
- delete result[k];
6499
- }
6500
- }
6501
- for (let i = 0;i < currKeys.length; i++) {
6502
- const k = currKeys[i];
6503
- if (!(k in old)) {
6504
- if (!changed) {
6505
- changed = true;
6506
- result = { ...old };
6507
- }
6508
- pathStack.push(k);
6509
- emit({ action: "set", path: pathStack.slice(), newValue: deepClone(curr[k]) });
6510
- pathStack.pop();
6511
- result[k] = deepClone(curr[k]);
6512
- } else {
6513
- pathStack.push(k);
6514
- const childResult = diffAndClone(curr[k], old[k], pathStack, emit);
6515
- pathStack.pop();
6516
- if (childResult !== old[k]) {
6517
- if (!changed) {
6518
- changed = true;
6519
- result = { ...old };
6520
- }
6521
- result[k] = childResult;
6522
- }
4514
+ if (tag === "date") {
4515
+ if (+curr !== +old) {
4516
+ tracker.emit({ action: "set", path: path.slice(), oldValue: copyValue(old), newValue: new Date(+curr) });
6523
4517
  }
4518
+ return;
6524
4519
  }
6525
- return changed ? result : old;
6526
- }
6527
- function diffAndCloneArray(curr, old, pathStack, emit) {
6528
- const min = Math.min(curr.length, old.length);
6529
- let changed = false;
6530
- let result = null;
6531
- for (let i = 0;i < min; i++) {
6532
- pathStack.push(i);
6533
- const childResult = diffAndClone(curr[i], old[i], pathStack, emit);
6534
- pathStack.pop();
6535
- if (childResult !== old[i]) {
6536
- if (!changed) {
6537
- changed = true;
6538
- result = old.slice();
6539
- }
6540
- result[i] = childResult;
6541
- }
6542
- }
6543
- if (curr.length > old.length) {
6544
- if (!changed) {
6545
- changed = true;
6546
- result = old.slice();
6547
- }
6548
- result.length = curr.length;
6549
- for (let i = old.length;i < curr.length; i++) {
6550
- pathStack.push(i);
6551
- emit({ action: "set", path: pathStack.slice(), newValue: deepClone(curr[i]) });
6552
- pathStack.pop();
6553
- result[i] = deepClone(curr[i]);
6554
- }
6555
- } else if (curr.length < old.length) {
6556
- if (!changed) {
6557
- changed = true;
6558
- result = old.slice();
6559
- }
6560
- pathStack.push("length");
6561
- emit({ action: "set", path: pathStack.slice(), newValue: curr.length, oldValue: old.length });
6562
- pathStack.pop();
6563
- result.length = curr.length;
6564
- }
6565
- return changed ? result : old;
6566
- }
6567
- function diffAndCloneMap(curr, old, pathStack, emit) {
6568
- let changed = false;
6569
- let result = null;
6570
- const path = pathStack.slice();
6571
- for (const [k, v] of old.entries()) {
6572
- if (!curr.has(k)) {
6573
- if (!changed) {
6574
- changed = true;
6575
- result = new Map(old);
4520
+ if (tag === "array") {
4521
+ const min = Math.min(curr.length, old.length);
4522
+ for (let i = 0;i < min; i++) {
4523
+ path.push(i);
4524
+ diffPlain(curr[i], old[i], path, tracker);
4525
+ path.pop();
4526
+ }
4527
+ if (curr.length > old.length) {
4528
+ for (let i = old.length;i < curr.length; i++) {
4529
+ path.push(i);
4530
+ tracker.emit({ action: "set", path: path.slice(), newValue: copyValue(curr[i]) });
4531
+ path.pop();
6576
4532
  }
6577
- emit({ action: "map-delete", path, key: k, oldValue: v });
6578
- result.delete(k);
4533
+ } else if (curr.length < old.length) {
4534
+ path.push("length");
4535
+ tracker.emit({ action: "set", path: path.slice(), newValue: curr.length, oldValue: old.length });
4536
+ path.pop();
6579
4537
  }
4538
+ return;
6580
4539
  }
6581
- for (const [k, v] of curr.entries()) {
6582
- const vClone = deepClone(v);
6583
- if (!old.has(k)) {
6584
- if (!changed) {
6585
- changed = true;
6586
- result = new Map(old);
6587
- }
6588
- emit({ action: "map-set", path, key: k, newValue: vClone });
6589
- result.set(k, vClone);
6590
- } else if (!deepEqual(vClone, old.get(k), new WeakMap)) {
6591
- if (!changed) {
6592
- changed = true;
6593
- result = new Map(old);
6594
- }
6595
- emit({ action: "map-set", path, key: k, newValue: vClone, oldValue: old.get(k) });
6596
- result.set(k, vClone);
4540
+ if (tag === "map" || tag === "set") {
4541
+ diffCollection(curr, old, path.slice(), tracker);
4542
+ return;
4543
+ }
4544
+ for (const k of Object.keys(old)) {
4545
+ if (!hasOwn2.call(curr, k)) {
4546
+ path.push(k);
4547
+ tracker.emit({ action: "delete", path: path.slice(), oldValue: copyValue(old[k]) });
4548
+ path.pop();
6597
4549
  }
6598
4550
  }
6599
- return changed ? result : old;
4551
+ for (const k of Object.keys(curr)) {
4552
+ path.push(k);
4553
+ if (!hasOwn2.call(old, k))
4554
+ tracker.emit({ action: "set", path: path.slice(), newValue: copyValue(curr[k]) });
4555
+ else
4556
+ diffPlain(curr[k], old[k], path, tracker);
4557
+ path.pop();
4558
+ }
6600
4559
  }
6601
- function diffAndCloneSet(curr, old, pathStack, emit) {
6602
- let changed = false;
6603
- let result = null;
6604
- const path = pathStack.slice();
6605
- for (const v of old.values()) {
6606
- if (!curr.has(v)) {
6607
- if (!changed) {
6608
- changed = true;
6609
- result = new Set(old);
6610
- }
6611
- emit({ action: "set-delete", path, value: v, oldValue: v });
6612
- result.delete(v);
6613
- }
4560
+ function sameValue(a, b, seen) {
4561
+ if (a === b || a !== a && b !== b)
4562
+ return true;
4563
+ const tag = typeTag(a);
4564
+ if (tag === "primitive" || tag !== typeTag(b))
4565
+ return false;
4566
+ if (tag === "date")
4567
+ return sameValue(+a, +b, seen);
4568
+ seen ??= new WeakMap;
4569
+ if (seen.get(a) === b)
4570
+ return true;
4571
+ seen.set(a, b);
4572
+ if (tag === "array") {
4573
+ if (a.length !== b.length)
4574
+ return false;
4575
+ for (let i = 0;i < a.length; i++)
4576
+ if (!sameValue(a[i], b[i], seen))
4577
+ return false;
4578
+ return true;
4579
+ }
4580
+ if (tag === "map") {
4581
+ if (a.size !== b.size)
4582
+ return false;
4583
+ for (const [k, v] of a)
4584
+ if (!b.has(k) || !sameValue(v, b.get(k), seen))
4585
+ return false;
4586
+ return true;
4587
+ }
4588
+ if (tag === "set") {
4589
+ if (a.size !== b.size)
4590
+ return false;
4591
+ for (const v of a)
4592
+ if (!b.has(v))
4593
+ return false;
4594
+ return true;
6614
4595
  }
6615
- for (const v of curr.values()) {
6616
- if (!old.has(v)) {
6617
- if (!changed) {
6618
- changed = true;
6619
- result = new Set(old);
4596
+ const keys = Object.keys(a);
4597
+ if (keys.length !== Object.keys(b).length)
4598
+ return false;
4599
+ for (const k of keys)
4600
+ if (!hasOwn2.call(b, k) || !sameValue(a[k], b[k], seen))
4601
+ return false;
4602
+ return true;
4603
+ }
4604
+ function diffCollection(curr, old, path, tracker) {
4605
+ if (curr instanceof Map) {
4606
+ const before = old;
4607
+ for (const [k, v] of before) {
4608
+ if (!curr.has(k))
4609
+ tracker.emit({ action: "map-delete", path: path.slice(), key: k, oldValue: v });
4610
+ }
4611
+ for (const [k, v] of curr) {
4612
+ if (!before.has(k)) {
4613
+ tracker.emit({ action: "map-set", path: path.slice(), key: k, newValue: v });
4614
+ } else if (!sameValue(v, before.get(k), undefined)) {
4615
+ tracker.emit({ action: "map-set", path: path.slice(), key: k, newValue: v, oldValue: before.get(k) });
6620
4616
  }
6621
- emit({ action: "set-add", path, value: deepClone(v) });
6622
- result.add(deepClone(v));
6623
4617
  }
4618
+ return;
4619
+ }
4620
+ for (const v of old) {
4621
+ if (!curr.has(v))
4622
+ tracker.emit({ action: "set-delete", path: path.slice(), value: v, oldValue: v });
4623
+ }
4624
+ for (const v of curr) {
4625
+ if (!old.has(v))
4626
+ tracker.emit({ action: "set-add", path: path.slice(), value: v });
6624
4627
  }
6625
- return changed ? result : old;
6626
4628
  }
6627
4629
  // src/integrations/electron-bridge.ts
6628
4630
  function makeTx() {