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