@ppg_pl/pallete 0.0.2 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/README.md +11 -0
  2. package/dist/pallete/app-globals-0f993ce5.js +3 -0
  3. package/dist/pallete/css-shim-60f618b9.js +4 -0
  4. package/dist/pallete/dom-4eeb3fee.js +73 -0
  5. package/dist/pallete/index-1ac7471e.js +3059 -0
  6. package/dist/pallete/index.esm.js +1 -0
  7. package/dist/pallete/my-backdrop.entry.js +15 -0
  8. package/dist/pallete/my-colorbox.entry.js +40 -0
  9. package/dist/{components/my-colorinfo2.js → pallete/my-colorinfo.entry.js} +7 -35
  10. package/dist/{components/my-component.js → pallete/my-component.entry.js} +10 -72
  11. package/dist/pallete/my-loader.entry.js +15 -0
  12. package/dist/{components/my-modal2.js → pallete/my-modal.entry.js} +84 -76
  13. package/dist/pallete/my-search.entry.js +36 -0
  14. package/dist/pallete/my-slider.entry.js +11333 -0
  15. package/dist/pallete/pallete.css +3 -1
  16. package/dist/pallete/pallete.esm.js +129 -1
  17. package/dist/pallete/shadow-css-02866686.js +387 -0
  18. package/package.json +1 -1
  19. package/www/build/app-globals-0f993ce5.js +3 -0
  20. package/www/build/css-shim-60f618b9.js +4 -0
  21. package/www/build/dom-4eeb3fee.js +73 -0
  22. package/www/build/gtmUtils-dcdac4ce.js +5 -0
  23. package/www/build/index-1ac7471e.js +3059 -0
  24. package/www/build/index.esm.js +1 -0
  25. package/www/build/my-backdrop.entry.js +15 -0
  26. package/www/build/my-colorbox.entry.js +40 -0
  27. package/www/build/my-colorinfo.entry.js +36 -0
  28. package/www/build/my-component.entry.js +154 -0
  29. package/www/build/my-loader.entry.js +15 -0
  30. package/www/build/my-modal.entry.js +2459 -0
  31. package/www/build/my-search.entry.js +36 -0
  32. package/www/build/my-slider.entry.js +11333 -0
  33. package/www/build/pallete.css +3 -1
  34. package/www/build/pallete.esm.js +129 -1
  35. package/www/build/shadow-css-02866686.js +387 -0
  36. package/www/index.html +40 -2
  37. package/dist/cjs/index-029079e0.js +0 -1365
  38. package/dist/cjs/index.cjs.js +0 -2
  39. package/dist/cjs/loader.cjs.js +0 -21
  40. package/dist/cjs/my-backdrop_8.cjs.entry.js +0 -8109
  41. package/dist/cjs/pallete.cjs.js +0 -19
  42. package/dist/collection/collection-manifest.json +0 -19
  43. package/dist/collection/components/api/index.js +0 -19
  44. package/dist/collection/components/api/services.js +0 -81
  45. package/dist/collection/components/my-backdrop/my-backdrop.css +0 -21
  46. package/dist/collection/components/my-backdrop/my-backdrop.js +0 -13
  47. package/dist/collection/components/my-colorbox/my-colorbox.css +0 -60
  48. package/dist/collection/components/my-colorbox/my-colorbox.js +0 -145
  49. package/dist/collection/components/my-colorinfo/my-colorinfo.js +0 -197
  50. package/dist/collection/components/my-component/my-component.css +0 -6
  51. package/dist/collection/components/my-component/my-component.js +0 -107
  52. package/dist/collection/components/my-loader/my-loader.css +0 -85
  53. package/dist/collection/components/my-loader/my-loader.js +0 -18
  54. package/dist/collection/components/my-modal/assets/arrow_down.png +0 -0
  55. package/dist/collection/components/my-modal/assets/close.png +0 -0
  56. package/dist/collection/components/my-modal/my-modal.css +0 -323
  57. package/dist/collection/components/my-modal/my-modal.js +0 -430
  58. package/dist/collection/components/my-search/assets/search.svg +0 -15
  59. package/dist/collection/components/my-search/my-search.css +0 -43
  60. package/dist/collection/components/my-search/my-search.js +0 -113
  61. package/dist/collection/components/my-slider/index.js +0 -145
  62. package/dist/collection/components/my-slider/my-slider.css +0 -96
  63. package/dist/collection/gtmUtils.js +0 -3
  64. package/dist/collection/index.js +0 -1
  65. package/dist/collection/types.js +0 -1
  66. package/dist/components/index.js +0 -9
  67. package/dist/components/index2.js +0 -5458
  68. package/dist/components/my-backdrop.js +0 -6
  69. package/dist/components/my-backdrop2.js +0 -29
  70. package/dist/components/my-colorbox.js +0 -6
  71. package/dist/components/my-colorbox2.js +0 -61
  72. package/dist/components/my-colorinfo.js +0 -6
  73. package/dist/components/my-loader.js +0 -6
  74. package/dist/components/my-loader2.js +0 -29
  75. package/dist/components/my-modal.js +0 -6
  76. package/dist/components/my-search.js +0 -6
  77. package/dist/components/my-search2.js +0 -55
  78. package/dist/components/my-slider.js +0 -6
  79. package/dist/esm/index-faf4241e.js +0 -1337
  80. package/dist/esm/index.js +0 -1
  81. package/dist/esm/loader.js +0 -17
  82. package/dist/esm/my-backdrop_8.entry.js +0 -8098
  83. package/dist/esm/pallete.js +0 -17
  84. package/dist/esm/polyfills/core-js.js +0 -11
  85. package/dist/esm/polyfills/css-shim.js +0 -1
  86. package/dist/esm/polyfills/dom.js +0 -79
  87. package/dist/esm/polyfills/es5-html-element.js +0 -1
  88. package/dist/esm/polyfills/index.js +0 -34
  89. package/dist/esm/polyfills/system.js +0 -6
  90. package/dist/index.cjs.js +0 -1
  91. package/dist/index.js +0 -1
  92. package/dist/pallete/p-562ae52f.js +0 -2
  93. package/dist/pallete/p-e260bfb9.entry.js +0 -1
  94. package/www/build/p-562ae52f.js +0 -2
  95. package/www/build/p-b6a676fa.css +0 -11
  96. package/www/build/p-e260bfb9.entry.js +0 -1
  97. package/www/build/p-ef55983a.js +0 -129
  98. /package/dist/{components/gtmUtils.js → pallete/gtmUtils-dcdac4ce.js} +0 -0
@@ -1,1365 +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 = 'pallete';
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 supportsConstructibleStylesheets = /*@__PURE__*/ (() => {
41
- try {
42
- new CSSStyleSheet();
43
- return typeof new CSSStyleSheet().replace === 'function';
44
- }
45
- catch (e) { }
46
- return false;
47
- })()
48
- ;
49
- const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
50
- if (listeners) {
51
- listeners.map(([flags, name, method]) => {
52
- const target = getHostListenerTarget(elm, flags) ;
53
- const handler = hostListenerProxy(hostRef, method);
54
- const opts = hostListenerOpts(flags);
55
- plt.ael(target, name, handler, opts);
56
- (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
57
- });
58
- }
59
- };
60
- const hostListenerProxy = (hostRef, methodName) => (ev) => {
61
- try {
62
- {
63
- if (hostRef.$flags$ & 256 /* isListenReady */) {
64
- // instance is ready, let's call it's member method for this event
65
- hostRef.$lazyInstance$[methodName](ev);
66
- }
67
- else {
68
- (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
69
- }
70
- }
71
- }
72
- catch (e) {
73
- consoleError(e);
74
- }
75
- };
76
- const getHostListenerTarget = (elm, flags) => {
77
- if (flags & 8 /* TargetWindow */)
78
- return win;
79
- return elm;
80
- };
81
- // prettier-ignore
82
- const hostListenerOpts = (flags) => (flags & 2 /* Capture */) !== 0;
83
- const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
84
- const createTime = (fnName, tagName = '') => {
85
- {
86
- return () => {
87
- return;
88
- };
89
- }
90
- };
91
- const uniqueTime = (key, measureText) => {
92
- {
93
- return () => {
94
- return;
95
- };
96
- }
97
- };
98
- const rootAppliedStyles = new WeakMap();
99
- const registerStyle = (scopeId, cssText, allowCS) => {
100
- let style = styles.get(scopeId);
101
- if (supportsConstructibleStylesheets && allowCS) {
102
- style = (style || new CSSStyleSheet());
103
- style.replace(cssText);
104
- }
105
- else {
106
- style = cssText;
107
- }
108
- styles.set(scopeId, style);
109
- };
110
- const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
111
- let scopeId = getScopeId(cmpMeta);
112
- const style = styles.get(scopeId);
113
- // if an element is NOT connected then getRootNode() will return the wrong root node
114
- // so the fallback is to always use the document for the root node in those cases
115
- styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
116
- if (style) {
117
- if (typeof style === 'string') {
118
- styleContainerNode = styleContainerNode.head || styleContainerNode;
119
- let appliedStyles = rootAppliedStyles.get(styleContainerNode);
120
- let styleElm;
121
- if (!appliedStyles) {
122
- rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
123
- }
124
- if (!appliedStyles.has(scopeId)) {
125
- {
126
- {
127
- styleElm = doc.createElement('style');
128
- styleElm.innerHTML = style;
129
- }
130
- styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
131
- }
132
- if (appliedStyles) {
133
- appliedStyles.add(scopeId);
134
- }
135
- }
136
- }
137
- else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
138
- styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
139
- }
140
- }
141
- return scopeId;
142
- };
143
- const attachStyles = (hostRef) => {
144
- const cmpMeta = hostRef.$cmpMeta$;
145
- const elm = hostRef.$hostElement$;
146
- const flags = cmpMeta.$flags$;
147
- const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
148
- const scopeId = addStyle(elm.getRootNode(), cmpMeta);
149
- if (flags & 10 /* needsScopedEncapsulation */) {
150
- // only required when we're NOT using native shadow dom (slot)
151
- // or this browser doesn't support native shadow dom
152
- // and this host element was NOT created with SSR
153
- // let's pick out the inner content for slot projection
154
- // create a node to represent where the original
155
- // content was first placed, which is useful later on
156
- // DOM WRITE!!
157
- elm['s-sc'] = scopeId;
158
- elm.classList.add(scopeId + '-h');
159
- if (flags & 2 /* scopedCssEncapsulation */) {
160
- elm.classList.add(scopeId + '-s');
161
- }
162
- }
163
- endAttachStyles();
164
- };
165
- const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
166
- /**
167
- * Default style mode id
168
- */
169
- /**
170
- * Reusable empty obj/array
171
- * Don't add values to these!!
172
- */
173
- const EMPTY_OBJ = {};
174
- const isDef = (v) => v != null;
175
- const isComplexType = (o) => {
176
- // https://jsperf.com/typeof-fn-object/5
177
- o = typeof o;
178
- return o === 'object' || o === 'function';
179
- };
180
- /**
181
- * Production h() function based on Preact by
182
- * Jason Miller (@developit)
183
- * Licensed under the MIT License
184
- * https://github.com/developit/preact/blob/master/LICENSE
185
- *
186
- * Modified for Stencil's compiler and vdom
187
- */
188
- // const stack: any[] = [];
189
- // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
190
- // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
191
- const h = (nodeName, vnodeData, ...children) => {
192
- let child = null;
193
- let key = null;
194
- let simple = false;
195
- let lastSimple = false;
196
- const vNodeChildren = [];
197
- const walk = (c) => {
198
- for (let i = 0; i < c.length; i++) {
199
- child = c[i];
200
- if (Array.isArray(child)) {
201
- walk(child);
202
- }
203
- else if (child != null && typeof child !== 'boolean') {
204
- if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
205
- child = String(child);
206
- }
207
- if (simple && lastSimple) {
208
- // If the previous child was simple (string), we merge both
209
- vNodeChildren[vNodeChildren.length - 1].$text$ += child;
210
- }
211
- else {
212
- // Append a new vNode, if it's text, we create a text vNode
213
- vNodeChildren.push(simple ? newVNode(null, child) : child);
214
- }
215
- lastSimple = simple;
216
- }
217
- }
218
- };
219
- walk(children);
220
- if (vnodeData) {
221
- // normalize class / classname attributes
222
- if (vnodeData.key) {
223
- key = vnodeData.key;
224
- }
225
- {
226
- const classData = vnodeData.className || vnodeData.class;
227
- if (classData) {
228
- vnodeData.class =
229
- typeof classData !== 'object'
230
- ? classData
231
- : Object.keys(classData)
232
- .filter((k) => classData[k])
233
- .join(' ');
234
- }
235
- }
236
- }
237
- if (typeof nodeName === 'function') {
238
- // nodeName is a functional component
239
- return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
240
- }
241
- const vnode = newVNode(nodeName, null);
242
- vnode.$attrs$ = vnodeData;
243
- if (vNodeChildren.length > 0) {
244
- vnode.$children$ = vNodeChildren;
245
- }
246
- {
247
- vnode.$key$ = key;
248
- }
249
- return vnode;
250
- };
251
- const newVNode = (tag, text) => {
252
- const vnode = {
253
- $flags$: 0,
254
- $tag$: tag,
255
- $text$: text,
256
- $elm$: null,
257
- $children$: null,
258
- };
259
- {
260
- vnode.$attrs$ = null;
261
- }
262
- {
263
- vnode.$key$ = null;
264
- }
265
- return vnode;
266
- };
267
- const Host = {};
268
- const isHost = (node) => node && node.$tag$ === Host;
269
- const vdomFnUtils = {
270
- forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
271
- map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate),
272
- };
273
- const convertToPublic = (node) => ({
274
- vattrs: node.$attrs$,
275
- vchildren: node.$children$,
276
- vkey: node.$key$,
277
- vname: node.$name$,
278
- vtag: node.$tag$,
279
- vtext: node.$text$,
280
- });
281
- const convertToPrivate = (node) => {
282
- if (typeof node.vtag === 'function') {
283
- const vnodeData = Object.assign({}, node.vattrs);
284
- if (node.vkey) {
285
- vnodeData.key = node.vkey;
286
- }
287
- if (node.vname) {
288
- vnodeData.name = node.vname;
289
- }
290
- return h(node.vtag, vnodeData, ...(node.vchildren || []));
291
- }
292
- const vnode = newVNode(node.vtag, node.vtext);
293
- vnode.$attrs$ = node.vattrs;
294
- vnode.$children$ = node.vchildren;
295
- vnode.$key$ = node.vkey;
296
- vnode.$name$ = node.vname;
297
- return vnode;
298
- };
299
- /**
300
- * Production setAccessor() function based on Preact by
301
- * Jason Miller (@developit)
302
- * Licensed under the MIT License
303
- * https://github.com/developit/preact/blob/master/LICENSE
304
- *
305
- * Modified for Stencil's compiler and vdom
306
- */
307
- const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
308
- if (oldValue !== newValue) {
309
- let isProp = isMemberInElement(elm, memberName);
310
- let ln = memberName.toLowerCase();
311
- if (memberName === 'class') {
312
- const classList = elm.classList;
313
- const oldClasses = parseClassList(oldValue);
314
- const newClasses = parseClassList(newValue);
315
- classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
316
- classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
317
- }
318
- else if (memberName === 'style') {
319
- // update style attribute, css properties and values
320
- {
321
- for (const prop in oldValue) {
322
- if (!newValue || newValue[prop] == null) {
323
- if (prop.includes('-')) {
324
- elm.style.removeProperty(prop);
325
- }
326
- else {
327
- elm.style[prop] = '';
328
- }
329
- }
330
- }
331
- }
332
- for (const prop in newValue) {
333
- if (!oldValue || newValue[prop] !== oldValue[prop]) {
334
- if (prop.includes('-')) {
335
- elm.style.setProperty(prop, newValue[prop]);
336
- }
337
- else {
338
- elm.style[prop] = newValue[prop];
339
- }
340
- }
341
- }
342
- }
343
- else if (memberName === 'key')
344
- ;
345
- else if ((!isProp ) &&
346
- memberName[0] === 'o' &&
347
- memberName[1] === 'n') {
348
- // Event Handlers
349
- // so if the member name starts with "on" and the 3rd characters is
350
- // a capital letter, and it's not already a member on the element,
351
- // then we're assuming it's an event listener
352
- if (memberName[2] === '-') {
353
- // on- prefixed events
354
- // allows to be explicit about the dom event to listen without any magic
355
- // under the hood:
356
- // <my-cmp on-click> // listens for "click"
357
- // <my-cmp on-Click> // listens for "Click"
358
- // <my-cmp on-ionChange> // listens for "ionChange"
359
- // <my-cmp on-EVENTS> // listens for "EVENTS"
360
- memberName = memberName.slice(3);
361
- }
362
- else if (isMemberInElement(win, ln)) {
363
- // standard event
364
- // the JSX attribute could have been "onMouseOver" and the
365
- // member name "onmouseover" is on the window's prototype
366
- // so let's add the listener "mouseover", which is all lowercased
367
- memberName = ln.slice(2);
368
- }
369
- else {
370
- // custom event
371
- // the JSX attribute could have been "onMyCustomEvent"
372
- // so let's trim off the "on" prefix and lowercase the first character
373
- // and add the listener "myCustomEvent"
374
- // except for the first character, we keep the event name case
375
- memberName = ln[2] + memberName.slice(3);
376
- }
377
- if (oldValue) {
378
- plt.rel(elm, memberName, oldValue, false);
379
- }
380
- if (newValue) {
381
- plt.ael(elm, memberName, newValue, false);
382
- }
383
- }
384
- else {
385
- // Set property if it exists and it's not a SVG
386
- const isComplex = isComplexType(newValue);
387
- if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
388
- try {
389
- if (!elm.tagName.includes('-')) {
390
- const n = newValue == null ? '' : newValue;
391
- // Workaround for Safari, moving the <input> caret when re-assigning the same valued
392
- if (memberName === 'list') {
393
- isProp = false;
394
- }
395
- else if (oldValue == null || elm[memberName] != n) {
396
- elm[memberName] = n;
397
- }
398
- }
399
- else {
400
- elm[memberName] = newValue;
401
- }
402
- }
403
- catch (e) { }
404
- }
405
- if (newValue == null || newValue === false) {
406
- if (newValue !== false || elm.getAttribute(memberName) === '') {
407
- {
408
- elm.removeAttribute(memberName);
409
- }
410
- }
411
- }
412
- else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
413
- newValue = newValue === true ? '' : newValue;
414
- {
415
- elm.setAttribute(memberName, newValue);
416
- }
417
- }
418
- }
419
- }
420
- };
421
- const parseClassListRegex = /\s/;
422
- const parseClassList = (value) => (!value ? [] : value.split(parseClassListRegex));
423
- const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
424
- // if the element passed in is a shadow root, which is a document fragment
425
- // then we want to be adding attrs/props to the shadow root's "host" element
426
- // if it's not a shadow root, then we add attrs/props to the same element
427
- const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host
428
- ? newVnode.$elm$.host
429
- : newVnode.$elm$;
430
- const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
431
- const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
432
- {
433
- // remove attributes no longer present on the vnode by setting them to undefined
434
- for (memberName in oldVnodeAttrs) {
435
- if (!(memberName in newVnodeAttrs)) {
436
- setAccessor(elm, memberName, oldVnodeAttrs[memberName], undefined, isSvgMode, newVnode.$flags$);
437
- }
438
- }
439
- }
440
- // add new & update changed attributes
441
- for (memberName in newVnodeAttrs) {
442
- setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
443
- }
444
- };
445
- const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
446
- // tslint:disable-next-line: prefer-const
447
- const newVNode = newParentVNode.$children$[childIndex];
448
- let i = 0;
449
- let elm;
450
- let childNode;
451
- if (newVNode.$text$ !== null) {
452
- // create text node
453
- elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
454
- }
455
- else {
456
- // create element
457
- elm = newVNode.$elm$ = (doc.createElement(newVNode.$tag$));
458
- // add css classes, attrs, props, listeners, etc.
459
- {
460
- updateElement(null, newVNode, isSvgMode);
461
- }
462
- if (isDef(scopeId) && elm['s-si'] !== scopeId) {
463
- // if there is a scopeId and this is the initial render
464
- // then let's add the scopeId as a css class
465
- elm.classList.add((elm['s-si'] = scopeId));
466
- }
467
- if (newVNode.$children$) {
468
- for (i = 0; i < newVNode.$children$.length; ++i) {
469
- // create the node
470
- childNode = createElm(oldParentVNode, newVNode, i);
471
- // return node could have been null
472
- if (childNode) {
473
- // append our new node
474
- elm.appendChild(childNode);
475
- }
476
- }
477
- }
478
- }
479
- return elm;
480
- };
481
- const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
482
- let containerElm = (parentElm);
483
- let childNode;
484
- for (; startIdx <= endIdx; ++startIdx) {
485
- if (vnodes[startIdx]) {
486
- childNode = createElm(null, parentVNode, startIdx);
487
- if (childNode) {
488
- vnodes[startIdx].$elm$ = childNode;
489
- containerElm.insertBefore(childNode, before);
490
- }
491
- }
492
- }
493
- };
494
- const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
495
- for (; startIdx <= endIdx; ++startIdx) {
496
- if ((vnode = vnodes[startIdx])) {
497
- elm = vnode.$elm$;
498
- // remove the vnode's element from the dom
499
- elm.remove();
500
- }
501
- }
502
- };
503
- const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
504
- let oldStartIdx = 0;
505
- let newStartIdx = 0;
506
- let idxInOld = 0;
507
- let i = 0;
508
- let oldEndIdx = oldCh.length - 1;
509
- let oldStartVnode = oldCh[0];
510
- let oldEndVnode = oldCh[oldEndIdx];
511
- let newEndIdx = newCh.length - 1;
512
- let newStartVnode = newCh[0];
513
- let newEndVnode = newCh[newEndIdx];
514
- let node;
515
- let elmToMove;
516
- while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
517
- if (oldStartVnode == null) {
518
- // Vnode might have been moved left
519
- oldStartVnode = oldCh[++oldStartIdx];
520
- }
521
- else if (oldEndVnode == null) {
522
- oldEndVnode = oldCh[--oldEndIdx];
523
- }
524
- else if (newStartVnode == null) {
525
- newStartVnode = newCh[++newStartIdx];
526
- }
527
- else if (newEndVnode == null) {
528
- newEndVnode = newCh[--newEndIdx];
529
- }
530
- else if (isSameVnode(oldStartVnode, newStartVnode)) {
531
- patch(oldStartVnode, newStartVnode);
532
- oldStartVnode = oldCh[++oldStartIdx];
533
- newStartVnode = newCh[++newStartIdx];
534
- }
535
- else if (isSameVnode(oldEndVnode, newEndVnode)) {
536
- patch(oldEndVnode, newEndVnode);
537
- oldEndVnode = oldCh[--oldEndIdx];
538
- newEndVnode = newCh[--newEndIdx];
539
- }
540
- else if (isSameVnode(oldStartVnode, newEndVnode)) {
541
- patch(oldStartVnode, newEndVnode);
542
- parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
543
- oldStartVnode = oldCh[++oldStartIdx];
544
- newEndVnode = newCh[--newEndIdx];
545
- }
546
- else if (isSameVnode(oldEndVnode, newStartVnode)) {
547
- patch(oldEndVnode, newStartVnode);
548
- parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
549
- oldEndVnode = oldCh[--oldEndIdx];
550
- newStartVnode = newCh[++newStartIdx];
551
- }
552
- else {
553
- // createKeyToOldIdx
554
- idxInOld = -1;
555
- {
556
- for (i = oldStartIdx; i <= oldEndIdx; ++i) {
557
- if (oldCh[i] && oldCh[i].$key$ !== null && oldCh[i].$key$ === newStartVnode.$key$) {
558
- idxInOld = i;
559
- break;
560
- }
561
- }
562
- }
563
- if (idxInOld >= 0) {
564
- elmToMove = oldCh[idxInOld];
565
- if (elmToMove.$tag$ !== newStartVnode.$tag$) {
566
- node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld);
567
- }
568
- else {
569
- patch(elmToMove, newStartVnode);
570
- oldCh[idxInOld] = undefined;
571
- node = elmToMove.$elm$;
572
- }
573
- newStartVnode = newCh[++newStartIdx];
574
- }
575
- else {
576
- // new element
577
- node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
578
- newStartVnode = newCh[++newStartIdx];
579
- }
580
- if (node) {
581
- {
582
- oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
583
- }
584
- }
585
- }
586
- }
587
- if (oldStartIdx > oldEndIdx) {
588
- addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
589
- }
590
- else if (newStartIdx > newEndIdx) {
591
- removeVnodes(oldCh, oldStartIdx, oldEndIdx);
592
- }
593
- };
594
- const isSameVnode = (vnode1, vnode2) => {
595
- // compare if two vnode to see if they're "technically" the same
596
- // need to have the same element tag, and same key to be the same
597
- if (vnode1.$tag$ === vnode2.$tag$) {
598
- {
599
- return vnode1.$key$ === vnode2.$key$;
600
- }
601
- }
602
- return false;
603
- };
604
- const patch = (oldVNode, newVNode) => {
605
- const elm = (newVNode.$elm$ = oldVNode.$elm$);
606
- const oldChildren = oldVNode.$children$;
607
- const newChildren = newVNode.$children$;
608
- const text = newVNode.$text$;
609
- if (text === null) {
610
- // element node
611
- {
612
- {
613
- // either this is the first render of an element OR it's an update
614
- // AND we already know it's possible it could have changed
615
- // this updates the element's css classes, attrs, props, listeners, etc.
616
- updateElement(oldVNode, newVNode, isSvgMode);
617
- }
618
- }
619
- if (oldChildren !== null && newChildren !== null) {
620
- // looks like there's child vnodes for both the old and new vnodes
621
- updateChildren(elm, oldChildren, newVNode, newChildren);
622
- }
623
- else if (newChildren !== null) {
624
- // no old child vnodes, but there are new child vnodes to add
625
- if (oldVNode.$text$ !== null) {
626
- // the old vnode was text, so be sure to clear it out
627
- elm.textContent = '';
628
- }
629
- // add the new vnode children
630
- addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
631
- }
632
- else if (oldChildren !== null) {
633
- // no new child vnodes, but there are old child vnodes to remove
634
- removeVnodes(oldChildren, 0, oldChildren.length - 1);
635
- }
636
- }
637
- else if (oldVNode.$text$ !== text) {
638
- // update the text content for the text only vnode
639
- // and also only if the text is different than before
640
- elm.data = text;
641
- }
642
- };
643
- const renderVdom = (hostRef, renderFnResults) => {
644
- const hostElm = hostRef.$hostElement$;
645
- const oldVNode = hostRef.$vnode$ || newVNode(null, null);
646
- const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
647
- rootVnode.$tag$ = null;
648
- rootVnode.$flags$ |= 4 /* isHost */;
649
- hostRef.$vnode$ = rootVnode;
650
- rootVnode.$elm$ = oldVNode.$elm$ = (hostElm);
651
- {
652
- scopeId = hostElm['s-sc'];
653
- }
654
- // synchronous patch
655
- patch(oldVNode, rootVnode);
656
- };
657
- const getElement = (ref) => (getHostRef(ref).$hostElement$ );
658
- const createEvent = (ref, name, flags) => {
659
- const elm = getElement(ref);
660
- return {
661
- emit: (detail) => {
662
- return emitEvent(elm, name, {
663
- bubbles: !!(flags & 4 /* Bubbles */),
664
- composed: !!(flags & 2 /* Composed */),
665
- cancelable: !!(flags & 1 /* Cancellable */),
666
- detail,
667
- });
668
- },
669
- };
670
- };
671
- /**
672
- * Helper function to create & dispatch a custom Event on a provided target
673
- * @param elm the target of the Event
674
- * @param name the name to give the custom Event
675
- * @param opts options for configuring a custom Event
676
- * @returns the custom Event
677
- */
678
- const emitEvent = (elm, name, opts) => {
679
- const ev = plt.ce(name, opts);
680
- elm.dispatchEvent(ev);
681
- return ev;
682
- };
683
- const attachToAncestor = (hostRef, ancestorComponent) => {
684
- if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
685
- ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
686
- }
687
- };
688
- const scheduleUpdate = (hostRef, isInitialLoad) => {
689
- {
690
- hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
691
- }
692
- if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
693
- hostRef.$flags$ |= 512 /* needsRerender */;
694
- return;
695
- }
696
- attachToAncestor(hostRef, hostRef.$ancestorComponent$);
697
- // there is no ancestor component or the ancestor component
698
- // has already fired off its lifecycle update then
699
- // fire off the initial update
700
- const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
701
- return writeTask(dispatch) ;
702
- };
703
- const dispatchHooks = (hostRef, isInitialLoad) => {
704
- const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
705
- const instance = hostRef.$lazyInstance$ ;
706
- let promise;
707
- if (isInitialLoad) {
708
- {
709
- hostRef.$flags$ |= 256 /* isListenReady */;
710
- if (hostRef.$queuedListeners$) {
711
- hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
712
- hostRef.$queuedListeners$ = null;
713
- }
714
- }
715
- {
716
- promise = safeCall(instance, 'componentWillLoad');
717
- }
718
- }
719
- {
720
- promise = then(promise, () => safeCall(instance, 'componentWillRender'));
721
- }
722
- endSchedule();
723
- return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
724
- };
725
- const updateComponent = async (hostRef, instance, isInitialLoad) => {
726
- // updateComponent
727
- const elm = hostRef.$hostElement$;
728
- const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
729
- const rc = elm['s-rc'];
730
- if (isInitialLoad) {
731
- // DOM WRITE!
732
- attachStyles(hostRef);
733
- }
734
- const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
735
- {
736
- callRender(hostRef, instance);
737
- }
738
- if (rc) {
739
- // ok, so turns out there are some child host elements
740
- // waiting on this parent element to load
741
- // let's fire off all update callbacks waiting
742
- rc.map((cb) => cb());
743
- elm['s-rc'] = undefined;
744
- }
745
- endRender();
746
- endUpdate();
747
- {
748
- const childrenPromises = elm['s-p'];
749
- const postUpdate = () => postUpdateComponent(hostRef);
750
- if (childrenPromises.length === 0) {
751
- postUpdate();
752
- }
753
- else {
754
- Promise.all(childrenPromises).then(postUpdate);
755
- hostRef.$flags$ |= 4 /* isWaitingForChildren */;
756
- childrenPromises.length = 0;
757
- }
758
- }
759
- };
760
- const callRender = (hostRef, instance, elm) => {
761
- try {
762
- instance = instance.render() ;
763
- {
764
- hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
765
- }
766
- {
767
- hostRef.$flags$ |= 2 /* hasRendered */;
768
- }
769
- {
770
- {
771
- // looks like we've got child nodes to render into this host element
772
- // or we need to update the css class/attrs on the host element
773
- // DOM WRITE!
774
- {
775
- renderVdom(hostRef, instance);
776
- }
777
- }
778
- }
779
- }
780
- catch (e) {
781
- consoleError(e, hostRef.$hostElement$);
782
- }
783
- return null;
784
- };
785
- const postUpdateComponent = (hostRef) => {
786
- const tagName = hostRef.$cmpMeta$.$tagName$;
787
- const elm = hostRef.$hostElement$;
788
- const endPostUpdate = createTime('postUpdate', tagName);
789
- const instance = hostRef.$lazyInstance$ ;
790
- const ancestorComponent = hostRef.$ancestorComponent$;
791
- if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
792
- hostRef.$flags$ |= 64 /* hasLoadedComponent */;
793
- {
794
- // DOM WRITE!
795
- addHydratedFlag(elm);
796
- }
797
- {
798
- safeCall(instance, 'componentDidLoad');
799
- }
800
- endPostUpdate();
801
- {
802
- hostRef.$onReadyResolve$(elm);
803
- if (!ancestorComponent) {
804
- appDidLoad();
805
- }
806
- }
807
- }
808
- else {
809
- endPostUpdate();
810
- }
811
- {
812
- hostRef.$onInstanceResolve$(elm);
813
- }
814
- // load events fire from bottom to top
815
- // the deepest elements load first then bubbles up
816
- {
817
- if (hostRef.$onRenderResolve$) {
818
- hostRef.$onRenderResolve$();
819
- hostRef.$onRenderResolve$ = undefined;
820
- }
821
- if (hostRef.$flags$ & 512 /* needsRerender */) {
822
- nextTick(() => scheduleUpdate(hostRef, false));
823
- }
824
- hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
825
- }
826
- // ( •_•)
827
- // ( •_•)>⌐■-■
828
- // (⌐■_■)
829
- };
830
- const appDidLoad = (who) => {
831
- // on appload
832
- // we have finish the first big initial render
833
- {
834
- addHydratedFlag(doc.documentElement);
835
- }
836
- nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
837
- };
838
- const safeCall = (instance, method, arg) => {
839
- if (instance && instance[method]) {
840
- try {
841
- return instance[method](arg);
842
- }
843
- catch (e) {
844
- consoleError(e);
845
- }
846
- }
847
- return undefined;
848
- };
849
- const then = (promise, thenFn) => {
850
- return promise && promise.then ? promise.then(thenFn) : thenFn();
851
- };
852
- const addHydratedFlag = (elm) => elm.classList.add('hydrated')
853
- ;
854
- /**
855
- * Parse a new property value for a given property type.
856
- *
857
- * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
858
- * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
859
- * 1. `any`, the type given to `propValue` in the function signature
860
- * 2. the type stored from `propType`.
861
- *
862
- * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
863
- *
864
- * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
865
- * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
866
- * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
867
- * ```tsx
868
- * <my-cmp prop-val={0}></my-cmp>
869
- * ```
870
- *
871
- * HTML prop values on the other hand, will always a string
872
- *
873
- * @param propValue the new value to coerce to some type
874
- * @param propType the type of the prop, expressed as a binary number
875
- * @returns the parsed/coerced value
876
- */
877
- const parsePropertyValue = (propValue, propType) => {
878
- // ensure this value is of the correct prop type
879
- if (propValue != null && !isComplexType(propValue)) {
880
- if (propType & 4 /* Boolean */) {
881
- // per the HTML spec, any string value means it is a boolean true value
882
- // but we'll cheat here and say that the string "false" is the boolean false
883
- return propValue === 'false' ? false : propValue === '' || !!propValue;
884
- }
885
- if (propType & 2 /* Number */) {
886
- // force it to be a number
887
- return parseFloat(propValue);
888
- }
889
- if (propType & 1 /* String */) {
890
- // could have been passed as a number or boolean
891
- // but we still want it as a string
892
- return String(propValue);
893
- }
894
- // redundant return here for better minification
895
- return propValue;
896
- }
897
- // not sure exactly what type we want
898
- // so no need to change to a different type
899
- return propValue;
900
- };
901
- const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
902
- const setValue = (ref, propName, newVal, cmpMeta) => {
903
- // check our new property value against our internal value
904
- const hostRef = getHostRef(ref);
905
- const elm = hostRef.$hostElement$ ;
906
- const oldVal = hostRef.$instanceValues$.get(propName);
907
- const flags = hostRef.$flags$;
908
- const instance = hostRef.$lazyInstance$ ;
909
- newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
910
- // explicitly check for NaN on both sides, as `NaN === NaN` is always false
911
- const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
912
- const didValueChange = newVal !== oldVal && !areBothNaN;
913
- if ((!(flags & 8 /* isConstructingInstance */) || oldVal === undefined) && didValueChange) {
914
- // gadzooks! the property's value has changed!!
915
- // set our new value!
916
- hostRef.$instanceValues$.set(propName, newVal);
917
- if (instance) {
918
- // get an array of method names of watch functions to call
919
- if (cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
920
- const watchMethods = cmpMeta.$watchers$[propName];
921
- if (watchMethods) {
922
- // this instance is watching for when this property changed
923
- watchMethods.map((watchMethodName) => {
924
- try {
925
- // fire off each of the watch methods that are watching this property
926
- instance[watchMethodName](newVal, oldVal, propName);
927
- }
928
- catch (e) {
929
- consoleError(e, elm);
930
- }
931
- });
932
- }
933
- }
934
- if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
935
- // looks like this value actually changed, so we've got work to do!
936
- // but only if we've already rendered, otherwise just chill out
937
- // queue that we need to do an update, but don't worry about queuing
938
- // up millions cuz this function ensures it only runs once
939
- scheduleUpdate(hostRef, false);
940
- }
941
- }
942
- }
943
- };
944
- const proxyComponent = (Cstr, cmpMeta, flags) => {
945
- if (cmpMeta.$members$) {
946
- if (Cstr.watchers) {
947
- cmpMeta.$watchers$ = Cstr.watchers;
948
- }
949
- // It's better to have a const than two Object.entries()
950
- const members = Object.entries(cmpMeta.$members$);
951
- const prototype = Cstr.prototype;
952
- members.map(([memberName, [memberFlags]]) => {
953
- if ((memberFlags & 31 /* Prop */ ||
954
- ((flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
955
- // proxyComponent - prop
956
- Object.defineProperty(prototype, memberName, {
957
- get() {
958
- // proxyComponent, get value
959
- return getValue(this, memberName);
960
- },
961
- set(newValue) {
962
- // proxyComponent, set value
963
- setValue(this, memberName, newValue, cmpMeta);
964
- },
965
- configurable: true,
966
- enumerable: true,
967
- });
968
- }
969
- else if (flags & 1 /* isElementConstructor */ &&
970
- memberFlags & 64 /* Method */) {
971
- // proxyComponent - method
972
- Object.defineProperty(prototype, memberName, {
973
- value(...args) {
974
- const ref = getHostRef(this);
975
- return ref.$onInstancePromise$.then(() => ref.$lazyInstance$[memberName](...args));
976
- },
977
- });
978
- }
979
- });
980
- if ((flags & 1 /* isElementConstructor */)) {
981
- const attrNameToPropName = new Map();
982
- prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
983
- plt.jmp(() => {
984
- const propName = attrNameToPropName.get(attrName);
985
- // In a web component lifecycle the attributeChangedCallback runs prior to connectedCallback
986
- // in the case where an attribute was set inline.
987
- // ```html
988
- // <my-component some-attribute="some-value"></my-component>
989
- // ```
990
- //
991
- // There is an edge case where a developer sets the attribute inline on a custom element and then
992
- // programmatically changes it before it has been upgraded as shown below:
993
- //
994
- // ```html
995
- // <!-- this component has _not_ been upgraded yet -->
996
- // <my-component id="test" some-attribute="some-value"></my-component>
997
- // <script>
998
- // // grab non-upgraded component
999
- // el = document.querySelector("#test");
1000
- // el.someAttribute = "another-value";
1001
- // // upgrade component
1002
- // customElements.define('my-component', MyComponent);
1003
- // </script>
1004
- // ```
1005
- // In this case if we do not unshadow here and use the value of the shadowing property, attributeChangedCallback
1006
- // will be called with `newValue = "some-value"` and will set the shadowed property (this.someAttribute = "another-value")
1007
- // to the value that was set inline i.e. "some-value" from above example. When
1008
- // the connectedCallback attempts to unshadow it will use "some-value" as the initial value rather than "another-value"
1009
- //
1010
- // The case where the attribute was NOT set inline but was not set programmatically shall be handled/unshadowed
1011
- // by connectedCallback as this attributeChangedCallback will not fire.
1012
- //
1013
- // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1014
- //
1015
- // TODO(STENCIL-16) we should think about whether or not we actually want to be reflecting the attributes to
1016
- // properties here given that this goes against best practices outlined here
1017
- // https://developers.google.com/web/fundamentals/web-components/best-practices#avoid-reentrancy
1018
- if (this.hasOwnProperty(propName)) {
1019
- newValue = this[propName];
1020
- delete this[propName];
1021
- }
1022
- else if (prototype.hasOwnProperty(propName) &&
1023
- typeof this[propName] === 'number' &&
1024
- this[propName] == newValue) {
1025
- // if the propName exists on the prototype of `Cstr`, this update may be a result of Stencil using native
1026
- // APIs to reflect props as attributes. Calls to `setAttribute(someElement, propName)` will result in
1027
- // `propName` to be converted to a `DOMString`, which may not be what we want for other primitive props.
1028
- return;
1029
- }
1030
- this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
1031
- });
1032
- };
1033
- // create an array of attributes to observe
1034
- // and also create a map of html attribute name to js property name
1035
- Cstr.observedAttributes = members
1036
- .filter(([_, m]) => m[0] & 15 /* HasAttribute */) // filter to only keep props that should match attributes
1037
- .map(([propName, m]) => {
1038
- const attrName = m[1] || propName;
1039
- attrNameToPropName.set(attrName, propName);
1040
- return attrName;
1041
- });
1042
- }
1043
- }
1044
- return Cstr;
1045
- };
1046
- const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
1047
- // initializeComponent
1048
- if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
1049
- {
1050
- // we haven't initialized this element yet
1051
- hostRef.$flags$ |= 32 /* hasInitializedComponent */;
1052
- // lazy loaded components
1053
- // request the component's implementation to be
1054
- // wired up with the host element
1055
- Cstr = loadModule(cmpMeta);
1056
- if (Cstr.then) {
1057
- // Await creates a micro-task avoid if possible
1058
- const endLoad = uniqueTime();
1059
- Cstr = await Cstr;
1060
- endLoad();
1061
- }
1062
- if (!Cstr.isProxied) {
1063
- // we've never proxied this Constructor before
1064
- // let's add the getters/setters to its prototype before
1065
- // the first time we create an instance of the implementation
1066
- {
1067
- cmpMeta.$watchers$ = Cstr.watchers;
1068
- }
1069
- proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
1070
- Cstr.isProxied = true;
1071
- }
1072
- const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
1073
- // ok, time to construct the instance
1074
- // but let's keep track of when we start and stop
1075
- // so that the getters/setters don't incorrectly step on data
1076
- {
1077
- hostRef.$flags$ |= 8 /* isConstructingInstance */;
1078
- }
1079
- // construct the lazy-loaded component implementation
1080
- // passing the hostRef is very important during
1081
- // construction in order to directly wire together the
1082
- // host element and the lazy-loaded instance
1083
- try {
1084
- new Cstr(hostRef);
1085
- }
1086
- catch (e) {
1087
- consoleError(e);
1088
- }
1089
- {
1090
- hostRef.$flags$ &= ~8 /* isConstructingInstance */;
1091
- }
1092
- {
1093
- hostRef.$flags$ |= 128 /* isWatchReady */;
1094
- }
1095
- endNewInstance();
1096
- }
1097
- if (Cstr.style) {
1098
- // this component has styles but we haven't registered them yet
1099
- let style = Cstr.style;
1100
- const scopeId = getScopeId(cmpMeta);
1101
- if (!styles.has(scopeId)) {
1102
- const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
1103
- registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
1104
- endRegisterStyles();
1105
- }
1106
- }
1107
- }
1108
- // we've successfully created a lazy instance
1109
- const ancestorComponent = hostRef.$ancestorComponent$;
1110
- const schedule = () => scheduleUpdate(hostRef, true);
1111
- if (ancestorComponent && ancestorComponent['s-rc']) {
1112
- // this is the initial load and this component it has an ancestor component
1113
- // but the ancestor component has NOT fired its will update lifecycle yet
1114
- // so let's just cool our jets and wait for the ancestor to continue first
1115
- // this will get fired off when the ancestor component
1116
- // finally gets around to rendering its lazy self
1117
- // fire off the initial update
1118
- ancestorComponent['s-rc'].push(schedule);
1119
- }
1120
- else {
1121
- schedule();
1122
- }
1123
- };
1124
- const connectedCallback = (elm) => {
1125
- if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1126
- const hostRef = getHostRef(elm);
1127
- const cmpMeta = hostRef.$cmpMeta$;
1128
- const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
1129
- if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
1130
- // first time this component has connected
1131
- hostRef.$flags$ |= 1 /* hasConnected */;
1132
- {
1133
- // find the first ancestor component (if there is one) and register
1134
- // this component as one of the actively loading child components for its ancestor
1135
- let ancestorComponent = elm;
1136
- while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
1137
- // climb up the ancestors looking for the first
1138
- // component that hasn't finished its lifecycle update yet
1139
- if (ancestorComponent['s-p']) {
1140
- // we found this components first ancestor component
1141
- // keep a reference to this component's ancestor component
1142
- attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
1143
- break;
1144
- }
1145
- }
1146
- }
1147
- // Lazy properties
1148
- // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1149
- if (cmpMeta.$members$) {
1150
- Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
1151
- if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
1152
- const value = elm[memberName];
1153
- delete elm[memberName];
1154
- elm[memberName] = value;
1155
- }
1156
- });
1157
- }
1158
- {
1159
- initializeComponent(elm, hostRef, cmpMeta);
1160
- }
1161
- }
1162
- else {
1163
- // not the first time this has connected
1164
- // reattach any event listeners to the host
1165
- // since they would have been removed when disconnected
1166
- addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
1167
- }
1168
- endConnected();
1169
- }
1170
- };
1171
- const disconnectedCallback = (elm) => {
1172
- if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1173
- const hostRef = getHostRef(elm);
1174
- {
1175
- if (hostRef.$rmListeners$) {
1176
- hostRef.$rmListeners$.map((rmListener) => rmListener());
1177
- hostRef.$rmListeners$ = undefined;
1178
- }
1179
- }
1180
- }
1181
- };
1182
- const bootstrapLazy = (lazyBundles, options = {}) => {
1183
- const endBootstrap = createTime();
1184
- const cmpTags = [];
1185
- const exclude = options.exclude || [];
1186
- const customElements = win.customElements;
1187
- const head = doc.head;
1188
- const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
1189
- const visibilityStyle = /*@__PURE__*/ doc.createElement('style');
1190
- const deferredConnectedCallbacks = [];
1191
- let appLoadFallback;
1192
- let isBootstrapping = true;
1193
- Object.assign(plt, options);
1194
- plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
1195
- lazyBundles.map((lazyBundle) => {
1196
- lazyBundle[1].map((compactMeta) => {
1197
- const cmpMeta = {
1198
- $flags$: compactMeta[0],
1199
- $tagName$: compactMeta[1],
1200
- $members$: compactMeta[2],
1201
- $listeners$: compactMeta[3],
1202
- };
1203
- {
1204
- cmpMeta.$members$ = compactMeta[2];
1205
- }
1206
- {
1207
- cmpMeta.$listeners$ = compactMeta[3];
1208
- }
1209
- {
1210
- cmpMeta.$watchers$ = {};
1211
- }
1212
- const tagName = cmpMeta.$tagName$;
1213
- const HostElement = class extends HTMLElement {
1214
- // StencilLazyHost
1215
- constructor(self) {
1216
- // @ts-ignore
1217
- super(self);
1218
- self = this;
1219
- registerHost(self, cmpMeta);
1220
- }
1221
- connectedCallback() {
1222
- if (appLoadFallback) {
1223
- clearTimeout(appLoadFallback);
1224
- appLoadFallback = null;
1225
- }
1226
- if (isBootstrapping) {
1227
- // connectedCallback will be processed once all components have been registered
1228
- deferredConnectedCallbacks.push(this);
1229
- }
1230
- else {
1231
- plt.jmp(() => connectedCallback(this));
1232
- }
1233
- }
1234
- disconnectedCallback() {
1235
- plt.jmp(() => disconnectedCallback(this));
1236
- }
1237
- componentOnReady() {
1238
- return getHostRef(this).$onReadyPromise$;
1239
- }
1240
- };
1241
- cmpMeta.$lazyBundleId$ = lazyBundle[0];
1242
- if (!exclude.includes(tagName) && !customElements.get(tagName)) {
1243
- cmpTags.push(tagName);
1244
- customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
1245
- }
1246
- });
1247
- });
1248
- {
1249
- visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
1250
- visibilityStyle.setAttribute('data-styles', '');
1251
- head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
1252
- }
1253
- // Process deferred connectedCallbacks now all components have been registered
1254
- isBootstrapping = false;
1255
- if (deferredConnectedCallbacks.length) {
1256
- deferredConnectedCallbacks.map((host) => host.connectedCallback());
1257
- }
1258
- else {
1259
- {
1260
- plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30)));
1261
- }
1262
- }
1263
- // Fallback appLoad event
1264
- endBootstrap();
1265
- };
1266
- const getAssetPath = (path) => {
1267
- const assetUrl = new URL(path, plt.$resourcesUrl$);
1268
- return assetUrl.origin !== win.location.origin ? assetUrl.href : assetUrl.pathname;
1269
- };
1270
- const hostRefs = new WeakMap();
1271
- const getHostRef = (ref) => hostRefs.get(ref);
1272
- const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
1273
- const registerHost = (elm, cmpMeta) => {
1274
- const hostRef = {
1275
- $flags$: 0,
1276
- $hostElement$: elm,
1277
- $cmpMeta$: cmpMeta,
1278
- $instanceValues$: new Map(),
1279
- };
1280
- {
1281
- hostRef.$onInstancePromise$ = new Promise((r) => (hostRef.$onInstanceResolve$ = r));
1282
- }
1283
- {
1284
- hostRef.$onReadyPromise$ = new Promise((r) => (hostRef.$onReadyResolve$ = r));
1285
- elm['s-p'] = [];
1286
- elm['s-rc'] = [];
1287
- }
1288
- addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
1289
- return hostRefs.set(elm, hostRef);
1290
- };
1291
- const isMemberInElement = (elm, memberName) => memberName in elm;
1292
- const consoleError = (e, el) => (0, console.error)(e, el);
1293
- const cmpModules = /*@__PURE__*/ new Map();
1294
- const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
1295
- // loadModuleImport
1296
- const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
1297
- const bundleId = cmpMeta.$lazyBundleId$;
1298
- const module = cmpModules.get(bundleId) ;
1299
- if (module) {
1300
- return module[exportName];
1301
- }
1302
- /*!__STENCIL_STATIC_IMPORT_SWITCH__*/
1303
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
1304
- /* @vite-ignore */
1305
- /* webpackInclude: /\.entry\.js$/ */
1306
- /* webpackExclude: /\.system\.entry\.js$/ */
1307
- /* webpackMode: "lazy" */
1308
- `./${bundleId}.entry.js${''}`)); }).then((importedModule) => {
1309
- {
1310
- cmpModules.set(bundleId, importedModule);
1311
- }
1312
- return importedModule[exportName];
1313
- }, consoleError);
1314
- };
1315
- const styles = new Map();
1316
- const queueDomReads = [];
1317
- const queueDomWrites = [];
1318
- const queueTask = (queue, write) => (cb) => {
1319
- queue.push(cb);
1320
- if (!queuePending) {
1321
- queuePending = true;
1322
- if (write && plt.$flags$ & 4 /* queueSync */) {
1323
- nextTick(flush);
1324
- }
1325
- else {
1326
- plt.raf(flush);
1327
- }
1328
- }
1329
- };
1330
- const consume = (queue) => {
1331
- for (let i = 0; i < queue.length; i++) {
1332
- try {
1333
- queue[i](performance.now());
1334
- }
1335
- catch (e) {
1336
- consoleError(e);
1337
- }
1338
- }
1339
- queue.length = 0;
1340
- };
1341
- const flush = () => {
1342
- // always force a bunch of medium callbacks to run, but still have
1343
- // a throttle on how many can run in a certain time
1344
- // DOM READS!!!
1345
- consume(queueDomReads);
1346
- // DOM WRITES!!!
1347
- {
1348
- consume(queueDomWrites);
1349
- if ((queuePending = queueDomReads.length > 0)) {
1350
- // still more to do yet, but we've run out of time
1351
- // let's let this thing cool off and try again in the next tick
1352
- plt.raf(flush);
1353
- }
1354
- }
1355
- };
1356
- const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
1357
- const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
1358
-
1359
- exports.bootstrapLazy = bootstrapLazy;
1360
- exports.createEvent = createEvent;
1361
- exports.getAssetPath = getAssetPath;
1362
- exports.getElement = getElement;
1363
- exports.h = h;
1364
- exports.promiseResolve = promiseResolve;
1365
- exports.registerInstance = registerInstance;