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