@sme.up/ketchup 6.5.0 → 6.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -1
- package/dist/cjs/{f-button-4e2a0bb6.js → f-button-bf76ab95.js} +2 -2
- package/dist/cjs/{f-cell-1fc8a8b6.js → f-cell-b7a1524a.js} +25 -23
- package/dist/cjs/{f-checkbox-cd977193.js → f-checkbox-1097ca5d.js} +1 -1
- package/dist/cjs/{f-chip-7867f17b.js → f-chip-a5e100b1.js} +3 -3
- package/dist/cjs/{f-image-6b7a6168.js → f-image-d80a2749.js} +2 -2
- package/dist/cjs/{f-paginator-utils-b7712403.js → f-paginator-utils-c70812fe.js} +3 -5
- package/dist/cjs/{f-text-field-153e827c.js → f-text-field-48b8bb16.js} +2 -2
- package/dist/cjs/{index-31125378.js → index-ffdb46f6.js} +423 -252
- package/dist/cjs/ketchup.cjs.js +3 -3
- package/dist/cjs/kup-accordion.cjs.entry.js +3 -3
- package/dist/cjs/kup-autocomplete_25.cjs.entry.js +433 -163
- package/dist/cjs/kup-box.cjs.entry.js +27 -16
- package/dist/cjs/kup-calendar.cjs.entry.js +5 -5
- package/dist/cjs/kup-cell.cjs.entry.js +7 -7
- package/dist/cjs/kup-dash-list.cjs.entry.js +2 -2
- package/dist/cjs/kup-dash_2.cjs.entry.js +2 -2
- package/dist/cjs/kup-dashboard.cjs.entry.js +6 -6
- package/dist/cjs/kup-drawer.cjs.entry.js +2 -2
- package/dist/cjs/kup-echart.cjs.entry.js +2 -2
- package/dist/cjs/kup-family-tree.cjs.entry.js +19 -7
- package/dist/cjs/kup-form.cjs.entry.js +8 -8
- package/dist/cjs/kup-iframe.cjs.entry.js +2 -2
- package/dist/cjs/kup-image-list.cjs.entry.js +9 -9
- package/dist/cjs/kup-lazy.cjs.entry.js +2 -2
- package/dist/cjs/kup-magic-box.cjs.entry.js +3 -3
- package/dist/cjs/{kup-manager-cfe2f36e.js → kup-manager-0e38bf48.js} +39 -26
- package/dist/cjs/kup-nav-bar.cjs.entry.js +2 -2
- package/dist/cjs/kup-numeric-picker.cjs.entry.js +3 -3
- package/dist/cjs/kup-photo-frame.cjs.entry.js +2 -2
- package/dist/cjs/kup-probe.cjs.entry.js +2 -2
- package/dist/cjs/kup-qlik.cjs.entry.js +2 -2
- package/dist/cjs/kup-snackbar.cjs.entry.js +4 -4
- package/dist/cjs/loader.cjs.js +3 -3
- package/dist/collection/assets/box.js +9 -6
- package/dist/collection/assets/card.js +12 -2
- package/dist/collection/collection-manifest.json +3 -3
- package/dist/collection/components/kup-accordion/kup-accordion.js +239 -234
- package/dist/collection/components/kup-autocomplete/kup-autocomplete.js +545 -530
- package/dist/collection/components/kup-badge/kup-badge.js +176 -170
- package/dist/collection/components/kup-box/kup-box.js +907 -913
- package/dist/collection/components/kup-button/kup-button.css +1 -0
- package/dist/collection/components/kup-button/kup-button.js +379 -370
- package/dist/collection/components/kup-button-list/kup-button-list.js +251 -240
- package/dist/collection/components/kup-calendar/kup-calendar.js +301 -300
- package/dist/collection/components/kup-card/box/kup-card-box.js +115 -0
- package/dist/collection/components/kup-card/built-in/kup-card-calendar.js +14 -28
- package/dist/collection/components/kup-card/built-in/kup-card-clock.js +6 -19
- package/dist/collection/components/kup-card/built-in/kup-card-column-drop-menu.js +1 -2
- package/dist/collection/components/kup-card/built-in/kup-card-numeric.js +9 -44
- package/dist/collection/components/kup-card/collapsible/kup-card-collapsible.js +2 -21
- package/dist/collection/components/kup-card/dialog/kup-card-dialog.js +6 -33
- package/dist/collection/components/kup-card/kup-card-declarations.js +2 -0
- package/dist/collection/components/kup-card/kup-card-helper.js +3 -8
- package/dist/collection/components/kup-card/kup-card.css +140 -20
- package/dist/collection/components/kup-card/kup-card.js +352 -340
- package/dist/collection/components/kup-card/scalable/kup-card-scalable.js +68 -81
- package/dist/collection/components/kup-card/standard/kup-card-standard.js +96 -304
- package/dist/collection/components/kup-cell/kup-cell.js +221 -216
- package/dist/collection/components/kup-chart/kup-chart.js +547 -537
- package/dist/collection/components/kup-checkbox/kup-checkbox.js +275 -266
- package/dist/collection/components/kup-chip/kup-chip.js +240 -231
- package/dist/collection/components/kup-color-picker/kup-color-picker.js +274 -264
- package/dist/collection/components/kup-combobox/kup-combobox.js +458 -440
- package/dist/collection/components/kup-dash/kup-dash.js +110 -158
- package/dist/collection/components/kup-dash-list/kup-dash-list.js +210 -213
- package/dist/collection/components/kup-dashboard/kup-dashboard.js +196 -203
- package/dist/collection/components/kup-data-table/kup-data-table.js +1932 -1838
- package/dist/collection/components/kup-date-picker/kup-date-picker.js +408 -394
- package/dist/collection/components/kup-drawer/kup-drawer.js +244 -236
- package/dist/collection/components/kup-dropdown-button/kup-dropdown-button.js +474 -464
- package/dist/collection/components/kup-echart/kup-echart.js +436 -423
- package/dist/collection/components/kup-family-tree/kup-family-tree-declarations.js +1 -0
- package/dist/collection/components/kup-family-tree/kup-family-tree.js +420 -398
- package/dist/collection/components/kup-form/kup-form.js +223 -225
- package/dist/collection/components/kup-gauge/kup-gauge.js +445 -445
- package/dist/collection/components/kup-grid/kup-grid.js +156 -153
- package/dist/collection/components/kup-iframe/kup-iframe.js +181 -173
- package/dist/collection/components/kup-image/canvas/kup-image-canvas.js +9 -3
- package/dist/collection/components/kup-image/kup-image.js +300 -295
- package/dist/collection/components/kup-image-list/kup-image-list.js +292 -285
- package/dist/collection/components/kup-lazy/kup-lazy.js +253 -253
- package/dist/collection/components/kup-list/kup-list.js +541 -504
- package/dist/collection/components/kup-magic-box/kup-magic-box.js +145 -145
- package/dist/collection/components/kup-nav-bar/kup-nav-bar.js +190 -184
- package/dist/collection/components/kup-numeric-picker/kup-numeric-picker.js +490 -478
- package/dist/collection/components/kup-photo-frame/kup-photo-frame.js +254 -242
- package/dist/collection/components/kup-probe/kup-probe.js +87 -83
- package/dist/collection/components/kup-progress-bar/kup-progress-bar.js +237 -241
- package/dist/collection/components/kup-qlik/kup-qlik.js +178 -170
- package/dist/collection/components/kup-radio/kup-radio.js +258 -255
- package/dist/collection/components/kup-rating/kup-rating.js +208 -197
- package/dist/collection/components/kup-snackbar/kup-snackbar.js +249 -246
- package/dist/collection/components/kup-spinner/kup-spinner.js +274 -269
- package/dist/collection/components/kup-switch/kup-switch.js +255 -246
- package/dist/collection/components/kup-tab-bar/kup-tab-bar.js +265 -224
- package/dist/collection/components/kup-text-field/kup-text-field.js +814 -805
- package/dist/collection/components/kup-time-picker/kup-time-picker.js +464 -450
- package/dist/collection/components/kup-tree/kup-tree-declarations.js +0 -2
- package/dist/collection/components/kup-tree/kup-tree-faker.js +3 -2
- package/dist/collection/components/kup-tree/kup-tree.js +1134 -1133
- package/dist/collection/f-components/f-button/f-button.js +11 -20
- package/dist/collection/f-components/f-cell/f-cell.js +23 -23
- package/dist/collection/f-components/f-checkbox/f-checkbox.js +1 -9
- package/dist/collection/f-components/f-chip/f-chip.js +18 -31
- package/dist/collection/f-components/f-image/f-image.js +1 -3
- package/dist/collection/f-components/f-paginator/f-paginator.js +1 -6
- package/dist/collection/f-components/f-switch/f-switch.js +1 -8
- package/dist/collection/f-components/f-text-field/f-text-field.js +18 -40
- package/dist/collection/managers/kup-debug/kup-debug.js +10 -5
- package/dist/collection/managers/kup-scroll-on-hover/kup-scroll-on-hover.js +25 -10
- package/dist/collection/managers/kup-theme/kup-theme-declarations.js +1 -0
- package/dist/collection/managers/kup-toolbar/kup-toolbar.js +10 -5
- package/dist/collection/managers/kup-tooltip/kup-tooltip.js +10 -5
- package/dist/collection/utils/kup-column-menu/kup-column-menu.js +0 -21
- package/dist/esm/{f-button-a24e43dd.js → f-button-e79f7594.js} +2 -2
- package/dist/esm/{f-cell-ebbb0c06.js → f-cell-9400374e.js} +25 -23
- package/dist/esm/{f-checkbox-e06cf07b.js → f-checkbox-b721178e.js} +1 -1
- package/dist/esm/{f-chip-e2c38ba8.js → f-chip-bf740287.js} +3 -3
- package/dist/esm/{f-image-7e02e88f.js → f-image-ab3dc8cb.js} +2 -2
- package/dist/esm/{f-paginator-utils-e6d2638f.js → f-paginator-utils-6909e43b.js} +3 -5
- package/dist/esm/{f-text-field-8438a278.js → f-text-field-4841dfea.js} +2 -2
- package/dist/esm/{index-e41330a5.js → index-a2197376.js} +423 -252
- package/dist/esm/ketchup.js +3 -3
- package/dist/esm/kup-accordion.entry.js +3 -3
- package/dist/esm/kup-autocomplete_25.entry.js +433 -163
- package/dist/esm/kup-box.entry.js +27 -16
- package/dist/esm/kup-calendar.entry.js +5 -5
- package/dist/esm/kup-cell.entry.js +7 -7
- package/dist/esm/kup-dash-list.entry.js +2 -2
- package/dist/esm/kup-dash_2.entry.js +2 -2
- package/dist/esm/kup-dashboard.entry.js +6 -6
- package/dist/esm/kup-drawer.entry.js +2 -2
- package/dist/esm/kup-echart.entry.js +2 -2
- package/dist/esm/kup-family-tree.entry.js +19 -7
- package/dist/esm/kup-form.entry.js +8 -8
- package/dist/esm/kup-iframe.entry.js +2 -2
- package/dist/esm/kup-image-list.entry.js +9 -9
- package/dist/esm/kup-lazy.entry.js +2 -2
- package/dist/esm/kup-magic-box.entry.js +3 -3
- package/dist/esm/{kup-manager-7c27e90e.js → kup-manager-c54e6df5.js} +22 -9
- package/dist/esm/kup-nav-bar.entry.js +2 -2
- package/dist/esm/kup-numeric-picker.entry.js +3 -3
- package/dist/esm/kup-photo-frame.entry.js +2 -2
- package/dist/esm/kup-probe.entry.js +2 -2
- package/dist/esm/kup-qlik.entry.js +2 -2
- package/dist/esm/kup-snackbar.entry.js +4 -4
- package/dist/esm/loader.js +3 -3
- package/dist/esm/polyfills/css-shim.js +1 -1
- package/dist/ketchup/ketchup.esm.js +1 -1
- package/dist/ketchup/{p-191096ff.entry.js → p-182b869e.entry.js} +1 -1
- package/dist/ketchup/p-1dfd2a51.js +30 -0
- package/dist/ketchup/{p-b502b91b.entry.js → p-1f5c7f21.entry.js} +1 -1
- package/dist/ketchup/p-22ec1ba0.entry.js +9 -0
- package/dist/ketchup/{p-5552f156.js → p-23cd5a68.js} +1 -1
- package/dist/ketchup/{p-26acb448.js → p-25bf0cb6.js} +1 -1
- package/dist/ketchup/{p-601a50db.entry.js → p-260ff835.entry.js} +1 -1
- package/dist/ketchup/{p-5a703573.entry.js → p-2e184b57.entry.js} +1 -1
- package/dist/ketchup/{p-45415b72.entry.js → p-30a63b85.entry.js} +1 -1
- package/dist/ketchup/{p-cc663bad.entry.js → p-313e376b.entry.js} +1 -1
- package/dist/ketchup/{p-e0ed3fd7.entry.js → p-41620707.entry.js} +1 -1
- package/dist/ketchup/{p-25875aa1.entry.js → p-4a0ccf18.entry.js} +1 -1
- package/dist/ketchup/{p-3decc8e4.js → p-4f0d3062.js} +1 -1
- package/dist/ketchup/p-4fdb684f.js +2 -0
- package/dist/ketchup/{p-52590a90.entry.js → p-53d3ae80.entry.js} +1 -1
- package/dist/ketchup/{p-92595296.js → p-5bea2971.js} +1 -1
- package/dist/ketchup/{p-a782ebd1.entry.js → p-60fa0ccf.entry.js} +1 -1
- package/dist/ketchup/p-6333388c.js +1 -0
- package/dist/ketchup/{p-2003a841.entry.js → p-6bd57787.entry.js} +1 -1
- package/dist/ketchup/p-758d03f4.entry.js +1 -0
- package/dist/ketchup/{p-2f009c42.entry.js → p-7e7b6127.entry.js} +1 -1
- package/dist/ketchup/p-8386e3db.entry.js +1 -0
- package/dist/ketchup/{p-23111c8d.entry.js → p-859163c2.entry.js} +1 -1
- package/dist/ketchup/{p-97f28bbd.entry.js → p-8e1fa7a8.entry.js} +6 -6
- package/dist/ketchup/{p-ca98059c.entry.js → p-90860d9e.entry.js} +1 -1
- package/dist/ketchup/{p-b131b257.entry.js → p-b7fdc7aa.entry.js} +1 -1
- package/dist/ketchup/{p-3138cabb.entry.js → p-bffaef6e.entry.js} +1 -1
- package/dist/ketchup/p-c35c5e05.js +1 -0
- package/dist/ketchup/{p-1468bf09.js → p-e1d0ea71.js} +1 -1
- package/dist/ketchup/p-f9d5e553.entry.js +1 -0
- package/dist/ketchup/{p-69dd11da.entry.js → p-fb4d772a.entry.js} +1 -1
- package/dist/loader/package.json +1 -0
- package/dist/types/components/kup-box/kup-box-declarations.d.ts +3 -0
- package/dist/types/components/kup-card/box/kup-card-box.d.ts +26 -0
- package/dist/types/components/kup-card/kup-card-declarations.d.ts +2 -0
- package/dist/types/components/kup-card/scalable/kup-card-scalable.d.ts +6 -0
- package/dist/types/components/kup-card/standard/kup-card-standard.d.ts +0 -6
- package/dist/types/components/kup-combobox/kup-combobox-declarations.d.ts +3 -1
- package/dist/types/components/kup-data-table/kup-data-table.d.ts +15 -1
- package/dist/types/components/kup-family-tree/kup-family-tree-declarations.d.ts +1 -0
- package/dist/types/components/kup-family-tree/kup-family-tree.d.ts +5 -0
- package/dist/types/components/kup-list/kup-list.d.ts +5 -0
- package/dist/types/components/kup-tab-bar/kup-tab-bar.d.ts +5 -0
- package/dist/types/components/kup-tree/kup-tree-declarations.d.ts +0 -4
- package/dist/types/components/kup-tree/kup-tree.d.ts +18 -12
- package/dist/types/components.d.ts +43 -16
- package/dist/types/managers/kup-scroll-on-hover/kup-scroll-on-hover-declarations.d.ts +1 -0
- package/dist/types/managers/kup-scroll-on-hover/kup-scroll-on-hover.d.ts +2 -1
- package/dist/types/stencil-public-runtime.d.ts +15 -4
- package/package.json +3 -2
- package/CHANGELOG.md +0 -5
- package/dist/ketchup/p-753c82d8.js +0 -1
- package/dist/ketchup/p-77600efd.entry.js +0 -9
- package/dist/ketchup/p-88722265.js +0 -1
- package/dist/ketchup/p-9027e5ac.js +0 -30
- package/dist/ketchup/p-aa564df8.entry.js +0 -1
- package/dist/ketchup/p-b0b3989b.js +0 -2
- package/dist/ketchup/p-b238f9ea.entry.js +0 -1
- package/dist/ketchup/p-b4f85d34.entry.js +0 -1
|
@@ -22,67 +22,23 @@ function _interopNamespace(e) {
|
|
|
22
22
|
|
|
23
23
|
const NAMESPACE = 'ketchup';
|
|
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 queuePending = false;
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
$flags$: 0,
|
|
33
|
-
$resourcesUrl$: '',
|
|
34
|
-
jmp: (h) => h(),
|
|
35
|
-
raf: (h) => requestAnimationFrame(h),
|
|
36
|
-
ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
|
|
37
|
-
rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
|
|
38
|
-
ce: (eventName, opts) => new CustomEvent(eventName, opts),
|
|
39
|
-
};
|
|
40
|
-
const promiseResolve = (v) => Promise.resolve(v);
|
|
41
|
-
const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
|
|
42
|
-
try {
|
|
43
|
-
new CSSStyleSheet();
|
|
44
|
-
return typeof new CSSStyleSheet().replaceSync === 'function';
|
|
45
|
-
}
|
|
46
|
-
catch (e) { }
|
|
47
|
-
return false;
|
|
48
|
-
})()
|
|
49
|
-
;
|
|
50
|
-
const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
|
|
51
|
-
if (listeners) {
|
|
52
|
-
listeners.map(([flags, name, method]) => {
|
|
53
|
-
const target = getHostListenerTarget(elm, flags) ;
|
|
54
|
-
const handler = hostListenerProxy(hostRef, method);
|
|
55
|
-
const opts = hostListenerOpts(flags);
|
|
56
|
-
plt.ael(target, name, handler, opts);
|
|
57
|
-
(hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
const hostListenerProxy = (hostRef, methodName) => (ev) => {
|
|
62
|
-
try {
|
|
63
|
-
{
|
|
64
|
-
if (hostRef.$flags$ & 256 /* isListenReady */) {
|
|
65
|
-
// instance is ready, let's call it's member method for this event
|
|
66
|
-
hostRef.$lazyInstance$[methodName](ev);
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
(hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
catch (e) {
|
|
74
|
-
consoleError(e);
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
const getHostListenerTarget = (elm, flags) => {
|
|
78
|
-
if (flags & 4 /* TargetDocument */)
|
|
79
|
-
return doc;
|
|
80
|
-
return elm;
|
|
37
|
+
const getAssetPath = (path) => {
|
|
38
|
+
const assetUrl = new URL(path, plt.$resourcesUrl$);
|
|
39
|
+
return assetUrl.origin !== win.location.origin ? assetUrl.href : assetUrl.pathname;
|
|
81
40
|
};
|
|
82
|
-
|
|
83
|
-
const hostListenerOpts = (flags) => (flags & 2 /* Capture */) !== 0;
|
|
84
|
-
const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
|
|
85
|
-
const XLINK_NS = 'http://www.w3.org/1999/xlink';
|
|
41
|
+
const setAssetPath = (path) => (plt.$resourcesUrl$ = path);
|
|
86
42
|
const createTime = (fnName, tagName = '') => {
|
|
87
43
|
{
|
|
88
44
|
return () => {
|
|
@@ -97,76 +53,8 @@ const uniqueTime = (key, measureText) => {
|
|
|
97
53
|
};
|
|
98
54
|
}
|
|
99
55
|
};
|
|
100
|
-
const
|
|
101
|
-
const
|
|
102
|
-
let style = styles.get(scopeId);
|
|
103
|
-
if (supportsConstructableStylesheets && allowCS) {
|
|
104
|
-
style = (style || new CSSStyleSheet());
|
|
105
|
-
if (typeof style === 'string') {
|
|
106
|
-
style = cssText;
|
|
107
|
-
}
|
|
108
|
-
else {
|
|
109
|
-
style.replaceSync(cssText);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
style = cssText;
|
|
114
|
-
}
|
|
115
|
-
styles.set(scopeId, style);
|
|
116
|
-
};
|
|
117
|
-
const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
|
|
118
|
-
let scopeId = getScopeId(cmpMeta);
|
|
119
|
-
const style = styles.get(scopeId);
|
|
120
|
-
// if an element is NOT connected then getRootNode() will return the wrong root node
|
|
121
|
-
// so the fallback is to always use the document for the root node in those cases
|
|
122
|
-
styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
|
|
123
|
-
if (style) {
|
|
124
|
-
if (typeof style === 'string') {
|
|
125
|
-
styleContainerNode = styleContainerNode.head || styleContainerNode;
|
|
126
|
-
let appliedStyles = rootAppliedStyles.get(styleContainerNode);
|
|
127
|
-
let styleElm;
|
|
128
|
-
if (!appliedStyles) {
|
|
129
|
-
rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
|
|
130
|
-
}
|
|
131
|
-
if (!appliedStyles.has(scopeId)) {
|
|
132
|
-
{
|
|
133
|
-
{
|
|
134
|
-
styleElm = doc.createElement('style');
|
|
135
|
-
styleElm.innerHTML = style;
|
|
136
|
-
}
|
|
137
|
-
styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
|
|
138
|
-
}
|
|
139
|
-
if (appliedStyles) {
|
|
140
|
-
appliedStyles.add(scopeId);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
|
|
145
|
-
styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
return scopeId;
|
|
149
|
-
};
|
|
150
|
-
const attachStyles = (hostRef) => {
|
|
151
|
-
const cmpMeta = hostRef.$cmpMeta$;
|
|
152
|
-
const elm = hostRef.$hostElement$;
|
|
153
|
-
const flags = cmpMeta.$flags$;
|
|
154
|
-
const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
|
|
155
|
-
const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
|
|
156
|
-
if (flags & 10 /* needsScopedEncapsulation */) {
|
|
157
|
-
// only required when we're NOT using native shadow dom (slot)
|
|
158
|
-
// or this browser doesn't support native shadow dom
|
|
159
|
-
// and this host element was NOT created with SSR
|
|
160
|
-
// let's pick out the inner content for slot projection
|
|
161
|
-
// create a node to represent where the original
|
|
162
|
-
// content was first placed, which is useful later on
|
|
163
|
-
// DOM WRITE!!
|
|
164
|
-
elm['s-sc'] = scopeId;
|
|
165
|
-
elm.classList.add(scopeId + '-h');
|
|
166
|
-
}
|
|
167
|
-
endAttachStyles();
|
|
168
|
-
};
|
|
169
|
-
const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
|
|
56
|
+
const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
|
|
57
|
+
const XLINK_NS = 'http://www.w3.org/1999/xlink';
|
|
170
58
|
/**
|
|
171
59
|
* Default style mode id
|
|
172
60
|
*/
|
|
@@ -305,6 +193,149 @@ const convertToPrivate = (node) => {
|
|
|
305
193
|
vnode.$name$ = node.vname;
|
|
306
194
|
return vnode;
|
|
307
195
|
};
|
|
196
|
+
/**
|
|
197
|
+
* Parse a new property value for a given property type.
|
|
198
|
+
*
|
|
199
|
+
* While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
|
|
200
|
+
* it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
|
|
201
|
+
* 1. `any`, the type given to `propValue` in the function signature
|
|
202
|
+
* 2. the type stored from `propType`.
|
|
203
|
+
*
|
|
204
|
+
* This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
|
|
205
|
+
*
|
|
206
|
+
* Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
|
|
207
|
+
* a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
|
|
208
|
+
* based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
|
|
209
|
+
* ```tsx
|
|
210
|
+
* <my-cmp prop-val={0}></my-cmp>
|
|
211
|
+
* ```
|
|
212
|
+
*
|
|
213
|
+
* HTML prop values on the other hand, will always a string
|
|
214
|
+
*
|
|
215
|
+
* @param propValue the new value to coerce to some type
|
|
216
|
+
* @param propType the type of the prop, expressed as a binary number
|
|
217
|
+
* @returns the parsed/coerced value
|
|
218
|
+
*/
|
|
219
|
+
const parsePropertyValue = (propValue, propType) => {
|
|
220
|
+
// ensure this value is of the correct prop type
|
|
221
|
+
if (propValue != null && !isComplexType(propValue)) {
|
|
222
|
+
if (propType & 4 /* MEMBER_FLAGS.Boolean */) {
|
|
223
|
+
// per the HTML spec, any string value means it is a boolean true value
|
|
224
|
+
// but we'll cheat here and say that the string "false" is the boolean false
|
|
225
|
+
return propValue === 'false' ? false : propValue === '' || !!propValue;
|
|
226
|
+
}
|
|
227
|
+
if (propType & 2 /* MEMBER_FLAGS.Number */) {
|
|
228
|
+
// force it to be a number
|
|
229
|
+
return parseFloat(propValue);
|
|
230
|
+
}
|
|
231
|
+
if (propType & 1 /* MEMBER_FLAGS.String */) {
|
|
232
|
+
// could have been passed as a number or boolean
|
|
233
|
+
// but we still want it as a string
|
|
234
|
+
return String(propValue);
|
|
235
|
+
}
|
|
236
|
+
// redundant return here for better minification
|
|
237
|
+
return propValue;
|
|
238
|
+
}
|
|
239
|
+
// not sure exactly what type we want
|
|
240
|
+
// so no need to change to a different type
|
|
241
|
+
return propValue;
|
|
242
|
+
};
|
|
243
|
+
const getElement = (ref) => (getHostRef(ref).$hostElement$ );
|
|
244
|
+
const createEvent = (ref, name, flags) => {
|
|
245
|
+
const elm = getElement(ref);
|
|
246
|
+
return {
|
|
247
|
+
emit: (detail) => {
|
|
248
|
+
return emitEvent(elm, name, {
|
|
249
|
+
bubbles: !!(flags & 4 /* EVENT_FLAGS.Bubbles */),
|
|
250
|
+
composed: !!(flags & 2 /* EVENT_FLAGS.Composed */),
|
|
251
|
+
cancelable: !!(flags & 1 /* EVENT_FLAGS.Cancellable */),
|
|
252
|
+
detail,
|
|
253
|
+
});
|
|
254
|
+
},
|
|
255
|
+
};
|
|
256
|
+
};
|
|
257
|
+
/**
|
|
258
|
+
* Helper function to create & dispatch a custom Event on a provided target
|
|
259
|
+
* @param elm the target of the Event
|
|
260
|
+
* @param name the name to give the custom Event
|
|
261
|
+
* @param opts options for configuring a custom Event
|
|
262
|
+
* @returns the custom Event
|
|
263
|
+
*/
|
|
264
|
+
const emitEvent = (elm, name, opts) => {
|
|
265
|
+
const ev = plt.ce(name, opts);
|
|
266
|
+
elm.dispatchEvent(ev);
|
|
267
|
+
return ev;
|
|
268
|
+
};
|
|
269
|
+
const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
|
|
270
|
+
const registerStyle = (scopeId, cssText, allowCS) => {
|
|
271
|
+
let style = styles.get(scopeId);
|
|
272
|
+
if (supportsConstructableStylesheets && allowCS) {
|
|
273
|
+
style = (style || new CSSStyleSheet());
|
|
274
|
+
if (typeof style === 'string') {
|
|
275
|
+
style = cssText;
|
|
276
|
+
}
|
|
277
|
+
else {
|
|
278
|
+
style.replaceSync(cssText);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
else {
|
|
282
|
+
style = cssText;
|
|
283
|
+
}
|
|
284
|
+
styles.set(scopeId, style);
|
|
285
|
+
};
|
|
286
|
+
const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
|
|
287
|
+
let scopeId = getScopeId(cmpMeta);
|
|
288
|
+
const style = styles.get(scopeId);
|
|
289
|
+
// if an element is NOT connected then getRootNode() will return the wrong root node
|
|
290
|
+
// so the fallback is to always use the document for the root node in those cases
|
|
291
|
+
styleContainerNode = styleContainerNode.nodeType === 11 /* NODE_TYPE.DocumentFragment */ ? styleContainerNode : doc;
|
|
292
|
+
if (style) {
|
|
293
|
+
if (typeof style === 'string') {
|
|
294
|
+
styleContainerNode = styleContainerNode.head || styleContainerNode;
|
|
295
|
+
let appliedStyles = rootAppliedStyles.get(styleContainerNode);
|
|
296
|
+
let styleElm;
|
|
297
|
+
if (!appliedStyles) {
|
|
298
|
+
rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
|
|
299
|
+
}
|
|
300
|
+
if (!appliedStyles.has(scopeId)) {
|
|
301
|
+
{
|
|
302
|
+
{
|
|
303
|
+
styleElm = doc.createElement('style');
|
|
304
|
+
styleElm.innerHTML = style;
|
|
305
|
+
}
|
|
306
|
+
styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
|
|
307
|
+
}
|
|
308
|
+
if (appliedStyles) {
|
|
309
|
+
appliedStyles.add(scopeId);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
|
|
314
|
+
styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
return scopeId;
|
|
318
|
+
};
|
|
319
|
+
const attachStyles = (hostRef) => {
|
|
320
|
+
const cmpMeta = hostRef.$cmpMeta$;
|
|
321
|
+
const elm = hostRef.$hostElement$;
|
|
322
|
+
const flags = cmpMeta.$flags$;
|
|
323
|
+
const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
|
|
324
|
+
const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
|
|
325
|
+
if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
|
|
326
|
+
// only required when we're NOT using native shadow dom (slot)
|
|
327
|
+
// or this browser doesn't support native shadow dom
|
|
328
|
+
// and this host element was NOT created with SSR
|
|
329
|
+
// let's pick out the inner content for slot projection
|
|
330
|
+
// create a node to represent where the original
|
|
331
|
+
// content was first placed, which is useful later on
|
|
332
|
+
// DOM WRITE!!
|
|
333
|
+
elm['s-sc'] = scopeId;
|
|
334
|
+
elm.classList.add(scopeId + '-h');
|
|
335
|
+
}
|
|
336
|
+
endAttachStyles();
|
|
337
|
+
};
|
|
338
|
+
const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
|
|
308
339
|
/**
|
|
309
340
|
* Production setAccessor() function based on Preact by
|
|
310
341
|
* Jason Miller (@developit)
|
|
@@ -441,7 +472,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
|
|
441
472
|
}
|
|
442
473
|
}
|
|
443
474
|
}
|
|
444
|
-
else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
|
|
475
|
+
else if ((!isProp || flags & 4 /* VNODE_FLAGS.isHost */ || isSvg) && !isComplex) {
|
|
445
476
|
newValue = newValue === true ? '' : newValue;
|
|
446
477
|
if (xlink) {
|
|
447
478
|
elm.setAttributeNS(XLINK_NS, memberName, newValue);
|
|
@@ -459,7 +490,7 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
|
|
|
459
490
|
// if the element passed in is a shadow root, which is a document fragment
|
|
460
491
|
// then we want to be adding attrs/props to the shadow root's "host" element
|
|
461
492
|
// if it's not a shadow root, then we add attrs/props to the same element
|
|
462
|
-
const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host
|
|
493
|
+
const elm = newVnode.$elm$.nodeType === 11 /* NODE_TYPE.DocumentFragment */ && newVnode.$elm$.host
|
|
463
494
|
? newVnode.$elm$.host
|
|
464
495
|
: newVnode.$elm$;
|
|
465
496
|
const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
|
|
@@ -477,6 +508,16 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
|
|
|
477
508
|
setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
|
|
478
509
|
}
|
|
479
510
|
};
|
|
511
|
+
/**
|
|
512
|
+
* Create a DOM Node corresponding to one of the children of a given VNode.
|
|
513
|
+
*
|
|
514
|
+
* @param oldParentVNode the parent VNode from the previous render
|
|
515
|
+
* @param newParentVNode the parent VNode from the current render
|
|
516
|
+
* @param childIndex the index of the VNode, in the _new_ parent node's
|
|
517
|
+
* children, for which we will create a new DOM node
|
|
518
|
+
* @param parentElm the parent DOM node which our new node will be a child of
|
|
519
|
+
* @returns the newly created node
|
|
520
|
+
*/
|
|
480
521
|
const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
481
522
|
// tslint:disable-next-line: prefer-const
|
|
482
523
|
const newVNode = newParentVNode.$children$[childIndex];
|
|
@@ -556,6 +597,74 @@ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
|
|
|
556
597
|
}
|
|
557
598
|
}
|
|
558
599
|
};
|
|
600
|
+
/**
|
|
601
|
+
* Reconcile the children of a new VNode with the children of an old VNode by
|
|
602
|
+
* traversing the two collections of children, identifying nodes that are
|
|
603
|
+
* conserved or changed, calling out to `patch` to make any necessary
|
|
604
|
+
* updates to the DOM, and rearranging DOM nodes as needed.
|
|
605
|
+
*
|
|
606
|
+
* The algorithm for reconciling children works by analyzing two 'windows' onto
|
|
607
|
+
* the two arrays of children (`oldCh` and `newCh`). We keep track of the
|
|
608
|
+
* 'windows' by storing start and end indices and references to the
|
|
609
|
+
* corresponding array entries. Initially the two 'windows' are basically equal
|
|
610
|
+
* to the entire array, but we progressively narrow the windows until there are
|
|
611
|
+
* no children left to update by doing the following:
|
|
612
|
+
*
|
|
613
|
+
* 1. Skip any `null` entries at the beginning or end of the two arrays, so
|
|
614
|
+
* that if we have an initial array like the following we'll end up dealing
|
|
615
|
+
* only with a window bounded by the highlighted elements:
|
|
616
|
+
*
|
|
617
|
+
* [null, null, VNode1 , ... , VNode2, null, null]
|
|
618
|
+
* ^^^^^^ ^^^^^^
|
|
619
|
+
*
|
|
620
|
+
* 2. Check to see if the elements at the head and tail positions are equal
|
|
621
|
+
* across the windows. This will basically detect elements which haven't
|
|
622
|
+
* been added, removed, or changed position, i.e. if you had the following
|
|
623
|
+
* VNode elements (represented as HTML):
|
|
624
|
+
*
|
|
625
|
+
* oldVNode: `<div><p><span>HEY</span></p></div>`
|
|
626
|
+
* newVNode: `<div><p><span>THERE</span></p></div>`
|
|
627
|
+
*
|
|
628
|
+
* Then when comparing the children of the `<div>` tag we check the equality
|
|
629
|
+
* of the VNodes corresponding to the `<p>` tags and, since they are the
|
|
630
|
+
* same tag in the same position, we'd be able to avoid completely
|
|
631
|
+
* re-rendering the subtree under them with a new DOM element and would just
|
|
632
|
+
* call out to `patch` to handle reconciling their children and so on.
|
|
633
|
+
*
|
|
634
|
+
* 3. Check, for both windows, to see if the element at the beginning of the
|
|
635
|
+
* window corresponds to the element at the end of the other window. This is
|
|
636
|
+
* a heuristic which will let us identify _some_ situations in which
|
|
637
|
+
* elements have changed position, for instance it _should_ detect that the
|
|
638
|
+
* children nodes themselves have not changed but merely moved in the
|
|
639
|
+
* following example:
|
|
640
|
+
*
|
|
641
|
+
* oldVNode: `<div><element-one /><element-two /></div>`
|
|
642
|
+
* newVNode: `<div><element-two /><element-one /></div>`
|
|
643
|
+
*
|
|
644
|
+
* If we find cases like this then we also need to move the concrete DOM
|
|
645
|
+
* elements corresponding to the moved children to write the re-order to the
|
|
646
|
+
* DOM.
|
|
647
|
+
*
|
|
648
|
+
* 4. Finally, if VNodes have the `key` attribute set on them we check for any
|
|
649
|
+
* nodes in the old children which have the same key as the first element in
|
|
650
|
+
* our window on the new children. If we find such a node we handle calling
|
|
651
|
+
* out to `patch`, moving relevant DOM nodes, and so on, in accordance with
|
|
652
|
+
* what we find.
|
|
653
|
+
*
|
|
654
|
+
* Finally, once we've narrowed our 'windows' to the point that either of them
|
|
655
|
+
* collapse (i.e. they have length 0) we then handle any remaining VNode
|
|
656
|
+
* insertion or deletion that needs to happen to get a DOM state that correctly
|
|
657
|
+
* reflects the new child VNodes. If, for instance, after our window on the old
|
|
658
|
+
* children has collapsed we still have more nodes on the new children that
|
|
659
|
+
* we haven't dealt with yet then we need to add them, or if the new children
|
|
660
|
+
* collapse but we still have unhandled _old_ children then we need to make
|
|
661
|
+
* sure the corresponding DOM nodes are removed.
|
|
662
|
+
*
|
|
663
|
+
* @param parentElm the node into which the parent VNode is rendered
|
|
664
|
+
* @param oldCh the old children of the parent node
|
|
665
|
+
* @param newVNode the new VNode which will replace the parent
|
|
666
|
+
* @param newCh the new children of the parent node
|
|
667
|
+
*/
|
|
559
668
|
const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
560
669
|
let oldStartIdx = 0;
|
|
561
670
|
let newStartIdx = 0;
|
|
@@ -571,7 +680,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
571
680
|
let elmToMove;
|
|
572
681
|
while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
|
|
573
682
|
if (oldStartVnode == null) {
|
|
574
|
-
//
|
|
683
|
+
// VNode might have been moved left
|
|
575
684
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
576
685
|
}
|
|
577
686
|
else if (oldEndVnode == null) {
|
|
@@ -584,29 +693,65 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
584
693
|
newEndVnode = newCh[--newEndIdx];
|
|
585
694
|
}
|
|
586
695
|
else if (isSameVnode(oldStartVnode, newStartVnode)) {
|
|
696
|
+
// if the start nodes are the same then we should patch the new VNode
|
|
697
|
+
// onto the old one, and increment our `newStartIdx` and `oldStartIdx`
|
|
698
|
+
// indices to reflect that. We don't need to move any DOM Nodes around
|
|
699
|
+
// since things are matched up in order.
|
|
587
700
|
patch(oldStartVnode, newStartVnode);
|
|
588
701
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
589
702
|
newStartVnode = newCh[++newStartIdx];
|
|
590
703
|
}
|
|
591
704
|
else if (isSameVnode(oldEndVnode, newEndVnode)) {
|
|
705
|
+
// likewise, if the end nodes are the same we patch new onto old and
|
|
706
|
+
// decrement our end indices, and also likewise in this case we don't
|
|
707
|
+
// need to move any DOM Nodes.
|
|
592
708
|
patch(oldEndVnode, newEndVnode);
|
|
593
709
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
594
710
|
newEndVnode = newCh[--newEndIdx];
|
|
595
711
|
}
|
|
596
712
|
else if (isSameVnode(oldStartVnode, newEndVnode)) {
|
|
597
713
|
patch(oldStartVnode, newEndVnode);
|
|
714
|
+
// We need to move the element for `oldStartVnode` into a position which
|
|
715
|
+
// will be appropriate for `newEndVnode`. For this we can use
|
|
716
|
+
// `.insertBefore` and `oldEndVnode.$elm$.nextSibling`. If there is a
|
|
717
|
+
// sibling for `oldEndVnode.$elm$` then we want to move the DOM node for
|
|
718
|
+
// `oldStartVnode` between `oldEndVnode` and it's sibling, like so:
|
|
719
|
+
//
|
|
720
|
+
// <old-start-node />
|
|
721
|
+
// <some-intervening-node />
|
|
722
|
+
// <old-end-node />
|
|
723
|
+
// <!-- -> <-- `oldStartVnode.$elm$` should be inserted here
|
|
724
|
+
// <next-sibling />
|
|
725
|
+
//
|
|
726
|
+
// If instead `oldEndVnode.$elm$` has no sibling then we just want to put
|
|
727
|
+
// the node for `oldStartVnode` at the end of the children of
|
|
728
|
+
// `parentElm`. Luckily, `Node.nextSibling` will return `null` if there
|
|
729
|
+
// aren't any siblings, and passing `null` to `Node.insertBefore` will
|
|
730
|
+
// append it to the children of the parent element.
|
|
598
731
|
parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
|
|
599
732
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
600
733
|
newEndVnode = newCh[--newEndIdx];
|
|
601
734
|
}
|
|
602
735
|
else if (isSameVnode(oldEndVnode, newStartVnode)) {
|
|
603
736
|
patch(oldEndVnode, newStartVnode);
|
|
737
|
+
// We've already checked above if `oldStartVnode` and `newStartVnode` are
|
|
738
|
+
// the same node, so since we're here we know that they are not. Thus we
|
|
739
|
+
// can move the element for `oldEndVnode` _before_ the element for
|
|
740
|
+
// `oldStartVnode`, leaving `oldStartVnode` to be reconciled in the
|
|
741
|
+
// future.
|
|
604
742
|
parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
|
|
605
743
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
606
744
|
newStartVnode = newCh[++newStartIdx];
|
|
607
745
|
}
|
|
608
746
|
else {
|
|
609
|
-
//
|
|
747
|
+
// Here we do some checks to match up old and new nodes based on the
|
|
748
|
+
// `$key$` attribute, which is set by putting a `key="my-key"` attribute
|
|
749
|
+
// in the JSX for a DOM element in the implementation of a Stencil
|
|
750
|
+
// component.
|
|
751
|
+
//
|
|
752
|
+
// First we check to see if there are any nodes in the array of old
|
|
753
|
+
// children which have the same key as the first node in the new
|
|
754
|
+
// children.
|
|
610
755
|
idxInOld = -1;
|
|
611
756
|
{
|
|
612
757
|
for (i = oldStartIdx; i <= oldEndIdx; ++i) {
|
|
@@ -617,23 +762,32 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
617
762
|
}
|
|
618
763
|
}
|
|
619
764
|
if (idxInOld >= 0) {
|
|
765
|
+
// We found a node in the old children which matches up with the first
|
|
766
|
+
// node in the new children! So let's deal with that
|
|
620
767
|
elmToMove = oldCh[idxInOld];
|
|
621
768
|
if (elmToMove.$tag$ !== newStartVnode.$tag$) {
|
|
769
|
+
// the tag doesn't match so we'll need a new DOM element
|
|
622
770
|
node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld);
|
|
623
771
|
}
|
|
624
772
|
else {
|
|
625
773
|
patch(elmToMove, newStartVnode);
|
|
774
|
+
// invalidate the matching old node so that we won't try to update it
|
|
775
|
+
// again later on
|
|
626
776
|
oldCh[idxInOld] = undefined;
|
|
627
777
|
node = elmToMove.$elm$;
|
|
628
778
|
}
|
|
629
779
|
newStartVnode = newCh[++newStartIdx];
|
|
630
780
|
}
|
|
631
781
|
else {
|
|
632
|
-
//
|
|
782
|
+
// We either didn't find an element in the old children that matches
|
|
783
|
+
// the key of the first new child OR the build is not using `key`
|
|
784
|
+
// attributes at all. In either case we need to create a new element
|
|
785
|
+
// for the new node.
|
|
633
786
|
node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
|
|
634
787
|
newStartVnode = newCh[++newStartIdx];
|
|
635
788
|
}
|
|
636
789
|
if (node) {
|
|
790
|
+
// if we created a new node then handle inserting it to the DOM
|
|
637
791
|
{
|
|
638
792
|
oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
|
|
639
793
|
}
|
|
@@ -641,22 +795,52 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
641
795
|
}
|
|
642
796
|
}
|
|
643
797
|
if (oldStartIdx > oldEndIdx) {
|
|
798
|
+
// we have some more new nodes to add which don't match up with old nodes
|
|
644
799
|
addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
|
|
645
800
|
}
|
|
646
801
|
else if (newStartIdx > newEndIdx) {
|
|
802
|
+
// there are nodes in the `oldCh` array which no longer correspond to nodes
|
|
803
|
+
// in the new array, so lets remove them (which entails cleaning up the
|
|
804
|
+
// relevant DOM nodes)
|
|
647
805
|
removeVnodes(oldCh, oldStartIdx, oldEndIdx);
|
|
648
806
|
}
|
|
649
807
|
};
|
|
650
|
-
|
|
808
|
+
/**
|
|
809
|
+
* Compare two VNodes to determine if they are the same
|
|
810
|
+
*
|
|
811
|
+
* **NB**: This function is an equality _heuristic_ based on the available
|
|
812
|
+
* information set on the two VNodes and can be misleading under certain
|
|
813
|
+
* circumstances. In particular, if the two nodes do not have `key` attrs
|
|
814
|
+
* (available under `$key$` on VNodes) then the function falls back on merely
|
|
815
|
+
* checking that they have the same tag.
|
|
816
|
+
*
|
|
817
|
+
* So, in other words, if `key` attrs are not set on VNodes which may be
|
|
818
|
+
* changing order within a `children` array or something along those lines then
|
|
819
|
+
* we could obtain a false positive and then have to do needless re-rendering.
|
|
820
|
+
*
|
|
821
|
+
* @param leftVNode the first VNode to check
|
|
822
|
+
* @param rightVNode the second VNode to check
|
|
823
|
+
* @returns whether they're equal or not
|
|
824
|
+
*/
|
|
825
|
+
const isSameVnode = (leftVNode, rightVNode) => {
|
|
651
826
|
// compare if two vnode to see if they're "technically" the same
|
|
652
827
|
// need to have the same element tag, and same key to be the same
|
|
653
|
-
if (
|
|
828
|
+
if (leftVNode.$tag$ === rightVNode.$tag$) {
|
|
829
|
+
// this will be set if components in the build have `key` attrs set on them
|
|
654
830
|
{
|
|
655
|
-
return
|
|
831
|
+
return leftVNode.$key$ === rightVNode.$key$;
|
|
656
832
|
}
|
|
657
833
|
}
|
|
658
834
|
return false;
|
|
659
835
|
};
|
|
836
|
+
/**
|
|
837
|
+
* Handle reconciling an outdated VNode with a new one which corresponds to
|
|
838
|
+
* it. This function handles flushing updates to the DOM and reconciling the
|
|
839
|
+
* children of the two nodes (if any).
|
|
840
|
+
*
|
|
841
|
+
* @param oldVNode an old VNode whose DOM element and children we want to update
|
|
842
|
+
* @param newVNode a new VNode representing an updated version of the old one
|
|
843
|
+
*/
|
|
660
844
|
const patch = (oldVNode, newVNode) => {
|
|
661
845
|
const elm = (newVNode.$elm$ = oldVNode.$elm$);
|
|
662
846
|
const oldChildren = oldVNode.$children$;
|
|
@@ -669,7 +853,6 @@ const patch = (oldVNode, newVNode) => {
|
|
|
669
853
|
// only add this to the when the compiler sees we're using an svg somewhere
|
|
670
854
|
isSvgMode = tag === 'svg' ? true : tag === 'foreignObject' ? false : isSvgMode;
|
|
671
855
|
}
|
|
672
|
-
// element node
|
|
673
856
|
{
|
|
674
857
|
if (tag === 'slot')
|
|
675
858
|
;
|
|
@@ -682,6 +865,7 @@ const patch = (oldVNode, newVNode) => {
|
|
|
682
865
|
}
|
|
683
866
|
if (oldChildren !== null && newChildren !== null) {
|
|
684
867
|
// looks like there's child vnodes for both the old and new vnodes
|
|
868
|
+
// so we need to call `updateChildren` to reconcile them
|
|
685
869
|
updateChildren(elm, oldChildren, newVNode, newChildren);
|
|
686
870
|
}
|
|
687
871
|
else if (newChildren !== null) {
|
|
@@ -724,7 +908,7 @@ const renderVdom = (hostRef, renderFnResults) => {
|
|
|
724
908
|
cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
|
|
725
909
|
}
|
|
726
910
|
rootVnode.$tag$ = null;
|
|
727
|
-
rootVnode.$flags$ |= 4 /* isHost */;
|
|
911
|
+
rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
|
|
728
912
|
hostRef.$vnode$ = rootVnode;
|
|
729
913
|
rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
|
|
730
914
|
{
|
|
@@ -733,32 +917,6 @@ const renderVdom = (hostRef, renderFnResults) => {
|
|
|
733
917
|
// synchronous patch
|
|
734
918
|
patch(oldVNode, rootVnode);
|
|
735
919
|
};
|
|
736
|
-
const getElement = (ref) => (getHostRef(ref).$hostElement$ );
|
|
737
|
-
const createEvent = (ref, name, flags) => {
|
|
738
|
-
const elm = getElement(ref);
|
|
739
|
-
return {
|
|
740
|
-
emit: (detail) => {
|
|
741
|
-
return emitEvent(elm, name, {
|
|
742
|
-
bubbles: !!(flags & 4 /* Bubbles */),
|
|
743
|
-
composed: !!(flags & 2 /* Composed */),
|
|
744
|
-
cancelable: !!(flags & 1 /* Cancellable */),
|
|
745
|
-
detail,
|
|
746
|
-
});
|
|
747
|
-
},
|
|
748
|
-
};
|
|
749
|
-
};
|
|
750
|
-
/**
|
|
751
|
-
* Helper function to create & dispatch a custom Event on a provided target
|
|
752
|
-
* @param elm the target of the Event
|
|
753
|
-
* @param name the name to give the custom Event
|
|
754
|
-
* @param opts options for configuring a custom Event
|
|
755
|
-
* @returns the custom Event
|
|
756
|
-
*/
|
|
757
|
-
const emitEvent = (elm, name, opts) => {
|
|
758
|
-
const ev = plt.ce(name, opts);
|
|
759
|
-
elm.dispatchEvent(ev);
|
|
760
|
-
return ev;
|
|
761
|
-
};
|
|
762
920
|
const attachToAncestor = (hostRef, ancestorComponent) => {
|
|
763
921
|
if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
|
|
764
922
|
ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
|
|
@@ -766,10 +924,10 @@ const attachToAncestor = (hostRef, ancestorComponent) => {
|
|
|
766
924
|
};
|
|
767
925
|
const scheduleUpdate = (hostRef, isInitialLoad) => {
|
|
768
926
|
{
|
|
769
|
-
hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
|
|
927
|
+
hostRef.$flags$ |= 16 /* HOST_FLAGS.isQueuedForUpdate */;
|
|
770
928
|
}
|
|
771
|
-
if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
|
|
772
|
-
hostRef.$flags$ |= 512 /* needsRerender */;
|
|
929
|
+
if (hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
|
|
930
|
+
hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
|
|
773
931
|
return;
|
|
774
932
|
}
|
|
775
933
|
attachToAncestor(hostRef, hostRef.$ancestorComponent$);
|
|
@@ -785,7 +943,7 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
|
|
|
785
943
|
let promise;
|
|
786
944
|
if (isInitialLoad) {
|
|
787
945
|
{
|
|
788
|
-
hostRef.$flags$ |= 256 /* isListenReady */;
|
|
946
|
+
hostRef.$flags$ |= 256 /* HOST_FLAGS.isListenReady */;
|
|
789
947
|
if (hostRef.$queuedListeners$) {
|
|
790
948
|
hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
|
|
791
949
|
hostRef.$queuedListeners$ = null;
|
|
@@ -836,7 +994,7 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
|
|
|
836
994
|
}
|
|
837
995
|
else {
|
|
838
996
|
Promise.all(childrenPromises).then(postUpdate);
|
|
839
|
-
hostRef.$flags$ |= 4 /* isWaitingForChildren */;
|
|
997
|
+
hostRef.$flags$ |= 4 /* HOST_FLAGS.isWaitingForChildren */;
|
|
840
998
|
childrenPromises.length = 0;
|
|
841
999
|
}
|
|
842
1000
|
}
|
|
@@ -845,10 +1003,10 @@ const callRender = (hostRef, instance, elm) => {
|
|
|
845
1003
|
try {
|
|
846
1004
|
instance = instance.render() ;
|
|
847
1005
|
{
|
|
848
|
-
hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
|
|
1006
|
+
hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
|
|
849
1007
|
}
|
|
850
1008
|
{
|
|
851
|
-
hostRef.$flags$ |= 2 /* hasRendered */;
|
|
1009
|
+
hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
|
|
852
1010
|
}
|
|
853
1011
|
{
|
|
854
1012
|
{
|
|
@@ -875,8 +1033,8 @@ const postUpdateComponent = (hostRef) => {
|
|
|
875
1033
|
{
|
|
876
1034
|
safeCall(instance, 'componentDidRender');
|
|
877
1035
|
}
|
|
878
|
-
if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
|
|
879
|
-
hostRef.$flags$ |= 64 /* hasLoadedComponent */;
|
|
1036
|
+
if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
|
|
1037
|
+
hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
|
|
880
1038
|
{
|
|
881
1039
|
// DOM WRITE!
|
|
882
1040
|
addHydratedFlag(elm);
|
|
@@ -908,10 +1066,10 @@ const postUpdateComponent = (hostRef) => {
|
|
|
908
1066
|
hostRef.$onRenderResolve$();
|
|
909
1067
|
hostRef.$onRenderResolve$ = undefined;
|
|
910
1068
|
}
|
|
911
|
-
if (hostRef.$flags$ & 512 /* needsRerender */) {
|
|
1069
|
+
if (hostRef.$flags$ & 512 /* HOST_FLAGS.needsRerender */) {
|
|
912
1070
|
nextTick(() => scheduleUpdate(hostRef, false));
|
|
913
1071
|
}
|
|
914
|
-
hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
|
|
1072
|
+
hostRef.$flags$ &= ~(4 /* HOST_FLAGS.isWaitingForChildren */ | 512 /* HOST_FLAGS.needsRerender */);
|
|
915
1073
|
}
|
|
916
1074
|
// ( •_•)
|
|
917
1075
|
// ( •_•)>⌐■-■
|
|
@@ -922,7 +1080,7 @@ const forceUpdate = (ref) => {
|
|
|
922
1080
|
const hostRef = getHostRef(ref);
|
|
923
1081
|
const isConnected = hostRef.$hostElement$.isConnected;
|
|
924
1082
|
if (isConnected &&
|
|
925
|
-
(hostRef.$flags$ & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
|
|
1083
|
+
(hostRef.$flags$ & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
|
|
926
1084
|
scheduleUpdate(hostRef, false);
|
|
927
1085
|
}
|
|
928
1086
|
// Returns "true" when the forced update was successfully scheduled
|
|
@@ -953,53 +1111,6 @@ const then = (promise, thenFn) => {
|
|
|
953
1111
|
};
|
|
954
1112
|
const addHydratedFlag = (elm) => elm.classList.add('hydrated')
|
|
955
1113
|
;
|
|
956
|
-
/**
|
|
957
|
-
* Parse a new property value for a given property type.
|
|
958
|
-
*
|
|
959
|
-
* While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
|
|
960
|
-
* it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
|
|
961
|
-
* 1. `any`, the type given to `propValue` in the function signature
|
|
962
|
-
* 2. the type stored from `propType`.
|
|
963
|
-
*
|
|
964
|
-
* This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
|
|
965
|
-
*
|
|
966
|
-
* Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
|
|
967
|
-
* a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
|
|
968
|
-
* based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
|
|
969
|
-
* ```tsx
|
|
970
|
-
* <my-cmp prop-val={0}></my-cmp>
|
|
971
|
-
* ```
|
|
972
|
-
*
|
|
973
|
-
* HTML prop values on the other hand, will always a string
|
|
974
|
-
*
|
|
975
|
-
* @param propValue the new value to coerce to some type
|
|
976
|
-
* @param propType the type of the prop, expressed as a binary number
|
|
977
|
-
* @returns the parsed/coerced value
|
|
978
|
-
*/
|
|
979
|
-
const parsePropertyValue = (propValue, propType) => {
|
|
980
|
-
// ensure this value is of the correct prop type
|
|
981
|
-
if (propValue != null && !isComplexType(propValue)) {
|
|
982
|
-
if (propType & 4 /* Boolean */) {
|
|
983
|
-
// per the HTML spec, any string value means it is a boolean true value
|
|
984
|
-
// but we'll cheat here and say that the string "false" is the boolean false
|
|
985
|
-
return propValue === 'false' ? false : propValue === '' || !!propValue;
|
|
986
|
-
}
|
|
987
|
-
if (propType & 2 /* Number */) {
|
|
988
|
-
// force it to be a number
|
|
989
|
-
return parseFloat(propValue);
|
|
990
|
-
}
|
|
991
|
-
if (propType & 1 /* String */) {
|
|
992
|
-
// could have been passed as a number or boolean
|
|
993
|
-
// but we still want it as a string
|
|
994
|
-
return String(propValue);
|
|
995
|
-
}
|
|
996
|
-
// redundant return here for better minification
|
|
997
|
-
return propValue;
|
|
998
|
-
}
|
|
999
|
-
// not sure exactly what type we want
|
|
1000
|
-
// so no need to change to a different type
|
|
1001
|
-
return propValue;
|
|
1002
|
-
};
|
|
1003
1114
|
const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
|
|
1004
1115
|
const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
1005
1116
|
// check our new property value against our internal value
|
|
@@ -1012,13 +1123,13 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
1012
1123
|
// explicitly check for NaN on both sides, as `NaN === NaN` is always false
|
|
1013
1124
|
const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
|
|
1014
1125
|
const didValueChange = newVal !== oldVal && !areBothNaN;
|
|
1015
|
-
if ((!(flags & 8 /* isConstructingInstance */) || oldVal === undefined) && didValueChange) {
|
|
1126
|
+
if ((!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
|
|
1016
1127
|
// gadzooks! the property's value has changed!!
|
|
1017
1128
|
// set our new value!
|
|
1018
1129
|
hostRef.$instanceValues$.set(propName, newVal);
|
|
1019
1130
|
if (instance) {
|
|
1020
1131
|
// get an array of method names of watch functions to call
|
|
1021
|
-
if (cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
|
|
1132
|
+
if (cmpMeta.$watchers$ && flags & 128 /* HOST_FLAGS.isWatchReady */) {
|
|
1022
1133
|
const watchMethods = cmpMeta.$watchers$[propName];
|
|
1023
1134
|
if (watchMethods) {
|
|
1024
1135
|
// this instance is watching for when this property changed
|
|
@@ -1033,7 +1144,7 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
1033
1144
|
});
|
|
1034
1145
|
}
|
|
1035
1146
|
}
|
|
1036
|
-
if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
|
|
1147
|
+
if ((flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
|
|
1037
1148
|
// looks like this value actually changed, so we've got work to do!
|
|
1038
1149
|
// but only if we've already rendered, otherwise just chill out
|
|
1039
1150
|
// queue that we need to do an update, but don't worry about queuing
|
|
@@ -1043,6 +1154,16 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
1043
1154
|
}
|
|
1044
1155
|
}
|
|
1045
1156
|
};
|
|
1157
|
+
/**
|
|
1158
|
+
* Attach a series of runtime constructs to a compiled Stencil component
|
|
1159
|
+
* constructor, including getters and setters for the `@Prop` and `@State`
|
|
1160
|
+
* decorators, callbacks for when attributes change, and so on.
|
|
1161
|
+
*
|
|
1162
|
+
* @param Cstr the constructor for a component that we need to process
|
|
1163
|
+
* @param cmpMeta metadata collected previously about the component
|
|
1164
|
+
* @param flags a number used to store a series of bit flags
|
|
1165
|
+
* @returns a reference to the same constructor passed in (but now mutated)
|
|
1166
|
+
*/
|
|
1046
1167
|
const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
1047
1168
|
if (cmpMeta.$members$) {
|
|
1048
1169
|
if (Cstr.watchers) {
|
|
@@ -1052,8 +1173,8 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1052
1173
|
const members = Object.entries(cmpMeta.$members$);
|
|
1053
1174
|
const prototype = Cstr.prototype;
|
|
1054
1175
|
members.map(([memberName, [memberFlags]]) => {
|
|
1055
|
-
if ((memberFlags & 31 /* Prop */ ||
|
|
1056
|
-
((flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
|
|
1176
|
+
if ((memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
|
|
1177
|
+
((flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
|
|
1057
1178
|
// proxyComponent - prop
|
|
1058
1179
|
Object.defineProperty(prototype, memberName, {
|
|
1059
1180
|
get() {
|
|
@@ -1068,8 +1189,8 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1068
1189
|
enumerable: true,
|
|
1069
1190
|
});
|
|
1070
1191
|
}
|
|
1071
|
-
else if (flags & 1 /* isElementConstructor */ &&
|
|
1072
|
-
memberFlags & 64 /* Method */) {
|
|
1192
|
+
else if (flags & 1 /* PROXY_FLAGS.isElementConstructor */ &&
|
|
1193
|
+
memberFlags & 64 /* MEMBER_FLAGS.Method */) {
|
|
1073
1194
|
// proxyComponent - method
|
|
1074
1195
|
Object.defineProperty(prototype, memberName, {
|
|
1075
1196
|
value(...args) {
|
|
@@ -1079,7 +1200,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1079
1200
|
});
|
|
1080
1201
|
}
|
|
1081
1202
|
});
|
|
1082
|
-
if ((flags & 1 /* isElementConstructor */)) {
|
|
1203
|
+
if ((flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
|
|
1083
1204
|
const attrNameToPropName = new Map();
|
|
1084
1205
|
prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
|
|
1085
1206
|
plt.jmp(() => {
|
|
@@ -1135,11 +1256,11 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1135
1256
|
// create an array of attributes to observe
|
|
1136
1257
|
// and also create a map of html attribute name to js property name
|
|
1137
1258
|
Cstr.observedAttributes = members
|
|
1138
|
-
.filter(([_, m]) => m[0] & 15 /* HasAttribute */) // filter to only keep props that should match attributes
|
|
1259
|
+
.filter(([_, m]) => m[0] & 15 /* MEMBER_FLAGS.HasAttribute */) // filter to only keep props that should match attributes
|
|
1139
1260
|
.map(([propName, m]) => {
|
|
1140
1261
|
const attrName = m[1] || propName;
|
|
1141
1262
|
attrNameToPropName.set(attrName, propName);
|
|
1142
|
-
if (m[0] & 512 /* ReflectAttr */) {
|
|
1263
|
+
if (m[0] & 512 /* MEMBER_FLAGS.ReflectAttr */) {
|
|
1143
1264
|
cmpMeta.$attrsToReflect$.push([propName, attrName]);
|
|
1144
1265
|
}
|
|
1145
1266
|
return attrName;
|
|
@@ -1150,10 +1271,10 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1150
1271
|
};
|
|
1151
1272
|
const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
|
|
1152
1273
|
// initializeComponent
|
|
1153
|
-
if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
|
|
1274
|
+
if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
|
|
1154
1275
|
{
|
|
1155
1276
|
// we haven't initialized this element yet
|
|
1156
|
-
hostRef.$flags$ |= 32 /* hasInitializedComponent */;
|
|
1277
|
+
hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
|
|
1157
1278
|
// lazy loaded components
|
|
1158
1279
|
// request the component's implementation to be
|
|
1159
1280
|
// wired up with the host element
|
|
@@ -1171,7 +1292,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1171
1292
|
{
|
|
1172
1293
|
cmpMeta.$watchers$ = Cstr.watchers;
|
|
1173
1294
|
}
|
|
1174
|
-
proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
|
|
1295
|
+
proxyComponent(Cstr, cmpMeta, 2 /* PROXY_FLAGS.proxyState */);
|
|
1175
1296
|
Cstr.isProxied = true;
|
|
1176
1297
|
}
|
|
1177
1298
|
const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
|
|
@@ -1179,7 +1300,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1179
1300
|
// but let's keep track of when we start and stop
|
|
1180
1301
|
// so that the getters/setters don't incorrectly step on data
|
|
1181
1302
|
{
|
|
1182
|
-
hostRef.$flags$ |= 8 /* isConstructingInstance */;
|
|
1303
|
+
hostRef.$flags$ |= 8 /* HOST_FLAGS.isConstructingInstance */;
|
|
1183
1304
|
}
|
|
1184
1305
|
// construct the lazy-loaded component implementation
|
|
1185
1306
|
// passing the hostRef is very important during
|
|
@@ -1192,10 +1313,10 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1192
1313
|
consoleError(e);
|
|
1193
1314
|
}
|
|
1194
1315
|
{
|
|
1195
|
-
hostRef.$flags$ &= ~8 /* isConstructingInstance */;
|
|
1316
|
+
hostRef.$flags$ &= ~8 /* HOST_FLAGS.isConstructingInstance */;
|
|
1196
1317
|
}
|
|
1197
1318
|
{
|
|
1198
|
-
hostRef.$flags$ |= 128 /* isWatchReady */;
|
|
1319
|
+
hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */;
|
|
1199
1320
|
}
|
|
1200
1321
|
endNewInstance();
|
|
1201
1322
|
}
|
|
@@ -1205,7 +1326,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1205
1326
|
const scopeId = getScopeId(cmpMeta);
|
|
1206
1327
|
if (!styles.has(scopeId)) {
|
|
1207
1328
|
const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
|
|
1208
|
-
registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
|
|
1329
|
+
registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
|
|
1209
1330
|
endRegisterStyles();
|
|
1210
1331
|
}
|
|
1211
1332
|
}
|
|
@@ -1227,13 +1348,13 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1227
1348
|
}
|
|
1228
1349
|
};
|
|
1229
1350
|
const connectedCallback = (elm) => {
|
|
1230
|
-
if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
|
|
1351
|
+
if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
|
|
1231
1352
|
const hostRef = getHostRef(elm);
|
|
1232
1353
|
const cmpMeta = hostRef.$cmpMeta$;
|
|
1233
1354
|
const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
|
|
1234
|
-
if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
|
|
1355
|
+
if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
|
|
1235
1356
|
// first time this component has connected
|
|
1236
|
-
hostRef.$flags$ |= 1 /* hasConnected */;
|
|
1357
|
+
hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
|
|
1237
1358
|
{
|
|
1238
1359
|
// find the first ancestor component (if there is one) and register
|
|
1239
1360
|
// this component as one of the actively loading child components for its ancestor
|
|
@@ -1253,7 +1374,7 @@ const connectedCallback = (elm) => {
|
|
|
1253
1374
|
// https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
|
|
1254
1375
|
if (cmpMeta.$members$) {
|
|
1255
1376
|
Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
|
|
1256
|
-
if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
|
|
1377
|
+
if (memberFlags & 31 /* MEMBER_FLAGS.Prop */ && elm.hasOwnProperty(memberName)) {
|
|
1257
1378
|
const value = elm[memberName];
|
|
1258
1379
|
delete elm[memberName];
|
|
1259
1380
|
elm[memberName] = value;
|
|
@@ -1274,7 +1395,7 @@ const connectedCallback = (elm) => {
|
|
|
1274
1395
|
}
|
|
1275
1396
|
};
|
|
1276
1397
|
const disconnectedCallback = (elm) => {
|
|
1277
|
-
if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
|
|
1398
|
+
if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
|
|
1278
1399
|
const hostRef = getHostRef(elm);
|
|
1279
1400
|
const instance = hostRef.$lazyInstance$ ;
|
|
1280
1401
|
{
|
|
@@ -1329,7 +1450,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1329
1450
|
super(self);
|
|
1330
1451
|
self = this;
|
|
1331
1452
|
registerHost(self, cmpMeta);
|
|
1332
|
-
if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
|
|
1453
|
+
if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
|
|
1333
1454
|
// this component is using shadow dom
|
|
1334
1455
|
// and this browser supports shadow dom
|
|
1335
1456
|
// add the read-only property "shadowRoot" to the host element
|
|
@@ -1364,7 +1485,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1364
1485
|
cmpMeta.$lazyBundleId$ = lazyBundle[0];
|
|
1365
1486
|
if (!exclude.includes(tagName) && !customElements.get(tagName)) {
|
|
1366
1487
|
cmpTags.push(tagName);
|
|
1367
|
-
customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
|
|
1488
|
+
customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */));
|
|
1368
1489
|
}
|
|
1369
1490
|
});
|
|
1370
1491
|
});
|
|
@@ -1386,12 +1507,41 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1386
1507
|
// Fallback appLoad event
|
|
1387
1508
|
endBootstrap();
|
|
1388
1509
|
};
|
|
1389
|
-
const
|
|
1390
|
-
|
|
1391
|
-
|
|
1510
|
+
const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
|
|
1511
|
+
if (listeners) {
|
|
1512
|
+
listeners.map(([flags, name, method]) => {
|
|
1513
|
+
const target = getHostListenerTarget(elm, flags) ;
|
|
1514
|
+
const handler = hostListenerProxy(hostRef, method);
|
|
1515
|
+
const opts = hostListenerOpts(flags);
|
|
1516
|
+
plt.ael(target, name, handler, opts);
|
|
1517
|
+
(hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
|
|
1518
|
+
});
|
|
1519
|
+
}
|
|
1392
1520
|
};
|
|
1393
|
-
const
|
|
1394
|
-
|
|
1521
|
+
const hostListenerProxy = (hostRef, methodName) => (ev) => {
|
|
1522
|
+
try {
|
|
1523
|
+
{
|
|
1524
|
+
if (hostRef.$flags$ & 256 /* HOST_FLAGS.isListenReady */) {
|
|
1525
|
+
// instance is ready, let's call it's member method for this event
|
|
1526
|
+
hostRef.$lazyInstance$[methodName](ev);
|
|
1527
|
+
}
|
|
1528
|
+
else {
|
|
1529
|
+
(hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
|
|
1530
|
+
}
|
|
1531
|
+
}
|
|
1532
|
+
}
|
|
1533
|
+
catch (e) {
|
|
1534
|
+
consoleError(e);
|
|
1535
|
+
}
|
|
1536
|
+
};
|
|
1537
|
+
const getHostListenerTarget = (elm, flags) => {
|
|
1538
|
+
if (flags & 4 /* LISTENER_FLAGS.TargetDocument */)
|
|
1539
|
+
return doc;
|
|
1540
|
+
return elm;
|
|
1541
|
+
};
|
|
1542
|
+
// prettier-ignore
|
|
1543
|
+
const hostListenerOpts = (flags) => (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0;
|
|
1544
|
+
const hostRefs = /*@__PURE__*/ new WeakMap();
|
|
1395
1545
|
const getHostRef = (ref) => hostRefs.get(ref);
|
|
1396
1546
|
const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
|
|
1397
1547
|
const registerHost = (elm, cmpMeta) => {
|
|
@@ -1436,14 +1586,35 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
|
|
|
1436
1586
|
return importedModule[exportName];
|
|
1437
1587
|
}, consoleError);
|
|
1438
1588
|
};
|
|
1439
|
-
const styles = new Map();
|
|
1589
|
+
const styles = /*@__PURE__*/ new Map();
|
|
1590
|
+
const win = typeof window !== 'undefined' ? window : {};
|
|
1591
|
+
const doc = win.document || { head: {} };
|
|
1592
|
+
const plt = {
|
|
1593
|
+
$flags$: 0,
|
|
1594
|
+
$resourcesUrl$: '',
|
|
1595
|
+
jmp: (h) => h(),
|
|
1596
|
+
raf: (h) => requestAnimationFrame(h),
|
|
1597
|
+
ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
|
|
1598
|
+
rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
|
|
1599
|
+
ce: (eventName, opts) => new CustomEvent(eventName, opts),
|
|
1600
|
+
};
|
|
1601
|
+
const promiseResolve = (v) => Promise.resolve(v);
|
|
1602
|
+
const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
|
|
1603
|
+
try {
|
|
1604
|
+
new CSSStyleSheet();
|
|
1605
|
+
return typeof new CSSStyleSheet().replaceSync === 'function';
|
|
1606
|
+
}
|
|
1607
|
+
catch (e) { }
|
|
1608
|
+
return false;
|
|
1609
|
+
})()
|
|
1610
|
+
;
|
|
1440
1611
|
const queueDomReads = [];
|
|
1441
1612
|
const queueDomWrites = [];
|
|
1442
1613
|
const queueTask = (queue, write) => (cb) => {
|
|
1443
1614
|
queue.push(cb);
|
|
1444
1615
|
if (!queuePending) {
|
|
1445
1616
|
queuePending = true;
|
|
1446
|
-
if (write && plt.$flags$ & 4 /* queueSync */) {
|
|
1617
|
+
if (write && plt.$flags$ & 4 /* PLATFORM_FLAGS.queueSync */) {
|
|
1447
1618
|
nextTick(flush);
|
|
1448
1619
|
}
|
|
1449
1620
|
else {
|