@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
@@ -30,6 +30,7 @@ const NAMESPACE = 'cura';
30
30
  *
31
31
  * Modified for Stencil's renderer and slot projection
32
32
  */
33
+ let scopeId;
33
34
  let contentRef;
34
35
  let hostTagName;
35
36
  let useNativeShadowDom = false;
@@ -51,6 +52,13 @@ const uniqueTime = (key, measureText) => {
51
52
  };
52
53
  }
53
54
  };
55
+ const CONTENT_REF_ID = 'r';
56
+ const ORG_LOCATION_ID = 'o';
57
+ const SLOT_NODE_ID = 's';
58
+ const TEXT_NODE_ID = 't';
59
+ const HYDRATE_ID = 's-id';
60
+ const HYDRATED_STYLE_ID = 'sty-id';
61
+ const HYDRATE_CHILD_ID = 'c-id';
54
62
  const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
55
63
  const XLINK_NS = 'http://www.w3.org/1999/xlink';
56
64
  /**
@@ -66,11 +74,31 @@ const EMPTY_OBJ = {};
66
74
  */
67
75
  const SVG_NS = 'http://www.w3.org/2000/svg';
68
76
  const HTML_NS = 'http://www.w3.org/1999/xhtml';
77
+ const isDef = (v) => v != null;
78
+ /**
79
+ * Check whether a value is a 'complex type', defined here as an object or a
80
+ * function.
81
+ *
82
+ * @param o the value to check
83
+ * @returns whether it's a complex type or not
84
+ */
69
85
  const isComplexType = (o) => {
70
86
  // https://jsperf.com/typeof-fn-object/5
71
87
  o = typeof o;
72
88
  return o === 'object' || o === 'function';
73
89
  };
90
+ /**
91
+ * Helper method for querying a `meta` tag that contains a nonce value
92
+ * out of a DOM's head.
93
+ *
94
+ * @param doc The DOM containing the `head` to query against
95
+ * @returns The content of the meta tag representing the nonce value, or `undefined` if no tag
96
+ * exists or the tag has no content.
97
+ */
98
+ function queryNonceMetaTagContent(doc) {
99
+ var _a, _b, _c;
100
+ 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;
101
+ }
74
102
  /**
75
103
  * Production h() function based on Preact by
76
104
  * Jason Miller (@developit)
@@ -79,7 +107,6 @@ const isComplexType = (o) => {
79
107
  *
80
108
  * Modified for Stencil's compiler and vdom
81
109
  */
82
- // const stack: any[] = [];
83
110
  // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
84
111
  // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
85
112
  const h = (nodeName, vnodeData, ...children) => {
@@ -137,6 +164,14 @@ const h = (nodeName, vnodeData, ...children) => {
137
164
  }
138
165
  return vnode;
139
166
  };
167
+ /**
168
+ * A utility function for creating a virtual DOM node from a tag and some
169
+ * possible text content.
170
+ *
171
+ * @param tag the tag for this element
172
+ * @param text possible text content for the node
173
+ * @returns a newly-minted virtual DOM node
174
+ */
140
175
  const newVNode = (tag, text) => {
141
176
  const vnode = {
142
177
  $flags$: 0,
@@ -154,7 +189,218 @@ const newVNode = (tag, text) => {
154
189
  return vnode;
155
190
  };
156
191
  const Host = {};
192
+ /**
193
+ * Check whether a given node is a Host node or not
194
+ *
195
+ * @param node the virtual DOM node to check
196
+ * @returns whether it's a Host node or not
197
+ */
157
198
  const isHost = (node) => node && node.$tag$ === Host;
199
+ const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
200
+ const endHydrate = createTime('hydrateClient', tagName);
201
+ const shadowRoot = hostElm.shadowRoot;
202
+ const childRenderNodes = [];
203
+ const slotNodes = [];
204
+ const shadowRootNodes = shadowRoot ? [] : null;
205
+ const vnode = (hostRef.$vnode$ = newVNode(tagName, null));
206
+ if (!plt.$orgLocNodes$) {
207
+ initializeDocumentHydrate(doc.body, (plt.$orgLocNodes$ = new Map()));
208
+ }
209
+ hostElm[HYDRATE_ID] = hostId;
210
+ hostElm.removeAttribute(HYDRATE_ID);
211
+ clientHydrate(vnode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, hostElm, hostId);
212
+ childRenderNodes.map((c) => {
213
+ const orgLocationId = c.$hostId$ + '.' + c.$nodeId$;
214
+ const orgLocationNode = plt.$orgLocNodes$.get(orgLocationId);
215
+ const node = c.$elm$;
216
+ if (orgLocationNode && supportsShadow && orgLocationNode['s-en'] === '') {
217
+ orgLocationNode.parentNode.insertBefore(node, orgLocationNode.nextSibling);
218
+ }
219
+ if (!shadowRoot) {
220
+ node['s-hn'] = tagName;
221
+ if (orgLocationNode) {
222
+ node['s-ol'] = orgLocationNode;
223
+ node['s-ol']['s-nr'] = node;
224
+ }
225
+ }
226
+ plt.$orgLocNodes$.delete(orgLocationId);
227
+ });
228
+ if (shadowRoot) {
229
+ shadowRootNodes.map((shadowRootNode) => {
230
+ if (shadowRootNode) {
231
+ shadowRoot.appendChild(shadowRootNode);
232
+ }
233
+ });
234
+ }
235
+ endHydrate();
236
+ };
237
+ const clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node, hostId) => {
238
+ let childNodeType;
239
+ let childIdSplt;
240
+ let childVNode;
241
+ let i;
242
+ if (node.nodeType === 1 /* NODE_TYPE.ElementNode */) {
243
+ childNodeType = node.getAttribute(HYDRATE_CHILD_ID);
244
+ if (childNodeType) {
245
+ // got the node data from the element's attribute
246
+ // `${hostId}.${nodeId}.${depth}.${index}`
247
+ childIdSplt = childNodeType.split('.');
248
+ if (childIdSplt[0] === hostId || childIdSplt[0] === '0') {
249
+ childVNode = {
250
+ $flags$: 0,
251
+ $hostId$: childIdSplt[0],
252
+ $nodeId$: childIdSplt[1],
253
+ $depth$: childIdSplt[2],
254
+ $index$: childIdSplt[3],
255
+ $tag$: node.tagName.toLowerCase(),
256
+ $elm$: node,
257
+ $attrs$: null,
258
+ $children$: null,
259
+ $key$: null,
260
+ $name$: null,
261
+ $text$: null,
262
+ };
263
+ childRenderNodes.push(childVNode);
264
+ node.removeAttribute(HYDRATE_CHILD_ID);
265
+ // this is a new child vnode
266
+ // so ensure its parent vnode has the vchildren array
267
+ if (!parentVNode.$children$) {
268
+ parentVNode.$children$ = [];
269
+ }
270
+ // add our child vnode to a specific index of the vnode's children
271
+ parentVNode.$children$[childVNode.$index$] = childVNode;
272
+ // this is now the new parent vnode for all the next child checks
273
+ parentVNode = childVNode;
274
+ if (shadowRootNodes && childVNode.$depth$ === '0') {
275
+ shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
276
+ }
277
+ }
278
+ }
279
+ // recursively drill down, end to start so we can remove nodes
280
+ for (i = node.childNodes.length - 1; i >= 0; i--) {
281
+ clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.childNodes[i], hostId);
282
+ }
283
+ if (node.shadowRoot) {
284
+ // keep drilling down through the shadow root nodes
285
+ for (i = node.shadowRoot.childNodes.length - 1; i >= 0; i--) {
286
+ clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.shadowRoot.childNodes[i], hostId);
287
+ }
288
+ }
289
+ }
290
+ else if (node.nodeType === 8 /* NODE_TYPE.CommentNode */) {
291
+ // `${COMMENT_TYPE}.${hostId}.${nodeId}.${depth}.${index}`
292
+ childIdSplt = node.nodeValue.split('.');
293
+ if (childIdSplt[1] === hostId || childIdSplt[1] === '0') {
294
+ // comment node for either the host id or a 0 host id
295
+ childNodeType = childIdSplt[0];
296
+ childVNode = {
297
+ $flags$: 0,
298
+ $hostId$: childIdSplt[1],
299
+ $nodeId$: childIdSplt[2],
300
+ $depth$: childIdSplt[3],
301
+ $index$: childIdSplt[4],
302
+ $elm$: node,
303
+ $attrs$: null,
304
+ $children$: null,
305
+ $key$: null,
306
+ $name$: null,
307
+ $tag$: null,
308
+ $text$: null,
309
+ };
310
+ if (childNodeType === TEXT_NODE_ID) {
311
+ childVNode.$elm$ = node.nextSibling;
312
+ if (childVNode.$elm$ && childVNode.$elm$.nodeType === 3 /* NODE_TYPE.TextNode */) {
313
+ childVNode.$text$ = childVNode.$elm$.textContent;
314
+ childRenderNodes.push(childVNode);
315
+ // remove the text comment since it's no longer needed
316
+ node.remove();
317
+ if (!parentVNode.$children$) {
318
+ parentVNode.$children$ = [];
319
+ }
320
+ parentVNode.$children$[childVNode.$index$] = childVNode;
321
+ if (shadowRootNodes && childVNode.$depth$ === '0') {
322
+ shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
323
+ }
324
+ }
325
+ }
326
+ else if (childVNode.$hostId$ === hostId) {
327
+ // this comment node is specifcally for this host id
328
+ if (childNodeType === SLOT_NODE_ID) {
329
+ // `${SLOT_NODE_ID}.${hostId}.${nodeId}.${depth}.${index}.${slotName}`;
330
+ childVNode.$tag$ = 'slot';
331
+ if (childIdSplt[5]) {
332
+ node['s-sn'] = childVNode.$name$ = childIdSplt[5];
333
+ }
334
+ else {
335
+ node['s-sn'] = '';
336
+ }
337
+ node['s-sr'] = true;
338
+ if (shadowRootNodes) {
339
+ // browser support shadowRoot and this is a shadow dom component
340
+ // create an actual slot element
341
+ childVNode.$elm$ = doc.createElement(childVNode.$tag$);
342
+ if (childVNode.$name$) {
343
+ // add the slot name attribute
344
+ childVNode.$elm$.setAttribute('name', childVNode.$name$);
345
+ }
346
+ // insert the new slot element before the slot comment
347
+ node.parentNode.insertBefore(childVNode.$elm$, node);
348
+ // remove the slot comment since it's not needed for shadow
349
+ node.remove();
350
+ if (childVNode.$depth$ === '0') {
351
+ shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
352
+ }
353
+ }
354
+ slotNodes.push(childVNode);
355
+ if (!parentVNode.$children$) {
356
+ parentVNode.$children$ = [];
357
+ }
358
+ parentVNode.$children$[childVNode.$index$] = childVNode;
359
+ }
360
+ else if (childNodeType === CONTENT_REF_ID) {
361
+ // `${CONTENT_REF_ID}.${hostId}`;
362
+ if (shadowRootNodes) {
363
+ // remove the content ref comment since it's not needed for shadow
364
+ node.remove();
365
+ }
366
+ else {
367
+ hostElm['s-cr'] = node;
368
+ node['s-cn'] = true;
369
+ }
370
+ }
371
+ }
372
+ }
373
+ }
374
+ else if (parentVNode && parentVNode.$tag$ === 'style') {
375
+ const vnode = newVNode(null, node.textContent);
376
+ vnode.$elm$ = node;
377
+ vnode.$index$ = '0';
378
+ parentVNode.$children$ = [vnode];
379
+ }
380
+ };
381
+ const initializeDocumentHydrate = (node, orgLocNodes) => {
382
+ if (node.nodeType === 1 /* NODE_TYPE.ElementNode */) {
383
+ let i = 0;
384
+ for (; i < node.childNodes.length; i++) {
385
+ initializeDocumentHydrate(node.childNodes[i], orgLocNodes);
386
+ }
387
+ if (node.shadowRoot) {
388
+ for (i = 0; i < node.shadowRoot.childNodes.length; i++) {
389
+ initializeDocumentHydrate(node.shadowRoot.childNodes[i], orgLocNodes);
390
+ }
391
+ }
392
+ }
393
+ else if (node.nodeType === 8 /* NODE_TYPE.CommentNode */) {
394
+ const childIdSplt = node.nodeValue.split('.');
395
+ if (childIdSplt[0] === ORG_LOCATION_ID) {
396
+ orgLocNodes.set(childIdSplt[1] + '.' + childIdSplt[2], node);
397
+ node.nodeValue = '';
398
+ // useful to know if the original location is
399
+ // the root light-dom of a shadow dom component
400
+ node['s-en'] = childIdSplt[3];
401
+ }
402
+ }
403
+ };
158
404
  /**
159
405
  * Parse a new property value for a given property type.
160
406
  *
@@ -233,6 +479,7 @@ const registerStyle = (scopeId, cssText, allowCS) => {
233
479
  styles.set(scopeId, style);
234
480
  };
235
481
  const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
482
+ var _a;
236
483
  let scopeId = getScopeId(cmpMeta);
237
484
  const style = styles.get(scopeId);
238
485
  // if an element is NOT connected then getRootNode() will return the wrong root node
@@ -247,11 +494,36 @@ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
247
494
  rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
248
495
  }
249
496
  if (!appliedStyles.has(scopeId)) {
250
- {
251
- {
497
+ if (styleContainerNode.host &&
498
+ (styleElm = styleContainerNode.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId}"]`))) {
499
+ // This is only happening on native shadow-dom, do not needs CSS var shim
500
+ styleElm.innerHTML = style;
501
+ }
502
+ else {
503
+ // TODO(STENCIL-659): Remove code implementing the CSS variable shim
504
+ if (plt.$cssShim$) {
505
+ // TODO(STENCIL-659): Remove code implementing the CSS variable shim
506
+ styleElm = plt.$cssShim$.createHostStyle(hostElm, scopeId, style,
507
+ // TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
508
+ !!(cmpMeta.$flags$ & 10 /* CMP_FLAGS.needsScopedEncapsulation */));
509
+ const newScopeId = styleElm['s-sc'];
510
+ if (newScopeId) {
511
+ scopeId = newScopeId;
512
+ // we don't want to add this styleID to the appliedStyles Set
513
+ // since the cssVarShim might need to apply several different
514
+ // stylesheets for the same component
515
+ appliedStyles = null;
516
+ }
517
+ }
518
+ else {
252
519
  styleElm = doc.createElement('style');
253
520
  styleElm.innerHTML = style;
254
521
  }
522
+ // Apply CSP nonce to the style tag if it exists
523
+ const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
524
+ if (nonce != null) {
525
+ styleElm.setAttribute('nonce', nonce);
526
+ }
255
527
  styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
256
528
  }
257
529
  if (appliedStyles) {
@@ -268,11 +540,25 @@ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
268
540
  const attachStyles = (hostRef) => {
269
541
  const cmpMeta = hostRef.$cmpMeta$;
270
542
  const elm = hostRef.$hostElement$;
543
+ const flags = cmpMeta.$flags$;
271
544
  const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
272
- addStyle(elm.getRootNode(), cmpMeta);
545
+ const scopeId = addStyle(supportsShadow && elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta, hostRef.$modeName$, elm);
546
+ // TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
547
+ if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
548
+ // only required when we're NOT using native shadow dom (slot)
549
+ // or this browser doesn't support native shadow dom
550
+ // and this host element was NOT created with SSR
551
+ // let's pick out the inner content for slot projection
552
+ // create a node to represent where the original
553
+ // content was first placed, which is useful later on
554
+ // DOM WRITE!!
555
+ elm['s-sc'] = scopeId;
556
+ elm.classList.add(scopeId + '-h');
557
+ }
273
558
  endAttachStyles();
274
559
  };
275
560
  const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
561
+ const convertScopedToShadow = (css) => css.replace(/\/\*!@([^\/]+)\*\/[^\{]+\{/g, '$1{');
276
562
  /**
277
563
  * Production setAccessor() function based on Preact by
278
564
  * Jason Miller (@developit)
@@ -458,6 +744,10 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
458
744
  // remember for later we need to check to relocate nodes
459
745
  checkSlotRelocate = true;
460
746
  if (newVNode.$tag$ === 'slot') {
747
+ if (scopeId) {
748
+ // scoped css needs to add its scoped id to the parent element
749
+ parentElm.classList.add(scopeId + '-s');
750
+ }
461
751
  newVNode.$flags$ |= newVNode.$children$
462
752
  ? // slot element has fallback content
463
753
  2 /* VNODE_FLAGS.isSlotFallback */
@@ -490,10 +780,15 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
490
780
  {
491
781
  updateElement(null, newVNode, isSvgMode);
492
782
  }
783
+ if (isDef(scopeId) && elm['s-si'] !== scopeId) {
784
+ // if there is a scopeId and this is the initial render
785
+ // then let's add the scopeId as a css class
786
+ elm.classList.add((elm['s-si'] = scopeId));
787
+ }
493
788
  if (newVNode.$children$) {
494
789
  for (i = 0; i < newVNode.$children$.length; ++i) {
495
790
  // create the node
496
- childNode = createElm(oldParentVNode, newVNode, i);
791
+ childNode = createElm(oldParentVNode, newVNode, i, elm);
497
792
  // return node could have been null
498
793
  if (childNode) {
499
794
  // append our new node
@@ -556,12 +851,30 @@ const putBackInOriginalLocation = (parentElm, recursive) => {
556
851
  }
557
852
  plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
558
853
  };
854
+ /**
855
+ * Create DOM nodes corresponding to a list of {@link d.Vnode} objects and
856
+ * add them to the DOM in the appropriate place.
857
+ *
858
+ * @param parentElm the DOM node which should be used as a parent for the new
859
+ * DOM nodes
860
+ * @param before a child of the `parentElm` which the new children should be
861
+ * inserted before (optional)
862
+ * @param parentVNode the parent virtual DOM node
863
+ * @param vnodes the new child virtual DOM nodes to produce DOM nodes for
864
+ * @param startIdx the index in the child virtual DOM nodes at which to start
865
+ * creating DOM nodes (inclusive)
866
+ * @param endIdx the index in the child virtual DOM nodes at which to stop
867
+ * creating DOM nodes (inclusive)
868
+ */
559
869
  const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
560
870
  let containerElm = ((parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
561
871
  let childNode;
872
+ if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
873
+ containerElm = containerElm.shadowRoot;
874
+ }
562
875
  for (; startIdx <= endIdx; ++startIdx) {
563
876
  if (vnodes[startIdx]) {
564
- childNode = createElm(null, parentVNode, startIdx);
877
+ childNode = createElm(null, parentVNode, startIdx, parentElm);
565
878
  if (childNode) {
566
879
  vnodes[startIdx].$elm$ = childNode;
567
880
  containerElm.insertBefore(childNode, referenceNode(before) );
@@ -569,26 +882,40 @@ const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) =>
569
882
  }
570
883
  }
571
884
  };
572
- const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
573
- for (; startIdx <= endIdx; ++startIdx) {
574
- if ((vnode = vnodes[startIdx])) {
575
- elm = vnode.$elm$;
576
- {
577
- // we're removing this element
578
- // so it's possible we need to show slot fallback content now
579
- checkSlotFallbackVisibility = true;
580
- if (elm['s-ol']) {
581
- // remove the original location comment
582
- elm['s-ol'].remove();
583
- }
584
- else {
585
- // it's possible that child nodes of the node
586
- // that's being removed are slot nodes
587
- putBackInOriginalLocation(elm, true);
885
+ /**
886
+ * Remove the DOM elements corresponding to a list of {@link d.VNode} objects.
887
+ * This can be used to, for instance, clean up after a list of children which
888
+ * should no longer be shown.
889
+ *
890
+ * This function also handles some of Stencil's slot relocation logic.
891
+ *
892
+ * @param vnodes a list of virtual DOM nodes to remove
893
+ * @param startIdx the index at which to start removing nodes (inclusive)
894
+ * @param endIdx the index at which to stop removing nodes (inclusive)
895
+ */
896
+ const removeVnodes = (vnodes, startIdx, endIdx) => {
897
+ for (let index = startIdx; index <= endIdx; ++index) {
898
+ const vnode = vnodes[index];
899
+ if (vnode) {
900
+ const elm = vnode.$elm$;
901
+ if (elm) {
902
+ {
903
+ // we're removing this element
904
+ // so it's possible we need to show slot fallback content now
905
+ checkSlotFallbackVisibility = true;
906
+ if (elm['s-ol']) {
907
+ // remove the original location comment
908
+ elm['s-ol'].remove();
909
+ }
910
+ else {
911
+ // it's possible that child nodes of the node
912
+ // that's being removed are slot nodes
913
+ putBackInOriginalLocation(elm, true);
914
+ }
588
915
  }
916
+ // remove the vnode's element from the dom
917
+ elm.remove();
589
918
  }
590
- // remove the vnode's element from the dom
591
- elm.remove();
592
919
  }
593
920
  }
594
921
  };
@@ -776,7 +1103,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
776
1103
  // the key of the first new child OR the build is not using `key`
777
1104
  // attributes at all. In either case we need to create a new element
778
1105
  // for the new node.
779
- node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
1106
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx, parentElm);
780
1107
  newStartVnode = newCh[++newStartIdx];
781
1108
  }
782
1109
  if (node) {
@@ -809,7 +1136,8 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
809
1136
  *
810
1137
  * So, in other words, if `key` attrs are not set on VNodes which may be
811
1138
  * changing order within a `children` array or something along those lines then
812
- * we could obtain a false positive and then have to do needless re-rendering.
1139
+ * we could obtain a false negative and then have to do needless re-rendering
1140
+ * (i.e. we'd say two VNodes aren't equal when in fact they should be).
813
1141
  *
814
1142
  * @param leftVNode the first VNode to check
815
1143
  * @param rightVNode the second VNode to check
@@ -1028,6 +1356,18 @@ const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
1028
1356
  }
1029
1357
  return slotNameAttr === '';
1030
1358
  };
1359
+ /**
1360
+ * The main entry point for Stencil's virtual DOM-based rendering engine
1361
+ *
1362
+ * Given a {@link d.HostRef} container and some virtual DOM nodes, this
1363
+ * function will handle creating a virtual DOM tree with a single root, patching
1364
+ * the current virtual DOM tree onto an old one (if any), dealing with slot
1365
+ * relocation, and reflecting attributes.
1366
+ *
1367
+ * @param hostRef data needed to root and render the virtual DOM tree, such as
1368
+ * the DOM node into which it should be rendered.
1369
+ * @param renderFnResults the virtual DOM nodes to be rendered
1370
+ */
1031
1371
  const renderVdom = (hostRef, renderFnResults) => {
1032
1372
  const hostElm = hostRef.$hostElement$;
1033
1373
  const cmpMeta = hostRef.$cmpMeta$;
@@ -1041,10 +1381,13 @@ const renderVdom = (hostRef, renderFnResults) => {
1041
1381
  rootVnode.$tag$ = null;
1042
1382
  rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
1043
1383
  hostRef.$vnode$ = rootVnode;
1044
- rootVnode.$elm$ = oldVNode.$elm$ = (hostElm);
1384
+ rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
1385
+ {
1386
+ scopeId = hostElm['s-sc'];
1387
+ }
1045
1388
  {
1046
1389
  contentRef = hostElm['s-cr'];
1047
- useNativeShadowDom = (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) !== 0;
1390
+ useNativeShadowDom = supportsShadow && (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) !== 0;
1048
1391
  // always reset
1049
1392
  checkSlotFallbackVisibility = false;
1050
1393
  }
@@ -1147,15 +1490,54 @@ const scheduleUpdate = (hostRef, isInitialLoad) => {
1147
1490
  const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
1148
1491
  return writeTask(dispatch) ;
1149
1492
  };
1493
+ /**
1494
+ * Dispatch initial-render and update lifecycle hooks, enqueuing calls to
1495
+ * component lifecycle methods like `componentWillLoad` as well as
1496
+ * {@link updateComponent}, which will kick off the virtual DOM re-render.
1497
+ *
1498
+ * @param hostRef a reference to a host DOM node
1499
+ * @param isInitialLoad whether we're on the initial load or not
1500
+ * @returns an empty Promise which is used to enqueue a series of operations for
1501
+ * the component
1502
+ */
1150
1503
  const dispatchHooks = (hostRef, isInitialLoad) => {
1151
1504
  const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
1152
1505
  const instance = hostRef.$lazyInstance$ ;
1153
- let promise;
1506
+ // We're going to use this variable together with `enqueue` to implement a
1507
+ // little promise-based queue. We start out with it `undefined`. When we add
1508
+ // the first function to the queue we'll set this variable to be that
1509
+ // function's return value. When we attempt to add subsequent values to the
1510
+ // queue we'll check that value and, if it was a `Promise`, we'll then chain
1511
+ // the new function off of that `Promise` using `.then()`. This will give our
1512
+ // queue two nice properties:
1513
+ //
1514
+ // 1. If all functions added to the queue are synchronous they'll be called
1515
+ // synchronously right away.
1516
+ // 2. If all functions added to the queue are asynchronous they'll all be
1517
+ // called in order after `dispatchHooks` exits.
1518
+ let maybePromise;
1154
1519
  endSchedule();
1155
- return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
1520
+ return enqueue(maybePromise, () => updateComponent(hostRef, instance, isInitialLoad));
1156
1521
  };
1522
+ /**
1523
+ * This function uses a Promise to implement a simple first-in, first-out queue
1524
+ * of functions to be called.
1525
+ *
1526
+ * The queue is ordered on the basis of the first argument. If it's
1527
+ * `undefined`, then nothing is on the queue yet, so the provided function can
1528
+ * be called synchronously (although note that this function may return a
1529
+ * `Promise`). The idea is that then the return value of that enqueueing
1530
+ * operation is kept around, so that if it was a `Promise` then subsequent
1531
+ * functions can be enqueued by calling this function again with that `Promise`
1532
+ * as the first argument.
1533
+ *
1534
+ * @param maybePromise either a `Promise` which should resolve before the next function is called or an 'empty' sentinel
1535
+ * @param fn a function to enqueue
1536
+ * @returns either a `Promise` or the return value of the provided function
1537
+ */
1538
+ const enqueue = (maybePromise, fn) => maybePromise instanceof Promise ? maybePromise.then(fn) : fn();
1157
1539
  const updateComponent = async (hostRef, instance, isInitialLoad) => {
1158
- // updateComponent
1540
+ var _a;
1159
1541
  const elm = hostRef.$hostElement$;
1160
1542
  const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
1161
1543
  const rc = elm['s-rc'];
@@ -1167,6 +1549,11 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
1167
1549
  {
1168
1550
  callRender(hostRef, instance);
1169
1551
  }
1552
+ // TODO(STENCIL-659): Remove code implementing the CSS variable shim
1553
+ if (plt.$cssShim$) {
1554
+ // TODO(STENCIL-659): Remove code implementing the CSS variable shim
1555
+ plt.$cssShim$.updateHost(elm);
1556
+ }
1170
1557
  if (rc) {
1171
1558
  // ok, so turns out there are some child host elements
1172
1559
  // waiting on this parent element to load
@@ -1177,7 +1564,7 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
1177
1564
  endRender();
1178
1565
  endUpdate();
1179
1566
  {
1180
- const childrenPromises = elm['s-p'];
1567
+ const childrenPromises = (_a = elm['s-p']) !== null && _a !== void 0 ? _a : [];
1181
1568
  const postUpdate = () => postUpdateComponent(hostRef);
1182
1569
  if (childrenPromises.length === 0) {
1183
1570
  postUpdate();
@@ -1271,9 +1658,6 @@ const safeCall = (instance, method, arg) => {
1271
1658
  }
1272
1659
  return undefined;
1273
1660
  };
1274
- const then = (promise, thenFn) => {
1275
- return promise && promise.then ? promise.then(thenFn) : thenFn();
1276
- };
1277
1661
  const addHydratedFlag = (elm) => elm.classList.add('hydrated')
1278
1662
  ;
1279
1663
  const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
@@ -1427,9 +1811,9 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1427
1811
  const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
1428
1812
  // initializeComponent
1429
1813
  if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
1814
+ // Let the runtime know that the component has been initialized
1815
+ hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
1430
1816
  {
1431
- // we haven't initialized this element yet
1432
- hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
1433
1817
  // lazy loaded components
1434
1818
  // request the component's implementation to be
1435
1819
  // wired up with the host element
@@ -1482,6 +1866,9 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
1482
1866
  const scopeId = getScopeId(cmpMeta);
1483
1867
  if (!styles.has(scopeId)) {
1484
1868
  const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
1869
+ if (cmpMeta.$flags$ & 8 /* CMP_FLAGS.needsShadowDomShim */) {
1870
+ style = await Promise.resolve().then(function () { return require('./shadow-css-8baae635.js'); }).then((m) => m.scopeCss(style, scopeId, false));
1871
+ }
1485
1872
  registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
1486
1873
  endRegisterStyles();
1487
1874
  }
@@ -1516,12 +1903,24 @@ const connectedCallback = (elm) => {
1516
1903
  if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
1517
1904
  // first time this component has connected
1518
1905
  hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
1906
+ let hostId;
1519
1907
  {
1908
+ hostId = elm.getAttribute(HYDRATE_ID);
1909
+ if (hostId) {
1910
+ if (supportsShadow && cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
1911
+ const scopeId = addStyle(elm.shadowRoot, cmpMeta);
1912
+ elm.classList.remove(scopeId + '-h', scopeId + '-s');
1913
+ }
1914
+ initializeClientHydrate(elm, cmpMeta.$tagName$, hostId, hostRef);
1915
+ }
1916
+ }
1917
+ if (!hostId) {
1520
1918
  // initUpdate
1521
1919
  // if the slot polyfill is required we'll need to put some nodes
1522
1920
  // in here to act as original content anchors as we move nodes around
1523
1921
  // host element has been connected to the DOM
1524
- if ((cmpMeta.$flags$ & (4 /* CMP_FLAGS.hasSlotRelocation */ | 8 /* CMP_FLAGS.needsShadowDomShim */))) {
1922
+ if ((// TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
1923
+ cmpMeta.$flags$ & (4 /* CMP_FLAGS.hasSlotRelocation */ | 8 /* CMP_FLAGS.needsShadowDomShim */))) {
1525
1924
  setContentReference(elm);
1526
1925
  }
1527
1926
  }
@@ -1532,7 +1931,10 @@ const connectedCallback = (elm) => {
1532
1931
  while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
1533
1932
  // climb up the ancestors looking for the first
1534
1933
  // component that hasn't finished its lifecycle update yet
1535
- if (ancestorComponent['s-p']) {
1934
+ if ((ancestorComponent.nodeType === 1 /* NODE_TYPE.ElementNode */ &&
1935
+ ancestorComponent.hasAttribute('s-id') &&
1936
+ ancestorComponent['s-p']) ||
1937
+ ancestorComponent['s-p']) {
1536
1938
  // we found this components first ancestor component
1537
1939
  // keep a reference to this component's ancestor component
1538
1940
  attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
@@ -1576,9 +1978,16 @@ const setContentReference = (elm) => {
1576
1978
  const disconnectedCallback = (elm) => {
1577
1979
  if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
1578
1980
  getHostRef(elm);
1981
+ // clear CSS var-shim tracking
1982
+ // TODO(STENCIL-659): Remove code implementing the CSS variable shim
1983
+ if (plt.$cssShim$) {
1984
+ // TODO(STENCIL-659): Remove code implementing the CSS variable shim
1985
+ plt.$cssShim$.removeHost(elm);
1986
+ }
1579
1987
  }
1580
1988
  };
1581
1989
  const bootstrapLazy = (lazyBundles, options = {}) => {
1990
+ var _a;
1582
1991
  const endBootstrap = createTime();
1583
1992
  const cmpTags = [];
1584
1993
  const exclude = options.exclude || [];
@@ -1587,10 +1996,22 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1587
1996
  const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
1588
1997
  const visibilityStyle = /*@__PURE__*/ doc.createElement('style');
1589
1998
  const deferredConnectedCallbacks = [];
1999
+ const styles = /*@__PURE__*/ doc.querySelectorAll(`[${HYDRATED_STYLE_ID}]`);
1590
2000
  let appLoadFallback;
1591
2001
  let isBootstrapping = true;
2002
+ let i = 0;
1592
2003
  Object.assign(plt, options);
1593
2004
  plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
2005
+ {
2006
+ // If the app is already hydrated there is not point to disable the
2007
+ // async queue. This will improve the first input delay
2008
+ plt.$flags$ |= 2 /* PLATFORM_FLAGS.appLoaded */;
2009
+ }
2010
+ {
2011
+ for (; i < styles.length; i++) {
2012
+ registerStyle(styles[i].getAttribute(HYDRATED_STYLE_ID), convertScopedToShadow(styles[i].innerHTML), true);
2013
+ }
2014
+ }
1594
2015
  lazyBundles.map((lazyBundle) => {
1595
2016
  lazyBundle[1].map((compactMeta) => {
1596
2017
  const cmpMeta = {
@@ -1608,6 +2029,10 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1608
2029
  {
1609
2030
  cmpMeta.$watchers$ = {};
1610
2031
  }
2032
+ if (!supportsShadow && cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
2033
+ // TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
2034
+ cmpMeta.$flags$ |= 8 /* CMP_FLAGS.needsShadowDomShim */;
2035
+ }
1611
2036
  const tagName = cmpMeta.$tagName$;
1612
2037
  const HostElement = class extends HTMLElement {
1613
2038
  // StencilLazyHost
@@ -1616,6 +2041,20 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1616
2041
  super(self);
1617
2042
  self = this;
1618
2043
  registerHost(self, cmpMeta);
2044
+ if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
2045
+ // this component is using shadow dom
2046
+ // and this browser supports shadow dom
2047
+ // add the read-only property "shadowRoot" to the host element
2048
+ // adding the shadow root build conditionals to minimize runtime
2049
+ if (supportsShadow) {
2050
+ {
2051
+ self.attachShadow({ mode: 'open' });
2052
+ }
2053
+ }
2054
+ else if (!('shadowRoot' in self)) {
2055
+ self.shadowRoot = self;
2056
+ }
2057
+ }
1619
2058
  }
1620
2059
  connectedCallback() {
1621
2060
  if (appLoadFallback) {
@@ -1647,6 +2086,11 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1647
2086
  {
1648
2087
  visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
1649
2088
  visibilityStyle.setAttribute('data-styles', '');
2089
+ // Apply CSP nonce to the style tag if it exists
2090
+ const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
2091
+ if (nonce != null) {
2092
+ visibilityStyle.setAttribute('nonce', nonce);
2093
+ }
1650
2094
  head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
1651
2095
  }
1652
2096
  // Process deferred connectedCallbacks now all components have been registered
@@ -1662,6 +2106,13 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1662
2106
  // Fallback appLoad event
1663
2107
  endBootstrap();
1664
2108
  };
2109
+ /**
2110
+ * Assigns the given value to the nonce property on the runtime platform object.
2111
+ * During runtime, this value is used to set the nonce attribute on all dynamically created script and style tags.
2112
+ * @param nonce The value to be assigned to the platform nonce property.
2113
+ * @returns void
2114
+ */
2115
+ const setNonce = (nonce) => (plt.$nonce$ = nonce);
1665
2116
  const hostRefs = /*@__PURE__*/ new WeakMap();
1666
2117
  const getHostRef = (ref) => hostRefs.get(ref);
1667
2118
  const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
@@ -1705,6 +2156,8 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
1705
2156
  };
1706
2157
  const styles = /*@__PURE__*/ new Map();
1707
2158
  const win = typeof window !== 'undefined' ? window : {};
2159
+ // TODO(STENCIL-659): Remove code implementing the CSS variable shim
2160
+ const CSS = win.CSS ;
1708
2161
  const doc = win.document || { head: {} };
1709
2162
  const plt = {
1710
2163
  $flags$: 0,
@@ -1715,6 +2168,10 @@ const plt = {
1715
2168
  rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
1716
2169
  ce: (eventName, opts) => new CustomEvent(eventName, opts),
1717
2170
  };
2171
+ const supportsShadow =
2172
+ // TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
2173
+ /*@__PURE__*/ (() => (doc.head.attachShadow + '').indexOf('[native') > -1)()
2174
+ ;
1718
2175
  const promiseResolve = (v) => Promise.resolve(v);
1719
2176
  const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
1720
2177
  try {
@@ -1768,9 +2225,15 @@ const flush = () => {
1768
2225
  const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
1769
2226
  const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
1770
2227
 
2228
+ exports.CSS = CSS;
1771
2229
  exports.Host = Host;
1772
2230
  exports.bootstrapLazy = bootstrapLazy;
1773
2231
  exports.getElement = getElement;
1774
2232
  exports.h = h;
2233
+ exports.plt = plt;
1775
2234
  exports.promiseResolve = promiseResolve;
1776
2235
  exports.registerInstance = registerInstance;
2236
+ exports.setNonce = setNonce;
2237
+ exports.win = win;
2238
+
2239
+ //# sourceMappingURL=index-29633529.js.map