@vue/shared 3.2.47 → 3.3.0-alpha.10
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/shared.cjs.js +337 -528
- package/dist/shared.cjs.prod.js +337 -527
- package/dist/shared.d.ts +308 -363
- package/dist/shared.esm-bundler.js +338 -530
- package/package.json +1 -1
package/dist/shared.cjs.js
CHANGED
|
@@ -2,603 +2,412 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
/**
|
|
6
|
-
* Make a map and return a function for checking if a key
|
|
7
|
-
* is in that map.
|
|
8
|
-
* IMPORTANT: all calls of this function must be prefixed with
|
|
9
|
-
* \/\*#\_\_PURE\_\_\*\/
|
|
10
|
-
* So that rollup can tree-shake them if necessary.
|
|
11
|
-
*/
|
|
12
5
|
function makeMap(str, expectsLowerCase) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
6
|
+
const map = /* @__PURE__ */ Object.create(null);
|
|
7
|
+
const list = str.split(",");
|
|
8
|
+
for (let i = 0; i < list.length; i++) {
|
|
9
|
+
map[list[i]] = true;
|
|
10
|
+
}
|
|
11
|
+
return expectsLowerCase ? (val) => !!map[val.toLowerCase()] : (val) => !!map[val];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const EMPTY_OBJ = Object.freeze({}) ;
|
|
15
|
+
const EMPTY_ARR = Object.freeze([]) ;
|
|
16
|
+
const NOOP = () => {
|
|
17
|
+
};
|
|
18
|
+
const NO = () => false;
|
|
19
|
+
const onRE = /^on[^a-z]/;
|
|
20
|
+
const isOn = (key) => onRE.test(key);
|
|
21
|
+
const isModelListener = (key) => key.startsWith("onUpdate:");
|
|
22
|
+
const extend = Object.assign;
|
|
23
|
+
const remove = (arr, el) => {
|
|
24
|
+
const i = arr.indexOf(el);
|
|
25
|
+
if (i > -1) {
|
|
26
|
+
arr.splice(i, 1);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
30
|
+
const hasOwn = (val, key) => hasOwnProperty.call(val, key);
|
|
31
|
+
const isArray = Array.isArray;
|
|
32
|
+
const isMap = (val) => toTypeString(val) === "[object Map]";
|
|
33
|
+
const isSet = (val) => toTypeString(val) === "[object Set]";
|
|
34
|
+
const isDate = (val) => toTypeString(val) === "[object Date]";
|
|
35
|
+
const isRegExp = (val) => toTypeString(val) === "[object RegExp]";
|
|
36
|
+
const isFunction = (val) => typeof val === "function";
|
|
37
|
+
const isString = (val) => typeof val === "string";
|
|
38
|
+
const isSymbol = (val) => typeof val === "symbol";
|
|
39
|
+
const isObject = (val) => val !== null && typeof val === "object";
|
|
40
|
+
const isPromise = (val) => {
|
|
41
|
+
return isObject(val) && isFunction(val.then) && isFunction(val.catch);
|
|
42
|
+
};
|
|
43
|
+
const objectToString = Object.prototype.toString;
|
|
44
|
+
const toTypeString = (value) => objectToString.call(value);
|
|
45
|
+
const toRawType = (value) => {
|
|
46
|
+
return toTypeString(value).slice(8, -1);
|
|
47
|
+
};
|
|
48
|
+
const isPlainObject = (val) => toTypeString(val) === "[object Object]";
|
|
49
|
+
const isIntegerKey = (key) => isString(key) && key !== "NaN" && key[0] !== "-" && "" + parseInt(key, 10) === key;
|
|
50
|
+
const isReservedProp = /* @__PURE__ */ makeMap(
|
|
51
|
+
// the leading comma is intentional so empty string "" is also included
|
|
52
|
+
",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"
|
|
53
|
+
);
|
|
54
|
+
const isBuiltInDirective = /* @__PURE__ */ makeMap(
|
|
55
|
+
"bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo"
|
|
56
|
+
);
|
|
57
|
+
const cacheStringFunction = (fn) => {
|
|
58
|
+
const cache = /* @__PURE__ */ Object.create(null);
|
|
59
|
+
return (str) => {
|
|
60
|
+
const hit = cache[str];
|
|
61
|
+
return hit || (cache[str] = fn(str));
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
const camelizeRE = /-(\w)/g;
|
|
65
|
+
const camelize = cacheStringFunction((str) => {
|
|
66
|
+
return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : "");
|
|
67
|
+
});
|
|
68
|
+
const hyphenateRE = /\B([A-Z])/g;
|
|
69
|
+
const hyphenate = cacheStringFunction(
|
|
70
|
+
(str) => str.replace(hyphenateRE, "-$1").toLowerCase()
|
|
71
|
+
);
|
|
72
|
+
const capitalize = cacheStringFunction(
|
|
73
|
+
(str) => str.charAt(0).toUpperCase() + str.slice(1)
|
|
74
|
+
);
|
|
75
|
+
const toHandlerKey = cacheStringFunction(
|
|
76
|
+
(str) => str ? `on${capitalize(str)}` : ``
|
|
77
|
+
);
|
|
78
|
+
const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
|
|
79
|
+
const invokeArrayFns = (fns, arg) => {
|
|
80
|
+
for (let i = 0; i < fns.length; i++) {
|
|
81
|
+
fns[i](arg);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
const def = (obj, key, value) => {
|
|
85
|
+
Object.defineProperty(obj, key, {
|
|
86
|
+
configurable: true,
|
|
87
|
+
enumerable: false,
|
|
88
|
+
value
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
const looseToNumber = (val) => {
|
|
92
|
+
const n = parseFloat(val);
|
|
93
|
+
return isNaN(n) ? val : n;
|
|
94
|
+
};
|
|
95
|
+
const toNumber = (val) => {
|
|
96
|
+
const n = isString(val) ? Number(val) : NaN;
|
|
97
|
+
return isNaN(n) ? val : n;
|
|
98
|
+
};
|
|
99
|
+
let _globalThis;
|
|
100
|
+
const getGlobalThis = () => {
|
|
101
|
+
return _globalThis || (_globalThis = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : {});
|
|
102
|
+
};
|
|
103
|
+
const identRE = /^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/;
|
|
104
|
+
function genPropsAccessExp(name) {
|
|
105
|
+
return identRE.test(name) ? `__props.${name}` : `__props[${JSON.stringify(name)}]`;
|
|
19
106
|
}
|
|
20
107
|
|
|
21
|
-
/**
|
|
22
|
-
* dev only flag -> name mapping
|
|
23
|
-
*/
|
|
24
108
|
const PatchFlagNames = {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
109
|
+
[1]: `TEXT`,
|
|
110
|
+
[2]: `CLASS`,
|
|
111
|
+
[4]: `STYLE`,
|
|
112
|
+
[8]: `PROPS`,
|
|
113
|
+
[16]: `FULL_PROPS`,
|
|
114
|
+
[32]: `HYDRATE_EVENTS`,
|
|
115
|
+
[64]: `STABLE_FRAGMENT`,
|
|
116
|
+
[128]: `KEYED_FRAGMENT`,
|
|
117
|
+
[256]: `UNKEYED_FRAGMENT`,
|
|
118
|
+
[512]: `NEED_PATCH`,
|
|
119
|
+
[1024]: `DYNAMIC_SLOTS`,
|
|
120
|
+
[2048]: `DEV_ROOT_FRAGMENT`,
|
|
121
|
+
[-1]: `HOISTED`,
|
|
122
|
+
[-2]: `BAIL`
|
|
39
123
|
};
|
|
40
124
|
|
|
41
|
-
/**
|
|
42
|
-
* Dev only
|
|
43
|
-
*/
|
|
44
125
|
const slotFlagsText = {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
126
|
+
[1]: "STABLE",
|
|
127
|
+
[2]: "DYNAMIC",
|
|
128
|
+
[3]: "FORWARDED"
|
|
48
129
|
};
|
|
49
130
|
|
|
50
|
-
const GLOBALS_WHITE_LISTED =
|
|
51
|
-
|
|
52
|
-
'Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt';
|
|
53
|
-
const isGloballyWhitelisted = /*#__PURE__*/ makeMap(GLOBALS_WHITE_LISTED);
|
|
131
|
+
const GLOBALS_WHITE_LISTED = "Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt";
|
|
132
|
+
const isGloballyWhitelisted = /* @__PURE__ */ makeMap(GLOBALS_WHITE_LISTED);
|
|
54
133
|
|
|
55
134
|
const range = 2;
|
|
56
135
|
function generateCodeFrame(source, start = 0, end = source.length) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
const length = Math.max(Math.min(end - count, lineLength), 1);
|
|
88
|
-
res.push(` | ` + '^'.repeat(length));
|
|
89
|
-
}
|
|
90
|
-
count += lineLength + newLineSeqLength;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
break;
|
|
136
|
+
let lines = source.split(/(\r?\n)/);
|
|
137
|
+
const newlineSequences = lines.filter((_, idx) => idx % 2 === 1);
|
|
138
|
+
lines = lines.filter((_, idx) => idx % 2 === 0);
|
|
139
|
+
let count = 0;
|
|
140
|
+
const res = [];
|
|
141
|
+
for (let i = 0; i < lines.length; i++) {
|
|
142
|
+
count += lines[i].length + (newlineSequences[i] && newlineSequences[i].length || 0);
|
|
143
|
+
if (count >= start) {
|
|
144
|
+
for (let j = i - range; j <= i + range || end > count; j++) {
|
|
145
|
+
if (j < 0 || j >= lines.length)
|
|
146
|
+
continue;
|
|
147
|
+
const line = j + 1;
|
|
148
|
+
res.push(
|
|
149
|
+
`${line}${" ".repeat(Math.max(3 - String(line).length, 0))}| ${lines[j]}`
|
|
150
|
+
);
|
|
151
|
+
const lineLength = lines[j].length;
|
|
152
|
+
const newLineSeqLength = newlineSequences[j] && newlineSequences[j].length || 0;
|
|
153
|
+
if (j === i) {
|
|
154
|
+
const pad = start - (count - (lineLength + newLineSeqLength));
|
|
155
|
+
const length = Math.max(
|
|
156
|
+
1,
|
|
157
|
+
end > count ? lineLength - pad : end - start
|
|
158
|
+
);
|
|
159
|
+
res.push(` | ` + " ".repeat(pad) + "^".repeat(length));
|
|
160
|
+
} else if (j > i) {
|
|
161
|
+
if (end > count) {
|
|
162
|
+
const length = Math.max(Math.min(end - count, lineLength), 1);
|
|
163
|
+
res.push(` | ` + "^".repeat(length));
|
|
164
|
+
}
|
|
165
|
+
count += lineLength + newLineSeqLength;
|
|
94
166
|
}
|
|
167
|
+
}
|
|
168
|
+
break;
|
|
95
169
|
}
|
|
96
|
-
|
|
170
|
+
}
|
|
171
|
+
return res.join("\n");
|
|
97
172
|
}
|
|
98
173
|
|
|
99
174
|
function normalizeStyle(value) {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
for (const key in normalized) {
|
|
109
|
-
res[key] = normalized[key];
|
|
110
|
-
}
|
|
111
|
-
}
|
|
175
|
+
if (isArray(value)) {
|
|
176
|
+
const res = {};
|
|
177
|
+
for (let i = 0; i < value.length; i++) {
|
|
178
|
+
const item = value[i];
|
|
179
|
+
const normalized = isString(item) ? parseStringStyle(item) : normalizeStyle(item);
|
|
180
|
+
if (normalized) {
|
|
181
|
+
for (const key in normalized) {
|
|
182
|
+
res[key] = normalized[key];
|
|
112
183
|
}
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
else if (isString(value)) {
|
|
116
|
-
return value;
|
|
117
|
-
}
|
|
118
|
-
else if (isObject(value)) {
|
|
119
|
-
return value;
|
|
184
|
+
}
|
|
120
185
|
}
|
|
186
|
+
return res;
|
|
187
|
+
} else if (isString(value)) {
|
|
188
|
+
return value;
|
|
189
|
+
} else if (isObject(value)) {
|
|
190
|
+
return value;
|
|
191
|
+
}
|
|
121
192
|
}
|
|
122
193
|
const listDelimiterRE = /;(?![^(]*\))/g;
|
|
123
194
|
const propertyDelimiterRE = /:([^]+)/;
|
|
124
195
|
const styleCommentRE = /\/\*.*?\*\//gs;
|
|
125
196
|
function parseStringStyle(cssText) {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
return ret;
|
|
197
|
+
const ret = {};
|
|
198
|
+
cssText.replace(styleCommentRE, "").split(listDelimiterRE).forEach((item) => {
|
|
199
|
+
if (item) {
|
|
200
|
+
const tmp = item.split(propertyDelimiterRE);
|
|
201
|
+
tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
return ret;
|
|
137
205
|
}
|
|
138
206
|
function stringifyStyle(styles) {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
return ret;
|
|
142
|
-
}
|
|
143
|
-
for (const key in styles) {
|
|
144
|
-
const value = styles[key];
|
|
145
|
-
const normalizedKey = key.startsWith(`--`) ? key : hyphenate(key);
|
|
146
|
-
if (isString(value) || typeof value === 'number') {
|
|
147
|
-
// only render valid values
|
|
148
|
-
ret += `${normalizedKey}:${value};`;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
207
|
+
let ret = "";
|
|
208
|
+
if (!styles || isString(styles)) {
|
|
151
209
|
return ret;
|
|
210
|
+
}
|
|
211
|
+
for (const key in styles) {
|
|
212
|
+
const value = styles[key];
|
|
213
|
+
const normalizedKey = key.startsWith(`--`) ? key : hyphenate(key);
|
|
214
|
+
if (isString(value) || typeof value === "number") {
|
|
215
|
+
ret += `${normalizedKey}:${value};`;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return ret;
|
|
152
219
|
}
|
|
153
220
|
function normalizeClass(value) {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
221
|
+
let res = "";
|
|
222
|
+
if (isString(value)) {
|
|
223
|
+
res = value;
|
|
224
|
+
} else if (isArray(value)) {
|
|
225
|
+
for (let i = 0; i < value.length; i++) {
|
|
226
|
+
const normalized = normalizeClass(value[i]);
|
|
227
|
+
if (normalized) {
|
|
228
|
+
res += normalized + " ";
|
|
229
|
+
}
|
|
157
230
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
else if (isObject(value)) {
|
|
167
|
-
for (const name in value) {
|
|
168
|
-
if (value[name]) {
|
|
169
|
-
res += name + ' ';
|
|
170
|
-
}
|
|
171
|
-
}
|
|
231
|
+
} else if (isObject(value)) {
|
|
232
|
+
for (const name in value) {
|
|
233
|
+
if (value[name]) {
|
|
234
|
+
res += name + " ";
|
|
235
|
+
}
|
|
172
236
|
}
|
|
173
|
-
|
|
237
|
+
}
|
|
238
|
+
return res.trim();
|
|
174
239
|
}
|
|
175
240
|
function normalizeProps(props) {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
241
|
+
if (!props)
|
|
242
|
+
return null;
|
|
243
|
+
let { class: klass, style } = props;
|
|
244
|
+
if (klass && !isString(klass)) {
|
|
245
|
+
props.class = normalizeClass(klass);
|
|
246
|
+
}
|
|
247
|
+
if (style) {
|
|
248
|
+
props.style = normalizeStyle(style);
|
|
249
|
+
}
|
|
250
|
+
return props;
|
|
186
251
|
}
|
|
187
252
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
const
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
'time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,' +
|
|
195
|
-
'canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,' +
|
|
196
|
-
'th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,' +
|
|
197
|
-
'option,output,progress,select,textarea,details,dialog,menu,' +
|
|
198
|
-
'summary,template,blockquote,iframe,tfoot';
|
|
199
|
-
// https://developer.mozilla.org/en-US/docs/Web/SVG/Element
|
|
200
|
-
const SVG_TAGS = 'svg,animate,animateMotion,animateTransform,circle,clipPath,color-profile,' +
|
|
201
|
-
'defs,desc,discard,ellipse,feBlend,feColorMatrix,feComponentTransfer,' +
|
|
202
|
-
'feComposite,feConvolveMatrix,feDiffuseLighting,feDisplacementMap,' +
|
|
203
|
-
'feDistantLight,feDropShadow,feFlood,feFuncA,feFuncB,feFuncG,feFuncR,' +
|
|
204
|
-
'feGaussianBlur,feImage,feMerge,feMergeNode,feMorphology,feOffset,' +
|
|
205
|
-
'fePointLight,feSpecularLighting,feSpotLight,feTile,feTurbulence,filter,' +
|
|
206
|
-
'foreignObject,g,hatch,hatchpath,image,line,linearGradient,marker,mask,' +
|
|
207
|
-
'mesh,meshgradient,meshpatch,meshrow,metadata,mpath,path,pattern,' +
|
|
208
|
-
'polygon,polyline,radialGradient,rect,set,solidcolor,stop,switch,symbol,' +
|
|
209
|
-
'text,textPath,title,tspan,unknown,use,view';
|
|
210
|
-
const VOID_TAGS = 'area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr';
|
|
211
|
-
/**
|
|
212
|
-
* Compiler only.
|
|
213
|
-
* Do NOT use in runtime code paths unless behind `true` flag.
|
|
214
|
-
*/
|
|
215
|
-
const isHTMLTag = /*#__PURE__*/ makeMap(HTML_TAGS);
|
|
216
|
-
/**
|
|
217
|
-
* Compiler only.
|
|
218
|
-
* Do NOT use in runtime code paths unless behind `true` flag.
|
|
219
|
-
*/
|
|
220
|
-
const isSVGTag = /*#__PURE__*/ makeMap(SVG_TAGS);
|
|
221
|
-
/**
|
|
222
|
-
* Compiler only.
|
|
223
|
-
* Do NOT use in runtime code paths unless behind `true` flag.
|
|
224
|
-
*/
|
|
225
|
-
const isVoidTag = /*#__PURE__*/ makeMap(VOID_TAGS);
|
|
253
|
+
const 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";
|
|
254
|
+
const 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";
|
|
255
|
+
const VOID_TAGS = "area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr";
|
|
256
|
+
const isHTMLTag = /* @__PURE__ */ makeMap(HTML_TAGS);
|
|
257
|
+
const isSVGTag = /* @__PURE__ */ makeMap(SVG_TAGS);
|
|
258
|
+
const isVoidTag = /* @__PURE__ */ makeMap(VOID_TAGS);
|
|
226
259
|
|
|
227
|
-
/**
|
|
228
|
-
* On the client we only need to offer special cases for boolean attributes that
|
|
229
|
-
* have different names from their corresponding dom properties:
|
|
230
|
-
* - itemscope -> N/A
|
|
231
|
-
* - allowfullscreen -> allowFullscreen
|
|
232
|
-
* - formnovalidate -> formNoValidate
|
|
233
|
-
* - ismap -> isMap
|
|
234
|
-
* - nomodule -> noModule
|
|
235
|
-
* - novalidate -> noValidate
|
|
236
|
-
* - readonly -> readOnly
|
|
237
|
-
*/
|
|
238
260
|
const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
|
|
239
|
-
const isSpecialBooleanAttr =
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
const isBooleanAttr = /*#__PURE__*/ makeMap(specialBooleanAttrs +
|
|
244
|
-
`,async,autofocus,autoplay,controls,default,defer,disabled,hidden,` +
|
|
245
|
-
`loop,open,required,reversed,scoped,seamless,` +
|
|
246
|
-
`checked,muted,multiple,selected`);
|
|
247
|
-
/**
|
|
248
|
-
* Boolean attributes should be included if the value is truthy or ''.
|
|
249
|
-
* e.g. `<select multiple>` compiles to `{ multiple: '' }`
|
|
250
|
-
*/
|
|
261
|
+
const isSpecialBooleanAttr = /* @__PURE__ */ makeMap(specialBooleanAttrs);
|
|
262
|
+
const isBooleanAttr = /* @__PURE__ */ makeMap(
|
|
263
|
+
specialBooleanAttrs + `,async,autofocus,autoplay,controls,default,defer,disabled,hidden,loop,open,required,reversed,scoped,seamless,checked,muted,multiple,selected`
|
|
264
|
+
);
|
|
251
265
|
function includeBooleanAttr(value) {
|
|
252
|
-
|
|
266
|
+
return !!value || value === "";
|
|
253
267
|
}
|
|
254
268
|
const unsafeAttrCharRE = /[>/="'\u0009\u000a\u000c\u0020]/;
|
|
255
269
|
const attrValidationCache = {};
|
|
256
270
|
function isSSRSafeAttrName(name) {
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
271
|
+
if (attrValidationCache.hasOwnProperty(name)) {
|
|
272
|
+
return attrValidationCache[name];
|
|
273
|
+
}
|
|
274
|
+
const isUnsafe = unsafeAttrCharRE.test(name);
|
|
275
|
+
if (isUnsafe) {
|
|
276
|
+
console.error(`unsafe attribute name: ${name}`);
|
|
277
|
+
}
|
|
278
|
+
return attrValidationCache[name] = !isUnsafe;
|
|
265
279
|
}
|
|
266
280
|
const propsToAttrMap = {
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
281
|
+
acceptCharset: "accept-charset",
|
|
282
|
+
className: "class",
|
|
283
|
+
htmlFor: "for",
|
|
284
|
+
httpEquiv: "http-equiv"
|
|
271
285
|
};
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
const isKnownHtmlAttr = /*#__PURE__*/ makeMap(`accept,accept-charset,accesskey,action,align,allow,alt,async,` +
|
|
279
|
-
`autocapitalize,autocomplete,autofocus,autoplay,background,bgcolor,` +
|
|
280
|
-
`border,buffered,capture,challenge,charset,checked,cite,class,code,` +
|
|
281
|
-
`codebase,color,cols,colspan,content,contenteditable,contextmenu,controls,` +
|
|
282
|
-
`coords,crossorigin,csp,data,datetime,decoding,default,defer,dir,dirname,` +
|
|
283
|
-
`disabled,download,draggable,dropzone,enctype,enterkeyhint,for,form,` +
|
|
284
|
-
`formaction,formenctype,formmethod,formnovalidate,formtarget,headers,` +
|
|
285
|
-
`height,hidden,high,href,hreflang,http-equiv,icon,id,importance,integrity,` +
|
|
286
|
-
`ismap,itemprop,keytype,kind,label,lang,language,loading,list,loop,low,` +
|
|
287
|
-
`manifest,max,maxlength,minlength,media,min,multiple,muted,name,novalidate,` +
|
|
288
|
-
`open,optimum,pattern,ping,placeholder,poster,preload,radiogroup,readonly,` +
|
|
289
|
-
`referrerpolicy,rel,required,reversed,rows,rowspan,sandbox,scope,scoped,` +
|
|
290
|
-
`selected,shape,size,sizes,slot,span,spellcheck,src,srcdoc,srclang,srcset,` +
|
|
291
|
-
`start,step,style,summary,tabindex,target,title,translate,type,usemap,` +
|
|
292
|
-
`value,width,wrap`);
|
|
293
|
-
/**
|
|
294
|
-
* Generated from https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute
|
|
295
|
-
*/
|
|
296
|
-
const isKnownSvgAttr = /*#__PURE__*/ makeMap(`xmlns,accent-height,accumulate,additive,alignment-baseline,alphabetic,amplitude,` +
|
|
297
|
-
`arabic-form,ascent,attributeName,attributeType,azimuth,baseFrequency,` +
|
|
298
|
-
`baseline-shift,baseProfile,bbox,begin,bias,by,calcMode,cap-height,class,` +
|
|
299
|
-
`clip,clipPathUnits,clip-path,clip-rule,color,color-interpolation,` +
|
|
300
|
-
`color-interpolation-filters,color-profile,color-rendering,` +
|
|
301
|
-
`contentScriptType,contentStyleType,crossorigin,cursor,cx,cy,d,decelerate,` +
|
|
302
|
-
`descent,diffuseConstant,direction,display,divisor,dominant-baseline,dur,dx,` +
|
|
303
|
-
`dy,edgeMode,elevation,enable-background,end,exponent,fill,fill-opacity,` +
|
|
304
|
-
`fill-rule,filter,filterRes,filterUnits,flood-color,flood-opacity,` +
|
|
305
|
-
`font-family,font-size,font-size-adjust,font-stretch,font-style,` +
|
|
306
|
-
`font-variant,font-weight,format,from,fr,fx,fy,g1,g2,glyph-name,` +
|
|
307
|
-
`glyph-orientation-horizontal,glyph-orientation-vertical,glyphRef,` +
|
|
308
|
-
`gradientTransform,gradientUnits,hanging,height,href,hreflang,horiz-adv-x,` +
|
|
309
|
-
`horiz-origin-x,id,ideographic,image-rendering,in,in2,intercept,k,k1,k2,k3,` +
|
|
310
|
-
`k4,kernelMatrix,kernelUnitLength,kerning,keyPoints,keySplines,keyTimes,` +
|
|
311
|
-
`lang,lengthAdjust,letter-spacing,lighting-color,limitingConeAngle,local,` +
|
|
312
|
-
`marker-end,marker-mid,marker-start,markerHeight,markerUnits,markerWidth,` +
|
|
313
|
-
`mask,maskContentUnits,maskUnits,mathematical,max,media,method,min,mode,` +
|
|
314
|
-
`name,numOctaves,offset,opacity,operator,order,orient,orientation,origin,` +
|
|
315
|
-
`overflow,overline-position,overline-thickness,panose-1,paint-order,path,` +
|
|
316
|
-
`pathLength,patternContentUnits,patternTransform,patternUnits,ping,` +
|
|
317
|
-
`pointer-events,points,pointsAtX,pointsAtY,pointsAtZ,preserveAlpha,` +
|
|
318
|
-
`preserveAspectRatio,primitiveUnits,r,radius,referrerPolicy,refX,refY,rel,` +
|
|
319
|
-
`rendering-intent,repeatCount,repeatDur,requiredExtensions,requiredFeatures,` +
|
|
320
|
-
`restart,result,rotate,rx,ry,scale,seed,shape-rendering,slope,spacing,` +
|
|
321
|
-
`specularConstant,specularExponent,speed,spreadMethod,startOffset,` +
|
|
322
|
-
`stdDeviation,stemh,stemv,stitchTiles,stop-color,stop-opacity,` +
|
|
323
|
-
`strikethrough-position,strikethrough-thickness,string,stroke,` +
|
|
324
|
-
`stroke-dasharray,stroke-dashoffset,stroke-linecap,stroke-linejoin,` +
|
|
325
|
-
`stroke-miterlimit,stroke-opacity,stroke-width,style,surfaceScale,` +
|
|
326
|
-
`systemLanguage,tabindex,tableValues,target,targetX,targetY,text-anchor,` +
|
|
327
|
-
`text-decoration,text-rendering,textLength,to,transform,transform-origin,` +
|
|
328
|
-
`type,u1,u2,underline-position,underline-thickness,unicode,unicode-bidi,` +
|
|
329
|
-
`unicode-range,units-per-em,v-alphabetic,v-hanging,v-ideographic,` +
|
|
330
|
-
`v-mathematical,values,vector-effect,version,vert-adv-y,vert-origin-x,` +
|
|
331
|
-
`vert-origin-y,viewBox,viewTarget,visibility,width,widths,word-spacing,` +
|
|
332
|
-
`writing-mode,x,x-height,x1,x2,xChannelSelector,xlink:actuate,xlink:arcrole,` +
|
|
333
|
-
`xlink:href,xlink:role,xlink:show,xlink:title,xlink:type,xml:base,xml:lang,` +
|
|
334
|
-
`xml:space,y,y1,y2,yChannelSelector,z,zoomAndPan`);
|
|
286
|
+
const isKnownHtmlAttr = /* @__PURE__ */ makeMap(
|
|
287
|
+
`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,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`
|
|
288
|
+
);
|
|
289
|
+
const isKnownSvgAttr = /* @__PURE__ */ makeMap(
|
|
290
|
+
`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,xml:base,xml:lang,xml:space,y,y1,y2,yChannelSelector,z,zoomAndPan`
|
|
291
|
+
);
|
|
335
292
|
|
|
336
293
|
const escapeRE = /["'&<>]/;
|
|
337
294
|
function escapeHtml(string) {
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
295
|
+
const str = "" + string;
|
|
296
|
+
const match = escapeRE.exec(str);
|
|
297
|
+
if (!match) {
|
|
298
|
+
return str;
|
|
299
|
+
}
|
|
300
|
+
let html = "";
|
|
301
|
+
let escaped;
|
|
302
|
+
let index;
|
|
303
|
+
let lastIndex = 0;
|
|
304
|
+
for (index = match.index; index < str.length; index++) {
|
|
305
|
+
switch (str.charCodeAt(index)) {
|
|
306
|
+
case 34:
|
|
307
|
+
escaped = """;
|
|
308
|
+
break;
|
|
309
|
+
case 38:
|
|
310
|
+
escaped = "&";
|
|
311
|
+
break;
|
|
312
|
+
case 39:
|
|
313
|
+
escaped = "'";
|
|
314
|
+
break;
|
|
315
|
+
case 60:
|
|
316
|
+
escaped = "<";
|
|
317
|
+
break;
|
|
318
|
+
case 62:
|
|
319
|
+
escaped = ">";
|
|
320
|
+
break;
|
|
321
|
+
default:
|
|
322
|
+
continue;
|
|
342
323
|
}
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
let index;
|
|
346
|
-
let lastIndex = 0;
|
|
347
|
-
for (index = match.index; index < str.length; index++) {
|
|
348
|
-
switch (str.charCodeAt(index)) {
|
|
349
|
-
case 34: // "
|
|
350
|
-
escaped = '"';
|
|
351
|
-
break;
|
|
352
|
-
case 38: // &
|
|
353
|
-
escaped = '&';
|
|
354
|
-
break;
|
|
355
|
-
case 39: // '
|
|
356
|
-
escaped = ''';
|
|
357
|
-
break;
|
|
358
|
-
case 60: // <
|
|
359
|
-
escaped = '<';
|
|
360
|
-
break;
|
|
361
|
-
case 62: // >
|
|
362
|
-
escaped = '>';
|
|
363
|
-
break;
|
|
364
|
-
default:
|
|
365
|
-
continue;
|
|
366
|
-
}
|
|
367
|
-
if (lastIndex !== index) {
|
|
368
|
-
html += str.slice(lastIndex, index);
|
|
369
|
-
}
|
|
370
|
-
lastIndex = index + 1;
|
|
371
|
-
html += escaped;
|
|
324
|
+
if (lastIndex !== index) {
|
|
325
|
+
html += str.slice(lastIndex, index);
|
|
372
326
|
}
|
|
373
|
-
|
|
327
|
+
lastIndex = index + 1;
|
|
328
|
+
html += escaped;
|
|
329
|
+
}
|
|
330
|
+
return lastIndex !== index ? html + str.slice(lastIndex, index) : html;
|
|
374
331
|
}
|
|
375
|
-
// https://www.w3.org/TR/html52/syntax.html#comments
|
|
376
332
|
const commentStripRE = /^-?>|<!--|-->|--!>|<!-$/g;
|
|
377
333
|
function escapeHtmlComment(src) {
|
|
378
|
-
|
|
334
|
+
return src.replace(commentStripRE, "");
|
|
379
335
|
}
|
|
380
336
|
|
|
381
337
|
function looseCompareArrays(a, b) {
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
338
|
+
if (a.length !== b.length)
|
|
339
|
+
return false;
|
|
340
|
+
let equal = true;
|
|
341
|
+
for (let i = 0; equal && i < a.length; i++) {
|
|
342
|
+
equal = looseEqual(a[i], b[i]);
|
|
343
|
+
}
|
|
344
|
+
return equal;
|
|
389
345
|
}
|
|
390
346
|
function looseEqual(a, b) {
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
347
|
+
if (a === b)
|
|
348
|
+
return true;
|
|
349
|
+
let aValidType = isDate(a);
|
|
350
|
+
let bValidType = isDate(b);
|
|
351
|
+
if (aValidType || bValidType) {
|
|
352
|
+
return aValidType && bValidType ? a.getTime() === b.getTime() : false;
|
|
353
|
+
}
|
|
354
|
+
aValidType = isSymbol(a);
|
|
355
|
+
bValidType = isSymbol(b);
|
|
356
|
+
if (aValidType || bValidType) {
|
|
357
|
+
return a === b;
|
|
358
|
+
}
|
|
359
|
+
aValidType = isArray(a);
|
|
360
|
+
bValidType = isArray(b);
|
|
361
|
+
if (aValidType || bValidType) {
|
|
362
|
+
return aValidType && bValidType ? looseCompareArrays(a, b) : false;
|
|
363
|
+
}
|
|
364
|
+
aValidType = isObject(a);
|
|
365
|
+
bValidType = isObject(b);
|
|
366
|
+
if (aValidType || bValidType) {
|
|
367
|
+
if (!aValidType || !bValidType) {
|
|
368
|
+
return false;
|
|
402
369
|
}
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
if (
|
|
406
|
-
|
|
370
|
+
const aKeysCount = Object.keys(a).length;
|
|
371
|
+
const bKeysCount = Object.keys(b).length;
|
|
372
|
+
if (aKeysCount !== bKeysCount) {
|
|
373
|
+
return false;
|
|
407
374
|
}
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
}
|
|
415
|
-
const aKeysCount = Object.keys(a).length;
|
|
416
|
-
const bKeysCount = Object.keys(b).length;
|
|
417
|
-
if (aKeysCount !== bKeysCount) {
|
|
418
|
-
return false;
|
|
419
|
-
}
|
|
420
|
-
for (const key in a) {
|
|
421
|
-
const aHasKey = a.hasOwnProperty(key);
|
|
422
|
-
const bHasKey = b.hasOwnProperty(key);
|
|
423
|
-
if ((aHasKey && !bHasKey) ||
|
|
424
|
-
(!aHasKey && bHasKey) ||
|
|
425
|
-
!looseEqual(a[key], b[key])) {
|
|
426
|
-
return false;
|
|
427
|
-
}
|
|
428
|
-
}
|
|
375
|
+
for (const key in a) {
|
|
376
|
+
const aHasKey = a.hasOwnProperty(key);
|
|
377
|
+
const bHasKey = b.hasOwnProperty(key);
|
|
378
|
+
if (aHasKey && !bHasKey || !aHasKey && bHasKey || !looseEqual(a[key], b[key])) {
|
|
379
|
+
return false;
|
|
380
|
+
}
|
|
429
381
|
}
|
|
430
|
-
|
|
382
|
+
}
|
|
383
|
+
return String(a) === String(b);
|
|
431
384
|
}
|
|
432
385
|
function looseIndexOf(arr, val) {
|
|
433
|
-
|
|
386
|
+
return arr.findIndex((item) => looseEqual(item, val));
|
|
434
387
|
}
|
|
435
388
|
|
|
436
|
-
/**
|
|
437
|
-
* For converting {{ interpolation }} values to displayed strings.
|
|
438
|
-
* @private
|
|
439
|
-
*/
|
|
440
389
|
const toDisplayString = (val) => {
|
|
441
|
-
|
|
442
|
-
? val
|
|
443
|
-
: val == null
|
|
444
|
-
? ''
|
|
445
|
-
: isArray(val) ||
|
|
446
|
-
(isObject(val) &&
|
|
447
|
-
(val.toString === objectToString || !isFunction(val.toString)))
|
|
448
|
-
? JSON.stringify(val, replacer, 2)
|
|
449
|
-
: String(val);
|
|
390
|
+
return isString(val) ? val : val == null ? "" : isArray(val) || isObject(val) && (val.toString === objectToString || !isFunction(val.toString)) ? JSON.stringify(val, replacer, 2) : String(val);
|
|
450
391
|
};
|
|
451
392
|
const replacer = (_key, val) => {
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
else if (isObject(val) && !isArray(val) && !isPlainObject(val)) {
|
|
470
|
-
return String(val);
|
|
471
|
-
}
|
|
472
|
-
return val;
|
|
473
|
-
};
|
|
474
|
-
|
|
475
|
-
const EMPTY_OBJ = Object.freeze({})
|
|
476
|
-
;
|
|
477
|
-
const EMPTY_ARR = Object.freeze([]) ;
|
|
478
|
-
const NOOP = () => { };
|
|
479
|
-
/**
|
|
480
|
-
* Always return false.
|
|
481
|
-
*/
|
|
482
|
-
const NO = () => false;
|
|
483
|
-
const onRE = /^on[^a-z]/;
|
|
484
|
-
const isOn = (key) => onRE.test(key);
|
|
485
|
-
const isModelListener = (key) => key.startsWith('onUpdate:');
|
|
486
|
-
const extend = Object.assign;
|
|
487
|
-
const remove = (arr, el) => {
|
|
488
|
-
const i = arr.indexOf(el);
|
|
489
|
-
if (i > -1) {
|
|
490
|
-
arr.splice(i, 1);
|
|
491
|
-
}
|
|
492
|
-
};
|
|
493
|
-
const hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
494
|
-
const hasOwn = (val, key) => hasOwnProperty.call(val, key);
|
|
495
|
-
const isArray = Array.isArray;
|
|
496
|
-
const isMap = (val) => toTypeString(val) === '[object Map]';
|
|
497
|
-
const isSet = (val) => toTypeString(val) === '[object Set]';
|
|
498
|
-
const isDate = (val) => toTypeString(val) === '[object Date]';
|
|
499
|
-
const isRegExp = (val) => toTypeString(val) === '[object RegExp]';
|
|
500
|
-
const isFunction = (val) => typeof val === 'function';
|
|
501
|
-
const isString = (val) => typeof val === 'string';
|
|
502
|
-
const isSymbol = (val) => typeof val === 'symbol';
|
|
503
|
-
const isObject = (val) => val !== null && typeof val === 'object';
|
|
504
|
-
const isPromise = (val) => {
|
|
505
|
-
return isObject(val) && isFunction(val.then) && isFunction(val.catch);
|
|
506
|
-
};
|
|
507
|
-
const objectToString = Object.prototype.toString;
|
|
508
|
-
const toTypeString = (value) => objectToString.call(value);
|
|
509
|
-
const toRawType = (value) => {
|
|
510
|
-
// extract "RawType" from strings like "[object RawType]"
|
|
511
|
-
return toTypeString(value).slice(8, -1);
|
|
512
|
-
};
|
|
513
|
-
const isPlainObject = (val) => toTypeString(val) === '[object Object]';
|
|
514
|
-
const isIntegerKey = (key) => isString(key) &&
|
|
515
|
-
key !== 'NaN' &&
|
|
516
|
-
key[0] !== '-' &&
|
|
517
|
-
'' + parseInt(key, 10) === key;
|
|
518
|
-
const isReservedProp = /*#__PURE__*/ makeMap(
|
|
519
|
-
// the leading comma is intentional so empty string "" is also included
|
|
520
|
-
',key,ref,ref_for,ref_key,' +
|
|
521
|
-
'onVnodeBeforeMount,onVnodeMounted,' +
|
|
522
|
-
'onVnodeBeforeUpdate,onVnodeUpdated,' +
|
|
523
|
-
'onVnodeBeforeUnmount,onVnodeUnmounted');
|
|
524
|
-
const isBuiltInDirective = /*#__PURE__*/ makeMap('bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo');
|
|
525
|
-
const cacheStringFunction = (fn) => {
|
|
526
|
-
const cache = Object.create(null);
|
|
527
|
-
return ((str) => {
|
|
528
|
-
const hit = cache[str];
|
|
529
|
-
return hit || (cache[str] = fn(str));
|
|
530
|
-
});
|
|
393
|
+
if (val && val.__v_isRef) {
|
|
394
|
+
return replacer(_key, val.value);
|
|
395
|
+
} else if (isMap(val)) {
|
|
396
|
+
return {
|
|
397
|
+
[`Map(${val.size})`]: [...val.entries()].reduce((entries, [key, val2]) => {
|
|
398
|
+
entries[`${key} =>`] = val2;
|
|
399
|
+
return entries;
|
|
400
|
+
}, {})
|
|
401
|
+
};
|
|
402
|
+
} else if (isSet(val)) {
|
|
403
|
+
return {
|
|
404
|
+
[`Set(${val.size})`]: [...val.values()]
|
|
405
|
+
};
|
|
406
|
+
} else if (isObject(val) && !isArray(val) && !isPlainObject(val)) {
|
|
407
|
+
return String(val);
|
|
408
|
+
}
|
|
409
|
+
return val;
|
|
531
410
|
};
|
|
532
|
-
const camelizeRE = /-(\w)/g;
|
|
533
|
-
/**
|
|
534
|
-
* @private
|
|
535
|
-
*/
|
|
536
|
-
const camelize = cacheStringFunction((str) => {
|
|
537
|
-
return str.replace(camelizeRE, (_, c) => (c ? c.toUpperCase() : ''));
|
|
538
|
-
});
|
|
539
|
-
const hyphenateRE = /\B([A-Z])/g;
|
|
540
|
-
/**
|
|
541
|
-
* @private
|
|
542
|
-
*/
|
|
543
|
-
const hyphenate = cacheStringFunction((str) => str.replace(hyphenateRE, '-$1').toLowerCase());
|
|
544
|
-
/**
|
|
545
|
-
* @private
|
|
546
|
-
*/
|
|
547
|
-
const capitalize = cacheStringFunction((str) => str.charAt(0).toUpperCase() + str.slice(1));
|
|
548
|
-
/**
|
|
549
|
-
* @private
|
|
550
|
-
*/
|
|
551
|
-
const toHandlerKey = cacheStringFunction((str) => str ? `on${capitalize(str)}` : ``);
|
|
552
|
-
// compare whether a value has changed, accounting for NaN.
|
|
553
|
-
const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
|
|
554
|
-
const invokeArrayFns = (fns, arg) => {
|
|
555
|
-
for (let i = 0; i < fns.length; i++) {
|
|
556
|
-
fns[i](arg);
|
|
557
|
-
}
|
|
558
|
-
};
|
|
559
|
-
const def = (obj, key, value) => {
|
|
560
|
-
Object.defineProperty(obj, key, {
|
|
561
|
-
configurable: true,
|
|
562
|
-
enumerable: false,
|
|
563
|
-
value
|
|
564
|
-
});
|
|
565
|
-
};
|
|
566
|
-
/**
|
|
567
|
-
* "123-foo" will be parsed to 123
|
|
568
|
-
* This is used for the .number modifier in v-model
|
|
569
|
-
*/
|
|
570
|
-
const looseToNumber = (val) => {
|
|
571
|
-
const n = parseFloat(val);
|
|
572
|
-
return isNaN(n) ? val : n;
|
|
573
|
-
};
|
|
574
|
-
/**
|
|
575
|
-
* Only conerces number-like strings
|
|
576
|
-
* "123-foo" will be returned as-is
|
|
577
|
-
*/
|
|
578
|
-
const toNumber = (val) => {
|
|
579
|
-
const n = isString(val) ? Number(val) : NaN;
|
|
580
|
-
return isNaN(n) ? val : n;
|
|
581
|
-
};
|
|
582
|
-
let _globalThis;
|
|
583
|
-
const getGlobalThis = () => {
|
|
584
|
-
return (_globalThis ||
|
|
585
|
-
(_globalThis =
|
|
586
|
-
typeof globalThis !== 'undefined'
|
|
587
|
-
? globalThis
|
|
588
|
-
: typeof self !== 'undefined'
|
|
589
|
-
? self
|
|
590
|
-
: typeof window !== 'undefined'
|
|
591
|
-
? window
|
|
592
|
-
: typeof global !== 'undefined'
|
|
593
|
-
? global
|
|
594
|
-
: {}));
|
|
595
|
-
};
|
|
596
|
-
const identRE = /^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/;
|
|
597
|
-
function genPropsAccessExp(name) {
|
|
598
|
-
return identRE.test(name)
|
|
599
|
-
? `__props.${name}`
|
|
600
|
-
: `__props[${JSON.stringify(name)}]`;
|
|
601
|
-
}
|
|
602
411
|
|
|
603
412
|
exports.EMPTY_ARR = EMPTY_ARR;
|
|
604
413
|
exports.EMPTY_OBJ = EMPTY_OBJ;
|