@geotrekce/geotrek-rando-widget 0.0.13 → 0.0.15
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/css-shim-1269258a.js +6 -0
- package/dist/cjs/{dom-d5e52c7e.js → dom-36862b77.js} +1 -1
- package/dist/cjs/geotrek-rando-widget.cjs.js +4 -4
- package/dist/cjs/grw-app.cjs.entry.js +5 -4
- package/dist/cjs/grw-filter_6.cjs.entry.js +489 -183
- package/dist/cjs/grw-information-desk-detail_3.cjs.entry.js +2 -2
- package/dist/cjs/grw-trek-card.cjs.entry.js +15 -7
- package/dist/cjs/{index-66d58516.js → index-e5425fef.js} +437 -266
- package/dist/cjs/loader.cjs.js +4 -4
- package/dist/cjs/{shadow-css-cf936b02.js → shadow-css-346c0795.js} +1 -1
- package/dist/cjs/{store-d301af22.js → store-a9172740.js} +4 -2
- package/dist/collection/collection-manifest.json +2 -2
- package/dist/collection/components/grw-app/grw-app.css +4 -0
- package/dist/collection/components/grw-app/grw-app.js +432 -450
- package/dist/collection/components/grw-filter/grw-filter.js +65 -61
- package/dist/collection/components/grw-information-desk-detail/grw-information-desk-detail.js +35 -44
- package/dist/collection/components/grw-map/grw-map.css +5 -4
- package/dist/collection/components/grw-map/grw-map.js +251 -217
- package/dist/collection/components/grw-poi-detail/grw-poi-detail.js +33 -32
- package/dist/collection/components/grw-sensitive-area-detail/grw-sensitive-area-detail.js +42 -47
- package/dist/collection/components/grw-trek-card/grw-trek-card.js +142 -129
- package/dist/collection/components/grw-trek-detail/grw-trek-detail.js +135 -208
- package/dist/collection/components/grw-treks-list/grw-treks-list.js +95 -65
- package/dist/collection/store/grw-trek-provider.js +61 -55
- package/dist/collection/store/grw-treks-provider.js +181 -177
- package/dist/collection/store/store.js +3 -2
- package/dist/components/grw-app.js +4 -3
- package/dist/components/grw-map2.js +467 -176
- package/dist/components/grw-trek-card2.js +17 -7
- package/dist/components/grw-trek-detail2.js +10 -3
- package/dist/components/grw-trek-provider2.js +6 -2
- package/dist/components/grw-treks-list2.js +7 -2
- package/dist/components/grw-treks-provider2.js +5 -3
- package/dist/components/store.js +3 -2
- package/dist/esm/css-shim-88cc621b.js +4 -0
- package/dist/esm/{dom-9794f747.js → dom-665d6011.js} +1 -1
- package/dist/esm/geotrek-rando-widget.js +4 -4
- package/dist/esm/grw-app.entry.js +5 -4
- package/dist/esm/grw-filter_6.entry.js +489 -183
- package/dist/esm/grw-information-desk-detail_3.entry.js +2 -2
- package/dist/esm/grw-trek-card.entry.js +15 -7
- package/dist/esm/{index-899307bb.js → index-185d186f.js} +437 -266
- package/dist/esm/loader.js +4 -4
- package/dist/esm/polyfills/css-shim.js +1 -1
- package/dist/esm/{shadow-css-4cd4480f.js → shadow-css-b18e99d7.js} +1 -1
- package/dist/esm/{store-70461a28.js → store-38e90440.js} +4 -3
- package/dist/esm-es5/css-shim-88cc621b.js +1 -0
- package/dist/esm-es5/{dom-9794f747.js → dom-665d6011.js} +0 -0
- package/dist/esm-es5/geotrek-rando-widget.js +1 -1
- package/dist/esm-es5/grw-app.entry.js +1 -1
- package/dist/esm-es5/grw-filter_6.entry.js +3 -3
- package/dist/esm-es5/grw-information-desk-detail_3.entry.js +1 -1
- package/dist/esm-es5/grw-trek-card.entry.js +1 -1
- package/dist/esm-es5/index-185d186f.js +2 -0
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/{shadow-css-4cd4480f.js → shadow-css-b18e99d7.js} +0 -0
- package/dist/esm-es5/{store-70461a28.js → store-38e90440.js} +1 -1
- package/dist/geotrek-rando-widget/geotrek-rando-widget.esm.js +1 -1
- package/dist/geotrek-rando-widget/geotrek-rando-widget.js +2 -2
- package/dist/geotrek-rando-widget/p-144c62f8.system.entry.js +1 -0
- package/dist/geotrek-rando-widget/p-23a696ea.system.entry.js +6 -0
- package/dist/geotrek-rando-widget/p-412fe797.system.js +1 -0
- package/dist/geotrek-rando-widget/p-4b12d113.js +1 -0
- package/dist/geotrek-rando-widget/p-54bf2ec8.js +2 -0
- package/dist/geotrek-rando-widget/{p-d1582cff.js → p-62b28500.js} +0 -0
- package/dist/geotrek-rando-widget/{p-2bd0278f.system.entry.js → p-6484dee6.system.entry.js} +1 -1
- package/dist/geotrek-rando-widget/{p-c8c96517.system.js → p-6a050b2c.system.js} +0 -0
- package/dist/geotrek-rando-widget/{p-b1530d9c.system.js → p-88092d06.system.js} +0 -0
- package/dist/geotrek-rando-widget/{p-533fc2bb.entry.js → p-911224bd.entry.js} +1 -1
- package/dist/geotrek-rando-widget/p-b44ba765.entry.js +1 -0
- package/dist/geotrek-rando-widget/p-bd5f732d.entry.js +1 -0
- package/dist/geotrek-rando-widget/p-d2dd6057.js +1 -0
- package/dist/geotrek-rando-widget/p-d6fffac2.entry.js +1 -0
- package/dist/geotrek-rando-widget/p-dd8d9020.system.js +2 -0
- package/dist/geotrek-rando-widget/p-e2652fee.system.js +1 -0
- package/dist/geotrek-rando-widget/p-e763374d.system.entry.js +1 -0
- package/dist/geotrek-rando-widget/{p-4eaf20b7.js → p-f26ed61d.js} +0 -0
- package/dist/geotrek-rando-widget/{p-82ca029f.system.js → p-f7cc8285.system.js} +1 -1
- package/dist/types/components/grw-map/grw-map.d.ts +3 -1
- package/dist/types/components/grw-trek-card/grw-trek-card.d.ts +4 -1
- package/dist/types/components/grw-trek-detail/grw-trek-detail.d.ts +3 -1
- package/dist/types/components/grw-treks-list/grw-treks-list.d.ts +1 -0
- package/dist/types/components.d.ts +8 -0
- package/dist/types/stencil-public-runtime.d.ts +15 -4
- package/dist/types/store/store.d.ts +5 -3
- package/dist/types/types/types.d.ts +6 -0
- package/loader/package.json +1 -0
- package/package.json +12 -12
- package/readme.md +4 -6
- package/dist/cjs/css-shim-6f592941.js +0 -6
- package/dist/esm/css-shim-2d0a698c.js +0 -4
- package/dist/esm-es5/css-shim-2d0a698c.js +0 -1
- package/dist/esm-es5/index-899307bb.js +0 -2
- package/dist/geotrek-rando-widget/p-067c02c4.system.js +0 -1
- package/dist/geotrek-rando-widget/p-0c5b047c.js +0 -1
- package/dist/geotrek-rando-widget/p-18038011.js +0 -1
- package/dist/geotrek-rando-widget/p-2712caa8.system.entry.js +0 -6
- package/dist/geotrek-rando-widget/p-32d97a4f.system.js +0 -1
- package/dist/geotrek-rando-widget/p-3ed52659.entry.js +0 -1
- package/dist/geotrek-rando-widget/p-4690907e.js +0 -2
- package/dist/geotrek-rando-widget/p-48d5dde7.entry.js +0 -1
- package/dist/geotrek-rando-widget/p-8f9914f4.system.js +0 -2
- package/dist/geotrek-rando-widget/p-e1431f36.system.entry.js +0 -1
- package/dist/geotrek-rando-widget/p-e38f4ff4.system.entry.js +0 -1
- package/dist/geotrek-rando-widget/p-f5d98aae.entry.js +0 -1
|
@@ -22,70 +22,19 @@ function _interopNamespace(e) {
|
|
|
22
22
|
|
|
23
23
|
const NAMESPACE = 'geotrek-rando-widget';
|
|
24
24
|
|
|
25
|
+
/**
|
|
26
|
+
* Virtual DOM patching algorithm based on Snabbdom by
|
|
27
|
+
* Simon Friis Vindum (@paldepind)
|
|
28
|
+
* Licensed under the MIT License
|
|
29
|
+
* https://github.com/snabbdom/snabbdom/blob/master/LICENSE
|
|
30
|
+
*
|
|
31
|
+
* Modified for Stencil's renderer and slot projection
|
|
32
|
+
*/
|
|
25
33
|
let scopeId;
|
|
26
34
|
let hostTagName;
|
|
27
35
|
let isSvgMode = false;
|
|
28
36
|
let renderingRef = null;
|
|
29
37
|
let queuePending = false;
|
|
30
|
-
const win = typeof window !== 'undefined' ? window : {};
|
|
31
|
-
const CSS = win.CSS ;
|
|
32
|
-
const doc = win.document || { head: {} };
|
|
33
|
-
const plt = {
|
|
34
|
-
$flags$: 0,
|
|
35
|
-
$resourcesUrl$: '',
|
|
36
|
-
jmp: (h) => h(),
|
|
37
|
-
raf: (h) => requestAnimationFrame(h),
|
|
38
|
-
ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
|
|
39
|
-
rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
|
|
40
|
-
ce: (eventName, opts) => new CustomEvent(eventName, opts),
|
|
41
|
-
};
|
|
42
|
-
const supportsShadow = /*@__PURE__*/ (() => (doc.head.attachShadow + '').indexOf('[native') > -1)()
|
|
43
|
-
;
|
|
44
|
-
const promiseResolve = (v) => Promise.resolve(v);
|
|
45
|
-
const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
|
|
46
|
-
try {
|
|
47
|
-
new CSSStyleSheet();
|
|
48
|
-
return typeof new CSSStyleSheet().replaceSync === 'function';
|
|
49
|
-
}
|
|
50
|
-
catch (e) { }
|
|
51
|
-
return false;
|
|
52
|
-
})()
|
|
53
|
-
;
|
|
54
|
-
const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
|
|
55
|
-
if (listeners) {
|
|
56
|
-
listeners.map(([flags, name, method]) => {
|
|
57
|
-
const target = getHostListenerTarget(elm, flags) ;
|
|
58
|
-
const handler = hostListenerProxy(hostRef, method);
|
|
59
|
-
const opts = hostListenerOpts(flags);
|
|
60
|
-
plt.ael(target, name, handler, opts);
|
|
61
|
-
(hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
const hostListenerProxy = (hostRef, methodName) => (ev) => {
|
|
66
|
-
try {
|
|
67
|
-
{
|
|
68
|
-
if (hostRef.$flags$ & 256 /* isListenReady */) {
|
|
69
|
-
// instance is ready, let's call it's member method for this event
|
|
70
|
-
hostRef.$lazyInstance$[methodName](ev);
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
(hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
catch (e) {
|
|
78
|
-
consoleError(e);
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
const getHostListenerTarget = (elm, flags) => {
|
|
82
|
-
if (flags & 8 /* TargetWindow */)
|
|
83
|
-
return win;
|
|
84
|
-
return elm;
|
|
85
|
-
};
|
|
86
|
-
// prettier-ignore
|
|
87
|
-
const hostListenerOpts = (flags) => (flags & 2 /* Capture */) !== 0;
|
|
88
|
-
const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
|
|
89
38
|
const createTime = (fnName, tagName = '') => {
|
|
90
39
|
{
|
|
91
40
|
return () => {
|
|
@@ -100,87 +49,7 @@ const uniqueTime = (key, measureText) => {
|
|
|
100
49
|
};
|
|
101
50
|
}
|
|
102
51
|
};
|
|
103
|
-
const
|
|
104
|
-
const registerStyle = (scopeId, cssText, allowCS) => {
|
|
105
|
-
let style = styles.get(scopeId);
|
|
106
|
-
if (supportsConstructableStylesheets && allowCS) {
|
|
107
|
-
style = (style || new CSSStyleSheet());
|
|
108
|
-
if (typeof style === 'string') {
|
|
109
|
-
style = cssText;
|
|
110
|
-
}
|
|
111
|
-
else {
|
|
112
|
-
style.replaceSync(cssText);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
style = cssText;
|
|
117
|
-
}
|
|
118
|
-
styles.set(scopeId, style);
|
|
119
|
-
};
|
|
120
|
-
const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
|
|
121
|
-
let scopeId = getScopeId(cmpMeta);
|
|
122
|
-
const style = styles.get(scopeId);
|
|
123
|
-
// if an element is NOT connected then getRootNode() will return the wrong root node
|
|
124
|
-
// so the fallback is to always use the document for the root node in those cases
|
|
125
|
-
styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
|
|
126
|
-
if (style) {
|
|
127
|
-
if (typeof style === 'string') {
|
|
128
|
-
styleContainerNode = styleContainerNode.head || styleContainerNode;
|
|
129
|
-
let appliedStyles = rootAppliedStyles.get(styleContainerNode);
|
|
130
|
-
let styleElm;
|
|
131
|
-
if (!appliedStyles) {
|
|
132
|
-
rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
|
|
133
|
-
}
|
|
134
|
-
if (!appliedStyles.has(scopeId)) {
|
|
135
|
-
{
|
|
136
|
-
if (plt.$cssShim$) {
|
|
137
|
-
styleElm = plt.$cssShim$.createHostStyle(hostElm, scopeId, style, !!(cmpMeta.$flags$ & 10 /* needsScopedEncapsulation */));
|
|
138
|
-
const newScopeId = styleElm['s-sc'];
|
|
139
|
-
if (newScopeId) {
|
|
140
|
-
scopeId = newScopeId;
|
|
141
|
-
// we don't want to add this styleID to the appliedStyles Set
|
|
142
|
-
// since the cssVarShim might need to apply several different
|
|
143
|
-
// stylesheets for the same component
|
|
144
|
-
appliedStyles = null;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
else {
|
|
148
|
-
styleElm = doc.createElement('style');
|
|
149
|
-
styleElm.innerHTML = style;
|
|
150
|
-
}
|
|
151
|
-
styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
|
|
152
|
-
}
|
|
153
|
-
if (appliedStyles) {
|
|
154
|
-
appliedStyles.add(scopeId);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
|
|
159
|
-
styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
return scopeId;
|
|
163
|
-
};
|
|
164
|
-
const attachStyles = (hostRef) => {
|
|
165
|
-
const cmpMeta = hostRef.$cmpMeta$;
|
|
166
|
-
const elm = hostRef.$hostElement$;
|
|
167
|
-
const flags = cmpMeta.$flags$;
|
|
168
|
-
const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
|
|
169
|
-
const scopeId = addStyle(supportsShadow && elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta, hostRef.$modeName$, elm);
|
|
170
|
-
if (flags & 10 /* needsScopedEncapsulation */) {
|
|
171
|
-
// only required when we're NOT using native shadow dom (slot)
|
|
172
|
-
// or this browser doesn't support native shadow dom
|
|
173
|
-
// and this host element was NOT created with SSR
|
|
174
|
-
// let's pick out the inner content for slot projection
|
|
175
|
-
// create a node to represent where the original
|
|
176
|
-
// content was first placed, which is useful later on
|
|
177
|
-
// DOM WRITE!!
|
|
178
|
-
elm['s-sc'] = scopeId;
|
|
179
|
-
elm.classList.add(scopeId + '-h');
|
|
180
|
-
}
|
|
181
|
-
endAttachStyles();
|
|
182
|
-
};
|
|
183
|
-
const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
|
|
52
|
+
const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
|
|
184
53
|
/**
|
|
185
54
|
* Default style mode id
|
|
186
55
|
*/
|
|
@@ -280,6 +149,160 @@ const newVNode = (tag, text) => {
|
|
|
280
149
|
};
|
|
281
150
|
const Host = {};
|
|
282
151
|
const isHost = (node) => node && node.$tag$ === Host;
|
|
152
|
+
/**
|
|
153
|
+
* Parse a new property value for a given property type.
|
|
154
|
+
*
|
|
155
|
+
* While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
|
|
156
|
+
* it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
|
|
157
|
+
* 1. `any`, the type given to `propValue` in the function signature
|
|
158
|
+
* 2. the type stored from `propType`.
|
|
159
|
+
*
|
|
160
|
+
* This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
|
|
161
|
+
*
|
|
162
|
+
* Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
|
|
163
|
+
* a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
|
|
164
|
+
* based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
|
|
165
|
+
* ```tsx
|
|
166
|
+
* <my-cmp prop-val={0}></my-cmp>
|
|
167
|
+
* ```
|
|
168
|
+
*
|
|
169
|
+
* HTML prop values on the other hand, will always a string
|
|
170
|
+
*
|
|
171
|
+
* @param propValue the new value to coerce to some type
|
|
172
|
+
* @param propType the type of the prop, expressed as a binary number
|
|
173
|
+
* @returns the parsed/coerced value
|
|
174
|
+
*/
|
|
175
|
+
const parsePropertyValue = (propValue, propType) => {
|
|
176
|
+
// ensure this value is of the correct prop type
|
|
177
|
+
if (propValue != null && !isComplexType(propValue)) {
|
|
178
|
+
if (propType & 4 /* MEMBER_FLAGS.Boolean */) {
|
|
179
|
+
// per the HTML spec, any string value means it is a boolean true value
|
|
180
|
+
// but we'll cheat here and say that the string "false" is the boolean false
|
|
181
|
+
return propValue === 'false' ? false : propValue === '' || !!propValue;
|
|
182
|
+
}
|
|
183
|
+
if (propType & 2 /* MEMBER_FLAGS.Number */) {
|
|
184
|
+
// force it to be a number
|
|
185
|
+
return parseFloat(propValue);
|
|
186
|
+
}
|
|
187
|
+
if (propType & 1 /* MEMBER_FLAGS.String */) {
|
|
188
|
+
// could have been passed as a number or boolean
|
|
189
|
+
// but we still want it as a string
|
|
190
|
+
return String(propValue);
|
|
191
|
+
}
|
|
192
|
+
// redundant return here for better minification
|
|
193
|
+
return propValue;
|
|
194
|
+
}
|
|
195
|
+
// not sure exactly what type we want
|
|
196
|
+
// so no need to change to a different type
|
|
197
|
+
return propValue;
|
|
198
|
+
};
|
|
199
|
+
const getElement = (ref) => (getHostRef(ref).$hostElement$ );
|
|
200
|
+
const createEvent = (ref, name, flags) => {
|
|
201
|
+
const elm = getElement(ref);
|
|
202
|
+
return {
|
|
203
|
+
emit: (detail) => {
|
|
204
|
+
return emitEvent(elm, name, {
|
|
205
|
+
bubbles: !!(flags & 4 /* EVENT_FLAGS.Bubbles */),
|
|
206
|
+
composed: !!(flags & 2 /* EVENT_FLAGS.Composed */),
|
|
207
|
+
cancelable: !!(flags & 1 /* EVENT_FLAGS.Cancellable */),
|
|
208
|
+
detail,
|
|
209
|
+
});
|
|
210
|
+
},
|
|
211
|
+
};
|
|
212
|
+
};
|
|
213
|
+
/**
|
|
214
|
+
* Helper function to create & dispatch a custom Event on a provided target
|
|
215
|
+
* @param elm the target of the Event
|
|
216
|
+
* @param name the name to give the custom Event
|
|
217
|
+
* @param opts options for configuring a custom Event
|
|
218
|
+
* @returns the custom Event
|
|
219
|
+
*/
|
|
220
|
+
const emitEvent = (elm, name, opts) => {
|
|
221
|
+
const ev = plt.ce(name, opts);
|
|
222
|
+
elm.dispatchEvent(ev);
|
|
223
|
+
return ev;
|
|
224
|
+
};
|
|
225
|
+
const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
|
|
226
|
+
const registerStyle = (scopeId, cssText, allowCS) => {
|
|
227
|
+
let style = styles.get(scopeId);
|
|
228
|
+
if (supportsConstructableStylesheets && allowCS) {
|
|
229
|
+
style = (style || new CSSStyleSheet());
|
|
230
|
+
if (typeof style === 'string') {
|
|
231
|
+
style = cssText;
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
style.replaceSync(cssText);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
style = cssText;
|
|
239
|
+
}
|
|
240
|
+
styles.set(scopeId, style);
|
|
241
|
+
};
|
|
242
|
+
const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
|
|
243
|
+
let scopeId = getScopeId(cmpMeta);
|
|
244
|
+
const style = styles.get(scopeId);
|
|
245
|
+
// if an element is NOT connected then getRootNode() will return the wrong root node
|
|
246
|
+
// so the fallback is to always use the document for the root node in those cases
|
|
247
|
+
styleContainerNode = styleContainerNode.nodeType === 11 /* NODE_TYPE.DocumentFragment */ ? styleContainerNode : doc;
|
|
248
|
+
if (style) {
|
|
249
|
+
if (typeof style === 'string') {
|
|
250
|
+
styleContainerNode = styleContainerNode.head || styleContainerNode;
|
|
251
|
+
let appliedStyles = rootAppliedStyles.get(styleContainerNode);
|
|
252
|
+
let styleElm;
|
|
253
|
+
if (!appliedStyles) {
|
|
254
|
+
rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
|
|
255
|
+
}
|
|
256
|
+
if (!appliedStyles.has(scopeId)) {
|
|
257
|
+
{
|
|
258
|
+
if (plt.$cssShim$) {
|
|
259
|
+
styleElm = plt.$cssShim$.createHostStyle(hostElm, scopeId, style, !!(cmpMeta.$flags$ & 10 /* CMP_FLAGS.needsScopedEncapsulation */));
|
|
260
|
+
const newScopeId = styleElm['s-sc'];
|
|
261
|
+
if (newScopeId) {
|
|
262
|
+
scopeId = newScopeId;
|
|
263
|
+
// we don't want to add this styleID to the appliedStyles Set
|
|
264
|
+
// since the cssVarShim might need to apply several different
|
|
265
|
+
// stylesheets for the same component
|
|
266
|
+
appliedStyles = null;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
else {
|
|
270
|
+
styleElm = doc.createElement('style');
|
|
271
|
+
styleElm.innerHTML = style;
|
|
272
|
+
}
|
|
273
|
+
styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
|
|
274
|
+
}
|
|
275
|
+
if (appliedStyles) {
|
|
276
|
+
appliedStyles.add(scopeId);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
|
|
281
|
+
styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
return scopeId;
|
|
285
|
+
};
|
|
286
|
+
const attachStyles = (hostRef) => {
|
|
287
|
+
const cmpMeta = hostRef.$cmpMeta$;
|
|
288
|
+
const elm = hostRef.$hostElement$;
|
|
289
|
+
const flags = cmpMeta.$flags$;
|
|
290
|
+
const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
|
|
291
|
+
const scopeId = addStyle(supportsShadow && elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta, hostRef.$modeName$, elm);
|
|
292
|
+
if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
|
|
293
|
+
// only required when we're NOT using native shadow dom (slot)
|
|
294
|
+
// or this browser doesn't support native shadow dom
|
|
295
|
+
// and this host element was NOT created with SSR
|
|
296
|
+
// let's pick out the inner content for slot projection
|
|
297
|
+
// create a node to represent where the original
|
|
298
|
+
// content was first placed, which is useful later on
|
|
299
|
+
// DOM WRITE!!
|
|
300
|
+
elm['s-sc'] = scopeId;
|
|
301
|
+
elm.classList.add(scopeId + '-h');
|
|
302
|
+
}
|
|
303
|
+
endAttachStyles();
|
|
304
|
+
};
|
|
305
|
+
const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
|
|
283
306
|
/**
|
|
284
307
|
* Production setAccessor() function based on Preact by
|
|
285
308
|
* Jason Miller (@developit)
|
|
@@ -393,7 +416,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
|
|
393
416
|
}
|
|
394
417
|
}
|
|
395
418
|
}
|
|
396
|
-
else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
|
|
419
|
+
else if ((!isProp || flags & 4 /* VNODE_FLAGS.isHost */ || isSvg) && !isComplex) {
|
|
397
420
|
newValue = newValue === true ? '' : newValue;
|
|
398
421
|
{
|
|
399
422
|
elm.setAttribute(memberName, newValue);
|
|
@@ -408,7 +431,7 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
|
|
|
408
431
|
// if the element passed in is a shadow root, which is a document fragment
|
|
409
432
|
// then we want to be adding attrs/props to the shadow root's "host" element
|
|
410
433
|
// if it's not a shadow root, then we add attrs/props to the same element
|
|
411
|
-
const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host
|
|
434
|
+
const elm = newVnode.$elm$.nodeType === 11 /* NODE_TYPE.DocumentFragment */ && newVnode.$elm$.host
|
|
412
435
|
? newVnode.$elm$.host
|
|
413
436
|
: newVnode.$elm$;
|
|
414
437
|
const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
|
|
@@ -426,6 +449,16 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
|
|
|
426
449
|
setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
|
|
427
450
|
}
|
|
428
451
|
};
|
|
452
|
+
/**
|
|
453
|
+
* Create a DOM Node corresponding to one of the children of a given VNode.
|
|
454
|
+
*
|
|
455
|
+
* @param oldParentVNode the parent VNode from the previous render
|
|
456
|
+
* @param newParentVNode the parent VNode from the current render
|
|
457
|
+
* @param childIndex the index of the VNode, in the _new_ parent node's
|
|
458
|
+
* children, for which we will create a new DOM node
|
|
459
|
+
* @param parentElm the parent DOM node which our new node will be a child of
|
|
460
|
+
* @returns the newly created node
|
|
461
|
+
*/
|
|
429
462
|
const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
430
463
|
// tslint:disable-next-line: prefer-const
|
|
431
464
|
const newVNode = newParentVNode.$children$[childIndex];
|
|
@@ -487,6 +520,74 @@ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
|
|
|
487
520
|
}
|
|
488
521
|
}
|
|
489
522
|
};
|
|
523
|
+
/**
|
|
524
|
+
* Reconcile the children of a new VNode with the children of an old VNode by
|
|
525
|
+
* traversing the two collections of children, identifying nodes that are
|
|
526
|
+
* conserved or changed, calling out to `patch` to make any necessary
|
|
527
|
+
* updates to the DOM, and rearranging DOM nodes as needed.
|
|
528
|
+
*
|
|
529
|
+
* The algorithm for reconciling children works by analyzing two 'windows' onto
|
|
530
|
+
* the two arrays of children (`oldCh` and `newCh`). We keep track of the
|
|
531
|
+
* 'windows' by storing start and end indices and references to the
|
|
532
|
+
* corresponding array entries. Initially the two 'windows' are basically equal
|
|
533
|
+
* to the entire array, but we progressively narrow the windows until there are
|
|
534
|
+
* no children left to update by doing the following:
|
|
535
|
+
*
|
|
536
|
+
* 1. Skip any `null` entries at the beginning or end of the two arrays, so
|
|
537
|
+
* that if we have an initial array like the following we'll end up dealing
|
|
538
|
+
* only with a window bounded by the highlighted elements:
|
|
539
|
+
*
|
|
540
|
+
* [null, null, VNode1 , ... , VNode2, null, null]
|
|
541
|
+
* ^^^^^^ ^^^^^^
|
|
542
|
+
*
|
|
543
|
+
* 2. Check to see if the elements at the head and tail positions are equal
|
|
544
|
+
* across the windows. This will basically detect elements which haven't
|
|
545
|
+
* been added, removed, or changed position, i.e. if you had the following
|
|
546
|
+
* VNode elements (represented as HTML):
|
|
547
|
+
*
|
|
548
|
+
* oldVNode: `<div><p><span>HEY</span></p></div>`
|
|
549
|
+
* newVNode: `<div><p><span>THERE</span></p></div>`
|
|
550
|
+
*
|
|
551
|
+
* Then when comparing the children of the `<div>` tag we check the equality
|
|
552
|
+
* of the VNodes corresponding to the `<p>` tags and, since they are the
|
|
553
|
+
* same tag in the same position, we'd be able to avoid completely
|
|
554
|
+
* re-rendering the subtree under them with a new DOM element and would just
|
|
555
|
+
* call out to `patch` to handle reconciling their children and so on.
|
|
556
|
+
*
|
|
557
|
+
* 3. Check, for both windows, to see if the element at the beginning of the
|
|
558
|
+
* window corresponds to the element at the end of the other window. This is
|
|
559
|
+
* a heuristic which will let us identify _some_ situations in which
|
|
560
|
+
* elements have changed position, for instance it _should_ detect that the
|
|
561
|
+
* children nodes themselves have not changed but merely moved in the
|
|
562
|
+
* following example:
|
|
563
|
+
*
|
|
564
|
+
* oldVNode: `<div><element-one /><element-two /></div>`
|
|
565
|
+
* newVNode: `<div><element-two /><element-one /></div>`
|
|
566
|
+
*
|
|
567
|
+
* If we find cases like this then we also need to move the concrete DOM
|
|
568
|
+
* elements corresponding to the moved children to write the re-order to the
|
|
569
|
+
* DOM.
|
|
570
|
+
*
|
|
571
|
+
* 4. Finally, if VNodes have the `key` attribute set on them we check for any
|
|
572
|
+
* nodes in the old children which have the same key as the first element in
|
|
573
|
+
* our window on the new children. If we find such a node we handle calling
|
|
574
|
+
* out to `patch`, moving relevant DOM nodes, and so on, in accordance with
|
|
575
|
+
* what we find.
|
|
576
|
+
*
|
|
577
|
+
* Finally, once we've narrowed our 'windows' to the point that either of them
|
|
578
|
+
* collapse (i.e. they have length 0) we then handle any remaining VNode
|
|
579
|
+
* insertion or deletion that needs to happen to get a DOM state that correctly
|
|
580
|
+
* reflects the new child VNodes. If, for instance, after our window on the old
|
|
581
|
+
* children has collapsed we still have more nodes on the new children that
|
|
582
|
+
* we haven't dealt with yet then we need to add them, or if the new children
|
|
583
|
+
* collapse but we still have unhandled _old_ children then we need to make
|
|
584
|
+
* sure the corresponding DOM nodes are removed.
|
|
585
|
+
*
|
|
586
|
+
* @param parentElm the node into which the parent VNode is rendered
|
|
587
|
+
* @param oldCh the old children of the parent node
|
|
588
|
+
* @param newVNode the new VNode which will replace the parent
|
|
589
|
+
* @param newCh the new children of the parent node
|
|
590
|
+
*/
|
|
490
591
|
const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
491
592
|
let oldStartIdx = 0;
|
|
492
593
|
let newStartIdx = 0;
|
|
@@ -502,7 +603,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
502
603
|
let elmToMove;
|
|
503
604
|
while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
|
|
504
605
|
if (oldStartVnode == null) {
|
|
505
|
-
//
|
|
606
|
+
// VNode might have been moved left
|
|
506
607
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
507
608
|
}
|
|
508
609
|
else if (oldEndVnode == null) {
|
|
@@ -515,29 +616,65 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
515
616
|
newEndVnode = newCh[--newEndIdx];
|
|
516
617
|
}
|
|
517
618
|
else if (isSameVnode(oldStartVnode, newStartVnode)) {
|
|
619
|
+
// if the start nodes are the same then we should patch the new VNode
|
|
620
|
+
// onto the old one, and increment our `newStartIdx` and `oldStartIdx`
|
|
621
|
+
// indices to reflect that. We don't need to move any DOM Nodes around
|
|
622
|
+
// since things are matched up in order.
|
|
518
623
|
patch(oldStartVnode, newStartVnode);
|
|
519
624
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
520
625
|
newStartVnode = newCh[++newStartIdx];
|
|
521
626
|
}
|
|
522
627
|
else if (isSameVnode(oldEndVnode, newEndVnode)) {
|
|
628
|
+
// likewise, if the end nodes are the same we patch new onto old and
|
|
629
|
+
// decrement our end indices, and also likewise in this case we don't
|
|
630
|
+
// need to move any DOM Nodes.
|
|
523
631
|
patch(oldEndVnode, newEndVnode);
|
|
524
632
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
525
633
|
newEndVnode = newCh[--newEndIdx];
|
|
526
634
|
}
|
|
527
635
|
else if (isSameVnode(oldStartVnode, newEndVnode)) {
|
|
528
636
|
patch(oldStartVnode, newEndVnode);
|
|
637
|
+
// We need to move the element for `oldStartVnode` into a position which
|
|
638
|
+
// will be appropriate for `newEndVnode`. For this we can use
|
|
639
|
+
// `.insertBefore` and `oldEndVnode.$elm$.nextSibling`. If there is a
|
|
640
|
+
// sibling for `oldEndVnode.$elm$` then we want to move the DOM node for
|
|
641
|
+
// `oldStartVnode` between `oldEndVnode` and it's sibling, like so:
|
|
642
|
+
//
|
|
643
|
+
// <old-start-node />
|
|
644
|
+
// <some-intervening-node />
|
|
645
|
+
// <old-end-node />
|
|
646
|
+
// <!-- -> <-- `oldStartVnode.$elm$` should be inserted here
|
|
647
|
+
// <next-sibling />
|
|
648
|
+
//
|
|
649
|
+
// If instead `oldEndVnode.$elm$` has no sibling then we just want to put
|
|
650
|
+
// the node for `oldStartVnode` at the end of the children of
|
|
651
|
+
// `parentElm`. Luckily, `Node.nextSibling` will return `null` if there
|
|
652
|
+
// aren't any siblings, and passing `null` to `Node.insertBefore` will
|
|
653
|
+
// append it to the children of the parent element.
|
|
529
654
|
parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
|
|
530
655
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
531
656
|
newEndVnode = newCh[--newEndIdx];
|
|
532
657
|
}
|
|
533
658
|
else if (isSameVnode(oldEndVnode, newStartVnode)) {
|
|
534
659
|
patch(oldEndVnode, newStartVnode);
|
|
660
|
+
// We've already checked above if `oldStartVnode` and `newStartVnode` are
|
|
661
|
+
// the same node, so since we're here we know that they are not. Thus we
|
|
662
|
+
// can move the element for `oldEndVnode` _before_ the element for
|
|
663
|
+
// `oldStartVnode`, leaving `oldStartVnode` to be reconciled in the
|
|
664
|
+
// future.
|
|
535
665
|
parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
|
|
536
666
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
537
667
|
newStartVnode = newCh[++newStartIdx];
|
|
538
668
|
}
|
|
539
669
|
else {
|
|
540
|
-
//
|
|
670
|
+
// Here we do some checks to match up old and new nodes based on the
|
|
671
|
+
// `$key$` attribute, which is set by putting a `key="my-key"` attribute
|
|
672
|
+
// in the JSX for a DOM element in the implementation of a Stencil
|
|
673
|
+
// component.
|
|
674
|
+
//
|
|
675
|
+
// First we check to see if there are any nodes in the array of old
|
|
676
|
+
// children which have the same key as the first node in the new
|
|
677
|
+
// children.
|
|
541
678
|
idxInOld = -1;
|
|
542
679
|
{
|
|
543
680
|
for (i = oldStartIdx; i <= oldEndIdx; ++i) {
|
|
@@ -548,23 +685,32 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
548
685
|
}
|
|
549
686
|
}
|
|
550
687
|
if (idxInOld >= 0) {
|
|
688
|
+
// We found a node in the old children which matches up with the first
|
|
689
|
+
// node in the new children! So let's deal with that
|
|
551
690
|
elmToMove = oldCh[idxInOld];
|
|
552
691
|
if (elmToMove.$tag$ !== newStartVnode.$tag$) {
|
|
692
|
+
// the tag doesn't match so we'll need a new DOM element
|
|
553
693
|
node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld);
|
|
554
694
|
}
|
|
555
695
|
else {
|
|
556
696
|
patch(elmToMove, newStartVnode);
|
|
697
|
+
// invalidate the matching old node so that we won't try to update it
|
|
698
|
+
// again later on
|
|
557
699
|
oldCh[idxInOld] = undefined;
|
|
558
700
|
node = elmToMove.$elm$;
|
|
559
701
|
}
|
|
560
702
|
newStartVnode = newCh[++newStartIdx];
|
|
561
703
|
}
|
|
562
704
|
else {
|
|
563
|
-
//
|
|
705
|
+
// We either didn't find an element in the old children that matches
|
|
706
|
+
// the key of the first new child OR the build is not using `key`
|
|
707
|
+
// attributes at all. In either case we need to create a new element
|
|
708
|
+
// for the new node.
|
|
564
709
|
node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
|
|
565
710
|
newStartVnode = newCh[++newStartIdx];
|
|
566
711
|
}
|
|
567
712
|
if (node) {
|
|
713
|
+
// if we created a new node then handle inserting it to the DOM
|
|
568
714
|
{
|
|
569
715
|
oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
|
|
570
716
|
}
|
|
@@ -572,29 +718,58 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
572
718
|
}
|
|
573
719
|
}
|
|
574
720
|
if (oldStartIdx > oldEndIdx) {
|
|
721
|
+
// we have some more new nodes to add which don't match up with old nodes
|
|
575
722
|
addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
|
|
576
723
|
}
|
|
577
724
|
else if (newStartIdx > newEndIdx) {
|
|
725
|
+
// there are nodes in the `oldCh` array which no longer correspond to nodes
|
|
726
|
+
// in the new array, so lets remove them (which entails cleaning up the
|
|
727
|
+
// relevant DOM nodes)
|
|
578
728
|
removeVnodes(oldCh, oldStartIdx, oldEndIdx);
|
|
579
729
|
}
|
|
580
730
|
};
|
|
581
|
-
|
|
731
|
+
/**
|
|
732
|
+
* Compare two VNodes to determine if they are the same
|
|
733
|
+
*
|
|
734
|
+
* **NB**: This function is an equality _heuristic_ based on the available
|
|
735
|
+
* information set on the two VNodes and can be misleading under certain
|
|
736
|
+
* circumstances. In particular, if the two nodes do not have `key` attrs
|
|
737
|
+
* (available under `$key$` on VNodes) then the function falls back on merely
|
|
738
|
+
* checking that they have the same tag.
|
|
739
|
+
*
|
|
740
|
+
* So, in other words, if `key` attrs are not set on VNodes which may be
|
|
741
|
+
* changing order within a `children` array or something along those lines then
|
|
742
|
+
* we could obtain a false positive and then have to do needless re-rendering.
|
|
743
|
+
*
|
|
744
|
+
* @param leftVNode the first VNode to check
|
|
745
|
+
* @param rightVNode the second VNode to check
|
|
746
|
+
* @returns whether they're equal or not
|
|
747
|
+
*/
|
|
748
|
+
const isSameVnode = (leftVNode, rightVNode) => {
|
|
582
749
|
// compare if two vnode to see if they're "technically" the same
|
|
583
750
|
// need to have the same element tag, and same key to be the same
|
|
584
|
-
if (
|
|
751
|
+
if (leftVNode.$tag$ === rightVNode.$tag$) {
|
|
752
|
+
// this will be set if components in the build have `key` attrs set on them
|
|
585
753
|
{
|
|
586
|
-
return
|
|
754
|
+
return leftVNode.$key$ === rightVNode.$key$;
|
|
587
755
|
}
|
|
588
756
|
}
|
|
589
757
|
return false;
|
|
590
758
|
};
|
|
759
|
+
/**
|
|
760
|
+
* Handle reconciling an outdated VNode with a new one which corresponds to
|
|
761
|
+
* it. This function handles flushing updates to the DOM and reconciling the
|
|
762
|
+
* children of the two nodes (if any).
|
|
763
|
+
*
|
|
764
|
+
* @param oldVNode an old VNode whose DOM element and children we want to update
|
|
765
|
+
* @param newVNode a new VNode representing an updated version of the old one
|
|
766
|
+
*/
|
|
591
767
|
const patch = (oldVNode, newVNode) => {
|
|
592
768
|
const elm = (newVNode.$elm$ = oldVNode.$elm$);
|
|
593
769
|
const oldChildren = oldVNode.$children$;
|
|
594
770
|
const newChildren = newVNode.$children$;
|
|
595
771
|
const text = newVNode.$text$;
|
|
596
772
|
if (text === null) {
|
|
597
|
-
// element node
|
|
598
773
|
{
|
|
599
774
|
{
|
|
600
775
|
// either this is the first render of an element OR it's an update
|
|
@@ -605,6 +780,7 @@ const patch = (oldVNode, newVNode) => {
|
|
|
605
780
|
}
|
|
606
781
|
if (oldChildren !== null && newChildren !== null) {
|
|
607
782
|
// looks like there's child vnodes for both the old and new vnodes
|
|
783
|
+
// so we need to call `updateChildren` to reconcile them
|
|
608
784
|
updateChildren(elm, oldChildren, newVNode, newChildren);
|
|
609
785
|
}
|
|
610
786
|
else if (newChildren !== null) {
|
|
@@ -633,7 +809,7 @@ const renderVdom = (hostRef, renderFnResults) => {
|
|
|
633
809
|
const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
|
|
634
810
|
hostTagName = hostElm.tagName;
|
|
635
811
|
rootVnode.$tag$ = null;
|
|
636
|
-
rootVnode.$flags$ |= 4 /* isHost */;
|
|
812
|
+
rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
|
|
637
813
|
hostRef.$vnode$ = rootVnode;
|
|
638
814
|
rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
|
|
639
815
|
{
|
|
@@ -642,32 +818,6 @@ const renderVdom = (hostRef, renderFnResults) => {
|
|
|
642
818
|
// synchronous patch
|
|
643
819
|
patch(oldVNode, rootVnode);
|
|
644
820
|
};
|
|
645
|
-
const getElement = (ref) => (getHostRef(ref).$hostElement$ );
|
|
646
|
-
const createEvent = (ref, name, flags) => {
|
|
647
|
-
const elm = getElement(ref);
|
|
648
|
-
return {
|
|
649
|
-
emit: (detail) => {
|
|
650
|
-
return emitEvent(elm, name, {
|
|
651
|
-
bubbles: !!(flags & 4 /* Bubbles */),
|
|
652
|
-
composed: !!(flags & 2 /* Composed */),
|
|
653
|
-
cancelable: !!(flags & 1 /* Cancellable */),
|
|
654
|
-
detail,
|
|
655
|
-
});
|
|
656
|
-
},
|
|
657
|
-
};
|
|
658
|
-
};
|
|
659
|
-
/**
|
|
660
|
-
* Helper function to create & dispatch a custom Event on a provided target
|
|
661
|
-
* @param elm the target of the Event
|
|
662
|
-
* @param name the name to give the custom Event
|
|
663
|
-
* @param opts options for configuring a custom Event
|
|
664
|
-
* @returns the custom Event
|
|
665
|
-
*/
|
|
666
|
-
const emitEvent = (elm, name, opts) => {
|
|
667
|
-
const ev = plt.ce(name, opts);
|
|
668
|
-
elm.dispatchEvent(ev);
|
|
669
|
-
return ev;
|
|
670
|
-
};
|
|
671
821
|
const attachToAncestor = (hostRef, ancestorComponent) => {
|
|
672
822
|
if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
|
|
673
823
|
ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
|
|
@@ -675,10 +825,10 @@ const attachToAncestor = (hostRef, ancestorComponent) => {
|
|
|
675
825
|
};
|
|
676
826
|
const scheduleUpdate = (hostRef, isInitialLoad) => {
|
|
677
827
|
{
|
|
678
|
-
hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
|
|
828
|
+
hostRef.$flags$ |= 16 /* HOST_FLAGS.isQueuedForUpdate */;
|
|
679
829
|
}
|
|
680
|
-
if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
|
|
681
|
-
hostRef.$flags$ |= 512 /* needsRerender */;
|
|
830
|
+
if (hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
|
|
831
|
+
hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
|
|
682
832
|
return;
|
|
683
833
|
}
|
|
684
834
|
attachToAncestor(hostRef, hostRef.$ancestorComponent$);
|
|
@@ -694,7 +844,7 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
|
|
|
694
844
|
let promise;
|
|
695
845
|
if (isInitialLoad) {
|
|
696
846
|
{
|
|
697
|
-
hostRef.$flags$ |= 256 /* isListenReady */;
|
|
847
|
+
hostRef.$flags$ |= 256 /* HOST_FLAGS.isListenReady */;
|
|
698
848
|
if (hostRef.$queuedListeners$) {
|
|
699
849
|
hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
|
|
700
850
|
hostRef.$queuedListeners$ = null;
|
|
@@ -740,7 +890,7 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
|
|
|
740
890
|
}
|
|
741
891
|
else {
|
|
742
892
|
Promise.all(childrenPromises).then(postUpdate);
|
|
743
|
-
hostRef.$flags$ |= 4 /* isWaitingForChildren */;
|
|
893
|
+
hostRef.$flags$ |= 4 /* HOST_FLAGS.isWaitingForChildren */;
|
|
744
894
|
childrenPromises.length = 0;
|
|
745
895
|
}
|
|
746
896
|
}
|
|
@@ -750,10 +900,10 @@ const callRender = (hostRef, instance, elm) => {
|
|
|
750
900
|
renderingRef = instance;
|
|
751
901
|
instance = instance.render() ;
|
|
752
902
|
{
|
|
753
|
-
hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
|
|
903
|
+
hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
|
|
754
904
|
}
|
|
755
905
|
{
|
|
756
|
-
hostRef.$flags$ |= 2 /* hasRendered */;
|
|
906
|
+
hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
|
|
757
907
|
}
|
|
758
908
|
{
|
|
759
909
|
{
|
|
@@ -779,8 +929,8 @@ const postUpdateComponent = (hostRef) => {
|
|
|
779
929
|
const endPostUpdate = createTime('postUpdate', tagName);
|
|
780
930
|
const instance = hostRef.$lazyInstance$ ;
|
|
781
931
|
const ancestorComponent = hostRef.$ancestorComponent$;
|
|
782
|
-
if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
|
|
783
|
-
hostRef.$flags$ |= 64 /* hasLoadedComponent */;
|
|
932
|
+
if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
|
|
933
|
+
hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
|
|
784
934
|
{
|
|
785
935
|
// DOM WRITE!
|
|
786
936
|
addHydratedFlag(elm);
|
|
@@ -806,10 +956,10 @@ const postUpdateComponent = (hostRef) => {
|
|
|
806
956
|
hostRef.$onRenderResolve$();
|
|
807
957
|
hostRef.$onRenderResolve$ = undefined;
|
|
808
958
|
}
|
|
809
|
-
if (hostRef.$flags$ & 512 /* needsRerender */) {
|
|
959
|
+
if (hostRef.$flags$ & 512 /* HOST_FLAGS.needsRerender */) {
|
|
810
960
|
nextTick(() => scheduleUpdate(hostRef, false));
|
|
811
961
|
}
|
|
812
|
-
hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
|
|
962
|
+
hostRef.$flags$ &= ~(4 /* HOST_FLAGS.isWaitingForChildren */ | 512 /* HOST_FLAGS.needsRerender */);
|
|
813
963
|
}
|
|
814
964
|
// ( •_•)
|
|
815
965
|
// ( •_•)>⌐■-■
|
|
@@ -820,7 +970,7 @@ const forceUpdate = (ref) => {
|
|
|
820
970
|
const hostRef = getHostRef(ref);
|
|
821
971
|
const isConnected = hostRef.$hostElement$.isConnected;
|
|
822
972
|
if (isConnected &&
|
|
823
|
-
(hostRef.$flags$ & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
|
|
973
|
+
(hostRef.$flags$ & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
|
|
824
974
|
scheduleUpdate(hostRef, false);
|
|
825
975
|
}
|
|
826
976
|
// Returns "true" when the forced update was successfully scheduled
|
|
@@ -851,53 +1001,6 @@ const then = (promise, thenFn) => {
|
|
|
851
1001
|
};
|
|
852
1002
|
const addHydratedFlag = (elm) => elm.classList.add('hydrated')
|
|
853
1003
|
;
|
|
854
|
-
/**
|
|
855
|
-
* Parse a new property value for a given property type.
|
|
856
|
-
*
|
|
857
|
-
* While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
|
|
858
|
-
* it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
|
|
859
|
-
* 1. `any`, the type given to `propValue` in the function signature
|
|
860
|
-
* 2. the type stored from `propType`.
|
|
861
|
-
*
|
|
862
|
-
* This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
|
|
863
|
-
*
|
|
864
|
-
* Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
|
|
865
|
-
* a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
|
|
866
|
-
* based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
|
|
867
|
-
* ```tsx
|
|
868
|
-
* <my-cmp prop-val={0}></my-cmp>
|
|
869
|
-
* ```
|
|
870
|
-
*
|
|
871
|
-
* HTML prop values on the other hand, will always a string
|
|
872
|
-
*
|
|
873
|
-
* @param propValue the new value to coerce to some type
|
|
874
|
-
* @param propType the type of the prop, expressed as a binary number
|
|
875
|
-
* @returns the parsed/coerced value
|
|
876
|
-
*/
|
|
877
|
-
const parsePropertyValue = (propValue, propType) => {
|
|
878
|
-
// ensure this value is of the correct prop type
|
|
879
|
-
if (propValue != null && !isComplexType(propValue)) {
|
|
880
|
-
if (propType & 4 /* Boolean */) {
|
|
881
|
-
// per the HTML spec, any string value means it is a boolean true value
|
|
882
|
-
// but we'll cheat here and say that the string "false" is the boolean false
|
|
883
|
-
return propValue === 'false' ? false : propValue === '' || !!propValue;
|
|
884
|
-
}
|
|
885
|
-
if (propType & 2 /* Number */) {
|
|
886
|
-
// force it to be a number
|
|
887
|
-
return parseFloat(propValue);
|
|
888
|
-
}
|
|
889
|
-
if (propType & 1 /* String */) {
|
|
890
|
-
// could have been passed as a number or boolean
|
|
891
|
-
// but we still want it as a string
|
|
892
|
-
return String(propValue);
|
|
893
|
-
}
|
|
894
|
-
// redundant return here for better minification
|
|
895
|
-
return propValue;
|
|
896
|
-
}
|
|
897
|
-
// not sure exactly what type we want
|
|
898
|
-
// so no need to change to a different type
|
|
899
|
-
return propValue;
|
|
900
|
-
};
|
|
901
1004
|
const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
|
|
902
1005
|
const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
903
1006
|
// check our new property value against our internal value
|
|
@@ -910,13 +1013,13 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
910
1013
|
// explicitly check for NaN on both sides, as `NaN === NaN` is always false
|
|
911
1014
|
const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
|
|
912
1015
|
const didValueChange = newVal !== oldVal && !areBothNaN;
|
|
913
|
-
if ((!(flags & 8 /* isConstructingInstance */) || oldVal === undefined) && didValueChange) {
|
|
1016
|
+
if ((!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
|
|
914
1017
|
// gadzooks! the property's value has changed!!
|
|
915
1018
|
// set our new value!
|
|
916
1019
|
hostRef.$instanceValues$.set(propName, newVal);
|
|
917
1020
|
if (instance) {
|
|
918
1021
|
// get an array of method names of watch functions to call
|
|
919
|
-
if (cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
|
|
1022
|
+
if (cmpMeta.$watchers$ && flags & 128 /* HOST_FLAGS.isWatchReady */) {
|
|
920
1023
|
const watchMethods = cmpMeta.$watchers$[propName];
|
|
921
1024
|
if (watchMethods) {
|
|
922
1025
|
// this instance is watching for when this property changed
|
|
@@ -931,7 +1034,7 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
931
1034
|
});
|
|
932
1035
|
}
|
|
933
1036
|
}
|
|
934
|
-
if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
|
|
1037
|
+
if ((flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
|
|
935
1038
|
// looks like this value actually changed, so we've got work to do!
|
|
936
1039
|
// but only if we've already rendered, otherwise just chill out
|
|
937
1040
|
// queue that we need to do an update, but don't worry about queuing
|
|
@@ -941,6 +1044,16 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
941
1044
|
}
|
|
942
1045
|
}
|
|
943
1046
|
};
|
|
1047
|
+
/**
|
|
1048
|
+
* Attach a series of runtime constructs to a compiled Stencil component
|
|
1049
|
+
* constructor, including getters and setters for the `@Prop` and `@State`
|
|
1050
|
+
* decorators, callbacks for when attributes change, and so on.
|
|
1051
|
+
*
|
|
1052
|
+
* @param Cstr the constructor for a component that we need to process
|
|
1053
|
+
* @param cmpMeta metadata collected previously about the component
|
|
1054
|
+
* @param flags a number used to store a series of bit flags
|
|
1055
|
+
* @returns a reference to the same constructor passed in (but now mutated)
|
|
1056
|
+
*/
|
|
944
1057
|
const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
945
1058
|
if (cmpMeta.$members$) {
|
|
946
1059
|
if (Cstr.watchers) {
|
|
@@ -950,8 +1063,8 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
950
1063
|
const members = Object.entries(cmpMeta.$members$);
|
|
951
1064
|
const prototype = Cstr.prototype;
|
|
952
1065
|
members.map(([memberName, [memberFlags]]) => {
|
|
953
|
-
if ((memberFlags & 31 /* Prop */ ||
|
|
954
|
-
((flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
|
|
1066
|
+
if ((memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
|
|
1067
|
+
((flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
|
|
955
1068
|
// proxyComponent - prop
|
|
956
1069
|
Object.defineProperty(prototype, memberName, {
|
|
957
1070
|
get() {
|
|
@@ -967,7 +1080,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
967
1080
|
});
|
|
968
1081
|
}
|
|
969
1082
|
});
|
|
970
|
-
if ((flags & 1 /* isElementConstructor */)) {
|
|
1083
|
+
if ((flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
|
|
971
1084
|
const attrNameToPropName = new Map();
|
|
972
1085
|
prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
|
|
973
1086
|
plt.jmp(() => {
|
|
@@ -1023,7 +1136,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1023
1136
|
// create an array of attributes to observe
|
|
1024
1137
|
// and also create a map of html attribute name to js property name
|
|
1025
1138
|
Cstr.observedAttributes = members
|
|
1026
|
-
.filter(([_, m]) => m[0] & 15 /* HasAttribute */) // filter to only keep props that should match attributes
|
|
1139
|
+
.filter(([_, m]) => m[0] & 15 /* MEMBER_FLAGS.HasAttribute */) // filter to only keep props that should match attributes
|
|
1027
1140
|
.map(([propName, m]) => {
|
|
1028
1141
|
const attrName = m[1] || propName;
|
|
1029
1142
|
attrNameToPropName.set(attrName, propName);
|
|
@@ -1035,10 +1148,10 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1035
1148
|
};
|
|
1036
1149
|
const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
|
|
1037
1150
|
// initializeComponent
|
|
1038
|
-
if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
|
|
1151
|
+
if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
|
|
1039
1152
|
{
|
|
1040
1153
|
// we haven't initialized this element yet
|
|
1041
|
-
hostRef.$flags$ |= 32 /* hasInitializedComponent */;
|
|
1154
|
+
hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
|
|
1042
1155
|
// lazy loaded components
|
|
1043
1156
|
// request the component's implementation to be
|
|
1044
1157
|
// wired up with the host element
|
|
@@ -1056,7 +1169,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1056
1169
|
{
|
|
1057
1170
|
cmpMeta.$watchers$ = Cstr.watchers;
|
|
1058
1171
|
}
|
|
1059
|
-
proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
|
|
1172
|
+
proxyComponent(Cstr, cmpMeta, 2 /* PROXY_FLAGS.proxyState */);
|
|
1060
1173
|
Cstr.isProxied = true;
|
|
1061
1174
|
}
|
|
1062
1175
|
const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
|
|
@@ -1064,7 +1177,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1064
1177
|
// but let's keep track of when we start and stop
|
|
1065
1178
|
// so that the getters/setters don't incorrectly step on data
|
|
1066
1179
|
{
|
|
1067
|
-
hostRef.$flags$ |= 8 /* isConstructingInstance */;
|
|
1180
|
+
hostRef.$flags$ |= 8 /* HOST_FLAGS.isConstructingInstance */;
|
|
1068
1181
|
}
|
|
1069
1182
|
// construct the lazy-loaded component implementation
|
|
1070
1183
|
// passing the hostRef is very important during
|
|
@@ -1077,10 +1190,10 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1077
1190
|
consoleError(e);
|
|
1078
1191
|
}
|
|
1079
1192
|
{
|
|
1080
|
-
hostRef.$flags$ &= ~8 /* isConstructingInstance */;
|
|
1193
|
+
hostRef.$flags$ &= ~8 /* HOST_FLAGS.isConstructingInstance */;
|
|
1081
1194
|
}
|
|
1082
1195
|
{
|
|
1083
|
-
hostRef.$flags$ |= 128 /* isWatchReady */;
|
|
1196
|
+
hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */;
|
|
1084
1197
|
}
|
|
1085
1198
|
endNewInstance();
|
|
1086
1199
|
fireConnectedCallback(hostRef.$lazyInstance$);
|
|
@@ -1091,10 +1204,10 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1091
1204
|
const scopeId = getScopeId(cmpMeta);
|
|
1092
1205
|
if (!styles.has(scopeId)) {
|
|
1093
1206
|
const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
|
|
1094
|
-
if (cmpMeta.$flags$ & 8 /* needsShadowDomShim */) {
|
|
1095
|
-
style = await Promise.resolve().then(function () { return require('./shadow-css-
|
|
1207
|
+
if (cmpMeta.$flags$ & 8 /* CMP_FLAGS.needsShadowDomShim */) {
|
|
1208
|
+
style = await Promise.resolve().then(function () { return require('./shadow-css-346c0795.js'); }).then((m) => m.scopeCss(style, scopeId, false));
|
|
1096
1209
|
}
|
|
1097
|
-
registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
|
|
1210
|
+
registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
|
|
1098
1211
|
endRegisterStyles();
|
|
1099
1212
|
}
|
|
1100
1213
|
}
|
|
@@ -1121,13 +1234,13 @@ const fireConnectedCallback = (instance) => {
|
|
|
1121
1234
|
}
|
|
1122
1235
|
};
|
|
1123
1236
|
const connectedCallback = (elm) => {
|
|
1124
|
-
if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
|
|
1237
|
+
if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
|
|
1125
1238
|
const hostRef = getHostRef(elm);
|
|
1126
1239
|
const cmpMeta = hostRef.$cmpMeta$;
|
|
1127
1240
|
const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
|
|
1128
|
-
if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
|
|
1241
|
+
if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
|
|
1129
1242
|
// first time this component has connected
|
|
1130
|
-
hostRef.$flags$ |= 1 /* hasConnected */;
|
|
1243
|
+
hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
|
|
1131
1244
|
{
|
|
1132
1245
|
// find the first ancestor component (if there is one) and register
|
|
1133
1246
|
// this component as one of the actively loading child components for its ancestor
|
|
@@ -1147,7 +1260,7 @@ const connectedCallback = (elm) => {
|
|
|
1147
1260
|
// https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
|
|
1148
1261
|
if (cmpMeta.$members$) {
|
|
1149
1262
|
Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
|
|
1150
|
-
if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
|
|
1263
|
+
if (memberFlags & 31 /* MEMBER_FLAGS.Prop */ && elm.hasOwnProperty(memberName)) {
|
|
1151
1264
|
const value = elm[memberName];
|
|
1152
1265
|
delete elm[memberName];
|
|
1153
1266
|
elm[memberName] = value;
|
|
@@ -1170,7 +1283,7 @@ const connectedCallback = (elm) => {
|
|
|
1170
1283
|
}
|
|
1171
1284
|
};
|
|
1172
1285
|
const disconnectedCallback = (elm) => {
|
|
1173
|
-
if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
|
|
1286
|
+
if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
|
|
1174
1287
|
const hostRef = getHostRef(elm);
|
|
1175
1288
|
const instance = hostRef.$lazyInstance$ ;
|
|
1176
1289
|
{
|
|
@@ -1194,7 +1307,7 @@ const patchChildSlotNodes = (elm, cmpMeta) => {
|
|
|
1194
1307
|
return this[n];
|
|
1195
1308
|
}
|
|
1196
1309
|
}
|
|
1197
|
-
if (cmpMeta.$flags$ & 8 /* needsShadowDomShim */) {
|
|
1310
|
+
if (cmpMeta.$flags$ & 8 /* CMP_FLAGS.needsShadowDomShim */) {
|
|
1198
1311
|
const childNodesFn = elm.__lookupGetter__('childNodes');
|
|
1199
1312
|
Object.defineProperty(elm, 'children', {
|
|
1200
1313
|
get() {
|
|
@@ -1209,8 +1322,8 @@ const patchChildSlotNodes = (elm, cmpMeta) => {
|
|
|
1209
1322
|
Object.defineProperty(elm, 'childNodes', {
|
|
1210
1323
|
get() {
|
|
1211
1324
|
const childNodes = childNodesFn.call(this);
|
|
1212
|
-
if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0 &&
|
|
1213
|
-
getHostRef(this).$flags$ & 2 /* hasRendered */) {
|
|
1325
|
+
if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0 &&
|
|
1326
|
+
getHostRef(this).$flags$ & 2 /* HOST_FLAGS.hasRendered */) {
|
|
1214
1327
|
const result = new FakeNodeList();
|
|
1215
1328
|
for (let i = 0; i < childNodes.length; i++) {
|
|
1216
1329
|
const slot = childNodes[i]['s-nr'];
|
|
@@ -1255,8 +1368,8 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1255
1368
|
{
|
|
1256
1369
|
cmpMeta.$watchers$ = {};
|
|
1257
1370
|
}
|
|
1258
|
-
if (!supportsShadow && cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
|
|
1259
|
-
cmpMeta.$flags$ |= 8 /* needsShadowDomShim */;
|
|
1371
|
+
if (!supportsShadow && cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
|
|
1372
|
+
cmpMeta.$flags$ |= 8 /* CMP_FLAGS.needsShadowDomShim */;
|
|
1260
1373
|
}
|
|
1261
1374
|
const tagName = cmpMeta.$tagName$;
|
|
1262
1375
|
const HostElement = class extends HTMLElement {
|
|
@@ -1266,7 +1379,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1266
1379
|
super(self);
|
|
1267
1380
|
self = this;
|
|
1268
1381
|
registerHost(self, cmpMeta);
|
|
1269
|
-
if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
|
|
1382
|
+
if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
|
|
1270
1383
|
// this component is using shadow dom
|
|
1271
1384
|
// and this browser supports shadow dom
|
|
1272
1385
|
// add the read-only property "shadowRoot" to the host element
|
|
@@ -1307,7 +1420,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1307
1420
|
cmpMeta.$lazyBundleId$ = lazyBundle[0];
|
|
1308
1421
|
if (!exclude.includes(tagName) && !customElements.get(tagName)) {
|
|
1309
1422
|
cmpTags.push(tagName);
|
|
1310
|
-
customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
|
|
1423
|
+
customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */));
|
|
1311
1424
|
}
|
|
1312
1425
|
});
|
|
1313
1426
|
});
|
|
@@ -1329,7 +1442,41 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1329
1442
|
// Fallback appLoad event
|
|
1330
1443
|
endBootstrap();
|
|
1331
1444
|
};
|
|
1332
|
-
const
|
|
1445
|
+
const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
|
|
1446
|
+
if (listeners) {
|
|
1447
|
+
listeners.map(([flags, name, method]) => {
|
|
1448
|
+
const target = getHostListenerTarget(elm, flags) ;
|
|
1449
|
+
const handler = hostListenerProxy(hostRef, method);
|
|
1450
|
+
const opts = hostListenerOpts(flags);
|
|
1451
|
+
plt.ael(target, name, handler, opts);
|
|
1452
|
+
(hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
|
|
1453
|
+
});
|
|
1454
|
+
}
|
|
1455
|
+
};
|
|
1456
|
+
const hostListenerProxy = (hostRef, methodName) => (ev) => {
|
|
1457
|
+
try {
|
|
1458
|
+
{
|
|
1459
|
+
if (hostRef.$flags$ & 256 /* HOST_FLAGS.isListenReady */) {
|
|
1460
|
+
// instance is ready, let's call it's member method for this event
|
|
1461
|
+
hostRef.$lazyInstance$[methodName](ev);
|
|
1462
|
+
}
|
|
1463
|
+
else {
|
|
1464
|
+
(hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
|
|
1465
|
+
}
|
|
1466
|
+
}
|
|
1467
|
+
}
|
|
1468
|
+
catch (e) {
|
|
1469
|
+
consoleError(e);
|
|
1470
|
+
}
|
|
1471
|
+
};
|
|
1472
|
+
const getHostListenerTarget = (elm, flags) => {
|
|
1473
|
+
if (flags & 8 /* LISTENER_FLAGS.TargetWindow */)
|
|
1474
|
+
return win;
|
|
1475
|
+
return elm;
|
|
1476
|
+
};
|
|
1477
|
+
// prettier-ignore
|
|
1478
|
+
const hostListenerOpts = (flags) => (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0;
|
|
1479
|
+
const hostRefs = /*@__PURE__*/ new WeakMap();
|
|
1333
1480
|
const getHostRef = (ref) => hostRefs.get(ref);
|
|
1334
1481
|
const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
|
|
1335
1482
|
const registerHost = (elm, cmpMeta) => {
|
|
@@ -1371,14 +1518,38 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
|
|
|
1371
1518
|
return importedModule[exportName];
|
|
1372
1519
|
}, consoleError);
|
|
1373
1520
|
};
|
|
1374
|
-
const styles = new Map();
|
|
1521
|
+
const styles = /*@__PURE__*/ new Map();
|
|
1522
|
+
const win = typeof window !== 'undefined' ? window : {};
|
|
1523
|
+
const CSS = win.CSS ;
|
|
1524
|
+
const doc = win.document || { head: {} };
|
|
1525
|
+
const plt = {
|
|
1526
|
+
$flags$: 0,
|
|
1527
|
+
$resourcesUrl$: '',
|
|
1528
|
+
jmp: (h) => h(),
|
|
1529
|
+
raf: (h) => requestAnimationFrame(h),
|
|
1530
|
+
ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
|
|
1531
|
+
rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
|
|
1532
|
+
ce: (eventName, opts) => new CustomEvent(eventName, opts),
|
|
1533
|
+
};
|
|
1534
|
+
const supportsShadow = /*@__PURE__*/ (() => (doc.head.attachShadow + '').indexOf('[native') > -1)()
|
|
1535
|
+
;
|
|
1536
|
+
const promiseResolve = (v) => Promise.resolve(v);
|
|
1537
|
+
const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
|
|
1538
|
+
try {
|
|
1539
|
+
new CSSStyleSheet();
|
|
1540
|
+
return typeof new CSSStyleSheet().replaceSync === 'function';
|
|
1541
|
+
}
|
|
1542
|
+
catch (e) { }
|
|
1543
|
+
return false;
|
|
1544
|
+
})()
|
|
1545
|
+
;
|
|
1375
1546
|
const queueDomReads = [];
|
|
1376
1547
|
const queueDomWrites = [];
|
|
1377
1548
|
const queueTask = (queue, write) => (cb) => {
|
|
1378
1549
|
queue.push(cb);
|
|
1379
1550
|
if (!queuePending) {
|
|
1380
1551
|
queuePending = true;
|
|
1381
|
-
if (write && plt.$flags$ & 4 /* queueSync */) {
|
|
1552
|
+
if (write && plt.$flags$ & 4 /* PLATFORM_FLAGS.queueSync */) {
|
|
1382
1553
|
nextTick(flush);
|
|
1383
1554
|
}
|
|
1384
1555
|
else {
|