@stencil/core 5.0.0-alpha.7 → 5.0.0-alpha.9

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 +2 -0
  2. package/dist/{runtime/app-data → app-data}/index.js +1 -1
  3. package/dist/{client-Dd-NB5Ei.mjs → client-aTQ7xHxx.mjs} +2 -157
  4. package/dist/compiler/index.d.mts +1 -1
  5. package/dist/compiler/index.mjs +2 -2
  6. package/dist/compiler/utils/index.d.mts +1 -1
  7. package/dist/{compiler-BmT_yLHU.mjs → compiler-C0qmPoKu.mjs} +161 -21
  8. package/dist/declarations/stencil-public-compiler.d.ts +4 -0
  9. package/dist/{index-ch-cf-bZ.d.mts → index-BvkyxSY6.d.mts} +1 -1
  10. package/dist/{index-CVhWFUM0.d.mts → index-vY35H18z.d.mts} +4 -0
  11. package/dist/{index-BuveMLxy.d.ts → index-xAkMgLX_.d.ts} +1 -1
  12. package/dist/index.mjs +1 -1
  13. package/dist/jsx-runtime.mjs +1 -1
  14. package/dist/{node-10UamZmn.mjs → node--akYC-sG.mjs} +1 -1
  15. package/dist/runtime/client/lazy.js +3 -164
  16. package/dist/runtime/client/runtime.d.ts +2 -30
  17. package/dist/runtime/client/runtime.js +3 -164
  18. package/dist/runtime/index.d.ts +2 -30
  19. package/dist/runtime/index.js +3 -164
  20. package/dist/runtime/server/index.d.mts +1 -1
  21. package/dist/runtime/server/index.mjs +16 -16
  22. package/dist/runtime/server/runner.mjs +1 -1
  23. package/dist/signals/index.js +1 -1
  24. package/dist/sys/node/index.d.mts +1 -1
  25. package/dist/sys/node/index.mjs +1 -1
  26. package/dist/sys/node/worker.mjs +2 -2
  27. package/dist/testing/index.d.mts +2 -2
  28. package/dist/testing/index.mjs +160 -3
  29. package/package.json +10 -10
  30. package/dist/runtime/app-data/index.d.ts +0 -2
  31. /package/dist/{runtime/app-globals → app-globals}/index.d.ts +0 -0
  32. /package/dist/{runtime/app-globals → app-globals}/index.js +0 -0
@@ -1,5 +1,5 @@
1
- import { BUILD, BUILD as BUILD$1, Env, NAMESPACE, NAMESPACE as NAMESPACE$1 } from "@stencil/core/runtime/app-data";
2
- import { globalScripts, globalStyles } from "@stencil/core/runtime/app-globals";
1
+ import { BUILD, BUILD as BUILD$1, Env, NAMESPACE, NAMESPACE as NAMESPACE$1 } from "@stencil/core/app-data";
2
+ import { globalScripts, globalStyles } from "@stencil/core/app-globals";
3
3
  import { effect, effect as effect$1, signal } from "@preact/signals-core";
4
4
  const MEMBER_FLAGS = {
5
5
  String: 1,
@@ -4503,6 +4503,20 @@ function hasKeys(obj) {
4503
4503
  return false;
4504
4504
  }
4505
4505
  //#endregion
4506
+ //#region src/server/platform/h-async.ts
4507
+ const hAsync = (nodeName, vnodeData, ...children) => {
4508
+ if (Array.isArray(children) && children.length > 0) {
4509
+ const flatChildren = children.flat(Infinity);
4510
+ if (flatChildren.some((child) => child instanceof Promise)) return Promise.all(flatChildren).then((resolvedChildren) => {
4511
+ return h(nodeName, vnodeData, ...resolvedChildren);
4512
+ }).catch((err) => {
4513
+ return h(nodeName, vnodeData);
4514
+ });
4515
+ return h(nodeName, vnodeData, ...flatChildren);
4516
+ }
4517
+ return h(nodeName, vnodeData);
4518
+ };
4519
+ //#endregion
4506
4520
  //#region src/runtime/vdom/vdom-annotations.ts
4507
4521
  /**
4508
4522
  * Updates the DOM generated on the server with annotations such as node attributes and
@@ -4658,20 +4672,6 @@ const insertChildVNodeAnnotations = (doc, vnodeChild, cmpData, hostId, depth, in
4658
4672
  }
4659
4673
  };
4660
4674
  //#endregion
4661
- //#region src/server/platform/h-async.ts
4662
- const hAsync = (nodeName, vnodeData, ...children) => {
4663
- if (Array.isArray(children) && children.length > 0) {
4664
- const flatChildren = children.flat(Infinity);
4665
- if (flatChildren.some((child) => child instanceof Promise)) return Promise.all(flatChildren).then((resolvedChildren) => {
4666
- return h(nodeName, vnodeData, ...resolvedChildren);
4667
- }).catch((err) => {
4668
- return h(nodeName, vnodeData);
4669
- });
4670
- return h(nodeName, vnodeData, ...flatChildren);
4671
- }
4672
- return h(nodeName, vnodeData);
4673
- };
4674
- //#endregion
4675
4675
  //#region src/server/platform/proxy-host-element.ts
4676
4676
  function proxyHostElement(elm, cstr) {
4677
4677
  const cmpMeta = cstr.cmpMeta;
@@ -1,5 +1,5 @@
1
1
  import { ssrFactory } from "@stencil/core/runtime/server/ssr-factory";
2
- import { BUILD } from "@stencil/core/runtime/app-data";
2
+ import { BUILD } from "@stencil/core/app-data";
3
3
  import "@preact/signals-core";
4
4
  //#region ../../node_modules/.pnpm/parse5@8.0.1/node_modules/parse5/dist/common/unicode.js
5
5
  const UNDEFINED_CODE_POINTS = new Set([
@@ -16,7 +16,7 @@ import { batch, computed, effect, signal, untracked } from "@preact/signals-core
16
16
  * }
17
17
  * ```
18
18
  *
19
- * `virtual:app-data`, the module that `BUILD` is imported from, is an alias for the `@stencil/core/runtime/app-data`, and is
19
+ * `virtual:app-data`, the module that `BUILD` is imported from, is an alias for `@stencil/core/app-data`, and is
20
20
  * partially referenced by {@link STENCIL_APP_DATA_ID}. The `src/compiler/bundle/app-data-plugin.ts` references
21
21
  * `STENCIL_APP_DATA_ID` uses it to replace these defaults with {@link BuildConditionals} that are derived from a
22
22
  * Stencil project's contents (i.e. metadata from the components). This replacement happens at a Stencil project's
@@ -1,4 +1,4 @@
1
- import { ei as Logger, vr as CompilerSystem } from "../../index-CVhWFUM0.mjs";
1
+ import { ei as Logger, vr as CompilerSystem } from "../../index-vY35H18z.mjs";
2
2
 
3
3
  //#region src/sys/node/logger/index.d.ts
4
4
  /**
@@ -1,2 +1,2 @@
1
- import { n as setupNodeProcess, r as createNodeLogger, t as createNodeSys } from "../../node-10UamZmn.mjs";
1
+ import { n as setupNodeProcess, r as createNodeLogger, t as createNodeSys } from "../../node--akYC-sG.mjs";
2
2
  export { createNodeLogger, createNodeSys, setupNodeProcess };
@@ -1,5 +1,5 @@
1
- import { l as createWorkerMessageHandler } from "../../compiler-BmT_yLHU.mjs";
2
- import { t as createNodeSys } from "../../node-10UamZmn.mjs";
1
+ import { l as createWorkerMessageHandler } from "../../compiler-C0qmPoKu.mjs";
2
+ import { t as createNodeSys } from "../../node--akYC-sG.mjs";
3
3
  //#region src/sys/node/node-worker-thread.ts
4
4
  /**
5
5
  * Initialize a worker thread, setting up various machinery for managing
@@ -1,5 +1,5 @@
1
- import { $r as LogLevel, B as ComponentCompilerMeta, Br as Diagnostic, Dt as HostRef, E as CompilerCtx, Et as HostElement, Nt as Module, Rt as NewSpecPageOptions, Zn as Compiler, Zr as LoadConfigInit, a as BuildCtx, aa as ValidatedConfig, cn as RuntimeRef, ei as Logger, fa as RafCallback, ha as UserBuildConditionals, ia as UnvalidatedConfig, kr as Config, mt as ComponentRuntimeMeta, ni as LoggerTimeSpan, pn as SpecPage, ua as ErrorHandler, vr as CompilerSystem } from "../index-CVhWFUM0.mjs";
2
- import { a as h, b as Env, d as getMode, g as getElement, h as createEvent, i as Host, m as Fragment, o as forceUpdate, p as Mixin, s as getRenderingRef, v as getAssetPath, y as setAssetPath } from "../index-ch-cf-bZ.mjs";
1
+ import { $r as LogLevel, B as ComponentCompilerMeta, Br as Diagnostic, Dt as HostRef, E as CompilerCtx, Et as HostElement, Nt as Module, Rt as NewSpecPageOptions, Zn as Compiler, Zr as LoadConfigInit, a as BuildCtx, aa as ValidatedConfig, cn as RuntimeRef, ei as Logger, fa as RafCallback, ha as UserBuildConditionals, ia as UnvalidatedConfig, kr as Config, mt as ComponentRuntimeMeta, ni as LoggerTimeSpan, pn as SpecPage, ua as ErrorHandler, vr as CompilerSystem } from "../index-vY35H18z.mjs";
2
+ import { a as h, b as Env, d as getMode, g as getElement, h as createEvent, i as Host, m as Fragment, o as forceUpdate, p as Mixin, s as getRenderingRef, v as getAssetPath, y as setAssetPath } from "../index-BvkyxSY6.mjs";
3
3
  import { Mock } from "vitest";
4
4
 
5
5
  //#region src/testing/testing-logger.d.ts
@@ -1,8 +1,8 @@
1
- import { C as setAssetPath, S as getAssetPath, U as BUILD, W as Env, _ as getRenderingRef, b as getElement, c as Mixin, d as getMode, g as forceUpdate, h, k as reWireGetterSetter, l as Fragment, m as Host, t as insertVdomAnnotations, u as bootstrapLazy, v as renderVdom, y as createEvent } from "../client-Dd-NB5Ei.mjs";
1
+ import { A as HYDRATE_ID, C as setAssetPath, D as DEFAULT_DOC_DATA, F as reWireGetterSetter, M as STENCIL_DOC_DATA, P as getHostRef$1, S as getAssetPath, X as Env, Y as BUILD, _ as insertBefore, b as getElement, c as Fragment, g as getRenderingRef, h as forceUpdate, j as NODE_TYPE, k as HYDRATE_CHILD_ID, l as bootstrapLazy, m as h, p as Host, s as Mixin, u as getMode, v as renderVdom, y as createEvent } from "../client-aTQ7xHxx.mjs";
2
2
  import { L as EVENT_FLAGS, h as noop, w as CMP_FLAGS } from "../regular-expression-CFVJOTUh.mjs";
3
- import { _ as getBuildFeatures, c as createWorkerContext, g as BuildContext, h as Cache, i as createSystem, o as loadConfig, p as createInMemoryFs, s as createCompiler } from "../compiler-BmT_yLHU.mjs";
3
+ import { _ as getBuildFeatures, c as createWorkerContext, g as BuildContext, h as Cache, i as createSystem, o as loadConfig, p as createInMemoryFs, s as createCompiler } from "../compiler-C0qmPoKu.mjs";
4
4
  import { wt as formatLazyBundleRuntimeMeta } from "../validation-ByxKj8bC.mjs";
5
- import { o as buildEvents } from "../node-10UamZmn.mjs";
5
+ import { o as buildEvents } from "../node--akYC-sG.mjs";
6
6
  import fs from "node:fs";
7
7
  import path from "node:path";
8
8
  import { fileURLToPath } from "node:url";
@@ -285,6 +285,7 @@ function mockValidatedConfig(overrides = {}) {
285
285
  srcDir: "/src",
286
286
  srcIndexHtml: "src/index.html",
287
287
  suppressReservedPublicNameWarnings: false,
288
+ suppressReservedEventNameWarnings: false,
288
289
  sys: createTestingSystem(),
289
290
  transformAliasedImportPaths: true,
290
291
  rolldownConfig: {},
@@ -325,6 +326,7 @@ function mockConfig(overrides = {}) {
325
326
  rootDir,
326
327
  sourceMap: true,
327
328
  suppressReservedPublicNameWarnings: false,
329
+ suppressReservedEventNameWarnings: false,
328
330
  sys,
329
331
  validateTypes: false,
330
332
  ...overrides
@@ -962,6 +964,161 @@ function registerModule(bundleId, Cstr) {
962
964
  moduleLoaded.set(bundleId, Cstr);
963
965
  }
964
966
  //#endregion
967
+ //#region src/runtime/vdom/vdom-annotations.ts
968
+ /**
969
+ * Updates the DOM generated on the server with annotations such as node attributes and
970
+ * comment nodes to facilitate future client-side hydration. These annotations are used for things
971
+ * like moving elements back to their original hosts if using Shadow DOM on the client, and for quickly
972
+ * reconstructing the vNode representations of the DOM.
973
+ *
974
+ * @param doc The DOM generated by the server.
975
+ * @param staticComponents Any components that should be considered static and do not need client-side hydration.
976
+ */
977
+ const insertVdomAnnotations = (doc, staticComponents) => {
978
+ if (doc != null) {
979
+ /**
980
+ * Initiated `docData` object from the document if it exists to ensure we
981
+ * maintain the same `docData` object across multiple hydration hydration runs.
982
+ */
983
+ const docData = "_stencilDocData" in doc ? doc[STENCIL_DOC_DATA] : { ...DEFAULT_DOC_DATA };
984
+ docData.staticComponents = new Set(staticComponents);
985
+ const orgLocationNodes = [];
986
+ parseVNodeAnnotations(doc, doc.body, docData, orgLocationNodes);
987
+ orgLocationNodes.forEach((orgLocationNode) => {
988
+ if (orgLocationNode != null && orgLocationNode["s-nr"]) {
989
+ const nodeRef = orgLocationNode["s-nr"];
990
+ let hostId = nodeRef["s-host-id"];
991
+ let nodeId = nodeRef["s-node-id"];
992
+ let childId = `${hostId}.${nodeId}`;
993
+ if (hostId == null) {
994
+ hostId = 0;
995
+ docData.rootLevelIds++;
996
+ nodeId = docData.rootLevelIds;
997
+ childId = `${hostId}.${nodeId}`;
998
+ if (nodeRef.nodeType === NODE_TYPE.ElementNode) {
999
+ nodeRef.setAttribute(HYDRATE_CHILD_ID, childId);
1000
+ if (typeof nodeRef["s-sn"] === "string" && !nodeRef.getAttribute("slot")) nodeRef.setAttribute("s-sn", nodeRef["s-sn"]);
1001
+ } else if (nodeRef.nodeType === NODE_TYPE.TextNode) {
1002
+ if (hostId === 0) {
1003
+ if (nodeRef.nodeValue?.trim() === "") {
1004
+ orgLocationNode.remove();
1005
+ return;
1006
+ }
1007
+ }
1008
+ const commentBeforeTextNode = doc.createComment(childId);
1009
+ commentBeforeTextNode.nodeValue = `t.${childId}`;
1010
+ insertBefore(nodeRef.parentNode, commentBeforeTextNode, nodeRef);
1011
+ } else if (nodeRef.nodeType === NODE_TYPE.CommentNode) {
1012
+ const commentBeforeTextNode = doc.createComment(childId);
1013
+ commentBeforeTextNode.nodeValue = `c.${childId}`;
1014
+ nodeRef.parentNode.insertBefore(commentBeforeTextNode, nodeRef);
1015
+ }
1016
+ }
1017
+ let orgLocationNodeId = `o.${childId}`;
1018
+ const orgLocationParentNode = orgLocationNode.parentElement;
1019
+ if (orgLocationParentNode) {
1020
+ if (orgLocationParentNode["s-en"] === "") orgLocationNodeId += `.`;
1021
+ else if (orgLocationParentNode["s-en"] === "c") orgLocationNodeId += `.c`;
1022
+ }
1023
+ orgLocationNode.nodeValue = orgLocationNodeId;
1024
+ }
1025
+ });
1026
+ }
1027
+ };
1028
+ /**
1029
+ * Recursively parses a node generated by the server and its children to set host and child id
1030
+ * attributes read during client-side hydration. This function also tracks whether each node is
1031
+ * an original location reference node meaning that a node has been moved via slot relocation.
1032
+ *
1033
+ * @param doc The DOM generated by the server.
1034
+ * @param node The node to parse.
1035
+ * @param docData An object containing metadata about the document.
1036
+ * @param orgLocationNodes An array of nodes that have been moved via slot relocation.
1037
+ */
1038
+ const parseVNodeAnnotations = (doc, node, docData, orgLocationNodes) => {
1039
+ if (node == null) return;
1040
+ if (node["s-nr"] != null) orgLocationNodes.push(node);
1041
+ if (node.nodeType === NODE_TYPE.ElementNode) [...Array.from(node.childNodes), ...Array.from(node.shadowRoot?.childNodes || [])].forEach((childNode) => {
1042
+ const hostRef = getHostRef$1(childNode);
1043
+ if (hostRef != null && !docData.staticComponents.has(childNode.nodeName.toLowerCase())) insertVNodeAnnotations(doc, childNode, hostRef.$vnode$, docData, { nodeIds: 0 });
1044
+ parseVNodeAnnotations(doc, childNode, docData, orgLocationNodes);
1045
+ });
1046
+ };
1047
+ /**
1048
+ * Insert attribute annotations on an element for its host ID and, potentially, its child ID.
1049
+ * Also makes calls to insert annotations on the element's children, keeping track of the depth of
1050
+ * the component tree.
1051
+ *
1052
+ * @param doc The DOM generated by the server.
1053
+ * @param hostElm The element to insert annotations for.
1054
+ * @param vnode The vNode representation of the element.
1055
+ * @param docData An object containing metadata about the document.
1056
+ * @param cmpData An object containing metadata about the component.
1057
+ */
1058
+ const insertVNodeAnnotations = (doc, hostElm, vnode, docData, cmpData) => {
1059
+ if (vnode != null) {
1060
+ const hostId = ++docData.hostIds;
1061
+ hostElm.setAttribute(HYDRATE_ID, hostId);
1062
+ if (hostElm["s-cr"] != null) hostElm["s-cr"].nodeValue = `r.${hostId}`;
1063
+ if (vnode.$children$ != null) {
1064
+ const depth = 0;
1065
+ vnode.$children$.forEach((vnodeChild, index) => {
1066
+ insertChildVNodeAnnotations(doc, vnodeChild, cmpData, hostId, depth, index);
1067
+ });
1068
+ }
1069
+ if (hostElm && vnode && vnode.$elm$ && !hostElm.hasAttribute("c-id")) {
1070
+ const parent = hostElm.parentElement;
1071
+ if (parent && parent.childNodes) {
1072
+ const parentChildNodes = Array.from(parent.childNodes);
1073
+ const comment = parentChildNodes.find((node) => node.nodeType === NODE_TYPE.CommentNode && node["s-sr"]);
1074
+ if (comment) {
1075
+ const index = parentChildNodes.indexOf(hostElm) - 1;
1076
+ vnode.$elm$.setAttribute(HYDRATE_CHILD_ID, `${comment["s-host-id"]}.${comment["s-node-id"]}.0.${index}`);
1077
+ }
1078
+ }
1079
+ }
1080
+ }
1081
+ };
1082
+ /**
1083
+ * Recursively analyzes the type of a child vNode and inserts annotations on the vNodes's element based on its type.
1084
+ * Element nodes receive a child ID attribute, text nodes have a comment with the child ID inserted before them,
1085
+ * and comment nodes representing a slot have their node value set to a slot node ID containing the child ID.
1086
+ *
1087
+ * @param doc The DOM generated by the server.
1088
+ * @param vnodeChild The vNode to insert annotations for.
1089
+ * @param cmpData An object containing metadata about the component.
1090
+ * @param hostId The host ID of this element's parent.
1091
+ * @param depth How deep this element sits in the component tree relative to its parent.
1092
+ * @param index The index of this element in its parent's children array.
1093
+ */
1094
+ const insertChildVNodeAnnotations = (doc, vnodeChild, cmpData, hostId, depth, index) => {
1095
+ const childElm = vnodeChild.$elm$;
1096
+ if (childElm == null) return;
1097
+ const nodeId = cmpData.nodeIds++;
1098
+ const childId = `${hostId}.${nodeId}.${depth}.${index}`;
1099
+ childElm["s-host-id"] = hostId;
1100
+ childElm["s-node-id"] = nodeId;
1101
+ if (childElm.nodeType === NODE_TYPE.ElementNode) {
1102
+ childElm.setAttribute(HYDRATE_CHILD_ID, childId);
1103
+ if (typeof childElm["s-sn"] === "string" && !childElm.getAttribute("slot")) childElm.setAttribute("s-sn", childElm["s-sn"]);
1104
+ } else if (childElm.nodeType === NODE_TYPE.TextNode) {
1105
+ const parentNode = childElm.parentNode;
1106
+ const nodeName = parentNode?.nodeName;
1107
+ if (nodeName !== "STYLE" && nodeName !== "SCRIPT") {
1108
+ const textNodeId = `t.${childId}`;
1109
+ insertBefore(parentNode, doc.createComment(textNodeId), childElm);
1110
+ }
1111
+ } else if (childElm.nodeType === NODE_TYPE.CommentNode) {
1112
+ if (childElm["s-sr"]) childElm.nodeValue = `s.${childId}.${childElm["s-sn"] || ""}`;
1113
+ }
1114
+ if (vnodeChild.$children$ != null) {
1115
+ const childDepth = depth + 1;
1116
+ vnodeChild.$children$.forEach((vnode, childIndex) => {
1117
+ insertChildVNodeAnnotations(doc, vnode, cmpData, hostId, childDepth, childIndex);
1118
+ });
1119
+ }
1120
+ };
1121
+ //#endregion
965
1122
  //#region src/testing/platform/index.ts
966
1123
  const setMode = (handler) => {
967
1124
  modeResolutionChain.length = 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stencil/core",
3
- "version": "5.0.0-alpha.7",
3
+ "version": "5.0.0-alpha.9",
4
4
  "description": "A Compiler for Web Components and Progressive Web Apps",
5
5
  "keywords": [
6
6
  "components",
@@ -64,13 +64,13 @@
64
64
  "types": "./dist/runtime/index.d.ts",
65
65
  "import": "./dist/runtime/index.js"
66
66
  },
67
- "./runtime/app-data": {
68
- "types": "./dist/runtime/app-data/index.d.ts",
69
- "import": "./dist/runtime/app-data/index.js"
67
+ "./app-data": {
68
+ "types": "./dist/app-data/index.d.ts",
69
+ "import": "./dist/app-data/index.js"
70
70
  },
71
- "./runtime/app-globals": {
72
- "types": "./dist/runtime/app-globals/index.d.ts",
73
- "import": "./dist/runtime/app-globals/index.js"
71
+ "./app-globals": {
72
+ "types": "./dist/app-globals/index.d.ts",
73
+ "import": "./dist/app-globals/index.js"
74
74
  },
75
75
  "./runtime/client": {
76
76
  "types": "./dist/runtime/client/runtime.d.ts",
@@ -121,9 +121,9 @@
121
121
  "terser": "^5.0.0",
122
122
  "tinyglobby": "^0.2.0",
123
123
  "typescript": ">4.0.0 <7.0.0",
124
- "@stencil/cli": "5.0.0-alpha.7",
125
- "@stencil/dev-server": "5.0.0-alpha.7",
126
- "@stencil/mock-doc": "5.0.0-alpha.7"
124
+ "@stencil/cli": "5.0.0-alpha.9",
125
+ "@stencil/dev-server": "5.0.0-alpha.9",
126
+ "@stencil/mock-doc": "5.0.0-alpha.9"
127
127
  },
128
128
  "devDependencies": {
129
129
  "@ionic/prettier-config": "^4.0.0",
@@ -1,2 +0,0 @@
1
- import { n as Env, r as NAMESPACE, t as BUILD } from "../../index-BuveMLxy.js";
2
- export { BUILD, Env, NAMESPACE };