@revolist/revogrid 3.2.0 → 3.2.4

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