@stencil/core 4.28.2-dev.1742303553.90ea840 → 4.28.2-dev.1742318817.ddf403c

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-dev.1742303553.90ea840 | MIT Licensed | https://stenciljs.com
2
+ Stencil Hydrate Platform v4.28.2-dev.1742318817.ddf403c | MIT Licensed | https://stenciljs.com
3
3
  */
4
4
  var __defProp = Object.defineProperty;
5
5
  var __export = (target, all) => {
@@ -138,6 +138,131 @@ import { BUILD as BUILD18 } from "@stencil/core/internal/app-data";
138
138
  // src/runtime/client-hydrate.ts
139
139
  import { BUILD as BUILD6 } from "@stencil/core/internal/app-data";
140
140
 
141
+ // src/hydrate/runner/serialize.ts
142
+ var PrimitiveType = /* @__PURE__ */ ((PrimitiveType2) => {
143
+ PrimitiveType2["Undefined"] = "undefined";
144
+ PrimitiveType2["Null"] = "null";
145
+ PrimitiveType2["String"] = "string";
146
+ PrimitiveType2["Number"] = "number";
147
+ PrimitiveType2["SpecialNumber"] = "number";
148
+ PrimitiveType2["Boolean"] = "boolean";
149
+ PrimitiveType2["BigInt"] = "bigint";
150
+ return PrimitiveType2;
151
+ })(PrimitiveType || {});
152
+ var NonPrimitiveType = /* @__PURE__ */ ((NonPrimitiveType2) => {
153
+ NonPrimitiveType2["Array"] = "array";
154
+ NonPrimitiveType2["Date"] = "date";
155
+ NonPrimitiveType2["Map"] = "map";
156
+ NonPrimitiveType2["Object"] = "object";
157
+ NonPrimitiveType2["RegularExpression"] = "regexp";
158
+ NonPrimitiveType2["Set"] = "set";
159
+ NonPrimitiveType2["Channel"] = "channel";
160
+ NonPrimitiveType2["Symbol"] = "symbol";
161
+ return NonPrimitiveType2;
162
+ })(NonPrimitiveType || {});
163
+ var TYPE_CONSTANT = "type";
164
+ var VALUE_CONSTANT = "value";
165
+ var SERIALIZED_PREFIX = "serialized:";
166
+ function deserializeProperty(value) {
167
+ if (typeof value !== "string" || !value.startsWith(SERIALIZED_PREFIX)) {
168
+ return value;
169
+ }
170
+ return RemoteValue.fromLocalValue(JSON.parse(atob(value.slice(SERIALIZED_PREFIX.length))));
171
+ }
172
+ var RemoteValue = class _RemoteValue {
173
+ /**
174
+ * Deserializes a LocalValue serialized object back to its original JavaScript representation
175
+ *
176
+ * @param serialized The serialized LocalValue object
177
+ * @returns The original JavaScript value/object
178
+ */
179
+ static fromLocalValue(serialized) {
180
+ const type = serialized[TYPE_CONSTANT];
181
+ const value = VALUE_CONSTANT in serialized ? serialized[VALUE_CONSTANT] : void 0;
182
+ switch (type) {
183
+ case "string" /* String */:
184
+ return value;
185
+ case "boolean" /* Boolean */:
186
+ return value;
187
+ case "bigint" /* BigInt */:
188
+ return BigInt(value);
189
+ case "undefined" /* Undefined */:
190
+ return void 0;
191
+ case "null" /* Null */:
192
+ return null;
193
+ case "number" /* Number */:
194
+ if (value === "NaN") return NaN;
195
+ if (value === "-0") return -0;
196
+ if (value === "Infinity") return Infinity;
197
+ if (value === "-Infinity") return -Infinity;
198
+ return value;
199
+ case "array" /* Array */:
200
+ return value.map((item) => _RemoteValue.fromLocalValue(item));
201
+ case "date" /* Date */:
202
+ return new Date(value);
203
+ case "map" /* Map */:
204
+ const map2 = /* @__PURE__ */ new Map();
205
+ for (const [key, val] of value) {
206
+ const deserializedKey = typeof key === "object" && key !== null ? _RemoteValue.fromLocalValue(key) : key;
207
+ const deserializedValue = _RemoteValue.fromLocalValue(val);
208
+ map2.set(deserializedKey, deserializedValue);
209
+ }
210
+ return map2;
211
+ case "object" /* Object */:
212
+ const obj = {};
213
+ for (const [key, val] of value) {
214
+ obj[key] = _RemoteValue.fromLocalValue(val);
215
+ }
216
+ return obj;
217
+ case "regexp" /* RegularExpression */:
218
+ const { pattern, flags } = value;
219
+ return new RegExp(pattern, flags);
220
+ case "set" /* Set */:
221
+ const set = /* @__PURE__ */ new Set();
222
+ for (const item of value) {
223
+ set.add(_RemoteValue.fromLocalValue(item));
224
+ }
225
+ return set;
226
+ case "symbol" /* Symbol */:
227
+ return Symbol(value);
228
+ default:
229
+ throw new Error(`Unsupported type: ${type}`);
230
+ }
231
+ }
232
+ /**
233
+ * Utility method to deserialize multiple LocalValues at once
234
+ *
235
+ * @param serializedValues Array of serialized LocalValue objects
236
+ * @returns Array of deserialized JavaScript values
237
+ */
238
+ static fromLocalValueArray(serializedValues) {
239
+ return serializedValues.map((value) => _RemoteValue.fromLocalValue(value));
240
+ }
241
+ /**
242
+ * Verifies if the given object matches the structure of a serialized LocalValue
243
+ *
244
+ * @param obj Object to verify
245
+ * @returns boolean indicating if the object has LocalValue structure
246
+ */
247
+ static isLocalValueObject(obj) {
248
+ if (typeof obj !== "object" || obj === null) {
249
+ return false;
250
+ }
251
+ if (!obj.hasOwnProperty(TYPE_CONSTANT)) {
252
+ return false;
253
+ }
254
+ const type = obj[TYPE_CONSTANT];
255
+ const hasTypeProperty = Object.values({ ...PrimitiveType, ...NonPrimitiveType }).includes(type);
256
+ if (!hasTypeProperty) {
257
+ return false;
258
+ }
259
+ if (type !== "null" /* Null */ && type !== "undefined" /* Undefined */) {
260
+ return obj.hasOwnProperty(VALUE_CONSTANT);
261
+ }
262
+ return true;
263
+ }
264
+ };
265
+
141
266
  // src/runtime/dom-extras.ts
142
267
  import { BUILD as BUILD3 } from "@stencil/core/internal/app-data";
143
268
 
@@ -912,6 +1037,7 @@ var validateInputProperties = (inputElm) => {
912
1037
 
913
1038
  // src/runtime/client-hydrate.ts
914
1039
  var initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
1040
+ var _a;
915
1041
  const endHydrate = createTime("hydrateClient", tagName);
916
1042
  const shadowRoot = hostElm.shadowRoot;
917
1043
  const childRenderNodes = [];
@@ -920,6 +1046,29 @@ var initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
920
1046
  const shadowRootNodes = BUILD6.shadowDom && shadowRoot ? [] : null;
921
1047
  const vnode = newVNode(tagName, null);
922
1048
  vnode.$elm$ = hostElm;
1049
+ let attributes;
1050
+ const members = Object.entries(((_a = hostRef.$cmpMeta$) == null ? void 0 : _a.$members$) || {});
1051
+ members.forEach(([memberName, [memberFlags, metaAttributeName]]) => {
1052
+ if (!(memberFlags & 31 /* Prop */)) {
1053
+ return;
1054
+ }
1055
+ const attributeName = metaAttributeName || memberName;
1056
+ let attrValue = hostElm.getAttribute(attributeName);
1057
+ if ((attrValue == null ? void 0 : attrValue.startsWith("{")) && attrValue.endsWith("}") || (attrValue == null ? void 0 : attrValue.startsWith("[")) && attrValue.endsWith("]")) {
1058
+ try {
1059
+ attrValue = JSON.parse(attrValue);
1060
+ } catch (e) {
1061
+ }
1062
+ } else if (attrValue == null ? void 0 : attrValue.startsWith(SERIALIZED_PREFIX)) {
1063
+ attrValue = deserializeProperty(attrValue);
1064
+ }
1065
+ if (!attributes) {
1066
+ attributes = {};
1067
+ }
1068
+ attributes[attributeName] = attrValue;
1069
+ hostRef.$instanceValues$.set(attributeName, attrValue);
1070
+ });
1071
+ vnode.$attrs$ = attributes;
923
1072
  let scopeId2;
924
1073
  if (BUILD6.scoped) {
925
1074
  const cmpMeta = hostRef.$cmpMeta$;
@@ -2452,7 +2601,11 @@ var renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
2452
2601
  const hostElm = hostRef.$hostElement$;
2453
2602
  const cmpMeta = hostRef.$cmpMeta$;
2454
2603
  const oldVNode = hostRef.$vnode$ || newVNode(null, null);
2455
- const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
2604
+ const isHostElem = isHost(renderFnResults);
2605
+ const rootVnode = isHostElem ? renderFnResults : h(null, null, renderFnResults);
2606
+ if (isInitialLoad && !isHostElem && hostRef.$vnode$) {
2607
+ rootVnode.$attrs$ = hostRef.$vnode$.$attrs$ || {};
2608
+ }
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.
@@ -3853,129 +4006,6 @@ import { globalScripts } from "@stencil/core/internal/app-globals";
3853
4006
 
3854
4007
  // src/hydrate/platform/proxy-host-element.ts
3855
4008
  import { BUILD as BUILD23 } from "@stencil/core/internal/app-data";
3856
-
3857
- // src/hydrate/runner/serialize.ts
3858
- var PrimitiveType = /* @__PURE__ */ ((PrimitiveType2) => {
3859
- PrimitiveType2["Undefined"] = "undefined";
3860
- PrimitiveType2["Null"] = "null";
3861
- PrimitiveType2["String"] = "string";
3862
- PrimitiveType2["Number"] = "number";
3863
- PrimitiveType2["SpecialNumber"] = "number";
3864
- PrimitiveType2["Boolean"] = "boolean";
3865
- PrimitiveType2["BigInt"] = "bigint";
3866
- return PrimitiveType2;
3867
- })(PrimitiveType || {});
3868
- var NonPrimitiveType = /* @__PURE__ */ ((NonPrimitiveType2) => {
3869
- NonPrimitiveType2["Array"] = "array";
3870
- NonPrimitiveType2["Date"] = "date";
3871
- NonPrimitiveType2["Map"] = "map";
3872
- NonPrimitiveType2["Object"] = "object";
3873
- NonPrimitiveType2["RegularExpression"] = "regexp";
3874
- NonPrimitiveType2["Set"] = "set";
3875
- NonPrimitiveType2["Channel"] = "channel";
3876
- NonPrimitiveType2["Symbol"] = "symbol";
3877
- return NonPrimitiveType2;
3878
- })(NonPrimitiveType || {});
3879
- var TYPE_CONSTANT = "type";
3880
- var VALUE_CONSTANT = "value";
3881
- function deserializeProperty(value) {
3882
- return RemoteValue.fromLocalValue(value);
3883
- }
3884
- var RemoteValue = class _RemoteValue {
3885
- /**
3886
- * Deserializes a LocalValue serialized object back to its original JavaScript representation
3887
- *
3888
- * @param serialized The serialized LocalValue object
3889
- * @returns The original JavaScript value/object
3890
- */
3891
- static fromLocalValue(serialized) {
3892
- const type = serialized[TYPE_CONSTANT];
3893
- const value = VALUE_CONSTANT in serialized ? serialized[VALUE_CONSTANT] : void 0;
3894
- switch (type) {
3895
- case "string" /* String */:
3896
- return value;
3897
- case "boolean" /* Boolean */:
3898
- return value;
3899
- case "bigint" /* BigInt */:
3900
- return BigInt(value);
3901
- case "undefined" /* Undefined */:
3902
- return void 0;
3903
- case "null" /* Null */:
3904
- return null;
3905
- case "number" /* Number */:
3906
- if (value === "NaN") return NaN;
3907
- if (value === "-0") return -0;
3908
- if (value === "Infinity") return Infinity;
3909
- if (value === "-Infinity") return -Infinity;
3910
- return value;
3911
- case "array" /* Array */:
3912
- return value.map((item) => _RemoteValue.fromLocalValue(item));
3913
- case "date" /* Date */:
3914
- return new Date(value);
3915
- case "map" /* Map */:
3916
- const map2 = /* @__PURE__ */ new Map();
3917
- for (const [key, val] of value) {
3918
- const deserializedKey = typeof key === "object" && key !== null ? _RemoteValue.fromLocalValue(key) : key;
3919
- const deserializedValue = _RemoteValue.fromLocalValue(val);
3920
- map2.set(deserializedKey, deserializedValue);
3921
- }
3922
- return map2;
3923
- case "object" /* Object */:
3924
- const obj = {};
3925
- for (const [key, val] of value) {
3926
- obj[key] = _RemoteValue.fromLocalValue(val);
3927
- }
3928
- return obj;
3929
- case "regexp" /* RegularExpression */:
3930
- const { pattern, flags } = value;
3931
- return new RegExp(pattern, flags);
3932
- case "set" /* Set */:
3933
- const set = /* @__PURE__ */ new Set();
3934
- for (const item of value) {
3935
- set.add(_RemoteValue.fromLocalValue(item));
3936
- }
3937
- return set;
3938
- case "symbol" /* Symbol */:
3939
- return Symbol(value);
3940
- default:
3941
- throw new Error(`Unsupported type: ${type}`);
3942
- }
3943
- }
3944
- /**
3945
- * Utility method to deserialize multiple LocalValues at once
3946
- *
3947
- * @param serializedValues Array of serialized LocalValue objects
3948
- * @returns Array of deserialized JavaScript values
3949
- */
3950
- static fromLocalValueArray(serializedValues) {
3951
- return serializedValues.map((value) => _RemoteValue.fromLocalValue(value));
3952
- }
3953
- /**
3954
- * Verifies if the given object matches the structure of a serialized LocalValue
3955
- *
3956
- * @param obj Object to verify
3957
- * @returns boolean indicating if the object has LocalValue structure
3958
- */
3959
- static isLocalValueObject(obj) {
3960
- if (typeof obj !== "object" || obj === null) {
3961
- return false;
3962
- }
3963
- if (!obj.hasOwnProperty(TYPE_CONSTANT)) {
3964
- return false;
3965
- }
3966
- const type = obj[TYPE_CONSTANT];
3967
- const hasTypeProperty = Object.values({ ...PrimitiveType, ...NonPrimitiveType }).includes(type);
3968
- if (!hasTypeProperty) {
3969
- return false;
3970
- }
3971
- if (type !== "null" /* Null */ && type !== "undefined" /* Undefined */) {
3972
- return obj.hasOwnProperty(VALUE_CONSTANT);
3973
- }
3974
- return true;
3975
- }
3976
- };
3977
-
3978
- // src/hydrate/platform/proxy-host-element.ts
3979
4009
  function proxyHostElement(elm, cstr) {
3980
4010
  const cmpMeta = cstr.cmpMeta;
3981
4011
  if (typeof elm.componentOnReady !== "function") {
@@ -4005,11 +4035,10 @@ function proxyHostElement(elm, cstr) {
4005
4035
  if ((attrValue == null ? void 0 : attrValue.startsWith("{")) && attrValue.endsWith("}") || (attrValue == null ? void 0 : attrValue.startsWith("[")) && attrValue.endsWith("]")) {
4006
4036
  try {
4007
4037
  attrValue = JSON.parse(attrValue);
4008
- if (TYPE_CONSTANT in attrValue) {
4009
- attrValue = deserializeProperty(attrValue);
4010
- }
4011
4038
  } catch (e) {
4012
4039
  }
4040
+ } else if (attrValue == null ? void 0 : attrValue.startsWith(SERIALIZED_PREFIX)) {
4041
+ attrValue = deserializeProperty(attrValue);
4013
4042
  }
4014
4043
  const { get: origGetter, set: origSetter } = Object.getOwnPropertyDescriptor(cstr.prototype, memberName) || {};
4015
4044
  let attrPropVal;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stencil/core/internal/hydrate",
3
- "version": "4.28.2-dev.1742303553.90ea840",
3
+ "version": "4.28.2-dev.1742318817.ddf403c",
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
@@ -255,66 +255,17 @@ export declare function renderToString(html: string | any, options: SerializeDoc
255
255
  export declare function hydrateDocument(doc: any | string, options?: HydrateDocumentOptions): Promise<HydrateResults>;
256
256
  export declare function hydrateDocument(doc: any | string, options: HydrateDocumentOptions | undefined, asStream?: boolean): Readable;
257
257
  export declare function serializeDocumentToString(doc: Document, opts: HydrateFactoryOptions): string;
258
- export type ScriptLocalValue = ScriptPrimitiveProtocolValue | ScriptArrayLocalValue | ScriptDateLocalValue | ScriptSymbolValue | ScriptMapLocalValue | ScriptObjectLocalValue | ScriptRegExpLocalValue | ScriptSetLocalValue;
259
- export type ScriptListLocalValue = ScriptLocalValue[];
260
- export interface ScriptArrayLocalValue {
261
- type: "array";
262
- value: ScriptListLocalValue;
263
- }
264
- export interface ScriptDateLocalValue {
265
- type: "date";
266
- value: string;
267
- }
268
- export type ScriptMappingLocalValue = (ScriptLocalValue | ScriptLocalValue)[];
269
- export interface ScriptMapLocalValue {
270
- type: "map";
271
- value: ScriptMappingLocalValue;
272
- }
273
- export interface ScriptObjectLocalValue {
274
- type: "object";
275
- value: ScriptMappingLocalValue;
276
- }
277
- export interface ScriptRegExpValue {
278
- pattern: string;
279
- flags?: string;
280
- }
281
- export interface ScriptRegExpLocalValue {
282
- type: "regexp";
283
- value: ScriptRegExpValue;
284
- }
285
- export interface ScriptSetLocalValue {
286
- type: "set";
287
- value: ScriptListLocalValue;
288
- }
289
- export type ScriptPrimitiveProtocolValue = ScriptUndefinedValue | ScriptNullValue | ScriptStringValue | ScriptNumberValue | ScriptBooleanValue | ScriptBigIntValue;
290
- export interface ScriptUndefinedValue {
291
- type: "undefined";
292
- }
293
- export interface ScriptNullValue {
294
- type: "null";
295
- }
296
- export interface ScriptStringValue {
297
- type: "string";
298
- value: string;
299
- }
300
- export interface ScriptSymbolValue {
301
- type: "symbol";
302
- value: string;
303
- }
304
- export type ScriptSpecialNumber = "NaN" | "-0" | "Infinity" | "-Infinity";
305
- export interface ScriptNumberValue {
306
- type: "number";
307
- value: number | ScriptSpecialNumber;
308
- }
309
- export interface ScriptBooleanValue {
310
- type: "boolean";
311
- value: boolean;
312
- }
313
- export interface ScriptBigIntValue {
314
- type: "bigint";
315
- value: string;
316
- }
317
- export declare function serializeProperty(value: unknown): string;
318
- export declare function deserializeProperty(value: ScriptLocalValue): any;
258
+ /**
259
+ * Serialize a value to a string that can be deserialized later.
260
+ * @param {unknown} value - The value to serialize.
261
+ * @returns {string} A string that can be deserialized later.
262
+ */
263
+ export declare function serializeProperty(value: unknown): string | number | boolean;
264
+ /**
265
+ * Deserialize a value from a string that was serialized earlier.
266
+ * @param {string} value - The string to deserialize.
267
+ * @returns {unknown} The deserialized value.
268
+ */
269
+ export declare function deserializeProperty(value: string): any;
319
270
 
320
271
  export {};