@siemens/ix-aggrid 2.0.2 → 2.0.4-beta.0

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