@stencil/core 4.37.1 → 4.38.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.
Files changed (41) hide show
  1. package/cli/index.cjs +2 -2
  2. package/cli/index.js +2 -2
  3. package/cli/package.json +1 -1
  4. package/compiler/package.json +1 -1
  5. package/compiler/stencil.js +337 -169
  6. package/dev-server/client/index.js +1 -1
  7. package/dev-server/client/package.json +1 -1
  8. package/dev-server/connector.html +2 -2
  9. package/dev-server/index.js +1 -1
  10. package/dev-server/package.json +1 -1
  11. package/dev-server/server-process.js +3 -3
  12. package/internal/app-data/index.cjs +1 -1
  13. package/internal/app-data/index.js +1 -1
  14. package/internal/app-data/package.json +1 -1
  15. package/internal/app-globals/package.json +1 -1
  16. package/internal/client/index.js +95 -46
  17. package/internal/client/package.json +1 -1
  18. package/internal/client/patch-browser.js +1 -1
  19. package/internal/hydrate/index.js +116 -64
  20. package/internal/hydrate/package.json +1 -1
  21. package/internal/hydrate/runner.d.ts +2 -0
  22. package/internal/hydrate/runner.js +1 -1
  23. package/internal/package.json +1 -1
  24. package/internal/stencil-core/index.d.ts +2 -0
  25. package/internal/stencil-private.d.ts +33 -8
  26. package/internal/stencil-public-compiler.d.ts +5 -0
  27. package/internal/stencil-public-runtime.d.ts +16 -2
  28. package/internal/testing/index.js +91 -44
  29. package/internal/testing/package.json +1 -1
  30. package/mock-doc/index.cjs +1 -1
  31. package/mock-doc/index.js +1 -1
  32. package/mock-doc/package.json +1 -1
  33. package/package.json +1 -1
  34. package/screenshot/index.js +2 -2
  35. package/screenshot/package.json +1 -1
  36. package/screenshot/pixel-match.js +1 -1
  37. package/sys/node/index.js +34 -34
  38. package/sys/node/package.json +1 -1
  39. package/sys/node/worker.js +1 -1
  40. package/testing/index.js +22 -12
  41. package/testing/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  /*
2
- Stencil Client Platform v4.37.1 | MIT Licensed | https://stenciljs.com
2
+ Stencil Client Platform v4.38.0 | MIT Licensed | https://stenciljs.com
3
3
  */
4
4
  var __defProp = Object.defineProperty;
5
5
  var __export = (target, all) => {
@@ -104,7 +104,8 @@ var registerHost = (hostElement, cmpMeta) => {
104
104
  $flags$: 0,
105
105
  $hostElement$: hostElement,
106
106
  $cmpMeta$: cmpMeta,
107
- $instanceValues$: /* @__PURE__ */ new Map()
107
+ $instanceValues$: /* @__PURE__ */ new Map(),
108
+ $serializerValues$: /* @__PURE__ */ new Map()
108
109
  };
109
110
  if (BUILD3.isDev) {
110
111
  hostRef.$renderCount$ = 0;
@@ -117,6 +118,9 @@ var registerHost = (hostElement, cmpMeta) => {
117
118
  hostElement["s-p"] = [];
118
119
  hostElement["s-rc"] = [];
119
120
  }
121
+ if (BUILD3.lazyLoad) {
122
+ hostRef.$fetchedCbList$ = [];
123
+ }
120
124
  const ref = hostRef;
121
125
  hostElement.__stencil__getHostRef = () => ref;
122
126
  if (!BUILD3.lazyLoad && BUILD3.modernPropertyDecls && (BUILD3.state || BUILD3.prop)) {
@@ -1140,11 +1144,13 @@ var inspect = (ref) => {
1140
1144
  needsRerender: !!(flags & 512 /* needsRerender */)
1141
1145
  },
1142
1146
  instanceValues: hostRef.$instanceValues$,
1147
+ serializerValues: hostRef.$serializerValues$,
1143
1148
  ancestorComponent: hostRef.$ancestorComponent$,
1144
1149
  hostElement,
1145
1150
  lazyInstance: hostRef.$lazyInstance$,
1146
1151
  vnode: hostRef.$vnode$,
1147
1152
  modeName: hostRef.$modeName$,
1153
+ fetchedCbList: hostRef.$fetchedCbList$,
1148
1154
  onReadyPromise: hostRef.$onReadyPromise$,
1149
1155
  onReadyResolve: hostRef.$onReadyResolve$,
1150
1156
  onInstancePromise: hostRef.$onInstancePromise$,
@@ -1441,7 +1447,7 @@ var validateInputProperties = (inputElm) => {
1441
1447
 
1442
1448
  // src/runtime/client-hydrate.ts
1443
1449
  var initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
1444
- var _a, _b, _c;
1450
+ var _a, _b;
1445
1451
  const endHydrate = createTime("hydrateClient", tagName);
1446
1452
  const shadowRoot = hostElm.shadowRoot;
1447
1453
  const childRenderNodes = [];
@@ -1450,23 +1456,6 @@ var initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
1450
1456
  const shadowRootNodes = BUILD14.shadowDom && shadowRoot ? [] : null;
1451
1457
  const vnode = newVNode(tagName, null);
1452
1458
  vnode.$elm$ = hostElm;
1453
- const members = Object.entries(((_a = hostRef.$cmpMeta$) == null ? void 0 : _a.$members$) || {});
1454
- members.forEach(([memberName, [memberFlags, metaAttributeName]]) => {
1455
- var _a2, _b2;
1456
- if (!(memberFlags & 31 /* Prop */)) {
1457
- return;
1458
- }
1459
- const attributeName = metaAttributeName || memberName;
1460
- const attrVal = hostElm.getAttribute(attributeName);
1461
- if (attrVal !== null) {
1462
- const attrPropVal = parsePropertyValue(
1463
- attrVal,
1464
- memberFlags,
1465
- BUILD14.formAssociated && !!(((_a2 = hostRef.$cmpMeta$) == null ? void 0 : _a2.$flags$) & 64 /* formAssociated */)
1466
- );
1467
- (_b2 = hostRef == null ? void 0 : hostRef.$instanceValues$) == null ? void 0 : _b2.set(memberName, attrPropVal);
1468
- }
1469
- });
1470
1459
  let scopeId2;
1471
1460
  if (BUILD14.scoped) {
1472
1461
  const cmpMeta = hostRef.$cmpMeta$;
@@ -1505,7 +1494,7 @@ var initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
1505
1494
  if (childRenderNode.$tag$ === "slot") {
1506
1495
  node["s-cr"] = hostElm["s-cr"];
1507
1496
  }
1508
- } else if (((_b = childRenderNode.$tag$) == null ? void 0 : _b.toString().includes("-")) && childRenderNode.$tag$ !== "slot-fb" && !childRenderNode.$elm$.shadowRoot) {
1497
+ } else if (((_a = childRenderNode.$tag$) == null ? void 0 : _a.toString().includes("-")) && childRenderNode.$tag$ !== "slot-fb" && !childRenderNode.$elm$.shadowRoot) {
1509
1498
  const cmpMeta = getHostRef(childRenderNode.$elm$);
1510
1499
  if (cmpMeta) {
1511
1500
  const scopeId3 = getScopeId(
@@ -1576,7 +1565,7 @@ var initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
1576
1565
  }
1577
1566
  }
1578
1567
  addSlotRelocateNode(slottedItem.node, slottedItem.slot, false, slottedItem.node["s-oo"]);
1579
- if (((_c = slottedItem.node.parentElement) == null ? void 0 : _c.shadowRoot) && slottedItem.node["getAttribute"] && slottedItem.node.getAttribute("slot")) {
1568
+ if (((_b = slottedItem.node.parentElement) == null ? void 0 : _b.shadowRoot) && slottedItem.node["getAttribute"] && slottedItem.node.getAttribute("slot")) {
1580
1569
  slottedItem.node.removeAttribute("slot");
1581
1570
  }
1582
1571
  if (BUILD14.experimentalSlotFixes) {
@@ -2999,9 +2988,13 @@ render() {
2999
2988
  }
3000
2989
  if (BUILD20.reflect && cmpMeta.$attrsToReflect$) {
3001
2990
  rootVnode.$attrs$ = rootVnode.$attrs$ || {};
3002
- cmpMeta.$attrsToReflect$.map(
3003
- ([propName, attribute]) => rootVnode.$attrs$[attribute] = hostElm[propName]
3004
- );
2991
+ cmpMeta.$attrsToReflect$.forEach(([propName, attribute]) => {
2992
+ if (BUILD20.serializer && hostRef.$serializerValues$.has(propName)) {
2993
+ rootVnode.$attrs$[attribute] = hostRef.$serializerValues$.get(propName);
2994
+ } else {
2995
+ rootVnode.$attrs$[attribute] = hostElm[propName];
2996
+ }
2997
+ });
3005
2998
  }
3006
2999
  if (isInitialLoad && rootVnode.$attrs$) {
3007
3000
  for (const key of Object.keys(rootVnode.$attrs$)) {
@@ -3156,11 +3149,16 @@ var dispatchHooks = (hostRef, isInitialLoad) => {
3156
3149
  }
3157
3150
  let maybePromise;
3158
3151
  if (isInitialLoad) {
3159
- if (BUILD21.lazyLoad && BUILD21.hostListener) {
3160
- hostRef.$flags$ |= 256 /* isListenReady */;
3161
- if (hostRef.$queuedListeners$) {
3162
- hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event, elm));
3163
- hostRef.$queuedListeners$ = void 0;
3152
+ if (BUILD21.lazyLoad) {
3153
+ if (BUILD21.hostListener) {
3154
+ hostRef.$flags$ |= 256 /* isListenReady */;
3155
+ if (hostRef.$queuedListeners$) {
3156
+ hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event, elm));
3157
+ hostRef.$queuedListeners$ = void 0;
3158
+ }
3159
+ }
3160
+ if (hostRef.$fetchedCbList$.length) {
3161
+ hostRef.$fetchedCbList$.forEach((cb) => cb(elm));
3164
3162
  }
3165
3163
  }
3166
3164
  emitLifecycleEvent(elm, "componentWillLoad");
@@ -3408,6 +3406,9 @@ var setValue = (ref, propName, newVal, cmpMeta) => {
3408
3406
  `Couldn't find host element for "${cmpMeta.$tagName$}" as it is unknown to this Stencil runtime. This usually happens when integrating a 3rd party Stencil component with another Stencil component or application. Please reach out to the maintainers of the 3rd party Stencil component or report this on the Stencil Discord server (https://chat.stenciljs.com) or comment on this similar [GitHub issue](https://github.com/stenciljs/core/issues/5457).`
3409
3407
  );
3410
3408
  }
3409
+ if (BUILD22.serializer && hostRef.$serializerValues$.has(propName) && hostRef.$serializerValues$.get(propName) === newVal) {
3410
+ return;
3411
+ }
3411
3412
  const elm = BUILD22.lazyLoad ? hostRef.$hostElement$ : ref;
3412
3413
  const oldVal = hostRef.$instanceValues$.get(propName);
3413
3414
  const flags = hostRef.$flags$;
@@ -3421,6 +3422,15 @@ var setValue = (ref, propName, newVal, cmpMeta) => {
3421
3422
  const didValueChange = newVal !== oldVal && !areBothNaN;
3422
3423
  if ((!BUILD22.lazyLoad || !(flags & 8 /* isConstructingInstance */) || oldVal === void 0) && didValueChange) {
3423
3424
  hostRef.$instanceValues$.set(propName, newVal);
3425
+ if (BUILD22.serializer && BUILD22.reflect && cmpMeta.$attrsToReflect$) {
3426
+ if (instance && cmpMeta.$serializers$ && cmpMeta.$serializers$[propName]) {
3427
+ let attrVal = newVal;
3428
+ for (const methodName of cmpMeta.$serializers$[propName]) {
3429
+ attrVal = instance[methodName](attrVal, propName);
3430
+ }
3431
+ hostRef.$serializerValues$.set(propName, attrVal);
3432
+ }
3433
+ }
3424
3434
  if (BUILD22.isDev) {
3425
3435
  if (hostRef.$flags$ & 1024 /* devOnRender */) {
3426
3436
  consoleDevWarn(
@@ -3445,7 +3455,7 @@ var setValue = (ref, propName, newVal, cmpMeta) => {
3445
3455
  }
3446
3456
  }
3447
3457
  if (!BUILD22.lazyLoad || instance) {
3448
- if (BUILD22.watchCallback && cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
3458
+ if (BUILD22.propChangeCallback && cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
3449
3459
  const watchMethods = cmpMeta.$watchers$[propName];
3450
3460
  if (watchMethods) {
3451
3461
  watchMethods.map((watchMethodName) => {
@@ -3500,9 +3510,17 @@ var proxyComponent = (Cstr, cmpMeta, flags) => {
3500
3510
  });
3501
3511
  });
3502
3512
  }
3503
- if (BUILD23.member && cmpMeta.$members$ || BUILD23.watchCallback && (cmpMeta.$watchers$ || Cstr.watchers)) {
3504
- if (BUILD23.watchCallback && Cstr.watchers && !cmpMeta.$watchers$) {
3505
- cmpMeta.$watchers$ = Cstr.watchers;
3513
+ if (BUILD23.member && cmpMeta.$members$ || BUILD23.propChangeCallback) {
3514
+ if (BUILD23.propChangeCallback) {
3515
+ if (Cstr.watchers && !cmpMeta.$watchers$) {
3516
+ cmpMeta.$watchers$ = Cstr.watchers;
3517
+ }
3518
+ if (Cstr.deserializers && !cmpMeta.$deserializers$) {
3519
+ cmpMeta.$deserializers$ = Cstr.deserializers;
3520
+ }
3521
+ if (Cstr.serializers && !cmpMeta.$serializers$) {
3522
+ cmpMeta.$serializers$ = Cstr.serializers;
3523
+ }
3506
3524
  }
3507
3525
  const members = Object.entries((_a = cmpMeta.$members$) != null ? _a : {});
3508
3526
  members.map(([memberName, [memberFlags]]) => {
@@ -3555,8 +3573,6 @@ More information: https://stenciljs.com/docs/properties#prop-mutability`
3555
3573
  const currentValue = memberFlags & 32 /* State */ ? this[memberName] : ref.$hostElement$[memberName];
3556
3574
  if (typeof currentValue === "undefined" && ref.$instanceValues$.get(memberName)) {
3557
3575
  newValue = ref.$instanceValues$.get(memberName);
3558
- } else if (!ref.$instanceValues$.get(memberName) && currentValue) {
3559
- ref.$instanceValues$.set(memberName, currentValue);
3560
3576
  }
3561
3577
  origSetter.apply(this, [
3562
3578
  parsePropertyValue(
@@ -3577,7 +3593,7 @@ More information: https://stenciljs.com/docs/properties#prop-mutability`
3577
3593
  if ((flags & 1 /* isElementConstructor */) === 0 || (cmpMeta.$members$[memberName][0] & 4096 /* Setter */) === 0) {
3578
3594
  setValue(this, memberName, newValue, cmpMeta);
3579
3595
  if (flags & 1 /* isElementConstructor */ && !ref.$lazyInstance$) {
3580
- ref.$onReadyPromise$.then(() => {
3596
+ ref.$fetchedCbList$.push(() => {
3581
3597
  if (cmpMeta.$members$[memberName][0] & 4096 /* Setter */ && ref.$lazyInstance$[memberName] !== ref.$instanceValues$.get(memberName)) {
3582
3598
  ref.$lazyInstance$[memberName] = newValue;
3583
3599
  }
@@ -3600,7 +3616,9 @@ More information: https://stenciljs.com/docs/properties#prop-mutability`
3600
3616
  if (ref.$lazyInstance$) {
3601
3617
  setterSetVal();
3602
3618
  } else {
3603
- ref.$onReadyPromise$.then(() => setterSetVal());
3619
+ ref.$fetchedCbList$.push(() => {
3620
+ setterSetVal();
3621
+ });
3604
3622
  }
3605
3623
  }
3606
3624
  }
@@ -3624,14 +3642,39 @@ More information: https://stenciljs.com/docs/properties#prop-mutability`
3624
3642
  plt.jmp(() => {
3625
3643
  var _a2;
3626
3644
  const propName = attrNameToPropName.get(attrName);
3645
+ const hostRef = getHostRef(this);
3646
+ if (BUILD23.serializer && hostRef.$serializerValues$.has(propName) && hostRef.$serializerValues$.get(propName) === newValue) {
3647
+ return;
3648
+ }
3627
3649
  if (this.hasOwnProperty(propName) && BUILD23.lazyLoad) {
3628
3650
  newValue = this[propName];
3629
3651
  delete this[propName];
3652
+ }
3653
+ if (BUILD23.deserializer && cmpMeta.$deserializers$ && cmpMeta.$deserializers$[propName]) {
3654
+ const setVal = (methodName, instance) => {
3655
+ const deserializeVal = instance == null ? void 0 : instance[methodName](newValue, propName);
3656
+ if (deserializeVal !== this[propName]) {
3657
+ this[propName] = deserializeVal;
3658
+ }
3659
+ };
3660
+ for (const methodName of cmpMeta.$deserializers$[propName]) {
3661
+ if (BUILD23.lazyLoad) {
3662
+ if (hostRef.$lazyInstance$) {
3663
+ setVal(methodName, hostRef.$lazyInstance$);
3664
+ } else {
3665
+ hostRef.$fetchedCbList$.push(() => {
3666
+ setVal(methodName, hostRef.$lazyInstance$);
3667
+ });
3668
+ }
3669
+ } else {
3670
+ setVal(methodName, this);
3671
+ }
3672
+ }
3673
+ return;
3630
3674
  } else if (prototype.hasOwnProperty(propName) && typeof this[propName] === "number" && // cast type to number to avoid TS compiler issues
3631
3675
  this[propName] == newValue) {
3632
3676
  return;
3633
3677
  } else if (propName == null) {
3634
- const hostRef = getHostRef(this);
3635
3678
  const flags2 = hostRef == null ? void 0 : hostRef.$flags$;
3636
3679
  if (hostRef && flags2 && !(flags2 & 8 /* isConstructingInstance */) && flags2 & 128 /* isWatchReady */ && newValue !== oldValue) {
3637
3680
  const elm = BUILD23.lazyLoad ? hostRef.$hostElement$ : this;
@@ -3647,7 +3690,7 @@ More information: https://stenciljs.com/docs/properties#prop-mutability`
3647
3690
  }
3648
3691
  const propDesc = Object.getOwnPropertyDescriptor(prototype, propName);
3649
3692
  newValue = newValue === null && typeof this[propName] === "boolean" ? false : newValue;
3650
- if (newValue !== this[propName] && (!propDesc.get || !!propDesc.set)) {
3693
+ if (newValue != this[propName] && (!propDesc.get || !!propDesc.set)) {
3651
3694
  this[propName] = newValue;
3652
3695
  }
3653
3696
  });
@@ -3693,8 +3736,10 @@ var initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
3693
3736
  throw new Error(`Constructor for "${cmpMeta.$tagName$}#${hostRef.$modeName$}" was not found`);
3694
3737
  }
3695
3738
  if (BUILD24.member && !Cstr.isProxied) {
3696
- if (BUILD24.watchCallback) {
3739
+ if (BUILD24.propChangeCallback) {
3697
3740
  cmpMeta.$watchers$ = Cstr.watchers;
3741
+ cmpMeta.$serializers$ = Cstr.serializers;
3742
+ cmpMeta.$deserializers$ = Cstr.deserializers;
3698
3743
  }
3699
3744
  proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
3700
3745
  Cstr.isProxied = true;
@@ -3711,7 +3756,7 @@ var initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
3711
3756
  if (BUILD24.member) {
3712
3757
  hostRef.$flags$ &= ~8 /* isConstructingInstance */;
3713
3758
  }
3714
- if (BUILD24.watchCallback) {
3759
+ if (BUILD24.propChangeCallback) {
3715
3760
  hostRef.$flags$ |= 128 /* isWatchReady */;
3716
3761
  }
3717
3762
  endNewInstance();
@@ -3808,7 +3853,7 @@ var connectedCallback = (elm) => {
3808
3853
  }
3809
3854
  if (BUILD25.prop && !BUILD25.hydrateServerSide && cmpMeta.$members$) {
3810
3855
  Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
3811
- if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
3856
+ if (memberFlags & 31 /* Prop */ && memberName in elm && elm[memberName] !== Object.prototype[memberName]) {
3812
3857
  const value = elm[memberName];
3813
3858
  delete elm[memberName];
3814
3859
  elm[memberName] = value;
@@ -3889,8 +3934,10 @@ var proxyCustomElement = (Cstr, compactMeta) => {
3889
3934
  if (BUILD27.hostListener) {
3890
3935
  cmpMeta.$listeners$ = compactMeta[3];
3891
3936
  }
3892
- if (BUILD27.watchCallback) {
3937
+ if (BUILD27.propChangeCallback) {
3893
3938
  cmpMeta.$watchers$ = Cstr.$watchers$;
3939
+ cmpMeta.$deserializers$ = Cstr.$deserializers$;
3940
+ cmpMeta.$serializers$ = Cstr.$serializers$;
3894
3941
  }
3895
3942
  if (BUILD27.reflect) {
3896
3943
  cmpMeta.$attrsToReflect$ = [];
@@ -4038,7 +4085,7 @@ var bootstrapLazy = (lazyBundles, options = {}) => {
4038
4085
  let hasSlotRelocation = false;
4039
4086
  lazyBundles.map((lazyBundle) => {
4040
4087
  lazyBundle[1].map((compactMeta) => {
4041
- var _a2;
4088
+ var _a2, _b, _c;
4042
4089
  const cmpMeta = {
4043
4090
  $flags$: compactMeta[0],
4044
4091
  $tagName$: compactMeta[1],
@@ -4057,8 +4104,10 @@ var bootstrapLazy = (lazyBundles, options = {}) => {
4057
4104
  if (BUILD28.reflect) {
4058
4105
  cmpMeta.$attrsToReflect$ = [];
4059
4106
  }
4060
- if (BUILD28.watchCallback) {
4107
+ if (BUILD28.propChangeCallback) {
4061
4108
  cmpMeta.$watchers$ = (_a2 = compactMeta[4]) != null ? _a2 : {};
4109
+ cmpMeta.$serializers$ = (_b = compactMeta[5]) != null ? _b : {};
4110
+ cmpMeta.$deserializers$ = (_c = compactMeta[6]) != null ? _c : {};
4062
4111
  }
4063
4112
  if (BUILD28.shadowDom && !supportsShadow && cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
4064
4113
  cmpMeta.$flags$ |= 8 /* needsShadowDomShim */;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stencil/core/internal/client",
3
- "version": "4.37.1",
3
+ "version": "4.38.0",
4
4
  "description": "Stencil internal client platform to be imported by the Stencil Compiler and internal runtime. Breaking changes can and will happen at any time.",
5
5
  "main": "./index.js",
6
6
  "exports": "./index.js",
@@ -1,5 +1,5 @@
1
1
  /*
2
- Stencil Client Patch Browser v4.37.1 | MIT Licensed | https://stenciljs.com
2
+ Stencil Client Patch Browser v4.38.0 | MIT Licensed | https://stenciljs.com
3
3
  */
4
4
 
5
5
  // src/client/client-patch-browser.ts