@vue/shared 3.6.0-beta.3 → 3.6.0-beta.5
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 +520 -480
- package/dist/shared.cjs.prod.js +518 -470
- package/dist/shared.d.ts +270 -243
- package/dist/shared.esm-bundler.js +516 -475
- package/package.json +1 -1
package/dist/shared.cjs.js
CHANGED
|
@@ -1,36 +1,45 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vue/shared v3.6.0-beta.
|
|
3
|
-
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
|
-
* @license MIT
|
|
5
|
-
**/
|
|
6
|
-
'
|
|
2
|
+
* @vue/shared v3.6.0-beta.5
|
|
3
|
+
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
|
+
* @license MIT
|
|
5
|
+
**/
|
|
6
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
//#region packages/shared/src/makeMap.ts
|
|
9
|
+
/**
|
|
10
|
+
* Make a map and return a function for checking if a key
|
|
11
|
+
* is in that map.
|
|
12
|
+
* IMPORTANT: all calls of this function must be prefixed with
|
|
13
|
+
* \/\*#\_\_PURE\_\_\*\/
|
|
14
|
+
* So that they can be tree-shaken if necessary.
|
|
15
|
+
*/
|
|
16
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
11
17
|
function makeMap(str) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
18
|
+
const map = Object.create(null);
|
|
19
|
+
for (const key of str.split(",")) map[key] = 1;
|
|
20
|
+
return (val) => val in map;
|
|
15
21
|
}
|
|
16
22
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region packages/shared/src/general.ts
|
|
25
|
+
const EMPTY_OBJ = Object.freeze({});
|
|
26
|
+
const EMPTY_ARR = Object.freeze([]);
|
|
27
|
+
const NOOP = () => {};
|
|
28
|
+
/**
|
|
29
|
+
* Always return true.
|
|
30
|
+
*/
|
|
21
31
|
const YES = () => true;
|
|
32
|
+
/**
|
|
33
|
+
* Always return false.
|
|
34
|
+
*/
|
|
22
35
|
const NO = () => false;
|
|
23
|
-
const isOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 &&
|
|
24
|
-
(key.charCodeAt(2) >
|
|
25
|
-
const isNativeOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && // lowercase letter
|
|
26
|
-
key.charCodeAt(2) > 96 && key.charCodeAt(2) < 123;
|
|
36
|
+
const isOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && (key.charCodeAt(2) > 122 || key.charCodeAt(2) < 97);
|
|
37
|
+
const isNativeOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && key.charCodeAt(2) > 96 && key.charCodeAt(2) < 123;
|
|
27
38
|
const isModelListener = (key) => key.startsWith("onUpdate:");
|
|
28
39
|
const extend = Object.assign;
|
|
29
40
|
const remove = (arr, el) => {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
arr.splice(i, 1);
|
|
33
|
-
}
|
|
41
|
+
const i = arr.indexOf(el);
|
|
42
|
+
if (i > -1) arr.splice(i, 1);
|
|
34
43
|
};
|
|
35
44
|
const hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
36
45
|
const hasOwn = (val, key) => hasOwnProperty.call(val, key);
|
|
@@ -44,595 +53,623 @@ const isString = (val) => typeof val === "string";
|
|
|
44
53
|
const isSymbol = (val) => typeof val === "symbol";
|
|
45
54
|
const isObject = (val) => val !== null && typeof val === "object";
|
|
46
55
|
const isPromise = (val) => {
|
|
47
|
-
|
|
56
|
+
return (isObject(val) || isFunction(val)) && isFunction(val.then) && isFunction(val.catch);
|
|
48
57
|
};
|
|
49
58
|
const objectToString = Object.prototype.toString;
|
|
50
59
|
const toTypeString = (value) => objectToString.call(value);
|
|
51
60
|
const toRawType = (value) => {
|
|
52
|
-
|
|
61
|
+
return toTypeString(value).slice(8, -1);
|
|
53
62
|
};
|
|
54
63
|
const isPlainObject = (val) => toTypeString(val) === "[object Object]";
|
|
55
64
|
const isIntegerKey = (key) => isString(key) && key !== "NaN" && key[0] !== "-" && "" + parseInt(key, 10) === key;
|
|
56
|
-
const isReservedProp = /* @__PURE__ */ makeMap(
|
|
57
|
-
// the leading comma is intentional so empty string "" is also included
|
|
58
|
-
",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"
|
|
59
|
-
);
|
|
65
|
+
const isReservedProp = /* @__PURE__ */ makeMap(",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted");
|
|
60
66
|
const isBuiltInTag = /* @__PURE__ */ makeMap("slot,component");
|
|
61
|
-
const isBuiltInDirective = /* @__PURE__ */ makeMap(
|
|
62
|
-
"bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo"
|
|
63
|
-
);
|
|
67
|
+
const isBuiltInDirective = /* @__PURE__ */ makeMap("bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo");
|
|
64
68
|
const cacheStringFunction = (fn) => {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
});
|
|
69
|
+
const cache = Object.create(null);
|
|
70
|
+
return ((str) => {
|
|
71
|
+
return cache[str] || (cache[str] = fn(str));
|
|
72
|
+
});
|
|
70
73
|
};
|
|
71
74
|
const camelizeRE = /-(\w)/g;
|
|
72
75
|
const camelizeReplacer = (_, c) => c ? c.toUpperCase() : "";
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
+
/**
|
|
77
|
+
* @private
|
|
78
|
+
*/
|
|
79
|
+
const camelize = cacheStringFunction((str) => str.replace(camelizeRE, camelizeReplacer));
|
|
76
80
|
const hyphenateRE = /\B([A-Z])/g;
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
81
|
+
/**
|
|
82
|
+
* @private
|
|
83
|
+
*/
|
|
84
|
+
const hyphenate = cacheStringFunction((str) => str.replace(hyphenateRE, "-$1").toLowerCase());
|
|
85
|
+
/**
|
|
86
|
+
* @private
|
|
87
|
+
*/
|
|
80
88
|
const capitalize = cacheStringFunction((str) => {
|
|
81
|
-
|
|
89
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
82
90
|
});
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
);
|
|
91
|
+
/**
|
|
92
|
+
* @private
|
|
93
|
+
*/
|
|
94
|
+
const toHandlerKey = cacheStringFunction((str) => {
|
|
95
|
+
return str ? `on${capitalize(str)}` : ``;
|
|
96
|
+
});
|
|
97
|
+
/**
|
|
98
|
+
* #13070 When v-model and v-model:model directives are used together,
|
|
99
|
+
* they will generate the same modelModifiers prop,
|
|
100
|
+
* so a `$` suffix is added to avoid conflicts.
|
|
101
|
+
* @private
|
|
102
|
+
*/
|
|
89
103
|
const getModifierPropName = (name) => {
|
|
90
|
-
|
|
104
|
+
return `${name === "modelValue" || name === "model-value" ? "model" : name}Modifiers${name === "model" ? "$" : ""}`;
|
|
91
105
|
};
|
|
92
106
|
const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
|
|
93
107
|
const invokeArrayFns = (fns, ...arg) => {
|
|
94
|
-
|
|
95
|
-
fns[i](...arg);
|
|
96
|
-
}
|
|
108
|
+
for (let i = 0; i < fns.length; i++) fns[i](...arg);
|
|
97
109
|
};
|
|
98
110
|
const def = (obj, key, value, writable = false) => {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
111
|
+
Object.defineProperty(obj, key, {
|
|
112
|
+
configurable: true,
|
|
113
|
+
enumerable: false,
|
|
114
|
+
writable,
|
|
115
|
+
value
|
|
116
|
+
});
|
|
105
117
|
};
|
|
118
|
+
/**
|
|
119
|
+
* "123-foo" will be parsed to 123
|
|
120
|
+
* This is used for the .number modifier in v-model
|
|
121
|
+
*/
|
|
106
122
|
const looseToNumber = (val) => {
|
|
107
|
-
|
|
108
|
-
|
|
123
|
+
const n = parseFloat(val);
|
|
124
|
+
return isNaN(n) ? val : n;
|
|
109
125
|
};
|
|
126
|
+
/**
|
|
127
|
+
* Only concerns number-like strings
|
|
128
|
+
* "123-foo" will be returned as-is
|
|
129
|
+
*/
|
|
110
130
|
const toNumber = (val) => {
|
|
111
|
-
|
|
112
|
-
|
|
131
|
+
const n = isString(val) ? Number(val) : NaN;
|
|
132
|
+
return isNaN(n) ? val : n;
|
|
113
133
|
};
|
|
114
134
|
let _globalThis;
|
|
115
135
|
const getGlobalThis = () => {
|
|
116
|
-
|
|
136
|
+
return _globalThis || (_globalThis = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : {});
|
|
117
137
|
};
|
|
118
138
|
const identRE = /^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/;
|
|
119
139
|
function genPropsAccessExp(name) {
|
|
120
|
-
|
|
140
|
+
return identRE.test(name) ? `__props.${name}` : `__props[${JSON.stringify(name)}]`;
|
|
121
141
|
}
|
|
122
142
|
function genCacheKey(source, options) {
|
|
123
|
-
|
|
124
|
-
options,
|
|
125
|
-
(_, val) => typeof val === "function" ? val.toString() : val
|
|
126
|
-
);
|
|
143
|
+
return source + JSON.stringify(options, (_, val) => typeof val === "function" ? val.toString() : val);
|
|
127
144
|
}
|
|
128
145
|
function canSetValueDirectly(tagName) {
|
|
129
|
-
|
|
130
|
-
!tagName.includes("-");
|
|
146
|
+
return tagName !== "PROGRESS" && !tagName.includes("-");
|
|
131
147
|
}
|
|
132
148
|
|
|
149
|
+
//#endregion
|
|
150
|
+
//#region packages/shared/src/patchFlags.ts
|
|
151
|
+
/**
|
|
152
|
+
* Patch flags are optimization hints generated by the compiler.
|
|
153
|
+
* when a block with dynamicChildren is encountered during diff, the algorithm
|
|
154
|
+
* enters "optimized mode". In this mode, we know that the vdom is produced by
|
|
155
|
+
* a render function generated by the compiler, so the algorithm only needs to
|
|
156
|
+
* handle updates explicitly marked by these patch flags.
|
|
157
|
+
*
|
|
158
|
+
* Patch flags can be combined using the | bitwise operator and can be checked
|
|
159
|
+
* using the & operator, e.g.
|
|
160
|
+
*
|
|
161
|
+
* ```js
|
|
162
|
+
* const flag = TEXT | CLASS
|
|
163
|
+
* if (flag & TEXT) { ... }
|
|
164
|
+
* ```
|
|
165
|
+
*
|
|
166
|
+
* Check the `patchElement` function in '../../runtime-core/src/renderer.ts' to see how the
|
|
167
|
+
* flags are handled during diff.
|
|
168
|
+
*/
|
|
133
169
|
const PatchFlags = {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
170
|
+
"TEXT": 1,
|
|
171
|
+
"1": "TEXT",
|
|
172
|
+
"CLASS": 2,
|
|
173
|
+
"2": "CLASS",
|
|
174
|
+
"STYLE": 4,
|
|
175
|
+
"4": "STYLE",
|
|
176
|
+
"PROPS": 8,
|
|
177
|
+
"8": "PROPS",
|
|
178
|
+
"FULL_PROPS": 16,
|
|
179
|
+
"16": "FULL_PROPS",
|
|
180
|
+
"NEED_HYDRATION": 32,
|
|
181
|
+
"32": "NEED_HYDRATION",
|
|
182
|
+
"STABLE_FRAGMENT": 64,
|
|
183
|
+
"64": "STABLE_FRAGMENT",
|
|
184
|
+
"KEYED_FRAGMENT": 128,
|
|
185
|
+
"128": "KEYED_FRAGMENT",
|
|
186
|
+
"UNKEYED_FRAGMENT": 256,
|
|
187
|
+
"256": "UNKEYED_FRAGMENT",
|
|
188
|
+
"NEED_PATCH": 512,
|
|
189
|
+
"512": "NEED_PATCH",
|
|
190
|
+
"DYNAMIC_SLOTS": 1024,
|
|
191
|
+
"1024": "DYNAMIC_SLOTS",
|
|
192
|
+
"DEV_ROOT_FRAGMENT": 2048,
|
|
193
|
+
"2048": "DEV_ROOT_FRAGMENT",
|
|
194
|
+
"CACHED": -1,
|
|
195
|
+
"-1": "CACHED",
|
|
196
|
+
"BAIL": -2,
|
|
197
|
+
"-2": "BAIL"
|
|
162
198
|
};
|
|
199
|
+
/**
|
|
200
|
+
* dev only flag -> name mapping
|
|
201
|
+
*/
|
|
163
202
|
const PatchFlagNames = {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
203
|
+
[1]: `TEXT`,
|
|
204
|
+
[2]: `CLASS`,
|
|
205
|
+
[4]: `STYLE`,
|
|
206
|
+
[8]: `PROPS`,
|
|
207
|
+
[16]: `FULL_PROPS`,
|
|
208
|
+
[32]: `NEED_HYDRATION`,
|
|
209
|
+
[64]: `STABLE_FRAGMENT`,
|
|
210
|
+
[128]: `KEYED_FRAGMENT`,
|
|
211
|
+
[256]: `UNKEYED_FRAGMENT`,
|
|
212
|
+
[512]: `NEED_PATCH`,
|
|
213
|
+
[1024]: `DYNAMIC_SLOTS`,
|
|
214
|
+
[2048]: `DEV_ROOT_FRAGMENT`,
|
|
215
|
+
[-1]: `CACHED`,
|
|
216
|
+
[-2]: `BAIL`
|
|
178
217
|
};
|
|
179
218
|
|
|
219
|
+
//#endregion
|
|
220
|
+
//#region packages/shared/src/shapeFlags.ts
|
|
180
221
|
const ShapeFlags = {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
222
|
+
"ELEMENT": 1,
|
|
223
|
+
"1": "ELEMENT",
|
|
224
|
+
"FUNCTIONAL_COMPONENT": 2,
|
|
225
|
+
"2": "FUNCTIONAL_COMPONENT",
|
|
226
|
+
"STATEFUL_COMPONENT": 4,
|
|
227
|
+
"4": "STATEFUL_COMPONENT",
|
|
228
|
+
"TEXT_CHILDREN": 8,
|
|
229
|
+
"8": "TEXT_CHILDREN",
|
|
230
|
+
"ARRAY_CHILDREN": 16,
|
|
231
|
+
"16": "ARRAY_CHILDREN",
|
|
232
|
+
"SLOTS_CHILDREN": 32,
|
|
233
|
+
"32": "SLOTS_CHILDREN",
|
|
234
|
+
"TELEPORT": 64,
|
|
235
|
+
"64": "TELEPORT",
|
|
236
|
+
"SUSPENSE": 128,
|
|
237
|
+
"128": "SUSPENSE",
|
|
238
|
+
"COMPONENT_SHOULD_KEEP_ALIVE": 256,
|
|
239
|
+
"256": "COMPONENT_SHOULD_KEEP_ALIVE",
|
|
240
|
+
"COMPONENT_KEPT_ALIVE": 512,
|
|
241
|
+
"512": "COMPONENT_KEPT_ALIVE",
|
|
242
|
+
"COMPONENT": 6,
|
|
243
|
+
"6": "COMPONENT"
|
|
203
244
|
};
|
|
204
245
|
|
|
246
|
+
//#endregion
|
|
247
|
+
//#region packages/shared/src/slotFlags.ts
|
|
205
248
|
const SlotFlags = {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
249
|
+
"STABLE": 1,
|
|
250
|
+
"1": "STABLE",
|
|
251
|
+
"DYNAMIC": 2,
|
|
252
|
+
"2": "DYNAMIC",
|
|
253
|
+
"FORWARDED": 3,
|
|
254
|
+
"3": "FORWARDED"
|
|
212
255
|
};
|
|
256
|
+
/**
|
|
257
|
+
* Dev only
|
|
258
|
+
*/
|
|
213
259
|
const slotFlagsText = {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
260
|
+
[1]: "STABLE",
|
|
261
|
+
[2]: "DYNAMIC",
|
|
262
|
+
[3]: "FORWARDED"
|
|
217
263
|
};
|
|
218
264
|
|
|
265
|
+
//#endregion
|
|
266
|
+
//#region packages/shared/src/globalsAllowList.ts
|
|
219
267
|
const 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";
|
|
220
268
|
const isGloballyAllowed = /* @__PURE__ */ makeMap(GLOBALS_ALLOWED);
|
|
269
|
+
/** @deprecated use `isGloballyAllowed` instead */
|
|
221
270
|
const isGloballyWhitelisted = isGloballyAllowed;
|
|
222
271
|
|
|
272
|
+
//#endregion
|
|
273
|
+
//#region packages/shared/src/codeframe.ts
|
|
223
274
|
const range = 2;
|
|
224
275
|
function generateCodeFrame(source, start = 0, end = source.length) {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
}
|
|
259
|
-
break;
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
return res.join("\n");
|
|
276
|
+
start = Math.max(0, Math.min(start, source.length));
|
|
277
|
+
end = Math.max(0, Math.min(end, source.length));
|
|
278
|
+
if (start > end) return "";
|
|
279
|
+
let lines = source.split(/(\r?\n)/);
|
|
280
|
+
const newlineSequences = lines.filter((_, idx) => idx % 2 === 1);
|
|
281
|
+
lines = lines.filter((_, idx) => idx % 2 === 0);
|
|
282
|
+
let count = 0;
|
|
283
|
+
const res = [];
|
|
284
|
+
for (let i = 0; i < lines.length; i++) {
|
|
285
|
+
count += lines[i].length + (newlineSequences[i] && newlineSequences[i].length || 0);
|
|
286
|
+
if (count >= start) {
|
|
287
|
+
for (let j = i - range; j <= i + range || end > count; j++) {
|
|
288
|
+
if (j < 0 || j >= lines.length) continue;
|
|
289
|
+
const line = j + 1;
|
|
290
|
+
res.push(`${line}${" ".repeat(Math.max(3 - String(line).length, 0))}| ${lines[j]}`);
|
|
291
|
+
const lineLength = lines[j].length;
|
|
292
|
+
const newLineSeqLength = newlineSequences[j] && newlineSequences[j].length || 0;
|
|
293
|
+
if (j === i) {
|
|
294
|
+
const pad = start - (count - (lineLength + newLineSeqLength));
|
|
295
|
+
const length = Math.max(1, end > count ? lineLength - pad : end - start);
|
|
296
|
+
res.push(` | ` + " ".repeat(pad) + "^".repeat(length));
|
|
297
|
+
} else if (j > i) {
|
|
298
|
+
if (end > count) {
|
|
299
|
+
const length = Math.max(Math.min(end - count, lineLength), 1);
|
|
300
|
+
res.push(` | ` + "^".repeat(length));
|
|
301
|
+
}
|
|
302
|
+
count += lineLength + newLineSeqLength;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
break;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
return res.join("\n");
|
|
263
309
|
}
|
|
264
310
|
|
|
311
|
+
//#endregion
|
|
312
|
+
//#region packages/shared/src/normalizeProp.ts
|
|
265
313
|
function normalizeStyle(value) {
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
return res;
|
|
278
|
-
} else if (isString(value) || isObject(value)) {
|
|
279
|
-
return value;
|
|
280
|
-
}
|
|
314
|
+
if (isArray(value)) {
|
|
315
|
+
const res = {};
|
|
316
|
+
for (let i = 0; i < value.length; i++) {
|
|
317
|
+
const item = value[i];
|
|
318
|
+
const normalized = isString(item) ? parseStringStyle(item) : normalizeStyle(item);
|
|
319
|
+
if (normalized) for (const key in normalized) res[key] = normalized[key];
|
|
320
|
+
}
|
|
321
|
+
return res;
|
|
322
|
+
} else if (isString(value) || isObject(value)) return value;
|
|
281
323
|
}
|
|
282
324
|
const listDelimiterRE = /;(?![^(]*\))/g;
|
|
283
325
|
const propertyDelimiterRE = /:([^]+)/;
|
|
284
326
|
const styleCommentRE = /\/\*[^]*?\*\//g;
|
|
285
327
|
function parseStringStyle(cssText) {
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
328
|
+
const ret = {};
|
|
329
|
+
cssText.replace(styleCommentRE, "").split(listDelimiterRE).forEach((item) => {
|
|
330
|
+
if (item) {
|
|
331
|
+
const tmp = item.split(propertyDelimiterRE);
|
|
332
|
+
tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
|
|
333
|
+
}
|
|
334
|
+
});
|
|
335
|
+
return ret;
|
|
294
336
|
}
|
|
295
337
|
function stringifyStyle(styles) {
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
338
|
+
if (!styles) return "";
|
|
339
|
+
if (isString(styles)) return styles;
|
|
340
|
+
let ret = "";
|
|
341
|
+
for (const key in styles) {
|
|
342
|
+
const value = styles[key];
|
|
343
|
+
if (isString(value) || typeof value === "number") {
|
|
344
|
+
const normalizedKey = key.startsWith(`--`) ? key : hyphenate(key);
|
|
345
|
+
ret += `${normalizedKey}:${value};`;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
return ret;
|
|
307
349
|
}
|
|
308
350
|
function normalizeClass(value) {
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
} else if (isObject(value)) {
|
|
320
|
-
for (const name in value) {
|
|
321
|
-
if (value[name]) {
|
|
322
|
-
res += name + " ";
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
return res.trim();
|
|
351
|
+
let res = "";
|
|
352
|
+
if (isString(value)) res = value;
|
|
353
|
+
else if (isArray(value)) for (let i = 0; i < value.length; i++) {
|
|
354
|
+
const normalized = normalizeClass(value[i]);
|
|
355
|
+
if (normalized) res += normalized + " ";
|
|
356
|
+
}
|
|
357
|
+
else if (isObject(value)) {
|
|
358
|
+
for (const name in value) if (value[name]) res += name + " ";
|
|
359
|
+
}
|
|
360
|
+
return res.trim();
|
|
327
361
|
}
|
|
328
362
|
function normalizeProps(props) {
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
if (style) {
|
|
335
|
-
props.style = normalizeStyle(style);
|
|
336
|
-
}
|
|
337
|
-
return props;
|
|
363
|
+
if (!props) return null;
|
|
364
|
+
let { class: klass, style } = props;
|
|
365
|
+
if (klass && !isString(klass)) props.class = normalizeClass(klass);
|
|
366
|
+
if (style) props.style = normalizeStyle(style);
|
|
367
|
+
return props;
|
|
338
368
|
}
|
|
339
369
|
|
|
370
|
+
//#endregion
|
|
371
|
+
//#region packages/shared/src/domTagConfig.ts
|
|
340
372
|
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";
|
|
341
373
|
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";
|
|
342
374
|
const 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";
|
|
343
375
|
const VOID_TAGS = "area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr";
|
|
344
376
|
const FORMATTING_TAGS = "a,b,big,code,em,font,i,nobr,s,small,strike,strong,tt,u";
|
|
377
|
+
const ALWAYS_CLOSE_TAGS = "title,style,script,noscript,template,object,table,button,textarea,select,iframe,fieldset";
|
|
378
|
+
const INLINE_TAGS = "a,abbr,acronym,b,bdi,bdo,big,br,button,canvas,cite,code,data,datalist,del,dfn,em,embed,i,iframe,img,input,ins,kbd,label,map,mark,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,small,span,strong,sub,sup,svg,textarea,time,u,tt,var,video";
|
|
379
|
+
const BLOCK_TAGS = "address,article,aside,blockquote,dd,details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,li,main,menu,nav,ol,p,pre,section,table,ul";
|
|
380
|
+
/**
|
|
381
|
+
* Compiler only.
|
|
382
|
+
* Do NOT use in runtime code paths unless behind `__DEV__` flag.
|
|
383
|
+
*/
|
|
345
384
|
const isHTMLTag = /* @__PURE__ */ makeMap(HTML_TAGS);
|
|
385
|
+
/**
|
|
386
|
+
* Compiler only.
|
|
387
|
+
* Do NOT use in runtime code paths unless behind `__DEV__` flag.
|
|
388
|
+
*/
|
|
346
389
|
const isSVGTag = /* @__PURE__ */ makeMap(SVG_TAGS);
|
|
390
|
+
/**
|
|
391
|
+
* Compiler only.
|
|
392
|
+
* Do NOT use in runtime code paths unless behind `__DEV__` flag.
|
|
393
|
+
*/
|
|
347
394
|
const isMathMLTag = /* @__PURE__ */ makeMap(MATH_TAGS);
|
|
395
|
+
/**
|
|
396
|
+
* Compiler only.
|
|
397
|
+
* Do NOT use in runtime code paths unless behind `__DEV__` flag.
|
|
398
|
+
*/
|
|
348
399
|
const isVoidTag = /* @__PURE__ */ makeMap(VOID_TAGS);
|
|
400
|
+
/**
|
|
401
|
+
* Compiler only.
|
|
402
|
+
* Do NOT use in runtime code paths unless behind `__DEV__` flag.
|
|
403
|
+
*/
|
|
349
404
|
const isFormattingTag = /* @__PURE__ */ makeMap(FORMATTING_TAGS);
|
|
405
|
+
/**
|
|
406
|
+
* Compiler only.
|
|
407
|
+
* Do NOT use in runtime code paths unless behind `__DEV__` flag.
|
|
408
|
+
*/
|
|
409
|
+
const isAlwaysCloseTag = /* @__PURE__ */ makeMap(ALWAYS_CLOSE_TAGS);
|
|
410
|
+
/**
|
|
411
|
+
* Compiler only.
|
|
412
|
+
* Do NOT use in runtime code paths unless behind `__DEV__` flag.
|
|
413
|
+
*/
|
|
414
|
+
const isInlineTag = /* @__PURE__ */ makeMap(INLINE_TAGS);
|
|
415
|
+
/**
|
|
416
|
+
* Compiler only.
|
|
417
|
+
* Do NOT use in runtime code paths unless behind `__DEV__` flag.
|
|
418
|
+
*/
|
|
419
|
+
const isBlockTag = /* @__PURE__ */ makeMap(BLOCK_TAGS);
|
|
350
420
|
|
|
421
|
+
//#endregion
|
|
422
|
+
//#region packages/shared/src/domAttrConfig.ts
|
|
423
|
+
/**
|
|
424
|
+
* On the client we only need to offer special cases for boolean attributes that
|
|
425
|
+
* have different names from their corresponding dom properties:
|
|
426
|
+
* - itemscope -> N/A
|
|
427
|
+
* - allowfullscreen -> allowFullscreen
|
|
428
|
+
* - formnovalidate -> formNoValidate
|
|
429
|
+
* - ismap -> isMap
|
|
430
|
+
* - nomodule -> noModule
|
|
431
|
+
* - novalidate -> noValidate
|
|
432
|
+
* - readonly -> readOnly
|
|
433
|
+
*/
|
|
351
434
|
const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
|
|
352
435
|
const isSpecialBooleanAttr = /* @__PURE__ */ makeMap(specialBooleanAttrs);
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
436
|
+
/**
|
|
437
|
+
* The full list is needed during SSR to produce the correct initial markup.
|
|
438
|
+
*/
|
|
439
|
+
const isBooleanAttr = /* @__PURE__ */ makeMap(specialBooleanAttrs + ",async,autofocus,autoplay,controls,default,defer,disabled,hidden,inert,loop,open,required,reversed,scoped,seamless,checked,muted,multiple,selected");
|
|
440
|
+
/**
|
|
441
|
+
* Boolean attributes should be included if the value is truthy or ''.
|
|
442
|
+
* e.g. `<select multiple>` compiles to `{ multiple: '' }`
|
|
443
|
+
*/
|
|
356
444
|
function includeBooleanAttr(value) {
|
|
357
|
-
|
|
445
|
+
return !!value || value === "";
|
|
358
446
|
}
|
|
359
447
|
const unsafeAttrCharRE = /[>/="'\u0009\u000a\u000c\u0020]/;
|
|
360
448
|
const attrValidationCache = {};
|
|
361
449
|
function isSSRSafeAttrName(name) {
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
if (isUnsafe) {
|
|
367
|
-
console.error(`unsafe attribute name: ${name}`);
|
|
368
|
-
}
|
|
369
|
-
return attrValidationCache[name] = !isUnsafe;
|
|
450
|
+
if (attrValidationCache.hasOwnProperty(name)) return attrValidationCache[name];
|
|
451
|
+
const isUnsafe = unsafeAttrCharRE.test(name);
|
|
452
|
+
if (isUnsafe) console.error(`unsafe attribute name: ${name}`);
|
|
453
|
+
return attrValidationCache[name] = !isUnsafe;
|
|
370
454
|
}
|
|
371
455
|
const propsToAttrMap = {
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
456
|
+
acceptCharset: "accept-charset",
|
|
457
|
+
className: "class",
|
|
458
|
+
htmlFor: "for",
|
|
459
|
+
httpEquiv: "http-equiv"
|
|
376
460
|
};
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
const
|
|
384
|
-
|
|
385
|
-
|
|
461
|
+
/**
|
|
462
|
+
* Known attributes, this is used for stringification of runtime static nodes
|
|
463
|
+
* so that we don't stringify bindings that cannot be set from HTML.
|
|
464
|
+
* Don't also forget to allow `data-*` and `aria-*`!
|
|
465
|
+
* Generated from https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes
|
|
466
|
+
*/
|
|
467
|
+
const 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");
|
|
468
|
+
/**
|
|
469
|
+
* Generated from https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute
|
|
470
|
+
*/
|
|
471
|
+
const 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");
|
|
472
|
+
/**
|
|
473
|
+
* Generated from https://developer.mozilla.org/en-US/docs/Web/MathML/Attribute
|
|
474
|
+
*/
|
|
475
|
+
const 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");
|
|
476
|
+
/**
|
|
477
|
+
* Shared between server-renderer and runtime-core hydration logic
|
|
478
|
+
*/
|
|
386
479
|
function isRenderableAttrValue(value) {
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
const type = typeof value;
|
|
391
|
-
return type === "string" || type === "number" || type === "boolean";
|
|
480
|
+
if (value == null) return false;
|
|
481
|
+
const type = typeof value;
|
|
482
|
+
return type === "string" || type === "number" || type === "boolean";
|
|
392
483
|
}
|
|
393
484
|
function shouldSetAsAttr(tagName, key) {
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
return true;
|
|
402
|
-
}
|
|
403
|
-
if (key === "type" && tagName === "TEXTAREA") {
|
|
404
|
-
return true;
|
|
405
|
-
}
|
|
406
|
-
if ((key === "width" || key === "height") && (tagName === "IMG" || tagName === "VIDEO" || tagName === "CANVAS" || tagName === "SOURCE")) {
|
|
407
|
-
return true;
|
|
408
|
-
}
|
|
409
|
-
if (key === "sandbox" && tagName === "IFRAME") {
|
|
410
|
-
return true;
|
|
411
|
-
}
|
|
412
|
-
return false;
|
|
485
|
+
if (key === "spellcheck" || key === "draggable" || key === "translate" || key === "autocorrect") return true;
|
|
486
|
+
if (key === "form") return true;
|
|
487
|
+
if (key === "list" && tagName === "INPUT") return true;
|
|
488
|
+
if (key === "type" && tagName === "TEXTAREA") return true;
|
|
489
|
+
if ((key === "width" || key === "height") && (tagName === "IMG" || tagName === "VIDEO" || tagName === "CANVAS" || tagName === "SOURCE")) return true;
|
|
490
|
+
if (key === "sandbox" && tagName === "IFRAME") return true;
|
|
491
|
+
return false;
|
|
413
492
|
}
|
|
414
493
|
|
|
494
|
+
//#endregion
|
|
495
|
+
//#region packages/shared/src/domNamespace.ts
|
|
415
496
|
const Namespaces = {
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
497
|
+
"HTML": 0,
|
|
498
|
+
"0": "HTML",
|
|
499
|
+
"SVG": 1,
|
|
500
|
+
"1": "SVG",
|
|
501
|
+
"MATH_ML": 2,
|
|
502
|
+
"2": "MATH_ML"
|
|
422
503
|
};
|
|
423
504
|
|
|
505
|
+
//#endregion
|
|
506
|
+
//#region packages/shared/src/escapeHtml.ts
|
|
424
507
|
const escapeRE = /["'&<>]/;
|
|
425
508
|
function escapeHtml(string) {
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
}
|
|
458
|
-
lastIndex = index + 1;
|
|
459
|
-
html += escaped;
|
|
460
|
-
}
|
|
461
|
-
return lastIndex !== index ? html + str.slice(lastIndex, index) : html;
|
|
509
|
+
const str = "" + string;
|
|
510
|
+
const match = escapeRE.exec(str);
|
|
511
|
+
if (!match) return str;
|
|
512
|
+
let html = "";
|
|
513
|
+
let escaped;
|
|
514
|
+
let index;
|
|
515
|
+
let lastIndex = 0;
|
|
516
|
+
for (index = match.index; index < str.length; index++) {
|
|
517
|
+
switch (str.charCodeAt(index)) {
|
|
518
|
+
case 34:
|
|
519
|
+
escaped = """;
|
|
520
|
+
break;
|
|
521
|
+
case 38:
|
|
522
|
+
escaped = "&";
|
|
523
|
+
break;
|
|
524
|
+
case 39:
|
|
525
|
+
escaped = "'";
|
|
526
|
+
break;
|
|
527
|
+
case 60:
|
|
528
|
+
escaped = "<";
|
|
529
|
+
break;
|
|
530
|
+
case 62:
|
|
531
|
+
escaped = ">";
|
|
532
|
+
break;
|
|
533
|
+
default: continue;
|
|
534
|
+
}
|
|
535
|
+
if (lastIndex !== index) html += str.slice(lastIndex, index);
|
|
536
|
+
lastIndex = index + 1;
|
|
537
|
+
html += escaped;
|
|
538
|
+
}
|
|
539
|
+
return lastIndex !== index ? html + str.slice(lastIndex, index) : html;
|
|
462
540
|
}
|
|
463
541
|
const commentStripRE = /^-?>|<!--|-->|--!>|<!-$/g;
|
|
464
542
|
function escapeHtmlComment(src) {
|
|
465
|
-
|
|
543
|
+
return src.replace(commentStripRE, "");
|
|
466
544
|
}
|
|
467
545
|
const cssVarNameEscapeSymbolsRE = /[ !"#$%&'()*+,./:;<=>?@[\\\]^`{|}~]/g;
|
|
468
546
|
function getEscapedCssVarName(key, doubleEscape) {
|
|
469
|
-
|
|
470
|
-
cssVarNameEscapeSymbolsRE,
|
|
471
|
-
(s) => doubleEscape ? s === '"' ? '\\\\\\"' : `\\\\${s}` : `\\${s}`
|
|
472
|
-
);
|
|
547
|
+
return key.replace(cssVarNameEscapeSymbolsRE, (s) => doubleEscape ? s === "\"" ? "\\\\\\\"" : `\\\\${s}` : `\\${s}`);
|
|
473
548
|
}
|
|
474
549
|
|
|
550
|
+
//#endregion
|
|
551
|
+
//#region packages/shared/src/looseEqual.ts
|
|
475
552
|
function looseCompareArrays(a, b) {
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
}
|
|
481
|
-
return equal;
|
|
553
|
+
if (a.length !== b.length) return false;
|
|
554
|
+
let equal = true;
|
|
555
|
+
for (let i = 0; equal && i < a.length; i++) equal = looseEqual(a[i], b[i]);
|
|
556
|
+
return equal;
|
|
482
557
|
}
|
|
483
558
|
function looseEqual(a, b) {
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
const aKeysCount = Object.keys(a).length;
|
|
507
|
-
const bKeysCount = Object.keys(b).length;
|
|
508
|
-
if (aKeysCount !== bKeysCount) {
|
|
509
|
-
return false;
|
|
510
|
-
}
|
|
511
|
-
for (const key in a) {
|
|
512
|
-
const aHasKey = a.hasOwnProperty(key);
|
|
513
|
-
const bHasKey = b.hasOwnProperty(key);
|
|
514
|
-
if (aHasKey && !bHasKey || !aHasKey && bHasKey || !looseEqual(a[key], b[key])) {
|
|
515
|
-
return false;
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
return String(a) === String(b);
|
|
559
|
+
if (a === b) return true;
|
|
560
|
+
let aValidType = isDate(a);
|
|
561
|
+
let bValidType = isDate(b);
|
|
562
|
+
if (aValidType || bValidType) return aValidType && bValidType ? a.getTime() === b.getTime() : false;
|
|
563
|
+
aValidType = isSymbol(a);
|
|
564
|
+
bValidType = isSymbol(b);
|
|
565
|
+
if (aValidType || bValidType) return a === b;
|
|
566
|
+
aValidType = isArray(a);
|
|
567
|
+
bValidType = isArray(b);
|
|
568
|
+
if (aValidType || bValidType) return aValidType && bValidType ? looseCompareArrays(a, b) : false;
|
|
569
|
+
aValidType = isObject(a);
|
|
570
|
+
bValidType = isObject(b);
|
|
571
|
+
if (aValidType || bValidType) {
|
|
572
|
+
if (!aValidType || !bValidType) return false;
|
|
573
|
+
if (Object.keys(a).length !== Object.keys(b).length) return false;
|
|
574
|
+
for (const key in a) {
|
|
575
|
+
const aHasKey = a.hasOwnProperty(key);
|
|
576
|
+
const bHasKey = b.hasOwnProperty(key);
|
|
577
|
+
if (aHasKey && !bHasKey || !aHasKey && bHasKey || !looseEqual(a[key], b[key])) return false;
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
return String(a) === String(b);
|
|
520
581
|
}
|
|
521
582
|
function looseIndexOf(arr, val) {
|
|
522
|
-
|
|
583
|
+
return arr.findIndex((item) => looseEqual(item, val));
|
|
523
584
|
}
|
|
524
585
|
|
|
586
|
+
//#endregion
|
|
587
|
+
//#region packages/shared/src/toDisplayString.ts
|
|
525
588
|
const isRef = (val) => {
|
|
526
|
-
|
|
589
|
+
return !!(val && val["__v_isRef"] === true);
|
|
527
590
|
};
|
|
591
|
+
/**
|
|
592
|
+
* For converting {{ interpolation }} values to displayed strings.
|
|
593
|
+
* @private
|
|
594
|
+
*/
|
|
528
595
|
const toDisplayString = (val) => {
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
return JSON.stringify(val, replacer, 2);
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
default:
|
|
541
|
-
return val == null ? "" : String(val);
|
|
542
|
-
}
|
|
596
|
+
switch (typeof val) {
|
|
597
|
+
case "string": return val;
|
|
598
|
+
case "object": if (val) {
|
|
599
|
+
if (isRef(val)) return toDisplayString(val.value);
|
|
600
|
+
else if (isArray(val) || val.toString === objectToString || !isFunction(val.toString)) return JSON.stringify(val, replacer, 2);
|
|
601
|
+
}
|
|
602
|
+
default: return val == null ? "" : String(val);
|
|
603
|
+
}
|
|
543
604
|
};
|
|
544
605
|
const replacer = (_key, val) => {
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
{}
|
|
555
|
-
)
|
|
556
|
-
};
|
|
557
|
-
} else if (isSet(val)) {
|
|
558
|
-
return {
|
|
559
|
-
[`Set(${val.size})`]: [...val.values()].map((v) => stringifySymbol(v))
|
|
560
|
-
};
|
|
561
|
-
} else if (isSymbol(val)) {
|
|
562
|
-
return stringifySymbol(val);
|
|
563
|
-
} else if (isObject(val) && !isArray(val) && !isPlainObject(val)) {
|
|
564
|
-
return String(val);
|
|
565
|
-
}
|
|
566
|
-
return val;
|
|
606
|
+
if (isRef(val)) return replacer(_key, val.value);
|
|
607
|
+
else if (isMap(val)) return { [`Map(${val.size})`]: [...val.entries()].reduce((entries, [key, val], i) => {
|
|
608
|
+
entries[stringifySymbol(key, i) + " =>"] = val;
|
|
609
|
+
return entries;
|
|
610
|
+
}, {}) };
|
|
611
|
+
else if (isSet(val)) return { [`Set(${val.size})`]: [...val.values()].map((v) => stringifySymbol(v)) };
|
|
612
|
+
else if (isSymbol(val)) return stringifySymbol(val);
|
|
613
|
+
else if (isObject(val) && !isArray(val) && !isPlainObject(val)) return String(val);
|
|
614
|
+
return val;
|
|
567
615
|
};
|
|
568
616
|
const stringifySymbol = (v, i = "") => {
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
// Symbol.description in es2019+ so we need to cast here to pass
|
|
572
|
-
// the lib: es2016 check
|
|
573
|
-
isSymbol(v) ? `Symbol(${(_a = v.description) != null ? _a : i})` : v
|
|
574
|
-
);
|
|
617
|
+
var _description;
|
|
618
|
+
return isSymbol(v) ? `Symbol(${(_description = v.description) !== null && _description !== void 0 ? _description : i})` : v;
|
|
575
619
|
};
|
|
576
620
|
|
|
621
|
+
//#endregion
|
|
622
|
+
//#region packages/shared/src/subSequence.ts
|
|
577
623
|
function getSequence(arr) {
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
while (u-- > 0) {
|
|
612
|
-
result[u] = v;
|
|
613
|
-
v = p[v];
|
|
614
|
-
}
|
|
615
|
-
return result;
|
|
624
|
+
const p = arr.slice();
|
|
625
|
+
const result = [0];
|
|
626
|
+
let i, j, u, v, c;
|
|
627
|
+
const len = arr.length;
|
|
628
|
+
for (i = 0; i < len; i++) {
|
|
629
|
+
const arrI = arr[i];
|
|
630
|
+
if (arrI !== 0) {
|
|
631
|
+
j = result[result.length - 1];
|
|
632
|
+
if (arr[j] < arrI) {
|
|
633
|
+
p[i] = j;
|
|
634
|
+
result.push(i);
|
|
635
|
+
continue;
|
|
636
|
+
}
|
|
637
|
+
u = 0;
|
|
638
|
+
v = result.length - 1;
|
|
639
|
+
while (u < v) {
|
|
640
|
+
c = u + v >> 1;
|
|
641
|
+
if (arr[result[c]] < arrI) u = c + 1;
|
|
642
|
+
else v = c;
|
|
643
|
+
}
|
|
644
|
+
if (arrI < arr[result[u]]) {
|
|
645
|
+
if (u > 0) p[i] = result[u - 1];
|
|
646
|
+
result[u] = i;
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
u = result.length;
|
|
651
|
+
v = result[u - 1];
|
|
652
|
+
while (u-- > 0) {
|
|
653
|
+
result[u] = v;
|
|
654
|
+
v = p[v];
|
|
655
|
+
}
|
|
656
|
+
return result;
|
|
616
657
|
}
|
|
617
658
|
|
|
659
|
+
//#endregion
|
|
660
|
+
//#region packages/shared/src/cssVars.ts
|
|
661
|
+
/**
|
|
662
|
+
* Normalize CSS var value created by `v-bind` in `<style>` block
|
|
663
|
+
* See https://github.com/vuejs/core/pull/12461#issuecomment-2495804664
|
|
664
|
+
*/
|
|
618
665
|
function normalizeCssVarValue(value) {
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
return value === "" ? " " : value;
|
|
624
|
-
}
|
|
625
|
-
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
626
|
-
{
|
|
627
|
-
console.warn(
|
|
628
|
-
"[Vue warn] Invalid value used for CSS binding. Expected a string or a finite number but received:",
|
|
629
|
-
value
|
|
630
|
-
);
|
|
631
|
-
}
|
|
632
|
-
}
|
|
633
|
-
return String(value);
|
|
666
|
+
if (value == null) return "initial";
|
|
667
|
+
if (typeof value === "string") return value === "" ? " " : value;
|
|
668
|
+
if (typeof value !== "number" || !Number.isFinite(value)) console.warn("[Vue warn] Invalid value used for CSS binding. Expected a string or a finite number but received:", value);
|
|
669
|
+
return String(value);
|
|
634
670
|
}
|
|
635
671
|
|
|
672
|
+
//#endregion
|
|
636
673
|
exports.EMPTY_ARR = EMPTY_ARR;
|
|
637
674
|
exports.EMPTY_OBJ = EMPTY_OBJ;
|
|
638
675
|
exports.NO = NO;
|
|
@@ -663,7 +700,9 @@ exports.hasOwn = hasOwn;
|
|
|
663
700
|
exports.hyphenate = hyphenate;
|
|
664
701
|
exports.includeBooleanAttr = includeBooleanAttr;
|
|
665
702
|
exports.invokeArrayFns = invokeArrayFns;
|
|
703
|
+
exports.isAlwaysCloseTag = isAlwaysCloseTag;
|
|
666
704
|
exports.isArray = isArray;
|
|
705
|
+
exports.isBlockTag = isBlockTag;
|
|
667
706
|
exports.isBooleanAttr = isBooleanAttr;
|
|
668
707
|
exports.isBuiltInDirective = isBuiltInDirective;
|
|
669
708
|
exports.isBuiltInTag = isBuiltInTag;
|
|
@@ -673,6 +712,7 @@ exports.isFunction = isFunction;
|
|
|
673
712
|
exports.isGloballyAllowed = isGloballyAllowed;
|
|
674
713
|
exports.isGloballyWhitelisted = isGloballyWhitelisted;
|
|
675
714
|
exports.isHTMLTag = isHTMLTag;
|
|
715
|
+
exports.isInlineTag = isInlineTag;
|
|
676
716
|
exports.isIntegerKey = isIntegerKey;
|
|
677
717
|
exports.isKnownHtmlAttr = isKnownHtmlAttr;
|
|
678
718
|
exports.isKnownMathMLAttr = isKnownMathMLAttr;
|
|
@@ -714,4 +754,4 @@ exports.toDisplayString = toDisplayString;
|
|
|
714
754
|
exports.toHandlerKey = toHandlerKey;
|
|
715
755
|
exports.toNumber = toNumber;
|
|
716
756
|
exports.toRawType = toRawType;
|
|
717
|
-
exports.toTypeString = toTypeString;
|
|
757
|
+
exports.toTypeString = toTypeString;
|