@vue/shared 3.6.0-beta.4 → 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.
@@ -1,36 +1,45 @@
1
1
  /**
2
- * @vue/shared v3.6.0-beta.4
3
- * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
- * @license MIT
5
- **/
6
- 'use strict';
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
- Object.defineProperty(exports, '__esModule', { value: true });
9
-
10
- // @__NO_SIDE_EFFECTS__
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
- const map = /* @__PURE__ */ Object.create(null);
13
- for (const key of str.split(",")) map[key] = 1;
14
- return (val) => val in map;
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
- const EMPTY_OBJ = Object.freeze({}) ;
18
- const EMPTY_ARR = Object.freeze([]) ;
19
- const NOOP = () => {
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 && // uppercase letter
24
- (key.charCodeAt(2) > 122 || key.charCodeAt(2) < 97);
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
- const i = arr.indexOf(el);
31
- if (i > -1) {
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,299 +53,322 @@ 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
- return (isObject(val) || isFunction(val)) && isFunction(val.then) && isFunction(val.catch);
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
- return toTypeString(value).slice(8, -1);
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
- const cache = /* @__PURE__ */ Object.create(null);
66
- return ((str) => {
67
- const hit = cache[str];
68
- return hit || (cache[str] = fn(str));
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
- const camelize = cacheStringFunction(
74
- (str) => str.replace(camelizeRE, camelizeReplacer)
75
- );
76
+ /**
77
+ * @private
78
+ */
79
+ const camelize = cacheStringFunction((str) => str.replace(camelizeRE, camelizeReplacer));
76
80
  const hyphenateRE = /\B([A-Z])/g;
77
- const hyphenate = cacheStringFunction(
78
- (str) => str.replace(hyphenateRE, "-$1").toLowerCase()
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
- return str.charAt(0).toUpperCase() + str.slice(1);
89
+ return str.charAt(0).toUpperCase() + str.slice(1);
82
90
  });
83
- const toHandlerKey = cacheStringFunction(
84
- (str) => {
85
- const s = str ? `on${capitalize(str)}` : ``;
86
- return s;
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
- return `${name === "modelValue" || name === "model-value" ? "model" : name}Modifiers${name === "model" ? "$" : ""}`;
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
- for (let i = 0; i < fns.length; i++) {
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
- Object.defineProperty(obj, key, {
100
- configurable: true,
101
- enumerable: false,
102
- writable,
103
- value
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
- const n = parseFloat(val);
108
- return isNaN(n) ? val : n;
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
- const n = isString(val) ? Number(val) : NaN;
112
- return isNaN(n) ? val : n;
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
- return _globalThis || (_globalThis = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : {});
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
- return identRE.test(name) ? `__props.${name}` : `__props[${JSON.stringify(name)}]`;
140
+ return identRE.test(name) ? `__props.${name}` : `__props[${JSON.stringify(name)}]`;
121
141
  }
122
142
  function genCacheKey(source, options) {
123
- return source + JSON.stringify(
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
- return tagName !== "PROGRESS" && // custom elements may use _value internally
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
- "TEXT": 1,
135
- "1": "TEXT",
136
- "CLASS": 2,
137
- "2": "CLASS",
138
- "STYLE": 4,
139
- "4": "STYLE",
140
- "PROPS": 8,
141
- "8": "PROPS",
142
- "FULL_PROPS": 16,
143
- "16": "FULL_PROPS",
144
- "NEED_HYDRATION": 32,
145
- "32": "NEED_HYDRATION",
146
- "STABLE_FRAGMENT": 64,
147
- "64": "STABLE_FRAGMENT",
148
- "KEYED_FRAGMENT": 128,
149
- "128": "KEYED_FRAGMENT",
150
- "UNKEYED_FRAGMENT": 256,
151
- "256": "UNKEYED_FRAGMENT",
152
- "NEED_PATCH": 512,
153
- "512": "NEED_PATCH",
154
- "DYNAMIC_SLOTS": 1024,
155
- "1024": "DYNAMIC_SLOTS",
156
- "DEV_ROOT_FRAGMENT": 2048,
157
- "2048": "DEV_ROOT_FRAGMENT",
158
- "CACHED": -1,
159
- "-1": "CACHED",
160
- "BAIL": -2,
161
- "-2": "BAIL"
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
- [1]: `TEXT`,
165
- [2]: `CLASS`,
166
- [4]: `STYLE`,
167
- [8]: `PROPS`,
168
- [16]: `FULL_PROPS`,
169
- [32]: `NEED_HYDRATION`,
170
- [64]: `STABLE_FRAGMENT`,
171
- [128]: `KEYED_FRAGMENT`,
172
- [256]: `UNKEYED_FRAGMENT`,
173
- [512]: `NEED_PATCH`,
174
- [1024]: `DYNAMIC_SLOTS`,
175
- [2048]: `DEV_ROOT_FRAGMENT`,
176
- [-1]: `CACHED`,
177
- [-2]: `BAIL`
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
- "ELEMENT": 1,
182
- "1": "ELEMENT",
183
- "FUNCTIONAL_COMPONENT": 2,
184
- "2": "FUNCTIONAL_COMPONENT",
185
- "STATEFUL_COMPONENT": 4,
186
- "4": "STATEFUL_COMPONENT",
187
- "TEXT_CHILDREN": 8,
188
- "8": "TEXT_CHILDREN",
189
- "ARRAY_CHILDREN": 16,
190
- "16": "ARRAY_CHILDREN",
191
- "SLOTS_CHILDREN": 32,
192
- "32": "SLOTS_CHILDREN",
193
- "TELEPORT": 64,
194
- "64": "TELEPORT",
195
- "SUSPENSE": 128,
196
- "128": "SUSPENSE",
197
- "COMPONENT_SHOULD_KEEP_ALIVE": 256,
198
- "256": "COMPONENT_SHOULD_KEEP_ALIVE",
199
- "COMPONENT_KEPT_ALIVE": 512,
200
- "512": "COMPONENT_KEPT_ALIVE",
201
- "COMPONENT": 6,
202
- "6": "COMPONENT"
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
- "STABLE": 1,
207
- "1": "STABLE",
208
- "DYNAMIC": 2,
209
- "2": "DYNAMIC",
210
- "FORWARDED": 3,
211
- "3": "FORWARDED"
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
- [1]: "STABLE",
215
- [2]: "DYNAMIC",
216
- [3]: "FORWARDED"
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
- start = Math.max(0, Math.min(start, source.length));
226
- end = Math.max(0, Math.min(end, source.length));
227
- if (start > end) return "";
228
- let lines = source.split(/(\r?\n)/);
229
- const newlineSequences = lines.filter((_, idx) => idx % 2 === 1);
230
- lines = lines.filter((_, idx) => idx % 2 === 0);
231
- let count = 0;
232
- const res = [];
233
- for (let i = 0; i < lines.length; i++) {
234
- count += lines[i].length + (newlineSequences[i] && newlineSequences[i].length || 0);
235
- if (count >= start) {
236
- for (let j = i - range; j <= i + range || end > count; j++) {
237
- if (j < 0 || j >= lines.length) continue;
238
- const line = j + 1;
239
- res.push(
240
- `${line}${" ".repeat(Math.max(3 - String(line).length, 0))}| ${lines[j]}`
241
- );
242
- const lineLength = lines[j].length;
243
- const newLineSeqLength = newlineSequences[j] && newlineSequences[j].length || 0;
244
- if (j === i) {
245
- const pad = start - (count - (lineLength + newLineSeqLength));
246
- const length = Math.max(
247
- 1,
248
- end > count ? lineLength - pad : end - start
249
- );
250
- res.push(` | ` + " ".repeat(pad) + "^".repeat(length));
251
- } else if (j > i) {
252
- if (end > count) {
253
- const length = Math.max(Math.min(end - count, lineLength), 1);
254
- res.push(` | ` + "^".repeat(length));
255
- }
256
- count += lineLength + newLineSeqLength;
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
- if (isArray(value)) {
267
- const res = {};
268
- for (let i = 0; i < value.length; i++) {
269
- const item = value[i];
270
- const normalized = isString(item) ? parseStringStyle(item) : normalizeStyle(item);
271
- if (normalized) {
272
- for (const key in normalized) {
273
- res[key] = normalized[key];
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
- const ret = {};
287
- cssText.replace(styleCommentRE, "").split(listDelimiterRE).forEach((item) => {
288
- if (item) {
289
- const tmp = item.split(propertyDelimiterRE);
290
- tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
291
- }
292
- });
293
- return ret;
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
- if (!styles) return "";
297
- if (isString(styles)) return styles;
298
- let ret = "";
299
- for (const key in styles) {
300
- const value = styles[key];
301
- if (isString(value) || typeof value === "number") {
302
- const normalizedKey = key.startsWith(`--`) ? key : hyphenate(key);
303
- ret += `${normalizedKey}:${value};`;
304
- }
305
- }
306
- return ret;
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
- let res = "";
310
- if (isString(value)) {
311
- res = value;
312
- } else if (isArray(value)) {
313
- for (let i = 0; i < value.length; i++) {
314
- const normalized = normalizeClass(value[i]);
315
- if (normalized) {
316
- res += normalized + " ";
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
- if (!props) return null;
330
- let { class: klass, style } = props;
331
- if (klass && !isString(klass)) {
332
- props.class = normalizeClass(klass);
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";
@@ -345,300 +377,299 @@ const FORMATTING_TAGS = "a,b,big,code,em,font,i,nobr,s,small,strike,strong,tt,u"
345
377
  const ALWAYS_CLOSE_TAGS = "title,style,script,noscript,template,object,table,button,textarea,select,iframe,fieldset";
346
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";
347
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
+ */
348
384
  const isHTMLTag = /* @__PURE__ */ makeMap(HTML_TAGS);
385
+ /**
386
+ * Compiler only.
387
+ * Do NOT use in runtime code paths unless behind `__DEV__` flag.
388
+ */
349
389
  const isSVGTag = /* @__PURE__ */ makeMap(SVG_TAGS);
390
+ /**
391
+ * Compiler only.
392
+ * Do NOT use in runtime code paths unless behind `__DEV__` flag.
393
+ */
350
394
  const isMathMLTag = /* @__PURE__ */ makeMap(MATH_TAGS);
395
+ /**
396
+ * Compiler only.
397
+ * Do NOT use in runtime code paths unless behind `__DEV__` flag.
398
+ */
351
399
  const isVoidTag = /* @__PURE__ */ makeMap(VOID_TAGS);
400
+ /**
401
+ * Compiler only.
402
+ * Do NOT use in runtime code paths unless behind `__DEV__` flag.
403
+ */
352
404
  const isFormattingTag = /* @__PURE__ */ makeMap(FORMATTING_TAGS);
405
+ /**
406
+ * Compiler only.
407
+ * Do NOT use in runtime code paths unless behind `__DEV__` flag.
408
+ */
353
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
+ */
354
414
  const isInlineTag = /* @__PURE__ */ makeMap(INLINE_TAGS);
415
+ /**
416
+ * Compiler only.
417
+ * Do NOT use in runtime code paths unless behind `__DEV__` flag.
418
+ */
355
419
  const isBlockTag = /* @__PURE__ */ makeMap(BLOCK_TAGS);
356
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
+ */
357
434
  const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
358
435
  const isSpecialBooleanAttr = /* @__PURE__ */ makeMap(specialBooleanAttrs);
359
- const isBooleanAttr = /* @__PURE__ */ makeMap(
360
- specialBooleanAttrs + `,async,autofocus,autoplay,controls,default,defer,disabled,hidden,inert,loop,open,required,reversed,scoped,seamless,checked,muted,multiple,selected`
361
- );
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
+ */
362
444
  function includeBooleanAttr(value) {
363
- return !!value || value === "";
445
+ return !!value || value === "";
364
446
  }
365
447
  const unsafeAttrCharRE = /[>/="'\u0009\u000a\u000c\u0020]/;
366
448
  const attrValidationCache = {};
367
449
  function isSSRSafeAttrName(name) {
368
- if (attrValidationCache.hasOwnProperty(name)) {
369
- return attrValidationCache[name];
370
- }
371
- const isUnsafe = unsafeAttrCharRE.test(name);
372
- if (isUnsafe) {
373
- console.error(`unsafe attribute name: ${name}`);
374
- }
375
- 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;
376
454
  }
377
455
  const propsToAttrMap = {
378
- acceptCharset: "accept-charset",
379
- className: "class",
380
- htmlFor: "for",
381
- httpEquiv: "http-equiv"
456
+ acceptCharset: "accept-charset",
457
+ className: "class",
458
+ htmlFor: "for",
459
+ httpEquiv: "http-equiv"
382
460
  };
383
- const isKnownHtmlAttr = /* @__PURE__ */ makeMap(
384
- `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`
385
- );
386
- const isKnownSvgAttr = /* @__PURE__ */ makeMap(
387
- `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`
388
- );
389
- const isKnownMathMLAttr = /* @__PURE__ */ makeMap(
390
- `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`
391
- );
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
+ */
392
479
  function isRenderableAttrValue(value) {
393
- if (value == null) {
394
- return false;
395
- }
396
- const type = typeof value;
397
- 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";
398
483
  }
399
484
  function shouldSetAsAttr(tagName, key) {
400
- if (key === "spellcheck" || key === "draggable" || key === "translate" || key === "autocorrect") {
401
- return true;
402
- }
403
- if (key === "form") {
404
- return true;
405
- }
406
- if (key === "list" && tagName === "INPUT") {
407
- return true;
408
- }
409
- if (key === "type" && tagName === "TEXTAREA") {
410
- return true;
411
- }
412
- if ((key === "width" || key === "height") && (tagName === "IMG" || tagName === "VIDEO" || tagName === "CANVAS" || tagName === "SOURCE")) {
413
- return true;
414
- }
415
- if (key === "sandbox" && tagName === "IFRAME") {
416
- return true;
417
- }
418
- 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;
419
492
  }
420
493
 
494
+ //#endregion
495
+ //#region packages/shared/src/domNamespace.ts
421
496
  const Namespaces = {
422
- "HTML": 0,
423
- "0": "HTML",
424
- "SVG": 1,
425
- "1": "SVG",
426
- "MATH_ML": 2,
427
- "2": "MATH_ML"
497
+ "HTML": 0,
498
+ "0": "HTML",
499
+ "SVG": 1,
500
+ "1": "SVG",
501
+ "MATH_ML": 2,
502
+ "2": "MATH_ML"
428
503
  };
429
504
 
505
+ //#endregion
506
+ //#region packages/shared/src/escapeHtml.ts
430
507
  const escapeRE = /["'&<>]/;
431
508
  function escapeHtml(string) {
432
- const str = "" + string;
433
- const match = escapeRE.exec(str);
434
- if (!match) {
435
- return str;
436
- }
437
- let html = "";
438
- let escaped;
439
- let index;
440
- let lastIndex = 0;
441
- for (index = match.index; index < str.length; index++) {
442
- switch (str.charCodeAt(index)) {
443
- case 34:
444
- escaped = "&quot;";
445
- break;
446
- case 38:
447
- escaped = "&amp;";
448
- break;
449
- case 39:
450
- escaped = "&#39;";
451
- break;
452
- case 60:
453
- escaped = "&lt;";
454
- break;
455
- case 62:
456
- escaped = "&gt;";
457
- break;
458
- default:
459
- continue;
460
- }
461
- if (lastIndex !== index) {
462
- html += str.slice(lastIndex, index);
463
- }
464
- lastIndex = index + 1;
465
- html += escaped;
466
- }
467
- 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 = "&quot;";
520
+ break;
521
+ case 38:
522
+ escaped = "&amp;";
523
+ break;
524
+ case 39:
525
+ escaped = "&#39;";
526
+ break;
527
+ case 60:
528
+ escaped = "&lt;";
529
+ break;
530
+ case 62:
531
+ escaped = "&gt;";
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;
468
540
  }
469
541
  const commentStripRE = /^-?>|<!--|-->|--!>|<!-$/g;
470
542
  function escapeHtmlComment(src) {
471
- return src.replace(commentStripRE, "");
543
+ return src.replace(commentStripRE, "");
472
544
  }
473
545
  const cssVarNameEscapeSymbolsRE = /[ !"#$%&'()*+,./:;<=>?@[\\\]^`{|}~]/g;
474
546
  function getEscapedCssVarName(key, doubleEscape) {
475
- return key.replace(
476
- cssVarNameEscapeSymbolsRE,
477
- (s) => doubleEscape ? s === '"' ? '\\\\\\"' : `\\\\${s}` : `\\${s}`
478
- );
547
+ return key.replace(cssVarNameEscapeSymbolsRE, (s) => doubleEscape ? s === "\"" ? "\\\\\\\"" : `\\\\${s}` : `\\${s}`);
479
548
  }
480
549
 
550
+ //#endregion
551
+ //#region packages/shared/src/looseEqual.ts
481
552
  function looseCompareArrays(a, b) {
482
- if (a.length !== b.length) return false;
483
- let equal = true;
484
- for (let i = 0; equal && i < a.length; i++) {
485
- equal = looseEqual(a[i], b[i]);
486
- }
487
- 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;
488
557
  }
489
558
  function looseEqual(a, b) {
490
- if (a === b) return true;
491
- let aValidType = isDate(a);
492
- let bValidType = isDate(b);
493
- if (aValidType || bValidType) {
494
- return aValidType && bValidType ? a.getTime() === b.getTime() : false;
495
- }
496
- aValidType = isSymbol(a);
497
- bValidType = isSymbol(b);
498
- if (aValidType || bValidType) {
499
- return a === b;
500
- }
501
- aValidType = isArray(a);
502
- bValidType = isArray(b);
503
- if (aValidType || bValidType) {
504
- return aValidType && bValidType ? looseCompareArrays(a, b) : false;
505
- }
506
- aValidType = isObject(a);
507
- bValidType = isObject(b);
508
- if (aValidType || bValidType) {
509
- if (!aValidType || !bValidType) {
510
- return false;
511
- }
512
- const aKeysCount = Object.keys(a).length;
513
- const bKeysCount = Object.keys(b).length;
514
- if (aKeysCount !== bKeysCount) {
515
- return false;
516
- }
517
- for (const key in a) {
518
- const aHasKey = a.hasOwnProperty(key);
519
- const bHasKey = b.hasOwnProperty(key);
520
- if (aHasKey && !bHasKey || !aHasKey && bHasKey || !looseEqual(a[key], b[key])) {
521
- return false;
522
- }
523
- }
524
- }
525
- 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);
526
581
  }
527
582
  function looseIndexOf(arr, val) {
528
- return arr.findIndex((item) => looseEqual(item, val));
583
+ return arr.findIndex((item) => looseEqual(item, val));
529
584
  }
530
585
 
586
+ //#endregion
587
+ //#region packages/shared/src/toDisplayString.ts
531
588
  const isRef = (val) => {
532
- return !!(val && val["__v_isRef"] === true);
589
+ return !!(val && val["__v_isRef"] === true);
533
590
  };
591
+ /**
592
+ * For converting {{ interpolation }} values to displayed strings.
593
+ * @private
594
+ */
534
595
  const toDisplayString = (val) => {
535
- switch (typeof val) {
536
- case "string":
537
- return val;
538
- case "object":
539
- if (val) {
540
- if (isRef(val)) {
541
- return toDisplayString(val.value);
542
- } else if (isArray(val) || val.toString === objectToString || !isFunction(val.toString)) {
543
- return JSON.stringify(val, replacer, 2);
544
- }
545
- }
546
- default:
547
- return val == null ? "" : String(val);
548
- }
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
+ }
549
604
  };
550
605
  const replacer = (_key, val) => {
551
- if (isRef(val)) {
552
- return replacer(_key, val.value);
553
- } else if (isMap(val)) {
554
- return {
555
- [`Map(${val.size})`]: [...val.entries()].reduce(
556
- (entries, [key, val2], i) => {
557
- entries[stringifySymbol(key, i) + " =>"] = val2;
558
- return entries;
559
- },
560
- {}
561
- )
562
- };
563
- } else if (isSet(val)) {
564
- return {
565
- [`Set(${val.size})`]: [...val.values()].map((v) => stringifySymbol(v))
566
- };
567
- } else if (isSymbol(val)) {
568
- return stringifySymbol(val);
569
- } else if (isObject(val) && !isArray(val) && !isPlainObject(val)) {
570
- return String(val);
571
- }
572
- 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;
573
615
  };
574
616
  const stringifySymbol = (v, i = "") => {
575
- var _a;
576
- return (
577
- // Symbol.description in es2019+ so we need to cast here to pass
578
- // the lib: es2016 check
579
- isSymbol(v) ? `Symbol(${(_a = v.description) != null ? _a : i})` : v
580
- );
617
+ var _description;
618
+ return isSymbol(v) ? `Symbol(${(_description = v.description) !== null && _description !== void 0 ? _description : i})` : v;
581
619
  };
582
620
 
621
+ //#endregion
622
+ //#region packages/shared/src/subSequence.ts
583
623
  function getSequence(arr) {
584
- const p = arr.slice();
585
- const result = [0];
586
- let i, j, u, v, c;
587
- const len = arr.length;
588
- for (i = 0; i < len; i++) {
589
- const arrI = arr[i];
590
- if (arrI !== 0) {
591
- j = result[result.length - 1];
592
- if (arr[j] < arrI) {
593
- p[i] = j;
594
- result.push(i);
595
- continue;
596
- }
597
- u = 0;
598
- v = result.length - 1;
599
- while (u < v) {
600
- c = u + v >> 1;
601
- if (arr[result[c]] < arrI) {
602
- u = c + 1;
603
- } else {
604
- v = c;
605
- }
606
- }
607
- if (arrI < arr[result[u]]) {
608
- if (u > 0) {
609
- p[i] = result[u - 1];
610
- }
611
- result[u] = i;
612
- }
613
- }
614
- }
615
- u = result.length;
616
- v = result[u - 1];
617
- while (u-- > 0) {
618
- result[u] = v;
619
- v = p[v];
620
- }
621
- 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;
622
657
  }
623
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
+ */
624
665
  function normalizeCssVarValue(value) {
625
- if (value == null) {
626
- return "initial";
627
- }
628
- if (typeof value === "string") {
629
- return value === "" ? " " : value;
630
- }
631
- if (typeof value !== "number" || !Number.isFinite(value)) {
632
- {
633
- console.warn(
634
- "[Vue warn] Invalid value used for CSS binding. Expected a string or a finite number but received:",
635
- value
636
- );
637
- }
638
- }
639
- 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);
640
670
  }
641
671
 
672
+ //#endregion
642
673
  exports.EMPTY_ARR = EMPTY_ARR;
643
674
  exports.EMPTY_OBJ = EMPTY_OBJ;
644
675
  exports.NO = NO;
@@ -723,4 +754,4 @@ exports.toDisplayString = toDisplayString;
723
754
  exports.toHandlerKey = toHandlerKey;
724
755
  exports.toNumber = toNumber;
725
756
  exports.toRawType = toRawType;
726
- exports.toTypeString = toTypeString;
757
+ exports.toTypeString = toTypeString;