@stencil/core 3.0.0-beta.1 → 3.0.0-rc.1

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 (44) hide show
  1. package/cli/index.cjs +12 -8
  2. package/cli/index.js +12 -8
  3. package/cli/package.json +1 -1
  4. package/compiler/package.json +1 -1
  5. package/compiler/stencil.js +60 -28
  6. package/compiler/stencil.min.js +2 -2
  7. package/dependencies.json +1 -1
  8. package/dev-server/client/index.js +1 -1
  9. package/dev-server/client/package.json +1 -1
  10. package/dev-server/connector.html +2 -2
  11. package/dev-server/index.js +1 -1
  12. package/dev-server/package.json +1 -1
  13. package/dev-server/server-process.js +6 -5
  14. package/dev-server/ws.js +1 -1
  15. package/internal/app-data/package.json +1 -1
  16. package/internal/client/css-shim.js +1 -1
  17. package/internal/client/dom.js +1 -1
  18. package/internal/client/index.js +108 -5
  19. package/internal/client/package.json +1 -1
  20. package/internal/client/patch-browser.js +19 -1
  21. package/internal/client/patch-esm.js +1 -1
  22. package/internal/client/shadow-css.js +1 -1
  23. package/internal/hydrate/index.js +48 -37
  24. package/internal/hydrate/package.json +1 -1
  25. package/internal/hydrate/runner.d.ts +16 -15
  26. package/internal/hydrate/runner.js +4 -2
  27. package/internal/package.json +1 -1
  28. package/internal/stencil-core/index.d.ts +1 -0
  29. package/internal/stencil-private.d.ts +10 -0
  30. package/internal/stencil-public-compiler.d.ts +12 -18
  31. package/internal/stencil-public-runtime.d.ts +20 -0
  32. package/internal/testing/index.js +53 -41
  33. package/internal/testing/package.json +1 -1
  34. package/mock-doc/index.cjs +1 -1
  35. package/mock-doc/index.js +1 -1
  36. package/mock-doc/package.json +1 -1
  37. package/package.json +7 -7
  38. package/screenshot/package.json +1 -1
  39. package/sys/node/glob.js +1 -1
  40. package/sys/node/index.js +1 -1
  41. package/sys/node/package.json +1 -1
  42. package/sys/node/worker.js +1 -1
  43. package/testing/index.js +72 -66
  44. package/testing/package.json +1 -1
@@ -19,7 +19,7 @@ let renderingRef = null;
19
19
  let queueCongestion = 0;
20
20
  let queuePending = false;
21
21
  /*
22
- Stencil Client Platform v3.0.0-beta.1 | MIT Licensed | https://stenciljs.com
22
+ Stencil Client Platform v3.0.0-rc.1 | MIT Licensed | https://stenciljs.com
23
23
  */
24
24
  import { BUILD, NAMESPACE } from '@stencil/core/internal/app-data';
25
25
  const Build = {
@@ -50,11 +50,11 @@ const createTime = (fnName, tagName = '') => {
50
50
  };
51
51
  const uniqueTime = (key, measureText) => {
52
52
  if (BUILD.profile && performance.mark) {
53
- if (performance.getEntriesByName(key).length === 0) {
53
+ if (performance.getEntriesByName(key, 'mark').length === 0) {
54
54
  performance.mark(key);
55
55
  }
56
56
  return () => {
57
- if (performance.getEntriesByName(measureText).length === 0) {
57
+ if (performance.getEntriesByName(measureText, 'measure').length === 0) {
58
58
  performance.measure(measureText, key);
59
59
  }
60
60
  };
@@ -148,6 +148,18 @@ const isComplexType = (o) => {
148
148
  o = typeof o;
149
149
  return o === 'object' || o === 'function';
150
150
  };
151
+ /**
152
+ * Helper method for querying a `meta` tag that contains a nonce value
153
+ * out of a DOM's head.
154
+ *
155
+ * @param doc The DOM containing the `head` to query against
156
+ * @returns The content of the meta tag representing the nonce value, or `undefined` if no tag
157
+ * exists or the tag has no content.
158
+ */
159
+ function queryNonceMetaTagContent(doc) {
160
+ var _a, _b, _c;
161
+ return (_c = (_b = (_a = doc.head) === null || _a === void 0 ? void 0 : _a.querySelector('meta[name="csp-nonce"]')) === null || _b === void 0 ? void 0 : _b.getAttribute('content')) !== null && _c !== void 0 ? _c : undefined;
162
+ }
151
163
  /**
152
164
  * Production h() function based on Preact by
153
165
  * Jason Miller (@developit)
@@ -238,6 +250,14 @@ Empty objects can also be the cause, look for JSX comments that became objects.`
238
250
  }
239
251
  return vnode;
240
252
  };
253
+ /**
254
+ * A utility function for creating a virtual DOM node from a tag and some
255
+ * possible text content.
256
+ *
257
+ * @param tag the tag for this element
258
+ * @param text possible text content for the node
259
+ * @returns a newly-minted virtual DOM node
260
+ */
241
261
  const newVNode = (tag, text) => {
242
262
  const vnode = {
243
263
  $flags$: 0,
@@ -258,6 +278,12 @@ const newVNode = (tag, text) => {
258
278
  return vnode;
259
279
  };
260
280
  const Host = {};
281
+ /**
282
+ * Check whether a given node is a Host node or not
283
+ *
284
+ * @param node the virtual DOM node to check
285
+ * @returns whether it's a Host node or not
286
+ */
261
287
  const isHost = (node) => node && node.$tag$ === Host;
262
288
  /**
263
289
  * Implementation of {@link d.FunctionalUtilities} for Stencil's VDom.
@@ -270,6 +296,13 @@ const vdomFnUtils = {
270
296
  forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
271
297
  map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate),
272
298
  };
299
+ /**
300
+ * Convert a {@link d.VNode} to a {@link d.ChildNode} in order to present a
301
+ * friendlier public interface (hence, 'convertToPublic').
302
+ *
303
+ * @param node the virtual DOM node to convert
304
+ * @returns a converted child node
305
+ */
273
306
  const convertToPublic = (node) => ({
274
307
  vattrs: node.$attrs$,
275
308
  vchildren: node.$children$,
@@ -278,6 +311,15 @@ const convertToPublic = (node) => ({
278
311
  vtag: node.$tag$,
279
312
  vtext: node.$text$,
280
313
  });
314
+ /**
315
+ * Convert a {@link d.ChildNode} back to an equivalent {@link d.VNode} in
316
+ * order to use the resulting object in the virtual DOM. The initial object was
317
+ * likely created as part of presenting a public API, so converting it back
318
+ * involved making it 'private' again (hence, `convertToPrivate`).
319
+ *
320
+ * @param node the child node to convert
321
+ * @returns a converted virtual DOM node
322
+ */
281
323
  const convertToPrivate = (node) => {
282
324
  if (typeof node.vtag === 'function') {
283
325
  const vnodeData = Object.assign({}, node.vattrs);
@@ -298,6 +340,7 @@ const convertToPrivate = (node) => {
298
340
  };
299
341
  /**
300
342
  * Validates the ordering of attributes on an input element
343
+ *
301
344
  * @param inputElm the element to validate
302
345
  */
303
346
  const validateInputProperties = (inputElm) => {
@@ -618,6 +661,7 @@ const registerStyle = (scopeId, cssText, allowCS) => {
618
661
  styles.set(scopeId, style);
619
662
  };
620
663
  const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
664
+ var _a;
621
665
  let scopeId = getScopeId(cmpMeta, mode);
622
666
  const style = styles.get(scopeId);
623
667
  if (!BUILD.attachStyles) {
@@ -661,6 +705,11 @@ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
661
705
  styleElm = doc.createElement('style');
662
706
  styleElm.innerHTML = style;
663
707
  }
708
+ // Apply CSP nonce to the style tag if it exists
709
+ const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
710
+ if (nonce != null) {
711
+ styleElm.setAttribute('nonce', nonce);
712
+ }
664
713
  if (BUILD.hydrateServerSide || BUILD.hotModuleReplacement) {
665
714
  styleElm.setAttribute(HYDRATED_STYLE_ID, scopeId);
666
715
  }
@@ -1009,6 +1058,21 @@ const putBackInOriginalLocation = (parentElm, recursive) => {
1009
1058
  }
1010
1059
  plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
1011
1060
  };
1061
+ /**
1062
+ * Create DOM nodes corresponding to a list of {@link d.Vnode} objects and
1063
+ * add them to the DOM in the appropriate place.
1064
+ *
1065
+ * @param parentElm the DOM node which should be used as a parent for the new
1066
+ * DOM nodes
1067
+ * @param before a child of the `parentElm` which the new children should be
1068
+ * inserted before (optional)
1069
+ * @param parentVNode the parent virtual DOM node
1070
+ * @param vnodes the new child virtual DOM nodes to produce DOM nodes for
1071
+ * @param startIdx the index in the child virtual DOM nodes at which to start
1072
+ * creating DOM nodes (inclusive)
1073
+ * @param endIdx the index in the child virtual DOM nodes at which to stop
1074
+ * creating DOM nodes (inclusive)
1075
+ */
1012
1076
  const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
1013
1077
  let containerElm = ((BUILD.slotRelocation && parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
1014
1078
  let childNode;
@@ -1025,6 +1089,19 @@ const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) =>
1025
1089
  }
1026
1090
  }
1027
1091
  };
1092
+ /**
1093
+ * Remove the DOM elements corresponding to a list of {@link d.VNode} objects.
1094
+ * This can be used to, for instance, clean up after a list of children which
1095
+ * should no longer be shown.
1096
+ *
1097
+ * This function also handles some of Stencil's slot relocation logic.
1098
+ *
1099
+ * @param vnodes a list of virtual DOM nodes to remove
1100
+ * @param startIdx the index at which to start removing nodes (inclusive)
1101
+ * @param endIdx the index at which to stop removing nodes (inclusive)
1102
+ * @param vnode a VNode
1103
+ * @param elm an element
1104
+ */
1028
1105
  const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
1029
1106
  for (; startIdx <= endIdx; ++startIdx) {
1030
1107
  if ((vnode = vnodes[startIdx])) {
@@ -1306,7 +1383,8 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
1306
1383
  *
1307
1384
  * So, in other words, if `key` attrs are not set on VNodes which may be
1308
1385
  * changing order within a `children` array or something along those lines then
1309
- * we could obtain a false positive and then have to do needless re-rendering.
1386
+ * we could obtain a false negative and then have to do needless re-rendering
1387
+ * (i.e. we'd say two VNodes aren't equal when in fact they should be).
1310
1388
  *
1311
1389
  * @param leftVNode the first VNode to check
1312
1390
  * @param rightVNode the second VNode to check
@@ -1535,6 +1613,18 @@ const callNodeRefs = (vNode) => {
1535
1613
  vNode.$children$ && vNode.$children$.map(callNodeRefs);
1536
1614
  }
1537
1615
  };
1616
+ /**
1617
+ * The main entry point for Stencil's virtual DOM-based rendering engine
1618
+ *
1619
+ * Given a {@link d.HostRef} container and some virtual DOM nodes, this
1620
+ * function will handle creating a virtual DOM tree with a single root, patching
1621
+ * the current virtual DOM tree onto an old one (if any), dealing with slot
1622
+ * relocation, and reflecting attributes.
1623
+ *
1624
+ * @param hostRef data needed to root and render the virtual DOM tree, such as
1625
+ * the DOM node into which it should be rendered.
1626
+ * @param renderFnResults the virtual DOM nodes to be rendered
1627
+ */
1538
1628
  const renderVdom = (hostRef, renderFnResults) => {
1539
1629
  const hostElm = hostRef.$hostElement$;
1540
1630
  const cmpMeta = hostRef.$cmpMeta$;
@@ -2677,6 +2767,7 @@ const hmrStart = (elm, cmpMeta, hmrVersionId) => {
2677
2767
  initializeComponent(elm, hostRef, cmpMeta, hmrVersionId);
2678
2768
  };
2679
2769
  const bootstrapLazy = (lazyBundles, options = {}) => {
2770
+ var _a;
2680
2771
  if (BUILD.profile && performance.mark) {
2681
2772
  performance.mark('st:app:start');
2682
2773
  }
@@ -2812,6 +2903,11 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
2812
2903
  if (BUILD.invisiblePrehydration && (BUILD.hydratedClass || BUILD.hydratedAttribute)) {
2813
2904
  visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
2814
2905
  visibilityStyle.setAttribute('data-styles', '');
2906
+ // Apply CSP nonce to the style tag if it exists
2907
+ const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
2908
+ if (nonce != null) {
2909
+ visibilityStyle.setAttribute('nonce', nonce);
2910
+ }
2815
2911
  head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
2816
2912
  }
2817
2913
  // Process deferred connectedCallbacks now all components have been registered
@@ -2947,6 +3043,13 @@ const hostListenerOpts = (flags) => supportsListenerOptions
2947
3043
  capture: (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0,
2948
3044
  })
2949
3045
  : (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0;
3046
+ /**
3047
+ * Assigns the given value to the nonce property on the runtime platform object.
3048
+ * During runtime, this value is used to set the nonce attribute on all dynamically created script and style tags.
3049
+ * @param nonce The value to be assigned to the platform nonce property.
3050
+ * @returns void
3051
+ */
3052
+ const setNonce = (nonce) => (plt.$nonce$ = nonce);
2950
3053
  const setPlatformOptions = (opts) => Object.assign(plt, opts);
2951
3054
  const insertVdomAnnotations = (doc, staticComponents) => {
2952
3055
  if (doc != null) {
@@ -3282,4 +3385,4 @@ const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
3282
3385
  const readTask = /*@__PURE__*/ queueTask(queueDomReads, false);
3283
3386
  const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
3284
3387
  export { BUILD, Env, NAMESPACE } from '@stencil/core/internal/app-data';
3285
- export { Build, CSS, Context, Fragment, H, H as HTMLElement, Host, STENCIL_DEV_MODE, addHostEventListeners, bootstrapLazy, cmpModules, connectedCallback, consoleDevError, consoleDevInfo, consoleDevWarn, consoleError, createEvent, defineCustomElement, disconnectedCallback, doc, forceModeUpdate, forceUpdate, getAssetPath, getConnect, getContext, getElement, getHostRef, getMode, getRenderingRef, getValue, h, insertVdomAnnotations, isMemberInElement, loadModule, modeResolutionChain, nextTick, parsePropertyValue, plt, postUpdateComponent, promiseResolve, proxyComponent, proxyCustomElement, readTask, registerHost, registerInstance, renderVdom, setAssetPath, setErrorHandler, setMode, setPlatformHelpers, setPlatformOptions, setValue, styles, supportsConstructableStylesheets, supportsListenerOptions, supportsShadow, win, writeTask };
3388
+ export { Build, CSS, Context, Fragment, H, H as HTMLElement, Host, STENCIL_DEV_MODE, addHostEventListeners, bootstrapLazy, cmpModules, connectedCallback, consoleDevError, consoleDevInfo, consoleDevWarn, consoleError, createEvent, defineCustomElement, disconnectedCallback, doc, forceModeUpdate, forceUpdate, getAssetPath, getConnect, getContext, getElement, getHostRef, getMode, getRenderingRef, getValue, h, insertVdomAnnotations, isMemberInElement, loadModule, modeResolutionChain, nextTick, parsePropertyValue, plt, postUpdateComponent, promiseResolve, proxyComponent, proxyCustomElement, readTask, registerHost, registerInstance, renderVdom, setAssetPath, setErrorHandler, setMode, setNonce, setPlatformHelpers, setPlatformOptions, setValue, styles, supportsConstructableStylesheets, supportsListenerOptions, supportsShadow, win, writeTask };
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stencil/core/internal/client",
3
- "version": "3.0.0-beta.1",
3
+ "version": "3.0.0-rc.1",
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
  "private": true,
@@ -1,8 +1,20 @@
1
1
  /*
2
- Stencil Client Patch Browser v3.0.0-beta.1 | MIT Licensed | https://stenciljs.com
2
+ Stencil Client Patch Browser v3.0.0-rc.1 | MIT Licensed | https://stenciljs.com
3
3
  */
4
4
  import { BUILD, NAMESPACE } from '@stencil/core/internal/app-data';
5
5
  import { consoleDevInfo, plt, win, doc, promiseResolve, H } from '@stencil/core';
6
+ /**
7
+ * Helper method for querying a `meta` tag that contains a nonce value
8
+ * out of a DOM's head.
9
+ *
10
+ * @param doc The DOM containing the `head` to query against
11
+ * @returns The content of the meta tag representing the nonce value, or `undefined` if no tag
12
+ * exists or the tag has no content.
13
+ */
14
+ function queryNonceMetaTagContent(doc) {
15
+ var _a, _b, _c;
16
+ return (_c = (_b = (_a = doc.head) === null || _a === void 0 ? void 0 : _a.querySelector('meta[name="csp-nonce"]')) === null || _b === void 0 ? void 0 : _b.getAttribute('content')) !== null && _c !== void 0 ? _c : undefined;
17
+ }
6
18
  // TODO(STENCIL-661): Remove code related to the dynamic import shim
7
19
  const getDynamicImportFunction = (namespace) => `__sc_import_${namespace.replace(/\s|-/g, '_')}`;
8
20
  const patchBrowser = () => {
@@ -93,6 +105,7 @@ const patchDynamicImport = (base, orgScriptElm) => {
93
105
  // basically this code is for old Edge, v18 and below
94
106
  const moduleMap = new Map();
95
107
  win[importFunctionName] = (src) => {
108
+ var _a;
96
109
  const url = new URL(src, base).href;
97
110
  let mod = moduleMap.get(url);
98
111
  if (!mod) {
@@ -102,6 +115,11 @@ const patchDynamicImport = (base, orgScriptElm) => {
102
115
  script.src = URL.createObjectURL(new Blob([`import * as m from '${url}'; window.${importFunctionName}.m = m;`], {
103
116
  type: 'application/javascript',
104
117
  }));
118
+ // Apply CSP nonce to the script tag if it exists
119
+ const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
120
+ if (nonce != null) {
121
+ script.setAttribute('nonce', nonce);
122
+ }
105
123
  mod = new Promise((resolve) => {
106
124
  script.onload = () => {
107
125
  resolve(win[importFunctionName].m);
@@ -1,5 +1,5 @@
1
1
  /*
2
- Stencil Client Patch Esm v3.0.0-beta.1 | MIT Licensed | https://stenciljs.com
2
+ Stencil Client Patch Esm v3.0.0-rc.1 | MIT Licensed | https://stenciljs.com
3
3
  */
4
4
  import { BUILD } from '@stencil/core/internal/app-data';
5
5
  import { CSS, plt, win, promiseResolve } from '@stencil/core';
@@ -1,5 +1,5 @@
1
1
  /*
2
- Stencil Client Platform v3.0.0-beta.1 | MIT Licensed | https://stenciljs.com
2
+ Stencil Client Platform v3.0.0-rc.1 | MIT Licensed | https://stenciljs.com
3
3
  */
4
4
  /**
5
5
  * @license
@@ -1,3 +1,8 @@
1
+ function queryNonceMetaTagContent(e) {
2
+ var t, o, n;
3
+ return null !== (n = null === (o = null === (t = e.head) || void 0 === t ? void 0 : t.querySelector('meta[name="csp-nonce"]')) || void 0 === o ? void 0 : o.getAttribute("content")) && void 0 !== n ? n : void 0;
4
+ }
5
+
1
6
  function componentOnReady() {
2
7
  return getHostRef(this).$onReadyPromise$;
3
8
  }
@@ -316,26 +321,28 @@ const createTime = (e, t = "") => {
316
321
  let n = styles.get(e);
317
322
  n = t, styles.set(e, n);
318
323
  }, addStyle = (e, t, o, n) => {
319
- let s = getScopeId(t, o);
320
- const l = styles.get(s);
321
- if (!BUILD.attachStyles) return s;
322
- if (e = 11 === e.nodeType ? e : doc, l) if ("string" == typeof l) {
324
+ var s;
325
+ let l = getScopeId(t, o);
326
+ const a = styles.get(l);
327
+ if (!BUILD.attachStyles) return l;
328
+ if (e = 11 === e.nodeType ? e : doc, a) if ("string" == typeof a) {
323
329
  e = e.head || e;
324
- let o, a = rootAppliedStyles.get(e);
325
- if (a || rootAppliedStyles.set(e, a = new Set), !a.has(s)) {
326
- if (BUILD.hydrateClientSide && e.host && (o = e.querySelector(`[sty-id="${s}"]`))) o.innerHTML = l; else {
330
+ let o, r = rootAppliedStyles.get(e);
331
+ if (r || rootAppliedStyles.set(e, r = new Set), !r.has(l)) {
332
+ if (BUILD.hydrateClientSide && e.host && (o = e.querySelector(`[sty-id="${l}"]`))) o.innerHTML = a; else {
327
333
  if (BUILD.cssVarShim && plt.$cssShim$) {
328
- o = plt.$cssShim$.createHostStyle(n, s, l, !!(10 & t.$flags$));
334
+ o = plt.$cssShim$.createHostStyle(n, l, a, !!(10 & t.$flags$));
329
335
  const e = o["s-sc"];
330
- e && (s = e, a = null);
331
- } else o = doc.createElement("style"), o.innerHTML = l;
332
- (BUILD.hydrateServerSide || BUILD.hotModuleReplacement) && o.setAttribute("sty-id", s),
336
+ e && (l = e, r = null);
337
+ } else o = doc.createElement("style"), o.innerHTML = a;
338
+ const i = null !== (s = plt.$nonce$) && void 0 !== s ? s : queryNonceMetaTagContent(doc);
339
+ null != i && o.setAttribute("nonce", i), (BUILD.hydrateServerSide || BUILD.hotModuleReplacement) && o.setAttribute("sty-id", l),
333
340
  e.insertBefore(o, e.querySelector("link"));
334
341
  }
335
- a && a.add(s);
342
+ r && r.add(l);
336
343
  }
337
- } else BUILD.constructableCSS && !e.adoptedStyleSheets.includes(l) && (e.adoptedStyleSheets = [ ...e.adoptedStyleSheets, l ]);
338
- return s;
344
+ } else BUILD.constructableCSS && !e.adoptedStyleSheets.includes(a) && (e.adoptedStyleSheets = [ ...e.adoptedStyleSheets, a ]);
345
+ return l;
339
346
  }, attachStyles = e => {
340
347
  const t = e.$cmpMeta$, o = e.$hostElement$, n = t.$flags$, s = createTime("attachStyles", t.$tagName$), l = addStyle(BUILD.shadowDom && supportsShadow && o.shadowRoot ? o.shadowRoot : o.getRootNode(), t, e.$modeName$, o);
341
348
  (BUILD.shadowDom || BUILD.scoped) && BUILD.cssAnnotations && 10 & n && (o["s-sc"] = l,
@@ -653,9 +660,9 @@ const callRender = (e, t, o) => {
653
660
  if (BUILD.lazyLoad || BUILD.hydrateClientSide) {
654
661
  if (t.$flags$ |= 32, (s = loadModule(o)).then) {
655
662
  const e = (l = `st:load:${o.$tagName$}:${t.$modeName$}`, a = `[Stencil] Load module for <${o.$tagName$}>`,
656
- BUILD.profile && performance.mark ? (0 === performance.getEntriesByName(l).length && performance.mark(l),
663
+ BUILD.profile && performance.mark ? (0 === performance.getEntriesByName(l, "mark").length && performance.mark(l),
657
664
  () => {
658
- 0 === performance.getEntriesByName(a).length && performance.measure(a, l);
665
+ 0 === performance.getEntriesByName(a, "measure").length && performance.measure(a, l);
659
666
  }) : () => {});
660
667
  s = await s, e();
661
668
  }
@@ -855,6 +862,7 @@ const callRender = (e, t, o) => {
855
862
  for (;(e = e.nextSibling) && e["s-sn"] === t; ) o.push(e);
856
863
  return o;
857
864
  }, bootstrapLazy = (e, t = {}) => {
865
+ var o;
858
866
  BUILD.profile && performance.mark && performance.mark("st:app:start"), (() => {
859
867
  if (BUILD.devTools) {
860
868
  const e = win.stencil = win.stencil || {}, t = e.inspect;
@@ -902,29 +910,29 @@ const callRender = (e, t, o) => {
902
910
  };
903
911
  }
904
912
  })();
905
- const o = createTime("bootstrapLazy"), n = [], s = t.exclude || [], l = win.customElements, a = doc.head, r = a.querySelector("meta[charset]"), i = doc.createElement("style"), d = [], c = doc.querySelectorAll("[sty-id]");
906
- let $, m = !0, p = 0;
913
+ const n = createTime("bootstrapLazy"), s = [], l = t.exclude || [], a = win.customElements, r = doc.head, i = r.querySelector("meta[charset]"), d = doc.createElement("style"), c = [], $ = doc.querySelectorAll("[sty-id]");
914
+ let m, p = !0, h = 0;
907
915
  if (Object.assign(plt, t), plt.$resourcesUrl$ = new URL(t.resourcesUrl || "./", doc.baseURI).href,
908
916
  BUILD.asyncQueue && t.syncQueue && (plt.$flags$ |= 4), BUILD.hydrateClientSide && (plt.$flags$ |= 2),
909
- BUILD.hydrateClientSide && BUILD.shadowDom) for (;p < c.length; p++) registerStyle(c[p].getAttribute("sty-id"), c[p].innerHTML.replace(/\/\*!@([^\/]+)\*\/[^\{]+\{/g, "$1{"));
910
- e.map((e => {
917
+ BUILD.hydrateClientSide && BUILD.shadowDom) for (;h < $.length; h++) registerStyle($[h].getAttribute("sty-id"), $[h].innerHTML.replace(/\/\*!@([^\/]+)\*\/[^\{]+\{/g, "$1{"));
918
+ if (e.map((e => {
911
919
  e[1].map((o => {
912
- const a = {
920
+ const n = {
913
921
  $flags$: o[0],
914
922
  $tagName$: o[1],
915
923
  $members$: o[2],
916
924
  $listeners$: o[3]
917
925
  };
918
- BUILD.member && (a.$members$ = o[2]), BUILD.hostListener && (a.$listeners$ = o[3]),
919
- BUILD.reflect && (a.$attrsToReflect$ = []), BUILD.watchCallback && (a.$watchers$ = {}),
920
- BUILD.shadowDom && !supportsShadow && 1 & a.$flags$ && (a.$flags$ |= 8);
921
- const r = BUILD.transformTagName && t.transformTagName ? t.transformTagName(a.$tagName$) : a.$tagName$, i = class extends HTMLElement {
926
+ BUILD.member && (n.$members$ = o[2]), BUILD.hostListener && (n.$listeners$ = o[3]),
927
+ BUILD.reflect && (n.$attrsToReflect$ = []), BUILD.watchCallback && (n.$watchers$ = {}),
928
+ BUILD.shadowDom && !supportsShadow && 1 & n.$flags$ && (n.$flags$ |= 8);
929
+ const r = BUILD.transformTagName && t.transformTagName ? t.transformTagName(n.$tagName$) : n.$tagName$, i = class extends HTMLElement {
922
930
  constructor(e) {
923
- super(e), registerHost(e = this, a), BUILD.shadowDom && 1 & a.$flags$ && (BUILD.hydrateServerSide || "shadowRoot" in e || (e.shadowRoot = e)),
924
- BUILD.slotChildNodesFix && patchChildSlotNodes(e, a);
931
+ super(e), registerHost(e = this, n), BUILD.shadowDom && 1 & n.$flags$ && (BUILD.hydrateServerSide || "shadowRoot" in e || (e.shadowRoot = e)),
932
+ BUILD.slotChildNodesFix && patchChildSlotNodes(e, n);
925
933
  }
926
934
  connectedCallback() {
927
- $ && (clearTimeout($), $ = null), m ? d.push(this) : plt.jmp((() => connectedCallback(this)));
935
+ m && (clearTimeout(m), m = null), p ? c.push(this) : plt.jmp((() => connectedCallback(this)));
928
936
  }
929
937
  disconnectedCallback() {
930
938
  plt.jmp((() => disconnectedCallback(this)));
@@ -940,14 +948,17 @@ const callRender = (e, t, o) => {
940
948
  n.$flags$ = 1, e["s-hmr-load"] = () => {
941
949
  delete e["s-hmr-load"];
942
950
  }, initializeComponent(e, n, t);
943
- })(this, a);
944
- }), BUILD.scopedSlotTextContentFix && patchTextContent(i.prototype, a), a.$lazyBundleId$ = e[0],
945
- s.includes(r) || l.get(r) || (n.push(r), l.define(r, proxyComponent(i, a, 1)));
951
+ })(this, n);
952
+ }), BUILD.scopedSlotTextContentFix && patchTextContent(i.prototype, n), n.$lazyBundleId$ = e[0],
953
+ l.includes(r) || a.get(r) || (s.push(r), a.define(r, proxyComponent(i, n, 1)));
946
954
  }));
947
- })), BUILD.invisiblePrehydration && (BUILD.hydratedClass || BUILD.hydratedAttribute) && (i.innerHTML = n + "{visibility:hidden}.hydrated{visibility:inherit}",
948
- i.setAttribute("data-styles", ""), a.insertBefore(i, r ? r.nextSibling : a.firstChild)),
949
- m = !1, d.length ? d.map((e => e.connectedCallback())) : BUILD.profile ? plt.jmp((() => $ = setTimeout(appDidLoad, 30, "timeout"))) : plt.jmp((() => $ = setTimeout(appDidLoad, 30))),
950
- o();
955
+ })), BUILD.invisiblePrehydration && (BUILD.hydratedClass || BUILD.hydratedAttribute)) {
956
+ d.innerHTML = s + "{visibility:hidden}.hydrated{visibility:inherit}", d.setAttribute("data-styles", "");
957
+ const e = null !== (o = plt.$nonce$) && void 0 !== o ? o : queryNonceMetaTagContent(doc);
958
+ null != e && d.setAttribute("nonce", e), r.insertBefore(d, i ? i.nextSibling : r.firstChild);
959
+ }
960
+ p = !1, c.length ? c.map((e => e.connectedCallback())) : BUILD.profile ? plt.jmp((() => m = setTimeout(appDidLoad, 30, "timeout"))) : plt.jmp((() => m = setTimeout(appDidLoad, 30))),
961
+ n();
951
962
  }, getConnect = (e, t) => {
952
963
  const o = () => {
953
964
  let e = doc.querySelector(t);
@@ -975,7 +986,7 @@ const callRender = (e, t, o) => {
975
986
  } catch (e) {
976
987
  consoleError(e);
977
988
  }
978
- }, getHostListenerTarget = (e, t) => BUILD.hostListenerTargetDocument && 4 & t ? doc : BUILD.hostListenerTargetWindow && 8 & t ? win : BUILD.hostListenerTargetBody && 16 & t ? doc.body : BUILD.hostListenerTargetParent && 32 & t ? e.parentElement : e, hostListenerOpts = e => 0 != (2 & e), insertVdomAnnotations = (e, t) => {
989
+ }, getHostListenerTarget = (e, t) => BUILD.hostListenerTargetDocument && 4 & t ? doc : BUILD.hostListenerTargetWindow && 8 & t ? win : BUILD.hostListenerTargetBody && 16 & t ? doc.body : BUILD.hostListenerTargetParent && 32 & t ? e.parentElement : e, hostListenerOpts = e => 0 != (2 & e), setNonce = e => plt.$nonce$ = e, insertVdomAnnotations = (e, t) => {
979
990
  if (null != e) {
980
991
  const o = {
981
992
  hostIds: 0,
@@ -1129,4 +1140,4 @@ const cmpModules = new Map, getModule = e => {
1129
1140
  isTesting: !1
1130
1141
  }, styles = new Map, modeResolutionChain = [];
1131
1142
 
1132
- export { Build, Context, Fragment, Host, addHostEventListeners, bootstrapLazy, cmpModules, connectedCallback, consoleDevError, consoleDevInfo, consoleDevWarn, consoleError, createEvent, defineCustomElement, disconnectedCallback, doc, forceModeUpdate, forceUpdate$1 as forceUpdate, getAssetPath, getConnect, getContext, getElement, getHostRef, getMode, getRenderingRef, getValue, hAsync as h, hydrateApp, insertVdomAnnotations, isMemberInElement, loadModule, modeResolutionChain, nextTick, parsePropertyValue, plt, postUpdateComponent, proxyComponent, proxyCustomElement, readTask, registerComponents, registerHost, registerInstance, renderVdom, setAssetPath, setErrorHandler, setMode, setPlatformHelpers, setValue, styles, supportsConstructableStylesheets, supportsListenerOptions, supportsShadow, win, writeTask };
1143
+ export { Build, Context, Fragment, Host, addHostEventListeners, bootstrapLazy, cmpModules, connectedCallback, consoleDevError, consoleDevInfo, consoleDevWarn, consoleError, createEvent, defineCustomElement, disconnectedCallback, doc, forceModeUpdate, forceUpdate$1 as forceUpdate, getAssetPath, getConnect, getContext, getElement, getHostRef, getMode, getRenderingRef, getValue, hAsync as h, hydrateApp, insertVdomAnnotations, isMemberInElement, loadModule, modeResolutionChain, nextTick, parsePropertyValue, plt, postUpdateComponent, proxyComponent, proxyCustomElement, readTask, registerComponents, registerHost, registerInstance, renderVdom, setAssetPath, setErrorHandler, setMode, setNonce, setPlatformHelpers, setValue, styles, supportsConstructableStylesheets, supportsListenerOptions, supportsShadow, win, writeTask };
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stencil/core/internal/hydrate",
3
- "version": "3.0.0-beta.1",
3
+ "version": "3.0.0-rc.1",
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
@@ -141,24 +141,25 @@ export interface HydrateFactoryOptions extends SerializeDocumentOptions {
141
141
  destroyDocument: boolean;
142
142
  }
143
143
  export interface Diagnostic {
144
- level: "error" | "warn" | "info" | "log" | "debug";
145
- type: string;
144
+ absFilePath?: string | undefined;
145
+ code?: string;
146
+ columnNumber?: number | undefined;
147
+ debugText?: string;
146
148
  header?: string;
147
149
  language?: string;
150
+ level: "error" | "warn" | "info" | "log" | "debug";
151
+ lineNumber?: number | undefined;
152
+ lines: PrintLine[];
148
153
  messageText: string;
149
- debugText?: string;
150
- code?: string;
151
- absFilePath?: string;
152
- relFilePath?: string;
153
- lineNumber?: number;
154
- columnNumber?: number;
155
- lines?: {
156
- lineIndex: number;
157
- lineNumber: number;
158
- text?: string;
159
- errorCharStart: number;
160
- errorLength?: number;
161
- }[];
154
+ relFilePath?: string | undefined;
155
+ type: string;
156
+ }
157
+ export interface PrintLine {
158
+ lineIndex: number;
159
+ lineNumber: number;
160
+ text?: string;
161
+ errorCharStart: number;
162
+ errorLength?: number;
162
163
  }
163
164
  export interface HydrateResults {
164
165
  buildId: string;
@@ -757,7 +757,8 @@ const templateWindows = new Map, isPromise = e => !!e && ("object" == typeof e |
757
757
  level: "warn",
758
758
  type: "css",
759
759
  header: "CSS Stringify",
760
- messageText: e
760
+ messageText: e,
761
+ lines: []
761
762
  });
762
763
  }
763
764
  } catch (e) {
@@ -765,7 +766,8 @@ const templateWindows = new Map, isPromise = e => !!e && ("object" == typeof e |
765
766
  level: "warn",
766
767
  type: "css",
767
768
  header: "CSS Parse",
768
- messageText: e
769
+ messageText: e,
770
+ lines: []
769
771
  });
770
772
  }
771
773
  }, SKIP_ATTRS = new Set([ "s-id", "c-id" ]), createHydrateBuildId = () => {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stencil/core/internal",
3
- "version": "3.0.0-beta.1",
3
+ "version": "3.0.0-rc.1",
4
4
  "description": "Stencil internals only to be imported by the Stencil Compiler. Breaking changes can and will happen at any time.",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",
@@ -43,6 +43,7 @@ export {
43
43
  setAssetPath,
44
44
  setErrorHandler,
45
45
  setMode,
46
+ setNonce,
46
47
  setPlatformHelpers,
47
48
  State,
48
49
  Watch,
@@ -1445,6 +1445,11 @@ export interface PlatformRuntime {
1445
1445
  $flags$: number;
1446
1446
  $orgLocNodes$?: Map<string, RenderNode>;
1447
1447
  $resourcesUrl$: string;
1448
+ /**
1449
+ * The nonce value to be applied to all script/style tags at runtime.
1450
+ * If `null`, the nonce attribute will not be applied.
1451
+ */
1452
+ $nonce$?: string | null;
1448
1453
  jmp: (c: Function) => any;
1449
1454
  raf: (c: FrameRequestCallback) => number;
1450
1455
  ael: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;
@@ -2072,6 +2077,11 @@ export interface NewSpecPageOptions {
2072
2077
  */
2073
2078
  attachStyles?: boolean;
2074
2079
  strictBuild?: boolean;
2080
+ /**
2081
+ * Default values to be set on the platform runtime object (@see PlatformRuntime) when creating
2082
+ * the spec page.
2083
+ */
2084
+ platform?: Partial<PlatformRuntime>;
2075
2085
  }
2076
2086
  /**
2077
2087
  * A record of `TypesMemberNameData` entities.
@@ -1,5 +1,5 @@
1
1
  import type { ConfigFlags } from '../cli/config-flags';
2
- import type { PrerenderUrlResults } from '../internal';
2
+ import type { PrerenderUrlResults, PrintLine } from '../internal';
3
3
  import type { JsonDocs } from './stencil-public-docs';
4
4
  export * from './stencil-public-docs';
5
5
  /**
@@ -151,7 +151,7 @@ export interface StencilConfig {
151
151
  * type of CSS properties and values are assigned before and after hydrating. This config
152
152
  * can also be used to not include the hydrated flag at all by setting it to `null`.
153
153
  */
154
- hydratedFlag?: HydratedFlag;
154
+ hydratedFlag?: HydratedFlag | null;
155
155
  /**
156
156
  * Ionic prefers to hide all components prior to hydration with a style tag appended
157
157
  * to the head of the document containing some `visibility: hidden;` css rules.
@@ -382,7 +382,7 @@ type RequireFields<T, K extends keyof T> = T & {
382
382
  /**
383
383
  * Fields in {@link Config} to make required for {@link ValidatedConfig}
384
384
  */
385
- type StrictConfigFields = 'flags' | 'logger' | 'outputTargets' | 'rootDir' | 'sys' | 'testing';
385
+ type StrictConfigFields = 'flags' | 'hydratedFlag' | 'logger' | 'outputTargets' | 'packageJsonFilePath' | 'rootDir' | 'sys' | 'testing';
386
386
  /**
387
387
  * A version of {@link Config} that makes certain fields required. This type represents a valid configuration entity.
388
388
  * When a configuration is received by the user, it is a bag of unverified data. In order to make stricter guarantees
@@ -2067,24 +2067,18 @@ export interface LoadConfigResults {
2067
2067
  };
2068
2068
  }
2069
2069
  export interface Diagnostic {
2070
- level: 'error' | 'warn' | 'info' | 'log' | 'debug';
2071
- type: string;
2070
+ absFilePath?: string | undefined;
2071
+ code?: string;
2072
+ columnNumber?: number | undefined;
2073
+ debugText?: string;
2072
2074
  header?: string;
2073
2075
  language?: string;
2076
+ level: 'error' | 'warn' | 'info' | 'log' | 'debug';
2077
+ lineNumber?: number | undefined;
2078
+ lines: PrintLine[];
2074
2079
  messageText: string;
2075
- debugText?: string;
2076
- code?: string;
2077
- absFilePath?: string;
2078
- relFilePath?: string;
2079
- lineNumber?: number;
2080
- columnNumber?: number;
2081
- lines?: {
2082
- lineIndex: number;
2083
- lineNumber: number;
2084
- text?: string;
2085
- errorCharStart: number;
2086
- errorLength?: number;
2087
- }[];
2080
+ relFilePath?: string | undefined;
2081
+ type: string;
2088
2082
  }
2089
2083
  export interface CacheStorage {
2090
2084
  get(key: string): Promise<any>;