@xplortech/apollo-core 0.4.1 → 0.5.0

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