@ppg_pl/pallete 0.0.5 → 0.0.6

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 (169) hide show
  1. package/dist/cjs/index-160fcb6c.js +1661 -0
  2. package/dist/cjs/index-160fcb6c.js.map +1 -0
  3. package/dist/cjs/loader.cjs.js +3 -21
  4. package/dist/cjs/loader.cjs.js.map +1 -1
  5. package/dist/cjs/my-backdrop_8.cjs.entry.js +7985 -0
  6. package/dist/cjs/my-backdrop_8.cjs.entry.js.map +1 -0
  7. package/dist/cjs/pallete.cjs.js +5 -145
  8. package/dist/cjs/pallete.cjs.js.map +1 -1
  9. package/dist/collection/collection-manifest.json +1 -1
  10. package/dist/collection/components/my-modal/__mocks__/index.js +759 -0
  11. package/dist/collection/components/my-modal/__mocks__/index.js.map +1 -0
  12. package/dist/collection/components/my-modal/my-modal.css +74 -32
  13. package/dist/collection/components/my-modal/my-modal.js +1 -1
  14. package/dist/collection/components/my-modal/my-modal.js.map +1 -1
  15. package/dist/components/index.js +0 -4
  16. package/dist/components/index.js.map +1 -1
  17. package/dist/components/index2.js +359 -6270
  18. package/dist/components/index2.js.map +1 -1
  19. package/dist/components/my-component.js +0 -2
  20. package/dist/components/my-component.js.map +1 -1
  21. package/dist/components/my-modal2.js +3 -84
  22. package/dist/components/my-modal2.js.map +1 -1
  23. package/dist/esm/index-943c259f.js +1632 -0
  24. package/dist/esm/index-943c259f.js.map +1 -0
  25. package/dist/esm/loader.js +4 -22
  26. package/dist/esm/loader.js.map +1 -1
  27. package/dist/esm/my-backdrop_8.entry.js +7974 -0
  28. package/dist/esm/my-backdrop_8.entry.js.map +1 -0
  29. package/dist/esm/pallete.js +6 -146
  30. package/dist/esm/pallete.js.map +1 -1
  31. package/dist/pallete/index.esm.js +0 -1
  32. package/dist/pallete/index.esm.js.map +1 -1
  33. package/dist/pallete/p-9a7eff4f.entry.js +2 -0
  34. package/dist/pallete/p-9a7eff4f.entry.js.map +1 -0
  35. package/dist/pallete/p-c77aaa54.js +3 -0
  36. package/dist/pallete/p-c77aaa54.js.map +1 -0
  37. package/dist/pallete/pallete.css +1 -3
  38. package/dist/pallete/pallete.esm.js +1 -162
  39. package/dist/pallete/pallete.esm.js.map +1 -1
  40. package/dist/types/components/my-modal/__mocks__/index.d.ts +415 -0
  41. package/package.json +3 -3
  42. package/www/build/index.esm.js +0 -1
  43. package/www/build/index.esm.js.map +1 -1
  44. package/www/build/p-825a7d1d.js +163 -0
  45. package/www/build/p-9a7eff4f.entry.js +2 -0
  46. package/www/build/p-9a7eff4f.entry.js.map +1 -0
  47. package/www/build/p-c77aaa54.js +3 -0
  48. package/www/build/p-c77aaa54.js.map +1 -0
  49. package/www/build/p-fd390eef.css +3 -0
  50. package/www/build/pallete.css +1 -3
  51. package/www/build/pallete.esm.js +1 -162
  52. package/www/build/pallete.esm.js.map +1 -1
  53. package/www/index.html +2 -11
  54. package/dist/cjs/app-globals-3a1e7e63.js +0 -7
  55. package/dist/cjs/app-globals-3a1e7e63.js.map +0 -1
  56. package/dist/cjs/css-shim-5d56550a.js +0 -8
  57. package/dist/cjs/css-shim-5d56550a.js.map +0 -1
  58. package/dist/cjs/dom-52c0133a.js +0 -77
  59. package/dist/cjs/dom-52c0133a.js.map +0 -1
  60. package/dist/cjs/gtmUtils-11a00b2b.js +0 -9
  61. package/dist/cjs/gtmUtils-11a00b2b.js.map +0 -1
  62. package/dist/cjs/index-a230bf6e.js +0 -3434
  63. package/dist/cjs/index-a230bf6e.js.map +0 -1
  64. package/dist/cjs/my-backdrop.cjs.entry.js +0 -21
  65. package/dist/cjs/my-backdrop.cjs.entry.js.map +0 -1
  66. package/dist/cjs/my-colorbox.cjs.entry.js +0 -52
  67. package/dist/cjs/my-colorbox.cjs.entry.js.map +0 -1
  68. package/dist/cjs/my-colorinfo.cjs.entry.js +0 -46
  69. package/dist/cjs/my-colorinfo.cjs.entry.js.map +0 -1
  70. package/dist/cjs/my-component.cjs.entry.js +0 -171
  71. package/dist/cjs/my-component.cjs.entry.js.map +0 -1
  72. package/dist/cjs/my-loader.cjs.entry.js +0 -21
  73. package/dist/cjs/my-loader.cjs.entry.js.map +0 -1
  74. package/dist/cjs/my-modal.cjs.entry.js +0 -2479
  75. package/dist/cjs/my-modal.cjs.entry.js.map +0 -1
  76. package/dist/cjs/my-search.cjs.entry.js +0 -44
  77. package/dist/cjs/my-search.cjs.entry.js.map +0 -1
  78. package/dist/cjs/my-slider.cjs.entry.js +0 -11201
  79. package/dist/cjs/my-slider.cjs.entry.js.map +0 -1
  80. package/dist/cjs/shadow-css-388a8a25.js +0 -391
  81. package/dist/cjs/shadow-css-388a8a25.js.map +0 -1
  82. package/dist/esm/app-globals-0f993ce5.js +0 -5
  83. package/dist/esm/app-globals-0f993ce5.js.map +0 -1
  84. package/dist/esm/css-shim-5eb36939.js +0 -6
  85. package/dist/esm/css-shim-5eb36939.js.map +0 -1
  86. package/dist/esm/dom-c0f8af80.js +0 -75
  87. package/dist/esm/dom-c0f8af80.js.map +0 -1
  88. package/dist/esm/gtmUtils-dcdac4ce.js +0 -7
  89. package/dist/esm/gtmUtils-dcdac4ce.js.map +0 -1
  90. package/dist/esm/index-c3dfdbab.js +0 -3397
  91. package/dist/esm/index-c3dfdbab.js.map +0 -1
  92. package/dist/esm/my-backdrop.entry.js +0 -17
  93. package/dist/esm/my-backdrop.entry.js.map +0 -1
  94. package/dist/esm/my-colorbox.entry.js +0 -48
  95. package/dist/esm/my-colorbox.entry.js.map +0 -1
  96. package/dist/esm/my-colorinfo.entry.js +0 -42
  97. package/dist/esm/my-colorinfo.entry.js.map +0 -1
  98. package/dist/esm/my-component.entry.js +0 -167
  99. package/dist/esm/my-component.entry.js.map +0 -1
  100. package/dist/esm/my-loader.entry.js +0 -17
  101. package/dist/esm/my-loader.entry.js.map +0 -1
  102. package/dist/esm/my-modal.entry.js +0 -2475
  103. package/dist/esm/my-modal.entry.js.map +0 -1
  104. package/dist/esm/my-search.entry.js +0 -40
  105. package/dist/esm/my-search.entry.js.map +0 -1
  106. package/dist/esm/my-slider.entry.js +0 -11197
  107. package/dist/esm/my-slider.entry.js.map +0 -1
  108. package/dist/esm/shadow-css-12b9a099.js +0 -389
  109. package/dist/esm/shadow-css-12b9a099.js.map +0 -1
  110. package/dist/pallete/app-globals-0f993ce5.js +0 -5
  111. package/dist/pallete/app-globals-0f993ce5.js.map +0 -1
  112. package/dist/pallete/css-shim-5eb36939.js +0 -6
  113. package/dist/pallete/css-shim-5eb36939.js.map +0 -1
  114. package/dist/pallete/dom-c0f8af80.js +0 -75
  115. package/dist/pallete/dom-c0f8af80.js.map +0 -1
  116. package/dist/pallete/gtmUtils-dcdac4ce.js +0 -7
  117. package/dist/pallete/gtmUtils-dcdac4ce.js.map +0 -1
  118. package/dist/pallete/index-591def6b.js +0 -3397
  119. package/dist/pallete/index-591def6b.js.map +0 -1
  120. package/dist/pallete/index-c3dfdbab.js +0 -3397
  121. package/dist/pallete/index-c3dfdbab.js.map +0 -1
  122. package/dist/pallete/my-backdrop.entry.js +0 -17
  123. package/dist/pallete/my-backdrop.entry.js.map +0 -1
  124. package/dist/pallete/my-colorbox.entry.js +0 -48
  125. package/dist/pallete/my-colorbox.entry.js.map +0 -1
  126. package/dist/pallete/my-colorinfo.entry.js +0 -42
  127. package/dist/pallete/my-colorinfo.entry.js.map +0 -1
  128. package/dist/pallete/my-component.entry.js +0 -167
  129. package/dist/pallete/my-component.entry.js.map +0 -1
  130. package/dist/pallete/my-loader.entry.js +0 -17
  131. package/dist/pallete/my-loader.entry.js.map +0 -1
  132. package/dist/pallete/my-modal.entry.js +0 -2475
  133. package/dist/pallete/my-modal.entry.js.map +0 -1
  134. package/dist/pallete/my-search.entry.js +0 -40
  135. package/dist/pallete/my-search.entry.js.map +0 -1
  136. package/dist/pallete/my-slider.entry.js +0 -11197
  137. package/dist/pallete/my-slider.entry.js.map +0 -1
  138. package/dist/pallete/shadow-css-12b9a099.js +0 -389
  139. package/dist/pallete/shadow-css-12b9a099.js.map +0 -1
  140. package/www/build/app-globals-0f993ce5.js +0 -5
  141. package/www/build/app-globals-0f993ce5.js.map +0 -1
  142. package/www/build/css-shim-5eb36939.js +0 -6
  143. package/www/build/css-shim-5eb36939.js.map +0 -1
  144. package/www/build/dom-c0f8af80.js +0 -75
  145. package/www/build/dom-c0f8af80.js.map +0 -1
  146. package/www/build/gtmUtils-dcdac4ce.js +0 -7
  147. package/www/build/gtmUtils-dcdac4ce.js.map +0 -1
  148. package/www/build/index-591def6b.js +0 -3397
  149. package/www/build/index-591def6b.js.map +0 -1
  150. package/www/build/index-c3dfdbab.js +0 -3397
  151. package/www/build/index-c3dfdbab.js.map +0 -1
  152. package/www/build/my-backdrop.entry.js +0 -17
  153. package/www/build/my-backdrop.entry.js.map +0 -1
  154. package/www/build/my-colorbox.entry.js +0 -48
  155. package/www/build/my-colorbox.entry.js.map +0 -1
  156. package/www/build/my-colorinfo.entry.js +0 -42
  157. package/www/build/my-colorinfo.entry.js.map +0 -1
  158. package/www/build/my-component.entry.js +0 -167
  159. package/www/build/my-component.entry.js.map +0 -1
  160. package/www/build/my-loader.entry.js +0 -17
  161. package/www/build/my-loader.entry.js.map +0 -1
  162. package/www/build/my-modal.entry.js +0 -2475
  163. package/www/build/my-modal.entry.js.map +0 -1
  164. package/www/build/my-search.entry.js +0 -40
  165. package/www/build/my-search.entry.js.map +0 -1
  166. package/www/build/my-slider.entry.js +0 -11197
  167. package/www/build/my-slider.entry.js.map +0 -1
  168. package/www/build/shadow-css-12b9a099.js +0 -389
  169. package/www/build/shadow-css-12b9a099.js.map +0 -1
@@ -0,0 +1,1661 @@
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 = 'pallete';
24
+
25
+ /**
26
+ * Virtual DOM patching algorithm based on Snabbdom by
27
+ * Simon Friis Vindum (@paldepind)
28
+ * Licensed under the MIT License
29
+ * https://github.com/snabbdom/snabbdom/blob/master/LICENSE
30
+ *
31
+ * Modified for Stencil's renderer and slot projection
32
+ */
33
+ let scopeId;
34
+ let isSvgMode = false;
35
+ let queuePending = false;
36
+ const getAssetPath = (path) => {
37
+ const assetUrl = new URL(path, plt.$resourcesUrl$);
38
+ return assetUrl.origin !== win.location.origin ? assetUrl.href : assetUrl.pathname;
39
+ };
40
+ const createTime = (fnName, tagName = '') => {
41
+ {
42
+ return () => {
43
+ return;
44
+ };
45
+ }
46
+ };
47
+ const uniqueTime = (key, measureText) => {
48
+ {
49
+ return () => {
50
+ return;
51
+ };
52
+ }
53
+ };
54
+ const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
55
+ /**
56
+ * Default style mode id
57
+ */
58
+ /**
59
+ * Reusable empty obj/array
60
+ * Don't add values to these!!
61
+ */
62
+ const EMPTY_OBJ = {};
63
+ const isDef = (v) => v != null;
64
+ /**
65
+ * Check whether a value is a 'complex type', defined here as an object or a
66
+ * function.
67
+ *
68
+ * @param o the value to check
69
+ * @returns whether it's a complex type or not
70
+ */
71
+ const isComplexType = (o) => {
72
+ // https://jsperf.com/typeof-fn-object/5
73
+ o = typeof o;
74
+ return o === 'object' || o === 'function';
75
+ };
76
+ /**
77
+ * Helper method for querying a `meta` tag that contains a nonce value
78
+ * out of a DOM's head.
79
+ *
80
+ * @param doc The DOM containing the `head` to query against
81
+ * @returns The content of the meta tag representing the nonce value, or `undefined` if no tag
82
+ * exists or the tag has no content.
83
+ */
84
+ function queryNonceMetaTagContent(doc) {
85
+ var _a, _b, _c;
86
+ 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;
87
+ }
88
+ /**
89
+ * Production h() function based on Preact by
90
+ * Jason Miller (@developit)
91
+ * Licensed under the MIT License
92
+ * https://github.com/developit/preact/blob/master/LICENSE
93
+ *
94
+ * Modified for Stencil's compiler and vdom
95
+ */
96
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
97
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
98
+ const h = (nodeName, vnodeData, ...children) => {
99
+ let child = null;
100
+ let key = null;
101
+ let simple = false;
102
+ let lastSimple = false;
103
+ const vNodeChildren = [];
104
+ const walk = (c) => {
105
+ for (let i = 0; i < c.length; i++) {
106
+ child = c[i];
107
+ if (Array.isArray(child)) {
108
+ walk(child);
109
+ }
110
+ else if (child != null && typeof child !== 'boolean') {
111
+ if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
112
+ child = String(child);
113
+ }
114
+ if (simple && lastSimple) {
115
+ // If the previous child was simple (string), we merge both
116
+ vNodeChildren[vNodeChildren.length - 1].$text$ += child;
117
+ }
118
+ else {
119
+ // Append a new vNode, if it's text, we create a text vNode
120
+ vNodeChildren.push(simple ? newVNode(null, child) : child);
121
+ }
122
+ lastSimple = simple;
123
+ }
124
+ }
125
+ };
126
+ walk(children);
127
+ if (vnodeData) {
128
+ // normalize class / classname attributes
129
+ if (vnodeData.key) {
130
+ key = vnodeData.key;
131
+ }
132
+ {
133
+ const classData = vnodeData.className || vnodeData.class;
134
+ if (classData) {
135
+ vnodeData.class =
136
+ typeof classData !== 'object'
137
+ ? classData
138
+ : Object.keys(classData)
139
+ .filter((k) => classData[k])
140
+ .join(' ');
141
+ }
142
+ }
143
+ }
144
+ if (typeof nodeName === 'function') {
145
+ // nodeName is a functional component
146
+ return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
147
+ }
148
+ const vnode = newVNode(nodeName, null);
149
+ vnode.$attrs$ = vnodeData;
150
+ if (vNodeChildren.length > 0) {
151
+ vnode.$children$ = vNodeChildren;
152
+ }
153
+ {
154
+ vnode.$key$ = key;
155
+ }
156
+ return vnode;
157
+ };
158
+ /**
159
+ * A utility function for creating a virtual DOM node from a tag and some
160
+ * possible text content.
161
+ *
162
+ * @param tag the tag for this element
163
+ * @param text possible text content for the node
164
+ * @returns a newly-minted virtual DOM node
165
+ */
166
+ const newVNode = (tag, text) => {
167
+ const vnode = {
168
+ $flags$: 0,
169
+ $tag$: tag,
170
+ $text$: text,
171
+ $elm$: null,
172
+ $children$: null,
173
+ };
174
+ {
175
+ vnode.$attrs$ = null;
176
+ }
177
+ {
178
+ vnode.$key$ = null;
179
+ }
180
+ return vnode;
181
+ };
182
+ const Host = {};
183
+ /**
184
+ * Check whether a given node is a Host node or not
185
+ *
186
+ * @param node the virtual DOM node to check
187
+ * @returns whether it's a Host node or not
188
+ */
189
+ const isHost = (node) => node && node.$tag$ === Host;
190
+ /**
191
+ * Implementation of {@link d.FunctionalUtilities} for Stencil's VDom.
192
+ *
193
+ * Note that these functions convert from {@link d.VNode} to
194
+ * {@link d.ChildNode} to give functional component developers a friendly
195
+ * interface.
196
+ */
197
+ const vdomFnUtils = {
198
+ forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
199
+ map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate),
200
+ };
201
+ /**
202
+ * Convert a {@link d.VNode} to a {@link d.ChildNode} in order to present a
203
+ * friendlier public interface (hence, 'convertToPublic').
204
+ *
205
+ * @param node the virtual DOM node to convert
206
+ * @returns a converted child node
207
+ */
208
+ const convertToPublic = (node) => ({
209
+ vattrs: node.$attrs$,
210
+ vchildren: node.$children$,
211
+ vkey: node.$key$,
212
+ vname: node.$name$,
213
+ vtag: node.$tag$,
214
+ vtext: node.$text$,
215
+ });
216
+ /**
217
+ * Convert a {@link d.ChildNode} back to an equivalent {@link d.VNode} in
218
+ * order to use the resulting object in the virtual DOM. The initial object was
219
+ * likely created as part of presenting a public API, so converting it back
220
+ * involved making it 'private' again (hence, `convertToPrivate`).
221
+ *
222
+ * @param node the child node to convert
223
+ * @returns a converted virtual DOM node
224
+ */
225
+ const convertToPrivate = (node) => {
226
+ if (typeof node.vtag === 'function') {
227
+ const vnodeData = Object.assign({}, node.vattrs);
228
+ if (node.vkey) {
229
+ vnodeData.key = node.vkey;
230
+ }
231
+ if (node.vname) {
232
+ vnodeData.name = node.vname;
233
+ }
234
+ return h(node.vtag, vnodeData, ...(node.vchildren || []));
235
+ }
236
+ const vnode = newVNode(node.vtag, node.vtext);
237
+ vnode.$attrs$ = node.vattrs;
238
+ vnode.$children$ = node.vchildren;
239
+ vnode.$key$ = node.vkey;
240
+ vnode.$name$ = node.vname;
241
+ return vnode;
242
+ };
243
+ /**
244
+ * Parse a new property value for a given property type.
245
+ *
246
+ * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
247
+ * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
248
+ * 1. `any`, the type given to `propValue` in the function signature
249
+ * 2. the type stored from `propType`.
250
+ *
251
+ * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
252
+ *
253
+ * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
254
+ * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
255
+ * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
256
+ * ```tsx
257
+ * <my-cmp prop-val={0}></my-cmp>
258
+ * ```
259
+ *
260
+ * HTML prop values on the other hand, will always a string
261
+ *
262
+ * @param propValue the new value to coerce to some type
263
+ * @param propType the type of the prop, expressed as a binary number
264
+ * @returns the parsed/coerced value
265
+ */
266
+ const parsePropertyValue = (propValue, propType) => {
267
+ // ensure this value is of the correct prop type
268
+ if (propValue != null && !isComplexType(propValue)) {
269
+ if (propType & 4 /* MEMBER_FLAGS.Boolean */) {
270
+ // per the HTML spec, any string value means it is a boolean true value
271
+ // but we'll cheat here and say that the string "false" is the boolean false
272
+ return propValue === 'false' ? false : propValue === '' || !!propValue;
273
+ }
274
+ if (propType & 2 /* MEMBER_FLAGS.Number */) {
275
+ // force it to be a number
276
+ return parseFloat(propValue);
277
+ }
278
+ if (propType & 1 /* MEMBER_FLAGS.String */) {
279
+ // could have been passed as a number or boolean
280
+ // but we still want it as a string
281
+ return String(propValue);
282
+ }
283
+ // redundant return here for better minification
284
+ return propValue;
285
+ }
286
+ // not sure exactly what type we want
287
+ // so no need to change to a different type
288
+ return propValue;
289
+ };
290
+ const getElement = (ref) => (getHostRef(ref).$hostElement$ );
291
+ const createEvent = (ref, name, flags) => {
292
+ const elm = getElement(ref);
293
+ return {
294
+ emit: (detail) => {
295
+ return emitEvent(elm, name, {
296
+ bubbles: !!(flags & 4 /* EVENT_FLAGS.Bubbles */),
297
+ composed: !!(flags & 2 /* EVENT_FLAGS.Composed */),
298
+ cancelable: !!(flags & 1 /* EVENT_FLAGS.Cancellable */),
299
+ detail,
300
+ });
301
+ },
302
+ };
303
+ };
304
+ /**
305
+ * Helper function to create & dispatch a custom Event on a provided target
306
+ * @param elm the target of the Event
307
+ * @param name the name to give the custom Event
308
+ * @param opts options for configuring a custom Event
309
+ * @returns the custom Event
310
+ */
311
+ const emitEvent = (elm, name, opts) => {
312
+ const ev = plt.ce(name, opts);
313
+ elm.dispatchEvent(ev);
314
+ return ev;
315
+ };
316
+ const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
317
+ const registerStyle = (scopeId, cssText, allowCS) => {
318
+ let style = styles.get(scopeId);
319
+ if (supportsConstructableStylesheets && allowCS) {
320
+ style = (style || new CSSStyleSheet());
321
+ if (typeof style === 'string') {
322
+ style = cssText;
323
+ }
324
+ else {
325
+ style.replaceSync(cssText);
326
+ }
327
+ }
328
+ else {
329
+ style = cssText;
330
+ }
331
+ styles.set(scopeId, style);
332
+ };
333
+ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
334
+ var _a;
335
+ let scopeId = getScopeId(cmpMeta);
336
+ const style = styles.get(scopeId);
337
+ // if an element is NOT connected then getRootNode() will return the wrong root node
338
+ // so the fallback is to always use the document for the root node in those cases
339
+ styleContainerNode = styleContainerNode.nodeType === 11 /* NODE_TYPE.DocumentFragment */ ? styleContainerNode : doc;
340
+ if (style) {
341
+ if (typeof style === 'string') {
342
+ styleContainerNode = styleContainerNode.head || styleContainerNode;
343
+ let appliedStyles = rootAppliedStyles.get(styleContainerNode);
344
+ let styleElm;
345
+ if (!appliedStyles) {
346
+ rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
347
+ }
348
+ if (!appliedStyles.has(scopeId)) {
349
+ {
350
+ // TODO(STENCIL-659): Remove code implementing the CSS variable shim
351
+ {
352
+ styleElm = doc.createElement('style');
353
+ styleElm.innerHTML = style;
354
+ }
355
+ // Apply CSP nonce to the style tag if it exists
356
+ const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
357
+ if (nonce != null) {
358
+ styleElm.setAttribute('nonce', nonce);
359
+ }
360
+ styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
361
+ }
362
+ if (appliedStyles) {
363
+ appliedStyles.add(scopeId);
364
+ }
365
+ }
366
+ }
367
+ else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
368
+ styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
369
+ }
370
+ }
371
+ return scopeId;
372
+ };
373
+ const attachStyles = (hostRef) => {
374
+ const cmpMeta = hostRef.$cmpMeta$;
375
+ const elm = hostRef.$hostElement$;
376
+ const flags = cmpMeta.$flags$;
377
+ const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
378
+ const scopeId = addStyle(elm.getRootNode(), cmpMeta);
379
+ // TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
380
+ if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
381
+ // only required when we're NOT using native shadow dom (slot)
382
+ // or this browser doesn't support native shadow dom
383
+ // and this host element was NOT created with SSR
384
+ // let's pick out the inner content for slot projection
385
+ // create a node to represent where the original
386
+ // content was first placed, which is useful later on
387
+ // DOM WRITE!!
388
+ elm['s-sc'] = scopeId;
389
+ elm.classList.add(scopeId + '-h');
390
+ if (flags & 2 /* CMP_FLAGS.scopedCssEncapsulation */) {
391
+ elm.classList.add(scopeId + '-s');
392
+ }
393
+ }
394
+ endAttachStyles();
395
+ };
396
+ const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
397
+ /**
398
+ * Production setAccessor() function based on Preact by
399
+ * Jason Miller (@developit)
400
+ * Licensed under the MIT License
401
+ * https://github.com/developit/preact/blob/master/LICENSE
402
+ *
403
+ * Modified for Stencil's compiler and vdom
404
+ */
405
+ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
406
+ if (oldValue !== newValue) {
407
+ let isProp = isMemberInElement(elm, memberName);
408
+ let ln = memberName.toLowerCase();
409
+ if (memberName === 'class') {
410
+ const classList = elm.classList;
411
+ const oldClasses = parseClassList(oldValue);
412
+ const newClasses = parseClassList(newValue);
413
+ classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
414
+ classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
415
+ }
416
+ else if (memberName === 'style') {
417
+ // update style attribute, css properties and values
418
+ {
419
+ for (const prop in oldValue) {
420
+ if (!newValue || newValue[prop] == null) {
421
+ if (prop.includes('-')) {
422
+ elm.style.removeProperty(prop);
423
+ }
424
+ else {
425
+ elm.style[prop] = '';
426
+ }
427
+ }
428
+ }
429
+ }
430
+ for (const prop in newValue) {
431
+ if (!oldValue || newValue[prop] !== oldValue[prop]) {
432
+ if (prop.includes('-')) {
433
+ elm.style.setProperty(prop, newValue[prop]);
434
+ }
435
+ else {
436
+ elm.style[prop] = newValue[prop];
437
+ }
438
+ }
439
+ }
440
+ }
441
+ else if (memberName === 'key')
442
+ ;
443
+ else if ((!isProp ) &&
444
+ memberName[0] === 'o' &&
445
+ memberName[1] === 'n') {
446
+ // Event Handlers
447
+ // so if the member name starts with "on" and the 3rd characters is
448
+ // a capital letter, and it's not already a member on the element,
449
+ // then we're assuming it's an event listener
450
+ if (memberName[2] === '-') {
451
+ // on- prefixed events
452
+ // allows to be explicit about the dom event to listen without any magic
453
+ // under the hood:
454
+ // <my-cmp on-click> // listens for "click"
455
+ // <my-cmp on-Click> // listens for "Click"
456
+ // <my-cmp on-ionChange> // listens for "ionChange"
457
+ // <my-cmp on-EVENTS> // listens for "EVENTS"
458
+ memberName = memberName.slice(3);
459
+ }
460
+ else if (isMemberInElement(win, ln)) {
461
+ // standard event
462
+ // the JSX attribute could have been "onMouseOver" and the
463
+ // member name "onmouseover" is on the window's prototype
464
+ // so let's add the listener "mouseover", which is all lowercased
465
+ memberName = ln.slice(2);
466
+ }
467
+ else {
468
+ // custom event
469
+ // the JSX attribute could have been "onMyCustomEvent"
470
+ // so let's trim off the "on" prefix and lowercase the first character
471
+ // and add the listener "myCustomEvent"
472
+ // except for the first character, we keep the event name case
473
+ memberName = ln[2] + memberName.slice(3);
474
+ }
475
+ if (oldValue) {
476
+ plt.rel(elm, memberName, oldValue, false);
477
+ }
478
+ if (newValue) {
479
+ plt.ael(elm, memberName, newValue, false);
480
+ }
481
+ }
482
+ else {
483
+ // Set property if it exists and it's not a SVG
484
+ const isComplex = isComplexType(newValue);
485
+ if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
486
+ try {
487
+ if (!elm.tagName.includes('-')) {
488
+ const n = newValue == null ? '' : newValue;
489
+ // Workaround for Safari, moving the <input> caret when re-assigning the same valued
490
+ if (memberName === 'list') {
491
+ isProp = false;
492
+ }
493
+ else if (oldValue == null || elm[memberName] != n) {
494
+ elm[memberName] = n;
495
+ }
496
+ }
497
+ else {
498
+ elm[memberName] = newValue;
499
+ }
500
+ }
501
+ catch (e) { }
502
+ }
503
+ if (newValue == null || newValue === false) {
504
+ if (newValue !== false || elm.getAttribute(memberName) === '') {
505
+ {
506
+ elm.removeAttribute(memberName);
507
+ }
508
+ }
509
+ }
510
+ else if ((!isProp || flags & 4 /* VNODE_FLAGS.isHost */ || isSvg) && !isComplex) {
511
+ newValue = newValue === true ? '' : newValue;
512
+ {
513
+ elm.setAttribute(memberName, newValue);
514
+ }
515
+ }
516
+ }
517
+ }
518
+ };
519
+ const parseClassListRegex = /\s/;
520
+ const parseClassList = (value) => (!value ? [] : value.split(parseClassListRegex));
521
+ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
522
+ // if the element passed in is a shadow root, which is a document fragment
523
+ // then we want to be adding attrs/props to the shadow root's "host" element
524
+ // if it's not a shadow root, then we add attrs/props to the same element
525
+ const elm = newVnode.$elm$.nodeType === 11 /* NODE_TYPE.DocumentFragment */ && newVnode.$elm$.host
526
+ ? newVnode.$elm$.host
527
+ : newVnode.$elm$;
528
+ const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
529
+ const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
530
+ {
531
+ // remove attributes no longer present on the vnode by setting them to undefined
532
+ for (memberName in oldVnodeAttrs) {
533
+ if (!(memberName in newVnodeAttrs)) {
534
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], undefined, isSvgMode, newVnode.$flags$);
535
+ }
536
+ }
537
+ }
538
+ // add new & update changed attributes
539
+ for (memberName in newVnodeAttrs) {
540
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
541
+ }
542
+ };
543
+ /**
544
+ * Create a DOM Node corresponding to one of the children of a given VNode.
545
+ *
546
+ * @param oldParentVNode the parent VNode from the previous render
547
+ * @param newParentVNode the parent VNode from the current render
548
+ * @param childIndex the index of the VNode, in the _new_ parent node's
549
+ * children, for which we will create a new DOM node
550
+ * @param parentElm the parent DOM node which our new node will be a child of
551
+ * @returns the newly created node
552
+ */
553
+ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
554
+ // tslint:disable-next-line: prefer-const
555
+ const newVNode = newParentVNode.$children$[childIndex];
556
+ let i = 0;
557
+ let elm;
558
+ let childNode;
559
+ if (newVNode.$text$ !== null) {
560
+ // create text node
561
+ elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
562
+ }
563
+ else {
564
+ // create element
565
+ elm = newVNode.$elm$ = (doc.createElement(newVNode.$tag$));
566
+ // add css classes, attrs, props, listeners, etc.
567
+ {
568
+ updateElement(null, newVNode, isSvgMode);
569
+ }
570
+ if (isDef(scopeId) && elm['s-si'] !== scopeId) {
571
+ // if there is a scopeId and this is the initial render
572
+ // then let's add the scopeId as a css class
573
+ elm.classList.add((elm['s-si'] = scopeId));
574
+ }
575
+ if (newVNode.$children$) {
576
+ for (i = 0; i < newVNode.$children$.length; ++i) {
577
+ // create the node
578
+ childNode = createElm(oldParentVNode, newVNode, i);
579
+ // return node could have been null
580
+ if (childNode) {
581
+ // append our new node
582
+ elm.appendChild(childNode);
583
+ }
584
+ }
585
+ }
586
+ }
587
+ return elm;
588
+ };
589
+ /**
590
+ * Create DOM nodes corresponding to a list of {@link d.Vnode} objects and
591
+ * add them to the DOM in the appropriate place.
592
+ *
593
+ * @param parentElm the DOM node which should be used as a parent for the new
594
+ * DOM nodes
595
+ * @param before a child of the `parentElm` which the new children should be
596
+ * inserted before (optional)
597
+ * @param parentVNode the parent virtual DOM node
598
+ * @param vnodes the new child virtual DOM nodes to produce DOM nodes for
599
+ * @param startIdx the index in the child virtual DOM nodes at which to start
600
+ * creating DOM nodes (inclusive)
601
+ * @param endIdx the index in the child virtual DOM nodes at which to stop
602
+ * creating DOM nodes (inclusive)
603
+ */
604
+ const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
605
+ let containerElm = (parentElm);
606
+ let childNode;
607
+ for (; startIdx <= endIdx; ++startIdx) {
608
+ if (vnodes[startIdx]) {
609
+ childNode = createElm(null, parentVNode, startIdx);
610
+ if (childNode) {
611
+ vnodes[startIdx].$elm$ = childNode;
612
+ containerElm.insertBefore(childNode, before);
613
+ }
614
+ }
615
+ }
616
+ };
617
+ /**
618
+ * Remove the DOM elements corresponding to a list of {@link d.VNode} objects.
619
+ * This can be used to, for instance, clean up after a list of children which
620
+ * should no longer be shown.
621
+ *
622
+ * This function also handles some of Stencil's slot relocation logic.
623
+ *
624
+ * @param vnodes a list of virtual DOM nodes to remove
625
+ * @param startIdx the index at which to start removing nodes (inclusive)
626
+ * @param endIdx the index at which to stop removing nodes (inclusive)
627
+ * @param vnode a VNode
628
+ * @param elm an element
629
+ */
630
+ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
631
+ for (; startIdx <= endIdx; ++startIdx) {
632
+ if ((vnode = vnodes[startIdx])) {
633
+ elm = vnode.$elm$;
634
+ // remove the vnode's element from the dom
635
+ elm.remove();
636
+ }
637
+ }
638
+ };
639
+ /**
640
+ * Reconcile the children of a new VNode with the children of an old VNode by
641
+ * traversing the two collections of children, identifying nodes that are
642
+ * conserved or changed, calling out to `patch` to make any necessary
643
+ * updates to the DOM, and rearranging DOM nodes as needed.
644
+ *
645
+ * The algorithm for reconciling children works by analyzing two 'windows' onto
646
+ * the two arrays of children (`oldCh` and `newCh`). We keep track of the
647
+ * 'windows' by storing start and end indices and references to the
648
+ * corresponding array entries. Initially the two 'windows' are basically equal
649
+ * to the entire array, but we progressively narrow the windows until there are
650
+ * no children left to update by doing the following:
651
+ *
652
+ * 1. Skip any `null` entries at the beginning or end of the two arrays, so
653
+ * that if we have an initial array like the following we'll end up dealing
654
+ * only with a window bounded by the highlighted elements:
655
+ *
656
+ * [null, null, VNode1 , ... , VNode2, null, null]
657
+ * ^^^^^^ ^^^^^^
658
+ *
659
+ * 2. Check to see if the elements at the head and tail positions are equal
660
+ * across the windows. This will basically detect elements which haven't
661
+ * been added, removed, or changed position, i.e. if you had the following
662
+ * VNode elements (represented as HTML):
663
+ *
664
+ * oldVNode: `<div><p><span>HEY</span></p></div>`
665
+ * newVNode: `<div><p><span>THERE</span></p></div>`
666
+ *
667
+ * Then when comparing the children of the `<div>` tag we check the equality
668
+ * of the VNodes corresponding to the `<p>` tags and, since they are the
669
+ * same tag in the same position, we'd be able to avoid completely
670
+ * re-rendering the subtree under them with a new DOM element and would just
671
+ * call out to `patch` to handle reconciling their children and so on.
672
+ *
673
+ * 3. Check, for both windows, to see if the element at the beginning of the
674
+ * window corresponds to the element at the end of the other window. This is
675
+ * a heuristic which will let us identify _some_ situations in which
676
+ * elements have changed position, for instance it _should_ detect that the
677
+ * children nodes themselves have not changed but merely moved in the
678
+ * following example:
679
+ *
680
+ * oldVNode: `<div><element-one /><element-two /></div>`
681
+ * newVNode: `<div><element-two /><element-one /></div>`
682
+ *
683
+ * If we find cases like this then we also need to move the concrete DOM
684
+ * elements corresponding to the moved children to write the re-order to the
685
+ * DOM.
686
+ *
687
+ * 4. Finally, if VNodes have the `key` attribute set on them we check for any
688
+ * nodes in the old children which have the same key as the first element in
689
+ * our window on the new children. If we find such a node we handle calling
690
+ * out to `patch`, moving relevant DOM nodes, and so on, in accordance with
691
+ * what we find.
692
+ *
693
+ * Finally, once we've narrowed our 'windows' to the point that either of them
694
+ * collapse (i.e. they have length 0) we then handle any remaining VNode
695
+ * insertion or deletion that needs to happen to get a DOM state that correctly
696
+ * reflects the new child VNodes. If, for instance, after our window on the old
697
+ * children has collapsed we still have more nodes on the new children that
698
+ * we haven't dealt with yet then we need to add them, or if the new children
699
+ * collapse but we still have unhandled _old_ children then we need to make
700
+ * sure the corresponding DOM nodes are removed.
701
+ *
702
+ * @param parentElm the node into which the parent VNode is rendered
703
+ * @param oldCh the old children of the parent node
704
+ * @param newVNode the new VNode which will replace the parent
705
+ * @param newCh the new children of the parent node
706
+ */
707
+ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
708
+ let oldStartIdx = 0;
709
+ let newStartIdx = 0;
710
+ let idxInOld = 0;
711
+ let i = 0;
712
+ let oldEndIdx = oldCh.length - 1;
713
+ let oldStartVnode = oldCh[0];
714
+ let oldEndVnode = oldCh[oldEndIdx];
715
+ let newEndIdx = newCh.length - 1;
716
+ let newStartVnode = newCh[0];
717
+ let newEndVnode = newCh[newEndIdx];
718
+ let node;
719
+ let elmToMove;
720
+ while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
721
+ if (oldStartVnode == null) {
722
+ // VNode might have been moved left
723
+ oldStartVnode = oldCh[++oldStartIdx];
724
+ }
725
+ else if (oldEndVnode == null) {
726
+ oldEndVnode = oldCh[--oldEndIdx];
727
+ }
728
+ else if (newStartVnode == null) {
729
+ newStartVnode = newCh[++newStartIdx];
730
+ }
731
+ else if (newEndVnode == null) {
732
+ newEndVnode = newCh[--newEndIdx];
733
+ }
734
+ else if (isSameVnode(oldStartVnode, newStartVnode)) {
735
+ // if the start nodes are the same then we should patch the new VNode
736
+ // onto the old one, and increment our `newStartIdx` and `oldStartIdx`
737
+ // indices to reflect that. We don't need to move any DOM Nodes around
738
+ // since things are matched up in order.
739
+ patch(oldStartVnode, newStartVnode);
740
+ oldStartVnode = oldCh[++oldStartIdx];
741
+ newStartVnode = newCh[++newStartIdx];
742
+ }
743
+ else if (isSameVnode(oldEndVnode, newEndVnode)) {
744
+ // likewise, if the end nodes are the same we patch new onto old and
745
+ // decrement our end indices, and also likewise in this case we don't
746
+ // need to move any DOM Nodes.
747
+ patch(oldEndVnode, newEndVnode);
748
+ oldEndVnode = oldCh[--oldEndIdx];
749
+ newEndVnode = newCh[--newEndIdx];
750
+ }
751
+ else if (isSameVnode(oldStartVnode, newEndVnode)) {
752
+ patch(oldStartVnode, newEndVnode);
753
+ // We need to move the element for `oldStartVnode` into a position which
754
+ // will be appropriate for `newEndVnode`. For this we can use
755
+ // `.insertBefore` and `oldEndVnode.$elm$.nextSibling`. If there is a
756
+ // sibling for `oldEndVnode.$elm$` then we want to move the DOM node for
757
+ // `oldStartVnode` between `oldEndVnode` and it's sibling, like so:
758
+ //
759
+ // <old-start-node />
760
+ // <some-intervening-node />
761
+ // <old-end-node />
762
+ // <!-- -> <-- `oldStartVnode.$elm$` should be inserted here
763
+ // <next-sibling />
764
+ //
765
+ // If instead `oldEndVnode.$elm$` has no sibling then we just want to put
766
+ // the node for `oldStartVnode` at the end of the children of
767
+ // `parentElm`. Luckily, `Node.nextSibling` will return `null` if there
768
+ // aren't any siblings, and passing `null` to `Node.insertBefore` will
769
+ // append it to the children of the parent element.
770
+ parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
771
+ oldStartVnode = oldCh[++oldStartIdx];
772
+ newEndVnode = newCh[--newEndIdx];
773
+ }
774
+ else if (isSameVnode(oldEndVnode, newStartVnode)) {
775
+ patch(oldEndVnode, newStartVnode);
776
+ // We've already checked above if `oldStartVnode` and `newStartVnode` are
777
+ // the same node, so since we're here we know that they are not. Thus we
778
+ // can move the element for `oldEndVnode` _before_ the element for
779
+ // `oldStartVnode`, leaving `oldStartVnode` to be reconciled in the
780
+ // future.
781
+ parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
782
+ oldEndVnode = oldCh[--oldEndIdx];
783
+ newStartVnode = newCh[++newStartIdx];
784
+ }
785
+ else {
786
+ // Here we do some checks to match up old and new nodes based on the
787
+ // `$key$` attribute, which is set by putting a `key="my-key"` attribute
788
+ // in the JSX for a DOM element in the implementation of a Stencil
789
+ // component.
790
+ //
791
+ // First we check to see if there are any nodes in the array of old
792
+ // children which have the same key as the first node in the new
793
+ // children.
794
+ idxInOld = -1;
795
+ {
796
+ for (i = oldStartIdx; i <= oldEndIdx; ++i) {
797
+ if (oldCh[i] && oldCh[i].$key$ !== null && oldCh[i].$key$ === newStartVnode.$key$) {
798
+ idxInOld = i;
799
+ break;
800
+ }
801
+ }
802
+ }
803
+ if (idxInOld >= 0) {
804
+ // We found a node in the old children which matches up with the first
805
+ // node in the new children! So let's deal with that
806
+ elmToMove = oldCh[idxInOld];
807
+ if (elmToMove.$tag$ !== newStartVnode.$tag$) {
808
+ // the tag doesn't match so we'll need a new DOM element
809
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld);
810
+ }
811
+ else {
812
+ patch(elmToMove, newStartVnode);
813
+ // invalidate the matching old node so that we won't try to update it
814
+ // again later on
815
+ oldCh[idxInOld] = undefined;
816
+ node = elmToMove.$elm$;
817
+ }
818
+ newStartVnode = newCh[++newStartIdx];
819
+ }
820
+ else {
821
+ // We either didn't find an element in the old children that matches
822
+ // the key of the first new child OR the build is not using `key`
823
+ // attributes at all. In either case we need to create a new element
824
+ // for the new node.
825
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
826
+ newStartVnode = newCh[++newStartIdx];
827
+ }
828
+ if (node) {
829
+ // if we created a new node then handle inserting it to the DOM
830
+ {
831
+ oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
832
+ }
833
+ }
834
+ }
835
+ }
836
+ if (oldStartIdx > oldEndIdx) {
837
+ // we have some more new nodes to add which don't match up with old nodes
838
+ addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
839
+ }
840
+ else if (newStartIdx > newEndIdx) {
841
+ // there are nodes in the `oldCh` array which no longer correspond to nodes
842
+ // in the new array, so lets remove them (which entails cleaning up the
843
+ // relevant DOM nodes)
844
+ removeVnodes(oldCh, oldStartIdx, oldEndIdx);
845
+ }
846
+ };
847
+ /**
848
+ * Compare two VNodes to determine if they are the same
849
+ *
850
+ * **NB**: This function is an equality _heuristic_ based on the available
851
+ * information set on the two VNodes and can be misleading under certain
852
+ * circumstances. In particular, if the two nodes do not have `key` attrs
853
+ * (available under `$key$` on VNodes) then the function falls back on merely
854
+ * checking that they have the same tag.
855
+ *
856
+ * So, in other words, if `key` attrs are not set on VNodes which may be
857
+ * changing order within a `children` array or something along those lines then
858
+ * we could obtain a false negative and then have to do needless re-rendering
859
+ * (i.e. we'd say two VNodes aren't equal when in fact they should be).
860
+ *
861
+ * @param leftVNode the first VNode to check
862
+ * @param rightVNode the second VNode to check
863
+ * @returns whether they're equal or not
864
+ */
865
+ const isSameVnode = (leftVNode, rightVNode) => {
866
+ // compare if two vnode to see if they're "technically" the same
867
+ // need to have the same element tag, and same key to be the same
868
+ if (leftVNode.$tag$ === rightVNode.$tag$) {
869
+ // this will be set if components in the build have `key` attrs set on them
870
+ {
871
+ return leftVNode.$key$ === rightVNode.$key$;
872
+ }
873
+ }
874
+ return false;
875
+ };
876
+ /**
877
+ * Handle reconciling an outdated VNode with a new one which corresponds to
878
+ * it. This function handles flushing updates to the DOM and reconciling the
879
+ * children of the two nodes (if any).
880
+ *
881
+ * @param oldVNode an old VNode whose DOM element and children we want to update
882
+ * @param newVNode a new VNode representing an updated version of the old one
883
+ */
884
+ const patch = (oldVNode, newVNode) => {
885
+ const elm = (newVNode.$elm$ = oldVNode.$elm$);
886
+ const oldChildren = oldVNode.$children$;
887
+ const newChildren = newVNode.$children$;
888
+ const text = newVNode.$text$;
889
+ if (text === null) {
890
+ {
891
+ {
892
+ // either this is the first render of an element OR it's an update
893
+ // AND we already know it's possible it could have changed
894
+ // this updates the element's css classes, attrs, props, listeners, etc.
895
+ updateElement(oldVNode, newVNode, isSvgMode);
896
+ }
897
+ }
898
+ if (oldChildren !== null && newChildren !== null) {
899
+ // looks like there's child vnodes for both the old and new vnodes
900
+ // so we need to call `updateChildren` to reconcile them
901
+ updateChildren(elm, oldChildren, newVNode, newChildren);
902
+ }
903
+ else if (newChildren !== null) {
904
+ // no old child vnodes, but there are new child vnodes to add
905
+ if (oldVNode.$text$ !== null) {
906
+ // the old vnode was text, so be sure to clear it out
907
+ elm.textContent = '';
908
+ }
909
+ // add the new vnode children
910
+ addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
911
+ }
912
+ else if (oldChildren !== null) {
913
+ // no new child vnodes, but there are old child vnodes to remove
914
+ removeVnodes(oldChildren, 0, oldChildren.length - 1);
915
+ }
916
+ }
917
+ else if (oldVNode.$text$ !== text) {
918
+ // update the text content for the text only vnode
919
+ // and also only if the text is different than before
920
+ elm.data = text;
921
+ }
922
+ };
923
+ /**
924
+ * The main entry point for Stencil's virtual DOM-based rendering engine
925
+ *
926
+ * Given a {@link d.HostRef} container and some virtual DOM nodes, this
927
+ * function will handle creating a virtual DOM tree with a single root, patching
928
+ * the current virtual DOM tree onto an old one (if any), dealing with slot
929
+ * relocation, and reflecting attributes.
930
+ *
931
+ * @param hostRef data needed to root and render the virtual DOM tree, such as
932
+ * the DOM node into which it should be rendered.
933
+ * @param renderFnResults the virtual DOM nodes to be rendered
934
+ */
935
+ const renderVdom = (hostRef, renderFnResults) => {
936
+ const hostElm = hostRef.$hostElement$;
937
+ const oldVNode = hostRef.$vnode$ || newVNode(null, null);
938
+ const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
939
+ rootVnode.$tag$ = null;
940
+ rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
941
+ hostRef.$vnode$ = rootVnode;
942
+ rootVnode.$elm$ = oldVNode.$elm$ = (hostElm);
943
+ {
944
+ scopeId = hostElm['s-sc'];
945
+ }
946
+ // synchronous patch
947
+ patch(oldVNode, rootVnode);
948
+ };
949
+ const attachToAncestor = (hostRef, ancestorComponent) => {
950
+ if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
951
+ ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
952
+ }
953
+ };
954
+ const scheduleUpdate = (hostRef, isInitialLoad) => {
955
+ {
956
+ hostRef.$flags$ |= 16 /* HOST_FLAGS.isQueuedForUpdate */;
957
+ }
958
+ if (hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
959
+ hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
960
+ return;
961
+ }
962
+ attachToAncestor(hostRef, hostRef.$ancestorComponent$);
963
+ // there is no ancestor component or the ancestor component
964
+ // has already fired off its lifecycle update then
965
+ // fire off the initial update
966
+ const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
967
+ return writeTask(dispatch) ;
968
+ };
969
+ const dispatchHooks = (hostRef, isInitialLoad) => {
970
+ const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
971
+ const instance = hostRef.$lazyInstance$ ;
972
+ let promise;
973
+ if (isInitialLoad) {
974
+ {
975
+ hostRef.$flags$ |= 256 /* HOST_FLAGS.isListenReady */;
976
+ if (hostRef.$queuedListeners$) {
977
+ hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
978
+ hostRef.$queuedListeners$ = null;
979
+ }
980
+ }
981
+ {
982
+ promise = safeCall(instance, 'componentWillLoad');
983
+ }
984
+ }
985
+ {
986
+ promise = then(promise, () => safeCall(instance, 'componentWillRender'));
987
+ }
988
+ endSchedule();
989
+ return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
990
+ };
991
+ const updateComponent = async (hostRef, instance, isInitialLoad) => {
992
+ // updateComponent
993
+ const elm = hostRef.$hostElement$;
994
+ const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
995
+ const rc = elm['s-rc'];
996
+ if (isInitialLoad) {
997
+ // DOM WRITE!
998
+ attachStyles(hostRef);
999
+ }
1000
+ const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
1001
+ {
1002
+ callRender(hostRef, instance);
1003
+ }
1004
+ if (rc) {
1005
+ // ok, so turns out there are some child host elements
1006
+ // waiting on this parent element to load
1007
+ // let's fire off all update callbacks waiting
1008
+ rc.map((cb) => cb());
1009
+ elm['s-rc'] = undefined;
1010
+ }
1011
+ endRender();
1012
+ endUpdate();
1013
+ {
1014
+ const childrenPromises = elm['s-p'];
1015
+ const postUpdate = () => postUpdateComponent(hostRef);
1016
+ if (childrenPromises.length === 0) {
1017
+ postUpdate();
1018
+ }
1019
+ else {
1020
+ Promise.all(childrenPromises).then(postUpdate);
1021
+ hostRef.$flags$ |= 4 /* HOST_FLAGS.isWaitingForChildren */;
1022
+ childrenPromises.length = 0;
1023
+ }
1024
+ }
1025
+ };
1026
+ const callRender = (hostRef, instance, elm) => {
1027
+ try {
1028
+ instance = instance.render() ;
1029
+ {
1030
+ hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
1031
+ }
1032
+ {
1033
+ hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
1034
+ }
1035
+ {
1036
+ {
1037
+ // looks like we've got child nodes to render into this host element
1038
+ // or we need to update the css class/attrs on the host element
1039
+ // DOM WRITE!
1040
+ {
1041
+ renderVdom(hostRef, instance);
1042
+ }
1043
+ }
1044
+ }
1045
+ }
1046
+ catch (e) {
1047
+ consoleError(e, hostRef.$hostElement$);
1048
+ }
1049
+ return null;
1050
+ };
1051
+ const postUpdateComponent = (hostRef) => {
1052
+ const tagName = hostRef.$cmpMeta$.$tagName$;
1053
+ const elm = hostRef.$hostElement$;
1054
+ const endPostUpdate = createTime('postUpdate', tagName);
1055
+ const instance = hostRef.$lazyInstance$ ;
1056
+ const ancestorComponent = hostRef.$ancestorComponent$;
1057
+ if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
1058
+ hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
1059
+ {
1060
+ // DOM WRITE!
1061
+ addHydratedFlag(elm);
1062
+ }
1063
+ {
1064
+ safeCall(instance, 'componentDidLoad');
1065
+ }
1066
+ endPostUpdate();
1067
+ {
1068
+ hostRef.$onReadyResolve$(elm);
1069
+ if (!ancestorComponent) {
1070
+ appDidLoad();
1071
+ }
1072
+ }
1073
+ }
1074
+ else {
1075
+ endPostUpdate();
1076
+ }
1077
+ {
1078
+ hostRef.$onInstanceResolve$(elm);
1079
+ }
1080
+ // load events fire from bottom to top
1081
+ // the deepest elements load first then bubbles up
1082
+ {
1083
+ if (hostRef.$onRenderResolve$) {
1084
+ hostRef.$onRenderResolve$();
1085
+ hostRef.$onRenderResolve$ = undefined;
1086
+ }
1087
+ if (hostRef.$flags$ & 512 /* HOST_FLAGS.needsRerender */) {
1088
+ nextTick(() => scheduleUpdate(hostRef, false));
1089
+ }
1090
+ hostRef.$flags$ &= ~(4 /* HOST_FLAGS.isWaitingForChildren */ | 512 /* HOST_FLAGS.needsRerender */);
1091
+ }
1092
+ // ( •_•)
1093
+ // ( •_•)>⌐■-■
1094
+ // (⌐■_■)
1095
+ };
1096
+ const appDidLoad = (who) => {
1097
+ // on appload
1098
+ // we have finish the first big initial render
1099
+ {
1100
+ addHydratedFlag(doc.documentElement);
1101
+ }
1102
+ nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
1103
+ };
1104
+ const safeCall = (instance, method, arg) => {
1105
+ if (instance && instance[method]) {
1106
+ try {
1107
+ return instance[method](arg);
1108
+ }
1109
+ catch (e) {
1110
+ consoleError(e);
1111
+ }
1112
+ }
1113
+ return undefined;
1114
+ };
1115
+ const then = (promise, thenFn) => {
1116
+ return promise && promise.then ? promise.then(thenFn) : thenFn();
1117
+ };
1118
+ const addHydratedFlag = (elm) => elm.classList.add('hydrated')
1119
+ ;
1120
+ const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
1121
+ const setValue = (ref, propName, newVal, cmpMeta) => {
1122
+ // check our new property value against our internal value
1123
+ const hostRef = getHostRef(ref);
1124
+ const elm = hostRef.$hostElement$ ;
1125
+ const oldVal = hostRef.$instanceValues$.get(propName);
1126
+ const flags = hostRef.$flags$;
1127
+ const instance = hostRef.$lazyInstance$ ;
1128
+ newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
1129
+ // explicitly check for NaN on both sides, as `NaN === NaN` is always false
1130
+ const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
1131
+ const didValueChange = newVal !== oldVal && !areBothNaN;
1132
+ if ((!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
1133
+ // gadzooks! the property's value has changed!!
1134
+ // set our new value!
1135
+ hostRef.$instanceValues$.set(propName, newVal);
1136
+ if (instance) {
1137
+ // get an array of method names of watch functions to call
1138
+ if (cmpMeta.$watchers$ && flags & 128 /* HOST_FLAGS.isWatchReady */) {
1139
+ const watchMethods = cmpMeta.$watchers$[propName];
1140
+ if (watchMethods) {
1141
+ // this instance is watching for when this property changed
1142
+ watchMethods.map((watchMethodName) => {
1143
+ try {
1144
+ // fire off each of the watch methods that are watching this property
1145
+ instance[watchMethodName](newVal, oldVal, propName);
1146
+ }
1147
+ catch (e) {
1148
+ consoleError(e, elm);
1149
+ }
1150
+ });
1151
+ }
1152
+ }
1153
+ if ((flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
1154
+ // looks like this value actually changed, so we've got work to do!
1155
+ // but only if we've already rendered, otherwise just chill out
1156
+ // queue that we need to do an update, but don't worry about queuing
1157
+ // up millions cuz this function ensures it only runs once
1158
+ scheduleUpdate(hostRef, false);
1159
+ }
1160
+ }
1161
+ }
1162
+ };
1163
+ /**
1164
+ * Attach a series of runtime constructs to a compiled Stencil component
1165
+ * constructor, including getters and setters for the `@Prop` and `@State`
1166
+ * decorators, callbacks for when attributes change, and so on.
1167
+ *
1168
+ * @param Cstr the constructor for a component that we need to process
1169
+ * @param cmpMeta metadata collected previously about the component
1170
+ * @param flags a number used to store a series of bit flags
1171
+ * @returns a reference to the same constructor passed in (but now mutated)
1172
+ */
1173
+ const proxyComponent = (Cstr, cmpMeta, flags) => {
1174
+ if (cmpMeta.$members$) {
1175
+ if (Cstr.watchers) {
1176
+ cmpMeta.$watchers$ = Cstr.watchers;
1177
+ }
1178
+ // It's better to have a const than two Object.entries()
1179
+ const members = Object.entries(cmpMeta.$members$);
1180
+ const prototype = Cstr.prototype;
1181
+ members.map(([memberName, [memberFlags]]) => {
1182
+ if ((memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
1183
+ ((flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
1184
+ // proxyComponent - prop
1185
+ Object.defineProperty(prototype, memberName, {
1186
+ get() {
1187
+ // proxyComponent, get value
1188
+ return getValue(this, memberName);
1189
+ },
1190
+ set(newValue) {
1191
+ // proxyComponent, set value
1192
+ setValue(this, memberName, newValue, cmpMeta);
1193
+ },
1194
+ configurable: true,
1195
+ enumerable: true,
1196
+ });
1197
+ }
1198
+ else if (flags & 1 /* PROXY_FLAGS.isElementConstructor */ &&
1199
+ memberFlags & 64 /* MEMBER_FLAGS.Method */) {
1200
+ // proxyComponent - method
1201
+ Object.defineProperty(prototype, memberName, {
1202
+ value(...args) {
1203
+ const ref = getHostRef(this);
1204
+ return ref.$onInstancePromise$.then(() => ref.$lazyInstance$[memberName](...args));
1205
+ },
1206
+ });
1207
+ }
1208
+ });
1209
+ if ((flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
1210
+ const attrNameToPropName = new Map();
1211
+ prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
1212
+ plt.jmp(() => {
1213
+ const propName = attrNameToPropName.get(attrName);
1214
+ // In a web component lifecycle the attributeChangedCallback runs prior to connectedCallback
1215
+ // in the case where an attribute was set inline.
1216
+ // ```html
1217
+ // <my-component some-attribute="some-value"></my-component>
1218
+ // ```
1219
+ //
1220
+ // There is an edge case where a developer sets the attribute inline on a custom element and then
1221
+ // programmatically changes it before it has been upgraded as shown below:
1222
+ //
1223
+ // ```html
1224
+ // <!-- this component has _not_ been upgraded yet -->
1225
+ // <my-component id="test" some-attribute="some-value"></my-component>
1226
+ // <script>
1227
+ // // grab non-upgraded component
1228
+ // el = document.querySelector("#test");
1229
+ // el.someAttribute = "another-value";
1230
+ // // upgrade component
1231
+ // customElements.define('my-component', MyComponent);
1232
+ // </script>
1233
+ // ```
1234
+ // In this case if we do not unshadow here and use the value of the shadowing property, attributeChangedCallback
1235
+ // will be called with `newValue = "some-value"` and will set the shadowed property (this.someAttribute = "another-value")
1236
+ // to the value that was set inline i.e. "some-value" from above example. When
1237
+ // the connectedCallback attempts to unshadow it will use "some-value" as the initial value rather than "another-value"
1238
+ //
1239
+ // The case where the attribute was NOT set inline but was not set programmatically shall be handled/unshadowed
1240
+ // by connectedCallback as this attributeChangedCallback will not fire.
1241
+ //
1242
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1243
+ //
1244
+ // TODO(STENCIL-16) we should think about whether or not we actually want to be reflecting the attributes to
1245
+ // properties here given that this goes against best practices outlined here
1246
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#avoid-reentrancy
1247
+ if (this.hasOwnProperty(propName)) {
1248
+ newValue = this[propName];
1249
+ delete this[propName];
1250
+ }
1251
+ else if (prototype.hasOwnProperty(propName) &&
1252
+ typeof this[propName] === 'number' &&
1253
+ this[propName] == newValue) {
1254
+ // if the propName exists on the prototype of `Cstr`, this update may be a result of Stencil using native
1255
+ // APIs to reflect props as attributes. Calls to `setAttribute(someElement, propName)` will result in
1256
+ // `propName` to be converted to a `DOMString`, which may not be what we want for other primitive props.
1257
+ return;
1258
+ }
1259
+ this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
1260
+ });
1261
+ };
1262
+ // create an array of attributes to observe
1263
+ // and also create a map of html attribute name to js property name
1264
+ Cstr.observedAttributes = members
1265
+ .filter(([_, m]) => m[0] & 15 /* MEMBER_FLAGS.HasAttribute */) // filter to only keep props that should match attributes
1266
+ .map(([propName, m]) => {
1267
+ const attrName = m[1] || propName;
1268
+ attrNameToPropName.set(attrName, propName);
1269
+ return attrName;
1270
+ });
1271
+ }
1272
+ }
1273
+ return Cstr;
1274
+ };
1275
+ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
1276
+ // initializeComponent
1277
+ if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
1278
+ {
1279
+ // we haven't initialized this element yet
1280
+ hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
1281
+ // lazy loaded components
1282
+ // request the component's implementation to be
1283
+ // wired up with the host element
1284
+ Cstr = loadModule(cmpMeta);
1285
+ if (Cstr.then) {
1286
+ // Await creates a micro-task avoid if possible
1287
+ const endLoad = uniqueTime();
1288
+ Cstr = await Cstr;
1289
+ endLoad();
1290
+ }
1291
+ if (!Cstr.isProxied) {
1292
+ // we've never proxied this Constructor before
1293
+ // let's add the getters/setters to its prototype before
1294
+ // the first time we create an instance of the implementation
1295
+ {
1296
+ cmpMeta.$watchers$ = Cstr.watchers;
1297
+ }
1298
+ proxyComponent(Cstr, cmpMeta, 2 /* PROXY_FLAGS.proxyState */);
1299
+ Cstr.isProxied = true;
1300
+ }
1301
+ const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
1302
+ // ok, time to construct the instance
1303
+ // but let's keep track of when we start and stop
1304
+ // so that the getters/setters don't incorrectly step on data
1305
+ {
1306
+ hostRef.$flags$ |= 8 /* HOST_FLAGS.isConstructingInstance */;
1307
+ }
1308
+ // construct the lazy-loaded component implementation
1309
+ // passing the hostRef is very important during
1310
+ // construction in order to directly wire together the
1311
+ // host element and the lazy-loaded instance
1312
+ try {
1313
+ new Cstr(hostRef);
1314
+ }
1315
+ catch (e) {
1316
+ consoleError(e);
1317
+ }
1318
+ {
1319
+ hostRef.$flags$ &= ~8 /* HOST_FLAGS.isConstructingInstance */;
1320
+ }
1321
+ {
1322
+ hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */;
1323
+ }
1324
+ endNewInstance();
1325
+ }
1326
+ if (Cstr.style) {
1327
+ // this component has styles but we haven't registered them yet
1328
+ let style = Cstr.style;
1329
+ const scopeId = getScopeId(cmpMeta);
1330
+ if (!styles.has(scopeId)) {
1331
+ const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
1332
+ registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
1333
+ endRegisterStyles();
1334
+ }
1335
+ }
1336
+ }
1337
+ // we've successfully created a lazy instance
1338
+ const ancestorComponent = hostRef.$ancestorComponent$;
1339
+ const schedule = () => scheduleUpdate(hostRef, true);
1340
+ if (ancestorComponent && ancestorComponent['s-rc']) {
1341
+ // this is the initial load and this component it has an ancestor component
1342
+ // but the ancestor component has NOT fired its will update lifecycle yet
1343
+ // so let's just cool our jets and wait for the ancestor to continue first
1344
+ // this will get fired off when the ancestor component
1345
+ // finally gets around to rendering its lazy self
1346
+ // fire off the initial update
1347
+ ancestorComponent['s-rc'].push(schedule);
1348
+ }
1349
+ else {
1350
+ schedule();
1351
+ }
1352
+ };
1353
+ const connectedCallback = (elm) => {
1354
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
1355
+ const hostRef = getHostRef(elm);
1356
+ const cmpMeta = hostRef.$cmpMeta$;
1357
+ const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
1358
+ if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
1359
+ // first time this component has connected
1360
+ hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
1361
+ {
1362
+ // find the first ancestor component (if there is one) and register
1363
+ // this component as one of the actively loading child components for its ancestor
1364
+ let ancestorComponent = elm;
1365
+ while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
1366
+ // climb up the ancestors looking for the first
1367
+ // component that hasn't finished its lifecycle update yet
1368
+ if (ancestorComponent['s-p']) {
1369
+ // we found this components first ancestor component
1370
+ // keep a reference to this component's ancestor component
1371
+ attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
1372
+ break;
1373
+ }
1374
+ }
1375
+ }
1376
+ // Lazy properties
1377
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1378
+ if (cmpMeta.$members$) {
1379
+ Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
1380
+ if (memberFlags & 31 /* MEMBER_FLAGS.Prop */ && elm.hasOwnProperty(memberName)) {
1381
+ const value = elm[memberName];
1382
+ delete elm[memberName];
1383
+ elm[memberName] = value;
1384
+ }
1385
+ });
1386
+ }
1387
+ {
1388
+ initializeComponent(elm, hostRef, cmpMeta);
1389
+ }
1390
+ }
1391
+ else {
1392
+ // not the first time this has connected
1393
+ // reattach any event listeners to the host
1394
+ // since they would have been removed when disconnected
1395
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
1396
+ }
1397
+ endConnected();
1398
+ }
1399
+ };
1400
+ const disconnectedCallback = (elm) => {
1401
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
1402
+ const hostRef = getHostRef(elm);
1403
+ {
1404
+ if (hostRef.$rmListeners$) {
1405
+ hostRef.$rmListeners$.map((rmListener) => rmListener());
1406
+ hostRef.$rmListeners$ = undefined;
1407
+ }
1408
+ }
1409
+ }
1410
+ };
1411
+ const bootstrapLazy = (lazyBundles, options = {}) => {
1412
+ var _a;
1413
+ const endBootstrap = createTime();
1414
+ const cmpTags = [];
1415
+ const exclude = options.exclude || [];
1416
+ const customElements = win.customElements;
1417
+ const head = doc.head;
1418
+ const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
1419
+ const visibilityStyle = /*@__PURE__*/ doc.createElement('style');
1420
+ const deferredConnectedCallbacks = [];
1421
+ let appLoadFallback;
1422
+ let isBootstrapping = true;
1423
+ Object.assign(plt, options);
1424
+ plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
1425
+ lazyBundles.map((lazyBundle) => {
1426
+ lazyBundle[1].map((compactMeta) => {
1427
+ const cmpMeta = {
1428
+ $flags$: compactMeta[0],
1429
+ $tagName$: compactMeta[1],
1430
+ $members$: compactMeta[2],
1431
+ $listeners$: compactMeta[3],
1432
+ };
1433
+ {
1434
+ cmpMeta.$members$ = compactMeta[2];
1435
+ }
1436
+ {
1437
+ cmpMeta.$listeners$ = compactMeta[3];
1438
+ }
1439
+ {
1440
+ cmpMeta.$watchers$ = {};
1441
+ }
1442
+ const tagName = cmpMeta.$tagName$;
1443
+ const HostElement = class extends HTMLElement {
1444
+ // StencilLazyHost
1445
+ constructor(self) {
1446
+ // @ts-ignore
1447
+ super(self);
1448
+ self = this;
1449
+ registerHost(self, cmpMeta);
1450
+ }
1451
+ connectedCallback() {
1452
+ if (appLoadFallback) {
1453
+ clearTimeout(appLoadFallback);
1454
+ appLoadFallback = null;
1455
+ }
1456
+ if (isBootstrapping) {
1457
+ // connectedCallback will be processed once all components have been registered
1458
+ deferredConnectedCallbacks.push(this);
1459
+ }
1460
+ else {
1461
+ plt.jmp(() => connectedCallback(this));
1462
+ }
1463
+ }
1464
+ disconnectedCallback() {
1465
+ plt.jmp(() => disconnectedCallback(this));
1466
+ }
1467
+ componentOnReady() {
1468
+ return getHostRef(this).$onReadyPromise$;
1469
+ }
1470
+ };
1471
+ cmpMeta.$lazyBundleId$ = lazyBundle[0];
1472
+ if (!exclude.includes(tagName) && !customElements.get(tagName)) {
1473
+ cmpTags.push(tagName);
1474
+ customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */));
1475
+ }
1476
+ });
1477
+ });
1478
+ {
1479
+ visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
1480
+ visibilityStyle.setAttribute('data-styles', '');
1481
+ // Apply CSP nonce to the style tag if it exists
1482
+ const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
1483
+ if (nonce != null) {
1484
+ visibilityStyle.setAttribute('nonce', nonce);
1485
+ }
1486
+ head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
1487
+ }
1488
+ // Process deferred connectedCallbacks now all components have been registered
1489
+ isBootstrapping = false;
1490
+ if (deferredConnectedCallbacks.length) {
1491
+ deferredConnectedCallbacks.map((host) => host.connectedCallback());
1492
+ }
1493
+ else {
1494
+ {
1495
+ plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30)));
1496
+ }
1497
+ }
1498
+ // Fallback appLoad event
1499
+ endBootstrap();
1500
+ };
1501
+ const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
1502
+ if (listeners) {
1503
+ listeners.map(([flags, name, method]) => {
1504
+ const target = getHostListenerTarget(elm, flags) ;
1505
+ const handler = hostListenerProxy(hostRef, method);
1506
+ const opts = hostListenerOpts(flags);
1507
+ plt.ael(target, name, handler, opts);
1508
+ (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
1509
+ });
1510
+ }
1511
+ };
1512
+ const hostListenerProxy = (hostRef, methodName) => (ev) => {
1513
+ try {
1514
+ {
1515
+ if (hostRef.$flags$ & 256 /* HOST_FLAGS.isListenReady */) {
1516
+ // instance is ready, let's call it's member method for this event
1517
+ hostRef.$lazyInstance$[methodName](ev);
1518
+ }
1519
+ else {
1520
+ (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
1521
+ }
1522
+ }
1523
+ }
1524
+ catch (e) {
1525
+ consoleError(e);
1526
+ }
1527
+ };
1528
+ const getHostListenerTarget = (elm, flags) => {
1529
+ if (flags & 8 /* LISTENER_FLAGS.TargetWindow */)
1530
+ return win;
1531
+ return elm;
1532
+ };
1533
+ // prettier-ignore
1534
+ const hostListenerOpts = (flags) => (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0;
1535
+ /**
1536
+ * Assigns the given value to the nonce property on the runtime platform object.
1537
+ * During runtime, this value is used to set the nonce attribute on all dynamically created script and style tags.
1538
+ * @param nonce The value to be assigned to the platform nonce property.
1539
+ * @returns void
1540
+ */
1541
+ const setNonce = (nonce) => (plt.$nonce$ = nonce);
1542
+ const hostRefs = /*@__PURE__*/ new WeakMap();
1543
+ const getHostRef = (ref) => hostRefs.get(ref);
1544
+ const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
1545
+ const registerHost = (elm, cmpMeta) => {
1546
+ const hostRef = {
1547
+ $flags$: 0,
1548
+ $hostElement$: elm,
1549
+ $cmpMeta$: cmpMeta,
1550
+ $instanceValues$: new Map(),
1551
+ };
1552
+ {
1553
+ hostRef.$onInstancePromise$ = new Promise((r) => (hostRef.$onInstanceResolve$ = r));
1554
+ }
1555
+ {
1556
+ hostRef.$onReadyPromise$ = new Promise((r) => (hostRef.$onReadyResolve$ = r));
1557
+ elm['s-p'] = [];
1558
+ elm['s-rc'] = [];
1559
+ }
1560
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
1561
+ return hostRefs.set(elm, hostRef);
1562
+ };
1563
+ const isMemberInElement = (elm, memberName) => memberName in elm;
1564
+ const consoleError = (e, el) => (0, console.error)(e, el);
1565
+ const cmpModules = /*@__PURE__*/ new Map();
1566
+ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
1567
+ // loadModuleImport
1568
+ const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
1569
+ const bundleId = cmpMeta.$lazyBundleId$;
1570
+ const module = cmpModules.get(bundleId) ;
1571
+ if (module) {
1572
+ return module[exportName];
1573
+ }
1574
+ /*!__STENCIL_STATIC_IMPORT_SWITCH__*/
1575
+ return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
1576
+ /* @vite-ignore */
1577
+ /* webpackInclude: /\.entry\.js$/ */
1578
+ /* webpackExclude: /\.system\.entry\.js$/ */
1579
+ /* webpackMode: "lazy" */
1580
+ `./${bundleId}.entry.js${''}`)); }).then((importedModule) => {
1581
+ {
1582
+ cmpModules.set(bundleId, importedModule);
1583
+ }
1584
+ return importedModule[exportName];
1585
+ }, consoleError);
1586
+ };
1587
+ const styles = /*@__PURE__*/ new Map();
1588
+ const win = typeof window !== 'undefined' ? window : {};
1589
+ const doc = win.document || { head: {} };
1590
+ const plt = {
1591
+ $flags$: 0,
1592
+ $resourcesUrl$: '',
1593
+ jmp: (h) => h(),
1594
+ raf: (h) => requestAnimationFrame(h),
1595
+ ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
1596
+ rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
1597
+ ce: (eventName, opts) => new CustomEvent(eventName, opts),
1598
+ };
1599
+ const promiseResolve = (v) => Promise.resolve(v);
1600
+ const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
1601
+ try {
1602
+ new CSSStyleSheet();
1603
+ return typeof new CSSStyleSheet().replaceSync === 'function';
1604
+ }
1605
+ catch (e) { }
1606
+ return false;
1607
+ })()
1608
+ ;
1609
+ const queueDomReads = [];
1610
+ const queueDomWrites = [];
1611
+ const queueTask = (queue, write) => (cb) => {
1612
+ queue.push(cb);
1613
+ if (!queuePending) {
1614
+ queuePending = true;
1615
+ if (write && plt.$flags$ & 4 /* PLATFORM_FLAGS.queueSync */) {
1616
+ nextTick(flush);
1617
+ }
1618
+ else {
1619
+ plt.raf(flush);
1620
+ }
1621
+ }
1622
+ };
1623
+ const consume = (queue) => {
1624
+ for (let i = 0; i < queue.length; i++) {
1625
+ try {
1626
+ queue[i](performance.now());
1627
+ }
1628
+ catch (e) {
1629
+ consoleError(e);
1630
+ }
1631
+ }
1632
+ queue.length = 0;
1633
+ };
1634
+ const flush = () => {
1635
+ // always force a bunch of medium callbacks to run, but still have
1636
+ // a throttle on how many can run in a certain time
1637
+ // DOM READS!!!
1638
+ consume(queueDomReads);
1639
+ // DOM WRITES!!!
1640
+ {
1641
+ consume(queueDomWrites);
1642
+ if ((queuePending = queueDomReads.length > 0)) {
1643
+ // still more to do yet, but we've run out of time
1644
+ // let's let this thing cool off and try again in the next tick
1645
+ plt.raf(flush);
1646
+ }
1647
+ }
1648
+ };
1649
+ const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
1650
+ const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
1651
+
1652
+ exports.bootstrapLazy = bootstrapLazy;
1653
+ exports.createEvent = createEvent;
1654
+ exports.getAssetPath = getAssetPath;
1655
+ exports.getElement = getElement;
1656
+ exports.h = h;
1657
+ exports.promiseResolve = promiseResolve;
1658
+ exports.registerInstance = registerInstance;
1659
+ exports.setNonce = setNonce;
1660
+
1661
+ //# sourceMappingURL=index-160fcb6c.js.map