@3t-transform/threeteeui 0.0.6 → 0.0.7

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 (101) hide show
  1. package/dist/cjs/{index-8a7479e4.js → index-253ca97c.js} +239 -415
  2. package/dist/cjs/loader.cjs.js +4 -3
  3. package/dist/cjs/tttx-button.cjs.entry.js +28 -0
  4. package/dist/cjs/tttx-checkbox.cjs.entry.js +28 -0
  5. package/dist/cjs/tttx-form.cjs.entry.js +58 -0
  6. package/dist/cjs/tttx-single-input.cjs.entry.js +44 -0
  7. package/dist/cjs/tttx-text-box.cjs.entry.js +38 -0
  8. package/dist/cjs/tttx.cjs.js +7 -3
  9. package/dist/collection/collection-manifest.json +7 -5
  10. package/dist/collection/components/atoms/tttx-button/tttx-button.css +61 -0
  11. package/dist/collection/components/atoms/tttx-button/tttx-button.js +93 -0
  12. package/dist/collection/components/atoms/tttx-button/tttx-button.stories.js +30 -0
  13. package/dist/collection/components/atoms/tttx-single-input/tttx-single-input.css +142 -0
  14. package/dist/collection/components/atoms/tttx-single-input/tttx-single-input.js +259 -0
  15. package/dist/collection/components/atoms/tttx-single-input/tttx-single-input.stories.js +92 -0
  16. package/dist/collection/components/atoms/tttx-text-box/tttx-text-box.css +142 -0
  17. package/dist/collection/components/atoms/tttx-text-box/tttx-text-box.js +150 -0
  18. package/dist/collection/components/atoms/tttx-text-box/tttx-text-box.stories.js +17 -0
  19. package/dist/collection/components/atoms/ttx-checkbox/tttx-checkbox.css +138 -0
  20. package/dist/collection/components/atoms/ttx-checkbox/tttx-checkbox.js +101 -0
  21. package/dist/collection/components/atoms/ttx-checkbox/tttx-checkbox.stories.js +13 -0
  22. package/dist/collection/components/molecules/tttx-form/tttx-form.js +109 -0
  23. package/dist/collection/components/molecules/tttx-form/tttx-form.stories.js +37 -0
  24. package/dist/collection/icons.js +2838 -0
  25. package/dist/components/index.d.ts +14 -3
  26. package/dist/components/index.js +6 -4
  27. package/dist/components/{tttx-page.d.ts → tttx-button.d.ts} +4 -4
  28. package/dist/components/tttx-button.js +45 -0
  29. package/dist/components/{tttx-worksheet.d.ts → tttx-checkbox.d.ts} +4 -4
  30. package/dist/components/tttx-checkbox.js +46 -0
  31. package/dist/components/{tttx-icon.d.ts → tttx-form.d.ts} +4 -4
  32. package/dist/components/tttx-form.js +75 -0
  33. package/dist/components/tttx-single-input.d.ts +11 -0
  34. package/dist/components/tttx-single-input.js +71 -0
  35. package/dist/components/tttx-text-box.d.ts +11 -0
  36. package/dist/components/tttx-text-box.js +59 -0
  37. package/dist/esm/{index-854ff56f.js → index-fcca6c58.js} +237 -416
  38. package/dist/esm/loader.js +4 -3
  39. package/dist/esm/polyfills/css-shim.js +1 -1
  40. package/dist/esm/tttx-button.entry.js +24 -0
  41. package/dist/esm/tttx-checkbox.entry.js +24 -0
  42. package/dist/esm/tttx-form.entry.js +54 -0
  43. package/dist/esm/tttx-single-input.entry.js +40 -0
  44. package/dist/esm/tttx-text-box.entry.js +34 -0
  45. package/dist/esm/tttx.js +4 -3
  46. package/dist/tttx/p-05d7d002.entry.js +1 -0
  47. package/dist/tttx/p-40709c59.entry.js +1 -0
  48. package/dist/tttx/p-64703252.entry.js +1 -0
  49. package/dist/tttx/p-8d1f2e5c.entry.js +1 -0
  50. package/dist/tttx/p-9bf836ed.entry.js +1 -0
  51. package/dist/tttx/p-a7b95fd2.js +2 -0
  52. package/dist/tttx/tttx.esm.js +1 -1
  53. package/dist/types/components/atoms/tttx-button/tttx-button.d.ts +9 -0
  54. package/dist/types/components/atoms/tttx-button/tttx-button.stories.d.ts +20 -0
  55. package/dist/types/components/atoms/tttx-single-input/tttx-single-input.d.ts +20 -0
  56. package/dist/types/components/atoms/tttx-single-input/tttx-single-input.stories.d.ts +27 -0
  57. package/dist/types/components/atoms/tttx-text-box/tttx-text-box.d.ts +14 -0
  58. package/dist/types/components/atoms/tttx-text-box/tttx-text-box.stories.d.ts +6 -0
  59. package/dist/types/components/atoms/ttx-checkbox/tttx-checkbox.d.ts +9 -0
  60. package/dist/types/components/atoms/ttx-checkbox/tttx-checkbox.stories.d.ts +6 -0
  61. package/dist/types/components/molecules/tttx-form/tttx-form.d.ts +11 -0
  62. package/dist/types/components/molecules/tttx-form/tttx-form.stories.d.ts +6 -0
  63. package/dist/types/components.d.ts +128 -51
  64. package/dist/types/icons.d.ts +2 -0
  65. package/dist/types/stencil-public-runtime.d.ts +59 -3
  66. package/loader/index.d.ts +9 -0
  67. package/package.json +58 -59
  68. package/readme.md +1 -6
  69. package/dist/cjs/toolbar-656be6e6.js +0 -34259
  70. package/dist/cjs/tttx-icon.cjs.entry.js +0 -21
  71. package/dist/cjs/tttx-page.cjs.entry.js +0 -927
  72. package/dist/cjs/tttx-worksheet.cjs.entry.js +0 -47
  73. package/dist/collection/components/components/tttx-icon/tttx-icon.css +0 -89
  74. package/dist/collection/components/components/tttx-icon/tttx-icon.js +0 -59
  75. package/dist/collection/components/components/tttx-icon/tttx-icon.stories.js +0 -40
  76. package/dist/collection/components/patterns/tttx-page/tttx-page.css +0 -162
  77. package/dist/collection/components/patterns/tttx-page/tttx-page.js +0 -213
  78. package/dist/collection/components/patterns/tttx-page/tttx-page.stories.js +0 -80
  79. package/dist/collection/components/patterns/tttx-worksheet/tttx-worksheet.css +0 -134
  80. package/dist/collection/components/patterns/tttx-worksheet/tttx-worksheet.js +0 -70
  81. package/dist/collection/components/patterns/tttx-worksheet/tttx-worksheet.stories.js +0 -44
  82. package/dist/components/tttx-icon.js +0 -37
  83. package/dist/components/tttx-page.js +0 -953
  84. package/dist/components/tttx-worksheet.js +0 -6
  85. package/dist/components/tttx-worksheet2.js +0 -34288
  86. package/dist/esm/toolbar-cede4385.js +0 -34231
  87. package/dist/esm/tttx-icon.entry.js +0 -17
  88. package/dist/esm/tttx-page.entry.js +0 -923
  89. package/dist/esm/tttx-worksheet.entry.js +0 -43
  90. package/dist/tttx/p-4b57de2e.entry.js +0 -1
  91. package/dist/tttx/p-61f78304.entry.js +0 -1
  92. package/dist/tttx/p-7244abd4.entry.js +0 -1
  93. package/dist/tttx/p-d038fe18.js +0 -1
  94. package/dist/tttx/p-ddfeb0ba.js +0 -2
  95. package/dist/tttx/tttx.css +0 -1
  96. package/dist/types/components/components/tttx-icon/tttx-icon.d.ts +0 -5
  97. package/dist/types/components/components/tttx-icon/tttx-icon.stories.d.ts +0 -24
  98. package/dist/types/components/patterns/tttx-page/tttx-page.d.ts +0 -21
  99. package/dist/types/components/patterns/tttx-page/tttx-page.stories.d.ts +0 -48
  100. package/dist/types/components/patterns/tttx-worksheet/tttx-worksheet.d.ts +0 -9
  101. package/dist/types/components/patterns/tttx-worksheet/tttx-worksheet.stories.d.ts +0 -23
@@ -8,11 +8,8 @@ const NAMESPACE = 'tttx';
8
8
  *
9
9
  * Modified for Stencil's renderer and slot projection
10
10
  */
11
- let contentRef;
11
+ let scopeId;
12
12
  let hostTagName;
13
- let useNativeShadowDom = false;
14
- let checkSlotFallbackVisibility = false;
15
- let checkSlotRelocate = false;
16
13
  let isSvgMode = false;
17
14
  let queuePending = false;
18
15
  const createTime = (fnName, tagName = '') => {
@@ -38,11 +35,24 @@ const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
38
35
  * Don't add values to these!!
39
36
  */
40
37
  const EMPTY_OBJ = {};
38
+ const isDef = (v) => v != null;
41
39
  const isComplexType = (o) => {
42
40
  // https://jsperf.com/typeof-fn-object/5
43
41
  o = typeof o;
44
42
  return o === 'object' || o === 'function';
45
43
  };
44
+ /**
45
+ * Helper method for querying a `meta` tag that contains a nonce value
46
+ * out of a DOM's head.
47
+ *
48
+ * @param doc The DOM containing the `head` to query against
49
+ * @returns The content of the meta tag representing the nonce value, or `undefined` if no tag
50
+ * exists or the tag has no content.
51
+ */
52
+ function queryNonceMetaTagContent(doc) {
53
+ var _a, _b, _c;
54
+ 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;
55
+ }
46
56
  /**
47
57
  * Production h() function based on Preact by
48
58
  * Jason Miller (@developit)
@@ -51,12 +61,10 @@ const isComplexType = (o) => {
51
61
  *
52
62
  * Modified for Stencil's compiler and vdom
53
63
  */
54
- // const stack: any[] = [];
55
64
  // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
56
65
  // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
57
66
  const h = (nodeName, vnodeData, ...children) => {
58
67
  let child = null;
59
- let slotName = null;
60
68
  let simple = false;
61
69
  let lastSimple = false;
62
70
  const vNodeChildren = [];
@@ -84,9 +92,6 @@ const h = (nodeName, vnodeData, ...children) => {
84
92
  };
85
93
  walk(children);
86
94
  if (vnodeData) {
87
- if (vnodeData.name) {
88
- slotName = vnodeData.name;
89
- }
90
95
  {
91
96
  const classData = vnodeData.className || vnodeData.class;
92
97
  if (classData) {
@@ -104,11 +109,16 @@ const h = (nodeName, vnodeData, ...children) => {
104
109
  if (vNodeChildren.length > 0) {
105
110
  vnode.$children$ = vNodeChildren;
106
111
  }
107
- {
108
- vnode.$name$ = slotName;
109
- }
110
112
  return vnode;
111
113
  };
114
+ /**
115
+ * A utility function for creating a virtual DOM node from a tag and some
116
+ * possible text content.
117
+ *
118
+ * @param tag the tag for this element
119
+ * @param text possible text content for the node
120
+ * @returns a newly-minted virtual DOM node
121
+ */
112
122
  const newVNode = (tag, text) => {
113
123
  const vnode = {
114
124
  $flags$: 0,
@@ -120,12 +130,15 @@ const newVNode = (tag, text) => {
120
130
  {
121
131
  vnode.$attrs$ = null;
122
132
  }
123
- {
124
- vnode.$name$ = null;
125
- }
126
133
  return vnode;
127
134
  };
128
135
  const Host = {};
136
+ /**
137
+ * Check whether a given node is a Host node or not
138
+ *
139
+ * @param node the virtual DOM node to check
140
+ * @returns whether it's a Host node or not
141
+ */
129
142
  const isHost = (node) => node && node.$tag$ === Host;
130
143
  /**
131
144
  * Parse a new property value for a given property type.
@@ -153,6 +166,11 @@ const isHost = (node) => node && node.$tag$ === Host;
153
166
  const parsePropertyValue = (propValue, propType) => {
154
167
  // ensure this value is of the correct prop type
155
168
  if (propValue != null && !isComplexType(propValue)) {
169
+ if (propType & 4 /* MEMBER_FLAGS.Boolean */) {
170
+ // per the HTML spec, any string value means it is a boolean true value
171
+ // but we'll cheat here and say that the string "false" is the boolean false
172
+ return propValue === 'false' ? false : propValue === '' || !!propValue;
173
+ }
156
174
  if (propType & 1 /* MEMBER_FLAGS.String */) {
157
175
  // could have been passed as a number or boolean
158
176
  // but we still want it as a string
@@ -165,6 +183,20 @@ const parsePropertyValue = (propValue, propType) => {
165
183
  // so no need to change to a different type
166
184
  return propValue;
167
185
  };
186
+ const getElement = (ref) => (getHostRef(ref).$hostElement$ );
187
+ const createEvent = (ref, name, flags) => {
188
+ const elm = getElement(ref);
189
+ return {
190
+ emit: (detail) => {
191
+ return emitEvent(elm, name, {
192
+ bubbles: !!(flags & 4 /* EVENT_FLAGS.Bubbles */),
193
+ composed: !!(flags & 2 /* EVENT_FLAGS.Composed */),
194
+ cancelable: !!(flags & 1 /* EVENT_FLAGS.Cancellable */),
195
+ detail,
196
+ });
197
+ },
198
+ };
199
+ };
168
200
  /**
169
201
  * Helper function to create & dispatch a custom Event on a provided target
170
202
  * @param elm the target of the Event
@@ -195,6 +227,7 @@ const registerStyle = (scopeId, cssText, allowCS) => {
195
227
  styles.set(scopeId, style);
196
228
  };
197
229
  const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
230
+ var _a;
198
231
  let scopeId = getScopeId(cmpMeta);
199
232
  const style = styles.get(scopeId);
200
233
  // if an element is NOT connected then getRootNode() will return the wrong root node
@@ -214,6 +247,11 @@ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
214
247
  styleElm = doc.createElement('style');
215
248
  styleElm.innerHTML = style;
216
249
  }
250
+ // Apply CSP nonce to the style tag if it exists
251
+ const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
252
+ if (nonce != null) {
253
+ styleElm.setAttribute('nonce', nonce);
254
+ }
217
255
  styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
218
256
  }
219
257
  if (appliedStyles) {
@@ -230,8 +268,20 @@ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
230
268
  const attachStyles = (hostRef) => {
231
269
  const cmpMeta = hostRef.$cmpMeta$;
232
270
  const elm = hostRef.$hostElement$;
271
+ const flags = cmpMeta.$flags$;
233
272
  const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
234
- addStyle(elm.getRootNode(), cmpMeta);
273
+ const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
274
+ if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
275
+ // only required when we're NOT using native shadow dom (slot)
276
+ // or this browser doesn't support native shadow dom
277
+ // and this host element was NOT created with SSR
278
+ // let's pick out the inner content for slot projection
279
+ // create a node to represent where the original
280
+ // content was first placed, which is useful later on
281
+ // DOM WRITE!!
282
+ elm['s-sc'] = scopeId;
283
+ elm.classList.add(scopeId + '-h');
284
+ }
235
285
  endAttachStyles();
236
286
  };
237
287
  const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
@@ -246,7 +296,7 @@ const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
246
296
  const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
247
297
  if (oldValue !== newValue) {
248
298
  let isProp = isMemberInElement(elm, memberName);
249
- memberName.toLowerCase();
299
+ let ln = memberName.toLowerCase();
250
300
  if (memberName === 'class') {
251
301
  const classList = elm.classList;
252
302
  const oldClasses = parseClassList(oldValue);
@@ -254,35 +304,43 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
254
304
  classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
255
305
  classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
256
306
  }
257
- else if (memberName === 'style') {
258
- // update style attribute, css properties and values
259
- {
260
- for (const prop in oldValue) {
261
- if (!newValue || newValue[prop] == null) {
262
- if (prop.includes('-')) {
263
- elm.style.removeProperty(prop);
264
- }
265
- else {
266
- elm.style[prop] = '';
267
- }
268
- }
269
- }
307
+ else if ((!isProp ) &&
308
+ memberName[0] === 'o' &&
309
+ memberName[1] === 'n') {
310
+ // Event Handlers
311
+ // so if the member name starts with "on" and the 3rd characters is
312
+ // a capital letter, and it's not already a member on the element,
313
+ // then we're assuming it's an event listener
314
+ if (memberName[2] === '-') {
315
+ // on- prefixed events
316
+ // allows to be explicit about the dom event to listen without any magic
317
+ // under the hood:
318
+ // <my-cmp on-click> // listens for "click"
319
+ // <my-cmp on-Click> // listens for "Click"
320
+ // <my-cmp on-ionChange> // listens for "ionChange"
321
+ // <my-cmp on-EVENTS> // listens for "EVENTS"
322
+ memberName = memberName.slice(3);
270
323
  }
271
- for (const prop in newValue) {
272
- if (!oldValue || newValue[prop] !== oldValue[prop]) {
273
- if (prop.includes('-')) {
274
- elm.style.setProperty(prop, newValue[prop]);
275
- }
276
- else {
277
- elm.style[prop] = newValue[prop];
278
- }
279
- }
324
+ else if (isMemberInElement(win, ln)) {
325
+ // standard event
326
+ // the JSX attribute could have been "onMouseOver" and the
327
+ // member name "onmouseover" is on the window's prototype
328
+ // so let's add the listener "mouseover", which is all lowercased
329
+ memberName = ln.slice(2);
330
+ }
331
+ else {
332
+ // custom event
333
+ // the JSX attribute could have been "onMyCustomEvent"
334
+ // so let's trim off the "on" prefix and lowercase the first character
335
+ // and add the listener "myCustomEvent"
336
+ // except for the first character, we keep the event name case
337
+ memberName = ln[2] + memberName.slice(3);
338
+ }
339
+ if (oldValue) {
340
+ plt.rel(elm, memberName, oldValue, false);
280
341
  }
281
- }
282
- else if (memberName === 'ref') {
283
- // minifier will clean this up
284
342
  if (newValue) {
285
- newValue(elm);
343
+ plt.ael(elm, memberName, newValue, false);
286
344
  }
287
345
  }
288
346
  else {
@@ -362,36 +420,22 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
362
420
  let i = 0;
363
421
  let elm;
364
422
  let childNode;
365
- let oldVNode;
366
- if (!useNativeShadowDom) {
367
- // remember for later we need to check to relocate nodes
368
- checkSlotRelocate = true;
369
- if (newVNode.$tag$ === 'slot') {
370
- newVNode.$flags$ |= newVNode.$children$
371
- ? // slot element has fallback content
372
- 2 /* VNODE_FLAGS.isSlotFallback */
373
- : // slot element does not have fallback content
374
- 1 /* VNODE_FLAGS.isSlotReference */;
375
- }
376
- }
377
423
  if (newVNode.$text$ !== null) {
378
424
  // create text node
379
425
  elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
380
426
  }
381
- else if (newVNode.$flags$ & 1 /* VNODE_FLAGS.isSlotReference */) {
382
- // create a slot reference node
383
- elm = newVNode.$elm$ =
384
- doc.createTextNode('');
385
- }
386
427
  else {
387
428
  // create element
388
- elm = newVNode.$elm$ = (doc.createElement(newVNode.$flags$ & 2 /* VNODE_FLAGS.isSlotFallback */
389
- ? 'slot-fb'
390
- : newVNode.$tag$));
429
+ elm = newVNode.$elm$ = (doc.createElement(newVNode.$tag$));
391
430
  // add css classes, attrs, props, listeners, etc.
392
431
  {
393
432
  updateElement(null, newVNode, isSvgMode);
394
433
  }
434
+ if (isDef(scopeId) && elm['s-si'] !== scopeId) {
435
+ // if there is a scopeId and this is the initial render
436
+ // then let's add the scopeId as a css class
437
+ elm.classList.add((elm['s-si'] = scopeId));
438
+ }
395
439
  if (newVNode.$children$) {
396
440
  for (i = 0; i < newVNode.$children$.length; ++i) {
397
441
  // create the node
@@ -404,82 +448,56 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
404
448
  }
405
449
  }
406
450
  }
407
- {
408
- elm['s-hn'] = hostTagName;
409
- if (newVNode.$flags$ & (2 /* VNODE_FLAGS.isSlotFallback */ | 1 /* VNODE_FLAGS.isSlotReference */)) {
410
- // remember the content reference comment
411
- elm['s-sr'] = true;
412
- // remember the content reference comment
413
- elm['s-cr'] = contentRef;
414
- // remember the slot name, or empty string for default slot
415
- elm['s-sn'] = newVNode.$name$ || '';
416
- // check if we've got an old vnode for this slot
417
- oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
418
- if (oldVNode && oldVNode.$tag$ === newVNode.$tag$ && oldParentVNode.$elm$) {
419
- // we've got an old slot vnode and the wrapper is being replaced
420
- // so let's move the old slot content back to it's original location
421
- putBackInOriginalLocation(oldParentVNode.$elm$, false);
422
- }
423
- }
424
- }
425
451
  return elm;
426
452
  };
427
- const putBackInOriginalLocation = (parentElm, recursive) => {
428
- plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
429
- const oldSlotChildNodes = parentElm.childNodes;
430
- for (let i = oldSlotChildNodes.length - 1; i >= 0; i--) {
431
- const childNode = oldSlotChildNodes[i];
432
- if (childNode['s-hn'] !== hostTagName && childNode['s-ol']) {
433
- // // this child node in the old element is from another component
434
- // // remove this node from the old slot's parent
435
- // childNode.remove();
436
- // and relocate it back to it's original location
437
- parentReferenceNode(childNode).insertBefore(childNode, referenceNode(childNode));
438
- // remove the old original location comment entirely
439
- // later on the patch function will know what to do
440
- // and move this to the correct spot in need be
441
- childNode['s-ol'].remove();
442
- childNode['s-ol'] = undefined;
443
- checkSlotRelocate = true;
444
- }
445
- if (recursive) {
446
- putBackInOriginalLocation(childNode, recursive);
447
- }
448
- }
449
- plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
450
- };
453
+ /**
454
+ * Create DOM nodes corresponding to a list of {@link d.Vnode} objects and
455
+ * add them to the DOM in the appropriate place.
456
+ *
457
+ * @param parentElm the DOM node which should be used as a parent for the new
458
+ * DOM nodes
459
+ * @param before a child of the `parentElm` which the new children should be
460
+ * inserted before (optional)
461
+ * @param parentVNode the parent virtual DOM node
462
+ * @param vnodes the new child virtual DOM nodes to produce DOM nodes for
463
+ * @param startIdx the index in the child virtual DOM nodes at which to start
464
+ * creating DOM nodes (inclusive)
465
+ * @param endIdx the index in the child virtual DOM nodes at which to stop
466
+ * creating DOM nodes (inclusive)
467
+ */
451
468
  const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
452
- let containerElm = ((parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
469
+ let containerElm = (parentElm);
453
470
  let childNode;
471
+ if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
472
+ containerElm = containerElm.shadowRoot;
473
+ }
454
474
  for (; startIdx <= endIdx; ++startIdx) {
455
475
  if (vnodes[startIdx]) {
456
476
  childNode = createElm(null, parentVNode, startIdx);
457
477
  if (childNode) {
458
478
  vnodes[startIdx].$elm$ = childNode;
459
- containerElm.insertBefore(childNode, referenceNode(before) );
479
+ containerElm.insertBefore(childNode, before);
460
480
  }
461
481
  }
462
482
  }
463
483
  };
484
+ /**
485
+ * Remove the DOM elements corresponding to a list of {@link d.VNode} objects.
486
+ * This can be used to, for instance, clean up after a list of children which
487
+ * should no longer be shown.
488
+ *
489
+ * This function also handles some of Stencil's slot relocation logic.
490
+ *
491
+ * @param vnodes a list of virtual DOM nodes to remove
492
+ * @param startIdx the index at which to start removing nodes (inclusive)
493
+ * @param endIdx the index at which to stop removing nodes (inclusive)
494
+ * @param vnode a VNode
495
+ * @param elm an element
496
+ */
464
497
  const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
465
498
  for (; startIdx <= endIdx; ++startIdx) {
466
499
  if ((vnode = vnodes[startIdx])) {
467
500
  elm = vnode.$elm$;
468
- callNodeRefs(vnode);
469
- {
470
- // we're removing this element
471
- // so it's possible we need to show slot fallback content now
472
- checkSlotFallbackVisibility = true;
473
- if (elm['s-ol']) {
474
- // remove the original location comment
475
- elm['s-ol'].remove();
476
- }
477
- else {
478
- // it's possible that child nodes of the node
479
- // that's being removed are slot nodes
480
- putBackInOriginalLocation(elm, true);
481
- }
482
- }
483
501
  // remove the vnode's element from the dom
484
502
  elm.remove();
485
503
  }
@@ -595,23 +613,6 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
595
613
  newEndVnode = newCh[--newEndIdx];
596
614
  }
597
615
  else if (isSameVnode(oldStartVnode, newEndVnode)) {
598
- // case: "Vnode moved right"
599
- //
600
- // We've found that the last node in our window on the new children is
601
- // the same VNode as the _first_ node in our window on the old children
602
- // we're dealing with now. Visually, this is the layout of these two
603
- // nodes:
604
- //
605
- // newCh: [..., newStartVnode , ... , newEndVnode , ...]
606
- // ^^^^^^^^^^^
607
- // oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
608
- // ^^^^^^^^^^^^^
609
- //
610
- // In this situation we need to patch `newEndVnode` onto `oldStartVnode`
611
- // and move the DOM element for `oldStartVnode`.
612
- if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
613
- putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
614
- }
615
616
  patch(oldStartVnode, newEndVnode);
616
617
  // We need to move the element for `oldStartVnode` into a position which
617
618
  // will be appropriate for `newEndVnode`. For this we can use
@@ -635,24 +636,6 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
635
636
  newEndVnode = newCh[--newEndIdx];
636
637
  }
637
638
  else if (isSameVnode(oldEndVnode, newStartVnode)) {
638
- // case: "Vnode moved left"
639
- //
640
- // We've found that the first node in our window on the new children is
641
- // the same VNode as the _last_ node in our window on the old children.
642
- // Visually, this is the layout of these two nodes:
643
- //
644
- // newCh: [..., newStartVnode , ... , newEndVnode , ...]
645
- // ^^^^^^^^^^^^^
646
- // oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
647
- // ^^^^^^^^^^^
648
- //
649
- // In this situation we need to patch `newStartVnode` onto `oldEndVnode`
650
- // (which will handle updating any changed attributes, reconciling their
651
- // children etc) but we also need to move the DOM node to which
652
- // `oldEndVnode` corresponds.
653
- if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
654
- putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
655
- }
656
639
  patch(oldEndVnode, newStartVnode);
657
640
  // We've already checked above if `oldStartVnode` and `newStartVnode` are
658
641
  // the same node, so since we're here we know that they are not. Thus we
@@ -675,7 +658,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
675
658
  if (node) {
676
659
  // if we created a new node then handle inserting it to the DOM
677
660
  {
678
- parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
661
+ oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
679
662
  }
680
663
  }
681
664
  }
@@ -702,7 +685,8 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
702
685
  *
703
686
  * So, in other words, if `key` attrs are not set on VNodes which may be
704
687
  * changing order within a `children` array or something along those lines then
705
- * we could obtain a false positive and then have to do needless re-rendering.
688
+ * we could obtain a false negative and then have to do needless re-rendering
689
+ * (i.e. we'd say two VNodes aren't equal when in fact they should be).
706
690
  *
707
691
  * @param leftVNode the first VNode to check
708
692
  * @param rightVNode the second VNode to check
@@ -712,21 +696,10 @@ const isSameVnode = (leftVNode, rightVNode) => {
712
696
  // compare if two vnode to see if they're "technically" the same
713
697
  // need to have the same element tag, and same key to be the same
714
698
  if (leftVNode.$tag$ === rightVNode.$tag$) {
715
- if (leftVNode.$tag$ === 'slot') {
716
- return leftVNode.$name$ === rightVNode.$name$;
717
- }
718
699
  return true;
719
700
  }
720
701
  return false;
721
702
  };
722
- const referenceNode = (node) => {
723
- // this node was relocated to a new location in the dom
724
- // because of some other component's slot
725
- // but we still have an html comment in place of where
726
- // it's original location was according to it's original vdom
727
- return (node && node['s-ol']) || node;
728
- };
729
- const parentReferenceNode = (node) => (node['s-ol'] ? node['s-ol'] : node).parentNode;
730
703
  /**
731
704
  * Handle reconciling an outdated VNode with a new one which corresponds to
732
705
  * it. This function handles flushing updates to the DOM and reconciling the
@@ -741,7 +714,6 @@ const patch = (oldVNode, newVNode) => {
741
714
  const newChildren = newVNode.$children$;
742
715
  const tag = newVNode.$tag$;
743
716
  const text = newVNode.$text$;
744
- let defaultHolder;
745
717
  if (text === null) {
746
718
  {
747
719
  if (tag === 'slot')
@@ -772,247 +744,38 @@ const patch = (oldVNode, newVNode) => {
772
744
  removeVnodes(oldChildren, 0, oldChildren.length - 1);
773
745
  }
774
746
  }
775
- else if ((defaultHolder = elm['s-cr'])) {
776
- // this element has slotted content
777
- defaultHolder.parentNode.textContent = text;
778
- }
779
747
  else if (oldVNode.$text$ !== text) {
780
748
  // update the text content for the text only vnode
781
749
  // and also only if the text is different than before
782
750
  elm.data = text;
783
751
  }
784
752
  };
785
- const updateFallbackSlotVisibility = (elm) => {
786
- // tslint:disable-next-line: prefer-const
787
- const childNodes = elm.childNodes;
788
- let childNode;
789
- let i;
790
- let ilen;
791
- let j;
792
- let slotNameAttr;
793
- let nodeType;
794
- for (i = 0, ilen = childNodes.length; i < ilen; i++) {
795
- childNode = childNodes[i];
796
- if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
797
- if (childNode['s-sr']) {
798
- // this is a slot fallback node
799
- // get the slot name for this slot reference node
800
- slotNameAttr = childNode['s-sn'];
801
- // by default always show a fallback slot node
802
- // then hide it if there are other slots in the light dom
803
- childNode.hidden = false;
804
- for (j = 0; j < ilen; j++) {
805
- nodeType = childNodes[j].nodeType;
806
- if (childNodes[j]['s-hn'] !== childNode['s-hn'] || slotNameAttr !== '') {
807
- // this sibling node is from a different component OR is a named fallback slot node
808
- if (nodeType === 1 /* NODE_TYPE.ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
809
- childNode.hidden = true;
810
- break;
811
- }
812
- }
813
- else {
814
- // this is a default fallback slot node
815
- // any element or text node (with content)
816
- // should hide the default fallback slot node
817
- if (nodeType === 1 /* NODE_TYPE.ElementNode */ ||
818
- (nodeType === 3 /* NODE_TYPE.TextNode */ && childNodes[j].textContent.trim() !== '')) {
819
- childNode.hidden = true;
820
- break;
821
- }
822
- }
823
- }
824
- }
825
- // keep drilling down
826
- updateFallbackSlotVisibility(childNode);
827
- }
828
- }
829
- };
830
- const relocateNodes = [];
831
- const relocateSlotContent = (elm) => {
832
- // tslint:disable-next-line: prefer-const
833
- let childNode;
834
- let node;
835
- let hostContentNodes;
836
- let slotNameAttr;
837
- let relocateNodeData;
838
- let j;
839
- let i = 0;
840
- const childNodes = elm.childNodes;
841
- const ilen = childNodes.length;
842
- for (; i < ilen; i++) {
843
- childNode = childNodes[i];
844
- if (childNode['s-sr'] && (node = childNode['s-cr']) && node.parentNode) {
845
- // first got the content reference comment node
846
- // then we got it's parent, which is where all the host content is in now
847
- hostContentNodes = node.parentNode.childNodes;
848
- slotNameAttr = childNode['s-sn'];
849
- for (j = hostContentNodes.length - 1; j >= 0; j--) {
850
- node = hostContentNodes[j];
851
- if (!node['s-cn'] && !node['s-nr'] && node['s-hn'] !== childNode['s-hn']) {
852
- // let's do some relocating to its new home
853
- // but never relocate a content reference node
854
- // that is suppose to always represent the original content location
855
- if (isNodeLocatedInSlot(node, slotNameAttr)) {
856
- // it's possible we've already decided to relocate this node
857
- relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
858
- // made some changes to slots
859
- // let's make sure we also double check
860
- // fallbacks are correctly hidden or shown
861
- checkSlotFallbackVisibility = true;
862
- node['s-sn'] = node['s-sn'] || slotNameAttr;
863
- if (relocateNodeData) {
864
- // previously we never found a slot home for this node
865
- // but turns out we did, so let's remember it now
866
- relocateNodeData.$slotRefNode$ = childNode;
867
- }
868
- else {
869
- // add to our list of nodes to relocate
870
- relocateNodes.push({
871
- $slotRefNode$: childNode,
872
- $nodeToRelocate$: node,
873
- });
874
- }
875
- if (node['s-sr']) {
876
- relocateNodes.map((relocateNode) => {
877
- if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node['s-sn'])) {
878
- relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
879
- if (relocateNodeData && !relocateNode.$slotRefNode$) {
880
- relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
881
- }
882
- }
883
- });
884
- }
885
- }
886
- else if (!relocateNodes.some((r) => r.$nodeToRelocate$ === node)) {
887
- // so far this element does not have a slot home, not setting slotRefNode on purpose
888
- // if we never find a home for this element then we'll need to hide it
889
- relocateNodes.push({
890
- $nodeToRelocate$: node,
891
- });
892
- }
893
- }
894
- }
895
- }
896
- if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
897
- relocateSlotContent(childNode);
898
- }
899
- }
900
- };
901
- const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
902
- if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
903
- if (nodeToRelocate.getAttribute('slot') === null && slotNameAttr === '') {
904
- return true;
905
- }
906
- if (nodeToRelocate.getAttribute('slot') === slotNameAttr) {
907
- return true;
908
- }
909
- return false;
910
- }
911
- if (nodeToRelocate['s-sn'] === slotNameAttr) {
912
- return true;
913
- }
914
- return slotNameAttr === '';
915
- };
916
- const callNodeRefs = (vNode) => {
917
- {
918
- vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
919
- vNode.$children$ && vNode.$children$.map(callNodeRefs);
920
- }
921
- };
753
+ /**
754
+ * The main entry point for Stencil's virtual DOM-based rendering engine
755
+ *
756
+ * Given a {@link d.HostRef} container and some virtual DOM nodes, this
757
+ * function will handle creating a virtual DOM tree with a single root, patching
758
+ * the current virtual DOM tree onto an old one (if any), dealing with slot
759
+ * relocation, and reflecting attributes.
760
+ *
761
+ * @param hostRef data needed to root and render the virtual DOM tree, such as
762
+ * the DOM node into which it should be rendered.
763
+ * @param renderFnResults the virtual DOM nodes to be rendered
764
+ */
922
765
  const renderVdom = (hostRef, renderFnResults) => {
923
766
  const hostElm = hostRef.$hostElement$;
924
- const cmpMeta = hostRef.$cmpMeta$;
925
767
  const oldVNode = hostRef.$vnode$ || newVNode(null, null);
926
768
  const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
927
769
  hostTagName = hostElm.tagName;
928
770
  rootVnode.$tag$ = null;
929
771
  rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
930
772
  hostRef.$vnode$ = rootVnode;
931
- rootVnode.$elm$ = oldVNode.$elm$ = (hostElm);
773
+ rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
932
774
  {
933
- contentRef = hostElm['s-cr'];
934
- useNativeShadowDom = (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) !== 0;
935
- // always reset
936
- checkSlotFallbackVisibility = false;
775
+ scopeId = hostElm['s-sc'];
937
776
  }
938
777
  // synchronous patch
939
778
  patch(oldVNode, rootVnode);
940
- {
941
- // while we're moving nodes around existing nodes, temporarily disable
942
- // the disconnectCallback from working
943
- plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
944
- if (checkSlotRelocate) {
945
- relocateSlotContent(rootVnode.$elm$);
946
- let relocateData;
947
- let nodeToRelocate;
948
- let orgLocationNode;
949
- let parentNodeRef;
950
- let insertBeforeNode;
951
- let refNode;
952
- let i = 0;
953
- for (; i < relocateNodes.length; i++) {
954
- relocateData = relocateNodes[i];
955
- nodeToRelocate = relocateData.$nodeToRelocate$;
956
- if (!nodeToRelocate['s-ol']) {
957
- // add a reference node marking this node's original location
958
- // keep a reference to this node for later lookups
959
- orgLocationNode =
960
- doc.createTextNode('');
961
- orgLocationNode['s-nr'] = nodeToRelocate;
962
- nodeToRelocate.parentNode.insertBefore((nodeToRelocate['s-ol'] = orgLocationNode), nodeToRelocate);
963
- }
964
- }
965
- for (i = 0; i < relocateNodes.length; i++) {
966
- relocateData = relocateNodes[i];
967
- nodeToRelocate = relocateData.$nodeToRelocate$;
968
- if (relocateData.$slotRefNode$) {
969
- // by default we're just going to insert it directly
970
- // after the slot reference node
971
- parentNodeRef = relocateData.$slotRefNode$.parentNode;
972
- insertBeforeNode = relocateData.$slotRefNode$.nextSibling;
973
- orgLocationNode = nodeToRelocate['s-ol'];
974
- while ((orgLocationNode = orgLocationNode.previousSibling)) {
975
- refNode = orgLocationNode['s-nr'];
976
- if (refNode && refNode['s-sn'] === nodeToRelocate['s-sn'] && parentNodeRef === refNode.parentNode) {
977
- refNode = refNode.nextSibling;
978
- if (!refNode || !refNode['s-nr']) {
979
- insertBeforeNode = refNode;
980
- break;
981
- }
982
- }
983
- }
984
- if ((!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode) ||
985
- nodeToRelocate.nextSibling !== insertBeforeNode) {
986
- // we've checked that it's worth while to relocate
987
- // since that the node to relocate
988
- // has a different next sibling or parent relocated
989
- if (nodeToRelocate !== insertBeforeNode) {
990
- if (!nodeToRelocate['s-hn'] && nodeToRelocate['s-ol']) {
991
- // probably a component in the index.html that doesn't have it's hostname set
992
- nodeToRelocate['s-hn'] = nodeToRelocate['s-ol'].parentNode.nodeName;
993
- }
994
- // add it back to the dom but in its new home
995
- parentNodeRef.insertBefore(nodeToRelocate, insertBeforeNode);
996
- }
997
- }
998
- }
999
- else {
1000
- // this node doesn't have a slot home to go to, so let's hide it
1001
- if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1002
- nodeToRelocate.hidden = true;
1003
- }
1004
- }
1005
- }
1006
- }
1007
- if (checkSlotFallbackVisibility) {
1008
- updateFallbackSlotVisibility(rootVnode.$elm$);
1009
- }
1010
- // done moving nodes around
1011
- // allow the disconnect callback to work again
1012
- plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
1013
- // always reset
1014
- relocateNodes.length = 0;
1015
- }
1016
779
  };
1017
780
  const attachToAncestor = (hostRef, ancestorComponent) => {
1018
781
  if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
@@ -1038,6 +801,15 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
1038
801
  const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
1039
802
  const instance = hostRef.$lazyInstance$ ;
1040
803
  let promise;
804
+ if (isInitialLoad) {
805
+ {
806
+ hostRef.$flags$ |= 256 /* HOST_FLAGS.isListenReady */;
807
+ if (hostRef.$queuedListeners$) {
808
+ hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
809
+ hostRef.$queuedListeners$ = null;
810
+ }
811
+ }
812
+ }
1041
813
  endSchedule();
1042
814
  return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
1043
815
  };
@@ -1369,15 +1141,6 @@ const connectedCallback = (elm) => {
1369
1141
  if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
1370
1142
  // first time this component has connected
1371
1143
  hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
1372
- {
1373
- // initUpdate
1374
- // if the slot polyfill is required we'll need to put some nodes
1375
- // in here to act as original content anchors as we move nodes around
1376
- // host element has been connected to the DOM
1377
- if ((cmpMeta.$flags$ & (4 /* CMP_FLAGS.hasSlotRelocation */ | 8 /* CMP_FLAGS.needsShadowDomShim */))) {
1378
- setContentReference(elm);
1379
- }
1380
- }
1381
1144
  {
1382
1145
  // find the first ancestor component (if there is one) and register
1383
1146
  // this component as one of the actively loading child components for its ancestor
@@ -1408,26 +1171,28 @@ const connectedCallback = (elm) => {
1408
1171
  initializeComponent(elm, hostRef, cmpMeta);
1409
1172
  }
1410
1173
  }
1174
+ else {
1175
+ // not the first time this has connected
1176
+ // reattach any event listeners to the host
1177
+ // since they would have been removed when disconnected
1178
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
1179
+ }
1411
1180
  endConnected();
1412
1181
  }
1413
1182
  };
1414
- const setContentReference = (elm) => {
1415
- // only required when we're NOT using native shadow dom (slot)
1416
- // or this browser doesn't support native shadow dom
1417
- // and this host element was NOT created with SSR
1418
- // let's pick out the inner content for slot projection
1419
- // create a node to represent where the original
1420
- // content was first placed, which is useful later on
1421
- const contentRefElm = (elm['s-cr'] = doc.createComment(''));
1422
- contentRefElm['s-cn'] = true;
1423
- elm.insertBefore(contentRefElm, elm.firstChild);
1424
- };
1425
1183
  const disconnectedCallback = (elm) => {
1426
1184
  if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
1427
- getHostRef(elm);
1185
+ const hostRef = getHostRef(elm);
1186
+ {
1187
+ if (hostRef.$rmListeners$) {
1188
+ hostRef.$rmListeners$.map((rmListener) => rmListener());
1189
+ hostRef.$rmListeners$ = undefined;
1190
+ }
1191
+ }
1428
1192
  }
1429
1193
  };
1430
1194
  const bootstrapLazy = (lazyBundles, options = {}) => {
1195
+ var _a;
1431
1196
  const endBootstrap = createTime();
1432
1197
  const cmpTags = [];
1433
1198
  const exclude = options.exclude || [];
@@ -1451,6 +1216,9 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1451
1216
  {
1452
1217
  cmpMeta.$members$ = compactMeta[2];
1453
1218
  }
1219
+ {
1220
+ cmpMeta.$listeners$ = compactMeta[3];
1221
+ }
1454
1222
  const tagName = cmpMeta.$tagName$;
1455
1223
  const HostElement = class extends HTMLElement {
1456
1224
  // StencilLazyHost
@@ -1459,6 +1227,17 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1459
1227
  super(self);
1460
1228
  self = this;
1461
1229
  registerHost(self, cmpMeta);
1230
+ if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
1231
+ // this component is using shadow dom
1232
+ // and this browser supports shadow dom
1233
+ // add the read-only property "shadowRoot" to the host element
1234
+ // adding the shadow root build conditionals to minimize runtime
1235
+ {
1236
+ {
1237
+ self.attachShadow({ mode: 'open' });
1238
+ }
1239
+ }
1240
+ }
1462
1241
  }
1463
1242
  connectedCallback() {
1464
1243
  if (appLoadFallback) {
@@ -1490,6 +1269,11 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1490
1269
  {
1491
1270
  visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
1492
1271
  visibilityStyle.setAttribute('data-styles', '');
1272
+ // Apply CSP nonce to the style tag if it exists
1273
+ const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
1274
+ if (nonce != null) {
1275
+ visibilityStyle.setAttribute('nonce', nonce);
1276
+ }
1493
1277
  head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
1494
1278
  }
1495
1279
  // Process deferred connectedCallbacks now all components have been registered
@@ -1505,6 +1289,42 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1505
1289
  // Fallback appLoad event
1506
1290
  endBootstrap();
1507
1291
  };
1292
+ const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
1293
+ if (listeners) {
1294
+ listeners.map(([flags, name, method]) => {
1295
+ const target = elm;
1296
+ const handler = hostListenerProxy(hostRef, method);
1297
+ const opts = hostListenerOpts(flags);
1298
+ plt.ael(target, name, handler, opts);
1299
+ (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
1300
+ });
1301
+ }
1302
+ };
1303
+ const hostListenerProxy = (hostRef, methodName) => (ev) => {
1304
+ try {
1305
+ {
1306
+ if (hostRef.$flags$ & 256 /* HOST_FLAGS.isListenReady */) {
1307
+ // instance is ready, let's call it's member method for this event
1308
+ hostRef.$lazyInstance$[methodName](ev);
1309
+ }
1310
+ else {
1311
+ (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
1312
+ }
1313
+ }
1314
+ }
1315
+ catch (e) {
1316
+ consoleError(e);
1317
+ }
1318
+ };
1319
+ // prettier-ignore
1320
+ const hostListenerOpts = (flags) => (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0;
1321
+ /**
1322
+ * Assigns the given value to the nonce property on the runtime platform object.
1323
+ * During runtime, this value is used to set the nonce attribute on all dynamically created script and style tags.
1324
+ * @param nonce The value to be assigned to the platform nonce property.
1325
+ * @returns void
1326
+ */
1327
+ const setNonce = (nonce) => (plt.$nonce$ = nonce);
1508
1328
  const hostRefs = /*@__PURE__*/ new WeakMap();
1509
1329
  const getHostRef = (ref) => hostRefs.get(ref);
1510
1330
  const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
@@ -1520,6 +1340,7 @@ const registerHost = (elm, cmpMeta) => {
1520
1340
  elm['s-p'] = [];
1521
1341
  elm['s-rc'] = [];
1522
1342
  }
1343
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
1523
1344
  return hostRefs.set(elm, hostRef);
1524
1345
  };
1525
1346
  const isMemberInElement = (elm, memberName) => memberName in elm;
@@ -1611,4 +1432,4 @@ const flush = () => {
1611
1432
  const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
1612
1433
  const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
1613
1434
 
1614
- export { Host as H, bootstrapLazy as b, h, promiseResolve as p, registerInstance as r };
1435
+ export { Host as H, bootstrapLazy as b, createEvent as c, getElement as g, h, promiseResolve as p, registerInstance as r, setNonce as s };