@everymatrix/user-actions 1.32.4 → 1.33.0

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 (46) hide show
  1. package/dist/cjs/index-46c0a1de.js +791 -0
  2. package/dist/cjs/index.cjs.js +2 -0
  3. package/dist/cjs/loader.cjs.js +21 -0
  4. package/dist/cjs/user-actions.cjs.entry.js +69 -0
  5. package/dist/cjs/user-actions.cjs.js +19 -0
  6. package/dist/collection/collection-manifest.json +12 -0
  7. package/dist/collection/components/user-actions/user-actions.css +3 -0
  8. package/dist/collection/components/user-actions/user-actions.js +90 -0
  9. package/dist/collection/index.js +1 -0
  10. package/dist/collection/utils/utils.js +22 -0
  11. package/dist/components/index.d.ts +26 -0
  12. package/dist/components/index.js +1 -0
  13. package/dist/components/user-actions.d.ts +11 -0
  14. package/dist/components/user-actions.js +87 -0
  15. package/dist/esm/index-6c13c021.js +767 -0
  16. package/dist/esm/index.js +1 -0
  17. package/dist/esm/loader.js +17 -0
  18. package/dist/esm/polyfills/core-js.js +11 -0
  19. package/dist/esm/polyfills/css-shim.js +1 -0
  20. package/dist/esm/polyfills/dom.js +79 -0
  21. package/dist/esm/polyfills/es5-html-element.js +1 -0
  22. package/dist/esm/polyfills/index.js +34 -0
  23. package/dist/esm/polyfills/system.js +6 -0
  24. package/dist/esm/user-actions.entry.js +65 -0
  25. package/dist/esm/user-actions.js +17 -0
  26. package/dist/index.cjs.js +1 -0
  27. package/dist/index.js +1 -0
  28. package/dist/stencil.config.js +22 -0
  29. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-stencil/packages/user-actions/.stencil/packages/user-actions/stencil.config.d.ts +2 -0
  30. package/dist/types/components/user-actions/user-actions.d.ts +11 -0
  31. package/dist/types/components.d.ts +41 -0
  32. package/dist/types/index.d.ts +1 -0
  33. package/dist/types/stencil-public-runtime.d.ts +1565 -0
  34. package/dist/types/utils/utils.d.ts +22 -0
  35. package/dist/user-actions/index.esm.js +0 -0
  36. package/dist/user-actions/p-31fa2e47.entry.js +1 -0
  37. package/dist/user-actions/p-d8d5dc61.js +1 -0
  38. package/dist/user-actions/user-actions.esm.js +1 -0
  39. package/loader/cdn.js +3 -0
  40. package/loader/index.cjs.js +3 -0
  41. package/loader/index.d.ts +12 -0
  42. package/loader/index.es2017.js +3 -0
  43. package/loader/index.js +4 -0
  44. package/loader/package.json +10 -0
  45. package/package.json +2 -3
  46. package/LICENSE +0 -21
@@ -0,0 +1,791 @@
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 = 'user-actions';
24
+
25
+ let queuePending = false;
26
+ const win = typeof window !== 'undefined' ? window : {};
27
+ const doc = win.document || { head: {} };
28
+ const plt = {
29
+ $flags$: 0,
30
+ $resourcesUrl$: '',
31
+ jmp: (h) => h(),
32
+ raf: (h) => requestAnimationFrame(h),
33
+ ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
34
+ rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
35
+ ce: (eventName, opts) => new CustomEvent(eventName, opts),
36
+ };
37
+ const promiseResolve = (v) => Promise.resolve(v);
38
+ const supportsConstructibleStylesheets = /*@__PURE__*/ (() => {
39
+ try {
40
+ new CSSStyleSheet();
41
+ return typeof new CSSStyleSheet().replace === 'function';
42
+ }
43
+ catch (e) { }
44
+ return false;
45
+ })()
46
+ ;
47
+ const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
48
+ if (listeners) {
49
+ listeners.map(([flags, name, method]) => {
50
+ const target = getHostListenerTarget(elm, flags) ;
51
+ const handler = hostListenerProxy(hostRef, method);
52
+ const opts = hostListenerOpts(flags);
53
+ plt.ael(target, name, handler, opts);
54
+ (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
55
+ });
56
+ }
57
+ };
58
+ const hostListenerProxy = (hostRef, methodName) => (ev) => {
59
+ try {
60
+ {
61
+ if (hostRef.$flags$ & 256 /* isListenReady */) {
62
+ // instance is ready, let's call it's member method for this event
63
+ hostRef.$lazyInstance$[methodName](ev);
64
+ }
65
+ else {
66
+ (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
67
+ }
68
+ }
69
+ }
70
+ catch (e) {
71
+ consoleError(e);
72
+ }
73
+ };
74
+ const getHostListenerTarget = (elm, flags) => {
75
+ if (flags & 8 /* TargetWindow */)
76
+ return win;
77
+ return elm;
78
+ };
79
+ // prettier-ignore
80
+ const hostListenerOpts = (flags) => (flags & 2 /* Capture */) !== 0;
81
+ const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
82
+ const createTime = (fnName, tagName = '') => {
83
+ {
84
+ return () => {
85
+ return;
86
+ };
87
+ }
88
+ };
89
+ const uniqueTime = (key, measureText) => {
90
+ {
91
+ return () => {
92
+ return;
93
+ };
94
+ }
95
+ };
96
+ const rootAppliedStyles = new WeakMap();
97
+ const registerStyle = (scopeId, cssText, allowCS) => {
98
+ let style = styles.get(scopeId);
99
+ if (supportsConstructibleStylesheets && allowCS) {
100
+ style = (style || new CSSStyleSheet());
101
+ style.replace(cssText);
102
+ }
103
+ else {
104
+ style = cssText;
105
+ }
106
+ styles.set(scopeId, style);
107
+ };
108
+ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
109
+ let scopeId = getScopeId(cmpMeta);
110
+ let style = styles.get(scopeId);
111
+ // if an element is NOT connected then getRootNode() will return the wrong root node
112
+ // so the fallback is to always use the document for the root node in those cases
113
+ styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
114
+ if (style) {
115
+ if (typeof style === 'string') {
116
+ styleContainerNode = styleContainerNode.head || styleContainerNode;
117
+ let appliedStyles = rootAppliedStyles.get(styleContainerNode);
118
+ let styleElm;
119
+ if (!appliedStyles) {
120
+ rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
121
+ }
122
+ if (!appliedStyles.has(scopeId)) {
123
+ {
124
+ {
125
+ styleElm = doc.createElement('style');
126
+ styleElm.innerHTML = style;
127
+ }
128
+ styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
129
+ }
130
+ if (appliedStyles) {
131
+ appliedStyles.add(scopeId);
132
+ }
133
+ }
134
+ }
135
+ else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
136
+ styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
137
+ }
138
+ }
139
+ return scopeId;
140
+ };
141
+ const attachStyles = (hostRef) => {
142
+ const cmpMeta = hostRef.$cmpMeta$;
143
+ const elm = hostRef.$hostElement$;
144
+ const flags = cmpMeta.$flags$;
145
+ const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
146
+ const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
147
+ if (flags & 10 /* needsScopedEncapsulation */) {
148
+ // only required when we're NOT using native shadow dom (slot)
149
+ // or this browser doesn't support native shadow dom
150
+ // and this host element was NOT created with SSR
151
+ // let's pick out the inner content for slot projection
152
+ // create a node to represent where the original
153
+ // content was first placed, which is useful later on
154
+ // DOM WRITE!!
155
+ elm['s-sc'] = scopeId;
156
+ elm.classList.add(scopeId + '-h');
157
+ }
158
+ endAttachStyles();
159
+ };
160
+ const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
161
+ const isComplexType = (o) => {
162
+ // https://jsperf.com/typeof-fn-object/5
163
+ o = typeof o;
164
+ return o === 'object' || o === 'function';
165
+ };
166
+ /**
167
+ * Helper function to create & dispatch a custom Event on a provided target
168
+ * @param elm the target of the Event
169
+ * @param name the name to give the custom Event
170
+ * @param opts options for configuring a custom Event
171
+ * @returns the custom Event
172
+ */
173
+ const emitEvent = (elm, name, opts) => {
174
+ const ev = plt.ce(name, opts);
175
+ elm.dispatchEvent(ev);
176
+ return ev;
177
+ };
178
+ const attachToAncestor = (hostRef, ancestorComponent) => {
179
+ if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
180
+ ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
181
+ }
182
+ };
183
+ const scheduleUpdate = (hostRef, isInitialLoad) => {
184
+ {
185
+ hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
186
+ }
187
+ if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
188
+ hostRef.$flags$ |= 512 /* needsRerender */;
189
+ return;
190
+ }
191
+ attachToAncestor(hostRef, hostRef.$ancestorComponent$);
192
+ // there is no ancestor component or the ancestor component
193
+ // has already fired off its lifecycle update then
194
+ // fire off the initial update
195
+ const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
196
+ return writeTask(dispatch) ;
197
+ };
198
+ const dispatchHooks = (hostRef, isInitialLoad) => {
199
+ const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
200
+ const instance = hostRef.$lazyInstance$ ;
201
+ let promise;
202
+ if (isInitialLoad) {
203
+ {
204
+ hostRef.$flags$ |= 256 /* isListenReady */;
205
+ if (hostRef.$queuedListeners$) {
206
+ hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
207
+ hostRef.$queuedListeners$ = null;
208
+ }
209
+ }
210
+ {
211
+ promise = safeCall(instance, 'componentWillLoad');
212
+ }
213
+ }
214
+ endSchedule();
215
+ return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
216
+ };
217
+ const updateComponent = async (hostRef, instance, isInitialLoad) => {
218
+ // updateComponent
219
+ const elm = hostRef.$hostElement$;
220
+ const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
221
+ const rc = elm['s-rc'];
222
+ if (isInitialLoad) {
223
+ // DOM WRITE!
224
+ attachStyles(hostRef);
225
+ }
226
+ const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
227
+ {
228
+ callRender(hostRef, instance, elm);
229
+ }
230
+ if (rc) {
231
+ // ok, so turns out there are some child host elements
232
+ // waiting on this parent element to load
233
+ // let's fire off all update callbacks waiting
234
+ rc.map((cb) => cb());
235
+ elm['s-rc'] = undefined;
236
+ }
237
+ endRender();
238
+ endUpdate();
239
+ {
240
+ const childrenPromises = elm['s-p'];
241
+ const postUpdate = () => postUpdateComponent(hostRef);
242
+ if (childrenPromises.length === 0) {
243
+ postUpdate();
244
+ }
245
+ else {
246
+ Promise.all(childrenPromises).then(postUpdate);
247
+ hostRef.$flags$ |= 4 /* isWaitingForChildren */;
248
+ childrenPromises.length = 0;
249
+ }
250
+ }
251
+ };
252
+ const callRender = (hostRef, instance, elm) => {
253
+ try {
254
+ instance = instance.render() ;
255
+ {
256
+ hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
257
+ }
258
+ {
259
+ hostRef.$flags$ |= 2 /* hasRendered */;
260
+ }
261
+ {
262
+ {
263
+ elm.textContent = instance;
264
+ }
265
+ }
266
+ }
267
+ catch (e) {
268
+ consoleError(e, hostRef.$hostElement$);
269
+ }
270
+ return null;
271
+ };
272
+ const postUpdateComponent = (hostRef) => {
273
+ const tagName = hostRef.$cmpMeta$.$tagName$;
274
+ const elm = hostRef.$hostElement$;
275
+ const endPostUpdate = createTime('postUpdate', tagName);
276
+ const ancestorComponent = hostRef.$ancestorComponent$;
277
+ if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
278
+ hostRef.$flags$ |= 64 /* hasLoadedComponent */;
279
+ {
280
+ // DOM WRITE!
281
+ addHydratedFlag(elm);
282
+ }
283
+ endPostUpdate();
284
+ {
285
+ hostRef.$onReadyResolve$(elm);
286
+ if (!ancestorComponent) {
287
+ appDidLoad();
288
+ }
289
+ }
290
+ }
291
+ else {
292
+ endPostUpdate();
293
+ }
294
+ // load events fire from bottom to top
295
+ // the deepest elements load first then bubbles up
296
+ {
297
+ if (hostRef.$onRenderResolve$) {
298
+ hostRef.$onRenderResolve$();
299
+ hostRef.$onRenderResolve$ = undefined;
300
+ }
301
+ if (hostRef.$flags$ & 512 /* needsRerender */) {
302
+ nextTick(() => scheduleUpdate(hostRef, false));
303
+ }
304
+ hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
305
+ }
306
+ // ( •_•)
307
+ // ( •_•)>⌐■-■
308
+ // (⌐■_■)
309
+ };
310
+ const appDidLoad = (who) => {
311
+ // on appload
312
+ // we have finish the first big initial render
313
+ {
314
+ addHydratedFlag(doc.documentElement);
315
+ }
316
+ nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
317
+ };
318
+ const safeCall = (instance, method, arg) => {
319
+ if (instance && instance[method]) {
320
+ try {
321
+ return instance[method](arg);
322
+ }
323
+ catch (e) {
324
+ consoleError(e);
325
+ }
326
+ }
327
+ return undefined;
328
+ };
329
+ const then = (promise, thenFn) => {
330
+ return promise && promise.then ? promise.then(thenFn) : thenFn();
331
+ };
332
+ const addHydratedFlag = (elm) => elm.classList.add('hydrated')
333
+ ;
334
+ /**
335
+ * Parse a new property value for a given property type.
336
+ *
337
+ * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
338
+ * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
339
+ * 1. `any`, the type given to `propValue` in the function signature
340
+ * 2. the type stored from `propType`.
341
+ *
342
+ * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
343
+ *
344
+ * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
345
+ * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
346
+ * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
347
+ * ```tsx
348
+ * <my-cmp prop-val={0}></my-cmp>
349
+ * ```
350
+ *
351
+ * HTML prop values on the other hand, will always a string
352
+ *
353
+ * @param propValue the new value to coerce to some type
354
+ * @param propType the type of the prop, expressed as a binary number
355
+ * @returns the parsed/coerced value
356
+ */
357
+ const parsePropertyValue = (propValue, propType) => {
358
+ // ensure this value is of the correct prop type
359
+ if (propValue != null && !isComplexType(propValue)) {
360
+ if (propType & 1 /* String */) {
361
+ // could have been passed as a number or boolean
362
+ // but we still want it as a string
363
+ return String(propValue);
364
+ }
365
+ // redundant return here for better minification
366
+ return propValue;
367
+ }
368
+ // not sure exactly what type we want
369
+ // so no need to change to a different type
370
+ return propValue;
371
+ };
372
+ const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
373
+ const setValue = (ref, propName, newVal, cmpMeta) => {
374
+ // check our new property value against our internal value
375
+ const hostRef = getHostRef(ref);
376
+ const oldVal = hostRef.$instanceValues$.get(propName);
377
+ const flags = hostRef.$flags$;
378
+ const instance = hostRef.$lazyInstance$ ;
379
+ newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
380
+ // explicitly check for NaN on both sides, as `NaN === NaN` is always false
381
+ const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
382
+ const didValueChange = newVal !== oldVal && !areBothNaN;
383
+ if ((!(flags & 8 /* isConstructingInstance */) || oldVal === undefined) && didValueChange) {
384
+ // gadzooks! the property's value has changed!!
385
+ // set our new value!
386
+ hostRef.$instanceValues$.set(propName, newVal);
387
+ if (instance) {
388
+ if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
389
+ // looks like this value actually changed, so we've got work to do!
390
+ // but only if we've already rendered, otherwise just chill out
391
+ // queue that we need to do an update, but don't worry about queuing
392
+ // up millions cuz this function ensures it only runs once
393
+ scheduleUpdate(hostRef, false);
394
+ }
395
+ }
396
+ }
397
+ };
398
+ const proxyComponent = (Cstr, cmpMeta, flags) => {
399
+ if (cmpMeta.$members$) {
400
+ // It's better to have a const than two Object.entries()
401
+ const members = Object.entries(cmpMeta.$members$);
402
+ const prototype = Cstr.prototype;
403
+ members.map(([memberName, [memberFlags]]) => {
404
+ if ((memberFlags & 31 /* Prop */ ||
405
+ ((flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
406
+ // proxyComponent - prop
407
+ Object.defineProperty(prototype, memberName, {
408
+ get() {
409
+ // proxyComponent, get value
410
+ return getValue(this, memberName);
411
+ },
412
+ set(newValue) {
413
+ // proxyComponent, set value
414
+ setValue(this, memberName, newValue, cmpMeta);
415
+ },
416
+ configurable: true,
417
+ enumerable: true,
418
+ });
419
+ }
420
+ });
421
+ if ((flags & 1 /* isElementConstructor */)) {
422
+ const attrNameToPropName = new Map();
423
+ prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
424
+ plt.jmp(() => {
425
+ const propName = attrNameToPropName.get(attrName);
426
+ // In a web component lifecycle the attributeChangedCallback runs prior to connectedCallback
427
+ // in the case where an attribute was set inline.
428
+ // ```html
429
+ // <my-component some-attribute="some-value"></my-component>
430
+ // ```
431
+ //
432
+ // There is an edge case where a developer sets the attribute inline on a custom element and then
433
+ // programmatically changes it before it has been upgraded as shown below:
434
+ //
435
+ // ```html
436
+ // <!-- this component has _not_ been upgraded yet -->
437
+ // <my-component id="test" some-attribute="some-value"></my-component>
438
+ // <script>
439
+ // // grab non-upgraded component
440
+ // el = document.querySelector("#test");
441
+ // el.someAttribute = "another-value";
442
+ // // upgrade component
443
+ // customElements.define('my-component', MyComponent);
444
+ // </script>
445
+ // ```
446
+ // In this case if we do not unshadow here and use the value of the shadowing property, attributeChangedCallback
447
+ // will be called with `newValue = "some-value"` and will set the shadowed property (this.someAttribute = "another-value")
448
+ // to the value that was set inline i.e. "some-value" from above example. When
449
+ // the connectedCallback attempts to unshadow it will use "some-value" as the initial value rather than "another-value"
450
+ //
451
+ // The case where the attribute was NOT set inline but was not set programmatically shall be handled/unshadowed
452
+ // by connectedCallback as this attributeChangedCallback will not fire.
453
+ //
454
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
455
+ //
456
+ // TODO(STENCIL-16) we should think about whether or not we actually want to be reflecting the attributes to
457
+ // properties here given that this goes against best practices outlined here
458
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#avoid-reentrancy
459
+ if (this.hasOwnProperty(propName)) {
460
+ newValue = this[propName];
461
+ delete this[propName];
462
+ }
463
+ else if (prototype.hasOwnProperty(propName) &&
464
+ typeof this[propName] === 'number' &&
465
+ this[propName] == newValue) {
466
+ // if the propName exists on the prototype of `Cstr`, this update may be a result of Stencil using native
467
+ // APIs to reflect props as attributes. Calls to `setAttribute(someElement, propName)` will result in
468
+ // `propName` to be converted to a `DOMString`, which may not be what we want for other primitive props.
469
+ return;
470
+ }
471
+ this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
472
+ });
473
+ };
474
+ // create an array of attributes to observe
475
+ // and also create a map of html attribute name to js property name
476
+ Cstr.observedAttributes = members
477
+ .filter(([_, m]) => m[0] & 15 /* HasAttribute */) // filter to only keep props that should match attributes
478
+ .map(([propName, m]) => {
479
+ const attrName = m[1] || propName;
480
+ attrNameToPropName.set(attrName, propName);
481
+ return attrName;
482
+ });
483
+ }
484
+ }
485
+ return Cstr;
486
+ };
487
+ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
488
+ // initializeComponent
489
+ if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
490
+ {
491
+ // we haven't initialized this element yet
492
+ hostRef.$flags$ |= 32 /* hasInitializedComponent */;
493
+ // lazy loaded components
494
+ // request the component's implementation to be
495
+ // wired up with the host element
496
+ Cstr = loadModule(cmpMeta);
497
+ if (Cstr.then) {
498
+ // Await creates a micro-task avoid if possible
499
+ const endLoad = uniqueTime();
500
+ Cstr = await Cstr;
501
+ endLoad();
502
+ }
503
+ if (!Cstr.isProxied) {
504
+ proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
505
+ Cstr.isProxied = true;
506
+ }
507
+ const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
508
+ // ok, time to construct the instance
509
+ // but let's keep track of when we start and stop
510
+ // so that the getters/setters don't incorrectly step on data
511
+ {
512
+ hostRef.$flags$ |= 8 /* isConstructingInstance */;
513
+ }
514
+ // construct the lazy-loaded component implementation
515
+ // passing the hostRef is very important during
516
+ // construction in order to directly wire together the
517
+ // host element and the lazy-loaded instance
518
+ try {
519
+ new Cstr(hostRef);
520
+ }
521
+ catch (e) {
522
+ consoleError(e);
523
+ }
524
+ {
525
+ hostRef.$flags$ &= ~8 /* isConstructingInstance */;
526
+ }
527
+ endNewInstance();
528
+ }
529
+ if (Cstr.style) {
530
+ // this component has styles but we haven't registered them yet
531
+ let style = Cstr.style;
532
+ const scopeId = getScopeId(cmpMeta);
533
+ if (!styles.has(scopeId)) {
534
+ const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
535
+ registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
536
+ endRegisterStyles();
537
+ }
538
+ }
539
+ }
540
+ // we've successfully created a lazy instance
541
+ const ancestorComponent = hostRef.$ancestorComponent$;
542
+ const schedule = () => scheduleUpdate(hostRef, true);
543
+ if (ancestorComponent && ancestorComponent['s-rc']) {
544
+ // this is the initial load and this component it has an ancestor component
545
+ // but the ancestor component has NOT fired its will update lifecycle yet
546
+ // so let's just cool our jets and wait for the ancestor to continue first
547
+ // this will get fired off when the ancestor component
548
+ // finally gets around to rendering its lazy self
549
+ // fire off the initial update
550
+ ancestorComponent['s-rc'].push(schedule);
551
+ }
552
+ else {
553
+ schedule();
554
+ }
555
+ };
556
+ const connectedCallback = (elm) => {
557
+ if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
558
+ const hostRef = getHostRef(elm);
559
+ const cmpMeta = hostRef.$cmpMeta$;
560
+ const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
561
+ if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
562
+ // first time this component has connected
563
+ hostRef.$flags$ |= 1 /* hasConnected */;
564
+ {
565
+ // find the first ancestor component (if there is one) and register
566
+ // this component as one of the actively loading child components for its ancestor
567
+ let ancestorComponent = elm;
568
+ while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
569
+ // climb up the ancestors looking for the first
570
+ // component that hasn't finished its lifecycle update yet
571
+ if (ancestorComponent['s-p']) {
572
+ // we found this components first ancestor component
573
+ // keep a reference to this component's ancestor component
574
+ attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
575
+ break;
576
+ }
577
+ }
578
+ }
579
+ // Lazy properties
580
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
581
+ if (cmpMeta.$members$) {
582
+ Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
583
+ if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
584
+ const value = elm[memberName];
585
+ delete elm[memberName];
586
+ elm[memberName] = value;
587
+ }
588
+ });
589
+ }
590
+ {
591
+ initializeComponent(elm, hostRef, cmpMeta);
592
+ }
593
+ }
594
+ else {
595
+ // not the first time this has connected
596
+ // reattach any event listeners to the host
597
+ // since they would have been removed when disconnected
598
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
599
+ }
600
+ endConnected();
601
+ }
602
+ };
603
+ const disconnectedCallback = (elm) => {
604
+ if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
605
+ const hostRef = getHostRef(elm);
606
+ {
607
+ if (hostRef.$rmListeners$) {
608
+ hostRef.$rmListeners$.map((rmListener) => rmListener());
609
+ hostRef.$rmListeners$ = undefined;
610
+ }
611
+ }
612
+ }
613
+ };
614
+ const bootstrapLazy = (lazyBundles, options = {}) => {
615
+ const endBootstrap = createTime();
616
+ const cmpTags = [];
617
+ const exclude = options.exclude || [];
618
+ const customElements = win.customElements;
619
+ const head = doc.head;
620
+ const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
621
+ const visibilityStyle = /*@__PURE__*/ doc.createElement('style');
622
+ const deferredConnectedCallbacks = [];
623
+ let appLoadFallback;
624
+ let isBootstrapping = true;
625
+ Object.assign(plt, options);
626
+ plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
627
+ lazyBundles.map((lazyBundle) => {
628
+ lazyBundle[1].map((compactMeta) => {
629
+ const cmpMeta = {
630
+ $flags$: compactMeta[0],
631
+ $tagName$: compactMeta[1],
632
+ $members$: compactMeta[2],
633
+ $listeners$: compactMeta[3],
634
+ };
635
+ {
636
+ cmpMeta.$members$ = compactMeta[2];
637
+ }
638
+ {
639
+ cmpMeta.$listeners$ = compactMeta[3];
640
+ }
641
+ const tagName = cmpMeta.$tagName$;
642
+ const HostElement = class extends HTMLElement {
643
+ // StencilLazyHost
644
+ constructor(self) {
645
+ // @ts-ignore
646
+ super(self);
647
+ self = this;
648
+ registerHost(self, cmpMeta);
649
+ if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
650
+ // this component is using shadow dom
651
+ // and this browser supports shadow dom
652
+ // add the read-only property "shadowRoot" to the host element
653
+ // adding the shadow root build conditionals to minimize runtime
654
+ {
655
+ {
656
+ self.attachShadow({ mode: 'open' });
657
+ }
658
+ }
659
+ }
660
+ }
661
+ connectedCallback() {
662
+ if (appLoadFallback) {
663
+ clearTimeout(appLoadFallback);
664
+ appLoadFallback = null;
665
+ }
666
+ if (isBootstrapping) {
667
+ // connectedCallback will be processed once all components have been registered
668
+ deferredConnectedCallbacks.push(this);
669
+ }
670
+ else {
671
+ plt.jmp(() => connectedCallback(this));
672
+ }
673
+ }
674
+ disconnectedCallback() {
675
+ plt.jmp(() => disconnectedCallback(this));
676
+ }
677
+ componentOnReady() {
678
+ return getHostRef(this).$onReadyPromise$;
679
+ }
680
+ };
681
+ cmpMeta.$lazyBundleId$ = lazyBundle[0];
682
+ if (!exclude.includes(tagName) && !customElements.get(tagName)) {
683
+ cmpTags.push(tagName);
684
+ customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
685
+ }
686
+ });
687
+ });
688
+ {
689
+ visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
690
+ visibilityStyle.setAttribute('data-styles', '');
691
+ head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
692
+ }
693
+ // Process deferred connectedCallbacks now all components have been registered
694
+ isBootstrapping = false;
695
+ if (deferredConnectedCallbacks.length) {
696
+ deferredConnectedCallbacks.map((host) => host.connectedCallback());
697
+ }
698
+ else {
699
+ {
700
+ plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30)));
701
+ }
702
+ }
703
+ // Fallback appLoad event
704
+ endBootstrap();
705
+ };
706
+ const hostRefs = new WeakMap();
707
+ const getHostRef = (ref) => hostRefs.get(ref);
708
+ const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
709
+ const registerHost = (elm, cmpMeta) => {
710
+ const hostRef = {
711
+ $flags$: 0,
712
+ $hostElement$: elm,
713
+ $cmpMeta$: cmpMeta,
714
+ $instanceValues$: new Map(),
715
+ };
716
+ {
717
+ hostRef.$onReadyPromise$ = new Promise((r) => (hostRef.$onReadyResolve$ = r));
718
+ elm['s-p'] = [];
719
+ elm['s-rc'] = [];
720
+ }
721
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
722
+ return hostRefs.set(elm, hostRef);
723
+ };
724
+ const consoleError = (e, el) => (0, console.error)(e, el);
725
+ const cmpModules = /*@__PURE__*/ new Map();
726
+ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
727
+ // loadModuleImport
728
+ const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
729
+ const bundleId = cmpMeta.$lazyBundleId$;
730
+ const module = cmpModules.get(bundleId) ;
731
+ if (module) {
732
+ return module[exportName];
733
+ }
734
+ return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
735
+ /* webpackInclude: /\.entry\.js$/ */
736
+ /* webpackExclude: /\.system\.entry\.js$/ */
737
+ /* webpackMode: "lazy" */
738
+ `./${bundleId}.entry.js${''}`)); }).then((importedModule) => {
739
+ {
740
+ cmpModules.set(bundleId, importedModule);
741
+ }
742
+ return importedModule[exportName];
743
+ }, consoleError);
744
+ };
745
+ const styles = new Map();
746
+ const queueDomReads = [];
747
+ const queueDomWrites = [];
748
+ const queueTask = (queue, write) => (cb) => {
749
+ queue.push(cb);
750
+ if (!queuePending) {
751
+ queuePending = true;
752
+ if (write && plt.$flags$ & 4 /* queueSync */) {
753
+ nextTick(flush);
754
+ }
755
+ else {
756
+ plt.raf(flush);
757
+ }
758
+ }
759
+ };
760
+ const consume = (queue) => {
761
+ for (let i = 0; i < queue.length; i++) {
762
+ try {
763
+ queue[i](performance.now());
764
+ }
765
+ catch (e) {
766
+ consoleError(e);
767
+ }
768
+ }
769
+ queue.length = 0;
770
+ };
771
+ const flush = () => {
772
+ // always force a bunch of medium callbacks to run, but still have
773
+ // a throttle on how many can run in a certain time
774
+ // DOM READS!!!
775
+ consume(queueDomReads);
776
+ // DOM WRITES!!!
777
+ {
778
+ consume(queueDomWrites);
779
+ if ((queuePending = queueDomReads.length > 0)) {
780
+ // still more to do yet, but we've run out of time
781
+ // let's let this thing cool off and try again in the next tick
782
+ plt.raf(flush);
783
+ }
784
+ }
785
+ };
786
+ const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
787
+ const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
788
+
789
+ exports.bootstrapLazy = bootstrapLazy;
790
+ exports.promiseResolve = promiseResolve;
791
+ exports.registerInstance = registerInstance;