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
|
@@ -22,31 +22,20 @@ function _interopNamespace(e) {
|
|
|
22
22
|
|
|
23
23
|
const NAMESPACE = 'favesalon-embed';
|
|
24
24
|
|
|
25
|
+
/**
|
|
26
|
+
* Virtual DOM patching algorithm based on Snabbdom by
|
|
27
|
+
* Simon Friis Vindum (@paldepind)
|
|
28
|
+
* Licensed under the MIT License
|
|
29
|
+
* https://github.com/snabbdom/snabbdom/blob/master/LICENSE
|
|
30
|
+
*
|
|
31
|
+
* Modified for Stencil's renderer and slot projection
|
|
32
|
+
*/
|
|
25
33
|
let isSvgMode = false;
|
|
26
34
|
let queuePending = false;
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
$flags$: 0,
|
|
31
|
-
$resourcesUrl$: '',
|
|
32
|
-
jmp: (h) => h(),
|
|
33
|
-
raf: (h) => requestAnimationFrame(h),
|
|
34
|
-
ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
|
|
35
|
-
rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
|
|
36
|
-
ce: (eventName, opts) => new CustomEvent(eventName, opts),
|
|
35
|
+
const getAssetPath = (path) => {
|
|
36
|
+
const assetUrl = new URL(path, plt.$resourcesUrl$);
|
|
37
|
+
return assetUrl.origin !== win.location.origin ? assetUrl.href : assetUrl.pathname;
|
|
37
38
|
};
|
|
38
|
-
const promiseResolve = (v) => Promise.resolve(v);
|
|
39
|
-
const supportsConstructibleStylesheets = /*@__PURE__*/ (() => {
|
|
40
|
-
try {
|
|
41
|
-
new CSSStyleSheet();
|
|
42
|
-
return typeof new CSSStyleSheet().replace === 'function';
|
|
43
|
-
}
|
|
44
|
-
catch (e) { }
|
|
45
|
-
return false;
|
|
46
|
-
})()
|
|
47
|
-
;
|
|
48
|
-
const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
|
|
49
|
-
const XLINK_NS = 'http://www.w3.org/1999/xlink';
|
|
50
39
|
const createTime = (fnName, tagName = '') => {
|
|
51
40
|
{
|
|
52
41
|
return () => {
|
|
@@ -61,59 +50,8 @@ const uniqueTime = (key, measureText) => {
|
|
|
61
50
|
};
|
|
62
51
|
}
|
|
63
52
|
};
|
|
64
|
-
const
|
|
65
|
-
const
|
|
66
|
-
let style = styles.get(scopeId);
|
|
67
|
-
if (supportsConstructibleStylesheets && allowCS) {
|
|
68
|
-
style = (style || new CSSStyleSheet());
|
|
69
|
-
style.replace(cssText);
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
style = cssText;
|
|
73
|
-
}
|
|
74
|
-
styles.set(scopeId, style);
|
|
75
|
-
};
|
|
76
|
-
const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
|
|
77
|
-
let scopeId = getScopeId(cmpMeta);
|
|
78
|
-
let style = styles.get(scopeId);
|
|
79
|
-
// if an element is NOT connected then getRootNode() will return the wrong root node
|
|
80
|
-
// so the fallback is to always use the document for the root node in those cases
|
|
81
|
-
styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
|
|
82
|
-
if (style) {
|
|
83
|
-
if (typeof style === 'string') {
|
|
84
|
-
styleContainerNode = styleContainerNode.head || styleContainerNode;
|
|
85
|
-
let appliedStyles = rootAppliedStyles.get(styleContainerNode);
|
|
86
|
-
let styleElm;
|
|
87
|
-
if (!appliedStyles) {
|
|
88
|
-
rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
|
|
89
|
-
}
|
|
90
|
-
if (!appliedStyles.has(scopeId)) {
|
|
91
|
-
{
|
|
92
|
-
{
|
|
93
|
-
styleElm = doc.createElement('style');
|
|
94
|
-
styleElm.innerHTML = style;
|
|
95
|
-
}
|
|
96
|
-
styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
|
|
97
|
-
}
|
|
98
|
-
if (appliedStyles) {
|
|
99
|
-
appliedStyles.add(scopeId);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
|
|
104
|
-
styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
return scopeId;
|
|
108
|
-
};
|
|
109
|
-
const attachStyles = (hostRef) => {
|
|
110
|
-
const cmpMeta = hostRef.$cmpMeta$;
|
|
111
|
-
const elm = hostRef.$hostElement$;
|
|
112
|
-
const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
|
|
113
|
-
addStyle(elm.getRootNode(), cmpMeta);
|
|
114
|
-
endAttachStyles();
|
|
115
|
-
};
|
|
116
|
-
const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
|
|
53
|
+
const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
|
|
54
|
+
const XLINK_NS = 'http://www.w3.org/1999/xlink';
|
|
117
55
|
/**
|
|
118
56
|
* Default style mode id
|
|
119
57
|
*/
|
|
@@ -132,6 +70,18 @@ const isComplexType = (o) => {
|
|
|
132
70
|
o = typeof o;
|
|
133
71
|
return o === 'object' || o === 'function';
|
|
134
72
|
};
|
|
73
|
+
/**
|
|
74
|
+
* Helper method for querying a `meta` tag that contains a nonce value
|
|
75
|
+
* out of a DOM's head.
|
|
76
|
+
*
|
|
77
|
+
* @param doc The DOM containing the `head` to query against
|
|
78
|
+
* @returns The content of the meta tag representing the nonce value, or `undefined` if no tag
|
|
79
|
+
* exists or the tag has no content.
|
|
80
|
+
*/
|
|
81
|
+
function queryNonceMetaTagContent(doc) {
|
|
82
|
+
var _a, _b, _c;
|
|
83
|
+
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;
|
|
84
|
+
}
|
|
135
85
|
/**
|
|
136
86
|
* Production h() function based on Preact by
|
|
137
87
|
* Jason Miller (@developit)
|
|
@@ -140,7 +90,6 @@ const isComplexType = (o) => {
|
|
|
140
90
|
*
|
|
141
91
|
* Modified for Stencil's compiler and vdom
|
|
142
92
|
*/
|
|
143
|
-
// const stack: any[] = [];
|
|
144
93
|
// export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
|
|
145
94
|
// export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
|
|
146
95
|
const h = (nodeName, vnodeData, ...children) => {
|
|
@@ -148,7 +97,7 @@ const h = (nodeName, vnodeData, ...children) => {
|
|
|
148
97
|
let key = null;
|
|
149
98
|
let simple = false;
|
|
150
99
|
let lastSimple = false;
|
|
151
|
-
|
|
100
|
+
const vNodeChildren = [];
|
|
152
101
|
const walk = (c) => {
|
|
153
102
|
for (let i = 0; i < c.length; i++) {
|
|
154
103
|
child = c[i];
|
|
@@ -199,6 +148,14 @@ const h = (nodeName, vnodeData, ...children) => {
|
|
|
199
148
|
}
|
|
200
149
|
return vnode;
|
|
201
150
|
};
|
|
151
|
+
/**
|
|
152
|
+
* A utility function for creating a virtual DOM node from a tag and some
|
|
153
|
+
* possible text content.
|
|
154
|
+
*
|
|
155
|
+
* @param tag the tag for this element
|
|
156
|
+
* @param text possible text content for the node
|
|
157
|
+
* @returns a newly-minted virtual DOM node
|
|
158
|
+
*/
|
|
202
159
|
const newVNode = (tag, text) => {
|
|
203
160
|
const vnode = {
|
|
204
161
|
$flags$: 0,
|
|
@@ -216,7 +173,136 @@ const newVNode = (tag, text) => {
|
|
|
216
173
|
return vnode;
|
|
217
174
|
};
|
|
218
175
|
const Host = {};
|
|
176
|
+
/**
|
|
177
|
+
* Check whether a given node is a Host node or not
|
|
178
|
+
*
|
|
179
|
+
* @param node the virtual DOM node to check
|
|
180
|
+
* @returns whether it's a Host node or not
|
|
181
|
+
*/
|
|
219
182
|
const isHost = (node) => node && node.$tag$ === Host;
|
|
183
|
+
/**
|
|
184
|
+
* Parse a new property value for a given property type.
|
|
185
|
+
*
|
|
186
|
+
* While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
|
|
187
|
+
* it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
|
|
188
|
+
* 1. `any`, the type given to `propValue` in the function signature
|
|
189
|
+
* 2. the type stored from `propType`.
|
|
190
|
+
*
|
|
191
|
+
* This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
|
|
192
|
+
*
|
|
193
|
+
* Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
|
|
194
|
+
* a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
|
|
195
|
+
* based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
|
|
196
|
+
* ```tsx
|
|
197
|
+
* <my-cmp prop-val={0}></my-cmp>
|
|
198
|
+
* ```
|
|
199
|
+
*
|
|
200
|
+
* HTML prop values on the other hand, will always a string
|
|
201
|
+
*
|
|
202
|
+
* @param propValue the new value to coerce to some type
|
|
203
|
+
* @param propType the type of the prop, expressed as a binary number
|
|
204
|
+
* @returns the parsed/coerced value
|
|
205
|
+
*/
|
|
206
|
+
const parsePropertyValue = (propValue, propType) => {
|
|
207
|
+
// ensure this value is of the correct prop type
|
|
208
|
+
if (propValue != null && !isComplexType(propValue)) {
|
|
209
|
+
if (propType & 4 /* MEMBER_FLAGS.Boolean */) {
|
|
210
|
+
// per the HTML spec, any string value means it is a boolean true value
|
|
211
|
+
// but we'll cheat here and say that the string "false" is the boolean false
|
|
212
|
+
return propValue === 'false' ? false : propValue === '' || !!propValue;
|
|
213
|
+
}
|
|
214
|
+
if (propType & 2 /* MEMBER_FLAGS.Number */) {
|
|
215
|
+
// force it to be a number
|
|
216
|
+
return parseFloat(propValue);
|
|
217
|
+
}
|
|
218
|
+
if (propType & 1 /* MEMBER_FLAGS.String */) {
|
|
219
|
+
// could have been passed as a number or boolean
|
|
220
|
+
// but we still want it as a string
|
|
221
|
+
return String(propValue);
|
|
222
|
+
}
|
|
223
|
+
// redundant return here for better minification
|
|
224
|
+
return propValue;
|
|
225
|
+
}
|
|
226
|
+
// not sure exactly what type we want
|
|
227
|
+
// so no need to change to a different type
|
|
228
|
+
return propValue;
|
|
229
|
+
};
|
|
230
|
+
/**
|
|
231
|
+
* Helper function to create & dispatch a custom Event on a provided target
|
|
232
|
+
* @param elm the target of the Event
|
|
233
|
+
* @param name the name to give the custom Event
|
|
234
|
+
* @param opts options for configuring a custom Event
|
|
235
|
+
* @returns the custom Event
|
|
236
|
+
*/
|
|
237
|
+
const emitEvent = (elm, name, opts) => {
|
|
238
|
+
const ev = plt.ce(name, opts);
|
|
239
|
+
elm.dispatchEvent(ev);
|
|
240
|
+
return ev;
|
|
241
|
+
};
|
|
242
|
+
const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
|
|
243
|
+
const registerStyle = (scopeId, cssText, allowCS) => {
|
|
244
|
+
let style = styles.get(scopeId);
|
|
245
|
+
if (supportsConstructableStylesheets && allowCS) {
|
|
246
|
+
style = (style || new CSSStyleSheet());
|
|
247
|
+
if (typeof style === 'string') {
|
|
248
|
+
style = cssText;
|
|
249
|
+
}
|
|
250
|
+
else {
|
|
251
|
+
style.replaceSync(cssText);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
else {
|
|
255
|
+
style = cssText;
|
|
256
|
+
}
|
|
257
|
+
styles.set(scopeId, style);
|
|
258
|
+
};
|
|
259
|
+
const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
|
|
260
|
+
var _a;
|
|
261
|
+
let scopeId = getScopeId(cmpMeta);
|
|
262
|
+
const style = styles.get(scopeId);
|
|
263
|
+
// if an element is NOT connected then getRootNode() will return the wrong root node
|
|
264
|
+
// so the fallback is to always use the document for the root node in those cases
|
|
265
|
+
styleContainerNode = styleContainerNode.nodeType === 11 /* NODE_TYPE.DocumentFragment */ ? styleContainerNode : doc;
|
|
266
|
+
if (style) {
|
|
267
|
+
if (typeof style === 'string') {
|
|
268
|
+
styleContainerNode = styleContainerNode.head || styleContainerNode;
|
|
269
|
+
let appliedStyles = rootAppliedStyles.get(styleContainerNode);
|
|
270
|
+
let styleElm;
|
|
271
|
+
if (!appliedStyles) {
|
|
272
|
+
rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
|
|
273
|
+
}
|
|
274
|
+
if (!appliedStyles.has(scopeId)) {
|
|
275
|
+
{
|
|
276
|
+
{
|
|
277
|
+
styleElm = doc.createElement('style');
|
|
278
|
+
styleElm.innerHTML = style;
|
|
279
|
+
}
|
|
280
|
+
// Apply CSP nonce to the style tag if it exists
|
|
281
|
+
const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
|
|
282
|
+
if (nonce != null) {
|
|
283
|
+
styleElm.setAttribute('nonce', nonce);
|
|
284
|
+
}
|
|
285
|
+
styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
|
|
286
|
+
}
|
|
287
|
+
if (appliedStyles) {
|
|
288
|
+
appliedStyles.add(scopeId);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
|
|
293
|
+
styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
return scopeId;
|
|
297
|
+
};
|
|
298
|
+
const attachStyles = (hostRef) => {
|
|
299
|
+
const cmpMeta = hostRef.$cmpMeta$;
|
|
300
|
+
const elm = hostRef.$hostElement$;
|
|
301
|
+
const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
|
|
302
|
+
addStyle(elm.getRootNode(), cmpMeta);
|
|
303
|
+
endAttachStyles();
|
|
304
|
+
};
|
|
305
|
+
const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
|
|
220
306
|
/**
|
|
221
307
|
* Production setAccessor() function based on Preact by
|
|
222
308
|
* Jason Miller (@developit)
|
|
@@ -314,11 +400,10 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
|
|
314
400
|
if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
|
|
315
401
|
try {
|
|
316
402
|
if (!elm.tagName.includes('-')) {
|
|
317
|
-
|
|
403
|
+
const n = newValue == null ? '' : newValue;
|
|
318
404
|
// Workaround for Safari, moving the <input> caret when re-assigning the same valued
|
|
319
405
|
if (memberName === 'list') {
|
|
320
406
|
isProp = false;
|
|
321
|
-
// tslint:disable-next-line: triple-equals
|
|
322
407
|
}
|
|
323
408
|
else if (oldValue == null || elm[memberName] != n) {
|
|
324
409
|
elm[memberName] = n;
|
|
@@ -354,7 +439,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
|
|
354
439
|
}
|
|
355
440
|
}
|
|
356
441
|
}
|
|
357
|
-
else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
|
|
442
|
+
else if ((!isProp || flags & 4 /* VNODE_FLAGS.isHost */ || isSvg) && !isComplex) {
|
|
358
443
|
newValue = newValue === true ? '' : newValue;
|
|
359
444
|
if (xlink) {
|
|
360
445
|
elm.setAttributeNS(XLINK_NS, memberName, newValue);
|
|
@@ -372,7 +457,7 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
|
|
|
372
457
|
// if the element passed in is a shadow root, which is a document fragment
|
|
373
458
|
// then we want to be adding attrs/props to the shadow root's "host" element
|
|
374
459
|
// if it's not a shadow root, then we add attrs/props to the same element
|
|
375
|
-
const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host
|
|
460
|
+
const elm = newVnode.$elm$.nodeType === 11 /* NODE_TYPE.DocumentFragment */ && newVnode.$elm$.host
|
|
376
461
|
? newVnode.$elm$.host
|
|
377
462
|
: newVnode.$elm$;
|
|
378
463
|
const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
|
|
@@ -390,9 +475,19 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
|
|
|
390
475
|
setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
|
|
391
476
|
}
|
|
392
477
|
};
|
|
478
|
+
/**
|
|
479
|
+
* Create a DOM Node corresponding to one of the children of a given VNode.
|
|
480
|
+
*
|
|
481
|
+
* @param oldParentVNode the parent VNode from the previous render
|
|
482
|
+
* @param newParentVNode the parent VNode from the current render
|
|
483
|
+
* @param childIndex the index of the VNode, in the _new_ parent node's
|
|
484
|
+
* children, for which we will create a new DOM node
|
|
485
|
+
* @param parentElm the parent DOM node which our new node will be a child of
|
|
486
|
+
* @returns the newly created node
|
|
487
|
+
*/
|
|
393
488
|
const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
394
489
|
// tslint:disable-next-line: prefer-const
|
|
395
|
-
|
|
490
|
+
const newVNode = newParentVNode.$children$[childIndex];
|
|
396
491
|
let i = 0;
|
|
397
492
|
let elm;
|
|
398
493
|
let childNode;
|
|
@@ -438,6 +533,21 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
438
533
|
}
|
|
439
534
|
return elm;
|
|
440
535
|
};
|
|
536
|
+
/**
|
|
537
|
+
* Create DOM nodes corresponding to a list of {@link d.Vnode} objects and
|
|
538
|
+
* add them to the DOM in the appropriate place.
|
|
539
|
+
*
|
|
540
|
+
* @param parentElm the DOM node which should be used as a parent for the new
|
|
541
|
+
* DOM nodes
|
|
542
|
+
* @param before a child of the `parentElm` which the new children should be
|
|
543
|
+
* inserted before (optional)
|
|
544
|
+
* @param parentVNode the parent virtual DOM node
|
|
545
|
+
* @param vnodes the new child virtual DOM nodes to produce DOM nodes for
|
|
546
|
+
* @param startIdx the index in the child virtual DOM nodes at which to start
|
|
547
|
+
* creating DOM nodes (inclusive)
|
|
548
|
+
* @param endIdx the index in the child virtual DOM nodes at which to stop
|
|
549
|
+
* creating DOM nodes (inclusive)
|
|
550
|
+
*/
|
|
441
551
|
const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
|
|
442
552
|
let containerElm = (parentElm);
|
|
443
553
|
let childNode;
|
|
@@ -451,6 +561,19 @@ const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) =>
|
|
|
451
561
|
}
|
|
452
562
|
}
|
|
453
563
|
};
|
|
564
|
+
/**
|
|
565
|
+
* Remove the DOM elements corresponding to a list of {@link d.VNode} objects.
|
|
566
|
+
* This can be used to, for instance, clean up after a list of children which
|
|
567
|
+
* should no longer be shown.
|
|
568
|
+
*
|
|
569
|
+
* This function also handles some of Stencil's slot relocation logic.
|
|
570
|
+
*
|
|
571
|
+
* @param vnodes a list of virtual DOM nodes to remove
|
|
572
|
+
* @param startIdx the index at which to start removing nodes (inclusive)
|
|
573
|
+
* @param endIdx the index at which to stop removing nodes (inclusive)
|
|
574
|
+
* @param vnode a VNode
|
|
575
|
+
* @param elm an element
|
|
576
|
+
*/
|
|
454
577
|
const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
|
|
455
578
|
for (; startIdx <= endIdx; ++startIdx) {
|
|
456
579
|
if ((vnode = vnodes[startIdx])) {
|
|
@@ -461,6 +584,74 @@ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
|
|
|
461
584
|
}
|
|
462
585
|
}
|
|
463
586
|
};
|
|
587
|
+
/**
|
|
588
|
+
* Reconcile the children of a new VNode with the children of an old VNode by
|
|
589
|
+
* traversing the two collections of children, identifying nodes that are
|
|
590
|
+
* conserved or changed, calling out to `patch` to make any necessary
|
|
591
|
+
* updates to the DOM, and rearranging DOM nodes as needed.
|
|
592
|
+
*
|
|
593
|
+
* The algorithm for reconciling children works by analyzing two 'windows' onto
|
|
594
|
+
* the two arrays of children (`oldCh` and `newCh`). We keep track of the
|
|
595
|
+
* 'windows' by storing start and end indices and references to the
|
|
596
|
+
* corresponding array entries. Initially the two 'windows' are basically equal
|
|
597
|
+
* to the entire array, but we progressively narrow the windows until there are
|
|
598
|
+
* no children left to update by doing the following:
|
|
599
|
+
*
|
|
600
|
+
* 1. Skip any `null` entries at the beginning or end of the two arrays, so
|
|
601
|
+
* that if we have an initial array like the following we'll end up dealing
|
|
602
|
+
* only with a window bounded by the highlighted elements:
|
|
603
|
+
*
|
|
604
|
+
* [null, null, VNode1 , ... , VNode2, null, null]
|
|
605
|
+
* ^^^^^^ ^^^^^^
|
|
606
|
+
*
|
|
607
|
+
* 2. Check to see if the elements at the head and tail positions are equal
|
|
608
|
+
* across the windows. This will basically detect elements which haven't
|
|
609
|
+
* been added, removed, or changed position, i.e. if you had the following
|
|
610
|
+
* VNode elements (represented as HTML):
|
|
611
|
+
*
|
|
612
|
+
* oldVNode: `<div><p><span>HEY</span></p></div>`
|
|
613
|
+
* newVNode: `<div><p><span>THERE</span></p></div>`
|
|
614
|
+
*
|
|
615
|
+
* Then when comparing the children of the `<div>` tag we check the equality
|
|
616
|
+
* of the VNodes corresponding to the `<p>` tags and, since they are the
|
|
617
|
+
* same tag in the same position, we'd be able to avoid completely
|
|
618
|
+
* re-rendering the subtree under them with a new DOM element and would just
|
|
619
|
+
* call out to `patch` to handle reconciling their children and so on.
|
|
620
|
+
*
|
|
621
|
+
* 3. Check, for both windows, to see if the element at the beginning of the
|
|
622
|
+
* window corresponds to the element at the end of the other window. This is
|
|
623
|
+
* a heuristic which will let us identify _some_ situations in which
|
|
624
|
+
* elements have changed position, for instance it _should_ detect that the
|
|
625
|
+
* children nodes themselves have not changed but merely moved in the
|
|
626
|
+
* following example:
|
|
627
|
+
*
|
|
628
|
+
* oldVNode: `<div><element-one /><element-two /></div>`
|
|
629
|
+
* newVNode: `<div><element-two /><element-one /></div>`
|
|
630
|
+
*
|
|
631
|
+
* If we find cases like this then we also need to move the concrete DOM
|
|
632
|
+
* elements corresponding to the moved children to write the re-order to the
|
|
633
|
+
* DOM.
|
|
634
|
+
*
|
|
635
|
+
* 4. Finally, if VNodes have the `key` attribute set on them we check for any
|
|
636
|
+
* nodes in the old children which have the same key as the first element in
|
|
637
|
+
* our window on the new children. If we find such a node we handle calling
|
|
638
|
+
* out to `patch`, moving relevant DOM nodes, and so on, in accordance with
|
|
639
|
+
* what we find.
|
|
640
|
+
*
|
|
641
|
+
* Finally, once we've narrowed our 'windows' to the point that either of them
|
|
642
|
+
* collapse (i.e. they have length 0) we then handle any remaining VNode
|
|
643
|
+
* insertion or deletion that needs to happen to get a DOM state that correctly
|
|
644
|
+
* reflects the new child VNodes. If, for instance, after our window on the old
|
|
645
|
+
* children has collapsed we still have more nodes on the new children that
|
|
646
|
+
* we haven't dealt with yet then we need to add them, or if the new children
|
|
647
|
+
* collapse but we still have unhandled _old_ children then we need to make
|
|
648
|
+
* sure the corresponding DOM nodes are removed.
|
|
649
|
+
*
|
|
650
|
+
* @param parentElm the node into which the parent VNode is rendered
|
|
651
|
+
* @param oldCh the old children of the parent node
|
|
652
|
+
* @param newVNode the new VNode which will replace the parent
|
|
653
|
+
* @param newCh the new children of the parent node
|
|
654
|
+
*/
|
|
464
655
|
const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
465
656
|
let oldStartIdx = 0;
|
|
466
657
|
let newStartIdx = 0;
|
|
@@ -476,7 +667,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
476
667
|
let elmToMove;
|
|
477
668
|
while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
|
|
478
669
|
if (oldStartVnode == null) {
|
|
479
|
-
//
|
|
670
|
+
// VNode might have been moved left
|
|
480
671
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
481
672
|
}
|
|
482
673
|
else if (oldEndVnode == null) {
|
|
@@ -489,29 +680,65 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
489
680
|
newEndVnode = newCh[--newEndIdx];
|
|
490
681
|
}
|
|
491
682
|
else if (isSameVnode(oldStartVnode, newStartVnode)) {
|
|
683
|
+
// if the start nodes are the same then we should patch the new VNode
|
|
684
|
+
// onto the old one, and increment our `newStartIdx` and `oldStartIdx`
|
|
685
|
+
// indices to reflect that. We don't need to move any DOM Nodes around
|
|
686
|
+
// since things are matched up in order.
|
|
492
687
|
patch(oldStartVnode, newStartVnode);
|
|
493
688
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
494
689
|
newStartVnode = newCh[++newStartIdx];
|
|
495
690
|
}
|
|
496
691
|
else if (isSameVnode(oldEndVnode, newEndVnode)) {
|
|
692
|
+
// likewise, if the end nodes are the same we patch new onto old and
|
|
693
|
+
// decrement our end indices, and also likewise in this case we don't
|
|
694
|
+
// need to move any DOM Nodes.
|
|
497
695
|
patch(oldEndVnode, newEndVnode);
|
|
498
696
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
499
697
|
newEndVnode = newCh[--newEndIdx];
|
|
500
698
|
}
|
|
501
699
|
else if (isSameVnode(oldStartVnode, newEndVnode)) {
|
|
502
700
|
patch(oldStartVnode, newEndVnode);
|
|
701
|
+
// We need to move the element for `oldStartVnode` into a position which
|
|
702
|
+
// will be appropriate for `newEndVnode`. For this we can use
|
|
703
|
+
// `.insertBefore` and `oldEndVnode.$elm$.nextSibling`. If there is a
|
|
704
|
+
// sibling for `oldEndVnode.$elm$` then we want to move the DOM node for
|
|
705
|
+
// `oldStartVnode` between `oldEndVnode` and it's sibling, like so:
|
|
706
|
+
//
|
|
707
|
+
// <old-start-node />
|
|
708
|
+
// <some-intervening-node />
|
|
709
|
+
// <old-end-node />
|
|
710
|
+
// <!-- -> <-- `oldStartVnode.$elm$` should be inserted here
|
|
711
|
+
// <next-sibling />
|
|
712
|
+
//
|
|
713
|
+
// If instead `oldEndVnode.$elm$` has no sibling then we just want to put
|
|
714
|
+
// the node for `oldStartVnode` at the end of the children of
|
|
715
|
+
// `parentElm`. Luckily, `Node.nextSibling` will return `null` if there
|
|
716
|
+
// aren't any siblings, and passing `null` to `Node.insertBefore` will
|
|
717
|
+
// append it to the children of the parent element.
|
|
503
718
|
parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
|
|
504
719
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
505
720
|
newEndVnode = newCh[--newEndIdx];
|
|
506
721
|
}
|
|
507
722
|
else if (isSameVnode(oldEndVnode, newStartVnode)) {
|
|
508
723
|
patch(oldEndVnode, newStartVnode);
|
|
724
|
+
// We've already checked above if `oldStartVnode` and `newStartVnode` are
|
|
725
|
+
// the same node, so since we're here we know that they are not. Thus we
|
|
726
|
+
// can move the element for `oldEndVnode` _before_ the element for
|
|
727
|
+
// `oldStartVnode`, leaving `oldStartVnode` to be reconciled in the
|
|
728
|
+
// future.
|
|
509
729
|
parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
|
|
510
730
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
511
731
|
newStartVnode = newCh[++newStartIdx];
|
|
512
732
|
}
|
|
513
733
|
else {
|
|
514
|
-
//
|
|
734
|
+
// Here we do some checks to match up old and new nodes based on the
|
|
735
|
+
// `$key$` attribute, which is set by putting a `key="my-key"` attribute
|
|
736
|
+
// in the JSX for a DOM element in the implementation of a Stencil
|
|
737
|
+
// component.
|
|
738
|
+
//
|
|
739
|
+
// First we check to see if there are any nodes in the array of old
|
|
740
|
+
// children which have the same key as the first node in the new
|
|
741
|
+
// children.
|
|
515
742
|
idxInOld = -1;
|
|
516
743
|
{
|
|
517
744
|
for (i = oldStartIdx; i <= oldEndIdx; ++i) {
|
|
@@ -522,23 +749,32 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
522
749
|
}
|
|
523
750
|
}
|
|
524
751
|
if (idxInOld >= 0) {
|
|
752
|
+
// We found a node in the old children which matches up with the first
|
|
753
|
+
// node in the new children! So let's deal with that
|
|
525
754
|
elmToMove = oldCh[idxInOld];
|
|
526
755
|
if (elmToMove.$tag$ !== newStartVnode.$tag$) {
|
|
756
|
+
// the tag doesn't match so we'll need a new DOM element
|
|
527
757
|
node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld);
|
|
528
758
|
}
|
|
529
759
|
else {
|
|
530
760
|
patch(elmToMove, newStartVnode);
|
|
761
|
+
// invalidate the matching old node so that we won't try to update it
|
|
762
|
+
// again later on
|
|
531
763
|
oldCh[idxInOld] = undefined;
|
|
532
764
|
node = elmToMove.$elm$;
|
|
533
765
|
}
|
|
534
766
|
newStartVnode = newCh[++newStartIdx];
|
|
535
767
|
}
|
|
536
768
|
else {
|
|
537
|
-
//
|
|
769
|
+
// We either didn't find an element in the old children that matches
|
|
770
|
+
// the key of the first new child OR the build is not using `key`
|
|
771
|
+
// attributes at all. In either case we need to create a new element
|
|
772
|
+
// for the new node.
|
|
538
773
|
node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
|
|
539
774
|
newStartVnode = newCh[++newStartIdx];
|
|
540
775
|
}
|
|
541
776
|
if (node) {
|
|
777
|
+
// if we created a new node then handle inserting it to the DOM
|
|
542
778
|
{
|
|
543
779
|
oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
|
|
544
780
|
}
|
|
@@ -546,22 +782,53 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
546
782
|
}
|
|
547
783
|
}
|
|
548
784
|
if (oldStartIdx > oldEndIdx) {
|
|
785
|
+
// we have some more new nodes to add which don't match up with old nodes
|
|
549
786
|
addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
|
|
550
787
|
}
|
|
551
788
|
else if (newStartIdx > newEndIdx) {
|
|
789
|
+
// there are nodes in the `oldCh` array which no longer correspond to nodes
|
|
790
|
+
// in the new array, so lets remove them (which entails cleaning up the
|
|
791
|
+
// relevant DOM nodes)
|
|
552
792
|
removeVnodes(oldCh, oldStartIdx, oldEndIdx);
|
|
553
793
|
}
|
|
554
794
|
};
|
|
555
|
-
|
|
795
|
+
/**
|
|
796
|
+
* Compare two VNodes to determine if they are the same
|
|
797
|
+
*
|
|
798
|
+
* **NB**: This function is an equality _heuristic_ based on the available
|
|
799
|
+
* information set on the two VNodes and can be misleading under certain
|
|
800
|
+
* circumstances. In particular, if the two nodes do not have `key` attrs
|
|
801
|
+
* (available under `$key$` on VNodes) then the function falls back on merely
|
|
802
|
+
* checking that they have the same tag.
|
|
803
|
+
*
|
|
804
|
+
* So, in other words, if `key` attrs are not set on VNodes which may be
|
|
805
|
+
* changing order within a `children` array or something along those lines then
|
|
806
|
+
* we could obtain a false negative and then have to do needless re-rendering
|
|
807
|
+
* (i.e. we'd say two VNodes aren't equal when in fact they should be).
|
|
808
|
+
*
|
|
809
|
+
* @param leftVNode the first VNode to check
|
|
810
|
+
* @param rightVNode the second VNode to check
|
|
811
|
+
* @returns whether they're equal or not
|
|
812
|
+
*/
|
|
813
|
+
const isSameVnode = (leftVNode, rightVNode) => {
|
|
556
814
|
// compare if two vnode to see if they're "technically" the same
|
|
557
815
|
// need to have the same element tag, and same key to be the same
|
|
558
|
-
if (
|
|
816
|
+
if (leftVNode.$tag$ === rightVNode.$tag$) {
|
|
817
|
+
// this will be set if components in the build have `key` attrs set on them
|
|
559
818
|
{
|
|
560
|
-
return
|
|
819
|
+
return leftVNode.$key$ === rightVNode.$key$;
|
|
561
820
|
}
|
|
562
821
|
}
|
|
563
822
|
return false;
|
|
564
823
|
};
|
|
824
|
+
/**
|
|
825
|
+
* Handle reconciling an outdated VNode with a new one which corresponds to
|
|
826
|
+
* it. This function handles flushing updates to the DOM and reconciling the
|
|
827
|
+
* children of the two nodes (if any).
|
|
828
|
+
*
|
|
829
|
+
* @param oldVNode an old VNode whose DOM element and children we want to update
|
|
830
|
+
* @param newVNode a new VNode representing an updated version of the old one
|
|
831
|
+
*/
|
|
565
832
|
const patch = (oldVNode, newVNode) => {
|
|
566
833
|
const elm = (newVNode.$elm$ = oldVNode.$elm$);
|
|
567
834
|
const oldChildren = oldVNode.$children$;
|
|
@@ -574,7 +841,6 @@ const patch = (oldVNode, newVNode) => {
|
|
|
574
841
|
// only add this to the when the compiler sees we're using an svg somewhere
|
|
575
842
|
isSvgMode = tag === 'svg' ? true : tag === 'foreignObject' ? false : isSvgMode;
|
|
576
843
|
}
|
|
577
|
-
// element node
|
|
578
844
|
{
|
|
579
845
|
{
|
|
580
846
|
// either this is the first render of an element OR it's an update
|
|
@@ -585,6 +851,7 @@ const patch = (oldVNode, newVNode) => {
|
|
|
585
851
|
}
|
|
586
852
|
if (oldChildren !== null && newChildren !== null) {
|
|
587
853
|
// looks like there's child vnodes for both the old and new vnodes
|
|
854
|
+
// so we need to call `updateChildren` to reconcile them
|
|
588
855
|
updateChildren(elm, oldChildren, newVNode, newChildren);
|
|
589
856
|
}
|
|
590
857
|
else if (newChildren !== null) {
|
|
@@ -616,29 +883,29 @@ const callNodeRefs = (vNode) => {
|
|
|
616
883
|
vNode.$children$ && vNode.$children$.map(callNodeRefs);
|
|
617
884
|
}
|
|
618
885
|
};
|
|
886
|
+
/**
|
|
887
|
+
* The main entry point for Stencil's virtual DOM-based rendering engine
|
|
888
|
+
*
|
|
889
|
+
* Given a {@link d.HostRef} container and some virtual DOM nodes, this
|
|
890
|
+
* function will handle creating a virtual DOM tree with a single root, patching
|
|
891
|
+
* the current virtual DOM tree onto an old one (if any), dealing with slot
|
|
892
|
+
* relocation, and reflecting attributes.
|
|
893
|
+
*
|
|
894
|
+
* @param hostRef data needed to root and render the virtual DOM tree, such as
|
|
895
|
+
* the DOM node into which it should be rendered.
|
|
896
|
+
* @param renderFnResults the virtual DOM nodes to be rendered
|
|
897
|
+
*/
|
|
619
898
|
const renderVdom = (hostRef, renderFnResults) => {
|
|
620
899
|
const hostElm = hostRef.$hostElement$;
|
|
621
900
|
const oldVNode = hostRef.$vnode$ || newVNode(null, null);
|
|
622
901
|
const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
|
|
623
902
|
rootVnode.$tag$ = null;
|
|
624
|
-
rootVnode.$flags$ |= 4 /* isHost */;
|
|
903
|
+
rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
|
|
625
904
|
hostRef.$vnode$ = rootVnode;
|
|
626
905
|
rootVnode.$elm$ = oldVNode.$elm$ = (hostElm);
|
|
627
906
|
// synchronous patch
|
|
628
907
|
patch(oldVNode, rootVnode);
|
|
629
908
|
};
|
|
630
|
-
/**
|
|
631
|
-
* Helper function to create & dispatch a custom Event on a provided target
|
|
632
|
-
* @param elm the target of the Event
|
|
633
|
-
* @param name the name to give the custom Event
|
|
634
|
-
* @param opts options for configuring a custom Event
|
|
635
|
-
* @returns the custom Event
|
|
636
|
-
*/
|
|
637
|
-
const emitEvent = (elm, name, opts) => {
|
|
638
|
-
const ev = plt.ce(name, opts);
|
|
639
|
-
elm.dispatchEvent(ev);
|
|
640
|
-
return ev;
|
|
641
|
-
};
|
|
642
909
|
const attachToAncestor = (hostRef, ancestorComponent) => {
|
|
643
910
|
if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
|
|
644
911
|
ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
|
|
@@ -646,10 +913,10 @@ const attachToAncestor = (hostRef, ancestorComponent) => {
|
|
|
646
913
|
};
|
|
647
914
|
const scheduleUpdate = (hostRef, isInitialLoad) => {
|
|
648
915
|
{
|
|
649
|
-
hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
|
|
916
|
+
hostRef.$flags$ |= 16 /* HOST_FLAGS.isQueuedForUpdate */;
|
|
650
917
|
}
|
|
651
|
-
if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
|
|
652
|
-
hostRef.$flags$ |= 512 /* needsRerender */;
|
|
918
|
+
if (hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
|
|
919
|
+
hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
|
|
653
920
|
return;
|
|
654
921
|
}
|
|
655
922
|
attachToAncestor(hostRef, hostRef.$ancestorComponent$);
|
|
@@ -668,6 +935,11 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
|
|
|
668
935
|
promise = safeCall(instance, 'componentWillLoad');
|
|
669
936
|
}
|
|
670
937
|
}
|
|
938
|
+
else {
|
|
939
|
+
{
|
|
940
|
+
promise = safeCall(instance, 'componentWillUpdate');
|
|
941
|
+
}
|
|
942
|
+
}
|
|
671
943
|
endSchedule();
|
|
672
944
|
return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
|
|
673
945
|
};
|
|
@@ -701,7 +973,7 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
|
|
|
701
973
|
}
|
|
702
974
|
else {
|
|
703
975
|
Promise.all(childrenPromises).then(postUpdate);
|
|
704
|
-
hostRef.$flags$ |= 4 /* isWaitingForChildren */;
|
|
976
|
+
hostRef.$flags$ |= 4 /* HOST_FLAGS.isWaitingForChildren */;
|
|
705
977
|
childrenPromises.length = 0;
|
|
706
978
|
}
|
|
707
979
|
}
|
|
@@ -710,10 +982,10 @@ const callRender = (hostRef, instance, elm) => {
|
|
|
710
982
|
try {
|
|
711
983
|
instance = instance.render() ;
|
|
712
984
|
{
|
|
713
|
-
hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
|
|
985
|
+
hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
|
|
714
986
|
}
|
|
715
987
|
{
|
|
716
|
-
hostRef.$flags$ |= 2 /* hasRendered */;
|
|
988
|
+
hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
|
|
717
989
|
}
|
|
718
990
|
{
|
|
719
991
|
{
|
|
@@ -740,8 +1012,8 @@ const postUpdateComponent = (hostRef) => {
|
|
|
740
1012
|
{
|
|
741
1013
|
safeCall(instance, 'componentDidRender');
|
|
742
1014
|
}
|
|
743
|
-
if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
|
|
744
|
-
hostRef.$flags$ |= 64 /* hasLoadedComponent */;
|
|
1015
|
+
if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
|
|
1016
|
+
hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
|
|
745
1017
|
{
|
|
746
1018
|
// DOM WRITE!
|
|
747
1019
|
addHydratedFlag(elm);
|
|
@@ -770,10 +1042,10 @@ const postUpdateComponent = (hostRef) => {
|
|
|
770
1042
|
hostRef.$onRenderResolve$();
|
|
771
1043
|
hostRef.$onRenderResolve$ = undefined;
|
|
772
1044
|
}
|
|
773
|
-
if (hostRef.$flags$ & 512 /* needsRerender */) {
|
|
1045
|
+
if (hostRef.$flags$ & 512 /* HOST_FLAGS.needsRerender */) {
|
|
774
1046
|
nextTick(() => scheduleUpdate(hostRef, false));
|
|
775
1047
|
}
|
|
776
|
-
hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
|
|
1048
|
+
hostRef.$flags$ &= ~(4 /* HOST_FLAGS.isWaitingForChildren */ | 512 /* HOST_FLAGS.needsRerender */);
|
|
777
1049
|
}
|
|
778
1050
|
// ( •_•)
|
|
779
1051
|
// ( •_•)>⌐■-■
|
|
@@ -803,30 +1075,6 @@ const then = (promise, thenFn) => {
|
|
|
803
1075
|
};
|
|
804
1076
|
const addHydratedFlag = (elm) => elm.classList.add('hydrated')
|
|
805
1077
|
;
|
|
806
|
-
const parsePropertyValue = (propValue, propType) => {
|
|
807
|
-
// ensure this value is of the correct prop type
|
|
808
|
-
if (propValue != null && !isComplexType(propValue)) {
|
|
809
|
-
if (propType & 4 /* Boolean */) {
|
|
810
|
-
// per the HTML spec, any string value means it is a boolean true value
|
|
811
|
-
// but we'll cheat here and say that the string "false" is the boolean false
|
|
812
|
-
return propValue === 'false' ? false : propValue === '' || !!propValue;
|
|
813
|
-
}
|
|
814
|
-
if (propType & 2 /* Number */) {
|
|
815
|
-
// force it to be a number
|
|
816
|
-
return parseFloat(propValue);
|
|
817
|
-
}
|
|
818
|
-
if (propType & 1 /* String */) {
|
|
819
|
-
// could have been passed as a number or boolean
|
|
820
|
-
// but we still want it as a string
|
|
821
|
-
return String(propValue);
|
|
822
|
-
}
|
|
823
|
-
// redundant return here for better minification
|
|
824
|
-
return propValue;
|
|
825
|
-
}
|
|
826
|
-
// not sure exactly what type we want
|
|
827
|
-
// so no need to change to a different type
|
|
828
|
-
return propValue;
|
|
829
|
-
};
|
|
830
1078
|
const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
|
|
831
1079
|
const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
832
1080
|
// check our new property value against our internal value
|
|
@@ -835,12 +1083,15 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
835
1083
|
const flags = hostRef.$flags$;
|
|
836
1084
|
const instance = hostRef.$lazyInstance$ ;
|
|
837
1085
|
newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
|
|
838
|
-
|
|
1086
|
+
// explicitly check for NaN on both sides, as `NaN === NaN` is always false
|
|
1087
|
+
const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
|
|
1088
|
+
const didValueChange = newVal !== oldVal && !areBothNaN;
|
|
1089
|
+
if ((!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
|
|
839
1090
|
// gadzooks! the property's value has changed!!
|
|
840
1091
|
// set our new value!
|
|
841
1092
|
hostRef.$instanceValues$.set(propName, newVal);
|
|
842
1093
|
if (instance) {
|
|
843
|
-
if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
|
|
1094
|
+
if ((flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
|
|
844
1095
|
// looks like this value actually changed, so we've got work to do!
|
|
845
1096
|
// but only if we've already rendered, otherwise just chill out
|
|
846
1097
|
// queue that we need to do an update, but don't worry about queuing
|
|
@@ -850,14 +1101,24 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
850
1101
|
}
|
|
851
1102
|
}
|
|
852
1103
|
};
|
|
1104
|
+
/**
|
|
1105
|
+
* Attach a series of runtime constructs to a compiled Stencil component
|
|
1106
|
+
* constructor, including getters and setters for the `@Prop` and `@State`
|
|
1107
|
+
* decorators, callbacks for when attributes change, and so on.
|
|
1108
|
+
*
|
|
1109
|
+
* @param Cstr the constructor for a component that we need to process
|
|
1110
|
+
* @param cmpMeta metadata collected previously about the component
|
|
1111
|
+
* @param flags a number used to store a series of bit flags
|
|
1112
|
+
* @returns a reference to the same constructor passed in (but now mutated)
|
|
1113
|
+
*/
|
|
853
1114
|
const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
854
1115
|
if (cmpMeta.$members$) {
|
|
855
1116
|
// It's better to have a const than two Object.entries()
|
|
856
1117
|
const members = Object.entries(cmpMeta.$members$);
|
|
857
1118
|
const prototype = Cstr.prototype;
|
|
858
1119
|
members.map(([memberName, [memberFlags]]) => {
|
|
859
|
-
if ((memberFlags & 31 /* Prop */ ||
|
|
860
|
-
((flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
|
|
1120
|
+
if ((memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
|
|
1121
|
+
((flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
|
|
861
1122
|
// proxyComponent - prop
|
|
862
1123
|
Object.defineProperty(prototype, memberName, {
|
|
863
1124
|
get() {
|
|
@@ -872,8 +1133,8 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
872
1133
|
enumerable: true,
|
|
873
1134
|
});
|
|
874
1135
|
}
|
|
875
|
-
else if (flags & 1 /* isElementConstructor */ &&
|
|
876
|
-
memberFlags & 64 /* Method */) {
|
|
1136
|
+
else if (flags & 1 /* PROXY_FLAGS.isElementConstructor */ &&
|
|
1137
|
+
memberFlags & 64 /* MEMBER_FLAGS.Method */) {
|
|
877
1138
|
// proxyComponent - method
|
|
878
1139
|
Object.defineProperty(prototype, memberName, {
|
|
879
1140
|
value(...args) {
|
|
@@ -883,19 +1144,19 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
883
1144
|
});
|
|
884
1145
|
}
|
|
885
1146
|
});
|
|
886
|
-
if ((flags & 1 /* isElementConstructor */)) {
|
|
1147
|
+
if ((flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
|
|
887
1148
|
const attrNameToPropName = new Map();
|
|
888
1149
|
prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
|
|
889
1150
|
plt.jmp(() => {
|
|
890
1151
|
const propName = attrNameToPropName.get(attrName);
|
|
891
|
-
// In a
|
|
1152
|
+
// In a web component lifecycle the attributeChangedCallback runs prior to connectedCallback
|
|
892
1153
|
// in the case where an attribute was set inline.
|
|
893
1154
|
// ```html
|
|
894
1155
|
// <my-component some-attribute="some-value"></my-component>
|
|
895
1156
|
// ```
|
|
896
1157
|
//
|
|
897
|
-
// There is an edge case where a developer sets the attribute inline on a custom element and then
|
|
898
|
-
// changes it before it has been upgraded as shown below:
|
|
1158
|
+
// There is an edge case where a developer sets the attribute inline on a custom element and then
|
|
1159
|
+
// programmatically changes it before it has been upgraded as shown below:
|
|
899
1160
|
//
|
|
900
1161
|
// ```html
|
|
901
1162
|
// <!-- this component has _not_ been upgraded yet -->
|
|
@@ -905,13 +1166,13 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
905
1166
|
// el = document.querySelector("#test");
|
|
906
1167
|
// el.someAttribute = "another-value";
|
|
907
1168
|
// // upgrade component
|
|
908
|
-
//
|
|
1169
|
+
// customElements.define('my-component', MyComponent);
|
|
909
1170
|
// </script>
|
|
910
1171
|
// ```
|
|
911
1172
|
// In this case if we do not unshadow here and use the value of the shadowing property, attributeChangedCallback
|
|
912
1173
|
// will be called with `newValue = "some-value"` and will set the shadowed property (this.someAttribute = "another-value")
|
|
913
1174
|
// to the value that was set inline i.e. "some-value" from above example. When
|
|
914
|
-
// the connectedCallback attempts to unshadow it will use "some-value" as the
|
|
1175
|
+
// the connectedCallback attempts to unshadow it will use "some-value" as the initial value rather than "another-value"
|
|
915
1176
|
//
|
|
916
1177
|
// The case where the attribute was NOT set inline but was not set programmatically shall be handled/unshadowed
|
|
917
1178
|
// by connectedCallback as this attributeChangedCallback will not fire.
|
|
@@ -925,13 +1186,21 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
925
1186
|
newValue = this[propName];
|
|
926
1187
|
delete this[propName];
|
|
927
1188
|
}
|
|
1189
|
+
else if (prototype.hasOwnProperty(propName) &&
|
|
1190
|
+
typeof this[propName] === 'number' &&
|
|
1191
|
+
this[propName] == newValue) {
|
|
1192
|
+
// if the propName exists on the prototype of `Cstr`, this update may be a result of Stencil using native
|
|
1193
|
+
// APIs to reflect props as attributes. Calls to `setAttribute(someElement, propName)` will result in
|
|
1194
|
+
// `propName` to be converted to a `DOMString`, which may not be what we want for other primitive props.
|
|
1195
|
+
return;
|
|
1196
|
+
}
|
|
928
1197
|
this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
|
|
929
1198
|
});
|
|
930
1199
|
};
|
|
931
1200
|
// create an array of attributes to observe
|
|
932
1201
|
// and also create a map of html attribute name to js property name
|
|
933
1202
|
Cstr.observedAttributes = members
|
|
934
|
-
.filter(([_, m]) => m[0] & 15 /* HasAttribute */) // filter to only keep props that should match attributes
|
|
1203
|
+
.filter(([_, m]) => m[0] & 15 /* MEMBER_FLAGS.HasAttribute */) // filter to only keep props that should match attributes
|
|
935
1204
|
.map(([propName, m]) => {
|
|
936
1205
|
const attrName = m[1] || propName;
|
|
937
1206
|
attrNameToPropName.set(attrName, propName);
|
|
@@ -943,10 +1212,10 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
943
1212
|
};
|
|
944
1213
|
const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
|
|
945
1214
|
// initializeComponent
|
|
946
|
-
if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
|
|
1215
|
+
if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
|
|
947
1216
|
{
|
|
948
1217
|
// we haven't initialized this element yet
|
|
949
|
-
hostRef.$flags$ |= 32 /* hasInitializedComponent */;
|
|
1218
|
+
hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
|
|
950
1219
|
// lazy loaded components
|
|
951
1220
|
// request the component's implementation to be
|
|
952
1221
|
// wired up with the host element
|
|
@@ -958,7 +1227,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
958
1227
|
endLoad();
|
|
959
1228
|
}
|
|
960
1229
|
if (!Cstr.isProxied) {
|
|
961
|
-
proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
|
|
1230
|
+
proxyComponent(Cstr, cmpMeta, 2 /* PROXY_FLAGS.proxyState */);
|
|
962
1231
|
Cstr.isProxied = true;
|
|
963
1232
|
}
|
|
964
1233
|
const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
|
|
@@ -966,7 +1235,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
966
1235
|
// but let's keep track of when we start and stop
|
|
967
1236
|
// so that the getters/setters don't incorrectly step on data
|
|
968
1237
|
{
|
|
969
|
-
hostRef.$flags$ |= 8 /* isConstructingInstance */;
|
|
1238
|
+
hostRef.$flags$ |= 8 /* HOST_FLAGS.isConstructingInstance */;
|
|
970
1239
|
}
|
|
971
1240
|
// construct the lazy-loaded component implementation
|
|
972
1241
|
// passing the hostRef is very important during
|
|
@@ -979,7 +1248,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
979
1248
|
consoleError(e);
|
|
980
1249
|
}
|
|
981
1250
|
{
|
|
982
|
-
hostRef.$flags$ &= ~8 /* isConstructingInstance */;
|
|
1251
|
+
hostRef.$flags$ &= ~8 /* HOST_FLAGS.isConstructingInstance */;
|
|
983
1252
|
}
|
|
984
1253
|
endNewInstance();
|
|
985
1254
|
}
|
|
@@ -989,7 +1258,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
989
1258
|
const scopeId = getScopeId(cmpMeta);
|
|
990
1259
|
if (!styles.has(scopeId)) {
|
|
991
1260
|
const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
|
|
992
|
-
registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
|
|
1261
|
+
registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
|
|
993
1262
|
endRegisterStyles();
|
|
994
1263
|
}
|
|
995
1264
|
}
|
|
@@ -998,7 +1267,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
998
1267
|
const ancestorComponent = hostRef.$ancestorComponent$;
|
|
999
1268
|
const schedule = () => scheduleUpdate(hostRef, true);
|
|
1000
1269
|
if (ancestorComponent && ancestorComponent['s-rc']) {
|
|
1001
|
-
// this is the
|
|
1270
|
+
// this is the initial load and this component it has an ancestor component
|
|
1002
1271
|
// but the ancestor component has NOT fired its will update lifecycle yet
|
|
1003
1272
|
// so let's just cool our jets and wait for the ancestor to continue first
|
|
1004
1273
|
// this will get fired off when the ancestor component
|
|
@@ -1011,13 +1280,13 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1011
1280
|
}
|
|
1012
1281
|
};
|
|
1013
1282
|
const connectedCallback = (elm) => {
|
|
1014
|
-
if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
|
|
1283
|
+
if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
|
|
1015
1284
|
const hostRef = getHostRef(elm);
|
|
1016
1285
|
const cmpMeta = hostRef.$cmpMeta$;
|
|
1017
1286
|
const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
|
|
1018
|
-
if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
|
|
1287
|
+
if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
|
|
1019
1288
|
// first time this component has connected
|
|
1020
|
-
hostRef.$flags$ |= 1 /* hasConnected */;
|
|
1289
|
+
hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
|
|
1021
1290
|
{
|
|
1022
1291
|
// find the first ancestor component (if there is one) and register
|
|
1023
1292
|
// this component as one of the actively loading child components for its ancestor
|
|
@@ -1037,7 +1306,7 @@ const connectedCallback = (elm) => {
|
|
|
1037
1306
|
// https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
|
|
1038
1307
|
if (cmpMeta.$members$) {
|
|
1039
1308
|
Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
|
|
1040
|
-
if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
|
|
1309
|
+
if (memberFlags & 31 /* MEMBER_FLAGS.Prop */ && elm.hasOwnProperty(memberName)) {
|
|
1041
1310
|
const value = elm[memberName];
|
|
1042
1311
|
delete elm[memberName];
|
|
1043
1312
|
elm[memberName] = value;
|
|
@@ -1052,11 +1321,12 @@ const connectedCallback = (elm) => {
|
|
|
1052
1321
|
}
|
|
1053
1322
|
};
|
|
1054
1323
|
const disconnectedCallback = (elm) => {
|
|
1055
|
-
if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
|
|
1324
|
+
if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
|
|
1056
1325
|
getHostRef(elm);
|
|
1057
1326
|
}
|
|
1058
1327
|
};
|
|
1059
1328
|
const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
1329
|
+
var _a;
|
|
1060
1330
|
const endBootstrap = createTime();
|
|
1061
1331
|
const cmpTags = [];
|
|
1062
1332
|
const exclude = options.exclude || [];
|
|
@@ -1069,54 +1339,61 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1069
1339
|
let isBootstrapping = true;
|
|
1070
1340
|
Object.assign(plt, options);
|
|
1071
1341
|
plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
|
|
1072
|
-
lazyBundles.map((lazyBundle) =>
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
const tagName = cmpMeta.$tagName$;
|
|
1083
|
-
const HostElement = class extends HTMLElement {
|
|
1084
|
-
// StencilLazyHost
|
|
1085
|
-
constructor(self) {
|
|
1086
|
-
// @ts-ignore
|
|
1087
|
-
super(self);
|
|
1088
|
-
self = this;
|
|
1089
|
-
registerHost(self, cmpMeta);
|
|
1342
|
+
lazyBundles.map((lazyBundle) => {
|
|
1343
|
+
lazyBundle[1].map((compactMeta) => {
|
|
1344
|
+
const cmpMeta = {
|
|
1345
|
+
$flags$: compactMeta[0],
|
|
1346
|
+
$tagName$: compactMeta[1],
|
|
1347
|
+
$members$: compactMeta[2],
|
|
1348
|
+
$listeners$: compactMeta[3],
|
|
1349
|
+
};
|
|
1350
|
+
{
|
|
1351
|
+
cmpMeta.$members$ = compactMeta[2];
|
|
1090
1352
|
}
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1353
|
+
const tagName = cmpMeta.$tagName$;
|
|
1354
|
+
const HostElement = class extends HTMLElement {
|
|
1355
|
+
// StencilLazyHost
|
|
1356
|
+
constructor(self) {
|
|
1357
|
+
// @ts-ignore
|
|
1358
|
+
super(self);
|
|
1359
|
+
self = this;
|
|
1360
|
+
registerHost(self, cmpMeta);
|
|
1095
1361
|
}
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1362
|
+
connectedCallback() {
|
|
1363
|
+
if (appLoadFallback) {
|
|
1364
|
+
clearTimeout(appLoadFallback);
|
|
1365
|
+
appLoadFallback = null;
|
|
1366
|
+
}
|
|
1367
|
+
if (isBootstrapping) {
|
|
1368
|
+
// connectedCallback will be processed once all components have been registered
|
|
1369
|
+
deferredConnectedCallbacks.push(this);
|
|
1370
|
+
}
|
|
1371
|
+
else {
|
|
1372
|
+
plt.jmp(() => connectedCallback(this));
|
|
1373
|
+
}
|
|
1099
1374
|
}
|
|
1100
|
-
|
|
1101
|
-
plt.jmp(() =>
|
|
1375
|
+
disconnectedCallback() {
|
|
1376
|
+
plt.jmp(() => disconnectedCallback(this));
|
|
1102
1377
|
}
|
|
1378
|
+
componentOnReady() {
|
|
1379
|
+
return getHostRef(this).$onReadyPromise$;
|
|
1380
|
+
}
|
|
1381
|
+
};
|
|
1382
|
+
cmpMeta.$lazyBundleId$ = lazyBundle[0];
|
|
1383
|
+
if (!exclude.includes(tagName) && !customElements.get(tagName)) {
|
|
1384
|
+
cmpTags.push(tagName);
|
|
1385
|
+
customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */));
|
|
1103
1386
|
}
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
}
|
|
1107
|
-
componentOnReady() {
|
|
1108
|
-
return getHostRef(this).$onReadyPromise$;
|
|
1109
|
-
}
|
|
1110
|
-
};
|
|
1111
|
-
cmpMeta.$lazyBundleId$ = lazyBundle[0];
|
|
1112
|
-
if (!exclude.includes(tagName) && !customElements.get(tagName)) {
|
|
1113
|
-
cmpTags.push(tagName);
|
|
1114
|
-
customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
|
|
1115
|
-
}
|
|
1116
|
-
}));
|
|
1387
|
+
});
|
|
1388
|
+
});
|
|
1117
1389
|
{
|
|
1118
1390
|
visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
|
|
1119
1391
|
visibilityStyle.setAttribute('data-styles', '');
|
|
1392
|
+
// Apply CSP nonce to the style tag if it exists
|
|
1393
|
+
const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
|
|
1394
|
+
if (nonce != null) {
|
|
1395
|
+
visibilityStyle.setAttribute('nonce', nonce);
|
|
1396
|
+
}
|
|
1120
1397
|
head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
|
|
1121
1398
|
}
|
|
1122
1399
|
// Process deferred connectedCallbacks now all components have been registered
|
|
@@ -1132,11 +1409,14 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1132
1409
|
// Fallback appLoad event
|
|
1133
1410
|
endBootstrap();
|
|
1134
1411
|
};
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1412
|
+
/**
|
|
1413
|
+
* Assigns the given value to the nonce property on the runtime platform object.
|
|
1414
|
+
* During runtime, this value is used to set the nonce attribute on all dynamically created script and style tags.
|
|
1415
|
+
* @param nonce The value to be assigned to the platform nonce property.
|
|
1416
|
+
* @returns void
|
|
1417
|
+
*/
|
|
1418
|
+
const setNonce = (nonce) => (plt.$nonce$ = nonce);
|
|
1419
|
+
const hostRefs = /*@__PURE__*/ new WeakMap();
|
|
1140
1420
|
const getHostRef = (ref) => hostRefs.get(ref);
|
|
1141
1421
|
const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
|
|
1142
1422
|
const registerHost = (elm, cmpMeta) => {
|
|
@@ -1167,7 +1447,9 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
|
|
|
1167
1447
|
if (module) {
|
|
1168
1448
|
return module[exportName];
|
|
1169
1449
|
}
|
|
1450
|
+
/*!__STENCIL_STATIC_IMPORT_SWITCH__*/
|
|
1170
1451
|
return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
|
|
1452
|
+
/* @vite-ignore */
|
|
1171
1453
|
/* webpackInclude: /\.entry\.js$/ */
|
|
1172
1454
|
/* webpackExclude: /\.system\.entry\.js$/ */
|
|
1173
1455
|
/* webpackMode: "lazy" */
|
|
@@ -1178,14 +1460,35 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
|
|
|
1178
1460
|
return importedModule[exportName];
|
|
1179
1461
|
}, consoleError);
|
|
1180
1462
|
};
|
|
1181
|
-
const styles = new Map();
|
|
1463
|
+
const styles = /*@__PURE__*/ new Map();
|
|
1464
|
+
const win = typeof window !== 'undefined' ? window : {};
|
|
1465
|
+
const doc = win.document || { head: {} };
|
|
1466
|
+
const plt = {
|
|
1467
|
+
$flags$: 0,
|
|
1468
|
+
$resourcesUrl$: '',
|
|
1469
|
+
jmp: (h) => h(),
|
|
1470
|
+
raf: (h) => requestAnimationFrame(h),
|
|
1471
|
+
ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
|
|
1472
|
+
rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
|
|
1473
|
+
ce: (eventName, opts) => new CustomEvent(eventName, opts),
|
|
1474
|
+
};
|
|
1475
|
+
const promiseResolve = (v) => Promise.resolve(v);
|
|
1476
|
+
const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
|
|
1477
|
+
try {
|
|
1478
|
+
new CSSStyleSheet();
|
|
1479
|
+
return typeof new CSSStyleSheet().replaceSync === 'function';
|
|
1480
|
+
}
|
|
1481
|
+
catch (e) { }
|
|
1482
|
+
return false;
|
|
1483
|
+
})()
|
|
1484
|
+
;
|
|
1182
1485
|
const queueDomReads = [];
|
|
1183
1486
|
const queueDomWrites = [];
|
|
1184
1487
|
const queueTask = (queue, write) => (cb) => {
|
|
1185
1488
|
queue.push(cb);
|
|
1186
1489
|
if (!queuePending) {
|
|
1187
1490
|
queuePending = true;
|
|
1188
|
-
if (write && plt.$flags$ & 4 /* queueSync */) {
|
|
1491
|
+
if (write && plt.$flags$ & 4 /* PLATFORM_FLAGS.queueSync */) {
|
|
1189
1492
|
nextTick(flush);
|
|
1190
1493
|
}
|
|
1191
1494
|
else {
|
|
@@ -1227,3 +1530,4 @@ exports.getAssetPath = getAssetPath;
|
|
|
1227
1530
|
exports.h = h;
|
|
1228
1531
|
exports.promiseResolve = promiseResolve;
|
|
1229
1532
|
exports.registerInstance = registerInstance;
|
|
1533
|
+
exports.setNonce = setNonce;
|