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