@sankhyalabs/sankhyablocks 1.3.31-beta.13 → 1.3.31-beta.16
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.
- package/dist/cjs/{SnkMessageBuilder-bb55d4c4.js → SnkMessageBuilder-79cf15c5.js} +1 -0
- package/dist/cjs/{index-c6671817.js → index-5575fe3d.js} +434 -231
- package/dist/cjs/loader.cjs.js +3 -3
- package/dist/cjs/sankhyablocks.cjs.js +3 -3
- package/dist/cjs/snk-application.cjs.entry.js +60 -2
- package/dist/cjs/snk-crud.cjs.entry.js +1 -1
- package/dist/cjs/snk-data-unit.cjs.entry.js +3 -3
- package/dist/cjs/snk-form_2.cjs.entry.js +2 -2
- package/dist/cjs/snk-pesquisa.cjs.entry.js +1 -1
- package/dist/cjs/snk-taskbar.cjs.entry.js +2 -2
- package/dist/cjs/{taskbar-elements-2888ceb6.js → taskbar-elements-2ae0d005.js} +1 -1
- package/dist/cjs/teste-pesquisa.cjs.entry.js +1 -1
- package/dist/collection/collection-manifest.json +2 -2
- package/dist/collection/components/snk-application/snk-application.js +703 -647
- package/dist/collection/components/snk-crud/snk-crud.js +75 -73
- package/dist/collection/components/snk-data-unit/snk-data-unit.js +262 -250
- package/dist/collection/components/snk-form/snk-form.js +111 -111
- package/dist/collection/components/snk-grid/snk-grid.js +93 -92
- package/dist/collection/components/snk-pesquisa/snk-pesquisa.js +80 -79
- package/dist/collection/components/snk-taskbar/elements/taskbar-elements.js +1 -2
- package/dist/collection/components/snk-taskbar/snk-taskbar.js +128 -116
- package/dist/collection/components/teste-pesquisa/teste-pesquisa.js +12 -9
- package/dist/collection/lib/http/data-fetcher/fetchers/totals-fetcher.js +47 -0
- package/dist/collection/lib/message/resources/snk-data-unit.msg.js +1 -0
- package/dist/components/SnkMessageBuilder.js +1 -0
- package/dist/components/index.d.ts +8 -5
- package/dist/components/index.js +8 -0
- package/dist/components/snk-application2.js +59 -0
- package/dist/components/snk-data-unit.js +1 -1
- package/dist/esm/{SnkMessageBuilder-17d91b88.js → SnkMessageBuilder-3cdde541.js} +1 -0
- package/dist/esm/{index-6a83ac96.js → index-cf91f542.js} +434 -231
- package/dist/esm/loader.js +3 -3
- package/dist/esm/polyfills/css-shim.js +1 -1
- package/dist/esm/sankhyablocks.js +3 -3
- package/dist/esm/snk-application.entry.js +60 -2
- package/dist/esm/snk-crud.entry.js +1 -1
- package/dist/esm/snk-data-unit.entry.js +3 -3
- package/dist/esm/snk-form_2.entry.js +2 -2
- package/dist/esm/snk-pesquisa.entry.js +1 -1
- package/dist/esm/snk-taskbar.entry.js +2 -2
- package/dist/esm/{taskbar-elements-5ea74223.js → taskbar-elements-bcccc0ff.js} +1 -1
- package/dist/esm/teste-pesquisa.entry.js +1 -1
- package/dist/sankhyablocks/{p-b7e029cd.entry.js → p-1ba29824.entry.js} +8 -3
- package/dist/sankhyablocks/{p-4c7b32d6.entry.js → p-2266555e.entry.js} +1 -1
- package/dist/sankhyablocks/p-23c4c94f.js +2 -0
- package/dist/sankhyablocks/{p-b559117b.js → p-2454be94.js} +1 -1
- package/dist/sankhyablocks/p-49743bc5.js +1 -0
- package/dist/sankhyablocks/{p-ce2d1214.entry.js → p-4fa389bd.entry.js} +1 -1
- package/dist/sankhyablocks/{p-56a32417.entry.js → p-5327ba05.entry.js} +1 -1
- package/dist/sankhyablocks/{p-d25803a1.entry.js → p-7a922fb4.entry.js} +1 -1
- package/dist/sankhyablocks/p-92d6f826.entry.js +1 -0
- package/dist/sankhyablocks/{p-d25637c9.entry.js → p-bdeef7f2.entry.js} +1 -1
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-application/snk-application.d.ts +8 -0
- package/dist/types/components.d.ts +5 -1
- package/dist/types/lib/http/data-fetcher/fetchers/totals-fetcher.d.ts +8 -0
- package/dist/types/stencil-public-runtime.d.ts +15 -4
- package/loader/package.json +1 -0
- package/package.json +5 -5
- package/dist/sankhyablocks/p-ab694dbc.js +0 -1
- package/dist/sankhyablocks/p-cd1dc099.js +0 -2
- package/dist/sankhyablocks/p-edf81d2c.entry.js +0 -1
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
const NAMESPACE = 'sankhyablocks';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Virtual DOM patching algorithm based on Snabbdom by
|
|
5
|
+
* Simon Friis Vindum (@paldepind)
|
|
6
|
+
* Licensed under the MIT License
|
|
7
|
+
* https://github.com/snabbdom/snabbdom/blob/master/LICENSE
|
|
8
|
+
*
|
|
9
|
+
* Modified for Stencil's renderer and slot projection
|
|
10
|
+
*/
|
|
3
11
|
let scopeId;
|
|
4
12
|
let contentRef;
|
|
5
13
|
let hostTagName;
|
|
@@ -8,28 +16,6 @@ let checkSlotFallbackVisibility = false;
|
|
|
8
16
|
let checkSlotRelocate = false;
|
|
9
17
|
let isSvgMode = false;
|
|
10
18
|
let queuePending = false;
|
|
11
|
-
const win = typeof window !== 'undefined' ? window : {};
|
|
12
|
-
const doc = win.document || { head: {} };
|
|
13
|
-
const plt = {
|
|
14
|
-
$flags$: 0,
|
|
15
|
-
$resourcesUrl$: '',
|
|
16
|
-
jmp: (h) => h(),
|
|
17
|
-
raf: (h) => requestAnimationFrame(h),
|
|
18
|
-
ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
|
|
19
|
-
rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
|
|
20
|
-
ce: (eventName, opts) => new CustomEvent(eventName, opts),
|
|
21
|
-
};
|
|
22
|
-
const promiseResolve = (v) => Promise.resolve(v);
|
|
23
|
-
const supportsConstructibleStylesheets = /*@__PURE__*/ (() => {
|
|
24
|
-
try {
|
|
25
|
-
new CSSStyleSheet();
|
|
26
|
-
return typeof new CSSStyleSheet().replace === 'function';
|
|
27
|
-
}
|
|
28
|
-
catch (e) { }
|
|
29
|
-
return false;
|
|
30
|
-
})()
|
|
31
|
-
;
|
|
32
|
-
const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
|
|
33
19
|
const createTime = (fnName, tagName = '') => {
|
|
34
20
|
{
|
|
35
21
|
return () => {
|
|
@@ -44,74 +30,7 @@ const uniqueTime = (key, measureText) => {
|
|
|
44
30
|
};
|
|
45
31
|
}
|
|
46
32
|
};
|
|
47
|
-
const
|
|
48
|
-
const registerStyle = (scopeId, cssText, allowCS) => {
|
|
49
|
-
let style = styles.get(scopeId);
|
|
50
|
-
if (supportsConstructibleStylesheets && allowCS) {
|
|
51
|
-
style = (style || new CSSStyleSheet());
|
|
52
|
-
style.replace(cssText);
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
style = cssText;
|
|
56
|
-
}
|
|
57
|
-
styles.set(scopeId, style);
|
|
58
|
-
};
|
|
59
|
-
const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
|
|
60
|
-
let scopeId = getScopeId(cmpMeta);
|
|
61
|
-
const style = styles.get(scopeId);
|
|
62
|
-
// if an element is NOT connected then getRootNode() will return the wrong root node
|
|
63
|
-
// so the fallback is to always use the document for the root node in those cases
|
|
64
|
-
styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
|
|
65
|
-
if (style) {
|
|
66
|
-
if (typeof style === 'string') {
|
|
67
|
-
styleContainerNode = styleContainerNode.head || styleContainerNode;
|
|
68
|
-
let appliedStyles = rootAppliedStyles.get(styleContainerNode);
|
|
69
|
-
let styleElm;
|
|
70
|
-
if (!appliedStyles) {
|
|
71
|
-
rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
|
|
72
|
-
}
|
|
73
|
-
if (!appliedStyles.has(scopeId)) {
|
|
74
|
-
{
|
|
75
|
-
{
|
|
76
|
-
styleElm = doc.createElement('style');
|
|
77
|
-
styleElm.innerHTML = style;
|
|
78
|
-
}
|
|
79
|
-
styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
|
|
80
|
-
}
|
|
81
|
-
if (appliedStyles) {
|
|
82
|
-
appliedStyles.add(scopeId);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
|
|
87
|
-
styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
return scopeId;
|
|
91
|
-
};
|
|
92
|
-
const attachStyles = (hostRef) => {
|
|
93
|
-
const cmpMeta = hostRef.$cmpMeta$;
|
|
94
|
-
const elm = hostRef.$hostElement$;
|
|
95
|
-
const flags = cmpMeta.$flags$;
|
|
96
|
-
const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
|
|
97
|
-
const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
|
|
98
|
-
if (flags & 10 /* needsScopedEncapsulation */) {
|
|
99
|
-
// only required when we're NOT using native shadow dom (slot)
|
|
100
|
-
// or this browser doesn't support native shadow dom
|
|
101
|
-
// and this host element was NOT created with SSR
|
|
102
|
-
// let's pick out the inner content for slot projection
|
|
103
|
-
// create a node to represent where the original
|
|
104
|
-
// content was first placed, which is useful later on
|
|
105
|
-
// DOM WRITE!!
|
|
106
|
-
elm['s-sc'] = scopeId;
|
|
107
|
-
elm.classList.add(scopeId + '-h');
|
|
108
|
-
if (flags & 2 /* scopedCssEncapsulation */) {
|
|
109
|
-
elm.classList.add(scopeId + '-s');
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
endAttachStyles();
|
|
113
|
-
};
|
|
114
|
-
const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
|
|
33
|
+
const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
|
|
115
34
|
/**
|
|
116
35
|
* Default style mode id
|
|
117
36
|
*/
|
|
@@ -221,6 +140,152 @@ const newVNode = (tag, text) => {
|
|
|
221
140
|
};
|
|
222
141
|
const Host = {};
|
|
223
142
|
const isHost = (node) => node && node.$tag$ === Host;
|
|
143
|
+
/**
|
|
144
|
+
* Parse a new property value for a given property type.
|
|
145
|
+
*
|
|
146
|
+
* While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
|
|
147
|
+
* it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
|
|
148
|
+
* 1. `any`, the type given to `propValue` in the function signature
|
|
149
|
+
* 2. the type stored from `propType`.
|
|
150
|
+
*
|
|
151
|
+
* This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
|
|
152
|
+
*
|
|
153
|
+
* Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
|
|
154
|
+
* a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
|
|
155
|
+
* based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
|
|
156
|
+
* ```tsx
|
|
157
|
+
* <my-cmp prop-val={0}></my-cmp>
|
|
158
|
+
* ```
|
|
159
|
+
*
|
|
160
|
+
* HTML prop values on the other hand, will always a string
|
|
161
|
+
*
|
|
162
|
+
* @param propValue the new value to coerce to some type
|
|
163
|
+
* @param propType the type of the prop, expressed as a binary number
|
|
164
|
+
* @returns the parsed/coerced value
|
|
165
|
+
*/
|
|
166
|
+
const parsePropertyValue = (propValue, propType) => {
|
|
167
|
+
// ensure this value is of the correct prop type
|
|
168
|
+
if (propValue != null && !isComplexType(propValue)) {
|
|
169
|
+
if (propType & 4 /* MEMBER_FLAGS.Boolean */) {
|
|
170
|
+
// per the HTML spec, any string value means it is a boolean true value
|
|
171
|
+
// but we'll cheat here and say that the string "false" is the boolean false
|
|
172
|
+
return propValue === 'false' ? false : propValue === '' || !!propValue;
|
|
173
|
+
}
|
|
174
|
+
if (propType & 2 /* MEMBER_FLAGS.Number */) {
|
|
175
|
+
// force it to be a number
|
|
176
|
+
return parseFloat(propValue);
|
|
177
|
+
}
|
|
178
|
+
if (propType & 1 /* MEMBER_FLAGS.String */) {
|
|
179
|
+
// could have been passed as a number or boolean
|
|
180
|
+
// but we still want it as a string
|
|
181
|
+
return String(propValue);
|
|
182
|
+
}
|
|
183
|
+
// redundant return here for better minification
|
|
184
|
+
return propValue;
|
|
185
|
+
}
|
|
186
|
+
// not sure exactly what type we want
|
|
187
|
+
// so no need to change to a different type
|
|
188
|
+
return propValue;
|
|
189
|
+
};
|
|
190
|
+
const getElement = (ref) => (getHostRef(ref).$hostElement$ );
|
|
191
|
+
const createEvent = (ref, name, flags) => {
|
|
192
|
+
const elm = getElement(ref);
|
|
193
|
+
return {
|
|
194
|
+
emit: (detail) => {
|
|
195
|
+
return emitEvent(elm, name, {
|
|
196
|
+
bubbles: !!(flags & 4 /* EVENT_FLAGS.Bubbles */),
|
|
197
|
+
composed: !!(flags & 2 /* EVENT_FLAGS.Composed */),
|
|
198
|
+
cancelable: !!(flags & 1 /* EVENT_FLAGS.Cancellable */),
|
|
199
|
+
detail,
|
|
200
|
+
});
|
|
201
|
+
},
|
|
202
|
+
};
|
|
203
|
+
};
|
|
204
|
+
/**
|
|
205
|
+
* Helper function to create & dispatch a custom Event on a provided target
|
|
206
|
+
* @param elm the target of the Event
|
|
207
|
+
* @param name the name to give the custom Event
|
|
208
|
+
* @param opts options for configuring a custom Event
|
|
209
|
+
* @returns the custom Event
|
|
210
|
+
*/
|
|
211
|
+
const emitEvent = (elm, name, opts) => {
|
|
212
|
+
const ev = plt.ce(name, opts);
|
|
213
|
+
elm.dispatchEvent(ev);
|
|
214
|
+
return ev;
|
|
215
|
+
};
|
|
216
|
+
const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
|
|
217
|
+
const registerStyle = (scopeId, cssText, allowCS) => {
|
|
218
|
+
let style = styles.get(scopeId);
|
|
219
|
+
if (supportsConstructableStylesheets && allowCS) {
|
|
220
|
+
style = (style || new CSSStyleSheet());
|
|
221
|
+
if (typeof style === 'string') {
|
|
222
|
+
style = cssText;
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
style.replaceSync(cssText);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
style = cssText;
|
|
230
|
+
}
|
|
231
|
+
styles.set(scopeId, style);
|
|
232
|
+
};
|
|
233
|
+
const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
|
|
234
|
+
let scopeId = getScopeId(cmpMeta);
|
|
235
|
+
const style = styles.get(scopeId);
|
|
236
|
+
// if an element is NOT connected then getRootNode() will return the wrong root node
|
|
237
|
+
// so the fallback is to always use the document for the root node in those cases
|
|
238
|
+
styleContainerNode = styleContainerNode.nodeType === 11 /* NODE_TYPE.DocumentFragment */ ? styleContainerNode : doc;
|
|
239
|
+
if (style) {
|
|
240
|
+
if (typeof style === 'string') {
|
|
241
|
+
styleContainerNode = styleContainerNode.head || styleContainerNode;
|
|
242
|
+
let appliedStyles = rootAppliedStyles.get(styleContainerNode);
|
|
243
|
+
let styleElm;
|
|
244
|
+
if (!appliedStyles) {
|
|
245
|
+
rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
|
|
246
|
+
}
|
|
247
|
+
if (!appliedStyles.has(scopeId)) {
|
|
248
|
+
{
|
|
249
|
+
{
|
|
250
|
+
styleElm = doc.createElement('style');
|
|
251
|
+
styleElm.innerHTML = style;
|
|
252
|
+
}
|
|
253
|
+
styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
|
|
254
|
+
}
|
|
255
|
+
if (appliedStyles) {
|
|
256
|
+
appliedStyles.add(scopeId);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
|
|
261
|
+
styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
return scopeId;
|
|
265
|
+
};
|
|
266
|
+
const attachStyles = (hostRef) => {
|
|
267
|
+
const cmpMeta = hostRef.$cmpMeta$;
|
|
268
|
+
const elm = hostRef.$hostElement$;
|
|
269
|
+
const flags = cmpMeta.$flags$;
|
|
270
|
+
const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
|
|
271
|
+
const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
|
|
272
|
+
if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
|
|
273
|
+
// only required when we're NOT using native shadow dom (slot)
|
|
274
|
+
// or this browser doesn't support native shadow dom
|
|
275
|
+
// and this host element was NOT created with SSR
|
|
276
|
+
// let's pick out the inner content for slot projection
|
|
277
|
+
// create a node to represent where the original
|
|
278
|
+
// content was first placed, which is useful later on
|
|
279
|
+
// DOM WRITE!!
|
|
280
|
+
elm['s-sc'] = scopeId;
|
|
281
|
+
elm.classList.add(scopeId + '-h');
|
|
282
|
+
if (flags & 2 /* CMP_FLAGS.scopedCssEncapsulation */) {
|
|
283
|
+
elm.classList.add(scopeId + '-s');
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
endAttachStyles();
|
|
287
|
+
};
|
|
288
|
+
const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
|
|
224
289
|
/**
|
|
225
290
|
* Production setAccessor() function based on Preact by
|
|
226
291
|
* Jason Miller (@developit)
|
|
@@ -315,7 +380,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
|
|
315
380
|
}
|
|
316
381
|
}
|
|
317
382
|
}
|
|
318
|
-
else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
|
|
383
|
+
else if ((!isProp || flags & 4 /* VNODE_FLAGS.isHost */ || isSvg) && !isComplex) {
|
|
319
384
|
newValue = newValue === true ? '' : newValue;
|
|
320
385
|
{
|
|
321
386
|
elm.setAttribute(memberName, newValue);
|
|
@@ -330,7 +395,7 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
|
|
|
330
395
|
// if the element passed in is a shadow root, which is a document fragment
|
|
331
396
|
// then we want to be adding attrs/props to the shadow root's "host" element
|
|
332
397
|
// if it's not a shadow root, then we add attrs/props to the same element
|
|
333
|
-
const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host
|
|
398
|
+
const elm = newVnode.$elm$.nodeType === 11 /* NODE_TYPE.DocumentFragment */ && newVnode.$elm$.host
|
|
334
399
|
? newVnode.$elm$.host
|
|
335
400
|
: newVnode.$elm$;
|
|
336
401
|
const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
|
|
@@ -348,6 +413,16 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
|
|
|
348
413
|
setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
|
|
349
414
|
}
|
|
350
415
|
};
|
|
416
|
+
/**
|
|
417
|
+
* Create a DOM Node corresponding to one of the children of a given VNode.
|
|
418
|
+
*
|
|
419
|
+
* @param oldParentVNode the parent VNode from the previous render
|
|
420
|
+
* @param newParentVNode the parent VNode from the current render
|
|
421
|
+
* @param childIndex the index of the VNode, in the _new_ parent node's
|
|
422
|
+
* children, for which we will create a new DOM node
|
|
423
|
+
* @param parentElm the parent DOM node which our new node will be a child of
|
|
424
|
+
* @returns the newly created node
|
|
425
|
+
*/
|
|
351
426
|
const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
352
427
|
// tslint:disable-next-line: prefer-const
|
|
353
428
|
const newVNode = newParentVNode.$children$[childIndex];
|
|
@@ -365,23 +440,23 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
365
440
|
}
|
|
366
441
|
newVNode.$flags$ |= newVNode.$children$
|
|
367
442
|
? // slot element has fallback content
|
|
368
|
-
2 /* isSlotFallback */
|
|
443
|
+
2 /* VNODE_FLAGS.isSlotFallback */
|
|
369
444
|
: // slot element does not have fallback content
|
|
370
|
-
1 /* isSlotReference */;
|
|
445
|
+
1 /* VNODE_FLAGS.isSlotReference */;
|
|
371
446
|
}
|
|
372
447
|
}
|
|
373
448
|
if (newVNode.$text$ !== null) {
|
|
374
449
|
// create text node
|
|
375
450
|
elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
|
|
376
451
|
}
|
|
377
|
-
else if (newVNode.$flags$ & 1 /* isSlotReference */) {
|
|
452
|
+
else if (newVNode.$flags$ & 1 /* VNODE_FLAGS.isSlotReference */) {
|
|
378
453
|
// create a slot reference node
|
|
379
454
|
elm = newVNode.$elm$ =
|
|
380
455
|
doc.createTextNode('');
|
|
381
456
|
}
|
|
382
457
|
else {
|
|
383
458
|
// create element
|
|
384
|
-
elm = newVNode.$elm$ = (doc.createElement(newVNode.$flags$ & 2 /* isSlotFallback */
|
|
459
|
+
elm = newVNode.$elm$ = (doc.createElement(newVNode.$flags$ & 2 /* VNODE_FLAGS.isSlotFallback */
|
|
385
460
|
? 'slot-fb'
|
|
386
461
|
: newVNode.$tag$));
|
|
387
462
|
// add css classes, attrs, props, listeners, etc.
|
|
@@ -407,7 +482,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
407
482
|
}
|
|
408
483
|
{
|
|
409
484
|
elm['s-hn'] = hostTagName;
|
|
410
|
-
if (newVNode.$flags$ & (2 /* isSlotFallback */ | 1 /* isSlotReference */)) {
|
|
485
|
+
if (newVNode.$flags$ & (2 /* VNODE_FLAGS.isSlotFallback */ | 1 /* VNODE_FLAGS.isSlotReference */)) {
|
|
411
486
|
// remember the content reference comment
|
|
412
487
|
elm['s-sr'] = true;
|
|
413
488
|
// remember the content reference comment
|
|
@@ -426,7 +501,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
426
501
|
return elm;
|
|
427
502
|
};
|
|
428
503
|
const putBackInOriginalLocation = (parentElm, recursive) => {
|
|
429
|
-
plt.$flags$ |= 1 /* isTmpDisconnected */;
|
|
504
|
+
plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
|
|
430
505
|
const oldSlotChildNodes = parentElm.childNodes;
|
|
431
506
|
for (let i = oldSlotChildNodes.length - 1; i >= 0; i--) {
|
|
432
507
|
const childNode = oldSlotChildNodes[i];
|
|
@@ -447,7 +522,7 @@ const putBackInOriginalLocation = (parentElm, recursive) => {
|
|
|
447
522
|
putBackInOriginalLocation(childNode, recursive);
|
|
448
523
|
}
|
|
449
524
|
}
|
|
450
|
-
plt.$flags$ &= ~1 /* isTmpDisconnected */;
|
|
525
|
+
plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
|
|
451
526
|
};
|
|
452
527
|
const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
|
|
453
528
|
let containerElm = ((parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
|
|
@@ -489,6 +564,74 @@ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
|
|
|
489
564
|
}
|
|
490
565
|
}
|
|
491
566
|
};
|
|
567
|
+
/**
|
|
568
|
+
* Reconcile the children of a new VNode with the children of an old VNode by
|
|
569
|
+
* traversing the two collections of children, identifying nodes that are
|
|
570
|
+
* conserved or changed, calling out to `patch` to make any necessary
|
|
571
|
+
* updates to the DOM, and rearranging DOM nodes as needed.
|
|
572
|
+
*
|
|
573
|
+
* The algorithm for reconciling children works by analyzing two 'windows' onto
|
|
574
|
+
* the two arrays of children (`oldCh` and `newCh`). We keep track of the
|
|
575
|
+
* 'windows' by storing start and end indices and references to the
|
|
576
|
+
* corresponding array entries. Initially the two 'windows' are basically equal
|
|
577
|
+
* to the entire array, but we progressively narrow the windows until there are
|
|
578
|
+
* no children left to update by doing the following:
|
|
579
|
+
*
|
|
580
|
+
* 1. Skip any `null` entries at the beginning or end of the two arrays, so
|
|
581
|
+
* that if we have an initial array like the following we'll end up dealing
|
|
582
|
+
* only with a window bounded by the highlighted elements:
|
|
583
|
+
*
|
|
584
|
+
* [null, null, VNode1 , ... , VNode2, null, null]
|
|
585
|
+
* ^^^^^^ ^^^^^^
|
|
586
|
+
*
|
|
587
|
+
* 2. Check to see if the elements at the head and tail positions are equal
|
|
588
|
+
* across the windows. This will basically detect elements which haven't
|
|
589
|
+
* been added, removed, or changed position, i.e. if you had the following
|
|
590
|
+
* VNode elements (represented as HTML):
|
|
591
|
+
*
|
|
592
|
+
* oldVNode: `<div><p><span>HEY</span></p></div>`
|
|
593
|
+
* newVNode: `<div><p><span>THERE</span></p></div>`
|
|
594
|
+
*
|
|
595
|
+
* Then when comparing the children of the `<div>` tag we check the equality
|
|
596
|
+
* of the VNodes corresponding to the `<p>` tags and, since they are the
|
|
597
|
+
* same tag in the same position, we'd be able to avoid completely
|
|
598
|
+
* re-rendering the subtree under them with a new DOM element and would just
|
|
599
|
+
* call out to `patch` to handle reconciling their children and so on.
|
|
600
|
+
*
|
|
601
|
+
* 3. Check, for both windows, to see if the element at the beginning of the
|
|
602
|
+
* window corresponds to the element at the end of the other window. This is
|
|
603
|
+
* a heuristic which will let us identify _some_ situations in which
|
|
604
|
+
* elements have changed position, for instance it _should_ detect that the
|
|
605
|
+
* children nodes themselves have not changed but merely moved in the
|
|
606
|
+
* following example:
|
|
607
|
+
*
|
|
608
|
+
* oldVNode: `<div><element-one /><element-two /></div>`
|
|
609
|
+
* newVNode: `<div><element-two /><element-one /></div>`
|
|
610
|
+
*
|
|
611
|
+
* If we find cases like this then we also need to move the concrete DOM
|
|
612
|
+
* elements corresponding to the moved children to write the re-order to the
|
|
613
|
+
* DOM.
|
|
614
|
+
*
|
|
615
|
+
* 4. Finally, if VNodes have the `key` attribute set on them we check for any
|
|
616
|
+
* nodes in the old children which have the same key as the first element in
|
|
617
|
+
* our window on the new children. If we find such a node we handle calling
|
|
618
|
+
* out to `patch`, moving relevant DOM nodes, and so on, in accordance with
|
|
619
|
+
* what we find.
|
|
620
|
+
*
|
|
621
|
+
* Finally, once we've narrowed our 'windows' to the point that either of them
|
|
622
|
+
* collapse (i.e. they have length 0) we then handle any remaining VNode
|
|
623
|
+
* insertion or deletion that needs to happen to get a DOM state that correctly
|
|
624
|
+
* reflects the new child VNodes. If, for instance, after our window on the old
|
|
625
|
+
* children has collapsed we still have more nodes on the new children that
|
|
626
|
+
* we haven't dealt with yet then we need to add them, or if the new children
|
|
627
|
+
* collapse but we still have unhandled _old_ children then we need to make
|
|
628
|
+
* sure the corresponding DOM nodes are removed.
|
|
629
|
+
*
|
|
630
|
+
* @param parentElm the node into which the parent VNode is rendered
|
|
631
|
+
* @param oldCh the old children of the parent node
|
|
632
|
+
* @param newVNode the new VNode which will replace the parent
|
|
633
|
+
* @param newCh the new children of the parent node
|
|
634
|
+
*/
|
|
492
635
|
const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
493
636
|
let oldStartIdx = 0;
|
|
494
637
|
let newStartIdx = 0;
|
|
@@ -504,7 +647,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
504
647
|
let elmToMove;
|
|
505
648
|
while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
|
|
506
649
|
if (oldStartVnode == null) {
|
|
507
|
-
//
|
|
650
|
+
// VNode might have been moved left
|
|
508
651
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
509
652
|
}
|
|
510
653
|
else if (oldEndVnode == null) {
|
|
@@ -517,37 +660,100 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
517
660
|
newEndVnode = newCh[--newEndIdx];
|
|
518
661
|
}
|
|
519
662
|
else if (isSameVnode(oldStartVnode, newStartVnode)) {
|
|
663
|
+
// if the start nodes are the same then we should patch the new VNode
|
|
664
|
+
// onto the old one, and increment our `newStartIdx` and `oldStartIdx`
|
|
665
|
+
// indices to reflect that. We don't need to move any DOM Nodes around
|
|
666
|
+
// since things are matched up in order.
|
|
520
667
|
patch(oldStartVnode, newStartVnode);
|
|
521
668
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
522
669
|
newStartVnode = newCh[++newStartIdx];
|
|
523
670
|
}
|
|
524
671
|
else if (isSameVnode(oldEndVnode, newEndVnode)) {
|
|
672
|
+
// likewise, if the end nodes are the same we patch new onto old and
|
|
673
|
+
// decrement our end indices, and also likewise in this case we don't
|
|
674
|
+
// need to move any DOM Nodes.
|
|
525
675
|
patch(oldEndVnode, newEndVnode);
|
|
526
676
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
527
677
|
newEndVnode = newCh[--newEndIdx];
|
|
528
678
|
}
|
|
529
679
|
else if (isSameVnode(oldStartVnode, newEndVnode)) {
|
|
530
|
-
// Vnode moved right
|
|
680
|
+
// case: "Vnode moved right"
|
|
681
|
+
//
|
|
682
|
+
// We've found that the last node in our window on the new children is
|
|
683
|
+
// the same VNode as the _first_ node in our window on the old children
|
|
684
|
+
// we're dealing with now. Visually, this is the layout of these two
|
|
685
|
+
// nodes:
|
|
686
|
+
//
|
|
687
|
+
// newCh: [..., newStartVnode , ... , newEndVnode , ...]
|
|
688
|
+
// ^^^^^^^^^^^
|
|
689
|
+
// oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
|
|
690
|
+
// ^^^^^^^^^^^^^
|
|
691
|
+
//
|
|
692
|
+
// In this situation we need to patch `newEndVnode` onto `oldStartVnode`
|
|
693
|
+
// and move the DOM element for `oldStartVnode`.
|
|
531
694
|
if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
|
|
532
695
|
putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
|
|
533
696
|
}
|
|
534
697
|
patch(oldStartVnode, newEndVnode);
|
|
698
|
+
// We need to move the element for `oldStartVnode` into a position which
|
|
699
|
+
// will be appropriate for `newEndVnode`. For this we can use
|
|
700
|
+
// `.insertBefore` and `oldEndVnode.$elm$.nextSibling`. If there is a
|
|
701
|
+
// sibling for `oldEndVnode.$elm$` then we want to move the DOM node for
|
|
702
|
+
// `oldStartVnode` between `oldEndVnode` and it's sibling, like so:
|
|
703
|
+
//
|
|
704
|
+
// <old-start-node />
|
|
705
|
+
// <some-intervening-node />
|
|
706
|
+
// <old-end-node />
|
|
707
|
+
// <!-- -> <-- `oldStartVnode.$elm$` should be inserted here
|
|
708
|
+
// <next-sibling />
|
|
709
|
+
//
|
|
710
|
+
// If instead `oldEndVnode.$elm$` has no sibling then we just want to put
|
|
711
|
+
// the node for `oldStartVnode` at the end of the children of
|
|
712
|
+
// `parentElm`. Luckily, `Node.nextSibling` will return `null` if there
|
|
713
|
+
// aren't any siblings, and passing `null` to `Node.insertBefore` will
|
|
714
|
+
// append it to the children of the parent element.
|
|
535
715
|
parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
|
|
536
716
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
537
717
|
newEndVnode = newCh[--newEndIdx];
|
|
538
718
|
}
|
|
539
719
|
else if (isSameVnode(oldEndVnode, newStartVnode)) {
|
|
540
|
-
// Vnode moved left
|
|
720
|
+
// case: "Vnode moved left"
|
|
721
|
+
//
|
|
722
|
+
// We've found that the first node in our window on the new children is
|
|
723
|
+
// the same VNode as the _last_ node in our window on the old children.
|
|
724
|
+
// Visually, this is the layout of these two nodes:
|
|
725
|
+
//
|
|
726
|
+
// newCh: [..., newStartVnode , ... , newEndVnode , ...]
|
|
727
|
+
// ^^^^^^^^^^^^^
|
|
728
|
+
// oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
|
|
729
|
+
// ^^^^^^^^^^^
|
|
730
|
+
//
|
|
731
|
+
// In this situation we need to patch `newStartVnode` onto `oldEndVnode`
|
|
732
|
+
// (which will handle updating any changed attributes, reconciling their
|
|
733
|
+
// children etc) but we also need to move the DOM node to which
|
|
734
|
+
// `oldEndVnode` corresponds.
|
|
541
735
|
if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
|
|
542
736
|
putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
|
|
543
737
|
}
|
|
544
738
|
patch(oldEndVnode, newStartVnode);
|
|
739
|
+
// We've already checked above if `oldStartVnode` and `newStartVnode` are
|
|
740
|
+
// the same node, so since we're here we know that they are not. Thus we
|
|
741
|
+
// can move the element for `oldEndVnode` _before_ the element for
|
|
742
|
+
// `oldStartVnode`, leaving `oldStartVnode` to be reconciled in the
|
|
743
|
+
// future.
|
|
545
744
|
parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
|
|
546
745
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
547
746
|
newStartVnode = newCh[++newStartIdx];
|
|
548
747
|
}
|
|
549
748
|
else {
|
|
550
|
-
//
|
|
749
|
+
// Here we do some checks to match up old and new nodes based on the
|
|
750
|
+
// `$key$` attribute, which is set by putting a `key="my-key"` attribute
|
|
751
|
+
// in the JSX for a DOM element in the implementation of a Stencil
|
|
752
|
+
// component.
|
|
753
|
+
//
|
|
754
|
+
// First we check to see if there are any nodes in the array of old
|
|
755
|
+
// children which have the same key as the first node in the new
|
|
756
|
+
// children.
|
|
551
757
|
idxInOld = -1;
|
|
552
758
|
{
|
|
553
759
|
for (i = oldStartIdx; i <= oldEndIdx; ++i) {
|
|
@@ -558,23 +764,32 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
558
764
|
}
|
|
559
765
|
}
|
|
560
766
|
if (idxInOld >= 0) {
|
|
767
|
+
// We found a node in the old children which matches up with the first
|
|
768
|
+
// node in the new children! So let's deal with that
|
|
561
769
|
elmToMove = oldCh[idxInOld];
|
|
562
770
|
if (elmToMove.$tag$ !== newStartVnode.$tag$) {
|
|
771
|
+
// the tag doesn't match so we'll need a new DOM element
|
|
563
772
|
node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld, parentElm);
|
|
564
773
|
}
|
|
565
774
|
else {
|
|
566
775
|
patch(elmToMove, newStartVnode);
|
|
776
|
+
// invalidate the matching old node so that we won't try to update it
|
|
777
|
+
// again later on
|
|
567
778
|
oldCh[idxInOld] = undefined;
|
|
568
779
|
node = elmToMove.$elm$;
|
|
569
780
|
}
|
|
570
781
|
newStartVnode = newCh[++newStartIdx];
|
|
571
782
|
}
|
|
572
783
|
else {
|
|
573
|
-
//
|
|
784
|
+
// We either didn't find an element in the old children that matches
|
|
785
|
+
// the key of the first new child OR the build is not using `key`
|
|
786
|
+
// attributes at all. In either case we need to create a new element
|
|
787
|
+
// for the new node.
|
|
574
788
|
node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx, parentElm);
|
|
575
789
|
newStartVnode = newCh[++newStartIdx];
|
|
576
790
|
}
|
|
577
791
|
if (node) {
|
|
792
|
+
// if we created a new node then handle inserting it to the DOM
|
|
578
793
|
{
|
|
579
794
|
parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
|
|
580
795
|
}
|
|
@@ -582,21 +797,43 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
582
797
|
}
|
|
583
798
|
}
|
|
584
799
|
if (oldStartIdx > oldEndIdx) {
|
|
800
|
+
// we have some more new nodes to add which don't match up with old nodes
|
|
585
801
|
addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
|
|
586
802
|
}
|
|
587
803
|
else if (newStartIdx > newEndIdx) {
|
|
804
|
+
// there are nodes in the `oldCh` array which no longer correspond to nodes
|
|
805
|
+
// in the new array, so lets remove them (which entails cleaning up the
|
|
806
|
+
// relevant DOM nodes)
|
|
588
807
|
removeVnodes(oldCh, oldStartIdx, oldEndIdx);
|
|
589
808
|
}
|
|
590
809
|
};
|
|
591
|
-
|
|
810
|
+
/**
|
|
811
|
+
* Compare two VNodes to determine if they are the same
|
|
812
|
+
*
|
|
813
|
+
* **NB**: This function is an equality _heuristic_ based on the available
|
|
814
|
+
* information set on the two VNodes and can be misleading under certain
|
|
815
|
+
* circumstances. In particular, if the two nodes do not have `key` attrs
|
|
816
|
+
* (available under `$key$` on VNodes) then the function falls back on merely
|
|
817
|
+
* checking that they have the same tag.
|
|
818
|
+
*
|
|
819
|
+
* So, in other words, if `key` attrs are not set on VNodes which may be
|
|
820
|
+
* changing order within a `children` array or something along those lines then
|
|
821
|
+
* we could obtain a false positive and then have to do needless re-rendering.
|
|
822
|
+
*
|
|
823
|
+
* @param leftVNode the first VNode to check
|
|
824
|
+
* @param rightVNode the second VNode to check
|
|
825
|
+
* @returns whether they're equal or not
|
|
826
|
+
*/
|
|
827
|
+
const isSameVnode = (leftVNode, rightVNode) => {
|
|
592
828
|
// compare if two vnode to see if they're "technically" the same
|
|
593
829
|
// need to have the same element tag, and same key to be the same
|
|
594
|
-
if (
|
|
595
|
-
if (
|
|
596
|
-
return
|
|
830
|
+
if (leftVNode.$tag$ === rightVNode.$tag$) {
|
|
831
|
+
if (leftVNode.$tag$ === 'slot') {
|
|
832
|
+
return leftVNode.$name$ === rightVNode.$name$;
|
|
597
833
|
}
|
|
834
|
+
// this will be set if components in the build have `key` attrs set on them
|
|
598
835
|
{
|
|
599
|
-
return
|
|
836
|
+
return leftVNode.$key$ === rightVNode.$key$;
|
|
600
837
|
}
|
|
601
838
|
}
|
|
602
839
|
return false;
|
|
@@ -609,6 +846,14 @@ const referenceNode = (node) => {
|
|
|
609
846
|
return (node && node['s-ol']) || node;
|
|
610
847
|
};
|
|
611
848
|
const parentReferenceNode = (node) => (node['s-ol'] ? node['s-ol'] : node).parentNode;
|
|
849
|
+
/**
|
|
850
|
+
* Handle reconciling an outdated VNode with a new one which corresponds to
|
|
851
|
+
* it. This function handles flushing updates to the DOM and reconciling the
|
|
852
|
+
* children of the two nodes (if any).
|
|
853
|
+
*
|
|
854
|
+
* @param oldVNode an old VNode whose DOM element and children we want to update
|
|
855
|
+
* @param newVNode a new VNode representing an updated version of the old one
|
|
856
|
+
*/
|
|
612
857
|
const patch = (oldVNode, newVNode) => {
|
|
613
858
|
const elm = (newVNode.$elm$ = oldVNode.$elm$);
|
|
614
859
|
const oldChildren = oldVNode.$children$;
|
|
@@ -617,7 +862,6 @@ const patch = (oldVNode, newVNode) => {
|
|
|
617
862
|
const text = newVNode.$text$;
|
|
618
863
|
let defaultHolder;
|
|
619
864
|
if (text === null) {
|
|
620
|
-
// element node
|
|
621
865
|
{
|
|
622
866
|
if (tag === 'slot')
|
|
623
867
|
;
|
|
@@ -630,6 +874,7 @@ const patch = (oldVNode, newVNode) => {
|
|
|
630
874
|
}
|
|
631
875
|
if (oldChildren !== null && newChildren !== null) {
|
|
632
876
|
// looks like there's child vnodes for both the old and new vnodes
|
|
877
|
+
// so we need to call `updateChildren` to reconcile them
|
|
633
878
|
updateChildren(elm, oldChildren, newVNode, newChildren);
|
|
634
879
|
}
|
|
635
880
|
else if (newChildren !== null) {
|
|
@@ -667,7 +912,7 @@ const updateFallbackSlotVisibility = (elm) => {
|
|
|
667
912
|
let nodeType;
|
|
668
913
|
for (i = 0, ilen = childNodes.length; i < ilen; i++) {
|
|
669
914
|
childNode = childNodes[i];
|
|
670
|
-
if (childNode.nodeType === 1 /* ElementNode */) {
|
|
915
|
+
if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
671
916
|
if (childNode['s-sr']) {
|
|
672
917
|
// this is a slot fallback node
|
|
673
918
|
// get the slot name for this slot reference node
|
|
@@ -679,7 +924,7 @@ const updateFallbackSlotVisibility = (elm) => {
|
|
|
679
924
|
nodeType = childNodes[j].nodeType;
|
|
680
925
|
if (childNodes[j]['s-hn'] !== childNode['s-hn'] || slotNameAttr !== '') {
|
|
681
926
|
// this sibling node is from a different component OR is a named fallback slot node
|
|
682
|
-
if (nodeType === 1 /* ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
|
|
927
|
+
if (nodeType === 1 /* NODE_TYPE.ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
|
|
683
928
|
childNode.hidden = true;
|
|
684
929
|
break;
|
|
685
930
|
}
|
|
@@ -688,8 +933,8 @@ const updateFallbackSlotVisibility = (elm) => {
|
|
|
688
933
|
// this is a default fallback slot node
|
|
689
934
|
// any element or text node (with content)
|
|
690
935
|
// should hide the default fallback slot node
|
|
691
|
-
if (nodeType === 1 /* ElementNode */ ||
|
|
692
|
-
(nodeType === 3 /* TextNode */ && childNodes[j].textContent.trim() !== '')) {
|
|
936
|
+
if (nodeType === 1 /* NODE_TYPE.ElementNode */ ||
|
|
937
|
+
(nodeType === 3 /* NODE_TYPE.TextNode */ && childNodes[j].textContent.trim() !== '')) {
|
|
693
938
|
childNode.hidden = true;
|
|
694
939
|
break;
|
|
695
940
|
}
|
|
@@ -767,13 +1012,13 @@ const relocateSlotContent = (elm) => {
|
|
|
767
1012
|
}
|
|
768
1013
|
}
|
|
769
1014
|
}
|
|
770
|
-
if (childNode.nodeType === 1 /* ElementNode */) {
|
|
1015
|
+
if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
771
1016
|
relocateSlotContent(childNode);
|
|
772
1017
|
}
|
|
773
1018
|
}
|
|
774
1019
|
};
|
|
775
1020
|
const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
|
|
776
|
-
if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
|
|
1021
|
+
if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
777
1022
|
if (nodeToRelocate.getAttribute('slot') === null && slotNameAttr === '') {
|
|
778
1023
|
return true;
|
|
779
1024
|
}
|
|
@@ -800,7 +1045,7 @@ const renderVdom = (hostRef, renderFnResults) => {
|
|
|
800
1045
|
const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
|
|
801
1046
|
hostTagName = hostElm.tagName;
|
|
802
1047
|
rootVnode.$tag$ = null;
|
|
803
|
-
rootVnode.$flags$ |= 4 /* isHost */;
|
|
1048
|
+
rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
|
|
804
1049
|
hostRef.$vnode$ = rootVnode;
|
|
805
1050
|
rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
|
|
806
1051
|
{
|
|
@@ -808,7 +1053,7 @@ const renderVdom = (hostRef, renderFnResults) => {
|
|
|
808
1053
|
}
|
|
809
1054
|
{
|
|
810
1055
|
contentRef = hostElm['s-cr'];
|
|
811
|
-
useNativeShadowDom = (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) !== 0;
|
|
1056
|
+
useNativeShadowDom = (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) !== 0;
|
|
812
1057
|
// always reset
|
|
813
1058
|
checkSlotFallbackVisibility = false;
|
|
814
1059
|
}
|
|
@@ -817,7 +1062,7 @@ const renderVdom = (hostRef, renderFnResults) => {
|
|
|
817
1062
|
{
|
|
818
1063
|
// while we're moving nodes around existing nodes, temporarily disable
|
|
819
1064
|
// the disconnectCallback from working
|
|
820
|
-
plt.$flags$ |= 1 /* isTmpDisconnected */;
|
|
1065
|
+
plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
|
|
821
1066
|
if (checkSlotRelocate) {
|
|
822
1067
|
relocateSlotContent(rootVnode.$elm$);
|
|
823
1068
|
let relocateData;
|
|
@@ -875,7 +1120,7 @@ const renderVdom = (hostRef, renderFnResults) => {
|
|
|
875
1120
|
}
|
|
876
1121
|
else {
|
|
877
1122
|
// this node doesn't have a slot home to go to, so let's hide it
|
|
878
|
-
if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
|
|
1123
|
+
if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
879
1124
|
nodeToRelocate.hidden = true;
|
|
880
1125
|
}
|
|
881
1126
|
}
|
|
@@ -886,37 +1131,11 @@ const renderVdom = (hostRef, renderFnResults) => {
|
|
|
886
1131
|
}
|
|
887
1132
|
// done moving nodes around
|
|
888
1133
|
// allow the disconnect callback to work again
|
|
889
|
-
plt.$flags$ &= ~1 /* isTmpDisconnected */;
|
|
1134
|
+
plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
|
|
890
1135
|
// always reset
|
|
891
1136
|
relocateNodes.length = 0;
|
|
892
1137
|
}
|
|
893
1138
|
};
|
|
894
|
-
const getElement = (ref) => (getHostRef(ref).$hostElement$ );
|
|
895
|
-
const createEvent = (ref, name, flags) => {
|
|
896
|
-
const elm = getElement(ref);
|
|
897
|
-
return {
|
|
898
|
-
emit: (detail) => {
|
|
899
|
-
return emitEvent(elm, name, {
|
|
900
|
-
bubbles: !!(flags & 4 /* Bubbles */),
|
|
901
|
-
composed: !!(flags & 2 /* Composed */),
|
|
902
|
-
cancelable: !!(flags & 1 /* Cancellable */),
|
|
903
|
-
detail,
|
|
904
|
-
});
|
|
905
|
-
},
|
|
906
|
-
};
|
|
907
|
-
};
|
|
908
|
-
/**
|
|
909
|
-
* Helper function to create & dispatch a custom Event on a provided target
|
|
910
|
-
* @param elm the target of the Event
|
|
911
|
-
* @param name the name to give the custom Event
|
|
912
|
-
* @param opts options for configuring a custom Event
|
|
913
|
-
* @returns the custom Event
|
|
914
|
-
*/
|
|
915
|
-
const emitEvent = (elm, name, opts) => {
|
|
916
|
-
const ev = plt.ce(name, opts);
|
|
917
|
-
elm.dispatchEvent(ev);
|
|
918
|
-
return ev;
|
|
919
|
-
};
|
|
920
1139
|
const attachToAncestor = (hostRef, ancestorComponent) => {
|
|
921
1140
|
if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
|
|
922
1141
|
ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
|
|
@@ -924,10 +1143,10 @@ const attachToAncestor = (hostRef, ancestorComponent) => {
|
|
|
924
1143
|
};
|
|
925
1144
|
const scheduleUpdate = (hostRef, isInitialLoad) => {
|
|
926
1145
|
{
|
|
927
|
-
hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
|
|
1146
|
+
hostRef.$flags$ |= 16 /* HOST_FLAGS.isQueuedForUpdate */;
|
|
928
1147
|
}
|
|
929
|
-
if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
|
|
930
|
-
hostRef.$flags$ |= 512 /* needsRerender */;
|
|
1148
|
+
if (hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
|
|
1149
|
+
hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
|
|
931
1150
|
return;
|
|
932
1151
|
}
|
|
933
1152
|
attachToAncestor(hostRef, hostRef.$ancestorComponent$);
|
|
@@ -982,7 +1201,7 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
|
|
|
982
1201
|
}
|
|
983
1202
|
else {
|
|
984
1203
|
Promise.all(childrenPromises).then(postUpdate);
|
|
985
|
-
hostRef.$flags$ |= 4 /* isWaitingForChildren */;
|
|
1204
|
+
hostRef.$flags$ |= 4 /* HOST_FLAGS.isWaitingForChildren */;
|
|
986
1205
|
childrenPromises.length = 0;
|
|
987
1206
|
}
|
|
988
1207
|
}
|
|
@@ -991,10 +1210,10 @@ const callRender = (hostRef, instance, elm) => {
|
|
|
991
1210
|
try {
|
|
992
1211
|
instance = instance.render() ;
|
|
993
1212
|
{
|
|
994
|
-
hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
|
|
1213
|
+
hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
|
|
995
1214
|
}
|
|
996
1215
|
{
|
|
997
|
-
hostRef.$flags$ |= 2 /* hasRendered */;
|
|
1216
|
+
hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
|
|
998
1217
|
}
|
|
999
1218
|
{
|
|
1000
1219
|
{
|
|
@@ -1018,8 +1237,8 @@ const postUpdateComponent = (hostRef) => {
|
|
|
1018
1237
|
const endPostUpdate = createTime('postUpdate', tagName);
|
|
1019
1238
|
const instance = hostRef.$lazyInstance$ ;
|
|
1020
1239
|
const ancestorComponent = hostRef.$ancestorComponent$;
|
|
1021
|
-
if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
|
|
1022
|
-
hostRef.$flags$ |= 64 /* hasLoadedComponent */;
|
|
1240
|
+
if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
|
|
1241
|
+
hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
|
|
1023
1242
|
{
|
|
1024
1243
|
// DOM WRITE!
|
|
1025
1244
|
addHydratedFlag(elm);
|
|
@@ -1048,10 +1267,10 @@ const postUpdateComponent = (hostRef) => {
|
|
|
1048
1267
|
hostRef.$onRenderResolve$();
|
|
1049
1268
|
hostRef.$onRenderResolve$ = undefined;
|
|
1050
1269
|
}
|
|
1051
|
-
if (hostRef.$flags$ & 512 /* needsRerender */) {
|
|
1270
|
+
if (hostRef.$flags$ & 512 /* HOST_FLAGS.needsRerender */) {
|
|
1052
1271
|
nextTick(() => scheduleUpdate(hostRef, false));
|
|
1053
1272
|
}
|
|
1054
|
-
hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
|
|
1273
|
+
hostRef.$flags$ &= ~(4 /* HOST_FLAGS.isWaitingForChildren */ | 512 /* HOST_FLAGS.needsRerender */);
|
|
1055
1274
|
}
|
|
1056
1275
|
// ( •_•)
|
|
1057
1276
|
// ( •_•)>⌐■-■
|
|
@@ -1081,53 +1300,6 @@ const then = (promise, thenFn) => {
|
|
|
1081
1300
|
};
|
|
1082
1301
|
const addHydratedFlag = (elm) => elm.classList.add('hydrated')
|
|
1083
1302
|
;
|
|
1084
|
-
/**
|
|
1085
|
-
* Parse a new property value for a given property type.
|
|
1086
|
-
*
|
|
1087
|
-
* While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
|
|
1088
|
-
* it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
|
|
1089
|
-
* 1. `any`, the type given to `propValue` in the function signature
|
|
1090
|
-
* 2. the type stored from `propType`.
|
|
1091
|
-
*
|
|
1092
|
-
* This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
|
|
1093
|
-
*
|
|
1094
|
-
* Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
|
|
1095
|
-
* a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
|
|
1096
|
-
* based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
|
|
1097
|
-
* ```tsx
|
|
1098
|
-
* <my-cmp prop-val={0}></my-cmp>
|
|
1099
|
-
* ```
|
|
1100
|
-
*
|
|
1101
|
-
* HTML prop values on the other hand, will always a string
|
|
1102
|
-
*
|
|
1103
|
-
* @param propValue the new value to coerce to some type
|
|
1104
|
-
* @param propType the type of the prop, expressed as a binary number
|
|
1105
|
-
* @returns the parsed/coerced value
|
|
1106
|
-
*/
|
|
1107
|
-
const parsePropertyValue = (propValue, propType) => {
|
|
1108
|
-
// ensure this value is of the correct prop type
|
|
1109
|
-
if (propValue != null && !isComplexType(propValue)) {
|
|
1110
|
-
if (propType & 4 /* Boolean */) {
|
|
1111
|
-
// per the HTML spec, any string value means it is a boolean true value
|
|
1112
|
-
// but we'll cheat here and say that the string "false" is the boolean false
|
|
1113
|
-
return propValue === 'false' ? false : propValue === '' || !!propValue;
|
|
1114
|
-
}
|
|
1115
|
-
if (propType & 2 /* Number */) {
|
|
1116
|
-
// force it to be a number
|
|
1117
|
-
return parseFloat(propValue);
|
|
1118
|
-
}
|
|
1119
|
-
if (propType & 1 /* String */) {
|
|
1120
|
-
// could have been passed as a number or boolean
|
|
1121
|
-
// but we still want it as a string
|
|
1122
|
-
return String(propValue);
|
|
1123
|
-
}
|
|
1124
|
-
// redundant return here for better minification
|
|
1125
|
-
return propValue;
|
|
1126
|
-
}
|
|
1127
|
-
// not sure exactly what type we want
|
|
1128
|
-
// so no need to change to a different type
|
|
1129
|
-
return propValue;
|
|
1130
|
-
};
|
|
1131
1303
|
const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
|
|
1132
1304
|
const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
1133
1305
|
// check our new property value against our internal value
|
|
@@ -1140,13 +1312,13 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
1140
1312
|
// explicitly check for NaN on both sides, as `NaN === NaN` is always false
|
|
1141
1313
|
const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
|
|
1142
1314
|
const didValueChange = newVal !== oldVal && !areBothNaN;
|
|
1143
|
-
if ((!(flags & 8 /* isConstructingInstance */) || oldVal === undefined) && didValueChange) {
|
|
1315
|
+
if ((!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
|
|
1144
1316
|
// gadzooks! the property's value has changed!!
|
|
1145
1317
|
// set our new value!
|
|
1146
1318
|
hostRef.$instanceValues$.set(propName, newVal);
|
|
1147
1319
|
if (instance) {
|
|
1148
1320
|
// get an array of method names of watch functions to call
|
|
1149
|
-
if (cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
|
|
1321
|
+
if (cmpMeta.$watchers$ && flags & 128 /* HOST_FLAGS.isWatchReady */) {
|
|
1150
1322
|
const watchMethods = cmpMeta.$watchers$[propName];
|
|
1151
1323
|
if (watchMethods) {
|
|
1152
1324
|
// this instance is watching for when this property changed
|
|
@@ -1161,7 +1333,7 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
1161
1333
|
});
|
|
1162
1334
|
}
|
|
1163
1335
|
}
|
|
1164
|
-
if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
|
|
1336
|
+
if ((flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
|
|
1165
1337
|
// looks like this value actually changed, so we've got work to do!
|
|
1166
1338
|
// but only if we've already rendered, otherwise just chill out
|
|
1167
1339
|
// queue that we need to do an update, but don't worry about queuing
|
|
@@ -1171,6 +1343,16 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
1171
1343
|
}
|
|
1172
1344
|
}
|
|
1173
1345
|
};
|
|
1346
|
+
/**
|
|
1347
|
+
* Attach a series of runtime constructs to a compiled Stencil component
|
|
1348
|
+
* constructor, including getters and setters for the `@Prop` and `@State`
|
|
1349
|
+
* decorators, callbacks for when attributes change, and so on.
|
|
1350
|
+
*
|
|
1351
|
+
* @param Cstr the constructor for a component that we need to process
|
|
1352
|
+
* @param cmpMeta metadata collected previously about the component
|
|
1353
|
+
* @param flags a number used to store a series of bit flags
|
|
1354
|
+
* @returns a reference to the same constructor passed in (but now mutated)
|
|
1355
|
+
*/
|
|
1174
1356
|
const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
1175
1357
|
if (cmpMeta.$members$) {
|
|
1176
1358
|
if (Cstr.watchers) {
|
|
@@ -1180,8 +1362,8 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1180
1362
|
const members = Object.entries(cmpMeta.$members$);
|
|
1181
1363
|
const prototype = Cstr.prototype;
|
|
1182
1364
|
members.map(([memberName, [memberFlags]]) => {
|
|
1183
|
-
if ((memberFlags & 31 /* Prop */ ||
|
|
1184
|
-
((flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
|
|
1365
|
+
if ((memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
|
|
1366
|
+
((flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
|
|
1185
1367
|
// proxyComponent - prop
|
|
1186
1368
|
Object.defineProperty(prototype, memberName, {
|
|
1187
1369
|
get() {
|
|
@@ -1196,8 +1378,8 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1196
1378
|
enumerable: true,
|
|
1197
1379
|
});
|
|
1198
1380
|
}
|
|
1199
|
-
else if (flags & 1 /* isElementConstructor */ &&
|
|
1200
|
-
memberFlags & 64 /* Method */) {
|
|
1381
|
+
else if (flags & 1 /* PROXY_FLAGS.isElementConstructor */ &&
|
|
1382
|
+
memberFlags & 64 /* MEMBER_FLAGS.Method */) {
|
|
1201
1383
|
// proxyComponent - method
|
|
1202
1384
|
Object.defineProperty(prototype, memberName, {
|
|
1203
1385
|
value(...args) {
|
|
@@ -1207,7 +1389,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1207
1389
|
});
|
|
1208
1390
|
}
|
|
1209
1391
|
});
|
|
1210
|
-
if ((flags & 1 /* isElementConstructor */)) {
|
|
1392
|
+
if ((flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
|
|
1211
1393
|
const attrNameToPropName = new Map();
|
|
1212
1394
|
prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
|
|
1213
1395
|
plt.jmp(() => {
|
|
@@ -1263,7 +1445,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1263
1445
|
// create an array of attributes to observe
|
|
1264
1446
|
// and also create a map of html attribute name to js property name
|
|
1265
1447
|
Cstr.observedAttributes = members
|
|
1266
|
-
.filter(([_, m]) => m[0] & 15 /* HasAttribute */) // filter to only keep props that should match attributes
|
|
1448
|
+
.filter(([_, m]) => m[0] & 15 /* MEMBER_FLAGS.HasAttribute */) // filter to only keep props that should match attributes
|
|
1267
1449
|
.map(([propName, m]) => {
|
|
1268
1450
|
const attrName = m[1] || propName;
|
|
1269
1451
|
attrNameToPropName.set(attrName, propName);
|
|
@@ -1275,10 +1457,10 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1275
1457
|
};
|
|
1276
1458
|
const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
|
|
1277
1459
|
// initializeComponent
|
|
1278
|
-
if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
|
|
1460
|
+
if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
|
|
1279
1461
|
{
|
|
1280
1462
|
// we haven't initialized this element yet
|
|
1281
|
-
hostRef.$flags$ |= 32 /* hasInitializedComponent */;
|
|
1463
|
+
hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
|
|
1282
1464
|
// lazy loaded components
|
|
1283
1465
|
// request the component's implementation to be
|
|
1284
1466
|
// wired up with the host element
|
|
@@ -1296,7 +1478,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1296
1478
|
{
|
|
1297
1479
|
cmpMeta.$watchers$ = Cstr.watchers;
|
|
1298
1480
|
}
|
|
1299
|
-
proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
|
|
1481
|
+
proxyComponent(Cstr, cmpMeta, 2 /* PROXY_FLAGS.proxyState */);
|
|
1300
1482
|
Cstr.isProxied = true;
|
|
1301
1483
|
}
|
|
1302
1484
|
const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
|
|
@@ -1304,7 +1486,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1304
1486
|
// but let's keep track of when we start and stop
|
|
1305
1487
|
// so that the getters/setters don't incorrectly step on data
|
|
1306
1488
|
{
|
|
1307
|
-
hostRef.$flags$ |= 8 /* isConstructingInstance */;
|
|
1489
|
+
hostRef.$flags$ |= 8 /* HOST_FLAGS.isConstructingInstance */;
|
|
1308
1490
|
}
|
|
1309
1491
|
// construct the lazy-loaded component implementation
|
|
1310
1492
|
// passing the hostRef is very important during
|
|
@@ -1317,10 +1499,10 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1317
1499
|
consoleError(e);
|
|
1318
1500
|
}
|
|
1319
1501
|
{
|
|
1320
|
-
hostRef.$flags$ &= ~8 /* isConstructingInstance */;
|
|
1502
|
+
hostRef.$flags$ &= ~8 /* HOST_FLAGS.isConstructingInstance */;
|
|
1321
1503
|
}
|
|
1322
1504
|
{
|
|
1323
|
-
hostRef.$flags$ |= 128 /* isWatchReady */;
|
|
1505
|
+
hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */;
|
|
1324
1506
|
}
|
|
1325
1507
|
endNewInstance();
|
|
1326
1508
|
fireConnectedCallback(hostRef.$lazyInstance$);
|
|
@@ -1331,7 +1513,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1331
1513
|
const scopeId = getScopeId(cmpMeta);
|
|
1332
1514
|
if (!styles.has(scopeId)) {
|
|
1333
1515
|
const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
|
|
1334
|
-
registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
|
|
1516
|
+
registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
|
|
1335
1517
|
endRegisterStyles();
|
|
1336
1518
|
}
|
|
1337
1519
|
}
|
|
@@ -1358,19 +1540,19 @@ const fireConnectedCallback = (instance) => {
|
|
|
1358
1540
|
}
|
|
1359
1541
|
};
|
|
1360
1542
|
const connectedCallback = (elm) => {
|
|
1361
|
-
if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
|
|
1543
|
+
if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
|
|
1362
1544
|
const hostRef = getHostRef(elm);
|
|
1363
1545
|
const cmpMeta = hostRef.$cmpMeta$;
|
|
1364
1546
|
const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
|
|
1365
|
-
if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
|
|
1547
|
+
if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
|
|
1366
1548
|
// first time this component has connected
|
|
1367
|
-
hostRef.$flags$ |= 1 /* hasConnected */;
|
|
1549
|
+
hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
|
|
1368
1550
|
{
|
|
1369
1551
|
// initUpdate
|
|
1370
1552
|
// if the slot polyfill is required we'll need to put some nodes
|
|
1371
1553
|
// in here to act as original content anchors as we move nodes around
|
|
1372
1554
|
// host element has been connected to the DOM
|
|
1373
|
-
if ((cmpMeta.$flags$ & (4 /* hasSlotRelocation */ | 8 /* needsShadowDomShim */))) {
|
|
1555
|
+
if ((cmpMeta.$flags$ & (4 /* CMP_FLAGS.hasSlotRelocation */ | 8 /* CMP_FLAGS.needsShadowDomShim */))) {
|
|
1374
1556
|
setContentReference(elm);
|
|
1375
1557
|
}
|
|
1376
1558
|
}
|
|
@@ -1393,7 +1575,7 @@ const connectedCallback = (elm) => {
|
|
|
1393
1575
|
// https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
|
|
1394
1576
|
if (cmpMeta.$members$) {
|
|
1395
1577
|
Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
|
|
1396
|
-
if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
|
|
1578
|
+
if (memberFlags & 31 /* MEMBER_FLAGS.Prop */ && elm.hasOwnProperty(memberName)) {
|
|
1397
1579
|
const value = elm[memberName];
|
|
1398
1580
|
delete elm[memberName];
|
|
1399
1581
|
elm[memberName] = value;
|
|
@@ -1423,7 +1605,7 @@ const setContentReference = (elm) => {
|
|
|
1423
1605
|
elm.insertBefore(contentRefElm, elm.firstChild);
|
|
1424
1606
|
};
|
|
1425
1607
|
const disconnectedCallback = (elm) => {
|
|
1426
|
-
if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
|
|
1608
|
+
if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
|
|
1427
1609
|
const hostRef = getHostRef(elm);
|
|
1428
1610
|
const instance = hostRef.$lazyInstance$ ;
|
|
1429
1611
|
{
|
|
@@ -1466,7 +1648,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1466
1648
|
super(self);
|
|
1467
1649
|
self = this;
|
|
1468
1650
|
registerHost(self, cmpMeta);
|
|
1469
|
-
if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
|
|
1651
|
+
if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
|
|
1470
1652
|
// this component is using shadow dom
|
|
1471
1653
|
// and this browser supports shadow dom
|
|
1472
1654
|
// add the read-only property "shadowRoot" to the host element
|
|
@@ -1501,7 +1683,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1501
1683
|
cmpMeta.$lazyBundleId$ = lazyBundle[0];
|
|
1502
1684
|
if (!exclude.includes(tagName) && !customElements.get(tagName)) {
|
|
1503
1685
|
cmpTags.push(tagName);
|
|
1504
|
-
customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
|
|
1686
|
+
customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */));
|
|
1505
1687
|
}
|
|
1506
1688
|
});
|
|
1507
1689
|
});
|
|
@@ -1523,7 +1705,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1523
1705
|
// Fallback appLoad event
|
|
1524
1706
|
endBootstrap();
|
|
1525
1707
|
};
|
|
1526
|
-
const hostRefs = new WeakMap();
|
|
1708
|
+
const hostRefs = /*@__PURE__*/ new WeakMap();
|
|
1527
1709
|
const getHostRef = (ref) => hostRefs.get(ref);
|
|
1528
1710
|
const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
|
|
1529
1711
|
const registerHost = (elm, cmpMeta) => {
|
|
@@ -1567,14 +1749,35 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
|
|
|
1567
1749
|
return importedModule[exportName];
|
|
1568
1750
|
}, consoleError);
|
|
1569
1751
|
};
|
|
1570
|
-
const styles = new Map();
|
|
1752
|
+
const styles = /*@__PURE__*/ new Map();
|
|
1753
|
+
const win = typeof window !== 'undefined' ? window : {};
|
|
1754
|
+
const doc = win.document || { head: {} };
|
|
1755
|
+
const plt = {
|
|
1756
|
+
$flags$: 0,
|
|
1757
|
+
$resourcesUrl$: '',
|
|
1758
|
+
jmp: (h) => h(),
|
|
1759
|
+
raf: (h) => requestAnimationFrame(h),
|
|
1760
|
+
ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
|
|
1761
|
+
rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
|
|
1762
|
+
ce: (eventName, opts) => new CustomEvent(eventName, opts),
|
|
1763
|
+
};
|
|
1764
|
+
const promiseResolve = (v) => Promise.resolve(v);
|
|
1765
|
+
const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
|
|
1766
|
+
try {
|
|
1767
|
+
new CSSStyleSheet();
|
|
1768
|
+
return typeof new CSSStyleSheet().replaceSync === 'function';
|
|
1769
|
+
}
|
|
1770
|
+
catch (e) { }
|
|
1771
|
+
return false;
|
|
1772
|
+
})()
|
|
1773
|
+
;
|
|
1571
1774
|
const queueDomReads = [];
|
|
1572
1775
|
const queueDomWrites = [];
|
|
1573
1776
|
const queueTask = (queue, write) => (cb) => {
|
|
1574
1777
|
queue.push(cb);
|
|
1575
1778
|
if (!queuePending) {
|
|
1576
1779
|
queuePending = true;
|
|
1577
|
-
if (write && plt.$flags$ & 4 /* queueSync */) {
|
|
1780
|
+
if (write && plt.$flags$ & 4 /* PLATFORM_FLAGS.queueSync */) {
|
|
1578
1781
|
nextTick(flush);
|
|
1579
1782
|
}
|
|
1580
1783
|
else {
|