@maggioli-design-system/mds-accordion-timer 2.0.1 → 2.1.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.
- package/dist/cjs/{index-71ce67f9.js → index-bd5d8a33.js} +381 -217
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/mds-accordion-timer.cjs.entry.js +1 -1
- package/dist/cjs/mds-accordion-timer.cjs.js +2 -2
- package/dist/collection/collection-manifest.json +2 -2
- package/dist/collection/common/aria.js +19 -0
- package/dist/collection/components/mds-accordion-timer/mds-accordion-timer.js +77 -66
- package/dist/collection/components/mds-accordion-timer/test/mds-accordion-timer.stories.js +1 -12
- package/dist/esm/{index-131803de.js → index-afb1c64b.js} +381 -217
- package/dist/esm/loader.js +2 -2
- package/dist/esm/mds-accordion-timer.entry.js +1 -1
- package/dist/esm/mds-accordion-timer.js +2 -2
- package/dist/esm/polyfills/css-shim.js +1 -1
- package/dist/esm-es5/index-afb1c64b.js +2 -0
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/mds-accordion-timer.entry.js +1 -1
- package/dist/esm-es5/mds-accordion-timer.js +1 -1
- package/dist/mds-accordion-timer/mds-accordion-timer.esm.js +1 -1
- package/dist/mds-accordion-timer/mds-accordion-timer.js +2 -1
- package/dist/mds-accordion-timer/{p-6384c515.system.entry.js → p-30c950ab.system.entry.js} +1 -1
- package/{www/build/p-4f6d2878.entry.js → dist/mds-accordion-timer/p-9784c024.entry.js} +1 -1
- package/dist/mds-accordion-timer/{p-b55643bd.system.js → p-a617eaf9.system.js} +1 -1
- package/dist/mds-accordion-timer/p-d5616601.js +2 -0
- package/dist/mds-accordion-timer/p-e2fa938f.system.js +2 -0
- package/dist/stats.json +31 -29
- package/dist/types/common/aria.d.ts +4 -0
- package/dist/types/stencil-public-runtime.d.ts +15 -4
- package/loader/package.json +1 -0
- package/package.json +6 -5
- package/src/common/aria.ts +27 -0
- package/src/components/mds-accordion-timer/.gitlab-ci.yml +2 -2
- package/src/components/mds-accordion-timer/mds-accordion-timer.tsx +1 -1
- package/www/build/mds-accordion-timer.esm.js +1 -1
- package/www/build/mds-accordion-timer.js +2 -1
- package/www/build/{p-6384c515.system.entry.js → p-30c950ab.system.entry.js} +1 -1
- package/{dist/mds-accordion-timer/p-4f6d2878.entry.js → www/build/p-9784c024.entry.js} +1 -1
- package/www/build/{p-b55643bd.system.js → p-a617eaf9.system.js} +1 -1
- package/www/build/p-d5616601.js +2 -0
- package/www/build/p-e2fa938f.system.js +2 -0
- package/dist/esm-es5/index-131803de.js +0 -2
- package/dist/mds-accordion-timer/p-65dca5f5.system.js +0 -2
- package/dist/mds-accordion-timer/p-9bd89dcd.js +0 -2
- package/www/build/p-65dca5f5.system.js +0 -2
- package/www/build/p-9bd89dcd.js +0 -2
|
@@ -1,59 +1,16 @@
|
|
|
1
1
|
const NAMESPACE = 'mds-accordion-timer';
|
|
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 hostTagName;
|
|
5
13
|
let queuePending = false;
|
|
6
|
-
const win = typeof window !== 'undefined' ? window : {};
|
|
7
|
-
const doc = win.document || { head: {} };
|
|
8
|
-
const plt = {
|
|
9
|
-
$flags$: 0,
|
|
10
|
-
$resourcesUrl$: '',
|
|
11
|
-
jmp: (h) => h(),
|
|
12
|
-
raf: (h) => requestAnimationFrame(h),
|
|
13
|
-
ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
|
|
14
|
-
rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
|
|
15
|
-
ce: (eventName, opts) => new CustomEvent(eventName, opts),
|
|
16
|
-
};
|
|
17
|
-
const promiseResolve = (v) => Promise.resolve(v);
|
|
18
|
-
const supportsConstructibleStylesheets = /*@__PURE__*/ (() => {
|
|
19
|
-
try {
|
|
20
|
-
new CSSStyleSheet();
|
|
21
|
-
return typeof new CSSStyleSheet().replace === 'function';
|
|
22
|
-
}
|
|
23
|
-
catch (e) { }
|
|
24
|
-
return false;
|
|
25
|
-
})()
|
|
26
|
-
;
|
|
27
|
-
const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
|
|
28
|
-
if (listeners) {
|
|
29
|
-
listeners.map(([flags, name, method]) => {
|
|
30
|
-
const target = elm;
|
|
31
|
-
const handler = hostListenerProxy(hostRef, method);
|
|
32
|
-
const opts = hostListenerOpts(flags);
|
|
33
|
-
plt.ael(target, name, handler, opts);
|
|
34
|
-
(hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
const hostListenerProxy = (hostRef, methodName) => (ev) => {
|
|
39
|
-
try {
|
|
40
|
-
{
|
|
41
|
-
if (hostRef.$flags$ & 256 /* isListenReady */) {
|
|
42
|
-
// instance is ready, let's call it's member method for this event
|
|
43
|
-
hostRef.$lazyInstance$[methodName](ev);
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
(hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
catch (e) {
|
|
51
|
-
consoleError(e);
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
// prettier-ignore
|
|
55
|
-
const hostListenerOpts = (flags) => (flags & 2 /* Capture */) !== 0;
|
|
56
|
-
const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
|
|
57
14
|
const createTime = (fnName, tagName = '') => {
|
|
58
15
|
{
|
|
59
16
|
return () => {
|
|
@@ -68,71 +25,7 @@ const uniqueTime = (key, measureText) => {
|
|
|
68
25
|
};
|
|
69
26
|
}
|
|
70
27
|
};
|
|
71
|
-
const
|
|
72
|
-
const registerStyle = (scopeId, cssText, allowCS) => {
|
|
73
|
-
let style = styles.get(scopeId);
|
|
74
|
-
if (supportsConstructibleStylesheets && allowCS) {
|
|
75
|
-
style = (style || new CSSStyleSheet());
|
|
76
|
-
style.replace(cssText);
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
style = cssText;
|
|
80
|
-
}
|
|
81
|
-
styles.set(scopeId, style);
|
|
82
|
-
};
|
|
83
|
-
const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
|
|
84
|
-
let scopeId = getScopeId(cmpMeta);
|
|
85
|
-
const style = styles.get(scopeId);
|
|
86
|
-
// if an element is NOT connected then getRootNode() will return the wrong root node
|
|
87
|
-
// so the fallback is to always use the document for the root node in those cases
|
|
88
|
-
styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
|
|
89
|
-
if (style) {
|
|
90
|
-
if (typeof style === 'string') {
|
|
91
|
-
styleContainerNode = styleContainerNode.head || styleContainerNode;
|
|
92
|
-
let appliedStyles = rootAppliedStyles.get(styleContainerNode);
|
|
93
|
-
let styleElm;
|
|
94
|
-
if (!appliedStyles) {
|
|
95
|
-
rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
|
|
96
|
-
}
|
|
97
|
-
if (!appliedStyles.has(scopeId)) {
|
|
98
|
-
{
|
|
99
|
-
{
|
|
100
|
-
styleElm = doc.createElement('style');
|
|
101
|
-
styleElm.innerHTML = style;
|
|
102
|
-
}
|
|
103
|
-
styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
|
|
104
|
-
}
|
|
105
|
-
if (appliedStyles) {
|
|
106
|
-
appliedStyles.add(scopeId);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
|
|
111
|
-
styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
return scopeId;
|
|
115
|
-
};
|
|
116
|
-
const attachStyles = (hostRef) => {
|
|
117
|
-
const cmpMeta = hostRef.$cmpMeta$;
|
|
118
|
-
const elm = hostRef.$hostElement$;
|
|
119
|
-
const flags = cmpMeta.$flags$;
|
|
120
|
-
const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
|
|
121
|
-
const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
|
|
122
|
-
if (flags & 10 /* needsScopedEncapsulation */) {
|
|
123
|
-
// only required when we're NOT using native shadow dom (slot)
|
|
124
|
-
// or this browser doesn't support native shadow dom
|
|
125
|
-
// and this host element was NOT created with SSR
|
|
126
|
-
// let's pick out the inner content for slot projection
|
|
127
|
-
// create a node to represent where the original
|
|
128
|
-
// content was first placed, which is useful later on
|
|
129
|
-
// DOM WRITE!!
|
|
130
|
-
elm['s-sc'] = scopeId;
|
|
131
|
-
elm.classList.add(scopeId + '-h');
|
|
132
|
-
}
|
|
133
|
-
endAttachStyles();
|
|
134
|
-
};
|
|
135
|
-
const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
|
|
28
|
+
const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
|
|
136
29
|
const isDef = (v) => v != null;
|
|
137
30
|
const isComplexType = (o) => {
|
|
138
31
|
// https://jsperf.com/typeof-fn-object/5
|
|
@@ -197,6 +90,149 @@ const newVNode = (tag, text) => {
|
|
|
197
90
|
};
|
|
198
91
|
const Host = {};
|
|
199
92
|
const isHost = (node) => node && node.$tag$ === Host;
|
|
93
|
+
/**
|
|
94
|
+
* Parse a new property value for a given property type.
|
|
95
|
+
*
|
|
96
|
+
* While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
|
|
97
|
+
* it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
|
|
98
|
+
* 1. `any`, the type given to `propValue` in the function signature
|
|
99
|
+
* 2. the type stored from `propType`.
|
|
100
|
+
*
|
|
101
|
+
* This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
|
|
102
|
+
*
|
|
103
|
+
* Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
|
|
104
|
+
* a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
|
|
105
|
+
* based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
|
|
106
|
+
* ```tsx
|
|
107
|
+
* <my-cmp prop-val={0}></my-cmp>
|
|
108
|
+
* ```
|
|
109
|
+
*
|
|
110
|
+
* HTML prop values on the other hand, will always a string
|
|
111
|
+
*
|
|
112
|
+
* @param propValue the new value to coerce to some type
|
|
113
|
+
* @param propType the type of the prop, expressed as a binary number
|
|
114
|
+
* @returns the parsed/coerced value
|
|
115
|
+
*/
|
|
116
|
+
const parsePropertyValue = (propValue, propType) => {
|
|
117
|
+
// ensure this value is of the correct prop type
|
|
118
|
+
if (propValue != null && !isComplexType(propValue)) {
|
|
119
|
+
if (propType & 2 /* MEMBER_FLAGS.Number */) {
|
|
120
|
+
// force it to be a number
|
|
121
|
+
return parseFloat(propValue);
|
|
122
|
+
}
|
|
123
|
+
// redundant return here for better minification
|
|
124
|
+
return propValue;
|
|
125
|
+
}
|
|
126
|
+
// not sure exactly what type we want
|
|
127
|
+
// so no need to change to a different type
|
|
128
|
+
return propValue;
|
|
129
|
+
};
|
|
130
|
+
const getElement = (ref) => (getHostRef(ref).$hostElement$ );
|
|
131
|
+
const createEvent = (ref, name, flags) => {
|
|
132
|
+
const elm = getElement(ref);
|
|
133
|
+
return {
|
|
134
|
+
emit: (detail) => {
|
|
135
|
+
return emitEvent(elm, name, {
|
|
136
|
+
bubbles: !!(flags & 4 /* EVENT_FLAGS.Bubbles */),
|
|
137
|
+
composed: !!(flags & 2 /* EVENT_FLAGS.Composed */),
|
|
138
|
+
cancelable: !!(flags & 1 /* EVENT_FLAGS.Cancellable */),
|
|
139
|
+
detail,
|
|
140
|
+
});
|
|
141
|
+
},
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* Helper function to create & dispatch a custom Event on a provided target
|
|
146
|
+
* @param elm the target of the Event
|
|
147
|
+
* @param name the name to give the custom Event
|
|
148
|
+
* @param opts options for configuring a custom Event
|
|
149
|
+
* @returns the custom Event
|
|
150
|
+
*/
|
|
151
|
+
const emitEvent = (elm, name, opts) => {
|
|
152
|
+
const ev = plt.ce(name, opts);
|
|
153
|
+
elm.dispatchEvent(ev);
|
|
154
|
+
return ev;
|
|
155
|
+
};
|
|
156
|
+
const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
|
|
157
|
+
const registerStyle = (scopeId, cssText, allowCS) => {
|
|
158
|
+
let style = styles.get(scopeId);
|
|
159
|
+
if (supportsConstructableStylesheets && allowCS) {
|
|
160
|
+
style = (style || new CSSStyleSheet());
|
|
161
|
+
if (typeof style === 'string') {
|
|
162
|
+
style = cssText;
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
style.replaceSync(cssText);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
style = cssText;
|
|
170
|
+
}
|
|
171
|
+
styles.set(scopeId, style);
|
|
172
|
+
};
|
|
173
|
+
const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
|
|
174
|
+
let scopeId = getScopeId(cmpMeta);
|
|
175
|
+
const style = styles.get(scopeId);
|
|
176
|
+
// if an element is NOT connected then getRootNode() will return the wrong root node
|
|
177
|
+
// so the fallback is to always use the document for the root node in those cases
|
|
178
|
+
styleContainerNode = styleContainerNode.nodeType === 11 /* NODE_TYPE.DocumentFragment */ ? styleContainerNode : doc;
|
|
179
|
+
if (style) {
|
|
180
|
+
if (typeof style === 'string') {
|
|
181
|
+
styleContainerNode = styleContainerNode.head || styleContainerNode;
|
|
182
|
+
let appliedStyles = rootAppliedStyles.get(styleContainerNode);
|
|
183
|
+
let styleElm;
|
|
184
|
+
if (!appliedStyles) {
|
|
185
|
+
rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
|
|
186
|
+
}
|
|
187
|
+
if (!appliedStyles.has(scopeId)) {
|
|
188
|
+
{
|
|
189
|
+
{
|
|
190
|
+
styleElm = doc.createElement('style');
|
|
191
|
+
styleElm.innerHTML = style;
|
|
192
|
+
}
|
|
193
|
+
styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
|
|
194
|
+
}
|
|
195
|
+
if (appliedStyles) {
|
|
196
|
+
appliedStyles.add(scopeId);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
|
|
201
|
+
styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return scopeId;
|
|
205
|
+
};
|
|
206
|
+
const attachStyles = (hostRef) => {
|
|
207
|
+
const cmpMeta = hostRef.$cmpMeta$;
|
|
208
|
+
const elm = hostRef.$hostElement$;
|
|
209
|
+
const flags = cmpMeta.$flags$;
|
|
210
|
+
const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
|
|
211
|
+
const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
|
|
212
|
+
if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
|
|
213
|
+
// only required when we're NOT using native shadow dom (slot)
|
|
214
|
+
// or this browser doesn't support native shadow dom
|
|
215
|
+
// and this host element was NOT created with SSR
|
|
216
|
+
// let's pick out the inner content for slot projection
|
|
217
|
+
// create a node to represent where the original
|
|
218
|
+
// content was first placed, which is useful later on
|
|
219
|
+
// DOM WRITE!!
|
|
220
|
+
elm['s-sc'] = scopeId;
|
|
221
|
+
elm.classList.add(scopeId + '-h');
|
|
222
|
+
}
|
|
223
|
+
endAttachStyles();
|
|
224
|
+
};
|
|
225
|
+
const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
|
|
226
|
+
/**
|
|
227
|
+
* Create a DOM Node corresponding to one of the children of a given VNode.
|
|
228
|
+
*
|
|
229
|
+
* @param oldParentVNode the parent VNode from the previous render
|
|
230
|
+
* @param newParentVNode the parent VNode from the current render
|
|
231
|
+
* @param childIndex the index of the VNode, in the _new_ parent node's
|
|
232
|
+
* children, for which we will create a new DOM node
|
|
233
|
+
* @param parentElm the parent DOM node which our new node will be a child of
|
|
234
|
+
* @returns the newly created node
|
|
235
|
+
*/
|
|
200
236
|
const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
201
237
|
// tslint:disable-next-line: prefer-const
|
|
202
238
|
const newVNode = newParentVNode.$children$[childIndex];
|
|
@@ -250,6 +286,74 @@ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
|
|
|
250
286
|
}
|
|
251
287
|
}
|
|
252
288
|
};
|
|
289
|
+
/**
|
|
290
|
+
* Reconcile the children of a new VNode with the children of an old VNode by
|
|
291
|
+
* traversing the two collections of children, identifying nodes that are
|
|
292
|
+
* conserved or changed, calling out to `patch` to make any necessary
|
|
293
|
+
* updates to the DOM, and rearranging DOM nodes as needed.
|
|
294
|
+
*
|
|
295
|
+
* The algorithm for reconciling children works by analyzing two 'windows' onto
|
|
296
|
+
* the two arrays of children (`oldCh` and `newCh`). We keep track of the
|
|
297
|
+
* 'windows' by storing start and end indices and references to the
|
|
298
|
+
* corresponding array entries. Initially the two 'windows' are basically equal
|
|
299
|
+
* to the entire array, but we progressively narrow the windows until there are
|
|
300
|
+
* no children left to update by doing the following:
|
|
301
|
+
*
|
|
302
|
+
* 1. Skip any `null` entries at the beginning or end of the two arrays, so
|
|
303
|
+
* that if we have an initial array like the following we'll end up dealing
|
|
304
|
+
* only with a window bounded by the highlighted elements:
|
|
305
|
+
*
|
|
306
|
+
* [null, null, VNode1 , ... , VNode2, null, null]
|
|
307
|
+
* ^^^^^^ ^^^^^^
|
|
308
|
+
*
|
|
309
|
+
* 2. Check to see if the elements at the head and tail positions are equal
|
|
310
|
+
* across the windows. This will basically detect elements which haven't
|
|
311
|
+
* been added, removed, or changed position, i.e. if you had the following
|
|
312
|
+
* VNode elements (represented as HTML):
|
|
313
|
+
*
|
|
314
|
+
* oldVNode: `<div><p><span>HEY</span></p></div>`
|
|
315
|
+
* newVNode: `<div><p><span>THERE</span></p></div>`
|
|
316
|
+
*
|
|
317
|
+
* Then when comparing the children of the `<div>` tag we check the equality
|
|
318
|
+
* of the VNodes corresponding to the `<p>` tags and, since they are the
|
|
319
|
+
* same tag in the same position, we'd be able to avoid completely
|
|
320
|
+
* re-rendering the subtree under them with a new DOM element and would just
|
|
321
|
+
* call out to `patch` to handle reconciling their children and so on.
|
|
322
|
+
*
|
|
323
|
+
* 3. Check, for both windows, to see if the element at the beginning of the
|
|
324
|
+
* window corresponds to the element at the end of the other window. This is
|
|
325
|
+
* a heuristic which will let us identify _some_ situations in which
|
|
326
|
+
* elements have changed position, for instance it _should_ detect that the
|
|
327
|
+
* children nodes themselves have not changed but merely moved in the
|
|
328
|
+
* following example:
|
|
329
|
+
*
|
|
330
|
+
* oldVNode: `<div><element-one /><element-two /></div>`
|
|
331
|
+
* newVNode: `<div><element-two /><element-one /></div>`
|
|
332
|
+
*
|
|
333
|
+
* If we find cases like this then we also need to move the concrete DOM
|
|
334
|
+
* elements corresponding to the moved children to write the re-order to the
|
|
335
|
+
* DOM.
|
|
336
|
+
*
|
|
337
|
+
* 4. Finally, if VNodes have the `key` attribute set on them we check for any
|
|
338
|
+
* nodes in the old children which have the same key as the first element in
|
|
339
|
+
* our window on the new children. If we find such a node we handle calling
|
|
340
|
+
* out to `patch`, moving relevant DOM nodes, and so on, in accordance with
|
|
341
|
+
* what we find.
|
|
342
|
+
*
|
|
343
|
+
* Finally, once we've narrowed our 'windows' to the point that either of them
|
|
344
|
+
* collapse (i.e. they have length 0) we then handle any remaining VNode
|
|
345
|
+
* insertion or deletion that needs to happen to get a DOM state that correctly
|
|
346
|
+
* reflects the new child VNodes. If, for instance, after our window on the old
|
|
347
|
+
* children has collapsed we still have more nodes on the new children that
|
|
348
|
+
* we haven't dealt with yet then we need to add them, or if the new children
|
|
349
|
+
* collapse but we still have unhandled _old_ children then we need to make
|
|
350
|
+
* sure the corresponding DOM nodes are removed.
|
|
351
|
+
*
|
|
352
|
+
* @param parentElm the node into which the parent VNode is rendered
|
|
353
|
+
* @param oldCh the old children of the parent node
|
|
354
|
+
* @param newVNode the new VNode which will replace the parent
|
|
355
|
+
* @param newCh the new children of the parent node
|
|
356
|
+
*/
|
|
253
357
|
const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
254
358
|
let oldStartIdx = 0;
|
|
255
359
|
let newStartIdx = 0;
|
|
@@ -262,7 +366,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
262
366
|
let node;
|
|
263
367
|
while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
|
|
264
368
|
if (oldStartVnode == null) {
|
|
265
|
-
//
|
|
369
|
+
// VNode might have been moved left
|
|
266
370
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
267
371
|
}
|
|
268
372
|
else if (oldEndVnode == null) {
|
|
@@ -275,34 +379,67 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
275
379
|
newEndVnode = newCh[--newEndIdx];
|
|
276
380
|
}
|
|
277
381
|
else if (isSameVnode(oldStartVnode, newStartVnode)) {
|
|
382
|
+
// if the start nodes are the same then we should patch the new VNode
|
|
383
|
+
// onto the old one, and increment our `newStartIdx` and `oldStartIdx`
|
|
384
|
+
// indices to reflect that. We don't need to move any DOM Nodes around
|
|
385
|
+
// since things are matched up in order.
|
|
278
386
|
patch(oldStartVnode, newStartVnode);
|
|
279
387
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
280
388
|
newStartVnode = newCh[++newStartIdx];
|
|
281
389
|
}
|
|
282
390
|
else if (isSameVnode(oldEndVnode, newEndVnode)) {
|
|
391
|
+
// likewise, if the end nodes are the same we patch new onto old and
|
|
392
|
+
// decrement our end indices, and also likewise in this case we don't
|
|
393
|
+
// need to move any DOM Nodes.
|
|
283
394
|
patch(oldEndVnode, newEndVnode);
|
|
284
395
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
285
396
|
newEndVnode = newCh[--newEndIdx];
|
|
286
397
|
}
|
|
287
398
|
else if (isSameVnode(oldStartVnode, newEndVnode)) {
|
|
288
399
|
patch(oldStartVnode, newEndVnode);
|
|
400
|
+
// We need to move the element for `oldStartVnode` into a position which
|
|
401
|
+
// will be appropriate for `newEndVnode`. For this we can use
|
|
402
|
+
// `.insertBefore` and `oldEndVnode.$elm$.nextSibling`. If there is a
|
|
403
|
+
// sibling for `oldEndVnode.$elm$` then we want to move the DOM node for
|
|
404
|
+
// `oldStartVnode` between `oldEndVnode` and it's sibling, like so:
|
|
405
|
+
//
|
|
406
|
+
// <old-start-node />
|
|
407
|
+
// <some-intervening-node />
|
|
408
|
+
// <old-end-node />
|
|
409
|
+
// <!-- -> <-- `oldStartVnode.$elm$` should be inserted here
|
|
410
|
+
// <next-sibling />
|
|
411
|
+
//
|
|
412
|
+
// If instead `oldEndVnode.$elm$` has no sibling then we just want to put
|
|
413
|
+
// the node for `oldStartVnode` at the end of the children of
|
|
414
|
+
// `parentElm`. Luckily, `Node.nextSibling` will return `null` if there
|
|
415
|
+
// aren't any siblings, and passing `null` to `Node.insertBefore` will
|
|
416
|
+
// append it to the children of the parent element.
|
|
289
417
|
parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
|
|
290
418
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
291
419
|
newEndVnode = newCh[--newEndIdx];
|
|
292
420
|
}
|
|
293
421
|
else if (isSameVnode(oldEndVnode, newStartVnode)) {
|
|
294
422
|
patch(oldEndVnode, newStartVnode);
|
|
423
|
+
// We've already checked above if `oldStartVnode` and `newStartVnode` are
|
|
424
|
+
// the same node, so since we're here we know that they are not. Thus we
|
|
425
|
+
// can move the element for `oldEndVnode` _before_ the element for
|
|
426
|
+
// `oldStartVnode`, leaving `oldStartVnode` to be reconciled in the
|
|
427
|
+
// future.
|
|
295
428
|
parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
|
|
296
429
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
297
430
|
newStartVnode = newCh[++newStartIdx];
|
|
298
431
|
}
|
|
299
432
|
else {
|
|
300
433
|
{
|
|
301
|
-
//
|
|
434
|
+
// We either didn't find an element in the old children that matches
|
|
435
|
+
// the key of the first new child OR the build is not using `key`
|
|
436
|
+
// attributes at all. In either case we need to create a new element
|
|
437
|
+
// for the new node.
|
|
302
438
|
node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
|
|
303
439
|
newStartVnode = newCh[++newStartIdx];
|
|
304
440
|
}
|
|
305
441
|
if (node) {
|
|
442
|
+
// if we created a new node then handle inserting it to the DOM
|
|
306
443
|
{
|
|
307
444
|
oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
|
|
308
445
|
}
|
|
@@ -310,20 +447,49 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
310
447
|
}
|
|
311
448
|
}
|
|
312
449
|
if (oldStartIdx > oldEndIdx) {
|
|
450
|
+
// we have some more new nodes to add which don't match up with old nodes
|
|
313
451
|
addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
|
|
314
452
|
}
|
|
315
453
|
else if (newStartIdx > newEndIdx) {
|
|
454
|
+
// there are nodes in the `oldCh` array which no longer correspond to nodes
|
|
455
|
+
// in the new array, so lets remove them (which entails cleaning up the
|
|
456
|
+
// relevant DOM nodes)
|
|
316
457
|
removeVnodes(oldCh, oldStartIdx, oldEndIdx);
|
|
317
458
|
}
|
|
318
459
|
};
|
|
319
|
-
|
|
460
|
+
/**
|
|
461
|
+
* Compare two VNodes to determine if they are the same
|
|
462
|
+
*
|
|
463
|
+
* **NB**: This function is an equality _heuristic_ based on the available
|
|
464
|
+
* information set on the two VNodes and can be misleading under certain
|
|
465
|
+
* circumstances. In particular, if the two nodes do not have `key` attrs
|
|
466
|
+
* (available under `$key$` on VNodes) then the function falls back on merely
|
|
467
|
+
* checking that they have the same tag.
|
|
468
|
+
*
|
|
469
|
+
* So, in other words, if `key` attrs are not set on VNodes which may be
|
|
470
|
+
* changing order within a `children` array or something along those lines then
|
|
471
|
+
* we could obtain a false positive and then have to do needless re-rendering.
|
|
472
|
+
*
|
|
473
|
+
* @param leftVNode the first VNode to check
|
|
474
|
+
* @param rightVNode the second VNode to check
|
|
475
|
+
* @returns whether they're equal or not
|
|
476
|
+
*/
|
|
477
|
+
const isSameVnode = (leftVNode, rightVNode) => {
|
|
320
478
|
// compare if two vnode to see if they're "technically" the same
|
|
321
479
|
// need to have the same element tag, and same key to be the same
|
|
322
|
-
if (
|
|
480
|
+
if (leftVNode.$tag$ === rightVNode.$tag$) {
|
|
323
481
|
return true;
|
|
324
482
|
}
|
|
325
483
|
return false;
|
|
326
484
|
};
|
|
485
|
+
/**
|
|
486
|
+
* Handle reconciling an outdated VNode with a new one which corresponds to
|
|
487
|
+
* it. This function handles flushing updates to the DOM and reconciling the
|
|
488
|
+
* children of the two nodes (if any).
|
|
489
|
+
*
|
|
490
|
+
* @param oldVNode an old VNode whose DOM element and children we want to update
|
|
491
|
+
* @param newVNode a new VNode representing an updated version of the old one
|
|
492
|
+
*/
|
|
327
493
|
const patch = (oldVNode, newVNode) => {
|
|
328
494
|
const elm = (newVNode.$elm$ = oldVNode.$elm$);
|
|
329
495
|
const oldChildren = oldVNode.$children$;
|
|
@@ -331,6 +497,7 @@ const patch = (oldVNode, newVNode) => {
|
|
|
331
497
|
{
|
|
332
498
|
if (oldChildren !== null && newChildren !== null) {
|
|
333
499
|
// looks like there's child vnodes for both the old and new vnodes
|
|
500
|
+
// so we need to call `updateChildren` to reconcile them
|
|
334
501
|
updateChildren(elm, oldChildren, newVNode, newChildren);
|
|
335
502
|
}
|
|
336
503
|
else if (newChildren !== null) {
|
|
@@ -349,7 +516,7 @@ const renderVdom = (hostRef, renderFnResults) => {
|
|
|
349
516
|
const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
|
|
350
517
|
hostTagName = hostElm.tagName;
|
|
351
518
|
rootVnode.$tag$ = null;
|
|
352
|
-
rootVnode.$flags$ |= 4 /* isHost */;
|
|
519
|
+
rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
|
|
353
520
|
hostRef.$vnode$ = rootVnode;
|
|
354
521
|
rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
|
|
355
522
|
{
|
|
@@ -358,32 +525,6 @@ const renderVdom = (hostRef, renderFnResults) => {
|
|
|
358
525
|
// synchronous patch
|
|
359
526
|
patch(oldVNode, rootVnode);
|
|
360
527
|
};
|
|
361
|
-
const getElement = (ref) => (getHostRef(ref).$hostElement$ );
|
|
362
|
-
const createEvent = (ref, name, flags) => {
|
|
363
|
-
const elm = getElement(ref);
|
|
364
|
-
return {
|
|
365
|
-
emit: (detail) => {
|
|
366
|
-
return emitEvent(elm, name, {
|
|
367
|
-
bubbles: !!(flags & 4 /* Bubbles */),
|
|
368
|
-
composed: !!(flags & 2 /* Composed */),
|
|
369
|
-
cancelable: !!(flags & 1 /* Cancellable */),
|
|
370
|
-
detail,
|
|
371
|
-
});
|
|
372
|
-
},
|
|
373
|
-
};
|
|
374
|
-
};
|
|
375
|
-
/**
|
|
376
|
-
* Helper function to create & dispatch a custom Event on a provided target
|
|
377
|
-
* @param elm the target of the Event
|
|
378
|
-
* @param name the name to give the custom Event
|
|
379
|
-
* @param opts options for configuring a custom Event
|
|
380
|
-
* @returns the custom Event
|
|
381
|
-
*/
|
|
382
|
-
const emitEvent = (elm, name, opts) => {
|
|
383
|
-
const ev = plt.ce(name, opts);
|
|
384
|
-
elm.dispatchEvent(ev);
|
|
385
|
-
return ev;
|
|
386
|
-
};
|
|
387
528
|
const attachToAncestor = (hostRef, ancestorComponent) => {
|
|
388
529
|
if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
|
|
389
530
|
ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
|
|
@@ -391,10 +532,10 @@ const attachToAncestor = (hostRef, ancestorComponent) => {
|
|
|
391
532
|
};
|
|
392
533
|
const scheduleUpdate = (hostRef, isInitialLoad) => {
|
|
393
534
|
{
|
|
394
|
-
hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
|
|
535
|
+
hostRef.$flags$ |= 16 /* HOST_FLAGS.isQueuedForUpdate */;
|
|
395
536
|
}
|
|
396
|
-
if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
|
|
397
|
-
hostRef.$flags$ |= 512 /* needsRerender */;
|
|
537
|
+
if (hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
|
|
538
|
+
hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
|
|
398
539
|
return;
|
|
399
540
|
}
|
|
400
541
|
attachToAncestor(hostRef, hostRef.$ancestorComponent$);
|
|
@@ -410,7 +551,7 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
|
|
|
410
551
|
let promise;
|
|
411
552
|
if (isInitialLoad) {
|
|
412
553
|
{
|
|
413
|
-
hostRef.$flags$ |= 256 /* isListenReady */;
|
|
554
|
+
hostRef.$flags$ |= 256 /* HOST_FLAGS.isListenReady */;
|
|
414
555
|
if (hostRef.$queuedListeners$) {
|
|
415
556
|
hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
|
|
416
557
|
hostRef.$queuedListeners$ = null;
|
|
@@ -450,7 +591,7 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
|
|
|
450
591
|
}
|
|
451
592
|
else {
|
|
452
593
|
Promise.all(childrenPromises).then(postUpdate);
|
|
453
|
-
hostRef.$flags$ |= 4 /* isWaitingForChildren */;
|
|
594
|
+
hostRef.$flags$ |= 4 /* HOST_FLAGS.isWaitingForChildren */;
|
|
454
595
|
childrenPromises.length = 0;
|
|
455
596
|
}
|
|
456
597
|
}
|
|
@@ -459,10 +600,10 @@ const callRender = (hostRef, instance, elm) => {
|
|
|
459
600
|
try {
|
|
460
601
|
instance = instance.render() ;
|
|
461
602
|
{
|
|
462
|
-
hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
|
|
603
|
+
hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
|
|
463
604
|
}
|
|
464
605
|
{
|
|
465
|
-
hostRef.$flags$ |= 2 /* hasRendered */;
|
|
606
|
+
hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
|
|
466
607
|
}
|
|
467
608
|
{
|
|
468
609
|
{
|
|
@@ -486,8 +627,8 @@ const postUpdateComponent = (hostRef) => {
|
|
|
486
627
|
const endPostUpdate = createTime('postUpdate', tagName);
|
|
487
628
|
const instance = hostRef.$lazyInstance$ ;
|
|
488
629
|
const ancestorComponent = hostRef.$ancestorComponent$;
|
|
489
|
-
if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
|
|
490
|
-
hostRef.$flags$ |= 64 /* hasLoadedComponent */;
|
|
630
|
+
if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
|
|
631
|
+
hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
|
|
491
632
|
{
|
|
492
633
|
// DOM WRITE!
|
|
493
634
|
addHydratedFlag(elm);
|
|
@@ -513,10 +654,10 @@ const postUpdateComponent = (hostRef) => {
|
|
|
513
654
|
hostRef.$onRenderResolve$();
|
|
514
655
|
hostRef.$onRenderResolve$ = undefined;
|
|
515
656
|
}
|
|
516
|
-
if (hostRef.$flags$ & 512 /* needsRerender */) {
|
|
657
|
+
if (hostRef.$flags$ & 512 /* HOST_FLAGS.needsRerender */) {
|
|
517
658
|
nextTick(() => scheduleUpdate(hostRef, false));
|
|
518
659
|
}
|
|
519
|
-
hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
|
|
660
|
+
hostRef.$flags$ &= ~(4 /* HOST_FLAGS.isWaitingForChildren */ | 512 /* HOST_FLAGS.needsRerender */);
|
|
520
661
|
}
|
|
521
662
|
// ( •_•)
|
|
522
663
|
// ( •_•)>⌐■-■
|
|
@@ -546,43 +687,6 @@ const then = (promise, thenFn) => {
|
|
|
546
687
|
};
|
|
547
688
|
const addHydratedFlag = (elm) => elm.classList.add('hydrated')
|
|
548
689
|
;
|
|
549
|
-
/**
|
|
550
|
-
* Parse a new property value for a given property type.
|
|
551
|
-
*
|
|
552
|
-
* While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
|
|
553
|
-
* it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
|
|
554
|
-
* 1. `any`, the type given to `propValue` in the function signature
|
|
555
|
-
* 2. the type stored from `propType`.
|
|
556
|
-
*
|
|
557
|
-
* This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
|
|
558
|
-
*
|
|
559
|
-
* Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
|
|
560
|
-
* a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
|
|
561
|
-
* based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
|
|
562
|
-
* ```tsx
|
|
563
|
-
* <my-cmp prop-val={0}></my-cmp>
|
|
564
|
-
* ```
|
|
565
|
-
*
|
|
566
|
-
* HTML prop values on the other hand, will always a string
|
|
567
|
-
*
|
|
568
|
-
* @param propValue the new value to coerce to some type
|
|
569
|
-
* @param propType the type of the prop, expressed as a binary number
|
|
570
|
-
* @returns the parsed/coerced value
|
|
571
|
-
*/
|
|
572
|
-
const parsePropertyValue = (propValue, propType) => {
|
|
573
|
-
// ensure this value is of the correct prop type
|
|
574
|
-
if (propValue != null && !isComplexType(propValue)) {
|
|
575
|
-
if (propType & 2 /* Number */) {
|
|
576
|
-
// force it to be a number
|
|
577
|
-
return parseFloat(propValue);
|
|
578
|
-
}
|
|
579
|
-
// redundant return here for better minification
|
|
580
|
-
return propValue;
|
|
581
|
-
}
|
|
582
|
-
// not sure exactly what type we want
|
|
583
|
-
// so no need to change to a different type
|
|
584
|
-
return propValue;
|
|
585
|
-
};
|
|
586
690
|
const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
|
|
587
691
|
const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
588
692
|
// check our new property value against our internal value
|
|
@@ -594,12 +698,12 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
594
698
|
// explicitly check for NaN on both sides, as `NaN === NaN` is always false
|
|
595
699
|
const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
|
|
596
700
|
const didValueChange = newVal !== oldVal && !areBothNaN;
|
|
597
|
-
if ((!(flags & 8 /* isConstructingInstance */) || oldVal === undefined) && didValueChange) {
|
|
701
|
+
if ((!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
|
|
598
702
|
// gadzooks! the property's value has changed!!
|
|
599
703
|
// set our new value!
|
|
600
704
|
hostRef.$instanceValues$.set(propName, newVal);
|
|
601
705
|
if (instance) {
|
|
602
|
-
if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
|
|
706
|
+
if ((flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
|
|
603
707
|
// looks like this value actually changed, so we've got work to do!
|
|
604
708
|
// but only if we've already rendered, otherwise just chill out
|
|
605
709
|
// queue that we need to do an update, but don't worry about queuing
|
|
@@ -609,14 +713,24 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
609
713
|
}
|
|
610
714
|
}
|
|
611
715
|
};
|
|
716
|
+
/**
|
|
717
|
+
* Attach a series of runtime constructs to a compiled Stencil component
|
|
718
|
+
* constructor, including getters and setters for the `@Prop` and `@State`
|
|
719
|
+
* decorators, callbacks for when attributes change, and so on.
|
|
720
|
+
*
|
|
721
|
+
* @param Cstr the constructor for a component that we need to process
|
|
722
|
+
* @param cmpMeta metadata collected previously about the component
|
|
723
|
+
* @param flags a number used to store a series of bit flags
|
|
724
|
+
* @returns a reference to the same constructor passed in (but now mutated)
|
|
725
|
+
*/
|
|
612
726
|
const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
613
727
|
if (cmpMeta.$members$) {
|
|
614
728
|
// It's better to have a const than two Object.entries()
|
|
615
729
|
const members = Object.entries(cmpMeta.$members$);
|
|
616
730
|
const prototype = Cstr.prototype;
|
|
617
731
|
members.map(([memberName, [memberFlags]]) => {
|
|
618
|
-
if ((memberFlags & 31 /* Prop */ ||
|
|
619
|
-
((flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
|
|
732
|
+
if ((memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
|
|
733
|
+
((flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
|
|
620
734
|
// proxyComponent - prop
|
|
621
735
|
Object.defineProperty(prototype, memberName, {
|
|
622
736
|
get() {
|
|
@@ -632,7 +746,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
632
746
|
});
|
|
633
747
|
}
|
|
634
748
|
});
|
|
635
|
-
if ((flags & 1 /* isElementConstructor */)) {
|
|
749
|
+
if ((flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
|
|
636
750
|
const attrNameToPropName = new Map();
|
|
637
751
|
prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
|
|
638
752
|
plt.jmp(() => {
|
|
@@ -688,7 +802,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
688
802
|
// create an array of attributes to observe
|
|
689
803
|
// and also create a map of html attribute name to js property name
|
|
690
804
|
Cstr.observedAttributes = members
|
|
691
|
-
.filter(([_, m]) => m[0] & 15 /* HasAttribute */) // filter to only keep props that should match attributes
|
|
805
|
+
.filter(([_, m]) => m[0] & 15 /* MEMBER_FLAGS.HasAttribute */) // filter to only keep props that should match attributes
|
|
692
806
|
.map(([propName, m]) => {
|
|
693
807
|
const attrName = m[1] || propName;
|
|
694
808
|
attrNameToPropName.set(attrName, propName);
|
|
@@ -700,10 +814,10 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
700
814
|
};
|
|
701
815
|
const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
|
|
702
816
|
// initializeComponent
|
|
703
|
-
if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
|
|
817
|
+
if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
|
|
704
818
|
{
|
|
705
819
|
// we haven't initialized this element yet
|
|
706
|
-
hostRef.$flags$ |= 32 /* hasInitializedComponent */;
|
|
820
|
+
hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
|
|
707
821
|
// lazy loaded components
|
|
708
822
|
// request the component's implementation to be
|
|
709
823
|
// wired up with the host element
|
|
@@ -715,7 +829,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
715
829
|
endLoad();
|
|
716
830
|
}
|
|
717
831
|
if (!Cstr.isProxied) {
|
|
718
|
-
proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
|
|
832
|
+
proxyComponent(Cstr, cmpMeta, 2 /* PROXY_FLAGS.proxyState */);
|
|
719
833
|
Cstr.isProxied = true;
|
|
720
834
|
}
|
|
721
835
|
const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
|
|
@@ -723,7 +837,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
723
837
|
// but let's keep track of when we start and stop
|
|
724
838
|
// so that the getters/setters don't incorrectly step on data
|
|
725
839
|
{
|
|
726
|
-
hostRef.$flags$ |= 8 /* isConstructingInstance */;
|
|
840
|
+
hostRef.$flags$ |= 8 /* HOST_FLAGS.isConstructingInstance */;
|
|
727
841
|
}
|
|
728
842
|
// construct the lazy-loaded component implementation
|
|
729
843
|
// passing the hostRef is very important during
|
|
@@ -736,7 +850,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
736
850
|
consoleError(e);
|
|
737
851
|
}
|
|
738
852
|
{
|
|
739
|
-
hostRef.$flags$ &= ~8 /* isConstructingInstance */;
|
|
853
|
+
hostRef.$flags$ &= ~8 /* HOST_FLAGS.isConstructingInstance */;
|
|
740
854
|
}
|
|
741
855
|
endNewInstance();
|
|
742
856
|
fireConnectedCallback(hostRef.$lazyInstance$);
|
|
@@ -747,7 +861,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
747
861
|
const scopeId = getScopeId(cmpMeta);
|
|
748
862
|
if (!styles.has(scopeId)) {
|
|
749
863
|
const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
|
|
750
|
-
registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
|
|
864
|
+
registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
|
|
751
865
|
endRegisterStyles();
|
|
752
866
|
}
|
|
753
867
|
}
|
|
@@ -774,13 +888,13 @@ const fireConnectedCallback = (instance) => {
|
|
|
774
888
|
}
|
|
775
889
|
};
|
|
776
890
|
const connectedCallback = (elm) => {
|
|
777
|
-
if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
|
|
891
|
+
if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
|
|
778
892
|
const hostRef = getHostRef(elm);
|
|
779
893
|
const cmpMeta = hostRef.$cmpMeta$;
|
|
780
894
|
const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
|
|
781
|
-
if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
|
|
895
|
+
if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
|
|
782
896
|
// first time this component has connected
|
|
783
|
-
hostRef.$flags$ |= 1 /* hasConnected */;
|
|
897
|
+
hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
|
|
784
898
|
{
|
|
785
899
|
// find the first ancestor component (if there is one) and register
|
|
786
900
|
// this component as one of the actively loading child components for its ancestor
|
|
@@ -800,7 +914,7 @@ const connectedCallback = (elm) => {
|
|
|
800
914
|
// https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
|
|
801
915
|
if (cmpMeta.$members$) {
|
|
802
916
|
Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
|
|
803
|
-
if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
|
|
917
|
+
if (memberFlags & 31 /* MEMBER_FLAGS.Prop */ && elm.hasOwnProperty(memberName)) {
|
|
804
918
|
const value = elm[memberName];
|
|
805
919
|
delete elm[memberName];
|
|
806
920
|
elm[memberName] = value;
|
|
@@ -823,7 +937,7 @@ const connectedCallback = (elm) => {
|
|
|
823
937
|
}
|
|
824
938
|
};
|
|
825
939
|
const disconnectedCallback = (elm) => {
|
|
826
|
-
if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
|
|
940
|
+
if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
|
|
827
941
|
const hostRef = getHostRef(elm);
|
|
828
942
|
const instance = hostRef.$lazyInstance$ ;
|
|
829
943
|
{
|
|
@@ -872,7 +986,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
872
986
|
super(self);
|
|
873
987
|
self = this;
|
|
874
988
|
registerHost(self, cmpMeta);
|
|
875
|
-
if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
|
|
989
|
+
if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
|
|
876
990
|
// this component is using shadow dom
|
|
877
991
|
// and this browser supports shadow dom
|
|
878
992
|
// add the read-only property "shadowRoot" to the host element
|
|
@@ -907,7 +1021,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
907
1021
|
cmpMeta.$lazyBundleId$ = lazyBundle[0];
|
|
908
1022
|
if (!exclude.includes(tagName) && !customElements.get(tagName)) {
|
|
909
1023
|
cmpTags.push(tagName);
|
|
910
|
-
customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
|
|
1024
|
+
customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */));
|
|
911
1025
|
}
|
|
912
1026
|
});
|
|
913
1027
|
});
|
|
@@ -929,7 +1043,36 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
929
1043
|
// Fallback appLoad event
|
|
930
1044
|
endBootstrap();
|
|
931
1045
|
};
|
|
932
|
-
const
|
|
1046
|
+
const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
|
|
1047
|
+
if (listeners) {
|
|
1048
|
+
listeners.map(([flags, name, method]) => {
|
|
1049
|
+
const target = elm;
|
|
1050
|
+
const handler = hostListenerProxy(hostRef, method);
|
|
1051
|
+
const opts = hostListenerOpts(flags);
|
|
1052
|
+
plt.ael(target, name, handler, opts);
|
|
1053
|
+
(hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
|
|
1054
|
+
});
|
|
1055
|
+
}
|
|
1056
|
+
};
|
|
1057
|
+
const hostListenerProxy = (hostRef, methodName) => (ev) => {
|
|
1058
|
+
try {
|
|
1059
|
+
{
|
|
1060
|
+
if (hostRef.$flags$ & 256 /* HOST_FLAGS.isListenReady */) {
|
|
1061
|
+
// instance is ready, let's call it's member method for this event
|
|
1062
|
+
hostRef.$lazyInstance$[methodName](ev);
|
|
1063
|
+
}
|
|
1064
|
+
else {
|
|
1065
|
+
(hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1069
|
+
catch (e) {
|
|
1070
|
+
consoleError(e);
|
|
1071
|
+
}
|
|
1072
|
+
};
|
|
1073
|
+
// prettier-ignore
|
|
1074
|
+
const hostListenerOpts = (flags) => (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0;
|
|
1075
|
+
const hostRefs = /*@__PURE__*/ new WeakMap();
|
|
933
1076
|
const getHostRef = (ref) => hostRefs.get(ref);
|
|
934
1077
|
const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
|
|
935
1078
|
const registerHost = (elm, cmpMeta) => {
|
|
@@ -970,14 +1113,35 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
|
|
|
970
1113
|
return importedModule[exportName];
|
|
971
1114
|
}, consoleError);
|
|
972
1115
|
};
|
|
973
|
-
const styles = new Map();
|
|
1116
|
+
const styles = /*@__PURE__*/ new Map();
|
|
1117
|
+
const win = typeof window !== 'undefined' ? window : {};
|
|
1118
|
+
const doc = win.document || { head: {} };
|
|
1119
|
+
const plt = {
|
|
1120
|
+
$flags$: 0,
|
|
1121
|
+
$resourcesUrl$: '',
|
|
1122
|
+
jmp: (h) => h(),
|
|
1123
|
+
raf: (h) => requestAnimationFrame(h),
|
|
1124
|
+
ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
|
|
1125
|
+
rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
|
|
1126
|
+
ce: (eventName, opts) => new CustomEvent(eventName, opts),
|
|
1127
|
+
};
|
|
1128
|
+
const promiseResolve = (v) => Promise.resolve(v);
|
|
1129
|
+
const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
|
|
1130
|
+
try {
|
|
1131
|
+
new CSSStyleSheet();
|
|
1132
|
+
return typeof new CSSStyleSheet().replaceSync === 'function';
|
|
1133
|
+
}
|
|
1134
|
+
catch (e) { }
|
|
1135
|
+
return false;
|
|
1136
|
+
})()
|
|
1137
|
+
;
|
|
974
1138
|
const queueDomReads = [];
|
|
975
1139
|
const queueDomWrites = [];
|
|
976
1140
|
const queueTask = (queue, write) => (cb) => {
|
|
977
1141
|
queue.push(cb);
|
|
978
1142
|
if (!queuePending) {
|
|
979
1143
|
queuePending = true;
|
|
980
|
-
if (write && plt.$flags$ & 4 /* queueSync */) {
|
|
1144
|
+
if (write && plt.$flags$ & 4 /* PLATFORM_FLAGS.queueSync */) {
|
|
981
1145
|
nextTick(flush);
|
|
982
1146
|
}
|
|
983
1147
|
else {
|