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