@maggioli-design-system/mds-accordion-timer 2.0.0 → 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/collection/dictionary/typography.js +14 -3
- package/dist/components/index.d.ts +1 -5
- package/dist/components/index.js +1 -0
- 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-6045986e.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/dictionary/typography.d.ts +5 -3
- package/dist/types/stencil-public-runtime.d.ts +15 -4
- package/dist/types/types/typography.d.ts +4 -2
- 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/src/dictionary/typography.ts +19 -4
- package/src/types/typography.ts +13 -2
- 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-6045986e.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
|
@@ -22,60 +22,17 @@ function _interopNamespace(e) {
|
|
|
22
22
|
|
|
23
23
|
const NAMESPACE = 'mds-accordion-timer';
|
|
24
24
|
|
|
25
|
+
/**
|
|
26
|
+
* Virtual DOM patching algorithm based on Snabbdom by
|
|
27
|
+
* Simon Friis Vindum (@paldepind)
|
|
28
|
+
* Licensed under the MIT License
|
|
29
|
+
* https://github.com/snabbdom/snabbdom/blob/master/LICENSE
|
|
30
|
+
*
|
|
31
|
+
* Modified for Stencil's renderer and slot projection
|
|
32
|
+
*/
|
|
25
33
|
let scopeId;
|
|
26
34
|
let hostTagName;
|
|
27
35
|
let queuePending = false;
|
|
28
|
-
const win = typeof window !== 'undefined' ? window : {};
|
|
29
|
-
const doc = win.document || { head: {} };
|
|
30
|
-
const plt = {
|
|
31
|
-
$flags$: 0,
|
|
32
|
-
$resourcesUrl$: '',
|
|
33
|
-
jmp: (h) => h(),
|
|
34
|
-
raf: (h) => requestAnimationFrame(h),
|
|
35
|
-
ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
|
|
36
|
-
rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
|
|
37
|
-
ce: (eventName, opts) => new CustomEvent(eventName, opts),
|
|
38
|
-
};
|
|
39
|
-
const promiseResolve = (v) => Promise.resolve(v);
|
|
40
|
-
const supportsConstructibleStylesheets = /*@__PURE__*/ (() => {
|
|
41
|
-
try {
|
|
42
|
-
new CSSStyleSheet();
|
|
43
|
-
return typeof new CSSStyleSheet().replace === 'function';
|
|
44
|
-
}
|
|
45
|
-
catch (e) { }
|
|
46
|
-
return false;
|
|
47
|
-
})()
|
|
48
|
-
;
|
|
49
|
-
const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
|
|
50
|
-
if (listeners) {
|
|
51
|
-
listeners.map(([flags, name, method]) => {
|
|
52
|
-
const target = elm;
|
|
53
|
-
const handler = hostListenerProxy(hostRef, method);
|
|
54
|
-
const opts = hostListenerOpts(flags);
|
|
55
|
-
plt.ael(target, name, handler, opts);
|
|
56
|
-
(hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
const hostListenerProxy = (hostRef, methodName) => (ev) => {
|
|
61
|
-
try {
|
|
62
|
-
{
|
|
63
|
-
if (hostRef.$flags$ & 256 /* isListenReady */) {
|
|
64
|
-
// instance is ready, let's call it's member method for this event
|
|
65
|
-
hostRef.$lazyInstance$[methodName](ev);
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
(hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
catch (e) {
|
|
73
|
-
consoleError(e);
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
// prettier-ignore
|
|
77
|
-
const hostListenerOpts = (flags) => (flags & 2 /* Capture */) !== 0;
|
|
78
|
-
const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
|
|
79
36
|
const createTime = (fnName, tagName = '') => {
|
|
80
37
|
{
|
|
81
38
|
return () => {
|
|
@@ -90,71 +47,7 @@ const uniqueTime = (key, measureText) => {
|
|
|
90
47
|
};
|
|
91
48
|
}
|
|
92
49
|
};
|
|
93
|
-
const
|
|
94
|
-
const registerStyle = (scopeId, cssText, allowCS) => {
|
|
95
|
-
let style = styles.get(scopeId);
|
|
96
|
-
if (supportsConstructibleStylesheets && allowCS) {
|
|
97
|
-
style = (style || new CSSStyleSheet());
|
|
98
|
-
style.replace(cssText);
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
style = cssText;
|
|
102
|
-
}
|
|
103
|
-
styles.set(scopeId, style);
|
|
104
|
-
};
|
|
105
|
-
const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
|
|
106
|
-
let scopeId = getScopeId(cmpMeta);
|
|
107
|
-
const style = styles.get(scopeId);
|
|
108
|
-
// if an element is NOT connected then getRootNode() will return the wrong root node
|
|
109
|
-
// so the fallback is to always use the document for the root node in those cases
|
|
110
|
-
styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
|
|
111
|
-
if (style) {
|
|
112
|
-
if (typeof style === 'string') {
|
|
113
|
-
styleContainerNode = styleContainerNode.head || styleContainerNode;
|
|
114
|
-
let appliedStyles = rootAppliedStyles.get(styleContainerNode);
|
|
115
|
-
let styleElm;
|
|
116
|
-
if (!appliedStyles) {
|
|
117
|
-
rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
|
|
118
|
-
}
|
|
119
|
-
if (!appliedStyles.has(scopeId)) {
|
|
120
|
-
{
|
|
121
|
-
{
|
|
122
|
-
styleElm = doc.createElement('style');
|
|
123
|
-
styleElm.innerHTML = style;
|
|
124
|
-
}
|
|
125
|
-
styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
|
|
126
|
-
}
|
|
127
|
-
if (appliedStyles) {
|
|
128
|
-
appliedStyles.add(scopeId);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
|
|
133
|
-
styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
return scopeId;
|
|
137
|
-
};
|
|
138
|
-
const attachStyles = (hostRef) => {
|
|
139
|
-
const cmpMeta = hostRef.$cmpMeta$;
|
|
140
|
-
const elm = hostRef.$hostElement$;
|
|
141
|
-
const flags = cmpMeta.$flags$;
|
|
142
|
-
const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
|
|
143
|
-
const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
|
|
144
|
-
if (flags & 10 /* needsScopedEncapsulation */) {
|
|
145
|
-
// only required when we're NOT using native shadow dom (slot)
|
|
146
|
-
// or this browser doesn't support native shadow dom
|
|
147
|
-
// and this host element was NOT created with SSR
|
|
148
|
-
// let's pick out the inner content for slot projection
|
|
149
|
-
// create a node to represent where the original
|
|
150
|
-
// content was first placed, which is useful later on
|
|
151
|
-
// DOM WRITE!!
|
|
152
|
-
elm['s-sc'] = scopeId;
|
|
153
|
-
elm.classList.add(scopeId + '-h');
|
|
154
|
-
}
|
|
155
|
-
endAttachStyles();
|
|
156
|
-
};
|
|
157
|
-
const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
|
|
50
|
+
const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
|
|
158
51
|
const isDef = (v) => v != null;
|
|
159
52
|
const isComplexType = (o) => {
|
|
160
53
|
// https://jsperf.com/typeof-fn-object/5
|
|
@@ -219,6 +112,149 @@ const newVNode = (tag, text) => {
|
|
|
219
112
|
};
|
|
220
113
|
const Host = {};
|
|
221
114
|
const isHost = (node) => node && node.$tag$ === Host;
|
|
115
|
+
/**
|
|
116
|
+
* Parse a new property value for a given property type.
|
|
117
|
+
*
|
|
118
|
+
* While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
|
|
119
|
+
* it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
|
|
120
|
+
* 1. `any`, the type given to `propValue` in the function signature
|
|
121
|
+
* 2. the type stored from `propType`.
|
|
122
|
+
*
|
|
123
|
+
* This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
|
|
124
|
+
*
|
|
125
|
+
* Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
|
|
126
|
+
* a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
|
|
127
|
+
* based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
|
|
128
|
+
* ```tsx
|
|
129
|
+
* <my-cmp prop-val={0}></my-cmp>
|
|
130
|
+
* ```
|
|
131
|
+
*
|
|
132
|
+
* HTML prop values on the other hand, will always a string
|
|
133
|
+
*
|
|
134
|
+
* @param propValue the new value to coerce to some type
|
|
135
|
+
* @param propType the type of the prop, expressed as a binary number
|
|
136
|
+
* @returns the parsed/coerced value
|
|
137
|
+
*/
|
|
138
|
+
const parsePropertyValue = (propValue, propType) => {
|
|
139
|
+
// ensure this value is of the correct prop type
|
|
140
|
+
if (propValue != null && !isComplexType(propValue)) {
|
|
141
|
+
if (propType & 2 /* MEMBER_FLAGS.Number */) {
|
|
142
|
+
// force it to be a number
|
|
143
|
+
return parseFloat(propValue);
|
|
144
|
+
}
|
|
145
|
+
// redundant return here for better minification
|
|
146
|
+
return propValue;
|
|
147
|
+
}
|
|
148
|
+
// not sure exactly what type we want
|
|
149
|
+
// so no need to change to a different type
|
|
150
|
+
return propValue;
|
|
151
|
+
};
|
|
152
|
+
const getElement = (ref) => (getHostRef(ref).$hostElement$ );
|
|
153
|
+
const createEvent = (ref, name, flags) => {
|
|
154
|
+
const elm = getElement(ref);
|
|
155
|
+
return {
|
|
156
|
+
emit: (detail) => {
|
|
157
|
+
return emitEvent(elm, name, {
|
|
158
|
+
bubbles: !!(flags & 4 /* EVENT_FLAGS.Bubbles */),
|
|
159
|
+
composed: !!(flags & 2 /* EVENT_FLAGS.Composed */),
|
|
160
|
+
cancelable: !!(flags & 1 /* EVENT_FLAGS.Cancellable */),
|
|
161
|
+
detail,
|
|
162
|
+
});
|
|
163
|
+
},
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* Helper function to create & dispatch a custom Event on a provided target
|
|
168
|
+
* @param elm the target of the Event
|
|
169
|
+
* @param name the name to give the custom Event
|
|
170
|
+
* @param opts options for configuring a custom Event
|
|
171
|
+
* @returns the custom Event
|
|
172
|
+
*/
|
|
173
|
+
const emitEvent = (elm, name, opts) => {
|
|
174
|
+
const ev = plt.ce(name, opts);
|
|
175
|
+
elm.dispatchEvent(ev);
|
|
176
|
+
return ev;
|
|
177
|
+
};
|
|
178
|
+
const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
|
|
179
|
+
const registerStyle = (scopeId, cssText, allowCS) => {
|
|
180
|
+
let style = styles.get(scopeId);
|
|
181
|
+
if (supportsConstructableStylesheets && allowCS) {
|
|
182
|
+
style = (style || new CSSStyleSheet());
|
|
183
|
+
if (typeof style === 'string') {
|
|
184
|
+
style = cssText;
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
style.replaceSync(cssText);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
style = cssText;
|
|
192
|
+
}
|
|
193
|
+
styles.set(scopeId, style);
|
|
194
|
+
};
|
|
195
|
+
const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
|
|
196
|
+
let scopeId = getScopeId(cmpMeta);
|
|
197
|
+
const style = styles.get(scopeId);
|
|
198
|
+
// if an element is NOT connected then getRootNode() will return the wrong root node
|
|
199
|
+
// so the fallback is to always use the document for the root node in those cases
|
|
200
|
+
styleContainerNode = styleContainerNode.nodeType === 11 /* NODE_TYPE.DocumentFragment */ ? styleContainerNode : doc;
|
|
201
|
+
if (style) {
|
|
202
|
+
if (typeof style === 'string') {
|
|
203
|
+
styleContainerNode = styleContainerNode.head || styleContainerNode;
|
|
204
|
+
let appliedStyles = rootAppliedStyles.get(styleContainerNode);
|
|
205
|
+
let styleElm;
|
|
206
|
+
if (!appliedStyles) {
|
|
207
|
+
rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
|
|
208
|
+
}
|
|
209
|
+
if (!appliedStyles.has(scopeId)) {
|
|
210
|
+
{
|
|
211
|
+
{
|
|
212
|
+
styleElm = doc.createElement('style');
|
|
213
|
+
styleElm.innerHTML = style;
|
|
214
|
+
}
|
|
215
|
+
styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
|
|
216
|
+
}
|
|
217
|
+
if (appliedStyles) {
|
|
218
|
+
appliedStyles.add(scopeId);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
|
|
223
|
+
styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return scopeId;
|
|
227
|
+
};
|
|
228
|
+
const attachStyles = (hostRef) => {
|
|
229
|
+
const cmpMeta = hostRef.$cmpMeta$;
|
|
230
|
+
const elm = hostRef.$hostElement$;
|
|
231
|
+
const flags = cmpMeta.$flags$;
|
|
232
|
+
const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
|
|
233
|
+
const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
|
|
234
|
+
if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
|
|
235
|
+
// only required when we're NOT using native shadow dom (slot)
|
|
236
|
+
// or this browser doesn't support native shadow dom
|
|
237
|
+
// and this host element was NOT created with SSR
|
|
238
|
+
// let's pick out the inner content for slot projection
|
|
239
|
+
// create a node to represent where the original
|
|
240
|
+
// content was first placed, which is useful later on
|
|
241
|
+
// DOM WRITE!!
|
|
242
|
+
elm['s-sc'] = scopeId;
|
|
243
|
+
elm.classList.add(scopeId + '-h');
|
|
244
|
+
}
|
|
245
|
+
endAttachStyles();
|
|
246
|
+
};
|
|
247
|
+
const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
|
|
248
|
+
/**
|
|
249
|
+
* Create a DOM Node corresponding to one of the children of a given VNode.
|
|
250
|
+
*
|
|
251
|
+
* @param oldParentVNode the parent VNode from the previous render
|
|
252
|
+
* @param newParentVNode the parent VNode from the current render
|
|
253
|
+
* @param childIndex the index of the VNode, in the _new_ parent node's
|
|
254
|
+
* children, for which we will create a new DOM node
|
|
255
|
+
* @param parentElm the parent DOM node which our new node will be a child of
|
|
256
|
+
* @returns the newly created node
|
|
257
|
+
*/
|
|
222
258
|
const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
223
259
|
// tslint:disable-next-line: prefer-const
|
|
224
260
|
const newVNode = newParentVNode.$children$[childIndex];
|
|
@@ -272,6 +308,74 @@ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
|
|
|
272
308
|
}
|
|
273
309
|
}
|
|
274
310
|
};
|
|
311
|
+
/**
|
|
312
|
+
* Reconcile the children of a new VNode with the children of an old VNode by
|
|
313
|
+
* traversing the two collections of children, identifying nodes that are
|
|
314
|
+
* conserved or changed, calling out to `patch` to make any necessary
|
|
315
|
+
* updates to the DOM, and rearranging DOM nodes as needed.
|
|
316
|
+
*
|
|
317
|
+
* The algorithm for reconciling children works by analyzing two 'windows' onto
|
|
318
|
+
* the two arrays of children (`oldCh` and `newCh`). We keep track of the
|
|
319
|
+
* 'windows' by storing start and end indices and references to the
|
|
320
|
+
* corresponding array entries. Initially the two 'windows' are basically equal
|
|
321
|
+
* to the entire array, but we progressively narrow the windows until there are
|
|
322
|
+
* no children left to update by doing the following:
|
|
323
|
+
*
|
|
324
|
+
* 1. Skip any `null` entries at the beginning or end of the two arrays, so
|
|
325
|
+
* that if we have an initial array like the following we'll end up dealing
|
|
326
|
+
* only with a window bounded by the highlighted elements:
|
|
327
|
+
*
|
|
328
|
+
* [null, null, VNode1 , ... , VNode2, null, null]
|
|
329
|
+
* ^^^^^^ ^^^^^^
|
|
330
|
+
*
|
|
331
|
+
* 2. Check to see if the elements at the head and tail positions are equal
|
|
332
|
+
* across the windows. This will basically detect elements which haven't
|
|
333
|
+
* been added, removed, or changed position, i.e. if you had the following
|
|
334
|
+
* VNode elements (represented as HTML):
|
|
335
|
+
*
|
|
336
|
+
* oldVNode: `<div><p><span>HEY</span></p></div>`
|
|
337
|
+
* newVNode: `<div><p><span>THERE</span></p></div>`
|
|
338
|
+
*
|
|
339
|
+
* Then when comparing the children of the `<div>` tag we check the equality
|
|
340
|
+
* of the VNodes corresponding to the `<p>` tags and, since they are the
|
|
341
|
+
* same tag in the same position, we'd be able to avoid completely
|
|
342
|
+
* re-rendering the subtree under them with a new DOM element and would just
|
|
343
|
+
* call out to `patch` to handle reconciling their children and so on.
|
|
344
|
+
*
|
|
345
|
+
* 3. Check, for both windows, to see if the element at the beginning of the
|
|
346
|
+
* window corresponds to the element at the end of the other window. This is
|
|
347
|
+
* a heuristic which will let us identify _some_ situations in which
|
|
348
|
+
* elements have changed position, for instance it _should_ detect that the
|
|
349
|
+
* children nodes themselves have not changed but merely moved in the
|
|
350
|
+
* following example:
|
|
351
|
+
*
|
|
352
|
+
* oldVNode: `<div><element-one /><element-two /></div>`
|
|
353
|
+
* newVNode: `<div><element-two /><element-one /></div>`
|
|
354
|
+
*
|
|
355
|
+
* If we find cases like this then we also need to move the concrete DOM
|
|
356
|
+
* elements corresponding to the moved children to write the re-order to the
|
|
357
|
+
* DOM.
|
|
358
|
+
*
|
|
359
|
+
* 4. Finally, if VNodes have the `key` attribute set on them we check for any
|
|
360
|
+
* nodes in the old children which have the same key as the first element in
|
|
361
|
+
* our window on the new children. If we find such a node we handle calling
|
|
362
|
+
* out to `patch`, moving relevant DOM nodes, and so on, in accordance with
|
|
363
|
+
* what we find.
|
|
364
|
+
*
|
|
365
|
+
* Finally, once we've narrowed our 'windows' to the point that either of them
|
|
366
|
+
* collapse (i.e. they have length 0) we then handle any remaining VNode
|
|
367
|
+
* insertion or deletion that needs to happen to get a DOM state that correctly
|
|
368
|
+
* reflects the new child VNodes. If, for instance, after our window on the old
|
|
369
|
+
* children has collapsed we still have more nodes on the new children that
|
|
370
|
+
* we haven't dealt with yet then we need to add them, or if the new children
|
|
371
|
+
* collapse but we still have unhandled _old_ children then we need to make
|
|
372
|
+
* sure the corresponding DOM nodes are removed.
|
|
373
|
+
*
|
|
374
|
+
* @param parentElm the node into which the parent VNode is rendered
|
|
375
|
+
* @param oldCh the old children of the parent node
|
|
376
|
+
* @param newVNode the new VNode which will replace the parent
|
|
377
|
+
* @param newCh the new children of the parent node
|
|
378
|
+
*/
|
|
275
379
|
const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
276
380
|
let oldStartIdx = 0;
|
|
277
381
|
let newStartIdx = 0;
|
|
@@ -284,7 +388,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
284
388
|
let node;
|
|
285
389
|
while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
|
|
286
390
|
if (oldStartVnode == null) {
|
|
287
|
-
//
|
|
391
|
+
// VNode might have been moved left
|
|
288
392
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
289
393
|
}
|
|
290
394
|
else if (oldEndVnode == null) {
|
|
@@ -297,34 +401,67 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
297
401
|
newEndVnode = newCh[--newEndIdx];
|
|
298
402
|
}
|
|
299
403
|
else if (isSameVnode(oldStartVnode, newStartVnode)) {
|
|
404
|
+
// if the start nodes are the same then we should patch the new VNode
|
|
405
|
+
// onto the old one, and increment our `newStartIdx` and `oldStartIdx`
|
|
406
|
+
// indices to reflect that. We don't need to move any DOM Nodes around
|
|
407
|
+
// since things are matched up in order.
|
|
300
408
|
patch(oldStartVnode, newStartVnode);
|
|
301
409
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
302
410
|
newStartVnode = newCh[++newStartIdx];
|
|
303
411
|
}
|
|
304
412
|
else if (isSameVnode(oldEndVnode, newEndVnode)) {
|
|
413
|
+
// likewise, if the end nodes are the same we patch new onto old and
|
|
414
|
+
// decrement our end indices, and also likewise in this case we don't
|
|
415
|
+
// need to move any DOM Nodes.
|
|
305
416
|
patch(oldEndVnode, newEndVnode);
|
|
306
417
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
307
418
|
newEndVnode = newCh[--newEndIdx];
|
|
308
419
|
}
|
|
309
420
|
else if (isSameVnode(oldStartVnode, newEndVnode)) {
|
|
310
421
|
patch(oldStartVnode, newEndVnode);
|
|
422
|
+
// We need to move the element for `oldStartVnode` into a position which
|
|
423
|
+
// will be appropriate for `newEndVnode`. For this we can use
|
|
424
|
+
// `.insertBefore` and `oldEndVnode.$elm$.nextSibling`. If there is a
|
|
425
|
+
// sibling for `oldEndVnode.$elm$` then we want to move the DOM node for
|
|
426
|
+
// `oldStartVnode` between `oldEndVnode` and it's sibling, like so:
|
|
427
|
+
//
|
|
428
|
+
// <old-start-node />
|
|
429
|
+
// <some-intervening-node />
|
|
430
|
+
// <old-end-node />
|
|
431
|
+
// <!-- -> <-- `oldStartVnode.$elm$` should be inserted here
|
|
432
|
+
// <next-sibling />
|
|
433
|
+
//
|
|
434
|
+
// If instead `oldEndVnode.$elm$` has no sibling then we just want to put
|
|
435
|
+
// the node for `oldStartVnode` at the end of the children of
|
|
436
|
+
// `parentElm`. Luckily, `Node.nextSibling` will return `null` if there
|
|
437
|
+
// aren't any siblings, and passing `null` to `Node.insertBefore` will
|
|
438
|
+
// append it to the children of the parent element.
|
|
311
439
|
parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
|
|
312
440
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
313
441
|
newEndVnode = newCh[--newEndIdx];
|
|
314
442
|
}
|
|
315
443
|
else if (isSameVnode(oldEndVnode, newStartVnode)) {
|
|
316
444
|
patch(oldEndVnode, newStartVnode);
|
|
445
|
+
// We've already checked above if `oldStartVnode` and `newStartVnode` are
|
|
446
|
+
// the same node, so since we're here we know that they are not. Thus we
|
|
447
|
+
// can move the element for `oldEndVnode` _before_ the element for
|
|
448
|
+
// `oldStartVnode`, leaving `oldStartVnode` to be reconciled in the
|
|
449
|
+
// future.
|
|
317
450
|
parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
|
|
318
451
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
319
452
|
newStartVnode = newCh[++newStartIdx];
|
|
320
453
|
}
|
|
321
454
|
else {
|
|
322
455
|
{
|
|
323
|
-
//
|
|
456
|
+
// We either didn't find an element in the old children that matches
|
|
457
|
+
// the key of the first new child OR the build is not using `key`
|
|
458
|
+
// attributes at all. In either case we need to create a new element
|
|
459
|
+
// for the new node.
|
|
324
460
|
node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
|
|
325
461
|
newStartVnode = newCh[++newStartIdx];
|
|
326
462
|
}
|
|
327
463
|
if (node) {
|
|
464
|
+
// if we created a new node then handle inserting it to the DOM
|
|
328
465
|
{
|
|
329
466
|
oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
|
|
330
467
|
}
|
|
@@ -332,20 +469,49 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
332
469
|
}
|
|
333
470
|
}
|
|
334
471
|
if (oldStartIdx > oldEndIdx) {
|
|
472
|
+
// we have some more new nodes to add which don't match up with old nodes
|
|
335
473
|
addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
|
|
336
474
|
}
|
|
337
475
|
else if (newStartIdx > newEndIdx) {
|
|
476
|
+
// there are nodes in the `oldCh` array which no longer correspond to nodes
|
|
477
|
+
// in the new array, so lets remove them (which entails cleaning up the
|
|
478
|
+
// relevant DOM nodes)
|
|
338
479
|
removeVnodes(oldCh, oldStartIdx, oldEndIdx);
|
|
339
480
|
}
|
|
340
481
|
};
|
|
341
|
-
|
|
482
|
+
/**
|
|
483
|
+
* Compare two VNodes to determine if they are the same
|
|
484
|
+
*
|
|
485
|
+
* **NB**: This function is an equality _heuristic_ based on the available
|
|
486
|
+
* information set on the two VNodes and can be misleading under certain
|
|
487
|
+
* circumstances. In particular, if the two nodes do not have `key` attrs
|
|
488
|
+
* (available under `$key$` on VNodes) then the function falls back on merely
|
|
489
|
+
* checking that they have the same tag.
|
|
490
|
+
*
|
|
491
|
+
* So, in other words, if `key` attrs are not set on VNodes which may be
|
|
492
|
+
* changing order within a `children` array or something along those lines then
|
|
493
|
+
* we could obtain a false positive and then have to do needless re-rendering.
|
|
494
|
+
*
|
|
495
|
+
* @param leftVNode the first VNode to check
|
|
496
|
+
* @param rightVNode the second VNode to check
|
|
497
|
+
* @returns whether they're equal or not
|
|
498
|
+
*/
|
|
499
|
+
const isSameVnode = (leftVNode, rightVNode) => {
|
|
342
500
|
// compare if two vnode to see if they're "technically" the same
|
|
343
501
|
// need to have the same element tag, and same key to be the same
|
|
344
|
-
if (
|
|
502
|
+
if (leftVNode.$tag$ === rightVNode.$tag$) {
|
|
345
503
|
return true;
|
|
346
504
|
}
|
|
347
505
|
return false;
|
|
348
506
|
};
|
|
507
|
+
/**
|
|
508
|
+
* Handle reconciling an outdated VNode with a new one which corresponds to
|
|
509
|
+
* it. This function handles flushing updates to the DOM and reconciling the
|
|
510
|
+
* children of the two nodes (if any).
|
|
511
|
+
*
|
|
512
|
+
* @param oldVNode an old VNode whose DOM element and children we want to update
|
|
513
|
+
* @param newVNode a new VNode representing an updated version of the old one
|
|
514
|
+
*/
|
|
349
515
|
const patch = (oldVNode, newVNode) => {
|
|
350
516
|
const elm = (newVNode.$elm$ = oldVNode.$elm$);
|
|
351
517
|
const oldChildren = oldVNode.$children$;
|
|
@@ -353,6 +519,7 @@ const patch = (oldVNode, newVNode) => {
|
|
|
353
519
|
{
|
|
354
520
|
if (oldChildren !== null && newChildren !== null) {
|
|
355
521
|
// looks like there's child vnodes for both the old and new vnodes
|
|
522
|
+
// so we need to call `updateChildren` to reconcile them
|
|
356
523
|
updateChildren(elm, oldChildren, newVNode, newChildren);
|
|
357
524
|
}
|
|
358
525
|
else if (newChildren !== null) {
|
|
@@ -371,7 +538,7 @@ const renderVdom = (hostRef, renderFnResults) => {
|
|
|
371
538
|
const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
|
|
372
539
|
hostTagName = hostElm.tagName;
|
|
373
540
|
rootVnode.$tag$ = null;
|
|
374
|
-
rootVnode.$flags$ |= 4 /* isHost */;
|
|
541
|
+
rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
|
|
375
542
|
hostRef.$vnode$ = rootVnode;
|
|
376
543
|
rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
|
|
377
544
|
{
|
|
@@ -380,32 +547,6 @@ const renderVdom = (hostRef, renderFnResults) => {
|
|
|
380
547
|
// synchronous patch
|
|
381
548
|
patch(oldVNode, rootVnode);
|
|
382
549
|
};
|
|
383
|
-
const getElement = (ref) => (getHostRef(ref).$hostElement$ );
|
|
384
|
-
const createEvent = (ref, name, flags) => {
|
|
385
|
-
const elm = getElement(ref);
|
|
386
|
-
return {
|
|
387
|
-
emit: (detail) => {
|
|
388
|
-
return emitEvent(elm, name, {
|
|
389
|
-
bubbles: !!(flags & 4 /* Bubbles */),
|
|
390
|
-
composed: !!(flags & 2 /* Composed */),
|
|
391
|
-
cancelable: !!(flags & 1 /* Cancellable */),
|
|
392
|
-
detail,
|
|
393
|
-
});
|
|
394
|
-
},
|
|
395
|
-
};
|
|
396
|
-
};
|
|
397
|
-
/**
|
|
398
|
-
* Helper function to create & dispatch a custom Event on a provided target
|
|
399
|
-
* @param elm the target of the Event
|
|
400
|
-
* @param name the name to give the custom Event
|
|
401
|
-
* @param opts options for configuring a custom Event
|
|
402
|
-
* @returns the custom Event
|
|
403
|
-
*/
|
|
404
|
-
const emitEvent = (elm, name, opts) => {
|
|
405
|
-
const ev = plt.ce(name, opts);
|
|
406
|
-
elm.dispatchEvent(ev);
|
|
407
|
-
return ev;
|
|
408
|
-
};
|
|
409
550
|
const attachToAncestor = (hostRef, ancestorComponent) => {
|
|
410
551
|
if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
|
|
411
552
|
ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
|
|
@@ -413,10 +554,10 @@ const attachToAncestor = (hostRef, ancestorComponent) => {
|
|
|
413
554
|
};
|
|
414
555
|
const scheduleUpdate = (hostRef, isInitialLoad) => {
|
|
415
556
|
{
|
|
416
|
-
hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
|
|
557
|
+
hostRef.$flags$ |= 16 /* HOST_FLAGS.isQueuedForUpdate */;
|
|
417
558
|
}
|
|
418
|
-
if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
|
|
419
|
-
hostRef.$flags$ |= 512 /* needsRerender */;
|
|
559
|
+
if (hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
|
|
560
|
+
hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
|
|
420
561
|
return;
|
|
421
562
|
}
|
|
422
563
|
attachToAncestor(hostRef, hostRef.$ancestorComponent$);
|
|
@@ -432,7 +573,7 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
|
|
|
432
573
|
let promise;
|
|
433
574
|
if (isInitialLoad) {
|
|
434
575
|
{
|
|
435
|
-
hostRef.$flags$ |= 256 /* isListenReady */;
|
|
576
|
+
hostRef.$flags$ |= 256 /* HOST_FLAGS.isListenReady */;
|
|
436
577
|
if (hostRef.$queuedListeners$) {
|
|
437
578
|
hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
|
|
438
579
|
hostRef.$queuedListeners$ = null;
|
|
@@ -472,7 +613,7 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
|
|
|
472
613
|
}
|
|
473
614
|
else {
|
|
474
615
|
Promise.all(childrenPromises).then(postUpdate);
|
|
475
|
-
hostRef.$flags$ |= 4 /* isWaitingForChildren */;
|
|
616
|
+
hostRef.$flags$ |= 4 /* HOST_FLAGS.isWaitingForChildren */;
|
|
476
617
|
childrenPromises.length = 0;
|
|
477
618
|
}
|
|
478
619
|
}
|
|
@@ -481,10 +622,10 @@ const callRender = (hostRef, instance, elm) => {
|
|
|
481
622
|
try {
|
|
482
623
|
instance = instance.render() ;
|
|
483
624
|
{
|
|
484
|
-
hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
|
|
625
|
+
hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
|
|
485
626
|
}
|
|
486
627
|
{
|
|
487
|
-
hostRef.$flags$ |= 2 /* hasRendered */;
|
|
628
|
+
hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
|
|
488
629
|
}
|
|
489
630
|
{
|
|
490
631
|
{
|
|
@@ -508,8 +649,8 @@ const postUpdateComponent = (hostRef) => {
|
|
|
508
649
|
const endPostUpdate = createTime('postUpdate', tagName);
|
|
509
650
|
const instance = hostRef.$lazyInstance$ ;
|
|
510
651
|
const ancestorComponent = hostRef.$ancestorComponent$;
|
|
511
|
-
if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
|
|
512
|
-
hostRef.$flags$ |= 64 /* hasLoadedComponent */;
|
|
652
|
+
if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
|
|
653
|
+
hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
|
|
513
654
|
{
|
|
514
655
|
// DOM WRITE!
|
|
515
656
|
addHydratedFlag(elm);
|
|
@@ -535,10 +676,10 @@ const postUpdateComponent = (hostRef) => {
|
|
|
535
676
|
hostRef.$onRenderResolve$();
|
|
536
677
|
hostRef.$onRenderResolve$ = undefined;
|
|
537
678
|
}
|
|
538
|
-
if (hostRef.$flags$ & 512 /* needsRerender */) {
|
|
679
|
+
if (hostRef.$flags$ & 512 /* HOST_FLAGS.needsRerender */) {
|
|
539
680
|
nextTick(() => scheduleUpdate(hostRef, false));
|
|
540
681
|
}
|
|
541
|
-
hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
|
|
682
|
+
hostRef.$flags$ &= ~(4 /* HOST_FLAGS.isWaitingForChildren */ | 512 /* HOST_FLAGS.needsRerender */);
|
|
542
683
|
}
|
|
543
684
|
// ( •_•)
|
|
544
685
|
// ( •_•)>⌐■-■
|
|
@@ -568,43 +709,6 @@ const then = (promise, thenFn) => {
|
|
|
568
709
|
};
|
|
569
710
|
const addHydratedFlag = (elm) => elm.classList.add('hydrated')
|
|
570
711
|
;
|
|
571
|
-
/**
|
|
572
|
-
* Parse a new property value for a given property type.
|
|
573
|
-
*
|
|
574
|
-
* While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
|
|
575
|
-
* it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
|
|
576
|
-
* 1. `any`, the type given to `propValue` in the function signature
|
|
577
|
-
* 2. the type stored from `propType`.
|
|
578
|
-
*
|
|
579
|
-
* This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
|
|
580
|
-
*
|
|
581
|
-
* Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
|
|
582
|
-
* a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
|
|
583
|
-
* based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
|
|
584
|
-
* ```tsx
|
|
585
|
-
* <my-cmp prop-val={0}></my-cmp>
|
|
586
|
-
* ```
|
|
587
|
-
*
|
|
588
|
-
* HTML prop values on the other hand, will always a string
|
|
589
|
-
*
|
|
590
|
-
* @param propValue the new value to coerce to some type
|
|
591
|
-
* @param propType the type of the prop, expressed as a binary number
|
|
592
|
-
* @returns the parsed/coerced value
|
|
593
|
-
*/
|
|
594
|
-
const parsePropertyValue = (propValue, propType) => {
|
|
595
|
-
// ensure this value is of the correct prop type
|
|
596
|
-
if (propValue != null && !isComplexType(propValue)) {
|
|
597
|
-
if (propType & 2 /* Number */) {
|
|
598
|
-
// force it to be a number
|
|
599
|
-
return parseFloat(propValue);
|
|
600
|
-
}
|
|
601
|
-
// redundant return here for better minification
|
|
602
|
-
return propValue;
|
|
603
|
-
}
|
|
604
|
-
// not sure exactly what type we want
|
|
605
|
-
// so no need to change to a different type
|
|
606
|
-
return propValue;
|
|
607
|
-
};
|
|
608
712
|
const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
|
|
609
713
|
const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
610
714
|
// check our new property value against our internal value
|
|
@@ -616,12 +720,12 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
616
720
|
// explicitly check for NaN on both sides, as `NaN === NaN` is always false
|
|
617
721
|
const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
|
|
618
722
|
const didValueChange = newVal !== oldVal && !areBothNaN;
|
|
619
|
-
if ((!(flags & 8 /* isConstructingInstance */) || oldVal === undefined) && didValueChange) {
|
|
723
|
+
if ((!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
|
|
620
724
|
// gadzooks! the property's value has changed!!
|
|
621
725
|
// set our new value!
|
|
622
726
|
hostRef.$instanceValues$.set(propName, newVal);
|
|
623
727
|
if (instance) {
|
|
624
|
-
if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
|
|
728
|
+
if ((flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
|
|
625
729
|
// looks like this value actually changed, so we've got work to do!
|
|
626
730
|
// but only if we've already rendered, otherwise just chill out
|
|
627
731
|
// queue that we need to do an update, but don't worry about queuing
|
|
@@ -631,14 +735,24 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
631
735
|
}
|
|
632
736
|
}
|
|
633
737
|
};
|
|
738
|
+
/**
|
|
739
|
+
* Attach a series of runtime constructs to a compiled Stencil component
|
|
740
|
+
* constructor, including getters and setters for the `@Prop` and `@State`
|
|
741
|
+
* decorators, callbacks for when attributes change, and so on.
|
|
742
|
+
*
|
|
743
|
+
* @param Cstr the constructor for a component that we need to process
|
|
744
|
+
* @param cmpMeta metadata collected previously about the component
|
|
745
|
+
* @param flags a number used to store a series of bit flags
|
|
746
|
+
* @returns a reference to the same constructor passed in (but now mutated)
|
|
747
|
+
*/
|
|
634
748
|
const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
635
749
|
if (cmpMeta.$members$) {
|
|
636
750
|
// It's better to have a const than two Object.entries()
|
|
637
751
|
const members = Object.entries(cmpMeta.$members$);
|
|
638
752
|
const prototype = Cstr.prototype;
|
|
639
753
|
members.map(([memberName, [memberFlags]]) => {
|
|
640
|
-
if ((memberFlags & 31 /* Prop */ ||
|
|
641
|
-
((flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
|
|
754
|
+
if ((memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
|
|
755
|
+
((flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
|
|
642
756
|
// proxyComponent - prop
|
|
643
757
|
Object.defineProperty(prototype, memberName, {
|
|
644
758
|
get() {
|
|
@@ -654,7 +768,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
654
768
|
});
|
|
655
769
|
}
|
|
656
770
|
});
|
|
657
|
-
if ((flags & 1 /* isElementConstructor */)) {
|
|
771
|
+
if ((flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
|
|
658
772
|
const attrNameToPropName = new Map();
|
|
659
773
|
prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
|
|
660
774
|
plt.jmp(() => {
|
|
@@ -710,7 +824,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
710
824
|
// create an array of attributes to observe
|
|
711
825
|
// and also create a map of html attribute name to js property name
|
|
712
826
|
Cstr.observedAttributes = members
|
|
713
|
-
.filter(([_, m]) => m[0] & 15 /* HasAttribute */) // filter to only keep props that should match attributes
|
|
827
|
+
.filter(([_, m]) => m[0] & 15 /* MEMBER_FLAGS.HasAttribute */) // filter to only keep props that should match attributes
|
|
714
828
|
.map(([propName, m]) => {
|
|
715
829
|
const attrName = m[1] || propName;
|
|
716
830
|
attrNameToPropName.set(attrName, propName);
|
|
@@ -722,10 +836,10 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
722
836
|
};
|
|
723
837
|
const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
|
|
724
838
|
// initializeComponent
|
|
725
|
-
if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
|
|
839
|
+
if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
|
|
726
840
|
{
|
|
727
841
|
// we haven't initialized this element yet
|
|
728
|
-
hostRef.$flags$ |= 32 /* hasInitializedComponent */;
|
|
842
|
+
hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
|
|
729
843
|
// lazy loaded components
|
|
730
844
|
// request the component's implementation to be
|
|
731
845
|
// wired up with the host element
|
|
@@ -737,7 +851,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
737
851
|
endLoad();
|
|
738
852
|
}
|
|
739
853
|
if (!Cstr.isProxied) {
|
|
740
|
-
proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
|
|
854
|
+
proxyComponent(Cstr, cmpMeta, 2 /* PROXY_FLAGS.proxyState */);
|
|
741
855
|
Cstr.isProxied = true;
|
|
742
856
|
}
|
|
743
857
|
const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
|
|
@@ -745,7 +859,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
745
859
|
// but let's keep track of when we start and stop
|
|
746
860
|
// so that the getters/setters don't incorrectly step on data
|
|
747
861
|
{
|
|
748
|
-
hostRef.$flags$ |= 8 /* isConstructingInstance */;
|
|
862
|
+
hostRef.$flags$ |= 8 /* HOST_FLAGS.isConstructingInstance */;
|
|
749
863
|
}
|
|
750
864
|
// construct the lazy-loaded component implementation
|
|
751
865
|
// passing the hostRef is very important during
|
|
@@ -758,7 +872,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
758
872
|
consoleError(e);
|
|
759
873
|
}
|
|
760
874
|
{
|
|
761
|
-
hostRef.$flags$ &= ~8 /* isConstructingInstance */;
|
|
875
|
+
hostRef.$flags$ &= ~8 /* HOST_FLAGS.isConstructingInstance */;
|
|
762
876
|
}
|
|
763
877
|
endNewInstance();
|
|
764
878
|
fireConnectedCallback(hostRef.$lazyInstance$);
|
|
@@ -769,7 +883,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
769
883
|
const scopeId = getScopeId(cmpMeta);
|
|
770
884
|
if (!styles.has(scopeId)) {
|
|
771
885
|
const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
|
|
772
|
-
registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
|
|
886
|
+
registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
|
|
773
887
|
endRegisterStyles();
|
|
774
888
|
}
|
|
775
889
|
}
|
|
@@ -796,13 +910,13 @@ const fireConnectedCallback = (instance) => {
|
|
|
796
910
|
}
|
|
797
911
|
};
|
|
798
912
|
const connectedCallback = (elm) => {
|
|
799
|
-
if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
|
|
913
|
+
if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
|
|
800
914
|
const hostRef = getHostRef(elm);
|
|
801
915
|
const cmpMeta = hostRef.$cmpMeta$;
|
|
802
916
|
const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
|
|
803
|
-
if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
|
|
917
|
+
if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
|
|
804
918
|
// first time this component has connected
|
|
805
|
-
hostRef.$flags$ |= 1 /* hasConnected */;
|
|
919
|
+
hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
|
|
806
920
|
{
|
|
807
921
|
// find the first ancestor component (if there is one) and register
|
|
808
922
|
// this component as one of the actively loading child components for its ancestor
|
|
@@ -822,7 +936,7 @@ const connectedCallback = (elm) => {
|
|
|
822
936
|
// https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
|
|
823
937
|
if (cmpMeta.$members$) {
|
|
824
938
|
Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
|
|
825
|
-
if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
|
|
939
|
+
if (memberFlags & 31 /* MEMBER_FLAGS.Prop */ && elm.hasOwnProperty(memberName)) {
|
|
826
940
|
const value = elm[memberName];
|
|
827
941
|
delete elm[memberName];
|
|
828
942
|
elm[memberName] = value;
|
|
@@ -845,7 +959,7 @@ const connectedCallback = (elm) => {
|
|
|
845
959
|
}
|
|
846
960
|
};
|
|
847
961
|
const disconnectedCallback = (elm) => {
|
|
848
|
-
if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
|
|
962
|
+
if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
|
|
849
963
|
const hostRef = getHostRef(elm);
|
|
850
964
|
const instance = hostRef.$lazyInstance$ ;
|
|
851
965
|
{
|
|
@@ -894,7 +1008,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
894
1008
|
super(self);
|
|
895
1009
|
self = this;
|
|
896
1010
|
registerHost(self, cmpMeta);
|
|
897
|
-
if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
|
|
1011
|
+
if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
|
|
898
1012
|
// this component is using shadow dom
|
|
899
1013
|
// and this browser supports shadow dom
|
|
900
1014
|
// add the read-only property "shadowRoot" to the host element
|
|
@@ -929,7 +1043,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
929
1043
|
cmpMeta.$lazyBundleId$ = lazyBundle[0];
|
|
930
1044
|
if (!exclude.includes(tagName) && !customElements.get(tagName)) {
|
|
931
1045
|
cmpTags.push(tagName);
|
|
932
|
-
customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
|
|
1046
|
+
customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */));
|
|
933
1047
|
}
|
|
934
1048
|
});
|
|
935
1049
|
});
|
|
@@ -951,7 +1065,36 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
951
1065
|
// Fallback appLoad event
|
|
952
1066
|
endBootstrap();
|
|
953
1067
|
};
|
|
954
|
-
const
|
|
1068
|
+
const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
|
|
1069
|
+
if (listeners) {
|
|
1070
|
+
listeners.map(([flags, name, method]) => {
|
|
1071
|
+
const target = elm;
|
|
1072
|
+
const handler = hostListenerProxy(hostRef, method);
|
|
1073
|
+
const opts = hostListenerOpts(flags);
|
|
1074
|
+
plt.ael(target, name, handler, opts);
|
|
1075
|
+
(hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
|
|
1076
|
+
});
|
|
1077
|
+
}
|
|
1078
|
+
};
|
|
1079
|
+
const hostListenerProxy = (hostRef, methodName) => (ev) => {
|
|
1080
|
+
try {
|
|
1081
|
+
{
|
|
1082
|
+
if (hostRef.$flags$ & 256 /* HOST_FLAGS.isListenReady */) {
|
|
1083
|
+
// instance is ready, let's call it's member method for this event
|
|
1084
|
+
hostRef.$lazyInstance$[methodName](ev);
|
|
1085
|
+
}
|
|
1086
|
+
else {
|
|
1087
|
+
(hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
catch (e) {
|
|
1092
|
+
consoleError(e);
|
|
1093
|
+
}
|
|
1094
|
+
};
|
|
1095
|
+
// prettier-ignore
|
|
1096
|
+
const hostListenerOpts = (flags) => (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0;
|
|
1097
|
+
const hostRefs = /*@__PURE__*/ new WeakMap();
|
|
955
1098
|
const getHostRef = (ref) => hostRefs.get(ref);
|
|
956
1099
|
const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
|
|
957
1100
|
const registerHost = (elm, cmpMeta) => {
|
|
@@ -992,14 +1135,35 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
|
|
|
992
1135
|
return importedModule[exportName];
|
|
993
1136
|
}, consoleError);
|
|
994
1137
|
};
|
|
995
|
-
const styles = new Map();
|
|
1138
|
+
const styles = /*@__PURE__*/ new Map();
|
|
1139
|
+
const win = typeof window !== 'undefined' ? window : {};
|
|
1140
|
+
const doc = win.document || { head: {} };
|
|
1141
|
+
const plt = {
|
|
1142
|
+
$flags$: 0,
|
|
1143
|
+
$resourcesUrl$: '',
|
|
1144
|
+
jmp: (h) => h(),
|
|
1145
|
+
raf: (h) => requestAnimationFrame(h),
|
|
1146
|
+
ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
|
|
1147
|
+
rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
|
|
1148
|
+
ce: (eventName, opts) => new CustomEvent(eventName, opts),
|
|
1149
|
+
};
|
|
1150
|
+
const promiseResolve = (v) => Promise.resolve(v);
|
|
1151
|
+
const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
|
|
1152
|
+
try {
|
|
1153
|
+
new CSSStyleSheet();
|
|
1154
|
+
return typeof new CSSStyleSheet().replaceSync === 'function';
|
|
1155
|
+
}
|
|
1156
|
+
catch (e) { }
|
|
1157
|
+
return false;
|
|
1158
|
+
})()
|
|
1159
|
+
;
|
|
996
1160
|
const queueDomReads = [];
|
|
997
1161
|
const queueDomWrites = [];
|
|
998
1162
|
const queueTask = (queue, write) => (cb) => {
|
|
999
1163
|
queue.push(cb);
|
|
1000
1164
|
if (!queuePending) {
|
|
1001
1165
|
queuePending = true;
|
|
1002
|
-
if (write && plt.$flags$ & 4 /* queueSync */) {
|
|
1166
|
+
if (write && plt.$flags$ & 4 /* PLATFORM_FLAGS.queueSync */) {
|
|
1003
1167
|
nextTick(flush);
|
|
1004
1168
|
}
|
|
1005
1169
|
else {
|