@siemens/ix-aggrid 1.0.0-beta.2

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