@ekyc_qoobiss/qbs-ect-cmp 3.6.26 → 3.6.27

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 (163) hide show
  1. package/dist/i18n/en.json +100 -0
  2. package/dist/i18n/ro.json +100 -0
  3. package/dist/i18n/ru.json +100 -0
  4. package/dist/{collection/helpers/Cameras.js → qbs-ect-cmp/Cameras-dfbebc29.js} +9 -6
  5. package/dist/{collection/models/CaptureFlow.js → qbs-ect-cmp/CaptureFlow-db5d90a4.js} +6 -4
  6. package/dist/{collection/libs/IDML5Detector/IDPose.js → qbs-ect-cmp/IDPose-181bcb25.js} +4 -2
  7. package/dist/{collection/models/IDevice.js → qbs-ect-cmp/IDevice-15ecfdeb.js} +6 -4
  8. package/dist/qbs-ect-cmp/ML5-657ef934.js +1370 -0
  9. package/dist/qbs-ect-cmp/Stream-b867a2be.js +3104 -0
  10. package/dist/qbs-ect-cmp/_commonjsHelpers-321aa363.js +44 -0
  11. package/dist/qbs-ect-cmp/agreement-check.entry.js +41 -0
  12. package/dist/qbs-ect-cmp/agreement-info.entry.js +66 -0
  13. package/dist/qbs-ect-cmp/app-globals-0f993ce5.js +3 -0
  14. package/dist/qbs-ect-cmp/base-component-2e490fd9.js +502 -0
  15. package/dist/qbs-ect-cmp/camera-comp.entry.js +103 -0
  16. package/dist/qbs-ect-cmp/camera-error.entry.js +59 -0
  17. package/dist/qbs-ect-cmp/capture-error.entry.js +53 -0
  18. package/dist/qbs-ect-cmp/css-shim-b7d3d95f.js +4 -0
  19. package/dist/qbs-ect-cmp/dom-64053c71.js +73 -0
  20. package/dist/qbs-ect-cmp/end-redirect.entry.js +25 -0
  21. package/dist/qbs-ect-cmp/error-end.entry.js +19 -0
  22. package/dist/qbs-ect-cmp/how-to-info.entry.js +52 -0
  23. package/dist/{collection/components/common/id-back-capture/id-back-capture.js → qbs-ect-cmp/id-back-capture.entry.js} +30 -100
  24. package/dist/{collection/components/common/id-capture/id-capture.js → qbs-ect-cmp/id-capture.entry.js} +28 -98
  25. package/dist/{collection/components/common/id-tilt/id-tilt.js → qbs-ect-cmp/id-tilt.entry.js} +28 -98
  26. package/dist/qbs-ect-cmp/identification-component.entry.js +909 -0
  27. package/dist/qbs-ect-cmp/index-78a05b9e.js +3371 -0
  28. package/dist/qbs-ect-cmp/index.esm.js +1 -0
  29. package/dist/qbs-ect-cmp/landing-validation.entry.js +90 -0
  30. package/dist/{esm → qbs-ect-cmp}/loader-dots.entry.js +1 -1
  31. package/dist/qbs-ect-cmp/mobile-redirect.entry.js +2984 -0
  32. package/dist/{collection/components/flow/process-id/process-id.js → qbs-ect-cmp/process-id.entry.js} +32 -100
  33. package/dist/qbs-ect-cmp/qbs-ect-cmp.css +320 -1
  34. package/dist/qbs-ect-cmp/qbs-ect-cmp.esm.js +148 -1
  35. package/dist/{esm → qbs-ect-cmp}/random-actions.entry.js +6 -3
  36. package/dist/{collection/components/common/selfie-capture/selfie-capture.js → qbs-ect-cmp/selfie-capture.entry.js} +28 -99
  37. package/dist/{collection/components/common/selfie-tilt/selfie-tilt.js → qbs-ect-cmp/selfie-tilt.entry.js} +29 -99
  38. package/dist/qbs-ect-cmp/shadow-css-98135883.js +387 -0
  39. package/dist/qbs-ect-cmp/sms-code-validation.entry.js +106 -0
  40. package/dist/{esm/store-fdeed827.js → qbs-ect-cmp/textValues-6bcc85dd.js} +51 -147
  41. package/dist/{collection/components/flow/user-liveness/user-liveness.js → qbs-ect-cmp/user-liveness.entry.js} +25 -91
  42. package/dist/{collection/utils/utils.js → qbs-ect-cmp/utils-8225f0b7.js} +10 -8
  43. package/dist/types/components/base-component.d.ts +2 -0
  44. package/dist/types/components/common/agreement-check/agreement-check.d.ts +1 -0
  45. package/dist/types/components/common/random-actions/random-actions.d.ts +2 -0
  46. package/dist/types/components/flow/end-redirect/end-redirect.d.ts +1 -0
  47. package/dist/types/components/identification-component/identification-component.d.ts +1 -0
  48. package/dist/types/components.d.ts +2 -0
  49. package/dist/types/helpers/TranslationUtils.d.ts +9 -0
  50. package/dist/types/helpers/textValues.d.ts +8 -95
  51. package/dist/types/models/IEctStore.d.ts +1 -0
  52. package/dist/types/models/ITranslationValues.d.ts +101 -0
  53. package/package.json +1 -1
  54. package/dist/cjs/agreement-check_19.cjs.entry.js +0 -9970
  55. package/dist/cjs/index-41696e0e.js +0 -1573
  56. package/dist/cjs/index.cjs.js +0 -2
  57. package/dist/cjs/loader-dots.cjs.entry.js +0 -19
  58. package/dist/cjs/loader.cjs.js +0 -22
  59. package/dist/cjs/qbs-ect-cmp.cjs.js +0 -23
  60. package/dist/cjs/random-actions.cjs.entry.js +0 -22
  61. package/dist/cjs/store-f1a0f55c.js +0 -413
  62. package/dist/collection/assets/canvas-masks/face_green.svg +0 -8
  63. package/dist/collection/assets/canvas-masks/face_white.svg +0 -8
  64. package/dist/collection/assets/canvas-masks/id_green.svg +0 -6
  65. package/dist/collection/assets/canvas-masks/id_white.svg +0 -6
  66. package/dist/collection/assets/complete.svg +0 -4
  67. package/dist/collection/assets/landing/device.svg +0 -14
  68. package/dist/collection/assets/landing/id.svg +0 -3
  69. package/dist/collection/assets/landing/info.svg +0 -3
  70. package/dist/collection/assets/landing/validation.svg +0 -16
  71. package/dist/collection/assets/loader.svg +0 -29
  72. package/dist/collection/collection-manifest.json +0 -32
  73. package/dist/collection/components/base-component.js +0 -59
  74. package/dist/collection/components/common/agreement-check/agreement-check.css +0 -0
  75. package/dist/collection/components/common/agreement-check/agreement-check.js +0 -101
  76. package/dist/collection/components/common/camera-error/camera-error.css +0 -0
  77. package/dist/collection/components/common/camera-error/camera-error.js +0 -91
  78. package/dist/collection/components/common/capture-error/capture-error.css +0 -0
  79. package/dist/collection/components/common/capture-error/capture-error.js +0 -101
  80. package/dist/collection/components/common/how-to-info/how-to-info.css +0 -0
  81. package/dist/collection/components/common/how-to-info/how-to-info.js +0 -122
  82. package/dist/collection/components/common/id-back-capture/id-back-capture.css +0 -35
  83. package/dist/collection/components/common/id-capture/id-capture.css +0 -35
  84. package/dist/collection/components/common/id-tilt/id-tilt.css +0 -35
  85. package/dist/collection/components/common/random-actions/random-actions.css +0 -0
  86. package/dist/collection/components/common/random-actions/random-actions.js +0 -20
  87. package/dist/collection/components/common/selfie-capture/selfie-capture.css +0 -7
  88. package/dist/collection/components/common/selfie-tilt/selfie-tilt.css +0 -7
  89. package/dist/collection/components/controls/camera/camera.css +0 -47
  90. package/dist/collection/components/controls/camera/camera.js +0 -289
  91. package/dist/collection/components/controls/loader-dots/loader-dots.css +0 -61
  92. package/dist/collection/components/controls/loader-dots/loader-dots.js +0 -18
  93. package/dist/collection/components/flow/agreement-info/agreement-info.css +0 -0
  94. package/dist/collection/components/flow/agreement-info/agreement-info.js +0 -106
  95. package/dist/collection/components/flow/end-redirect/end-redirect.css +0 -128
  96. package/dist/collection/components/flow/end-redirect/end-redirect.js +0 -44
  97. package/dist/collection/components/flow/error-end/error-end.css +0 -0
  98. package/dist/collection/components/flow/error-end/error-end.js +0 -61
  99. package/dist/collection/components/flow/landing-validation/landing-validation.css +0 -0
  100. package/dist/collection/components/flow/landing-validation/landing-validation.js +0 -122
  101. package/dist/collection/components/flow/mobile-redirect/mobile-redirect.css +0 -10
  102. package/dist/collection/components/flow/mobile-redirect/mobile-redirect.js +0 -144
  103. package/dist/collection/components/flow/process-id/process-id.css +0 -0
  104. package/dist/collection/components/flow/sms-code-validation/sms-code-validation.css +0 -0
  105. package/dist/collection/components/flow/sms-code-validation/sms-code-validation.js +0 -140
  106. package/dist/collection/components/flow/user-liveness/user-liveness.css +0 -0
  107. package/dist/collection/components/identification-component/identification-component.css +0 -991
  108. package/dist/collection/components/identification-component/identification-component.js +0 -387
  109. package/dist/collection/global.js +0 -0
  110. package/dist/collection/helpers/ApiCall.js +0 -223
  111. package/dist/collection/helpers/DeviceDetection.js +0 -85
  112. package/dist/collection/helpers/Events.js +0 -58
  113. package/dist/collection/helpers/ML5.js +0 -38
  114. package/dist/collection/helpers/Stream.js +0 -229
  115. package/dist/collection/helpers/canvas.js +0 -10
  116. package/dist/collection/helpers/index.js +0 -21
  117. package/dist/collection/helpers/security.js +0 -25
  118. package/dist/collection/helpers/store.js +0 -47
  119. package/dist/collection/helpers/textValues.js +0 -145
  120. package/dist/collection/index.js +0 -1
  121. package/dist/collection/libs/FaceML5Detector/FaceML5Detector.js +0 -182
  122. package/dist/collection/libs/FaceML5Detector/FacePose.js +0 -85
  123. package/dist/collection/libs/IDML5Detector/IDML5Detector.js +0 -99
  124. package/dist/collection/models/FlowStatus.js +0 -14
  125. package/dist/collection/models/FlowSteps.js +0 -30
  126. package/dist/collection/models/IAbortResult.js +0 -1
  127. package/dist/collection/models/IAddRequest.js +0 -1
  128. package/dist/collection/models/IAgreement.js +0 -1
  129. package/dist/collection/models/ICamera.js +0 -1
  130. package/dist/collection/models/IEctStore.js +0 -1
  131. package/dist/collection/models/IGeneration.js +0 -1
  132. package/dist/collection/models/ILinkSend.js +0 -1
  133. package/dist/collection/models/ILogResult.js +0 -1
  134. package/dist/collection/models/IOrderStatus.js +0 -1
  135. package/dist/collection/models/IOtpCheck.js +0 -1
  136. package/dist/collection/models/IOtpSend.js +0 -1
  137. package/dist/collection/models/IUploadFile.js +0 -1
  138. package/dist/collection/models/IVerificationMode.js +0 -5
  139. package/dist/collection/models/OrderStatuses.js +0 -8
  140. package/dist/esm/agreement-check_19.entry.js +0 -9948
  141. package/dist/esm/index-cf54a432.js +0 -1543
  142. package/dist/esm/index.js +0 -1
  143. package/dist/esm/loader.js +0 -18
  144. package/dist/esm/polyfills/core-js.js +0 -11
  145. package/dist/esm/polyfills/css-shim.js +0 -1
  146. package/dist/esm/polyfills/dom.js +0 -79
  147. package/dist/esm/polyfills/es5-html-element.js +0 -1
  148. package/dist/esm/polyfills/index.js +0 -34
  149. package/dist/esm/polyfills/system.js +0 -6
  150. package/dist/esm/qbs-ect-cmp.js +0 -18
  151. package/dist/index.cjs.js +0 -1
  152. package/dist/index.js +0 -1
  153. package/dist/loader/cdn.js +0 -3
  154. package/dist/loader/index.cjs.js +0 -3
  155. package/dist/loader/index.d.ts +0 -21
  156. package/dist/loader/index.es2017.js +0 -3
  157. package/dist/loader/index.js +0 -4
  158. package/dist/loader/package.json +0 -11
  159. package/dist/qbs-ect-cmp/p-054dc5b3.entry.js +0 -1
  160. package/dist/qbs-ect-cmp/p-0b381be5.js +0 -1
  161. package/dist/qbs-ect-cmp/p-40480abb.entry.js +0 -1373
  162. package/dist/qbs-ect-cmp/p-6be3b9ca.entry.js +0 -1
  163. package/dist/qbs-ect-cmp/p-8942656c.js +0 -2
@@ -1,1543 +0,0 @@
1
- const NAMESPACE = 'qbs-ect-cmp';
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 isSvgMode = false;
14
- let renderingRef = null;
15
- let queuePending = false;
16
- const createTime = (fnName, tagName = '') => {
17
- {
18
- return () => {
19
- return;
20
- };
21
- }
22
- };
23
- const uniqueTime = (key, measureText) => {
24
- {
25
- return () => {
26
- return;
27
- };
28
- }
29
- };
30
- const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
31
- /**
32
- * Default style mode id
33
- */
34
- /**
35
- * Reusable empty obj/array
36
- * Don't add values to these!!
37
- */
38
- const EMPTY_OBJ = {};
39
- const isDef = (v) => v != null;
40
- const isComplexType = (o) => {
41
- // https://jsperf.com/typeof-fn-object/5
42
- o = typeof o;
43
- return o === 'object' || o === 'function';
44
- };
45
- /**
46
- * Helper method for querying a `meta` tag that contains a nonce value
47
- * out of a DOM's head.
48
- *
49
- * @param doc The DOM containing the `head` to query against
50
- * @returns The content of the meta tag representing the nonce value, or `undefined` if no tag
51
- * exists or the tag has no content.
52
- */
53
- function queryNonceMetaTagContent(doc) {
54
- var _a, _b, _c;
55
- return (_c = (_b = (_a = doc.head) === null || _a === void 0 ? void 0 : _a.querySelector('meta[name="csp-nonce"]')) === null || _b === void 0 ? void 0 : _b.getAttribute('content')) !== null && _c !== void 0 ? _c : undefined;
56
- }
57
- /**
58
- * Production h() function based on Preact by
59
- * Jason Miller (@developit)
60
- * Licensed under the MIT License
61
- * https://github.com/developit/preact/blob/master/LICENSE
62
- *
63
- * Modified for Stencil's compiler and vdom
64
- */
65
- // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
66
- // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
67
- const h = (nodeName, vnodeData, ...children) => {
68
- let child = null;
69
- let simple = false;
70
- let lastSimple = false;
71
- const vNodeChildren = [];
72
- const walk = (c) => {
73
- for (let i = 0; i < c.length; i++) {
74
- child = c[i];
75
- if (Array.isArray(child)) {
76
- walk(child);
77
- }
78
- else if (child != null && typeof child !== 'boolean') {
79
- if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
80
- child = String(child);
81
- }
82
- if (simple && lastSimple) {
83
- // If the previous child was simple (string), we merge both
84
- vNodeChildren[vNodeChildren.length - 1].$text$ += child;
85
- }
86
- else {
87
- // Append a new vNode, if it's text, we create a text vNode
88
- vNodeChildren.push(simple ? newVNode(null, child) : child);
89
- }
90
- lastSimple = simple;
91
- }
92
- }
93
- };
94
- walk(children);
95
- if (vnodeData) {
96
- {
97
- const classData = vnodeData.className || vnodeData.class;
98
- if (classData) {
99
- vnodeData.class =
100
- typeof classData !== 'object'
101
- ? classData
102
- : Object.keys(classData)
103
- .filter((k) => classData[k])
104
- .join(' ');
105
- }
106
- }
107
- }
108
- const vnode = newVNode(nodeName, null);
109
- vnode.$attrs$ = vnodeData;
110
- if (vNodeChildren.length > 0) {
111
- vnode.$children$ = vNodeChildren;
112
- }
113
- return vnode;
114
- };
115
- /**
116
- * A utility function for creating a virtual DOM node from a tag and some
117
- * possible text content.
118
- *
119
- * @param tag the tag for this element
120
- * @param text possible text content for the node
121
- * @returns a newly-minted virtual DOM node
122
- */
123
- const newVNode = (tag, text) => {
124
- const vnode = {
125
- $flags$: 0,
126
- $tag$: tag,
127
- $text$: text,
128
- $elm$: null,
129
- $children$: null,
130
- };
131
- {
132
- vnode.$attrs$ = null;
133
- }
134
- return vnode;
135
- };
136
- const Host = {};
137
- /**
138
- * Check whether a given node is a Host node or not
139
- *
140
- * @param node the virtual DOM node to check
141
- * @returns whether it's a Host node or not
142
- */
143
- const isHost = (node) => node && node.$tag$ === Host;
144
- /**
145
- * Parse a new property value for a given property type.
146
- *
147
- * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
148
- * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
149
- * 1. `any`, the type given to `propValue` in the function signature
150
- * 2. the type stored from `propType`.
151
- *
152
- * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
153
- *
154
- * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
155
- * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
156
- * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
157
- * ```tsx
158
- * <my-cmp prop-val={0}></my-cmp>
159
- * ```
160
- *
161
- * HTML prop values on the other hand, will always a string
162
- *
163
- * @param propValue the new value to coerce to some type
164
- * @param propType the type of the prop, expressed as a binary number
165
- * @returns the parsed/coerced value
166
- */
167
- const parsePropertyValue = (propValue, propType) => {
168
- // ensure this value is of the correct prop type
169
- if (propValue != null && !isComplexType(propValue)) {
170
- if (propType & 2 /* MEMBER_FLAGS.Number */) {
171
- // force it to be a number
172
- return parseFloat(propValue);
173
- }
174
- if (propType & 1 /* MEMBER_FLAGS.String */) {
175
- // could have been passed as a number or boolean
176
- // but we still want it as a string
177
- return String(propValue);
178
- }
179
- // redundant return here for better minification
180
- return propValue;
181
- }
182
- // not sure exactly what type we want
183
- // so no need to change to a different type
184
- return propValue;
185
- };
186
- const getElement = (ref) => (getHostRef(ref).$hostElement$ );
187
- const createEvent = (ref, name, flags) => {
188
- const elm = getElement(ref);
189
- return {
190
- emit: (detail) => {
191
- return emitEvent(elm, name, {
192
- bubbles: !!(flags & 4 /* EVENT_FLAGS.Bubbles */),
193
- composed: !!(flags & 2 /* EVENT_FLAGS.Composed */),
194
- cancelable: !!(flags & 1 /* EVENT_FLAGS.Cancellable */),
195
- detail,
196
- });
197
- },
198
- };
199
- };
200
- /**
201
- * Helper function to create & dispatch a custom Event on a provided target
202
- * @param elm the target of the Event
203
- * @param name the name to give the custom Event
204
- * @param opts options for configuring a custom Event
205
- * @returns the custom Event
206
- */
207
- const emitEvent = (elm, name, opts) => {
208
- const ev = plt.ce(name, opts);
209
- elm.dispatchEvent(ev);
210
- return ev;
211
- };
212
- const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
213
- const registerStyle = (scopeId, cssText, allowCS) => {
214
- let style = styles.get(scopeId);
215
- if (supportsConstructableStylesheets && allowCS) {
216
- style = (style || new CSSStyleSheet());
217
- if (typeof style === 'string') {
218
- style = cssText;
219
- }
220
- else {
221
- style.replaceSync(cssText);
222
- }
223
- }
224
- else {
225
- style = cssText;
226
- }
227
- styles.set(scopeId, style);
228
- };
229
- const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
230
- var _a;
231
- let scopeId = getScopeId(cmpMeta);
232
- const style = styles.get(scopeId);
233
- // if an element is NOT connected then getRootNode() will return the wrong root node
234
- // so the fallback is to always use the document for the root node in those cases
235
- styleContainerNode = styleContainerNode.nodeType === 11 /* NODE_TYPE.DocumentFragment */ ? styleContainerNode : doc;
236
- if (style) {
237
- if (typeof style === 'string') {
238
- styleContainerNode = styleContainerNode.head || styleContainerNode;
239
- let appliedStyles = rootAppliedStyles.get(styleContainerNode);
240
- let styleElm;
241
- if (!appliedStyles) {
242
- rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
243
- }
244
- if (!appliedStyles.has(scopeId)) {
245
- {
246
- {
247
- styleElm = doc.createElement('style');
248
- styleElm.innerHTML = style;
249
- }
250
- // Apply CSP nonce to the style tag if it exists
251
- const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
252
- if (nonce != null) {
253
- styleElm.setAttribute('nonce', nonce);
254
- }
255
- styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
256
- }
257
- if (appliedStyles) {
258
- appliedStyles.add(scopeId);
259
- }
260
- }
261
- }
262
- else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
263
- styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
264
- }
265
- }
266
- return scopeId;
267
- };
268
- const attachStyles = (hostRef) => {
269
- const cmpMeta = hostRef.$cmpMeta$;
270
- const elm = hostRef.$hostElement$;
271
- const flags = cmpMeta.$flags$;
272
- const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
273
- const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
274
- if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
275
- // only required when we're NOT using native shadow dom (slot)
276
- // or this browser doesn't support native shadow dom
277
- // and this host element was NOT created with SSR
278
- // let's pick out the inner content for slot projection
279
- // create a node to represent where the original
280
- // content was first placed, which is useful later on
281
- // DOM WRITE!!
282
- elm['s-sc'] = scopeId;
283
- elm.classList.add(scopeId + '-h');
284
- }
285
- endAttachStyles();
286
- };
287
- const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
288
- /**
289
- * Production setAccessor() function based on Preact by
290
- * Jason Miller (@developit)
291
- * Licensed under the MIT License
292
- * https://github.com/developit/preact/blob/master/LICENSE
293
- *
294
- * Modified for Stencil's compiler and vdom
295
- */
296
- const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
297
- if (oldValue !== newValue) {
298
- let isProp = isMemberInElement(elm, memberName);
299
- let ln = memberName.toLowerCase();
300
- if (memberName === 'class') {
301
- const classList = elm.classList;
302
- const oldClasses = parseClassList(oldValue);
303
- const newClasses = parseClassList(newValue);
304
- classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
305
- classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
306
- }
307
- else if (memberName === 'style') {
308
- // update style attribute, css properties and values
309
- {
310
- for (const prop in oldValue) {
311
- if (!newValue || newValue[prop] == null) {
312
- if (prop.includes('-')) {
313
- elm.style.removeProperty(prop);
314
- }
315
- else {
316
- elm.style[prop] = '';
317
- }
318
- }
319
- }
320
- }
321
- for (const prop in newValue) {
322
- if (!oldValue || newValue[prop] !== oldValue[prop]) {
323
- if (prop.includes('-')) {
324
- elm.style.setProperty(prop, newValue[prop]);
325
- }
326
- else {
327
- elm.style[prop] = newValue[prop];
328
- }
329
- }
330
- }
331
- }
332
- else if (memberName === 'ref') {
333
- // minifier will clean this up
334
- if (newValue) {
335
- newValue(elm);
336
- }
337
- }
338
- else if ((!isProp ) &&
339
- memberName[0] === 'o' &&
340
- memberName[1] === 'n') {
341
- // Event Handlers
342
- // so if the member name starts with "on" and the 3rd characters is
343
- // a capital letter, and it's not already a member on the element,
344
- // then we're assuming it's an event listener
345
- if (memberName[2] === '-') {
346
- // on- prefixed events
347
- // allows to be explicit about the dom event to listen without any magic
348
- // under the hood:
349
- // <my-cmp on-click> // listens for "click"
350
- // <my-cmp on-Click> // listens for "Click"
351
- // <my-cmp on-ionChange> // listens for "ionChange"
352
- // <my-cmp on-EVENTS> // listens for "EVENTS"
353
- memberName = memberName.slice(3);
354
- }
355
- else if (isMemberInElement(win, ln)) {
356
- // standard event
357
- // the JSX attribute could have been "onMouseOver" and the
358
- // member name "onmouseover" is on the window's prototype
359
- // so let's add the listener "mouseover", which is all lowercased
360
- memberName = ln.slice(2);
361
- }
362
- else {
363
- // custom event
364
- // the JSX attribute could have been "onMyCustomEvent"
365
- // so let's trim off the "on" prefix and lowercase the first character
366
- // and add the listener "myCustomEvent"
367
- // except for the first character, we keep the event name case
368
- memberName = ln[2] + memberName.slice(3);
369
- }
370
- if (oldValue) {
371
- plt.rel(elm, memberName, oldValue, false);
372
- }
373
- if (newValue) {
374
- plt.ael(elm, memberName, newValue, false);
375
- }
376
- }
377
- else {
378
- // Set property if it exists and it's not a SVG
379
- const isComplex = isComplexType(newValue);
380
- if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
381
- try {
382
- if (!elm.tagName.includes('-')) {
383
- const n = newValue == null ? '' : newValue;
384
- // Workaround for Safari, moving the <input> caret when re-assigning the same valued
385
- if (memberName === 'list') {
386
- isProp = false;
387
- }
388
- else if (oldValue == null || elm[memberName] != n) {
389
- elm[memberName] = n;
390
- }
391
- }
392
- else {
393
- elm[memberName] = newValue;
394
- }
395
- }
396
- catch (e) { }
397
- }
398
- if (newValue == null || newValue === false) {
399
- if (newValue !== false || elm.getAttribute(memberName) === '') {
400
- {
401
- elm.removeAttribute(memberName);
402
- }
403
- }
404
- }
405
- else if ((!isProp || flags & 4 /* VNODE_FLAGS.isHost */ || isSvg) && !isComplex) {
406
- newValue = newValue === true ? '' : newValue;
407
- {
408
- elm.setAttribute(memberName, newValue);
409
- }
410
- }
411
- }
412
- }
413
- };
414
- const parseClassListRegex = /\s/;
415
- const parseClassList = (value) => (!value ? [] : value.split(parseClassListRegex));
416
- const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
417
- // if the element passed in is a shadow root, which is a document fragment
418
- // then we want to be adding attrs/props to the shadow root's "host" element
419
- // if it's not a shadow root, then we add attrs/props to the same element
420
- const elm = newVnode.$elm$.nodeType === 11 /* NODE_TYPE.DocumentFragment */ && newVnode.$elm$.host
421
- ? newVnode.$elm$.host
422
- : newVnode.$elm$;
423
- const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
424
- const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
425
- {
426
- // remove attributes no longer present on the vnode by setting them to undefined
427
- for (memberName in oldVnodeAttrs) {
428
- if (!(memberName in newVnodeAttrs)) {
429
- setAccessor(elm, memberName, oldVnodeAttrs[memberName], undefined, isSvgMode, newVnode.$flags$);
430
- }
431
- }
432
- }
433
- // add new & update changed attributes
434
- for (memberName in newVnodeAttrs) {
435
- setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
436
- }
437
- };
438
- /**
439
- * Create a DOM Node corresponding to one of the children of a given VNode.
440
- *
441
- * @param oldParentVNode the parent VNode from the previous render
442
- * @param newParentVNode the parent VNode from the current render
443
- * @param childIndex the index of the VNode, in the _new_ parent node's
444
- * children, for which we will create a new DOM node
445
- * @param parentElm the parent DOM node which our new node will be a child of
446
- * @returns the newly created node
447
- */
448
- const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
449
- // tslint:disable-next-line: prefer-const
450
- const newVNode = newParentVNode.$children$[childIndex];
451
- let i = 0;
452
- let elm;
453
- let childNode;
454
- if (newVNode.$text$ !== null) {
455
- // create text node
456
- elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
457
- }
458
- else {
459
- // create element
460
- elm = newVNode.$elm$ = (doc.createElement(newVNode.$tag$));
461
- // add css classes, attrs, props, listeners, etc.
462
- {
463
- updateElement(null, newVNode, isSvgMode);
464
- }
465
- if (isDef(scopeId) && elm['s-si'] !== scopeId) {
466
- // if there is a scopeId and this is the initial render
467
- // then let's add the scopeId as a css class
468
- elm.classList.add((elm['s-si'] = scopeId));
469
- }
470
- if (newVNode.$children$) {
471
- for (i = 0; i < newVNode.$children$.length; ++i) {
472
- // create the node
473
- childNode = createElm(oldParentVNode, newVNode, i);
474
- // return node could have been null
475
- if (childNode) {
476
- // append our new node
477
- elm.appendChild(childNode);
478
- }
479
- }
480
- }
481
- }
482
- return elm;
483
- };
484
- /**
485
- * Create DOM nodes corresponding to a list of {@link d.Vnode} objects and
486
- * add them to the DOM in the appropriate place.
487
- *
488
- * @param parentElm the DOM node which should be used as a parent for the new
489
- * DOM nodes
490
- * @param before a child of the `parentElm` which the new children should be
491
- * inserted before (optional)
492
- * @param parentVNode the parent virtual DOM node
493
- * @param vnodes the new child virtual DOM nodes to produce DOM nodes for
494
- * @param startIdx the index in the child virtual DOM nodes at which to start
495
- * creating DOM nodes (inclusive)
496
- * @param endIdx the index in the child virtual DOM nodes at which to stop
497
- * creating DOM nodes (inclusive)
498
- */
499
- const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
500
- let containerElm = (parentElm);
501
- let childNode;
502
- if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
503
- containerElm = containerElm.shadowRoot;
504
- }
505
- for (; startIdx <= endIdx; ++startIdx) {
506
- if (vnodes[startIdx]) {
507
- childNode = createElm(null, parentVNode, startIdx);
508
- if (childNode) {
509
- vnodes[startIdx].$elm$ = childNode;
510
- containerElm.insertBefore(childNode, before);
511
- }
512
- }
513
- }
514
- };
515
- /**
516
- * Remove the DOM elements corresponding to a list of {@link d.VNode} objects.
517
- * This can be used to, for instance, clean up after a list of children which
518
- * should no longer be shown.
519
- *
520
- * This function also handles some of Stencil's slot relocation logic.
521
- *
522
- * @param vnodes a list of virtual DOM nodes to remove
523
- * @param startIdx the index at which to start removing nodes (inclusive)
524
- * @param endIdx the index at which to stop removing nodes (inclusive)
525
- * @param vnode a VNode
526
- * @param elm an element
527
- */
528
- const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
529
- for (; startIdx <= endIdx; ++startIdx) {
530
- if ((vnode = vnodes[startIdx])) {
531
- elm = vnode.$elm$;
532
- callNodeRefs(vnode);
533
- // remove the vnode's element from the dom
534
- elm.remove();
535
- }
536
- }
537
- };
538
- /**
539
- * Reconcile the children of a new VNode with the children of an old VNode by
540
- * traversing the two collections of children, identifying nodes that are
541
- * conserved or changed, calling out to `patch` to make any necessary
542
- * updates to the DOM, and rearranging DOM nodes as needed.
543
- *
544
- * The algorithm for reconciling children works by analyzing two 'windows' onto
545
- * the two arrays of children (`oldCh` and `newCh`). We keep track of the
546
- * 'windows' by storing start and end indices and references to the
547
- * corresponding array entries. Initially the two 'windows' are basically equal
548
- * to the entire array, but we progressively narrow the windows until there are
549
- * no children left to update by doing the following:
550
- *
551
- * 1. Skip any `null` entries at the beginning or end of the two arrays, so
552
- * that if we have an initial array like the following we'll end up dealing
553
- * only with a window bounded by the highlighted elements:
554
- *
555
- * [null, null, VNode1 , ... , VNode2, null, null]
556
- * ^^^^^^ ^^^^^^
557
- *
558
- * 2. Check to see if the elements at the head and tail positions are equal
559
- * across the windows. This will basically detect elements which haven't
560
- * been added, removed, or changed position, i.e. if you had the following
561
- * VNode elements (represented as HTML):
562
- *
563
- * oldVNode: `<div><p><span>HEY</span></p></div>`
564
- * newVNode: `<div><p><span>THERE</span></p></div>`
565
- *
566
- * Then when comparing the children of the `<div>` tag we check the equality
567
- * of the VNodes corresponding to the `<p>` tags and, since they are the
568
- * same tag in the same position, we'd be able to avoid completely
569
- * re-rendering the subtree under them with a new DOM element and would just
570
- * call out to `patch` to handle reconciling their children and so on.
571
- *
572
- * 3. Check, for both windows, to see if the element at the beginning of the
573
- * window corresponds to the element at the end of the other window. This is
574
- * a heuristic which will let us identify _some_ situations in which
575
- * elements have changed position, for instance it _should_ detect that the
576
- * children nodes themselves have not changed but merely moved in the
577
- * following example:
578
- *
579
- * oldVNode: `<div><element-one /><element-two /></div>`
580
- * newVNode: `<div><element-two /><element-one /></div>`
581
- *
582
- * If we find cases like this then we also need to move the concrete DOM
583
- * elements corresponding to the moved children to write the re-order to the
584
- * DOM.
585
- *
586
- * 4. Finally, if VNodes have the `key` attribute set on them we check for any
587
- * nodes in the old children which have the same key as the first element in
588
- * our window on the new children. If we find such a node we handle calling
589
- * out to `patch`, moving relevant DOM nodes, and so on, in accordance with
590
- * what we find.
591
- *
592
- * Finally, once we've narrowed our 'windows' to the point that either of them
593
- * collapse (i.e. they have length 0) we then handle any remaining VNode
594
- * insertion or deletion that needs to happen to get a DOM state that correctly
595
- * reflects the new child VNodes. If, for instance, after our window on the old
596
- * children has collapsed we still have more nodes on the new children that
597
- * we haven't dealt with yet then we need to add them, or if the new children
598
- * collapse but we still have unhandled _old_ children then we need to make
599
- * sure the corresponding DOM nodes are removed.
600
- *
601
- * @param parentElm the node into which the parent VNode is rendered
602
- * @param oldCh the old children of the parent node
603
- * @param newVNode the new VNode which will replace the parent
604
- * @param newCh the new children of the parent node
605
- */
606
- const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
607
- let oldStartIdx = 0;
608
- let newStartIdx = 0;
609
- let oldEndIdx = oldCh.length - 1;
610
- let oldStartVnode = oldCh[0];
611
- let oldEndVnode = oldCh[oldEndIdx];
612
- let newEndIdx = newCh.length - 1;
613
- let newStartVnode = newCh[0];
614
- let newEndVnode = newCh[newEndIdx];
615
- let node;
616
- while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
617
- if (oldStartVnode == null) {
618
- // VNode might have been moved left
619
- oldStartVnode = oldCh[++oldStartIdx];
620
- }
621
- else if (oldEndVnode == null) {
622
- oldEndVnode = oldCh[--oldEndIdx];
623
- }
624
- else if (newStartVnode == null) {
625
- newStartVnode = newCh[++newStartIdx];
626
- }
627
- else if (newEndVnode == null) {
628
- newEndVnode = newCh[--newEndIdx];
629
- }
630
- else if (isSameVnode(oldStartVnode, newStartVnode)) {
631
- // if the start nodes are the same then we should patch the new VNode
632
- // onto the old one, and increment our `newStartIdx` and `oldStartIdx`
633
- // indices to reflect that. We don't need to move any DOM Nodes around
634
- // since things are matched up in order.
635
- patch(oldStartVnode, newStartVnode);
636
- oldStartVnode = oldCh[++oldStartIdx];
637
- newStartVnode = newCh[++newStartIdx];
638
- }
639
- else if (isSameVnode(oldEndVnode, newEndVnode)) {
640
- // likewise, if the end nodes are the same we patch new onto old and
641
- // decrement our end indices, and also likewise in this case we don't
642
- // need to move any DOM Nodes.
643
- patch(oldEndVnode, newEndVnode);
644
- oldEndVnode = oldCh[--oldEndIdx];
645
- newEndVnode = newCh[--newEndIdx];
646
- }
647
- else if (isSameVnode(oldStartVnode, newEndVnode)) {
648
- patch(oldStartVnode, newEndVnode);
649
- // We need to move the element for `oldStartVnode` into a position which
650
- // will be appropriate for `newEndVnode`. For this we can use
651
- // `.insertBefore` and `oldEndVnode.$elm$.nextSibling`. If there is a
652
- // sibling for `oldEndVnode.$elm$` then we want to move the DOM node for
653
- // `oldStartVnode` between `oldEndVnode` and it's sibling, like so:
654
- //
655
- // <old-start-node />
656
- // <some-intervening-node />
657
- // <old-end-node />
658
- // <!-- -> <-- `oldStartVnode.$elm$` should be inserted here
659
- // <next-sibling />
660
- //
661
- // If instead `oldEndVnode.$elm$` has no sibling then we just want to put
662
- // the node for `oldStartVnode` at the end of the children of
663
- // `parentElm`. Luckily, `Node.nextSibling` will return `null` if there
664
- // aren't any siblings, and passing `null` to `Node.insertBefore` will
665
- // append it to the children of the parent element.
666
- parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
667
- oldStartVnode = oldCh[++oldStartIdx];
668
- newEndVnode = newCh[--newEndIdx];
669
- }
670
- else if (isSameVnode(oldEndVnode, newStartVnode)) {
671
- patch(oldEndVnode, newStartVnode);
672
- // We've already checked above if `oldStartVnode` and `newStartVnode` are
673
- // the same node, so since we're here we know that they are not. Thus we
674
- // can move the element for `oldEndVnode` _before_ the element for
675
- // `oldStartVnode`, leaving `oldStartVnode` to be reconciled in the
676
- // future.
677
- parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
678
- oldEndVnode = oldCh[--oldEndIdx];
679
- newStartVnode = newCh[++newStartIdx];
680
- }
681
- else {
682
- {
683
- // We either didn't find an element in the old children that matches
684
- // the key of the first new child OR the build is not using `key`
685
- // attributes at all. In either case we need to create a new element
686
- // for the new node.
687
- node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
688
- newStartVnode = newCh[++newStartIdx];
689
- }
690
- if (node) {
691
- // if we created a new node then handle inserting it to the DOM
692
- {
693
- oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
694
- }
695
- }
696
- }
697
- }
698
- if (oldStartIdx > oldEndIdx) {
699
- // we have some more new nodes to add which don't match up with old nodes
700
- addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
701
- }
702
- else if (newStartIdx > newEndIdx) {
703
- // there are nodes in the `oldCh` array which no longer correspond to nodes
704
- // in the new array, so lets remove them (which entails cleaning up the
705
- // relevant DOM nodes)
706
- removeVnodes(oldCh, oldStartIdx, oldEndIdx);
707
- }
708
- };
709
- /**
710
- * Compare two VNodes to determine if they are the same
711
- *
712
- * **NB**: This function is an equality _heuristic_ based on the available
713
- * information set on the two VNodes and can be misleading under certain
714
- * circumstances. In particular, if the two nodes do not have `key` attrs
715
- * (available under `$key$` on VNodes) then the function falls back on merely
716
- * checking that they have the same tag.
717
- *
718
- * So, in other words, if `key` attrs are not set on VNodes which may be
719
- * changing order within a `children` array or something along those lines then
720
- * we could obtain a false negative and then have to do needless re-rendering
721
- * (i.e. we'd say two VNodes aren't equal when in fact they should be).
722
- *
723
- * @param leftVNode the first VNode to check
724
- * @param rightVNode the second VNode to check
725
- * @returns whether they're equal or not
726
- */
727
- const isSameVnode = (leftVNode, rightVNode) => {
728
- // compare if two vnode to see if they're "technically" the same
729
- // need to have the same element tag, and same key to be the same
730
- if (leftVNode.$tag$ === rightVNode.$tag$) {
731
- return true;
732
- }
733
- return false;
734
- };
735
- /**
736
- * Handle reconciling an outdated VNode with a new one which corresponds to
737
- * it. This function handles flushing updates to the DOM and reconciling the
738
- * children of the two nodes (if any).
739
- *
740
- * @param oldVNode an old VNode whose DOM element and children we want to update
741
- * @param newVNode a new VNode representing an updated version of the old one
742
- */
743
- const patch = (oldVNode, newVNode) => {
744
- const elm = (newVNode.$elm$ = oldVNode.$elm$);
745
- const oldChildren = oldVNode.$children$;
746
- const newChildren = newVNode.$children$;
747
- const text = newVNode.$text$;
748
- if (text === null) {
749
- {
750
- {
751
- // either this is the first render of an element OR it's an update
752
- // AND we already know it's possible it could have changed
753
- // this updates the element's css classes, attrs, props, listeners, etc.
754
- updateElement(oldVNode, newVNode, isSvgMode);
755
- }
756
- }
757
- if (oldChildren !== null && newChildren !== null) {
758
- // looks like there's child vnodes for both the old and new vnodes
759
- // so we need to call `updateChildren` to reconcile them
760
- updateChildren(elm, oldChildren, newVNode, newChildren);
761
- }
762
- else if (newChildren !== null) {
763
- // no old child vnodes, but there are new child vnodes to add
764
- if (oldVNode.$text$ !== null) {
765
- // the old vnode was text, so be sure to clear it out
766
- elm.textContent = '';
767
- }
768
- // add the new vnode children
769
- addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
770
- }
771
- else if (oldChildren !== null) {
772
- // no new child vnodes, but there are old child vnodes to remove
773
- removeVnodes(oldChildren, 0, oldChildren.length - 1);
774
- }
775
- }
776
- else if (oldVNode.$text$ !== text) {
777
- // update the text content for the text only vnode
778
- // and also only if the text is different than before
779
- elm.data = text;
780
- }
781
- };
782
- const callNodeRefs = (vNode) => {
783
- {
784
- vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
785
- vNode.$children$ && vNode.$children$.map(callNodeRefs);
786
- }
787
- };
788
- /**
789
- * The main entry point for Stencil's virtual DOM-based rendering engine
790
- *
791
- * Given a {@link d.HostRef} container and some virtual DOM nodes, this
792
- * function will handle creating a virtual DOM tree with a single root, patching
793
- * the current virtual DOM tree onto an old one (if any), dealing with slot
794
- * relocation, and reflecting attributes.
795
- *
796
- * @param hostRef data needed to root and render the virtual DOM tree, such as
797
- * the DOM node into which it should be rendered.
798
- * @param renderFnResults the virtual DOM nodes to be rendered
799
- */
800
- const renderVdom = (hostRef, renderFnResults) => {
801
- const hostElm = hostRef.$hostElement$;
802
- const cmpMeta = hostRef.$cmpMeta$;
803
- const oldVNode = hostRef.$vnode$ || newVNode(null, null);
804
- const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
805
- hostTagName = hostElm.tagName;
806
- if (cmpMeta.$attrsToReflect$) {
807
- rootVnode.$attrs$ = rootVnode.$attrs$ || {};
808
- cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
809
- }
810
- rootVnode.$tag$ = null;
811
- rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
812
- hostRef.$vnode$ = rootVnode;
813
- rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
814
- {
815
- scopeId = hostElm['s-sc'];
816
- }
817
- // synchronous patch
818
- patch(oldVNode, rootVnode);
819
- };
820
- const attachToAncestor = (hostRef, ancestorComponent) => {
821
- if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
822
- ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
823
- }
824
- };
825
- const scheduleUpdate = (hostRef, isInitialLoad) => {
826
- {
827
- hostRef.$flags$ |= 16 /* HOST_FLAGS.isQueuedForUpdate */;
828
- }
829
- if (hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
830
- hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
831
- return;
832
- }
833
- attachToAncestor(hostRef, hostRef.$ancestorComponent$);
834
- // there is no ancestor component or the ancestor component
835
- // has already fired off its lifecycle update then
836
- // fire off the initial update
837
- const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
838
- return writeTask(dispatch) ;
839
- };
840
- const dispatchHooks = (hostRef, isInitialLoad) => {
841
- const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
842
- const instance = hostRef.$lazyInstance$ ;
843
- let promise;
844
- if (isInitialLoad) {
845
- {
846
- hostRef.$flags$ |= 256 /* HOST_FLAGS.isListenReady */;
847
- if (hostRef.$queuedListeners$) {
848
- hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
849
- hostRef.$queuedListeners$ = null;
850
- }
851
- }
852
- {
853
- promise = safeCall(instance, 'componentWillLoad');
854
- }
855
- }
856
- {
857
- promise = then(promise, () => safeCall(instance, 'componentWillRender'));
858
- }
859
- endSchedule();
860
- return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
861
- };
862
- const updateComponent = async (hostRef, instance, isInitialLoad) => {
863
- // updateComponent
864
- const elm = hostRef.$hostElement$;
865
- const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
866
- const rc = elm['s-rc'];
867
- if (isInitialLoad) {
868
- // DOM WRITE!
869
- attachStyles(hostRef);
870
- }
871
- const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
872
- {
873
- callRender(hostRef, instance);
874
- }
875
- if (rc) {
876
- // ok, so turns out there are some child host elements
877
- // waiting on this parent element to load
878
- // let's fire off all update callbacks waiting
879
- rc.map((cb) => cb());
880
- elm['s-rc'] = undefined;
881
- }
882
- endRender();
883
- endUpdate();
884
- {
885
- const childrenPromises = elm['s-p'];
886
- const postUpdate = () => postUpdateComponent(hostRef);
887
- if (childrenPromises.length === 0) {
888
- postUpdate();
889
- }
890
- else {
891
- Promise.all(childrenPromises).then(postUpdate);
892
- hostRef.$flags$ |= 4 /* HOST_FLAGS.isWaitingForChildren */;
893
- childrenPromises.length = 0;
894
- }
895
- }
896
- };
897
- const callRender = (hostRef, instance, elm) => {
898
- try {
899
- renderingRef = instance;
900
- instance = instance.render() ;
901
- {
902
- hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
903
- }
904
- {
905
- hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
906
- }
907
- {
908
- {
909
- // looks like we've got child nodes to render into this host element
910
- // or we need to update the css class/attrs on the host element
911
- // DOM WRITE!
912
- {
913
- renderVdom(hostRef, instance);
914
- }
915
- }
916
- }
917
- }
918
- catch (e) {
919
- consoleError(e, hostRef.$hostElement$);
920
- }
921
- renderingRef = null;
922
- return null;
923
- };
924
- const getRenderingRef = () => renderingRef;
925
- const postUpdateComponent = (hostRef) => {
926
- const tagName = hostRef.$cmpMeta$.$tagName$;
927
- const elm = hostRef.$hostElement$;
928
- const endPostUpdate = createTime('postUpdate', tagName);
929
- const instance = hostRef.$lazyInstance$ ;
930
- const ancestorComponent = hostRef.$ancestorComponent$;
931
- if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
932
- hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
933
- {
934
- // DOM WRITE!
935
- addHydratedFlag(elm);
936
- }
937
- {
938
- safeCall(instance, 'componentDidLoad');
939
- }
940
- endPostUpdate();
941
- {
942
- hostRef.$onReadyResolve$(elm);
943
- if (!ancestorComponent) {
944
- appDidLoad();
945
- }
946
- }
947
- }
948
- else {
949
- endPostUpdate();
950
- }
951
- // load events fire from bottom to top
952
- // the deepest elements load first then bubbles up
953
- {
954
- if (hostRef.$onRenderResolve$) {
955
- hostRef.$onRenderResolve$();
956
- hostRef.$onRenderResolve$ = undefined;
957
- }
958
- if (hostRef.$flags$ & 512 /* HOST_FLAGS.needsRerender */) {
959
- nextTick(() => scheduleUpdate(hostRef, false));
960
- }
961
- hostRef.$flags$ &= ~(4 /* HOST_FLAGS.isWaitingForChildren */ | 512 /* HOST_FLAGS.needsRerender */);
962
- }
963
- // ( •_•)
964
- // ( •_•)>⌐■-■
965
- // (⌐■_■)
966
- };
967
- const forceUpdate = (ref) => {
968
- {
969
- const hostRef = getHostRef(ref);
970
- const isConnected = hostRef.$hostElement$.isConnected;
971
- if (isConnected &&
972
- (hostRef.$flags$ & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
973
- scheduleUpdate(hostRef, false);
974
- }
975
- // Returns "true" when the forced update was successfully scheduled
976
- return isConnected;
977
- }
978
- };
979
- const appDidLoad = (who) => {
980
- // on appload
981
- // we have finish the first big initial render
982
- {
983
- addHydratedFlag(doc.documentElement);
984
- }
985
- nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
986
- };
987
- const safeCall = (instance, method, arg) => {
988
- if (instance && instance[method]) {
989
- try {
990
- return instance[method](arg);
991
- }
992
- catch (e) {
993
- consoleError(e);
994
- }
995
- }
996
- return undefined;
997
- };
998
- const then = (promise, thenFn) => {
999
- return promise && promise.then ? promise.then(thenFn) : thenFn();
1000
- };
1001
- const addHydratedFlag = (elm) => elm.classList.add('hydrated')
1002
- ;
1003
- const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
1004
- const setValue = (ref, propName, newVal, cmpMeta) => {
1005
- // check our new property value against our internal value
1006
- const hostRef = getHostRef(ref);
1007
- const elm = hostRef.$hostElement$ ;
1008
- const oldVal = hostRef.$instanceValues$.get(propName);
1009
- const flags = hostRef.$flags$;
1010
- const instance = hostRef.$lazyInstance$ ;
1011
- newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
1012
- // explicitly check for NaN on both sides, as `NaN === NaN` is always false
1013
- const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
1014
- const didValueChange = newVal !== oldVal && !areBothNaN;
1015
- if ((!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
1016
- // gadzooks! the property's value has changed!!
1017
- // set our new value!
1018
- hostRef.$instanceValues$.set(propName, newVal);
1019
- if (instance) {
1020
- // get an array of method names of watch functions to call
1021
- if (cmpMeta.$watchers$ && flags & 128 /* HOST_FLAGS.isWatchReady */) {
1022
- const watchMethods = cmpMeta.$watchers$[propName];
1023
- if (watchMethods) {
1024
- // this instance is watching for when this property changed
1025
- watchMethods.map((watchMethodName) => {
1026
- try {
1027
- // fire off each of the watch methods that are watching this property
1028
- instance[watchMethodName](newVal, oldVal, propName);
1029
- }
1030
- catch (e) {
1031
- consoleError(e, elm);
1032
- }
1033
- });
1034
- }
1035
- }
1036
- if ((flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
1037
- // looks like this value actually changed, so we've got work to do!
1038
- // but only if we've already rendered, otherwise just chill out
1039
- // queue that we need to do an update, but don't worry about queuing
1040
- // up millions cuz this function ensures it only runs once
1041
- scheduleUpdate(hostRef, false);
1042
- }
1043
- }
1044
- }
1045
- };
1046
- /**
1047
- * Attach a series of runtime constructs to a compiled Stencil component
1048
- * constructor, including getters and setters for the `@Prop` and `@State`
1049
- * decorators, callbacks for when attributes change, and so on.
1050
- *
1051
- * @param Cstr the constructor for a component that we need to process
1052
- * @param cmpMeta metadata collected previously about the component
1053
- * @param flags a number used to store a series of bit flags
1054
- * @returns a reference to the same constructor passed in (but now mutated)
1055
- */
1056
- const proxyComponent = (Cstr, cmpMeta, flags) => {
1057
- if (cmpMeta.$members$) {
1058
- if (Cstr.watchers) {
1059
- cmpMeta.$watchers$ = Cstr.watchers;
1060
- }
1061
- // It's better to have a const than two Object.entries()
1062
- const members = Object.entries(cmpMeta.$members$);
1063
- const prototype = Cstr.prototype;
1064
- members.map(([memberName, [memberFlags]]) => {
1065
- if ((memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
1066
- ((flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
1067
- // proxyComponent - prop
1068
- Object.defineProperty(prototype, memberName, {
1069
- get() {
1070
- // proxyComponent, get value
1071
- return getValue(this, memberName);
1072
- },
1073
- set(newValue) {
1074
- // proxyComponent, set value
1075
- setValue(this, memberName, newValue, cmpMeta);
1076
- },
1077
- configurable: true,
1078
- enumerable: true,
1079
- });
1080
- }
1081
- });
1082
- if ((flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
1083
- const attrNameToPropName = new Map();
1084
- prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
1085
- plt.jmp(() => {
1086
- const propName = attrNameToPropName.get(attrName);
1087
- // In a web component lifecycle the attributeChangedCallback runs prior to connectedCallback
1088
- // in the case where an attribute was set inline.
1089
- // ```html
1090
- // <my-component some-attribute="some-value"></my-component>
1091
- // ```
1092
- //
1093
- // There is an edge case where a developer sets the attribute inline on a custom element and then
1094
- // programmatically changes it before it has been upgraded as shown below:
1095
- //
1096
- // ```html
1097
- // <!-- this component has _not_ been upgraded yet -->
1098
- // <my-component id="test" some-attribute="some-value"></my-component>
1099
- // <script>
1100
- // // grab non-upgraded component
1101
- // el = document.querySelector("#test");
1102
- // el.someAttribute = "another-value";
1103
- // // upgrade component
1104
- // customElements.define('my-component', MyComponent);
1105
- // </script>
1106
- // ```
1107
- // In this case if we do not unshadow here and use the value of the shadowing property, attributeChangedCallback
1108
- // will be called with `newValue = "some-value"` and will set the shadowed property (this.someAttribute = "another-value")
1109
- // to the value that was set inline i.e. "some-value" from above example. When
1110
- // the connectedCallback attempts to unshadow it will use "some-value" as the initial value rather than "another-value"
1111
- //
1112
- // The case where the attribute was NOT set inline but was not set programmatically shall be handled/unshadowed
1113
- // by connectedCallback as this attributeChangedCallback will not fire.
1114
- //
1115
- // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1116
- //
1117
- // TODO(STENCIL-16) we should think about whether or not we actually want to be reflecting the attributes to
1118
- // properties here given that this goes against best practices outlined here
1119
- // https://developers.google.com/web/fundamentals/web-components/best-practices#avoid-reentrancy
1120
- if (this.hasOwnProperty(propName)) {
1121
- newValue = this[propName];
1122
- delete this[propName];
1123
- }
1124
- else if (prototype.hasOwnProperty(propName) &&
1125
- typeof this[propName] === 'number' &&
1126
- this[propName] == newValue) {
1127
- // if the propName exists on the prototype of `Cstr`, this update may be a result of Stencil using native
1128
- // APIs to reflect props as attributes. Calls to `setAttribute(someElement, propName)` will result in
1129
- // `propName` to be converted to a `DOMString`, which may not be what we want for other primitive props.
1130
- return;
1131
- }
1132
- this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
1133
- });
1134
- };
1135
- // create an array of attributes to observe
1136
- // and also create a map of html attribute name to js property name
1137
- Cstr.observedAttributes = members
1138
- .filter(([_, m]) => m[0] & 15 /* MEMBER_FLAGS.HasAttribute */) // filter to only keep props that should match attributes
1139
- .map(([propName, m]) => {
1140
- const attrName = m[1] || propName;
1141
- attrNameToPropName.set(attrName, propName);
1142
- if (m[0] & 512 /* MEMBER_FLAGS.ReflectAttr */) {
1143
- cmpMeta.$attrsToReflect$.push([propName, attrName]);
1144
- }
1145
- return attrName;
1146
- });
1147
- }
1148
- }
1149
- return Cstr;
1150
- };
1151
- const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
1152
- // initializeComponent
1153
- if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
1154
- {
1155
- // we haven't initialized this element yet
1156
- hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
1157
- // lazy loaded components
1158
- // request the component's implementation to be
1159
- // wired up with the host element
1160
- Cstr = loadModule(cmpMeta);
1161
- if (Cstr.then) {
1162
- // Await creates a micro-task avoid if possible
1163
- const endLoad = uniqueTime();
1164
- Cstr = await Cstr;
1165
- endLoad();
1166
- }
1167
- if (!Cstr.isProxied) {
1168
- // we've never proxied this Constructor before
1169
- // let's add the getters/setters to its prototype before
1170
- // the first time we create an instance of the implementation
1171
- {
1172
- cmpMeta.$watchers$ = Cstr.watchers;
1173
- }
1174
- proxyComponent(Cstr, cmpMeta, 2 /* PROXY_FLAGS.proxyState */);
1175
- Cstr.isProxied = true;
1176
- }
1177
- const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
1178
- // ok, time to construct the instance
1179
- // but let's keep track of when we start and stop
1180
- // so that the getters/setters don't incorrectly step on data
1181
- {
1182
- hostRef.$flags$ |= 8 /* HOST_FLAGS.isConstructingInstance */;
1183
- }
1184
- // construct the lazy-loaded component implementation
1185
- // passing the hostRef is very important during
1186
- // construction in order to directly wire together the
1187
- // host element and the lazy-loaded instance
1188
- try {
1189
- new Cstr(hostRef);
1190
- }
1191
- catch (e) {
1192
- consoleError(e);
1193
- }
1194
- {
1195
- hostRef.$flags$ &= ~8 /* HOST_FLAGS.isConstructingInstance */;
1196
- }
1197
- {
1198
- hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */;
1199
- }
1200
- endNewInstance();
1201
- }
1202
- if (Cstr.style) {
1203
- // this component has styles but we haven't registered them yet
1204
- let style = Cstr.style;
1205
- const scopeId = getScopeId(cmpMeta);
1206
- if (!styles.has(scopeId)) {
1207
- const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
1208
- registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
1209
- endRegisterStyles();
1210
- }
1211
- }
1212
- }
1213
- // we've successfully created a lazy instance
1214
- const ancestorComponent = hostRef.$ancestorComponent$;
1215
- const schedule = () => scheduleUpdate(hostRef, true);
1216
- if (ancestorComponent && ancestorComponent['s-rc']) {
1217
- // this is the initial load and this component it has an ancestor component
1218
- // but the ancestor component has NOT fired its will update lifecycle yet
1219
- // so let's just cool our jets and wait for the ancestor to continue first
1220
- // this will get fired off when the ancestor component
1221
- // finally gets around to rendering its lazy self
1222
- // fire off the initial update
1223
- ancestorComponent['s-rc'].push(schedule);
1224
- }
1225
- else {
1226
- schedule();
1227
- }
1228
- };
1229
- const connectedCallback = (elm) => {
1230
- if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
1231
- const hostRef = getHostRef(elm);
1232
- const cmpMeta = hostRef.$cmpMeta$;
1233
- const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
1234
- if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
1235
- // first time this component has connected
1236
- hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
1237
- {
1238
- // find the first ancestor component (if there is one) and register
1239
- // this component as one of the actively loading child components for its ancestor
1240
- let ancestorComponent = elm;
1241
- while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
1242
- // climb up the ancestors looking for the first
1243
- // component that hasn't finished its lifecycle update yet
1244
- if (ancestorComponent['s-p']) {
1245
- // we found this components first ancestor component
1246
- // keep a reference to this component's ancestor component
1247
- attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
1248
- break;
1249
- }
1250
- }
1251
- }
1252
- // Lazy properties
1253
- // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1254
- if (cmpMeta.$members$) {
1255
- Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
1256
- if (memberFlags & 31 /* MEMBER_FLAGS.Prop */ && elm.hasOwnProperty(memberName)) {
1257
- const value = elm[memberName];
1258
- delete elm[memberName];
1259
- elm[memberName] = value;
1260
- }
1261
- });
1262
- }
1263
- {
1264
- initializeComponent(elm, hostRef, cmpMeta);
1265
- }
1266
- }
1267
- else {
1268
- // not the first time this has connected
1269
- // reattach any event listeners to the host
1270
- // since they would have been removed when disconnected
1271
- addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
1272
- }
1273
- endConnected();
1274
- }
1275
- };
1276
- const disconnectedCallback = (elm) => {
1277
- if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
1278
- const hostRef = getHostRef(elm);
1279
- const instance = hostRef.$lazyInstance$ ;
1280
- {
1281
- if (hostRef.$rmListeners$) {
1282
- hostRef.$rmListeners$.map((rmListener) => rmListener());
1283
- hostRef.$rmListeners$ = undefined;
1284
- }
1285
- }
1286
- {
1287
- safeCall(instance, 'disconnectedCallback');
1288
- }
1289
- }
1290
- };
1291
- const bootstrapLazy = (lazyBundles, options = {}) => {
1292
- var _a;
1293
- const endBootstrap = createTime();
1294
- const cmpTags = [];
1295
- const exclude = options.exclude || [];
1296
- const customElements = win.customElements;
1297
- const head = doc.head;
1298
- const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
1299
- const visibilityStyle = /*@__PURE__*/ doc.createElement('style');
1300
- const deferredConnectedCallbacks = [];
1301
- let appLoadFallback;
1302
- let isBootstrapping = true;
1303
- Object.assign(plt, options);
1304
- plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
1305
- lazyBundles.map((lazyBundle) => {
1306
- lazyBundle[1].map((compactMeta) => {
1307
- const cmpMeta = {
1308
- $flags$: compactMeta[0],
1309
- $tagName$: compactMeta[1],
1310
- $members$: compactMeta[2],
1311
- $listeners$: compactMeta[3],
1312
- };
1313
- {
1314
- cmpMeta.$members$ = compactMeta[2];
1315
- }
1316
- {
1317
- cmpMeta.$listeners$ = compactMeta[3];
1318
- }
1319
- {
1320
- cmpMeta.$attrsToReflect$ = [];
1321
- }
1322
- {
1323
- cmpMeta.$watchers$ = {};
1324
- }
1325
- const tagName = cmpMeta.$tagName$;
1326
- const HostElement = class extends HTMLElement {
1327
- // StencilLazyHost
1328
- constructor(self) {
1329
- // @ts-ignore
1330
- super(self);
1331
- self = this;
1332
- registerHost(self, cmpMeta);
1333
- if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
1334
- // this component is using shadow dom
1335
- // and this browser supports shadow dom
1336
- // add the read-only property "shadowRoot" to the host element
1337
- // adding the shadow root build conditionals to minimize runtime
1338
- {
1339
- {
1340
- self.attachShadow({ mode: 'open' });
1341
- }
1342
- }
1343
- }
1344
- }
1345
- connectedCallback() {
1346
- if (appLoadFallback) {
1347
- clearTimeout(appLoadFallback);
1348
- appLoadFallback = null;
1349
- }
1350
- if (isBootstrapping) {
1351
- // connectedCallback will be processed once all components have been registered
1352
- deferredConnectedCallbacks.push(this);
1353
- }
1354
- else {
1355
- plt.jmp(() => connectedCallback(this));
1356
- }
1357
- }
1358
- disconnectedCallback() {
1359
- plt.jmp(() => disconnectedCallback(this));
1360
- }
1361
- componentOnReady() {
1362
- return getHostRef(this).$onReadyPromise$;
1363
- }
1364
- };
1365
- cmpMeta.$lazyBundleId$ = lazyBundle[0];
1366
- if (!exclude.includes(tagName) && !customElements.get(tagName)) {
1367
- cmpTags.push(tagName);
1368
- customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */));
1369
- }
1370
- });
1371
- });
1372
- {
1373
- visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
1374
- visibilityStyle.setAttribute('data-styles', '');
1375
- // Apply CSP nonce to the style tag if it exists
1376
- const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
1377
- if (nonce != null) {
1378
- visibilityStyle.setAttribute('nonce', nonce);
1379
- }
1380
- head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
1381
- }
1382
- // Process deferred connectedCallbacks now all components have been registered
1383
- isBootstrapping = false;
1384
- if (deferredConnectedCallbacks.length) {
1385
- deferredConnectedCallbacks.map((host) => host.connectedCallback());
1386
- }
1387
- else {
1388
- {
1389
- plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30)));
1390
- }
1391
- }
1392
- // Fallback appLoad event
1393
- endBootstrap();
1394
- };
1395
- const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
1396
- if (listeners) {
1397
- listeners.map(([flags, name, method]) => {
1398
- const target = getHostListenerTarget(elm, flags) ;
1399
- const handler = hostListenerProxy(hostRef, method);
1400
- const opts = hostListenerOpts(flags);
1401
- plt.ael(target, name, handler, opts);
1402
- (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
1403
- });
1404
- }
1405
- };
1406
- const hostListenerProxy = (hostRef, methodName) => (ev) => {
1407
- try {
1408
- {
1409
- if (hostRef.$flags$ & 256 /* HOST_FLAGS.isListenReady */) {
1410
- // instance is ready, let's call it's member method for this event
1411
- hostRef.$lazyInstance$[methodName](ev);
1412
- }
1413
- else {
1414
- (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
1415
- }
1416
- }
1417
- }
1418
- catch (e) {
1419
- consoleError(e);
1420
- }
1421
- };
1422
- const getHostListenerTarget = (elm, flags) => {
1423
- if (flags & 8 /* LISTENER_FLAGS.TargetWindow */)
1424
- return win;
1425
- return elm;
1426
- };
1427
- // prettier-ignore
1428
- const hostListenerOpts = (flags) => (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0;
1429
- /**
1430
- * Assigns the given value to the nonce property on the runtime platform object.
1431
- * During runtime, this value is used to set the nonce attribute on all dynamically created script and style tags.
1432
- * @param nonce The value to be assigned to the platform nonce property.
1433
- * @returns void
1434
- */
1435
- const setNonce = (nonce) => (plt.$nonce$ = nonce);
1436
- const hostRefs = /*@__PURE__*/ new WeakMap();
1437
- const getHostRef = (ref) => hostRefs.get(ref);
1438
- const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
1439
- const registerHost = (elm, cmpMeta) => {
1440
- const hostRef = {
1441
- $flags$: 0,
1442
- $hostElement$: elm,
1443
- $cmpMeta$: cmpMeta,
1444
- $instanceValues$: new Map(),
1445
- };
1446
- {
1447
- hostRef.$onReadyPromise$ = new Promise((r) => (hostRef.$onReadyResolve$ = r));
1448
- elm['s-p'] = [];
1449
- elm['s-rc'] = [];
1450
- }
1451
- addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
1452
- return hostRefs.set(elm, hostRef);
1453
- };
1454
- const isMemberInElement = (elm, memberName) => memberName in elm;
1455
- const consoleError = (e, el) => (0, console.error)(e, el);
1456
- const cmpModules = /*@__PURE__*/ new Map();
1457
- const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
1458
- // loadModuleImport
1459
- const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
1460
- const bundleId = cmpMeta.$lazyBundleId$;
1461
- const module = cmpModules.get(bundleId) ;
1462
- if (module) {
1463
- return module[exportName];
1464
- }
1465
- /*!__STENCIL_STATIC_IMPORT_SWITCH__*/
1466
- return import(
1467
- /* @vite-ignore */
1468
- /* webpackInclude: /\.entry\.js$/ */
1469
- /* webpackExclude: /\.system\.entry\.js$/ */
1470
- /* webpackMode: "lazy" */
1471
- `./${bundleId}.entry.js${''}`).then((importedModule) => {
1472
- {
1473
- cmpModules.set(bundleId, importedModule);
1474
- }
1475
- return importedModule[exportName];
1476
- }, consoleError);
1477
- };
1478
- const styles = /*@__PURE__*/ new Map();
1479
- const win = typeof window !== 'undefined' ? window : {};
1480
- const doc = win.document || { head: {} };
1481
- const plt = {
1482
- $flags$: 0,
1483
- $resourcesUrl$: '',
1484
- jmp: (h) => h(),
1485
- raf: (h) => requestAnimationFrame(h),
1486
- ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
1487
- rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
1488
- ce: (eventName, opts) => new CustomEvent(eventName, opts),
1489
- };
1490
- const promiseResolve = (v) => Promise.resolve(v);
1491
- const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
1492
- try {
1493
- new CSSStyleSheet();
1494
- return typeof new CSSStyleSheet().replaceSync === 'function';
1495
- }
1496
- catch (e) { }
1497
- return false;
1498
- })()
1499
- ;
1500
- const queueDomReads = [];
1501
- const queueDomWrites = [];
1502
- const queueTask = (queue, write) => (cb) => {
1503
- queue.push(cb);
1504
- if (!queuePending) {
1505
- queuePending = true;
1506
- if (write && plt.$flags$ & 4 /* PLATFORM_FLAGS.queueSync */) {
1507
- nextTick(flush);
1508
- }
1509
- else {
1510
- plt.raf(flush);
1511
- }
1512
- }
1513
- };
1514
- const consume = (queue) => {
1515
- for (let i = 0; i < queue.length; i++) {
1516
- try {
1517
- queue[i](performance.now());
1518
- }
1519
- catch (e) {
1520
- consoleError(e);
1521
- }
1522
- }
1523
- queue.length = 0;
1524
- };
1525
- const flush = () => {
1526
- // always force a bunch of medium callbacks to run, but still have
1527
- // a throttle on how many can run in a certain time
1528
- // DOM READS!!!
1529
- consume(queueDomReads);
1530
- // DOM WRITES!!!
1531
- {
1532
- consume(queueDomWrites);
1533
- if ((queuePending = queueDomReads.length > 0)) {
1534
- // still more to do yet, but we've run out of time
1535
- // let's let this thing cool off and try again in the next tick
1536
- plt.raf(flush);
1537
- }
1538
- }
1539
- };
1540
- const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
1541
- const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
1542
-
1543
- export { getRenderingRef as a, bootstrapLazy as b, createEvent as c, forceUpdate as f, getElement as g, h, promiseResolve as p, registerInstance as r, setNonce as s };