@runopencode/rx-stencil 0.4.2 → 0.4.4

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 (113) hide show
  1. package/dist/cjs/app-globals-V2Kpy_OQ.js +5 -0
  2. package/dist/cjs/index-CbERigo8.js +1211 -0
  3. package/dist/cjs/index.cjs.js +162 -543
  4. package/dist/cjs/loader.cjs.js +4 -6
  5. package/dist/cjs/rx-async.cjs.entry.js +29 -63
  6. package/dist/cjs/rx-stencil.cjs.js +14 -14
  7. package/dist/cjs/set-property-BZHuI0P5.js +9525 -0
  8. package/dist/collection/collection-manifest.json +2 -2
  9. package/dist/collection/components/async/async.css +3 -0
  10. package/dist/collection/components/async/async.js +62 -61
  11. package/dist/collection/components/index.js +1 -0
  12. package/dist/collection/index.js +0 -1
  13. package/dist/collection/rx/decorator/index.js +0 -1
  14. package/dist/collection/rx/decorator/query-selector-all.js +26 -27
  15. package/dist/collection/rx/decorator/query-selector.js +32 -33
  16. package/dist/collection/rx/index.js +0 -1
  17. package/dist/collection/rx/observable/index.js +0 -1
  18. package/dist/collection/rx/observable/mutation-observable.js +8 -9
  19. package/dist/collection/rx/observable/properties-observable.js +6 -7
  20. package/dist/collection/rx/observable/property-observable.js +20 -21
  21. package/dist/collection/rx/observable/render-observable.js +15 -16
  22. package/dist/collection/rx/operator/index.js +0 -1
  23. package/dist/collection/rx/operator/schedule-render.js +9 -10
  24. package/dist/collection/rx/operator/to-property.js +8 -9
  25. package/dist/collection/rx/operator/until-disconnected.js +56 -57
  26. package/dist/collection/rx/subscriber/index.js +0 -1
  27. package/dist/collection/rx/subscriber/set-property.js +12 -13
  28. package/dist/collection/utils/get-property-descriptor.js +10 -11
  29. package/dist/collection/utils/index.js +0 -1
  30. package/dist/components/index.d.ts +2 -0
  31. package/dist/components/index.js +1 -661
  32. package/dist/components/rx-async.d.ts +2 -2
  33. package/dist/components/rx-async.js +1 -86
  34. package/dist/components/set-property.js +1 -1153
  35. package/dist/esm/app-globals-DQuL1Twl.js +3 -0
  36. package/dist/esm/index-BIBww8qU.js +1202 -0
  37. package/dist/esm/index.js +164 -543
  38. package/dist/esm/loader.js +5 -5
  39. package/dist/esm/rx-async.entry.js +29 -61
  40. package/dist/esm/rx-stencil.js +14 -13
  41. package/dist/esm/set-property-CpZKE-Xu.js +9520 -0
  42. package/dist/rx-stencil/index.esm.js +1 -2
  43. package/dist/rx-stencil/p-77100dee.entry.js +1 -0
  44. package/dist/rx-stencil/p-BIBww8qU.js +2 -0
  45. package/dist/rx-stencil/p-DQuL1Twl.js +1 -0
  46. package/dist/rx-stencil/p-IbpJ_cRo.js +1 -0
  47. package/dist/rx-stencil/rx-stencil.esm.js +1 -2
  48. package/dist/types/components/async/async.d.ts +5 -5
  49. package/dist/types/components/index.d.ts +1 -0
  50. package/dist/types/components.d.ts +7 -1
  51. package/dist/types/rx/decorator/query-selector-all.d.ts +9 -9
  52. package/dist/types/rx/decorator/query-selector.d.ts +9 -9
  53. package/dist/types/rx/subscriber/set-property.d.ts +12 -12
  54. package/dist/types/stencil-public-runtime.d.ts +225 -17
  55. package/loader/cdn.js +1 -3
  56. package/loader/index.cjs.js +1 -3
  57. package/loader/index.d.ts +3 -0
  58. package/loader/index.es2017.js +1 -3
  59. package/loader/index.js +1 -3
  60. package/package.json +8 -9
  61. package/dist/cjs/index-5f6f12ab.js +0 -1265
  62. package/dist/cjs/index-5f6f12ab.js.map +0 -1
  63. package/dist/cjs/index.cjs.js.map +0 -1
  64. package/dist/cjs/loader.cjs.js.map +0 -1
  65. package/dist/cjs/rx-async.cjs.entry.js.map +0 -1
  66. package/dist/cjs/rx-stencil.cjs.js.map +0 -1
  67. package/dist/cjs/set-property-c1def9c5.js +0 -1171
  68. package/dist/cjs/set-property-c1def9c5.js.map +0 -1
  69. package/dist/collection/components/async/async.js.map +0 -1
  70. package/dist/collection/components/async/async.scss +0 -3
  71. package/dist/collection/index.js.map +0 -1
  72. package/dist/collection/rx/decorator/index.js.map +0 -1
  73. package/dist/collection/rx/decorator/query-selector-all.js.map +0 -1
  74. package/dist/collection/rx/decorator/query-selector.js.map +0 -1
  75. package/dist/collection/rx/index.js.map +0 -1
  76. package/dist/collection/rx/observable/index.js.map +0 -1
  77. package/dist/collection/rx/observable/mutation-observable.js.map +0 -1
  78. package/dist/collection/rx/observable/properties-observable.js.map +0 -1
  79. package/dist/collection/rx/observable/property-observable.js.map +0 -1
  80. package/dist/collection/rx/observable/render-observable.js.map +0 -1
  81. package/dist/collection/rx/operator/index.js.map +0 -1
  82. package/dist/collection/rx/operator/schedule-render.js.map +0 -1
  83. package/dist/collection/rx/operator/to-property.js.map +0 -1
  84. package/dist/collection/rx/operator/until-disconnected.js.map +0 -1
  85. package/dist/collection/rx/subscriber/index.js.map +0 -1
  86. package/dist/collection/rx/subscriber/set-property.js.map +0 -1
  87. package/dist/collection/utils/get-property-descriptor.js.map +0 -1
  88. package/dist/collection/utils/index.js.map +0 -1
  89. package/dist/components/index.js.map +0 -1
  90. package/dist/components/rx-async.js.map +0 -1
  91. package/dist/components/set-property.js.map +0 -1
  92. package/dist/esm/index-9102de09.js +0 -1236
  93. package/dist/esm/index-9102de09.js.map +0 -1
  94. package/dist/esm/index.js.map +0 -1
  95. package/dist/esm/loader.js.map +0 -1
  96. package/dist/esm/polyfills/core-js.js +0 -11
  97. package/dist/esm/polyfills/dom.js +0 -79
  98. package/dist/esm/polyfills/es5-html-element.js +0 -1
  99. package/dist/esm/polyfills/index.js +0 -34
  100. package/dist/esm/polyfills/system.js +0 -6
  101. package/dist/esm/rx-async.entry.js.map +0 -1
  102. package/dist/esm/rx-stencil.js.map +0 -1
  103. package/dist/esm/set-property-9befeb72.js +0 -1153
  104. package/dist/esm/set-property-9befeb72.js.map +0 -1
  105. package/dist/rx-stencil/index.esm.js.map +0 -1
  106. package/dist/rx-stencil/p-2fc78e52.js +0 -2
  107. package/dist/rx-stencil/p-2fc78e52.js.map +0 -1
  108. package/dist/rx-stencil/p-8411601b.js +0 -3
  109. package/dist/rx-stencil/p-8411601b.js.map +0 -1
  110. package/dist/rx-stencil/p-c823932c.entry.js +0 -2
  111. package/dist/rx-stencil/p-c823932c.entry.js.map +0 -1
  112. package/dist/rx-stencil/rx-stencil.esm.js.map +0 -1
  113. package/loader/package.json +0 -11
@@ -1,1265 +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 = 'rx-stencil';
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 queuePending = false;
34
- const createTime = (fnName, tagName = '') => {
35
- {
36
- return () => {
37
- return;
38
- };
39
- }
40
- };
41
- const uniqueTime = (key, measureText) => {
42
- {
43
- return () => {
44
- return;
45
- };
46
- }
47
- };
48
- const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
49
- /**
50
- * Check whether a value is a 'complex type', defined here as an object or a
51
- * function.
52
- *
53
- * @param o the value to check
54
- * @returns whether it's a complex type or not
55
- */
56
- const isComplexType = (o) => {
57
- // https://jsperf.com/typeof-fn-object/5
58
- o = typeof o;
59
- return o === 'object' || o === 'function';
60
- };
61
- /**
62
- * Helper method for querying a `meta` tag that contains a nonce value
63
- * out of a DOM's head.
64
- *
65
- * @param doc The DOM containing the `head` to query against
66
- * @returns The content of the meta tag representing the nonce value, or `undefined` if no tag
67
- * exists or the tag has no content.
68
- */
69
- function queryNonceMetaTagContent(doc) {
70
- var _a, _b, _c;
71
- 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;
72
- }
73
- /**
74
- * Production h() function based on Preact by
75
- * Jason Miller (@developit)
76
- * Licensed under the MIT License
77
- * https://github.com/developit/preact/blob/master/LICENSE
78
- *
79
- * Modified for Stencil's compiler and vdom
80
- */
81
- // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
82
- // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
83
- const h = (nodeName, vnodeData, ...children) => {
84
- let child = null;
85
- let simple = false;
86
- let lastSimple = false;
87
- const vNodeChildren = [];
88
- const walk = (c) => {
89
- for (let i = 0; i < c.length; i++) {
90
- child = c[i];
91
- if (Array.isArray(child)) {
92
- walk(child);
93
- }
94
- else if (child != null && typeof child !== 'boolean') {
95
- if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
96
- child = String(child);
97
- }
98
- if (simple && lastSimple) {
99
- // If the previous child was simple (string), we merge both
100
- vNodeChildren[vNodeChildren.length - 1].$text$ += child;
101
- }
102
- else {
103
- // Append a new vNode, if it's text, we create a text vNode
104
- vNodeChildren.push(simple ? newVNode(null, child) : child);
105
- }
106
- lastSimple = simple;
107
- }
108
- }
109
- };
110
- walk(children);
111
- const vnode = newVNode(nodeName, null);
112
- vnode.$attrs$ = vnodeData;
113
- if (vNodeChildren.length > 0) {
114
- vnode.$children$ = vNodeChildren;
115
- }
116
- return vnode;
117
- };
118
- /**
119
- * A utility function for creating a virtual DOM node from a tag and some
120
- * possible text content.
121
- *
122
- * @param tag the tag for this element
123
- * @param text possible text content for the node
124
- * @returns a newly-minted virtual DOM node
125
- */
126
- const newVNode = (tag, text) => {
127
- const vnode = {
128
- $flags$: 0,
129
- $tag$: tag,
130
- $text$: text,
131
- $elm$: null,
132
- $children$: null,
133
- };
134
- return vnode;
135
- };
136
- const Host = {};
137
- /**
138
- * Check whether a given node is a Host node or not
139
- *
140
- * @param node the virtual DOM node to check
141
- * @returns whether it's a Host node or not
142
- */
143
- const isHost = (node) => node && node.$tag$ === Host;
144
- /**
145
- * Parse a new property value for a given property type.
146
- *
147
- * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
148
- * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
149
- * 1. `any`, the type given to `propValue` in the function signature
150
- * 2. the type stored from `propType`.
151
- *
152
- * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
153
- *
154
- * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
155
- * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
156
- * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
157
- * ```tsx
158
- * <my-cmp prop-val={0}></my-cmp>
159
- * ```
160
- *
161
- * HTML prop values on the other hand, will always a string
162
- *
163
- * @param propValue the new value to coerce to some type
164
- * @param propType the type of the prop, expressed as a binary number
165
- * @returns the parsed/coerced value
166
- */
167
- const parsePropertyValue = (propValue, propType) => {
168
- // ensure this value is of the correct prop type
169
- if (propValue != null && !isComplexType(propValue)) {
170
- // redundant return here for better minification
171
- return propValue;
172
- }
173
- // not sure exactly what type we want
174
- // so no need to change to a different type
175
- return propValue;
176
- };
177
- const getElement = (ref) => (getHostRef(ref).$hostElement$ );
178
- /**
179
- * Helper function to create & dispatch a custom Event on a provided target
180
- * @param elm the target of the Event
181
- * @param name the name to give the custom Event
182
- * @param opts options for configuring a custom Event
183
- * @returns the custom Event
184
- */
185
- const emitEvent = (elm, name, opts) => {
186
- const ev = plt.ce(name, opts);
187
- elm.dispatchEvent(ev);
188
- return ev;
189
- };
190
- const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
191
- const registerStyle = (scopeId, cssText, allowCS) => {
192
- let style = styles.get(scopeId);
193
- if (supportsConstructableStylesheets && allowCS) {
194
- style = (style || new CSSStyleSheet());
195
- if (typeof style === 'string') {
196
- style = cssText;
197
- }
198
- else {
199
- style.replaceSync(cssText);
200
- }
201
- }
202
- else {
203
- style = cssText;
204
- }
205
- styles.set(scopeId, style);
206
- };
207
- const addStyle = (styleContainerNode, cmpMeta, mode) => {
208
- var _a;
209
- const scopeId = getScopeId(cmpMeta);
210
- const style = styles.get(scopeId);
211
- // if an element is NOT connected then getRootNode() will return the wrong root node
212
- // so the fallback is to always use the document for the root node in those cases
213
- styleContainerNode = styleContainerNode.nodeType === 11 /* NODE_TYPE.DocumentFragment */ ? styleContainerNode : doc;
214
- if (style) {
215
- if (typeof style === 'string') {
216
- styleContainerNode = styleContainerNode.head || styleContainerNode;
217
- let appliedStyles = rootAppliedStyles.get(styleContainerNode);
218
- let styleElm;
219
- if (!appliedStyles) {
220
- rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
221
- }
222
- if (!appliedStyles.has(scopeId)) {
223
- {
224
- styleElm = doc.createElement('style');
225
- styleElm.innerHTML = style;
226
- // Apply CSP nonce to the style tag if it exists
227
- const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
228
- if (nonce != null) {
229
- styleElm.setAttribute('nonce', nonce);
230
- }
231
- styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
232
- }
233
- if (appliedStyles) {
234
- appliedStyles.add(scopeId);
235
- }
236
- }
237
- }
238
- else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
239
- styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
240
- }
241
- }
242
- return scopeId;
243
- };
244
- const attachStyles = (hostRef) => {
245
- const cmpMeta = hostRef.$cmpMeta$;
246
- const elm = hostRef.$hostElement$;
247
- const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
248
- addStyle(elm.getRootNode(), cmpMeta);
249
- endAttachStyles();
250
- };
251
- const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
252
- /**
253
- * Create a DOM Node corresponding to one of the children of a given VNode.
254
- *
255
- * @param oldParentVNode the parent VNode from the previous render
256
- * @param newParentVNode the parent VNode from the current render
257
- * @param childIndex the index of the VNode, in the _new_ parent node's
258
- * children, for which we will create a new DOM node
259
- * @param parentElm the parent DOM node which our new node will be a child of
260
- * @returns the newly created node
261
- */
262
- const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
263
- // tslint:disable-next-line: prefer-const
264
- const newVNode = newParentVNode.$children$[childIndex];
265
- let i = 0;
266
- let elm;
267
- let childNode;
268
- if (newVNode.$text$ !== null) {
269
- // create text node
270
- elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
271
- }
272
- else {
273
- // create element
274
- elm = newVNode.$elm$ = (doc.createElement(newVNode.$tag$));
275
- if (newVNode.$children$) {
276
- for (i = 0; i < newVNode.$children$.length; ++i) {
277
- // create the node
278
- childNode = createElm(oldParentVNode, newVNode, i);
279
- // return node could have been null
280
- if (childNode) {
281
- // append our new node
282
- elm.appendChild(childNode);
283
- }
284
- }
285
- }
286
- }
287
- return elm;
288
- };
289
- /**
290
- * Create DOM nodes corresponding to a list of {@link d.Vnode} objects and
291
- * add them to the DOM in the appropriate place.
292
- *
293
- * @param parentElm the DOM node which should be used as a parent for the new
294
- * DOM nodes
295
- * @param before a child of the `parentElm` which the new children should be
296
- * inserted before (optional)
297
- * @param parentVNode the parent virtual DOM node
298
- * @param vnodes the new child virtual DOM nodes to produce DOM nodes for
299
- * @param startIdx the index in the child virtual DOM nodes at which to start
300
- * creating DOM nodes (inclusive)
301
- * @param endIdx the index in the child virtual DOM nodes at which to stop
302
- * creating DOM nodes (inclusive)
303
- */
304
- const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
305
- let containerElm = (parentElm);
306
- let childNode;
307
- for (; startIdx <= endIdx; ++startIdx) {
308
- if (vnodes[startIdx]) {
309
- childNode = createElm(null, parentVNode, startIdx);
310
- if (childNode) {
311
- vnodes[startIdx].$elm$ = childNode;
312
- containerElm.insertBefore(childNode, before);
313
- }
314
- }
315
- }
316
- };
317
- /**
318
- * Remove the DOM elements corresponding to a list of {@link d.VNode} objects.
319
- * This can be used to, for instance, clean up after a list of children which
320
- * should no longer be shown.
321
- *
322
- * This function also handles some of Stencil's slot relocation logic.
323
- *
324
- * @param vnodes a list of virtual DOM nodes to remove
325
- * @param startIdx the index at which to start removing nodes (inclusive)
326
- * @param endIdx the index at which to stop removing nodes (inclusive)
327
- */
328
- const removeVnodes = (vnodes, startIdx, endIdx) => {
329
- for (let index = startIdx; index <= endIdx; ++index) {
330
- const vnode = vnodes[index];
331
- if (vnode) {
332
- const elm = vnode.$elm$;
333
- if (elm) {
334
- // remove the vnode's element from the dom
335
- elm.remove();
336
- }
337
- }
338
- }
339
- };
340
- /**
341
- * Reconcile the children of a new VNode with the children of an old VNode by
342
- * traversing the two collections of children, identifying nodes that are
343
- * conserved or changed, calling out to `patch` to make any necessary
344
- * updates to the DOM, and rearranging DOM nodes as needed.
345
- *
346
- * The algorithm for reconciling children works by analyzing two 'windows' onto
347
- * the two arrays of children (`oldCh` and `newCh`). We keep track of the
348
- * 'windows' by storing start and end indices and references to the
349
- * corresponding array entries. Initially the two 'windows' are basically equal
350
- * to the entire array, but we progressively narrow the windows until there are
351
- * no children left to update by doing the following:
352
- *
353
- * 1. Skip any `null` entries at the beginning or end of the two arrays, so
354
- * that if we have an initial array like the following we'll end up dealing
355
- * only with a window bounded by the highlighted elements:
356
- *
357
- * [null, null, VNode1 , ... , VNode2, null, null]
358
- * ^^^^^^ ^^^^^^
359
- *
360
- * 2. Check to see if the elements at the head and tail positions are equal
361
- * across the windows. This will basically detect elements which haven't
362
- * been added, removed, or changed position, i.e. if you had the following
363
- * VNode elements (represented as HTML):
364
- *
365
- * oldVNode: `<div><p><span>HEY</span></p></div>`
366
- * newVNode: `<div><p><span>THERE</span></p></div>`
367
- *
368
- * Then when comparing the children of the `<div>` tag we check the equality
369
- * of the VNodes corresponding to the `<p>` tags and, since they are the
370
- * same tag in the same position, we'd be able to avoid completely
371
- * re-rendering the subtree under them with a new DOM element and would just
372
- * call out to `patch` to handle reconciling their children and so on.
373
- *
374
- * 3. Check, for both windows, to see if the element at the beginning of the
375
- * window corresponds to the element at the end of the other window. This is
376
- * a heuristic which will let us identify _some_ situations in which
377
- * elements have changed position, for instance it _should_ detect that the
378
- * children nodes themselves have not changed but merely moved in the
379
- * following example:
380
- *
381
- * oldVNode: `<div><element-one /><element-two /></div>`
382
- * newVNode: `<div><element-two /><element-one /></div>`
383
- *
384
- * If we find cases like this then we also need to move the concrete DOM
385
- * elements corresponding to the moved children to write the re-order to the
386
- * DOM.
387
- *
388
- * 4. Finally, if VNodes have the `key` attribute set on them we check for any
389
- * nodes in the old children which have the same key as the first element in
390
- * our window on the new children. If we find such a node we handle calling
391
- * out to `patch`, moving relevant DOM nodes, and so on, in accordance with
392
- * what we find.
393
- *
394
- * Finally, once we've narrowed our 'windows' to the point that either of them
395
- * collapse (i.e. they have length 0) we then handle any remaining VNode
396
- * insertion or deletion that needs to happen to get a DOM state that correctly
397
- * reflects the new child VNodes. If, for instance, after our window on the old
398
- * children has collapsed we still have more nodes on the new children that
399
- * we haven't dealt with yet then we need to add them, or if the new children
400
- * collapse but we still have unhandled _old_ children then we need to make
401
- * sure the corresponding DOM nodes are removed.
402
- *
403
- * @param parentElm the node into which the parent VNode is rendered
404
- * @param oldCh the old children of the parent node
405
- * @param newVNode the new VNode which will replace the parent
406
- * @param newCh the new children of the parent node
407
- */
408
- const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
409
- let oldStartIdx = 0;
410
- let newStartIdx = 0;
411
- let oldEndIdx = oldCh.length - 1;
412
- let oldStartVnode = oldCh[0];
413
- let oldEndVnode = oldCh[oldEndIdx];
414
- let newEndIdx = newCh.length - 1;
415
- let newStartVnode = newCh[0];
416
- let newEndVnode = newCh[newEndIdx];
417
- let node;
418
- while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
419
- if (oldStartVnode == null) {
420
- // VNode might have been moved left
421
- oldStartVnode = oldCh[++oldStartIdx];
422
- }
423
- else if (oldEndVnode == null) {
424
- oldEndVnode = oldCh[--oldEndIdx];
425
- }
426
- else if (newStartVnode == null) {
427
- newStartVnode = newCh[++newStartIdx];
428
- }
429
- else if (newEndVnode == null) {
430
- newEndVnode = newCh[--newEndIdx];
431
- }
432
- else if (isSameVnode(oldStartVnode, newStartVnode)) {
433
- // if the start nodes are the same then we should patch the new VNode
434
- // onto the old one, and increment our `newStartIdx` and `oldStartIdx`
435
- // indices to reflect that. We don't need to move any DOM Nodes around
436
- // since things are matched up in order.
437
- patch(oldStartVnode, newStartVnode);
438
- oldStartVnode = oldCh[++oldStartIdx];
439
- newStartVnode = newCh[++newStartIdx];
440
- }
441
- else if (isSameVnode(oldEndVnode, newEndVnode)) {
442
- // likewise, if the end nodes are the same we patch new onto old and
443
- // decrement our end indices, and also likewise in this case we don't
444
- // need to move any DOM Nodes.
445
- patch(oldEndVnode, newEndVnode);
446
- oldEndVnode = oldCh[--oldEndIdx];
447
- newEndVnode = newCh[--newEndIdx];
448
- }
449
- else if (isSameVnode(oldStartVnode, newEndVnode)) {
450
- patch(oldStartVnode, newEndVnode);
451
- // We need to move the element for `oldStartVnode` into a position which
452
- // will be appropriate for `newEndVnode`. For this we can use
453
- // `.insertBefore` and `oldEndVnode.$elm$.nextSibling`. If there is a
454
- // sibling for `oldEndVnode.$elm$` then we want to move the DOM node for
455
- // `oldStartVnode` between `oldEndVnode` and it's sibling, like so:
456
- //
457
- // <old-start-node />
458
- // <some-intervening-node />
459
- // <old-end-node />
460
- // <!-- -> <-- `oldStartVnode.$elm$` should be inserted here
461
- // <next-sibling />
462
- //
463
- // If instead `oldEndVnode.$elm$` has no sibling then we just want to put
464
- // the node for `oldStartVnode` at the end of the children of
465
- // `parentElm`. Luckily, `Node.nextSibling` will return `null` if there
466
- // aren't any siblings, and passing `null` to `Node.insertBefore` will
467
- // append it to the children of the parent element.
468
- parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
469
- oldStartVnode = oldCh[++oldStartIdx];
470
- newEndVnode = newCh[--newEndIdx];
471
- }
472
- else if (isSameVnode(oldEndVnode, newStartVnode)) {
473
- patch(oldEndVnode, newStartVnode);
474
- // We've already checked above if `oldStartVnode` and `newStartVnode` are
475
- // the same node, so since we're here we know that they are not. Thus we
476
- // can move the element for `oldEndVnode` _before_ the element for
477
- // `oldStartVnode`, leaving `oldStartVnode` to be reconciled in the
478
- // future.
479
- parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
480
- oldEndVnode = oldCh[--oldEndIdx];
481
- newStartVnode = newCh[++newStartIdx];
482
- }
483
- else {
484
- {
485
- // We either didn't find an element in the old children that matches
486
- // the key of the first new child OR the build is not using `key`
487
- // attributes at all. In either case we need to create a new element
488
- // for the new node.
489
- node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
490
- newStartVnode = newCh[++newStartIdx];
491
- }
492
- if (node) {
493
- // if we created a new node then handle inserting it to the DOM
494
- {
495
- oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
496
- }
497
- }
498
- }
499
- }
500
- if (oldStartIdx > oldEndIdx) {
501
- // we have some more new nodes to add which don't match up with old nodes
502
- addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
503
- }
504
- else if (newStartIdx > newEndIdx) {
505
- // there are nodes in the `oldCh` array which no longer correspond to nodes
506
- // in the new array, so lets remove them (which entails cleaning up the
507
- // relevant DOM nodes)
508
- removeVnodes(oldCh, oldStartIdx, oldEndIdx);
509
- }
510
- };
511
- /**
512
- * Compare two VNodes to determine if they are the same
513
- *
514
- * **NB**: This function is an equality _heuristic_ based on the available
515
- * information set on the two VNodes and can be misleading under certain
516
- * circumstances. In particular, if the two nodes do not have `key` attrs
517
- * (available under `$key$` on VNodes) then the function falls back on merely
518
- * checking that they have the same tag.
519
- *
520
- * So, in other words, if `key` attrs are not set on VNodes which may be
521
- * changing order within a `children` array or something along those lines then
522
- * we could obtain a false negative and then have to do needless re-rendering
523
- * (i.e. we'd say two VNodes aren't equal when in fact they should be).
524
- *
525
- * @param leftVNode the first VNode to check
526
- * @param rightVNode the second VNode to check
527
- * @returns whether they're equal or not
528
- */
529
- const isSameVnode = (leftVNode, rightVNode) => {
530
- // compare if two vnode to see if they're "technically" the same
531
- // need to have the same element tag, and same key to be the same
532
- if (leftVNode.$tag$ === rightVNode.$tag$) {
533
- return true;
534
- }
535
- return false;
536
- };
537
- /**
538
- * Handle reconciling an outdated VNode with a new one which corresponds to
539
- * it. This function handles flushing updates to the DOM and reconciling the
540
- * children of the two nodes (if any).
541
- *
542
- * @param oldVNode an old VNode whose DOM element and children we want to update
543
- * @param newVNode a new VNode representing an updated version of the old one
544
- */
545
- const patch = (oldVNode, newVNode) => {
546
- const elm = (newVNode.$elm$ = oldVNode.$elm$);
547
- const oldChildren = oldVNode.$children$;
548
- const newChildren = newVNode.$children$;
549
- const text = newVNode.$text$;
550
- if (text === null) {
551
- if (oldChildren !== null && newChildren !== null) {
552
- // looks like there's child vnodes for both the old and new vnodes
553
- // so we need to call `updateChildren` to reconcile them
554
- updateChildren(elm, oldChildren, newVNode, newChildren);
555
- }
556
- else if (newChildren !== null) {
557
- // no old child vnodes, but there are new child vnodes to add
558
- if (oldVNode.$text$ !== null) {
559
- // the old vnode was text, so be sure to clear it out
560
- elm.textContent = '';
561
- }
562
- // add the new vnode children
563
- addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
564
- }
565
- else if (oldChildren !== null) {
566
- // no new child vnodes, but there are old child vnodes to remove
567
- removeVnodes(oldChildren, 0, oldChildren.length - 1);
568
- }
569
- }
570
- else if (oldVNode.$text$ !== text) {
571
- // update the text content for the text only vnode
572
- // and also only if the text is different than before
573
- elm.data = text;
574
- }
575
- };
576
- /**
577
- * The main entry point for Stencil's virtual DOM-based rendering engine
578
- *
579
- * Given a {@link d.HostRef} container and some virtual DOM nodes, this
580
- * function will handle creating a virtual DOM tree with a single root, patching
581
- * the current virtual DOM tree onto an old one (if any), dealing with slot
582
- * relocation, and reflecting attributes.
583
- *
584
- * @param hostRef data needed to root and render the virtual DOM tree, such as
585
- * the DOM node into which it should be rendered.
586
- * @param renderFnResults the virtual DOM nodes to be rendered
587
- * @param isInitialLoad whether or not this is the first call after page load
588
- */
589
- const renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
590
- const hostElm = hostRef.$hostElement$;
591
- const oldVNode = hostRef.$vnode$ || newVNode(null, null);
592
- // if `renderFnResults` is a Host node then we can use it directly. If not,
593
- // we need to call `h` again to wrap the children of our component in a
594
- // 'dummy' Host node (well, an empty vnode) since `renderVdom` assumes
595
- // implicitly that the top-level vdom node is 1) an only child and 2)
596
- // contains attrs that need to be set on the host element.
597
- const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
598
- // On the first render and *only* on the first render we want to check for
599
- // any attributes set on the host element which are also set on the vdom
600
- // node. If we find them, we override the value on the VDom node attrs with
601
- // the value from the host element, which allows developers building apps
602
- // with Stencil components to override e.g. the `role` attribute on a
603
- // component even if it's already set on the `Host`.
604
- if (isInitialLoad && rootVnode.$attrs$) {
605
- for (const key of Object.keys(rootVnode.$attrs$)) {
606
- // We have a special implementation in `setAccessor` for `style` and
607
- // `class` which reconciles values coming from the VDom with values
608
- // already present on the DOM element, so we don't want to override those
609
- // attributes on the VDom tree with values from the host element if they
610
- // are present.
611
- //
612
- // Likewise, `ref` and `key` are special internal values for the Stencil
613
- // runtime and we don't want to override those either.
614
- if (hostElm.hasAttribute(key) && !['key', 'ref', 'style', 'class'].includes(key)) {
615
- rootVnode.$attrs$[key] = hostElm[key];
616
- }
617
- }
618
- }
619
- rootVnode.$tag$ = null;
620
- rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
621
- hostRef.$vnode$ = rootVnode;
622
- rootVnode.$elm$ = oldVNode.$elm$ = (hostElm);
623
- // synchronous patch
624
- patch(oldVNode, rootVnode);
625
- };
626
- const attachToAncestor = (hostRef, ancestorComponent) => {
627
- if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
628
- ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
629
- }
630
- };
631
- const scheduleUpdate = (hostRef, isInitialLoad) => {
632
- {
633
- hostRef.$flags$ |= 16 /* HOST_FLAGS.isQueuedForUpdate */;
634
- }
635
- if (hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
636
- hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
637
- return;
638
- }
639
- attachToAncestor(hostRef, hostRef.$ancestorComponent$);
640
- // there is no ancestor component or the ancestor component
641
- // has already fired off its lifecycle update then
642
- // fire off the initial update
643
- const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
644
- return writeTask(dispatch) ;
645
- };
646
- /**
647
- * Dispatch initial-render and update lifecycle hooks, enqueuing calls to
648
- * component lifecycle methods like `componentWillLoad` as well as
649
- * {@link updateComponent}, which will kick off the virtual DOM re-render.
650
- *
651
- * @param hostRef a reference to a host DOM node
652
- * @param isInitialLoad whether we're on the initial load or not
653
- * @returns an empty Promise which is used to enqueue a series of operations for
654
- * the component
655
- */
656
- const dispatchHooks = (hostRef, isInitialLoad) => {
657
- const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
658
- const instance = hostRef.$lazyInstance$ ;
659
- // We're going to use this variable together with `enqueue` to implement a
660
- // little promise-based queue. We start out with it `undefined`. When we add
661
- // the first function to the queue we'll set this variable to be that
662
- // function's return value. When we attempt to add subsequent values to the
663
- // queue we'll check that value and, if it was a `Promise`, we'll then chain
664
- // the new function off of that `Promise` using `.then()`. This will give our
665
- // queue two nice properties:
666
- //
667
- // 1. If all functions added to the queue are synchronous they'll be called
668
- // synchronously right away.
669
- // 2. If all functions added to the queue are asynchronous they'll all be
670
- // called in order after `dispatchHooks` exits.
671
- let maybePromise;
672
- endSchedule();
673
- return enqueue(maybePromise, () => updateComponent(hostRef, instance, isInitialLoad));
674
- };
675
- /**
676
- * This function uses a Promise to implement a simple first-in, first-out queue
677
- * of functions to be called.
678
- *
679
- * The queue is ordered on the basis of the first argument. If it's
680
- * `undefined`, then nothing is on the queue yet, so the provided function can
681
- * be called synchronously (although note that this function may return a
682
- * `Promise`). The idea is that then the return value of that enqueueing
683
- * operation is kept around, so that if it was a `Promise` then subsequent
684
- * functions can be enqueued by calling this function again with that `Promise`
685
- * as the first argument.
686
- *
687
- * @param maybePromise either a `Promise` which should resolve before the next function is called or an 'empty' sentinel
688
- * @param fn a function to enqueue
689
- * @returns either a `Promise` or the return value of the provided function
690
- */
691
- const enqueue = (maybePromise, fn) => isPromisey(maybePromise) ? maybePromise.then(fn) : fn();
692
- /**
693
- * Check that a value is a `Promise`. To check, we first see if the value is an
694
- * instance of the `Promise` global. In a few circumstances, in particular if
695
- * the global has been overwritten, this is could be misleading, so we also do
696
- * a little 'duck typing' check to see if the `.then` property of the value is
697
- * defined and a function.
698
- *
699
- * @param maybePromise it might be a promise!
700
- * @returns whether it is or not
701
- */
702
- const isPromisey = (maybePromise) => maybePromise instanceof Promise ||
703
- (maybePromise && maybePromise.then && typeof maybePromise.then === 'function');
704
- /**
705
- * Update a component given reference to its host elements and so on.
706
- *
707
- * @param hostRef an object containing references to the element's host node,
708
- * VDom nodes, and other metadata
709
- * @param instance a reference to the underlying host element where it will be
710
- * rendered
711
- * @param isInitialLoad whether or not this function is being called as part of
712
- * the first render cycle
713
- */
714
- const updateComponent = async (hostRef, instance, isInitialLoad) => {
715
- var _a;
716
- const elm = hostRef.$hostElement$;
717
- const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
718
- const rc = elm['s-rc'];
719
- if (isInitialLoad) {
720
- // DOM WRITE!
721
- attachStyles(hostRef);
722
- }
723
- const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
724
- {
725
- callRender(hostRef, instance, elm, isInitialLoad);
726
- }
727
- if (rc) {
728
- // ok, so turns out there are some child host elements
729
- // waiting on this parent element to load
730
- // let's fire off all update callbacks waiting
731
- rc.map((cb) => cb());
732
- elm['s-rc'] = undefined;
733
- }
734
- endRender();
735
- endUpdate();
736
- {
737
- const childrenPromises = (_a = elm['s-p']) !== null && _a !== void 0 ? _a : [];
738
- const postUpdate = () => postUpdateComponent(hostRef);
739
- if (childrenPromises.length === 0) {
740
- postUpdate();
741
- }
742
- else {
743
- Promise.all(childrenPromises).then(postUpdate);
744
- hostRef.$flags$ |= 4 /* HOST_FLAGS.isWaitingForChildren */;
745
- childrenPromises.length = 0;
746
- }
747
- }
748
- };
749
- /**
750
- * Handle making the call to the VDom renderer with the proper context given
751
- * various build variables
752
- *
753
- * @param hostRef an object containing references to the element's host node,
754
- * VDom nodes, and other metadata
755
- * @param instance a reference to the underlying host element where it will be
756
- * rendered
757
- * @param elm the Host element for the component
758
- * @param isInitialLoad whether or not this function is being called as part of
759
- * @returns an empty promise
760
- */
761
- const callRender = (hostRef, instance, elm, isInitialLoad) => {
762
- try {
763
- instance = instance.render() ;
764
- {
765
- hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
766
- }
767
- {
768
- hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
769
- }
770
- {
771
- {
772
- // looks like we've got child nodes to render into this host element
773
- // or we need to update the css class/attrs on the host element
774
- // DOM WRITE!
775
- {
776
- renderVdom(hostRef, instance, isInitialLoad);
777
- }
778
- }
779
- }
780
- }
781
- catch (e) {
782
- consoleError(e, hostRef.$hostElement$);
783
- }
784
- return null;
785
- };
786
- const postUpdateComponent = (hostRef) => {
787
- const tagName = hostRef.$cmpMeta$.$tagName$;
788
- const elm = hostRef.$hostElement$;
789
- const endPostUpdate = createTime('postUpdate', tagName);
790
- const ancestorComponent = hostRef.$ancestorComponent$;
791
- if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
792
- hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
793
- {
794
- // DOM WRITE!
795
- addHydratedFlag(elm);
796
- }
797
- endPostUpdate();
798
- {
799
- hostRef.$onReadyResolve$(elm);
800
- if (!ancestorComponent) {
801
- appDidLoad();
802
- }
803
- }
804
- }
805
- else {
806
- endPostUpdate();
807
- }
808
- // load events fire from bottom to top
809
- // the deepest elements load first then bubbles up
810
- {
811
- if (hostRef.$onRenderResolve$) {
812
- hostRef.$onRenderResolve$();
813
- hostRef.$onRenderResolve$ = undefined;
814
- }
815
- if (hostRef.$flags$ & 512 /* HOST_FLAGS.needsRerender */) {
816
- nextTick(() => scheduleUpdate(hostRef, false));
817
- }
818
- hostRef.$flags$ &= ~(4 /* HOST_FLAGS.isWaitingForChildren */ | 512 /* HOST_FLAGS.needsRerender */);
819
- }
820
- // ( •_•)
821
- // ( •_•)>⌐■-■
822
- // (⌐■_■)
823
- };
824
- const forceUpdate = (ref) => {
825
- {
826
- const hostRef = getHostRef(ref);
827
- const isConnected = hostRef.$hostElement$.isConnected;
828
- if (isConnected &&
829
- (hostRef.$flags$ & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
830
- scheduleUpdate(hostRef, false);
831
- }
832
- // Returns "true" when the forced update was successfully scheduled
833
- return isConnected;
834
- }
835
- };
836
- const appDidLoad = (who) => {
837
- // on appload
838
- // we have finish the first big initial render
839
- {
840
- addHydratedFlag(doc.documentElement);
841
- }
842
- nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
843
- };
844
- const safeCall = (instance, method, arg) => {
845
- if (instance && instance[method]) {
846
- try {
847
- return instance[method](arg);
848
- }
849
- catch (e) {
850
- consoleError(e);
851
- }
852
- }
853
- return undefined;
854
- };
855
- const addHydratedFlag = (elm) => elm.classList.add('hydrated')
856
- ;
857
- const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
858
- const setValue = (ref, propName, newVal, cmpMeta) => {
859
- // check our new property value against our internal value
860
- const hostRef = getHostRef(ref);
861
- const oldVal = hostRef.$instanceValues$.get(propName);
862
- const flags = hostRef.$flags$;
863
- const instance = hostRef.$lazyInstance$ ;
864
- newVal = parsePropertyValue(newVal);
865
- // explicitly check for NaN on both sides, as `NaN === NaN` is always false
866
- const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
867
- const didValueChange = newVal !== oldVal && !areBothNaN;
868
- if ((!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
869
- // gadzooks! the property's value has changed!!
870
- // set our new value!
871
- hostRef.$instanceValues$.set(propName, newVal);
872
- if (instance) {
873
- if ((flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
874
- // looks like this value actually changed, so we've got work to do!
875
- // but only if we've already rendered, otherwise just chill out
876
- // queue that we need to do an update, but don't worry about queuing
877
- // up millions cuz this function ensures it only runs once
878
- scheduleUpdate(hostRef, false);
879
- }
880
- }
881
- }
882
- };
883
- /**
884
- * Attach a series of runtime constructs to a compiled Stencil component
885
- * constructor, including getters and setters for the `@Prop` and `@State`
886
- * decorators, callbacks for when attributes change, and so on.
887
- *
888
- * @param Cstr the constructor for a component that we need to process
889
- * @param cmpMeta metadata collected previously about the component
890
- * @param flags a number used to store a series of bit flags
891
- * @returns a reference to the same constructor passed in (but now mutated)
892
- */
893
- const proxyComponent = (Cstr, cmpMeta, flags) => {
894
- if (cmpMeta.$members$) {
895
- // It's better to have a const than two Object.entries()
896
- const members = Object.entries(cmpMeta.$members$);
897
- const prototype = Cstr.prototype;
898
- members.map(([memberName, [memberFlags]]) => {
899
- if ((memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
900
- ((flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
901
- // proxyComponent - prop
902
- Object.defineProperty(prototype, memberName, {
903
- get() {
904
- // proxyComponent, get value
905
- return getValue(this, memberName);
906
- },
907
- set(newValue) {
908
- // proxyComponent, set value
909
- setValue(this, memberName, newValue);
910
- },
911
- configurable: true,
912
- enumerable: true,
913
- });
914
- }
915
- });
916
- }
917
- return Cstr;
918
- };
919
- const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
920
- // initializeComponent
921
- if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
922
- // Let the runtime know that the component has been initialized
923
- hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
924
- {
925
- // lazy loaded components
926
- // request the component's implementation to be
927
- // wired up with the host element
928
- Cstr = loadModule(cmpMeta);
929
- if (Cstr.then) {
930
- // Await creates a micro-task avoid if possible
931
- const endLoad = uniqueTime();
932
- Cstr = await Cstr;
933
- endLoad();
934
- }
935
- if (!Cstr.isProxied) {
936
- proxyComponent(Cstr, cmpMeta, 2 /* PROXY_FLAGS.proxyState */);
937
- Cstr.isProxied = true;
938
- }
939
- const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
940
- // ok, time to construct the instance
941
- // but let's keep track of when we start and stop
942
- // so that the getters/setters don't incorrectly step on data
943
- {
944
- hostRef.$flags$ |= 8 /* HOST_FLAGS.isConstructingInstance */;
945
- }
946
- // construct the lazy-loaded component implementation
947
- // passing the hostRef is very important during
948
- // construction in order to directly wire together the
949
- // host element and the lazy-loaded instance
950
- try {
951
- new Cstr(hostRef);
952
- }
953
- catch (e) {
954
- consoleError(e);
955
- }
956
- {
957
- hostRef.$flags$ &= ~8 /* HOST_FLAGS.isConstructingInstance */;
958
- }
959
- endNewInstance();
960
- fireConnectedCallback(hostRef.$lazyInstance$);
961
- }
962
- if (Cstr.style) {
963
- // this component has styles but we haven't registered them yet
964
- let style = Cstr.style;
965
- const scopeId = getScopeId(cmpMeta);
966
- if (!styles.has(scopeId)) {
967
- const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
968
- registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
969
- endRegisterStyles();
970
- }
971
- }
972
- }
973
- // we've successfully created a lazy instance
974
- const ancestorComponent = hostRef.$ancestorComponent$;
975
- const schedule = () => scheduleUpdate(hostRef, true);
976
- if (ancestorComponent && ancestorComponent['s-rc']) {
977
- // this is the initial load and this component it has an ancestor component
978
- // but the ancestor component has NOT fired its will update lifecycle yet
979
- // so let's just cool our jets and wait for the ancestor to continue first
980
- // this will get fired off when the ancestor component
981
- // finally gets around to rendering its lazy self
982
- // fire off the initial update
983
- ancestorComponent['s-rc'].push(schedule);
984
- }
985
- else {
986
- schedule();
987
- }
988
- };
989
- const fireConnectedCallback = (instance) => {
990
- {
991
- safeCall(instance, 'connectedCallback');
992
- }
993
- };
994
- const connectedCallback = (elm) => {
995
- if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
996
- const hostRef = getHostRef(elm);
997
- const cmpMeta = hostRef.$cmpMeta$;
998
- const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
999
- if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
1000
- // first time this component has connected
1001
- hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
1002
- {
1003
- // find the first ancestor component (if there is one) and register
1004
- // this component as one of the actively loading child components for its ancestor
1005
- let ancestorComponent = elm;
1006
- while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
1007
- // climb up the ancestors looking for the first
1008
- // component that hasn't finished its lifecycle update yet
1009
- if (ancestorComponent['s-p']) {
1010
- // we found this components first ancestor component
1011
- // keep a reference to this component's ancestor component
1012
- attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
1013
- break;
1014
- }
1015
- }
1016
- }
1017
- // Lazy properties
1018
- // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1019
- if (cmpMeta.$members$) {
1020
- Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
1021
- if (memberFlags & 31 /* MEMBER_FLAGS.Prop */ && elm.hasOwnProperty(memberName)) {
1022
- const value = elm[memberName];
1023
- delete elm[memberName];
1024
- elm[memberName] = value;
1025
- }
1026
- });
1027
- }
1028
- {
1029
- initializeComponent(elm, hostRef, cmpMeta);
1030
- }
1031
- }
1032
- else {
1033
- // fire off connectedCallback() on component instance
1034
- if (hostRef === null || hostRef === void 0 ? void 0 : hostRef.$lazyInstance$) {
1035
- fireConnectedCallback(hostRef.$lazyInstance$);
1036
- }
1037
- else if (hostRef === null || hostRef === void 0 ? void 0 : hostRef.$onReadyPromise$) {
1038
- hostRef.$onReadyPromise$.then(() => fireConnectedCallback(hostRef.$lazyInstance$));
1039
- }
1040
- }
1041
- endConnected();
1042
- }
1043
- };
1044
- const disconnectInstance = (instance) => {
1045
- {
1046
- safeCall(instance, 'disconnectedCallback');
1047
- }
1048
- };
1049
- const disconnectedCallback = async (elm) => {
1050
- if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
1051
- const hostRef = getHostRef(elm);
1052
- if (hostRef === null || hostRef === void 0 ? void 0 : hostRef.$lazyInstance$) {
1053
- disconnectInstance(hostRef.$lazyInstance$);
1054
- }
1055
- else if (hostRef === null || hostRef === void 0 ? void 0 : hostRef.$onReadyPromise$) {
1056
- hostRef.$onReadyPromise$.then(() => disconnectInstance(hostRef.$lazyInstance$));
1057
- }
1058
- }
1059
- };
1060
- const bootstrapLazy = (lazyBundles, options = {}) => {
1061
- var _a;
1062
- const endBootstrap = createTime();
1063
- const cmpTags = [];
1064
- const exclude = options.exclude || [];
1065
- const customElements = win.customElements;
1066
- const head = doc.head;
1067
- const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
1068
- const visibilityStyle = /*@__PURE__*/ doc.createElement('style');
1069
- const deferredConnectedCallbacks = [];
1070
- let appLoadFallback;
1071
- let isBootstrapping = true;
1072
- Object.assign(plt, options);
1073
- plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
1074
- lazyBundles.map((lazyBundle) => {
1075
- lazyBundle[1].map((compactMeta) => {
1076
- const cmpMeta = {
1077
- $flags$: compactMeta[0],
1078
- $tagName$: compactMeta[1],
1079
- $members$: compactMeta[2],
1080
- $listeners$: compactMeta[3],
1081
- };
1082
- {
1083
- cmpMeta.$members$ = compactMeta[2];
1084
- }
1085
- const tagName = cmpMeta.$tagName$;
1086
- const HostElement = class extends HTMLElement {
1087
- // StencilLazyHost
1088
- constructor(self) {
1089
- // @ts-ignore
1090
- super(self);
1091
- self = this;
1092
- registerHost(self, cmpMeta);
1093
- }
1094
- connectedCallback() {
1095
- if (appLoadFallback) {
1096
- clearTimeout(appLoadFallback);
1097
- appLoadFallback = null;
1098
- }
1099
- if (isBootstrapping) {
1100
- // connectedCallback will be processed once all components have been registered
1101
- deferredConnectedCallbacks.push(this);
1102
- }
1103
- else {
1104
- plt.jmp(() => connectedCallback(this));
1105
- }
1106
- }
1107
- disconnectedCallback() {
1108
- plt.jmp(() => disconnectedCallback(this));
1109
- }
1110
- componentOnReady() {
1111
- return getHostRef(this).$onReadyPromise$;
1112
- }
1113
- };
1114
- cmpMeta.$lazyBundleId$ = lazyBundle[0];
1115
- if (!exclude.includes(tagName) && !customElements.get(tagName)) {
1116
- cmpTags.push(tagName);
1117
- customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */));
1118
- }
1119
- });
1120
- });
1121
- {
1122
- visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
1123
- visibilityStyle.setAttribute('data-styles', '');
1124
- // Apply CSP nonce to the style tag if it exists
1125
- const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
1126
- if (nonce != null) {
1127
- visibilityStyle.setAttribute('nonce', nonce);
1128
- }
1129
- head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
1130
- }
1131
- // Process deferred connectedCallbacks now all components have been registered
1132
- isBootstrapping = false;
1133
- if (deferredConnectedCallbacks.length) {
1134
- deferredConnectedCallbacks.map((host) => host.connectedCallback());
1135
- }
1136
- else {
1137
- {
1138
- plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30)));
1139
- }
1140
- }
1141
- // Fallback appLoad event
1142
- endBootstrap();
1143
- };
1144
- /**
1145
- * Assigns the given value to the nonce property on the runtime platform object.
1146
- * During runtime, this value is used to set the nonce attribute on all dynamically created script and style tags.
1147
- * @param nonce The value to be assigned to the platform nonce property.
1148
- * @returns void
1149
- */
1150
- const setNonce = (nonce) => (plt.$nonce$ = nonce);
1151
- const hostRefs = /*@__PURE__*/ new WeakMap();
1152
- const getHostRef = (ref) => hostRefs.get(ref);
1153
- const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
1154
- const registerHost = (elm, cmpMeta) => {
1155
- const hostRef = {
1156
- $flags$: 0,
1157
- $hostElement$: elm,
1158
- $cmpMeta$: cmpMeta,
1159
- $instanceValues$: new Map(),
1160
- };
1161
- {
1162
- hostRef.$onReadyPromise$ = new Promise((r) => (hostRef.$onReadyResolve$ = r));
1163
- elm['s-p'] = [];
1164
- elm['s-rc'] = [];
1165
- }
1166
- return hostRefs.set(elm, hostRef);
1167
- };
1168
- const consoleError = (e, el) => (0, console.error)(e, el);
1169
- const cmpModules = /*@__PURE__*/ new Map();
1170
- const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
1171
- // loadModuleImport
1172
- const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
1173
- const bundleId = cmpMeta.$lazyBundleId$;
1174
- const module = cmpModules.get(bundleId) ;
1175
- if (module) {
1176
- return module[exportName];
1177
- }
1178
- /*!__STENCIL_STATIC_IMPORT_SWITCH__*/
1179
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
1180
- /* @vite-ignore */
1181
- /* webpackInclude: /\.entry\.js$/ */
1182
- /* webpackExclude: /\.system\.entry\.js$/ */
1183
- /* webpackMode: "lazy" */
1184
- `./${bundleId}.entry.js${''}`)); }).then((importedModule) => {
1185
- {
1186
- cmpModules.set(bundleId, importedModule);
1187
- }
1188
- return importedModule[exportName];
1189
- }, consoleError);
1190
- };
1191
- const styles = /*@__PURE__*/ new Map();
1192
- const win = typeof window !== 'undefined' ? window : {};
1193
- const doc = win.document || { head: {} };
1194
- const plt = {
1195
- $flags$: 0,
1196
- $resourcesUrl$: '',
1197
- jmp: (h) => h(),
1198
- raf: (h) => requestAnimationFrame(h),
1199
- ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
1200
- rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
1201
- ce: (eventName, opts) => new CustomEvent(eventName, opts),
1202
- };
1203
- const promiseResolve = (v) => Promise.resolve(v);
1204
- const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
1205
- try {
1206
- new CSSStyleSheet();
1207
- return typeof new CSSStyleSheet().replaceSync === 'function';
1208
- }
1209
- catch (e) { }
1210
- return false;
1211
- })()
1212
- ;
1213
- const queueDomReads = [];
1214
- const queueDomWrites = [];
1215
- const queueTask = (queue, write) => (cb) => {
1216
- queue.push(cb);
1217
- if (!queuePending) {
1218
- queuePending = true;
1219
- if (write && plt.$flags$ & 4 /* PLATFORM_FLAGS.queueSync */) {
1220
- nextTick(flush);
1221
- }
1222
- else {
1223
- plt.raf(flush);
1224
- }
1225
- }
1226
- };
1227
- const consume = (queue) => {
1228
- for (let i = 0; i < queue.length; i++) {
1229
- try {
1230
- queue[i](performance.now());
1231
- }
1232
- catch (e) {
1233
- consoleError(e);
1234
- }
1235
- }
1236
- queue.length = 0;
1237
- };
1238
- const flush = () => {
1239
- // always force a bunch of medium callbacks to run, but still have
1240
- // a throttle on how many can run in a certain time
1241
- // DOM READS!!!
1242
- consume(queueDomReads);
1243
- // DOM WRITES!!!
1244
- {
1245
- consume(queueDomWrites);
1246
- if ((queuePending = queueDomReads.length > 0)) {
1247
- // still more to do yet, but we've run out of time
1248
- // let's let this thing cool off and try again in the next tick
1249
- plt.raf(flush);
1250
- }
1251
- }
1252
- };
1253
- const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
1254
- const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
1255
-
1256
- exports.Host = Host;
1257
- exports.bootstrapLazy = bootstrapLazy;
1258
- exports.forceUpdate = forceUpdate;
1259
- exports.getElement = getElement;
1260
- exports.h = h;
1261
- exports.promiseResolve = promiseResolve;
1262
- exports.registerInstance = registerInstance;
1263
- exports.setNonce = setNonce;
1264
-
1265
- //# sourceMappingURL=index-5f6f12ab.js.map