@jaak.ai/stamps 1.0.0-dev.9 → 2.0.0-beta.1

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