@rededor/cura 0.3.4-alpha.1 → 0.3.4-alpha.2

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 (193) hide show
  1. package/dist/cjs/{app-globals-0f70160b.js → app-globals-a41d7f40.js} +40 -17
  2. package/dist/cjs/app-globals-a41d7f40.js.map +1 -0
  3. package/dist/cjs/css-shim-83cf0349.js +8 -0
  4. package/dist/cjs/css-shim-83cf0349.js.map +1 -0
  5. package/dist/cjs/cura-button_6.cjs.entry.js +322 -0
  6. package/dist/cjs/cura-button_6.cjs.entry.js.map +1 -0
  7. package/dist/cjs/cura-icons-view.cjs.entry.js +4 -2
  8. package/dist/cjs/cura-icons-view.cjs.entry.js.map +1 -0
  9. package/dist/cjs/cura.cjs.js +19 -4
  10. package/dist/cjs/cura.cjs.js.map +1 -0
  11. package/dist/cjs/{index-76f95c4b.js → index-29633529.js} +502 -39
  12. package/dist/cjs/index-29633529.js.map +1 -0
  13. package/dist/cjs/index.cjs.js +2 -0
  14. package/dist/cjs/index.cjs.js.map +1 -0
  15. package/dist/cjs/loader.cjs.js +23 -4
  16. package/dist/cjs/loader.cjs.js.map +1 -0
  17. package/dist/cjs/shadow-css-8baae635.js +391 -0
  18. package/dist/cjs/shadow-css-8baae635.js.map +1 -0
  19. package/dist/collection/api/cura-api.js +1 -0
  20. package/dist/collection/api/cura-api.js.map +1 -0
  21. package/dist/collection/api/cura-api.type.js +1 -0
  22. package/dist/collection/api/cura-api.type.js.map +1 -0
  23. package/dist/collection/api/modules/cura-theme-colors-module.js +1 -0
  24. package/dist/collection/api/modules/cura-theme-colors-module.js.map +1 -0
  25. package/dist/collection/api/modules/cura-theme-fonts-module.js +1 -0
  26. package/dist/collection/api/modules/cura-theme-fonts-module.js.map +1 -0
  27. package/dist/collection/api/modules/cura-theme-module.js +1 -0
  28. package/dist/collection/api/modules/cura-theme-module.js.map +1 -0
  29. package/dist/collection/api/modules/cura-theme-spacing-module.js +1 -0
  30. package/dist/collection/api/modules/cura-theme-spacing-module.js.map +1 -0
  31. package/dist/collection/api/theme-presets/static.js +1 -0
  32. package/dist/collection/api/theme-presets/static.js.map +1 -0
  33. package/dist/collection/api/theme-presets/theme-default.js +6 -5
  34. package/dist/collection/api/theme-presets/theme-default.js.map +1 -0
  35. package/dist/collection/api/theme-presets/theme-maternity.js +8 -0
  36. package/dist/collection/api/theme-presets/theme-maternity.js.map +1 -0
  37. package/dist/collection/api/theme-presets/theme-oncology.js +27 -12
  38. package/dist/collection/api/theme-presets/theme-oncology.js.map +1 -0
  39. package/dist/collection/api/theme-presets/theme-presets.js +1 -0
  40. package/dist/collection/api/theme-presets/theme-presets.js.map +1 -0
  41. package/dist/collection/assets/icons/iconset-default-list.js +1 -0
  42. package/dist/collection/assets/icons/iconset-default-list.js.map +1 -0
  43. package/dist/collection/collection-manifest.json +3 -2
  44. package/dist/collection/components/buttons/cura-button/cura-button.css +70 -0
  45. package/dist/collection/components/buttons/cura-button/cura-button.js +255 -0
  46. package/dist/collection/components/buttons/cura-button/cura-button.js.map +1 -0
  47. package/dist/collection/components/cura-icon/cura-icon.css +2 -2
  48. package/dist/collection/components/cura-icon/cura-icon.js +8 -5
  49. package/dist/collection/components/cura-icon/cura-icon.js.map +1 -0
  50. package/dist/collection/components/cura-icons-view/cura-icons-view.js +3 -1
  51. package/dist/collection/components/cura-icons-view/cura-icons-view.js.map +1 -0
  52. package/dist/collection/components/cura-page-template/cura-page-template.css +24 -24
  53. package/dist/collection/components/cura-page-template/cura-page-template.js +3 -1
  54. package/dist/collection/components/cura-page-template/cura-page-template.js.map +1 -0
  55. package/dist/collection/components/text/cura-display/cura-display.css +13 -14
  56. package/dist/collection/components/text/cura-display/cura-display.js +3 -17
  57. package/dist/collection/components/text/cura-display/cura-display.js.map +1 -0
  58. package/dist/collection/components/text/cura-heading/cura-heading.css +15 -15
  59. package/dist/collection/components/text/cura-heading/cura-heading.js +3 -21
  60. package/dist/collection/components/text/cura-heading/cura-heading.js.map +1 -0
  61. package/dist/collection/components/text/cura-paragraph/cura-paragraph.css +16 -17
  62. package/dist/collection/components/text/cura-paragraph/cura-paragraph.js +3 -13
  63. package/dist/collection/components/text/cura-paragraph/cura-paragraph.js.map +1 -0
  64. package/dist/collection/index.js +1 -0
  65. package/dist/collection/index.js.map +1 -0
  66. package/dist/collection/rededor-cura-start.js +1 -0
  67. package/dist/collection/rededor-cura-start.js.map +1 -0
  68. package/dist/collection/utils/utils.js +1 -0
  69. package/dist/collection/utils/utils.js.map +1 -0
  70. package/dist/collection/utils/utils.spec.js +16 -0
  71. package/dist/collection/utils/utils.spec.js.map +1 -0
  72. package/dist/components/cura-button.d.ts +11 -0
  73. package/dist/components/cura-button.js +97 -0
  74. package/dist/components/cura-button.js.map +1 -0
  75. package/dist/components/cura-display.js +7 -20
  76. package/dist/components/cura-display.js.map +1 -0
  77. package/dist/components/cura-heading.js +7 -24
  78. package/dist/components/cura-heading.js.map +1 -0
  79. package/dist/components/cura-icon.js +2 -0
  80. package/dist/components/cura-icon.js.map +1 -0
  81. package/dist/components/cura-icon2.js +12 -8
  82. package/dist/components/cura-icon2.js.map +1 -0
  83. package/dist/components/cura-icons-view.js +6 -3
  84. package/dist/components/cura-icons-view.js.map +1 -0
  85. package/dist/components/cura-page-template.js +7 -4
  86. package/dist/components/cura-page-template.js.map +1 -0
  87. package/dist/components/cura-paragraph.js +7 -16
  88. package/dist/components/cura-paragraph.js.map +1 -0
  89. package/dist/components/index.d.ts +21 -9
  90. package/dist/components/index.js +67 -24
  91. package/dist/components/index.js.map +1 -0
  92. package/dist/cura/cura.esm.js +2 -1
  93. package/dist/cura/cura.esm.js.map +1 -0
  94. package/dist/cura/cura.js +3 -1
  95. package/dist/cura/index.esm.js +2 -0
  96. package/dist/cura/index.esm.js.map +1 -0
  97. package/dist/cura/p-118112e5.system.js +14 -0
  98. package/dist/cura/p-118112e5.system.js.map +1 -0
  99. package/dist/cura/p-183305c3.js +2 -0
  100. package/dist/cura/p-183305c3.js.map +1 -0
  101. package/dist/cura/p-3f6aaefc.system.js +2 -0
  102. package/dist/cura/p-3f6aaefc.system.js.map +1 -0
  103. package/dist/cura/p-4c60d085.entry.js +2 -0
  104. package/dist/cura/p-4c60d085.entry.js.map +1 -0
  105. package/dist/cura/p-4fc49972.system.js +2 -0
  106. package/dist/cura/p-4fc49972.system.js.map +1 -0
  107. package/dist/cura/p-50ea2036.system.js +2 -1
  108. package/dist/cura/p-50ea2036.system.js.map +1 -0
  109. package/dist/cura/p-61953b75.system.js +2 -0
  110. package/dist/cura/p-61953b75.system.js.map +1 -0
  111. package/dist/cura/p-731abb13.entry.js +2 -0
  112. package/dist/cura/p-731abb13.entry.js.map +1 -0
  113. package/dist/cura/{p-54c09404.system.entry.js → p-958c8695.system.entry.js} +2 -1
  114. package/dist/cura/p-958c8695.system.entry.js.map +1 -0
  115. package/dist/cura/p-b5872ed0.system.entry.js +2 -0
  116. package/dist/cura/p-b5872ed0.system.entry.js.map +1 -0
  117. package/dist/cura/p-bac0b4ab.js +2 -0
  118. package/dist/cura/p-bac0b4ab.js.map +1 -0
  119. package/dist/cura/p-beab48cd.js +13 -0
  120. package/dist/cura/p-beab48cd.js.map +1 -0
  121. package/dist/cura/p-c30e14d5.system.js +3 -0
  122. package/dist/cura/p-c30e14d5.system.js.map +1 -0
  123. package/dist/cura/p-d5990392.js +3 -0
  124. package/dist/cura/p-d5990392.js.map +1 -0
  125. package/dist/esm/{app-globals-cb45bff3.js → app-globals-8ed931e6.js} +40 -17
  126. package/dist/esm/app-globals-8ed931e6.js.map +1 -0
  127. package/dist/esm/css-shim-d13f0738.js +6 -0
  128. package/dist/esm/css-shim-d13f0738.js.map +1 -0
  129. package/dist/esm/cura-button_6.entry.js +313 -0
  130. package/dist/esm/cura-button_6.entry.js.map +1 -0
  131. package/dist/esm/cura-icons-view.entry.js +4 -2
  132. package/dist/esm/cura-icons-view.entry.js.map +1 -0
  133. package/dist/esm/cura.js +16 -4
  134. package/dist/esm/cura.js.map +1 -0
  135. package/dist/esm/{index-7e8c969d.js → index-e11775ce.js} +499 -40
  136. package/dist/esm/index-e11775ce.js.map +1 -0
  137. package/dist/esm/index.js +2 -0
  138. package/dist/esm/index.js.map +1 -0
  139. package/dist/esm/loader.js +23 -4
  140. package/dist/esm/loader.js.map +1 -0
  141. package/dist/esm/polyfills/css-shim.js +1 -1
  142. package/dist/esm/shadow-css-07b0c8c8.js +389 -0
  143. package/dist/esm/shadow-css-07b0c8c8.js.map +1 -0
  144. package/dist/esm-es5/app-globals-8ed931e6.js +2 -0
  145. package/dist/esm-es5/app-globals-8ed931e6.js.map +1 -0
  146. package/dist/esm-es5/css-shim-d13f0738.js +2 -0
  147. package/dist/esm-es5/css-shim-d13f0738.js.map +1 -0
  148. package/dist/esm-es5/cura-button_6.entry.js +2 -0
  149. package/dist/esm-es5/cura-button_6.entry.js.map +1 -0
  150. package/dist/esm-es5/cura-icons-view.entry.js +2 -1
  151. package/dist/esm-es5/cura-icons-view.entry.js.map +1 -0
  152. package/dist/esm-es5/cura.js +2 -1
  153. package/dist/esm-es5/cura.js.map +1 -0
  154. package/dist/esm-es5/index-e11775ce.js +3 -0
  155. package/dist/esm-es5/index-e11775ce.js.map +1 -0
  156. package/dist/esm-es5/index.js +2 -0
  157. package/dist/esm-es5/index.js.map +1 -0
  158. package/dist/esm-es5/loader.js +2 -1
  159. package/dist/esm-es5/loader.js.map +1 -0
  160. package/dist/esm-es5/shadow-css-07b0c8c8.js +13 -0
  161. package/dist/esm-es5/shadow-css-07b0c8c8.js.map +1 -0
  162. package/dist/{dist/loader → loader}/cdn.js +1 -1
  163. package/dist/{dist/loader → loader}/index.cjs.js +1 -1
  164. package/dist/{dist/loader → loader}/index.d.ts +10 -1
  165. package/dist/loader/index.es2017.js +3 -0
  166. package/dist/{dist/loader → loader}/index.js +2 -2
  167. package/dist/types/api/theme-presets/theme-maternity.d.ts +7 -0
  168. package/dist/types/api/theme-presets/theme-oncology.d.ts +5 -5
  169. package/dist/types/api/theme-presets/theme-presets.d.ts +12 -5
  170. package/dist/types/components/buttons/cura-button/cura-button.d.ts +49 -0
  171. package/dist/types/components.d.ts +93 -0
  172. package/dist/types/stencil-public-runtime.d.ts +77 -15
  173. package/package.json +7 -7
  174. package/dist/cjs/cura-display_4.cjs.entry.js +0 -257
  175. package/dist/cjs/cura-icon.cjs.entry.js +0 -59
  176. package/dist/cura/p-0b79032f.system.js +0 -2
  177. package/dist/cura/p-11002b56.system.js +0 -1
  178. package/dist/cura/p-32769783.system.js +0 -1
  179. package/dist/cura/p-57c5329e.js +0 -2
  180. package/dist/cura/p-5a6643e1.entry.js +0 -1
  181. package/dist/cura/p-a2ad5637.system.entry.js +0 -1
  182. package/dist/cura/p-aca36c98.js +0 -1
  183. package/dist/cura/p-bd91ecb9.system.entry.js +0 -1
  184. package/dist/cura/p-d69916ee.entry.js +0 -1
  185. package/dist/cura/p-f8a5b97d.entry.js +0 -1
  186. package/dist/dist/loader/index.es2017.js +0 -3
  187. package/dist/esm/cura-display_4.entry.js +0 -250
  188. package/dist/esm/cura-icon.entry.js +0 -55
  189. package/dist/esm-es5/app-globals-cb45bff3.js +0 -1
  190. package/dist/esm-es5/cura-display_4.entry.js +0 -1
  191. package/dist/esm-es5/cura-icon.entry.js +0 -1
  192. package/dist/esm-es5/index-7e8c969d.js +0 -2
  193. /package/dist/{dist/loader → loader}/package.json +0 -0
@@ -8,6 +8,7 @@ const NAMESPACE = 'cura';
8
8
  *
9
9
  * Modified for Stencil's renderer and slot projection
10
10
  */
11
+ let scopeId;
11
12
  let contentRef;
12
13
  let hostTagName;
13
14
  let useNativeShadowDom = false;
@@ -29,6 +30,13 @@ const uniqueTime = (key, measureText) => {
29
30
  };
30
31
  }
31
32
  };
33
+ const CONTENT_REF_ID = 'r';
34
+ const ORG_LOCATION_ID = 'o';
35
+ const SLOT_NODE_ID = 's';
36
+ const TEXT_NODE_ID = 't';
37
+ const HYDRATE_ID = 's-id';
38
+ const HYDRATED_STYLE_ID = 'sty-id';
39
+ const HYDRATE_CHILD_ID = 'c-id';
32
40
  const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
33
41
  const XLINK_NS = 'http://www.w3.org/1999/xlink';
34
42
  /**
@@ -44,11 +52,31 @@ const EMPTY_OBJ = {};
44
52
  */
45
53
  const SVG_NS = 'http://www.w3.org/2000/svg';
46
54
  const HTML_NS = 'http://www.w3.org/1999/xhtml';
55
+ const isDef = (v) => v != null;
56
+ /**
57
+ * Check whether a value is a 'complex type', defined here as an object or a
58
+ * function.
59
+ *
60
+ * @param o the value to check
61
+ * @returns whether it's a complex type or not
62
+ */
47
63
  const isComplexType = (o) => {
48
64
  // https://jsperf.com/typeof-fn-object/5
49
65
  o = typeof o;
50
66
  return o === 'object' || o === 'function';
51
67
  };
68
+ /**
69
+ * Helper method for querying a `meta` tag that contains a nonce value
70
+ * out of a DOM's head.
71
+ *
72
+ * @param doc The DOM containing the `head` to query against
73
+ * @returns The content of the meta tag representing the nonce value, or `undefined` if no tag
74
+ * exists or the tag has no content.
75
+ */
76
+ function queryNonceMetaTagContent(doc) {
77
+ var _a, _b, _c;
78
+ 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;
79
+ }
52
80
  /**
53
81
  * Production h() function based on Preact by
54
82
  * Jason Miller (@developit)
@@ -57,7 +85,6 @@ const isComplexType = (o) => {
57
85
  *
58
86
  * Modified for Stencil's compiler and vdom
59
87
  */
60
- // const stack: any[] = [];
61
88
  // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
62
89
  // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
63
90
  const h = (nodeName, vnodeData, ...children) => {
@@ -115,6 +142,14 @@ const h = (nodeName, vnodeData, ...children) => {
115
142
  }
116
143
  return vnode;
117
144
  };
145
+ /**
146
+ * A utility function for creating a virtual DOM node from a tag and some
147
+ * possible text content.
148
+ *
149
+ * @param tag the tag for this element
150
+ * @param text possible text content for the node
151
+ * @returns a newly-minted virtual DOM node
152
+ */
118
153
  const newVNode = (tag, text) => {
119
154
  const vnode = {
120
155
  $flags$: 0,
@@ -132,7 +167,218 @@ const newVNode = (tag, text) => {
132
167
  return vnode;
133
168
  };
134
169
  const Host = {};
170
+ /**
171
+ * Check whether a given node is a Host node or not
172
+ *
173
+ * @param node the virtual DOM node to check
174
+ * @returns whether it's a Host node or not
175
+ */
135
176
  const isHost = (node) => node && node.$tag$ === Host;
177
+ const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
178
+ const endHydrate = createTime('hydrateClient', tagName);
179
+ const shadowRoot = hostElm.shadowRoot;
180
+ const childRenderNodes = [];
181
+ const slotNodes = [];
182
+ const shadowRootNodes = shadowRoot ? [] : null;
183
+ const vnode = (hostRef.$vnode$ = newVNode(tagName, null));
184
+ if (!plt.$orgLocNodes$) {
185
+ initializeDocumentHydrate(doc.body, (plt.$orgLocNodes$ = new Map()));
186
+ }
187
+ hostElm[HYDRATE_ID] = hostId;
188
+ hostElm.removeAttribute(HYDRATE_ID);
189
+ clientHydrate(vnode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, hostElm, hostId);
190
+ childRenderNodes.map((c) => {
191
+ const orgLocationId = c.$hostId$ + '.' + c.$nodeId$;
192
+ const orgLocationNode = plt.$orgLocNodes$.get(orgLocationId);
193
+ const node = c.$elm$;
194
+ if (orgLocationNode && supportsShadow && orgLocationNode['s-en'] === '') {
195
+ orgLocationNode.parentNode.insertBefore(node, orgLocationNode.nextSibling);
196
+ }
197
+ if (!shadowRoot) {
198
+ node['s-hn'] = tagName;
199
+ if (orgLocationNode) {
200
+ node['s-ol'] = orgLocationNode;
201
+ node['s-ol']['s-nr'] = node;
202
+ }
203
+ }
204
+ plt.$orgLocNodes$.delete(orgLocationId);
205
+ });
206
+ if (shadowRoot) {
207
+ shadowRootNodes.map((shadowRootNode) => {
208
+ if (shadowRootNode) {
209
+ shadowRoot.appendChild(shadowRootNode);
210
+ }
211
+ });
212
+ }
213
+ endHydrate();
214
+ };
215
+ const clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node, hostId) => {
216
+ let childNodeType;
217
+ let childIdSplt;
218
+ let childVNode;
219
+ let i;
220
+ if (node.nodeType === 1 /* NODE_TYPE.ElementNode */) {
221
+ childNodeType = node.getAttribute(HYDRATE_CHILD_ID);
222
+ if (childNodeType) {
223
+ // got the node data from the element's attribute
224
+ // `${hostId}.${nodeId}.${depth}.${index}`
225
+ childIdSplt = childNodeType.split('.');
226
+ if (childIdSplt[0] === hostId || childIdSplt[0] === '0') {
227
+ childVNode = {
228
+ $flags$: 0,
229
+ $hostId$: childIdSplt[0],
230
+ $nodeId$: childIdSplt[1],
231
+ $depth$: childIdSplt[2],
232
+ $index$: childIdSplt[3],
233
+ $tag$: node.tagName.toLowerCase(),
234
+ $elm$: node,
235
+ $attrs$: null,
236
+ $children$: null,
237
+ $key$: null,
238
+ $name$: null,
239
+ $text$: null,
240
+ };
241
+ childRenderNodes.push(childVNode);
242
+ node.removeAttribute(HYDRATE_CHILD_ID);
243
+ // this is a new child vnode
244
+ // so ensure its parent vnode has the vchildren array
245
+ if (!parentVNode.$children$) {
246
+ parentVNode.$children$ = [];
247
+ }
248
+ // add our child vnode to a specific index of the vnode's children
249
+ parentVNode.$children$[childVNode.$index$] = childVNode;
250
+ // this is now the new parent vnode for all the next child checks
251
+ parentVNode = childVNode;
252
+ if (shadowRootNodes && childVNode.$depth$ === '0') {
253
+ shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
254
+ }
255
+ }
256
+ }
257
+ // recursively drill down, end to start so we can remove nodes
258
+ for (i = node.childNodes.length - 1; i >= 0; i--) {
259
+ clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.childNodes[i], hostId);
260
+ }
261
+ if (node.shadowRoot) {
262
+ // keep drilling down through the shadow root nodes
263
+ for (i = node.shadowRoot.childNodes.length - 1; i >= 0; i--) {
264
+ clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.shadowRoot.childNodes[i], hostId);
265
+ }
266
+ }
267
+ }
268
+ else if (node.nodeType === 8 /* NODE_TYPE.CommentNode */) {
269
+ // `${COMMENT_TYPE}.${hostId}.${nodeId}.${depth}.${index}`
270
+ childIdSplt = node.nodeValue.split('.');
271
+ if (childIdSplt[1] === hostId || childIdSplt[1] === '0') {
272
+ // comment node for either the host id or a 0 host id
273
+ childNodeType = childIdSplt[0];
274
+ childVNode = {
275
+ $flags$: 0,
276
+ $hostId$: childIdSplt[1],
277
+ $nodeId$: childIdSplt[2],
278
+ $depth$: childIdSplt[3],
279
+ $index$: childIdSplt[4],
280
+ $elm$: node,
281
+ $attrs$: null,
282
+ $children$: null,
283
+ $key$: null,
284
+ $name$: null,
285
+ $tag$: null,
286
+ $text$: null,
287
+ };
288
+ if (childNodeType === TEXT_NODE_ID) {
289
+ childVNode.$elm$ = node.nextSibling;
290
+ if (childVNode.$elm$ && childVNode.$elm$.nodeType === 3 /* NODE_TYPE.TextNode */) {
291
+ childVNode.$text$ = childVNode.$elm$.textContent;
292
+ childRenderNodes.push(childVNode);
293
+ // remove the text comment since it's no longer needed
294
+ node.remove();
295
+ if (!parentVNode.$children$) {
296
+ parentVNode.$children$ = [];
297
+ }
298
+ parentVNode.$children$[childVNode.$index$] = childVNode;
299
+ if (shadowRootNodes && childVNode.$depth$ === '0') {
300
+ shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
301
+ }
302
+ }
303
+ }
304
+ else if (childVNode.$hostId$ === hostId) {
305
+ // this comment node is specifcally for this host id
306
+ if (childNodeType === SLOT_NODE_ID) {
307
+ // `${SLOT_NODE_ID}.${hostId}.${nodeId}.${depth}.${index}.${slotName}`;
308
+ childVNode.$tag$ = 'slot';
309
+ if (childIdSplt[5]) {
310
+ node['s-sn'] = childVNode.$name$ = childIdSplt[5];
311
+ }
312
+ else {
313
+ node['s-sn'] = '';
314
+ }
315
+ node['s-sr'] = true;
316
+ if (shadowRootNodes) {
317
+ // browser support shadowRoot and this is a shadow dom component
318
+ // create an actual slot element
319
+ childVNode.$elm$ = doc.createElement(childVNode.$tag$);
320
+ if (childVNode.$name$) {
321
+ // add the slot name attribute
322
+ childVNode.$elm$.setAttribute('name', childVNode.$name$);
323
+ }
324
+ // insert the new slot element before the slot comment
325
+ node.parentNode.insertBefore(childVNode.$elm$, node);
326
+ // remove the slot comment since it's not needed for shadow
327
+ node.remove();
328
+ if (childVNode.$depth$ === '0') {
329
+ shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
330
+ }
331
+ }
332
+ slotNodes.push(childVNode);
333
+ if (!parentVNode.$children$) {
334
+ parentVNode.$children$ = [];
335
+ }
336
+ parentVNode.$children$[childVNode.$index$] = childVNode;
337
+ }
338
+ else if (childNodeType === CONTENT_REF_ID) {
339
+ // `${CONTENT_REF_ID}.${hostId}`;
340
+ if (shadowRootNodes) {
341
+ // remove the content ref comment since it's not needed for shadow
342
+ node.remove();
343
+ }
344
+ else {
345
+ hostElm['s-cr'] = node;
346
+ node['s-cn'] = true;
347
+ }
348
+ }
349
+ }
350
+ }
351
+ }
352
+ else if (parentVNode && parentVNode.$tag$ === 'style') {
353
+ const vnode = newVNode(null, node.textContent);
354
+ vnode.$elm$ = node;
355
+ vnode.$index$ = '0';
356
+ parentVNode.$children$ = [vnode];
357
+ }
358
+ };
359
+ const initializeDocumentHydrate = (node, orgLocNodes) => {
360
+ if (node.nodeType === 1 /* NODE_TYPE.ElementNode */) {
361
+ let i = 0;
362
+ for (; i < node.childNodes.length; i++) {
363
+ initializeDocumentHydrate(node.childNodes[i], orgLocNodes);
364
+ }
365
+ if (node.shadowRoot) {
366
+ for (i = 0; i < node.shadowRoot.childNodes.length; i++) {
367
+ initializeDocumentHydrate(node.shadowRoot.childNodes[i], orgLocNodes);
368
+ }
369
+ }
370
+ }
371
+ else if (node.nodeType === 8 /* NODE_TYPE.CommentNode */) {
372
+ const childIdSplt = node.nodeValue.split('.');
373
+ if (childIdSplt[0] === ORG_LOCATION_ID) {
374
+ orgLocNodes.set(childIdSplt[1] + '.' + childIdSplt[2], node);
375
+ node.nodeValue = '';
376
+ // useful to know if the original location is
377
+ // the root light-dom of a shadow dom component
378
+ node['s-en'] = childIdSplt[3];
379
+ }
380
+ }
381
+ };
136
382
  /**
137
383
  * Parse a new property value for a given property type.
138
384
  *
@@ -211,6 +457,7 @@ const registerStyle = (scopeId, cssText, allowCS) => {
211
457
  styles.set(scopeId, style);
212
458
  };
213
459
  const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
460
+ var _a;
214
461
  let scopeId = getScopeId(cmpMeta);
215
462
  const style = styles.get(scopeId);
216
463
  // if an element is NOT connected then getRootNode() will return the wrong root node
@@ -225,11 +472,36 @@ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
225
472
  rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
226
473
  }
227
474
  if (!appliedStyles.has(scopeId)) {
228
- {
229
- {
475
+ if (styleContainerNode.host &&
476
+ (styleElm = styleContainerNode.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId}"]`))) {
477
+ // This is only happening on native shadow-dom, do not needs CSS var shim
478
+ styleElm.innerHTML = style;
479
+ }
480
+ else {
481
+ // TODO(STENCIL-659): Remove code implementing the CSS variable shim
482
+ if (plt.$cssShim$) {
483
+ // TODO(STENCIL-659): Remove code implementing the CSS variable shim
484
+ styleElm = plt.$cssShim$.createHostStyle(hostElm, scopeId, style,
485
+ // TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
486
+ !!(cmpMeta.$flags$ & 10 /* CMP_FLAGS.needsScopedEncapsulation */));
487
+ const newScopeId = styleElm['s-sc'];
488
+ if (newScopeId) {
489
+ scopeId = newScopeId;
490
+ // we don't want to add this styleID to the appliedStyles Set
491
+ // since the cssVarShim might need to apply several different
492
+ // stylesheets for the same component
493
+ appliedStyles = null;
494
+ }
495
+ }
496
+ else {
230
497
  styleElm = doc.createElement('style');
231
498
  styleElm.innerHTML = style;
232
499
  }
500
+ // Apply CSP nonce to the style tag if it exists
501
+ const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
502
+ if (nonce != null) {
503
+ styleElm.setAttribute('nonce', nonce);
504
+ }
233
505
  styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
234
506
  }
235
507
  if (appliedStyles) {
@@ -246,11 +518,25 @@ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
246
518
  const attachStyles = (hostRef) => {
247
519
  const cmpMeta = hostRef.$cmpMeta$;
248
520
  const elm = hostRef.$hostElement$;
521
+ const flags = cmpMeta.$flags$;
249
522
  const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
250
- addStyle(elm.getRootNode(), cmpMeta);
523
+ const scopeId = addStyle(supportsShadow && elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta, hostRef.$modeName$, elm);
524
+ // TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
525
+ if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
526
+ // only required when we're NOT using native shadow dom (slot)
527
+ // or this browser doesn't support native shadow dom
528
+ // and this host element was NOT created with SSR
529
+ // let's pick out the inner content for slot projection
530
+ // create a node to represent where the original
531
+ // content was first placed, which is useful later on
532
+ // DOM WRITE!!
533
+ elm['s-sc'] = scopeId;
534
+ elm.classList.add(scopeId + '-h');
535
+ }
251
536
  endAttachStyles();
252
537
  };
253
538
  const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
539
+ const convertScopedToShadow = (css) => css.replace(/\/\*!@([^\/]+)\*\/[^\{]+\{/g, '$1{');
254
540
  /**
255
541
  * Production setAccessor() function based on Preact by
256
542
  * Jason Miller (@developit)
@@ -436,6 +722,10 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
436
722
  // remember for later we need to check to relocate nodes
437
723
  checkSlotRelocate = true;
438
724
  if (newVNode.$tag$ === 'slot') {
725
+ if (scopeId) {
726
+ // scoped css needs to add its scoped id to the parent element
727
+ parentElm.classList.add(scopeId + '-s');
728
+ }
439
729
  newVNode.$flags$ |= newVNode.$children$
440
730
  ? // slot element has fallback content
441
731
  2 /* VNODE_FLAGS.isSlotFallback */
@@ -468,10 +758,15 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
468
758
  {
469
759
  updateElement(null, newVNode, isSvgMode);
470
760
  }
761
+ if (isDef(scopeId) && elm['s-si'] !== scopeId) {
762
+ // if there is a scopeId and this is the initial render
763
+ // then let's add the scopeId as a css class
764
+ elm.classList.add((elm['s-si'] = scopeId));
765
+ }
471
766
  if (newVNode.$children$) {
472
767
  for (i = 0; i < newVNode.$children$.length; ++i) {
473
768
  // create the node
474
- childNode = createElm(oldParentVNode, newVNode, i);
769
+ childNode = createElm(oldParentVNode, newVNode, i, elm);
475
770
  // return node could have been null
476
771
  if (childNode) {
477
772
  // append our new node
@@ -534,12 +829,30 @@ const putBackInOriginalLocation = (parentElm, recursive) => {
534
829
  }
535
830
  plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
536
831
  };
832
+ /**
833
+ * Create DOM nodes corresponding to a list of {@link d.Vnode} objects and
834
+ * add them to the DOM in the appropriate place.
835
+ *
836
+ * @param parentElm the DOM node which should be used as a parent for the new
837
+ * DOM nodes
838
+ * @param before a child of the `parentElm` which the new children should be
839
+ * inserted before (optional)
840
+ * @param parentVNode the parent virtual DOM node
841
+ * @param vnodes the new child virtual DOM nodes to produce DOM nodes for
842
+ * @param startIdx the index in the child virtual DOM nodes at which to start
843
+ * creating DOM nodes (inclusive)
844
+ * @param endIdx the index in the child virtual DOM nodes at which to stop
845
+ * creating DOM nodes (inclusive)
846
+ */
537
847
  const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
538
848
  let containerElm = ((parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
539
849
  let childNode;
850
+ if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
851
+ containerElm = containerElm.shadowRoot;
852
+ }
540
853
  for (; startIdx <= endIdx; ++startIdx) {
541
854
  if (vnodes[startIdx]) {
542
- childNode = createElm(null, parentVNode, startIdx);
855
+ childNode = createElm(null, parentVNode, startIdx, parentElm);
543
856
  if (childNode) {
544
857
  vnodes[startIdx].$elm$ = childNode;
545
858
  containerElm.insertBefore(childNode, referenceNode(before) );
@@ -547,26 +860,40 @@ const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) =>
547
860
  }
548
861
  }
549
862
  };
550
- const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
551
- for (; startIdx <= endIdx; ++startIdx) {
552
- if ((vnode = vnodes[startIdx])) {
553
- elm = vnode.$elm$;
554
- {
555
- // we're removing this element
556
- // so it's possible we need to show slot fallback content now
557
- checkSlotFallbackVisibility = true;
558
- if (elm['s-ol']) {
559
- // remove the original location comment
560
- elm['s-ol'].remove();
561
- }
562
- else {
563
- // it's possible that child nodes of the node
564
- // that's being removed are slot nodes
565
- putBackInOriginalLocation(elm, true);
863
+ /**
864
+ * Remove the DOM elements corresponding to a list of {@link d.VNode} objects.
865
+ * This can be used to, for instance, clean up after a list of children which
866
+ * should no longer be shown.
867
+ *
868
+ * This function also handles some of Stencil's slot relocation logic.
869
+ *
870
+ * @param vnodes a list of virtual DOM nodes to remove
871
+ * @param startIdx the index at which to start removing nodes (inclusive)
872
+ * @param endIdx the index at which to stop removing nodes (inclusive)
873
+ */
874
+ const removeVnodes = (vnodes, startIdx, endIdx) => {
875
+ for (let index = startIdx; index <= endIdx; ++index) {
876
+ const vnode = vnodes[index];
877
+ if (vnode) {
878
+ const elm = vnode.$elm$;
879
+ if (elm) {
880
+ {
881
+ // we're removing this element
882
+ // so it's possible we need to show slot fallback content now
883
+ checkSlotFallbackVisibility = true;
884
+ if (elm['s-ol']) {
885
+ // remove the original location comment
886
+ elm['s-ol'].remove();
887
+ }
888
+ else {
889
+ // it's possible that child nodes of the node
890
+ // that's being removed are slot nodes
891
+ putBackInOriginalLocation(elm, true);
892
+ }
566
893
  }
894
+ // remove the vnode's element from the dom
895
+ elm.remove();
567
896
  }
568
- // remove the vnode's element from the dom
569
- elm.remove();
570
897
  }
571
898
  }
572
899
  };
@@ -754,7 +1081,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
754
1081
  // the key of the first new child OR the build is not using `key`
755
1082
  // attributes at all. In either case we need to create a new element
756
1083
  // for the new node.
757
- node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
1084
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx, parentElm);
758
1085
  newStartVnode = newCh[++newStartIdx];
759
1086
  }
760
1087
  if (node) {
@@ -787,7 +1114,8 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
787
1114
  *
788
1115
  * So, in other words, if `key` attrs are not set on VNodes which may be
789
1116
  * changing order within a `children` array or something along those lines then
790
- * we could obtain a false positive and then have to do needless re-rendering.
1117
+ * we could obtain a false negative and then have to do needless re-rendering
1118
+ * (i.e. we'd say two VNodes aren't equal when in fact they should be).
791
1119
  *
792
1120
  * @param leftVNode the first VNode to check
793
1121
  * @param rightVNode the second VNode to check
@@ -1006,6 +1334,18 @@ const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
1006
1334
  }
1007
1335
  return slotNameAttr === '';
1008
1336
  };
1337
+ /**
1338
+ * The main entry point for Stencil's virtual DOM-based rendering engine
1339
+ *
1340
+ * Given a {@link d.HostRef} container and some virtual DOM nodes, this
1341
+ * function will handle creating a virtual DOM tree with a single root, patching
1342
+ * the current virtual DOM tree onto an old one (if any), dealing with slot
1343
+ * relocation, and reflecting attributes.
1344
+ *
1345
+ * @param hostRef data needed to root and render the virtual DOM tree, such as
1346
+ * the DOM node into which it should be rendered.
1347
+ * @param renderFnResults the virtual DOM nodes to be rendered
1348
+ */
1009
1349
  const renderVdom = (hostRef, renderFnResults) => {
1010
1350
  const hostElm = hostRef.$hostElement$;
1011
1351
  const cmpMeta = hostRef.$cmpMeta$;
@@ -1019,10 +1359,13 @@ const renderVdom = (hostRef, renderFnResults) => {
1019
1359
  rootVnode.$tag$ = null;
1020
1360
  rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
1021
1361
  hostRef.$vnode$ = rootVnode;
1022
- rootVnode.$elm$ = oldVNode.$elm$ = (hostElm);
1362
+ rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
1363
+ {
1364
+ scopeId = hostElm['s-sc'];
1365
+ }
1023
1366
  {
1024
1367
  contentRef = hostElm['s-cr'];
1025
- useNativeShadowDom = (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) !== 0;
1368
+ useNativeShadowDom = supportsShadow && (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) !== 0;
1026
1369
  // always reset
1027
1370
  checkSlotFallbackVisibility = false;
1028
1371
  }
@@ -1125,15 +1468,54 @@ const scheduleUpdate = (hostRef, isInitialLoad) => {
1125
1468
  const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
1126
1469
  return writeTask(dispatch) ;
1127
1470
  };
1471
+ /**
1472
+ * Dispatch initial-render and update lifecycle hooks, enqueuing calls to
1473
+ * component lifecycle methods like `componentWillLoad` as well as
1474
+ * {@link updateComponent}, which will kick off the virtual DOM re-render.
1475
+ *
1476
+ * @param hostRef a reference to a host DOM node
1477
+ * @param isInitialLoad whether we're on the initial load or not
1478
+ * @returns an empty Promise which is used to enqueue a series of operations for
1479
+ * the component
1480
+ */
1128
1481
  const dispatchHooks = (hostRef, isInitialLoad) => {
1129
1482
  const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
1130
1483
  const instance = hostRef.$lazyInstance$ ;
1131
- let promise;
1484
+ // We're going to use this variable together with `enqueue` to implement a
1485
+ // little promise-based queue. We start out with it `undefined`. When we add
1486
+ // the first function to the queue we'll set this variable to be that
1487
+ // function's return value. When we attempt to add subsequent values to the
1488
+ // queue we'll check that value and, if it was a `Promise`, we'll then chain
1489
+ // the new function off of that `Promise` using `.then()`. This will give our
1490
+ // queue two nice properties:
1491
+ //
1492
+ // 1. If all functions added to the queue are synchronous they'll be called
1493
+ // synchronously right away.
1494
+ // 2. If all functions added to the queue are asynchronous they'll all be
1495
+ // called in order after `dispatchHooks` exits.
1496
+ let maybePromise;
1132
1497
  endSchedule();
1133
- return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
1498
+ return enqueue(maybePromise, () => updateComponent(hostRef, instance, isInitialLoad));
1134
1499
  };
1500
+ /**
1501
+ * This function uses a Promise to implement a simple first-in, first-out queue
1502
+ * of functions to be called.
1503
+ *
1504
+ * The queue is ordered on the basis of the first argument. If it's
1505
+ * `undefined`, then nothing is on the queue yet, so the provided function can
1506
+ * be called synchronously (although note that this function may return a
1507
+ * `Promise`). The idea is that then the return value of that enqueueing
1508
+ * operation is kept around, so that if it was a `Promise` then subsequent
1509
+ * functions can be enqueued by calling this function again with that `Promise`
1510
+ * as the first argument.
1511
+ *
1512
+ * @param maybePromise either a `Promise` which should resolve before the next function is called or an 'empty' sentinel
1513
+ * @param fn a function to enqueue
1514
+ * @returns either a `Promise` or the return value of the provided function
1515
+ */
1516
+ const enqueue = (maybePromise, fn) => maybePromise instanceof Promise ? maybePromise.then(fn) : fn();
1135
1517
  const updateComponent = async (hostRef, instance, isInitialLoad) => {
1136
- // updateComponent
1518
+ var _a;
1137
1519
  const elm = hostRef.$hostElement$;
1138
1520
  const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
1139
1521
  const rc = elm['s-rc'];
@@ -1145,6 +1527,11 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
1145
1527
  {
1146
1528
  callRender(hostRef, instance);
1147
1529
  }
1530
+ // TODO(STENCIL-659): Remove code implementing the CSS variable shim
1531
+ if (plt.$cssShim$) {
1532
+ // TODO(STENCIL-659): Remove code implementing the CSS variable shim
1533
+ plt.$cssShim$.updateHost(elm);
1534
+ }
1148
1535
  if (rc) {
1149
1536
  // ok, so turns out there are some child host elements
1150
1537
  // waiting on this parent element to load
@@ -1155,7 +1542,7 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
1155
1542
  endRender();
1156
1543
  endUpdate();
1157
1544
  {
1158
- const childrenPromises = elm['s-p'];
1545
+ const childrenPromises = (_a = elm['s-p']) !== null && _a !== void 0 ? _a : [];
1159
1546
  const postUpdate = () => postUpdateComponent(hostRef);
1160
1547
  if (childrenPromises.length === 0) {
1161
1548
  postUpdate();
@@ -1249,9 +1636,6 @@ const safeCall = (instance, method, arg) => {
1249
1636
  }
1250
1637
  return undefined;
1251
1638
  };
1252
- const then = (promise, thenFn) => {
1253
- return promise && promise.then ? promise.then(thenFn) : thenFn();
1254
- };
1255
1639
  const addHydratedFlag = (elm) => elm.classList.add('hydrated')
1256
1640
  ;
1257
1641
  const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
@@ -1405,9 +1789,9 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1405
1789
  const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
1406
1790
  // initializeComponent
1407
1791
  if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
1792
+ // Let the runtime know that the component has been initialized
1793
+ hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
1408
1794
  {
1409
- // we haven't initialized this element yet
1410
- hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
1411
1795
  // lazy loaded components
1412
1796
  // request the component's implementation to be
1413
1797
  // wired up with the host element
@@ -1460,6 +1844,9 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
1460
1844
  const scopeId = getScopeId(cmpMeta);
1461
1845
  if (!styles.has(scopeId)) {
1462
1846
  const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
1847
+ if (cmpMeta.$flags$ & 8 /* CMP_FLAGS.needsShadowDomShim */) {
1848
+ style = await import('./shadow-css-07b0c8c8.js').then((m) => m.scopeCss(style, scopeId, false));
1849
+ }
1463
1850
  registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
1464
1851
  endRegisterStyles();
1465
1852
  }
@@ -1494,12 +1881,24 @@ const connectedCallback = (elm) => {
1494
1881
  if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
1495
1882
  // first time this component has connected
1496
1883
  hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
1884
+ let hostId;
1497
1885
  {
1886
+ hostId = elm.getAttribute(HYDRATE_ID);
1887
+ if (hostId) {
1888
+ if (supportsShadow && cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
1889
+ const scopeId = addStyle(elm.shadowRoot, cmpMeta);
1890
+ elm.classList.remove(scopeId + '-h', scopeId + '-s');
1891
+ }
1892
+ initializeClientHydrate(elm, cmpMeta.$tagName$, hostId, hostRef);
1893
+ }
1894
+ }
1895
+ if (!hostId) {
1498
1896
  // initUpdate
1499
1897
  // if the slot polyfill is required we'll need to put some nodes
1500
1898
  // in here to act as original content anchors as we move nodes around
1501
1899
  // host element has been connected to the DOM
1502
- if ((cmpMeta.$flags$ & (4 /* CMP_FLAGS.hasSlotRelocation */ | 8 /* CMP_FLAGS.needsShadowDomShim */))) {
1900
+ if ((// TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
1901
+ cmpMeta.$flags$ & (4 /* CMP_FLAGS.hasSlotRelocation */ | 8 /* CMP_FLAGS.needsShadowDomShim */))) {
1503
1902
  setContentReference(elm);
1504
1903
  }
1505
1904
  }
@@ -1510,7 +1909,10 @@ const connectedCallback = (elm) => {
1510
1909
  while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
1511
1910
  // climb up the ancestors looking for the first
1512
1911
  // component that hasn't finished its lifecycle update yet
1513
- if (ancestorComponent['s-p']) {
1912
+ if ((ancestorComponent.nodeType === 1 /* NODE_TYPE.ElementNode */ &&
1913
+ ancestorComponent.hasAttribute('s-id') &&
1914
+ ancestorComponent['s-p']) ||
1915
+ ancestorComponent['s-p']) {
1514
1916
  // we found this components first ancestor component
1515
1917
  // keep a reference to this component's ancestor component
1516
1918
  attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
@@ -1554,9 +1956,16 @@ const setContentReference = (elm) => {
1554
1956
  const disconnectedCallback = (elm) => {
1555
1957
  if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
1556
1958
  getHostRef(elm);
1959
+ // clear CSS var-shim tracking
1960
+ // TODO(STENCIL-659): Remove code implementing the CSS variable shim
1961
+ if (plt.$cssShim$) {
1962
+ // TODO(STENCIL-659): Remove code implementing the CSS variable shim
1963
+ plt.$cssShim$.removeHost(elm);
1964
+ }
1557
1965
  }
1558
1966
  };
1559
1967
  const bootstrapLazy = (lazyBundles, options = {}) => {
1968
+ var _a;
1560
1969
  const endBootstrap = createTime();
1561
1970
  const cmpTags = [];
1562
1971
  const exclude = options.exclude || [];
@@ -1565,10 +1974,22 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1565
1974
  const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
1566
1975
  const visibilityStyle = /*@__PURE__*/ doc.createElement('style');
1567
1976
  const deferredConnectedCallbacks = [];
1977
+ const styles = /*@__PURE__*/ doc.querySelectorAll(`[${HYDRATED_STYLE_ID}]`);
1568
1978
  let appLoadFallback;
1569
1979
  let isBootstrapping = true;
1980
+ let i = 0;
1570
1981
  Object.assign(plt, options);
1571
1982
  plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
1983
+ {
1984
+ // If the app is already hydrated there is not point to disable the
1985
+ // async queue. This will improve the first input delay
1986
+ plt.$flags$ |= 2 /* PLATFORM_FLAGS.appLoaded */;
1987
+ }
1988
+ {
1989
+ for (; i < styles.length; i++) {
1990
+ registerStyle(styles[i].getAttribute(HYDRATED_STYLE_ID), convertScopedToShadow(styles[i].innerHTML), true);
1991
+ }
1992
+ }
1572
1993
  lazyBundles.map((lazyBundle) => {
1573
1994
  lazyBundle[1].map((compactMeta) => {
1574
1995
  const cmpMeta = {
@@ -1586,6 +2007,10 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1586
2007
  {
1587
2008
  cmpMeta.$watchers$ = {};
1588
2009
  }
2010
+ if (!supportsShadow && cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
2011
+ // TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
2012
+ cmpMeta.$flags$ |= 8 /* CMP_FLAGS.needsShadowDomShim */;
2013
+ }
1589
2014
  const tagName = cmpMeta.$tagName$;
1590
2015
  const HostElement = class extends HTMLElement {
1591
2016
  // StencilLazyHost
@@ -1594,6 +2019,20 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1594
2019
  super(self);
1595
2020
  self = this;
1596
2021
  registerHost(self, cmpMeta);
2022
+ if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
2023
+ // this component is using shadow dom
2024
+ // and this browser supports shadow dom
2025
+ // add the read-only property "shadowRoot" to the host element
2026
+ // adding the shadow root build conditionals to minimize runtime
2027
+ if (supportsShadow) {
2028
+ {
2029
+ self.attachShadow({ mode: 'open' });
2030
+ }
2031
+ }
2032
+ else if (!('shadowRoot' in self)) {
2033
+ self.shadowRoot = self;
2034
+ }
2035
+ }
1597
2036
  }
1598
2037
  connectedCallback() {
1599
2038
  if (appLoadFallback) {
@@ -1625,6 +2064,11 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1625
2064
  {
1626
2065
  visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
1627
2066
  visibilityStyle.setAttribute('data-styles', '');
2067
+ // Apply CSP nonce to the style tag if it exists
2068
+ const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
2069
+ if (nonce != null) {
2070
+ visibilityStyle.setAttribute('nonce', nonce);
2071
+ }
1628
2072
  head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
1629
2073
  }
1630
2074
  // Process deferred connectedCallbacks now all components have been registered
@@ -1640,6 +2084,13 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1640
2084
  // Fallback appLoad event
1641
2085
  endBootstrap();
1642
2086
  };
2087
+ /**
2088
+ * Assigns the given value to the nonce property on the runtime platform object.
2089
+ * During runtime, this value is used to set the nonce attribute on all dynamically created script and style tags.
2090
+ * @param nonce The value to be assigned to the platform nonce property.
2091
+ * @returns void
2092
+ */
2093
+ const setNonce = (nonce) => (plt.$nonce$ = nonce);
1643
2094
  const hostRefs = /*@__PURE__*/ new WeakMap();
1644
2095
  const getHostRef = (ref) => hostRefs.get(ref);
1645
2096
  const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
@@ -1683,6 +2134,8 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
1683
2134
  };
1684
2135
  const styles = /*@__PURE__*/ new Map();
1685
2136
  const win = typeof window !== 'undefined' ? window : {};
2137
+ // TODO(STENCIL-659): Remove code implementing the CSS variable shim
2138
+ const CSS = win.CSS ;
1686
2139
  const doc = win.document || { head: {} };
1687
2140
  const plt = {
1688
2141
  $flags$: 0,
@@ -1693,6 +2146,10 @@ const plt = {
1693
2146
  rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
1694
2147
  ce: (eventName, opts) => new CustomEvent(eventName, opts),
1695
2148
  };
2149
+ const supportsShadow =
2150
+ // TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
2151
+ /*@__PURE__*/ (() => (doc.head.attachShadow + '').indexOf('[native') > -1)()
2152
+ ;
1696
2153
  const promiseResolve = (v) => Promise.resolve(v);
1697
2154
  const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
1698
2155
  try {
@@ -1746,4 +2203,6 @@ const flush = () => {
1746
2203
  const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
1747
2204
  const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
1748
2205
 
1749
- export { Host as H, bootstrapLazy as b, getElement as g, h, promiseResolve as p, registerInstance as r };
2206
+ export { CSS as C, Host as H, promiseResolve as a, bootstrapLazy as b, getElement as g, h, plt as p, registerInstance as r, setNonce as s, win as w };
2207
+
2208
+ //# sourceMappingURL=index-e11775ce.js.map