@jumpgroup/jump-design-system 0.3.19 → 0.3.21

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 (172) hide show
  1. package/dist/cjs/class-map-b27ebf69.js +37 -0
  2. package/dist/cjs/class-map-b27ebf69.js.map +1 -0
  3. package/dist/cjs/index-86f59981.js +1575 -0
  4. package/dist/cjs/index-86f59981.js.map +1 -0
  5. package/dist/cjs/jump-accordion.cjs.entry.js +533 -3
  6. package/dist/cjs/jump-accordion.cjs.entry.js.map +1 -1
  7. package/dist/cjs/jump-badge.cjs.entry.js +2 -2
  8. package/dist/cjs/jump-button_2.cjs.entry.js +2 -2
  9. package/dist/cjs/jump-card-ecommerce-option.cjs.entry.js +2 -2
  10. package/dist/cjs/jump-card-ecommerce.cjs.entry.js +28 -19
  11. package/dist/cjs/jump-card-ecommerce.cjs.entry.js.map +1 -1
  12. package/dist/cjs/jump-card.cjs.entry.js +3 -3
  13. package/dist/cjs/jump-design-system.cjs.js +10 -10
  14. package/dist/cjs/jump-design-system.cjs.js.map +1 -1
  15. package/dist/cjs/jump-filter-checkbox.cjs.entry.js +8 -33
  16. package/dist/cjs/jump-filter-checkbox.cjs.entry.js.map +1 -1
  17. package/dist/cjs/jump-filter.cjs.entry.js +4 -4
  18. package/dist/cjs/jump-filtergroup.cjs.entry.js +4 -4
  19. package/dist/cjs/jump-pagination-table.cjs.entry.js +4 -4
  20. package/dist/cjs/jump-pagination.cjs.entry.js +4 -4
  21. package/dist/cjs/jump-pagination.cjs.entry.js.map +1 -1
  22. package/dist/cjs/jump-quantity.cjs.entry.js +4 -4
  23. package/dist/cjs/jump-tab-item.cjs.entry.js +3 -3
  24. package/dist/cjs/jump-tab-panel.cjs.entry.js +2 -2
  25. package/dist/cjs/jump-tab.cjs.entry.js +2 -2
  26. package/dist/cjs/loader.cjs.js +2 -2
  27. package/dist/collection/collection-manifest.json +2 -2
  28. package/dist/collection/components/jump-accordion/jump-accordion.css +100 -1
  29. package/dist/collection/components/jump-accordion/jump-accordion.js +163 -1
  30. package/dist/collection/components/jump-accordion/jump-accordion.js.map +1 -1
  31. package/dist/collection/components/jump-accordion/jump-accordion.stories.js +127 -0
  32. package/dist/collection/components/jump-accordion/jump-accordion.stories.js.map +1 -0
  33. package/dist/collection/components/jump-badge/jump-badge.js +1 -1
  34. package/dist/collection/components/jump-button/jump-button.js +1 -1
  35. package/dist/collection/components/jump-card/jump-card.js +2 -2
  36. package/dist/collection/components/jump-card-ecommerce/jump-card-ecommerce.css +23 -2
  37. package/dist/collection/components/jump-card-ecommerce/jump-card-ecommerce.js +44 -17
  38. package/dist/collection/components/jump-card-ecommerce/jump-card-ecommerce.js.map +1 -1
  39. package/dist/collection/components/jump-card-ecommerce/jump-card-ecommerce.stories.js +8 -1
  40. package/dist/collection/components/jump-card-ecommerce/jump-card-ecommerce.stories.js.map +1 -1
  41. package/dist/collection/components/jump-card-ecommerce-option/jump-card-ecommerce-option.js +1 -1
  42. package/dist/collection/components/jump-filter/jump-filter.js +3 -3
  43. package/dist/collection/components/jump-filter-checkbox/jump-filter-checkbox.js +2 -2
  44. package/dist/collection/components/jump-filtergroup/jump-filtergroup.js +3 -3
  45. package/dist/collection/components/jump-pagination/jump-pagination.js +3 -3
  46. package/dist/collection/components/jump-pagination/jump-pagination.stories.js +3 -2
  47. package/dist/collection/components/jump-pagination/jump-pagination.stories.js.map +1 -1
  48. package/dist/collection/components/jump-pagination-table/jump-pagination-table.js +3 -3
  49. package/dist/collection/components/jump-quantity/jump-quantity.js +3 -3
  50. package/dist/collection/components/jump-tab/jump-tab.js +1 -1
  51. package/dist/collection/components/jump-tab-item/jump-tab-item.js +2 -2
  52. package/dist/collection/components/jump-tab-panel/jump-tab-panel.js +1 -1
  53. package/dist/components/chunk.H33C3MRM.js +57 -57
  54. package/dist/components/chunk.H33C3MRM.js.map +1 -1
  55. package/dist/components/class-map.js +31 -0
  56. package/dist/components/class-map.js.map +1 -0
  57. package/dist/components/jump-accordion.js +548 -5
  58. package/dist/components/jump-accordion.js.map +1 -1
  59. package/dist/components/jump-badge2.js +1 -1
  60. package/dist/components/jump-button2.js +1 -1
  61. package/dist/components/jump-card-ecommerce-option.js +1 -1
  62. package/dist/components/jump-card-ecommerce.js +28 -18
  63. package/dist/components/jump-card-ecommerce.js.map +1 -1
  64. package/dist/components/jump-card.js +2 -2
  65. package/dist/components/jump-filter-checkbox.js +9 -34
  66. package/dist/components/jump-filter-checkbox.js.map +1 -1
  67. package/dist/components/jump-filter.js +3 -3
  68. package/dist/components/jump-filtergroup.js +3 -3
  69. package/dist/components/jump-pagination-table.js +3 -3
  70. package/dist/components/jump-pagination.js +3 -3
  71. package/dist/components/jump-pagination.js.map +1 -1
  72. package/dist/components/jump-quantity.js +3 -3
  73. package/dist/components/jump-tab-item.js +2 -2
  74. package/dist/components/jump-tab-panel.js +1 -1
  75. package/dist/components/jump-tab.js +1 -1
  76. package/dist/esm/{chunk.H33C3MRM-d1872e67.js → chunk.H33C3MRM-632f8755.js} +2 -2
  77. package/dist/esm/{chunk.H33C3MRM-d1872e67.js.map → chunk.H33C3MRM-632f8755.js.map} +1 -1
  78. package/dist/esm/class-map-3150cdfe.js +31 -0
  79. package/dist/esm/class-map-3150cdfe.js.map +1 -0
  80. package/dist/esm/index-a94d133e.js +1546 -0
  81. package/dist/esm/index-a94d133e.js.map +1 -0
  82. package/dist/esm/jump-accordion.entry.js +533 -3
  83. package/dist/esm/jump-accordion.entry.js.map +1 -1
  84. package/dist/esm/jump-badge.entry.js +2 -2
  85. package/dist/esm/jump-button_2.entry.js +3 -3
  86. package/dist/esm/jump-card-ecommerce-option.entry.js +2 -2
  87. package/dist/esm/jump-card-ecommerce.entry.js +28 -19
  88. package/dist/esm/jump-card-ecommerce.entry.js.map +1 -1
  89. package/dist/esm/jump-card.entry.js +3 -3
  90. package/dist/esm/jump-design-system.js +11 -11
  91. package/dist/esm/jump-design-system.js.map +1 -1
  92. package/dist/esm/jump-filter-checkbox.entry.js +10 -35
  93. package/dist/esm/jump-filter-checkbox.entry.js.map +1 -1
  94. package/dist/esm/jump-filter.entry.js +4 -4
  95. package/dist/esm/jump-filtergroup.entry.js +4 -4
  96. package/dist/esm/jump-pagination-table.entry.js +4 -4
  97. package/dist/esm/jump-pagination.entry.js +4 -4
  98. package/dist/esm/jump-pagination.entry.js.map +1 -1
  99. package/dist/esm/jump-quantity.entry.js +4 -4
  100. package/dist/esm/jump-tab-item.entry.js +3 -3
  101. package/dist/esm/jump-tab-panel.entry.js +2 -2
  102. package/dist/esm/jump-tab.entry.js +2 -2
  103. package/dist/esm/loader.js +3 -3
  104. package/dist/jump-design-system/jump-design-system.esm.js +1 -1
  105. package/dist/jump-design-system/jump-design-system.esm.js.map +1 -1
  106. package/dist/jump-design-system/{p-a5aaa1dd.entry.js → p-13950869.entry.js} +2 -2
  107. package/dist/jump-design-system/p-198cfe62.js +22 -0
  108. package/dist/jump-design-system/p-198cfe62.js.map +1 -0
  109. package/dist/jump-design-system/p-32650f5e.entry.js +2 -0
  110. package/dist/jump-design-system/p-32650f5e.entry.js.map +1 -0
  111. package/dist/jump-design-system/{p-c8733544.entry.js → p-4d0c4007.entry.js} +2 -2
  112. package/dist/jump-design-system/p-570e63e4.entry.js +2 -0
  113. package/dist/jump-design-system/{p-23d91e12.entry.js → p-6309cc45.entry.js} +2 -2
  114. package/dist/jump-design-system/{p-9d9b0076.entry.js → p-678bd41e.entry.js} +2 -2
  115. package/dist/jump-design-system/{p-27fa0ba4.entry.js → p-6ad4dc92.entry.js} +2 -2
  116. package/dist/jump-design-system/{p-5e9b8062.entry.js → p-7272666a.entry.js} +11 -31
  117. package/dist/jump-design-system/p-7272666a.entry.js.map +1 -0
  118. package/dist/jump-design-system/p-95462766.entry.js +117 -0
  119. package/dist/jump-design-system/p-95462766.entry.js.map +1 -0
  120. package/dist/jump-design-system/{p-60849b83.entry.js → p-acd1dac1.entry.js} +2 -2
  121. package/dist/jump-design-system/{p-4302b229.entry.js → p-c964c3d9.entry.js} +2 -2
  122. package/dist/jump-design-system/p-c964c3d9.entry.js.map +1 -0
  123. package/dist/jump-design-system/{p-a4b9515b.js → p-d33f4f1d.js} +2 -2
  124. package/dist/jump-design-system/p-d4c681a4.js +3 -0
  125. package/dist/jump-design-system/p-d4c681a4.js.map +1 -0
  126. package/dist/jump-design-system/{p-ed897778.entry.js → p-e926995e.entry.js} +2 -2
  127. package/dist/jump-design-system/{p-c1665537.entry.js → p-f0590653.entry.js} +2 -2
  128. package/dist/jump-design-system/p-f281e150.entry.js +2 -0
  129. package/dist/jump-design-system/{p-839e054d.entry.js → p-f534e22b.entry.js} +2 -2
  130. package/dist/jump-design-system-elements.json +52 -1
  131. package/dist/types/components/jump-accordion/jump-accordion.d.ts +11 -0
  132. package/dist/types/components/jump-accordion/jump-accordion.stories.d.ts +39 -0
  133. package/dist/types/components/jump-card-ecommerce/jump-card-ecommerce.d.ts +2 -0
  134. package/dist/types/components/jump-card-ecommerce/jump-card-ecommerce.stories.d.ts +6 -0
  135. package/dist/types/components.d.ts +36 -0
  136. package/dist/types/stencil-public-runtime.d.ts +3 -8
  137. package/loader/cdn.js +1 -3
  138. package/loader/index.cjs.js +1 -3
  139. package/loader/index.es2017.js +1 -3
  140. package/loader/index.js +1 -3
  141. package/package.json +1 -1
  142. package/dist/cjs/index-674508e2.js +0 -2451
  143. package/dist/cjs/index-674508e2.js.map +0 -1
  144. package/dist/esm/index-70f1949a.js +0 -2422
  145. package/dist/esm/index-70f1949a.js.map +0 -1
  146. package/dist/esm/polyfills/core-js.js +0 -11
  147. package/dist/esm/polyfills/dom.js +0 -79
  148. package/dist/esm/polyfills/es5-html-element.js +0 -1
  149. package/dist/esm/polyfills/index.js +0 -34
  150. package/dist/esm/polyfills/system.js +0 -6
  151. package/dist/jump-design-system/p-4302b229.entry.js.map +0 -1
  152. package/dist/jump-design-system/p-4d6cc90d.js +0 -3
  153. package/dist/jump-design-system/p-4d6cc90d.js.map +0 -1
  154. package/dist/jump-design-system/p-56609b82.entry.js +0 -2
  155. package/dist/jump-design-system/p-56609b82.entry.js.map +0 -1
  156. package/dist/jump-design-system/p-5e9b8062.entry.js.map +0 -1
  157. package/dist/jump-design-system/p-aee5a8c3.entry.js +0 -2
  158. package/dist/jump-design-system/p-d6be9517.entry.js +0 -2
  159. package/dist/jump-design-system/p-d6be9517.entry.js.map +0 -1
  160. package/dist/jump-design-system/p-fde99383.entry.js +0 -2
  161. /package/dist/jump-design-system/{p-a5aaa1dd.entry.js.map → p-13950869.entry.js.map} +0 -0
  162. /package/dist/jump-design-system/{p-c8733544.entry.js.map → p-4d0c4007.entry.js.map} +0 -0
  163. /package/dist/jump-design-system/{p-aee5a8c3.entry.js.map → p-570e63e4.entry.js.map} +0 -0
  164. /package/dist/jump-design-system/{p-23d91e12.entry.js.map → p-6309cc45.entry.js.map} +0 -0
  165. /package/dist/jump-design-system/{p-9d9b0076.entry.js.map → p-678bd41e.entry.js.map} +0 -0
  166. /package/dist/jump-design-system/{p-27fa0ba4.entry.js.map → p-6ad4dc92.entry.js.map} +0 -0
  167. /package/dist/jump-design-system/{p-60849b83.entry.js.map → p-acd1dac1.entry.js.map} +0 -0
  168. /package/dist/jump-design-system/{p-a4b9515b.js.map → p-d33f4f1d.js.map} +0 -0
  169. /package/dist/jump-design-system/{p-ed897778.entry.js.map → p-e926995e.entry.js.map} +0 -0
  170. /package/dist/jump-design-system/{p-c1665537.entry.js.map → p-f0590653.entry.js.map} +0 -0
  171. /package/dist/jump-design-system/{p-fde99383.entry.js.map → p-f281e150.entry.js.map} +0 -0
  172. /package/dist/jump-design-system/{p-839e054d.entry.js.map → p-f534e22b.entry.js.map} +0 -0
@@ -1,2451 +0,0 @@
1
- 'use strict';
2
-
3
- function _interopNamespace(e) {
4
- if (e && e.__esModule) return e;
5
- var n = Object.create(null);
6
- if (e) {
7
- Object.keys(e).forEach(function (k) {
8
- if (k !== 'default') {
9
- var d = Object.getOwnPropertyDescriptor(e, k);
10
- Object.defineProperty(n, k, d.get ? d : {
11
- enumerable: true,
12
- get: function () {
13
- return e[k];
14
- }
15
- });
16
- }
17
- });
18
- }
19
- n['default'] = e;
20
- return Object.freeze(n);
21
- }
22
-
23
- const NAMESPACE = 'jump-design-system';
24
- const BUILD = /* jump-design-system */ { allRenderFn: true, appendChildSlotFix: false, asyncLoading: true, asyncQueue: false, attachStyles: true, cloneNodeFix: false, cmpDidLoad: true, cmpDidRender: false, cmpDidUnload: false, cmpDidUpdate: false, cmpShouldUpdate: false, cmpWillLoad: true, cmpWillRender: false, cmpWillUpdate: false, connectedCallback: false, constructableCSS: true, cssAnnotations: true, devTools: false, disconnectedCallback: true, element: false, event: true, experimentalScopedSlotChanges: false, experimentalSlotFixes: false, formAssociated: true, hasRenderFn: true, hostListener: true, hostListenerTarget: true, hostListenerTargetBody: false, hostListenerTargetDocument: false, hostListenerTargetParent: false, hostListenerTargetWindow: true, hotModuleReplacement: false, hydrateClientSide: false, hydrateServerSide: false, hydratedAttribute: false, hydratedClass: true, initializeNextTick: false, invisiblePrehydration: true, isDebug: false, isDev: false, isTesting: false, lazyLoad: true, lifecycle: true, lifecycleDOMEvents: false, member: true, method: true, mode: false, observeAttribute: true, profile: false, prop: true, propBoolean: true, propMutable: true, propNumber: true, propString: true, reflect: true, scoped: false, scopedSlotTextContentFix: false, scriptDataOpts: false, shadowDelegatesFocus: false, shadowDom: true, slot: true, slotChildNodesFix: false, slotRelocation: true, state: true, style: true, svg: false, taskQueue: true, transformTagName: false, updatable: true, vdomAttribute: true, vdomClass: true, vdomFunctional: false, vdomKey: true, vdomListener: true, vdomPropOrAttr: true, vdomRef: true, vdomRender: true, vdomStyle: false, vdomText: true, vdomXlink: false, watchCallback: true };
25
-
26
- /**
27
- * Virtual DOM patching algorithm based on Snabbdom by
28
- * Simon Friis Vindum (@paldepind)
29
- * Licensed under the MIT License
30
- * https://github.com/snabbdom/snabbdom/blob/master/LICENSE
31
- *
32
- * Modified for Stencil's renderer and slot projection
33
- */
34
- let scopeId;
35
- let contentRef;
36
- let hostTagName;
37
- let useNativeShadowDom = false;
38
- let checkSlotFallbackVisibility = false;
39
- let checkSlotRelocate = false;
40
- let isSvgMode = false;
41
- let queuePending = false;
42
- const createTime = (fnName, tagName = '') => {
43
- {
44
- return () => {
45
- return;
46
- };
47
- }
48
- };
49
- const uniqueTime = (key, measureText) => {
50
- {
51
- return () => {
52
- return;
53
- };
54
- }
55
- };
56
- const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
57
- /**
58
- * Constant for styles to be globally applied to `slot-fb` elements for pseudo-slot behavior.
59
- *
60
- * Two cascading rules must be used instead of a `:not()` selector due to Stencil browser
61
- * support as of Stencil v4.
62
- */
63
- const SLOT_FB_CSS = 'slot-fb{display:contents}slot-fb[hidden]{display:none}';
64
- const FORM_ASSOCIATED_CUSTOM_ELEMENT_CALLBACKS = [
65
- 'formAssociatedCallback',
66
- 'formResetCallback',
67
- 'formDisabledCallback',
68
- 'formStateRestoreCallback',
69
- ];
70
- /**
71
- * Default style mode id
72
- */
73
- /**
74
- * Reusable empty obj/array
75
- * Don't add values to these!!
76
- */
77
- const EMPTY_OBJ = {};
78
- const isDef = (v) => v != null;
79
- /**
80
- * Check whether a value is a 'complex type', defined here as an object or a
81
- * function.
82
- *
83
- * @param o the value to check
84
- * @returns whether it's a complex type or not
85
- */
86
- const isComplexType = (o) => {
87
- // https://jsperf.com/typeof-fn-object/5
88
- o = typeof o;
89
- return o === 'object' || o === 'function';
90
- };
91
- /**
92
- * Helper method for querying a `meta` tag that contains a nonce value
93
- * out of a DOM's head.
94
- *
95
- * @param doc The DOM containing the `head` to query against
96
- * @returns The content of the meta tag representing the nonce value, or `undefined` if no tag
97
- * exists or the tag has no content.
98
- */
99
- function queryNonceMetaTagContent(doc) {
100
- var _a, _b, _c;
101
- 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;
102
- }
103
- /**
104
- * Production h() function based on Preact by
105
- * Jason Miller (@developit)
106
- * Licensed under the MIT License
107
- * https://github.com/developit/preact/blob/master/LICENSE
108
- *
109
- * Modified for Stencil's compiler and vdom
110
- */
111
- // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
112
- // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
113
- const h = (nodeName, vnodeData, ...children) => {
114
- let child = null;
115
- let key = null;
116
- let slotName = null;
117
- let simple = false;
118
- let lastSimple = false;
119
- const vNodeChildren = [];
120
- const walk = (c) => {
121
- for (let i = 0; i < c.length; i++) {
122
- child = c[i];
123
- if (Array.isArray(child)) {
124
- walk(child);
125
- }
126
- else if (child != null && typeof child !== 'boolean') {
127
- if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
128
- child = String(child);
129
- }
130
- if (simple && lastSimple) {
131
- // If the previous child was simple (string), we merge both
132
- vNodeChildren[vNodeChildren.length - 1].$text$ += child;
133
- }
134
- else {
135
- // Append a new vNode, if it's text, we create a text vNode
136
- vNodeChildren.push(simple ? newVNode(null, child) : child);
137
- }
138
- lastSimple = simple;
139
- }
140
- }
141
- };
142
- walk(children);
143
- if (vnodeData) {
144
- if (vnodeData.key) {
145
- key = vnodeData.key;
146
- }
147
- if (vnodeData.name) {
148
- slotName = vnodeData.name;
149
- }
150
- // normalize class / className attributes
151
- {
152
- const classData = vnodeData.className || vnodeData.class;
153
- if (classData) {
154
- vnodeData.class =
155
- typeof classData !== 'object'
156
- ? classData
157
- : Object.keys(classData)
158
- .filter((k) => classData[k])
159
- .join(' ');
160
- }
161
- }
162
- }
163
- const vnode = newVNode(nodeName, null);
164
- vnode.$attrs$ = vnodeData;
165
- if (vNodeChildren.length > 0) {
166
- vnode.$children$ = vNodeChildren;
167
- }
168
- {
169
- vnode.$key$ = key;
170
- }
171
- {
172
- vnode.$name$ = slotName;
173
- }
174
- return vnode;
175
- };
176
- /**
177
- * A utility function for creating a virtual DOM node from a tag and some
178
- * possible text content.
179
- *
180
- * @param tag the tag for this element
181
- * @param text possible text content for the node
182
- * @returns a newly-minted virtual DOM node
183
- */
184
- const newVNode = (tag, text) => {
185
- const vnode = {
186
- $flags$: 0,
187
- $tag$: tag,
188
- $text$: text,
189
- $elm$: null,
190
- $children$: null,
191
- };
192
- {
193
- vnode.$attrs$ = null;
194
- }
195
- {
196
- vnode.$key$ = null;
197
- }
198
- {
199
- vnode.$name$ = null;
200
- }
201
- return vnode;
202
- };
203
- const Host = {};
204
- /**
205
- * Check whether a given node is a Host node or not
206
- *
207
- * @param node the virtual DOM node to check
208
- * @returns whether it's a Host node or not
209
- */
210
- const isHost = (node) => node && node.$tag$ === Host;
211
- /**
212
- * Parse a new property value for a given property type.
213
- *
214
- * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
215
- * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
216
- * 1. `any`, the type given to `propValue` in the function signature
217
- * 2. the type stored from `propType`.
218
- *
219
- * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
220
- *
221
- * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
222
- * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
223
- * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
224
- * ```tsx
225
- * <my-cmp prop-val={0}></my-cmp>
226
- * ```
227
- *
228
- * HTML prop values on the other hand, will always a string
229
- *
230
- * @param propValue the new value to coerce to some type
231
- * @param propType the type of the prop, expressed as a binary number
232
- * @returns the parsed/coerced value
233
- */
234
- const parsePropertyValue = (propValue, propType) => {
235
- // ensure this value is of the correct prop type
236
- if (propValue != null && !isComplexType(propValue)) {
237
- if (propType & 4 /* MEMBER_FLAGS.Boolean */) {
238
- // per the HTML spec, any string value means it is a boolean true value
239
- // but we'll cheat here and say that the string "false" is the boolean false
240
- return propValue === 'false' ? false : propValue === '' || !!propValue;
241
- }
242
- if (propType & 2 /* MEMBER_FLAGS.Number */) {
243
- // force it to be a number
244
- return parseFloat(propValue);
245
- }
246
- if (propType & 1 /* MEMBER_FLAGS.String */) {
247
- // could have been passed as a number or boolean
248
- // but we still want it as a string
249
- return String(propValue);
250
- }
251
- // redundant return here for better minification
252
- return propValue;
253
- }
254
- // not sure exactly what type we want
255
- // so no need to change to a different type
256
- return propValue;
257
- };
258
- const getElement = (ref) => (getHostRef(ref).$hostElement$ );
259
- const createEvent = (ref, name, flags) => {
260
- const elm = getElement(ref);
261
- return {
262
- emit: (detail) => {
263
- return emitEvent(elm, name, {
264
- bubbles: !!(flags & 4 /* EVENT_FLAGS.Bubbles */),
265
- composed: !!(flags & 2 /* EVENT_FLAGS.Composed */),
266
- cancelable: !!(flags & 1 /* EVENT_FLAGS.Cancellable */),
267
- detail,
268
- });
269
- },
270
- };
271
- };
272
- /**
273
- * Helper function to create & dispatch a custom Event on a provided target
274
- * @param elm the target of the Event
275
- * @param name the name to give the custom Event
276
- * @param opts options for configuring a custom Event
277
- * @returns the custom Event
278
- */
279
- const emitEvent = (elm, name, opts) => {
280
- const ev = plt.ce(name, opts);
281
- elm.dispatchEvent(ev);
282
- return ev;
283
- };
284
- const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
285
- const registerStyle = (scopeId, cssText, allowCS) => {
286
- let style = styles.get(scopeId);
287
- if (supportsConstructableStylesheets && allowCS) {
288
- style = (style || new CSSStyleSheet());
289
- if (typeof style === 'string') {
290
- style = cssText;
291
- }
292
- else {
293
- style.replaceSync(cssText);
294
- }
295
- }
296
- else {
297
- style = cssText;
298
- }
299
- styles.set(scopeId, style);
300
- };
301
- const addStyle = (styleContainerNode, cmpMeta, mode) => {
302
- var _a;
303
- const scopeId = getScopeId(cmpMeta);
304
- const style = styles.get(scopeId);
305
- // if an element is NOT connected then getRootNode() will return the wrong root node
306
- // so the fallback is to always use the document for the root node in those cases
307
- styleContainerNode = styleContainerNode.nodeType === 11 /* NODE_TYPE.DocumentFragment */ ? styleContainerNode : doc;
308
- if (style) {
309
- if (typeof style === 'string') {
310
- styleContainerNode = styleContainerNode.head || styleContainerNode;
311
- let appliedStyles = rootAppliedStyles.get(styleContainerNode);
312
- let styleElm;
313
- if (!appliedStyles) {
314
- rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
315
- }
316
- if (!appliedStyles.has(scopeId)) {
317
- {
318
- styleElm = doc.createElement('style');
319
- styleElm.innerHTML = style;
320
- // Apply CSP nonce to the style tag if it exists
321
- const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
322
- if (nonce != null) {
323
- styleElm.setAttribute('nonce', nonce);
324
- }
325
- styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
326
- }
327
- // Add styles for `slot-fb` elements if we're using slots outside the Shadow DOM
328
- if (cmpMeta.$flags$ & 4 /* CMP_FLAGS.hasSlotRelocation */) {
329
- styleElm.innerHTML += SLOT_FB_CSS;
330
- }
331
- if (appliedStyles) {
332
- appliedStyles.add(scopeId);
333
- }
334
- }
335
- }
336
- else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
337
- styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
338
- }
339
- }
340
- return scopeId;
341
- };
342
- const attachStyles = (hostRef) => {
343
- const cmpMeta = hostRef.$cmpMeta$;
344
- const elm = hostRef.$hostElement$;
345
- const flags = cmpMeta.$flags$;
346
- const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
347
- const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
348
- if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
349
- // only required when we're NOT using native shadow dom (slot)
350
- // or this browser doesn't support native shadow dom
351
- // and this host element was NOT created with SSR
352
- // let's pick out the inner content for slot projection
353
- // create a node to represent where the original
354
- // content was first placed, which is useful later on
355
- // DOM WRITE!!
356
- elm['s-sc'] = scopeId;
357
- elm.classList.add(scopeId + '-h');
358
- }
359
- endAttachStyles();
360
- };
361
- const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
362
- /**
363
- * Production setAccessor() function based on Preact by
364
- * Jason Miller (@developit)
365
- * Licensed under the MIT License
366
- * https://github.com/developit/preact/blob/master/LICENSE
367
- *
368
- * Modified for Stencil's compiler and vdom
369
- */
370
- /**
371
- * When running a VDom render set properties present on a VDom node onto the
372
- * corresponding HTML element.
373
- *
374
- * Note that this function has special functionality for the `class`,
375
- * `style`, `key`, and `ref` attributes, as well as event handlers (like
376
- * `onClick`, etc). All others are just passed through as-is.
377
- *
378
- * @param elm the HTMLElement onto which attributes should be set
379
- * @param memberName the name of the attribute to set
380
- * @param oldValue the old value for the attribute
381
- * @param newValue the new value for the attribute
382
- * @param isSvg whether we're in an svg context or not
383
- * @param flags bitflags for Vdom variables
384
- */
385
- const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
386
- if (oldValue !== newValue) {
387
- let isProp = isMemberInElement(elm, memberName);
388
- let ln = memberName.toLowerCase();
389
- if (memberName === 'class') {
390
- const classList = elm.classList;
391
- const oldClasses = parseClassList(oldValue);
392
- const newClasses = parseClassList(newValue);
393
- classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
394
- classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
395
- }
396
- else if (memberName === 'key')
397
- ;
398
- else if (memberName === 'ref') {
399
- // minifier will clean this up
400
- if (newValue) {
401
- newValue(elm);
402
- }
403
- }
404
- else if ((!isProp ) &&
405
- memberName[0] === 'o' &&
406
- memberName[1] === 'n') {
407
- // Event Handlers
408
- // so if the member name starts with "on" and the 3rd characters is
409
- // a capital letter, and it's not already a member on the element,
410
- // then we're assuming it's an event listener
411
- if (memberName[2] === '-') {
412
- // on- prefixed events
413
- // allows to be explicit about the dom event to listen without any magic
414
- // under the hood:
415
- // <my-cmp on-click> // listens for "click"
416
- // <my-cmp on-Click> // listens for "Click"
417
- // <my-cmp on-ionChange> // listens for "ionChange"
418
- // <my-cmp on-EVENTS> // listens for "EVENTS"
419
- memberName = memberName.slice(3);
420
- }
421
- else if (isMemberInElement(win, ln)) {
422
- // standard event
423
- // the JSX attribute could have been "onMouseOver" and the
424
- // member name "onmouseover" is on the window's prototype
425
- // so let's add the listener "mouseover", which is all lowercased
426
- memberName = ln.slice(2);
427
- }
428
- else {
429
- // custom event
430
- // the JSX attribute could have been "onMyCustomEvent"
431
- // so let's trim off the "on" prefix and lowercase the first character
432
- // and add the listener "myCustomEvent"
433
- // except for the first character, we keep the event name case
434
- memberName = ln[2] + memberName.slice(3);
435
- }
436
- if (oldValue || newValue) {
437
- // Need to account for "capture" events.
438
- // If the event name ends with "Capture", we'll update the name to remove
439
- // the "Capture" suffix and make sure the event listener is setup to handle the capture event.
440
- const capture = memberName.endsWith(CAPTURE_EVENT_SUFFIX);
441
- // Make sure we only replace the last instance of "Capture"
442
- memberName = memberName.replace(CAPTURE_EVENT_REGEX, '');
443
- if (oldValue) {
444
- plt.rel(elm, memberName, oldValue, capture);
445
- }
446
- if (newValue) {
447
- plt.ael(elm, memberName, newValue, capture);
448
- }
449
- }
450
- }
451
- else {
452
- // Set property if it exists and it's not a SVG
453
- const isComplex = isComplexType(newValue);
454
- if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
455
- try {
456
- if (!elm.tagName.includes('-')) {
457
- const n = newValue == null ? '' : newValue;
458
- // Workaround for Safari, moving the <input> caret when re-assigning the same valued
459
- if (memberName === 'list') {
460
- isProp = false;
461
- }
462
- else if (oldValue == null || elm[memberName] != n) {
463
- elm[memberName] = n;
464
- }
465
- }
466
- else {
467
- elm[memberName] = newValue;
468
- }
469
- }
470
- catch (e) {
471
- /**
472
- * in case someone tries to set a read-only property, e.g. "namespaceURI", we just ignore it
473
- */
474
- }
475
- }
476
- if (newValue == null || newValue === false) {
477
- if (newValue !== false || elm.getAttribute(memberName) === '') {
478
- {
479
- elm.removeAttribute(memberName);
480
- }
481
- }
482
- }
483
- else if ((!isProp || flags & 4 /* VNODE_FLAGS.isHost */ || isSvg) && !isComplex) {
484
- newValue = newValue === true ? '' : newValue;
485
- {
486
- elm.setAttribute(memberName, newValue);
487
- }
488
- }
489
- }
490
- }
491
- };
492
- const parseClassListRegex = /\s/;
493
- /**
494
- * Parsed a string of classnames into an array
495
- * @param value className string, e.g. "foo bar baz"
496
- * @returns list of classes, e.g. ["foo", "bar", "baz"]
497
- */
498
- const parseClassList = (value) => (!value ? [] : value.split(parseClassListRegex));
499
- const CAPTURE_EVENT_SUFFIX = 'Capture';
500
- const CAPTURE_EVENT_REGEX = new RegExp(CAPTURE_EVENT_SUFFIX + '$');
501
- const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
502
- // if the element passed in is a shadow root, which is a document fragment
503
- // then we want to be adding attrs/props to the shadow root's "host" element
504
- // if it's not a shadow root, then we add attrs/props to the same element
505
- const elm = newVnode.$elm$.nodeType === 11 /* NODE_TYPE.DocumentFragment */ && newVnode.$elm$.host
506
- ? newVnode.$elm$.host
507
- : newVnode.$elm$;
508
- const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
509
- const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
510
- {
511
- // remove attributes no longer present on the vnode by setting them to undefined
512
- for (memberName of sortedAttrNames(Object.keys(oldVnodeAttrs))) {
513
- if (!(memberName in newVnodeAttrs)) {
514
- setAccessor(elm, memberName, oldVnodeAttrs[memberName], undefined, isSvgMode, newVnode.$flags$);
515
- }
516
- }
517
- }
518
- // add new & update changed attributes
519
- for (memberName of sortedAttrNames(Object.keys(newVnodeAttrs))) {
520
- setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
521
- }
522
- };
523
- /**
524
- * Sort a list of attribute names to ensure that all the attribute names which
525
- * are _not_ `"ref"` come before `"ref"`. Preserve the order of the non-ref
526
- * attributes.
527
- *
528
- * **Note**: if the supplied attributes do not include `'ref'` then the same
529
- * (by reference) array will be returned without modification.
530
- *
531
- * @param attrNames attribute names to sort
532
- * @returns a list of attribute names, sorted if they include `"ref"`
533
- */
534
- function sortedAttrNames(attrNames) {
535
- return attrNames.includes('ref')
536
- ? // we need to sort these to ensure that `'ref'` is the last attr
537
- [...attrNames.filter((attr) => attr !== 'ref'), 'ref']
538
- : // no need to sort, return the original array
539
- attrNames;
540
- }
541
- /**
542
- * Create a DOM Node corresponding to one of the children of a given VNode.
543
- *
544
- * @param oldParentVNode the parent VNode from the previous render
545
- * @param newParentVNode the parent VNode from the current render
546
- * @param childIndex the index of the VNode, in the _new_ parent node's
547
- * children, for which we will create a new DOM node
548
- * @param parentElm the parent DOM node which our new node will be a child of
549
- * @returns the newly created node
550
- */
551
- const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
552
- var _a;
553
- // tslint:disable-next-line: prefer-const
554
- const newVNode = newParentVNode.$children$[childIndex];
555
- let i = 0;
556
- let elm;
557
- let childNode;
558
- let oldVNode;
559
- if (!useNativeShadowDom) {
560
- // remember for later we need to check to relocate nodes
561
- checkSlotRelocate = true;
562
- if (newVNode.$tag$ === 'slot') {
563
- if (scopeId) {
564
- // scoped css needs to add its scoped id to the parent element
565
- parentElm.classList.add(scopeId + '-s');
566
- }
567
- newVNode.$flags$ |= newVNode.$children$
568
- ? // slot element has fallback content
569
- 2 /* VNODE_FLAGS.isSlotFallback */
570
- : // slot element does not have fallback content
571
- 1 /* VNODE_FLAGS.isSlotReference */;
572
- }
573
- }
574
- if (newVNode.$text$ !== null) {
575
- // create text node
576
- elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
577
- }
578
- else if (newVNode.$flags$ & 1 /* VNODE_FLAGS.isSlotReference */) {
579
- // create a slot reference node
580
- elm = newVNode.$elm$ =
581
- doc.createTextNode('');
582
- }
583
- else {
584
- // create element
585
- elm = newVNode.$elm$ = (doc.createElement(newVNode.$flags$ & 2 /* VNODE_FLAGS.isSlotFallback */
586
- ? 'slot-fb'
587
- : newVNode.$tag$));
588
- // add css classes, attrs, props, listeners, etc.
589
- {
590
- updateElement(null, newVNode, isSvgMode);
591
- }
592
- if (isDef(scopeId) && elm['s-si'] !== scopeId) {
593
- // if there is a scopeId and this is the initial render
594
- // then let's add the scopeId as a css class
595
- elm.classList.add((elm['s-si'] = scopeId));
596
- }
597
- if (newVNode.$children$) {
598
- for (i = 0; i < newVNode.$children$.length; ++i) {
599
- // create the node
600
- childNode = createElm(oldParentVNode, newVNode, i, elm);
601
- // return node could have been null
602
- if (childNode) {
603
- // append our new node
604
- elm.appendChild(childNode);
605
- }
606
- }
607
- }
608
- }
609
- // This needs to always happen so we can hide nodes that are projected
610
- // to another component but don't end up in a slot
611
- elm['s-hn'] = hostTagName;
612
- {
613
- if (newVNode.$flags$ & (2 /* VNODE_FLAGS.isSlotFallback */ | 1 /* VNODE_FLAGS.isSlotReference */)) {
614
- // remember the content reference comment
615
- elm['s-sr'] = true;
616
- // remember the content reference comment
617
- elm['s-cr'] = contentRef;
618
- // remember the slot name, or empty string for default slot
619
- elm['s-sn'] = newVNode.$name$ || '';
620
- // remember the ref callback function
621
- elm['s-rf'] = (_a = newVNode.$attrs$) === null || _a === void 0 ? void 0 : _a.ref;
622
- // check if we've got an old vnode for this slot
623
- oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
624
- if (oldVNode && oldVNode.$tag$ === newVNode.$tag$ && oldParentVNode.$elm$) {
625
- {
626
- // we've got an old slot vnode and the wrapper is being replaced
627
- // so let's move the old slot content back to its original location
628
- putBackInOriginalLocation(oldParentVNode.$elm$, false);
629
- }
630
- }
631
- }
632
- }
633
- return elm;
634
- };
635
- const putBackInOriginalLocation = (parentElm, recursive) => {
636
- plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
637
- const oldSlotChildNodes = Array.from(parentElm.childNodes);
638
- if (parentElm['s-sr'] && BUILD.experimentalSlotFixes) {
639
- let node = parentElm;
640
- while ((node = node.nextSibling)) {
641
- if (node && node['s-sn'] === parentElm['s-sn'] && node['s-sh'] === hostTagName) {
642
- oldSlotChildNodes.push(node);
643
- }
644
- }
645
- }
646
- for (let i = oldSlotChildNodes.length - 1; i >= 0; i--) {
647
- const childNode = oldSlotChildNodes[i];
648
- if (childNode['s-hn'] !== hostTagName && childNode['s-ol']) {
649
- // and relocate it back to it's original location
650
- parentReferenceNode(childNode).insertBefore(childNode, referenceNode(childNode));
651
- // remove the old original location comment entirely
652
- // later on the patch function will know what to do
653
- // and move this to the correct spot if need be
654
- childNode['s-ol'].remove();
655
- childNode['s-ol'] = undefined;
656
- // Reset so we can correctly move the node around again.
657
- childNode['s-sh'] = undefined;
658
- checkSlotRelocate = true;
659
- }
660
- if (recursive) {
661
- putBackInOriginalLocation(childNode, recursive);
662
- }
663
- }
664
- plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
665
- };
666
- /**
667
- * Create DOM nodes corresponding to a list of {@link d.Vnode} objects and
668
- * add them to the DOM in the appropriate place.
669
- *
670
- * @param parentElm the DOM node which should be used as a parent for the new
671
- * DOM nodes
672
- * @param before a child of the `parentElm` which the new children should be
673
- * inserted before (optional)
674
- * @param parentVNode the parent virtual DOM node
675
- * @param vnodes the new child virtual DOM nodes to produce DOM nodes for
676
- * @param startIdx the index in the child virtual DOM nodes at which to start
677
- * creating DOM nodes (inclusive)
678
- * @param endIdx the index in the child virtual DOM nodes at which to stop
679
- * creating DOM nodes (inclusive)
680
- */
681
- const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
682
- let containerElm = ((parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
683
- let childNode;
684
- if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
685
- containerElm = containerElm.shadowRoot;
686
- }
687
- for (; startIdx <= endIdx; ++startIdx) {
688
- if (vnodes[startIdx]) {
689
- childNode = createElm(null, parentVNode, startIdx, parentElm);
690
- if (childNode) {
691
- vnodes[startIdx].$elm$ = childNode;
692
- containerElm.insertBefore(childNode, referenceNode(before) );
693
- }
694
- }
695
- }
696
- };
697
- /**
698
- * Remove the DOM elements corresponding to a list of {@link d.VNode} objects.
699
- * This can be used to, for instance, clean up after a list of children which
700
- * should no longer be shown.
701
- *
702
- * This function also handles some of Stencil's slot relocation logic.
703
- *
704
- * @param vnodes a list of virtual DOM nodes to remove
705
- * @param startIdx the index at which to start removing nodes (inclusive)
706
- * @param endIdx the index at which to stop removing nodes (inclusive)
707
- */
708
- const removeVnodes = (vnodes, startIdx, endIdx) => {
709
- for (let index = startIdx; index <= endIdx; ++index) {
710
- const vnode = vnodes[index];
711
- if (vnode) {
712
- const elm = vnode.$elm$;
713
- nullifyVNodeRefs(vnode);
714
- if (elm) {
715
- {
716
- // we're removing this element
717
- // so it's possible we need to show slot fallback content now
718
- checkSlotFallbackVisibility = true;
719
- if (elm['s-ol']) {
720
- // remove the original location comment
721
- elm['s-ol'].remove();
722
- }
723
- else {
724
- // it's possible that child nodes of the node
725
- // that's being removed are slot nodes
726
- putBackInOriginalLocation(elm, true);
727
- }
728
- }
729
- // remove the vnode's element from the dom
730
- elm.remove();
731
- }
732
- }
733
- }
734
- };
735
- /**
736
- * Reconcile the children of a new VNode with the children of an old VNode by
737
- * traversing the two collections of children, identifying nodes that are
738
- * conserved or changed, calling out to `patch` to make any necessary
739
- * updates to the DOM, and rearranging DOM nodes as needed.
740
- *
741
- * The algorithm for reconciling children works by analyzing two 'windows' onto
742
- * the two arrays of children (`oldCh` and `newCh`). We keep track of the
743
- * 'windows' by storing start and end indices and references to the
744
- * corresponding array entries. Initially the two 'windows' are basically equal
745
- * to the entire array, but we progressively narrow the windows until there are
746
- * no children left to update by doing the following:
747
- *
748
- * 1. Skip any `null` entries at the beginning or end of the two arrays, so
749
- * that if we have an initial array like the following we'll end up dealing
750
- * only with a window bounded by the highlighted elements:
751
- *
752
- * [null, null, VNode1 , ... , VNode2, null, null]
753
- * ^^^^^^ ^^^^^^
754
- *
755
- * 2. Check to see if the elements at the head and tail positions are equal
756
- * across the windows. This will basically detect elements which haven't
757
- * been added, removed, or changed position, i.e. if you had the following
758
- * VNode elements (represented as HTML):
759
- *
760
- * oldVNode: `<div><p><span>HEY</span></p></div>`
761
- * newVNode: `<div><p><span>THERE</span></p></div>`
762
- *
763
- * Then when comparing the children of the `<div>` tag we check the equality
764
- * of the VNodes corresponding to the `<p>` tags and, since they are the
765
- * same tag in the same position, we'd be able to avoid completely
766
- * re-rendering the subtree under them with a new DOM element and would just
767
- * call out to `patch` to handle reconciling their children and so on.
768
- *
769
- * 3. Check, for both windows, to see if the element at the beginning of the
770
- * window corresponds to the element at the end of the other window. This is
771
- * a heuristic which will let us identify _some_ situations in which
772
- * elements have changed position, for instance it _should_ detect that the
773
- * children nodes themselves have not changed but merely moved in the
774
- * following example:
775
- *
776
- * oldVNode: `<div><element-one /><element-two /></div>`
777
- * newVNode: `<div><element-two /><element-one /></div>`
778
- *
779
- * If we find cases like this then we also need to move the concrete DOM
780
- * elements corresponding to the moved children to write the re-order to the
781
- * DOM.
782
- *
783
- * 4. Finally, if VNodes have the `key` attribute set on them we check for any
784
- * nodes in the old children which have the same key as the first element in
785
- * our window on the new children. If we find such a node we handle calling
786
- * out to `patch`, moving relevant DOM nodes, and so on, in accordance with
787
- * what we find.
788
- *
789
- * Finally, once we've narrowed our 'windows' to the point that either of them
790
- * collapse (i.e. they have length 0) we then handle any remaining VNode
791
- * insertion or deletion that needs to happen to get a DOM state that correctly
792
- * reflects the new child VNodes. If, for instance, after our window on the old
793
- * children has collapsed we still have more nodes on the new children that
794
- * we haven't dealt with yet then we need to add them, or if the new children
795
- * collapse but we still have unhandled _old_ children then we need to make
796
- * sure the corresponding DOM nodes are removed.
797
- *
798
- * @param parentElm the node into which the parent VNode is rendered
799
- * @param oldCh the old children of the parent node
800
- * @param newVNode the new VNode which will replace the parent
801
- * @param newCh the new children of the parent node
802
- * @param isInitialRender whether or not this is the first render of the vdom
803
- */
804
- const updateChildren = (parentElm, oldCh, newVNode, newCh, isInitialRender = false) => {
805
- let oldStartIdx = 0;
806
- let newStartIdx = 0;
807
- let idxInOld = 0;
808
- let i = 0;
809
- let oldEndIdx = oldCh.length - 1;
810
- let oldStartVnode = oldCh[0];
811
- let oldEndVnode = oldCh[oldEndIdx];
812
- let newEndIdx = newCh.length - 1;
813
- let newStartVnode = newCh[0];
814
- let newEndVnode = newCh[newEndIdx];
815
- let node;
816
- let elmToMove;
817
- while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
818
- if (oldStartVnode == null) {
819
- // VNode might have been moved left
820
- oldStartVnode = oldCh[++oldStartIdx];
821
- }
822
- else if (oldEndVnode == null) {
823
- oldEndVnode = oldCh[--oldEndIdx];
824
- }
825
- else if (newStartVnode == null) {
826
- newStartVnode = newCh[++newStartIdx];
827
- }
828
- else if (newEndVnode == null) {
829
- newEndVnode = newCh[--newEndIdx];
830
- }
831
- else if (isSameVnode(oldStartVnode, newStartVnode, isInitialRender)) {
832
- // if the start nodes are the same then we should patch the new VNode
833
- // onto the old one, and increment our `newStartIdx` and `oldStartIdx`
834
- // indices to reflect that. We don't need to move any DOM Nodes around
835
- // since things are matched up in order.
836
- patch(oldStartVnode, newStartVnode, isInitialRender);
837
- oldStartVnode = oldCh[++oldStartIdx];
838
- newStartVnode = newCh[++newStartIdx];
839
- }
840
- else if (isSameVnode(oldEndVnode, newEndVnode, isInitialRender)) {
841
- // likewise, if the end nodes are the same we patch new onto old and
842
- // decrement our end indices, and also likewise in this case we don't
843
- // need to move any DOM Nodes.
844
- patch(oldEndVnode, newEndVnode, isInitialRender);
845
- oldEndVnode = oldCh[--oldEndIdx];
846
- newEndVnode = newCh[--newEndIdx];
847
- }
848
- else if (isSameVnode(oldStartVnode, newEndVnode, isInitialRender)) {
849
- // case: "Vnode moved right"
850
- //
851
- // We've found that the last node in our window on the new children is
852
- // the same VNode as the _first_ node in our window on the old children
853
- // we're dealing with now. Visually, this is the layout of these two
854
- // nodes:
855
- //
856
- // newCh: [..., newStartVnode , ... , newEndVnode , ...]
857
- // ^^^^^^^^^^^
858
- // oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
859
- // ^^^^^^^^^^^^^
860
- //
861
- // In this situation we need to patch `newEndVnode` onto `oldStartVnode`
862
- // and move the DOM element for `oldStartVnode`.
863
- if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
864
- putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
865
- }
866
- patch(oldStartVnode, newEndVnode, isInitialRender);
867
- // We need to move the element for `oldStartVnode` into a position which
868
- // will be appropriate for `newEndVnode`. For this we can use
869
- // `.insertBefore` and `oldEndVnode.$elm$.nextSibling`. If there is a
870
- // sibling for `oldEndVnode.$elm$` then we want to move the DOM node for
871
- // `oldStartVnode` between `oldEndVnode` and it's sibling, like so:
872
- //
873
- // <old-start-node />
874
- // <some-intervening-node />
875
- // <old-end-node />
876
- // <!-- -> <-- `oldStartVnode.$elm$` should be inserted here
877
- // <next-sibling />
878
- //
879
- // If instead `oldEndVnode.$elm$` has no sibling then we just want to put
880
- // the node for `oldStartVnode` at the end of the children of
881
- // `parentElm`. Luckily, `Node.nextSibling` will return `null` if there
882
- // aren't any siblings, and passing `null` to `Node.insertBefore` will
883
- // append it to the children of the parent element.
884
- parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
885
- oldStartVnode = oldCh[++oldStartIdx];
886
- newEndVnode = newCh[--newEndIdx];
887
- }
888
- else if (isSameVnode(oldEndVnode, newStartVnode, isInitialRender)) {
889
- // case: "Vnode moved left"
890
- //
891
- // We've found that the first node in our window on the new children is
892
- // the same VNode as the _last_ node in our window on the old children.
893
- // Visually, this is the layout of these two nodes:
894
- //
895
- // newCh: [..., newStartVnode , ... , newEndVnode , ...]
896
- // ^^^^^^^^^^^^^
897
- // oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
898
- // ^^^^^^^^^^^
899
- //
900
- // In this situation we need to patch `newStartVnode` onto `oldEndVnode`
901
- // (which will handle updating any changed attributes, reconciling their
902
- // children etc) but we also need to move the DOM node to which
903
- // `oldEndVnode` corresponds.
904
- if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
905
- putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
906
- }
907
- patch(oldEndVnode, newStartVnode, isInitialRender);
908
- // We've already checked above if `oldStartVnode` and `newStartVnode` are
909
- // the same node, so since we're here we know that they are not. Thus we
910
- // can move the element for `oldEndVnode` _before_ the element for
911
- // `oldStartVnode`, leaving `oldStartVnode` to be reconciled in the
912
- // future.
913
- parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
914
- oldEndVnode = oldCh[--oldEndIdx];
915
- newStartVnode = newCh[++newStartIdx];
916
- }
917
- else {
918
- // Here we do some checks to match up old and new nodes based on the
919
- // `$key$` attribute, which is set by putting a `key="my-key"` attribute
920
- // in the JSX for a DOM element in the implementation of a Stencil
921
- // component.
922
- //
923
- // First we check to see if there are any nodes in the array of old
924
- // children which have the same key as the first node in the new
925
- // children.
926
- idxInOld = -1;
927
- {
928
- for (i = oldStartIdx; i <= oldEndIdx; ++i) {
929
- if (oldCh[i] && oldCh[i].$key$ !== null && oldCh[i].$key$ === newStartVnode.$key$) {
930
- idxInOld = i;
931
- break;
932
- }
933
- }
934
- }
935
- if (idxInOld >= 0) {
936
- // We found a node in the old children which matches up with the first
937
- // node in the new children! So let's deal with that
938
- elmToMove = oldCh[idxInOld];
939
- if (elmToMove.$tag$ !== newStartVnode.$tag$) {
940
- // the tag doesn't match so we'll need a new DOM element
941
- node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld, parentElm);
942
- }
943
- else {
944
- patch(elmToMove, newStartVnode, isInitialRender);
945
- // invalidate the matching old node so that we won't try to update it
946
- // again later on
947
- oldCh[idxInOld] = undefined;
948
- node = elmToMove.$elm$;
949
- }
950
- newStartVnode = newCh[++newStartIdx];
951
- }
952
- else {
953
- // We either didn't find an element in the old children that matches
954
- // the key of the first new child OR the build is not using `key`
955
- // attributes at all. In either case we need to create a new element
956
- // for the new node.
957
- node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx, parentElm);
958
- newStartVnode = newCh[++newStartIdx];
959
- }
960
- if (node) {
961
- // if we created a new node then handle inserting it to the DOM
962
- {
963
- parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
964
- }
965
- }
966
- }
967
- }
968
- if (oldStartIdx > oldEndIdx) {
969
- // we have some more new nodes to add which don't match up with old nodes
970
- addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
971
- }
972
- else if (newStartIdx > newEndIdx) {
973
- // there are nodes in the `oldCh` array which no longer correspond to nodes
974
- // in the new array, so lets remove them (which entails cleaning up the
975
- // relevant DOM nodes)
976
- removeVnodes(oldCh, oldStartIdx, oldEndIdx);
977
- }
978
- };
979
- /**
980
- * Compare two VNodes to determine if they are the same
981
- *
982
- * **NB**: This function is an equality _heuristic_ based on the available
983
- * information set on the two VNodes and can be misleading under certain
984
- * circumstances. In particular, if the two nodes do not have `key` attrs
985
- * (available under `$key$` on VNodes) then the function falls back on merely
986
- * checking that they have the same tag.
987
- *
988
- * So, in other words, if `key` attrs are not set on VNodes which may be
989
- * changing order within a `children` array or something along those lines then
990
- * we could obtain a false negative and then have to do needless re-rendering
991
- * (i.e. we'd say two VNodes aren't equal when in fact they should be).
992
- *
993
- * @param leftVNode the first VNode to check
994
- * @param rightVNode the second VNode to check
995
- * @param isInitialRender whether or not this is the first render of the vdom
996
- * @returns whether they're equal or not
997
- */
998
- const isSameVnode = (leftVNode, rightVNode, isInitialRender = false) => {
999
- // compare if two vnode to see if they're "technically" the same
1000
- // need to have the same element tag, and same key to be the same
1001
- if (leftVNode.$tag$ === rightVNode.$tag$) {
1002
- if (leftVNode.$tag$ === 'slot') {
1003
- return leftVNode.$name$ === rightVNode.$name$;
1004
- }
1005
- // this will be set if JSX tags in the build have `key` attrs set on them
1006
- // we only want to check this if we're not on the first render since on
1007
- // first render `leftVNode.$key$` will always be `null`, so we can be led
1008
- // astray and, for instance, accidentally delete a DOM node that we want to
1009
- // keep around.
1010
- if (!isInitialRender) {
1011
- return leftVNode.$key$ === rightVNode.$key$;
1012
- }
1013
- return true;
1014
- }
1015
- return false;
1016
- };
1017
- const referenceNode = (node) => {
1018
- // this node was relocated to a new location in the dom
1019
- // because of some other component's slot
1020
- // but we still have an html comment in place of where
1021
- // it's original location was according to it's original vdom
1022
- return (node && node['s-ol']) || node;
1023
- };
1024
- const parentReferenceNode = (node) => (node['s-ol'] ? node['s-ol'] : node).parentNode;
1025
- /**
1026
- * Handle reconciling an outdated VNode with a new one which corresponds to
1027
- * it. This function handles flushing updates to the DOM and reconciling the
1028
- * children of the two nodes (if any).
1029
- *
1030
- * @param oldVNode an old VNode whose DOM element and children we want to update
1031
- * @param newVNode a new VNode representing an updated version of the old one
1032
- * @param isInitialRender whether or not this is the first render of the vdom
1033
- */
1034
- const patch = (oldVNode, newVNode, isInitialRender = false) => {
1035
- const elm = (newVNode.$elm$ = oldVNode.$elm$);
1036
- const oldChildren = oldVNode.$children$;
1037
- const newChildren = newVNode.$children$;
1038
- const tag = newVNode.$tag$;
1039
- const text = newVNode.$text$;
1040
- let defaultHolder;
1041
- if (text === null) {
1042
- {
1043
- if (tag === 'slot' && !useNativeShadowDom) ;
1044
- else {
1045
- // either this is the first render of an element OR it's an update
1046
- // AND we already know it's possible it could have changed
1047
- // this updates the element's css classes, attrs, props, listeners, etc.
1048
- updateElement(oldVNode, newVNode, isSvgMode);
1049
- }
1050
- }
1051
- if (oldChildren !== null && newChildren !== null) {
1052
- // looks like there's child vnodes for both the old and new vnodes
1053
- // so we need to call `updateChildren` to reconcile them
1054
- updateChildren(elm, oldChildren, newVNode, newChildren, isInitialRender);
1055
- }
1056
- else if (newChildren !== null) {
1057
- // no old child vnodes, but there are new child vnodes to add
1058
- if (oldVNode.$text$ !== null) {
1059
- // the old vnode was text, so be sure to clear it out
1060
- elm.textContent = '';
1061
- }
1062
- // add the new vnode children
1063
- addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
1064
- }
1065
- else if (oldChildren !== null) {
1066
- // no new child vnodes, but there are old child vnodes to remove
1067
- removeVnodes(oldChildren, 0, oldChildren.length - 1);
1068
- }
1069
- }
1070
- else if ((defaultHolder = elm['s-cr'])) {
1071
- // this element has slotted content
1072
- defaultHolder.parentNode.textContent = text;
1073
- }
1074
- else if (oldVNode.$text$ !== text) {
1075
- // update the text content for the text only vnode
1076
- // and also only if the text is different than before
1077
- elm.data = text;
1078
- }
1079
- };
1080
- /**
1081
- * Adjust the `.hidden` property as-needed on any nodes in a DOM subtree which
1082
- * are slot fallbacks nodes.
1083
- *
1084
- * A slot fallback node should be visible by default. Then, it should be
1085
- * conditionally hidden if:
1086
- *
1087
- * - it has a sibling with a `slot` property set to its slot name or if
1088
- * - it is a default fallback slot node, in which case we hide if it has any
1089
- * content
1090
- *
1091
- * @param elm the element of interest
1092
- */
1093
- const updateFallbackSlotVisibility = (elm) => {
1094
- const childNodes = elm.childNodes;
1095
- for (const childNode of childNodes) {
1096
- if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1097
- if (childNode['s-sr']) {
1098
- // this is a slot fallback node
1099
- // get the slot name for this slot reference node
1100
- const slotName = childNode['s-sn'];
1101
- // by default always show a fallback slot node
1102
- // then hide it if there are other slots in the light dom
1103
- childNode.hidden = false;
1104
- // we need to check all of its sibling nodes in order to see if
1105
- // `childNode` should be hidden
1106
- for (const siblingNode of childNodes) {
1107
- // Don't check the node against itself
1108
- if (siblingNode !== childNode) {
1109
- if (siblingNode['s-hn'] !== childNode['s-hn'] || slotName !== '') {
1110
- // this sibling node is from a different component OR is a named
1111
- // fallback slot node
1112
- if (siblingNode.nodeType === 1 /* NODE_TYPE.ElementNode */ &&
1113
- (slotName === siblingNode.getAttribute('slot') || slotName === siblingNode['s-sn'])) {
1114
- childNode.hidden = true;
1115
- break;
1116
- }
1117
- }
1118
- else {
1119
- // this is a default fallback slot node
1120
- // any element or text node (with content)
1121
- // should hide the default fallback slot node
1122
- if (siblingNode.nodeType === 1 /* NODE_TYPE.ElementNode */ ||
1123
- (siblingNode.nodeType === 3 /* NODE_TYPE.TextNode */ && siblingNode.textContent.trim() !== '')) {
1124
- childNode.hidden = true;
1125
- break;
1126
- }
1127
- }
1128
- }
1129
- }
1130
- }
1131
- // keep drilling down
1132
- updateFallbackSlotVisibility(childNode);
1133
- }
1134
- }
1135
- };
1136
- /**
1137
- * Component-global information about nodes which are either currently being
1138
- * relocated or will be shortly.
1139
- */
1140
- const relocateNodes = [];
1141
- /**
1142
- * Mark the contents of a slot for relocation via adding references to them to
1143
- * the {@link relocateNodes} data structure. The actual work of relocating them
1144
- * will then be handled in {@link renderVdom}.
1145
- *
1146
- * @param elm a render node whose child nodes need to be relocated
1147
- */
1148
- const markSlotContentForRelocation = (elm) => {
1149
- // tslint:disable-next-line: prefer-const
1150
- let node;
1151
- let hostContentNodes;
1152
- let j;
1153
- for (const childNode of elm.childNodes) {
1154
- // we need to find child nodes which are slot references so we can then try
1155
- // to match them up with nodes that need to be relocated
1156
- if (childNode['s-sr'] && (node = childNode['s-cr']) && node.parentNode) {
1157
- // first get the content reference comment node ('s-cr'), then we get
1158
- // its parent, which is where all the host content is now
1159
- hostContentNodes = node.parentNode.childNodes;
1160
- const slotName = childNode['s-sn'];
1161
- // iterate through all the nodes under the location where the host was
1162
- // originally rendered
1163
- for (j = hostContentNodes.length - 1; j >= 0; j--) {
1164
- node = hostContentNodes[j];
1165
- // check that the node is not a content reference node or a node
1166
- // reference and then check that the host name does not match that of
1167
- // childNode.
1168
- // In addition, check that the slot either has not already been relocated, or
1169
- // that its current location's host is not childNode's host. This is essentially
1170
- // a check so that we don't try to relocate (and then hide) a node that is already
1171
- // where it should be.
1172
- if (!node['s-cn'] &&
1173
- !node['s-nr'] &&
1174
- node['s-hn'] !== childNode['s-hn'] &&
1175
- (!BUILD.experimentalSlotFixes )) {
1176
- // if `node` is located in the slot that `childNode` refers to (via the
1177
- // `'s-sn'` property) then we need to relocate it from it's current spot
1178
- // (under the host element parent) to the right slot location
1179
- if (isNodeLocatedInSlot(node, slotName)) {
1180
- // it's possible we've already decided to relocate this node
1181
- let relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
1182
- // made some changes to slots
1183
- // let's make sure we also double check
1184
- // fallbacks are correctly hidden or shown
1185
- checkSlotFallbackVisibility = true;
1186
- // ensure that the slot-name attr is correct
1187
- node['s-sn'] = node['s-sn'] || slotName;
1188
- if (relocateNodeData) {
1189
- relocateNodeData.$nodeToRelocate$['s-sh'] = childNode['s-hn'];
1190
- // we marked this node for relocation previously but didn't find
1191
- // out the slot reference node to which it needs to be relocated
1192
- // so write it down now!
1193
- relocateNodeData.$slotRefNode$ = childNode;
1194
- }
1195
- else {
1196
- node['s-sh'] = childNode['s-hn'];
1197
- // add to our list of nodes to relocate
1198
- relocateNodes.push({
1199
- $slotRefNode$: childNode,
1200
- $nodeToRelocate$: node,
1201
- });
1202
- }
1203
- if (node['s-sr']) {
1204
- relocateNodes.map((relocateNode) => {
1205
- if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node['s-sn'])) {
1206
- relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
1207
- if (relocateNodeData && !relocateNode.$slotRefNode$) {
1208
- relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
1209
- }
1210
- }
1211
- });
1212
- }
1213
- }
1214
- else if (!relocateNodes.some((r) => r.$nodeToRelocate$ === node)) {
1215
- // the node is not found within the slot (`childNode`) that we're
1216
- // currently looking at, so we stick it into `relocateNodes` to
1217
- // handle later. If we never find a home for this element then
1218
- // we'll need to hide it
1219
- relocateNodes.push({
1220
- $nodeToRelocate$: node,
1221
- });
1222
- }
1223
- }
1224
- }
1225
- }
1226
- // if we're dealing with any type of element (capable of itself being a
1227
- // slot reference or containing one) then we recur
1228
- if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1229
- markSlotContentForRelocation(childNode);
1230
- }
1231
- }
1232
- };
1233
- /**
1234
- * Check whether a node is located in a given named slot.
1235
- *
1236
- * @param nodeToRelocate the node of interest
1237
- * @param slotName the slot name to check
1238
- * @returns whether the node is located in the slot or not
1239
- */
1240
- const isNodeLocatedInSlot = (nodeToRelocate, slotName) => {
1241
- if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1242
- if (nodeToRelocate.getAttribute('slot') === null && slotName === '') {
1243
- // if the node doesn't have a slot attribute, and the slot we're checking
1244
- // is not a named slot, then we assume the node should be within the slot
1245
- return true;
1246
- }
1247
- if (nodeToRelocate.getAttribute('slot') === slotName) {
1248
- return true;
1249
- }
1250
- return false;
1251
- }
1252
- if (nodeToRelocate['s-sn'] === slotName) {
1253
- return true;
1254
- }
1255
- return slotName === '';
1256
- };
1257
- /**
1258
- * 'Nullify' any VDom `ref` callbacks on a VDom node or its children by calling
1259
- * them with `null`. This signals that the DOM element corresponding to the VDom
1260
- * node has been removed from the DOM.
1261
- *
1262
- * @param vNode a virtual DOM node
1263
- */
1264
- const nullifyVNodeRefs = (vNode) => {
1265
- {
1266
- vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
1267
- vNode.$children$ && vNode.$children$.map(nullifyVNodeRefs);
1268
- }
1269
- };
1270
- /**
1271
- * The main entry point for Stencil's virtual DOM-based rendering engine
1272
- *
1273
- * Given a {@link d.HostRef} container and some virtual DOM nodes, this
1274
- * function will handle creating a virtual DOM tree with a single root, patching
1275
- * the current virtual DOM tree onto an old one (if any), dealing with slot
1276
- * relocation, and reflecting attributes.
1277
- *
1278
- * @param hostRef data needed to root and render the virtual DOM tree, such as
1279
- * the DOM node into which it should be rendered.
1280
- * @param renderFnResults the virtual DOM nodes to be rendered
1281
- * @param isInitialLoad whether or not this is the first call after page load
1282
- */
1283
- const renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
1284
- var _a, _b, _c, _d;
1285
- const hostElm = hostRef.$hostElement$;
1286
- const cmpMeta = hostRef.$cmpMeta$;
1287
- const oldVNode = hostRef.$vnode$ || newVNode(null, null);
1288
- // if `renderFnResults` is a Host node then we can use it directly. If not,
1289
- // we need to call `h` again to wrap the children of our component in a
1290
- // 'dummy' Host node (well, an empty vnode) since `renderVdom` assumes
1291
- // implicitly that the top-level vdom node is 1) an only child and 2)
1292
- // contains attrs that need to be set on the host element.
1293
- const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
1294
- hostTagName = hostElm.tagName;
1295
- if (cmpMeta.$attrsToReflect$) {
1296
- rootVnode.$attrs$ = rootVnode.$attrs$ || {};
1297
- cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
1298
- }
1299
- // On the first render and *only* on the first render we want to check for
1300
- // any attributes set on the host element which are also set on the vdom
1301
- // node. If we find them, we override the value on the VDom node attrs with
1302
- // the value from the host element, which allows developers building apps
1303
- // with Stencil components to override e.g. the `role` attribute on a
1304
- // component even if it's already set on the `Host`.
1305
- if (isInitialLoad && rootVnode.$attrs$) {
1306
- for (const key of Object.keys(rootVnode.$attrs$)) {
1307
- // We have a special implementation in `setAccessor` for `style` and
1308
- // `class` which reconciles values coming from the VDom with values
1309
- // already present on the DOM element, so we don't want to override those
1310
- // attributes on the VDom tree with values from the host element if they
1311
- // are present.
1312
- //
1313
- // Likewise, `ref` and `key` are special internal values for the Stencil
1314
- // runtime and we don't want to override those either.
1315
- if (hostElm.hasAttribute(key) && !['key', 'ref', 'style', 'class'].includes(key)) {
1316
- rootVnode.$attrs$[key] = hostElm[key];
1317
- }
1318
- }
1319
- }
1320
- rootVnode.$tag$ = null;
1321
- rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
1322
- hostRef.$vnode$ = rootVnode;
1323
- rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
1324
- {
1325
- scopeId = hostElm['s-sc'];
1326
- }
1327
- useNativeShadowDom = (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) !== 0;
1328
- {
1329
- contentRef = hostElm['s-cr'];
1330
- // always reset
1331
- checkSlotFallbackVisibility = false;
1332
- }
1333
- // synchronous patch
1334
- patch(oldVNode, rootVnode, isInitialLoad);
1335
- {
1336
- // while we're moving nodes around existing nodes, temporarily disable
1337
- // the disconnectCallback from working
1338
- plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
1339
- if (checkSlotRelocate) {
1340
- markSlotContentForRelocation(rootVnode.$elm$);
1341
- for (const relocateData of relocateNodes) {
1342
- const nodeToRelocate = relocateData.$nodeToRelocate$;
1343
- if (!nodeToRelocate['s-ol']) {
1344
- // add a reference node marking this node's original location
1345
- // keep a reference to this node for later lookups
1346
- const orgLocationNode = doc.createTextNode('');
1347
- orgLocationNode['s-nr'] = nodeToRelocate;
1348
- nodeToRelocate.parentNode.insertBefore((nodeToRelocate['s-ol'] = orgLocationNode), nodeToRelocate);
1349
- }
1350
- }
1351
- for (const relocateData of relocateNodes) {
1352
- const nodeToRelocate = relocateData.$nodeToRelocate$;
1353
- const slotRefNode = relocateData.$slotRefNode$;
1354
- if (slotRefNode) {
1355
- const parentNodeRef = slotRefNode.parentNode;
1356
- // When determining where to insert content, the most simple case would be
1357
- // to relocate the node immediately following the slot reference node. We do this
1358
- // by getting a reference to the node immediately following the slot reference node
1359
- // since we will use `insertBefore` to manipulate the DOM.
1360
- //
1361
- // If there is no node immediately following the slot reference node, then we will just
1362
- // end up appending the node as the last child of the parent.
1363
- let insertBeforeNode = slotRefNode.nextSibling;
1364
- // If the node we're currently planning on inserting the new node before is an element,
1365
- // we need to do some additional checks to make sure we're inserting the node in the correct order.
1366
- // The use case here would be that we have multiple nodes being relocated to the same slot. So, we want
1367
- // to make sure they get inserted into their new home in the same order they were declared in their original location.
1368
- //
1369
- // TODO(STENCIL-914): Remove `experimentalSlotFixes` check
1370
- {
1371
- let orgLocationNode = (_a = nodeToRelocate['s-ol']) === null || _a === void 0 ? void 0 : _a.previousSibling;
1372
- while (orgLocationNode) {
1373
- let refNode = (_b = orgLocationNode['s-nr']) !== null && _b !== void 0 ? _b : null;
1374
- if (refNode && refNode['s-sn'] === nodeToRelocate['s-sn'] && parentNodeRef === refNode.parentNode) {
1375
- refNode = refNode.nextSibling;
1376
- // If the refNode is the same node to be relocated or another element's slot reference, keep searching to find the
1377
- // correct relocation target
1378
- while (refNode === nodeToRelocate || (refNode === null || refNode === void 0 ? void 0 : refNode['s-sr'])) {
1379
- refNode = refNode === null || refNode === void 0 ? void 0 : refNode.nextSibling;
1380
- }
1381
- if (!refNode || !refNode['s-nr']) {
1382
- insertBeforeNode = refNode;
1383
- break;
1384
- }
1385
- }
1386
- orgLocationNode = orgLocationNode.previousSibling;
1387
- }
1388
- }
1389
- if ((!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode) ||
1390
- nodeToRelocate.nextSibling !== insertBeforeNode) {
1391
- // we've checked that it's worth while to relocate
1392
- // since that the node to relocate
1393
- // has a different next sibling or parent relocated
1394
- if (nodeToRelocate !== insertBeforeNode) {
1395
- if (!nodeToRelocate['s-hn'] && nodeToRelocate['s-ol']) {
1396
- // probably a component in the index.html that doesn't have its hostname set
1397
- nodeToRelocate['s-hn'] = nodeToRelocate['s-ol'].parentNode.nodeName;
1398
- }
1399
- // Add it back to the dom but in its new home
1400
- // If we get to this point and `insertBeforeNode` is `null`, that means
1401
- // we're just going to append the node as the last child of the parent. Passing
1402
- // `null` as the second arg here will trigger that behavior.
1403
- parentNodeRef.insertBefore(nodeToRelocate, insertBeforeNode);
1404
- // Reset the `hidden` value back to what it was defined as originally
1405
- // This solves a problem where a `slot` is dynamically rendered and `hidden` may have
1406
- // been set on content originally, but now it has a slot to go to so it should have
1407
- // the value it was defined as having in the DOM, not what we overrode it to.
1408
- if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1409
- nodeToRelocate.hidden = (_c = nodeToRelocate['s-ih']) !== null && _c !== void 0 ? _c : false;
1410
- }
1411
- }
1412
- }
1413
- nodeToRelocate && typeof slotRefNode['s-rf'] === 'function' && slotRefNode['s-rf'](nodeToRelocate);
1414
- }
1415
- else {
1416
- // this node doesn't have a slot home to go to, so let's hide it
1417
- if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1418
- // Store the initial value of `hidden` so we can reset it later when
1419
- // moving nodes around.
1420
- if (isInitialLoad) {
1421
- nodeToRelocate['s-ih'] = (_d = nodeToRelocate.hidden) !== null && _d !== void 0 ? _d : false;
1422
- }
1423
- nodeToRelocate.hidden = true;
1424
- }
1425
- }
1426
- }
1427
- }
1428
- if (checkSlotFallbackVisibility) {
1429
- updateFallbackSlotVisibility(rootVnode.$elm$);
1430
- }
1431
- // done moving nodes around
1432
- // allow the disconnect callback to work again
1433
- plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
1434
- // always reset
1435
- relocateNodes.length = 0;
1436
- }
1437
- // Clear the content ref so we don't create a memory leak
1438
- contentRef = undefined;
1439
- };
1440
- const attachToAncestor = (hostRef, ancestorComponent) => {
1441
- if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
1442
- ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
1443
- }
1444
- };
1445
- const scheduleUpdate = (hostRef, isInitialLoad) => {
1446
- {
1447
- hostRef.$flags$ |= 16 /* HOST_FLAGS.isQueuedForUpdate */;
1448
- }
1449
- if (hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
1450
- hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
1451
- return;
1452
- }
1453
- attachToAncestor(hostRef, hostRef.$ancestorComponent$);
1454
- // there is no ancestor component or the ancestor component
1455
- // has already fired off its lifecycle update then
1456
- // fire off the initial update
1457
- const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
1458
- return writeTask(dispatch) ;
1459
- };
1460
- /**
1461
- * Dispatch initial-render and update lifecycle hooks, enqueuing calls to
1462
- * component lifecycle methods like `componentWillLoad` as well as
1463
- * {@link updateComponent}, which will kick off the virtual DOM re-render.
1464
- *
1465
- * @param hostRef a reference to a host DOM node
1466
- * @param isInitialLoad whether we're on the initial load or not
1467
- * @returns an empty Promise which is used to enqueue a series of operations for
1468
- * the component
1469
- */
1470
- const dispatchHooks = (hostRef, isInitialLoad) => {
1471
- const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
1472
- const instance = hostRef.$lazyInstance$ ;
1473
- // We're going to use this variable together with `enqueue` to implement a
1474
- // little promise-based queue. We start out with it `undefined`. When we add
1475
- // the first function to the queue we'll set this variable to be that
1476
- // function's return value. When we attempt to add subsequent values to the
1477
- // queue we'll check that value and, if it was a `Promise`, we'll then chain
1478
- // the new function off of that `Promise` using `.then()`. This will give our
1479
- // queue two nice properties:
1480
- //
1481
- // 1. If all functions added to the queue are synchronous they'll be called
1482
- // synchronously right away.
1483
- // 2. If all functions added to the queue are asynchronous they'll all be
1484
- // called in order after `dispatchHooks` exits.
1485
- let maybePromise;
1486
- if (isInitialLoad) {
1487
- {
1488
- hostRef.$flags$ |= 256 /* HOST_FLAGS.isListenReady */;
1489
- if (hostRef.$queuedListeners$) {
1490
- hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
1491
- hostRef.$queuedListeners$ = undefined;
1492
- }
1493
- }
1494
- {
1495
- // If `componentWillLoad` returns a `Promise` then we want to wait on
1496
- // whatever's going on in that `Promise` before we launch into
1497
- // rendering the component, doing other lifecycle stuff, etc. So
1498
- // in that case we assign the returned promise to the variable we
1499
- // declared above to hold a possible 'queueing' Promise
1500
- maybePromise = safeCall(instance, 'componentWillLoad');
1501
- }
1502
- }
1503
- endSchedule();
1504
- return enqueue(maybePromise, () => updateComponent(hostRef, instance, isInitialLoad));
1505
- };
1506
- /**
1507
- * This function uses a Promise to implement a simple first-in, first-out queue
1508
- * of functions to be called.
1509
- *
1510
- * The queue is ordered on the basis of the first argument. If it's
1511
- * `undefined`, then nothing is on the queue yet, so the provided function can
1512
- * be called synchronously (although note that this function may return a
1513
- * `Promise`). The idea is that then the return value of that enqueueing
1514
- * operation is kept around, so that if it was a `Promise` then subsequent
1515
- * functions can be enqueued by calling this function again with that `Promise`
1516
- * as the first argument.
1517
- *
1518
- * @param maybePromise either a `Promise` which should resolve before the next function is called or an 'empty' sentinel
1519
- * @param fn a function to enqueue
1520
- * @returns either a `Promise` or the return value of the provided function
1521
- */
1522
- const enqueue = (maybePromise, fn) => isPromisey(maybePromise) ? maybePromise.then(fn) : fn();
1523
- /**
1524
- * Check that a value is a `Promise`. To check, we first see if the value is an
1525
- * instance of the `Promise` global. In a few circumstances, in particular if
1526
- * the global has been overwritten, this is could be misleading, so we also do
1527
- * a little 'duck typing' check to see if the `.then` property of the value is
1528
- * defined and a function.
1529
- *
1530
- * @param maybePromise it might be a promise!
1531
- * @returns whether it is or not
1532
- */
1533
- const isPromisey = (maybePromise) => maybePromise instanceof Promise ||
1534
- (maybePromise && maybePromise.then && typeof maybePromise.then === 'function');
1535
- /**
1536
- * Update a component given reference to its host elements and so on.
1537
- *
1538
- * @param hostRef an object containing references to the element's host node,
1539
- * VDom nodes, and other metadata
1540
- * @param instance a reference to the underlying host element where it will be
1541
- * rendered
1542
- * @param isInitialLoad whether or not this function is being called as part of
1543
- * the first render cycle
1544
- */
1545
- const updateComponent = async (hostRef, instance, isInitialLoad) => {
1546
- var _a;
1547
- const elm = hostRef.$hostElement$;
1548
- const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
1549
- const rc = elm['s-rc'];
1550
- if (isInitialLoad) {
1551
- // DOM WRITE!
1552
- attachStyles(hostRef);
1553
- }
1554
- const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
1555
- {
1556
- callRender(hostRef, instance, elm, isInitialLoad);
1557
- }
1558
- if (rc) {
1559
- // ok, so turns out there are some child host elements
1560
- // waiting on this parent element to load
1561
- // let's fire off all update callbacks waiting
1562
- rc.map((cb) => cb());
1563
- elm['s-rc'] = undefined;
1564
- }
1565
- endRender();
1566
- endUpdate();
1567
- {
1568
- const childrenPromises = (_a = elm['s-p']) !== null && _a !== void 0 ? _a : [];
1569
- const postUpdate = () => postUpdateComponent(hostRef);
1570
- if (childrenPromises.length === 0) {
1571
- postUpdate();
1572
- }
1573
- else {
1574
- Promise.all(childrenPromises).then(postUpdate);
1575
- hostRef.$flags$ |= 4 /* HOST_FLAGS.isWaitingForChildren */;
1576
- childrenPromises.length = 0;
1577
- }
1578
- }
1579
- };
1580
- /**
1581
- * Handle making the call to the VDom renderer with the proper context given
1582
- * various build variables
1583
- *
1584
- * @param hostRef an object containing references to the element's host node,
1585
- * VDom nodes, and other metadata
1586
- * @param instance a reference to the underlying host element where it will be
1587
- * rendered
1588
- * @param elm the Host element for the component
1589
- * @param isInitialLoad whether or not this function is being called as part of
1590
- * @returns an empty promise
1591
- */
1592
- const callRender = (hostRef, instance, elm, isInitialLoad) => {
1593
- try {
1594
- /**
1595
- * minification optimization: `allRenderFn` is `true` if all components have a `render`
1596
- * method, so we can call the method immediately. If not, check before calling it.
1597
- */
1598
- instance = instance.render() ;
1599
- {
1600
- hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
1601
- }
1602
- {
1603
- hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
1604
- }
1605
- {
1606
- {
1607
- // looks like we've got child nodes to render into this host element
1608
- // or we need to update the css class/attrs on the host element
1609
- // DOM WRITE!
1610
- {
1611
- renderVdom(hostRef, instance, isInitialLoad);
1612
- }
1613
- }
1614
- }
1615
- }
1616
- catch (e) {
1617
- consoleError(e, hostRef.$hostElement$);
1618
- }
1619
- return null;
1620
- };
1621
- const postUpdateComponent = (hostRef) => {
1622
- const tagName = hostRef.$cmpMeta$.$tagName$;
1623
- const elm = hostRef.$hostElement$;
1624
- const endPostUpdate = createTime('postUpdate', tagName);
1625
- const instance = hostRef.$lazyInstance$ ;
1626
- const ancestorComponent = hostRef.$ancestorComponent$;
1627
- if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
1628
- hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
1629
- {
1630
- // DOM WRITE!
1631
- addHydratedFlag(elm);
1632
- }
1633
- {
1634
- safeCall(instance, 'componentDidLoad');
1635
- }
1636
- endPostUpdate();
1637
- {
1638
- hostRef.$onReadyResolve$(elm);
1639
- if (!ancestorComponent) {
1640
- appDidLoad();
1641
- }
1642
- }
1643
- }
1644
- else {
1645
- endPostUpdate();
1646
- }
1647
- {
1648
- hostRef.$onInstanceResolve$(elm);
1649
- }
1650
- // load events fire from bottom to top
1651
- // the deepest elements load first then bubbles up
1652
- {
1653
- if (hostRef.$onRenderResolve$) {
1654
- hostRef.$onRenderResolve$();
1655
- hostRef.$onRenderResolve$ = undefined;
1656
- }
1657
- if (hostRef.$flags$ & 512 /* HOST_FLAGS.needsRerender */) {
1658
- nextTick(() => scheduleUpdate(hostRef, false));
1659
- }
1660
- hostRef.$flags$ &= ~(4 /* HOST_FLAGS.isWaitingForChildren */ | 512 /* HOST_FLAGS.needsRerender */);
1661
- }
1662
- // ( •_•)
1663
- // ( •_•)>⌐■-■
1664
- // (⌐■_■)
1665
- };
1666
- const appDidLoad = (who) => {
1667
- // on appload
1668
- // we have finish the first big initial render
1669
- {
1670
- addHydratedFlag(doc.documentElement);
1671
- }
1672
- nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
1673
- };
1674
- /**
1675
- * Allows to safely call a method, e.g. `componentDidLoad`, on an instance,
1676
- * e.g. custom element node. If a build figures out that e.g. no component
1677
- * has a `componentDidLoad` method, the instance method gets removed from the
1678
- * output bundle and this function returns `undefined`.
1679
- * @param instance any object that may or may not contain methods
1680
- * @param method method name
1681
- * @param arg single arbitrary argument
1682
- * @returns result of method call if it exists, otherwise `undefined`
1683
- */
1684
- const safeCall = (instance, method, arg) => {
1685
- if (instance && instance[method]) {
1686
- try {
1687
- return instance[method](arg);
1688
- }
1689
- catch (e) {
1690
- consoleError(e);
1691
- }
1692
- }
1693
- return undefined;
1694
- };
1695
- const addHydratedFlag = (elm) => elm.classList.add('hydrated')
1696
- ;
1697
- const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
1698
- const setValue = (ref, propName, newVal, cmpMeta) => {
1699
- // check our new property value against our internal value
1700
- const hostRef = getHostRef(ref);
1701
- const elm = hostRef.$hostElement$ ;
1702
- const oldVal = hostRef.$instanceValues$.get(propName);
1703
- const flags = hostRef.$flags$;
1704
- const instance = hostRef.$lazyInstance$ ;
1705
- newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
1706
- // explicitly check for NaN on both sides, as `NaN === NaN` is always false
1707
- const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
1708
- const didValueChange = newVal !== oldVal && !areBothNaN;
1709
- if ((!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
1710
- // gadzooks! the property's value has changed!!
1711
- // set our new value!
1712
- hostRef.$instanceValues$.set(propName, newVal);
1713
- if (instance) {
1714
- // get an array of method names of watch functions to call
1715
- if (cmpMeta.$watchers$ && flags & 128 /* HOST_FLAGS.isWatchReady */) {
1716
- const watchMethods = cmpMeta.$watchers$[propName];
1717
- if (watchMethods) {
1718
- // this instance is watching for when this property changed
1719
- watchMethods.map((watchMethodName) => {
1720
- try {
1721
- // fire off each of the watch methods that are watching this property
1722
- instance[watchMethodName](newVal, oldVal, propName);
1723
- }
1724
- catch (e) {
1725
- consoleError(e, elm);
1726
- }
1727
- });
1728
- }
1729
- }
1730
- if ((flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
1731
- // looks like this value actually changed, so we've got work to do!
1732
- // but only if we've already rendered, otherwise just chill out
1733
- // queue that we need to do an update, but don't worry about queuing
1734
- // up millions cuz this function ensures it only runs once
1735
- scheduleUpdate(hostRef, false);
1736
- }
1737
- }
1738
- }
1739
- };
1740
- /**
1741
- * Attach a series of runtime constructs to a compiled Stencil component
1742
- * constructor, including getters and setters for the `@Prop` and `@State`
1743
- * decorators, callbacks for when attributes change, and so on.
1744
- *
1745
- * @param Cstr the constructor for a component that we need to process
1746
- * @param cmpMeta metadata collected previously about the component
1747
- * @param flags a number used to store a series of bit flags
1748
- * @returns a reference to the same constructor passed in (but now mutated)
1749
- */
1750
- const proxyComponent = (Cstr, cmpMeta, flags) => {
1751
- var _a;
1752
- const prototype = Cstr.prototype;
1753
- /**
1754
- * proxy form associated custom element lifecycle callbacks
1755
- * @ref https://web.dev/articles/more-capable-form-controls#lifecycle_callbacks
1756
- */
1757
- if (cmpMeta.$flags$ & 64 /* CMP_FLAGS.formAssociated */ && flags & 1 /* PROXY_FLAGS.isElementConstructor */) {
1758
- FORM_ASSOCIATED_CUSTOM_ELEMENT_CALLBACKS.forEach((cbName) => Object.defineProperty(prototype, cbName, {
1759
- value(...args) {
1760
- const hostRef = getHostRef(this);
1761
- const instance = hostRef.$lazyInstance$ ;
1762
- if (!instance) {
1763
- hostRef.$onReadyPromise$.then((instance) => {
1764
- const cb = instance[cbName];
1765
- typeof cb === 'function' && cb.call(instance, ...args);
1766
- });
1767
- }
1768
- else {
1769
- const cb = instance[cbName];
1770
- typeof cb === 'function' && cb.call(instance, ...args);
1771
- }
1772
- },
1773
- }));
1774
- }
1775
- if (cmpMeta.$members$) {
1776
- if (Cstr.watchers) {
1777
- cmpMeta.$watchers$ = Cstr.watchers;
1778
- }
1779
- // It's better to have a const than two Object.entries()
1780
- const members = Object.entries(cmpMeta.$members$);
1781
- members.map(([memberName, [memberFlags]]) => {
1782
- if ((memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
1783
- ((flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
1784
- // proxyComponent - prop
1785
- Object.defineProperty(prototype, memberName, {
1786
- get() {
1787
- // proxyComponent, get value
1788
- return getValue(this, memberName);
1789
- },
1790
- set(newValue) {
1791
- // proxyComponent, set value
1792
- setValue(this, memberName, newValue, cmpMeta);
1793
- },
1794
- configurable: true,
1795
- enumerable: true,
1796
- });
1797
- }
1798
- else if (flags & 1 /* PROXY_FLAGS.isElementConstructor */ &&
1799
- memberFlags & 64 /* MEMBER_FLAGS.Method */) {
1800
- // proxyComponent - method
1801
- Object.defineProperty(prototype, memberName, {
1802
- value(...args) {
1803
- var _a;
1804
- const ref = getHostRef(this);
1805
- return (_a = ref === null || ref === void 0 ? void 0 : ref.$onInstancePromise$) === null || _a === void 0 ? void 0 : _a.then(() => { var _a; return (_a = ref.$lazyInstance$) === null || _a === void 0 ? void 0 : _a[memberName](...args); });
1806
- },
1807
- });
1808
- }
1809
- });
1810
- if ((flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
1811
- const attrNameToPropName = new Map();
1812
- prototype.attributeChangedCallback = function (attrName, oldValue, newValue) {
1813
- plt.jmp(() => {
1814
- var _a;
1815
- const propName = attrNameToPropName.get(attrName);
1816
- // In a web component lifecycle the attributeChangedCallback runs prior to connectedCallback
1817
- // in the case where an attribute was set inline.
1818
- // ```html
1819
- // <my-component some-attribute="some-value"></my-component>
1820
- // ```
1821
- //
1822
- // There is an edge case where a developer sets the attribute inline on a custom element and then
1823
- // programmatically changes it before it has been upgraded as shown below:
1824
- //
1825
- // ```html
1826
- // <!-- this component has _not_ been upgraded yet -->
1827
- // <my-component id="test" some-attribute="some-value"></my-component>
1828
- // <script>
1829
- // // grab non-upgraded component
1830
- // el = document.querySelector("#test");
1831
- // el.someAttribute = "another-value";
1832
- // // upgrade component
1833
- // customElements.define('my-component', MyComponent);
1834
- // </script>
1835
- // ```
1836
- // In this case if we do not un-shadow here and use the value of the shadowing property, attributeChangedCallback
1837
- // will be called with `newValue = "some-value"` and will set the shadowed property (this.someAttribute = "another-value")
1838
- // to the value that was set inline i.e. "some-value" from above example. When
1839
- // the connectedCallback attempts to un-shadow it will use "some-value" as the initial value rather than "another-value"
1840
- //
1841
- // The case where the attribute was NOT set inline but was not set programmatically shall be handled/un-shadowed
1842
- // by connectedCallback as this attributeChangedCallback will not fire.
1843
- //
1844
- // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1845
- //
1846
- // TODO(STENCIL-16) we should think about whether or not we actually want to be reflecting the attributes to
1847
- // properties here given that this goes against best practices outlined here
1848
- // https://developers.google.com/web/fundamentals/web-components/best-practices#avoid-reentrancy
1849
- if (this.hasOwnProperty(propName)) {
1850
- newValue = this[propName];
1851
- delete this[propName];
1852
- }
1853
- else if (prototype.hasOwnProperty(propName) &&
1854
- typeof this[propName] === 'number' &&
1855
- this[propName] == newValue) {
1856
- // if the propName exists on the prototype of `Cstr`, this update may be a result of Stencil using native
1857
- // APIs to reflect props as attributes. Calls to `setAttribute(someElement, propName)` will result in
1858
- // `propName` to be converted to a `DOMString`, which may not be what we want for other primitive props.
1859
- return;
1860
- }
1861
- else if (propName == null) {
1862
- // At this point we should know this is not a "member", so we can treat it like watching an attribute
1863
- // on a vanilla web component
1864
- const hostRef = getHostRef(this);
1865
- const flags = hostRef === null || hostRef === void 0 ? void 0 : hostRef.$flags$;
1866
- // We only want to trigger the callback(s) if:
1867
- // 1. The instance is ready
1868
- // 2. The watchers are ready
1869
- // 3. The value has changed
1870
- if (flags &&
1871
- !(flags & 8 /* HOST_FLAGS.isConstructingInstance */) &&
1872
- flags & 128 /* HOST_FLAGS.isWatchReady */ &&
1873
- newValue !== oldValue) {
1874
- const instance = hostRef.$lazyInstance$ ;
1875
- const entry = (_a = cmpMeta.$watchers$) === null || _a === void 0 ? void 0 : _a[attrName];
1876
- entry === null || entry === void 0 ? void 0 : entry.forEach((callbackName) => {
1877
- if (instance[callbackName] != null) {
1878
- instance[callbackName].call(instance, newValue, oldValue, attrName);
1879
- }
1880
- });
1881
- }
1882
- return;
1883
- }
1884
- this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
1885
- });
1886
- };
1887
- // Create an array of attributes to observe
1888
- // This list in comprised of all strings used within a `@Watch()` decorator
1889
- // on a component as well as any Stencil-specific "members" (`@Prop()`s and `@State()`s).
1890
- // As such, there is no way to guarantee type-safety here that a user hasn't entered
1891
- // an invalid attribute.
1892
- Cstr.observedAttributes = Array.from(new Set([
1893
- ...Object.keys((_a = cmpMeta.$watchers$) !== null && _a !== void 0 ? _a : {}),
1894
- ...members
1895
- .filter(([_, m]) => m[0] & 15 /* MEMBER_FLAGS.HasAttribute */)
1896
- .map(([propName, m]) => {
1897
- var _a;
1898
- const attrName = m[1] || propName;
1899
- attrNameToPropName.set(attrName, propName);
1900
- if (m[0] & 512 /* MEMBER_FLAGS.ReflectAttr */) {
1901
- (_a = cmpMeta.$attrsToReflect$) === null || _a === void 0 ? void 0 : _a.push([propName, attrName]);
1902
- }
1903
- return attrName;
1904
- }),
1905
- ]));
1906
- }
1907
- }
1908
- return Cstr;
1909
- };
1910
- /**
1911
- * Initialize a Stencil component given a reference to its host element, its
1912
- * runtime bookkeeping data structure, runtime metadata about the component,
1913
- * and (optionally) an HMR version ID.
1914
- *
1915
- * @param elm a host element
1916
- * @param hostRef the element's runtime bookkeeping object
1917
- * @param cmpMeta runtime metadata for the Stencil component
1918
- * @param hmrVersionId an (optional) HMR version ID
1919
- */
1920
- const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
1921
- let Cstr;
1922
- // initializeComponent
1923
- if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
1924
- // Let the runtime know that the component has been initialized
1925
- hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
1926
- const bundleId = cmpMeta.$lazyBundleId$;
1927
- if (bundleId) {
1928
- // lazy loaded components
1929
- // request the component's implementation to be
1930
- // wired up with the host element
1931
- Cstr = loadModule(cmpMeta);
1932
- if (Cstr.then) {
1933
- // Await creates a micro-task avoid if possible
1934
- const endLoad = uniqueTime();
1935
- Cstr = await Cstr;
1936
- endLoad();
1937
- }
1938
- if (!Cstr.isProxied) {
1939
- // we've never proxied this Constructor before
1940
- // let's add the getters/setters to its prototype before
1941
- // the first time we create an instance of the implementation
1942
- {
1943
- cmpMeta.$watchers$ = Cstr.watchers;
1944
- }
1945
- proxyComponent(Cstr, cmpMeta, 2 /* PROXY_FLAGS.proxyState */);
1946
- Cstr.isProxied = true;
1947
- }
1948
- const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
1949
- // ok, time to construct the instance
1950
- // but let's keep track of when we start and stop
1951
- // so that the getters/setters don't incorrectly step on data
1952
- {
1953
- hostRef.$flags$ |= 8 /* HOST_FLAGS.isConstructingInstance */;
1954
- }
1955
- // construct the lazy-loaded component implementation
1956
- // passing the hostRef is very important during
1957
- // construction in order to directly wire together the
1958
- // host element and the lazy-loaded instance
1959
- try {
1960
- new Cstr(hostRef);
1961
- }
1962
- catch (e) {
1963
- consoleError(e);
1964
- }
1965
- {
1966
- hostRef.$flags$ &= ~8 /* HOST_FLAGS.isConstructingInstance */;
1967
- }
1968
- {
1969
- hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */;
1970
- }
1971
- endNewInstance();
1972
- }
1973
- else {
1974
- // sync constructor component
1975
- Cstr = elm.constructor;
1976
- // wait for the CustomElementRegistry to mark the component as ready before setting `isWatchReady`. Otherwise,
1977
- // watchers may fire prematurely if `customElements.get()`/`customElements.whenDefined()` resolves _before_
1978
- // Stencil has completed instantiating the component.
1979
- customElements.whenDefined(cmpMeta.$tagName$).then(() => (hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */));
1980
- }
1981
- if (Cstr.style) {
1982
- // this component has styles but we haven't registered them yet
1983
- let style = Cstr.style;
1984
- const scopeId = getScopeId(cmpMeta);
1985
- if (!styles.has(scopeId)) {
1986
- const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
1987
- registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
1988
- endRegisterStyles();
1989
- }
1990
- }
1991
- }
1992
- // we've successfully created a lazy instance
1993
- const ancestorComponent = hostRef.$ancestorComponent$;
1994
- const schedule = () => scheduleUpdate(hostRef, true);
1995
- if (ancestorComponent && ancestorComponent['s-rc']) {
1996
- // this is the initial load and this component it has an ancestor component
1997
- // but the ancestor component has NOT fired its will update lifecycle yet
1998
- // so let's just cool our jets and wait for the ancestor to continue first
1999
- // this will get fired off when the ancestor component
2000
- // finally gets around to rendering its lazy self
2001
- // fire off the initial update
2002
- ancestorComponent['s-rc'].push(schedule);
2003
- }
2004
- else {
2005
- schedule();
2006
- }
2007
- };
2008
- const fireConnectedCallback = (instance) => {
2009
- };
2010
- const connectedCallback = (elm) => {
2011
- if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
2012
- const hostRef = getHostRef(elm);
2013
- const cmpMeta = hostRef.$cmpMeta$;
2014
- const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
2015
- if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
2016
- // first time this component has connected
2017
- hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
2018
- {
2019
- // initUpdate
2020
- // if the slot polyfill is required we'll need to put some nodes
2021
- // in here to act as original content anchors as we move nodes around
2022
- // host element has been connected to the DOM
2023
- if ((// TODO(STENCIL-854): Remove code related to legacy shadowDomShim field
2024
- cmpMeta.$flags$ & (4 /* CMP_FLAGS.hasSlotRelocation */ | 8 /* CMP_FLAGS.needsShadowDomShim */))) {
2025
- setContentReference(elm);
2026
- }
2027
- }
2028
- {
2029
- // find the first ancestor component (if there is one) and register
2030
- // this component as one of the actively loading child components for its ancestor
2031
- let ancestorComponent = elm;
2032
- while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
2033
- // climb up the ancestors looking for the first
2034
- // component that hasn't finished its lifecycle update yet
2035
- if (ancestorComponent['s-p']) {
2036
- // we found this components first ancestor component
2037
- // keep a reference to this component's ancestor component
2038
- attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
2039
- break;
2040
- }
2041
- }
2042
- }
2043
- // Lazy properties
2044
- // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
2045
- if (cmpMeta.$members$) {
2046
- Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
2047
- if (memberFlags & 31 /* MEMBER_FLAGS.Prop */ && elm.hasOwnProperty(memberName)) {
2048
- const value = elm[memberName];
2049
- delete elm[memberName];
2050
- elm[memberName] = value;
2051
- }
2052
- });
2053
- }
2054
- {
2055
- initializeComponent(elm, hostRef, cmpMeta);
2056
- }
2057
- }
2058
- else {
2059
- // not the first time this has connected
2060
- // reattach any event listeners to the host
2061
- // since they would have been removed when disconnected
2062
- addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
2063
- // fire off connectedCallback() on component instance
2064
- if (hostRef === null || hostRef === void 0 ? void 0 : hostRef.$lazyInstance$) ;
2065
- else if (hostRef === null || hostRef === void 0 ? void 0 : hostRef.$onReadyPromise$) {
2066
- hostRef.$onReadyPromise$.then(() => fireConnectedCallback());
2067
- }
2068
- }
2069
- endConnected();
2070
- }
2071
- };
2072
- const setContentReference = (elm) => {
2073
- // only required when we're NOT using native shadow dom (slot)
2074
- // or this browser doesn't support native shadow dom
2075
- // and this host element was NOT created with SSR
2076
- // let's pick out the inner content for slot projection
2077
- // create a node to represent where the original
2078
- // content was first placed, which is useful later on
2079
- const contentRefElm = (elm['s-cr'] = doc.createComment(''));
2080
- contentRefElm['s-cn'] = true;
2081
- elm.insertBefore(contentRefElm, elm.firstChild);
2082
- };
2083
- const disconnectInstance = (instance) => {
2084
- {
2085
- safeCall(instance, 'disconnectedCallback');
2086
- }
2087
- };
2088
- const disconnectedCallback = async (elm) => {
2089
- if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
2090
- const hostRef = getHostRef(elm);
2091
- {
2092
- if (hostRef.$rmListeners$) {
2093
- hostRef.$rmListeners$.map((rmListener) => rmListener());
2094
- hostRef.$rmListeners$ = undefined;
2095
- }
2096
- }
2097
- if (hostRef === null || hostRef === void 0 ? void 0 : hostRef.$lazyInstance$) {
2098
- disconnectInstance(hostRef.$lazyInstance$);
2099
- }
2100
- else if (hostRef === null || hostRef === void 0 ? void 0 : hostRef.$onReadyPromise$) {
2101
- hostRef.$onReadyPromise$.then(() => disconnectInstance(hostRef.$lazyInstance$));
2102
- }
2103
- }
2104
- };
2105
- const bootstrapLazy = (lazyBundles, options = {}) => {
2106
- var _a;
2107
- const endBootstrap = createTime();
2108
- const cmpTags = [];
2109
- const exclude = options.exclude || [];
2110
- const customElements = win.customElements;
2111
- const head = doc.head;
2112
- const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
2113
- const dataStyles = /*@__PURE__*/ doc.createElement('style');
2114
- const deferredConnectedCallbacks = [];
2115
- let appLoadFallback;
2116
- let isBootstrapping = true;
2117
- Object.assign(plt, options);
2118
- plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
2119
- let hasSlotRelocation = false;
2120
- lazyBundles.map((lazyBundle) => {
2121
- lazyBundle[1].map((compactMeta) => {
2122
- var _a;
2123
- const cmpMeta = {
2124
- $flags$: compactMeta[0],
2125
- $tagName$: compactMeta[1],
2126
- $members$: compactMeta[2],
2127
- $listeners$: compactMeta[3],
2128
- };
2129
- // Check if we are using slots outside the shadow DOM in this component.
2130
- // We'll use this information later to add styles for `slot-fb` elements
2131
- if (cmpMeta.$flags$ & 4 /* CMP_FLAGS.hasSlotRelocation */) {
2132
- hasSlotRelocation = true;
2133
- }
2134
- {
2135
- cmpMeta.$members$ = compactMeta[2];
2136
- }
2137
- {
2138
- cmpMeta.$listeners$ = compactMeta[3];
2139
- }
2140
- {
2141
- cmpMeta.$attrsToReflect$ = [];
2142
- }
2143
- {
2144
- cmpMeta.$watchers$ = (_a = compactMeta[4]) !== null && _a !== void 0 ? _a : {};
2145
- }
2146
- const tagName = cmpMeta.$tagName$;
2147
- const HostElement = class extends HTMLElement {
2148
- // StencilLazyHost
2149
- constructor(self) {
2150
- // @ts-ignore
2151
- super(self);
2152
- self = this;
2153
- registerHost(self, cmpMeta);
2154
- if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
2155
- // this component is using shadow dom
2156
- // and this browser supports shadow dom
2157
- // add the read-only property "shadowRoot" to the host element
2158
- // adding the shadow root build conditionals to minimize runtime
2159
- {
2160
- {
2161
- self.attachShadow({ mode: 'open' });
2162
- }
2163
- }
2164
- }
2165
- }
2166
- connectedCallback() {
2167
- if (appLoadFallback) {
2168
- clearTimeout(appLoadFallback);
2169
- appLoadFallback = null;
2170
- }
2171
- if (isBootstrapping) {
2172
- // connectedCallback will be processed once all components have been registered
2173
- deferredConnectedCallbacks.push(this);
2174
- }
2175
- else {
2176
- plt.jmp(() => connectedCallback(this));
2177
- }
2178
- }
2179
- disconnectedCallback() {
2180
- plt.jmp(() => disconnectedCallback(this));
2181
- }
2182
- componentOnReady() {
2183
- return getHostRef(this).$onReadyPromise$;
2184
- }
2185
- };
2186
- // if the component is formAssociated we need to set that on the host
2187
- // element so that it will be ready for `attachInternals` to be called on
2188
- // it later on
2189
- if (cmpMeta.$flags$ & 64 /* CMP_FLAGS.formAssociated */) {
2190
- HostElement.formAssociated = true;
2191
- }
2192
- cmpMeta.$lazyBundleId$ = lazyBundle[0];
2193
- if (!exclude.includes(tagName) && !customElements.get(tagName)) {
2194
- cmpTags.push(tagName);
2195
- customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */));
2196
- }
2197
- });
2198
- });
2199
- // Only bother generating CSS if we have components
2200
- // TODO(STENCIL-1118): Add test cases for CSS content based on conditionals
2201
- if (cmpTags.length > 0) {
2202
- // Add styles for `slot-fb` elements if any of our components are using slots outside the Shadow DOM
2203
- if (hasSlotRelocation) {
2204
- dataStyles.textContent += SLOT_FB_CSS;
2205
- }
2206
- // Add hydration styles
2207
- {
2208
- dataStyles.textContent += cmpTags + HYDRATED_CSS;
2209
- }
2210
- // If we have styles, add them to the DOM
2211
- if (dataStyles.innerHTML.length) {
2212
- dataStyles.setAttribute('data-styles', '');
2213
- // Apply CSP nonce to the style tag if it exists
2214
- const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
2215
- if (nonce != null) {
2216
- dataStyles.setAttribute('nonce', nonce);
2217
- }
2218
- // Insert the styles into the document head
2219
- // NOTE: this _needs_ to happen last so we can ensure the nonce (and other attributes) are applied
2220
- head.insertBefore(dataStyles, metaCharset ? metaCharset.nextSibling : head.firstChild);
2221
- }
2222
- }
2223
- // Process deferred connectedCallbacks now all components have been registered
2224
- isBootstrapping = false;
2225
- if (deferredConnectedCallbacks.length) {
2226
- deferredConnectedCallbacks.map((host) => host.connectedCallback());
2227
- }
2228
- else {
2229
- {
2230
- plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30)));
2231
- }
2232
- }
2233
- // Fallback appLoad event
2234
- endBootstrap();
2235
- };
2236
- const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
2237
- if (listeners) {
2238
- listeners.map(([flags, name, method]) => {
2239
- const target = getHostListenerTarget(elm, flags) ;
2240
- const handler = hostListenerProxy(hostRef, method);
2241
- const opts = hostListenerOpts(flags);
2242
- plt.ael(target, name, handler, opts);
2243
- (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
2244
- });
2245
- }
2246
- };
2247
- const hostListenerProxy = (hostRef, methodName) => (ev) => {
2248
- try {
2249
- {
2250
- if (hostRef.$flags$ & 256 /* HOST_FLAGS.isListenReady */) {
2251
- // instance is ready, let's call it's member method for this event
2252
- hostRef.$lazyInstance$[methodName](ev);
2253
- }
2254
- else {
2255
- (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
2256
- }
2257
- }
2258
- }
2259
- catch (e) {
2260
- consoleError(e);
2261
- }
2262
- };
2263
- const getHostListenerTarget = (elm, flags) => {
2264
- if (flags & 8 /* LISTENER_FLAGS.TargetWindow */)
2265
- return win;
2266
- return elm;
2267
- };
2268
- // prettier-ignore
2269
- const hostListenerOpts = (flags) => supportsListenerOptions
2270
- ? ({
2271
- passive: (flags & 1 /* LISTENER_FLAGS.Passive */) !== 0,
2272
- capture: (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0,
2273
- })
2274
- : (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0;
2275
- /**
2276
- * Assigns the given value to the nonce property on the runtime platform object.
2277
- * During runtime, this value is used to set the nonce attribute on all dynamically created script and style tags.
2278
- * @param nonce The value to be assigned to the platform nonce property.
2279
- * @returns void
2280
- */
2281
- const setNonce = (nonce) => (plt.$nonce$ = nonce);
2282
- /**
2283
- * A WeakMap mapping runtime component references to their corresponding host reference
2284
- * instances.
2285
- *
2286
- * **Note**: If we're in an HMR context we need to store a reference to this
2287
- * value on `window` in order to maintain the mapping of {@link d.RuntimeRef}
2288
- * to {@link d.HostRef} across HMR updates.
2289
- *
2290
- * This is necessary because when HMR updates for a component are processed by
2291
- * the browser-side dev server client the JS bundle for that component is
2292
- * re-fetched. Since the module containing {@link hostRefs} is included in
2293
- * that bundle, if we do not store a reference to it the new iteration of the
2294
- * component will not have access to the previous hostRef map, leading to a
2295
- * bug where the new version of the component cannot properly initialize.
2296
- */
2297
- const hostRefs = new WeakMap();
2298
- /**
2299
- * Given a {@link d.RuntimeRef} retrieve the corresponding {@link d.HostRef}
2300
- *
2301
- * @param ref the runtime ref of interest
2302
- * @returns the Host reference (if found) or undefined
2303
- */
2304
- const getHostRef = (ref) => hostRefs.get(ref);
2305
- /**
2306
- * Register a lazy instance with the {@link hostRefs} object so it's
2307
- * corresponding {@link d.HostRef} can be retrieved later.
2308
- *
2309
- * @param lazyInstance the lazy instance of interest
2310
- * @param hostRef that instances `HostRef` object
2311
- * @returns a reference to the host ref WeakMap
2312
- */
2313
- const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
2314
- /**
2315
- * Register a host element for a Stencil component, setting up various metadata
2316
- * and callbacks based on {@link BUILD} flags as well as the component's runtime
2317
- * metadata.
2318
- *
2319
- * @param hostElement the host element to register
2320
- * @param cmpMeta runtime metadata for that component
2321
- * @returns a reference to the host ref WeakMap
2322
- */
2323
- const registerHost = (hostElement, cmpMeta) => {
2324
- const hostRef = {
2325
- $flags$: 0,
2326
- $hostElement$: hostElement,
2327
- $cmpMeta$: cmpMeta,
2328
- $instanceValues$: new Map(),
2329
- };
2330
- {
2331
- hostRef.$onInstancePromise$ = new Promise((r) => (hostRef.$onInstanceResolve$ = r));
2332
- }
2333
- {
2334
- hostRef.$onReadyPromise$ = new Promise((r) => (hostRef.$onReadyResolve$ = r));
2335
- hostElement['s-p'] = [];
2336
- hostElement['s-rc'] = [];
2337
- }
2338
- addHostEventListeners(hostElement, hostRef, cmpMeta.$listeners$);
2339
- return hostRefs.set(hostElement, hostRef);
2340
- };
2341
- const isMemberInElement = (elm, memberName) => memberName in elm;
2342
- const consoleError = (e, el) => (0, console.error)(e, el);
2343
- const cmpModules = /*@__PURE__*/ new Map();
2344
- const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
2345
- // loadModuleImport
2346
- const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
2347
- const bundleId = cmpMeta.$lazyBundleId$;
2348
- const module = cmpModules.get(bundleId) ;
2349
- if (module) {
2350
- return module[exportName];
2351
- }
2352
- /*!__STENCIL_STATIC_IMPORT_SWITCH__*/
2353
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
2354
- /* @vite-ignore */
2355
- /* webpackInclude: /\.entry\.js$/ */
2356
- /* webpackExclude: /\.system\.entry\.js$/ */
2357
- /* webpackMode: "lazy" */
2358
- `./${bundleId}.entry.js${''}`)); }).then((importedModule) => {
2359
- {
2360
- cmpModules.set(bundleId, importedModule);
2361
- }
2362
- return importedModule[exportName];
2363
- }, consoleError);
2364
- };
2365
- const styles = /*@__PURE__*/ new Map();
2366
- const win = typeof window !== 'undefined' ? window : {};
2367
- const doc = win.document || { head: {} };
2368
- const plt = {
2369
- $flags$: 0,
2370
- $resourcesUrl$: '',
2371
- jmp: (h) => h(),
2372
- raf: (h) => requestAnimationFrame(h),
2373
- ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
2374
- rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
2375
- ce: (eventName, opts) => new CustomEvent(eventName, opts),
2376
- };
2377
- const supportsListenerOptions = /*@__PURE__*/ (() => {
2378
- let supportsListenerOptions = false;
2379
- try {
2380
- doc.addEventListener('e', null, Object.defineProperty({}, 'passive', {
2381
- get() {
2382
- supportsListenerOptions = true;
2383
- },
2384
- }));
2385
- }
2386
- catch (e) { }
2387
- return supportsListenerOptions;
2388
- })();
2389
- const promiseResolve = (v) => Promise.resolve(v);
2390
- const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
2391
- try {
2392
- new CSSStyleSheet();
2393
- return typeof new CSSStyleSheet().replaceSync === 'function';
2394
- }
2395
- catch (e) { }
2396
- return false;
2397
- })()
2398
- ;
2399
- const queueDomReads = [];
2400
- const queueDomWrites = [];
2401
- const queueTask = (queue, write) => (cb) => {
2402
- queue.push(cb);
2403
- if (!queuePending) {
2404
- queuePending = true;
2405
- if (write && plt.$flags$ & 4 /* PLATFORM_FLAGS.queueSync */) {
2406
- nextTick(flush);
2407
- }
2408
- else {
2409
- plt.raf(flush);
2410
- }
2411
- }
2412
- };
2413
- const consume = (queue) => {
2414
- for (let i = 0; i < queue.length; i++) {
2415
- try {
2416
- queue[i](performance.now());
2417
- }
2418
- catch (e) {
2419
- consoleError(e);
2420
- }
2421
- }
2422
- queue.length = 0;
2423
- };
2424
- const flush = () => {
2425
- // always force a bunch of medium callbacks to run, but still have
2426
- // a throttle on how many can run in a certain time
2427
- // DOM READS!!!
2428
- consume(queueDomReads);
2429
- // DOM WRITES!!!
2430
- {
2431
- consume(queueDomWrites);
2432
- if ((queuePending = queueDomReads.length > 0)) {
2433
- // still more to do yet, but we've run out of time
2434
- // let's let this thing cool off and try again in the next tick
2435
- plt.raf(flush);
2436
- }
2437
- }
2438
- };
2439
- const nextTick = (cb) => promiseResolve().then(cb);
2440
- const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
2441
-
2442
- exports.Host = Host;
2443
- exports.bootstrapLazy = bootstrapLazy;
2444
- exports.createEvent = createEvent;
2445
- exports.getElement = getElement;
2446
- exports.h = h;
2447
- exports.promiseResolve = promiseResolve;
2448
- exports.registerInstance = registerInstance;
2449
- exports.setNonce = setNonce;
2450
-
2451
- //# sourceMappingURL=index-674508e2.js.map