favesalon-embed 0.1.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/chat-button.cjs.entry.js +118 -0
- package/dist/cjs/favesalon-embed.cjs.js +7 -3
- package/dist/cjs/google-map_5.cjs.entry.js +26 -7
- package/dist/cjs/{index-e6bea8f5.js → index-47c2a5f6.js} +512 -208
- package/dist/cjs/loader.cjs.js +4 -3
- package/dist/cjs/relativeTime-3721080d.js +9 -0
- package/dist/cjs/salon-booking-modal.cjs.entry.js +3 -2
- package/dist/cjs/salon-booking.cjs.entry.js +3 -2
- package/dist/cjs/salon-gift-card-modal.cjs.entry.js +3 -2
- package/dist/cjs/salon-gift-card.cjs.entry.js +3 -2
- package/dist/cjs/salon-latest-reviews.cjs.entry.js +5 -3
- package/dist/cjs/salon-lookbook.cjs.entry.js +7 -3
- package/dist/cjs/salon-ranking.cjs.entry.js +3 -2
- package/dist/cjs/salon-reviews.cjs.entry.js +10 -3
- package/dist/cjs/salon-services.cjs.entry.js +6 -3
- package/dist/cjs/salon-stylists.cjs.entry.js +9 -3
- package/dist/cjs/services-125c82d8.js +21492 -0
- package/dist/cjs/style-detail.cjs.entry.js +11 -9
- package/dist/cjs/user-avatar.cjs.entry.js +7 -3
- package/dist/collection/collection-manifest.json +3 -2
- package/dist/collection/components/chat-button/index.css +122 -0
- package/dist/collection/components/chat-button/index.js +218 -0
- package/dist/collection/components/chat-conversation/index.js +103 -0
- package/dist/collection/components/google-map/index.js +72 -68
- package/dist/collection/components/salon-booking/index.css +5 -0
- package/dist/collection/components/salon-booking/index.js +85 -80
- package/dist/collection/components/salon-booking/salon-booking-modal.js +73 -69
- package/dist/collection/components/salon-gift-card/index.css +6 -1
- package/dist/collection/components/salon-gift-card/index.js +85 -80
- package/dist/collection/components/salon-gift-card/salon-gift-card-modal.js +56 -52
- package/dist/collection/components/salon-info/index.css +1 -0
- package/dist/collection/components/salon-info/index.js +60 -54
- package/dist/collection/components/salon-latest-reviews/index.css +3 -0
- package/dist/collection/components/salon-latest-reviews/index.js +131 -144
- package/dist/collection/components/salon-latest-styles/index.css +2 -0
- package/dist/collection/components/salon-latest-styles/index.js +143 -138
- package/dist/collection/components/salon-locations/index.css +3 -0
- package/dist/collection/components/salon-locations/index.js +112 -120
- package/dist/collection/components/salon-lookbook/index.css +3 -0
- package/dist/collection/components/salon-lookbook/index.js +182 -190
- package/dist/collection/components/salon-ranking/index.js +68 -65
- package/dist/collection/components/salon-reviews/index.css +3 -0
- package/dist/collection/components/salon-reviews/index.js +146 -183
- package/dist/collection/components/salon-schedules/index.css +3 -0
- package/dist/collection/components/salon-schedules/index.js +129 -151
- package/dist/collection/components/salon-services/index.css +1 -0
- package/dist/collection/components/salon-services/index.js +117 -127
- package/dist/collection/components/salon-stylists/index.css +8 -0
- package/dist/collection/components/salon-stylists/index.js +137 -136
- package/dist/collection/components/style-detail/index.css +14 -0
- package/dist/collection/components/style-detail/index.js +265 -340
- package/dist/collection/components/user-avatar/index.js +119 -112
- package/dist/collection/mocks/users.js +10 -0
- package/dist/collection/services/services.js +121 -0
- package/dist/collection/types/chat.js +23 -0
- package/dist/collection/types/user.js +1 -1
- package/dist/custom-elements/index.d.ts +6 -0
- package/dist/custom-elements/index.js +24628 -8605
- package/dist/esm/chat-button.entry.js +114 -0
- package/dist/esm/favesalon-embed.js +4 -3
- package/dist/esm/google-map_5.entry.js +26 -7
- package/dist/esm/{index-6af0a03d.js → index-3fae868e.js} +512 -209
- package/dist/esm/loader.js +4 -3
- package/dist/esm/polyfills/css-shim.js +1 -1
- package/dist/esm/relativeTime-cd452e6d.js +7 -0
- package/dist/esm/salon-booking-modal.entry.js +3 -2
- package/dist/esm/salon-booking.entry.js +3 -2
- package/dist/esm/salon-gift-card-modal.entry.js +3 -2
- package/dist/esm/salon-gift-card.entry.js +3 -2
- package/dist/esm/salon-latest-reviews.entry.js +5 -3
- package/dist/esm/salon-lookbook.entry.js +7 -3
- package/dist/esm/salon-ranking.entry.js +3 -2
- package/dist/esm/salon-reviews.entry.js +10 -3
- package/dist/esm/salon-services.entry.js +6 -3
- package/dist/esm/salon-stylists.entry.js +9 -3
- package/dist/esm/services-40a3e622.js +21485 -0
- package/dist/esm/style-detail.entry.js +10 -8
- package/dist/esm/user-avatar.entry.js +7 -3
- package/dist/favesalon-embed/favesalon-embed.esm.js +1 -1
- package/dist/favesalon-embed/p-019c5ccd.entry.js +1 -0
- package/dist/favesalon-embed/p-083a8821.entry.js +1 -0
- package/dist/favesalon-embed/p-0d0ed9ea.entry.js +1 -0
- package/dist/favesalon-embed/p-119db8de.entry.js +1 -0
- package/dist/favesalon-embed/p-1432c51b.entry.js +1 -0
- package/dist/favesalon-embed/p-22093506.entry.js +1 -0
- package/dist/favesalon-embed/p-32b314e9.js +2 -0
- package/dist/favesalon-embed/p-4a5eca9a.js +1 -1
- package/dist/favesalon-embed/p-58d2e9be.js +1 -0
- package/dist/favesalon-embed/p-71404b6a.entry.js +1 -0
- package/dist/favesalon-embed/p-857c3a61.entry.js +1 -0
- package/dist/favesalon-embed/p-99ec77f7.entry.js +1 -0
- package/dist/favesalon-embed/p-b0c3673a.entry.js +1 -0
- package/dist/favesalon-embed/p-b287b1ea.entry.js +1 -0
- package/dist/favesalon-embed/p-b3af7842.entry.js +1 -0
- package/dist/favesalon-embed/p-b630ae68.js +1580 -0
- package/dist/favesalon-embed/p-ce2c1c9a.entry.js +1 -0
- package/dist/favesalon-embed/p-d9b7ad58.entry.js +1 -0
- package/dist/favesalon-embed/p-fc9a5551.js +1 -1
- package/dist/types/components/chat-button/index.d.ts +24 -0
- package/dist/types/components.d.ts +22 -0
- package/dist/types/mocks/users.d.ts +10 -0
- package/dist/types/services/services.d.ts +15 -0
- package/dist/types/stencil-public-runtime.d.ts +85 -11
- package/dist/types/types/chat.d.ts +17 -0
- package/loader/index.d.ts +9 -0
- package/loader/package.json +1 -0
- package/package.json +3 -3
- package/readme.md +2 -2
- package/dist/cjs/services-eee8f251.js +0 -5634
- package/dist/esm/services-295247b1.js +0 -5627
- package/dist/favesalon-embed/p-292b97ba.entry.js +0 -1
- package/dist/favesalon-embed/p-4869dfed.entry.js +0 -1
- package/dist/favesalon-embed/p-4aee4fd9.entry.js +0 -1
- package/dist/favesalon-embed/p-5528c705.entry.js +0 -1
- package/dist/favesalon-embed/p-612ad685.entry.js +0 -1
- package/dist/favesalon-embed/p-75aef7e0.entry.js +0 -1
- package/dist/favesalon-embed/p-8c780874.entry.js +0 -1
- package/dist/favesalon-embed/p-8dbf04c5.js +0 -1
- package/dist/favesalon-embed/p-9f31061a.entry.js +0 -1
- package/dist/favesalon-embed/p-a60d78e9.entry.js +0 -1
- package/dist/favesalon-embed/p-a6debdae.entry.js +0 -1
- package/dist/favesalon-embed/p-bad1e9a7.entry.js +0 -1
- package/dist/favesalon-embed/p-c2ecb365.js +0 -1
- package/dist/favesalon-embed/p-c7dea70c.entry.js +0 -1
- package/dist/favesalon-embed/p-f0e14641.entry.js +0 -1
- package/dist/types/types/tmp.d.ts +0 -0
- /package/dist/{collection/types/tmp.js → types/components/chat-conversation/index.d.ts} +0 -0
|
@@ -1,30 +1,19 @@
|
|
|
1
1
|
const NAMESPACE = 'favesalon-embed';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Virtual DOM patching algorithm based on Snabbdom by
|
|
5
|
+
* Simon Friis Vindum (@paldepind)
|
|
6
|
+
* Licensed under the MIT License
|
|
7
|
+
* https://github.com/snabbdom/snabbdom/blob/master/LICENSE
|
|
8
|
+
*
|
|
9
|
+
* Modified for Stencil's renderer and slot projection
|
|
10
|
+
*/
|
|
3
11
|
let isSvgMode = false;
|
|
4
12
|
let queuePending = false;
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
$flags$: 0,
|
|
9
|
-
$resourcesUrl$: '',
|
|
10
|
-
jmp: (h) => h(),
|
|
11
|
-
raf: (h) => requestAnimationFrame(h),
|
|
12
|
-
ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
|
|
13
|
-
rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
|
|
14
|
-
ce: (eventName, opts) => new CustomEvent(eventName, opts),
|
|
13
|
+
const getAssetPath = (path) => {
|
|
14
|
+
const assetUrl = new URL(path, plt.$resourcesUrl$);
|
|
15
|
+
return assetUrl.origin !== win.location.origin ? assetUrl.href : assetUrl.pathname;
|
|
15
16
|
};
|
|
16
|
-
const promiseResolve = (v) => Promise.resolve(v);
|
|
17
|
-
const supportsConstructibleStylesheets = /*@__PURE__*/ (() => {
|
|
18
|
-
try {
|
|
19
|
-
new CSSStyleSheet();
|
|
20
|
-
return typeof new CSSStyleSheet().replace === 'function';
|
|
21
|
-
}
|
|
22
|
-
catch (e) { }
|
|
23
|
-
return false;
|
|
24
|
-
})()
|
|
25
|
-
;
|
|
26
|
-
const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
|
|
27
|
-
const XLINK_NS = 'http://www.w3.org/1999/xlink';
|
|
28
17
|
const createTime = (fnName, tagName = '') => {
|
|
29
18
|
{
|
|
30
19
|
return () => {
|
|
@@ -39,59 +28,8 @@ const uniqueTime = (key, measureText) => {
|
|
|
39
28
|
};
|
|
40
29
|
}
|
|
41
30
|
};
|
|
42
|
-
const
|
|
43
|
-
const
|
|
44
|
-
let style = styles.get(scopeId);
|
|
45
|
-
if (supportsConstructibleStylesheets && allowCS) {
|
|
46
|
-
style = (style || new CSSStyleSheet());
|
|
47
|
-
style.replace(cssText);
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
style = cssText;
|
|
51
|
-
}
|
|
52
|
-
styles.set(scopeId, style);
|
|
53
|
-
};
|
|
54
|
-
const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
|
|
55
|
-
let scopeId = getScopeId(cmpMeta);
|
|
56
|
-
let style = styles.get(scopeId);
|
|
57
|
-
// if an element is NOT connected then getRootNode() will return the wrong root node
|
|
58
|
-
// so the fallback is to always use the document for the root node in those cases
|
|
59
|
-
styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
|
|
60
|
-
if (style) {
|
|
61
|
-
if (typeof style === 'string') {
|
|
62
|
-
styleContainerNode = styleContainerNode.head || styleContainerNode;
|
|
63
|
-
let appliedStyles = rootAppliedStyles.get(styleContainerNode);
|
|
64
|
-
let styleElm;
|
|
65
|
-
if (!appliedStyles) {
|
|
66
|
-
rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
|
|
67
|
-
}
|
|
68
|
-
if (!appliedStyles.has(scopeId)) {
|
|
69
|
-
{
|
|
70
|
-
{
|
|
71
|
-
styleElm = doc.createElement('style');
|
|
72
|
-
styleElm.innerHTML = style;
|
|
73
|
-
}
|
|
74
|
-
styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
|
|
75
|
-
}
|
|
76
|
-
if (appliedStyles) {
|
|
77
|
-
appliedStyles.add(scopeId);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
|
|
82
|
-
styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
return scopeId;
|
|
86
|
-
};
|
|
87
|
-
const attachStyles = (hostRef) => {
|
|
88
|
-
const cmpMeta = hostRef.$cmpMeta$;
|
|
89
|
-
const elm = hostRef.$hostElement$;
|
|
90
|
-
const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
|
|
91
|
-
addStyle(elm.getRootNode(), cmpMeta);
|
|
92
|
-
endAttachStyles();
|
|
93
|
-
};
|
|
94
|
-
const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
|
|
31
|
+
const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
|
|
32
|
+
const XLINK_NS = 'http://www.w3.org/1999/xlink';
|
|
95
33
|
/**
|
|
96
34
|
* Default style mode id
|
|
97
35
|
*/
|
|
@@ -110,6 +48,18 @@ const isComplexType = (o) => {
|
|
|
110
48
|
o = typeof o;
|
|
111
49
|
return o === 'object' || o === 'function';
|
|
112
50
|
};
|
|
51
|
+
/**
|
|
52
|
+
* Helper method for querying a `meta` tag that contains a nonce value
|
|
53
|
+
* out of a DOM's head.
|
|
54
|
+
*
|
|
55
|
+
* @param doc The DOM containing the `head` to query against
|
|
56
|
+
* @returns The content of the meta tag representing the nonce value, or `undefined` if no tag
|
|
57
|
+
* exists or the tag has no content.
|
|
58
|
+
*/
|
|
59
|
+
function queryNonceMetaTagContent(doc) {
|
|
60
|
+
var _a, _b, _c;
|
|
61
|
+
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;
|
|
62
|
+
}
|
|
113
63
|
/**
|
|
114
64
|
* Production h() function based on Preact by
|
|
115
65
|
* Jason Miller (@developit)
|
|
@@ -118,7 +68,6 @@ const isComplexType = (o) => {
|
|
|
118
68
|
*
|
|
119
69
|
* Modified for Stencil's compiler and vdom
|
|
120
70
|
*/
|
|
121
|
-
// const stack: any[] = [];
|
|
122
71
|
// export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
|
|
123
72
|
// export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
|
|
124
73
|
const h = (nodeName, vnodeData, ...children) => {
|
|
@@ -126,7 +75,7 @@ const h = (nodeName, vnodeData, ...children) => {
|
|
|
126
75
|
let key = null;
|
|
127
76
|
let simple = false;
|
|
128
77
|
let lastSimple = false;
|
|
129
|
-
|
|
78
|
+
const vNodeChildren = [];
|
|
130
79
|
const walk = (c) => {
|
|
131
80
|
for (let i = 0; i < c.length; i++) {
|
|
132
81
|
child = c[i];
|
|
@@ -177,6 +126,14 @@ const h = (nodeName, vnodeData, ...children) => {
|
|
|
177
126
|
}
|
|
178
127
|
return vnode;
|
|
179
128
|
};
|
|
129
|
+
/**
|
|
130
|
+
* A utility function for creating a virtual DOM node from a tag and some
|
|
131
|
+
* possible text content.
|
|
132
|
+
*
|
|
133
|
+
* @param tag the tag for this element
|
|
134
|
+
* @param text possible text content for the node
|
|
135
|
+
* @returns a newly-minted virtual DOM node
|
|
136
|
+
*/
|
|
180
137
|
const newVNode = (tag, text) => {
|
|
181
138
|
const vnode = {
|
|
182
139
|
$flags$: 0,
|
|
@@ -194,7 +151,136 @@ const newVNode = (tag, text) => {
|
|
|
194
151
|
return vnode;
|
|
195
152
|
};
|
|
196
153
|
const Host = {};
|
|
154
|
+
/**
|
|
155
|
+
* Check whether a given node is a Host node or not
|
|
156
|
+
*
|
|
157
|
+
* @param node the virtual DOM node to check
|
|
158
|
+
* @returns whether it's a Host node or not
|
|
159
|
+
*/
|
|
197
160
|
const isHost = (node) => node && node.$tag$ === Host;
|
|
161
|
+
/**
|
|
162
|
+
* Parse a new property value for a given property type.
|
|
163
|
+
*
|
|
164
|
+
* While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
|
|
165
|
+
* it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
|
|
166
|
+
* 1. `any`, the type given to `propValue` in the function signature
|
|
167
|
+
* 2. the type stored from `propType`.
|
|
168
|
+
*
|
|
169
|
+
* This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
|
|
170
|
+
*
|
|
171
|
+
* Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
|
|
172
|
+
* a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
|
|
173
|
+
* based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
|
|
174
|
+
* ```tsx
|
|
175
|
+
* <my-cmp prop-val={0}></my-cmp>
|
|
176
|
+
* ```
|
|
177
|
+
*
|
|
178
|
+
* HTML prop values on the other hand, will always a string
|
|
179
|
+
*
|
|
180
|
+
* @param propValue the new value to coerce to some type
|
|
181
|
+
* @param propType the type of the prop, expressed as a binary number
|
|
182
|
+
* @returns the parsed/coerced value
|
|
183
|
+
*/
|
|
184
|
+
const parsePropertyValue = (propValue, propType) => {
|
|
185
|
+
// ensure this value is of the correct prop type
|
|
186
|
+
if (propValue != null && !isComplexType(propValue)) {
|
|
187
|
+
if (propType & 4 /* MEMBER_FLAGS.Boolean */) {
|
|
188
|
+
// per the HTML spec, any string value means it is a boolean true value
|
|
189
|
+
// but we'll cheat here and say that the string "false" is the boolean false
|
|
190
|
+
return propValue === 'false' ? false : propValue === '' || !!propValue;
|
|
191
|
+
}
|
|
192
|
+
if (propType & 2 /* MEMBER_FLAGS.Number */) {
|
|
193
|
+
// force it to be a number
|
|
194
|
+
return parseFloat(propValue);
|
|
195
|
+
}
|
|
196
|
+
if (propType & 1 /* MEMBER_FLAGS.String */) {
|
|
197
|
+
// could have been passed as a number or boolean
|
|
198
|
+
// but we still want it as a string
|
|
199
|
+
return String(propValue);
|
|
200
|
+
}
|
|
201
|
+
// redundant return here for better minification
|
|
202
|
+
return propValue;
|
|
203
|
+
}
|
|
204
|
+
// not sure exactly what type we want
|
|
205
|
+
// so no need to change to a different type
|
|
206
|
+
return propValue;
|
|
207
|
+
};
|
|
208
|
+
/**
|
|
209
|
+
* Helper function to create & dispatch a custom Event on a provided target
|
|
210
|
+
* @param elm the target of the Event
|
|
211
|
+
* @param name the name to give the custom Event
|
|
212
|
+
* @param opts options for configuring a custom Event
|
|
213
|
+
* @returns the custom Event
|
|
214
|
+
*/
|
|
215
|
+
const emitEvent = (elm, name, opts) => {
|
|
216
|
+
const ev = plt.ce(name, opts);
|
|
217
|
+
elm.dispatchEvent(ev);
|
|
218
|
+
return ev;
|
|
219
|
+
};
|
|
220
|
+
const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
|
|
221
|
+
const registerStyle = (scopeId, cssText, allowCS) => {
|
|
222
|
+
let style = styles.get(scopeId);
|
|
223
|
+
if (supportsConstructableStylesheets && allowCS) {
|
|
224
|
+
style = (style || new CSSStyleSheet());
|
|
225
|
+
if (typeof style === 'string') {
|
|
226
|
+
style = cssText;
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
style.replaceSync(cssText);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
style = cssText;
|
|
234
|
+
}
|
|
235
|
+
styles.set(scopeId, style);
|
|
236
|
+
};
|
|
237
|
+
const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
|
|
238
|
+
var _a;
|
|
239
|
+
let scopeId = getScopeId(cmpMeta);
|
|
240
|
+
const style = styles.get(scopeId);
|
|
241
|
+
// if an element is NOT connected then getRootNode() will return the wrong root node
|
|
242
|
+
// so the fallback is to always use the document for the root node in those cases
|
|
243
|
+
styleContainerNode = styleContainerNode.nodeType === 11 /* NODE_TYPE.DocumentFragment */ ? styleContainerNode : doc;
|
|
244
|
+
if (style) {
|
|
245
|
+
if (typeof style === 'string') {
|
|
246
|
+
styleContainerNode = styleContainerNode.head || styleContainerNode;
|
|
247
|
+
let appliedStyles = rootAppliedStyles.get(styleContainerNode);
|
|
248
|
+
let styleElm;
|
|
249
|
+
if (!appliedStyles) {
|
|
250
|
+
rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
|
|
251
|
+
}
|
|
252
|
+
if (!appliedStyles.has(scopeId)) {
|
|
253
|
+
{
|
|
254
|
+
{
|
|
255
|
+
styleElm = doc.createElement('style');
|
|
256
|
+
styleElm.innerHTML = style;
|
|
257
|
+
}
|
|
258
|
+
// Apply CSP nonce to the style tag if it exists
|
|
259
|
+
const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
|
|
260
|
+
if (nonce != null) {
|
|
261
|
+
styleElm.setAttribute('nonce', nonce);
|
|
262
|
+
}
|
|
263
|
+
styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
|
|
264
|
+
}
|
|
265
|
+
if (appliedStyles) {
|
|
266
|
+
appliedStyles.add(scopeId);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
|
|
271
|
+
styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
return scopeId;
|
|
275
|
+
};
|
|
276
|
+
const attachStyles = (hostRef) => {
|
|
277
|
+
const cmpMeta = hostRef.$cmpMeta$;
|
|
278
|
+
const elm = hostRef.$hostElement$;
|
|
279
|
+
const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
|
|
280
|
+
addStyle(elm.getRootNode(), cmpMeta);
|
|
281
|
+
endAttachStyles();
|
|
282
|
+
};
|
|
283
|
+
const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
|
|
198
284
|
/**
|
|
199
285
|
* Production setAccessor() function based on Preact by
|
|
200
286
|
* Jason Miller (@developit)
|
|
@@ -292,11 +378,10 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
|
|
292
378
|
if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
|
|
293
379
|
try {
|
|
294
380
|
if (!elm.tagName.includes('-')) {
|
|
295
|
-
|
|
381
|
+
const n = newValue == null ? '' : newValue;
|
|
296
382
|
// Workaround for Safari, moving the <input> caret when re-assigning the same valued
|
|
297
383
|
if (memberName === 'list') {
|
|
298
384
|
isProp = false;
|
|
299
|
-
// tslint:disable-next-line: triple-equals
|
|
300
385
|
}
|
|
301
386
|
else if (oldValue == null || elm[memberName] != n) {
|
|
302
387
|
elm[memberName] = n;
|
|
@@ -332,7 +417,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
|
|
332
417
|
}
|
|
333
418
|
}
|
|
334
419
|
}
|
|
335
|
-
else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
|
|
420
|
+
else if ((!isProp || flags & 4 /* VNODE_FLAGS.isHost */ || isSvg) && !isComplex) {
|
|
336
421
|
newValue = newValue === true ? '' : newValue;
|
|
337
422
|
if (xlink) {
|
|
338
423
|
elm.setAttributeNS(XLINK_NS, memberName, newValue);
|
|
@@ -350,7 +435,7 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
|
|
|
350
435
|
// if the element passed in is a shadow root, which is a document fragment
|
|
351
436
|
// then we want to be adding attrs/props to the shadow root's "host" element
|
|
352
437
|
// if it's not a shadow root, then we add attrs/props to the same element
|
|
353
|
-
const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host
|
|
438
|
+
const elm = newVnode.$elm$.nodeType === 11 /* NODE_TYPE.DocumentFragment */ && newVnode.$elm$.host
|
|
354
439
|
? newVnode.$elm$.host
|
|
355
440
|
: newVnode.$elm$;
|
|
356
441
|
const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
|
|
@@ -368,9 +453,19 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
|
|
|
368
453
|
setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
|
|
369
454
|
}
|
|
370
455
|
};
|
|
456
|
+
/**
|
|
457
|
+
* Create a DOM Node corresponding to one of the children of a given VNode.
|
|
458
|
+
*
|
|
459
|
+
* @param oldParentVNode the parent VNode from the previous render
|
|
460
|
+
* @param newParentVNode the parent VNode from the current render
|
|
461
|
+
* @param childIndex the index of the VNode, in the _new_ parent node's
|
|
462
|
+
* children, for which we will create a new DOM node
|
|
463
|
+
* @param parentElm the parent DOM node which our new node will be a child of
|
|
464
|
+
* @returns the newly created node
|
|
465
|
+
*/
|
|
371
466
|
const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
372
467
|
// tslint:disable-next-line: prefer-const
|
|
373
|
-
|
|
468
|
+
const newVNode = newParentVNode.$children$[childIndex];
|
|
374
469
|
let i = 0;
|
|
375
470
|
let elm;
|
|
376
471
|
let childNode;
|
|
@@ -416,6 +511,21 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
416
511
|
}
|
|
417
512
|
return elm;
|
|
418
513
|
};
|
|
514
|
+
/**
|
|
515
|
+
* Create DOM nodes corresponding to a list of {@link d.Vnode} objects and
|
|
516
|
+
* add them to the DOM in the appropriate place.
|
|
517
|
+
*
|
|
518
|
+
* @param parentElm the DOM node which should be used as a parent for the new
|
|
519
|
+
* DOM nodes
|
|
520
|
+
* @param before a child of the `parentElm` which the new children should be
|
|
521
|
+
* inserted before (optional)
|
|
522
|
+
* @param parentVNode the parent virtual DOM node
|
|
523
|
+
* @param vnodes the new child virtual DOM nodes to produce DOM nodes for
|
|
524
|
+
* @param startIdx the index in the child virtual DOM nodes at which to start
|
|
525
|
+
* creating DOM nodes (inclusive)
|
|
526
|
+
* @param endIdx the index in the child virtual DOM nodes at which to stop
|
|
527
|
+
* creating DOM nodes (inclusive)
|
|
528
|
+
*/
|
|
419
529
|
const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
|
|
420
530
|
let containerElm = (parentElm);
|
|
421
531
|
let childNode;
|
|
@@ -429,6 +539,19 @@ const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) =>
|
|
|
429
539
|
}
|
|
430
540
|
}
|
|
431
541
|
};
|
|
542
|
+
/**
|
|
543
|
+
* Remove the DOM elements corresponding to a list of {@link d.VNode} objects.
|
|
544
|
+
* This can be used to, for instance, clean up after a list of children which
|
|
545
|
+
* should no longer be shown.
|
|
546
|
+
*
|
|
547
|
+
* This function also handles some of Stencil's slot relocation logic.
|
|
548
|
+
*
|
|
549
|
+
* @param vnodes a list of virtual DOM nodes to remove
|
|
550
|
+
* @param startIdx the index at which to start removing nodes (inclusive)
|
|
551
|
+
* @param endIdx the index at which to stop removing nodes (inclusive)
|
|
552
|
+
* @param vnode a VNode
|
|
553
|
+
* @param elm an element
|
|
554
|
+
*/
|
|
432
555
|
const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
|
|
433
556
|
for (; startIdx <= endIdx; ++startIdx) {
|
|
434
557
|
if ((vnode = vnodes[startIdx])) {
|
|
@@ -439,6 +562,74 @@ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
|
|
|
439
562
|
}
|
|
440
563
|
}
|
|
441
564
|
};
|
|
565
|
+
/**
|
|
566
|
+
* Reconcile the children of a new VNode with the children of an old VNode by
|
|
567
|
+
* traversing the two collections of children, identifying nodes that are
|
|
568
|
+
* conserved or changed, calling out to `patch` to make any necessary
|
|
569
|
+
* updates to the DOM, and rearranging DOM nodes as needed.
|
|
570
|
+
*
|
|
571
|
+
* The algorithm for reconciling children works by analyzing two 'windows' onto
|
|
572
|
+
* the two arrays of children (`oldCh` and `newCh`). We keep track of the
|
|
573
|
+
* 'windows' by storing start and end indices and references to the
|
|
574
|
+
* corresponding array entries. Initially the two 'windows' are basically equal
|
|
575
|
+
* to the entire array, but we progressively narrow the windows until there are
|
|
576
|
+
* no children left to update by doing the following:
|
|
577
|
+
*
|
|
578
|
+
* 1. Skip any `null` entries at the beginning or end of the two arrays, so
|
|
579
|
+
* that if we have an initial array like the following we'll end up dealing
|
|
580
|
+
* only with a window bounded by the highlighted elements:
|
|
581
|
+
*
|
|
582
|
+
* [null, null, VNode1 , ... , VNode2, null, null]
|
|
583
|
+
* ^^^^^^ ^^^^^^
|
|
584
|
+
*
|
|
585
|
+
* 2. Check to see if the elements at the head and tail positions are equal
|
|
586
|
+
* across the windows. This will basically detect elements which haven't
|
|
587
|
+
* been added, removed, or changed position, i.e. if you had the following
|
|
588
|
+
* VNode elements (represented as HTML):
|
|
589
|
+
*
|
|
590
|
+
* oldVNode: `<div><p><span>HEY</span></p></div>`
|
|
591
|
+
* newVNode: `<div><p><span>THERE</span></p></div>`
|
|
592
|
+
*
|
|
593
|
+
* Then when comparing the children of the `<div>` tag we check the equality
|
|
594
|
+
* of the VNodes corresponding to the `<p>` tags and, since they are the
|
|
595
|
+
* same tag in the same position, we'd be able to avoid completely
|
|
596
|
+
* re-rendering the subtree under them with a new DOM element and would just
|
|
597
|
+
* call out to `patch` to handle reconciling their children and so on.
|
|
598
|
+
*
|
|
599
|
+
* 3. Check, for both windows, to see if the element at the beginning of the
|
|
600
|
+
* window corresponds to the element at the end of the other window. This is
|
|
601
|
+
* a heuristic which will let us identify _some_ situations in which
|
|
602
|
+
* elements have changed position, for instance it _should_ detect that the
|
|
603
|
+
* children nodes themselves have not changed but merely moved in the
|
|
604
|
+
* following example:
|
|
605
|
+
*
|
|
606
|
+
* oldVNode: `<div><element-one /><element-two /></div>`
|
|
607
|
+
* newVNode: `<div><element-two /><element-one /></div>`
|
|
608
|
+
*
|
|
609
|
+
* If we find cases like this then we also need to move the concrete DOM
|
|
610
|
+
* elements corresponding to the moved children to write the re-order to the
|
|
611
|
+
* DOM.
|
|
612
|
+
*
|
|
613
|
+
* 4. Finally, if VNodes have the `key` attribute set on them we check for any
|
|
614
|
+
* nodes in the old children which have the same key as the first element in
|
|
615
|
+
* our window on the new children. If we find such a node we handle calling
|
|
616
|
+
* out to `patch`, moving relevant DOM nodes, and so on, in accordance with
|
|
617
|
+
* what we find.
|
|
618
|
+
*
|
|
619
|
+
* Finally, once we've narrowed our 'windows' to the point that either of them
|
|
620
|
+
* collapse (i.e. they have length 0) we then handle any remaining VNode
|
|
621
|
+
* insertion or deletion that needs to happen to get a DOM state that correctly
|
|
622
|
+
* reflects the new child VNodes. If, for instance, after our window on the old
|
|
623
|
+
* children has collapsed we still have more nodes on the new children that
|
|
624
|
+
* we haven't dealt with yet then we need to add them, or if the new children
|
|
625
|
+
* collapse but we still have unhandled _old_ children then we need to make
|
|
626
|
+
* sure the corresponding DOM nodes are removed.
|
|
627
|
+
*
|
|
628
|
+
* @param parentElm the node into which the parent VNode is rendered
|
|
629
|
+
* @param oldCh the old children of the parent node
|
|
630
|
+
* @param newVNode the new VNode which will replace the parent
|
|
631
|
+
* @param newCh the new children of the parent node
|
|
632
|
+
*/
|
|
442
633
|
const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
443
634
|
let oldStartIdx = 0;
|
|
444
635
|
let newStartIdx = 0;
|
|
@@ -454,7 +645,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
454
645
|
let elmToMove;
|
|
455
646
|
while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
|
|
456
647
|
if (oldStartVnode == null) {
|
|
457
|
-
//
|
|
648
|
+
// VNode might have been moved left
|
|
458
649
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
459
650
|
}
|
|
460
651
|
else if (oldEndVnode == null) {
|
|
@@ -467,29 +658,65 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
467
658
|
newEndVnode = newCh[--newEndIdx];
|
|
468
659
|
}
|
|
469
660
|
else if (isSameVnode(oldStartVnode, newStartVnode)) {
|
|
661
|
+
// if the start nodes are the same then we should patch the new VNode
|
|
662
|
+
// onto the old one, and increment our `newStartIdx` and `oldStartIdx`
|
|
663
|
+
// indices to reflect that. We don't need to move any DOM Nodes around
|
|
664
|
+
// since things are matched up in order.
|
|
470
665
|
patch(oldStartVnode, newStartVnode);
|
|
471
666
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
472
667
|
newStartVnode = newCh[++newStartIdx];
|
|
473
668
|
}
|
|
474
669
|
else if (isSameVnode(oldEndVnode, newEndVnode)) {
|
|
670
|
+
// likewise, if the end nodes are the same we patch new onto old and
|
|
671
|
+
// decrement our end indices, and also likewise in this case we don't
|
|
672
|
+
// need to move any DOM Nodes.
|
|
475
673
|
patch(oldEndVnode, newEndVnode);
|
|
476
674
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
477
675
|
newEndVnode = newCh[--newEndIdx];
|
|
478
676
|
}
|
|
479
677
|
else if (isSameVnode(oldStartVnode, newEndVnode)) {
|
|
480
678
|
patch(oldStartVnode, newEndVnode);
|
|
679
|
+
// We need to move the element for `oldStartVnode` into a position which
|
|
680
|
+
// will be appropriate for `newEndVnode`. For this we can use
|
|
681
|
+
// `.insertBefore` and `oldEndVnode.$elm$.nextSibling`. If there is a
|
|
682
|
+
// sibling for `oldEndVnode.$elm$` then we want to move the DOM node for
|
|
683
|
+
// `oldStartVnode` between `oldEndVnode` and it's sibling, like so:
|
|
684
|
+
//
|
|
685
|
+
// <old-start-node />
|
|
686
|
+
// <some-intervening-node />
|
|
687
|
+
// <old-end-node />
|
|
688
|
+
// <!-- -> <-- `oldStartVnode.$elm$` should be inserted here
|
|
689
|
+
// <next-sibling />
|
|
690
|
+
//
|
|
691
|
+
// If instead `oldEndVnode.$elm$` has no sibling then we just want to put
|
|
692
|
+
// the node for `oldStartVnode` at the end of the children of
|
|
693
|
+
// `parentElm`. Luckily, `Node.nextSibling` will return `null` if there
|
|
694
|
+
// aren't any siblings, and passing `null` to `Node.insertBefore` will
|
|
695
|
+
// append it to the children of the parent element.
|
|
481
696
|
parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
|
|
482
697
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
483
698
|
newEndVnode = newCh[--newEndIdx];
|
|
484
699
|
}
|
|
485
700
|
else if (isSameVnode(oldEndVnode, newStartVnode)) {
|
|
486
701
|
patch(oldEndVnode, newStartVnode);
|
|
702
|
+
// We've already checked above if `oldStartVnode` and `newStartVnode` are
|
|
703
|
+
// the same node, so since we're here we know that they are not. Thus we
|
|
704
|
+
// can move the element for `oldEndVnode` _before_ the element for
|
|
705
|
+
// `oldStartVnode`, leaving `oldStartVnode` to be reconciled in the
|
|
706
|
+
// future.
|
|
487
707
|
parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
|
|
488
708
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
489
709
|
newStartVnode = newCh[++newStartIdx];
|
|
490
710
|
}
|
|
491
711
|
else {
|
|
492
|
-
//
|
|
712
|
+
// Here we do some checks to match up old and new nodes based on the
|
|
713
|
+
// `$key$` attribute, which is set by putting a `key="my-key"` attribute
|
|
714
|
+
// in the JSX for a DOM element in the implementation of a Stencil
|
|
715
|
+
// component.
|
|
716
|
+
//
|
|
717
|
+
// First we check to see if there are any nodes in the array of old
|
|
718
|
+
// children which have the same key as the first node in the new
|
|
719
|
+
// children.
|
|
493
720
|
idxInOld = -1;
|
|
494
721
|
{
|
|
495
722
|
for (i = oldStartIdx; i <= oldEndIdx; ++i) {
|
|
@@ -500,23 +727,32 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
500
727
|
}
|
|
501
728
|
}
|
|
502
729
|
if (idxInOld >= 0) {
|
|
730
|
+
// We found a node in the old children which matches up with the first
|
|
731
|
+
// node in the new children! So let's deal with that
|
|
503
732
|
elmToMove = oldCh[idxInOld];
|
|
504
733
|
if (elmToMove.$tag$ !== newStartVnode.$tag$) {
|
|
734
|
+
// the tag doesn't match so we'll need a new DOM element
|
|
505
735
|
node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld);
|
|
506
736
|
}
|
|
507
737
|
else {
|
|
508
738
|
patch(elmToMove, newStartVnode);
|
|
739
|
+
// invalidate the matching old node so that we won't try to update it
|
|
740
|
+
// again later on
|
|
509
741
|
oldCh[idxInOld] = undefined;
|
|
510
742
|
node = elmToMove.$elm$;
|
|
511
743
|
}
|
|
512
744
|
newStartVnode = newCh[++newStartIdx];
|
|
513
745
|
}
|
|
514
746
|
else {
|
|
515
|
-
//
|
|
747
|
+
// We either didn't find an element in the old children that matches
|
|
748
|
+
// the key of the first new child OR the build is not using `key`
|
|
749
|
+
// attributes at all. In either case we need to create a new element
|
|
750
|
+
// for the new node.
|
|
516
751
|
node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
|
|
517
752
|
newStartVnode = newCh[++newStartIdx];
|
|
518
753
|
}
|
|
519
754
|
if (node) {
|
|
755
|
+
// if we created a new node then handle inserting it to the DOM
|
|
520
756
|
{
|
|
521
757
|
oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
|
|
522
758
|
}
|
|
@@ -524,22 +760,53 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
524
760
|
}
|
|
525
761
|
}
|
|
526
762
|
if (oldStartIdx > oldEndIdx) {
|
|
763
|
+
// we have some more new nodes to add which don't match up with old nodes
|
|
527
764
|
addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
|
|
528
765
|
}
|
|
529
766
|
else if (newStartIdx > newEndIdx) {
|
|
767
|
+
// there are nodes in the `oldCh` array which no longer correspond to nodes
|
|
768
|
+
// in the new array, so lets remove them (which entails cleaning up the
|
|
769
|
+
// relevant DOM nodes)
|
|
530
770
|
removeVnodes(oldCh, oldStartIdx, oldEndIdx);
|
|
531
771
|
}
|
|
532
772
|
};
|
|
533
|
-
|
|
773
|
+
/**
|
|
774
|
+
* Compare two VNodes to determine if they are the same
|
|
775
|
+
*
|
|
776
|
+
* **NB**: This function is an equality _heuristic_ based on the available
|
|
777
|
+
* information set on the two VNodes and can be misleading under certain
|
|
778
|
+
* circumstances. In particular, if the two nodes do not have `key` attrs
|
|
779
|
+
* (available under `$key$` on VNodes) then the function falls back on merely
|
|
780
|
+
* checking that they have the same tag.
|
|
781
|
+
*
|
|
782
|
+
* So, in other words, if `key` attrs are not set on VNodes which may be
|
|
783
|
+
* changing order within a `children` array or something along those lines then
|
|
784
|
+
* we could obtain a false negative and then have to do needless re-rendering
|
|
785
|
+
* (i.e. we'd say two VNodes aren't equal when in fact they should be).
|
|
786
|
+
*
|
|
787
|
+
* @param leftVNode the first VNode to check
|
|
788
|
+
* @param rightVNode the second VNode to check
|
|
789
|
+
* @returns whether they're equal or not
|
|
790
|
+
*/
|
|
791
|
+
const isSameVnode = (leftVNode, rightVNode) => {
|
|
534
792
|
// compare if two vnode to see if they're "technically" the same
|
|
535
793
|
// need to have the same element tag, and same key to be the same
|
|
536
|
-
if (
|
|
794
|
+
if (leftVNode.$tag$ === rightVNode.$tag$) {
|
|
795
|
+
// this will be set if components in the build have `key` attrs set on them
|
|
537
796
|
{
|
|
538
|
-
return
|
|
797
|
+
return leftVNode.$key$ === rightVNode.$key$;
|
|
539
798
|
}
|
|
540
799
|
}
|
|
541
800
|
return false;
|
|
542
801
|
};
|
|
802
|
+
/**
|
|
803
|
+
* Handle reconciling an outdated VNode with a new one which corresponds to
|
|
804
|
+
* it. This function handles flushing updates to the DOM and reconciling the
|
|
805
|
+
* children of the two nodes (if any).
|
|
806
|
+
*
|
|
807
|
+
* @param oldVNode an old VNode whose DOM element and children we want to update
|
|
808
|
+
* @param newVNode a new VNode representing an updated version of the old one
|
|
809
|
+
*/
|
|
543
810
|
const patch = (oldVNode, newVNode) => {
|
|
544
811
|
const elm = (newVNode.$elm$ = oldVNode.$elm$);
|
|
545
812
|
const oldChildren = oldVNode.$children$;
|
|
@@ -552,7 +819,6 @@ const patch = (oldVNode, newVNode) => {
|
|
|
552
819
|
// only add this to the when the compiler sees we're using an svg somewhere
|
|
553
820
|
isSvgMode = tag === 'svg' ? true : tag === 'foreignObject' ? false : isSvgMode;
|
|
554
821
|
}
|
|
555
|
-
// element node
|
|
556
822
|
{
|
|
557
823
|
{
|
|
558
824
|
// either this is the first render of an element OR it's an update
|
|
@@ -563,6 +829,7 @@ const patch = (oldVNode, newVNode) => {
|
|
|
563
829
|
}
|
|
564
830
|
if (oldChildren !== null && newChildren !== null) {
|
|
565
831
|
// looks like there's child vnodes for both the old and new vnodes
|
|
832
|
+
// so we need to call `updateChildren` to reconcile them
|
|
566
833
|
updateChildren(elm, oldChildren, newVNode, newChildren);
|
|
567
834
|
}
|
|
568
835
|
else if (newChildren !== null) {
|
|
@@ -594,29 +861,29 @@ const callNodeRefs = (vNode) => {
|
|
|
594
861
|
vNode.$children$ && vNode.$children$.map(callNodeRefs);
|
|
595
862
|
}
|
|
596
863
|
};
|
|
864
|
+
/**
|
|
865
|
+
* The main entry point for Stencil's virtual DOM-based rendering engine
|
|
866
|
+
*
|
|
867
|
+
* Given a {@link d.HostRef} container and some virtual DOM nodes, this
|
|
868
|
+
* function will handle creating a virtual DOM tree with a single root, patching
|
|
869
|
+
* the current virtual DOM tree onto an old one (if any), dealing with slot
|
|
870
|
+
* relocation, and reflecting attributes.
|
|
871
|
+
*
|
|
872
|
+
* @param hostRef data needed to root and render the virtual DOM tree, such as
|
|
873
|
+
* the DOM node into which it should be rendered.
|
|
874
|
+
* @param renderFnResults the virtual DOM nodes to be rendered
|
|
875
|
+
*/
|
|
597
876
|
const renderVdom = (hostRef, renderFnResults) => {
|
|
598
877
|
const hostElm = hostRef.$hostElement$;
|
|
599
878
|
const oldVNode = hostRef.$vnode$ || newVNode(null, null);
|
|
600
879
|
const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
|
|
601
880
|
rootVnode.$tag$ = null;
|
|
602
|
-
rootVnode.$flags$ |= 4 /* isHost */;
|
|
881
|
+
rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
|
|
603
882
|
hostRef.$vnode$ = rootVnode;
|
|
604
883
|
rootVnode.$elm$ = oldVNode.$elm$ = (hostElm);
|
|
605
884
|
// synchronous patch
|
|
606
885
|
patch(oldVNode, rootVnode);
|
|
607
886
|
};
|
|
608
|
-
/**
|
|
609
|
-
* Helper function to create & dispatch a custom Event on a provided target
|
|
610
|
-
* @param elm the target of the Event
|
|
611
|
-
* @param name the name to give the custom Event
|
|
612
|
-
* @param opts options for configuring a custom Event
|
|
613
|
-
* @returns the custom Event
|
|
614
|
-
*/
|
|
615
|
-
const emitEvent = (elm, name, opts) => {
|
|
616
|
-
const ev = plt.ce(name, opts);
|
|
617
|
-
elm.dispatchEvent(ev);
|
|
618
|
-
return ev;
|
|
619
|
-
};
|
|
620
887
|
const attachToAncestor = (hostRef, ancestorComponent) => {
|
|
621
888
|
if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
|
|
622
889
|
ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
|
|
@@ -624,10 +891,10 @@ const attachToAncestor = (hostRef, ancestorComponent) => {
|
|
|
624
891
|
};
|
|
625
892
|
const scheduleUpdate = (hostRef, isInitialLoad) => {
|
|
626
893
|
{
|
|
627
|
-
hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
|
|
894
|
+
hostRef.$flags$ |= 16 /* HOST_FLAGS.isQueuedForUpdate */;
|
|
628
895
|
}
|
|
629
|
-
if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
|
|
630
|
-
hostRef.$flags$ |= 512 /* needsRerender */;
|
|
896
|
+
if (hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
|
|
897
|
+
hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
|
|
631
898
|
return;
|
|
632
899
|
}
|
|
633
900
|
attachToAncestor(hostRef, hostRef.$ancestorComponent$);
|
|
@@ -646,6 +913,11 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
|
|
|
646
913
|
promise = safeCall(instance, 'componentWillLoad');
|
|
647
914
|
}
|
|
648
915
|
}
|
|
916
|
+
else {
|
|
917
|
+
{
|
|
918
|
+
promise = safeCall(instance, 'componentWillUpdate');
|
|
919
|
+
}
|
|
920
|
+
}
|
|
649
921
|
endSchedule();
|
|
650
922
|
return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
|
|
651
923
|
};
|
|
@@ -679,7 +951,7 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
|
|
|
679
951
|
}
|
|
680
952
|
else {
|
|
681
953
|
Promise.all(childrenPromises).then(postUpdate);
|
|
682
|
-
hostRef.$flags$ |= 4 /* isWaitingForChildren */;
|
|
954
|
+
hostRef.$flags$ |= 4 /* HOST_FLAGS.isWaitingForChildren */;
|
|
683
955
|
childrenPromises.length = 0;
|
|
684
956
|
}
|
|
685
957
|
}
|
|
@@ -688,10 +960,10 @@ const callRender = (hostRef, instance, elm) => {
|
|
|
688
960
|
try {
|
|
689
961
|
instance = instance.render() ;
|
|
690
962
|
{
|
|
691
|
-
hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
|
|
963
|
+
hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
|
|
692
964
|
}
|
|
693
965
|
{
|
|
694
|
-
hostRef.$flags$ |= 2 /* hasRendered */;
|
|
966
|
+
hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
|
|
695
967
|
}
|
|
696
968
|
{
|
|
697
969
|
{
|
|
@@ -718,8 +990,8 @@ const postUpdateComponent = (hostRef) => {
|
|
|
718
990
|
{
|
|
719
991
|
safeCall(instance, 'componentDidRender');
|
|
720
992
|
}
|
|
721
|
-
if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
|
|
722
|
-
hostRef.$flags$ |= 64 /* hasLoadedComponent */;
|
|
993
|
+
if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
|
|
994
|
+
hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
|
|
723
995
|
{
|
|
724
996
|
// DOM WRITE!
|
|
725
997
|
addHydratedFlag(elm);
|
|
@@ -748,10 +1020,10 @@ const postUpdateComponent = (hostRef) => {
|
|
|
748
1020
|
hostRef.$onRenderResolve$();
|
|
749
1021
|
hostRef.$onRenderResolve$ = undefined;
|
|
750
1022
|
}
|
|
751
|
-
if (hostRef.$flags$ & 512 /* needsRerender */) {
|
|
1023
|
+
if (hostRef.$flags$ & 512 /* HOST_FLAGS.needsRerender */) {
|
|
752
1024
|
nextTick(() => scheduleUpdate(hostRef, false));
|
|
753
1025
|
}
|
|
754
|
-
hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
|
|
1026
|
+
hostRef.$flags$ &= ~(4 /* HOST_FLAGS.isWaitingForChildren */ | 512 /* HOST_FLAGS.needsRerender */);
|
|
755
1027
|
}
|
|
756
1028
|
// ( •_•)
|
|
757
1029
|
// ( •_•)>⌐■-■
|
|
@@ -781,30 +1053,6 @@ const then = (promise, thenFn) => {
|
|
|
781
1053
|
};
|
|
782
1054
|
const addHydratedFlag = (elm) => elm.classList.add('hydrated')
|
|
783
1055
|
;
|
|
784
|
-
const parsePropertyValue = (propValue, propType) => {
|
|
785
|
-
// ensure this value is of the correct prop type
|
|
786
|
-
if (propValue != null && !isComplexType(propValue)) {
|
|
787
|
-
if (propType & 4 /* Boolean */) {
|
|
788
|
-
// per the HTML spec, any string value means it is a boolean true value
|
|
789
|
-
// but we'll cheat here and say that the string "false" is the boolean false
|
|
790
|
-
return propValue === 'false' ? false : propValue === '' || !!propValue;
|
|
791
|
-
}
|
|
792
|
-
if (propType & 2 /* Number */) {
|
|
793
|
-
// force it to be a number
|
|
794
|
-
return parseFloat(propValue);
|
|
795
|
-
}
|
|
796
|
-
if (propType & 1 /* String */) {
|
|
797
|
-
// could have been passed as a number or boolean
|
|
798
|
-
// but we still want it as a string
|
|
799
|
-
return String(propValue);
|
|
800
|
-
}
|
|
801
|
-
// redundant return here for better minification
|
|
802
|
-
return propValue;
|
|
803
|
-
}
|
|
804
|
-
// not sure exactly what type we want
|
|
805
|
-
// so no need to change to a different type
|
|
806
|
-
return propValue;
|
|
807
|
-
};
|
|
808
1056
|
const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
|
|
809
1057
|
const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
810
1058
|
// check our new property value against our internal value
|
|
@@ -813,12 +1061,15 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
813
1061
|
const flags = hostRef.$flags$;
|
|
814
1062
|
const instance = hostRef.$lazyInstance$ ;
|
|
815
1063
|
newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
|
|
816
|
-
|
|
1064
|
+
// explicitly check for NaN on both sides, as `NaN === NaN` is always false
|
|
1065
|
+
const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
|
|
1066
|
+
const didValueChange = newVal !== oldVal && !areBothNaN;
|
|
1067
|
+
if ((!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
|
|
817
1068
|
// gadzooks! the property's value has changed!!
|
|
818
1069
|
// set our new value!
|
|
819
1070
|
hostRef.$instanceValues$.set(propName, newVal);
|
|
820
1071
|
if (instance) {
|
|
821
|
-
if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
|
|
1072
|
+
if ((flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
|
|
822
1073
|
// looks like this value actually changed, so we've got work to do!
|
|
823
1074
|
// but only if we've already rendered, otherwise just chill out
|
|
824
1075
|
// queue that we need to do an update, but don't worry about queuing
|
|
@@ -828,14 +1079,24 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
828
1079
|
}
|
|
829
1080
|
}
|
|
830
1081
|
};
|
|
1082
|
+
/**
|
|
1083
|
+
* Attach a series of runtime constructs to a compiled Stencil component
|
|
1084
|
+
* constructor, including getters and setters for the `@Prop` and `@State`
|
|
1085
|
+
* decorators, callbacks for when attributes change, and so on.
|
|
1086
|
+
*
|
|
1087
|
+
* @param Cstr the constructor for a component that we need to process
|
|
1088
|
+
* @param cmpMeta metadata collected previously about the component
|
|
1089
|
+
* @param flags a number used to store a series of bit flags
|
|
1090
|
+
* @returns a reference to the same constructor passed in (but now mutated)
|
|
1091
|
+
*/
|
|
831
1092
|
const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
832
1093
|
if (cmpMeta.$members$) {
|
|
833
1094
|
// It's better to have a const than two Object.entries()
|
|
834
1095
|
const members = Object.entries(cmpMeta.$members$);
|
|
835
1096
|
const prototype = Cstr.prototype;
|
|
836
1097
|
members.map(([memberName, [memberFlags]]) => {
|
|
837
|
-
if ((memberFlags & 31 /* Prop */ ||
|
|
838
|
-
((flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
|
|
1098
|
+
if ((memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
|
|
1099
|
+
((flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
|
|
839
1100
|
// proxyComponent - prop
|
|
840
1101
|
Object.defineProperty(prototype, memberName, {
|
|
841
1102
|
get() {
|
|
@@ -850,8 +1111,8 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
850
1111
|
enumerable: true,
|
|
851
1112
|
});
|
|
852
1113
|
}
|
|
853
|
-
else if (flags & 1 /* isElementConstructor */ &&
|
|
854
|
-
memberFlags & 64 /* Method */) {
|
|
1114
|
+
else if (flags & 1 /* PROXY_FLAGS.isElementConstructor */ &&
|
|
1115
|
+
memberFlags & 64 /* MEMBER_FLAGS.Method */) {
|
|
855
1116
|
// proxyComponent - method
|
|
856
1117
|
Object.defineProperty(prototype, memberName, {
|
|
857
1118
|
value(...args) {
|
|
@@ -861,19 +1122,19 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
861
1122
|
});
|
|
862
1123
|
}
|
|
863
1124
|
});
|
|
864
|
-
if ((flags & 1 /* isElementConstructor */)) {
|
|
1125
|
+
if ((flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
|
|
865
1126
|
const attrNameToPropName = new Map();
|
|
866
1127
|
prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
|
|
867
1128
|
plt.jmp(() => {
|
|
868
1129
|
const propName = attrNameToPropName.get(attrName);
|
|
869
|
-
// In a
|
|
1130
|
+
// In a web component lifecycle the attributeChangedCallback runs prior to connectedCallback
|
|
870
1131
|
// in the case where an attribute was set inline.
|
|
871
1132
|
// ```html
|
|
872
1133
|
// <my-component some-attribute="some-value"></my-component>
|
|
873
1134
|
// ```
|
|
874
1135
|
//
|
|
875
|
-
// There is an edge case where a developer sets the attribute inline on a custom element and then
|
|
876
|
-
// changes it before it has been upgraded as shown below:
|
|
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:
|
|
877
1138
|
//
|
|
878
1139
|
// ```html
|
|
879
1140
|
// <!-- this component has _not_ been upgraded yet -->
|
|
@@ -883,13 +1144,13 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
883
1144
|
// el = document.querySelector("#test");
|
|
884
1145
|
// el.someAttribute = "another-value";
|
|
885
1146
|
// // upgrade component
|
|
886
|
-
//
|
|
1147
|
+
// customElements.define('my-component', MyComponent);
|
|
887
1148
|
// </script>
|
|
888
1149
|
// ```
|
|
889
1150
|
// In this case if we do not unshadow here and use the value of the shadowing property, attributeChangedCallback
|
|
890
1151
|
// will be called with `newValue = "some-value"` and will set the shadowed property (this.someAttribute = "another-value")
|
|
891
1152
|
// to the value that was set inline i.e. "some-value" from above example. When
|
|
892
|
-
// the connectedCallback attempts to unshadow it will use "some-value" as the
|
|
1153
|
+
// the connectedCallback attempts to unshadow it will use "some-value" as the initial value rather than "another-value"
|
|
893
1154
|
//
|
|
894
1155
|
// The case where the attribute was NOT set inline but was not set programmatically shall be handled/unshadowed
|
|
895
1156
|
// by connectedCallback as this attributeChangedCallback will not fire.
|
|
@@ -903,13 +1164,21 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
903
1164
|
newValue = this[propName];
|
|
904
1165
|
delete this[propName];
|
|
905
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
|
+
}
|
|
906
1175
|
this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
|
|
907
1176
|
});
|
|
908
1177
|
};
|
|
909
1178
|
// create an array of attributes to observe
|
|
910
1179
|
// and also create a map of html attribute name to js property name
|
|
911
1180
|
Cstr.observedAttributes = members
|
|
912
|
-
.filter(([_, m]) => m[0] & 15 /* HasAttribute */) // filter to only keep props that should match attributes
|
|
1181
|
+
.filter(([_, m]) => m[0] & 15 /* MEMBER_FLAGS.HasAttribute */) // filter to only keep props that should match attributes
|
|
913
1182
|
.map(([propName, m]) => {
|
|
914
1183
|
const attrName = m[1] || propName;
|
|
915
1184
|
attrNameToPropName.set(attrName, propName);
|
|
@@ -921,10 +1190,10 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
921
1190
|
};
|
|
922
1191
|
const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
|
|
923
1192
|
// initializeComponent
|
|
924
|
-
if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
|
|
1193
|
+
if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
|
|
925
1194
|
{
|
|
926
1195
|
// we haven't initialized this element yet
|
|
927
|
-
hostRef.$flags$ |= 32 /* hasInitializedComponent */;
|
|
1196
|
+
hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
|
|
928
1197
|
// lazy loaded components
|
|
929
1198
|
// request the component's implementation to be
|
|
930
1199
|
// wired up with the host element
|
|
@@ -936,7 +1205,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
936
1205
|
endLoad();
|
|
937
1206
|
}
|
|
938
1207
|
if (!Cstr.isProxied) {
|
|
939
|
-
proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
|
|
1208
|
+
proxyComponent(Cstr, cmpMeta, 2 /* PROXY_FLAGS.proxyState */);
|
|
940
1209
|
Cstr.isProxied = true;
|
|
941
1210
|
}
|
|
942
1211
|
const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
|
|
@@ -944,7 +1213,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
944
1213
|
// but let's keep track of when we start and stop
|
|
945
1214
|
// so that the getters/setters don't incorrectly step on data
|
|
946
1215
|
{
|
|
947
|
-
hostRef.$flags$ |= 8 /* isConstructingInstance */;
|
|
1216
|
+
hostRef.$flags$ |= 8 /* HOST_FLAGS.isConstructingInstance */;
|
|
948
1217
|
}
|
|
949
1218
|
// construct the lazy-loaded component implementation
|
|
950
1219
|
// passing the hostRef is very important during
|
|
@@ -957,7 +1226,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
957
1226
|
consoleError(e);
|
|
958
1227
|
}
|
|
959
1228
|
{
|
|
960
|
-
hostRef.$flags$ &= ~8 /* isConstructingInstance */;
|
|
1229
|
+
hostRef.$flags$ &= ~8 /* HOST_FLAGS.isConstructingInstance */;
|
|
961
1230
|
}
|
|
962
1231
|
endNewInstance();
|
|
963
1232
|
}
|
|
@@ -967,7 +1236,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
967
1236
|
const scopeId = getScopeId(cmpMeta);
|
|
968
1237
|
if (!styles.has(scopeId)) {
|
|
969
1238
|
const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
|
|
970
|
-
registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
|
|
1239
|
+
registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
|
|
971
1240
|
endRegisterStyles();
|
|
972
1241
|
}
|
|
973
1242
|
}
|
|
@@ -976,7 +1245,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
976
1245
|
const ancestorComponent = hostRef.$ancestorComponent$;
|
|
977
1246
|
const schedule = () => scheduleUpdate(hostRef, true);
|
|
978
1247
|
if (ancestorComponent && ancestorComponent['s-rc']) {
|
|
979
|
-
// this is the
|
|
1248
|
+
// this is the initial load and this component it has an ancestor component
|
|
980
1249
|
// but the ancestor component has NOT fired its will update lifecycle yet
|
|
981
1250
|
// so let's just cool our jets and wait for the ancestor to continue first
|
|
982
1251
|
// this will get fired off when the ancestor component
|
|
@@ -989,13 +1258,13 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
989
1258
|
}
|
|
990
1259
|
};
|
|
991
1260
|
const connectedCallback = (elm) => {
|
|
992
|
-
if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
|
|
1261
|
+
if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
|
|
993
1262
|
const hostRef = getHostRef(elm);
|
|
994
1263
|
const cmpMeta = hostRef.$cmpMeta$;
|
|
995
1264
|
const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
|
|
996
|
-
if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
|
|
1265
|
+
if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
|
|
997
1266
|
// first time this component has connected
|
|
998
|
-
hostRef.$flags$ |= 1 /* hasConnected */;
|
|
1267
|
+
hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
|
|
999
1268
|
{
|
|
1000
1269
|
// find the first ancestor component (if there is one) and register
|
|
1001
1270
|
// this component as one of the actively loading child components for its ancestor
|
|
@@ -1015,7 +1284,7 @@ const connectedCallback = (elm) => {
|
|
|
1015
1284
|
// https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
|
|
1016
1285
|
if (cmpMeta.$members$) {
|
|
1017
1286
|
Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
|
|
1018
|
-
if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
|
|
1287
|
+
if (memberFlags & 31 /* MEMBER_FLAGS.Prop */ && elm.hasOwnProperty(memberName)) {
|
|
1019
1288
|
const value = elm[memberName];
|
|
1020
1289
|
delete elm[memberName];
|
|
1021
1290
|
elm[memberName] = value;
|
|
@@ -1030,11 +1299,12 @@ const connectedCallback = (elm) => {
|
|
|
1030
1299
|
}
|
|
1031
1300
|
};
|
|
1032
1301
|
const disconnectedCallback = (elm) => {
|
|
1033
|
-
if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
|
|
1302
|
+
if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
|
|
1034
1303
|
getHostRef(elm);
|
|
1035
1304
|
}
|
|
1036
1305
|
};
|
|
1037
1306
|
const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
1307
|
+
var _a;
|
|
1038
1308
|
const endBootstrap = createTime();
|
|
1039
1309
|
const cmpTags = [];
|
|
1040
1310
|
const exclude = options.exclude || [];
|
|
@@ -1047,54 +1317,61 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1047
1317
|
let isBootstrapping = true;
|
|
1048
1318
|
Object.assign(plt, options);
|
|
1049
1319
|
plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
|
|
1050
|
-
lazyBundles.map((lazyBundle) =>
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
const tagName = cmpMeta.$tagName$;
|
|
1061
|
-
const HostElement = class extends HTMLElement {
|
|
1062
|
-
// StencilLazyHost
|
|
1063
|
-
constructor(self) {
|
|
1064
|
-
// @ts-ignore
|
|
1065
|
-
super(self);
|
|
1066
|
-
self = this;
|
|
1067
|
-
registerHost(self, cmpMeta);
|
|
1320
|
+
lazyBundles.map((lazyBundle) => {
|
|
1321
|
+
lazyBundle[1].map((compactMeta) => {
|
|
1322
|
+
const cmpMeta = {
|
|
1323
|
+
$flags$: compactMeta[0],
|
|
1324
|
+
$tagName$: compactMeta[1],
|
|
1325
|
+
$members$: compactMeta[2],
|
|
1326
|
+
$listeners$: compactMeta[3],
|
|
1327
|
+
};
|
|
1328
|
+
{
|
|
1329
|
+
cmpMeta.$members$ = compactMeta[2];
|
|
1068
1330
|
}
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1331
|
+
const tagName = cmpMeta.$tagName$;
|
|
1332
|
+
const HostElement = class extends HTMLElement {
|
|
1333
|
+
// StencilLazyHost
|
|
1334
|
+
constructor(self) {
|
|
1335
|
+
// @ts-ignore
|
|
1336
|
+
super(self);
|
|
1337
|
+
self = this;
|
|
1338
|
+
registerHost(self, cmpMeta);
|
|
1339
|
+
}
|
|
1340
|
+
connectedCallback() {
|
|
1341
|
+
if (appLoadFallback) {
|
|
1342
|
+
clearTimeout(appLoadFallback);
|
|
1343
|
+
appLoadFallback = null;
|
|
1344
|
+
}
|
|
1345
|
+
if (isBootstrapping) {
|
|
1346
|
+
// connectedCallback will be processed once all components have been registered
|
|
1347
|
+
deferredConnectedCallbacks.push(this);
|
|
1348
|
+
}
|
|
1349
|
+
else {
|
|
1350
|
+
plt.jmp(() => connectedCallback(this));
|
|
1351
|
+
}
|
|
1073
1352
|
}
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
deferredConnectedCallbacks.push(this);
|
|
1353
|
+
disconnectedCallback() {
|
|
1354
|
+
plt.jmp(() => disconnectedCallback(this));
|
|
1077
1355
|
}
|
|
1078
|
-
|
|
1079
|
-
|
|
1356
|
+
componentOnReady() {
|
|
1357
|
+
return getHostRef(this).$onReadyPromise$;
|
|
1080
1358
|
}
|
|
1359
|
+
};
|
|
1360
|
+
cmpMeta.$lazyBundleId$ = lazyBundle[0];
|
|
1361
|
+
if (!exclude.includes(tagName) && !customElements.get(tagName)) {
|
|
1362
|
+
cmpTags.push(tagName);
|
|
1363
|
+
customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */));
|
|
1081
1364
|
}
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
}
|
|
1085
|
-
componentOnReady() {
|
|
1086
|
-
return getHostRef(this).$onReadyPromise$;
|
|
1087
|
-
}
|
|
1088
|
-
};
|
|
1089
|
-
cmpMeta.$lazyBundleId$ = lazyBundle[0];
|
|
1090
|
-
if (!exclude.includes(tagName) && !customElements.get(tagName)) {
|
|
1091
|
-
cmpTags.push(tagName);
|
|
1092
|
-
customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
|
|
1093
|
-
}
|
|
1094
|
-
}));
|
|
1365
|
+
});
|
|
1366
|
+
});
|
|
1095
1367
|
{
|
|
1096
1368
|
visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
|
|
1097
1369
|
visibilityStyle.setAttribute('data-styles', '');
|
|
1370
|
+
// Apply CSP nonce to the style tag if it exists
|
|
1371
|
+
const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
|
|
1372
|
+
if (nonce != null) {
|
|
1373
|
+
visibilityStyle.setAttribute('nonce', nonce);
|
|
1374
|
+
}
|
|
1098
1375
|
head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
|
|
1099
1376
|
}
|
|
1100
1377
|
// Process deferred connectedCallbacks now all components have been registered
|
|
@@ -1110,11 +1387,14 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1110
1387
|
// Fallback appLoad event
|
|
1111
1388
|
endBootstrap();
|
|
1112
1389
|
};
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1390
|
+
/**
|
|
1391
|
+
* Assigns the given value to the nonce property on the runtime platform object.
|
|
1392
|
+
* During runtime, this value is used to set the nonce attribute on all dynamically created script and style tags.
|
|
1393
|
+
* @param nonce The value to be assigned to the platform nonce property.
|
|
1394
|
+
* @returns void
|
|
1395
|
+
*/
|
|
1396
|
+
const setNonce = (nonce) => (plt.$nonce$ = nonce);
|
|
1397
|
+
const hostRefs = /*@__PURE__*/ new WeakMap();
|
|
1118
1398
|
const getHostRef = (ref) => hostRefs.get(ref);
|
|
1119
1399
|
const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
|
|
1120
1400
|
const registerHost = (elm, cmpMeta) => {
|
|
@@ -1145,7 +1425,9 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
|
|
|
1145
1425
|
if (module) {
|
|
1146
1426
|
return module[exportName];
|
|
1147
1427
|
}
|
|
1428
|
+
/*!__STENCIL_STATIC_IMPORT_SWITCH__*/
|
|
1148
1429
|
return import(
|
|
1430
|
+
/* @vite-ignore */
|
|
1149
1431
|
/* webpackInclude: /\.entry\.js$/ */
|
|
1150
1432
|
/* webpackExclude: /\.system\.entry\.js$/ */
|
|
1151
1433
|
/* webpackMode: "lazy" */
|
|
@@ -1156,14 +1438,35 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
|
|
|
1156
1438
|
return importedModule[exportName];
|
|
1157
1439
|
}, consoleError);
|
|
1158
1440
|
};
|
|
1159
|
-
const styles = new Map();
|
|
1441
|
+
const styles = /*@__PURE__*/ new Map();
|
|
1442
|
+
const win = typeof window !== 'undefined' ? window : {};
|
|
1443
|
+
const doc = win.document || { head: {} };
|
|
1444
|
+
const plt = {
|
|
1445
|
+
$flags$: 0,
|
|
1446
|
+
$resourcesUrl$: '',
|
|
1447
|
+
jmp: (h) => h(),
|
|
1448
|
+
raf: (h) => requestAnimationFrame(h),
|
|
1449
|
+
ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
|
|
1450
|
+
rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
|
|
1451
|
+
ce: (eventName, opts) => new CustomEvent(eventName, opts),
|
|
1452
|
+
};
|
|
1453
|
+
const promiseResolve = (v) => Promise.resolve(v);
|
|
1454
|
+
const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
|
|
1455
|
+
try {
|
|
1456
|
+
new CSSStyleSheet();
|
|
1457
|
+
return typeof new CSSStyleSheet().replaceSync === 'function';
|
|
1458
|
+
}
|
|
1459
|
+
catch (e) { }
|
|
1460
|
+
return false;
|
|
1461
|
+
})()
|
|
1462
|
+
;
|
|
1160
1463
|
const queueDomReads = [];
|
|
1161
1464
|
const queueDomWrites = [];
|
|
1162
1465
|
const queueTask = (queue, write) => (cb) => {
|
|
1163
1466
|
queue.push(cb);
|
|
1164
1467
|
if (!queuePending) {
|
|
1165
1468
|
queuePending = true;
|
|
1166
|
-
if (write && plt.$flags$ & 4 /* queueSync */) {
|
|
1469
|
+
if (write && plt.$flags$ & 4 /* PLATFORM_FLAGS.queueSync */) {
|
|
1167
1470
|
nextTick(flush);
|
|
1168
1471
|
}
|
|
1169
1472
|
else {
|
|
@@ -1200,4 +1503,4 @@ const flush = () => {
|
|
|
1200
1503
|
const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
|
|
1201
1504
|
const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
|
|
1202
1505
|
|
|
1203
|
-
export { bootstrapLazy as b, getAssetPath as g, h, promiseResolve as p, registerInstance as r };
|
|
1506
|
+
export { bootstrapLazy as b, getAssetPath as g, h, promiseResolve as p, registerInstance as r, setNonce as s };
|