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