@paperless/core 0.0.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 (188) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +119 -0
  3. package/dist/assets/fonts/ibm-plex-sans-v3-latin-300.eot +0 -0
  4. package/dist/assets/fonts/ibm-plex-sans-v3-latin-300.svg +336 -0
  5. package/dist/assets/fonts/ibm-plex-sans-v3-latin-300.ttf +0 -0
  6. package/dist/assets/fonts/ibm-plex-sans-v3-latin-300.woff +0 -0
  7. package/dist/assets/fonts/ibm-plex-sans-v3-latin-300.woff2 +0 -0
  8. package/dist/assets/fonts/ibm-plex-sans-v3-latin-500.eot +0 -0
  9. package/dist/assets/fonts/ibm-plex-sans-v3-latin-500.svg +337 -0
  10. package/dist/assets/fonts/ibm-plex-sans-v3-latin-500.ttf +0 -0
  11. package/dist/assets/fonts/ibm-plex-sans-v3-latin-500.woff +0 -0
  12. package/dist/assets/fonts/ibm-plex-sans-v3-latin-500.woff2 +0 -0
  13. package/dist/assets/fonts/ibm-plex-sans-v3-latin-600.eot +0 -0
  14. package/dist/assets/fonts/ibm-plex-sans-v3-latin-600.svg +336 -0
  15. package/dist/assets/fonts/ibm-plex-sans-v3-latin-600.ttf +0 -0
  16. package/dist/assets/fonts/ibm-plex-sans-v3-latin-600.woff +0 -0
  17. package/dist/assets/fonts/ibm-plex-sans-v3-latin-600.woff2 +0 -0
  18. package/dist/assets/fonts/ibm-plex-sans-v3-latin-700.eot +0 -0
  19. package/dist/assets/fonts/ibm-plex-sans-v3-latin-700.svg +336 -0
  20. package/dist/assets/fonts/ibm-plex-sans-v3-latin-700.ttf +0 -0
  21. package/dist/assets/fonts/ibm-plex-sans-v3-latin-700.woff +0 -0
  22. package/dist/assets/fonts/ibm-plex-sans-v3-latin-700.woff2 +0 -0
  23. package/dist/assets/fonts/ibm-plex-sans-v3-latin-regular.eot +0 -0
  24. package/dist/assets/fonts/ibm-plex-sans-v3-latin-regular.svg +337 -0
  25. package/dist/assets/fonts/ibm-plex-sans-v3-latin-regular.ttf +0 -0
  26. package/dist/assets/fonts/ibm-plex-sans-v3-latin-regular.woff +0 -0
  27. package/dist/assets/fonts/ibm-plex-sans-v3-latin-regular.woff2 +0 -0
  28. package/dist/assets/icons/arrow.svg +14 -0
  29. package/dist/assets/icons/attachment.svg +16 -0
  30. package/dist/assets/icons/bread.svg +17 -0
  31. package/dist/assets/icons/calendar.svg +16 -0
  32. package/dist/assets/icons/car.svg +17 -0
  33. package/dist/assets/icons/checkmark.svg +17 -0
  34. package/dist/assets/icons/chevron.svg +17 -0
  35. package/dist/assets/icons/clock.svg +17 -0
  36. package/dist/assets/icons/cogs.svg +17 -0
  37. package/dist/assets/icons/comment.svg +17 -0
  38. package/dist/assets/icons/document.svg +17 -0
  39. package/dist/assets/icons/download.svg +17 -0
  40. package/dist/assets/icons/envelope.svg +17 -0
  41. package/dist/assets/icons/explanation.svg +17 -0
  42. package/dist/assets/icons/eye.svg +17 -0
  43. package/dist/assets/icons/filter.svg +17 -0
  44. package/dist/assets/icons/grid.svg +17 -0
  45. package/dist/assets/icons/headset.svg +17 -0
  46. package/dist/assets/icons/list.svg +17 -0
  47. package/dist/assets/icons/location.svg +17 -0
  48. package/dist/assets/icons/megaphone.svg +17 -0
  49. package/dist/assets/icons/minus.svg +17 -0
  50. package/dist/assets/icons/negative.svg +17 -0
  51. package/dist/assets/icons/pagination.svg +17 -0
  52. package/dist/assets/icons/payment.svg +17 -0
  53. package/dist/assets/icons/pencil.svg +17 -0
  54. package/dist/assets/icons/person.svg +17 -0
  55. package/dist/assets/icons/plus.svg +17 -0
  56. package/dist/assets/icons/question.svg +17 -0
  57. package/dist/assets/icons/receipt.svg +17 -0
  58. package/dist/assets/icons/report.svg +17 -0
  59. package/dist/assets/icons/search.svg +17 -0
  60. package/dist/assets/icons/settings.svg +25 -0
  61. package/dist/assets/icons/sick.svg +17 -0
  62. package/dist/assets/icons/tachometer.svg +17 -0
  63. package/dist/assets/icons/tool.svg +17 -0
  64. package/dist/assets/icons/trash.svg +17 -0
  65. package/dist/assets/icons/turn.svg +17 -0
  66. package/dist/assets/icons/upload.svg +17 -0
  67. package/dist/assets/icons/warning.svg +17 -0
  68. package/dist/assets/illustrations/default-empty-state.svg +186 -0
  69. package/dist/assets/illustrations/departments.svg +31 -0
  70. package/dist/assets/illustrations/expenses.svg +397 -0
  71. package/dist/assets/illustrations/functions.svg +58 -0
  72. package/dist/assets/illustrations/questions.svg +30 -0
  73. package/dist/assets/illustrations/sick-leave.svg +353 -0
  74. package/dist/assets/illustrations/time-off.svg +271 -0
  75. package/dist/assets/illustrations/upgrade-to-hr.svg +56 -0
  76. package/dist/assets/images/paperless.png +0 -0
  77. package/dist/build/index.esm.js +0 -0
  78. package/dist/build/p-123f3a00.entry.js +1 -0
  79. package/dist/build/p-2f230908.css +70 -0
  80. package/dist/build/p-54459ae1.js +2 -0
  81. package/dist/build/paperless.css +70 -0
  82. package/dist/build/paperless.esm.js +1 -0
  83. package/dist/build/paperless.js +33 -0
  84. package/dist/cjs/index-e3e940d8.js +1032 -0
  85. package/dist/cjs/index.cjs.js +2 -0
  86. package/dist/cjs/loader.cjs.js +21 -0
  87. package/dist/cjs/p-button.cjs.entry.js +23 -0
  88. package/dist/cjs/paperless.cjs.js +19 -0
  89. package/dist/collection/assets/fonts/ibm-plex-sans-v3-latin-300.svg +336 -0
  90. package/dist/collection/assets/fonts/ibm-plex-sans-v3-latin-500.svg +337 -0
  91. package/dist/collection/assets/fonts/ibm-plex-sans-v3-latin-600.svg +336 -0
  92. package/dist/collection/assets/fonts/ibm-plex-sans-v3-latin-700.svg +336 -0
  93. package/dist/collection/assets/fonts/ibm-plex-sans-v3-latin-regular.svg +337 -0
  94. package/dist/collection/assets/icons/arrow.svg +14 -0
  95. package/dist/collection/assets/icons/attachment.svg +16 -0
  96. package/dist/collection/assets/icons/bread.svg +17 -0
  97. package/dist/collection/assets/icons/calendar.svg +16 -0
  98. package/dist/collection/assets/icons/car.svg +17 -0
  99. package/dist/collection/assets/icons/checkmark.svg +17 -0
  100. package/dist/collection/assets/icons/chevron.svg +17 -0
  101. package/dist/collection/assets/icons/clock.svg +17 -0
  102. package/dist/collection/assets/icons/cogs.svg +17 -0
  103. package/dist/collection/assets/icons/comment.svg +17 -0
  104. package/dist/collection/assets/icons/document.svg +17 -0
  105. package/dist/collection/assets/icons/download.svg +17 -0
  106. package/dist/collection/assets/icons/envelope.svg +17 -0
  107. package/dist/collection/assets/icons/explanation.svg +17 -0
  108. package/dist/collection/assets/icons/eye.svg +17 -0
  109. package/dist/collection/assets/icons/filter.svg +17 -0
  110. package/dist/collection/assets/icons/grid.svg +17 -0
  111. package/dist/collection/assets/icons/headset.svg +17 -0
  112. package/dist/collection/assets/icons/list.svg +17 -0
  113. package/dist/collection/assets/icons/location.svg +17 -0
  114. package/dist/collection/assets/icons/megaphone.svg +17 -0
  115. package/dist/collection/assets/icons/minus.svg +17 -0
  116. package/dist/collection/assets/icons/negative.svg +17 -0
  117. package/dist/collection/assets/icons/pagination.svg +17 -0
  118. package/dist/collection/assets/icons/payment.svg +17 -0
  119. package/dist/collection/assets/icons/pencil.svg +17 -0
  120. package/dist/collection/assets/icons/person.svg +17 -0
  121. package/dist/collection/assets/icons/plus.svg +17 -0
  122. package/dist/collection/assets/icons/question.svg +17 -0
  123. package/dist/collection/assets/icons/receipt.svg +17 -0
  124. package/dist/collection/assets/icons/report.svg +17 -0
  125. package/dist/collection/assets/icons/search.svg +17 -0
  126. package/dist/collection/assets/icons/settings.svg +25 -0
  127. package/dist/collection/assets/icons/sick.svg +17 -0
  128. package/dist/collection/assets/icons/tachometer.svg +17 -0
  129. package/dist/collection/assets/icons/tool.svg +17 -0
  130. package/dist/collection/assets/icons/trash.svg +17 -0
  131. package/dist/collection/assets/icons/turn.svg +17 -0
  132. package/dist/collection/assets/icons/upload.svg +17 -0
  133. package/dist/collection/assets/icons/warning.svg +17 -0
  134. package/dist/collection/assets/illustrations/default-empty-state.svg +186 -0
  135. package/dist/collection/assets/illustrations/departments.svg +31 -0
  136. package/dist/collection/assets/illustrations/expenses.svg +397 -0
  137. package/dist/collection/assets/illustrations/functions.svg +58 -0
  138. package/dist/collection/assets/illustrations/questions.svg +30 -0
  139. package/dist/collection/assets/illustrations/sick-leave.svg +353 -0
  140. package/dist/collection/assets/illustrations/time-off.svg +271 -0
  141. package/dist/collection/assets/illustrations/upgrade-to-hr.svg +56 -0
  142. package/dist/collection/collection-manifest.json +12 -0
  143. package/dist/collection/components/button/button.component.css +6 -0
  144. package/dist/collection/components/button/button.component.js +41 -0
  145. package/dist/collection/index.js +1 -0
  146. package/dist/collection/tailwind/border-radius.js +7 -0
  147. package/dist/collection/tailwind/colors.js +52 -0
  148. package/dist/collection/tailwind/shadows.js +7 -0
  149. package/dist/collection/tailwind.config.js +14 -0
  150. package/dist/collection/utils/utils.js +3 -0
  151. package/dist/components/index.d.ts +22 -0
  152. package/dist/components/index.js +2 -0
  153. package/dist/components/p-button.d.ts +11 -0
  154. package/dist/components/p-button.js +39 -0
  155. package/dist/esm/index-100a5ae6.js +1007 -0
  156. package/dist/esm/index.js +1 -0
  157. package/dist/esm/loader.js +17 -0
  158. package/dist/esm/p-button.entry.js +19 -0
  159. package/dist/esm/paperless.js +17 -0
  160. package/dist/esm/polyfills/core-js.js +11 -0
  161. package/dist/esm/polyfills/css-shim.js +1 -0
  162. package/dist/esm/polyfills/dom.js +79 -0
  163. package/dist/esm/polyfills/es5-html-element.js +1 -0
  164. package/dist/esm/polyfills/index.js +34 -0
  165. package/dist/esm/polyfills/system.js +6 -0
  166. package/dist/host.config.json +15 -0
  167. package/dist/index.cjs.js +1 -0
  168. package/dist/index.html +17 -0
  169. package/dist/index.js +1 -0
  170. package/dist/paperless/index.esm.js +0 -0
  171. package/dist/paperless/p-123f3a00.entry.js +1 -0
  172. package/dist/paperless/p-54459ae1.js +2 -0
  173. package/dist/paperless/paperless.css +661 -0
  174. package/dist/paperless/paperless.esm.js +1 -0
  175. package/dist/sw.js +172 -0
  176. package/dist/tailwind.config.js +14 -0
  177. package/dist/types/components/button/button.component.d.ts +7 -0
  178. package/dist/types/components.d.ts +45 -0
  179. package/dist/types/index.d.ts +1 -0
  180. package/dist/types/stencil-public-runtime.d.ts +1565 -0
  181. package/dist/types/utils/utils.d.ts +1 -0
  182. package/loader/cdn.js +3 -0
  183. package/loader/index.cjs.js +3 -0
  184. package/loader/index.d.ts +12 -0
  185. package/loader/index.es2017.js +3 -0
  186. package/loader/index.js +4 -0
  187. package/loader/package.json +10 -0
  188. package/package.json +59 -0
@@ -0,0 +1,1032 @@
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 = 'paperless';
24
+
25
+ let scopeId;
26
+ let hostTagName;
27
+ let queuePending = false;
28
+ const win = typeof window !== 'undefined' ? window : {};
29
+ const doc = win.document || { head: {} };
30
+ const plt = {
31
+ $flags$: 0,
32
+ $resourcesUrl$: '',
33
+ jmp: (h) => h(),
34
+ raf: (h) => requestAnimationFrame(h),
35
+ ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
36
+ rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
37
+ ce: (eventName, opts) => new CustomEvent(eventName, opts),
38
+ };
39
+ const promiseResolve = (v) => Promise.resolve(v);
40
+ const supportsConstructibleStylesheets = /*@__PURE__*/ (() => {
41
+ try {
42
+ new CSSStyleSheet();
43
+ return typeof new CSSStyleSheet().replace === 'function';
44
+ }
45
+ catch (e) { }
46
+ return false;
47
+ })()
48
+ ;
49
+ const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
50
+ const createTime = (fnName, tagName = '') => {
51
+ {
52
+ return () => {
53
+ return;
54
+ };
55
+ }
56
+ };
57
+ const uniqueTime = (key, measureText) => {
58
+ {
59
+ return () => {
60
+ return;
61
+ };
62
+ }
63
+ };
64
+ const rootAppliedStyles = new WeakMap();
65
+ const registerStyle = (scopeId, cssText, allowCS) => {
66
+ let style = styles.get(scopeId);
67
+ if (supportsConstructibleStylesheets && allowCS) {
68
+ style = (style || new CSSStyleSheet());
69
+ style.replace(cssText);
70
+ }
71
+ else {
72
+ style = cssText;
73
+ }
74
+ styles.set(scopeId, style);
75
+ };
76
+ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
77
+ let scopeId = getScopeId(cmpMeta);
78
+ const style = styles.get(scopeId);
79
+ // if an element is NOT connected then getRootNode() will return the wrong root node
80
+ // so the fallback is to always use the document for the root node in those cases
81
+ styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
82
+ if (style) {
83
+ if (typeof style === 'string') {
84
+ styleContainerNode = styleContainerNode.head || styleContainerNode;
85
+ let appliedStyles = rootAppliedStyles.get(styleContainerNode);
86
+ let styleElm;
87
+ if (!appliedStyles) {
88
+ rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
89
+ }
90
+ if (!appliedStyles.has(scopeId)) {
91
+ {
92
+ {
93
+ styleElm = doc.createElement('style');
94
+ styleElm.innerHTML = style;
95
+ }
96
+ styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
97
+ }
98
+ if (appliedStyles) {
99
+ appliedStyles.add(scopeId);
100
+ }
101
+ }
102
+ }
103
+ else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
104
+ styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
105
+ }
106
+ }
107
+ return scopeId;
108
+ };
109
+ const attachStyles = (hostRef) => {
110
+ const cmpMeta = hostRef.$cmpMeta$;
111
+ const elm = hostRef.$hostElement$;
112
+ const flags = cmpMeta.$flags$;
113
+ const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
114
+ const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
115
+ if (flags & 10 /* needsScopedEncapsulation */) {
116
+ // only required when we're NOT using native shadow dom (slot)
117
+ // or this browser doesn't support native shadow dom
118
+ // and this host element was NOT created with SSR
119
+ // let's pick out the inner content for slot projection
120
+ // create a node to represent where the original
121
+ // content was first placed, which is useful later on
122
+ // DOM WRITE!!
123
+ elm['s-sc'] = scopeId;
124
+ elm.classList.add(scopeId + '-h');
125
+ }
126
+ endAttachStyles();
127
+ };
128
+ const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
129
+ /**
130
+ * Default style mode id
131
+ */
132
+ /**
133
+ * Reusable empty obj/array
134
+ * Don't add values to these!!
135
+ */
136
+ const EMPTY_OBJ = {};
137
+ const isDef = (v) => v != null;
138
+ const isComplexType = (o) => {
139
+ // https://jsperf.com/typeof-fn-object/5
140
+ o = typeof o;
141
+ return o === 'object' || o === 'function';
142
+ };
143
+ /**
144
+ * Production h() function based on Preact by
145
+ * Jason Miller (@developit)
146
+ * Licensed under the MIT License
147
+ * https://github.com/developit/preact/blob/master/LICENSE
148
+ *
149
+ * Modified for Stencil's compiler and vdom
150
+ */
151
+ // const stack: any[] = [];
152
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
153
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
154
+ const h = (nodeName, vnodeData, ...children) => {
155
+ let child = null;
156
+ let simple = false;
157
+ let lastSimple = false;
158
+ const vNodeChildren = [];
159
+ const walk = (c) => {
160
+ for (let i = 0; i < c.length; i++) {
161
+ child = c[i];
162
+ if (Array.isArray(child)) {
163
+ walk(child);
164
+ }
165
+ else if (child != null && typeof child !== 'boolean') {
166
+ if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
167
+ child = String(child);
168
+ }
169
+ if (simple && lastSimple) {
170
+ // If the previous child was simple (string), we merge both
171
+ vNodeChildren[vNodeChildren.length - 1].$text$ += child;
172
+ }
173
+ else {
174
+ // Append a new vNode, if it's text, we create a text vNode
175
+ vNodeChildren.push(simple ? newVNode(null, child) : child);
176
+ }
177
+ lastSimple = simple;
178
+ }
179
+ }
180
+ };
181
+ walk(children);
182
+ if (vnodeData) {
183
+ {
184
+ const classData = vnodeData.className || vnodeData.class;
185
+ if (classData) {
186
+ vnodeData.class =
187
+ typeof classData !== 'object'
188
+ ? classData
189
+ : Object.keys(classData)
190
+ .filter((k) => classData[k])
191
+ .join(' ');
192
+ }
193
+ }
194
+ }
195
+ const vnode = newVNode(nodeName, null);
196
+ vnode.$attrs$ = vnodeData;
197
+ if (vNodeChildren.length > 0) {
198
+ vnode.$children$ = vNodeChildren;
199
+ }
200
+ return vnode;
201
+ };
202
+ const newVNode = (tag, text) => {
203
+ const vnode = {
204
+ $flags$: 0,
205
+ $tag$: tag,
206
+ $text$: text,
207
+ $elm$: null,
208
+ $children$: null,
209
+ };
210
+ {
211
+ vnode.$attrs$ = null;
212
+ }
213
+ return vnode;
214
+ };
215
+ const Host = {};
216
+ const isHost = (node) => node && node.$tag$ === Host;
217
+ /**
218
+ * Production setAccessor() function based on Preact by
219
+ * Jason Miller (@developit)
220
+ * Licensed under the MIT License
221
+ * https://github.com/developit/preact/blob/master/LICENSE
222
+ *
223
+ * Modified for Stencil's compiler and vdom
224
+ */
225
+ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
226
+ if (oldValue !== newValue) {
227
+ memberName.toLowerCase();
228
+ if (memberName === 'class') {
229
+ const classList = elm.classList;
230
+ const oldClasses = parseClassList(oldValue);
231
+ const newClasses = parseClassList(newValue);
232
+ classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
233
+ classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
234
+ }
235
+ }
236
+ };
237
+ const parseClassListRegex = /\s/;
238
+ const parseClassList = (value) => (!value ? [] : value.split(parseClassListRegex));
239
+ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
240
+ // if the element passed in is a shadow root, which is a document fragment
241
+ // then we want to be adding attrs/props to the shadow root's "host" element
242
+ // if it's not a shadow root, then we add attrs/props to the same element
243
+ const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host
244
+ ? newVnode.$elm$.host
245
+ : newVnode.$elm$;
246
+ const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
247
+ const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
248
+ {
249
+ // remove attributes no longer present on the vnode by setting them to undefined
250
+ for (memberName in oldVnodeAttrs) {
251
+ if (!(memberName in newVnodeAttrs)) {
252
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], undefined);
253
+ }
254
+ }
255
+ }
256
+ // add new & update changed attributes
257
+ for (memberName in newVnodeAttrs) {
258
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName]);
259
+ }
260
+ };
261
+ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
262
+ // tslint:disable-next-line: prefer-const
263
+ const newVNode = newParentVNode.$children$[childIndex];
264
+ let i = 0;
265
+ let elm;
266
+ let childNode;
267
+ {
268
+ // create element
269
+ elm = newVNode.$elm$ = (doc.createElement(newVNode.$tag$));
270
+ // add css classes, attrs, props, listeners, etc.
271
+ {
272
+ updateElement(null, newVNode);
273
+ }
274
+ if (isDef(scopeId) && elm['s-si'] !== scopeId) {
275
+ // if there is a scopeId and this is the initial render
276
+ // then let's add the scopeId as a css class
277
+ elm.classList.add((elm['s-si'] = scopeId));
278
+ }
279
+ if (newVNode.$children$) {
280
+ for (i = 0; i < newVNode.$children$.length; ++i) {
281
+ // create the node
282
+ childNode = createElm(oldParentVNode, newVNode, i);
283
+ // return node could have been null
284
+ if (childNode) {
285
+ // append our new node
286
+ elm.appendChild(childNode);
287
+ }
288
+ }
289
+ }
290
+ }
291
+ return elm;
292
+ };
293
+ const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
294
+ let containerElm = (parentElm);
295
+ let childNode;
296
+ if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
297
+ containerElm = containerElm.shadowRoot;
298
+ }
299
+ for (; startIdx <= endIdx; ++startIdx) {
300
+ if (vnodes[startIdx]) {
301
+ childNode = createElm(null, parentVNode, startIdx);
302
+ if (childNode) {
303
+ vnodes[startIdx].$elm$ = childNode;
304
+ containerElm.insertBefore(childNode, before);
305
+ }
306
+ }
307
+ }
308
+ };
309
+ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
310
+ for (; startIdx <= endIdx; ++startIdx) {
311
+ if ((vnode = vnodes[startIdx])) {
312
+ elm = vnode.$elm$;
313
+ // remove the vnode's element from the dom
314
+ elm.remove();
315
+ }
316
+ }
317
+ };
318
+ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
319
+ let oldStartIdx = 0;
320
+ let newStartIdx = 0;
321
+ let oldEndIdx = oldCh.length - 1;
322
+ let oldStartVnode = oldCh[0];
323
+ let oldEndVnode = oldCh[oldEndIdx];
324
+ let newEndIdx = newCh.length - 1;
325
+ let newStartVnode = newCh[0];
326
+ let newEndVnode = newCh[newEndIdx];
327
+ let node;
328
+ while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
329
+ if (oldStartVnode == null) {
330
+ // Vnode might have been moved left
331
+ oldStartVnode = oldCh[++oldStartIdx];
332
+ }
333
+ else if (oldEndVnode == null) {
334
+ oldEndVnode = oldCh[--oldEndIdx];
335
+ }
336
+ else if (newStartVnode == null) {
337
+ newStartVnode = newCh[++newStartIdx];
338
+ }
339
+ else if (newEndVnode == null) {
340
+ newEndVnode = newCh[--newEndIdx];
341
+ }
342
+ else if (isSameVnode(oldStartVnode, newStartVnode)) {
343
+ patch(oldStartVnode, newStartVnode);
344
+ oldStartVnode = oldCh[++oldStartIdx];
345
+ newStartVnode = newCh[++newStartIdx];
346
+ }
347
+ else if (isSameVnode(oldEndVnode, newEndVnode)) {
348
+ patch(oldEndVnode, newEndVnode);
349
+ oldEndVnode = oldCh[--oldEndIdx];
350
+ newEndVnode = newCh[--newEndIdx];
351
+ }
352
+ else if (isSameVnode(oldStartVnode, newEndVnode)) {
353
+ patch(oldStartVnode, newEndVnode);
354
+ parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
355
+ oldStartVnode = oldCh[++oldStartIdx];
356
+ newEndVnode = newCh[--newEndIdx];
357
+ }
358
+ else if (isSameVnode(oldEndVnode, newStartVnode)) {
359
+ patch(oldEndVnode, newStartVnode);
360
+ parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
361
+ oldEndVnode = oldCh[--oldEndIdx];
362
+ newStartVnode = newCh[++newStartIdx];
363
+ }
364
+ else {
365
+ {
366
+ // new element
367
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
368
+ newStartVnode = newCh[++newStartIdx];
369
+ }
370
+ if (node) {
371
+ {
372
+ oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
373
+ }
374
+ }
375
+ }
376
+ }
377
+ if (oldStartIdx > oldEndIdx) {
378
+ addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
379
+ }
380
+ else if (newStartIdx > newEndIdx) {
381
+ removeVnodes(oldCh, oldStartIdx, oldEndIdx);
382
+ }
383
+ };
384
+ const isSameVnode = (vnode1, vnode2) => {
385
+ // compare if two vnode to see if they're "technically" the same
386
+ // need to have the same element tag, and same key to be the same
387
+ if (vnode1.$tag$ === vnode2.$tag$) {
388
+ return true;
389
+ }
390
+ return false;
391
+ };
392
+ const patch = (oldVNode, newVNode) => {
393
+ const elm = (newVNode.$elm$ = oldVNode.$elm$);
394
+ const oldChildren = oldVNode.$children$;
395
+ const newChildren = newVNode.$children$;
396
+ const tag = newVNode.$tag$;
397
+ {
398
+ // element node
399
+ {
400
+ if (tag === 'slot')
401
+ ;
402
+ else {
403
+ // either this is the first render of an element OR it's an update
404
+ // AND we already know it's possible it could have changed
405
+ // this updates the element's css classes, attrs, props, listeners, etc.
406
+ updateElement(oldVNode, newVNode);
407
+ }
408
+ }
409
+ if (oldChildren !== null && newChildren !== null) {
410
+ // looks like there's child vnodes for both the old and new vnodes
411
+ updateChildren(elm, oldChildren, newVNode, newChildren);
412
+ }
413
+ else if (newChildren !== null) {
414
+ // add the new vnode children
415
+ addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
416
+ }
417
+ else if (oldChildren !== null) {
418
+ // no new child vnodes, but there are old child vnodes to remove
419
+ removeVnodes(oldChildren, 0, oldChildren.length - 1);
420
+ }
421
+ }
422
+ };
423
+ const renderVdom = (hostRef, renderFnResults) => {
424
+ const hostElm = hostRef.$hostElement$;
425
+ const oldVNode = hostRef.$vnode$ || newVNode(null, null);
426
+ const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
427
+ hostTagName = hostElm.tagName;
428
+ rootVnode.$tag$ = null;
429
+ rootVnode.$flags$ |= 4 /* isHost */;
430
+ hostRef.$vnode$ = rootVnode;
431
+ rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
432
+ {
433
+ scopeId = hostElm['s-sc'];
434
+ }
435
+ // synchronous patch
436
+ patch(oldVNode, rootVnode);
437
+ };
438
+ /**
439
+ * Helper function to create & dispatch a custom Event on a provided target
440
+ * @param elm the target of the Event
441
+ * @param name the name to give the custom Event
442
+ * @param opts options for configuring a custom Event
443
+ * @returns the custom Event
444
+ */
445
+ const emitEvent = (elm, name, opts) => {
446
+ const ev = plt.ce(name, opts);
447
+ elm.dispatchEvent(ev);
448
+ return ev;
449
+ };
450
+ const attachToAncestor = (hostRef, ancestorComponent) => {
451
+ if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
452
+ ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
453
+ }
454
+ };
455
+ const scheduleUpdate = (hostRef, isInitialLoad) => {
456
+ {
457
+ hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
458
+ }
459
+ if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
460
+ hostRef.$flags$ |= 512 /* needsRerender */;
461
+ return;
462
+ }
463
+ attachToAncestor(hostRef, hostRef.$ancestorComponent$);
464
+ // there is no ancestor component or the ancestor component
465
+ // has already fired off its lifecycle update then
466
+ // fire off the initial update
467
+ const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
468
+ return writeTask(dispatch) ;
469
+ };
470
+ const dispatchHooks = (hostRef, isInitialLoad) => {
471
+ const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
472
+ const instance = hostRef.$lazyInstance$ ;
473
+ let promise;
474
+ endSchedule();
475
+ return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
476
+ };
477
+ const updateComponent = async (hostRef, instance, isInitialLoad) => {
478
+ // updateComponent
479
+ const elm = hostRef.$hostElement$;
480
+ const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
481
+ const rc = elm['s-rc'];
482
+ if (isInitialLoad) {
483
+ // DOM WRITE!
484
+ attachStyles(hostRef);
485
+ }
486
+ const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
487
+ {
488
+ callRender(hostRef, instance);
489
+ }
490
+ if (rc) {
491
+ // ok, so turns out there are some child host elements
492
+ // waiting on this parent element to load
493
+ // let's fire off all update callbacks waiting
494
+ rc.map((cb) => cb());
495
+ elm['s-rc'] = undefined;
496
+ }
497
+ endRender();
498
+ endUpdate();
499
+ {
500
+ const childrenPromises = elm['s-p'];
501
+ const postUpdate = () => postUpdateComponent(hostRef);
502
+ if (childrenPromises.length === 0) {
503
+ postUpdate();
504
+ }
505
+ else {
506
+ Promise.all(childrenPromises).then(postUpdate);
507
+ hostRef.$flags$ |= 4 /* isWaitingForChildren */;
508
+ childrenPromises.length = 0;
509
+ }
510
+ }
511
+ };
512
+ const callRender = (hostRef, instance, elm) => {
513
+ try {
514
+ instance = instance.render() ;
515
+ {
516
+ hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
517
+ }
518
+ {
519
+ hostRef.$flags$ |= 2 /* hasRendered */;
520
+ }
521
+ {
522
+ {
523
+ // looks like we've got child nodes to render into this host element
524
+ // or we need to update the css class/attrs on the host element
525
+ // DOM WRITE!
526
+ {
527
+ renderVdom(hostRef, instance);
528
+ }
529
+ }
530
+ }
531
+ }
532
+ catch (e) {
533
+ consoleError(e, hostRef.$hostElement$);
534
+ }
535
+ return null;
536
+ };
537
+ const postUpdateComponent = (hostRef) => {
538
+ const tagName = hostRef.$cmpMeta$.$tagName$;
539
+ const elm = hostRef.$hostElement$;
540
+ const endPostUpdate = createTime('postUpdate', tagName);
541
+ const ancestorComponent = hostRef.$ancestorComponent$;
542
+ if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
543
+ hostRef.$flags$ |= 64 /* hasLoadedComponent */;
544
+ {
545
+ // DOM WRITE!
546
+ addHydratedFlag(elm);
547
+ }
548
+ endPostUpdate();
549
+ {
550
+ hostRef.$onReadyResolve$(elm);
551
+ if (!ancestorComponent) {
552
+ appDidLoad();
553
+ }
554
+ }
555
+ }
556
+ else {
557
+ endPostUpdate();
558
+ }
559
+ // load events fire from bottom to top
560
+ // the deepest elements load first then bubbles up
561
+ {
562
+ if (hostRef.$onRenderResolve$) {
563
+ hostRef.$onRenderResolve$();
564
+ hostRef.$onRenderResolve$ = undefined;
565
+ }
566
+ if (hostRef.$flags$ & 512 /* needsRerender */) {
567
+ nextTick(() => scheduleUpdate(hostRef, false));
568
+ }
569
+ hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
570
+ }
571
+ // ( •_•)
572
+ // ( •_•)>⌐■-■
573
+ // (⌐■_■)
574
+ };
575
+ const appDidLoad = (who) => {
576
+ // on appload
577
+ // we have finish the first big initial render
578
+ {
579
+ addHydratedFlag(doc.documentElement);
580
+ }
581
+ nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
582
+ };
583
+ const then = (promise, thenFn) => {
584
+ return promise && promise.then ? promise.then(thenFn) : thenFn();
585
+ };
586
+ const addHydratedFlag = (elm) => elm.classList.add('hydrated')
587
+ ;
588
+ /**
589
+ * Parse a new property value for a given property type.
590
+ *
591
+ * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
592
+ * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
593
+ * 1. `any`, the type given to `propValue` in the function signature
594
+ * 2. the type stored from `propType`.
595
+ *
596
+ * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
597
+ *
598
+ * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
599
+ * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
600
+ * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
601
+ * ```tsx
602
+ * <my-cmp prop-val={0}></my-cmp>
603
+ * ```
604
+ *
605
+ * HTML prop values on the other hand, will always a string
606
+ *
607
+ * @param propValue the new value to coerce to some type
608
+ * @param propType the type of the prop, expressed as a binary number
609
+ * @returns the parsed/coerced value
610
+ */
611
+ const parsePropertyValue = (propValue, propType) => {
612
+ // ensure this value is of the correct prop type
613
+ if (propValue != null && !isComplexType(propValue)) {
614
+ if (propType & 1 /* String */) {
615
+ // could have been passed as a number or boolean
616
+ // but we still want it as a string
617
+ return String(propValue);
618
+ }
619
+ // redundant return here for better minification
620
+ return propValue;
621
+ }
622
+ // not sure exactly what type we want
623
+ // so no need to change to a different type
624
+ return propValue;
625
+ };
626
+ const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
627
+ const setValue = (ref, propName, newVal, cmpMeta) => {
628
+ // check our new property value against our internal value
629
+ const hostRef = getHostRef(ref);
630
+ const oldVal = hostRef.$instanceValues$.get(propName);
631
+ const flags = hostRef.$flags$;
632
+ const instance = hostRef.$lazyInstance$ ;
633
+ newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
634
+ // explicitly check for NaN on both sides, as `NaN === NaN` is always false
635
+ const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
636
+ const didValueChange = newVal !== oldVal && !areBothNaN;
637
+ if ((!(flags & 8 /* isConstructingInstance */) || oldVal === undefined) && didValueChange) {
638
+ // gadzooks! the property's value has changed!!
639
+ // set our new value!
640
+ hostRef.$instanceValues$.set(propName, newVal);
641
+ if (instance) {
642
+ if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
643
+ // looks like this value actually changed, so we've got work to do!
644
+ // but only if we've already rendered, otherwise just chill out
645
+ // queue that we need to do an update, but don't worry about queuing
646
+ // up millions cuz this function ensures it only runs once
647
+ scheduleUpdate(hostRef, false);
648
+ }
649
+ }
650
+ }
651
+ };
652
+ const proxyComponent = (Cstr, cmpMeta, flags) => {
653
+ if (cmpMeta.$members$) {
654
+ // It's better to have a const than two Object.entries()
655
+ const members = Object.entries(cmpMeta.$members$);
656
+ const prototype = Cstr.prototype;
657
+ members.map(([memberName, [memberFlags]]) => {
658
+ if ((memberFlags & 31 /* Prop */ ||
659
+ ((flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
660
+ // proxyComponent - prop
661
+ Object.defineProperty(prototype, memberName, {
662
+ get() {
663
+ // proxyComponent, get value
664
+ return getValue(this, memberName);
665
+ },
666
+ set(newValue) {
667
+ // proxyComponent, set value
668
+ setValue(this, memberName, newValue, cmpMeta);
669
+ },
670
+ configurable: true,
671
+ enumerable: true,
672
+ });
673
+ }
674
+ });
675
+ if ((flags & 1 /* isElementConstructor */)) {
676
+ const attrNameToPropName = new Map();
677
+ prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
678
+ plt.jmp(() => {
679
+ const propName = attrNameToPropName.get(attrName);
680
+ // In a web component lifecycle the attributeChangedCallback runs prior to connectedCallback
681
+ // in the case where an attribute was set inline.
682
+ // ```html
683
+ // <my-component some-attribute="some-value"></my-component>
684
+ // ```
685
+ //
686
+ // There is an edge case where a developer sets the attribute inline on a custom element and then
687
+ // programmatically changes it before it has been upgraded as shown below:
688
+ //
689
+ // ```html
690
+ // <!-- this component has _not_ been upgraded yet -->
691
+ // <my-component id="test" some-attribute="some-value"></my-component>
692
+ // <script>
693
+ // // grab non-upgraded component
694
+ // el = document.querySelector("#test");
695
+ // el.someAttribute = "another-value";
696
+ // // upgrade component
697
+ // customElements.define('my-component', MyComponent);
698
+ // </script>
699
+ // ```
700
+ // In this case if we do not unshadow here and use the value of the shadowing property, attributeChangedCallback
701
+ // will be called with `newValue = "some-value"` and will set the shadowed property (this.someAttribute = "another-value")
702
+ // to the value that was set inline i.e. "some-value" from above example. When
703
+ // the connectedCallback attempts to unshadow it will use "some-value" as the initial value rather than "another-value"
704
+ //
705
+ // The case where the attribute was NOT set inline but was not set programmatically shall be handled/unshadowed
706
+ // by connectedCallback as this attributeChangedCallback will not fire.
707
+ //
708
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
709
+ //
710
+ // TODO(STENCIL-16) we should think about whether or not we actually want to be reflecting the attributes to
711
+ // properties here given that this goes against best practices outlined here
712
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#avoid-reentrancy
713
+ if (this.hasOwnProperty(propName)) {
714
+ newValue = this[propName];
715
+ delete this[propName];
716
+ }
717
+ else if (prototype.hasOwnProperty(propName) &&
718
+ typeof this[propName] === 'number' &&
719
+ this[propName] == newValue) {
720
+ // if the propName exists on the prototype of `Cstr`, this update may be a result of Stencil using native
721
+ // APIs to reflect props as attributes. Calls to `setAttribute(someElement, propName)` will result in
722
+ // `propName` to be converted to a `DOMString`, which may not be what we want for other primitive props.
723
+ return;
724
+ }
725
+ this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
726
+ });
727
+ };
728
+ // create an array of attributes to observe
729
+ // and also create a map of html attribute name to js property name
730
+ Cstr.observedAttributes = members
731
+ .filter(([_, m]) => m[0] & 15 /* HasAttribute */) // filter to only keep props that should match attributes
732
+ .map(([propName, m]) => {
733
+ const attrName = m[1] || propName;
734
+ attrNameToPropName.set(attrName, propName);
735
+ return attrName;
736
+ });
737
+ }
738
+ }
739
+ return Cstr;
740
+ };
741
+ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
742
+ // initializeComponent
743
+ if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
744
+ {
745
+ // we haven't initialized this element yet
746
+ hostRef.$flags$ |= 32 /* hasInitializedComponent */;
747
+ // lazy loaded components
748
+ // request the component's implementation to be
749
+ // wired up with the host element
750
+ Cstr = loadModule(cmpMeta);
751
+ if (Cstr.then) {
752
+ // Await creates a micro-task avoid if possible
753
+ const endLoad = uniqueTime();
754
+ Cstr = await Cstr;
755
+ endLoad();
756
+ }
757
+ if (!Cstr.isProxied) {
758
+ proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
759
+ Cstr.isProxied = true;
760
+ }
761
+ const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
762
+ // ok, time to construct the instance
763
+ // but let's keep track of when we start and stop
764
+ // so that the getters/setters don't incorrectly step on data
765
+ {
766
+ hostRef.$flags$ |= 8 /* isConstructingInstance */;
767
+ }
768
+ // construct the lazy-loaded component implementation
769
+ // passing the hostRef is very important during
770
+ // construction in order to directly wire together the
771
+ // host element and the lazy-loaded instance
772
+ try {
773
+ new Cstr(hostRef);
774
+ }
775
+ catch (e) {
776
+ consoleError(e);
777
+ }
778
+ {
779
+ hostRef.$flags$ &= ~8 /* isConstructingInstance */;
780
+ }
781
+ endNewInstance();
782
+ }
783
+ if (Cstr.style) {
784
+ // this component has styles but we haven't registered them yet
785
+ let style = Cstr.style;
786
+ const scopeId = getScopeId(cmpMeta);
787
+ if (!styles.has(scopeId)) {
788
+ const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
789
+ registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
790
+ endRegisterStyles();
791
+ }
792
+ }
793
+ }
794
+ // we've successfully created a lazy instance
795
+ const ancestorComponent = hostRef.$ancestorComponent$;
796
+ const schedule = () => scheduleUpdate(hostRef, true);
797
+ if (ancestorComponent && ancestorComponent['s-rc']) {
798
+ // this is the initial load and this component it has an ancestor component
799
+ // but the ancestor component has NOT fired its will update lifecycle yet
800
+ // so let's just cool our jets and wait for the ancestor to continue first
801
+ // this will get fired off when the ancestor component
802
+ // finally gets around to rendering its lazy self
803
+ // fire off the initial update
804
+ ancestorComponent['s-rc'].push(schedule);
805
+ }
806
+ else {
807
+ schedule();
808
+ }
809
+ };
810
+ const connectedCallback = (elm) => {
811
+ if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
812
+ const hostRef = getHostRef(elm);
813
+ const cmpMeta = hostRef.$cmpMeta$;
814
+ const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
815
+ if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
816
+ // first time this component has connected
817
+ hostRef.$flags$ |= 1 /* hasConnected */;
818
+ {
819
+ // find the first ancestor component (if there is one) and register
820
+ // this component as one of the actively loading child components for its ancestor
821
+ let ancestorComponent = elm;
822
+ while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
823
+ // climb up the ancestors looking for the first
824
+ // component that hasn't finished its lifecycle update yet
825
+ if (ancestorComponent['s-p']) {
826
+ // we found this components first ancestor component
827
+ // keep a reference to this component's ancestor component
828
+ attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
829
+ break;
830
+ }
831
+ }
832
+ }
833
+ // Lazy properties
834
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
835
+ if (cmpMeta.$members$) {
836
+ Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
837
+ if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
838
+ const value = elm[memberName];
839
+ delete elm[memberName];
840
+ elm[memberName] = value;
841
+ }
842
+ });
843
+ }
844
+ {
845
+ initializeComponent(elm, hostRef, cmpMeta);
846
+ }
847
+ }
848
+ endConnected();
849
+ }
850
+ };
851
+ const disconnectedCallback = (elm) => {
852
+ if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
853
+ getHostRef(elm);
854
+ }
855
+ };
856
+ const bootstrapLazy = (lazyBundles, options = {}) => {
857
+ const endBootstrap = createTime();
858
+ const cmpTags = [];
859
+ const exclude = options.exclude || [];
860
+ const customElements = win.customElements;
861
+ const head = doc.head;
862
+ const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
863
+ const visibilityStyle = /*@__PURE__*/ doc.createElement('style');
864
+ const deferredConnectedCallbacks = [];
865
+ let appLoadFallback;
866
+ let isBootstrapping = true;
867
+ Object.assign(plt, options);
868
+ plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
869
+ lazyBundles.map((lazyBundle) => {
870
+ lazyBundle[1].map((compactMeta) => {
871
+ const cmpMeta = {
872
+ $flags$: compactMeta[0],
873
+ $tagName$: compactMeta[1],
874
+ $members$: compactMeta[2],
875
+ $listeners$: compactMeta[3],
876
+ };
877
+ {
878
+ cmpMeta.$members$ = compactMeta[2];
879
+ }
880
+ const tagName = cmpMeta.$tagName$;
881
+ const HostElement = class extends HTMLElement {
882
+ // StencilLazyHost
883
+ constructor(self) {
884
+ // @ts-ignore
885
+ super(self);
886
+ self = this;
887
+ registerHost(self, cmpMeta);
888
+ if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
889
+ // this component is using shadow dom
890
+ // and this browser supports shadow dom
891
+ // add the read-only property "shadowRoot" to the host element
892
+ // adding the shadow root build conditionals to minimize runtime
893
+ {
894
+ {
895
+ self.attachShadow({ mode: 'open' });
896
+ }
897
+ }
898
+ }
899
+ }
900
+ connectedCallback() {
901
+ if (appLoadFallback) {
902
+ clearTimeout(appLoadFallback);
903
+ appLoadFallback = null;
904
+ }
905
+ if (isBootstrapping) {
906
+ // connectedCallback will be processed once all components have been registered
907
+ deferredConnectedCallbacks.push(this);
908
+ }
909
+ else {
910
+ plt.jmp(() => connectedCallback(this));
911
+ }
912
+ }
913
+ disconnectedCallback() {
914
+ plt.jmp(() => disconnectedCallback(this));
915
+ }
916
+ componentOnReady() {
917
+ return getHostRef(this).$onReadyPromise$;
918
+ }
919
+ };
920
+ cmpMeta.$lazyBundleId$ = lazyBundle[0];
921
+ if (!exclude.includes(tagName) && !customElements.get(tagName)) {
922
+ cmpTags.push(tagName);
923
+ customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
924
+ }
925
+ });
926
+ });
927
+ {
928
+ visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
929
+ visibilityStyle.setAttribute('data-styles', '');
930
+ head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
931
+ }
932
+ // Process deferred connectedCallbacks now all components have been registered
933
+ isBootstrapping = false;
934
+ if (deferredConnectedCallbacks.length) {
935
+ deferredConnectedCallbacks.map((host) => host.connectedCallback());
936
+ }
937
+ else {
938
+ {
939
+ plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30)));
940
+ }
941
+ }
942
+ // Fallback appLoad event
943
+ endBootstrap();
944
+ };
945
+ const hostRefs = new WeakMap();
946
+ const getHostRef = (ref) => hostRefs.get(ref);
947
+ const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
948
+ const registerHost = (elm, cmpMeta) => {
949
+ const hostRef = {
950
+ $flags$: 0,
951
+ $hostElement$: elm,
952
+ $cmpMeta$: cmpMeta,
953
+ $instanceValues$: new Map(),
954
+ };
955
+ {
956
+ hostRef.$onReadyPromise$ = new Promise((r) => (hostRef.$onReadyResolve$ = r));
957
+ elm['s-p'] = [];
958
+ elm['s-rc'] = [];
959
+ }
960
+ return hostRefs.set(elm, hostRef);
961
+ };
962
+ const consoleError = (e, el) => (0, console.error)(e, el);
963
+ const cmpModules = /*@__PURE__*/ new Map();
964
+ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
965
+ // loadModuleImport
966
+ const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
967
+ const bundleId = cmpMeta.$lazyBundleId$;
968
+ const module = cmpModules.get(bundleId) ;
969
+ if (module) {
970
+ return module[exportName];
971
+ }
972
+ /*!__STENCIL_STATIC_IMPORT_SWITCH__*/
973
+ return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
974
+ /* @vite-ignore */
975
+ /* webpackInclude: /\.entry\.js$/ */
976
+ /* webpackExclude: /\.system\.entry\.js$/ */
977
+ /* webpackMode: "lazy" */
978
+ `./${bundleId}.entry.js${''}`)); }).then((importedModule) => {
979
+ {
980
+ cmpModules.set(bundleId, importedModule);
981
+ }
982
+ return importedModule[exportName];
983
+ }, consoleError);
984
+ };
985
+ const styles = new Map();
986
+ const queueDomReads = [];
987
+ const queueDomWrites = [];
988
+ const queueTask = (queue, write) => (cb) => {
989
+ queue.push(cb);
990
+ if (!queuePending) {
991
+ queuePending = true;
992
+ if (write && plt.$flags$ & 4 /* queueSync */) {
993
+ nextTick(flush);
994
+ }
995
+ else {
996
+ plt.raf(flush);
997
+ }
998
+ }
999
+ };
1000
+ const consume = (queue) => {
1001
+ for (let i = 0; i < queue.length; i++) {
1002
+ try {
1003
+ queue[i](performance.now());
1004
+ }
1005
+ catch (e) {
1006
+ consoleError(e);
1007
+ }
1008
+ }
1009
+ queue.length = 0;
1010
+ };
1011
+ const flush = () => {
1012
+ // always force a bunch of medium callbacks to run, but still have
1013
+ // a throttle on how many can run in a certain time
1014
+ // DOM READS!!!
1015
+ consume(queueDomReads);
1016
+ // DOM WRITES!!!
1017
+ {
1018
+ consume(queueDomWrites);
1019
+ if ((queuePending = queueDomReads.length > 0)) {
1020
+ // still more to do yet, but we've run out of time
1021
+ // let's let this thing cool off and try again in the next tick
1022
+ plt.raf(flush);
1023
+ }
1024
+ }
1025
+ };
1026
+ const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
1027
+ const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
1028
+
1029
+ exports.bootstrapLazy = bootstrapLazy;
1030
+ exports.h = h;
1031
+ exports.promiseResolve = promiseResolve;
1032
+ exports.registerInstance = registerInstance;