cmdesigns 0.0.1

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 (48) hide show
  1. package/LICENSE +21 -0
  2. package/dist/cjs/cm-text_2.cjs.entry.js +32 -0
  3. package/dist/cjs/cmdesigns.cjs.js +19 -0
  4. package/dist/cjs/index-77fd923d.js +797 -0
  5. package/dist/cjs/index.cjs.js +2 -0
  6. package/dist/cjs/loader.cjs.js +21 -0
  7. package/dist/cmdesigns/cmdesigns.esm.js +1 -0
  8. package/dist/cmdesigns/index.esm.js +0 -0
  9. package/dist/cmdesigns/p-41d106c8.js +2 -0
  10. package/dist/cmdesigns/p-f6aeaa48.entry.js +1 -0
  11. package/dist/collection/collection-manifest.json +13 -0
  12. package/dist/collection/components/cm-text/cm-text.css +13 -0
  13. package/dist/collection/components/cm-text/cm-text.js +18 -0
  14. package/dist/collection/components/fg-text/fg-text.css +14 -0
  15. package/dist/collection/components/fg-text/fg-text.js +18 -0
  16. package/dist/collection/index.js +1 -0
  17. package/dist/components/cm-text.d.ts +11 -0
  18. package/dist/components/cm-text.js +33 -0
  19. package/dist/components/fg-text.d.ts +11 -0
  20. package/dist/components/fg-text.js +33 -0
  21. package/dist/components/index.d.ts +23 -0
  22. package/dist/components/index.js +3 -0
  23. package/dist/esm/cm-text_2.entry.js +27 -0
  24. package/dist/esm/cmdesigns.js +17 -0
  25. package/dist/esm/index-a877cbd8.js +772 -0
  26. package/dist/esm/index.js +1 -0
  27. package/dist/esm/loader.js +17 -0
  28. package/dist/esm/polyfills/core-js.js +11 -0
  29. package/dist/esm/polyfills/css-shim.js +1 -0
  30. package/dist/esm/polyfills/dom.js +79 -0
  31. package/dist/esm/polyfills/es5-html-element.js +1 -0
  32. package/dist/esm/polyfills/index.js +34 -0
  33. package/dist/esm/polyfills/system.js +6 -0
  34. package/dist/index.cjs.js +1 -0
  35. package/dist/index.js +1 -0
  36. package/dist/types/components/cm-text/cm-text.d.ts +3 -0
  37. package/dist/types/components/fg-text/fg-text.d.ts +3 -0
  38. package/dist/types/components.d.ts +50 -0
  39. package/dist/types/index.d.ts +1 -0
  40. package/dist/types/stencil-public-runtime.d.ts +1581 -0
  41. package/loader/cdn.js +3 -0
  42. package/loader/index.cjs.js +3 -0
  43. package/loader/index.d.ts +12 -0
  44. package/loader/index.es2017.js +3 -0
  45. package/loader/index.js +4 -0
  46. package/loader/package.json +11 -0
  47. package/package.json +38 -0
  48. package/readme.md +75 -0
@@ -0,0 +1,772 @@
1
+ const NAMESPACE = 'cmdesigns';
2
+
3
+ /**
4
+ * Virtual DOM patching algorithm based on Snabbdom by
5
+ * Simon Friis Vindum (@paldepind)
6
+ * Licensed under the MIT License
7
+ * https://github.com/snabbdom/snabbdom/blob/master/LICENSE
8
+ *
9
+ * Modified for Stencil's renderer and slot projection
10
+ */
11
+ let scopeId;
12
+ let hostTagName;
13
+ let queuePending = false;
14
+ const createTime = (fnName, tagName = '') => {
15
+ {
16
+ return () => {
17
+ return;
18
+ };
19
+ }
20
+ };
21
+ const uniqueTime = (key, measureText) => {
22
+ {
23
+ return () => {
24
+ return;
25
+ };
26
+ }
27
+ };
28
+ const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
29
+ /**
30
+ * Default style mode id
31
+ */
32
+ /**
33
+ * Reusable empty obj/array
34
+ * Don't add values to these!!
35
+ */
36
+ const EMPTY_OBJ = {};
37
+ const isDef = (v) => v != null;
38
+ const isComplexType = (o) => {
39
+ // https://jsperf.com/typeof-fn-object/5
40
+ o = typeof o;
41
+ return o === 'object' || o === 'function';
42
+ };
43
+ /**
44
+ * Production h() function based on Preact by
45
+ * Jason Miller (@developit)
46
+ * Licensed under the MIT License
47
+ * https://github.com/developit/preact/blob/master/LICENSE
48
+ *
49
+ * Modified for Stencil's compiler and vdom
50
+ */
51
+ // const stack: any[] = [];
52
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
53
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
54
+ const h = (nodeName, vnodeData, ...children) => {
55
+ let child = null;
56
+ let simple = false;
57
+ let lastSimple = false;
58
+ const vNodeChildren = [];
59
+ const walk = (c) => {
60
+ for (let i = 0; i < c.length; i++) {
61
+ child = c[i];
62
+ if (Array.isArray(child)) {
63
+ walk(child);
64
+ }
65
+ else if (child != null && typeof child !== 'boolean') {
66
+ if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
67
+ child = String(child);
68
+ }
69
+ if (simple && lastSimple) {
70
+ // If the previous child was simple (string), we merge both
71
+ vNodeChildren[vNodeChildren.length - 1].$text$ += child;
72
+ }
73
+ else {
74
+ // Append a new vNode, if it's text, we create a text vNode
75
+ vNodeChildren.push(simple ? newVNode(null, child) : child);
76
+ }
77
+ lastSimple = simple;
78
+ }
79
+ }
80
+ };
81
+ walk(children);
82
+ if (vnodeData) {
83
+ {
84
+ const classData = vnodeData.className || vnodeData.class;
85
+ if (classData) {
86
+ vnodeData.class =
87
+ typeof classData !== 'object'
88
+ ? classData
89
+ : Object.keys(classData)
90
+ .filter((k) => classData[k])
91
+ .join(' ');
92
+ }
93
+ }
94
+ }
95
+ const vnode = newVNode(nodeName, null);
96
+ vnode.$attrs$ = vnodeData;
97
+ if (vNodeChildren.length > 0) {
98
+ vnode.$children$ = vNodeChildren;
99
+ }
100
+ return vnode;
101
+ };
102
+ const newVNode = (tag, text) => {
103
+ const vnode = {
104
+ $flags$: 0,
105
+ $tag$: tag,
106
+ $text$: text,
107
+ $elm$: null,
108
+ $children$: null,
109
+ };
110
+ {
111
+ vnode.$attrs$ = null;
112
+ }
113
+ return vnode;
114
+ };
115
+ const Host = {};
116
+ const isHost = (node) => node && node.$tag$ === Host;
117
+ /**
118
+ * Helper function to create & dispatch a custom Event on a provided target
119
+ * @param elm the target of the Event
120
+ * @param name the name to give the custom Event
121
+ * @param opts options for configuring a custom Event
122
+ * @returns the custom Event
123
+ */
124
+ const emitEvent = (elm, name, opts) => {
125
+ const ev = plt.ce(name, opts);
126
+ elm.dispatchEvent(ev);
127
+ return ev;
128
+ };
129
+ const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
130
+ const registerStyle = (scopeId, cssText, allowCS) => {
131
+ let style = styles.get(scopeId);
132
+ if (supportsConstructableStylesheets && allowCS) {
133
+ style = (style || new CSSStyleSheet());
134
+ if (typeof style === 'string') {
135
+ style = cssText;
136
+ }
137
+ else {
138
+ style.replaceSync(cssText);
139
+ }
140
+ }
141
+ else {
142
+ style = cssText;
143
+ }
144
+ styles.set(scopeId, style);
145
+ };
146
+ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
147
+ let scopeId = getScopeId(cmpMeta);
148
+ const style = styles.get(scopeId);
149
+ // if an element is NOT connected then getRootNode() will return the wrong root node
150
+ // so the fallback is to always use the document for the root node in those cases
151
+ styleContainerNode = styleContainerNode.nodeType === 11 /* NODE_TYPE.DocumentFragment */ ? styleContainerNode : doc;
152
+ if (style) {
153
+ if (typeof style === 'string') {
154
+ styleContainerNode = styleContainerNode.head || styleContainerNode;
155
+ let appliedStyles = rootAppliedStyles.get(styleContainerNode);
156
+ let styleElm;
157
+ if (!appliedStyles) {
158
+ rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
159
+ }
160
+ if (!appliedStyles.has(scopeId)) {
161
+ {
162
+ {
163
+ styleElm = doc.createElement('style');
164
+ styleElm.innerHTML = style;
165
+ }
166
+ styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
167
+ }
168
+ if (appliedStyles) {
169
+ appliedStyles.add(scopeId);
170
+ }
171
+ }
172
+ }
173
+ else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
174
+ styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
175
+ }
176
+ }
177
+ return scopeId;
178
+ };
179
+ const attachStyles = (hostRef) => {
180
+ const cmpMeta = hostRef.$cmpMeta$;
181
+ const elm = hostRef.$hostElement$;
182
+ const flags = cmpMeta.$flags$;
183
+ const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
184
+ const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
185
+ if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
186
+ // only required when we're NOT using native shadow dom (slot)
187
+ // or this browser doesn't support native shadow dom
188
+ // and this host element was NOT created with SSR
189
+ // let's pick out the inner content for slot projection
190
+ // create a node to represent where the original
191
+ // content was first placed, which is useful later on
192
+ // DOM WRITE!!
193
+ elm['s-sc'] = scopeId;
194
+ elm.classList.add(scopeId + '-h');
195
+ }
196
+ endAttachStyles();
197
+ };
198
+ const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
199
+ /**
200
+ * Production setAccessor() function based on Preact by
201
+ * Jason Miller (@developit)
202
+ * Licensed under the MIT License
203
+ * https://github.com/developit/preact/blob/master/LICENSE
204
+ *
205
+ * Modified for Stencil's compiler and vdom
206
+ */
207
+ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
208
+ if (oldValue !== newValue) {
209
+ memberName.toLowerCase();
210
+ if (memberName === 'class') {
211
+ const classList = elm.classList;
212
+ const oldClasses = parseClassList(oldValue);
213
+ const newClasses = parseClassList(newValue);
214
+ classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
215
+ classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
216
+ }
217
+ }
218
+ };
219
+ const parseClassListRegex = /\s/;
220
+ const parseClassList = (value) => (!value ? [] : value.split(parseClassListRegex));
221
+ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
222
+ // if the element passed in is a shadow root, which is a document fragment
223
+ // then we want to be adding attrs/props to the shadow root's "host" element
224
+ // if it's not a shadow root, then we add attrs/props to the same element
225
+ const elm = newVnode.$elm$.nodeType === 11 /* NODE_TYPE.DocumentFragment */ && newVnode.$elm$.host
226
+ ? newVnode.$elm$.host
227
+ : newVnode.$elm$;
228
+ const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
229
+ const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
230
+ // add new & update changed attributes
231
+ for (memberName in newVnodeAttrs) {
232
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName]);
233
+ }
234
+ };
235
+ /**
236
+ * Create a DOM Node corresponding to one of the children of a given VNode.
237
+ *
238
+ * @param oldParentVNode the parent VNode from the previous render
239
+ * @param newParentVNode the parent VNode from the current render
240
+ * @param childIndex the index of the VNode, in the _new_ parent node's
241
+ * children, for which we will create a new DOM node
242
+ * @param parentElm the parent DOM node which our new node will be a child of
243
+ * @returns the newly created node
244
+ */
245
+ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
246
+ // tslint:disable-next-line: prefer-const
247
+ const newVNode = newParentVNode.$children$[childIndex];
248
+ let i = 0;
249
+ let elm;
250
+ let childNode;
251
+ if (newVNode.$text$ !== null) {
252
+ // create text node
253
+ elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
254
+ }
255
+ else {
256
+ // create element
257
+ elm = newVNode.$elm$ = (doc.createElement(newVNode.$tag$));
258
+ // add css classes, attrs, props, listeners, etc.
259
+ {
260
+ updateElement(null, newVNode);
261
+ }
262
+ if (isDef(scopeId) && elm['s-si'] !== scopeId) {
263
+ // if there is a scopeId and this is the initial render
264
+ // then let's add the scopeId as a css class
265
+ elm.classList.add((elm['s-si'] = scopeId));
266
+ }
267
+ if (newVNode.$children$) {
268
+ for (i = 0; i < newVNode.$children$.length; ++i) {
269
+ // create the node
270
+ childNode = createElm(oldParentVNode, newVNode, i);
271
+ // return node could have been null
272
+ if (childNode) {
273
+ // append our new node
274
+ elm.appendChild(childNode);
275
+ }
276
+ }
277
+ }
278
+ }
279
+ return elm;
280
+ };
281
+ const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
282
+ let containerElm = (parentElm);
283
+ let childNode;
284
+ if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
285
+ containerElm = containerElm.shadowRoot;
286
+ }
287
+ for (; startIdx <= endIdx; ++startIdx) {
288
+ if (vnodes[startIdx]) {
289
+ childNode = createElm(null, parentVNode, startIdx);
290
+ if (childNode) {
291
+ vnodes[startIdx].$elm$ = childNode;
292
+ containerElm.insertBefore(childNode, before);
293
+ }
294
+ }
295
+ }
296
+ };
297
+ /**
298
+ * Handle reconciling an outdated VNode with a new one which corresponds to
299
+ * it. This function handles flushing updates to the DOM and reconciling the
300
+ * children of the two nodes (if any).
301
+ *
302
+ * @param oldVNode an old VNode whose DOM element and children we want to update
303
+ * @param newVNode a new VNode representing an updated version of the old one
304
+ */
305
+ const patch = (oldVNode, newVNode) => {
306
+ const elm = (newVNode.$elm$ = oldVNode.$elm$);
307
+ const newChildren = newVNode.$children$;
308
+ const text = newVNode.$text$;
309
+ if (text === null) {
310
+ {
311
+ {
312
+ // either this is the first render of an element OR it's an update
313
+ // AND we already know it's possible it could have changed
314
+ // this updates the element's css classes, attrs, props, listeners, etc.
315
+ updateElement(oldVNode, newVNode);
316
+ }
317
+ }
318
+ if (newChildren !== null) {
319
+ // add the new vnode children
320
+ addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
321
+ }
322
+ else ;
323
+ }
324
+ else if (oldVNode.$text$ !== text) {
325
+ // update the text content for the text only vnode
326
+ // and also only if the text is different than before
327
+ elm.data = text;
328
+ }
329
+ };
330
+ const renderVdom = (hostRef, renderFnResults) => {
331
+ const hostElm = hostRef.$hostElement$;
332
+ const oldVNode = hostRef.$vnode$ || newVNode(null, null);
333
+ const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
334
+ hostTagName = hostElm.tagName;
335
+ rootVnode.$tag$ = null;
336
+ rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
337
+ hostRef.$vnode$ = rootVnode;
338
+ rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
339
+ {
340
+ scopeId = hostElm['s-sc'];
341
+ }
342
+ // synchronous patch
343
+ patch(oldVNode, rootVnode);
344
+ };
345
+ const attachToAncestor = (hostRef, ancestorComponent) => {
346
+ if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
347
+ ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
348
+ }
349
+ };
350
+ const scheduleUpdate = (hostRef, isInitialLoad) => {
351
+ if (hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
352
+ hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
353
+ return;
354
+ }
355
+ attachToAncestor(hostRef, hostRef.$ancestorComponent$);
356
+ // there is no ancestor component or the ancestor component
357
+ // has already fired off its lifecycle update then
358
+ // fire off the initial update
359
+ const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
360
+ return writeTask(dispatch) ;
361
+ };
362
+ const dispatchHooks = (hostRef, isInitialLoad) => {
363
+ const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
364
+ const instance = hostRef.$lazyInstance$ ;
365
+ let promise;
366
+ endSchedule();
367
+ return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
368
+ };
369
+ const updateComponent = async (hostRef, instance, isInitialLoad) => {
370
+ // updateComponent
371
+ const elm = hostRef.$hostElement$;
372
+ const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
373
+ const rc = elm['s-rc'];
374
+ if (isInitialLoad) {
375
+ // DOM WRITE!
376
+ attachStyles(hostRef);
377
+ }
378
+ const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
379
+ {
380
+ callRender(hostRef, instance);
381
+ }
382
+ if (rc) {
383
+ // ok, so turns out there are some child host elements
384
+ // waiting on this parent element to load
385
+ // let's fire off all update callbacks waiting
386
+ rc.map((cb) => cb());
387
+ elm['s-rc'] = undefined;
388
+ }
389
+ endRender();
390
+ endUpdate();
391
+ {
392
+ const childrenPromises = elm['s-p'];
393
+ const postUpdate = () => postUpdateComponent(hostRef);
394
+ if (childrenPromises.length === 0) {
395
+ postUpdate();
396
+ }
397
+ else {
398
+ Promise.all(childrenPromises).then(postUpdate);
399
+ hostRef.$flags$ |= 4 /* HOST_FLAGS.isWaitingForChildren */;
400
+ childrenPromises.length = 0;
401
+ }
402
+ }
403
+ };
404
+ const callRender = (hostRef, instance, elm) => {
405
+ try {
406
+ instance = instance.render() ;
407
+ {
408
+ hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
409
+ }
410
+ {
411
+ {
412
+ // looks like we've got child nodes to render into this host element
413
+ // or we need to update the css class/attrs on the host element
414
+ // DOM WRITE!
415
+ {
416
+ renderVdom(hostRef, instance);
417
+ }
418
+ }
419
+ }
420
+ }
421
+ catch (e) {
422
+ consoleError(e, hostRef.$hostElement$);
423
+ }
424
+ return null;
425
+ };
426
+ const postUpdateComponent = (hostRef) => {
427
+ const tagName = hostRef.$cmpMeta$.$tagName$;
428
+ const elm = hostRef.$hostElement$;
429
+ const endPostUpdate = createTime('postUpdate', tagName);
430
+ const ancestorComponent = hostRef.$ancestorComponent$;
431
+ if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
432
+ hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
433
+ {
434
+ // DOM WRITE!
435
+ addHydratedFlag(elm);
436
+ }
437
+ endPostUpdate();
438
+ {
439
+ hostRef.$onReadyResolve$(elm);
440
+ if (!ancestorComponent) {
441
+ appDidLoad();
442
+ }
443
+ }
444
+ }
445
+ else {
446
+ endPostUpdate();
447
+ }
448
+ // load events fire from bottom to top
449
+ // the deepest elements load first then bubbles up
450
+ {
451
+ if (hostRef.$onRenderResolve$) {
452
+ hostRef.$onRenderResolve$();
453
+ hostRef.$onRenderResolve$ = undefined;
454
+ }
455
+ if (hostRef.$flags$ & 512 /* HOST_FLAGS.needsRerender */) {
456
+ nextTick(() => scheduleUpdate(hostRef, false));
457
+ }
458
+ hostRef.$flags$ &= ~(4 /* HOST_FLAGS.isWaitingForChildren */ | 512 /* HOST_FLAGS.needsRerender */);
459
+ }
460
+ // ( •_•)
461
+ // ( •_•)>⌐■-■
462
+ // (⌐■_■)
463
+ };
464
+ const appDidLoad = (who) => {
465
+ // on appload
466
+ // we have finish the first big initial render
467
+ {
468
+ addHydratedFlag(doc.documentElement);
469
+ }
470
+ nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
471
+ };
472
+ const then = (promise, thenFn) => {
473
+ return promise && promise.then ? promise.then(thenFn) : thenFn();
474
+ };
475
+ const addHydratedFlag = (elm) => elm.classList.add('hydrated')
476
+ ;
477
+ /**
478
+ * Attach a series of runtime constructs to a compiled Stencil component
479
+ * constructor, including getters and setters for the `@Prop` and `@State`
480
+ * decorators, callbacks for when attributes change, and so on.
481
+ *
482
+ * @param Cstr the constructor for a component that we need to process
483
+ * @param cmpMeta metadata collected previously about the component
484
+ * @param flags a number used to store a series of bit flags
485
+ * @returns a reference to the same constructor passed in (but now mutated)
486
+ */
487
+ const proxyComponent = (Cstr, cmpMeta, flags) => {
488
+ return Cstr;
489
+ };
490
+ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
491
+ // initializeComponent
492
+ if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
493
+ {
494
+ // we haven't initialized this element yet
495
+ hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
496
+ // lazy loaded components
497
+ // request the component's implementation to be
498
+ // wired up with the host element
499
+ Cstr = loadModule(cmpMeta);
500
+ if (Cstr.then) {
501
+ // Await creates a micro-task avoid if possible
502
+ const endLoad = uniqueTime();
503
+ Cstr = await Cstr;
504
+ endLoad();
505
+ }
506
+ const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
507
+ // construct the lazy-loaded component implementation
508
+ // passing the hostRef is very important during
509
+ // construction in order to directly wire together the
510
+ // host element and the lazy-loaded instance
511
+ try {
512
+ new Cstr(hostRef);
513
+ }
514
+ catch (e) {
515
+ consoleError(e);
516
+ }
517
+ endNewInstance();
518
+ }
519
+ if (Cstr.style) {
520
+ // this component has styles but we haven't registered them yet
521
+ let style = Cstr.style;
522
+ const scopeId = getScopeId(cmpMeta);
523
+ if (!styles.has(scopeId)) {
524
+ const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
525
+ registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
526
+ endRegisterStyles();
527
+ }
528
+ }
529
+ }
530
+ // we've successfully created a lazy instance
531
+ const ancestorComponent = hostRef.$ancestorComponent$;
532
+ const schedule = () => scheduleUpdate(hostRef, true);
533
+ if (ancestorComponent && ancestorComponent['s-rc']) {
534
+ // this is the initial load and this component it has an ancestor component
535
+ // but the ancestor component has NOT fired its will update lifecycle yet
536
+ // so let's just cool our jets and wait for the ancestor to continue first
537
+ // this will get fired off when the ancestor component
538
+ // finally gets around to rendering its lazy self
539
+ // fire off the initial update
540
+ ancestorComponent['s-rc'].push(schedule);
541
+ }
542
+ else {
543
+ schedule();
544
+ }
545
+ };
546
+ const connectedCallback = (elm) => {
547
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
548
+ const hostRef = getHostRef(elm);
549
+ const cmpMeta = hostRef.$cmpMeta$;
550
+ const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
551
+ if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
552
+ // first time this component has connected
553
+ hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
554
+ {
555
+ // find the first ancestor component (if there is one) and register
556
+ // this component as one of the actively loading child components for its ancestor
557
+ let ancestorComponent = elm;
558
+ while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
559
+ // climb up the ancestors looking for the first
560
+ // component that hasn't finished its lifecycle update yet
561
+ if (ancestorComponent['s-p']) {
562
+ // we found this components first ancestor component
563
+ // keep a reference to this component's ancestor component
564
+ attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
565
+ break;
566
+ }
567
+ }
568
+ }
569
+ {
570
+ initializeComponent(elm, hostRef, cmpMeta);
571
+ }
572
+ }
573
+ endConnected();
574
+ }
575
+ };
576
+ const disconnectedCallback = (elm) => {
577
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
578
+ getHostRef(elm);
579
+ }
580
+ };
581
+ const bootstrapLazy = (lazyBundles, options = {}) => {
582
+ const endBootstrap = createTime();
583
+ const cmpTags = [];
584
+ const exclude = options.exclude || [];
585
+ const customElements = win.customElements;
586
+ const head = doc.head;
587
+ const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
588
+ const visibilityStyle = /*@__PURE__*/ doc.createElement('style');
589
+ const deferredConnectedCallbacks = [];
590
+ let appLoadFallback;
591
+ let isBootstrapping = true;
592
+ Object.assign(plt, options);
593
+ plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
594
+ lazyBundles.map((lazyBundle) => {
595
+ lazyBundle[1].map((compactMeta) => {
596
+ const cmpMeta = {
597
+ $flags$: compactMeta[0],
598
+ $tagName$: compactMeta[1],
599
+ $members$: compactMeta[2],
600
+ $listeners$: compactMeta[3],
601
+ };
602
+ const tagName = cmpMeta.$tagName$;
603
+ const HostElement = class extends HTMLElement {
604
+ // StencilLazyHost
605
+ constructor(self) {
606
+ // @ts-ignore
607
+ super(self);
608
+ self = this;
609
+ registerHost(self, cmpMeta);
610
+ if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
611
+ // this component is using shadow dom
612
+ // and this browser supports shadow dom
613
+ // add the read-only property "shadowRoot" to the host element
614
+ // adding the shadow root build conditionals to minimize runtime
615
+ {
616
+ {
617
+ self.attachShadow({ mode: 'open' });
618
+ }
619
+ }
620
+ }
621
+ }
622
+ connectedCallback() {
623
+ if (appLoadFallback) {
624
+ clearTimeout(appLoadFallback);
625
+ appLoadFallback = null;
626
+ }
627
+ if (isBootstrapping) {
628
+ // connectedCallback will be processed once all components have been registered
629
+ deferredConnectedCallbacks.push(this);
630
+ }
631
+ else {
632
+ plt.jmp(() => connectedCallback(this));
633
+ }
634
+ }
635
+ disconnectedCallback() {
636
+ plt.jmp(() => disconnectedCallback(this));
637
+ }
638
+ componentOnReady() {
639
+ return getHostRef(this).$onReadyPromise$;
640
+ }
641
+ };
642
+ cmpMeta.$lazyBundleId$ = lazyBundle[0];
643
+ if (!exclude.includes(tagName) && !customElements.get(tagName)) {
644
+ cmpTags.push(tagName);
645
+ customElements.define(tagName, proxyComponent(HostElement));
646
+ }
647
+ });
648
+ });
649
+ {
650
+ visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
651
+ visibilityStyle.setAttribute('data-styles', '');
652
+ head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
653
+ }
654
+ // Process deferred connectedCallbacks now all components have been registered
655
+ isBootstrapping = false;
656
+ if (deferredConnectedCallbacks.length) {
657
+ deferredConnectedCallbacks.map((host) => host.connectedCallback());
658
+ }
659
+ else {
660
+ {
661
+ plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30)));
662
+ }
663
+ }
664
+ // Fallback appLoad event
665
+ endBootstrap();
666
+ };
667
+ const hostRefs = /*@__PURE__*/ new WeakMap();
668
+ const getHostRef = (ref) => hostRefs.get(ref);
669
+ const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
670
+ const registerHost = (elm, cmpMeta) => {
671
+ const hostRef = {
672
+ $flags$: 0,
673
+ $hostElement$: elm,
674
+ $cmpMeta$: cmpMeta,
675
+ $instanceValues$: new Map(),
676
+ };
677
+ {
678
+ hostRef.$onReadyPromise$ = new Promise((r) => (hostRef.$onReadyResolve$ = r));
679
+ elm['s-p'] = [];
680
+ elm['s-rc'] = [];
681
+ }
682
+ return hostRefs.set(elm, hostRef);
683
+ };
684
+ const consoleError = (e, el) => (0, console.error)(e, el);
685
+ const cmpModules = /*@__PURE__*/ new Map();
686
+ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
687
+ // loadModuleImport
688
+ const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
689
+ const bundleId = cmpMeta.$lazyBundleId$;
690
+ const module = cmpModules.get(bundleId) ;
691
+ if (module) {
692
+ return module[exportName];
693
+ }
694
+ /*!__STENCIL_STATIC_IMPORT_SWITCH__*/
695
+ return import(
696
+ /* @vite-ignore */
697
+ /* webpackInclude: /\.entry\.js$/ */
698
+ /* webpackExclude: /\.system\.entry\.js$/ */
699
+ /* webpackMode: "lazy" */
700
+ `./${bundleId}.entry.js${''}`).then((importedModule) => {
701
+ {
702
+ cmpModules.set(bundleId, importedModule);
703
+ }
704
+ return importedModule[exportName];
705
+ }, consoleError);
706
+ };
707
+ const styles = /*@__PURE__*/ new Map();
708
+ const win = typeof window !== 'undefined' ? window : {};
709
+ const doc = win.document || { head: {} };
710
+ const plt = {
711
+ $flags$: 0,
712
+ $resourcesUrl$: '',
713
+ jmp: (h) => h(),
714
+ raf: (h) => requestAnimationFrame(h),
715
+ ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
716
+ rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
717
+ ce: (eventName, opts) => new CustomEvent(eventName, opts),
718
+ };
719
+ const promiseResolve = (v) => Promise.resolve(v);
720
+ const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
721
+ try {
722
+ new CSSStyleSheet();
723
+ return typeof new CSSStyleSheet().replaceSync === 'function';
724
+ }
725
+ catch (e) { }
726
+ return false;
727
+ })()
728
+ ;
729
+ const queueDomReads = [];
730
+ const queueDomWrites = [];
731
+ const queueTask = (queue, write) => (cb) => {
732
+ queue.push(cb);
733
+ if (!queuePending) {
734
+ queuePending = true;
735
+ if (write && plt.$flags$ & 4 /* PLATFORM_FLAGS.queueSync */) {
736
+ nextTick(flush);
737
+ }
738
+ else {
739
+ plt.raf(flush);
740
+ }
741
+ }
742
+ };
743
+ const consume = (queue) => {
744
+ for (let i = 0; i < queue.length; i++) {
745
+ try {
746
+ queue[i](performance.now());
747
+ }
748
+ catch (e) {
749
+ consoleError(e);
750
+ }
751
+ }
752
+ queue.length = 0;
753
+ };
754
+ const flush = () => {
755
+ // always force a bunch of medium callbacks to run, but still have
756
+ // a throttle on how many can run in a certain time
757
+ // DOM READS!!!
758
+ consume(queueDomReads);
759
+ // DOM WRITES!!!
760
+ {
761
+ consume(queueDomWrites);
762
+ if ((queuePending = queueDomReads.length > 0)) {
763
+ // still more to do yet, but we've run out of time
764
+ // let's let this thing cool off and try again in the next tick
765
+ plt.raf(flush);
766
+ }
767
+ }
768
+ };
769
+ const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
770
+ const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
771
+
772
+ export { bootstrapLazy as b, h, promiseResolve as p, registerInstance as r };