@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
|
@@ -1,69 +1,18 @@
|
|
|
1
1
|
const NAMESPACE = 'geotrek-rando-widget';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Virtual DOM patching algorithm based on Snabbdom by
|
|
5
|
+
* Simon Friis Vindum (@paldepind)
|
|
6
|
+
* Licensed under the MIT License
|
|
7
|
+
* https://github.com/snabbdom/snabbdom/blob/master/LICENSE
|
|
8
|
+
*
|
|
9
|
+
* Modified for Stencil's renderer and slot projection
|
|
10
|
+
*/
|
|
3
11
|
let scopeId;
|
|
4
12
|
let hostTagName;
|
|
5
13
|
let isSvgMode = false;
|
|
6
14
|
let renderingRef = null;
|
|
7
15
|
let queuePending = false;
|
|
8
|
-
const win = typeof window !== 'undefined' ? window : {};
|
|
9
|
-
const CSS = win.CSS ;
|
|
10
|
-
const doc = win.document || { head: {} };
|
|
11
|
-
const plt = {
|
|
12
|
-
$flags$: 0,
|
|
13
|
-
$resourcesUrl$: '',
|
|
14
|
-
jmp: (h) => h(),
|
|
15
|
-
raf: (h) => requestAnimationFrame(h),
|
|
16
|
-
ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
|
|
17
|
-
rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
|
|
18
|
-
ce: (eventName, opts) => new CustomEvent(eventName, opts),
|
|
19
|
-
};
|
|
20
|
-
const supportsShadow = /*@__PURE__*/ (() => (doc.head.attachShadow + '').indexOf('[native') > -1)()
|
|
21
|
-
;
|
|
22
|
-
const promiseResolve = (v) => Promise.resolve(v);
|
|
23
|
-
const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
|
|
24
|
-
try {
|
|
25
|
-
new CSSStyleSheet();
|
|
26
|
-
return typeof new CSSStyleSheet().replaceSync === 'function';
|
|
27
|
-
}
|
|
28
|
-
catch (e) { }
|
|
29
|
-
return false;
|
|
30
|
-
})()
|
|
31
|
-
;
|
|
32
|
-
const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
|
|
33
|
-
if (listeners) {
|
|
34
|
-
listeners.map(([flags, name, method]) => {
|
|
35
|
-
const target = getHostListenerTarget(elm, flags) ;
|
|
36
|
-
const handler = hostListenerProxy(hostRef, method);
|
|
37
|
-
const opts = hostListenerOpts(flags);
|
|
38
|
-
plt.ael(target, name, handler, opts);
|
|
39
|
-
(hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
const hostListenerProxy = (hostRef, methodName) => (ev) => {
|
|
44
|
-
try {
|
|
45
|
-
{
|
|
46
|
-
if (hostRef.$flags$ & 256 /* isListenReady */) {
|
|
47
|
-
// instance is ready, let's call it's member method for this event
|
|
48
|
-
hostRef.$lazyInstance$[methodName](ev);
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
(hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
catch (e) {
|
|
56
|
-
consoleError(e);
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
const getHostListenerTarget = (elm, flags) => {
|
|
60
|
-
if (flags & 8 /* TargetWindow */)
|
|
61
|
-
return win;
|
|
62
|
-
return elm;
|
|
63
|
-
};
|
|
64
|
-
// prettier-ignore
|
|
65
|
-
const hostListenerOpts = (flags) => (flags & 2 /* Capture */) !== 0;
|
|
66
|
-
const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
|
|
67
16
|
const createTime = (fnName, tagName = '') => {
|
|
68
17
|
{
|
|
69
18
|
return () => {
|
|
@@ -78,87 +27,7 @@ const uniqueTime = (key, measureText) => {
|
|
|
78
27
|
};
|
|
79
28
|
}
|
|
80
29
|
};
|
|
81
|
-
const
|
|
82
|
-
const registerStyle = (scopeId, cssText, allowCS) => {
|
|
83
|
-
let style = styles.get(scopeId);
|
|
84
|
-
if (supportsConstructableStylesheets && allowCS) {
|
|
85
|
-
style = (style || new CSSStyleSheet());
|
|
86
|
-
if (typeof style === 'string') {
|
|
87
|
-
style = cssText;
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
style.replaceSync(cssText);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
style = cssText;
|
|
95
|
-
}
|
|
96
|
-
styles.set(scopeId, style);
|
|
97
|
-
};
|
|
98
|
-
const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
|
|
99
|
-
let scopeId = getScopeId(cmpMeta);
|
|
100
|
-
const style = styles.get(scopeId);
|
|
101
|
-
// if an element is NOT connected then getRootNode() will return the wrong root node
|
|
102
|
-
// so the fallback is to always use the document for the root node in those cases
|
|
103
|
-
styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
|
|
104
|
-
if (style) {
|
|
105
|
-
if (typeof style === 'string') {
|
|
106
|
-
styleContainerNode = styleContainerNode.head || styleContainerNode;
|
|
107
|
-
let appliedStyles = rootAppliedStyles.get(styleContainerNode);
|
|
108
|
-
let styleElm;
|
|
109
|
-
if (!appliedStyles) {
|
|
110
|
-
rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
|
|
111
|
-
}
|
|
112
|
-
if (!appliedStyles.has(scopeId)) {
|
|
113
|
-
{
|
|
114
|
-
if (plt.$cssShim$) {
|
|
115
|
-
styleElm = plt.$cssShim$.createHostStyle(hostElm, scopeId, style, !!(cmpMeta.$flags$ & 10 /* needsScopedEncapsulation */));
|
|
116
|
-
const newScopeId = styleElm['s-sc'];
|
|
117
|
-
if (newScopeId) {
|
|
118
|
-
scopeId = newScopeId;
|
|
119
|
-
// we don't want to add this styleID to the appliedStyles Set
|
|
120
|
-
// since the cssVarShim might need to apply several different
|
|
121
|
-
// stylesheets for the same component
|
|
122
|
-
appliedStyles = null;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
else {
|
|
126
|
-
styleElm = doc.createElement('style');
|
|
127
|
-
styleElm.innerHTML = style;
|
|
128
|
-
}
|
|
129
|
-
styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
|
|
130
|
-
}
|
|
131
|
-
if (appliedStyles) {
|
|
132
|
-
appliedStyles.add(scopeId);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
|
|
137
|
-
styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
return scopeId;
|
|
141
|
-
};
|
|
142
|
-
const attachStyles = (hostRef) => {
|
|
143
|
-
const cmpMeta = hostRef.$cmpMeta$;
|
|
144
|
-
const elm = hostRef.$hostElement$;
|
|
145
|
-
const flags = cmpMeta.$flags$;
|
|
146
|
-
const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
|
|
147
|
-
const scopeId = addStyle(supportsShadow && elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta, hostRef.$modeName$, elm);
|
|
148
|
-
if (flags & 10 /* needsScopedEncapsulation */) {
|
|
149
|
-
// only required when we're NOT using native shadow dom (slot)
|
|
150
|
-
// or this browser doesn't support native shadow dom
|
|
151
|
-
// and this host element was NOT created with SSR
|
|
152
|
-
// let's pick out the inner content for slot projection
|
|
153
|
-
// create a node to represent where the original
|
|
154
|
-
// content was first placed, which is useful later on
|
|
155
|
-
// DOM WRITE!!
|
|
156
|
-
elm['s-sc'] = scopeId;
|
|
157
|
-
elm.classList.add(scopeId + '-h');
|
|
158
|
-
}
|
|
159
|
-
endAttachStyles();
|
|
160
|
-
};
|
|
161
|
-
const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
|
|
30
|
+
const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
|
|
162
31
|
/**
|
|
163
32
|
* Default style mode id
|
|
164
33
|
*/
|
|
@@ -258,6 +127,160 @@ const newVNode = (tag, text) => {
|
|
|
258
127
|
};
|
|
259
128
|
const Host = {};
|
|
260
129
|
const isHost = (node) => node && node.$tag$ === Host;
|
|
130
|
+
/**
|
|
131
|
+
* Parse a new property value for a given property type.
|
|
132
|
+
*
|
|
133
|
+
* While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
|
|
134
|
+
* it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
|
|
135
|
+
* 1. `any`, the type given to `propValue` in the function signature
|
|
136
|
+
* 2. the type stored from `propType`.
|
|
137
|
+
*
|
|
138
|
+
* This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
|
|
139
|
+
*
|
|
140
|
+
* Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
|
|
141
|
+
* a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
|
|
142
|
+
* based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
|
|
143
|
+
* ```tsx
|
|
144
|
+
* <my-cmp prop-val={0}></my-cmp>
|
|
145
|
+
* ```
|
|
146
|
+
*
|
|
147
|
+
* HTML prop values on the other hand, will always a string
|
|
148
|
+
*
|
|
149
|
+
* @param propValue the new value to coerce to some type
|
|
150
|
+
* @param propType the type of the prop, expressed as a binary number
|
|
151
|
+
* @returns the parsed/coerced value
|
|
152
|
+
*/
|
|
153
|
+
const parsePropertyValue = (propValue, propType) => {
|
|
154
|
+
// ensure this value is of the correct prop type
|
|
155
|
+
if (propValue != null && !isComplexType(propValue)) {
|
|
156
|
+
if (propType & 4 /* MEMBER_FLAGS.Boolean */) {
|
|
157
|
+
// per the HTML spec, any string value means it is a boolean true value
|
|
158
|
+
// but we'll cheat here and say that the string "false" is the boolean false
|
|
159
|
+
return propValue === 'false' ? false : propValue === '' || !!propValue;
|
|
160
|
+
}
|
|
161
|
+
if (propType & 2 /* MEMBER_FLAGS.Number */) {
|
|
162
|
+
// force it to be a number
|
|
163
|
+
return parseFloat(propValue);
|
|
164
|
+
}
|
|
165
|
+
if (propType & 1 /* MEMBER_FLAGS.String */) {
|
|
166
|
+
// could have been passed as a number or boolean
|
|
167
|
+
// but we still want it as a string
|
|
168
|
+
return String(propValue);
|
|
169
|
+
}
|
|
170
|
+
// redundant return here for better minification
|
|
171
|
+
return propValue;
|
|
172
|
+
}
|
|
173
|
+
// not sure exactly what type we want
|
|
174
|
+
// so no need to change to a different type
|
|
175
|
+
return propValue;
|
|
176
|
+
};
|
|
177
|
+
const getElement = (ref) => (getHostRef(ref).$hostElement$ );
|
|
178
|
+
const createEvent = (ref, name, flags) => {
|
|
179
|
+
const elm = getElement(ref);
|
|
180
|
+
return {
|
|
181
|
+
emit: (detail) => {
|
|
182
|
+
return emitEvent(elm, name, {
|
|
183
|
+
bubbles: !!(flags & 4 /* EVENT_FLAGS.Bubbles */),
|
|
184
|
+
composed: !!(flags & 2 /* EVENT_FLAGS.Composed */),
|
|
185
|
+
cancelable: !!(flags & 1 /* EVENT_FLAGS.Cancellable */),
|
|
186
|
+
detail,
|
|
187
|
+
});
|
|
188
|
+
},
|
|
189
|
+
};
|
|
190
|
+
};
|
|
191
|
+
/**
|
|
192
|
+
* Helper function to create & dispatch a custom Event on a provided target
|
|
193
|
+
* @param elm the target of the Event
|
|
194
|
+
* @param name the name to give the custom Event
|
|
195
|
+
* @param opts options for configuring a custom Event
|
|
196
|
+
* @returns the custom Event
|
|
197
|
+
*/
|
|
198
|
+
const emitEvent = (elm, name, opts) => {
|
|
199
|
+
const ev = plt.ce(name, opts);
|
|
200
|
+
elm.dispatchEvent(ev);
|
|
201
|
+
return ev;
|
|
202
|
+
};
|
|
203
|
+
const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
|
|
204
|
+
const registerStyle = (scopeId, cssText, allowCS) => {
|
|
205
|
+
let style = styles.get(scopeId);
|
|
206
|
+
if (supportsConstructableStylesheets && allowCS) {
|
|
207
|
+
style = (style || new CSSStyleSheet());
|
|
208
|
+
if (typeof style === 'string') {
|
|
209
|
+
style = cssText;
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
style.replaceSync(cssText);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
style = cssText;
|
|
217
|
+
}
|
|
218
|
+
styles.set(scopeId, style);
|
|
219
|
+
};
|
|
220
|
+
const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
|
|
221
|
+
let scopeId = getScopeId(cmpMeta);
|
|
222
|
+
const style = styles.get(scopeId);
|
|
223
|
+
// if an element is NOT connected then getRootNode() will return the wrong root node
|
|
224
|
+
// so the fallback is to always use the document for the root node in those cases
|
|
225
|
+
styleContainerNode = styleContainerNode.nodeType === 11 /* NODE_TYPE.DocumentFragment */ ? styleContainerNode : doc;
|
|
226
|
+
if (style) {
|
|
227
|
+
if (typeof style === 'string') {
|
|
228
|
+
styleContainerNode = styleContainerNode.head || styleContainerNode;
|
|
229
|
+
let appliedStyles = rootAppliedStyles.get(styleContainerNode);
|
|
230
|
+
let styleElm;
|
|
231
|
+
if (!appliedStyles) {
|
|
232
|
+
rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
|
|
233
|
+
}
|
|
234
|
+
if (!appliedStyles.has(scopeId)) {
|
|
235
|
+
{
|
|
236
|
+
if (plt.$cssShim$) {
|
|
237
|
+
styleElm = plt.$cssShim$.createHostStyle(hostElm, scopeId, style, !!(cmpMeta.$flags$ & 10 /* CMP_FLAGS.needsScopedEncapsulation */));
|
|
238
|
+
const newScopeId = styleElm['s-sc'];
|
|
239
|
+
if (newScopeId) {
|
|
240
|
+
scopeId = newScopeId;
|
|
241
|
+
// we don't want to add this styleID to the appliedStyles Set
|
|
242
|
+
// since the cssVarShim might need to apply several different
|
|
243
|
+
// stylesheets for the same component
|
|
244
|
+
appliedStyles = null;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
else {
|
|
248
|
+
styleElm = doc.createElement('style');
|
|
249
|
+
styleElm.innerHTML = style;
|
|
250
|
+
}
|
|
251
|
+
styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
|
|
252
|
+
}
|
|
253
|
+
if (appliedStyles) {
|
|
254
|
+
appliedStyles.add(scopeId);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
|
|
259
|
+
styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
return scopeId;
|
|
263
|
+
};
|
|
264
|
+
const attachStyles = (hostRef) => {
|
|
265
|
+
const cmpMeta = hostRef.$cmpMeta$;
|
|
266
|
+
const elm = hostRef.$hostElement$;
|
|
267
|
+
const flags = cmpMeta.$flags$;
|
|
268
|
+
const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
|
|
269
|
+
const scopeId = addStyle(supportsShadow && elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta, hostRef.$modeName$, elm);
|
|
270
|
+
if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
|
|
271
|
+
// only required when we're NOT using native shadow dom (slot)
|
|
272
|
+
// or this browser doesn't support native shadow dom
|
|
273
|
+
// and this host element was NOT created with SSR
|
|
274
|
+
// let's pick out the inner content for slot projection
|
|
275
|
+
// create a node to represent where the original
|
|
276
|
+
// content was first placed, which is useful later on
|
|
277
|
+
// DOM WRITE!!
|
|
278
|
+
elm['s-sc'] = scopeId;
|
|
279
|
+
elm.classList.add(scopeId + '-h');
|
|
280
|
+
}
|
|
281
|
+
endAttachStyles();
|
|
282
|
+
};
|
|
283
|
+
const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
|
|
261
284
|
/**
|
|
262
285
|
* Production setAccessor() function based on Preact by
|
|
263
286
|
* Jason Miller (@developit)
|
|
@@ -371,7 +394,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
|
|
371
394
|
}
|
|
372
395
|
}
|
|
373
396
|
}
|
|
374
|
-
else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
|
|
397
|
+
else if ((!isProp || flags & 4 /* VNODE_FLAGS.isHost */ || isSvg) && !isComplex) {
|
|
375
398
|
newValue = newValue === true ? '' : newValue;
|
|
376
399
|
{
|
|
377
400
|
elm.setAttribute(memberName, newValue);
|
|
@@ -386,7 +409,7 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
|
|
|
386
409
|
// if the element passed in is a shadow root, which is a document fragment
|
|
387
410
|
// then we want to be adding attrs/props to the shadow root's "host" element
|
|
388
411
|
// if it's not a shadow root, then we add attrs/props to the same element
|
|
389
|
-
const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host
|
|
412
|
+
const elm = newVnode.$elm$.nodeType === 11 /* NODE_TYPE.DocumentFragment */ && newVnode.$elm$.host
|
|
390
413
|
? newVnode.$elm$.host
|
|
391
414
|
: newVnode.$elm$;
|
|
392
415
|
const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
|
|
@@ -404,6 +427,16 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
|
|
|
404
427
|
setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
|
|
405
428
|
}
|
|
406
429
|
};
|
|
430
|
+
/**
|
|
431
|
+
* Create a DOM Node corresponding to one of the children of a given VNode.
|
|
432
|
+
*
|
|
433
|
+
* @param oldParentVNode the parent VNode from the previous render
|
|
434
|
+
* @param newParentVNode the parent VNode from the current render
|
|
435
|
+
* @param childIndex the index of the VNode, in the _new_ parent node's
|
|
436
|
+
* children, for which we will create a new DOM node
|
|
437
|
+
* @param parentElm the parent DOM node which our new node will be a child of
|
|
438
|
+
* @returns the newly created node
|
|
439
|
+
*/
|
|
407
440
|
const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
408
441
|
// tslint:disable-next-line: prefer-const
|
|
409
442
|
const newVNode = newParentVNode.$children$[childIndex];
|
|
@@ -465,6 +498,74 @@ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
|
|
|
465
498
|
}
|
|
466
499
|
}
|
|
467
500
|
};
|
|
501
|
+
/**
|
|
502
|
+
* Reconcile the children of a new VNode with the children of an old VNode by
|
|
503
|
+
* traversing the two collections of children, identifying nodes that are
|
|
504
|
+
* conserved or changed, calling out to `patch` to make any necessary
|
|
505
|
+
* updates to the DOM, and rearranging DOM nodes as needed.
|
|
506
|
+
*
|
|
507
|
+
* The algorithm for reconciling children works by analyzing two 'windows' onto
|
|
508
|
+
* the two arrays of children (`oldCh` and `newCh`). We keep track of the
|
|
509
|
+
* 'windows' by storing start and end indices and references to the
|
|
510
|
+
* corresponding array entries. Initially the two 'windows' are basically equal
|
|
511
|
+
* to the entire array, but we progressively narrow the windows until there are
|
|
512
|
+
* no children left to update by doing the following:
|
|
513
|
+
*
|
|
514
|
+
* 1. Skip any `null` entries at the beginning or end of the two arrays, so
|
|
515
|
+
* that if we have an initial array like the following we'll end up dealing
|
|
516
|
+
* only with a window bounded by the highlighted elements:
|
|
517
|
+
*
|
|
518
|
+
* [null, null, VNode1 , ... , VNode2, null, null]
|
|
519
|
+
* ^^^^^^ ^^^^^^
|
|
520
|
+
*
|
|
521
|
+
* 2. Check to see if the elements at the head and tail positions are equal
|
|
522
|
+
* across the windows. This will basically detect elements which haven't
|
|
523
|
+
* been added, removed, or changed position, i.e. if you had the following
|
|
524
|
+
* VNode elements (represented as HTML):
|
|
525
|
+
*
|
|
526
|
+
* oldVNode: `<div><p><span>HEY</span></p></div>`
|
|
527
|
+
* newVNode: `<div><p><span>THERE</span></p></div>`
|
|
528
|
+
*
|
|
529
|
+
* Then when comparing the children of the `<div>` tag we check the equality
|
|
530
|
+
* of the VNodes corresponding to the `<p>` tags and, since they are the
|
|
531
|
+
* same tag in the same position, we'd be able to avoid completely
|
|
532
|
+
* re-rendering the subtree under them with a new DOM element and would just
|
|
533
|
+
* call out to `patch` to handle reconciling their children and so on.
|
|
534
|
+
*
|
|
535
|
+
* 3. Check, for both windows, to see if the element at the beginning of the
|
|
536
|
+
* window corresponds to the element at the end of the other window. This is
|
|
537
|
+
* a heuristic which will let us identify _some_ situations in which
|
|
538
|
+
* elements have changed position, for instance it _should_ detect that the
|
|
539
|
+
* children nodes themselves have not changed but merely moved in the
|
|
540
|
+
* following example:
|
|
541
|
+
*
|
|
542
|
+
* oldVNode: `<div><element-one /><element-two /></div>`
|
|
543
|
+
* newVNode: `<div><element-two /><element-one /></div>`
|
|
544
|
+
*
|
|
545
|
+
* If we find cases like this then we also need to move the concrete DOM
|
|
546
|
+
* elements corresponding to the moved children to write the re-order to the
|
|
547
|
+
* DOM.
|
|
548
|
+
*
|
|
549
|
+
* 4. Finally, if VNodes have the `key` attribute set on them we check for any
|
|
550
|
+
* nodes in the old children which have the same key as the first element in
|
|
551
|
+
* our window on the new children. If we find such a node we handle calling
|
|
552
|
+
* out to `patch`, moving relevant DOM nodes, and so on, in accordance with
|
|
553
|
+
* what we find.
|
|
554
|
+
*
|
|
555
|
+
* Finally, once we've narrowed our 'windows' to the point that either of them
|
|
556
|
+
* collapse (i.e. they have length 0) we then handle any remaining VNode
|
|
557
|
+
* insertion or deletion that needs to happen to get a DOM state that correctly
|
|
558
|
+
* reflects the new child VNodes. If, for instance, after our window on the old
|
|
559
|
+
* children has collapsed we still have more nodes on the new children that
|
|
560
|
+
* we haven't dealt with yet then we need to add them, or if the new children
|
|
561
|
+
* collapse but we still have unhandled _old_ children then we need to make
|
|
562
|
+
* sure the corresponding DOM nodes are removed.
|
|
563
|
+
*
|
|
564
|
+
* @param parentElm the node into which the parent VNode is rendered
|
|
565
|
+
* @param oldCh the old children of the parent node
|
|
566
|
+
* @param newVNode the new VNode which will replace the parent
|
|
567
|
+
* @param newCh the new children of the parent node
|
|
568
|
+
*/
|
|
468
569
|
const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
469
570
|
let oldStartIdx = 0;
|
|
470
571
|
let newStartIdx = 0;
|
|
@@ -480,7 +581,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
480
581
|
let elmToMove;
|
|
481
582
|
while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
|
|
482
583
|
if (oldStartVnode == null) {
|
|
483
|
-
//
|
|
584
|
+
// VNode might have been moved left
|
|
484
585
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
485
586
|
}
|
|
486
587
|
else if (oldEndVnode == null) {
|
|
@@ -493,29 +594,65 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
493
594
|
newEndVnode = newCh[--newEndIdx];
|
|
494
595
|
}
|
|
495
596
|
else if (isSameVnode(oldStartVnode, newStartVnode)) {
|
|
597
|
+
// if the start nodes are the same then we should patch the new VNode
|
|
598
|
+
// onto the old one, and increment our `newStartIdx` and `oldStartIdx`
|
|
599
|
+
// indices to reflect that. We don't need to move any DOM Nodes around
|
|
600
|
+
// since things are matched up in order.
|
|
496
601
|
patch(oldStartVnode, newStartVnode);
|
|
497
602
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
498
603
|
newStartVnode = newCh[++newStartIdx];
|
|
499
604
|
}
|
|
500
605
|
else if (isSameVnode(oldEndVnode, newEndVnode)) {
|
|
606
|
+
// likewise, if the end nodes are the same we patch new onto old and
|
|
607
|
+
// decrement our end indices, and also likewise in this case we don't
|
|
608
|
+
// need to move any DOM Nodes.
|
|
501
609
|
patch(oldEndVnode, newEndVnode);
|
|
502
610
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
503
611
|
newEndVnode = newCh[--newEndIdx];
|
|
504
612
|
}
|
|
505
613
|
else if (isSameVnode(oldStartVnode, newEndVnode)) {
|
|
506
614
|
patch(oldStartVnode, newEndVnode);
|
|
615
|
+
// We need to move the element for `oldStartVnode` into a position which
|
|
616
|
+
// will be appropriate for `newEndVnode`. For this we can use
|
|
617
|
+
// `.insertBefore` and `oldEndVnode.$elm$.nextSibling`. If there is a
|
|
618
|
+
// sibling for `oldEndVnode.$elm$` then we want to move the DOM node for
|
|
619
|
+
// `oldStartVnode` between `oldEndVnode` and it's sibling, like so:
|
|
620
|
+
//
|
|
621
|
+
// <old-start-node />
|
|
622
|
+
// <some-intervening-node />
|
|
623
|
+
// <old-end-node />
|
|
624
|
+
// <!-- -> <-- `oldStartVnode.$elm$` should be inserted here
|
|
625
|
+
// <next-sibling />
|
|
626
|
+
//
|
|
627
|
+
// If instead `oldEndVnode.$elm$` has no sibling then we just want to put
|
|
628
|
+
// the node for `oldStartVnode` at the end of the children of
|
|
629
|
+
// `parentElm`. Luckily, `Node.nextSibling` will return `null` if there
|
|
630
|
+
// aren't any siblings, and passing `null` to `Node.insertBefore` will
|
|
631
|
+
// append it to the children of the parent element.
|
|
507
632
|
parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
|
|
508
633
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
509
634
|
newEndVnode = newCh[--newEndIdx];
|
|
510
635
|
}
|
|
511
636
|
else if (isSameVnode(oldEndVnode, newStartVnode)) {
|
|
512
637
|
patch(oldEndVnode, newStartVnode);
|
|
638
|
+
// We've already checked above if `oldStartVnode` and `newStartVnode` are
|
|
639
|
+
// the same node, so since we're here we know that they are not. Thus we
|
|
640
|
+
// can move the element for `oldEndVnode` _before_ the element for
|
|
641
|
+
// `oldStartVnode`, leaving `oldStartVnode` to be reconciled in the
|
|
642
|
+
// future.
|
|
513
643
|
parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
|
|
514
644
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
515
645
|
newStartVnode = newCh[++newStartIdx];
|
|
516
646
|
}
|
|
517
647
|
else {
|
|
518
|
-
//
|
|
648
|
+
// Here we do some checks to match up old and new nodes based on the
|
|
649
|
+
// `$key$` attribute, which is set by putting a `key="my-key"` attribute
|
|
650
|
+
// in the JSX for a DOM element in the implementation of a Stencil
|
|
651
|
+
// component.
|
|
652
|
+
//
|
|
653
|
+
// First we check to see if there are any nodes in the array of old
|
|
654
|
+
// children which have the same key as the first node in the new
|
|
655
|
+
// children.
|
|
519
656
|
idxInOld = -1;
|
|
520
657
|
{
|
|
521
658
|
for (i = oldStartIdx; i <= oldEndIdx; ++i) {
|
|
@@ -526,23 +663,32 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
526
663
|
}
|
|
527
664
|
}
|
|
528
665
|
if (idxInOld >= 0) {
|
|
666
|
+
// We found a node in the old children which matches up with the first
|
|
667
|
+
// node in the new children! So let's deal with that
|
|
529
668
|
elmToMove = oldCh[idxInOld];
|
|
530
669
|
if (elmToMove.$tag$ !== newStartVnode.$tag$) {
|
|
670
|
+
// the tag doesn't match so we'll need a new DOM element
|
|
531
671
|
node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld);
|
|
532
672
|
}
|
|
533
673
|
else {
|
|
534
674
|
patch(elmToMove, newStartVnode);
|
|
675
|
+
// invalidate the matching old node so that we won't try to update it
|
|
676
|
+
// again later on
|
|
535
677
|
oldCh[idxInOld] = undefined;
|
|
536
678
|
node = elmToMove.$elm$;
|
|
537
679
|
}
|
|
538
680
|
newStartVnode = newCh[++newStartIdx];
|
|
539
681
|
}
|
|
540
682
|
else {
|
|
541
|
-
//
|
|
683
|
+
// We either didn't find an element in the old children that matches
|
|
684
|
+
// the key of the first new child OR the build is not using `key`
|
|
685
|
+
// attributes at all. In either case we need to create a new element
|
|
686
|
+
// for the new node.
|
|
542
687
|
node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
|
|
543
688
|
newStartVnode = newCh[++newStartIdx];
|
|
544
689
|
}
|
|
545
690
|
if (node) {
|
|
691
|
+
// if we created a new node then handle inserting it to the DOM
|
|
546
692
|
{
|
|
547
693
|
oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
|
|
548
694
|
}
|
|
@@ -550,29 +696,58 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
550
696
|
}
|
|
551
697
|
}
|
|
552
698
|
if (oldStartIdx > oldEndIdx) {
|
|
699
|
+
// we have some more new nodes to add which don't match up with old nodes
|
|
553
700
|
addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
|
|
554
701
|
}
|
|
555
702
|
else if (newStartIdx > newEndIdx) {
|
|
703
|
+
// there are nodes in the `oldCh` array which no longer correspond to nodes
|
|
704
|
+
// in the new array, so lets remove them (which entails cleaning up the
|
|
705
|
+
// relevant DOM nodes)
|
|
556
706
|
removeVnodes(oldCh, oldStartIdx, oldEndIdx);
|
|
557
707
|
}
|
|
558
708
|
};
|
|
559
|
-
|
|
709
|
+
/**
|
|
710
|
+
* Compare two VNodes to determine if they are the same
|
|
711
|
+
*
|
|
712
|
+
* **NB**: This function is an equality _heuristic_ based on the available
|
|
713
|
+
* information set on the two VNodes and can be misleading under certain
|
|
714
|
+
* circumstances. In particular, if the two nodes do not have `key` attrs
|
|
715
|
+
* (available under `$key$` on VNodes) then the function falls back on merely
|
|
716
|
+
* checking that they have the same tag.
|
|
717
|
+
*
|
|
718
|
+
* So, in other words, if `key` attrs are not set on VNodes which may be
|
|
719
|
+
* changing order within a `children` array or something along those lines then
|
|
720
|
+
* we could obtain a false positive and then have to do needless re-rendering.
|
|
721
|
+
*
|
|
722
|
+
* @param leftVNode the first VNode to check
|
|
723
|
+
* @param rightVNode the second VNode to check
|
|
724
|
+
* @returns whether they're equal or not
|
|
725
|
+
*/
|
|
726
|
+
const isSameVnode = (leftVNode, rightVNode) => {
|
|
560
727
|
// compare if two vnode to see if they're "technically" the same
|
|
561
728
|
// need to have the same element tag, and same key to be the same
|
|
562
|
-
if (
|
|
729
|
+
if (leftVNode.$tag$ === rightVNode.$tag$) {
|
|
730
|
+
// this will be set if components in the build have `key` attrs set on them
|
|
563
731
|
{
|
|
564
|
-
return
|
|
732
|
+
return leftVNode.$key$ === rightVNode.$key$;
|
|
565
733
|
}
|
|
566
734
|
}
|
|
567
735
|
return false;
|
|
568
736
|
};
|
|
737
|
+
/**
|
|
738
|
+
* Handle reconciling an outdated VNode with a new one which corresponds to
|
|
739
|
+
* it. This function handles flushing updates to the DOM and reconciling the
|
|
740
|
+
* children of the two nodes (if any).
|
|
741
|
+
*
|
|
742
|
+
* @param oldVNode an old VNode whose DOM element and children we want to update
|
|
743
|
+
* @param newVNode a new VNode representing an updated version of the old one
|
|
744
|
+
*/
|
|
569
745
|
const patch = (oldVNode, newVNode) => {
|
|
570
746
|
const elm = (newVNode.$elm$ = oldVNode.$elm$);
|
|
571
747
|
const oldChildren = oldVNode.$children$;
|
|
572
748
|
const newChildren = newVNode.$children$;
|
|
573
749
|
const text = newVNode.$text$;
|
|
574
750
|
if (text === null) {
|
|
575
|
-
// element node
|
|
576
751
|
{
|
|
577
752
|
{
|
|
578
753
|
// either this is the first render of an element OR it's an update
|
|
@@ -583,6 +758,7 @@ const patch = (oldVNode, newVNode) => {
|
|
|
583
758
|
}
|
|
584
759
|
if (oldChildren !== null && newChildren !== null) {
|
|
585
760
|
// looks like there's child vnodes for both the old and new vnodes
|
|
761
|
+
// so we need to call `updateChildren` to reconcile them
|
|
586
762
|
updateChildren(elm, oldChildren, newVNode, newChildren);
|
|
587
763
|
}
|
|
588
764
|
else if (newChildren !== null) {
|
|
@@ -611,7 +787,7 @@ const renderVdom = (hostRef, renderFnResults) => {
|
|
|
611
787
|
const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
|
|
612
788
|
hostTagName = hostElm.tagName;
|
|
613
789
|
rootVnode.$tag$ = null;
|
|
614
|
-
rootVnode.$flags$ |= 4 /* isHost */;
|
|
790
|
+
rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
|
|
615
791
|
hostRef.$vnode$ = rootVnode;
|
|
616
792
|
rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
|
|
617
793
|
{
|
|
@@ -620,32 +796,6 @@ const renderVdom = (hostRef, renderFnResults) => {
|
|
|
620
796
|
// synchronous patch
|
|
621
797
|
patch(oldVNode, rootVnode);
|
|
622
798
|
};
|
|
623
|
-
const getElement = (ref) => (getHostRef(ref).$hostElement$ );
|
|
624
|
-
const createEvent = (ref, name, flags) => {
|
|
625
|
-
const elm = getElement(ref);
|
|
626
|
-
return {
|
|
627
|
-
emit: (detail) => {
|
|
628
|
-
return emitEvent(elm, name, {
|
|
629
|
-
bubbles: !!(flags & 4 /* Bubbles */),
|
|
630
|
-
composed: !!(flags & 2 /* Composed */),
|
|
631
|
-
cancelable: !!(flags & 1 /* Cancellable */),
|
|
632
|
-
detail,
|
|
633
|
-
});
|
|
634
|
-
},
|
|
635
|
-
};
|
|
636
|
-
};
|
|
637
|
-
/**
|
|
638
|
-
* Helper function to create & dispatch a custom Event on a provided target
|
|
639
|
-
* @param elm the target of the Event
|
|
640
|
-
* @param name the name to give the custom Event
|
|
641
|
-
* @param opts options for configuring a custom Event
|
|
642
|
-
* @returns the custom Event
|
|
643
|
-
*/
|
|
644
|
-
const emitEvent = (elm, name, opts) => {
|
|
645
|
-
const ev = plt.ce(name, opts);
|
|
646
|
-
elm.dispatchEvent(ev);
|
|
647
|
-
return ev;
|
|
648
|
-
};
|
|
649
799
|
const attachToAncestor = (hostRef, ancestorComponent) => {
|
|
650
800
|
if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
|
|
651
801
|
ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
|
|
@@ -653,10 +803,10 @@ const attachToAncestor = (hostRef, ancestorComponent) => {
|
|
|
653
803
|
};
|
|
654
804
|
const scheduleUpdate = (hostRef, isInitialLoad) => {
|
|
655
805
|
{
|
|
656
|
-
hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
|
|
806
|
+
hostRef.$flags$ |= 16 /* HOST_FLAGS.isQueuedForUpdate */;
|
|
657
807
|
}
|
|
658
|
-
if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
|
|
659
|
-
hostRef.$flags$ |= 512 /* needsRerender */;
|
|
808
|
+
if (hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
|
|
809
|
+
hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
|
|
660
810
|
return;
|
|
661
811
|
}
|
|
662
812
|
attachToAncestor(hostRef, hostRef.$ancestorComponent$);
|
|
@@ -672,7 +822,7 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
|
|
|
672
822
|
let promise;
|
|
673
823
|
if (isInitialLoad) {
|
|
674
824
|
{
|
|
675
|
-
hostRef.$flags$ |= 256 /* isListenReady */;
|
|
825
|
+
hostRef.$flags$ |= 256 /* HOST_FLAGS.isListenReady */;
|
|
676
826
|
if (hostRef.$queuedListeners$) {
|
|
677
827
|
hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
|
|
678
828
|
hostRef.$queuedListeners$ = null;
|
|
@@ -718,7 +868,7 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
|
|
|
718
868
|
}
|
|
719
869
|
else {
|
|
720
870
|
Promise.all(childrenPromises).then(postUpdate);
|
|
721
|
-
hostRef.$flags$ |= 4 /* isWaitingForChildren */;
|
|
871
|
+
hostRef.$flags$ |= 4 /* HOST_FLAGS.isWaitingForChildren */;
|
|
722
872
|
childrenPromises.length = 0;
|
|
723
873
|
}
|
|
724
874
|
}
|
|
@@ -728,10 +878,10 @@ const callRender = (hostRef, instance, elm) => {
|
|
|
728
878
|
renderingRef = instance;
|
|
729
879
|
instance = instance.render() ;
|
|
730
880
|
{
|
|
731
|
-
hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
|
|
881
|
+
hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
|
|
732
882
|
}
|
|
733
883
|
{
|
|
734
|
-
hostRef.$flags$ |= 2 /* hasRendered */;
|
|
884
|
+
hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
|
|
735
885
|
}
|
|
736
886
|
{
|
|
737
887
|
{
|
|
@@ -757,8 +907,8 @@ const postUpdateComponent = (hostRef) => {
|
|
|
757
907
|
const endPostUpdate = createTime('postUpdate', tagName);
|
|
758
908
|
const instance = hostRef.$lazyInstance$ ;
|
|
759
909
|
const ancestorComponent = hostRef.$ancestorComponent$;
|
|
760
|
-
if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
|
|
761
|
-
hostRef.$flags$ |= 64 /* hasLoadedComponent */;
|
|
910
|
+
if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
|
|
911
|
+
hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
|
|
762
912
|
{
|
|
763
913
|
// DOM WRITE!
|
|
764
914
|
addHydratedFlag(elm);
|
|
@@ -784,10 +934,10 @@ const postUpdateComponent = (hostRef) => {
|
|
|
784
934
|
hostRef.$onRenderResolve$();
|
|
785
935
|
hostRef.$onRenderResolve$ = undefined;
|
|
786
936
|
}
|
|
787
|
-
if (hostRef.$flags$ & 512 /* needsRerender */) {
|
|
937
|
+
if (hostRef.$flags$ & 512 /* HOST_FLAGS.needsRerender */) {
|
|
788
938
|
nextTick(() => scheduleUpdate(hostRef, false));
|
|
789
939
|
}
|
|
790
|
-
hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
|
|
940
|
+
hostRef.$flags$ &= ~(4 /* HOST_FLAGS.isWaitingForChildren */ | 512 /* HOST_FLAGS.needsRerender */);
|
|
791
941
|
}
|
|
792
942
|
// ( •_•)
|
|
793
943
|
// ( •_•)>⌐■-■
|
|
@@ -798,7 +948,7 @@ const forceUpdate = (ref) => {
|
|
|
798
948
|
const hostRef = getHostRef(ref);
|
|
799
949
|
const isConnected = hostRef.$hostElement$.isConnected;
|
|
800
950
|
if (isConnected &&
|
|
801
|
-
(hostRef.$flags$ & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
|
|
951
|
+
(hostRef.$flags$ & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
|
|
802
952
|
scheduleUpdate(hostRef, false);
|
|
803
953
|
}
|
|
804
954
|
// Returns "true" when the forced update was successfully scheduled
|
|
@@ -829,53 +979,6 @@ const then = (promise, thenFn) => {
|
|
|
829
979
|
};
|
|
830
980
|
const addHydratedFlag = (elm) => elm.classList.add('hydrated')
|
|
831
981
|
;
|
|
832
|
-
/**
|
|
833
|
-
* Parse a new property value for a given property type.
|
|
834
|
-
*
|
|
835
|
-
* While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
|
|
836
|
-
* it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
|
|
837
|
-
* 1. `any`, the type given to `propValue` in the function signature
|
|
838
|
-
* 2. the type stored from `propType`.
|
|
839
|
-
*
|
|
840
|
-
* This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
|
|
841
|
-
*
|
|
842
|
-
* Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
|
|
843
|
-
* a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
|
|
844
|
-
* based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
|
|
845
|
-
* ```tsx
|
|
846
|
-
* <my-cmp prop-val={0}></my-cmp>
|
|
847
|
-
* ```
|
|
848
|
-
*
|
|
849
|
-
* HTML prop values on the other hand, will always a string
|
|
850
|
-
*
|
|
851
|
-
* @param propValue the new value to coerce to some type
|
|
852
|
-
* @param propType the type of the prop, expressed as a binary number
|
|
853
|
-
* @returns the parsed/coerced value
|
|
854
|
-
*/
|
|
855
|
-
const parsePropertyValue = (propValue, propType) => {
|
|
856
|
-
// ensure this value is of the correct prop type
|
|
857
|
-
if (propValue != null && !isComplexType(propValue)) {
|
|
858
|
-
if (propType & 4 /* Boolean */) {
|
|
859
|
-
// per the HTML spec, any string value means it is a boolean true value
|
|
860
|
-
// but we'll cheat here and say that the string "false" is the boolean false
|
|
861
|
-
return propValue === 'false' ? false : propValue === '' || !!propValue;
|
|
862
|
-
}
|
|
863
|
-
if (propType & 2 /* Number */) {
|
|
864
|
-
// force it to be a number
|
|
865
|
-
return parseFloat(propValue);
|
|
866
|
-
}
|
|
867
|
-
if (propType & 1 /* String */) {
|
|
868
|
-
// could have been passed as a number or boolean
|
|
869
|
-
// but we still want it as a string
|
|
870
|
-
return String(propValue);
|
|
871
|
-
}
|
|
872
|
-
// redundant return here for better minification
|
|
873
|
-
return propValue;
|
|
874
|
-
}
|
|
875
|
-
// not sure exactly what type we want
|
|
876
|
-
// so no need to change to a different type
|
|
877
|
-
return propValue;
|
|
878
|
-
};
|
|
879
982
|
const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
|
|
880
983
|
const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
881
984
|
// check our new property value against our internal value
|
|
@@ -888,13 +991,13 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
888
991
|
// explicitly check for NaN on both sides, as `NaN === NaN` is always false
|
|
889
992
|
const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
|
|
890
993
|
const didValueChange = newVal !== oldVal && !areBothNaN;
|
|
891
|
-
if ((!(flags & 8 /* isConstructingInstance */) || oldVal === undefined) && didValueChange) {
|
|
994
|
+
if ((!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
|
|
892
995
|
// gadzooks! the property's value has changed!!
|
|
893
996
|
// set our new value!
|
|
894
997
|
hostRef.$instanceValues$.set(propName, newVal);
|
|
895
998
|
if (instance) {
|
|
896
999
|
// get an array of method names of watch functions to call
|
|
897
|
-
if (cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
|
|
1000
|
+
if (cmpMeta.$watchers$ && flags & 128 /* HOST_FLAGS.isWatchReady */) {
|
|
898
1001
|
const watchMethods = cmpMeta.$watchers$[propName];
|
|
899
1002
|
if (watchMethods) {
|
|
900
1003
|
// this instance is watching for when this property changed
|
|
@@ -909,7 +1012,7 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
909
1012
|
});
|
|
910
1013
|
}
|
|
911
1014
|
}
|
|
912
|
-
if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
|
|
1015
|
+
if ((flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
|
|
913
1016
|
// looks like this value actually changed, so we've got work to do!
|
|
914
1017
|
// but only if we've already rendered, otherwise just chill out
|
|
915
1018
|
// queue that we need to do an update, but don't worry about queuing
|
|
@@ -919,6 +1022,16 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
919
1022
|
}
|
|
920
1023
|
}
|
|
921
1024
|
};
|
|
1025
|
+
/**
|
|
1026
|
+
* Attach a series of runtime constructs to a compiled Stencil component
|
|
1027
|
+
* constructor, including getters and setters for the `@Prop` and `@State`
|
|
1028
|
+
* decorators, callbacks for when attributes change, and so on.
|
|
1029
|
+
*
|
|
1030
|
+
* @param Cstr the constructor for a component that we need to process
|
|
1031
|
+
* @param cmpMeta metadata collected previously about the component
|
|
1032
|
+
* @param flags a number used to store a series of bit flags
|
|
1033
|
+
* @returns a reference to the same constructor passed in (but now mutated)
|
|
1034
|
+
*/
|
|
922
1035
|
const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
923
1036
|
if (cmpMeta.$members$) {
|
|
924
1037
|
if (Cstr.watchers) {
|
|
@@ -928,8 +1041,8 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
928
1041
|
const members = Object.entries(cmpMeta.$members$);
|
|
929
1042
|
const prototype = Cstr.prototype;
|
|
930
1043
|
members.map(([memberName, [memberFlags]]) => {
|
|
931
|
-
if ((memberFlags & 31 /* Prop */ ||
|
|
932
|
-
((flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
|
|
1044
|
+
if ((memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
|
|
1045
|
+
((flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
|
|
933
1046
|
// proxyComponent - prop
|
|
934
1047
|
Object.defineProperty(prototype, memberName, {
|
|
935
1048
|
get() {
|
|
@@ -945,7 +1058,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
945
1058
|
});
|
|
946
1059
|
}
|
|
947
1060
|
});
|
|
948
|
-
if ((flags & 1 /* isElementConstructor */)) {
|
|
1061
|
+
if ((flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
|
|
949
1062
|
const attrNameToPropName = new Map();
|
|
950
1063
|
prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
|
|
951
1064
|
plt.jmp(() => {
|
|
@@ -1001,7 +1114,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1001
1114
|
// create an array of attributes to observe
|
|
1002
1115
|
// and also create a map of html attribute name to js property name
|
|
1003
1116
|
Cstr.observedAttributes = members
|
|
1004
|
-
.filter(([_, m]) => m[0] & 15 /* HasAttribute */) // filter to only keep props that should match attributes
|
|
1117
|
+
.filter(([_, m]) => m[0] & 15 /* MEMBER_FLAGS.HasAttribute */) // filter to only keep props that should match attributes
|
|
1005
1118
|
.map(([propName, m]) => {
|
|
1006
1119
|
const attrName = m[1] || propName;
|
|
1007
1120
|
attrNameToPropName.set(attrName, propName);
|
|
@@ -1013,10 +1126,10 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1013
1126
|
};
|
|
1014
1127
|
const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
|
|
1015
1128
|
// initializeComponent
|
|
1016
|
-
if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
|
|
1129
|
+
if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
|
|
1017
1130
|
{
|
|
1018
1131
|
// we haven't initialized this element yet
|
|
1019
|
-
hostRef.$flags$ |= 32 /* hasInitializedComponent */;
|
|
1132
|
+
hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
|
|
1020
1133
|
// lazy loaded components
|
|
1021
1134
|
// request the component's implementation to be
|
|
1022
1135
|
// wired up with the host element
|
|
@@ -1034,7 +1147,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1034
1147
|
{
|
|
1035
1148
|
cmpMeta.$watchers$ = Cstr.watchers;
|
|
1036
1149
|
}
|
|
1037
|
-
proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
|
|
1150
|
+
proxyComponent(Cstr, cmpMeta, 2 /* PROXY_FLAGS.proxyState */);
|
|
1038
1151
|
Cstr.isProxied = true;
|
|
1039
1152
|
}
|
|
1040
1153
|
const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
|
|
@@ -1042,7 +1155,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1042
1155
|
// but let's keep track of when we start and stop
|
|
1043
1156
|
// so that the getters/setters don't incorrectly step on data
|
|
1044
1157
|
{
|
|
1045
|
-
hostRef.$flags$ |= 8 /* isConstructingInstance */;
|
|
1158
|
+
hostRef.$flags$ |= 8 /* HOST_FLAGS.isConstructingInstance */;
|
|
1046
1159
|
}
|
|
1047
1160
|
// construct the lazy-loaded component implementation
|
|
1048
1161
|
// passing the hostRef is very important during
|
|
@@ -1055,10 +1168,10 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1055
1168
|
consoleError(e);
|
|
1056
1169
|
}
|
|
1057
1170
|
{
|
|
1058
|
-
hostRef.$flags$ &= ~8 /* isConstructingInstance */;
|
|
1171
|
+
hostRef.$flags$ &= ~8 /* HOST_FLAGS.isConstructingInstance */;
|
|
1059
1172
|
}
|
|
1060
1173
|
{
|
|
1061
|
-
hostRef.$flags$ |= 128 /* isWatchReady */;
|
|
1174
|
+
hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */;
|
|
1062
1175
|
}
|
|
1063
1176
|
endNewInstance();
|
|
1064
1177
|
fireConnectedCallback(hostRef.$lazyInstance$);
|
|
@@ -1069,10 +1182,10 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1069
1182
|
const scopeId = getScopeId(cmpMeta);
|
|
1070
1183
|
if (!styles.has(scopeId)) {
|
|
1071
1184
|
const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
|
|
1072
|
-
if (cmpMeta.$flags$ & 8 /* needsShadowDomShim */) {
|
|
1073
|
-
style = await import('./shadow-css-
|
|
1185
|
+
if (cmpMeta.$flags$ & 8 /* CMP_FLAGS.needsShadowDomShim */) {
|
|
1186
|
+
style = await import('./shadow-css-b18e99d7.js').then((m) => m.scopeCss(style, scopeId, false));
|
|
1074
1187
|
}
|
|
1075
|
-
registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
|
|
1188
|
+
registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
|
|
1076
1189
|
endRegisterStyles();
|
|
1077
1190
|
}
|
|
1078
1191
|
}
|
|
@@ -1099,13 +1212,13 @@ const fireConnectedCallback = (instance) => {
|
|
|
1099
1212
|
}
|
|
1100
1213
|
};
|
|
1101
1214
|
const connectedCallback = (elm) => {
|
|
1102
|
-
if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
|
|
1215
|
+
if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
|
|
1103
1216
|
const hostRef = getHostRef(elm);
|
|
1104
1217
|
const cmpMeta = hostRef.$cmpMeta$;
|
|
1105
1218
|
const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
|
|
1106
|
-
if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
|
|
1219
|
+
if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
|
|
1107
1220
|
// first time this component has connected
|
|
1108
|
-
hostRef.$flags$ |= 1 /* hasConnected */;
|
|
1221
|
+
hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
|
|
1109
1222
|
{
|
|
1110
1223
|
// find the first ancestor component (if there is one) and register
|
|
1111
1224
|
// this component as one of the actively loading child components for its ancestor
|
|
@@ -1125,7 +1238,7 @@ const connectedCallback = (elm) => {
|
|
|
1125
1238
|
// https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
|
|
1126
1239
|
if (cmpMeta.$members$) {
|
|
1127
1240
|
Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
|
|
1128
|
-
if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
|
|
1241
|
+
if (memberFlags & 31 /* MEMBER_FLAGS.Prop */ && elm.hasOwnProperty(memberName)) {
|
|
1129
1242
|
const value = elm[memberName];
|
|
1130
1243
|
delete elm[memberName];
|
|
1131
1244
|
elm[memberName] = value;
|
|
@@ -1148,7 +1261,7 @@ const connectedCallback = (elm) => {
|
|
|
1148
1261
|
}
|
|
1149
1262
|
};
|
|
1150
1263
|
const disconnectedCallback = (elm) => {
|
|
1151
|
-
if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
|
|
1264
|
+
if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
|
|
1152
1265
|
const hostRef = getHostRef(elm);
|
|
1153
1266
|
const instance = hostRef.$lazyInstance$ ;
|
|
1154
1267
|
{
|
|
@@ -1172,7 +1285,7 @@ const patchChildSlotNodes = (elm, cmpMeta) => {
|
|
|
1172
1285
|
return this[n];
|
|
1173
1286
|
}
|
|
1174
1287
|
}
|
|
1175
|
-
if (cmpMeta.$flags$ & 8 /* needsShadowDomShim */) {
|
|
1288
|
+
if (cmpMeta.$flags$ & 8 /* CMP_FLAGS.needsShadowDomShim */) {
|
|
1176
1289
|
const childNodesFn = elm.__lookupGetter__('childNodes');
|
|
1177
1290
|
Object.defineProperty(elm, 'children', {
|
|
1178
1291
|
get() {
|
|
@@ -1187,8 +1300,8 @@ const patchChildSlotNodes = (elm, cmpMeta) => {
|
|
|
1187
1300
|
Object.defineProperty(elm, 'childNodes', {
|
|
1188
1301
|
get() {
|
|
1189
1302
|
const childNodes = childNodesFn.call(this);
|
|
1190
|
-
if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0 &&
|
|
1191
|
-
getHostRef(this).$flags$ & 2 /* hasRendered */) {
|
|
1303
|
+
if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0 &&
|
|
1304
|
+
getHostRef(this).$flags$ & 2 /* HOST_FLAGS.hasRendered */) {
|
|
1192
1305
|
const result = new FakeNodeList();
|
|
1193
1306
|
for (let i = 0; i < childNodes.length; i++) {
|
|
1194
1307
|
const slot = childNodes[i]['s-nr'];
|
|
@@ -1233,8 +1346,8 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1233
1346
|
{
|
|
1234
1347
|
cmpMeta.$watchers$ = {};
|
|
1235
1348
|
}
|
|
1236
|
-
if (!supportsShadow && cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
|
|
1237
|
-
cmpMeta.$flags$ |= 8 /* needsShadowDomShim */;
|
|
1349
|
+
if (!supportsShadow && cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
|
|
1350
|
+
cmpMeta.$flags$ |= 8 /* CMP_FLAGS.needsShadowDomShim */;
|
|
1238
1351
|
}
|
|
1239
1352
|
const tagName = cmpMeta.$tagName$;
|
|
1240
1353
|
const HostElement = class extends HTMLElement {
|
|
@@ -1244,7 +1357,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1244
1357
|
super(self);
|
|
1245
1358
|
self = this;
|
|
1246
1359
|
registerHost(self, cmpMeta);
|
|
1247
|
-
if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
|
|
1360
|
+
if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
|
|
1248
1361
|
// this component is using shadow dom
|
|
1249
1362
|
// and this browser supports shadow dom
|
|
1250
1363
|
// add the read-only property "shadowRoot" to the host element
|
|
@@ -1285,7 +1398,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1285
1398
|
cmpMeta.$lazyBundleId$ = lazyBundle[0];
|
|
1286
1399
|
if (!exclude.includes(tagName) && !customElements.get(tagName)) {
|
|
1287
1400
|
cmpTags.push(tagName);
|
|
1288
|
-
customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
|
|
1401
|
+
customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */));
|
|
1289
1402
|
}
|
|
1290
1403
|
});
|
|
1291
1404
|
});
|
|
@@ -1307,7 +1420,41 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1307
1420
|
// Fallback appLoad event
|
|
1308
1421
|
endBootstrap();
|
|
1309
1422
|
};
|
|
1310
|
-
const
|
|
1423
|
+
const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
|
|
1424
|
+
if (listeners) {
|
|
1425
|
+
listeners.map(([flags, name, method]) => {
|
|
1426
|
+
const target = getHostListenerTarget(elm, flags) ;
|
|
1427
|
+
const handler = hostListenerProxy(hostRef, method);
|
|
1428
|
+
const opts = hostListenerOpts(flags);
|
|
1429
|
+
plt.ael(target, name, handler, opts);
|
|
1430
|
+
(hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
|
|
1431
|
+
});
|
|
1432
|
+
}
|
|
1433
|
+
};
|
|
1434
|
+
const hostListenerProxy = (hostRef, methodName) => (ev) => {
|
|
1435
|
+
try {
|
|
1436
|
+
{
|
|
1437
|
+
if (hostRef.$flags$ & 256 /* HOST_FLAGS.isListenReady */) {
|
|
1438
|
+
// instance is ready, let's call it's member method for this event
|
|
1439
|
+
hostRef.$lazyInstance$[methodName](ev);
|
|
1440
|
+
}
|
|
1441
|
+
else {
|
|
1442
|
+
(hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
|
|
1443
|
+
}
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
catch (e) {
|
|
1447
|
+
consoleError(e);
|
|
1448
|
+
}
|
|
1449
|
+
};
|
|
1450
|
+
const getHostListenerTarget = (elm, flags) => {
|
|
1451
|
+
if (flags & 8 /* LISTENER_FLAGS.TargetWindow */)
|
|
1452
|
+
return win;
|
|
1453
|
+
return elm;
|
|
1454
|
+
};
|
|
1455
|
+
// prettier-ignore
|
|
1456
|
+
const hostListenerOpts = (flags) => (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0;
|
|
1457
|
+
const hostRefs = /*@__PURE__*/ new WeakMap();
|
|
1311
1458
|
const getHostRef = (ref) => hostRefs.get(ref);
|
|
1312
1459
|
const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
|
|
1313
1460
|
const registerHost = (elm, cmpMeta) => {
|
|
@@ -1349,14 +1496,38 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
|
|
|
1349
1496
|
return importedModule[exportName];
|
|
1350
1497
|
}, consoleError);
|
|
1351
1498
|
};
|
|
1352
|
-
const styles = new Map();
|
|
1499
|
+
const styles = /*@__PURE__*/ new Map();
|
|
1500
|
+
const win = typeof window !== 'undefined' ? window : {};
|
|
1501
|
+
const CSS = win.CSS ;
|
|
1502
|
+
const doc = win.document || { head: {} };
|
|
1503
|
+
const plt = {
|
|
1504
|
+
$flags$: 0,
|
|
1505
|
+
$resourcesUrl$: '',
|
|
1506
|
+
jmp: (h) => h(),
|
|
1507
|
+
raf: (h) => requestAnimationFrame(h),
|
|
1508
|
+
ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
|
|
1509
|
+
rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
|
|
1510
|
+
ce: (eventName, opts) => new CustomEvent(eventName, opts),
|
|
1511
|
+
};
|
|
1512
|
+
const supportsShadow = /*@__PURE__*/ (() => (doc.head.attachShadow + '').indexOf('[native') > -1)()
|
|
1513
|
+
;
|
|
1514
|
+
const promiseResolve = (v) => Promise.resolve(v);
|
|
1515
|
+
const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
|
|
1516
|
+
try {
|
|
1517
|
+
new CSSStyleSheet();
|
|
1518
|
+
return typeof new CSSStyleSheet().replaceSync === 'function';
|
|
1519
|
+
}
|
|
1520
|
+
catch (e) { }
|
|
1521
|
+
return false;
|
|
1522
|
+
})()
|
|
1523
|
+
;
|
|
1353
1524
|
const queueDomReads = [];
|
|
1354
1525
|
const queueDomWrites = [];
|
|
1355
1526
|
const queueTask = (queue, write) => (cb) => {
|
|
1356
1527
|
queue.push(cb);
|
|
1357
1528
|
if (!queuePending) {
|
|
1358
1529
|
queuePending = true;
|
|
1359
|
-
if (write && plt.$flags$ & 4 /* queueSync */) {
|
|
1530
|
+
if (write && plt.$flags$ & 4 /* PLATFORM_FLAGS.queueSync */) {
|
|
1360
1531
|
nextTick(flush);
|
|
1361
1532
|
}
|
|
1362
1533
|
else {
|