@sankhyalabs/sankhyablocks 1.0.12 → 1.1.14

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