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