@sankhyalabs/sankhyablocks 1.3.31-beta.14 → 1.3.31-beta.17

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