@stencil/core 4.28.2 → 4.29.0

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,5 +1,5 @@
1
1
  /*
2
- Stencil Hydrate Platform v4.28.2 | MIT Licensed | https://stenciljs.com
2
+ Stencil Hydrate Platform v4.29.0 | MIT Licensed | https://stenciljs.com
3
3
  */
4
4
  var __defProp = Object.defineProperty;
5
5
  var __export = (target, all) => {
@@ -16,6 +16,30 @@ import { BUILD } from "@stencil/core/internal/app-data";
16
16
  // src/utils/constants.ts
17
17
  var SVG_NS = "http://www.w3.org/2000/svg";
18
18
  var HTML_NS = "http://www.w3.org/1999/xhtml";
19
+ var PrimitiveType = /* @__PURE__ */ ((PrimitiveType2) => {
20
+ PrimitiveType2["Undefined"] = "undefined";
21
+ PrimitiveType2["Null"] = "null";
22
+ PrimitiveType2["String"] = "string";
23
+ PrimitiveType2["Number"] = "number";
24
+ PrimitiveType2["SpecialNumber"] = "number";
25
+ PrimitiveType2["Boolean"] = "boolean";
26
+ PrimitiveType2["BigInt"] = "bigint";
27
+ return PrimitiveType2;
28
+ })(PrimitiveType || {});
29
+ var NonPrimitiveType = /* @__PURE__ */ ((NonPrimitiveType2) => {
30
+ NonPrimitiveType2["Array"] = "array";
31
+ NonPrimitiveType2["Date"] = "date";
32
+ NonPrimitiveType2["Map"] = "map";
33
+ NonPrimitiveType2["Object"] = "object";
34
+ NonPrimitiveType2["RegularExpression"] = "regexp";
35
+ NonPrimitiveType2["Set"] = "set";
36
+ NonPrimitiveType2["Channel"] = "channel";
37
+ NonPrimitiveType2["Symbol"] = "symbol";
38
+ return NonPrimitiveType2;
39
+ })(NonPrimitiveType || {});
40
+ var TYPE_CONSTANT = "type";
41
+ var VALUE_CONSTANT = "value";
42
+ var SERIALIZED_PREFIX = "serialized:";
19
43
 
20
44
  // src/utils/es2022-rewire-class-members.ts
21
45
  var reWireGetterSetter = (instance, hostRef) => {
@@ -69,6 +93,101 @@ var escapeRegExpSpecialCharacters = (text) => {
69
93
  return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
70
94
  };
71
95
 
96
+ // src/utils/remote-value.ts
97
+ var RemoteValue = class _RemoteValue {
98
+ /**
99
+ * Deserializes a LocalValue serialized object back to its original JavaScript representation
100
+ *
101
+ * @param serialized The serialized LocalValue object
102
+ * @returns The original JavaScript value/object
103
+ */
104
+ static fromLocalValue(serialized) {
105
+ const type = serialized[TYPE_CONSTANT];
106
+ const value = VALUE_CONSTANT in serialized ? serialized[VALUE_CONSTANT] : void 0;
107
+ switch (type) {
108
+ case "string" /* String */:
109
+ return value;
110
+ case "boolean" /* Boolean */:
111
+ return value;
112
+ case "bigint" /* BigInt */:
113
+ return BigInt(value);
114
+ case "undefined" /* Undefined */:
115
+ return void 0;
116
+ case "null" /* Null */:
117
+ return null;
118
+ case "number" /* Number */:
119
+ if (value === "NaN") return NaN;
120
+ if (value === "-0") return -0;
121
+ if (value === "Infinity") return Infinity;
122
+ if (value === "-Infinity") return -Infinity;
123
+ return value;
124
+ case "array" /* Array */:
125
+ return value.map((item) => _RemoteValue.fromLocalValue(item));
126
+ case "date" /* Date */:
127
+ return new Date(value);
128
+ case "map" /* Map */:
129
+ const map2 = /* @__PURE__ */ new Map();
130
+ for (const [key, val] of value) {
131
+ const deserializedKey = typeof key === "object" && key !== null ? _RemoteValue.fromLocalValue(key) : key;
132
+ const deserializedValue = _RemoteValue.fromLocalValue(val);
133
+ map2.set(deserializedKey, deserializedValue);
134
+ }
135
+ return map2;
136
+ case "object" /* Object */:
137
+ const obj = {};
138
+ for (const [key, val] of value) {
139
+ obj[key] = _RemoteValue.fromLocalValue(val);
140
+ }
141
+ return obj;
142
+ case "regexp" /* RegularExpression */:
143
+ const { pattern, flags } = value;
144
+ return new RegExp(pattern, flags);
145
+ case "set" /* Set */:
146
+ const set = /* @__PURE__ */ new Set();
147
+ for (const item of value) {
148
+ set.add(_RemoteValue.fromLocalValue(item));
149
+ }
150
+ return set;
151
+ case "symbol" /* Symbol */:
152
+ return Symbol(value);
153
+ default:
154
+ throw new Error(`Unsupported type: ${type}`);
155
+ }
156
+ }
157
+ /**
158
+ * Utility method to deserialize multiple LocalValues at once
159
+ *
160
+ * @param serializedValues Array of serialized LocalValue objects
161
+ * @returns Array of deserialized JavaScript values
162
+ */
163
+ static fromLocalValueArray(serializedValues) {
164
+ return serializedValues.map((value) => _RemoteValue.fromLocalValue(value));
165
+ }
166
+ /**
167
+ * Verifies if the given object matches the structure of a serialized LocalValue
168
+ *
169
+ * @param obj Object to verify
170
+ * @returns boolean indicating if the object has LocalValue structure
171
+ */
172
+ static isLocalValueObject(obj) {
173
+ if (typeof obj !== "object" || obj === null) {
174
+ return false;
175
+ }
176
+ if (!obj.hasOwnProperty(TYPE_CONSTANT)) {
177
+ return false;
178
+ }
179
+ const type = obj[TYPE_CONSTANT];
180
+ const hasTypeProperty = Object.values({ ...PrimitiveType, ...NonPrimitiveType }).includes(type);
181
+ if (!hasTypeProperty) {
182
+ return false;
183
+ }
184
+ if (type !== "null" /* Null */ && type !== "undefined" /* Undefined */) {
185
+ return obj.hasOwnProperty(VALUE_CONSTANT);
186
+ }
187
+ return true;
188
+ }
189
+ };
190
+
72
191
  // src/utils/result.ts
73
192
  var result_exports = {};
74
193
  __export(result_exports, {
@@ -118,6 +237,14 @@ var unwrapErr = (result) => {
118
237
  }
119
238
  };
120
239
 
240
+ // src/utils/serialize.ts
241
+ function deserializeProperty(value) {
242
+ if (typeof value !== "string" || !value.startsWith(SERIALIZED_PREFIX)) {
243
+ return value;
244
+ }
245
+ return RemoteValue.fromLocalValue(JSON.parse(atob(value.slice(SERIALIZED_PREFIX.length))));
246
+ }
247
+
121
248
  // src/utils/util.ts
122
249
  var lowerPathParam = (fn) => (p) => fn(p.toLowerCase());
123
250
  var isDtsFile = lowerPathParam((p) => p.endsWith(".d.ts") || p.endsWith(".d.mts") || p.endsWith(".d.cts"));
@@ -912,6 +1039,7 @@ var validateInputProperties = (inputElm) => {
912
1039
 
913
1040
  // src/runtime/client-hydrate.ts
914
1041
  var initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
1042
+ var _a;
915
1043
  const endHydrate = createTime("hydrateClient", tagName);
916
1044
  const shadowRoot = hostElm.shadowRoot;
917
1045
  const childRenderNodes = [];
@@ -920,6 +1048,19 @@ var initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
920
1048
  const shadowRootNodes = BUILD6.shadowDom && shadowRoot ? [] : null;
921
1049
  const vnode = newVNode(tagName, null);
922
1050
  vnode.$elm$ = hostElm;
1051
+ const members = Object.entries(((_a = hostRef.$cmpMeta$) == null ? void 0 : _a.$members$) || {});
1052
+ members.forEach(([memberName, [memberFlags, metaAttributeName]]) => {
1053
+ var _a2;
1054
+ if (!(memberFlags & 31 /* Prop */)) {
1055
+ return;
1056
+ }
1057
+ const attributeName = metaAttributeName || memberName;
1058
+ const attrVal = hostElm.getAttribute(attributeName);
1059
+ if (attrVal !== null) {
1060
+ const attrPropVal = parsePropertyValue(attrVal, memberFlags);
1061
+ (_a2 = hostRef == null ? void 0 : hostRef.$instanceValues$) == null ? void 0 : _a2.set(memberName, attrPropVal);
1062
+ }
1063
+ });
923
1064
  let scopeId2;
924
1065
  if (BUILD6.scoped) {
925
1066
  const cmpMeta = hostRef.$cmpMeta$;
@@ -1672,12 +1813,23 @@ import { BUILD as BUILD15 } from "@stencil/core/internal/app-data";
1672
1813
  // src/runtime/parse-property-value.ts
1673
1814
  import { BUILD as BUILD7 } from "@stencil/core/internal/app-data";
1674
1815
  var parsePropertyValue = (propValue, propType) => {
1816
+ if ((BUILD7.hydrateClientSide || BUILD7.hydrateServerSide) && typeof propValue === "string" && (propValue.startsWith("{") && propValue.endsWith("}") || propValue.startsWith("[") && propValue.endsWith("]"))) {
1817
+ try {
1818
+ propValue = JSON.parse(propValue);
1819
+ return propValue;
1820
+ } catch (e) {
1821
+ }
1822
+ }
1823
+ if ((BUILD7.hydrateClientSide || BUILD7.hydrateServerSide) && typeof propValue === "string" && propValue.startsWith(SERIALIZED_PREFIX)) {
1824
+ propValue = deserializeProperty(propValue);
1825
+ return propValue;
1826
+ }
1675
1827
  if (propValue != null && !isComplexType(propValue)) {
1676
1828
  if (BUILD7.propBoolean && propType & 4 /* Boolean */) {
1677
1829
  return propValue === "false" ? false : propValue === "" || !!propValue;
1678
1830
  }
1679
1831
  if (BUILD7.propNumber && propType & 2 /* Number */) {
1680
- return parseFloat(propValue);
1832
+ return typeof propValue === "string" ? parseFloat(propValue) : typeof propValue === "number" ? propValue : NaN;
1681
1833
  }
1682
1834
  if (BUILD7.propString && propType & 1 /* String */) {
1683
1835
  return String(propValue);
@@ -2452,7 +2604,8 @@ var renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
2452
2604
  const hostElm = hostRef.$hostElement$;
2453
2605
  const cmpMeta = hostRef.$cmpMeta$;
2454
2606
  const oldVNode = hostRef.$vnode$ || newVNode(null, null);
2455
- const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
2607
+ const isHostElement = isHost(renderFnResults);
2608
+ const rootVnode = isHostElement ? renderFnResults : h(null, null, renderFnResults);
2456
2609
  hostTagName = hostElm.tagName;
2457
2610
  if (BUILD13.isDev && Array.isArray(renderFnResults) && renderFnResults.some(isHost)) {
2458
2611
  throw new Error(`The <Host> must be the single root component.
@@ -3878,21 +4031,15 @@ function proxyHostElement(elm, cstr) {
3878
4031
  var _a;
3879
4032
  if (memberFlags & 31 /* Prop */) {
3880
4033
  const attributeName = metaAttributeName || memberName;
3881
- let attrValue = elm.getAttribute(attributeName);
3882
- if ((attrValue == null ? void 0 : attrValue.startsWith("{")) && attrValue.endsWith("}") || (attrValue == null ? void 0 : attrValue.startsWith("[")) && attrValue.endsWith("]")) {
3883
- try {
3884
- attrValue = JSON.parse(attrValue);
3885
- } catch (e) {
3886
- }
3887
- }
3888
- const { get: origGetter, set: origSetter } = Object.getOwnPropertyDescriptor(cstr.prototype, memberName) || {};
4034
+ const attrValue = elm.getAttribute(attributeName);
4035
+ const propValue = elm[memberName];
3889
4036
  let attrPropVal;
4037
+ const { get: origGetter, set: origSetter } = Object.getOwnPropertyDescriptor(cstr.prototype, memberName) || {};
3890
4038
  if (attrValue != null) {
3891
4039
  attrPropVal = parsePropertyValue(attrValue, memberFlags);
3892
4040
  }
3893
- const ownValue = elm[memberName];
3894
- if (ownValue !== void 0) {
3895
- attrPropVal = ownValue;
4041
+ if (propValue !== void 0) {
4042
+ attrPropVal = propValue;
3896
4043
  delete elm[memberName];
3897
4044
  }
3898
4045
  if (attrPropVal !== void 0) {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stencil/core/internal/hydrate",
3
- "version": "4.28.2",
3
+ "version": "4.29.0",
4
4
  "description": "Stencil internal hydrate platform to be imported by the Stencil Compiler. Breaking changes can and will happen at any time.",
5
5
  "main": "./index.js",
6
6
  "private": true
@@ -3,6 +3,18 @@
3
3
  import { Readable } from 'node:stream';
4
4
 
5
5
  export declare function createWindowFromHtml(templateHtml: string, uniqueId: string): any;
6
+ /**
7
+ * Serialize a value to a string that can be deserialized later.
8
+ * @param {unknown} value - The value to serialize.
9
+ * @returns {string} A string that can be deserialized later.
10
+ */
11
+ export declare function serializeProperty(value: unknown): string | number | boolean;
12
+ /**
13
+ * Deserialize a value from a string that was serialized earlier.
14
+ * @param {string} value - The string to deserialize.
15
+ * @returns {unknown} The deserialized value.
16
+ */
17
+ export declare function deserializeProperty(value: string): any;
6
18
  export type ResolutionHandler = (elm: HTMLElement) => string | undefined | null;
7
19
  export interface HydrateDocumentOptions {
8
20
  /**
@@ -1,5 +1,5 @@
1
1
  /*
2
- Stencil Hydrate Runner v4.28.2 | MIT Licensed | https://stenciljs.com
2
+ Stencil Hydrate Runner v4.29.0 | MIT Licensed | https://stenciljs.com
3
3
  */
4
4
  var __defProp = Object.defineProperty;
5
5
  var __export = (target, all) => {
@@ -14087,6 +14087,32 @@ import { BUILD as BUILD3 } from "@stencil/core/internal/app-data";
14087
14087
  // src/utils/es2022-rewire-class-members.ts
14088
14088
  import { BUILD as BUILD2 } from "@stencil/core/internal/app-data";
14089
14089
 
14090
+ // src/utils/constants.ts
14091
+ var PrimitiveType = /* @__PURE__ */ ((PrimitiveType2) => {
14092
+ PrimitiveType2["Undefined"] = "undefined";
14093
+ PrimitiveType2["Null"] = "null";
14094
+ PrimitiveType2["String"] = "string";
14095
+ PrimitiveType2["Number"] = "number";
14096
+ PrimitiveType2["SpecialNumber"] = "number";
14097
+ PrimitiveType2["Boolean"] = "boolean";
14098
+ PrimitiveType2["BigInt"] = "bigint";
14099
+ return PrimitiveType2;
14100
+ })(PrimitiveType || {});
14101
+ var NonPrimitiveType = /* @__PURE__ */ ((NonPrimitiveType2) => {
14102
+ NonPrimitiveType2["Array"] = "array";
14103
+ NonPrimitiveType2["Date"] = "date";
14104
+ NonPrimitiveType2["Map"] = "map";
14105
+ NonPrimitiveType2["Object"] = "object";
14106
+ NonPrimitiveType2["RegularExpression"] = "regexp";
14107
+ NonPrimitiveType2["Set"] = "set";
14108
+ NonPrimitiveType2["Channel"] = "channel";
14109
+ NonPrimitiveType2["Symbol"] = "symbol";
14110
+ return NonPrimitiveType2;
14111
+ })(NonPrimitiveType || {});
14112
+ var TYPE_CONSTANT = "type";
14113
+ var VALUE_CONSTANT = "value";
14114
+ var SERIALIZED_PREFIX = "serialized:";
14115
+
14090
14116
  // src/client/client-load-module.ts
14091
14117
  import { BUILD as BUILD5 } from "@stencil/core/internal/app-data";
14092
14118
 
@@ -14127,6 +14153,232 @@ import { BUILD as BUILD26 } from "@stencil/core/internal/app-data";
14127
14153
  // src/utils/helpers.ts
14128
14154
  var isString = (v) => typeof v === "string";
14129
14155
 
14156
+ // src/utils/local-value.ts
14157
+ var LocalValue = class _LocalValue {
14158
+ constructor(type, value) {
14159
+ if (type === "undefined" /* Undefined */ || type === "null" /* Null */) {
14160
+ this.type = type;
14161
+ } else {
14162
+ this.type = type;
14163
+ this.value = value;
14164
+ }
14165
+ }
14166
+ /**
14167
+ * Creates a new LocalValue object with a string value.
14168
+ *
14169
+ * @param {string} value - The string value to be stored in the LocalValue object.
14170
+ * @returns {LocalValue} - The created LocalValue object.
14171
+ */
14172
+ static createStringValue(value) {
14173
+ return new _LocalValue("string" /* String */, value);
14174
+ }
14175
+ /**
14176
+ * Creates a new LocalValue object with a number value.
14177
+ *
14178
+ * @param {number} value - The number value.
14179
+ * @returns {LocalValue} - The created LocalValue object.
14180
+ */
14181
+ static createNumberValue(value) {
14182
+ return new _LocalValue("number" /* Number */, value);
14183
+ }
14184
+ /**
14185
+ * Creates a new LocalValue object with a special number value.
14186
+ *
14187
+ * @param {number} value - The value of the special number.
14188
+ * @returns {LocalValue} - The created LocalValue object.
14189
+ */
14190
+ static createSpecialNumberValue(value) {
14191
+ if (Number.isNaN(value)) {
14192
+ return new _LocalValue("number" /* SpecialNumber */, "NaN");
14193
+ }
14194
+ if (Object.is(value, -0)) {
14195
+ return new _LocalValue("number" /* SpecialNumber */, "-0");
14196
+ }
14197
+ if (value === Infinity) {
14198
+ return new _LocalValue("number" /* SpecialNumber */, "Infinity");
14199
+ }
14200
+ if (value === -Infinity) {
14201
+ return new _LocalValue("number" /* SpecialNumber */, "-Infinity");
14202
+ }
14203
+ return new _LocalValue("number" /* SpecialNumber */, value);
14204
+ }
14205
+ /**
14206
+ * Creates a new LocalValue object with an undefined value.
14207
+ * @returns {LocalValue} - The created LocalValue object.
14208
+ */
14209
+ static createUndefinedValue() {
14210
+ return new _LocalValue("undefined" /* Undefined */);
14211
+ }
14212
+ /**
14213
+ * Creates a new LocalValue object with a null value.
14214
+ * @returns {LocalValue} - The created LocalValue object.
14215
+ */
14216
+ static createNullValue() {
14217
+ return new _LocalValue("null" /* Null */);
14218
+ }
14219
+ /**
14220
+ * Creates a new LocalValue object with a boolean value.
14221
+ *
14222
+ * @param {boolean} value - The boolean value.
14223
+ * @returns {LocalValue} - The created LocalValue object.
14224
+ */
14225
+ static createBooleanValue(value) {
14226
+ return new _LocalValue("boolean" /* Boolean */, value);
14227
+ }
14228
+ /**
14229
+ * Creates a new LocalValue object with a BigInt value.
14230
+ *
14231
+ * @param {BigInt} value - The BigInt value.
14232
+ * @returns {LocalValue} - The created LocalValue object.
14233
+ */
14234
+ static createBigIntValue(value) {
14235
+ return new _LocalValue("bigint" /* BigInt */, value.toString());
14236
+ }
14237
+ /**
14238
+ * Creates a new LocalValue object with an array.
14239
+ *
14240
+ * @param {Array} value - The array.
14241
+ * @returns {LocalValue} - The created LocalValue object.
14242
+ */
14243
+ static createArrayValue(value) {
14244
+ return new _LocalValue("array" /* Array */, value);
14245
+ }
14246
+ /**
14247
+ * Creates a new LocalValue object with date value.
14248
+ *
14249
+ * @param {string} value - The date.
14250
+ * @returns {LocalValue} - The created LocalValue object.
14251
+ */
14252
+ static createDateValue(value) {
14253
+ return new _LocalValue("date" /* Date */, value);
14254
+ }
14255
+ /**
14256
+ * Creates a new LocalValue object of map value.
14257
+ * @param {Map} map - The map.
14258
+ * @returns {LocalValue} - The created LocalValue object.
14259
+ */
14260
+ static createMapValue(map2) {
14261
+ const value = [];
14262
+ Array.from(map2.entries()).forEach(([key, val]) => {
14263
+ value.push([_LocalValue.getArgument(key), _LocalValue.getArgument(val)]);
14264
+ });
14265
+ return new _LocalValue("map" /* Map */, value);
14266
+ }
14267
+ /**
14268
+ * Creates a new LocalValue object from the passed object.
14269
+ *
14270
+ * @param object the object to create a LocalValue from
14271
+ * @returns {LocalValue} - The created LocalValue object.
14272
+ */
14273
+ static createObjectValue(object) {
14274
+ const value = [];
14275
+ Object.entries(object).forEach(([key, val]) => {
14276
+ value.push([key, _LocalValue.getArgument(val)]);
14277
+ });
14278
+ return new _LocalValue("object" /* Object */, value);
14279
+ }
14280
+ /**
14281
+ * Creates a new LocalValue object of regular expression value.
14282
+ *
14283
+ * @param {string} value - The value of the regular expression.
14284
+ * @returns {LocalValue} - The created LocalValue object.
14285
+ */
14286
+ static createRegularExpressionValue(value) {
14287
+ return new _LocalValue("regexp" /* RegularExpression */, value);
14288
+ }
14289
+ /**
14290
+ * Creates a new LocalValue object with the specified value.
14291
+ * @param {Set} value - The value to be set.
14292
+ * @returns {LocalValue} - The created LocalValue object.
14293
+ */
14294
+ static createSetValue(value) {
14295
+ return new _LocalValue("set" /* Set */, value);
14296
+ }
14297
+ /**
14298
+ * Creates a new LocalValue object with the given channel value
14299
+ *
14300
+ * @param {ChannelValue} value - The channel value.
14301
+ * @returns {LocalValue} - The created LocalValue object.
14302
+ */
14303
+ static createChannelValue(value) {
14304
+ return new _LocalValue("channel" /* Channel */, value);
14305
+ }
14306
+ /**
14307
+ * Creates a new LocalValue object with a Symbol value.
14308
+ *
14309
+ * @param {Symbol} symbol - The Symbol value
14310
+ * @returns {LocalValue} - The created LocalValue object
14311
+ */
14312
+ static createSymbolValue(symbol) {
14313
+ const description = symbol.description || "Symbol()";
14314
+ return new _LocalValue("symbol" /* Symbol */, description);
14315
+ }
14316
+ static getArgument(argument) {
14317
+ const type = typeof argument;
14318
+ switch (type) {
14319
+ case "string" /* String */:
14320
+ return _LocalValue.createStringValue(argument);
14321
+ case "number" /* Number */:
14322
+ if (Number.isNaN(argument) || Object.is(argument, -0) || !Number.isFinite(argument)) {
14323
+ return _LocalValue.createSpecialNumberValue(argument);
14324
+ }
14325
+ return _LocalValue.createNumberValue(argument);
14326
+ case "boolean" /* Boolean */:
14327
+ return _LocalValue.createBooleanValue(argument);
14328
+ case "bigint" /* BigInt */:
14329
+ return _LocalValue.createBigIntValue(argument);
14330
+ case "undefined" /* Undefined */:
14331
+ return _LocalValue.createUndefinedValue();
14332
+ case "symbol" /* Symbol */:
14333
+ return _LocalValue.createSymbolValue(argument);
14334
+ case "object" /* Object */:
14335
+ if (argument === null) {
14336
+ return _LocalValue.createNullValue();
14337
+ }
14338
+ if (argument instanceof Date) {
14339
+ return _LocalValue.createDateValue(argument);
14340
+ }
14341
+ if (argument instanceof Map) {
14342
+ const map2 = [];
14343
+ argument.forEach((value, key) => {
14344
+ const objectKey = typeof key === "string" ? key : _LocalValue.getArgument(key);
14345
+ const objectValue = _LocalValue.getArgument(value);
14346
+ map2.push([objectKey, objectValue]);
14347
+ });
14348
+ return _LocalValue.createMapValue(argument);
14349
+ }
14350
+ if (argument instanceof Set) {
14351
+ const set = [];
14352
+ argument.forEach((value) => {
14353
+ set.push(_LocalValue.getArgument(value));
14354
+ });
14355
+ return _LocalValue.createSetValue(set);
14356
+ }
14357
+ if (argument instanceof Array) {
14358
+ const arr = [];
14359
+ argument.forEach((value) => {
14360
+ arr.push(_LocalValue.getArgument(value));
14361
+ });
14362
+ return _LocalValue.createArrayValue(arr);
14363
+ }
14364
+ if (argument instanceof RegExp) {
14365
+ return _LocalValue.createRegularExpressionValue({
14366
+ pattern: argument.source,
14367
+ flags: argument.flags
14368
+ });
14369
+ }
14370
+ return _LocalValue.createObjectValue(argument);
14371
+ }
14372
+ throw new Error(`Unsupported type: ${type}`);
14373
+ }
14374
+ asMap() {
14375
+ return {
14376
+ [TYPE_CONSTANT]: this.type,
14377
+ ...!(this.type === "null" /* Null */ || this.type === "undefined" /* Undefined */) ? { [VALUE_CONSTANT]: this.value } : {}
14378
+ };
14379
+ }
14380
+ };
14381
+
14130
14382
  // src/utils/message-utils.ts
14131
14383
  var catchError = (diagnostics, err2, msg) => {
14132
14384
  const diagnostic = {
@@ -14165,6 +14417,101 @@ var shouldIgnoreError = (msg) => {
14165
14417
  };
14166
14418
  var TASK_CANCELED_MSG = `task canceled`;
14167
14419
 
14420
+ // src/utils/remote-value.ts
14421
+ var RemoteValue = class _RemoteValue {
14422
+ /**
14423
+ * Deserializes a LocalValue serialized object back to its original JavaScript representation
14424
+ *
14425
+ * @param serialized The serialized LocalValue object
14426
+ * @returns The original JavaScript value/object
14427
+ */
14428
+ static fromLocalValue(serialized) {
14429
+ const type = serialized[TYPE_CONSTANT];
14430
+ const value = VALUE_CONSTANT in serialized ? serialized[VALUE_CONSTANT] : void 0;
14431
+ switch (type) {
14432
+ case "string" /* String */:
14433
+ return value;
14434
+ case "boolean" /* Boolean */:
14435
+ return value;
14436
+ case "bigint" /* BigInt */:
14437
+ return BigInt(value);
14438
+ case "undefined" /* Undefined */:
14439
+ return void 0;
14440
+ case "null" /* Null */:
14441
+ return null;
14442
+ case "number" /* Number */:
14443
+ if (value === "NaN") return NaN;
14444
+ if (value === "-0") return -0;
14445
+ if (value === "Infinity") return Infinity;
14446
+ if (value === "-Infinity") return -Infinity;
14447
+ return value;
14448
+ case "array" /* Array */:
14449
+ return value.map((item) => _RemoteValue.fromLocalValue(item));
14450
+ case "date" /* Date */:
14451
+ return new Date(value);
14452
+ case "map" /* Map */:
14453
+ const map2 = /* @__PURE__ */ new Map();
14454
+ for (const [key, val] of value) {
14455
+ const deserializedKey = typeof key === "object" && key !== null ? _RemoteValue.fromLocalValue(key) : key;
14456
+ const deserializedValue = _RemoteValue.fromLocalValue(val);
14457
+ map2.set(deserializedKey, deserializedValue);
14458
+ }
14459
+ return map2;
14460
+ case "object" /* Object */:
14461
+ const obj = {};
14462
+ for (const [key, val] of value) {
14463
+ obj[key] = _RemoteValue.fromLocalValue(val);
14464
+ }
14465
+ return obj;
14466
+ case "regexp" /* RegularExpression */:
14467
+ const { pattern, flags } = value;
14468
+ return new RegExp(pattern, flags);
14469
+ case "set" /* Set */:
14470
+ const set = /* @__PURE__ */ new Set();
14471
+ for (const item of value) {
14472
+ set.add(_RemoteValue.fromLocalValue(item));
14473
+ }
14474
+ return set;
14475
+ case "symbol" /* Symbol */:
14476
+ return Symbol(value);
14477
+ default:
14478
+ throw new Error(`Unsupported type: ${type}`);
14479
+ }
14480
+ }
14481
+ /**
14482
+ * Utility method to deserialize multiple LocalValues at once
14483
+ *
14484
+ * @param serializedValues Array of serialized LocalValue objects
14485
+ * @returns Array of deserialized JavaScript values
14486
+ */
14487
+ static fromLocalValueArray(serializedValues) {
14488
+ return serializedValues.map((value) => _RemoteValue.fromLocalValue(value));
14489
+ }
14490
+ /**
14491
+ * Verifies if the given object matches the structure of a serialized LocalValue
14492
+ *
14493
+ * @param obj Object to verify
14494
+ * @returns boolean indicating if the object has LocalValue structure
14495
+ */
14496
+ static isLocalValueObject(obj) {
14497
+ if (typeof obj !== "object" || obj === null) {
14498
+ return false;
14499
+ }
14500
+ if (!obj.hasOwnProperty(TYPE_CONSTANT)) {
14501
+ return false;
14502
+ }
14503
+ const type = obj[TYPE_CONSTANT];
14504
+ const hasTypeProperty = Object.values({ ...PrimitiveType, ...NonPrimitiveType }).includes(type);
14505
+ if (!hasTypeProperty) {
14506
+ return false;
14507
+ }
14508
+ if (type !== "null" /* Null */ && type !== "undefined" /* Undefined */) {
14509
+ return obj.hasOwnProperty(VALUE_CONSTANT);
14510
+ }
14511
+ return true;
14512
+ }
14513
+ };
14514
+
14168
14515
  // src/utils/result.ts
14169
14516
  var result_exports = {};
14170
14517
  __export(result_exports, {
@@ -14214,6 +14561,21 @@ var unwrapErr = (result) => {
14214
14561
  }
14215
14562
  };
14216
14563
 
14564
+ // src/utils/serialize.ts
14565
+ function serializeProperty(value) {
14566
+ if (["string", "boolean", "undefined"].includes(typeof value) || typeof value === "number" && value !== Infinity && value !== -Infinity && !isNaN(value)) {
14567
+ return value;
14568
+ }
14569
+ const arg = LocalValue.getArgument(value);
14570
+ return SERIALIZED_PREFIX + btoa(JSON.stringify(arg));
14571
+ }
14572
+ function deserializeProperty(value) {
14573
+ if (typeof value !== "string" || !value.startsWith(SERIALIZED_PREFIX)) {
14574
+ return value;
14575
+ }
14576
+ return RemoteValue.fromLocalValue(JSON.parse(atob(value.slice(SERIALIZED_PREFIX.length))));
14577
+ }
14578
+
14217
14579
  // src/utils/util.ts
14218
14580
  var lowerPathParam = (fn) => (p) => fn(p.toLowerCase());
14219
14581
  var isDtsFile = lowerPathParam((p) => p.endsWith(".d.ts") || p.endsWith(".d.mts") || p.endsWith(".d.cts"));
@@ -15689,8 +16051,10 @@ function removeScripts(elm) {
15689
16051
  }
15690
16052
  export {
15691
16053
  createWindowFromHtml,
16054
+ deserializeProperty,
15692
16055
  hydrateDocument,
15693
16056
  renderToString,
15694
16057
  serializeDocumentToString,
16058
+ serializeProperty,
15695
16059
  streamToString
15696
16060
  };
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stencil/core/internal",
3
- "version": "4.28.2",
3
+ "version": "4.29.0",
4
4
  "description": "Stencil internals only to be imported by the Stencil Compiler. Breaking changes can and will happen at any time.",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",