@sankhyalabs/sankhyablocks 1.3.31-beta.16 → 1.3.31-beta.18
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/{SnkMessageBuilder-79cf15c5.js → SnkMessageBuilder-02c2ca02.js} +137 -1
- package/dist/cjs/app-globals-3a1e7e63.js +5 -0
- package/dist/cjs/css-shim-b8158822.js +6 -0
- package/dist/cjs/dom-36862b77.js +75 -0
- package/dist/cjs/filter-item-type.enum-e2e1bc5b.js +14 -0
- package/dist/cjs/index-02201bc9.js +2397 -0
- package/dist/cjs/{index-5575fe3d.js → index-b0b676c5.js} +1598 -145
- package/dist/cjs/loader.cjs.js +18 -2
- package/dist/cjs/sankhyablocks.cjs.js +116 -4
- package/dist/cjs/shadow-css-346c0795.js +389 -0
- package/dist/cjs/snk-application.cjs.entry.js +662 -66
- package/dist/cjs/snk-crud.cjs.entry.js +3 -2
- package/dist/cjs/snk-data-unit.cjs.entry.js +23 -24
- package/dist/cjs/snk-filter-bar.cjs.entry.js +247 -0
- package/dist/cjs/snk-filter-binary-select.cjs.entry.js +47 -0
- package/dist/cjs/snk-filter-detail.cjs.entry.js +49 -0
- package/dist/cjs/snk-filter-item.cjs.entry.js +143 -0
- package/dist/cjs/snk-filter-list.cjs.entry.js +91 -0
- package/dist/cjs/snk-filter-multi-select.cjs.entry.js +23 -0
- package/dist/cjs/snk-filter-number.cjs.entry.js +24 -0
- package/dist/cjs/snk-filter-period.cjs.entry.js +26 -0
- package/dist/cjs/snk-filter-search.cjs.entry.js +44 -0
- package/dist/cjs/snk-filter-text.cjs.entry.js +22 -0
- package/dist/cjs/{snk-form_2.cjs.entry.js → snk-form.cjs.entry.js} +21 -65
- package/dist/cjs/snk-grid.cjs.entry.js +79 -0
- package/dist/cjs/snk-pesquisa.cjs.entry.js +5 -5
- package/dist/cjs/snk-taskbar.cjs.entry.js +17 -13
- package/dist/cjs/{taskbar-elements-2ae0d005.js → taskbar-elements-283c737e.js} +37 -18
- package/dist/cjs/taskbar-processor-6bd0d35c.js +47 -0
- package/dist/cjs/teste-pesquisa.cjs.entry.js +5 -5
- package/dist/collection/collection-manifest.json +10 -0
- package/dist/collection/components/snk-application/errorhandler/snk-error-handler.js +7 -0
- package/dist/collection/components/snk-application/snk-application.js +89 -17
- package/dist/collection/components/snk-crud/snk-crud.js +41 -3
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-binary-select.js +88 -0
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-multi-select.js +64 -0
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-number.js +65 -0
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-period.js +69 -0
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-search.js +118 -0
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-text.js +63 -0
- package/dist/collection/components/snk-filter-bar/filter-item/filter-item-type.enum.js +10 -0
- package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-detail.js +118 -0
- package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-item.js +244 -0
- package/dist/collection/components/snk-filter-bar/filter-list/snk-filter-list.js +233 -0
- package/dist/collection/components/snk-filter-bar/snk-filter-bar.css +114 -0
- package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +305 -0
- package/dist/collection/components/snk-form/snk-form.js +41 -1
- package/dist/collection/components/snk-grid/snk-grid.css +14 -1
- package/dist/collection/components/snk-grid/snk-grid.js +35 -3
- package/dist/collection/components/snk-taskbar/elements/taskbar-elements.js +35 -17
- package/dist/collection/components/snk-taskbar/processor/taskbar-processor.js +43 -0
- package/dist/collection/components/snk-taskbar/snk-taskbar.js +36 -11
- package/dist/collection/lib/http/data-fetcher/DataFetcher.js +24 -2
- package/dist/collection/lib/http/data-fetcher/fetchers/dataunit-fetcher.js +1 -1
- package/dist/collection/lib/http/data-fetcher/fetchers/filter-bar-config-fetcher.js +388 -0
- package/dist/collection/lib/message/SnkMessageBuilder.js +3 -1
- package/dist/collection/lib/message/resources/snk-filter-bar.msg.js +18 -0
- package/dist/components/SnkMessageBuilder.js +137 -2
- package/dist/components/filter-item-type.enum.js +12 -0
- package/dist/components/index.d.ts +10 -0
- package/dist/components/index.js +14 -0
- package/dist/components/index2.js +2384 -0
- package/dist/components/snk-application2.js +628 -30
- package/dist/components/snk-crud.js +29 -3
- package/dist/components/snk-data-unit.js +2 -3
- package/dist/components/snk-filter-bar.d.ts +11 -0
- package/dist/components/snk-filter-bar.js +6 -0
- package/dist/components/snk-filter-bar2.js +278 -0
- package/dist/components/snk-filter-binary-select.d.ts +11 -0
- package/dist/components/snk-filter-binary-select.js +63 -0
- package/dist/components/snk-filter-detail.d.ts +11 -0
- package/dist/components/snk-filter-detail.js +6 -0
- package/dist/components/snk-filter-detail2.js +63 -0
- package/dist/components/snk-filter-item.d.ts +11 -0
- package/dist/components/snk-filter-item.js +6 -0
- package/dist/components/snk-filter-item2.js +164 -0
- package/dist/components/snk-filter-list.d.ts +11 -0
- package/dist/components/snk-filter-list.js +6 -0
- package/dist/components/snk-filter-list2.js +111 -0
- package/dist/components/snk-filter-multi-select.d.ts +11 -0
- package/dist/components/snk-filter-multi-select.js +39 -0
- package/dist/components/snk-filter-number.d.ts +11 -0
- package/dist/components/snk-filter-number.js +40 -0
- package/dist/components/snk-filter-period.d.ts +11 -0
- package/dist/components/snk-filter-period.js +42 -0
- package/dist/components/snk-filter-search.d.ts +11 -0
- package/dist/components/snk-filter-search.js +62 -0
- package/dist/components/snk-filter-text.d.ts +11 -0
- package/dist/components/snk-filter-text.js +38 -0
- package/dist/components/snk-form2.js +21 -2
- package/dist/components/snk-grid2.js +42 -7
- package/dist/components/snk-pesquisa2.js +1 -1
- package/dist/components/snk-taskbar2.js +50 -27
- package/dist/components/taskbar-processor.js +45 -0
- package/dist/components/teste-pesquisa.js +1 -1
- package/dist/esm/{SnkMessageBuilder-3cdde541.js → SnkMessageBuilder-65d431bd.js} +137 -2
- package/dist/esm/app-globals-0f993ce5.js +3 -0
- package/dist/esm/css-shim-b3f2ee8d.js +4 -0
- package/dist/esm/dom-665d6011.js +73 -0
- package/dist/esm/filter-item-type.enum-61fbf80a.js +12 -0
- package/dist/esm/index-2b4d2d14.js +3262 -0
- package/dist/esm/index-e5b61043.js +2384 -0
- package/dist/esm/loader.js +18 -2
- package/dist/esm/sankhyablocks.js +116 -4
- package/dist/esm/shadow-css-b18e99d7.js +387 -0
- package/dist/esm/snk-application.entry.js +627 -31
- package/dist/esm/snk-crud.entry.js +3 -2
- package/dist/esm/snk-data-unit.entry.js +3 -4
- package/dist/esm/snk-filter-bar.entry.js +243 -0
- package/dist/esm/snk-filter-binary-select.entry.js +43 -0
- package/dist/esm/snk-filter-detail.entry.js +45 -0
- package/dist/esm/snk-filter-item.entry.js +139 -0
- package/dist/esm/snk-filter-list.entry.js +87 -0
- package/dist/esm/snk-filter-multi-select.entry.js +19 -0
- package/dist/esm/snk-filter-number.entry.js +20 -0
- package/dist/esm/snk-filter-period.entry.js +22 -0
- package/dist/esm/snk-filter-search.entry.js +40 -0
- package/dist/esm/snk-filter-text.entry.js +18 -0
- package/dist/esm/{snk-form_2.entry.js → snk-form.entry.js} +21 -64
- package/dist/esm/snk-grid.entry.js +75 -0
- package/dist/esm/snk-pesquisa.entry.js +2 -2
- package/dist/esm/snk-taskbar.entry.js +16 -12
- package/dist/esm/taskbar-elements-35d64ff9.js +90 -0
- package/dist/esm/taskbar-processor-aa6772c9.js +45 -0
- package/dist/esm/teste-pesquisa.entry.js +2 -2
- package/dist/sankhyablocks/SnkMessageBuilder-65d431bd.js +303 -0
- package/dist/sankhyablocks/app-globals-0f993ce5.js +3 -0
- package/dist/sankhyablocks/css-shim-b3f2ee8d.js +4 -0
- package/dist/sankhyablocks/dom-665d6011.js +73 -0
- package/dist/sankhyablocks/filter-item-type.enum-61fbf80a.js +12 -0
- package/dist/sankhyablocks/index-2b4d2d14.js +3262 -0
- package/dist/sankhyablocks/index-e5b61043.js +2384 -0
- package/dist/sankhyablocks/index.esm.js +1 -0
- package/dist/sankhyablocks/sankhyablocks.esm.js +129 -1
- package/dist/sankhyablocks/shadow-css-b18e99d7.js +387 -0
- package/dist/sankhyablocks/snk-application.entry.js +8426 -0
- package/dist/sankhyablocks/snk-crud.entry.js +61 -0
- package/dist/sankhyablocks/snk-data-unit.entry.js +272 -0
- package/dist/sankhyablocks/snk-filter-bar.entry.js +243 -0
- package/dist/sankhyablocks/snk-filter-binary-select.entry.js +43 -0
- package/dist/sankhyablocks/snk-filter-detail.entry.js +45 -0
- package/dist/sankhyablocks/snk-filter-item.entry.js +139 -0
- package/dist/sankhyablocks/snk-filter-list.entry.js +87 -0
- package/dist/sankhyablocks/snk-filter-multi-select.entry.js +19 -0
- package/dist/sankhyablocks/snk-filter-number.entry.js +20 -0
- package/dist/sankhyablocks/snk-filter-period.entry.js +22 -0
- package/dist/sankhyablocks/snk-filter-search.entry.js +40 -0
- package/dist/sankhyablocks/snk-filter-text.entry.js +18 -0
- package/dist/sankhyablocks/snk-form.entry.js +129 -0
- package/dist/sankhyablocks/snk-grid.entry.js +75 -0
- package/dist/sankhyablocks/snk-pesquisa.entry.js +311 -0
- package/dist/sankhyablocks/snk-taskbar.entry.js +156 -0
- package/dist/sankhyablocks/taskbar-elements-35d64ff9.js +90 -0
- package/dist/sankhyablocks/taskbar-processor-aa6772c9.js +45 -0
- package/dist/sankhyablocks/teste-pesquisa.entry.js +33 -0
- package/dist/types/components/snk-application/errorhandler/snk-error-handler.d.ts +1 -0
- package/dist/types/components/snk-application/snk-application.d.ts +9 -0
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-binary-select.d.ts +12 -0
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-multi-select.d.ts +7 -0
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-number.d.ts +7 -0
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-period.d.ts +13 -0
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-search.d.ts +12 -0
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-text.d.ts +7 -0
- package/dist/types/components/snk-filter-bar/filter-item/filter-item-type.enum.d.ts +9 -0
- package/dist/types/components/snk-filter-bar/filter-item/snk-filter-detail.d.ts +14 -0
- package/dist/types/components/snk-filter-bar/filter-list/snk-filter-list.d.ts +40 -0
- package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +45 -0
- package/dist/types/components/snk-taskbar/elements/taskbar-elements.d.ts +3 -2
- package/dist/types/components/snk-taskbar/processor/taskbar-processor.d.ts +12 -0
- package/dist/types/components/snk-taskbar/snk-taskbar.d.ts +17 -1
- package/dist/types/components.d.ts +277 -2
- package/dist/types/lib/http/data-fetcher/DataFetcher.d.ts +1 -0
- package/dist/types/lib/http/data-fetcher/fetchers/filter-bar-config-fetcher.d.ts +5 -0
- package/dist/types/lib/message/resources/snk-filter-bar.msg.d.ts +2 -0
- package/package.json +2 -2
- package/react/components.d.ts +0 -7
- package/react/components.js +0 -7
- package/react/components.js.map +1 -1
- package/dist/esm/index-cf91f542.js +0 -1817
- package/dist/esm/taskbar-elements-bcccc0ff.js +0 -72
- package/dist/sankhyablocks/p-1ba29824.entry.js +0 -74
- package/dist/sankhyablocks/p-2266555e.entry.js +0 -1
- package/dist/sankhyablocks/p-23c4c94f.js +0 -2
- package/dist/sankhyablocks/p-2454be94.js +0 -1
- package/dist/sankhyablocks/p-49743bc5.js +0 -1
- package/dist/sankhyablocks/p-4fa389bd.entry.js +0 -1
- package/dist/sankhyablocks/p-5327ba05.entry.js +0 -1
- package/dist/sankhyablocks/p-7a922fb4.entry.js +0 -1
- package/dist/sankhyablocks/p-92d6f826.entry.js +0 -1
- package/dist/sankhyablocks/p-bdeef7f2.entry.js +0 -1
|
@@ -21,6 +21,8 @@ function _interopNamespace(e) {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
const NAMESPACE = 'sankhyablocks';
|
|
24
|
+
const BUILD = /* sankhyablocks */ { allRenderFn: true, appendChildSlotFix: false, asyncLoading: true, asyncQueue: false, attachStyles: true, cloneNodeFix: false, cmpDidLoad: true, cmpDidRender: true, cmpDidUnload: false, cmpDidUpdate: false, cmpShouldUpdate: false, cmpWillLoad: true, cmpWillRender: true, cmpWillUpdate: false, connectedCallback: true, constructableCSS: true, cssAnnotations: true, cssVarShim: false, devTools: false, disconnectedCallback: true, dynamicImportShim: false, element: false, event: true, hasRenderFn: true, hostListener: true, hostListenerTarget: false, hostListenerTargetBody: false, hostListenerTargetDocument: false, hostListenerTargetParent: false, hostListenerTargetWindow: false, hotModuleReplacement: false, hydrateClientSide: false, hydrateServerSide: false, hydratedAttribute: false, hydratedClass: true, initializeNextTick: false, invisiblePrehydration: true, isDebug: false, isDev: true, isTesting: true, lazyLoad: true, lifecycle: true, lifecycleDOMEvents: true, member: true, method: true, mode: false, observeAttribute: true, profile: false, prop: true, propBoolean: true, propMutable: true, propNumber: true, propString: true, reflect: true, safari10: false, scoped: true, scopedSlotTextContentFix: false, scriptDataOpts: false, shadowDelegatesFocus: false, shadowDom: true, shadowDomShim: false, slot: true, slotChildNodesFix: false, slotRelocation: true, state: true, style: true, svg: false, taskQueue: true, transformTagName: false, updatable: true, vdomAttribute: true, vdomClass: true, vdomFunctional: true, vdomKey: true, vdomListener: true, vdomPropOrAttr: true, vdomRef: true, vdomRender: true, vdomStyle: false, vdomText: true, vdomXlink: false, watchCallback: true };
|
|
25
|
+
const Env = /* sankhyablocks */ {};
|
|
24
26
|
|
|
25
27
|
/**
|
|
26
28
|
* Virtual DOM patching algorithm based on Snabbdom by
|
|
@@ -33,26 +35,122 @@ const NAMESPACE = 'sankhyablocks';
|
|
|
33
35
|
let scopeId;
|
|
34
36
|
let contentRef;
|
|
35
37
|
let hostTagName;
|
|
38
|
+
let customError;
|
|
39
|
+
let i = 0;
|
|
36
40
|
let useNativeShadowDom = false;
|
|
37
41
|
let checkSlotFallbackVisibility = false;
|
|
38
42
|
let checkSlotRelocate = false;
|
|
39
43
|
let isSvgMode = false;
|
|
44
|
+
let renderingRef = null;
|
|
45
|
+
let queueCongestion = 0;
|
|
40
46
|
let queuePending = false;
|
|
47
|
+
const Build = {
|
|
48
|
+
isDev: BUILD.isDev ? true : false,
|
|
49
|
+
isBrowser: true,
|
|
50
|
+
isServer: false,
|
|
51
|
+
isTesting: BUILD.isTesting ? true : false,
|
|
52
|
+
};
|
|
53
|
+
const Context = {};
|
|
54
|
+
const getAssetPath = (path) => {
|
|
55
|
+
const assetUrl = new URL(path, plt.$resourcesUrl$);
|
|
56
|
+
return assetUrl.origin !== win.location.origin ? assetUrl.href : assetUrl.pathname;
|
|
57
|
+
};
|
|
58
|
+
const setAssetPath = (path) => (plt.$resourcesUrl$ = path);
|
|
41
59
|
const createTime = (fnName, tagName = '') => {
|
|
42
|
-
{
|
|
60
|
+
if (BUILD.profile && performance.mark) {
|
|
61
|
+
const key = `st:${fnName}:${tagName}:${i++}`;
|
|
62
|
+
// Start
|
|
63
|
+
performance.mark(key);
|
|
64
|
+
// End
|
|
65
|
+
return () => performance.measure(`[Stencil] ${fnName}() <${tagName}>`, key);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
43
68
|
return () => {
|
|
44
69
|
return;
|
|
45
70
|
};
|
|
46
71
|
}
|
|
47
72
|
};
|
|
48
73
|
const uniqueTime = (key, measureText) => {
|
|
49
|
-
{
|
|
74
|
+
if (BUILD.profile && performance.mark) {
|
|
75
|
+
if (performance.getEntriesByName(key).length === 0) {
|
|
76
|
+
performance.mark(key);
|
|
77
|
+
}
|
|
78
|
+
return () => {
|
|
79
|
+
if (performance.getEntriesByName(measureText).length === 0) {
|
|
80
|
+
performance.measure(measureText, key);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
50
85
|
return () => {
|
|
51
86
|
return;
|
|
52
87
|
};
|
|
53
88
|
}
|
|
54
89
|
};
|
|
90
|
+
const inspect = (ref) => {
|
|
91
|
+
const hostRef = getHostRef(ref);
|
|
92
|
+
if (!hostRef) {
|
|
93
|
+
return undefined;
|
|
94
|
+
}
|
|
95
|
+
const flags = hostRef.$flags$;
|
|
96
|
+
const hostElement = hostRef.$hostElement$;
|
|
97
|
+
return {
|
|
98
|
+
renderCount: hostRef.$renderCount$,
|
|
99
|
+
flags: {
|
|
100
|
+
hasRendered: !!(flags & 2 /* HOST_FLAGS.hasRendered */),
|
|
101
|
+
hasConnected: !!(flags & 1 /* HOST_FLAGS.hasConnected */),
|
|
102
|
+
isWaitingForChildren: !!(flags & 4 /* HOST_FLAGS.isWaitingForChildren */),
|
|
103
|
+
isConstructingInstance: !!(flags & 8 /* HOST_FLAGS.isConstructingInstance */),
|
|
104
|
+
isQueuedForUpdate: !!(flags & 16 /* HOST_FLAGS.isQueuedForUpdate */),
|
|
105
|
+
hasInitializedComponent: !!(flags & 32 /* HOST_FLAGS.hasInitializedComponent */),
|
|
106
|
+
hasLoadedComponent: !!(flags & 64 /* HOST_FLAGS.hasLoadedComponent */),
|
|
107
|
+
isWatchReady: !!(flags & 128 /* HOST_FLAGS.isWatchReady */),
|
|
108
|
+
isListenReady: !!(flags & 256 /* HOST_FLAGS.isListenReady */),
|
|
109
|
+
needsRerender: !!(flags & 512 /* HOST_FLAGS.needsRerender */),
|
|
110
|
+
},
|
|
111
|
+
instanceValues: hostRef.$instanceValues$,
|
|
112
|
+
ancestorComponent: hostRef.$ancestorComponent$,
|
|
113
|
+
hostElement,
|
|
114
|
+
lazyInstance: hostRef.$lazyInstance$,
|
|
115
|
+
vnode: hostRef.$vnode$,
|
|
116
|
+
modeName: hostRef.$modeName$,
|
|
117
|
+
onReadyPromise: hostRef.$onReadyPromise$,
|
|
118
|
+
onReadyResolve: hostRef.$onReadyResolve$,
|
|
119
|
+
onInstancePromise: hostRef.$onInstancePromise$,
|
|
120
|
+
onInstanceResolve: hostRef.$onInstanceResolve$,
|
|
121
|
+
onRenderResolve: hostRef.$onRenderResolve$,
|
|
122
|
+
queuedListeners: hostRef.$queuedListeners$,
|
|
123
|
+
rmListeners: hostRef.$rmListeners$,
|
|
124
|
+
['s-id']: hostElement['s-id'],
|
|
125
|
+
['s-cr']: hostElement['s-cr'],
|
|
126
|
+
['s-lr']: hostElement['s-lr'],
|
|
127
|
+
['s-p']: hostElement['s-p'],
|
|
128
|
+
['s-rc']: hostElement['s-rc'],
|
|
129
|
+
['s-sc']: hostElement['s-sc'],
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
const installDevTools = () => {
|
|
133
|
+
if (BUILD.devTools) {
|
|
134
|
+
const stencil = (win.stencil = win.stencil || {});
|
|
135
|
+
const originalInspect = stencil.inspect;
|
|
136
|
+
stencil.inspect = (ref) => {
|
|
137
|
+
let result = inspect(ref);
|
|
138
|
+
if (!result && typeof originalInspect === 'function') {
|
|
139
|
+
result = originalInspect(ref);
|
|
140
|
+
}
|
|
141
|
+
return result;
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
const CONTENT_REF_ID = 'r';
|
|
146
|
+
const ORG_LOCATION_ID = 'o';
|
|
147
|
+
const SLOT_NODE_ID = 's';
|
|
148
|
+
const TEXT_NODE_ID = 't';
|
|
149
|
+
const HYDRATE_ID = 's-id';
|
|
150
|
+
const HYDRATED_STYLE_ID = 'sty-id';
|
|
151
|
+
const HYDRATE_CHILD_ID = 'c-id';
|
|
55
152
|
const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
|
|
153
|
+
const XLINK_NS = 'http://www.w3.org/1999/xlink';
|
|
56
154
|
/**
|
|
57
155
|
* Default style mode id
|
|
58
156
|
*/
|
|
@@ -61,6 +159,11 @@ const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
|
|
|
61
159
|
* Don't add values to these!!
|
|
62
160
|
*/
|
|
63
161
|
const EMPTY_OBJ = {};
|
|
162
|
+
/**
|
|
163
|
+
* Namespaces
|
|
164
|
+
*/
|
|
165
|
+
const SVG_NS = 'http://www.w3.org/2000/svg';
|
|
166
|
+
const HTML_NS = 'http://www.w3.org/1999/xhtml';
|
|
64
167
|
const isDef = (v) => v != null;
|
|
65
168
|
const isComplexType = (o) => {
|
|
66
169
|
// https://jsperf.com/typeof-fn-object/5
|
|
@@ -95,6 +198,11 @@ const h = (nodeName, vnodeData, ...children) => {
|
|
|
95
198
|
if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
|
|
96
199
|
child = String(child);
|
|
97
200
|
}
|
|
201
|
+
else if (BUILD.isDev && typeof nodeName !== 'function' && child.$flags$ === undefined) {
|
|
202
|
+
consoleDevError(`vNode passed as children has unexpected type.
|
|
203
|
+
Make sure it's using the correct h() function.
|
|
204
|
+
Empty objects can also be the cause, look for JSX comments that became objects.`);
|
|
205
|
+
}
|
|
98
206
|
if (simple && lastSimple) {
|
|
99
207
|
// If the previous child was simple (string), we merge both
|
|
100
208
|
vNodeChildren[vNodeChildren.length - 1].$text$ += child;
|
|
@@ -109,14 +217,17 @@ const h = (nodeName, vnodeData, ...children) => {
|
|
|
109
217
|
};
|
|
110
218
|
walk(children);
|
|
111
219
|
if (vnodeData) {
|
|
220
|
+
if (BUILD.isDev && nodeName === 'input') {
|
|
221
|
+
validateInputProperties(vnodeData);
|
|
222
|
+
}
|
|
112
223
|
// normalize class / classname attributes
|
|
113
|
-
if (vnodeData.key) {
|
|
224
|
+
if (BUILD.vdomKey && vnodeData.key) {
|
|
114
225
|
key = vnodeData.key;
|
|
115
226
|
}
|
|
116
|
-
if (vnodeData.name) {
|
|
227
|
+
if (BUILD.slotRelocation && vnodeData.name) {
|
|
117
228
|
slotName = vnodeData.name;
|
|
118
229
|
}
|
|
119
|
-
{
|
|
230
|
+
if (BUILD.vdomClass) {
|
|
120
231
|
const classData = vnodeData.className || vnodeData.class;
|
|
121
232
|
if (classData) {
|
|
122
233
|
vnodeData.class =
|
|
@@ -128,15 +239,24 @@ const h = (nodeName, vnodeData, ...children) => {
|
|
|
128
239
|
}
|
|
129
240
|
}
|
|
130
241
|
}
|
|
242
|
+
if (BUILD.isDev && vNodeChildren.some(isHost)) {
|
|
243
|
+
consoleDevError(`The <Host> must be the single root component. Make sure:
|
|
244
|
+
- You are NOT using hostData() and <Host> in the same component.
|
|
245
|
+
- <Host> is used once, and it's the single root component of the render() function.`);
|
|
246
|
+
}
|
|
247
|
+
if (BUILD.vdomFunctional && typeof nodeName === 'function') {
|
|
248
|
+
// nodeName is a functional component
|
|
249
|
+
return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
|
|
250
|
+
}
|
|
131
251
|
const vnode = newVNode(nodeName, null);
|
|
132
252
|
vnode.$attrs$ = vnodeData;
|
|
133
253
|
if (vNodeChildren.length > 0) {
|
|
134
254
|
vnode.$children$ = vNodeChildren;
|
|
135
255
|
}
|
|
136
|
-
{
|
|
256
|
+
if (BUILD.vdomKey) {
|
|
137
257
|
vnode.$key$ = key;
|
|
138
258
|
}
|
|
139
|
-
{
|
|
259
|
+
if (BUILD.slotRelocation) {
|
|
140
260
|
vnode.$name$ = slotName;
|
|
141
261
|
}
|
|
142
262
|
return vnode;
|
|
@@ -149,19 +269,277 @@ const newVNode = (tag, text) => {
|
|
|
149
269
|
$elm$: null,
|
|
150
270
|
$children$: null,
|
|
151
271
|
};
|
|
152
|
-
{
|
|
272
|
+
if (BUILD.vdomAttribute) {
|
|
153
273
|
vnode.$attrs$ = null;
|
|
154
274
|
}
|
|
155
|
-
{
|
|
275
|
+
if (BUILD.vdomKey) {
|
|
156
276
|
vnode.$key$ = null;
|
|
157
277
|
}
|
|
158
|
-
{
|
|
278
|
+
if (BUILD.slotRelocation) {
|
|
159
279
|
vnode.$name$ = null;
|
|
160
280
|
}
|
|
161
281
|
return vnode;
|
|
162
282
|
};
|
|
163
283
|
const Host = {};
|
|
164
284
|
const isHost = (node) => node && node.$tag$ === Host;
|
|
285
|
+
const vdomFnUtils = {
|
|
286
|
+
forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
|
|
287
|
+
map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate),
|
|
288
|
+
};
|
|
289
|
+
const convertToPublic = (node) => ({
|
|
290
|
+
vattrs: node.$attrs$,
|
|
291
|
+
vchildren: node.$children$,
|
|
292
|
+
vkey: node.$key$,
|
|
293
|
+
vname: node.$name$,
|
|
294
|
+
vtag: node.$tag$,
|
|
295
|
+
vtext: node.$text$,
|
|
296
|
+
});
|
|
297
|
+
const convertToPrivate = (node) => {
|
|
298
|
+
if (typeof node.vtag === 'function') {
|
|
299
|
+
const vnodeData = Object.assign({}, node.vattrs);
|
|
300
|
+
if (node.vkey) {
|
|
301
|
+
vnodeData.key = node.vkey;
|
|
302
|
+
}
|
|
303
|
+
if (node.vname) {
|
|
304
|
+
vnodeData.name = node.vname;
|
|
305
|
+
}
|
|
306
|
+
return h(node.vtag, vnodeData, ...(node.vchildren || []));
|
|
307
|
+
}
|
|
308
|
+
const vnode = newVNode(node.vtag, node.vtext);
|
|
309
|
+
vnode.$attrs$ = node.vattrs;
|
|
310
|
+
vnode.$children$ = node.vchildren;
|
|
311
|
+
vnode.$key$ = node.vkey;
|
|
312
|
+
vnode.$name$ = node.vname;
|
|
313
|
+
return vnode;
|
|
314
|
+
};
|
|
315
|
+
/**
|
|
316
|
+
* Validates the ordering of attributes on an input element
|
|
317
|
+
* @param inputElm the element to validate
|
|
318
|
+
*/
|
|
319
|
+
const validateInputProperties = (inputElm) => {
|
|
320
|
+
const props = Object.keys(inputElm);
|
|
321
|
+
const value = props.indexOf('value');
|
|
322
|
+
if (value === -1) {
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
const typeIndex = props.indexOf('type');
|
|
326
|
+
const minIndex = props.indexOf('min');
|
|
327
|
+
const maxIndex = props.indexOf('max');
|
|
328
|
+
const stepIndex = props.indexOf('step');
|
|
329
|
+
if (value < typeIndex || value < minIndex || value < maxIndex || value < stepIndex) {
|
|
330
|
+
consoleDevWarn(`The "value" prop of <input> should be set after "min", "max", "type" and "step"`);
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
|
|
334
|
+
const endHydrate = createTime('hydrateClient', tagName);
|
|
335
|
+
const shadowRoot = hostElm.shadowRoot;
|
|
336
|
+
const childRenderNodes = [];
|
|
337
|
+
const slotNodes = [];
|
|
338
|
+
const shadowRootNodes = BUILD.shadowDom && shadowRoot ? [] : null;
|
|
339
|
+
const vnode = (hostRef.$vnode$ = newVNode(tagName, null));
|
|
340
|
+
if (!plt.$orgLocNodes$) {
|
|
341
|
+
initializeDocumentHydrate(doc.body, (plt.$orgLocNodes$ = new Map()));
|
|
342
|
+
}
|
|
343
|
+
hostElm[HYDRATE_ID] = hostId;
|
|
344
|
+
hostElm.removeAttribute(HYDRATE_ID);
|
|
345
|
+
clientHydrate(vnode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, hostElm, hostId);
|
|
346
|
+
childRenderNodes.map((c) => {
|
|
347
|
+
const orgLocationId = c.$hostId$ + '.' + c.$nodeId$;
|
|
348
|
+
const orgLocationNode = plt.$orgLocNodes$.get(orgLocationId);
|
|
349
|
+
const node = c.$elm$;
|
|
350
|
+
if (orgLocationNode && supportsShadow && orgLocationNode['s-en'] === '') {
|
|
351
|
+
orgLocationNode.parentNode.insertBefore(node, orgLocationNode.nextSibling);
|
|
352
|
+
}
|
|
353
|
+
if (!shadowRoot) {
|
|
354
|
+
node['s-hn'] = tagName;
|
|
355
|
+
if (orgLocationNode) {
|
|
356
|
+
node['s-ol'] = orgLocationNode;
|
|
357
|
+
node['s-ol']['s-nr'] = node;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
plt.$orgLocNodes$.delete(orgLocationId);
|
|
361
|
+
});
|
|
362
|
+
if (BUILD.shadowDom && shadowRoot) {
|
|
363
|
+
shadowRootNodes.map((shadowRootNode) => {
|
|
364
|
+
if (shadowRootNode) {
|
|
365
|
+
shadowRoot.appendChild(shadowRootNode);
|
|
366
|
+
}
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
endHydrate();
|
|
370
|
+
};
|
|
371
|
+
const clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node, hostId) => {
|
|
372
|
+
let childNodeType;
|
|
373
|
+
let childIdSplt;
|
|
374
|
+
let childVNode;
|
|
375
|
+
let i;
|
|
376
|
+
if (node.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
377
|
+
childNodeType = node.getAttribute(HYDRATE_CHILD_ID);
|
|
378
|
+
if (childNodeType) {
|
|
379
|
+
// got the node data from the element's attribute
|
|
380
|
+
// `${hostId}.${nodeId}.${depth}.${index}`
|
|
381
|
+
childIdSplt = childNodeType.split('.');
|
|
382
|
+
if (childIdSplt[0] === hostId || childIdSplt[0] === '0') {
|
|
383
|
+
childVNode = {
|
|
384
|
+
$flags$: 0,
|
|
385
|
+
$hostId$: childIdSplt[0],
|
|
386
|
+
$nodeId$: childIdSplt[1],
|
|
387
|
+
$depth$: childIdSplt[2],
|
|
388
|
+
$index$: childIdSplt[3],
|
|
389
|
+
$tag$: node.tagName.toLowerCase(),
|
|
390
|
+
$elm$: node,
|
|
391
|
+
$attrs$: null,
|
|
392
|
+
$children$: null,
|
|
393
|
+
$key$: null,
|
|
394
|
+
$name$: null,
|
|
395
|
+
$text$: null,
|
|
396
|
+
};
|
|
397
|
+
childRenderNodes.push(childVNode);
|
|
398
|
+
node.removeAttribute(HYDRATE_CHILD_ID);
|
|
399
|
+
// this is a new child vnode
|
|
400
|
+
// so ensure its parent vnode has the vchildren array
|
|
401
|
+
if (!parentVNode.$children$) {
|
|
402
|
+
parentVNode.$children$ = [];
|
|
403
|
+
}
|
|
404
|
+
// add our child vnode to a specific index of the vnode's children
|
|
405
|
+
parentVNode.$children$[childVNode.$index$] = childVNode;
|
|
406
|
+
// this is now the new parent vnode for all the next child checks
|
|
407
|
+
parentVNode = childVNode;
|
|
408
|
+
if (shadowRootNodes && childVNode.$depth$ === '0') {
|
|
409
|
+
shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
// recursively drill down, end to start so we can remove nodes
|
|
414
|
+
for (i = node.childNodes.length - 1; i >= 0; i--) {
|
|
415
|
+
clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.childNodes[i], hostId);
|
|
416
|
+
}
|
|
417
|
+
if (node.shadowRoot) {
|
|
418
|
+
// keep drilling down through the shadow root nodes
|
|
419
|
+
for (i = node.shadowRoot.childNodes.length - 1; i >= 0; i--) {
|
|
420
|
+
clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.shadowRoot.childNodes[i], hostId);
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
else if (node.nodeType === 8 /* NODE_TYPE.CommentNode */) {
|
|
425
|
+
// `${COMMENT_TYPE}.${hostId}.${nodeId}.${depth}.${index}`
|
|
426
|
+
childIdSplt = node.nodeValue.split('.');
|
|
427
|
+
if (childIdSplt[1] === hostId || childIdSplt[1] === '0') {
|
|
428
|
+
// comment node for either the host id or a 0 host id
|
|
429
|
+
childNodeType = childIdSplt[0];
|
|
430
|
+
childVNode = {
|
|
431
|
+
$flags$: 0,
|
|
432
|
+
$hostId$: childIdSplt[1],
|
|
433
|
+
$nodeId$: childIdSplt[2],
|
|
434
|
+
$depth$: childIdSplt[3],
|
|
435
|
+
$index$: childIdSplt[4],
|
|
436
|
+
$elm$: node,
|
|
437
|
+
$attrs$: null,
|
|
438
|
+
$children$: null,
|
|
439
|
+
$key$: null,
|
|
440
|
+
$name$: null,
|
|
441
|
+
$tag$: null,
|
|
442
|
+
$text$: null,
|
|
443
|
+
};
|
|
444
|
+
if (childNodeType === TEXT_NODE_ID) {
|
|
445
|
+
childVNode.$elm$ = node.nextSibling;
|
|
446
|
+
if (childVNode.$elm$ && childVNode.$elm$.nodeType === 3 /* NODE_TYPE.TextNode */) {
|
|
447
|
+
childVNode.$text$ = childVNode.$elm$.textContent;
|
|
448
|
+
childRenderNodes.push(childVNode);
|
|
449
|
+
// remove the text comment since it's no longer needed
|
|
450
|
+
node.remove();
|
|
451
|
+
if (!parentVNode.$children$) {
|
|
452
|
+
parentVNode.$children$ = [];
|
|
453
|
+
}
|
|
454
|
+
parentVNode.$children$[childVNode.$index$] = childVNode;
|
|
455
|
+
if (shadowRootNodes && childVNode.$depth$ === '0') {
|
|
456
|
+
shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
else if (childVNode.$hostId$ === hostId) {
|
|
461
|
+
// this comment node is specifcally for this host id
|
|
462
|
+
if (childNodeType === SLOT_NODE_ID) {
|
|
463
|
+
// `${SLOT_NODE_ID}.${hostId}.${nodeId}.${depth}.${index}.${slotName}`;
|
|
464
|
+
childVNode.$tag$ = 'slot';
|
|
465
|
+
if (childIdSplt[5]) {
|
|
466
|
+
node['s-sn'] = childVNode.$name$ = childIdSplt[5];
|
|
467
|
+
}
|
|
468
|
+
else {
|
|
469
|
+
node['s-sn'] = '';
|
|
470
|
+
}
|
|
471
|
+
node['s-sr'] = true;
|
|
472
|
+
if (BUILD.shadowDom && shadowRootNodes) {
|
|
473
|
+
// browser support shadowRoot and this is a shadow dom component
|
|
474
|
+
// create an actual slot element
|
|
475
|
+
childVNode.$elm$ = doc.createElement(childVNode.$tag$);
|
|
476
|
+
if (childVNode.$name$) {
|
|
477
|
+
// add the slot name attribute
|
|
478
|
+
childVNode.$elm$.setAttribute('name', childVNode.$name$);
|
|
479
|
+
}
|
|
480
|
+
// insert the new slot element before the slot comment
|
|
481
|
+
node.parentNode.insertBefore(childVNode.$elm$, node);
|
|
482
|
+
// remove the slot comment since it's not needed for shadow
|
|
483
|
+
node.remove();
|
|
484
|
+
if (childVNode.$depth$ === '0') {
|
|
485
|
+
shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
slotNodes.push(childVNode);
|
|
489
|
+
if (!parentVNode.$children$) {
|
|
490
|
+
parentVNode.$children$ = [];
|
|
491
|
+
}
|
|
492
|
+
parentVNode.$children$[childVNode.$index$] = childVNode;
|
|
493
|
+
}
|
|
494
|
+
else if (childNodeType === CONTENT_REF_ID) {
|
|
495
|
+
// `${CONTENT_REF_ID}.${hostId}`;
|
|
496
|
+
if (BUILD.shadowDom && shadowRootNodes) {
|
|
497
|
+
// remove the content ref comment since it's not needed for shadow
|
|
498
|
+
node.remove();
|
|
499
|
+
}
|
|
500
|
+
else if (BUILD.slotRelocation) {
|
|
501
|
+
hostElm['s-cr'] = node;
|
|
502
|
+
node['s-cn'] = true;
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
else if (parentVNode && parentVNode.$tag$ === 'style') {
|
|
509
|
+
const vnode = newVNode(null, node.textContent);
|
|
510
|
+
vnode.$elm$ = node;
|
|
511
|
+
vnode.$index$ = '0';
|
|
512
|
+
parentVNode.$children$ = [vnode];
|
|
513
|
+
}
|
|
514
|
+
};
|
|
515
|
+
const initializeDocumentHydrate = (node, orgLocNodes) => {
|
|
516
|
+
if (node.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
517
|
+
let i = 0;
|
|
518
|
+
for (; i < node.childNodes.length; i++) {
|
|
519
|
+
initializeDocumentHydrate(node.childNodes[i], orgLocNodes);
|
|
520
|
+
}
|
|
521
|
+
if (node.shadowRoot) {
|
|
522
|
+
for (i = 0; i < node.shadowRoot.childNodes.length; i++) {
|
|
523
|
+
initializeDocumentHydrate(node.shadowRoot.childNodes[i], orgLocNodes);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
else if (node.nodeType === 8 /* NODE_TYPE.CommentNode */) {
|
|
528
|
+
const childIdSplt = node.nodeValue.split('.');
|
|
529
|
+
if (childIdSplt[0] === ORG_LOCATION_ID) {
|
|
530
|
+
orgLocNodes.set(childIdSplt[1] + '.' + childIdSplt[2], node);
|
|
531
|
+
node.nodeValue = '';
|
|
532
|
+
// useful to know if the original location is
|
|
533
|
+
// the root light-dom of a shadow dom component
|
|
534
|
+
node['s-en'] = childIdSplt[3];
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
};
|
|
538
|
+
// Private
|
|
539
|
+
const computeMode = (elm) => modeResolutionChain.map((h) => h(elm)).find((m) => !!m);
|
|
540
|
+
// Public
|
|
541
|
+
const setMode = (handler) => modeResolutionChain.push(handler);
|
|
542
|
+
const getMode = (ref) => getHostRef(ref).$modeName$;
|
|
165
543
|
/**
|
|
166
544
|
* Parse a new property value for a given property type.
|
|
167
545
|
*
|
|
@@ -188,16 +566,16 @@ const isHost = (node) => node && node.$tag$ === Host;
|
|
|
188
566
|
const parsePropertyValue = (propValue, propType) => {
|
|
189
567
|
// ensure this value is of the correct prop type
|
|
190
568
|
if (propValue != null && !isComplexType(propValue)) {
|
|
191
|
-
if (propType & 4 /* MEMBER_FLAGS.Boolean */) {
|
|
569
|
+
if (BUILD.propBoolean && propType & 4 /* MEMBER_FLAGS.Boolean */) {
|
|
192
570
|
// per the HTML spec, any string value means it is a boolean true value
|
|
193
571
|
// but we'll cheat here and say that the string "false" is the boolean false
|
|
194
572
|
return propValue === 'false' ? false : propValue === '' || !!propValue;
|
|
195
573
|
}
|
|
196
|
-
if (propType & 2 /* MEMBER_FLAGS.Number */) {
|
|
574
|
+
if (BUILD.propNumber && propType & 2 /* MEMBER_FLAGS.Number */) {
|
|
197
575
|
// force it to be a number
|
|
198
576
|
return parseFloat(propValue);
|
|
199
577
|
}
|
|
200
|
-
if (propType & 1 /* MEMBER_FLAGS.String */) {
|
|
578
|
+
if (BUILD.propString && propType & 1 /* MEMBER_FLAGS.String */) {
|
|
201
579
|
// could have been passed as a number or boolean
|
|
202
580
|
// but we still want it as a string
|
|
203
581
|
return String(propValue);
|
|
@@ -209,11 +587,14 @@ const parsePropertyValue = (propValue, propType) => {
|
|
|
209
587
|
// so no need to change to a different type
|
|
210
588
|
return propValue;
|
|
211
589
|
};
|
|
212
|
-
const getElement = (ref) => (getHostRef(ref).$hostElement$ );
|
|
590
|
+
const getElement = (ref) => (BUILD.lazyLoad ? getHostRef(ref).$hostElement$ : ref);
|
|
213
591
|
const createEvent = (ref, name, flags) => {
|
|
214
592
|
const elm = getElement(ref);
|
|
215
593
|
return {
|
|
216
594
|
emit: (detail) => {
|
|
595
|
+
if (BUILD.isDev && !elm.isConnected) {
|
|
596
|
+
consoleDevWarn(`The "${name}" event was emitted, but the dispatcher node is no longer connected to the dom.`);
|
|
597
|
+
}
|
|
217
598
|
return emitEvent(elm, name, {
|
|
218
599
|
bubbles: !!(flags & 4 /* EVENT_FLAGS.Bubbles */),
|
|
219
600
|
composed: !!(flags & 2 /* EVENT_FLAGS.Composed */),
|
|
@@ -253,8 +634,11 @@ const registerStyle = (scopeId, cssText, allowCS) => {
|
|
|
253
634
|
styles.set(scopeId, style);
|
|
254
635
|
};
|
|
255
636
|
const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
|
|
256
|
-
let scopeId = getScopeId(cmpMeta);
|
|
637
|
+
let scopeId = getScopeId(cmpMeta, mode);
|
|
257
638
|
const style = styles.get(scopeId);
|
|
639
|
+
if (!BUILD.attachStyles) {
|
|
640
|
+
return scopeId;
|
|
641
|
+
}
|
|
258
642
|
// if an element is NOT connected then getRootNode() will return the wrong root node
|
|
259
643
|
// so the fallback is to always use the document for the root node in those cases
|
|
260
644
|
styleContainerNode = styleContainerNode.nodeType === 11 /* NODE_TYPE.DocumentFragment */ ? styleContainerNode : doc;
|
|
@@ -267,11 +651,31 @@ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
|
|
|
267
651
|
rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
|
|
268
652
|
}
|
|
269
653
|
if (!appliedStyles.has(scopeId)) {
|
|
270
|
-
|
|
271
|
-
|
|
654
|
+
if (BUILD.hydrateClientSide &&
|
|
655
|
+
styleContainerNode.host &&
|
|
656
|
+
(styleElm = styleContainerNode.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId}"]`))) {
|
|
657
|
+
// This is only happening on native shadow-dom, do not needs CSS var shim
|
|
658
|
+
styleElm.innerHTML = style;
|
|
659
|
+
}
|
|
660
|
+
else {
|
|
661
|
+
if (BUILD.cssVarShim && plt.$cssShim$) {
|
|
662
|
+
styleElm = plt.$cssShim$.createHostStyle(hostElm, scopeId, style, !!(cmpMeta.$flags$ & 10 /* CMP_FLAGS.needsScopedEncapsulation */));
|
|
663
|
+
const newScopeId = styleElm['s-sc'];
|
|
664
|
+
if (newScopeId) {
|
|
665
|
+
scopeId = newScopeId;
|
|
666
|
+
// we don't want to add this styleID to the appliedStyles Set
|
|
667
|
+
// since the cssVarShim might need to apply several different
|
|
668
|
+
// stylesheets for the same component
|
|
669
|
+
appliedStyles = null;
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
else {
|
|
272
673
|
styleElm = doc.createElement('style');
|
|
273
674
|
styleElm.innerHTML = style;
|
|
274
675
|
}
|
|
676
|
+
if (BUILD.hydrateServerSide || BUILD.hotModuleReplacement) {
|
|
677
|
+
styleElm.setAttribute(HYDRATED_STYLE_ID, scopeId);
|
|
678
|
+
}
|
|
275
679
|
styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
|
|
276
680
|
}
|
|
277
681
|
if (appliedStyles) {
|
|
@@ -279,7 +683,7 @@ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
|
|
|
279
683
|
}
|
|
280
684
|
}
|
|
281
685
|
}
|
|
282
|
-
else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
|
|
686
|
+
else if (BUILD.constructableCSS && !styleContainerNode.adoptedStyleSheets.includes(style)) {
|
|
283
687
|
styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
|
|
284
688
|
}
|
|
285
689
|
}
|
|
@@ -290,8 +694,8 @@ const attachStyles = (hostRef) => {
|
|
|
290
694
|
const elm = hostRef.$hostElement$;
|
|
291
695
|
const flags = cmpMeta.$flags$;
|
|
292
696
|
const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
|
|
293
|
-
const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
|
|
294
|
-
if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
|
|
697
|
+
const scopeId = addStyle(BUILD.shadowDom && supportsShadow && elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta, hostRef.$modeName$, elm);
|
|
698
|
+
if ((BUILD.shadowDom || BUILD.scoped) && BUILD.cssAnnotations && flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
|
|
295
699
|
// only required when we're NOT using native shadow dom (slot)
|
|
296
700
|
// or this browser doesn't support native shadow dom
|
|
297
701
|
// and this host element was NOT created with SSR
|
|
@@ -301,13 +705,14 @@ const attachStyles = (hostRef) => {
|
|
|
301
705
|
// DOM WRITE!!
|
|
302
706
|
elm['s-sc'] = scopeId;
|
|
303
707
|
elm.classList.add(scopeId + '-h');
|
|
304
|
-
if (flags & 2 /* CMP_FLAGS.scopedCssEncapsulation */) {
|
|
708
|
+
if (BUILD.scoped && flags & 2 /* CMP_FLAGS.scopedCssEncapsulation */) {
|
|
305
709
|
elm.classList.add(scopeId + '-s');
|
|
306
710
|
}
|
|
307
711
|
}
|
|
308
712
|
endAttachStyles();
|
|
309
713
|
};
|
|
310
|
-
const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
|
|
714
|
+
const getScopeId = (cmp, mode) => 'sc-' + (BUILD.mode && mode && cmp.$flags$ & 32 /* CMP_FLAGS.hasMode */ ? cmp.$tagName$ + '-' + mode : cmp.$tagName$);
|
|
715
|
+
const convertScopedToShadow = (css) => css.replace(/\/\*!@([^\/]+)\*\/[^\{]+\{/g, '$1{');
|
|
311
716
|
/**
|
|
312
717
|
* Production setAccessor() function based on Preact by
|
|
313
718
|
* Jason Miller (@developit)
|
|
@@ -320,22 +725,48 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
|
|
320
725
|
if (oldValue !== newValue) {
|
|
321
726
|
let isProp = isMemberInElement(elm, memberName);
|
|
322
727
|
let ln = memberName.toLowerCase();
|
|
323
|
-
if (memberName === 'class') {
|
|
728
|
+
if (BUILD.vdomClass && memberName === 'class') {
|
|
324
729
|
const classList = elm.classList;
|
|
325
730
|
const oldClasses = parseClassList(oldValue);
|
|
326
731
|
const newClasses = parseClassList(newValue);
|
|
327
732
|
classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
|
|
328
733
|
classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
|
|
329
734
|
}
|
|
330
|
-
else if (memberName === '
|
|
735
|
+
else if (BUILD.vdomStyle && memberName === 'style') {
|
|
736
|
+
// update style attribute, css properties and values
|
|
737
|
+
if (BUILD.updatable) {
|
|
738
|
+
for (const prop in oldValue) {
|
|
739
|
+
if (!newValue || newValue[prop] == null) {
|
|
740
|
+
if (!BUILD.hydrateServerSide && prop.includes('-')) {
|
|
741
|
+
elm.style.removeProperty(prop);
|
|
742
|
+
}
|
|
743
|
+
else {
|
|
744
|
+
elm.style[prop] = '';
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
for (const prop in newValue) {
|
|
750
|
+
if (!oldValue || newValue[prop] !== oldValue[prop]) {
|
|
751
|
+
if (!BUILD.hydrateServerSide && prop.includes('-')) {
|
|
752
|
+
elm.style.setProperty(prop, newValue[prop]);
|
|
753
|
+
}
|
|
754
|
+
else {
|
|
755
|
+
elm.style[prop] = newValue[prop];
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
else if (BUILD.vdomKey && memberName === 'key')
|
|
331
761
|
;
|
|
332
|
-
else if (memberName === 'ref') {
|
|
762
|
+
else if (BUILD.vdomRef && memberName === 'ref') {
|
|
333
763
|
// minifier will clean this up
|
|
334
764
|
if (newValue) {
|
|
335
765
|
newValue(elm);
|
|
336
766
|
}
|
|
337
767
|
}
|
|
338
|
-
else if (
|
|
768
|
+
else if (BUILD.vdomListener &&
|
|
769
|
+
(BUILD.lazyLoad ? !isProp : !elm.__lookupSetter__(memberName)) &&
|
|
339
770
|
memberName[0] === 'o' &&
|
|
340
771
|
memberName[1] === 'n') {
|
|
341
772
|
// Event Handlers
|
|
@@ -374,7 +805,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
|
|
374
805
|
plt.ael(elm, memberName, newValue, false);
|
|
375
806
|
}
|
|
376
807
|
}
|
|
377
|
-
else {
|
|
808
|
+
else if (BUILD.vdomPropOrAttr) {
|
|
378
809
|
// Set property if it exists and it's not a SVG
|
|
379
810
|
const isComplex = isComplexType(newValue);
|
|
380
811
|
if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
|
|
@@ -395,16 +826,36 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
|
|
395
826
|
}
|
|
396
827
|
catch (e) { }
|
|
397
828
|
}
|
|
829
|
+
/**
|
|
830
|
+
* Need to manually update attribute if:
|
|
831
|
+
* - memberName is not an attribute
|
|
832
|
+
* - if we are rendering the host element in order to reflect attribute
|
|
833
|
+
* - if it's a SVG, since properties might not work in <svg>
|
|
834
|
+
* - if the newValue is null/undefined or 'false'.
|
|
835
|
+
*/
|
|
836
|
+
let xlink = false;
|
|
837
|
+
if (BUILD.vdomXlink) {
|
|
838
|
+
if (ln !== (ln = ln.replace(/^xlink\:?/, ''))) {
|
|
839
|
+
memberName = ln;
|
|
840
|
+
xlink = true;
|
|
841
|
+
}
|
|
842
|
+
}
|
|
398
843
|
if (newValue == null || newValue === false) {
|
|
399
844
|
if (newValue !== false || elm.getAttribute(memberName) === '') {
|
|
400
|
-
{
|
|
845
|
+
if (BUILD.vdomXlink && xlink) {
|
|
846
|
+
elm.removeAttributeNS(XLINK_NS, memberName);
|
|
847
|
+
}
|
|
848
|
+
else {
|
|
401
849
|
elm.removeAttribute(memberName);
|
|
402
850
|
}
|
|
403
851
|
}
|
|
404
852
|
}
|
|
405
853
|
else if ((!isProp || flags & 4 /* VNODE_FLAGS.isHost */ || isSvg) && !isComplex) {
|
|
406
854
|
newValue = newValue === true ? '' : newValue;
|
|
407
|
-
{
|
|
855
|
+
if (BUILD.vdomXlink && xlink) {
|
|
856
|
+
elm.setAttributeNS(XLINK_NS, memberName, newValue);
|
|
857
|
+
}
|
|
858
|
+
else {
|
|
408
859
|
elm.setAttribute(memberName, newValue);
|
|
409
860
|
}
|
|
410
861
|
}
|
|
@@ -422,7 +873,7 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
|
|
|
422
873
|
: newVnode.$elm$;
|
|
423
874
|
const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
|
|
424
875
|
const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
|
|
425
|
-
{
|
|
876
|
+
if (BUILD.updatable) {
|
|
426
877
|
// remove attributes no longer present on the vnode by setting them to undefined
|
|
427
878
|
for (memberName in oldVnodeAttrs) {
|
|
428
879
|
if (!(memberName in newVnodeAttrs)) {
|
|
@@ -452,7 +903,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
452
903
|
let elm;
|
|
453
904
|
let childNode;
|
|
454
905
|
let oldVNode;
|
|
455
|
-
if (!useNativeShadowDom) {
|
|
906
|
+
if (BUILD.slotRelocation && !useNativeShadowDom) {
|
|
456
907
|
// remember for later we need to check to relocate nodes
|
|
457
908
|
checkSlotRelocate = true;
|
|
458
909
|
if (newVNode.$tag$ === 'slot') {
|
|
@@ -467,25 +918,38 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
467
918
|
1 /* VNODE_FLAGS.isSlotReference */;
|
|
468
919
|
}
|
|
469
920
|
}
|
|
470
|
-
if (newVNode.$
|
|
921
|
+
if (BUILD.isDev && newVNode.$elm$) {
|
|
922
|
+
consoleDevError(`The JSX ${newVNode.$text$ !== null ? `"${newVNode.$text$}" text` : `"${newVNode.$tag$}" element`} node should not be shared within the same renderer. The renderer caches element lookups in order to improve performance. However, a side effect from this is that the exact same JSX node should not be reused. For more information please see https://stenciljs.com/docs/templating-jsx#avoid-shared-jsx-nodes`);
|
|
923
|
+
}
|
|
924
|
+
if (BUILD.vdomText && newVNode.$text$ !== null) {
|
|
471
925
|
// create text node
|
|
472
926
|
elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
|
|
473
927
|
}
|
|
474
|
-
else if (newVNode.$flags$ & 1 /* VNODE_FLAGS.isSlotReference */) {
|
|
928
|
+
else if (BUILD.slotRelocation && newVNode.$flags$ & 1 /* VNODE_FLAGS.isSlotReference */) {
|
|
475
929
|
// create a slot reference node
|
|
476
930
|
elm = newVNode.$elm$ =
|
|
477
|
-
doc.createTextNode('');
|
|
931
|
+
BUILD.isDebug || BUILD.hydrateServerSide ? slotReferenceDebugNode(newVNode) : doc.createTextNode('');
|
|
478
932
|
}
|
|
479
933
|
else {
|
|
934
|
+
if (BUILD.svg && !isSvgMode) {
|
|
935
|
+
isSvgMode = newVNode.$tag$ === 'svg';
|
|
936
|
+
}
|
|
480
937
|
// create element
|
|
481
|
-
elm = newVNode.$elm$ = (
|
|
938
|
+
elm = newVNode.$elm$ = (BUILD.svg
|
|
939
|
+
? doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, BUILD.slotRelocation && newVNode.$flags$ & 2 /* VNODE_FLAGS.isSlotFallback */
|
|
940
|
+
? 'slot-fb'
|
|
941
|
+
: newVNode.$tag$)
|
|
942
|
+
: doc.createElement(BUILD.slotRelocation && newVNode.$flags$ & 2 /* VNODE_FLAGS.isSlotFallback */
|
|
482
943
|
? 'slot-fb'
|
|
483
944
|
: newVNode.$tag$));
|
|
945
|
+
if (BUILD.svg && isSvgMode && newVNode.$tag$ === 'foreignObject') {
|
|
946
|
+
isSvgMode = false;
|
|
947
|
+
}
|
|
484
948
|
// add css classes, attrs, props, listeners, etc.
|
|
485
|
-
{
|
|
949
|
+
if (BUILD.vdomAttribute) {
|
|
486
950
|
updateElement(null, newVNode, isSvgMode);
|
|
487
951
|
}
|
|
488
|
-
if (isDef(scopeId) && elm['s-si'] !== scopeId) {
|
|
952
|
+
if ((BUILD.shadowDom || BUILD.scoped) && isDef(scopeId) && elm['s-si'] !== scopeId) {
|
|
489
953
|
// if there is a scopeId and this is the initial render
|
|
490
954
|
// then let's add the scopeId as a css class
|
|
491
955
|
elm.classList.add((elm['s-si'] = scopeId));
|
|
@@ -501,8 +965,18 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
501
965
|
}
|
|
502
966
|
}
|
|
503
967
|
}
|
|
968
|
+
if (BUILD.svg) {
|
|
969
|
+
if (newVNode.$tag$ === 'svg') {
|
|
970
|
+
// Only reset the SVG context when we're exiting <svg> element
|
|
971
|
+
isSvgMode = false;
|
|
972
|
+
}
|
|
973
|
+
else if (elm.tagName === 'foreignObject') {
|
|
974
|
+
// Reenter SVG context when we're exiting <foreignObject> element
|
|
975
|
+
isSvgMode = true;
|
|
976
|
+
}
|
|
977
|
+
}
|
|
504
978
|
}
|
|
505
|
-
{
|
|
979
|
+
if (BUILD.slotRelocation) {
|
|
506
980
|
elm['s-hn'] = hostTagName;
|
|
507
981
|
if (newVNode.$flags$ & (2 /* VNODE_FLAGS.isSlotFallback */ | 1 /* VNODE_FLAGS.isSlotReference */)) {
|
|
508
982
|
// remember the content reference comment
|
|
@@ -547,9 +1021,9 @@ const putBackInOriginalLocation = (parentElm, recursive) => {
|
|
|
547
1021
|
plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
|
|
548
1022
|
};
|
|
549
1023
|
const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
|
|
550
|
-
let containerElm = ((parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
|
|
1024
|
+
let containerElm = ((BUILD.slotRelocation && parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
|
|
551
1025
|
let childNode;
|
|
552
|
-
if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
|
|
1026
|
+
if (BUILD.shadowDom && containerElm.shadowRoot && containerElm.tagName === hostTagName) {
|
|
553
1027
|
containerElm = containerElm.shadowRoot;
|
|
554
1028
|
}
|
|
555
1029
|
for (; startIdx <= endIdx; ++startIdx) {
|
|
@@ -557,7 +1031,7 @@ const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) =>
|
|
|
557
1031
|
childNode = createElm(null, parentVNode, startIdx, parentElm);
|
|
558
1032
|
if (childNode) {
|
|
559
1033
|
vnodes[startIdx].$elm$ = childNode;
|
|
560
|
-
containerElm.insertBefore(childNode, referenceNode(before) );
|
|
1034
|
+
containerElm.insertBefore(childNode, BUILD.slotRelocation ? referenceNode(before) : before);
|
|
561
1035
|
}
|
|
562
1036
|
}
|
|
563
1037
|
}
|
|
@@ -567,7 +1041,7 @@ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
|
|
|
567
1041
|
if ((vnode = vnodes[startIdx])) {
|
|
568
1042
|
elm = vnode.$elm$;
|
|
569
1043
|
callNodeRefs(vnode);
|
|
570
|
-
{
|
|
1044
|
+
if (BUILD.slotRelocation) {
|
|
571
1045
|
// we're removing this element
|
|
572
1046
|
// so it's possible we need to show slot fallback content now
|
|
573
1047
|
checkSlotFallbackVisibility = true;
|
|
@@ -713,7 +1187,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
713
1187
|
//
|
|
714
1188
|
// In this situation we need to patch `newEndVnode` onto `oldStartVnode`
|
|
715
1189
|
// and move the DOM element for `oldStartVnode`.
|
|
716
|
-
if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
|
|
1190
|
+
if (BUILD.slotRelocation && (oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
|
|
717
1191
|
putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
|
|
718
1192
|
}
|
|
719
1193
|
patch(oldStartVnode, newEndVnode);
|
|
@@ -754,7 +1228,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
754
1228
|
// (which will handle updating any changed attributes, reconciling their
|
|
755
1229
|
// children etc) but we also need to move the DOM node to which
|
|
756
1230
|
// `oldEndVnode` corresponds.
|
|
757
|
-
if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
|
|
1231
|
+
if (BUILD.slotRelocation && (oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
|
|
758
1232
|
putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
|
|
759
1233
|
}
|
|
760
1234
|
patch(oldEndVnode, newStartVnode);
|
|
@@ -777,7 +1251,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
777
1251
|
// children which have the same key as the first node in the new
|
|
778
1252
|
// children.
|
|
779
1253
|
idxInOld = -1;
|
|
780
|
-
{
|
|
1254
|
+
if (BUILD.vdomKey) {
|
|
781
1255
|
for (i = oldStartIdx; i <= oldEndIdx; ++i) {
|
|
782
1256
|
if (oldCh[i] && oldCh[i].$key$ !== null && oldCh[i].$key$ === newStartVnode.$key$) {
|
|
783
1257
|
idxInOld = i;
|
|
@@ -785,7 +1259,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
785
1259
|
}
|
|
786
1260
|
}
|
|
787
1261
|
}
|
|
788
|
-
if (idxInOld >= 0) {
|
|
1262
|
+
if (BUILD.vdomKey && idxInOld >= 0) {
|
|
789
1263
|
// We found a node in the old children which matches up with the first
|
|
790
1264
|
// node in the new children! So let's deal with that
|
|
791
1265
|
elmToMove = oldCh[idxInOld];
|
|
@@ -812,9 +1286,12 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
812
1286
|
}
|
|
813
1287
|
if (node) {
|
|
814
1288
|
// if we created a new node then handle inserting it to the DOM
|
|
815
|
-
{
|
|
1289
|
+
if (BUILD.slotRelocation) {
|
|
816
1290
|
parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
|
|
817
1291
|
}
|
|
1292
|
+
else {
|
|
1293
|
+
oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
|
|
1294
|
+
}
|
|
818
1295
|
}
|
|
819
1296
|
}
|
|
820
1297
|
}
|
|
@@ -822,7 +1299,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
822
1299
|
// we have some more new nodes to add which don't match up with old nodes
|
|
823
1300
|
addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
|
|
824
1301
|
}
|
|
825
|
-
else if (newStartIdx > newEndIdx) {
|
|
1302
|
+
else if (BUILD.updatable && newStartIdx > newEndIdx) {
|
|
826
1303
|
// there are nodes in the `oldCh` array which no longer correspond to nodes
|
|
827
1304
|
// in the new array, so lets remove them (which entails cleaning up the
|
|
828
1305
|
// relevant DOM nodes)
|
|
@@ -850,13 +1327,14 @@ const isSameVnode = (leftVNode, rightVNode) => {
|
|
|
850
1327
|
// compare if two vnode to see if they're "technically" the same
|
|
851
1328
|
// need to have the same element tag, and same key to be the same
|
|
852
1329
|
if (leftVNode.$tag$ === rightVNode.$tag$) {
|
|
853
|
-
if (leftVNode.$tag$ === 'slot') {
|
|
1330
|
+
if (BUILD.slotRelocation && leftVNode.$tag$ === 'slot') {
|
|
854
1331
|
return leftVNode.$name$ === rightVNode.$name$;
|
|
855
1332
|
}
|
|
856
1333
|
// this will be set if components in the build have `key` attrs set on them
|
|
857
|
-
{
|
|
1334
|
+
if (BUILD.vdomKey) {
|
|
858
1335
|
return leftVNode.$key$ === rightVNode.$key$;
|
|
859
1336
|
}
|
|
1337
|
+
return true;
|
|
860
1338
|
}
|
|
861
1339
|
return false;
|
|
862
1340
|
};
|
|
@@ -883,9 +1361,14 @@ const patch = (oldVNode, newVNode) => {
|
|
|
883
1361
|
const tag = newVNode.$tag$;
|
|
884
1362
|
const text = newVNode.$text$;
|
|
885
1363
|
let defaultHolder;
|
|
886
|
-
if (text === null) {
|
|
887
|
-
{
|
|
888
|
-
if
|
|
1364
|
+
if (!BUILD.vdomText || text === null) {
|
|
1365
|
+
if (BUILD.svg) {
|
|
1366
|
+
// test if we're rendering an svg element, or still rendering nodes inside of one
|
|
1367
|
+
// only add this to the when the compiler sees we're using an svg somewhere
|
|
1368
|
+
isSvgMode = tag === 'svg' ? true : tag === 'foreignObject' ? false : isSvgMode;
|
|
1369
|
+
}
|
|
1370
|
+
if (BUILD.vdomAttribute || BUILD.reflect) {
|
|
1371
|
+
if (BUILD.slot && tag === 'slot')
|
|
889
1372
|
;
|
|
890
1373
|
else {
|
|
891
1374
|
// either this is the first render of an element OR it's an update
|
|
@@ -894,30 +1377,33 @@ const patch = (oldVNode, newVNode) => {
|
|
|
894
1377
|
updateElement(oldVNode, newVNode, isSvgMode);
|
|
895
1378
|
}
|
|
896
1379
|
}
|
|
897
|
-
if (oldChildren !== null && newChildren !== null) {
|
|
1380
|
+
if (BUILD.updatable && oldChildren !== null && newChildren !== null) {
|
|
898
1381
|
// looks like there's child vnodes for both the old and new vnodes
|
|
899
1382
|
// so we need to call `updateChildren` to reconcile them
|
|
900
1383
|
updateChildren(elm, oldChildren, newVNode, newChildren);
|
|
901
1384
|
}
|
|
902
1385
|
else if (newChildren !== null) {
|
|
903
1386
|
// no old child vnodes, but there are new child vnodes to add
|
|
904
|
-
if (oldVNode.$text$ !== null) {
|
|
1387
|
+
if (BUILD.updatable && BUILD.vdomText && oldVNode.$text$ !== null) {
|
|
905
1388
|
// the old vnode was text, so be sure to clear it out
|
|
906
1389
|
elm.textContent = '';
|
|
907
1390
|
}
|
|
908
1391
|
// add the new vnode children
|
|
909
1392
|
addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
|
|
910
1393
|
}
|
|
911
|
-
else if (oldChildren !== null) {
|
|
1394
|
+
else if (BUILD.updatable && oldChildren !== null) {
|
|
912
1395
|
// no new child vnodes, but there are old child vnodes to remove
|
|
913
1396
|
removeVnodes(oldChildren, 0, oldChildren.length - 1);
|
|
914
1397
|
}
|
|
1398
|
+
if (BUILD.svg && isSvgMode && tag === 'svg') {
|
|
1399
|
+
isSvgMode = false;
|
|
1400
|
+
}
|
|
915
1401
|
}
|
|
916
|
-
else if ((defaultHolder = elm['s-cr'])) {
|
|
1402
|
+
else if (BUILD.vdomText && BUILD.slotRelocation && (defaultHolder = elm['s-cr'])) {
|
|
917
1403
|
// this element has slotted content
|
|
918
1404
|
defaultHolder.parentNode.textContent = text;
|
|
919
1405
|
}
|
|
920
|
-
else if (oldVNode.$text$ !== text) {
|
|
1406
|
+
else if (BUILD.vdomText && oldVNode.$text$ !== text) {
|
|
921
1407
|
// update the text content for the text only vnode
|
|
922
1408
|
// and also only if the text is different than before
|
|
923
1409
|
elm.data = text;
|
|
@@ -1055,7 +1541,7 @@ const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
|
|
|
1055
1541
|
return slotNameAttr === '';
|
|
1056
1542
|
};
|
|
1057
1543
|
const callNodeRefs = (vNode) => {
|
|
1058
|
-
{
|
|
1544
|
+
if (BUILD.vdomRef) {
|
|
1059
1545
|
vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
|
|
1060
1546
|
vNode.$children$ && vNode.$children$.map(callNodeRefs);
|
|
1061
1547
|
}
|
|
@@ -1066,22 +1552,41 @@ const renderVdom = (hostRef, renderFnResults) => {
|
|
|
1066
1552
|
const oldVNode = hostRef.$vnode$ || newVNode(null, null);
|
|
1067
1553
|
const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
|
|
1068
1554
|
hostTagName = hostElm.tagName;
|
|
1555
|
+
// <Host> runtime check
|
|
1556
|
+
if (BUILD.isDev && Array.isArray(renderFnResults) && renderFnResults.some(isHost)) {
|
|
1557
|
+
throw new Error(`The <Host> must be the single root component.
|
|
1558
|
+
Looks like the render() function of "${hostTagName.toLowerCase()}" is returning an array that contains the <Host>.
|
|
1559
|
+
|
|
1560
|
+
The render() function should look like this instead:
|
|
1561
|
+
|
|
1562
|
+
render() {
|
|
1563
|
+
// Do not return an array
|
|
1564
|
+
return (
|
|
1565
|
+
<Host>{content}</Host>
|
|
1566
|
+
);
|
|
1567
|
+
}
|
|
1568
|
+
`);
|
|
1569
|
+
}
|
|
1570
|
+
if (BUILD.reflect && cmpMeta.$attrsToReflect$) {
|
|
1571
|
+
rootVnode.$attrs$ = rootVnode.$attrs$ || {};
|
|
1572
|
+
cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
|
|
1573
|
+
}
|
|
1069
1574
|
rootVnode.$tag$ = null;
|
|
1070
1575
|
rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
|
|
1071
1576
|
hostRef.$vnode$ = rootVnode;
|
|
1072
|
-
rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
|
|
1073
|
-
{
|
|
1577
|
+
rootVnode.$elm$ = oldVNode.$elm$ = (BUILD.shadowDom ? hostElm.shadowRoot || hostElm : hostElm);
|
|
1578
|
+
if (BUILD.scoped || BUILD.shadowDom) {
|
|
1074
1579
|
scopeId = hostElm['s-sc'];
|
|
1075
1580
|
}
|
|
1076
|
-
{
|
|
1581
|
+
if (BUILD.slotRelocation) {
|
|
1077
1582
|
contentRef = hostElm['s-cr'];
|
|
1078
|
-
useNativeShadowDom = (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) !== 0;
|
|
1583
|
+
useNativeShadowDom = supportsShadow && (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) !== 0;
|
|
1079
1584
|
// always reset
|
|
1080
1585
|
checkSlotFallbackVisibility = false;
|
|
1081
1586
|
}
|
|
1082
1587
|
// synchronous patch
|
|
1083
1588
|
patch(oldVNode, rootVnode);
|
|
1084
|
-
{
|
|
1589
|
+
if (BUILD.slotRelocation) {
|
|
1085
1590
|
// while we're moving nodes around existing nodes, temporarily disable
|
|
1086
1591
|
// the disconnectCallback from working
|
|
1087
1592
|
plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
|
|
@@ -1101,7 +1606,9 @@ const renderVdom = (hostRef, renderFnResults) => {
|
|
|
1101
1606
|
// add a reference node marking this node's original location
|
|
1102
1607
|
// keep a reference to this node for later lookups
|
|
1103
1608
|
orgLocationNode =
|
|
1104
|
-
|
|
1609
|
+
BUILD.isDebug || BUILD.hydrateServerSide
|
|
1610
|
+
? originalLocationDebugNode(nodeToRelocate)
|
|
1611
|
+
: doc.createTextNode('');
|
|
1105
1612
|
orgLocationNode['s-nr'] = nodeToRelocate;
|
|
1106
1613
|
nodeToRelocate.parentNode.insertBefore((nodeToRelocate['s-ol'] = orgLocationNode), nodeToRelocate);
|
|
1107
1614
|
}
|
|
@@ -1158,16 +1665,23 @@ const renderVdom = (hostRef, renderFnResults) => {
|
|
|
1158
1665
|
relocateNodes.length = 0;
|
|
1159
1666
|
}
|
|
1160
1667
|
};
|
|
1668
|
+
// slot comment debug nodes only created with the `--debug` flag
|
|
1669
|
+
// otherwise these nodes are text nodes w/out content
|
|
1670
|
+
const slotReferenceDebugNode = (slotVNode) => doc.createComment(`<slot${slotVNode.$name$ ? ' name="' + slotVNode.$name$ + '"' : ''}> (host=${hostTagName.toLowerCase()})`);
|
|
1671
|
+
const originalLocationDebugNode = (nodeToRelocate) => doc.createComment(`org-location for ` +
|
|
1672
|
+
(nodeToRelocate.localName
|
|
1673
|
+
? `<${nodeToRelocate.localName}> (host=${nodeToRelocate['s-hn']})`
|
|
1674
|
+
: `[${nodeToRelocate.textContent}]`));
|
|
1161
1675
|
const attachToAncestor = (hostRef, ancestorComponent) => {
|
|
1162
|
-
if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
|
|
1676
|
+
if (BUILD.asyncLoading && ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
|
|
1163
1677
|
ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
|
|
1164
1678
|
}
|
|
1165
1679
|
};
|
|
1166
1680
|
const scheduleUpdate = (hostRef, isInitialLoad) => {
|
|
1167
|
-
{
|
|
1681
|
+
if (BUILD.taskQueue && BUILD.updatable) {
|
|
1168
1682
|
hostRef.$flags$ |= 16 /* HOST_FLAGS.isQueuedForUpdate */;
|
|
1169
1683
|
}
|
|
1170
|
-
if (hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
|
|
1684
|
+
if (BUILD.asyncLoading && hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
|
|
1171
1685
|
hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
|
|
1172
1686
|
return;
|
|
1173
1687
|
}
|
|
@@ -1176,18 +1690,34 @@ const scheduleUpdate = (hostRef, isInitialLoad) => {
|
|
|
1176
1690
|
// has already fired off its lifecycle update then
|
|
1177
1691
|
// fire off the initial update
|
|
1178
1692
|
const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
|
|
1179
|
-
return writeTask(dispatch) ;
|
|
1693
|
+
return BUILD.taskQueue ? writeTask(dispatch) : dispatch();
|
|
1180
1694
|
};
|
|
1181
1695
|
const dispatchHooks = (hostRef, isInitialLoad) => {
|
|
1696
|
+
const elm = hostRef.$hostElement$;
|
|
1182
1697
|
const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
|
|
1183
|
-
const instance = hostRef.$lazyInstance$ ;
|
|
1698
|
+
const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
|
|
1184
1699
|
let promise;
|
|
1185
1700
|
if (isInitialLoad) {
|
|
1186
|
-
{
|
|
1701
|
+
if (BUILD.lazyLoad && BUILD.hostListener) {
|
|
1702
|
+
hostRef.$flags$ |= 256 /* HOST_FLAGS.isListenReady */;
|
|
1703
|
+
if (hostRef.$queuedListeners$) {
|
|
1704
|
+
hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
|
|
1705
|
+
hostRef.$queuedListeners$ = null;
|
|
1706
|
+
}
|
|
1707
|
+
}
|
|
1708
|
+
emitLifecycleEvent(elm, 'componentWillLoad');
|
|
1709
|
+
if (BUILD.cmpWillLoad) {
|
|
1187
1710
|
promise = safeCall(instance, 'componentWillLoad');
|
|
1188
1711
|
}
|
|
1189
1712
|
}
|
|
1190
|
-
{
|
|
1713
|
+
else {
|
|
1714
|
+
emitLifecycleEvent(elm, 'componentWillUpdate');
|
|
1715
|
+
if (BUILD.cmpWillUpdate) {
|
|
1716
|
+
promise = safeCall(instance, 'componentWillUpdate');
|
|
1717
|
+
}
|
|
1718
|
+
}
|
|
1719
|
+
emitLifecycleEvent(elm, 'componentWillRender');
|
|
1720
|
+
if (BUILD.cmpWillRender) {
|
|
1191
1721
|
promise = then(promise, () => safeCall(instance, 'componentWillRender'));
|
|
1192
1722
|
}
|
|
1193
1723
|
endSchedule();
|
|
@@ -1198,15 +1728,46 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
|
|
|
1198
1728
|
const elm = hostRef.$hostElement$;
|
|
1199
1729
|
const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
|
|
1200
1730
|
const rc = elm['s-rc'];
|
|
1201
|
-
if (isInitialLoad) {
|
|
1731
|
+
if (BUILD.style && isInitialLoad) {
|
|
1202
1732
|
// DOM WRITE!
|
|
1203
1733
|
attachStyles(hostRef);
|
|
1204
1734
|
}
|
|
1205
1735
|
const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
|
|
1206
|
-
{
|
|
1207
|
-
|
|
1736
|
+
if (BUILD.isDev) {
|
|
1737
|
+
hostRef.$flags$ |= 1024 /* HOST_FLAGS.devOnRender */;
|
|
1738
|
+
}
|
|
1739
|
+
if (BUILD.hydrateServerSide) {
|
|
1740
|
+
await callRender(hostRef, instance, elm);
|
|
1208
1741
|
}
|
|
1209
|
-
|
|
1742
|
+
else {
|
|
1743
|
+
callRender(hostRef, instance, elm);
|
|
1744
|
+
}
|
|
1745
|
+
if (BUILD.cssVarShim && plt.$cssShim$) {
|
|
1746
|
+
plt.$cssShim$.updateHost(elm);
|
|
1747
|
+
}
|
|
1748
|
+
if (BUILD.isDev) {
|
|
1749
|
+
hostRef.$renderCount$++;
|
|
1750
|
+
hostRef.$flags$ &= ~1024 /* HOST_FLAGS.devOnRender */;
|
|
1751
|
+
}
|
|
1752
|
+
if (BUILD.hydrateServerSide) {
|
|
1753
|
+
try {
|
|
1754
|
+
// manually connected child components during server-side hydrate
|
|
1755
|
+
serverSideConnected(elm);
|
|
1756
|
+
if (isInitialLoad) {
|
|
1757
|
+
// using only during server-side hydrate
|
|
1758
|
+
if (hostRef.$cmpMeta$.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
|
|
1759
|
+
elm['s-en'] = '';
|
|
1760
|
+
}
|
|
1761
|
+
else if (hostRef.$cmpMeta$.$flags$ & 2 /* CMP_FLAGS.scopedCssEncapsulation */) {
|
|
1762
|
+
elm['s-en'] = 'c';
|
|
1763
|
+
}
|
|
1764
|
+
}
|
|
1765
|
+
}
|
|
1766
|
+
catch (e) {
|
|
1767
|
+
consoleError(e, elm);
|
|
1768
|
+
}
|
|
1769
|
+
}
|
|
1770
|
+
if (BUILD.asyncLoading && rc) {
|
|
1210
1771
|
// ok, so turns out there are some child host elements
|
|
1211
1772
|
// waiting on this parent element to load
|
|
1212
1773
|
// let's fire off all update callbacks waiting
|
|
@@ -1215,7 +1776,7 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
|
|
|
1215
1776
|
}
|
|
1216
1777
|
endRender();
|
|
1217
1778
|
endUpdate();
|
|
1218
|
-
{
|
|
1779
|
+
if (BUILD.asyncLoading) {
|
|
1219
1780
|
const childrenPromises = elm['s-p'];
|
|
1220
1781
|
const postUpdate = () => postUpdateComponent(hostRef);
|
|
1221
1782
|
if (childrenPromises.length === 0) {
|
|
@@ -1227,64 +1788,117 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
|
|
|
1227
1788
|
childrenPromises.length = 0;
|
|
1228
1789
|
}
|
|
1229
1790
|
}
|
|
1791
|
+
else {
|
|
1792
|
+
postUpdateComponent(hostRef);
|
|
1793
|
+
}
|
|
1230
1794
|
};
|
|
1231
1795
|
const callRender = (hostRef, instance, elm) => {
|
|
1796
|
+
// in order for bundlers to correctly treeshake the BUILD object
|
|
1797
|
+
// we need to ensure BUILD is not deoptimized within a try/catch
|
|
1798
|
+
// https://rollupjs.org/guide/en/#treeshake tryCatchDeoptimization
|
|
1799
|
+
const allRenderFn = BUILD.allRenderFn ? true : false;
|
|
1800
|
+
const lazyLoad = BUILD.lazyLoad ? true : false;
|
|
1801
|
+
const taskQueue = BUILD.taskQueue ? true : false;
|
|
1802
|
+
const updatable = BUILD.updatable ? true : false;
|
|
1232
1803
|
try {
|
|
1233
|
-
|
|
1234
|
-
|
|
1804
|
+
renderingRef = instance;
|
|
1805
|
+
instance = allRenderFn ? instance.render() : instance.render && instance.render();
|
|
1806
|
+
if (updatable && taskQueue) {
|
|
1235
1807
|
hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
|
|
1236
1808
|
}
|
|
1237
|
-
{
|
|
1809
|
+
if (updatable || lazyLoad) {
|
|
1238
1810
|
hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
|
|
1239
1811
|
}
|
|
1240
|
-
{
|
|
1241
|
-
{
|
|
1812
|
+
if (BUILD.hasRenderFn || BUILD.reflect) {
|
|
1813
|
+
if (BUILD.vdomRender || BUILD.reflect) {
|
|
1242
1814
|
// looks like we've got child nodes to render into this host element
|
|
1243
1815
|
// or we need to update the css class/attrs on the host element
|
|
1244
1816
|
// DOM WRITE!
|
|
1245
|
-
{
|
|
1817
|
+
if (BUILD.hydrateServerSide) {
|
|
1818
|
+
return Promise.resolve(instance).then((value) => renderVdom(hostRef, value));
|
|
1819
|
+
}
|
|
1820
|
+
else {
|
|
1246
1821
|
renderVdom(hostRef, instance);
|
|
1247
1822
|
}
|
|
1248
1823
|
}
|
|
1824
|
+
else {
|
|
1825
|
+
elm.textContent = instance;
|
|
1826
|
+
}
|
|
1249
1827
|
}
|
|
1250
1828
|
}
|
|
1251
1829
|
catch (e) {
|
|
1252
1830
|
consoleError(e, hostRef.$hostElement$);
|
|
1253
1831
|
}
|
|
1832
|
+
renderingRef = null;
|
|
1254
1833
|
return null;
|
|
1255
1834
|
};
|
|
1835
|
+
const getRenderingRef = () => renderingRef;
|
|
1256
1836
|
const postUpdateComponent = (hostRef) => {
|
|
1257
1837
|
const tagName = hostRef.$cmpMeta$.$tagName$;
|
|
1258
1838
|
const elm = hostRef.$hostElement$;
|
|
1259
1839
|
const endPostUpdate = createTime('postUpdate', tagName);
|
|
1260
|
-
const instance = hostRef.$lazyInstance$ ;
|
|
1840
|
+
const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
|
|
1261
1841
|
const ancestorComponent = hostRef.$ancestorComponent$;
|
|
1842
|
+
if (BUILD.cmpDidRender) {
|
|
1843
|
+
if (BUILD.isDev) {
|
|
1844
|
+
hostRef.$flags$ |= 1024 /* HOST_FLAGS.devOnRender */;
|
|
1845
|
+
}
|
|
1846
|
+
safeCall(instance, 'componentDidRender');
|
|
1847
|
+
if (BUILD.isDev) {
|
|
1848
|
+
hostRef.$flags$ &= ~1024 /* HOST_FLAGS.devOnRender */;
|
|
1849
|
+
}
|
|
1850
|
+
}
|
|
1851
|
+
emitLifecycleEvent(elm, 'componentDidRender');
|
|
1262
1852
|
if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
|
|
1263
1853
|
hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
|
|
1264
|
-
{
|
|
1854
|
+
if (BUILD.asyncLoading && BUILD.cssAnnotations) {
|
|
1265
1855
|
// DOM WRITE!
|
|
1266
1856
|
addHydratedFlag(elm);
|
|
1267
1857
|
}
|
|
1268
|
-
{
|
|
1858
|
+
if (BUILD.cmpDidLoad) {
|
|
1859
|
+
if (BUILD.isDev) {
|
|
1860
|
+
hostRef.$flags$ |= 2048 /* HOST_FLAGS.devOnDidLoad */;
|
|
1861
|
+
}
|
|
1269
1862
|
safeCall(instance, 'componentDidLoad');
|
|
1863
|
+
if (BUILD.isDev) {
|
|
1864
|
+
hostRef.$flags$ &= ~2048 /* HOST_FLAGS.devOnDidLoad */;
|
|
1865
|
+
}
|
|
1270
1866
|
}
|
|
1867
|
+
emitLifecycleEvent(elm, 'componentDidLoad');
|
|
1271
1868
|
endPostUpdate();
|
|
1272
|
-
{
|
|
1869
|
+
if (BUILD.asyncLoading) {
|
|
1273
1870
|
hostRef.$onReadyResolve$(elm);
|
|
1274
1871
|
if (!ancestorComponent) {
|
|
1275
|
-
appDidLoad();
|
|
1872
|
+
appDidLoad(tagName);
|
|
1276
1873
|
}
|
|
1277
1874
|
}
|
|
1278
1875
|
}
|
|
1279
1876
|
else {
|
|
1877
|
+
if (BUILD.cmpDidUpdate) {
|
|
1878
|
+
// we've already loaded this component
|
|
1879
|
+
// fire off the user's componentDidUpdate method (if one was provided)
|
|
1880
|
+
// componentDidUpdate runs AFTER render() has been called
|
|
1881
|
+
// and all child components have finished updating
|
|
1882
|
+
if (BUILD.isDev) {
|
|
1883
|
+
hostRef.$flags$ |= 1024 /* HOST_FLAGS.devOnRender */;
|
|
1884
|
+
}
|
|
1885
|
+
safeCall(instance, 'componentDidUpdate');
|
|
1886
|
+
if (BUILD.isDev) {
|
|
1887
|
+
hostRef.$flags$ &= ~1024 /* HOST_FLAGS.devOnRender */;
|
|
1888
|
+
}
|
|
1889
|
+
}
|
|
1890
|
+
emitLifecycleEvent(elm, 'componentDidUpdate');
|
|
1280
1891
|
endPostUpdate();
|
|
1281
1892
|
}
|
|
1282
|
-
{
|
|
1893
|
+
if (BUILD.hotModuleReplacement) {
|
|
1894
|
+
elm['s-hmr-load'] && elm['s-hmr-load']();
|
|
1895
|
+
}
|
|
1896
|
+
if (BUILD.method && BUILD.lazyLoad) {
|
|
1283
1897
|
hostRef.$onInstanceResolve$(elm);
|
|
1284
1898
|
}
|
|
1285
1899
|
// load events fire from bottom to top
|
|
1286
1900
|
// the deepest elements load first then bubbles up
|
|
1287
|
-
{
|
|
1901
|
+
if (BUILD.asyncLoading) {
|
|
1288
1902
|
if (hostRef.$onRenderResolve$) {
|
|
1289
1903
|
hostRef.$onRenderResolve$();
|
|
1290
1904
|
hostRef.$onRenderResolve$ = undefined;
|
|
@@ -1298,13 +1912,32 @@ const postUpdateComponent = (hostRef) => {
|
|
|
1298
1912
|
// ( •_•)>⌐■-■
|
|
1299
1913
|
// (⌐■_■)
|
|
1300
1914
|
};
|
|
1915
|
+
const forceUpdate = (ref) => {
|
|
1916
|
+
if (BUILD.updatable) {
|
|
1917
|
+
const hostRef = getHostRef(ref);
|
|
1918
|
+
const isConnected = hostRef.$hostElement$.isConnected;
|
|
1919
|
+
if (isConnected &&
|
|
1920
|
+
(hostRef.$flags$ & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
|
|
1921
|
+
scheduleUpdate(hostRef, false);
|
|
1922
|
+
}
|
|
1923
|
+
// Returns "true" when the forced update was successfully scheduled
|
|
1924
|
+
return isConnected;
|
|
1925
|
+
}
|
|
1926
|
+
return false;
|
|
1927
|
+
};
|
|
1301
1928
|
const appDidLoad = (who) => {
|
|
1302
1929
|
// on appload
|
|
1303
1930
|
// we have finish the first big initial render
|
|
1304
|
-
{
|
|
1931
|
+
if (BUILD.cssAnnotations) {
|
|
1305
1932
|
addHydratedFlag(doc.documentElement);
|
|
1306
1933
|
}
|
|
1934
|
+
if (BUILD.asyncQueue) {
|
|
1935
|
+
plt.$flags$ |= 2 /* PLATFORM_FLAGS.appLoaded */;
|
|
1936
|
+
}
|
|
1307
1937
|
nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
|
|
1938
|
+
if (BUILD.profile && performance.measure) {
|
|
1939
|
+
performance.measure(`[Stencil] ${NAMESPACE} initial load (by ${who})`, 'st:app:start');
|
|
1940
|
+
}
|
|
1308
1941
|
};
|
|
1309
1942
|
const safeCall = (instance, method, arg) => {
|
|
1310
1943
|
if (instance && instance[method]) {
|
|
@@ -1320,27 +1953,61 @@ const safeCall = (instance, method, arg) => {
|
|
|
1320
1953
|
const then = (promise, thenFn) => {
|
|
1321
1954
|
return promise && promise.then ? promise.then(thenFn) : thenFn();
|
|
1322
1955
|
};
|
|
1323
|
-
const
|
|
1324
|
-
|
|
1956
|
+
const emitLifecycleEvent = (elm, lifecycleName) => {
|
|
1957
|
+
if (BUILD.lifecycleDOMEvents) {
|
|
1958
|
+
emitEvent(elm, 'stencil_' + lifecycleName, {
|
|
1959
|
+
bubbles: true,
|
|
1960
|
+
composed: true,
|
|
1961
|
+
detail: {
|
|
1962
|
+
namespace: NAMESPACE,
|
|
1963
|
+
},
|
|
1964
|
+
});
|
|
1965
|
+
}
|
|
1966
|
+
};
|
|
1967
|
+
const addHydratedFlag = (elm) => BUILD.hydratedClass
|
|
1968
|
+
? elm.classList.add('hydrated')
|
|
1969
|
+
: BUILD.hydratedAttribute
|
|
1970
|
+
? elm.setAttribute('hydrated', '')
|
|
1971
|
+
: undefined;
|
|
1972
|
+
const serverSideConnected = (elm) => {
|
|
1973
|
+
const children = elm.children;
|
|
1974
|
+
if (children != null) {
|
|
1975
|
+
for (let i = 0, ii = children.length; i < ii; i++) {
|
|
1976
|
+
const childElm = children[i];
|
|
1977
|
+
if (typeof childElm.connectedCallback === 'function') {
|
|
1978
|
+
childElm.connectedCallback();
|
|
1979
|
+
}
|
|
1980
|
+
serverSideConnected(childElm);
|
|
1981
|
+
}
|
|
1982
|
+
}
|
|
1983
|
+
};
|
|
1325
1984
|
const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
|
|
1326
1985
|
const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
1327
1986
|
// check our new property value against our internal value
|
|
1328
1987
|
const hostRef = getHostRef(ref);
|
|
1329
|
-
const elm = hostRef.$hostElement$ ;
|
|
1988
|
+
const elm = BUILD.lazyLoad ? hostRef.$hostElement$ : ref;
|
|
1330
1989
|
const oldVal = hostRef.$instanceValues$.get(propName);
|
|
1331
1990
|
const flags = hostRef.$flags$;
|
|
1332
|
-
const instance = hostRef.$lazyInstance$ ;
|
|
1991
|
+
const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
|
|
1333
1992
|
newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
|
|
1334
1993
|
// explicitly check for NaN on both sides, as `NaN === NaN` is always false
|
|
1335
1994
|
const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
|
|
1336
1995
|
const didValueChange = newVal !== oldVal && !areBothNaN;
|
|
1337
|
-
if ((!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
|
|
1996
|
+
if ((!BUILD.lazyLoad || !(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
|
|
1338
1997
|
// gadzooks! the property's value has changed!!
|
|
1339
1998
|
// set our new value!
|
|
1340
1999
|
hostRef.$instanceValues$.set(propName, newVal);
|
|
1341
|
-
if (
|
|
2000
|
+
if (BUILD.isDev) {
|
|
2001
|
+
if (hostRef.$flags$ & 1024 /* HOST_FLAGS.devOnRender */) {
|
|
2002
|
+
consoleDevWarn(`The state/prop "${propName}" changed during rendering. This can potentially lead to infinite-loops and other bugs.`, '\nElement', elm, '\nNew value', newVal, '\nOld value', oldVal);
|
|
2003
|
+
}
|
|
2004
|
+
else if (hostRef.$flags$ & 2048 /* HOST_FLAGS.devOnDidLoad */) {
|
|
2005
|
+
consoleDevWarn(`The state/prop "${propName}" changed during "componentDidLoad()", this triggers extra re-renders, try to setup on "componentWillLoad()"`, '\nElement', elm, '\nNew value', newVal, '\nOld value', oldVal);
|
|
2006
|
+
}
|
|
2007
|
+
}
|
|
2008
|
+
if (!BUILD.lazyLoad || instance) {
|
|
1342
2009
|
// get an array of method names of watch functions to call
|
|
1343
|
-
if (cmpMeta.$watchers$ && flags & 128 /* HOST_FLAGS.isWatchReady */) {
|
|
2010
|
+
if (BUILD.watchCallback && cmpMeta.$watchers$ && flags & 128 /* HOST_FLAGS.isWatchReady */) {
|
|
1344
2011
|
const watchMethods = cmpMeta.$watchers$[propName];
|
|
1345
2012
|
if (watchMethods) {
|
|
1346
2013
|
// this instance is watching for when this property changed
|
|
@@ -1355,7 +2022,13 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
1355
2022
|
});
|
|
1356
2023
|
}
|
|
1357
2024
|
}
|
|
1358
|
-
if (
|
|
2025
|
+
if (BUILD.updatable &&
|
|
2026
|
+
(flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
|
|
2027
|
+
if (BUILD.cmpShouldUpdate && instance.componentShouldUpdate) {
|
|
2028
|
+
if (instance.componentShouldUpdate(newVal, oldVal, propName) === false) {
|
|
2029
|
+
return;
|
|
2030
|
+
}
|
|
2031
|
+
}
|
|
1359
2032
|
// looks like this value actually changed, so we've got work to do!
|
|
1360
2033
|
// but only if we've already rendered, otherwise just chill out
|
|
1361
2034
|
// queue that we need to do an update, but don't worry about queuing
|
|
@@ -1376,16 +2049,17 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
1376
2049
|
* @returns a reference to the same constructor passed in (but now mutated)
|
|
1377
2050
|
*/
|
|
1378
2051
|
const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
1379
|
-
if (cmpMeta.$members$) {
|
|
1380
|
-
if (Cstr.watchers) {
|
|
2052
|
+
if (BUILD.member && cmpMeta.$members$) {
|
|
2053
|
+
if (BUILD.watchCallback && Cstr.watchers) {
|
|
1381
2054
|
cmpMeta.$watchers$ = Cstr.watchers;
|
|
1382
2055
|
}
|
|
1383
2056
|
// It's better to have a const than two Object.entries()
|
|
1384
2057
|
const members = Object.entries(cmpMeta.$members$);
|
|
1385
2058
|
const prototype = Cstr.prototype;
|
|
1386
2059
|
members.map(([memberName, [memberFlags]]) => {
|
|
1387
|
-
if ((
|
|
1388
|
-
|
|
2060
|
+
if ((BUILD.prop || BUILD.state) &&
|
|
2061
|
+
(memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
|
|
2062
|
+
((!BUILD.lazyLoad || flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
|
|
1389
2063
|
// proxyComponent - prop
|
|
1390
2064
|
Object.defineProperty(prototype, memberName, {
|
|
1391
2065
|
get() {
|
|
@@ -1393,6 +2067,21 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1393
2067
|
return getValue(this, memberName);
|
|
1394
2068
|
},
|
|
1395
2069
|
set(newValue) {
|
|
2070
|
+
// only during dev time
|
|
2071
|
+
if (BUILD.isDev) {
|
|
2072
|
+
const ref = getHostRef(this);
|
|
2073
|
+
if (
|
|
2074
|
+
// we are proxying the instance (not element)
|
|
2075
|
+
(flags & 1 /* PROXY_FLAGS.isElementConstructor */) === 0 &&
|
|
2076
|
+
// the element is not constructing
|
|
2077
|
+
(ref.$flags$ & 8 /* HOST_FLAGS.isConstructingInstance */) === 0 &&
|
|
2078
|
+
// the member is a prop
|
|
2079
|
+
(memberFlags & 31 /* MEMBER_FLAGS.Prop */) !== 0 &&
|
|
2080
|
+
// the member is not mutable
|
|
2081
|
+
(memberFlags & 1024 /* MEMBER_FLAGS.Mutable */) === 0) {
|
|
2082
|
+
consoleDevWarn(`@Prop() "${memberName}" on <${cmpMeta.$tagName$}> is immutable but was modified from within the component.\nMore information: https://stenciljs.com/docs/properties#prop-mutability`);
|
|
2083
|
+
}
|
|
2084
|
+
}
|
|
1396
2085
|
// proxyComponent, set value
|
|
1397
2086
|
setValue(this, memberName, newValue, cmpMeta);
|
|
1398
2087
|
},
|
|
@@ -1400,7 +2089,9 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1400
2089
|
enumerable: true,
|
|
1401
2090
|
});
|
|
1402
2091
|
}
|
|
1403
|
-
else if (
|
|
2092
|
+
else if (BUILD.lazyLoad &&
|
|
2093
|
+
BUILD.method &&
|
|
2094
|
+
flags & 1 /* PROXY_FLAGS.isElementConstructor */ &&
|
|
1404
2095
|
memberFlags & 64 /* MEMBER_FLAGS.Method */) {
|
|
1405
2096
|
// proxyComponent - method
|
|
1406
2097
|
Object.defineProperty(prototype, memberName, {
|
|
@@ -1411,7 +2102,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1411
2102
|
});
|
|
1412
2103
|
}
|
|
1413
2104
|
});
|
|
1414
|
-
if ((flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
|
|
2105
|
+
if (BUILD.observeAttribute && (!BUILD.lazyLoad || flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
|
|
1415
2106
|
const attrNameToPropName = new Map();
|
|
1416
2107
|
prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
|
|
1417
2108
|
plt.jmp(() => {
|
|
@@ -1471,6 +2162,9 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1471
2162
|
.map(([propName, m]) => {
|
|
1472
2163
|
const attrName = m[1] || propName;
|
|
1473
2164
|
attrNameToPropName.set(attrName, propName);
|
|
2165
|
+
if (BUILD.reflect && m[0] & 512 /* MEMBER_FLAGS.ReflectAttr */) {
|
|
2166
|
+
cmpMeta.$attrsToReflect$.push([propName, attrName]);
|
|
2167
|
+
}
|
|
1474
2168
|
return attrName;
|
|
1475
2169
|
});
|
|
1476
2170
|
}
|
|
@@ -1479,25 +2173,29 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1479
2173
|
};
|
|
1480
2174
|
const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
|
|
1481
2175
|
// initializeComponent
|
|
1482
|
-
if ((
|
|
1483
|
-
{
|
|
2176
|
+
if ((BUILD.lazyLoad || BUILD.hydrateServerSide || BUILD.style) &&
|
|
2177
|
+
(hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
|
|
2178
|
+
if (BUILD.lazyLoad || BUILD.hydrateClientSide) {
|
|
1484
2179
|
// we haven't initialized this element yet
|
|
1485
2180
|
hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
|
|
1486
2181
|
// lazy loaded components
|
|
1487
2182
|
// request the component's implementation to be
|
|
1488
2183
|
// wired up with the host element
|
|
1489
|
-
Cstr = loadModule(cmpMeta);
|
|
2184
|
+
Cstr = loadModule(cmpMeta, hostRef, hmrVersionId);
|
|
1490
2185
|
if (Cstr.then) {
|
|
1491
2186
|
// Await creates a micro-task avoid if possible
|
|
1492
|
-
const endLoad = uniqueTime();
|
|
2187
|
+
const endLoad = uniqueTime(`st:load:${cmpMeta.$tagName$}:${hostRef.$modeName$}`, `[Stencil] Load module for <${cmpMeta.$tagName$}>`);
|
|
1493
2188
|
Cstr = await Cstr;
|
|
1494
2189
|
endLoad();
|
|
1495
2190
|
}
|
|
1496
|
-
if (!Cstr
|
|
2191
|
+
if ((BUILD.isDev || BUILD.isDebug) && !Cstr) {
|
|
2192
|
+
throw new Error(`Constructor for "${cmpMeta.$tagName$}#${hostRef.$modeName$}" was not found`);
|
|
2193
|
+
}
|
|
2194
|
+
if (BUILD.member && !Cstr.isProxied) {
|
|
1497
2195
|
// we've never proxied this Constructor before
|
|
1498
2196
|
// let's add the getters/setters to its prototype before
|
|
1499
2197
|
// the first time we create an instance of the implementation
|
|
1500
|
-
{
|
|
2198
|
+
if (BUILD.watchCallback) {
|
|
1501
2199
|
cmpMeta.$watchers$ = Cstr.watchers;
|
|
1502
2200
|
}
|
|
1503
2201
|
proxyComponent(Cstr, cmpMeta, 2 /* PROXY_FLAGS.proxyState */);
|
|
@@ -1507,7 +2205,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1507
2205
|
// ok, time to construct the instance
|
|
1508
2206
|
// but let's keep track of when we start and stop
|
|
1509
2207
|
// so that the getters/setters don't incorrectly step on data
|
|
1510
|
-
{
|
|
2208
|
+
if (BUILD.member) {
|
|
1511
2209
|
hostRef.$flags$ |= 8 /* HOST_FLAGS.isConstructingInstance */;
|
|
1512
2210
|
}
|
|
1513
2211
|
// construct the lazy-loaded component implementation
|
|
@@ -1520,21 +2218,42 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1520
2218
|
catch (e) {
|
|
1521
2219
|
consoleError(e);
|
|
1522
2220
|
}
|
|
1523
|
-
{
|
|
2221
|
+
if (BUILD.member) {
|
|
1524
2222
|
hostRef.$flags$ &= ~8 /* HOST_FLAGS.isConstructingInstance */;
|
|
1525
2223
|
}
|
|
1526
|
-
{
|
|
2224
|
+
if (BUILD.watchCallback) {
|
|
1527
2225
|
hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */;
|
|
1528
2226
|
}
|
|
1529
2227
|
endNewInstance();
|
|
1530
2228
|
fireConnectedCallback(hostRef.$lazyInstance$);
|
|
1531
2229
|
}
|
|
1532
|
-
|
|
2230
|
+
else {
|
|
2231
|
+
// sync constructor component
|
|
2232
|
+
Cstr = elm.constructor;
|
|
2233
|
+
hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
|
|
2234
|
+
// wait for the CustomElementRegistry to mark the component as ready before setting `isWatchReady`. Otherwise,
|
|
2235
|
+
// watchers may fire prematurely if `customElements.get()`/`customElements.whenDefined()` resolves _before_
|
|
2236
|
+
// Stencil has completed instantiating the component.
|
|
2237
|
+
customElements.whenDefined(cmpMeta.$tagName$).then(() => (hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */));
|
|
2238
|
+
}
|
|
2239
|
+
if (BUILD.style && Cstr.style) {
|
|
1533
2240
|
// this component has styles but we haven't registered them yet
|
|
1534
2241
|
let style = Cstr.style;
|
|
1535
|
-
|
|
2242
|
+
if (BUILD.mode && typeof style !== 'string') {
|
|
2243
|
+
style = style[(hostRef.$modeName$ = computeMode(elm))];
|
|
2244
|
+
if (BUILD.hydrateServerSide && hostRef.$modeName$) {
|
|
2245
|
+
elm.setAttribute('s-mode', hostRef.$modeName$);
|
|
2246
|
+
}
|
|
2247
|
+
}
|
|
2248
|
+
const scopeId = getScopeId(cmpMeta, hostRef.$modeName$);
|
|
1536
2249
|
if (!styles.has(scopeId)) {
|
|
1537
2250
|
const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
|
|
2251
|
+
if (!BUILD.hydrateServerSide &&
|
|
2252
|
+
BUILD.shadowDom &&
|
|
2253
|
+
BUILD.shadowDomShim &&
|
|
2254
|
+
cmpMeta.$flags$ & 8 /* CMP_FLAGS.needsShadowDomShim */) {
|
|
2255
|
+
style = await Promise.resolve().then(function () { return require('./shadow-css-346c0795.js'); }).then((m) => m.scopeCss(style, scopeId, false));
|
|
2256
|
+
}
|
|
1538
2257
|
registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
|
|
1539
2258
|
endRegisterStyles();
|
|
1540
2259
|
}
|
|
@@ -1543,7 +2262,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1543
2262
|
// we've successfully created a lazy instance
|
|
1544
2263
|
const ancestorComponent = hostRef.$ancestorComponent$;
|
|
1545
2264
|
const schedule = () => scheduleUpdate(hostRef, true);
|
|
1546
|
-
if (ancestorComponent && ancestorComponent['s-rc']) {
|
|
2265
|
+
if (BUILD.asyncLoading && ancestorComponent && ancestorComponent['s-rc']) {
|
|
1547
2266
|
// this is the initial load and this component it has an ancestor component
|
|
1548
2267
|
// but the ancestor component has NOT fired its will update lifecycle yet
|
|
1549
2268
|
// so let's just cool our jets and wait for the ancestor to continue first
|
|
@@ -1557,7 +2276,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1557
2276
|
}
|
|
1558
2277
|
};
|
|
1559
2278
|
const fireConnectedCallback = (instance) => {
|
|
1560
|
-
{
|
|
2279
|
+
if (BUILD.lazyLoad && BUILD.connectedCallback) {
|
|
1561
2280
|
safeCall(instance, 'connectedCallback');
|
|
1562
2281
|
}
|
|
1563
2282
|
};
|
|
@@ -1566,26 +2285,49 @@ const connectedCallback = (elm) => {
|
|
|
1566
2285
|
const hostRef = getHostRef(elm);
|
|
1567
2286
|
const cmpMeta = hostRef.$cmpMeta$;
|
|
1568
2287
|
const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
|
|
2288
|
+
if (BUILD.hostListenerTargetParent) {
|
|
2289
|
+
// only run if we have listeners being attached to a parent
|
|
2290
|
+
addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, true);
|
|
2291
|
+
}
|
|
1569
2292
|
if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
|
|
1570
2293
|
// first time this component has connected
|
|
1571
2294
|
hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
|
|
1572
|
-
|
|
2295
|
+
let hostId;
|
|
2296
|
+
if (BUILD.hydrateClientSide) {
|
|
2297
|
+
hostId = elm.getAttribute(HYDRATE_ID);
|
|
2298
|
+
if (hostId) {
|
|
2299
|
+
if (BUILD.shadowDom && supportsShadow && cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
|
|
2300
|
+
const scopeId = BUILD.mode
|
|
2301
|
+
? addStyle(elm.shadowRoot, cmpMeta, elm.getAttribute('s-mode'))
|
|
2302
|
+
: addStyle(elm.shadowRoot, cmpMeta);
|
|
2303
|
+
elm.classList.remove(scopeId + '-h', scopeId + '-s');
|
|
2304
|
+
}
|
|
2305
|
+
initializeClientHydrate(elm, cmpMeta.$tagName$, hostId, hostRef);
|
|
2306
|
+
}
|
|
2307
|
+
}
|
|
2308
|
+
if (BUILD.slotRelocation && !hostId) {
|
|
1573
2309
|
// initUpdate
|
|
1574
2310
|
// if the slot polyfill is required we'll need to put some nodes
|
|
1575
2311
|
// in here to act as original content anchors as we move nodes around
|
|
1576
2312
|
// host element has been connected to the DOM
|
|
1577
|
-
if (
|
|
2313
|
+
if (BUILD.hydrateServerSide ||
|
|
2314
|
+
((BUILD.slot || BUILD.shadowDom) &&
|
|
2315
|
+
cmpMeta.$flags$ & (4 /* CMP_FLAGS.hasSlotRelocation */ | 8 /* CMP_FLAGS.needsShadowDomShim */))) {
|
|
1578
2316
|
setContentReference(elm);
|
|
1579
2317
|
}
|
|
1580
2318
|
}
|
|
1581
|
-
{
|
|
2319
|
+
if (BUILD.asyncLoading) {
|
|
1582
2320
|
// find the first ancestor component (if there is one) and register
|
|
1583
2321
|
// this component as one of the actively loading child components for its ancestor
|
|
1584
2322
|
let ancestorComponent = elm;
|
|
1585
2323
|
while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
|
|
1586
2324
|
// climb up the ancestors looking for the first
|
|
1587
2325
|
// component that hasn't finished its lifecycle update yet
|
|
1588
|
-
if (
|
|
2326
|
+
if ((BUILD.hydrateClientSide &&
|
|
2327
|
+
ancestorComponent.nodeType === 1 /* NODE_TYPE.ElementNode */ &&
|
|
2328
|
+
ancestorComponent.hasAttribute('s-id') &&
|
|
2329
|
+
ancestorComponent['s-p']) ||
|
|
2330
|
+
ancestorComponent['s-p']) {
|
|
1589
2331
|
// we found this components first ancestor component
|
|
1590
2332
|
// keep a reference to this component's ancestor component
|
|
1591
2333
|
attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
|
|
@@ -1595,7 +2337,7 @@ const connectedCallback = (elm) => {
|
|
|
1595
2337
|
}
|
|
1596
2338
|
// Lazy properties
|
|
1597
2339
|
// https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
|
|
1598
|
-
if (cmpMeta.$members$) {
|
|
2340
|
+
if (BUILD.prop && !BUILD.hydrateServerSide && cmpMeta.$members$) {
|
|
1599
2341
|
Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
|
|
1600
2342
|
if (memberFlags & 31 /* MEMBER_FLAGS.Prop */ && elm.hasOwnProperty(memberName)) {
|
|
1601
2343
|
const value = elm[memberName];
|
|
@@ -1604,11 +2346,22 @@ const connectedCallback = (elm) => {
|
|
|
1604
2346
|
}
|
|
1605
2347
|
});
|
|
1606
2348
|
}
|
|
1607
|
-
{
|
|
2349
|
+
if (BUILD.initializeNextTick) {
|
|
2350
|
+
// connectedCallback, taskQueue, initialLoad
|
|
2351
|
+
// angular sets attribute AFTER connectCallback
|
|
2352
|
+
// https://github.com/angular/angular/issues/18909
|
|
2353
|
+
// https://github.com/angular/angular/issues/19940
|
|
2354
|
+
nextTick(() => initializeComponent(elm, hostRef, cmpMeta));
|
|
2355
|
+
}
|
|
2356
|
+
else {
|
|
1608
2357
|
initializeComponent(elm, hostRef, cmpMeta);
|
|
1609
2358
|
}
|
|
1610
2359
|
}
|
|
1611
2360
|
else {
|
|
2361
|
+
// not the first time this has connected
|
|
2362
|
+
// reattach any event listeners to the host
|
|
2363
|
+
// since they would have been removed when disconnected
|
|
2364
|
+
addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, false);
|
|
1612
2365
|
// fire off connectedCallback() on component instance
|
|
1613
2366
|
fireConnectedCallback(hostRef.$lazyInstance$);
|
|
1614
2367
|
}
|
|
@@ -1622,21 +2375,316 @@ const setContentReference = (elm) => {
|
|
|
1622
2375
|
// let's pick out the inner content for slot projection
|
|
1623
2376
|
// create a node to represent where the original
|
|
1624
2377
|
// content was first placed, which is useful later on
|
|
1625
|
-
const contentRefElm = (elm['s-cr'] = doc.createComment(''));
|
|
2378
|
+
const contentRefElm = (elm['s-cr'] = doc.createComment(BUILD.isDebug ? `content-ref (host=${elm.localName})` : ''));
|
|
1626
2379
|
contentRefElm['s-cn'] = true;
|
|
1627
2380
|
elm.insertBefore(contentRefElm, elm.firstChild);
|
|
1628
2381
|
};
|
|
1629
2382
|
const disconnectedCallback = (elm) => {
|
|
1630
2383
|
if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
|
|
1631
2384
|
const hostRef = getHostRef(elm);
|
|
1632
|
-
const instance = hostRef.$lazyInstance$ ;
|
|
1633
|
-
{
|
|
2385
|
+
const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
|
|
2386
|
+
if (BUILD.hostListener) {
|
|
2387
|
+
if (hostRef.$rmListeners$) {
|
|
2388
|
+
hostRef.$rmListeners$.map((rmListener) => rmListener());
|
|
2389
|
+
hostRef.$rmListeners$ = undefined;
|
|
2390
|
+
}
|
|
2391
|
+
}
|
|
2392
|
+
// clear CSS var-shim tracking
|
|
2393
|
+
if (BUILD.cssVarShim && plt.$cssShim$) {
|
|
2394
|
+
plt.$cssShim$.removeHost(elm);
|
|
2395
|
+
}
|
|
2396
|
+
if (BUILD.lazyLoad && BUILD.disconnectedCallback) {
|
|
1634
2397
|
safeCall(instance, 'disconnectedCallback');
|
|
1635
2398
|
}
|
|
2399
|
+
if (BUILD.cmpDidUnload) {
|
|
2400
|
+
safeCall(instance, 'componentDidUnload');
|
|
2401
|
+
}
|
|
2402
|
+
}
|
|
2403
|
+
};
|
|
2404
|
+
const defineCustomElement = (Cstr, compactMeta) => {
|
|
2405
|
+
customElements.define(compactMeta[1], proxyCustomElement(Cstr, compactMeta));
|
|
2406
|
+
};
|
|
2407
|
+
const proxyCustomElement = (Cstr, compactMeta) => {
|
|
2408
|
+
const cmpMeta = {
|
|
2409
|
+
$flags$: compactMeta[0],
|
|
2410
|
+
$tagName$: compactMeta[1],
|
|
2411
|
+
};
|
|
2412
|
+
if (BUILD.member) {
|
|
2413
|
+
cmpMeta.$members$ = compactMeta[2];
|
|
2414
|
+
}
|
|
2415
|
+
if (BUILD.hostListener) {
|
|
2416
|
+
cmpMeta.$listeners$ = compactMeta[3];
|
|
2417
|
+
}
|
|
2418
|
+
if (BUILD.watchCallback) {
|
|
2419
|
+
cmpMeta.$watchers$ = Cstr.$watchers$;
|
|
2420
|
+
}
|
|
2421
|
+
if (BUILD.reflect) {
|
|
2422
|
+
cmpMeta.$attrsToReflect$ = [];
|
|
2423
|
+
}
|
|
2424
|
+
if (BUILD.shadowDom && !supportsShadow && cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
|
|
2425
|
+
cmpMeta.$flags$ |= 8 /* CMP_FLAGS.needsShadowDomShim */;
|
|
2426
|
+
}
|
|
2427
|
+
const originalConnectedCallback = Cstr.prototype.connectedCallback;
|
|
2428
|
+
const originalDisconnectedCallback = Cstr.prototype.disconnectedCallback;
|
|
2429
|
+
Object.assign(Cstr.prototype, {
|
|
2430
|
+
__registerHost() {
|
|
2431
|
+
registerHost(this, cmpMeta);
|
|
2432
|
+
},
|
|
2433
|
+
connectedCallback() {
|
|
2434
|
+
connectedCallback(this);
|
|
2435
|
+
if (BUILD.connectedCallback && originalConnectedCallback) {
|
|
2436
|
+
originalConnectedCallback.call(this);
|
|
2437
|
+
}
|
|
2438
|
+
},
|
|
2439
|
+
disconnectedCallback() {
|
|
2440
|
+
disconnectedCallback(this);
|
|
2441
|
+
if (BUILD.disconnectedCallback && originalDisconnectedCallback) {
|
|
2442
|
+
originalDisconnectedCallback.call(this);
|
|
2443
|
+
}
|
|
2444
|
+
},
|
|
2445
|
+
__attachShadow() {
|
|
2446
|
+
if (supportsShadow) {
|
|
2447
|
+
if (BUILD.shadowDelegatesFocus) {
|
|
2448
|
+
this.attachShadow({
|
|
2449
|
+
mode: 'open',
|
|
2450
|
+
delegatesFocus: !!(cmpMeta.$flags$ & 16 /* CMP_FLAGS.shadowDelegatesFocus */),
|
|
2451
|
+
});
|
|
2452
|
+
}
|
|
2453
|
+
else {
|
|
2454
|
+
this.attachShadow({ mode: 'open' });
|
|
2455
|
+
}
|
|
2456
|
+
}
|
|
2457
|
+
else {
|
|
2458
|
+
this.shadowRoot = this;
|
|
2459
|
+
}
|
|
2460
|
+
},
|
|
2461
|
+
});
|
|
2462
|
+
Cstr.is = cmpMeta.$tagName$;
|
|
2463
|
+
return proxyComponent(Cstr, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */ | 2 /* PROXY_FLAGS.proxyState */);
|
|
2464
|
+
};
|
|
2465
|
+
const forceModeUpdate = (elm) => {
|
|
2466
|
+
if (BUILD.style && BUILD.mode && !BUILD.lazyLoad) {
|
|
2467
|
+
const mode = computeMode(elm);
|
|
2468
|
+
const hostRef = getHostRef(elm);
|
|
2469
|
+
if (hostRef.$modeName$ !== mode) {
|
|
2470
|
+
const cmpMeta = hostRef.$cmpMeta$;
|
|
2471
|
+
const oldScopeId = elm['s-sc'];
|
|
2472
|
+
const scopeId = getScopeId(cmpMeta, mode);
|
|
2473
|
+
const style = elm.constructor.style[mode];
|
|
2474
|
+
const flags = cmpMeta.$flags$;
|
|
2475
|
+
if (style) {
|
|
2476
|
+
if (!styles.has(scopeId)) {
|
|
2477
|
+
registerStyle(scopeId, style, !!(flags & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
|
|
2478
|
+
}
|
|
2479
|
+
hostRef.$modeName$ = mode;
|
|
2480
|
+
elm.classList.remove(oldScopeId + '-h', oldScopeId + '-s');
|
|
2481
|
+
attachStyles(hostRef);
|
|
2482
|
+
forceUpdate(elm);
|
|
2483
|
+
}
|
|
2484
|
+
}
|
|
2485
|
+
}
|
|
2486
|
+
};
|
|
2487
|
+
const patchCloneNode = (HostElementPrototype) => {
|
|
2488
|
+
const orgCloneNode = HostElementPrototype.cloneNode;
|
|
2489
|
+
HostElementPrototype.cloneNode = function (deep) {
|
|
2490
|
+
const srcNode = this;
|
|
2491
|
+
const isShadowDom = BUILD.shadowDom ? srcNode.shadowRoot && supportsShadow : false;
|
|
2492
|
+
const clonedNode = orgCloneNode.call(srcNode, isShadowDom ? deep : false);
|
|
2493
|
+
if (BUILD.slot && !isShadowDom && deep) {
|
|
2494
|
+
let i = 0;
|
|
2495
|
+
let slotted, nonStencilNode;
|
|
2496
|
+
const stencilPrivates = [
|
|
2497
|
+
's-id',
|
|
2498
|
+
's-cr',
|
|
2499
|
+
's-lr',
|
|
2500
|
+
's-rc',
|
|
2501
|
+
's-sc',
|
|
2502
|
+
's-p',
|
|
2503
|
+
's-cn',
|
|
2504
|
+
's-sr',
|
|
2505
|
+
's-sn',
|
|
2506
|
+
's-hn',
|
|
2507
|
+
's-ol',
|
|
2508
|
+
's-nr',
|
|
2509
|
+
's-si',
|
|
2510
|
+
];
|
|
2511
|
+
for (; i < srcNode.childNodes.length; i++) {
|
|
2512
|
+
slotted = srcNode.childNodes[i]['s-nr'];
|
|
2513
|
+
nonStencilNode = stencilPrivates.every((privateField) => !srcNode.childNodes[i][privateField]);
|
|
2514
|
+
if (slotted) {
|
|
2515
|
+
if (BUILD.appendChildSlotFix && clonedNode.__appendChild) {
|
|
2516
|
+
clonedNode.__appendChild(slotted.cloneNode(true));
|
|
2517
|
+
}
|
|
2518
|
+
else {
|
|
2519
|
+
clonedNode.appendChild(slotted.cloneNode(true));
|
|
2520
|
+
}
|
|
2521
|
+
}
|
|
2522
|
+
if (nonStencilNode) {
|
|
2523
|
+
clonedNode.appendChild(srcNode.childNodes[i].cloneNode(true));
|
|
2524
|
+
}
|
|
2525
|
+
}
|
|
2526
|
+
}
|
|
2527
|
+
return clonedNode;
|
|
2528
|
+
};
|
|
2529
|
+
};
|
|
2530
|
+
const patchSlotAppendChild = (HostElementPrototype) => {
|
|
2531
|
+
HostElementPrototype.__appendChild = HostElementPrototype.appendChild;
|
|
2532
|
+
HostElementPrototype.appendChild = function (newChild) {
|
|
2533
|
+
const slotName = (newChild['s-sn'] = getSlotName(newChild));
|
|
2534
|
+
const slotNode = getHostSlotNode(this.childNodes, slotName);
|
|
2535
|
+
if (slotNode) {
|
|
2536
|
+
const slotChildNodes = getHostSlotChildNodes(slotNode, slotName);
|
|
2537
|
+
const appendAfter = slotChildNodes[slotChildNodes.length - 1];
|
|
2538
|
+
return appendAfter.parentNode.insertBefore(newChild, appendAfter.nextSibling);
|
|
2539
|
+
}
|
|
2540
|
+
return this.__appendChild(newChild);
|
|
2541
|
+
};
|
|
2542
|
+
};
|
|
2543
|
+
/**
|
|
2544
|
+
* Patches the text content of an unnamed slotted node inside a scoped component
|
|
2545
|
+
* @param hostElementPrototype the `Element` to be patched
|
|
2546
|
+
* @param cmpMeta component runtime metadata used to determine if the component should be patched or not
|
|
2547
|
+
*/
|
|
2548
|
+
const patchTextContent = (hostElementPrototype, cmpMeta) => {
|
|
2549
|
+
if (BUILD.scoped && cmpMeta.$flags$ & 2 /* CMP_FLAGS.scopedCssEncapsulation */) {
|
|
2550
|
+
const descriptor = Object.getOwnPropertyDescriptor(Node.prototype, 'textContent');
|
|
2551
|
+
Object.defineProperty(hostElementPrototype, '__textContent', descriptor);
|
|
2552
|
+
Object.defineProperty(hostElementPrototype, 'textContent', {
|
|
2553
|
+
get() {
|
|
2554
|
+
var _a;
|
|
2555
|
+
// get the 'default slot', which would be the first slot in a shadow tree (if we were using one), whose name is
|
|
2556
|
+
// the empty string
|
|
2557
|
+
const slotNode = getHostSlotNode(this.childNodes, '');
|
|
2558
|
+
// when a slot node is found, the textContent _may_ be found in the next sibling (text) node, depending on how
|
|
2559
|
+
// nodes were reordered during the vdom render. first try to get the text content from the sibling.
|
|
2560
|
+
if (((_a = slotNode === null || slotNode === void 0 ? void 0 : slotNode.nextSibling) === null || _a === void 0 ? void 0 : _a.nodeType) === 3 /* NODE_TYPES.TEXT_NODE */) {
|
|
2561
|
+
return slotNode.nextSibling.textContent;
|
|
2562
|
+
}
|
|
2563
|
+
else if (slotNode) {
|
|
2564
|
+
return slotNode.textContent;
|
|
2565
|
+
}
|
|
2566
|
+
else {
|
|
2567
|
+
// fallback to the original implementation
|
|
2568
|
+
return this.__textContent;
|
|
2569
|
+
}
|
|
2570
|
+
},
|
|
2571
|
+
set(value) {
|
|
2572
|
+
var _a;
|
|
2573
|
+
// get the 'default slot', which would be the first slot in a shadow tree (if we were using one), whose name is
|
|
2574
|
+
// the empty string
|
|
2575
|
+
const slotNode = getHostSlotNode(this.childNodes, '');
|
|
2576
|
+
// when a slot node is found, the textContent _may_ need to be placed in the next sibling (text) node,
|
|
2577
|
+
// depending on how nodes were reordered during the vdom render. first try to set the text content on the
|
|
2578
|
+
// sibling.
|
|
2579
|
+
if (((_a = slotNode === null || slotNode === void 0 ? void 0 : slotNode.nextSibling) === null || _a === void 0 ? void 0 : _a.nodeType) === 3 /* NODE_TYPES.TEXT_NODE */) {
|
|
2580
|
+
slotNode.nextSibling.textContent = value;
|
|
2581
|
+
}
|
|
2582
|
+
else if (slotNode) {
|
|
2583
|
+
slotNode.textContent = value;
|
|
2584
|
+
}
|
|
2585
|
+
else {
|
|
2586
|
+
// we couldn't find a slot, but that doesn't mean that there isn't one. if this check ran before the DOM
|
|
2587
|
+
// loaded, we could have missed it. check for a content reference element on the scoped component and insert
|
|
2588
|
+
// it there
|
|
2589
|
+
this.__textContent = value;
|
|
2590
|
+
const contentRefElm = this['s-cr'];
|
|
2591
|
+
if (contentRefElm) {
|
|
2592
|
+
this.insertBefore(contentRefElm, this.firstChild);
|
|
2593
|
+
}
|
|
2594
|
+
}
|
|
2595
|
+
},
|
|
2596
|
+
});
|
|
2597
|
+
}
|
|
2598
|
+
};
|
|
2599
|
+
const patchChildSlotNodes = (elm, cmpMeta) => {
|
|
2600
|
+
class FakeNodeList extends Array {
|
|
2601
|
+
item(n) {
|
|
2602
|
+
return this[n];
|
|
2603
|
+
}
|
|
2604
|
+
}
|
|
2605
|
+
if (cmpMeta.$flags$ & 8 /* CMP_FLAGS.needsShadowDomShim */) {
|
|
2606
|
+
const childNodesFn = elm.__lookupGetter__('childNodes');
|
|
2607
|
+
Object.defineProperty(elm, 'children', {
|
|
2608
|
+
get() {
|
|
2609
|
+
return this.childNodes.map((n) => n.nodeType === 1);
|
|
2610
|
+
},
|
|
2611
|
+
});
|
|
2612
|
+
Object.defineProperty(elm, 'childElementCount', {
|
|
2613
|
+
get() {
|
|
2614
|
+
return elm.children.length;
|
|
2615
|
+
},
|
|
2616
|
+
});
|
|
2617
|
+
Object.defineProperty(elm, 'childNodes', {
|
|
2618
|
+
get() {
|
|
2619
|
+
const childNodes = childNodesFn.call(this);
|
|
2620
|
+
if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0 &&
|
|
2621
|
+
getHostRef(this).$flags$ & 2 /* HOST_FLAGS.hasRendered */) {
|
|
2622
|
+
const result = new FakeNodeList();
|
|
2623
|
+
for (let i = 0; i < childNodes.length; i++) {
|
|
2624
|
+
const slot = childNodes[i]['s-nr'];
|
|
2625
|
+
if (slot) {
|
|
2626
|
+
result.push(slot);
|
|
2627
|
+
}
|
|
2628
|
+
}
|
|
2629
|
+
return result;
|
|
2630
|
+
}
|
|
2631
|
+
return FakeNodeList.from(childNodes);
|
|
2632
|
+
},
|
|
2633
|
+
});
|
|
1636
2634
|
}
|
|
1637
2635
|
};
|
|
2636
|
+
const getSlotName = (node) => node['s-sn'] || (node.nodeType === 1 && node.getAttribute('slot')) || '';
|
|
2637
|
+
/**
|
|
2638
|
+
* Recursively searches a series of child nodes for a slot with the provided name.
|
|
2639
|
+
* @param childNodes the nodes to search for a slot with a specific name.
|
|
2640
|
+
* @param slotName the name of the slot to match on.
|
|
2641
|
+
* @returns a reference to the slot node that matches the provided name, `null` otherwise
|
|
2642
|
+
*/
|
|
2643
|
+
const getHostSlotNode = (childNodes, slotName) => {
|
|
2644
|
+
let i = 0;
|
|
2645
|
+
let childNode;
|
|
2646
|
+
for (; i < childNodes.length; i++) {
|
|
2647
|
+
childNode = childNodes[i];
|
|
2648
|
+
if (childNode['s-sr'] && childNode['s-sn'] === slotName) {
|
|
2649
|
+
return childNode;
|
|
2650
|
+
}
|
|
2651
|
+
childNode = getHostSlotNode(childNode.childNodes, slotName);
|
|
2652
|
+
if (childNode) {
|
|
2653
|
+
return childNode;
|
|
2654
|
+
}
|
|
2655
|
+
}
|
|
2656
|
+
return null;
|
|
2657
|
+
};
|
|
2658
|
+
const getHostSlotChildNodes = (n, slotName) => {
|
|
2659
|
+
const childNodes = [n];
|
|
2660
|
+
while ((n = n.nextSibling) && n['s-sn'] === slotName) {
|
|
2661
|
+
childNodes.push(n);
|
|
2662
|
+
}
|
|
2663
|
+
return childNodes;
|
|
2664
|
+
};
|
|
2665
|
+
const hmrStart = (elm, cmpMeta, hmrVersionId) => {
|
|
2666
|
+
// ¯\_(ツ)_/¯
|
|
2667
|
+
const hostRef = getHostRef(elm);
|
|
2668
|
+
// reset state flags to only have been connected
|
|
2669
|
+
hostRef.$flags$ = 1 /* HOST_FLAGS.hasConnected */;
|
|
2670
|
+
// TODO
|
|
2671
|
+
// detatch any event listeners that may have been added
|
|
2672
|
+
// because we're not passing an exact event name it'll
|
|
2673
|
+
// remove all of this element's event, which is good
|
|
2674
|
+
// create a callback for when this component finishes hmr
|
|
2675
|
+
elm['s-hmr-load'] = () => {
|
|
2676
|
+
// finished hmr for this element
|
|
2677
|
+
delete elm['s-hmr-load'];
|
|
2678
|
+
};
|
|
2679
|
+
// re-initialize the component
|
|
2680
|
+
initializeComponent(elm, hostRef, cmpMeta, hmrVersionId);
|
|
2681
|
+
};
|
|
1638
2682
|
const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
1639
|
-
|
|
2683
|
+
if (BUILD.profile && performance.mark) {
|
|
2684
|
+
performance.mark('st:app:start');
|
|
2685
|
+
}
|
|
2686
|
+
installDevTools();
|
|
2687
|
+
const endBootstrap = createTime('bootstrapLazy');
|
|
1640
2688
|
const cmpTags = [];
|
|
1641
2689
|
const exclude = options.exclude || [];
|
|
1642
2690
|
const customElements = win.customElements;
|
|
@@ -1644,10 +2692,27 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1644
2692
|
const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
|
|
1645
2693
|
const visibilityStyle = /*@__PURE__*/ doc.createElement('style');
|
|
1646
2694
|
const deferredConnectedCallbacks = [];
|
|
2695
|
+
const styles = /*@__PURE__*/ doc.querySelectorAll(`[${HYDRATED_STYLE_ID}]`);
|
|
1647
2696
|
let appLoadFallback;
|
|
1648
2697
|
let isBootstrapping = true;
|
|
2698
|
+
let i = 0;
|
|
1649
2699
|
Object.assign(plt, options);
|
|
1650
2700
|
plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
|
|
2701
|
+
if (BUILD.asyncQueue) {
|
|
2702
|
+
if (options.syncQueue) {
|
|
2703
|
+
plt.$flags$ |= 4 /* PLATFORM_FLAGS.queueSync */;
|
|
2704
|
+
}
|
|
2705
|
+
}
|
|
2706
|
+
if (BUILD.hydrateClientSide) {
|
|
2707
|
+
// If the app is already hydrated there is not point to disable the
|
|
2708
|
+
// async queue. This will improve the first input delay
|
|
2709
|
+
plt.$flags$ |= 2 /* PLATFORM_FLAGS.appLoaded */;
|
|
2710
|
+
}
|
|
2711
|
+
if (BUILD.hydrateClientSide && BUILD.shadowDom) {
|
|
2712
|
+
for (; i < styles.length; i++) {
|
|
2713
|
+
registerStyle(styles[i].getAttribute(HYDRATED_STYLE_ID), convertScopedToShadow(styles[i].innerHTML), true);
|
|
2714
|
+
}
|
|
2715
|
+
}
|
|
1651
2716
|
lazyBundles.map((lazyBundle) => {
|
|
1652
2717
|
lazyBundle[1].map((compactMeta) => {
|
|
1653
2718
|
const cmpMeta = {
|
|
@@ -1656,13 +2721,24 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1656
2721
|
$members$: compactMeta[2],
|
|
1657
2722
|
$listeners$: compactMeta[3],
|
|
1658
2723
|
};
|
|
1659
|
-
{
|
|
2724
|
+
if (BUILD.member) {
|
|
1660
2725
|
cmpMeta.$members$ = compactMeta[2];
|
|
1661
2726
|
}
|
|
1662
|
-
{
|
|
2727
|
+
if (BUILD.hostListener) {
|
|
2728
|
+
cmpMeta.$listeners$ = compactMeta[3];
|
|
2729
|
+
}
|
|
2730
|
+
if (BUILD.reflect) {
|
|
2731
|
+
cmpMeta.$attrsToReflect$ = [];
|
|
2732
|
+
}
|
|
2733
|
+
if (BUILD.watchCallback) {
|
|
1663
2734
|
cmpMeta.$watchers$ = {};
|
|
1664
2735
|
}
|
|
1665
|
-
|
|
2736
|
+
if (BUILD.shadowDom && !supportsShadow && cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
|
|
2737
|
+
cmpMeta.$flags$ |= 8 /* CMP_FLAGS.needsShadowDomShim */;
|
|
2738
|
+
}
|
|
2739
|
+
const tagName = BUILD.transformTagName && options.transformTagName
|
|
2740
|
+
? options.transformTagName(cmpMeta.$tagName$)
|
|
2741
|
+
: cmpMeta.$tagName$;
|
|
1666
2742
|
const HostElement = class extends HTMLElement {
|
|
1667
2743
|
// StencilLazyHost
|
|
1668
2744
|
constructor(self) {
|
|
@@ -1670,16 +2746,28 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1670
2746
|
super(self);
|
|
1671
2747
|
self = this;
|
|
1672
2748
|
registerHost(self, cmpMeta);
|
|
1673
|
-
if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
|
|
2749
|
+
if (BUILD.shadowDom && cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
|
|
1674
2750
|
// this component is using shadow dom
|
|
1675
2751
|
// and this browser supports shadow dom
|
|
1676
2752
|
// add the read-only property "shadowRoot" to the host element
|
|
1677
2753
|
// adding the shadow root build conditionals to minimize runtime
|
|
1678
|
-
{
|
|
1679
|
-
{
|
|
2754
|
+
if (supportsShadow) {
|
|
2755
|
+
if (BUILD.shadowDelegatesFocus) {
|
|
2756
|
+
self.attachShadow({
|
|
2757
|
+
mode: 'open',
|
|
2758
|
+
delegatesFocus: !!(cmpMeta.$flags$ & 16 /* CMP_FLAGS.shadowDelegatesFocus */),
|
|
2759
|
+
});
|
|
2760
|
+
}
|
|
2761
|
+
else {
|
|
1680
2762
|
self.attachShadow({ mode: 'open' });
|
|
1681
2763
|
}
|
|
1682
2764
|
}
|
|
2765
|
+
else if (!BUILD.hydrateServerSide && !('shadowRoot' in self)) {
|
|
2766
|
+
self.shadowRoot = self;
|
|
2767
|
+
}
|
|
2768
|
+
}
|
|
2769
|
+
if (BUILD.slotChildNodesFix) {
|
|
2770
|
+
patchChildSlotNodes(self, cmpMeta);
|
|
1683
2771
|
}
|
|
1684
2772
|
}
|
|
1685
2773
|
connectedCallback() {
|
|
@@ -1702,6 +2790,20 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1702
2790
|
return getHostRef(this).$onReadyPromise$;
|
|
1703
2791
|
}
|
|
1704
2792
|
};
|
|
2793
|
+
if (BUILD.cloneNodeFix) {
|
|
2794
|
+
patchCloneNode(HostElement.prototype);
|
|
2795
|
+
}
|
|
2796
|
+
if (BUILD.appendChildSlotFix) {
|
|
2797
|
+
patchSlotAppendChild(HostElement.prototype);
|
|
2798
|
+
}
|
|
2799
|
+
if (BUILD.hotModuleReplacement) {
|
|
2800
|
+
HostElement.prototype['s-hmr'] = function (hmrVersionId) {
|
|
2801
|
+
hmrStart(this, cmpMeta, hmrVersionId);
|
|
2802
|
+
};
|
|
2803
|
+
}
|
|
2804
|
+
if (BUILD.scopedSlotTextContentFix) {
|
|
2805
|
+
patchTextContent(HostElement.prototype, cmpMeta);
|
|
2806
|
+
}
|
|
1705
2807
|
cmpMeta.$lazyBundleId$ = lazyBundle[0];
|
|
1706
2808
|
if (!exclude.includes(tagName) && !customElements.get(tagName)) {
|
|
1707
2809
|
cmpTags.push(tagName);
|
|
@@ -1709,7 +2811,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1709
2811
|
}
|
|
1710
2812
|
});
|
|
1711
2813
|
});
|
|
1712
|
-
{
|
|
2814
|
+
if (BUILD.invisiblePrehydration && (BUILD.hydratedClass || BUILD.hydratedAttribute)) {
|
|
1713
2815
|
visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
|
|
1714
2816
|
visibilityStyle.setAttribute('data-styles', '');
|
|
1715
2817
|
head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
|
|
@@ -1720,13 +2822,273 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1720
2822
|
deferredConnectedCallbacks.map((host) => host.connectedCallback());
|
|
1721
2823
|
}
|
|
1722
2824
|
else {
|
|
1723
|
-
{
|
|
2825
|
+
if (BUILD.profile) {
|
|
2826
|
+
plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30, 'timeout')));
|
|
2827
|
+
}
|
|
2828
|
+
else {
|
|
1724
2829
|
plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30)));
|
|
1725
2830
|
}
|
|
1726
2831
|
}
|
|
1727
2832
|
// Fallback appLoad event
|
|
1728
2833
|
endBootstrap();
|
|
1729
2834
|
};
|
|
2835
|
+
const getConnect = (_ref, tagName) => {
|
|
2836
|
+
const componentOnReady = () => {
|
|
2837
|
+
let elm = doc.querySelector(tagName);
|
|
2838
|
+
if (!elm) {
|
|
2839
|
+
elm = doc.createElement(tagName);
|
|
2840
|
+
doc.body.appendChild(elm);
|
|
2841
|
+
}
|
|
2842
|
+
return typeof elm.componentOnReady === 'function' ? elm.componentOnReady() : Promise.resolve(elm);
|
|
2843
|
+
};
|
|
2844
|
+
const create = (...args) => {
|
|
2845
|
+
return componentOnReady().then((el) => el.create(...args));
|
|
2846
|
+
};
|
|
2847
|
+
return {
|
|
2848
|
+
create,
|
|
2849
|
+
componentOnReady,
|
|
2850
|
+
};
|
|
2851
|
+
};
|
|
2852
|
+
const getContext = (_elm, context) => {
|
|
2853
|
+
if (context in Context) {
|
|
2854
|
+
return Context[context];
|
|
2855
|
+
}
|
|
2856
|
+
else if (context === 'window') {
|
|
2857
|
+
return win;
|
|
2858
|
+
}
|
|
2859
|
+
else if (context === 'document') {
|
|
2860
|
+
return doc;
|
|
2861
|
+
}
|
|
2862
|
+
else if (context === 'isServer' || context === 'isPrerender') {
|
|
2863
|
+
return BUILD.hydrateServerSide ? true : false;
|
|
2864
|
+
}
|
|
2865
|
+
else if (context === 'isClient') {
|
|
2866
|
+
return BUILD.hydrateServerSide ? false : true;
|
|
2867
|
+
}
|
|
2868
|
+
else if (context === 'resourcesUrl' || context === 'publicPath') {
|
|
2869
|
+
return getAssetPath('.');
|
|
2870
|
+
}
|
|
2871
|
+
else if (context === 'queue') {
|
|
2872
|
+
return {
|
|
2873
|
+
write: writeTask,
|
|
2874
|
+
read: readTask,
|
|
2875
|
+
tick: {
|
|
2876
|
+
then(cb) {
|
|
2877
|
+
return nextTick(cb);
|
|
2878
|
+
},
|
|
2879
|
+
},
|
|
2880
|
+
};
|
|
2881
|
+
}
|
|
2882
|
+
return undefined;
|
|
2883
|
+
};
|
|
2884
|
+
const Fragment = (_, children) => children;
|
|
2885
|
+
const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
|
|
2886
|
+
if (BUILD.hostListener && listeners) {
|
|
2887
|
+
// this is called immediately within the element's constructor
|
|
2888
|
+
// initialize our event listeners on the host element
|
|
2889
|
+
// we do this now so that we can listen to events that may
|
|
2890
|
+
// have fired even before the instance is ready
|
|
2891
|
+
if (BUILD.hostListenerTargetParent) {
|
|
2892
|
+
// this component may have event listeners that should be attached to the parent
|
|
2893
|
+
if (attachParentListeners) {
|
|
2894
|
+
// this is being ran from within the connectedCallback
|
|
2895
|
+
// which is important so that we know the host element actually has a parent element
|
|
2896
|
+
// filter out the listeners to only have the ones that ARE being attached to the parent
|
|
2897
|
+
listeners = listeners.filter(([flags]) => flags & 32 /* LISTENER_FLAGS.TargetParent */);
|
|
2898
|
+
}
|
|
2899
|
+
else {
|
|
2900
|
+
// this is being ran from within the component constructor
|
|
2901
|
+
// everything BUT the parent element listeners should be attached at this time
|
|
2902
|
+
// filter out the listeners that are NOT being attached to the parent
|
|
2903
|
+
listeners = listeners.filter(([flags]) => !(flags & 32 /* LISTENER_FLAGS.TargetParent */));
|
|
2904
|
+
}
|
|
2905
|
+
}
|
|
2906
|
+
listeners.map(([flags, name, method]) => {
|
|
2907
|
+
const target = BUILD.hostListenerTarget ? getHostListenerTarget(elm, flags) : elm;
|
|
2908
|
+
const handler = hostListenerProxy(hostRef, method);
|
|
2909
|
+
const opts = hostListenerOpts(flags);
|
|
2910
|
+
plt.ael(target, name, handler, opts);
|
|
2911
|
+
(hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
|
|
2912
|
+
});
|
|
2913
|
+
}
|
|
2914
|
+
};
|
|
2915
|
+
const hostListenerProxy = (hostRef, methodName) => (ev) => {
|
|
2916
|
+
try {
|
|
2917
|
+
if (BUILD.lazyLoad) {
|
|
2918
|
+
if (hostRef.$flags$ & 256 /* HOST_FLAGS.isListenReady */) {
|
|
2919
|
+
// instance is ready, let's call it's member method for this event
|
|
2920
|
+
hostRef.$lazyInstance$[methodName](ev);
|
|
2921
|
+
}
|
|
2922
|
+
else {
|
|
2923
|
+
(hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
|
|
2924
|
+
}
|
|
2925
|
+
}
|
|
2926
|
+
else {
|
|
2927
|
+
hostRef.$hostElement$[methodName](ev);
|
|
2928
|
+
}
|
|
2929
|
+
}
|
|
2930
|
+
catch (e) {
|
|
2931
|
+
consoleError(e);
|
|
2932
|
+
}
|
|
2933
|
+
};
|
|
2934
|
+
const getHostListenerTarget = (elm, flags) => {
|
|
2935
|
+
if (BUILD.hostListenerTargetDocument && flags & 4 /* LISTENER_FLAGS.TargetDocument */)
|
|
2936
|
+
return doc;
|
|
2937
|
+
if (BUILD.hostListenerTargetWindow && flags & 8 /* LISTENER_FLAGS.TargetWindow */)
|
|
2938
|
+
return win;
|
|
2939
|
+
if (BUILD.hostListenerTargetBody && flags & 16 /* LISTENER_FLAGS.TargetBody */)
|
|
2940
|
+
return doc.body;
|
|
2941
|
+
if (BUILD.hostListenerTargetParent && flags & 32 /* LISTENER_FLAGS.TargetParent */)
|
|
2942
|
+
return elm.parentElement;
|
|
2943
|
+
return elm;
|
|
2944
|
+
};
|
|
2945
|
+
// prettier-ignore
|
|
2946
|
+
const hostListenerOpts = (flags) => supportsListenerOptions
|
|
2947
|
+
? ({
|
|
2948
|
+
passive: (flags & 1 /* LISTENER_FLAGS.Passive */) !== 0,
|
|
2949
|
+
capture: (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0,
|
|
2950
|
+
})
|
|
2951
|
+
: (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0;
|
|
2952
|
+
const setPlatformOptions = (opts) => Object.assign(plt, opts);
|
|
2953
|
+
const insertVdomAnnotations = (doc, staticComponents) => {
|
|
2954
|
+
if (doc != null) {
|
|
2955
|
+
const docData = {
|
|
2956
|
+
hostIds: 0,
|
|
2957
|
+
rootLevelIds: 0,
|
|
2958
|
+
staticComponents: new Set(staticComponents),
|
|
2959
|
+
};
|
|
2960
|
+
const orgLocationNodes = [];
|
|
2961
|
+
parseVNodeAnnotations(doc, doc.body, docData, orgLocationNodes);
|
|
2962
|
+
orgLocationNodes.forEach((orgLocationNode) => {
|
|
2963
|
+
if (orgLocationNode != null) {
|
|
2964
|
+
const nodeRef = orgLocationNode['s-nr'];
|
|
2965
|
+
let hostId = nodeRef['s-host-id'];
|
|
2966
|
+
let nodeId = nodeRef['s-node-id'];
|
|
2967
|
+
let childId = `${hostId}.${nodeId}`;
|
|
2968
|
+
if (hostId == null) {
|
|
2969
|
+
hostId = 0;
|
|
2970
|
+
docData.rootLevelIds++;
|
|
2971
|
+
nodeId = docData.rootLevelIds;
|
|
2972
|
+
childId = `${hostId}.${nodeId}`;
|
|
2973
|
+
if (nodeRef.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
2974
|
+
nodeRef.setAttribute(HYDRATE_CHILD_ID, childId);
|
|
2975
|
+
}
|
|
2976
|
+
else if (nodeRef.nodeType === 3 /* NODE_TYPE.TextNode */) {
|
|
2977
|
+
if (hostId === 0) {
|
|
2978
|
+
const textContent = nodeRef.nodeValue.trim();
|
|
2979
|
+
if (textContent === '') {
|
|
2980
|
+
// useless whitespace node at the document root
|
|
2981
|
+
orgLocationNode.remove();
|
|
2982
|
+
return;
|
|
2983
|
+
}
|
|
2984
|
+
}
|
|
2985
|
+
const commentBeforeTextNode = doc.createComment(childId);
|
|
2986
|
+
commentBeforeTextNode.nodeValue = `${TEXT_NODE_ID}.${childId}`;
|
|
2987
|
+
nodeRef.parentNode.insertBefore(commentBeforeTextNode, nodeRef);
|
|
2988
|
+
}
|
|
2989
|
+
}
|
|
2990
|
+
let orgLocationNodeId = `${ORG_LOCATION_ID}.${childId}`;
|
|
2991
|
+
const orgLocationParentNode = orgLocationNode.parentElement;
|
|
2992
|
+
if (orgLocationParentNode) {
|
|
2993
|
+
if (orgLocationParentNode['s-en'] === '') {
|
|
2994
|
+
// ending with a "." means that the parent element
|
|
2995
|
+
// of this node's original location is a SHADOW dom element
|
|
2996
|
+
// and this node is apart of the root level light dom
|
|
2997
|
+
orgLocationNodeId += `.`;
|
|
2998
|
+
}
|
|
2999
|
+
else if (orgLocationParentNode['s-en'] === 'c') {
|
|
3000
|
+
// ending with a ".c" means that the parent element
|
|
3001
|
+
// of this node's original location is a SCOPED element
|
|
3002
|
+
// and this node is apart of the root level light dom
|
|
3003
|
+
orgLocationNodeId += `.c`;
|
|
3004
|
+
}
|
|
3005
|
+
}
|
|
3006
|
+
orgLocationNode.nodeValue = orgLocationNodeId;
|
|
3007
|
+
}
|
|
3008
|
+
});
|
|
3009
|
+
}
|
|
3010
|
+
};
|
|
3011
|
+
const parseVNodeAnnotations = (doc, node, docData, orgLocationNodes) => {
|
|
3012
|
+
if (node == null) {
|
|
3013
|
+
return;
|
|
3014
|
+
}
|
|
3015
|
+
if (node['s-nr'] != null) {
|
|
3016
|
+
orgLocationNodes.push(node);
|
|
3017
|
+
}
|
|
3018
|
+
if (node.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
3019
|
+
node.childNodes.forEach((childNode) => {
|
|
3020
|
+
const hostRef = getHostRef(childNode);
|
|
3021
|
+
if (hostRef != null && !docData.staticComponents.has(childNode.nodeName.toLowerCase())) {
|
|
3022
|
+
const cmpData = {
|
|
3023
|
+
nodeIds: 0,
|
|
3024
|
+
};
|
|
3025
|
+
insertVNodeAnnotations(doc, childNode, hostRef.$vnode$, docData, cmpData);
|
|
3026
|
+
}
|
|
3027
|
+
parseVNodeAnnotations(doc, childNode, docData, orgLocationNodes);
|
|
3028
|
+
});
|
|
3029
|
+
}
|
|
3030
|
+
};
|
|
3031
|
+
const insertVNodeAnnotations = (doc, hostElm, vnode, docData, cmpData) => {
|
|
3032
|
+
if (vnode != null) {
|
|
3033
|
+
const hostId = ++docData.hostIds;
|
|
3034
|
+
hostElm.setAttribute(HYDRATE_ID, hostId);
|
|
3035
|
+
if (hostElm['s-cr'] != null) {
|
|
3036
|
+
hostElm['s-cr'].nodeValue = `${CONTENT_REF_ID}.${hostId}`;
|
|
3037
|
+
}
|
|
3038
|
+
if (vnode.$children$ != null) {
|
|
3039
|
+
const depth = 0;
|
|
3040
|
+
vnode.$children$.forEach((vnodeChild, index) => {
|
|
3041
|
+
insertChildVNodeAnnotations(doc, vnodeChild, cmpData, hostId, depth, index);
|
|
3042
|
+
});
|
|
3043
|
+
}
|
|
3044
|
+
if (hostElm && vnode && vnode.$elm$ && !hostElm.hasAttribute('c-id')) {
|
|
3045
|
+
const parent = hostElm.parentElement;
|
|
3046
|
+
if (parent && parent.childNodes) {
|
|
3047
|
+
const parentChildNodes = Array.from(parent.childNodes);
|
|
3048
|
+
const comment = parentChildNodes.find((node) => node.nodeType === 8 /* NODE_TYPE.CommentNode */ && node['s-sr']);
|
|
3049
|
+
if (comment) {
|
|
3050
|
+
const index = parentChildNodes.indexOf(hostElm) - 1;
|
|
3051
|
+
vnode.$elm$.setAttribute(HYDRATE_CHILD_ID, `${comment['s-host-id']}.${comment['s-node-id']}.0.${index}`);
|
|
3052
|
+
}
|
|
3053
|
+
}
|
|
3054
|
+
}
|
|
3055
|
+
}
|
|
3056
|
+
};
|
|
3057
|
+
const insertChildVNodeAnnotations = (doc, vnodeChild, cmpData, hostId, depth, index) => {
|
|
3058
|
+
const childElm = vnodeChild.$elm$;
|
|
3059
|
+
if (childElm == null) {
|
|
3060
|
+
return;
|
|
3061
|
+
}
|
|
3062
|
+
const nodeId = cmpData.nodeIds++;
|
|
3063
|
+
const childId = `${hostId}.${nodeId}.${depth}.${index}`;
|
|
3064
|
+
childElm['s-host-id'] = hostId;
|
|
3065
|
+
childElm['s-node-id'] = nodeId;
|
|
3066
|
+
if (childElm.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
3067
|
+
childElm.setAttribute(HYDRATE_CHILD_ID, childId);
|
|
3068
|
+
}
|
|
3069
|
+
else if (childElm.nodeType === 3 /* NODE_TYPE.TextNode */) {
|
|
3070
|
+
const parentNode = childElm.parentNode;
|
|
3071
|
+
const nodeName = parentNode.nodeName;
|
|
3072
|
+
if (nodeName !== 'STYLE' && nodeName !== 'SCRIPT') {
|
|
3073
|
+
const textNodeId = `${TEXT_NODE_ID}.${childId}`;
|
|
3074
|
+
const commentBeforeTextNode = doc.createComment(textNodeId);
|
|
3075
|
+
parentNode.insertBefore(commentBeforeTextNode, childElm);
|
|
3076
|
+
}
|
|
3077
|
+
}
|
|
3078
|
+
else if (childElm.nodeType === 8 /* NODE_TYPE.CommentNode */) {
|
|
3079
|
+
if (childElm['s-sr']) {
|
|
3080
|
+
const slotName = childElm['s-sn'] || '';
|
|
3081
|
+
const slotNodeId = `${SLOT_NODE_ID}.${childId}.${slotName}`;
|
|
3082
|
+
childElm.nodeValue = slotNodeId;
|
|
3083
|
+
}
|
|
3084
|
+
}
|
|
3085
|
+
if (vnodeChild.$children$ != null) {
|
|
3086
|
+
const childDepth = depth + 1;
|
|
3087
|
+
vnodeChild.$children$.forEach((vnode, index) => {
|
|
3088
|
+
insertChildVNodeAnnotations(doc, vnode, cmpData, hostId, childDepth, index);
|
|
3089
|
+
});
|
|
3090
|
+
}
|
|
3091
|
+
};
|
|
1730
3092
|
const hostRefs = /*@__PURE__*/ new WeakMap();
|
|
1731
3093
|
const getHostRef = (ref) => hostRefs.get(ref);
|
|
1732
3094
|
const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
|
|
@@ -1737,24 +3099,42 @@ const registerHost = (elm, cmpMeta) => {
|
|
|
1737
3099
|
$cmpMeta$: cmpMeta,
|
|
1738
3100
|
$instanceValues$: new Map(),
|
|
1739
3101
|
};
|
|
1740
|
-
{
|
|
3102
|
+
if (BUILD.isDev) {
|
|
3103
|
+
hostRef.$renderCount$ = 0;
|
|
3104
|
+
}
|
|
3105
|
+
if (BUILD.method && BUILD.lazyLoad) {
|
|
1741
3106
|
hostRef.$onInstancePromise$ = new Promise((r) => (hostRef.$onInstanceResolve$ = r));
|
|
1742
3107
|
}
|
|
1743
|
-
{
|
|
3108
|
+
if (BUILD.asyncLoading) {
|
|
1744
3109
|
hostRef.$onReadyPromise$ = new Promise((r) => (hostRef.$onReadyResolve$ = r));
|
|
1745
3110
|
elm['s-p'] = [];
|
|
1746
3111
|
elm['s-rc'] = [];
|
|
1747
3112
|
}
|
|
3113
|
+
addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, false);
|
|
1748
3114
|
return hostRefs.set(elm, hostRef);
|
|
1749
3115
|
};
|
|
1750
3116
|
const isMemberInElement = (elm, memberName) => memberName in elm;
|
|
1751
|
-
const consoleError = (e, el) => (
|
|
3117
|
+
const consoleError = (e, el) => (customError || console.error)(e, el);
|
|
3118
|
+
const STENCIL_DEV_MODE = BUILD.isTesting
|
|
3119
|
+
? ['STENCIL:'] // E2E testing
|
|
3120
|
+
: [
|
|
3121
|
+
'%cstencil',
|
|
3122
|
+
'color: white;background:#4c47ff;font-weight: bold; font-size:10px; padding:2px 6px; border-radius: 5px',
|
|
3123
|
+
];
|
|
3124
|
+
const consoleDevError = (...m) => console.error(...STENCIL_DEV_MODE, ...m);
|
|
3125
|
+
const consoleDevWarn = (...m) => console.warn(...STENCIL_DEV_MODE, ...m);
|
|
3126
|
+
const consoleDevInfo = (...m) => console.info(...STENCIL_DEV_MODE, ...m);
|
|
3127
|
+
const setErrorHandler = (handler) => (customError = handler);
|
|
1752
3128
|
const cmpModules = /*@__PURE__*/ new Map();
|
|
1753
3129
|
const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
|
|
1754
3130
|
// loadModuleImport
|
|
1755
3131
|
const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
|
|
1756
3132
|
const bundleId = cmpMeta.$lazyBundleId$;
|
|
1757
|
-
|
|
3133
|
+
if (BUILD.isDev && typeof bundleId !== 'string') {
|
|
3134
|
+
consoleDevError(`Trying to lazily load component <${cmpMeta.$tagName$}> with style mode "${hostRef.$modeName$}", but it does not exist.`);
|
|
3135
|
+
return undefined;
|
|
3136
|
+
}
|
|
3137
|
+
const module = !BUILD.hotModuleReplacement ? cmpModules.get(bundleId) : false;
|
|
1758
3138
|
if (module) {
|
|
1759
3139
|
return module[exportName];
|
|
1760
3140
|
}
|
|
@@ -1764,16 +3144,20 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
|
|
|
1764
3144
|
/* webpackInclude: /\.entry\.js$/ */
|
|
1765
3145
|
/* webpackExclude: /\.system\.entry\.js$/ */
|
|
1766
3146
|
/* webpackMode: "lazy" */
|
|
1767
|
-
`./${bundleId}.entry.js${''}`)); }).then((importedModule) => {
|
|
1768
|
-
{
|
|
3147
|
+
`./${bundleId}.entry.js${BUILD.hotModuleReplacement && hmrVersionId ? '?s-hmr=' + hmrVersionId : ''}`)); }).then((importedModule) => {
|
|
3148
|
+
if (!BUILD.hotModuleReplacement) {
|
|
1769
3149
|
cmpModules.set(bundleId, importedModule);
|
|
1770
3150
|
}
|
|
1771
3151
|
return importedModule[exportName];
|
|
1772
3152
|
}, consoleError);
|
|
1773
3153
|
};
|
|
1774
3154
|
const styles = /*@__PURE__*/ new Map();
|
|
3155
|
+
const modeResolutionChain = [];
|
|
1775
3156
|
const win = typeof window !== 'undefined' ? window : {};
|
|
3157
|
+
const CSS = BUILD.cssVarShim ? win.CSS : null;
|
|
1776
3158
|
const doc = win.document || { head: {} };
|
|
3159
|
+
const H = (win.HTMLElement || class {
|
|
3160
|
+
});
|
|
1777
3161
|
const plt = {
|
|
1778
3162
|
$flags$: 0,
|
|
1779
3163
|
$resourcesUrl$: '',
|
|
@@ -1783,8 +3167,27 @@ const plt = {
|
|
|
1783
3167
|
rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
|
|
1784
3168
|
ce: (eventName, opts) => new CustomEvent(eventName, opts),
|
|
1785
3169
|
};
|
|
3170
|
+
const setPlatformHelpers = (helpers) => {
|
|
3171
|
+
Object.assign(plt, helpers);
|
|
3172
|
+
};
|
|
3173
|
+
const supportsShadow = BUILD.shadowDomShim && BUILD.shadowDom
|
|
3174
|
+
? /*@__PURE__*/ (() => (doc.head.attachShadow + '').indexOf('[native') > -1)()
|
|
3175
|
+
: true;
|
|
3176
|
+
const supportsListenerOptions = /*@__PURE__*/ (() => {
|
|
3177
|
+
let supportsListenerOptions = false;
|
|
3178
|
+
try {
|
|
3179
|
+
doc.addEventListener('e', null, Object.defineProperty({}, 'passive', {
|
|
3180
|
+
get() {
|
|
3181
|
+
supportsListenerOptions = true;
|
|
3182
|
+
},
|
|
3183
|
+
}));
|
|
3184
|
+
}
|
|
3185
|
+
catch (e) { }
|
|
3186
|
+
return supportsListenerOptions;
|
|
3187
|
+
})();
|
|
1786
3188
|
const promiseResolve = (v) => Promise.resolve(v);
|
|
1787
|
-
const supportsConstructableStylesheets =
|
|
3189
|
+
const supportsConstructableStylesheets = BUILD.constructableCSS
|
|
3190
|
+
? /*@__PURE__*/ (() => {
|
|
1788
3191
|
try {
|
|
1789
3192
|
new CSSStyleSheet();
|
|
1790
3193
|
return typeof new CSSStyleSheet().replaceSync === 'function';
|
|
@@ -1792,9 +3195,10 @@ const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
|
|
|
1792
3195
|
catch (e) { }
|
|
1793
3196
|
return false;
|
|
1794
3197
|
})()
|
|
1795
|
-
;
|
|
3198
|
+
: false;
|
|
1796
3199
|
const queueDomReads = [];
|
|
1797
3200
|
const queueDomWrites = [];
|
|
3201
|
+
const queueDomWritesLow = [];
|
|
1798
3202
|
const queueTask = (queue, write) => (cb) => {
|
|
1799
3203
|
queue.push(cb);
|
|
1800
3204
|
if (!queuePending) {
|
|
@@ -1818,13 +3222,53 @@ const consume = (queue) => {
|
|
|
1818
3222
|
}
|
|
1819
3223
|
queue.length = 0;
|
|
1820
3224
|
};
|
|
3225
|
+
const consumeTimeout = (queue, timeout) => {
|
|
3226
|
+
let i = 0;
|
|
3227
|
+
let ts = 0;
|
|
3228
|
+
while (i < queue.length && (ts = performance.now()) < timeout) {
|
|
3229
|
+
try {
|
|
3230
|
+
queue[i++](ts);
|
|
3231
|
+
}
|
|
3232
|
+
catch (e) {
|
|
3233
|
+
consoleError(e);
|
|
3234
|
+
}
|
|
3235
|
+
}
|
|
3236
|
+
if (i === queue.length) {
|
|
3237
|
+
queue.length = 0;
|
|
3238
|
+
}
|
|
3239
|
+
else if (i !== 0) {
|
|
3240
|
+
queue.splice(0, i);
|
|
3241
|
+
}
|
|
3242
|
+
};
|
|
1821
3243
|
const flush = () => {
|
|
3244
|
+
if (BUILD.asyncQueue) {
|
|
3245
|
+
queueCongestion++;
|
|
3246
|
+
}
|
|
1822
3247
|
// always force a bunch of medium callbacks to run, but still have
|
|
1823
3248
|
// a throttle on how many can run in a certain time
|
|
1824
3249
|
// DOM READS!!!
|
|
1825
3250
|
consume(queueDomReads);
|
|
1826
3251
|
// DOM WRITES!!!
|
|
1827
|
-
{
|
|
3252
|
+
if (BUILD.asyncQueue) {
|
|
3253
|
+
const timeout = (plt.$flags$ & 6 /* PLATFORM_FLAGS.queueMask */) === 2 /* PLATFORM_FLAGS.appLoaded */
|
|
3254
|
+
? performance.now() + 14 * Math.ceil(queueCongestion * (1.0 / 10.0))
|
|
3255
|
+
: Infinity;
|
|
3256
|
+
consumeTimeout(queueDomWrites, timeout);
|
|
3257
|
+
consumeTimeout(queueDomWritesLow, timeout);
|
|
3258
|
+
if (queueDomWrites.length > 0) {
|
|
3259
|
+
queueDomWritesLow.push(...queueDomWrites);
|
|
3260
|
+
queueDomWrites.length = 0;
|
|
3261
|
+
}
|
|
3262
|
+
if ((queuePending = queueDomReads.length + queueDomWrites.length + queueDomWritesLow.length > 0)) {
|
|
3263
|
+
// still more to do yet, but we've run out of time
|
|
3264
|
+
// let's let this thing cool off and try again in the next tick
|
|
3265
|
+
plt.raf(flush);
|
|
3266
|
+
}
|
|
3267
|
+
else {
|
|
3268
|
+
queueCongestion = 0;
|
|
3269
|
+
}
|
|
3270
|
+
}
|
|
3271
|
+
else {
|
|
1828
3272
|
consume(queueDomWrites);
|
|
1829
3273
|
if ((queuePending = queueDomReads.length > 0)) {
|
|
1830
3274
|
// still more to do yet, but we've run out of time
|
|
@@ -1834,12 +3278,21 @@ const flush = () => {
|
|
|
1834
3278
|
}
|
|
1835
3279
|
};
|
|
1836
3280
|
const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
|
|
3281
|
+
const readTask = /*@__PURE__*/ queueTask(queueDomReads, false);
|
|
1837
3282
|
const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
|
|
1838
3283
|
|
|
3284
|
+
exports.BUILD = BUILD;
|
|
3285
|
+
exports.CSS = CSS;
|
|
3286
|
+
exports.H = H;
|
|
1839
3287
|
exports.Host = Host;
|
|
3288
|
+
exports.NAMESPACE = NAMESPACE;
|
|
1840
3289
|
exports.bootstrapLazy = bootstrapLazy;
|
|
3290
|
+
exports.consoleDevInfo = consoleDevInfo;
|
|
1841
3291
|
exports.createEvent = createEvent;
|
|
3292
|
+
exports.doc = doc;
|
|
1842
3293
|
exports.getElement = getElement;
|
|
1843
3294
|
exports.h = h;
|
|
3295
|
+
exports.plt = plt;
|
|
1844
3296
|
exports.promiseResolve = promiseResolve;
|
|
1845
3297
|
exports.registerInstance = registerInstance;
|
|
3298
|
+
exports.win = win;
|