@stencil/core 5.0.0-beta.1 → 5.0.0-beta.11

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 (32) hide show
  1. package/dist/app-data/index.d.ts +1 -1
  2. package/dist/{client-BRu0GtRn.mjs → client-CdFmjaQa.mjs} +40 -15
  3. package/dist/compiler/browser.d.ts +1 -1
  4. package/dist/compiler/browser.js +77 -41
  5. package/dist/compiler/index.d.mts +1 -1
  6. package/dist/compiler/index.mjs +2 -2
  7. package/dist/compiler/utils/index.d.mts +1 -1
  8. package/dist/{compiler-CJG6qvQt.mjs → compiler-2EypBn_Y.mjs} +346 -122
  9. package/dist/declarations/stencil-public-compiler.d.ts +6 -1
  10. package/dist/declarations/stencil-public-runtime.d.ts +57 -55
  11. package/dist/{index-BXAcVN2j.d.ts → index-BHciXst1.d.ts} +57 -55
  12. package/dist/{index-DmHmu3y0.d.mts → index-CKnzMkZC.d.mts} +1 -1
  13. package/dist/{index-BopBfjPu.d.mts → index-Cw1NW9FW.d.mts} +6 -1
  14. package/dist/index.mjs +1 -1
  15. package/dist/jsx-runtime.mjs +1 -1
  16. package/dist/{node-75gQKkFz.mjs → node-HKfDhPR3.mjs} +1 -1
  17. package/dist/runtime/client/lazy.js +63 -31
  18. package/dist/runtime/client/runtime.d.ts +57 -55
  19. package/dist/runtime/client/runtime.js +63 -31
  20. package/dist/runtime/index.d.ts +1 -1
  21. package/dist/runtime/index.js +63 -31
  22. package/dist/runtime/server/index.d.mts +2 -1
  23. package/dist/runtime/server/index.mjs +83 -44
  24. package/dist/runtime/server/runner.mjs +8 -5
  25. package/dist/signals/index.d.ts +11 -2
  26. package/dist/signals/index.js +11 -1
  27. package/dist/sys/node/index.d.mts +1 -1
  28. package/dist/sys/node/index.mjs +1 -1
  29. package/dist/sys/node/worker.mjs +2 -2
  30. package/dist/testing/index.d.mts +6 -1
  31. package/dist/testing/index.mjs +64 -32
  32. package/package.json +4 -4
@@ -3,7 +3,7 @@ import { MockWindow, setupGlobal } from "@stencil/mock-doc";
3
3
  import "typescript";
4
4
  import fs from "node:fs";
5
5
  import "picomatch";
6
- import { effect, effect as effect$1, signal } from "@preact/signals-core";
6
+ import * as SignalsCore from "@preact/signals-core";
7
7
  import path, { basename, dirname } from "path";
8
8
  import "postcss";
9
9
  import "postcss-safe-parser";
@@ -32,7 +32,7 @@ import "@rollup/pluginutils";
32
32
  import { createHash } from "crypto";
33
33
  import { afterAll, vi } from "vitest";
34
34
  //#region src/version.ts
35
- const version = "5.0.0-beta.1";
35
+ const version = "5.0.0-beta.11";
36
36
  const MEMBER_FLAGS = {
37
37
  String: 1,
38
38
  Number: 2,
@@ -2110,6 +2110,13 @@ const hydrateScopedToShadow = () => {
2110
2110
  registerStyle(scopeId, convertScopedToShadow(styleElements[i].innerHTML), allowCS);
2111
2111
  }
2112
2112
  };
2113
+ //#endregion
2114
+ //#region src/runtime/signals-core.ts
2115
+ const getCore = () => globalThis[Symbol.for("stencil.preact-signals-core")] ??= SignalsCore;
2116
+ const effect = (fn, options) => getCore().effect(fn, options);
2117
+ function signal(value, options) {
2118
+ return getCore().signal(value, options);
2119
+ }
2113
2120
  const getRegistry = () => customElements;
2114
2121
  //#endregion
2115
2122
  //#region src/runtime/vdom/set-accessor.ts
@@ -2154,7 +2161,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
2154
2161
  attrMap.get(memberName)?.();
2155
2162
  if (!signalAttrDisposers.has(elm)) signalAttrDisposers.set(elm, attrMap);
2156
2163
  let prevVal = oldValue;
2157
- attrMap.set(memberName, effect$1(() => {
2164
+ attrMap.set(memberName, effect(() => {
2158
2165
  const curVal = newValue.value;
2159
2166
  setAccessor(elm, memberName, prevVal, curVal, isSvg, flags);
2160
2167
  prevVal = curVal;
@@ -2371,16 +2378,33 @@ const signalNodeDisposers = /* @__PURE__ */ new WeakMap();
2371
2378
  const disposeSignalVNode = (vnode) => {
2372
2379
  const elm = vnode.$elm$;
2373
2380
  if (elm) {
2374
- const dispose = signalNodeDisposers.get(elm);
2375
- if (dispose) {
2376
- dispose();
2377
- signalNodeDisposers.delete(elm);
2378
- }
2381
+ disposeTextSignal(elm);
2379
2382
  disposeAllSignalAttrs(elm);
2380
2383
  }
2381
2384
  vnode.$children$?.forEach(disposeSignalVNode);
2382
2385
  };
2383
2386
  /**
2387
+ * Tear down a text node's signal subscription, if it has one.
2388
+ * @param textNode the text node to unsubscribe
2389
+ */
2390
+ const disposeTextSignal = (textNode) => {
2391
+ const dispose = signalNodeDisposers.get(textNode);
2392
+ if (dispose) {
2393
+ dispose();
2394
+ signalNodeDisposers.delete(textNode);
2395
+ }
2396
+ };
2397
+ /**
2398
+ * Subscribe a text node to a signal, keeping its `data` in sync on every change.
2399
+ * @param textNode the text node to keep in sync
2400
+ * @param textSig the signal to subscribe to
2401
+ */
2402
+ const wireTextSignal = (textNode, textSig) => {
2403
+ signalNodeDisposers.set(textNode, effect(() => {
2404
+ textNode.data = String(textSig.value);
2405
+ }));
2406
+ };
2407
+ /**
2384
2408
  * Create a DOM Node corresponding to one of the children of a given VNode.
2385
2409
  *
2386
2410
  * @param oldParentVNode the parent VNode from the previous render
@@ -2402,13 +2426,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex) => {
2402
2426
  if (BUILD.isDev && newVNode.$elm$) consoleDevError(`The JSX ${newVNode.$text$ !== null ? `"${newVNode.$text$}" text` : `"${String(newVNode.$tag$)}" element`} node should not be shared within the same renderer. The renderer caches element lookups in order to improve performance. However, a side effect from this is that the exact same JSX node should not be reused. For more information please see https://stenciljs.com/docs/templating-jsx#avoid-shared-jsx-nodes`);
2403
2427
  if (BUILD.vdomText && newVNode.$text$ != null) {
2404
2428
  elm = newVNode.$elm$ = win.document.createTextNode(newVNode.$text$);
2405
- if (BUILD.vdomSignals && newVNode.$signal$) {
2406
- const textSig = newVNode.$signal$;
2407
- const textNode = elm;
2408
- signalNodeDisposers.set(textNode, effect$1(() => {
2409
- textNode.data = String(textSig.value);
2410
- }));
2411
- }
2429
+ if (BUILD.vdomSignals && newVNode.$signal$) wireTextSignal(elm, newVNode.$signal$);
2412
2430
  } else if (BUILD.slotRelocation && newVNode.$flags$ & VNODE_FLAGS.isSlotReference) {
2413
2431
  elm = newVNode.$elm$ = BUILD.isDebug || BUILD.hydrateServerSide ? slotReferenceDebugNode(newVNode) : win.document.createTextNode("");
2414
2432
  if (typeof newVNode.$attrs$?.slot === "string") elm["s-sa"] = newVNode.$attrs$.slot;
@@ -2676,7 +2694,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh, isInitialRender = fal
2676
2694
  }
2677
2695
  if (BUILD.vdomKey && idxInOld >= 0) {
2678
2696
  elmToMove = oldCh[idxInOld];
2679
- if (elmToMove.$tag$ !== newStartVnode.$tag$) node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld);
2697
+ if (elmToMove.$tag$ !== newStartVnode.$tag$) node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
2680
2698
  else {
2681
2699
  patch(elmToMove, newStartVnode, isInitialRender);
2682
2700
  oldCh[idxInOld] = void 0;
@@ -2769,7 +2787,17 @@ const patch = (oldVNode, newVNode, isInitialRender = false) => {
2769
2787
  else if (BUILD.hydrateClientSide && isInitialRender && BUILD.updatable && oldChildren !== null && newChildren === null) newVNode.$children$ = oldChildren;
2770
2788
  if (BUILD.svg && isSvgMode && tag === "svg") isSvgMode = false;
2771
2789
  } else if (BUILD.vdomText && BUILD.slotRelocation && (defaultHolder = elm["s-cr"])) defaultHolder.parentNode.textContent = text;
2772
- else if (BUILD.vdomText && oldVNode.$text$ !== text) elm.data = text;
2790
+ else if (BUILD.vdomText) {
2791
+ if (BUILD.vdomSignals && newVNode.$signal$) {
2792
+ if (newVNode.$signal$ !== oldVNode.$signal$) {
2793
+ disposeTextSignal(elm);
2794
+ wireTextSignal(elm, newVNode.$signal$);
2795
+ }
2796
+ } else {
2797
+ if (BUILD.vdomSignals && oldVNode.$signal$) disposeTextSignal(elm);
2798
+ if (oldVNode.$text$ !== text) elm.data = text;
2799
+ }
2800
+ }
2773
2801
  };
2774
2802
  /**
2775
2803
  * Component-global information about nodes which are either currently being
@@ -3469,8 +3497,7 @@ const initializeSignals = (elm, hostRef, cmpMeta) => {
3469
3497
  const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
3470
3498
  for (const [memberName, [memberFlags]] of Object.entries(cmpMeta.$members$ ?? {})) {
3471
3499
  if (!(memberFlags & MEMBER_FLAGS.PropLike)) continue;
3472
- const initialVal = hostRef.$instanceValues$.get(memberName);
3473
- const sig = signal(initialVal);
3500
+ const sig = signal(hostRef.$instanceValues$.get(memberName));
3474
3501
  hostRef.$signalValues$.set(memberName, sig);
3475
3502
  let prevScheduleVal = sig.peek();
3476
3503
  disposers.push(effect(() => {
@@ -4365,12 +4392,13 @@ const scopeSelector = (selector, scopeSelectorText, hostSelector, slotSelector)
4365
4392
  else return shallowPart.trim();
4366
4393
  }).join(", ");
4367
4394
  };
4395
+ const isScopableAtRule = (selector) => selector.startsWith("@media") || selector.startsWith("@supports") || selector.startsWith("@page") || selector.startsWith("@document") || selector.startsWith("@layer");
4368
4396
  const scopeSelectors = (cssText, scopeSelectorText, hostSelector, slotSelector, commentOriginalSelector) => {
4369
4397
  return processRules(cssText, (rule) => {
4370
4398
  let selector = rule.selector;
4371
4399
  let content = rule.content;
4372
4400
  if (rule.selector[0] !== "@") selector = scopeSelector(rule.selector, scopeSelectorText, hostSelector, slotSelector);
4373
- else if (rule.selector.startsWith("@media") || rule.selector.startsWith("@supports") || rule.selector.startsWith("@page") || rule.selector.startsWith("@document")) content = scopeSelectors(rule.content, scopeSelectorText, hostSelector, slotSelector, commentOriginalSelector);
4401
+ else if (isScopableAtRule(rule.selector)) content = scopeSelectors(rule.content, scopeSelectorText, hostSelector, slotSelector, commentOriginalSelector);
4374
4402
  return {
4375
4403
  selector: selector.replace(/\s{2,}/g, " ").trim(),
4376
4404
  content
@@ -4462,14 +4490,12 @@ const scopeCss = (cssText, scopeId, commentOriginalSelector) => {
4462
4490
  rule.selector = placeholder + rule.selector;
4463
4491
  return rule;
4464
4492
  };
4465
- cssText = processRules(cssText, (rule) => {
4493
+ const commentSelectors = (input) => processRules(input, (rule) => {
4466
4494
  if (rule.selector[0] !== "@") return processCommentedSelector(rule);
4467
- else if (rule.selector.startsWith("@media") || rule.selector.startsWith("@supports") || rule.selector.startsWith("@page") || rule.selector.startsWith("@document")) {
4468
- rule.content = processRules(rule.content, processCommentedSelector);
4469
- return rule;
4470
- }
4495
+ if (isScopableAtRule(rule.selector)) rule.content = commentSelectors(rule.content);
4471
4496
  return rule;
4472
4497
  });
4498
+ cssText = commentSelectors(cssText);
4473
4499
  }
4474
4500
  const scoped = scopeCssText(cssText, scopeId, hostScopeId, slotScopeId, commentOriginalSelector);
4475
4501
  cssText = [scoped.cssText, ...commentsWithHash].join("\n");
@@ -4765,16 +4791,21 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
4765
4791
  });
4766
4792
  return;
4767
4793
  }
4768
- const setterSetVal = () => {
4794
+ const parsedValue = parsePropertyValue(newValue, memberFlags, BUILD.formAssociated && !!(cmpMeta.$flags$ & CMP_FLAGS.formAssociated));
4795
+ const setterSetVal = (val) => {
4769
4796
  const currentValue = ref.$lazyInstance$[memberName];
4770
4797
  if (!ref.$instanceValues$.get(memberName) && currentValue) ref.$instanceValues$.set(memberName, currentValue);
4771
- ref.$lazyInstance$[memberName] = parsePropertyValue(newValue, memberFlags, BUILD.formAssociated && !!(cmpMeta.$flags$ & CMP_FLAGS.formAssociated));
4798
+ ref.$lazyInstance$[memberName] = val;
4772
4799
  setValue(this, memberName, ref.$lazyInstance$[memberName], cmpMeta);
4773
4800
  };
4774
- if (ref.$lazyInstance$) setterSetVal();
4775
- else ref.$fetchedCbList$.push(() => {
4776
- setterSetVal();
4777
- });
4801
+ if (ref.$lazyInstance$) setterSetVal(parsedValue);
4802
+ else {
4803
+ ref.$instanceValues$.set(memberName, parsedValue);
4804
+ ref.$fetchedCbList$.push(() => {
4805
+ const pendingValue = ref.$instanceValues$.get(memberName);
4806
+ if (ref.$lazyInstance$[memberName] !== pendingValue) setterSetVal(pendingValue);
4807
+ });
4808
+ }
4778
4809
  }
4779
4810
  } });
4780
4811
  } else if (BUILD.lazyLoad && BUILD.method && flags & PROXY_FLAGS.isElementConstructor && memberFlags & MEMBER_FLAGS.Method) Object.defineProperty(prototype, memberName, { value(...args) {
@@ -4827,8 +4858,9 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
4827
4858
  if (BUILD.reflect && propMemberFlags & MEMBER_FLAGS.ReflectAttr && propMemberFlags & MEMBER_FLAGS.Any && !isComplexType(this[propName]) && reflectedAttrValue(this[propName]) === newValue) return;
4828
4859
  const isSpuriousBooleanRemoval = isBooleanTarget && newValue === null && this[propName] === void 0;
4829
4860
  if (isBooleanTarget) newValue = !(newValue === null || newValue === "false");
4861
+ const currentValue = BUILD.lazyLoad && propMemberFlags & MEMBER_FLAGS.Setter ? hostRef.$instanceValues$.get(propName) : this[propName];
4830
4862
  const propDesc = Object.getOwnPropertyDescriptor(prototype, propName);
4831
- if (!isSpuriousBooleanRemoval && newValue != this[propName] && (!propDesc.get || !!propDesc.set)) this[propName] = newValue;
4863
+ if (!isSpuriousBooleanRemoval && newValue != currentValue && (!propDesc.get || !!propDesc.set)) this[propName] = newValue;
4832
4864
  });
4833
4865
  };
4834
4866
  Cstr.observedAttributes = Array.from(/* @__PURE__ */ new Set([...Object.keys(cmpMeta.$watchers$ ?? {}), ...members.filter(([_, m]) => m[0] & MEMBER_FLAGS.HasAttribute).map(([propName, m]) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stencil/core",
3
- "version": "5.0.0-beta.1",
3
+ "version": "5.0.0-beta.11",
4
4
  "description": "A Compiler for Web Components and Progressive Web Apps",
5
5
  "keywords": [
6
6
  "components",
@@ -125,9 +125,9 @@
125
125
  "terser": "^5.50.0",
126
126
  "tinyglobby": "^0.2.17",
127
127
  "typescript": ">5.0.0 <7.0.0",
128
- "@stencil/cli": "5.0.0-beta.1",
129
- "@stencil/mock-doc": "5.0.0-beta.1",
130
- "@stencil/dev-server": "5.0.0-beta.1"
128
+ "@stencil/cli": "5.0.0-beta.11",
129
+ "@stencil/dev-server": "5.0.0-beta.11",
130
+ "@stencil/mock-doc": "5.0.0-beta.11"
131
131
  },
132
132
  "devDependencies": {
133
133
  "@ionic/prettier-config": "^4.0.0",