@stencil/core 4.28.2-dev.1742308320.adbef04 → 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.1742308320.adbef04 | 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,133 +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
- var SERIALIZED_PREFIX = "serialized:";
3882
- function deserializeProperty(value) {
3883
- if (!value.startsWith(SERIALIZED_PREFIX)) {
3884
- return value;
3885
- }
3886
- return RemoteValue.fromLocalValue(JSON.parse(atob(value.slice(SERIALIZED_PREFIX.length))));
3887
- }
3888
- var RemoteValue = class _RemoteValue {
3889
- /**
3890
- * Deserializes a LocalValue serialized object back to its original JavaScript representation
3891
- *
3892
- * @param serialized The serialized LocalValue object
3893
- * @returns The original JavaScript value/object
3894
- */
3895
- static fromLocalValue(serialized) {
3896
- const type = serialized[TYPE_CONSTANT];
3897
- const value = VALUE_CONSTANT in serialized ? serialized[VALUE_CONSTANT] : void 0;
3898
- switch (type) {
3899
- case "string" /* String */:
3900
- return value;
3901
- case "boolean" /* Boolean */:
3902
- return value;
3903
- case "bigint" /* BigInt */:
3904
- return BigInt(value);
3905
- case "undefined" /* Undefined */:
3906
- return void 0;
3907
- case "null" /* Null */:
3908
- return null;
3909
- case "number" /* Number */:
3910
- if (value === "NaN") return NaN;
3911
- if (value === "-0") return -0;
3912
- if (value === "Infinity") return Infinity;
3913
- if (value === "-Infinity") return -Infinity;
3914
- return value;
3915
- case "array" /* Array */:
3916
- return value.map((item) => _RemoteValue.fromLocalValue(item));
3917
- case "date" /* Date */:
3918
- return new Date(value);
3919
- case "map" /* Map */:
3920
- const map2 = /* @__PURE__ */ new Map();
3921
- for (const [key, val] of value) {
3922
- const deserializedKey = typeof key === "object" && key !== null ? _RemoteValue.fromLocalValue(key) : key;
3923
- const deserializedValue = _RemoteValue.fromLocalValue(val);
3924
- map2.set(deserializedKey, deserializedValue);
3925
- }
3926
- return map2;
3927
- case "object" /* Object */:
3928
- const obj = {};
3929
- for (const [key, val] of value) {
3930
- obj[key] = _RemoteValue.fromLocalValue(val);
3931
- }
3932
- return obj;
3933
- case "regexp" /* RegularExpression */:
3934
- const { pattern, flags } = value;
3935
- return new RegExp(pattern, flags);
3936
- case "set" /* Set */:
3937
- const set = /* @__PURE__ */ new Set();
3938
- for (const item of value) {
3939
- set.add(_RemoteValue.fromLocalValue(item));
3940
- }
3941
- return set;
3942
- case "symbol" /* Symbol */:
3943
- return Symbol(value);
3944
- default:
3945
- throw new Error(`Unsupported type: ${type}`);
3946
- }
3947
- }
3948
- /**
3949
- * Utility method to deserialize multiple LocalValues at once
3950
- *
3951
- * @param serializedValues Array of serialized LocalValue objects
3952
- * @returns Array of deserialized JavaScript values
3953
- */
3954
- static fromLocalValueArray(serializedValues) {
3955
- return serializedValues.map((value) => _RemoteValue.fromLocalValue(value));
3956
- }
3957
- /**
3958
- * Verifies if the given object matches the structure of a serialized LocalValue
3959
- *
3960
- * @param obj Object to verify
3961
- * @returns boolean indicating if the object has LocalValue structure
3962
- */
3963
- static isLocalValueObject(obj) {
3964
- if (typeof obj !== "object" || obj === null) {
3965
- return false;
3966
- }
3967
- if (!obj.hasOwnProperty(TYPE_CONSTANT)) {
3968
- return false;
3969
- }
3970
- const type = obj[TYPE_CONSTANT];
3971
- const hasTypeProperty = Object.values({ ...PrimitiveType, ...NonPrimitiveType }).includes(type);
3972
- if (!hasTypeProperty) {
3973
- return false;
3974
- }
3975
- if (type !== "null" /* Null */ && type !== "undefined" /* Undefined */) {
3976
- return obj.hasOwnProperty(VALUE_CONSTANT);
3977
- }
3978
- return true;
3979
- }
3980
- };
3981
-
3982
- // src/hydrate/platform/proxy-host-element.ts
3983
4009
  function proxyHostElement(elm, cstr) {
3984
4010
  const cmpMeta = cstr.cmpMeta;
3985
4011
  if (typeof elm.componentOnReady !== "function") {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stencil/core/internal/hydrate",
3
- "version": "4.28.2-dev.1742308320.adbef04",
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
@@ -260,7 +260,7 @@ export declare function serializeDocumentToString(doc: Document, opts: HydrateFa
260
260
  * @param {unknown} value - The value to serialize.
261
261
  * @returns {string} A string that can be deserialized later.
262
262
  */
263
- export declare function serializeProperty(value: unknown): string;
263
+ export declare function serializeProperty(value: unknown): string | number | boolean;
264
264
  /**
265
265
  * Deserialize a value from a string that was serialized earlier.
266
266
  * @param {string} value - The string to deserialize.