@xplortech/apollo-core 0.5.2 → 0.5.3

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