@stencil/core 5.0.0-alpha.2 → 5.0.0-alpha.3

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.
Files changed (42) hide show
  1. package/dist/{client-DucyoZT4.mjs → client-CSm3x5ke.mjs} +81 -60
  2. package/dist/compiler/index.d.mts +3 -3
  3. package/dist/compiler/index.mjs +2 -2
  4. package/dist/compiler/utils/index.d.mts +2 -2
  5. package/dist/compiler/utils/index.mjs +3 -3
  6. package/dist/{compiler-DyK1_szo.mjs → compiler-D6iP7Bzb.mjs} +1390 -1631
  7. package/dist/declarations/stencil-public-compiler.d.ts +4031 -2
  8. package/dist/declarations/stencil-public-compiler.js +0 -1
  9. package/dist/declarations/stencil-public-docs.d.ts +494 -1
  10. package/dist/declarations/stencil-public-runtime.d.ts +1943 -2
  11. package/dist/{index-fIuYTL9f.d.mts → index-CXHCTQNt.d.mts} +14 -2
  12. package/dist/{index-BONzXKJt.d.ts → index-CyrGY82h.d.ts} +5 -7
  13. package/dist/{index-CHjZtib0.d.ts → index-hS-KBdAP.d.ts} +1 -1
  14. package/dist/{index-D-LlB2nw.d.mts → index-tUR6pD3J.d.mts} +145 -809
  15. package/dist/index.d.mts +1 -0
  16. package/dist/index.mjs +2 -2
  17. package/dist/{jsx-runtime-DBzBJLKk.d.ts → jsx-runtime-DlDkTqps.d.ts} +1 -1
  18. package/dist/jsx-runtime.d.ts +1 -1
  19. package/dist/jsx-runtime.js +1 -1
  20. package/dist/{node-BWBQAh8C.mjs → node-Bg-mO5dw.mjs} +3 -14
  21. package/dist/regular-expression-D5pGVpCu.mjs +415 -0
  22. package/dist/runtime/app-data/index.d.ts +1 -1
  23. package/dist/runtime/app-data/index.js +1 -2
  24. package/dist/runtime/client/index.d.ts +14 -4
  25. package/dist/runtime/client/index.js +103 -205
  26. package/dist/runtime/index.d.ts +16 -4
  27. package/dist/runtime/index.js +2 -2
  28. package/dist/runtime/server/index.d.mts +1 -3
  29. package/dist/runtime/server/index.mjs +103 -205
  30. package/dist/runtime/server/runner.d.mts +1 -17
  31. package/dist/runtime/server/runner.mjs +12 -394
  32. package/dist/{runtime-CqlPYKjW.js → runtime-BBCnuprF.js} +103 -205
  33. package/dist/sys/node/index.d.mts +1 -1
  34. package/dist/sys/node/index.mjs +1 -1
  35. package/dist/sys/node/worker.mjs +2 -2
  36. package/dist/testing/index.d.mts +3 -3
  37. package/dist/testing/index.mjs +18 -17
  38. package/dist/{validation-BR7tMYEv.mjs → validation-Byxie0Uk.mjs} +28 -24
  39. package/package.json +9 -13
  40. package/dist/serialize-o-Sj1lvg.mjs +0 -792
  41. package/dist/stencil-public-compiler-C_X1iolo.d.ts +0 -4455
  42. package/dist/stencil-public-runtime-DlV8o7-z.d.ts +0 -1845
@@ -1,792 +0,0 @@
1
- const MEMBER_FLAGS = {
2
- String: 1,
3
- Number: 2,
4
- Boolean: 4,
5
- Any: 8,
6
- Unknown: 16,
7
- State: 32,
8
- Method: 64,
9
- Event: 128,
10
- Element: 256,
11
- ReflectAttr: 512,
12
- Mutable: 1024,
13
- Getter: 2048,
14
- Setter: 4096,
15
- Prop: 31,
16
- HasAttribute: 31,
17
- PropLike: 63
18
- };
19
- const WATCH_FLAGS = { Immediate: 1 };
20
- const EVENT_FLAGS = {
21
- Cancellable: 1,
22
- Composed: 2,
23
- Bubbles: 4
24
- };
25
- const LISTENER_FLAGS = {
26
- Passive: 1,
27
- Capture: 2,
28
- TargetDocument: 4,
29
- TargetWindow: 8,
30
- TargetBody: 16,
31
- TargetParent: 32
32
- };
33
- const HOST_FLAGS = {
34
- hasConnected: 1,
35
- hasRendered: 2,
36
- isWaitingForChildren: 4,
37
- isConstructingInstance: 8,
38
- isQueuedForUpdate: 16,
39
- hasInitializedComponent: 32,
40
- hasLoadedComponent: 64,
41
- isWatchReady: 128,
42
- isListenReady: 256,
43
- needsRerender: 512,
44
- devOnRender: 1024,
45
- devOnDidLoad: 2048
46
- };
47
- const CF_scopedCssEncapsulation = 2;
48
- const CF_needsShadowDomShim = 8;
49
- /**
50
- * A set of flags used for bitwise calculations against {@link ComponentRuntimeMeta#$flags$}.
51
- *
52
- * These flags should only be used in conjunction with {@link ComponentRuntimeMeta#$flags$}.
53
- * They should _not_ be used for calculations against other fields/numbers
54
- */
55
- const CMP_FLAGS = {
56
- shadowDomEncapsulation: 1,
57
- scopedCssEncapsulation: CF_scopedCssEncapsulation,
58
- hasSlotRelocation: 4,
59
- needsShadowDomShim: CF_needsShadowDomShim,
60
- shadowDelegatesFocus: 16,
61
- hasMode: 32,
62
- needsScopedEncapsulation: CF_scopedCssEncapsulation | CF_needsShadowDomShim,
63
- formAssociated: 64,
64
- shadowNeedsScopedCss: 128,
65
- hasSlot: 256,
66
- hasModernPropertyDecls: 512,
67
- shadowSlotAssignmentManual: 1024
68
- };
69
- /**
70
- * Default style mode id
71
- */
72
- const DEFAULT_STYLE_MODE = "$";
73
- /**
74
- * Namespaces
75
- */
76
- const SVG_NS = "http://www.w3.org/2000/svg";
77
- const HTML_NS = "http://www.w3.org/1999/xhtml";
78
- const XLINK_NS = "http://www.w3.org/1999/xlink";
79
- /**
80
- * File names and value
81
- */
82
- const COLLECTION_MANIFEST_FILE_NAME = "collection-manifest.json";
83
- /**
84
- * Constant for the 'copy' output target
85
- */
86
- const COPY = "copy";
87
- /**
88
- * Constant for the 'custom' output target
89
- */
90
- const CUSTOM = "custom";
91
- /**
92
- * Constant for the 'dist' output target
93
- */
94
- const DIST = "dist";
95
- /**
96
- * Constant for the 'dist-collection' output target
97
- */
98
- const DIST_COLLECTION = "dist-collection";
99
- /**
100
- * Constant for the 'dist-custom-elements' output target
101
- */
102
- const DIST_CUSTOM_ELEMENTS = "dist-custom-elements";
103
- /**
104
- * Constant for the 'dist-types' output target
105
- */
106
- const DIST_TYPES = "dist-types";
107
- /**
108
- * Constant for the 'dist-hydrate-script' output target
109
- */
110
- const DIST_HYDRATE_SCRIPT = "dist-hydrate-script";
111
- /**
112
- * Constant for the 'dist-lazy' output target
113
- */
114
- const DIST_LAZY = "dist-lazy";
115
- /**
116
- * Constant for the 'dist-lazy-loader' output target
117
- */
118
- const DIST_LAZY_LOADER = "dist-lazy-loader";
119
- /**
120
- * Constant for the 'dist-global-styles' output target
121
- */
122
- const DIST_GLOBAL_STYLES = "dist-global-styles";
123
- /**
124
- * Constant for the 'docs-custom' output target
125
- */
126
- const DOCS_CUSTOM = "docs-custom";
127
- /**
128
- * Constant for the 'docs-json' output target
129
- */
130
- const DOCS_JSON = "docs-json";
131
- /**
132
- * Constant for the 'docs-readme' output target
133
- */
134
- const DOCS_README = "docs-readme";
135
- /**
136
- * Constant for the 'docs-vscode' output target
137
- */
138
- const DOCS_VSCODE = "docs-vscode";
139
- /**
140
- * Constant for the 'docs-custom-elements-manifest' output target
141
- */
142
- const DOCS_CUSTOM_ELEMENTS_MANIFEST = "docs-custom-elements-manifest";
143
- /**
144
- * Constant for the 'stats' output target
145
- */
146
- const STATS = "stats";
147
- /**
148
- * Constant for the 'www' output target
149
- */
150
- const WWW = "www";
151
- /**
152
- * Valid output targets to specify in a Stencil config.
153
- *
154
- * Note that there are some output targets (e.g. `DIST_TYPES`) which are
155
- * programmatically set as output targets by the compiler when other output
156
- * targets (in that case `DIST`) are set, but which are _not_ supported in a
157
- * Stencil config. This is enforced in the output target validation code.
158
- */
159
- const VALID_CONFIG_OUTPUT_TARGETS = [
160
- "www",
161
- DIST,
162
- DIST_COLLECTION,
163
- DIST_CUSTOM_ELEMENTS,
164
- DIST_LAZY,
165
- DIST_HYDRATE_SCRIPT,
166
- DOCS_JSON,
167
- DOCS_README,
168
- DOCS_VSCODE,
169
- DOCS_CUSTOM,
170
- DOCS_CUSTOM_ELEMENTS_MANIFEST,
171
- COPY,
172
- CUSTOM,
173
- STATS
174
- ];
175
- const GENERATED_DTS = "components.d.ts";
176
- /**
177
- * DOM Node types
178
- *
179
- * See https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType
180
- *
181
- * Note: this is a duplicate of the `NODE_TYPES` enum in mock-doc, it's
182
- * copied over here so that we do not need to introduce a dependency on the
183
- * mock-doc bundle in the runtime. See
184
- * https://github.com/stenciljs/core/pull/5705 for more details.
185
- */
186
- const NODE_TYPES = {
187
- ELEMENT_NODE: 1,
188
- ATTRIBUTE_NODE: 2,
189
- TEXT_NODE: 3,
190
- CDATA_SECTION_NODE: 4,
191
- ENTITY_REFERENCE_NODE: 5,
192
- ENTITY_NODE: 6,
193
- PROCESSING_INSTRUCTION_NODE: 7,
194
- COMMENT_NODE: 8,
195
- DOCUMENT_NODE: 9,
196
- DOCUMENT_TYPE_NODE: 10,
197
- DOCUMENT_FRAGMENT_NODE: 11,
198
- NOTATION_NODE: 12
199
- };
200
- /**
201
- * Represents a primitive type.
202
- * Described in https://w3c.github.io/webdriver-bidi/#type-script-PrimitiveProtocolValue.
203
- */
204
- const PrimitiveType = {
205
- Undefined: "undefined",
206
- Null: "null",
207
- String: "string",
208
- Number: "number",
209
- SpecialNumber: "number",
210
- Boolean: "boolean",
211
- BigInt: "bigint"
212
- };
213
- /**
214
- * Represents a non-primitive type.
215
- * Described in https://w3c.github.io/webdriver-bidi/#type-script-RemoteValue.
216
- * @deprecated will be removed in v5. Use `@AttrDeserialize()` / `@PropDeserialize()` decorators instead.
217
- */
218
- const NonPrimitiveType = {
219
- Array: "array",
220
- Date: "date",
221
- Map: "map",
222
- Object: "object",
223
- RegularExpression: "regexp",
224
- Set: "set",
225
- Channel: "channel",
226
- Symbol: "symbol"
227
- };
228
- /** @deprecated will be removed in v5. Use `@AttrDeserialize()` / `@PropDeserialize()` decorators instead. */
229
- const TYPE_CONSTANT = "type";
230
- /** @deprecated will be removed in v5. Use `@AttrDeserialize()` / `@PropDeserialize()` decorators instead. */
231
- const VALUE_CONSTANT = "value";
232
- /** @deprecated will be removed in v5. Use `@AttrDeserialize()` / `@PropDeserialize()` decorators instead. */
233
- const SERIALIZED_PREFIX = "serialized:";
234
- //#endregion
235
- //#region src/utils/query-nonce-meta-tag-content.ts
236
- /**
237
- * Helper method for querying a `meta` tag that contains a nonce value
238
- * out of a DOM's head.
239
- *
240
- * @param doc The DOM containing the `head` to query against
241
- * @returns The content of the meta tag representing the nonce value, or `undefined` if no tag
242
- * exists or the tag has no content.
243
- */
244
- function queryNonceMetaTagContent(doc) {
245
- return doc.head?.querySelector("meta[name=\"csp-nonce\"]")?.getAttribute("content") ?? void 0;
246
- }
247
- //#endregion
248
- //#region src/utils/helpers.ts
249
- /**
250
- * Check if a value is defined (not null and not undefined).
251
- *
252
- * @param v - the value to check
253
- * @returns true if the value is defined
254
- */
255
- const isDef = (v) => v != null && v !== void 0;
256
- /**
257
- * Convert a string from PascalCase to dash-case
258
- *
259
- * @param str the string to convert
260
- * @returns a converted string
261
- */
262
- const toDashCase = (str) => str.replace(/([A-Z0-9])/g, (match) => ` ${match[0]}`).trim().split(" ").join("-").toLowerCase();
263
- /**
264
- * Convert a string from dash-case / kebab-case to PascalCase (or CamelCase,
265
- * or whatever you call it!)
266
- *
267
- * @param str a string to convert
268
- * @returns a converted string
269
- */
270
- const dashToPascalCase = (str) => str.toLowerCase().split("-").map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1)).join("");
271
- /**
272
- * Convert a string to 'camelCase'
273
- *
274
- * @param str the string to convert
275
- * @returns the converted string
276
- */
277
- const toCamelCase = (str) => {
278
- const pascalCase = dashToPascalCase(str);
279
- return pascalCase.charAt(0).toLowerCase() + pascalCase.slice(1);
280
- };
281
- /**
282
- * Capitalize the first letter of a string
283
- *
284
- * @param str the string to capitalize
285
- * @returns a capitalized string
286
- */
287
- const toTitleCase = (str) => str.charAt(0).toUpperCase() + str.slice(1);
288
- /**
289
- * Escapes all occurrences of a specified pattern in a string.
290
- * This function replaces all matches of a given pattern in the input text with a specified replacement string.
291
- * It can handle both string and regular expression patterns and allows toggling between global and single-match replacements.
292
- *
293
- * @param text - The input string to process.
294
- * @param pattern - The pattern to search for in the input string. Can be a regular expression or a string.
295
- * @param replacement - The string to replace each match with.
296
- * @param replaceAll - Whether to replace all occurrences (true) or just the first occurrence (false). Defaults to true.
297
- * @returns The processed string with the replacements applied.
298
- */
299
- const escapeWithPattern = (text, pattern, replacement, replaceAll = true) => {
300
- let regex;
301
- if (typeof pattern === "string") {
302
- const escaped = pattern.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
303
- regex = new RegExp(escaped, replaceAll ? "g" : "");
304
- } else {
305
- const flags = pattern.flags;
306
- const hasG = flags.includes("g");
307
- const newFlags = replaceAll ? hasG ? flags : flags + "g" : hasG ? flags.replace(/g/g, "") : flags;
308
- regex = new RegExp(pattern.source, newFlags);
309
- }
310
- return text.replace(regex, replacement);
311
- };
312
- /**
313
- * This is just a no-op, don't expect it to do anything.
314
- */
315
- const noop = () => {};
316
- /**
317
- * Check whether a value is a 'complex type', defined here as an object or a
318
- * function.
319
- *
320
- * @param o the value to check
321
- * @returns whether it's a complex type or not
322
- */
323
- const isComplexType = (o) => {
324
- o = typeof o;
325
- return o === "object" || o === "function";
326
- };
327
- /**
328
- * Sort an array without mutating it in-place (as `Array.prototype.sort`
329
- * unfortunately does)
330
- *
331
- * @param array the array you'd like to sort
332
- * @param prop a function for deriving sortable values (strings or numbers)
333
- * from array members
334
- * @returns a new array of all items `x` in `array` ordered by `prop(x)`
335
- */
336
- const sortBy = (array, prop) => {
337
- return array.slice().sort((a, b) => {
338
- const nameA = prop(a);
339
- const nameB = prop(b);
340
- if (nameA < nameB) return -1;
341
- if (nameA > nameB) return 1;
342
- return 0;
343
- });
344
- };
345
- /**
346
- * A polyfill of sorts for `Array.prototype.flat` which will return the result
347
- * of calling that method if present and, if not, return an equivalent based on
348
- * `Array.prototype.reduce`.
349
- *
350
- * @param array the array to flatten (one level)
351
- * @returns a flattened array
352
- */
353
- const flatOne = (array) => {
354
- if (array.flat) return array.flat(1);
355
- return array.reduce((result, item) => {
356
- result.push(...item);
357
- return result;
358
- }, []);
359
- };
360
- /**
361
- * Deduplicate an array, retaining items at the earliest position in which
362
- * they appear.
363
- *
364
- * So `unique([1,3,2,1,1,4])` would be `[1,3,2,4]`.
365
- *
366
- * @param array the array to deduplicate
367
- * @param predicate an optional function used to generate the key used to
368
- * determine uniqueness
369
- * @returns a new, deduplicated array
370
- */
371
- const unique = (array, predicate = (i) => i) => {
372
- const set = /* @__PURE__ */ new Set();
373
- return array.filter((item) => {
374
- const key = predicate(item);
375
- if (key == null) return true;
376
- if (set.has(key)) return false;
377
- set.add(key);
378
- return true;
379
- });
380
- };
381
- /**
382
- * Merge elements of an array into an existing array, using a predicate to
383
- * determine uniqueness and only adding elements when they are not present in
384
- * the first array.
385
- *
386
- * **Note**: this mutates the target array! This is intentional to avoid
387
- * unnecessary array allocation, but be sure that it's what you want!
388
- *
389
- * @param target the target array, to which new unique items should be added
390
- * @param newItems a list of new items, some (or all!) of which may be added
391
- * @param mergeWith a predicate function which reduces the items in `target`
392
- * and `newItems` to a value which can be equated with `===` for the purposes
393
- * of determining uniqueness
394
- */
395
- function mergeIntoWith(target, newItems, mergeWith) {
396
- for (const item of newItems) if (!target.find((existingItem) => mergeWith(existingItem) === mergeWith(item))) target.push(item);
397
- }
398
- /**
399
- * A utility for building an object from an iterable very similar to
400
- * `Object.fromEntries`
401
- *
402
- * @param entries an iterable object holding entries (key-value tuples) to
403
- * plop into a new object
404
- * @returns an object containing those entries
405
- */
406
- const fromEntries = (entries) => {
407
- const object = {};
408
- for (const [key, value] of entries) object[key] = value;
409
- return object;
410
- };
411
- /**
412
- * Based on a given object, create a new object which has only the specified
413
- * key-value pairs included in it.
414
- *
415
- * @param obj the object from which to take values
416
- * @param keys a set of keys to take
417
- * @returns an object mapping `key` to `obj[key]` if `obj[key]` is truthy for
418
- * every `key` in `keys`
419
- */
420
- const pluck = (obj, keys) => {
421
- return keys.reduce((final, key) => {
422
- if (obj[key]) final[key] = obj[key];
423
- return final;
424
- }, {});
425
- };
426
- const isDefined = (v) => v !== null && v !== void 0;
427
- const isBoolean = (v) => typeof v === "boolean";
428
- const isFunction = (v) => typeof v === "function";
429
- const isNumber = (v) => typeof v === "number";
430
- const isObject = (val) => val != null && typeof val === "object" && Array.isArray(val) === false;
431
- const isString = (v) => typeof v === "string";
432
- const isIterable = (v) => isDefined(v) && isFunction(v[Symbol.iterator]);
433
- //#endregion
434
- //#region src/utils/regular-expression.ts
435
- /**
436
- * Utility function that will escape all regular expression special characters in a string.
437
- *
438
- * @param text The string potentially containing special characters.
439
- * @returns The string with all special characters escaped.
440
- */
441
- const escapeRegExpSpecialCharacters = (text) => {
442
- return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
443
- };
444
- //#endregion
445
- //#region src/utils/local-value.ts
446
- /**
447
- * Represents a local value with a specified type and optional value.
448
- * Described in https://w3c.github.io/webdriver-bidi/#type-script-LocalValue
449
- * @deprecated will be removed in v5. Use `@AttrDeserialize()` / `@PropDeserialize()` decorators instead.
450
- */
451
- var LocalValue = class LocalValue {
452
- type;
453
- value;
454
- constructor(type, value) {
455
- if (type === PrimitiveType.Undefined || type === PrimitiveType.Null) this.type = type;
456
- else {
457
- this.type = type;
458
- this.value = value;
459
- }
460
- }
461
- /**
462
- * Creates a new LocalValue object with a string value.
463
- *
464
- * @param {string} value - The string value to be stored in the LocalValue object.
465
- * @returns {LocalValue} - The created LocalValue object.
466
- */
467
- static createStringValue(value) {
468
- return new LocalValue(PrimitiveType.String, value);
469
- }
470
- /**
471
- * Creates a new LocalValue object with a number value.
472
- *
473
- * @param {number} value - The number value.
474
- * @returns {LocalValue} - The created LocalValue object.
475
- */
476
- static createNumberValue(value) {
477
- return new LocalValue(PrimitiveType.Number, value);
478
- }
479
- /**
480
- * Creates a new LocalValue object with a special number value.
481
- *
482
- * @param {number} value - The value of the special number.
483
- * @returns {LocalValue} - The created LocalValue object.
484
- */
485
- static createSpecialNumberValue(value) {
486
- if (Number.isNaN(value)) return new LocalValue(PrimitiveType.SpecialNumber, "NaN");
487
- if (Object.is(value, -0)) return new LocalValue(PrimitiveType.SpecialNumber, "-0");
488
- if (value === Infinity) return new LocalValue(PrimitiveType.SpecialNumber, "Infinity");
489
- if (value === -Infinity) return new LocalValue(PrimitiveType.SpecialNumber, "-Infinity");
490
- return new LocalValue(PrimitiveType.SpecialNumber, value);
491
- }
492
- /**
493
- * Creates a new LocalValue object with an undefined value.
494
- * @returns {LocalValue} - The created LocalValue object.
495
- */
496
- static createUndefinedValue() {
497
- return new LocalValue(PrimitiveType.Undefined);
498
- }
499
- /**
500
- * Creates a new LocalValue object with a null value.
501
- * @returns {LocalValue} - The created LocalValue object.
502
- */
503
- static createNullValue() {
504
- return new LocalValue(PrimitiveType.Null);
505
- }
506
- /**
507
- * Creates a new LocalValue object with a boolean value.
508
- *
509
- * @param {boolean} value - The boolean value.
510
- * @returns {LocalValue} - The created LocalValue object.
511
- */
512
- static createBooleanValue(value) {
513
- return new LocalValue(PrimitiveType.Boolean, value);
514
- }
515
- /**
516
- * Creates a new LocalValue object with a BigInt value.
517
- *
518
- * @param {BigInt} value - The BigInt value.
519
- * @returns {LocalValue} - The created LocalValue object.
520
- */
521
- static createBigIntValue(value) {
522
- return new LocalValue(PrimitiveType.BigInt, value.toString());
523
- }
524
- /**
525
- * Creates a new LocalValue object with an array.
526
- *
527
- * @param {Array} value - The array.
528
- * @returns {LocalValue} - The created LocalValue object.
529
- */
530
- static createArrayValue(value) {
531
- return new LocalValue(NonPrimitiveType.Array, value);
532
- }
533
- /**
534
- * Creates a new LocalValue object with date value.
535
- *
536
- * @param {string} value - The date.
537
- * @returns {LocalValue} - The created LocalValue object.
538
- */
539
- static createDateValue(value) {
540
- return new LocalValue(NonPrimitiveType.Date, value);
541
- }
542
- /**
543
- * Creates a new LocalValue object of map value.
544
- * @param {Map} map - The map.
545
- * @returns {LocalValue} - The created LocalValue object.
546
- */
547
- static createMapValue(map) {
548
- const value = [];
549
- Array.from(map.entries()).forEach(([key, val]) => {
550
- value.push([LocalValue.getArgument(key), LocalValue.getArgument(val)]);
551
- });
552
- return new LocalValue(NonPrimitiveType.Map, value);
553
- }
554
- /**
555
- * Creates a new LocalValue object from the passed object.
556
- *
557
- * @param object the object to create a LocalValue from
558
- * @returns {LocalValue} - The created LocalValue object.
559
- */
560
- static createObjectValue(object) {
561
- const value = [];
562
- Object.entries(object).forEach(([key, val]) => {
563
- value.push([key, LocalValue.getArgument(val)]);
564
- });
565
- return new LocalValue(NonPrimitiveType.Object, value);
566
- }
567
- /**
568
- * Creates a new LocalValue object of regular expression value.
569
- *
570
- * @param {string} value - The value of the regular expression.
571
- * @returns {LocalValue} - The created LocalValue object.
572
- */
573
- static createRegularExpressionValue(value) {
574
- return new LocalValue(NonPrimitiveType.RegularExpression, value);
575
- }
576
- /**
577
- * Creates a new LocalValue object with the specified value.
578
- * @param {Set} value - The value to be set.
579
- * @returns {LocalValue} - The created LocalValue object.
580
- */
581
- static createSetValue(value) {
582
- return new LocalValue(NonPrimitiveType.Set, value);
583
- }
584
- /**
585
- * Creates a new LocalValue object with the given channel value
586
- *
587
- * @param {ChannelValue} value - The channel value.
588
- * @returns {LocalValue} - The created LocalValue object.
589
- */
590
- static createChannelValue(value) {
591
- return new LocalValue(NonPrimitiveType.Channel, value);
592
- }
593
- /**
594
- * Creates a new LocalValue object with a Symbol value.
595
- *
596
- * @param {Symbol} symbol - The Symbol value
597
- * @returns {LocalValue} - The created LocalValue object
598
- */
599
- static createSymbolValue(symbol) {
600
- const description = symbol.description || "Symbol()";
601
- return new LocalValue(NonPrimitiveType.Symbol, description);
602
- }
603
- static getArgument(argument) {
604
- const type = typeof argument;
605
- switch (type) {
606
- case PrimitiveType.String: return LocalValue.createStringValue(argument);
607
- case PrimitiveType.Number:
608
- if (Number.isNaN(argument) || Object.is(argument, -0) || !Number.isFinite(argument)) return LocalValue.createSpecialNumberValue(argument);
609
- return LocalValue.createNumberValue(argument);
610
- case PrimitiveType.Boolean: return LocalValue.createBooleanValue(argument);
611
- case PrimitiveType.BigInt: return LocalValue.createBigIntValue(argument);
612
- case PrimitiveType.Undefined: return LocalValue.createUndefinedValue();
613
- case NonPrimitiveType.Symbol: return LocalValue.createSymbolValue(argument);
614
- case NonPrimitiveType.Object:
615
- if (argument === null) return LocalValue.createNullValue();
616
- if (argument instanceof Date) return LocalValue.createDateValue(argument);
617
- if (argument instanceof Map) {
618
- const map = [];
619
- argument.forEach((value, key) => {
620
- const objectKey = typeof key === "string" ? key : LocalValue.getArgument(key);
621
- const objectValue = LocalValue.getArgument(value);
622
- map.push([objectKey, objectValue]);
623
- });
624
- return LocalValue.createMapValue(argument);
625
- }
626
- if (argument instanceof Set) {
627
- const set = [];
628
- argument.forEach((value) => {
629
- set.push(LocalValue.getArgument(value));
630
- });
631
- return LocalValue.createSetValue(set);
632
- }
633
- if (argument instanceof Array) {
634
- const arr = [];
635
- argument.forEach((value) => {
636
- arr.push(LocalValue.getArgument(value));
637
- });
638
- return LocalValue.createArrayValue(arr);
639
- }
640
- if (argument instanceof RegExp) return LocalValue.createRegularExpressionValue({
641
- pattern: argument.source,
642
- flags: argument.flags
643
- });
644
- return LocalValue.createObjectValue(argument);
645
- }
646
- throw new Error(`Unsupported type: ${type}`);
647
- }
648
- asMap() {
649
- return {
650
- [TYPE_CONSTANT]: this.type,
651
- ...!(this.type === PrimitiveType.Null || this.type === PrimitiveType.Undefined) ? { [VALUE_CONSTANT]: this.value } : {}
652
- };
653
- }
654
- };
655
- //#endregion
656
- //#region src/utils/remote-value.ts
657
- /**
658
- * RemoteValue class for deserializing LocalValue serialized objects back into their original form
659
- * @deprecated will be removed in v5. Use `@AttrDeserialize()` / `@PropDeserialize()` decorators instead.
660
- */
661
- var RemoteValue = class RemoteValue {
662
- /**
663
- * Deserializes a LocalValue serialized object back to its original JavaScript representation
664
- *
665
- * @param serialized The serialized LocalValue object
666
- * @returns The original JavaScript value/object
667
- */
668
- static fromLocalValue(serialized) {
669
- const type = serialized[TYPE_CONSTANT];
670
- const value = "value" in serialized ? serialized[VALUE_CONSTANT] : void 0;
671
- switch (type) {
672
- case PrimitiveType.String: return value;
673
- case PrimitiveType.Boolean: return value;
674
- case PrimitiveType.BigInt: return BigInt(value);
675
- case PrimitiveType.Undefined: return;
676
- case PrimitiveType.Null: return null;
677
- case PrimitiveType.Number:
678
- if (value === "NaN") return NaN;
679
- if (value === "-0") return -0;
680
- if (value === "Infinity") return Infinity;
681
- if (value === "-Infinity") return -Infinity;
682
- return value;
683
- case NonPrimitiveType.Array: return value.map((item) => RemoteValue.fromLocalValue(item));
684
- case NonPrimitiveType.Date: return new Date(value);
685
- case NonPrimitiveType.Map:
686
- const map = /* @__PURE__ */ new Map();
687
- for (const [key, val] of value) {
688
- const deserializedKey = typeof key === "object" && key !== null ? RemoteValue.fromLocalValue(key) : key;
689
- const deserializedValue = RemoteValue.fromLocalValue(val);
690
- map.set(deserializedKey, deserializedValue);
691
- }
692
- return map;
693
- case NonPrimitiveType.Object:
694
- const obj = {};
695
- for (const [key, val] of value) obj[key] = RemoteValue.fromLocalValue(val);
696
- return obj;
697
- case NonPrimitiveType.RegularExpression:
698
- const { pattern, flags } = value;
699
- return new RegExp(pattern, flags);
700
- case NonPrimitiveType.Set:
701
- const set = /* @__PURE__ */ new Set();
702
- for (const item of value) set.add(RemoteValue.fromLocalValue(item));
703
- return set;
704
- case NonPrimitiveType.Symbol: return Symbol(value);
705
- default: throw new Error(`Unsupported type: ${type}`);
706
- }
707
- }
708
- /**
709
- * Utility method to deserialize multiple LocalValues at once
710
- *
711
- * @param serializedValues Array of serialized LocalValue objects
712
- * @returns Array of deserialized JavaScript values
713
- */
714
- static fromLocalValueArray(serializedValues) {
715
- return serializedValues.map((value) => RemoteValue.fromLocalValue(value));
716
- }
717
- /**
718
- * Verifies if the given object matches the structure of a serialized LocalValue
719
- *
720
- * @param obj Object to verify
721
- * @returns boolean indicating if the object has LocalValue structure
722
- */
723
- static isLocalValueObject(obj) {
724
- if (typeof obj !== "object" || obj === null) return false;
725
- if (!obj.hasOwnProperty("type")) return false;
726
- const type = obj[TYPE_CONSTANT];
727
- if (!Object.values({
728
- ...PrimitiveType,
729
- ...NonPrimitiveType
730
- }).includes(type)) return false;
731
- if (type !== PrimitiveType.Null && type !== PrimitiveType.Undefined) return obj.hasOwnProperty(VALUE_CONSTANT);
732
- return true;
733
- }
734
- };
735
- //#endregion
736
- //#region src/utils/serialize.ts
737
- /**
738
- * Unicode-safe base64 encoding that handles characters outside Latin1 range.
739
- * Unlike btoa(), this properly handles Unicode characters including emoji,
740
- * CJK characters, and currency symbols like €.
741
- * @param {string} str - The string to encode.
742
- * @returns {string} Base64 encoded string.
743
- */
744
- function encodeBase64Unicode(str) {
745
- const utf8Bytes = new TextEncoder().encode(str);
746
- let binary = "";
747
- for (let i = 0; i < utf8Bytes.length; i++) binary += String.fromCharCode(utf8Bytes[i]);
748
- return btoa(binary);
749
- }
750
- /**
751
- * Unicode-safe base64 decoding that handles characters outside Latin1 range.
752
- * Unlike atob(), this properly decodes Unicode characters including emoji,
753
- * CJK characters, and currency symbols like €.
754
- * @param {string} base64 - The base64 string to decode.
755
- * @returns {string} Decoded string.
756
- */
757
- function decodeBase64Unicode(base64) {
758
- const binary = atob(base64);
759
- const bytes = new Uint8Array(binary.length);
760
- for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
761
- return new TextDecoder().decode(bytes);
762
- }
763
- /**
764
- * Serialize a value to a string that can be deserialized later.
765
- * @param {unknown} value - The value to serialize.
766
- * @returns {string} A string that can be deserialized later.
767
- * @deprecated will be removed in v5. Use `@PropSerialize()` decorator instead.
768
- */
769
- function serializeProperty(value) {
770
- /**
771
- * If the value is a primitive type, return it as is.
772
- */
773
- if ([
774
- "string",
775
- "boolean",
776
- "undefined"
777
- ].includes(typeof value) || typeof value === "number" && value !== Infinity && value !== -Infinity && !isNaN(value)) return value;
778
- const arg = LocalValue.getArgument(value);
779
- return SERIALIZED_PREFIX + encodeBase64Unicode(JSON.stringify(arg));
780
- }
781
- /**
782
- * Deserialize a value from a string that was serialized earlier.
783
- * @param {string} value - The string to deserialize.
784
- * @returns {unknown} The deserialized value.
785
- * @deprecated will be removed in v5. Use `@AttrDeserialize()` decorator instead.
786
- */
787
- function deserializeProperty(value) {
788
- if (typeof value !== "string" || !value.startsWith("serialized:")) return value;
789
- return RemoteValue.fromLocalValue(JSON.parse(decodeBase64Unicode(value.slice(11))));
790
- }
791
- //#endregion
792
- export { PrimitiveType as $, CUSTOM as A, DOCS_CUSTOM as B, toDashCase as C, CMP_FLAGS as D, queryNonceMetaTagContent as E, DIST_GLOBAL_STYLES as F, EVENT_FLAGS as G, DOCS_JSON as H, DIST_HYDRATE_SCRIPT as I, HTML_NS as J, GENERATED_DTS as K, DIST_LAZY as L, DIST as M, DIST_COLLECTION as N, COLLECTION_MANIFEST_FILE_NAME as O, DIST_CUSTOM_ELEMENTS as P, NonPrimitiveType as Q, DIST_LAZY_LOADER as R, toCamelCase as S, unique as T, DOCS_README as U, DOCS_CUSTOM_ELEMENTS_MANIFEST as V, DOCS_VSCODE as W, MEMBER_FLAGS as X, LISTENER_FLAGS as Y, NODE_TYPES as Z, isString as _, escapeRegExpSpecialCharacters as a, VALUE_CONSTANT as at, pluck as b, flatOne as c, XLINK_NS as ct, isComplexType as d, SERIALIZED_PREFIX as et, isDef as f, isObject as g, isNumber as h, LocalValue as i, VALID_CONFIG_OUTPUT_TARGETS as it, DEFAULT_STYLE_MODE as j, COPY as k, fromEntries as l, isIterable as m, serializeProperty as n, SVG_NS as nt, dashToPascalCase as o, WATCH_FLAGS as ot, isFunction as p, HOST_FLAGS as q, RemoteValue as r, TYPE_CONSTANT as rt, escapeWithPattern as s, WWW as st, deserializeProperty as t, STATS as tt, isBoolean as u, mergeIntoWith as v, toTitleCase as w, sortBy as x, noop as y, DIST_TYPES as z };