proto-table-wc 0.0.501 → 0.0.502
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/demo-table_2.cjs.entry.js +1 -1
- package/dist/cjs/index-c9a111f0.js +1112 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/proto-table-wc.cjs.js +9 -9
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/esm/demo-table_2.entry.js +1 -1
- package/dist/esm/index-78c62227.js +1086 -0
- package/dist/esm/loader.js +2 -2
- package/dist/esm/proto-table-wc.js +10 -10
- package/dist/proto-table-wc/{p-271c985b.entry.js → p-1fb75b34.entry.js} +1 -1
- package/dist/proto-table-wc/p-8b5d455f.js +2 -0
- package/dist/proto-table-wc/proto-table-wc.esm.js +1 -1
- package/package.json +2 -2
- package/dist/cjs/index-215e1883.js +0 -1809
- package/dist/esm/index-b878de0a.js +0 -1783
- package/dist/proto-table-wc/p-bb46f1f8.js +0 -2
@@ -1,1809 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
function _interopNamespace(e) {
|
4
|
-
if (e && e.__esModule) return e;
|
5
|
-
var n = Object.create(null);
|
6
|
-
if (e) {
|
7
|
-
Object.keys(e).forEach(function (k) {
|
8
|
-
if (k !== 'default') {
|
9
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
10
|
-
Object.defineProperty(n, k, d.get ? d : {
|
11
|
-
enumerable: true,
|
12
|
-
get: function () {
|
13
|
-
return e[k];
|
14
|
-
}
|
15
|
-
});
|
16
|
-
}
|
17
|
-
});
|
18
|
-
}
|
19
|
-
n['default'] = e;
|
20
|
-
return Object.freeze(n);
|
21
|
-
}
|
22
|
-
|
23
|
-
const NAMESPACE = 'proto-table-wc';
|
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
|
-
*/
|
33
|
-
let scopeId;
|
34
|
-
let hostTagName;
|
35
|
-
let isSvgMode = false;
|
36
|
-
let queuePending = false;
|
37
|
-
const createTime = (fnName, tagName = '') => {
|
38
|
-
{
|
39
|
-
return () => {
|
40
|
-
return;
|
41
|
-
};
|
42
|
-
}
|
43
|
-
};
|
44
|
-
const uniqueTime = (key, measureText) => {
|
45
|
-
{
|
46
|
-
return () => {
|
47
|
-
return;
|
48
|
-
};
|
49
|
-
}
|
50
|
-
};
|
51
|
-
const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
|
52
|
-
/**
|
53
|
-
* Constant for styles to be globally applied to `slot-fb` elements for pseudo-slot behavior.
|
54
|
-
*
|
55
|
-
* Two cascading rules must be used instead of a `:not()` selector due to Stencil browser
|
56
|
-
* support as of Stencil v4.
|
57
|
-
*/
|
58
|
-
const SLOT_FB_CSS = 'slot-fb{display:contents}slot-fb[hidden]{display:none}';
|
59
|
-
/**
|
60
|
-
* Default style mode id
|
61
|
-
*/
|
62
|
-
/**
|
63
|
-
* Reusable empty obj/array
|
64
|
-
* Don't add values to these!!
|
65
|
-
*/
|
66
|
-
const EMPTY_OBJ = {};
|
67
|
-
/**
|
68
|
-
* Namespaces
|
69
|
-
*/
|
70
|
-
const SVG_NS = 'http://www.w3.org/2000/svg';
|
71
|
-
const HTML_NS = 'http://www.w3.org/1999/xhtml';
|
72
|
-
const isDef = (v) => v != null;
|
73
|
-
/**
|
74
|
-
* Check whether a value is a 'complex type', defined here as an object or a
|
75
|
-
* function.
|
76
|
-
*
|
77
|
-
* @param o the value to check
|
78
|
-
* @returns whether it's a complex type or not
|
79
|
-
*/
|
80
|
-
const isComplexType = (o) => {
|
81
|
-
// https://jsperf.com/typeof-fn-object/5
|
82
|
-
o = typeof o;
|
83
|
-
return o === 'object' || o === 'function';
|
84
|
-
};
|
85
|
-
/**
|
86
|
-
* Helper method for querying a `meta` tag that contains a nonce value
|
87
|
-
* out of a DOM's head.
|
88
|
-
*
|
89
|
-
* @param doc The DOM containing the `head` to query against
|
90
|
-
* @returns The content of the meta tag representing the nonce value, or `undefined` if no tag
|
91
|
-
* exists or the tag has no content.
|
92
|
-
*/
|
93
|
-
function queryNonceMetaTagContent(doc) {
|
94
|
-
var _a, _b, _c;
|
95
|
-
return (_c = (_b = (_a = doc.head) === null || _a === void 0 ? void 0 : _a.querySelector('meta[name="csp-nonce"]')) === null || _b === void 0 ? void 0 : _b.getAttribute('content')) !== null && _c !== void 0 ? _c : undefined;
|
96
|
-
}
|
97
|
-
/**
|
98
|
-
* Production h() function based on Preact by
|
99
|
-
* Jason Miller (@developit)
|
100
|
-
* Licensed under the MIT License
|
101
|
-
* https://github.com/developit/preact/blob/master/LICENSE
|
102
|
-
*
|
103
|
-
* Modified for Stencil's compiler and vdom
|
104
|
-
*/
|
105
|
-
// export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
|
106
|
-
// export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
|
107
|
-
const h = (nodeName, vnodeData, ...children) => {
|
108
|
-
let child = null;
|
109
|
-
let key = null;
|
110
|
-
let simple = false;
|
111
|
-
let lastSimple = false;
|
112
|
-
const vNodeChildren = [];
|
113
|
-
const walk = (c) => {
|
114
|
-
for (let i = 0; i < c.length; i++) {
|
115
|
-
child = c[i];
|
116
|
-
if (Array.isArray(child)) {
|
117
|
-
walk(child);
|
118
|
-
}
|
119
|
-
else if (child != null && typeof child !== 'boolean') {
|
120
|
-
if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
|
121
|
-
child = String(child);
|
122
|
-
}
|
123
|
-
if (simple && lastSimple) {
|
124
|
-
// If the previous child was simple (string), we merge both
|
125
|
-
vNodeChildren[vNodeChildren.length - 1].$text$ += child;
|
126
|
-
}
|
127
|
-
else {
|
128
|
-
// Append a new vNode, if it's text, we create a text vNode
|
129
|
-
vNodeChildren.push(simple ? newVNode(null, child) : child);
|
130
|
-
}
|
131
|
-
lastSimple = simple;
|
132
|
-
}
|
133
|
-
}
|
134
|
-
};
|
135
|
-
walk(children);
|
136
|
-
if (vnodeData) {
|
137
|
-
if (vnodeData.key) {
|
138
|
-
key = vnodeData.key;
|
139
|
-
}
|
140
|
-
// normalize class / className attributes
|
141
|
-
{
|
142
|
-
const classData = vnodeData.className || vnodeData.class;
|
143
|
-
if (classData) {
|
144
|
-
vnodeData.class =
|
145
|
-
typeof classData !== 'object'
|
146
|
-
? classData
|
147
|
-
: Object.keys(classData)
|
148
|
-
.filter((k) => classData[k])
|
149
|
-
.join(' ');
|
150
|
-
}
|
151
|
-
}
|
152
|
-
}
|
153
|
-
const vnode = newVNode(nodeName, null);
|
154
|
-
vnode.$attrs$ = vnodeData;
|
155
|
-
if (vNodeChildren.length > 0) {
|
156
|
-
vnode.$children$ = vNodeChildren;
|
157
|
-
}
|
158
|
-
{
|
159
|
-
vnode.$key$ = key;
|
160
|
-
}
|
161
|
-
return vnode;
|
162
|
-
};
|
163
|
-
/**
|
164
|
-
* A utility function for creating a virtual DOM node from a tag and some
|
165
|
-
* possible text content.
|
166
|
-
*
|
167
|
-
* @param tag the tag for this element
|
168
|
-
* @param text possible text content for the node
|
169
|
-
* @returns a newly-minted virtual DOM node
|
170
|
-
*/
|
171
|
-
const newVNode = (tag, text) => {
|
172
|
-
const vnode = {
|
173
|
-
$flags$: 0,
|
174
|
-
$tag$: tag,
|
175
|
-
$text$: text,
|
176
|
-
$elm$: null,
|
177
|
-
$children$: null,
|
178
|
-
};
|
179
|
-
{
|
180
|
-
vnode.$attrs$ = null;
|
181
|
-
}
|
182
|
-
{
|
183
|
-
vnode.$key$ = null;
|
184
|
-
}
|
185
|
-
return vnode;
|
186
|
-
};
|
187
|
-
const Host = {};
|
188
|
-
/**
|
189
|
-
* Check whether a given node is a Host node or not
|
190
|
-
*
|
191
|
-
* @param node the virtual DOM node to check
|
192
|
-
* @returns whether it's a Host node or not
|
193
|
-
*/
|
194
|
-
const isHost = (node) => node && node.$tag$ === Host;
|
195
|
-
/**
|
196
|
-
* Parse a new property value for a given property type.
|
197
|
-
*
|
198
|
-
* While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
|
199
|
-
* it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
|
200
|
-
* 1. `any`, the type given to `propValue` in the function signature
|
201
|
-
* 2. the type stored from `propType`.
|
202
|
-
*
|
203
|
-
* This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
|
204
|
-
*
|
205
|
-
* Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
|
206
|
-
* a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
|
207
|
-
* based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
|
208
|
-
* ```tsx
|
209
|
-
* <my-cmp prop-val={0}></my-cmp>
|
210
|
-
* ```
|
211
|
-
*
|
212
|
-
* HTML prop values on the other hand, will always a string
|
213
|
-
*
|
214
|
-
* @param propValue the new value to coerce to some type
|
215
|
-
* @param propType the type of the prop, expressed as a binary number
|
216
|
-
* @returns the parsed/coerced value
|
217
|
-
*/
|
218
|
-
const parsePropertyValue = (propValue, propType) => {
|
219
|
-
// ensure this value is of the correct prop type
|
220
|
-
if (propValue != null && !isComplexType(propValue)) {
|
221
|
-
// redundant return here for better minification
|
222
|
-
return propValue;
|
223
|
-
}
|
224
|
-
// not sure exactly what type we want
|
225
|
-
// so no need to change to a different type
|
226
|
-
return propValue;
|
227
|
-
};
|
228
|
-
/**
|
229
|
-
* Helper function to create & dispatch a custom Event on a provided target
|
230
|
-
* @param elm the target of the Event
|
231
|
-
* @param name the name to give the custom Event
|
232
|
-
* @param opts options for configuring a custom Event
|
233
|
-
* @returns the custom Event
|
234
|
-
*/
|
235
|
-
const emitEvent = (elm, name, opts) => {
|
236
|
-
const ev = plt.ce(name, opts);
|
237
|
-
elm.dispatchEvent(ev);
|
238
|
-
return ev;
|
239
|
-
};
|
240
|
-
const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
|
241
|
-
const registerStyle = (scopeId, cssText, allowCS) => {
|
242
|
-
let style = styles.get(scopeId);
|
243
|
-
if (supportsConstructableStylesheets && allowCS) {
|
244
|
-
style = (style || new CSSStyleSheet());
|
245
|
-
if (typeof style === 'string') {
|
246
|
-
style = cssText;
|
247
|
-
}
|
248
|
-
else {
|
249
|
-
style.replaceSync(cssText);
|
250
|
-
}
|
251
|
-
}
|
252
|
-
else {
|
253
|
-
style = cssText;
|
254
|
-
}
|
255
|
-
styles.set(scopeId, style);
|
256
|
-
};
|
257
|
-
const addStyle = (styleContainerNode, cmpMeta, mode) => {
|
258
|
-
var _a;
|
259
|
-
const scopeId = getScopeId(cmpMeta);
|
260
|
-
const style = styles.get(scopeId);
|
261
|
-
// if an element is NOT connected then getRootNode() will return the wrong root node
|
262
|
-
// so the fallback is to always use the document for the root node in those cases
|
263
|
-
styleContainerNode = styleContainerNode.nodeType === 11 /* NODE_TYPE.DocumentFragment */ ? styleContainerNode : doc;
|
264
|
-
if (style) {
|
265
|
-
if (typeof style === 'string') {
|
266
|
-
styleContainerNode = styleContainerNode.head || styleContainerNode;
|
267
|
-
let appliedStyles = rootAppliedStyles.get(styleContainerNode);
|
268
|
-
let styleElm;
|
269
|
-
if (!appliedStyles) {
|
270
|
-
rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
|
271
|
-
}
|
272
|
-
if (!appliedStyles.has(scopeId)) {
|
273
|
-
{
|
274
|
-
styleElm = doc.createElement('style');
|
275
|
-
styleElm.innerHTML = style;
|
276
|
-
// Apply CSP nonce to the style tag if it exists
|
277
|
-
const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
|
278
|
-
if (nonce != null) {
|
279
|
-
styleElm.setAttribute('nonce', nonce);
|
280
|
-
}
|
281
|
-
styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
|
282
|
-
}
|
283
|
-
// Add styles for `slot-fb` elements if we're using slots outside the Shadow DOM
|
284
|
-
if (cmpMeta.$flags$ & 4 /* CMP_FLAGS.hasSlotRelocation */) {
|
285
|
-
styleElm.innerHTML += SLOT_FB_CSS;
|
286
|
-
}
|
287
|
-
if (appliedStyles) {
|
288
|
-
appliedStyles.add(scopeId);
|
289
|
-
}
|
290
|
-
}
|
291
|
-
}
|
292
|
-
else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
|
293
|
-
styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
|
294
|
-
}
|
295
|
-
}
|
296
|
-
return scopeId;
|
297
|
-
};
|
298
|
-
const attachStyles = (hostRef) => {
|
299
|
-
const cmpMeta = hostRef.$cmpMeta$;
|
300
|
-
const elm = hostRef.$hostElement$;
|
301
|
-
const flags = cmpMeta.$flags$;
|
302
|
-
const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
|
303
|
-
const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
|
304
|
-
if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
|
305
|
-
// only required when we're NOT using native shadow dom (slot)
|
306
|
-
// or this browser doesn't support native shadow dom
|
307
|
-
// and this host element was NOT created with SSR
|
308
|
-
// let's pick out the inner content for slot projection
|
309
|
-
// create a node to represent where the original
|
310
|
-
// content was first placed, which is useful later on
|
311
|
-
// DOM WRITE!!
|
312
|
-
elm['s-sc'] = scopeId;
|
313
|
-
elm.classList.add(scopeId + '-h');
|
314
|
-
}
|
315
|
-
endAttachStyles();
|
316
|
-
};
|
317
|
-
const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
|
318
|
-
/**
|
319
|
-
* Production setAccessor() function based on Preact by
|
320
|
-
* Jason Miller (@developit)
|
321
|
-
* Licensed under the MIT License
|
322
|
-
* https://github.com/developit/preact/blob/master/LICENSE
|
323
|
-
*
|
324
|
-
* Modified for Stencil's compiler and vdom
|
325
|
-
*/
|
326
|
-
/**
|
327
|
-
* When running a VDom render set properties present on a VDom node onto the
|
328
|
-
* corresponding HTML element.
|
329
|
-
*
|
330
|
-
* Note that this function has special functionality for the `class`,
|
331
|
-
* `style`, `key`, and `ref` attributes, as well as event handlers (like
|
332
|
-
* `onClick`, etc). All others are just passed through as-is.
|
333
|
-
*
|
334
|
-
* @param elm the HTMLElement onto which attributes should be set
|
335
|
-
* @param memberName the name of the attribute to set
|
336
|
-
* @param oldValue the old value for the attribute
|
337
|
-
* @param newValue the new value for the attribute
|
338
|
-
* @param isSvg whether we're in an svg context or not
|
339
|
-
* @param flags bitflags for Vdom variables
|
340
|
-
*/
|
341
|
-
const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
342
|
-
if (oldValue !== newValue) {
|
343
|
-
let isProp = isMemberInElement(elm, memberName);
|
344
|
-
let ln = memberName.toLowerCase();
|
345
|
-
if (memberName === 'class') {
|
346
|
-
const classList = elm.classList;
|
347
|
-
const oldClasses = parseClassList(oldValue);
|
348
|
-
const newClasses = parseClassList(newValue);
|
349
|
-
classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
|
350
|
-
classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
|
351
|
-
}
|
352
|
-
else if (memberName === 'key')
|
353
|
-
;
|
354
|
-
else if (memberName === 'ref') {
|
355
|
-
// minifier will clean this up
|
356
|
-
if (newValue) {
|
357
|
-
newValue(elm);
|
358
|
-
}
|
359
|
-
}
|
360
|
-
else if ((!isProp ) &&
|
361
|
-
memberName[0] === 'o' &&
|
362
|
-
memberName[1] === 'n') {
|
363
|
-
// Event Handlers
|
364
|
-
// so if the member name starts with "on" and the 3rd characters is
|
365
|
-
// a capital letter, and it's not already a member on the element,
|
366
|
-
// then we're assuming it's an event listener
|
367
|
-
if (memberName[2] === '-') {
|
368
|
-
// on- prefixed events
|
369
|
-
// allows to be explicit about the dom event to listen without any magic
|
370
|
-
// under the hood:
|
371
|
-
// <my-cmp on-click> // listens for "click"
|
372
|
-
// <my-cmp on-Click> // listens for "Click"
|
373
|
-
// <my-cmp on-ionChange> // listens for "ionChange"
|
374
|
-
// <my-cmp on-EVENTS> // listens for "EVENTS"
|
375
|
-
memberName = memberName.slice(3);
|
376
|
-
}
|
377
|
-
else if (isMemberInElement(win, ln)) {
|
378
|
-
// standard event
|
379
|
-
// the JSX attribute could have been "onMouseOver" and the
|
380
|
-
// member name "onmouseover" is on the window's prototype
|
381
|
-
// so let's add the listener "mouseover", which is all lowercased
|
382
|
-
memberName = ln.slice(2);
|
383
|
-
}
|
384
|
-
else {
|
385
|
-
// custom event
|
386
|
-
// the JSX attribute could have been "onMyCustomEvent"
|
387
|
-
// so let's trim off the "on" prefix and lowercase the first character
|
388
|
-
// and add the listener "myCustomEvent"
|
389
|
-
// except for the first character, we keep the event name case
|
390
|
-
memberName = ln[2] + memberName.slice(3);
|
391
|
-
}
|
392
|
-
if (oldValue || newValue) {
|
393
|
-
// Need to account for "capture" events.
|
394
|
-
// If the event name ends with "Capture", we'll update the name to remove
|
395
|
-
// the "Capture" suffix and make sure the event listener is setup to handle the capture event.
|
396
|
-
const capture = memberName.endsWith(CAPTURE_EVENT_SUFFIX);
|
397
|
-
// Make sure we only replace the last instance of "Capture"
|
398
|
-
memberName = memberName.replace(CAPTURE_EVENT_REGEX, '');
|
399
|
-
if (oldValue) {
|
400
|
-
plt.rel(elm, memberName, oldValue, capture);
|
401
|
-
}
|
402
|
-
if (newValue) {
|
403
|
-
plt.ael(elm, memberName, newValue, capture);
|
404
|
-
}
|
405
|
-
}
|
406
|
-
}
|
407
|
-
else {
|
408
|
-
// Set property if it exists and it's not a SVG
|
409
|
-
const isComplex = isComplexType(newValue);
|
410
|
-
if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
|
411
|
-
try {
|
412
|
-
if (!elm.tagName.includes('-')) {
|
413
|
-
const n = newValue == null ? '' : newValue;
|
414
|
-
// Workaround for Safari, moving the <input> caret when re-assigning the same valued
|
415
|
-
if (memberName === 'list') {
|
416
|
-
isProp = false;
|
417
|
-
}
|
418
|
-
else if (oldValue == null || elm[memberName] != n) {
|
419
|
-
elm[memberName] = n;
|
420
|
-
}
|
421
|
-
}
|
422
|
-
else {
|
423
|
-
elm[memberName] = newValue;
|
424
|
-
}
|
425
|
-
}
|
426
|
-
catch (e) {
|
427
|
-
/**
|
428
|
-
* in case someone tries to set a read-only property, e.g. "namespaceURI", we just ignore it
|
429
|
-
*/
|
430
|
-
}
|
431
|
-
}
|
432
|
-
if (newValue == null || newValue === false) {
|
433
|
-
if (newValue !== false || elm.getAttribute(memberName) === '') {
|
434
|
-
{
|
435
|
-
elm.removeAttribute(memberName);
|
436
|
-
}
|
437
|
-
}
|
438
|
-
}
|
439
|
-
else if ((!isProp || flags & 4 /* VNODE_FLAGS.isHost */ || isSvg) && !isComplex) {
|
440
|
-
newValue = newValue === true ? '' : newValue;
|
441
|
-
{
|
442
|
-
elm.setAttribute(memberName, newValue);
|
443
|
-
}
|
444
|
-
}
|
445
|
-
}
|
446
|
-
}
|
447
|
-
};
|
448
|
-
const parseClassListRegex = /\s/;
|
449
|
-
/**
|
450
|
-
* Parsed a string of classnames into an array
|
451
|
-
* @param value className string, e.g. "foo bar baz"
|
452
|
-
* @returns list of classes, e.g. ["foo", "bar", "baz"]
|
453
|
-
*/
|
454
|
-
const parseClassList = (value) => (!value ? [] : value.split(parseClassListRegex));
|
455
|
-
const CAPTURE_EVENT_SUFFIX = 'Capture';
|
456
|
-
const CAPTURE_EVENT_REGEX = new RegExp(CAPTURE_EVENT_SUFFIX + '$');
|
457
|
-
const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
|
458
|
-
// if the element passed in is a shadow root, which is a document fragment
|
459
|
-
// then we want to be adding attrs/props to the shadow root's "host" element
|
460
|
-
// if it's not a shadow root, then we add attrs/props to the same element
|
461
|
-
const elm = newVnode.$elm$.nodeType === 11 /* NODE_TYPE.DocumentFragment */ && newVnode.$elm$.host
|
462
|
-
? newVnode.$elm$.host
|
463
|
-
: newVnode.$elm$;
|
464
|
-
const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
|
465
|
-
const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
|
466
|
-
{
|
467
|
-
// remove attributes no longer present on the vnode by setting them to undefined
|
468
|
-
for (memberName of sortedAttrNames(Object.keys(oldVnodeAttrs))) {
|
469
|
-
if (!(memberName in newVnodeAttrs)) {
|
470
|
-
setAccessor(elm, memberName, oldVnodeAttrs[memberName], undefined, isSvgMode, newVnode.$flags$);
|
471
|
-
}
|
472
|
-
}
|
473
|
-
}
|
474
|
-
// add new & update changed attributes
|
475
|
-
for (memberName of sortedAttrNames(Object.keys(newVnodeAttrs))) {
|
476
|
-
setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
|
477
|
-
}
|
478
|
-
};
|
479
|
-
/**
|
480
|
-
* Sort a list of attribute names to ensure that all the attribute names which
|
481
|
-
* are _not_ `"ref"` come before `"ref"`. Preserve the order of the non-ref
|
482
|
-
* attributes.
|
483
|
-
*
|
484
|
-
* **Note**: if the supplied attributes do not include `'ref'` then the same
|
485
|
-
* (by reference) array will be returned without modification.
|
486
|
-
*
|
487
|
-
* @param attrNames attribute names to sort
|
488
|
-
* @returns a list of attribute names, sorted if they include `"ref"`
|
489
|
-
*/
|
490
|
-
function sortedAttrNames(attrNames) {
|
491
|
-
return attrNames.includes('ref')
|
492
|
-
? // we need to sort these to ensure that `'ref'` is the last attr
|
493
|
-
[...attrNames.filter((attr) => attr !== 'ref'), 'ref']
|
494
|
-
: // no need to sort, return the original array
|
495
|
-
attrNames;
|
496
|
-
}
|
497
|
-
/**
|
498
|
-
* Create a DOM Node corresponding to one of the children of a given VNode.
|
499
|
-
*
|
500
|
-
* @param oldParentVNode the parent VNode from the previous render
|
501
|
-
* @param newParentVNode the parent VNode from the current render
|
502
|
-
* @param childIndex the index of the VNode, in the _new_ parent node's
|
503
|
-
* children, for which we will create a new DOM node
|
504
|
-
* @param parentElm the parent DOM node which our new node will be a child of
|
505
|
-
* @returns the newly created node
|
506
|
-
*/
|
507
|
-
const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
508
|
-
// tslint:disable-next-line: prefer-const
|
509
|
-
const newVNode = newParentVNode.$children$[childIndex];
|
510
|
-
let i = 0;
|
511
|
-
let elm;
|
512
|
-
let childNode;
|
513
|
-
if (newVNode.$text$ !== null) {
|
514
|
-
// create text node
|
515
|
-
elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
|
516
|
-
}
|
517
|
-
else {
|
518
|
-
if (!isSvgMode) {
|
519
|
-
isSvgMode = newVNode.$tag$ === 'svg';
|
520
|
-
}
|
521
|
-
// create element
|
522
|
-
elm = newVNode.$elm$ = (doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, newVNode.$tag$)
|
523
|
-
);
|
524
|
-
if (isSvgMode && newVNode.$tag$ === 'foreignObject') {
|
525
|
-
isSvgMode = false;
|
526
|
-
}
|
527
|
-
// add css classes, attrs, props, listeners, etc.
|
528
|
-
{
|
529
|
-
updateElement(null, newVNode, isSvgMode);
|
530
|
-
}
|
531
|
-
if (isDef(scopeId) && elm['s-si'] !== scopeId) {
|
532
|
-
// if there is a scopeId and this is the initial render
|
533
|
-
// then let's add the scopeId as a css class
|
534
|
-
elm.classList.add((elm['s-si'] = scopeId));
|
535
|
-
}
|
536
|
-
if (newVNode.$children$) {
|
537
|
-
for (i = 0; i < newVNode.$children$.length; ++i) {
|
538
|
-
// create the node
|
539
|
-
childNode = createElm(oldParentVNode, newVNode, i);
|
540
|
-
// return node could have been null
|
541
|
-
if (childNode) {
|
542
|
-
// append our new node
|
543
|
-
elm.appendChild(childNode);
|
544
|
-
}
|
545
|
-
}
|
546
|
-
}
|
547
|
-
{
|
548
|
-
if (newVNode.$tag$ === 'svg') {
|
549
|
-
// Only reset the SVG context when we're exiting <svg> element
|
550
|
-
isSvgMode = false;
|
551
|
-
}
|
552
|
-
else if (elm.tagName === 'foreignObject') {
|
553
|
-
// Reenter SVG context when we're exiting <foreignObject> element
|
554
|
-
isSvgMode = true;
|
555
|
-
}
|
556
|
-
}
|
557
|
-
}
|
558
|
-
// This needs to always happen so we can hide nodes that are projected
|
559
|
-
// to another component but don't end up in a slot
|
560
|
-
elm['s-hn'] = hostTagName;
|
561
|
-
return elm;
|
562
|
-
};
|
563
|
-
/**
|
564
|
-
* Create DOM nodes corresponding to a list of {@link d.Vnode} objects and
|
565
|
-
* add them to the DOM in the appropriate place.
|
566
|
-
*
|
567
|
-
* @param parentElm the DOM node which should be used as a parent for the new
|
568
|
-
* DOM nodes
|
569
|
-
* @param before a child of the `parentElm` which the new children should be
|
570
|
-
* inserted before (optional)
|
571
|
-
* @param parentVNode the parent virtual DOM node
|
572
|
-
* @param vnodes the new child virtual DOM nodes to produce DOM nodes for
|
573
|
-
* @param startIdx the index in the child virtual DOM nodes at which to start
|
574
|
-
* creating DOM nodes (inclusive)
|
575
|
-
* @param endIdx the index in the child virtual DOM nodes at which to stop
|
576
|
-
* creating DOM nodes (inclusive)
|
577
|
-
*/
|
578
|
-
const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
|
579
|
-
let containerElm = (parentElm);
|
580
|
-
let childNode;
|
581
|
-
if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
|
582
|
-
containerElm = containerElm.shadowRoot;
|
583
|
-
}
|
584
|
-
for (; startIdx <= endIdx; ++startIdx) {
|
585
|
-
if (vnodes[startIdx]) {
|
586
|
-
childNode = createElm(null, parentVNode, startIdx);
|
587
|
-
if (childNode) {
|
588
|
-
vnodes[startIdx].$elm$ = childNode;
|
589
|
-
containerElm.insertBefore(childNode, before);
|
590
|
-
}
|
591
|
-
}
|
592
|
-
}
|
593
|
-
};
|
594
|
-
/**
|
595
|
-
* Remove the DOM elements corresponding to a list of {@link d.VNode} objects.
|
596
|
-
* This can be used to, for instance, clean up after a list of children which
|
597
|
-
* should no longer be shown.
|
598
|
-
*
|
599
|
-
* This function also handles some of Stencil's slot relocation logic.
|
600
|
-
*
|
601
|
-
* @param vnodes a list of virtual DOM nodes to remove
|
602
|
-
* @param startIdx the index at which to start removing nodes (inclusive)
|
603
|
-
* @param endIdx the index at which to stop removing nodes (inclusive)
|
604
|
-
*/
|
605
|
-
const removeVnodes = (vnodes, startIdx, endIdx) => {
|
606
|
-
for (let index = startIdx; index <= endIdx; ++index) {
|
607
|
-
const vnode = vnodes[index];
|
608
|
-
if (vnode) {
|
609
|
-
const elm = vnode.$elm$;
|
610
|
-
nullifyVNodeRefs(vnode);
|
611
|
-
if (elm) {
|
612
|
-
// remove the vnode's element from the dom
|
613
|
-
elm.remove();
|
614
|
-
}
|
615
|
-
}
|
616
|
-
}
|
617
|
-
};
|
618
|
-
/**
|
619
|
-
* Reconcile the children of a new VNode with the children of an old VNode by
|
620
|
-
* traversing the two collections of children, identifying nodes that are
|
621
|
-
* conserved or changed, calling out to `patch` to make any necessary
|
622
|
-
* updates to the DOM, and rearranging DOM nodes as needed.
|
623
|
-
*
|
624
|
-
* The algorithm for reconciling children works by analyzing two 'windows' onto
|
625
|
-
* the two arrays of children (`oldCh` and `newCh`). We keep track of the
|
626
|
-
* 'windows' by storing start and end indices and references to the
|
627
|
-
* corresponding array entries. Initially the two 'windows' are basically equal
|
628
|
-
* to the entire array, but we progressively narrow the windows until there are
|
629
|
-
* no children left to update by doing the following:
|
630
|
-
*
|
631
|
-
* 1. Skip any `null` entries at the beginning or end of the two arrays, so
|
632
|
-
* that if we have an initial array like the following we'll end up dealing
|
633
|
-
* only with a window bounded by the highlighted elements:
|
634
|
-
*
|
635
|
-
* [null, null, VNode1 , ... , VNode2, null, null]
|
636
|
-
* ^^^^^^ ^^^^^^
|
637
|
-
*
|
638
|
-
* 2. Check to see if the elements at the head and tail positions are equal
|
639
|
-
* across the windows. This will basically detect elements which haven't
|
640
|
-
* been added, removed, or changed position, i.e. if you had the following
|
641
|
-
* VNode elements (represented as HTML):
|
642
|
-
*
|
643
|
-
* oldVNode: `<div><p><span>HEY</span></p></div>`
|
644
|
-
* newVNode: `<div><p><span>THERE</span></p></div>`
|
645
|
-
*
|
646
|
-
* Then when comparing the children of the `<div>` tag we check the equality
|
647
|
-
* of the VNodes corresponding to the `<p>` tags and, since they are the
|
648
|
-
* same tag in the same position, we'd be able to avoid completely
|
649
|
-
* re-rendering the subtree under them with a new DOM element and would just
|
650
|
-
* call out to `patch` to handle reconciling their children and so on.
|
651
|
-
*
|
652
|
-
* 3. Check, for both windows, to see if the element at the beginning of the
|
653
|
-
* window corresponds to the element at the end of the other window. This is
|
654
|
-
* a heuristic which will let us identify _some_ situations in which
|
655
|
-
* elements have changed position, for instance it _should_ detect that the
|
656
|
-
* children nodes themselves have not changed but merely moved in the
|
657
|
-
* following example:
|
658
|
-
*
|
659
|
-
* oldVNode: `<div><element-one /><element-two /></div>`
|
660
|
-
* newVNode: `<div><element-two /><element-one /></div>`
|
661
|
-
*
|
662
|
-
* If we find cases like this then we also need to move the concrete DOM
|
663
|
-
* elements corresponding to the moved children to write the re-order to the
|
664
|
-
* DOM.
|
665
|
-
*
|
666
|
-
* 4. Finally, if VNodes have the `key` attribute set on them we check for any
|
667
|
-
* nodes in the old children which have the same key as the first element in
|
668
|
-
* our window on the new children. If we find such a node we handle calling
|
669
|
-
* out to `patch`, moving relevant DOM nodes, and so on, in accordance with
|
670
|
-
* what we find.
|
671
|
-
*
|
672
|
-
* Finally, once we've narrowed our 'windows' to the point that either of them
|
673
|
-
* collapse (i.e. they have length 0) we then handle any remaining VNode
|
674
|
-
* insertion or deletion that needs to happen to get a DOM state that correctly
|
675
|
-
* reflects the new child VNodes. If, for instance, after our window on the old
|
676
|
-
* children has collapsed we still have more nodes on the new children that
|
677
|
-
* we haven't dealt with yet then we need to add them, or if the new children
|
678
|
-
* collapse but we still have unhandled _old_ children then we need to make
|
679
|
-
* sure the corresponding DOM nodes are removed.
|
680
|
-
*
|
681
|
-
* @param parentElm the node into which the parent VNode is rendered
|
682
|
-
* @param oldCh the old children of the parent node
|
683
|
-
* @param newVNode the new VNode which will replace the parent
|
684
|
-
* @param newCh the new children of the parent node
|
685
|
-
* @param isInitialRender whether or not this is the first render of the vdom
|
686
|
-
*/
|
687
|
-
const updateChildren = (parentElm, oldCh, newVNode, newCh, isInitialRender = false) => {
|
688
|
-
let oldStartIdx = 0;
|
689
|
-
let newStartIdx = 0;
|
690
|
-
let idxInOld = 0;
|
691
|
-
let i = 0;
|
692
|
-
let oldEndIdx = oldCh.length - 1;
|
693
|
-
let oldStartVnode = oldCh[0];
|
694
|
-
let oldEndVnode = oldCh[oldEndIdx];
|
695
|
-
let newEndIdx = newCh.length - 1;
|
696
|
-
let newStartVnode = newCh[0];
|
697
|
-
let newEndVnode = newCh[newEndIdx];
|
698
|
-
let node;
|
699
|
-
let elmToMove;
|
700
|
-
while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
|
701
|
-
if (oldStartVnode == null) {
|
702
|
-
// VNode might have been moved left
|
703
|
-
oldStartVnode = oldCh[++oldStartIdx];
|
704
|
-
}
|
705
|
-
else if (oldEndVnode == null) {
|
706
|
-
oldEndVnode = oldCh[--oldEndIdx];
|
707
|
-
}
|
708
|
-
else if (newStartVnode == null) {
|
709
|
-
newStartVnode = newCh[++newStartIdx];
|
710
|
-
}
|
711
|
-
else if (newEndVnode == null) {
|
712
|
-
newEndVnode = newCh[--newEndIdx];
|
713
|
-
}
|
714
|
-
else if (isSameVnode(oldStartVnode, newStartVnode, isInitialRender)) {
|
715
|
-
// if the start nodes are the same then we should patch the new VNode
|
716
|
-
// onto the old one, and increment our `newStartIdx` and `oldStartIdx`
|
717
|
-
// indices to reflect that. We don't need to move any DOM Nodes around
|
718
|
-
// since things are matched up in order.
|
719
|
-
patch(oldStartVnode, newStartVnode, isInitialRender);
|
720
|
-
oldStartVnode = oldCh[++oldStartIdx];
|
721
|
-
newStartVnode = newCh[++newStartIdx];
|
722
|
-
}
|
723
|
-
else if (isSameVnode(oldEndVnode, newEndVnode, isInitialRender)) {
|
724
|
-
// likewise, if the end nodes are the same we patch new onto old and
|
725
|
-
// decrement our end indices, and also likewise in this case we don't
|
726
|
-
// need to move any DOM Nodes.
|
727
|
-
patch(oldEndVnode, newEndVnode, isInitialRender);
|
728
|
-
oldEndVnode = oldCh[--oldEndIdx];
|
729
|
-
newEndVnode = newCh[--newEndIdx];
|
730
|
-
}
|
731
|
-
else if (isSameVnode(oldStartVnode, newEndVnode, isInitialRender)) {
|
732
|
-
patch(oldStartVnode, newEndVnode, isInitialRender);
|
733
|
-
// We need to move the element for `oldStartVnode` into a position which
|
734
|
-
// will be appropriate for `newEndVnode`. For this we can use
|
735
|
-
// `.insertBefore` and `oldEndVnode.$elm$.nextSibling`. If there is a
|
736
|
-
// sibling for `oldEndVnode.$elm$` then we want to move the DOM node for
|
737
|
-
// `oldStartVnode` between `oldEndVnode` and it's sibling, like so:
|
738
|
-
//
|
739
|
-
// <old-start-node />
|
740
|
-
// <some-intervening-node />
|
741
|
-
// <old-end-node />
|
742
|
-
// <!-- -> <-- `oldStartVnode.$elm$` should be inserted here
|
743
|
-
// <next-sibling />
|
744
|
-
//
|
745
|
-
// If instead `oldEndVnode.$elm$` has no sibling then we just want to put
|
746
|
-
// the node for `oldStartVnode` at the end of the children of
|
747
|
-
// `parentElm`. Luckily, `Node.nextSibling` will return `null` if there
|
748
|
-
// aren't any siblings, and passing `null` to `Node.insertBefore` will
|
749
|
-
// append it to the children of the parent element.
|
750
|
-
parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
|
751
|
-
oldStartVnode = oldCh[++oldStartIdx];
|
752
|
-
newEndVnode = newCh[--newEndIdx];
|
753
|
-
}
|
754
|
-
else if (isSameVnode(oldEndVnode, newStartVnode, isInitialRender)) {
|
755
|
-
patch(oldEndVnode, newStartVnode, isInitialRender);
|
756
|
-
// We've already checked above if `oldStartVnode` and `newStartVnode` are
|
757
|
-
// the same node, so since we're here we know that they are not. Thus we
|
758
|
-
// can move the element for `oldEndVnode` _before_ the element for
|
759
|
-
// `oldStartVnode`, leaving `oldStartVnode` to be reconciled in the
|
760
|
-
// future.
|
761
|
-
parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
|
762
|
-
oldEndVnode = oldCh[--oldEndIdx];
|
763
|
-
newStartVnode = newCh[++newStartIdx];
|
764
|
-
}
|
765
|
-
else {
|
766
|
-
// Here we do some checks to match up old and new nodes based on the
|
767
|
-
// `$key$` attribute, which is set by putting a `key="my-key"` attribute
|
768
|
-
// in the JSX for a DOM element in the implementation of a Stencil
|
769
|
-
// component.
|
770
|
-
//
|
771
|
-
// First we check to see if there are any nodes in the array of old
|
772
|
-
// children which have the same key as the first node in the new
|
773
|
-
// children.
|
774
|
-
idxInOld = -1;
|
775
|
-
{
|
776
|
-
for (i = oldStartIdx; i <= oldEndIdx; ++i) {
|
777
|
-
if (oldCh[i] && oldCh[i].$key$ !== null && oldCh[i].$key$ === newStartVnode.$key$) {
|
778
|
-
idxInOld = i;
|
779
|
-
break;
|
780
|
-
}
|
781
|
-
}
|
782
|
-
}
|
783
|
-
if (idxInOld >= 0) {
|
784
|
-
// We found a node in the old children which matches up with the first
|
785
|
-
// node in the new children! So let's deal with that
|
786
|
-
elmToMove = oldCh[idxInOld];
|
787
|
-
if (elmToMove.$tag$ !== newStartVnode.$tag$) {
|
788
|
-
// the tag doesn't match so we'll need a new DOM element
|
789
|
-
node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld);
|
790
|
-
}
|
791
|
-
else {
|
792
|
-
patch(elmToMove, newStartVnode, isInitialRender);
|
793
|
-
// invalidate the matching old node so that we won't try to update it
|
794
|
-
// again later on
|
795
|
-
oldCh[idxInOld] = undefined;
|
796
|
-
node = elmToMove.$elm$;
|
797
|
-
}
|
798
|
-
newStartVnode = newCh[++newStartIdx];
|
799
|
-
}
|
800
|
-
else {
|
801
|
-
// We either didn't find an element in the old children that matches
|
802
|
-
// the key of the first new child OR the build is not using `key`
|
803
|
-
// attributes at all. In either case we need to create a new element
|
804
|
-
// for the new node.
|
805
|
-
node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
|
806
|
-
newStartVnode = newCh[++newStartIdx];
|
807
|
-
}
|
808
|
-
if (node) {
|
809
|
-
// if we created a new node then handle inserting it to the DOM
|
810
|
-
{
|
811
|
-
oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
|
812
|
-
}
|
813
|
-
}
|
814
|
-
}
|
815
|
-
}
|
816
|
-
if (oldStartIdx > oldEndIdx) {
|
817
|
-
// we have some more new nodes to add which don't match up with old nodes
|
818
|
-
addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
|
819
|
-
}
|
820
|
-
else if (newStartIdx > newEndIdx) {
|
821
|
-
// there are nodes in the `oldCh` array which no longer correspond to nodes
|
822
|
-
// in the new array, so lets remove them (which entails cleaning up the
|
823
|
-
// relevant DOM nodes)
|
824
|
-
removeVnodes(oldCh, oldStartIdx, oldEndIdx);
|
825
|
-
}
|
826
|
-
};
|
827
|
-
/**
|
828
|
-
* Compare two VNodes to determine if they are the same
|
829
|
-
*
|
830
|
-
* **NB**: This function is an equality _heuristic_ based on the available
|
831
|
-
* information set on the two VNodes and can be misleading under certain
|
832
|
-
* circumstances. In particular, if the two nodes do not have `key` attrs
|
833
|
-
* (available under `$key$` on VNodes) then the function falls back on merely
|
834
|
-
* checking that they have the same tag.
|
835
|
-
*
|
836
|
-
* So, in other words, if `key` attrs are not set on VNodes which may be
|
837
|
-
* changing order within a `children` array or something along those lines then
|
838
|
-
* we could obtain a false negative and then have to do needless re-rendering
|
839
|
-
* (i.e. we'd say two VNodes aren't equal when in fact they should be).
|
840
|
-
*
|
841
|
-
* @param leftVNode the first VNode to check
|
842
|
-
* @param rightVNode the second VNode to check
|
843
|
-
* @param isInitialRender whether or not this is the first render of the vdom
|
844
|
-
* @returns whether they're equal or not
|
845
|
-
*/
|
846
|
-
const isSameVnode = (leftVNode, rightVNode, isInitialRender = false) => {
|
847
|
-
// compare if two vnode to see if they're "technically" the same
|
848
|
-
// need to have the same element tag, and same key to be the same
|
849
|
-
if (leftVNode.$tag$ === rightVNode.$tag$) {
|
850
|
-
// this will be set if JSX tags in the build have `key` attrs set on them
|
851
|
-
// we only want to check this if we're not on the first render since on
|
852
|
-
// first render `leftVNode.$key$` will always be `null`, so we can be led
|
853
|
-
// astray and, for instance, accidentally delete a DOM node that we want to
|
854
|
-
// keep around.
|
855
|
-
if (!isInitialRender) {
|
856
|
-
return leftVNode.$key$ === rightVNode.$key$;
|
857
|
-
}
|
858
|
-
return true;
|
859
|
-
}
|
860
|
-
return false;
|
861
|
-
};
|
862
|
-
/**
|
863
|
-
* Handle reconciling an outdated VNode with a new one which corresponds to
|
864
|
-
* it. This function handles flushing updates to the DOM and reconciling the
|
865
|
-
* children of the two nodes (if any).
|
866
|
-
*
|
867
|
-
* @param oldVNode an old VNode whose DOM element and children we want to update
|
868
|
-
* @param newVNode a new VNode representing an updated version of the old one
|
869
|
-
* @param isInitialRender whether or not this is the first render of the vdom
|
870
|
-
*/
|
871
|
-
const patch = (oldVNode, newVNode, isInitialRender = false) => {
|
872
|
-
const elm = (newVNode.$elm$ = oldVNode.$elm$);
|
873
|
-
const oldChildren = oldVNode.$children$;
|
874
|
-
const newChildren = newVNode.$children$;
|
875
|
-
const tag = newVNode.$tag$;
|
876
|
-
const text = newVNode.$text$;
|
877
|
-
if (text === null) {
|
878
|
-
{
|
879
|
-
// test if we're rendering an svg element, or still rendering nodes inside of one
|
880
|
-
// only add this to the when the compiler sees we're using an svg somewhere
|
881
|
-
isSvgMode = tag === 'svg' ? true : tag === 'foreignObject' ? false : isSvgMode;
|
882
|
-
}
|
883
|
-
{
|
884
|
-
{
|
885
|
-
// either this is the first render of an element OR it's an update
|
886
|
-
// AND we already know it's possible it could have changed
|
887
|
-
// this updates the element's css classes, attrs, props, listeners, etc.
|
888
|
-
updateElement(oldVNode, newVNode, isSvgMode);
|
889
|
-
}
|
890
|
-
}
|
891
|
-
if (oldChildren !== null && newChildren !== null) {
|
892
|
-
// looks like there's child vnodes for both the old and new vnodes
|
893
|
-
// so we need to call `updateChildren` to reconcile them
|
894
|
-
updateChildren(elm, oldChildren, newVNode, newChildren, isInitialRender);
|
895
|
-
}
|
896
|
-
else if (newChildren !== null) {
|
897
|
-
// no old child vnodes, but there are new child vnodes to add
|
898
|
-
if (oldVNode.$text$ !== null) {
|
899
|
-
// the old vnode was text, so be sure to clear it out
|
900
|
-
elm.textContent = '';
|
901
|
-
}
|
902
|
-
// add the new vnode children
|
903
|
-
addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
|
904
|
-
}
|
905
|
-
else if (oldChildren !== null) {
|
906
|
-
// no new child vnodes, but there are old child vnodes to remove
|
907
|
-
removeVnodes(oldChildren, 0, oldChildren.length - 1);
|
908
|
-
}
|
909
|
-
if (isSvgMode && tag === 'svg') {
|
910
|
-
isSvgMode = false;
|
911
|
-
}
|
912
|
-
}
|
913
|
-
else if (oldVNode.$text$ !== text) {
|
914
|
-
// update the text content for the text only vnode
|
915
|
-
// and also only if the text is different than before
|
916
|
-
elm.data = text;
|
917
|
-
}
|
918
|
-
};
|
919
|
-
/**
|
920
|
-
* 'Nullify' any VDom `ref` callbacks on a VDom node or its children by calling
|
921
|
-
* them with `null`. This signals that the DOM element corresponding to the VDom
|
922
|
-
* node has been removed from the DOM.
|
923
|
-
*
|
924
|
-
* @param vNode a virtual DOM node
|
925
|
-
*/
|
926
|
-
const nullifyVNodeRefs = (vNode) => {
|
927
|
-
{
|
928
|
-
vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
|
929
|
-
vNode.$children$ && vNode.$children$.map(nullifyVNodeRefs);
|
930
|
-
}
|
931
|
-
};
|
932
|
-
/**
|
933
|
-
* The main entry point for Stencil's virtual DOM-based rendering engine
|
934
|
-
*
|
935
|
-
* Given a {@link d.HostRef} container and some virtual DOM nodes, this
|
936
|
-
* function will handle creating a virtual DOM tree with a single root, patching
|
937
|
-
* the current virtual DOM tree onto an old one (if any), dealing with slot
|
938
|
-
* relocation, and reflecting attributes.
|
939
|
-
*
|
940
|
-
* @param hostRef data needed to root and render the virtual DOM tree, such as
|
941
|
-
* the DOM node into which it should be rendered.
|
942
|
-
* @param renderFnResults the virtual DOM nodes to be rendered
|
943
|
-
* @param isInitialLoad whether or not this is the first call after page load
|
944
|
-
*/
|
945
|
-
const renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
|
946
|
-
const hostElm = hostRef.$hostElement$;
|
947
|
-
const oldVNode = hostRef.$vnode$ || newVNode(null, null);
|
948
|
-
// if `renderFnResults` is a Host node then we can use it directly. If not,
|
949
|
-
// we need to call `h` again to wrap the children of our component in a
|
950
|
-
// 'dummy' Host node (well, an empty vnode) since `renderVdom` assumes
|
951
|
-
// implicitly that the top-level vdom node is 1) an only child and 2)
|
952
|
-
// contains attrs that need to be set on the host element.
|
953
|
-
const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
|
954
|
-
hostTagName = hostElm.tagName;
|
955
|
-
// On the first render and *only* on the first render we want to check for
|
956
|
-
// any attributes set on the host element which are also set on the vdom
|
957
|
-
// node. If we find them, we override the value on the VDom node attrs with
|
958
|
-
// the value from the host element, which allows developers building apps
|
959
|
-
// with Stencil components to override e.g. the `role` attribute on a
|
960
|
-
// component even if it's already set on the `Host`.
|
961
|
-
if (isInitialLoad && rootVnode.$attrs$) {
|
962
|
-
for (const key of Object.keys(rootVnode.$attrs$)) {
|
963
|
-
// We have a special implementation in `setAccessor` for `style` and
|
964
|
-
// `class` which reconciles values coming from the VDom with values
|
965
|
-
// already present on the DOM element, so we don't want to override those
|
966
|
-
// attributes on the VDom tree with values from the host element if they
|
967
|
-
// are present.
|
968
|
-
//
|
969
|
-
// Likewise, `ref` and `key` are special internal values for the Stencil
|
970
|
-
// runtime and we don't want to override those either.
|
971
|
-
if (hostElm.hasAttribute(key) && !['key', 'ref', 'style', 'class'].includes(key)) {
|
972
|
-
rootVnode.$attrs$[key] = hostElm[key];
|
973
|
-
}
|
974
|
-
}
|
975
|
-
}
|
976
|
-
rootVnode.$tag$ = null;
|
977
|
-
rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
|
978
|
-
hostRef.$vnode$ = rootVnode;
|
979
|
-
rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
|
980
|
-
{
|
981
|
-
scopeId = hostElm['s-sc'];
|
982
|
-
}
|
983
|
-
// synchronous patch
|
984
|
-
patch(oldVNode, rootVnode, isInitialLoad);
|
985
|
-
};
|
986
|
-
const attachToAncestor = (hostRef, ancestorComponent) => {
|
987
|
-
if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
|
988
|
-
ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
|
989
|
-
}
|
990
|
-
};
|
991
|
-
const scheduleUpdate = (hostRef, isInitialLoad) => {
|
992
|
-
{
|
993
|
-
hostRef.$flags$ |= 16 /* HOST_FLAGS.isQueuedForUpdate */;
|
994
|
-
}
|
995
|
-
if (hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
|
996
|
-
hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
|
997
|
-
return;
|
998
|
-
}
|
999
|
-
attachToAncestor(hostRef, hostRef.$ancestorComponent$);
|
1000
|
-
// there is no ancestor component or the ancestor component
|
1001
|
-
// has already fired off its lifecycle update then
|
1002
|
-
// fire off the initial update
|
1003
|
-
const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
|
1004
|
-
return writeTask(dispatch) ;
|
1005
|
-
};
|
1006
|
-
/**
|
1007
|
-
* Dispatch initial-render and update lifecycle hooks, enqueuing calls to
|
1008
|
-
* component lifecycle methods like `componentWillLoad` as well as
|
1009
|
-
* {@link updateComponent}, which will kick off the virtual DOM re-render.
|
1010
|
-
*
|
1011
|
-
* @param hostRef a reference to a host DOM node
|
1012
|
-
* @param isInitialLoad whether we're on the initial load or not
|
1013
|
-
* @returns an empty Promise which is used to enqueue a series of operations for
|
1014
|
-
* the component
|
1015
|
-
*/
|
1016
|
-
const dispatchHooks = (hostRef, isInitialLoad) => {
|
1017
|
-
const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
|
1018
|
-
const instance = hostRef.$lazyInstance$ ;
|
1019
|
-
// We're going to use this variable together with `enqueue` to implement a
|
1020
|
-
// little promise-based queue. We start out with it `undefined`. When we add
|
1021
|
-
// the first function to the queue we'll set this variable to be that
|
1022
|
-
// function's return value. When we attempt to add subsequent values to the
|
1023
|
-
// queue we'll check that value and, if it was a `Promise`, we'll then chain
|
1024
|
-
// the new function off of that `Promise` using `.then()`. This will give our
|
1025
|
-
// queue two nice properties:
|
1026
|
-
//
|
1027
|
-
// 1. If all functions added to the queue are synchronous they'll be called
|
1028
|
-
// synchronously right away.
|
1029
|
-
// 2. If all functions added to the queue are asynchronous they'll all be
|
1030
|
-
// called in order after `dispatchHooks` exits.
|
1031
|
-
let maybePromise;
|
1032
|
-
if (isInitialLoad) {
|
1033
|
-
{
|
1034
|
-
// If `componentWillLoad` returns a `Promise` then we want to wait on
|
1035
|
-
// whatever's going on in that `Promise` before we launch into
|
1036
|
-
// rendering the component, doing other lifecycle stuff, etc. So
|
1037
|
-
// in that case we assign the returned promise to the variable we
|
1038
|
-
// declared above to hold a possible 'queueing' Promise
|
1039
|
-
maybePromise = safeCall(instance, 'componentWillLoad');
|
1040
|
-
}
|
1041
|
-
}
|
1042
|
-
endSchedule();
|
1043
|
-
return enqueue(maybePromise, () => updateComponent(hostRef, instance, isInitialLoad));
|
1044
|
-
};
|
1045
|
-
/**
|
1046
|
-
* This function uses a Promise to implement a simple first-in, first-out queue
|
1047
|
-
* of functions to be called.
|
1048
|
-
*
|
1049
|
-
* The queue is ordered on the basis of the first argument. If it's
|
1050
|
-
* `undefined`, then nothing is on the queue yet, so the provided function can
|
1051
|
-
* be called synchronously (although note that this function may return a
|
1052
|
-
* `Promise`). The idea is that then the return value of that enqueueing
|
1053
|
-
* operation is kept around, so that if it was a `Promise` then subsequent
|
1054
|
-
* functions can be enqueued by calling this function again with that `Promise`
|
1055
|
-
* as the first argument.
|
1056
|
-
*
|
1057
|
-
* @param maybePromise either a `Promise` which should resolve before the next function is called or an 'empty' sentinel
|
1058
|
-
* @param fn a function to enqueue
|
1059
|
-
* @returns either a `Promise` or the return value of the provided function
|
1060
|
-
*/
|
1061
|
-
const enqueue = (maybePromise, fn) => isPromisey(maybePromise) ? maybePromise.then(fn) : fn();
|
1062
|
-
/**
|
1063
|
-
* Check that a value is a `Promise`. To check, we first see if the value is an
|
1064
|
-
* instance of the `Promise` global. In a few circumstances, in particular if
|
1065
|
-
* the global has been overwritten, this is could be misleading, so we also do
|
1066
|
-
* a little 'duck typing' check to see if the `.then` property of the value is
|
1067
|
-
* defined and a function.
|
1068
|
-
*
|
1069
|
-
* @param maybePromise it might be a promise!
|
1070
|
-
* @returns whether it is or not
|
1071
|
-
*/
|
1072
|
-
const isPromisey = (maybePromise) => maybePromise instanceof Promise ||
|
1073
|
-
(maybePromise && maybePromise.then && typeof maybePromise.then === 'function');
|
1074
|
-
/**
|
1075
|
-
* Update a component given reference to its host elements and so on.
|
1076
|
-
*
|
1077
|
-
* @param hostRef an object containing references to the element's host node,
|
1078
|
-
* VDom nodes, and other metadata
|
1079
|
-
* @param instance a reference to the underlying host element where it will be
|
1080
|
-
* rendered
|
1081
|
-
* @param isInitialLoad whether or not this function is being called as part of
|
1082
|
-
* the first render cycle
|
1083
|
-
*/
|
1084
|
-
const updateComponent = async (hostRef, instance, isInitialLoad) => {
|
1085
|
-
var _a;
|
1086
|
-
const elm = hostRef.$hostElement$;
|
1087
|
-
const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
|
1088
|
-
const rc = elm['s-rc'];
|
1089
|
-
if (isInitialLoad) {
|
1090
|
-
// DOM WRITE!
|
1091
|
-
attachStyles(hostRef);
|
1092
|
-
}
|
1093
|
-
const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
|
1094
|
-
{
|
1095
|
-
callRender(hostRef, instance, elm, isInitialLoad);
|
1096
|
-
}
|
1097
|
-
if (rc) {
|
1098
|
-
// ok, so turns out there are some child host elements
|
1099
|
-
// waiting on this parent element to load
|
1100
|
-
// let's fire off all update callbacks waiting
|
1101
|
-
rc.map((cb) => cb());
|
1102
|
-
elm['s-rc'] = undefined;
|
1103
|
-
}
|
1104
|
-
endRender();
|
1105
|
-
endUpdate();
|
1106
|
-
{
|
1107
|
-
const childrenPromises = (_a = elm['s-p']) !== null && _a !== void 0 ? _a : [];
|
1108
|
-
const postUpdate = () => postUpdateComponent(hostRef);
|
1109
|
-
if (childrenPromises.length === 0) {
|
1110
|
-
postUpdate();
|
1111
|
-
}
|
1112
|
-
else {
|
1113
|
-
Promise.all(childrenPromises).then(postUpdate);
|
1114
|
-
hostRef.$flags$ |= 4 /* HOST_FLAGS.isWaitingForChildren */;
|
1115
|
-
childrenPromises.length = 0;
|
1116
|
-
}
|
1117
|
-
}
|
1118
|
-
};
|
1119
|
-
/**
|
1120
|
-
* Handle making the call to the VDom renderer with the proper context given
|
1121
|
-
* various build variables
|
1122
|
-
*
|
1123
|
-
* @param hostRef an object containing references to the element's host node,
|
1124
|
-
* VDom nodes, and other metadata
|
1125
|
-
* @param instance a reference to the underlying host element where it will be
|
1126
|
-
* rendered
|
1127
|
-
* @param elm the Host element for the component
|
1128
|
-
* @param isInitialLoad whether or not this function is being called as part of
|
1129
|
-
* @returns an empty promise
|
1130
|
-
*/
|
1131
|
-
const callRender = (hostRef, instance, elm, isInitialLoad) => {
|
1132
|
-
try {
|
1133
|
-
/**
|
1134
|
-
* minification optimization: `allRenderFn` is `true` if all components have a `render`
|
1135
|
-
* method, so we can call the method immediately. If not, check before calling it.
|
1136
|
-
*/
|
1137
|
-
instance = instance.render() ;
|
1138
|
-
{
|
1139
|
-
hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
|
1140
|
-
}
|
1141
|
-
{
|
1142
|
-
hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
|
1143
|
-
}
|
1144
|
-
{
|
1145
|
-
{
|
1146
|
-
// looks like we've got child nodes to render into this host element
|
1147
|
-
// or we need to update the css class/attrs on the host element
|
1148
|
-
// DOM WRITE!
|
1149
|
-
{
|
1150
|
-
renderVdom(hostRef, instance, isInitialLoad);
|
1151
|
-
}
|
1152
|
-
}
|
1153
|
-
}
|
1154
|
-
}
|
1155
|
-
catch (e) {
|
1156
|
-
consoleError(e, hostRef.$hostElement$);
|
1157
|
-
}
|
1158
|
-
return null;
|
1159
|
-
};
|
1160
|
-
const postUpdateComponent = (hostRef) => {
|
1161
|
-
const tagName = hostRef.$cmpMeta$.$tagName$;
|
1162
|
-
const elm = hostRef.$hostElement$;
|
1163
|
-
const endPostUpdate = createTime('postUpdate', tagName);
|
1164
|
-
const instance = hostRef.$lazyInstance$ ;
|
1165
|
-
const ancestorComponent = hostRef.$ancestorComponent$;
|
1166
|
-
if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
|
1167
|
-
hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
|
1168
|
-
{
|
1169
|
-
// DOM WRITE!
|
1170
|
-
addHydratedFlag(elm);
|
1171
|
-
}
|
1172
|
-
{
|
1173
|
-
safeCall(instance, 'componentDidLoad');
|
1174
|
-
}
|
1175
|
-
endPostUpdate();
|
1176
|
-
{
|
1177
|
-
hostRef.$onReadyResolve$(elm);
|
1178
|
-
if (!ancestorComponent) {
|
1179
|
-
appDidLoad();
|
1180
|
-
}
|
1181
|
-
}
|
1182
|
-
}
|
1183
|
-
else {
|
1184
|
-
endPostUpdate();
|
1185
|
-
}
|
1186
|
-
// load events fire from bottom to top
|
1187
|
-
// the deepest elements load first then bubbles up
|
1188
|
-
{
|
1189
|
-
if (hostRef.$onRenderResolve$) {
|
1190
|
-
hostRef.$onRenderResolve$();
|
1191
|
-
hostRef.$onRenderResolve$ = undefined;
|
1192
|
-
}
|
1193
|
-
if (hostRef.$flags$ & 512 /* HOST_FLAGS.needsRerender */) {
|
1194
|
-
nextTick(() => scheduleUpdate(hostRef, false));
|
1195
|
-
}
|
1196
|
-
hostRef.$flags$ &= ~(4 /* HOST_FLAGS.isWaitingForChildren */ | 512 /* HOST_FLAGS.needsRerender */);
|
1197
|
-
}
|
1198
|
-
// ( •_•)
|
1199
|
-
// ( •_•)>⌐■-■
|
1200
|
-
// (⌐■_■)
|
1201
|
-
};
|
1202
|
-
const appDidLoad = (who) => {
|
1203
|
-
// on appload
|
1204
|
-
// we have finish the first big initial render
|
1205
|
-
{
|
1206
|
-
addHydratedFlag(doc.documentElement);
|
1207
|
-
}
|
1208
|
-
nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
|
1209
|
-
};
|
1210
|
-
/**
|
1211
|
-
* Allows to safely call a method, e.g. `componentDidLoad`, on an instance,
|
1212
|
-
* e.g. custom element node. If a build figures out that e.g. no component
|
1213
|
-
* has a `componentDidLoad` method, the instance method gets removed from the
|
1214
|
-
* output bundle and this function returns `undefined`.
|
1215
|
-
* @param instance any object that may or may not contain methods
|
1216
|
-
* @param method method name
|
1217
|
-
* @param arg single arbitrary argument
|
1218
|
-
* @returns result of method call if it exists, otherwise `undefined`
|
1219
|
-
*/
|
1220
|
-
const safeCall = (instance, method, arg) => {
|
1221
|
-
if (instance && instance[method]) {
|
1222
|
-
try {
|
1223
|
-
return instance[method](arg);
|
1224
|
-
}
|
1225
|
-
catch (e) {
|
1226
|
-
consoleError(e);
|
1227
|
-
}
|
1228
|
-
}
|
1229
|
-
return undefined;
|
1230
|
-
};
|
1231
|
-
const addHydratedFlag = (elm) => elm.classList.add('hydrated')
|
1232
|
-
;
|
1233
|
-
const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
|
1234
|
-
const setValue = (ref, propName, newVal, cmpMeta) => {
|
1235
|
-
// check our new property value against our internal value
|
1236
|
-
const hostRef = getHostRef(ref);
|
1237
|
-
const oldVal = hostRef.$instanceValues$.get(propName);
|
1238
|
-
const flags = hostRef.$flags$;
|
1239
|
-
const instance = hostRef.$lazyInstance$ ;
|
1240
|
-
newVal = parsePropertyValue(newVal);
|
1241
|
-
// explicitly check for NaN on both sides, as `NaN === NaN` is always false
|
1242
|
-
const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
|
1243
|
-
const didValueChange = newVal !== oldVal && !areBothNaN;
|
1244
|
-
if ((!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
|
1245
|
-
// gadzooks! the property's value has changed!!
|
1246
|
-
// set our new value!
|
1247
|
-
hostRef.$instanceValues$.set(propName, newVal);
|
1248
|
-
if (instance) {
|
1249
|
-
if ((flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
|
1250
|
-
// looks like this value actually changed, so we've got work to do!
|
1251
|
-
// but only if we've already rendered, otherwise just chill out
|
1252
|
-
// queue that we need to do an update, but don't worry about queuing
|
1253
|
-
// up millions cuz this function ensures it only runs once
|
1254
|
-
scheduleUpdate(hostRef, false);
|
1255
|
-
}
|
1256
|
-
}
|
1257
|
-
}
|
1258
|
-
};
|
1259
|
-
/**
|
1260
|
-
* Attach a series of runtime constructs to a compiled Stencil component
|
1261
|
-
* constructor, including getters and setters for the `@Prop` and `@State`
|
1262
|
-
* decorators, callbacks for when attributes change, and so on.
|
1263
|
-
*
|
1264
|
-
* @param Cstr the constructor for a component that we need to process
|
1265
|
-
* @param cmpMeta metadata collected previously about the component
|
1266
|
-
* @param flags a number used to store a series of bit flags
|
1267
|
-
* @returns a reference to the same constructor passed in (but now mutated)
|
1268
|
-
*/
|
1269
|
-
const proxyComponent = (Cstr, cmpMeta, flags) => {
|
1270
|
-
var _a;
|
1271
|
-
const prototype = Cstr.prototype;
|
1272
|
-
if (cmpMeta.$members$) {
|
1273
|
-
// It's better to have a const than two Object.entries()
|
1274
|
-
const members = Object.entries(cmpMeta.$members$);
|
1275
|
-
members.map(([memberName, [memberFlags]]) => {
|
1276
|
-
if ((memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
|
1277
|
-
((flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
|
1278
|
-
// proxyComponent - prop
|
1279
|
-
Object.defineProperty(prototype, memberName, {
|
1280
|
-
get() {
|
1281
|
-
// proxyComponent, get value
|
1282
|
-
return getValue(this, memberName);
|
1283
|
-
},
|
1284
|
-
set(newValue) {
|
1285
|
-
// proxyComponent, set value
|
1286
|
-
setValue(this, memberName, newValue);
|
1287
|
-
},
|
1288
|
-
configurable: true,
|
1289
|
-
enumerable: true,
|
1290
|
-
});
|
1291
|
-
}
|
1292
|
-
});
|
1293
|
-
if ((flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
|
1294
|
-
const attrNameToPropName = new Map();
|
1295
|
-
prototype.attributeChangedCallback = function (attrName, oldValue, newValue) {
|
1296
|
-
plt.jmp(() => {
|
1297
|
-
var _a;
|
1298
|
-
const propName = attrNameToPropName.get(attrName);
|
1299
|
-
// In a web component lifecycle the attributeChangedCallback runs prior to connectedCallback
|
1300
|
-
// in the case where an attribute was set inline.
|
1301
|
-
// ```html
|
1302
|
-
// <my-component some-attribute="some-value"></my-component>
|
1303
|
-
// ```
|
1304
|
-
//
|
1305
|
-
// There is an edge case where a developer sets the attribute inline on a custom element and then
|
1306
|
-
// programmatically changes it before it has been upgraded as shown below:
|
1307
|
-
//
|
1308
|
-
// ```html
|
1309
|
-
// <!-- this component has _not_ been upgraded yet -->
|
1310
|
-
// <my-component id="test" some-attribute="some-value"></my-component>
|
1311
|
-
// <script>
|
1312
|
-
// // grab non-upgraded component
|
1313
|
-
// el = document.querySelector("#test");
|
1314
|
-
// el.someAttribute = "another-value";
|
1315
|
-
// // upgrade component
|
1316
|
-
// customElements.define('my-component', MyComponent);
|
1317
|
-
// </script>
|
1318
|
-
// ```
|
1319
|
-
// In this case if we do not un-shadow here and use the value of the shadowing property, attributeChangedCallback
|
1320
|
-
// will be called with `newValue = "some-value"` and will set the shadowed property (this.someAttribute = "another-value")
|
1321
|
-
// to the value that was set inline i.e. "some-value" from above example. When
|
1322
|
-
// the connectedCallback attempts to un-shadow it will use "some-value" as the initial value rather than "another-value"
|
1323
|
-
//
|
1324
|
-
// The case where the attribute was NOT set inline but was not set programmatically shall be handled/un-shadowed
|
1325
|
-
// by connectedCallback as this attributeChangedCallback will not fire.
|
1326
|
-
//
|
1327
|
-
// https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
|
1328
|
-
//
|
1329
|
-
// TODO(STENCIL-16) we should think about whether or not we actually want to be reflecting the attributes to
|
1330
|
-
// properties here given that this goes against best practices outlined here
|
1331
|
-
// https://developers.google.com/web/fundamentals/web-components/best-practices#avoid-reentrancy
|
1332
|
-
if (this.hasOwnProperty(propName)) {
|
1333
|
-
newValue = this[propName];
|
1334
|
-
delete this[propName];
|
1335
|
-
}
|
1336
|
-
else if (prototype.hasOwnProperty(propName) &&
|
1337
|
-
typeof this[propName] === 'number' &&
|
1338
|
-
this[propName] == newValue) {
|
1339
|
-
// if the propName exists on the prototype of `Cstr`, this update may be a result of Stencil using native
|
1340
|
-
// APIs to reflect props as attributes. Calls to `setAttribute(someElement, propName)` will result in
|
1341
|
-
// `propName` to be converted to a `DOMString`, which may not be what we want for other primitive props.
|
1342
|
-
return;
|
1343
|
-
}
|
1344
|
-
else if (propName == null) {
|
1345
|
-
// At this point we should know this is not a "member", so we can treat it like watching an attribute
|
1346
|
-
// on a vanilla web component
|
1347
|
-
const hostRef = getHostRef(this);
|
1348
|
-
const flags = hostRef === null || hostRef === void 0 ? void 0 : hostRef.$flags$;
|
1349
|
-
// We only want to trigger the callback(s) if:
|
1350
|
-
// 1. The instance is ready
|
1351
|
-
// 2. The watchers are ready
|
1352
|
-
// 3. The value has changed
|
1353
|
-
if (flags &&
|
1354
|
-
!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) &&
|
1355
|
-
flags & 128 /* HOST_FLAGS.isWatchReady */ &&
|
1356
|
-
newValue !== oldValue) {
|
1357
|
-
const instance = hostRef.$lazyInstance$ ;
|
1358
|
-
const entry = (_a = cmpMeta.$watchers$) === null || _a === void 0 ? void 0 : _a[attrName];
|
1359
|
-
entry === null || entry === void 0 ? void 0 : entry.forEach((callbackName) => {
|
1360
|
-
if (instance[callbackName] != null) {
|
1361
|
-
instance[callbackName].call(instance, newValue, oldValue, attrName);
|
1362
|
-
}
|
1363
|
-
});
|
1364
|
-
}
|
1365
|
-
return;
|
1366
|
-
}
|
1367
|
-
this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
|
1368
|
-
});
|
1369
|
-
};
|
1370
|
-
// Create an array of attributes to observe
|
1371
|
-
// This list in comprised of all strings used within a `@Watch()` decorator
|
1372
|
-
// on a component as well as any Stencil-specific "members" (`@Prop()`s and `@State()`s).
|
1373
|
-
// As such, there is no way to guarantee type-safety here that a user hasn't entered
|
1374
|
-
// an invalid attribute.
|
1375
|
-
Cstr.observedAttributes = Array.from(new Set([
|
1376
|
-
...Object.keys((_a = cmpMeta.$watchers$) !== null && _a !== void 0 ? _a : {}),
|
1377
|
-
...members
|
1378
|
-
.filter(([_, m]) => m[0] & 15 /* MEMBER_FLAGS.HasAttribute */)
|
1379
|
-
.map(([propName, m]) => {
|
1380
|
-
const attrName = m[1] || propName;
|
1381
|
-
attrNameToPropName.set(attrName, propName);
|
1382
|
-
return attrName;
|
1383
|
-
}),
|
1384
|
-
]));
|
1385
|
-
}
|
1386
|
-
}
|
1387
|
-
return Cstr;
|
1388
|
-
};
|
1389
|
-
/**
|
1390
|
-
* Initialize a Stencil component given a reference to its host element, its
|
1391
|
-
* runtime bookkeeping data structure, runtime metadata about the component,
|
1392
|
-
* and (optionally) an HMR version ID.
|
1393
|
-
*
|
1394
|
-
* @param elm a host element
|
1395
|
-
* @param hostRef the element's runtime bookkeeping object
|
1396
|
-
* @param cmpMeta runtime metadata for the Stencil component
|
1397
|
-
* @param hmrVersionId an (optional) HMR version ID
|
1398
|
-
*/
|
1399
|
-
const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
|
1400
|
-
let Cstr;
|
1401
|
-
// initializeComponent
|
1402
|
-
if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
|
1403
|
-
// Let the runtime know that the component has been initialized
|
1404
|
-
hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
|
1405
|
-
const bundleId = cmpMeta.$lazyBundleId$;
|
1406
|
-
if (bundleId) {
|
1407
|
-
// lazy loaded components
|
1408
|
-
// request the component's implementation to be
|
1409
|
-
// wired up with the host element
|
1410
|
-
Cstr = loadModule(cmpMeta);
|
1411
|
-
if (Cstr.then) {
|
1412
|
-
// Await creates a micro-task avoid if possible
|
1413
|
-
const endLoad = uniqueTime();
|
1414
|
-
Cstr = await Cstr;
|
1415
|
-
endLoad();
|
1416
|
-
}
|
1417
|
-
if (!Cstr.isProxied) {
|
1418
|
-
proxyComponent(Cstr, cmpMeta, 2 /* PROXY_FLAGS.proxyState */);
|
1419
|
-
Cstr.isProxied = true;
|
1420
|
-
}
|
1421
|
-
const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
|
1422
|
-
// ok, time to construct the instance
|
1423
|
-
// but let's keep track of when we start and stop
|
1424
|
-
// so that the getters/setters don't incorrectly step on data
|
1425
|
-
{
|
1426
|
-
hostRef.$flags$ |= 8 /* HOST_FLAGS.isConstructingInstance */;
|
1427
|
-
}
|
1428
|
-
// construct the lazy-loaded component implementation
|
1429
|
-
// passing the hostRef is very important during
|
1430
|
-
// construction in order to directly wire together the
|
1431
|
-
// host element and the lazy-loaded instance
|
1432
|
-
try {
|
1433
|
-
new Cstr(hostRef);
|
1434
|
-
}
|
1435
|
-
catch (e) {
|
1436
|
-
consoleError(e);
|
1437
|
-
}
|
1438
|
-
{
|
1439
|
-
hostRef.$flags$ &= ~8 /* HOST_FLAGS.isConstructingInstance */;
|
1440
|
-
}
|
1441
|
-
endNewInstance();
|
1442
|
-
}
|
1443
|
-
else {
|
1444
|
-
// sync constructor component
|
1445
|
-
Cstr = elm.constructor;
|
1446
|
-
// wait for the CustomElementRegistry to mark the component as ready before setting `isWatchReady`. Otherwise,
|
1447
|
-
// watchers may fire prematurely if `customElements.get()`/`customElements.whenDefined()` resolves _before_
|
1448
|
-
// Stencil has completed instantiating the component.
|
1449
|
-
customElements.whenDefined(cmpMeta.$tagName$).then(() => (hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */));
|
1450
|
-
}
|
1451
|
-
if (Cstr.style) {
|
1452
|
-
// this component has styles but we haven't registered them yet
|
1453
|
-
let style = Cstr.style;
|
1454
|
-
const scopeId = getScopeId(cmpMeta);
|
1455
|
-
if (!styles.has(scopeId)) {
|
1456
|
-
const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
|
1457
|
-
registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
|
1458
|
-
endRegisterStyles();
|
1459
|
-
}
|
1460
|
-
}
|
1461
|
-
}
|
1462
|
-
// we've successfully created a lazy instance
|
1463
|
-
const ancestorComponent = hostRef.$ancestorComponent$;
|
1464
|
-
const schedule = () => scheduleUpdate(hostRef, true);
|
1465
|
-
if (ancestorComponent && ancestorComponent['s-rc']) {
|
1466
|
-
// this is the initial load and this component it has an ancestor component
|
1467
|
-
// but the ancestor component has NOT fired its will update lifecycle yet
|
1468
|
-
// so let's just cool our jets and wait for the ancestor to continue first
|
1469
|
-
// this will get fired off when the ancestor component
|
1470
|
-
// finally gets around to rendering its lazy self
|
1471
|
-
// fire off the initial update
|
1472
|
-
ancestorComponent['s-rc'].push(schedule);
|
1473
|
-
}
|
1474
|
-
else {
|
1475
|
-
schedule();
|
1476
|
-
}
|
1477
|
-
};
|
1478
|
-
const fireConnectedCallback = (instance) => {
|
1479
|
-
};
|
1480
|
-
const connectedCallback = (elm) => {
|
1481
|
-
if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
|
1482
|
-
const hostRef = getHostRef(elm);
|
1483
|
-
const cmpMeta = hostRef.$cmpMeta$;
|
1484
|
-
const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
|
1485
|
-
if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
|
1486
|
-
// first time this component has connected
|
1487
|
-
hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
|
1488
|
-
{
|
1489
|
-
// find the first ancestor component (if there is one) and register
|
1490
|
-
// this component as one of the actively loading child components for its ancestor
|
1491
|
-
let ancestorComponent = elm;
|
1492
|
-
while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
|
1493
|
-
// climb up the ancestors looking for the first
|
1494
|
-
// component that hasn't finished its lifecycle update yet
|
1495
|
-
if (ancestorComponent['s-p']) {
|
1496
|
-
// we found this components first ancestor component
|
1497
|
-
// keep a reference to this component's ancestor component
|
1498
|
-
attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
|
1499
|
-
break;
|
1500
|
-
}
|
1501
|
-
}
|
1502
|
-
}
|
1503
|
-
// Lazy properties
|
1504
|
-
// https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
|
1505
|
-
if (cmpMeta.$members$) {
|
1506
|
-
Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
|
1507
|
-
if (memberFlags & 31 /* MEMBER_FLAGS.Prop */ && elm.hasOwnProperty(memberName)) {
|
1508
|
-
const value = elm[memberName];
|
1509
|
-
delete elm[memberName];
|
1510
|
-
elm[memberName] = value;
|
1511
|
-
}
|
1512
|
-
});
|
1513
|
-
}
|
1514
|
-
{
|
1515
|
-
initializeComponent(elm, hostRef, cmpMeta);
|
1516
|
-
}
|
1517
|
-
}
|
1518
|
-
else {
|
1519
|
-
// fire off connectedCallback() on component instance
|
1520
|
-
if (hostRef === null || hostRef === void 0 ? void 0 : hostRef.$lazyInstance$) ;
|
1521
|
-
else if (hostRef === null || hostRef === void 0 ? void 0 : hostRef.$onReadyPromise$) {
|
1522
|
-
hostRef.$onReadyPromise$.then(() => fireConnectedCallback());
|
1523
|
-
}
|
1524
|
-
}
|
1525
|
-
endConnected();
|
1526
|
-
}
|
1527
|
-
};
|
1528
|
-
const disconnectInstance = (instance) => {
|
1529
|
-
};
|
1530
|
-
const disconnectedCallback = async (elm) => {
|
1531
|
-
if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
|
1532
|
-
const hostRef = getHostRef(elm);
|
1533
|
-
if (hostRef === null || hostRef === void 0 ? void 0 : hostRef.$lazyInstance$) ;
|
1534
|
-
else if (hostRef === null || hostRef === void 0 ? void 0 : hostRef.$onReadyPromise$) {
|
1535
|
-
hostRef.$onReadyPromise$.then(() => disconnectInstance());
|
1536
|
-
}
|
1537
|
-
}
|
1538
|
-
};
|
1539
|
-
const bootstrapLazy = (lazyBundles, options = {}) => {
|
1540
|
-
var _a;
|
1541
|
-
const endBootstrap = createTime();
|
1542
|
-
const cmpTags = [];
|
1543
|
-
const exclude = options.exclude || [];
|
1544
|
-
const customElements = win.customElements;
|
1545
|
-
const head = doc.head;
|
1546
|
-
const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
|
1547
|
-
const dataStyles = /*@__PURE__*/ doc.createElement('style');
|
1548
|
-
const deferredConnectedCallbacks = [];
|
1549
|
-
let appLoadFallback;
|
1550
|
-
let isBootstrapping = true;
|
1551
|
-
Object.assign(plt, options);
|
1552
|
-
plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
|
1553
|
-
let hasSlotRelocation = false;
|
1554
|
-
lazyBundles.map((lazyBundle) => {
|
1555
|
-
lazyBundle[1].map((compactMeta) => {
|
1556
|
-
const cmpMeta = {
|
1557
|
-
$flags$: compactMeta[0],
|
1558
|
-
$tagName$: compactMeta[1],
|
1559
|
-
$members$: compactMeta[2],
|
1560
|
-
$listeners$: compactMeta[3],
|
1561
|
-
};
|
1562
|
-
// Check if we are using slots outside the shadow DOM in this component.
|
1563
|
-
// We'll use this information later to add styles for `slot-fb` elements
|
1564
|
-
if (cmpMeta.$flags$ & 4 /* CMP_FLAGS.hasSlotRelocation */) {
|
1565
|
-
hasSlotRelocation = true;
|
1566
|
-
}
|
1567
|
-
{
|
1568
|
-
cmpMeta.$members$ = compactMeta[2];
|
1569
|
-
}
|
1570
|
-
const tagName = cmpMeta.$tagName$;
|
1571
|
-
const HostElement = class extends HTMLElement {
|
1572
|
-
// StencilLazyHost
|
1573
|
-
constructor(self) {
|
1574
|
-
// @ts-ignore
|
1575
|
-
super(self);
|
1576
|
-
self = this;
|
1577
|
-
registerHost(self, cmpMeta);
|
1578
|
-
if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
|
1579
|
-
// this component is using shadow dom
|
1580
|
-
// and this browser supports shadow dom
|
1581
|
-
// add the read-only property "shadowRoot" to the host element
|
1582
|
-
// adding the shadow root build conditionals to minimize runtime
|
1583
|
-
{
|
1584
|
-
{
|
1585
|
-
self.attachShadow({ mode: 'open' });
|
1586
|
-
}
|
1587
|
-
}
|
1588
|
-
}
|
1589
|
-
}
|
1590
|
-
connectedCallback() {
|
1591
|
-
if (appLoadFallback) {
|
1592
|
-
clearTimeout(appLoadFallback);
|
1593
|
-
appLoadFallback = null;
|
1594
|
-
}
|
1595
|
-
if (isBootstrapping) {
|
1596
|
-
// connectedCallback will be processed once all components have been registered
|
1597
|
-
deferredConnectedCallbacks.push(this);
|
1598
|
-
}
|
1599
|
-
else {
|
1600
|
-
plt.jmp(() => connectedCallback(this));
|
1601
|
-
}
|
1602
|
-
}
|
1603
|
-
disconnectedCallback() {
|
1604
|
-
plt.jmp(() => disconnectedCallback(this));
|
1605
|
-
}
|
1606
|
-
componentOnReady() {
|
1607
|
-
return getHostRef(this).$onReadyPromise$;
|
1608
|
-
}
|
1609
|
-
};
|
1610
|
-
cmpMeta.$lazyBundleId$ = lazyBundle[0];
|
1611
|
-
if (!exclude.includes(tagName) && !customElements.get(tagName)) {
|
1612
|
-
cmpTags.push(tagName);
|
1613
|
-
customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */));
|
1614
|
-
}
|
1615
|
-
});
|
1616
|
-
});
|
1617
|
-
// Only bother generating CSS if we have components
|
1618
|
-
// TODO(STENCIL-1118): Add test cases for CSS content based on conditionals
|
1619
|
-
if (cmpTags.length > 0) {
|
1620
|
-
// Add styles for `slot-fb` elements if any of our components are using slots outside the Shadow DOM
|
1621
|
-
if (hasSlotRelocation) {
|
1622
|
-
dataStyles.textContent += SLOT_FB_CSS;
|
1623
|
-
}
|
1624
|
-
// Add hydration styles
|
1625
|
-
{
|
1626
|
-
dataStyles.textContent += cmpTags + HYDRATED_CSS;
|
1627
|
-
}
|
1628
|
-
// If we have styles, add them to the DOM
|
1629
|
-
if (dataStyles.innerHTML.length) {
|
1630
|
-
dataStyles.setAttribute('data-styles', '');
|
1631
|
-
// Apply CSP nonce to the style tag if it exists
|
1632
|
-
const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
|
1633
|
-
if (nonce != null) {
|
1634
|
-
dataStyles.setAttribute('nonce', nonce);
|
1635
|
-
}
|
1636
|
-
// Insert the styles into the document head
|
1637
|
-
// NOTE: this _needs_ to happen last so we can ensure the nonce (and other attributes) are applied
|
1638
|
-
head.insertBefore(dataStyles, metaCharset ? metaCharset.nextSibling : head.firstChild);
|
1639
|
-
}
|
1640
|
-
}
|
1641
|
-
// Process deferred connectedCallbacks now all components have been registered
|
1642
|
-
isBootstrapping = false;
|
1643
|
-
if (deferredConnectedCallbacks.length) {
|
1644
|
-
deferredConnectedCallbacks.map((host) => host.connectedCallback());
|
1645
|
-
}
|
1646
|
-
else {
|
1647
|
-
{
|
1648
|
-
plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30)));
|
1649
|
-
}
|
1650
|
-
}
|
1651
|
-
// Fallback appLoad event
|
1652
|
-
endBootstrap();
|
1653
|
-
};
|
1654
|
-
/**
|
1655
|
-
* Assigns the given value to the nonce property on the runtime platform object.
|
1656
|
-
* During runtime, this value is used to set the nonce attribute on all dynamically created script and style tags.
|
1657
|
-
* @param nonce The value to be assigned to the platform nonce property.
|
1658
|
-
* @returns void
|
1659
|
-
*/
|
1660
|
-
const setNonce = (nonce) => (plt.$nonce$ = nonce);
|
1661
|
-
/**
|
1662
|
-
* A WeakMap mapping runtime component references to their corresponding host reference
|
1663
|
-
* instances.
|
1664
|
-
*
|
1665
|
-
* **Note**: If we're in an HMR context we need to store a reference to this
|
1666
|
-
* value on `window` in order to maintain the mapping of {@link d.RuntimeRef}
|
1667
|
-
* to {@link d.HostRef} across HMR updates.
|
1668
|
-
*
|
1669
|
-
* This is necessary because when HMR updates for a component are processed by
|
1670
|
-
* the browser-side dev server client the JS bundle for that component is
|
1671
|
-
* re-fetched. Since the module containing {@link hostRefs} is included in
|
1672
|
-
* that bundle, if we do not store a reference to it the new iteration of the
|
1673
|
-
* component will not have access to the previous hostRef map, leading to a
|
1674
|
-
* bug where the new version of the component cannot properly initialize.
|
1675
|
-
*/
|
1676
|
-
const hostRefs = new WeakMap();
|
1677
|
-
/**
|
1678
|
-
* Given a {@link d.RuntimeRef} retrieve the corresponding {@link d.HostRef}
|
1679
|
-
*
|
1680
|
-
* @param ref the runtime ref of interest
|
1681
|
-
* @returns the Host reference (if found) or undefined
|
1682
|
-
*/
|
1683
|
-
const getHostRef = (ref) => hostRefs.get(ref);
|
1684
|
-
/**
|
1685
|
-
* Register a lazy instance with the {@link hostRefs} object so it's
|
1686
|
-
* corresponding {@link d.HostRef} can be retrieved later.
|
1687
|
-
*
|
1688
|
-
* @param lazyInstance the lazy instance of interest
|
1689
|
-
* @param hostRef that instances `HostRef` object
|
1690
|
-
* @returns a reference to the host ref WeakMap
|
1691
|
-
*/
|
1692
|
-
const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
|
1693
|
-
/**
|
1694
|
-
* Register a host element for a Stencil component, setting up various metadata
|
1695
|
-
* and callbacks based on {@link BUILD} flags as well as the component's runtime
|
1696
|
-
* metadata.
|
1697
|
-
*
|
1698
|
-
* @param hostElement the host element to register
|
1699
|
-
* @param cmpMeta runtime metadata for that component
|
1700
|
-
* @returns a reference to the host ref WeakMap
|
1701
|
-
*/
|
1702
|
-
const registerHost = (hostElement, cmpMeta) => {
|
1703
|
-
const hostRef = {
|
1704
|
-
$flags$: 0,
|
1705
|
-
$hostElement$: hostElement,
|
1706
|
-
$cmpMeta$: cmpMeta,
|
1707
|
-
$instanceValues$: new Map(),
|
1708
|
-
};
|
1709
|
-
{
|
1710
|
-
hostRef.$onReadyPromise$ = new Promise((r) => (hostRef.$onReadyResolve$ = r));
|
1711
|
-
hostElement['s-p'] = [];
|
1712
|
-
hostElement['s-rc'] = [];
|
1713
|
-
}
|
1714
|
-
return hostRefs.set(hostElement, hostRef);
|
1715
|
-
};
|
1716
|
-
const isMemberInElement = (elm, memberName) => memberName in elm;
|
1717
|
-
const consoleError = (e, el) => (0, console.error)(e, el);
|
1718
|
-
const cmpModules = /*@__PURE__*/ new Map();
|
1719
|
-
const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
|
1720
|
-
// loadModuleImport
|
1721
|
-
const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
|
1722
|
-
const bundleId = cmpMeta.$lazyBundleId$;
|
1723
|
-
const module = cmpModules.get(bundleId) ;
|
1724
|
-
if (module) {
|
1725
|
-
return module[exportName];
|
1726
|
-
}
|
1727
|
-
/*!__STENCIL_STATIC_IMPORT_SWITCH__*/
|
1728
|
-
return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
|
1729
|
-
/* @vite-ignore */
|
1730
|
-
/* webpackInclude: /\.entry\.js$/ */
|
1731
|
-
/* webpackExclude: /\.system\.entry\.js$/ */
|
1732
|
-
/* webpackMode: "lazy" */
|
1733
|
-
`./${bundleId}.entry.js${''}`)); }).then((importedModule) => {
|
1734
|
-
{
|
1735
|
-
cmpModules.set(bundleId, importedModule);
|
1736
|
-
}
|
1737
|
-
return importedModule[exportName];
|
1738
|
-
}, consoleError);
|
1739
|
-
};
|
1740
|
-
const styles = /*@__PURE__*/ new Map();
|
1741
|
-
const win = typeof window !== 'undefined' ? window : {};
|
1742
|
-
const doc = win.document || { head: {} };
|
1743
|
-
const plt = {
|
1744
|
-
$flags$: 0,
|
1745
|
-
$resourcesUrl$: '',
|
1746
|
-
jmp: (h) => h(),
|
1747
|
-
raf: (h) => requestAnimationFrame(h),
|
1748
|
-
ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
|
1749
|
-
rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
|
1750
|
-
ce: (eventName, opts) => new CustomEvent(eventName, opts),
|
1751
|
-
};
|
1752
|
-
const promiseResolve = (v) => Promise.resolve(v);
|
1753
|
-
const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
|
1754
|
-
try {
|
1755
|
-
new CSSStyleSheet();
|
1756
|
-
return typeof new CSSStyleSheet().replaceSync === 'function';
|
1757
|
-
}
|
1758
|
-
catch (e) { }
|
1759
|
-
return false;
|
1760
|
-
})()
|
1761
|
-
;
|
1762
|
-
const queueDomReads = [];
|
1763
|
-
const queueDomWrites = [];
|
1764
|
-
const queueTask = (queue, write) => (cb) => {
|
1765
|
-
queue.push(cb);
|
1766
|
-
if (!queuePending) {
|
1767
|
-
queuePending = true;
|
1768
|
-
if (write && plt.$flags$ & 4 /* PLATFORM_FLAGS.queueSync */) {
|
1769
|
-
nextTick(flush);
|
1770
|
-
}
|
1771
|
-
else {
|
1772
|
-
plt.raf(flush);
|
1773
|
-
}
|
1774
|
-
}
|
1775
|
-
};
|
1776
|
-
const consume = (queue) => {
|
1777
|
-
for (let i = 0; i < queue.length; i++) {
|
1778
|
-
try {
|
1779
|
-
queue[i](performance.now());
|
1780
|
-
}
|
1781
|
-
catch (e) {
|
1782
|
-
consoleError(e);
|
1783
|
-
}
|
1784
|
-
}
|
1785
|
-
queue.length = 0;
|
1786
|
-
};
|
1787
|
-
const flush = () => {
|
1788
|
-
// always force a bunch of medium callbacks to run, but still have
|
1789
|
-
// a throttle on how many can run in a certain time
|
1790
|
-
// DOM READS!!!
|
1791
|
-
consume(queueDomReads);
|
1792
|
-
// DOM WRITES!!!
|
1793
|
-
{
|
1794
|
-
consume(queueDomWrites);
|
1795
|
-
if ((queuePending = queueDomReads.length > 0)) {
|
1796
|
-
// still more to do yet, but we've run out of time
|
1797
|
-
// let's let this thing cool off and try again in the next tick
|
1798
|
-
plt.raf(flush);
|
1799
|
-
}
|
1800
|
-
}
|
1801
|
-
};
|
1802
|
-
const nextTick = (cb) => promiseResolve().then(cb);
|
1803
|
-
const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
|
1804
|
-
|
1805
|
-
exports.bootstrapLazy = bootstrapLazy;
|
1806
|
-
exports.h = h;
|
1807
|
-
exports.promiseResolve = promiseResolve;
|
1808
|
-
exports.registerInstance = registerInstance;
|
1809
|
-
exports.setNonce = setNonce;
|