@ezeep/ezeep-js 1.0.267 → 1.0.269

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