@sankhyalabs/sankhyablocks 1.0.12 → 1.1.12

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