@dooboostore/simple-web-component 1.0.35 → 1.0.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +58 -21
- package/dist/cjs/{elements/SwcAppEngine.js → SwcAppEngine.js} +6 -6
- package/dist/cjs/SwcAppEngine.js.map +7 -0
- package/dist/cjs/decorators/addEventListener.js +12 -4
- package/dist/cjs/decorators/addEventListener.js.map +2 -2
- package/dist/cjs/decorators/applyAttribute.js +19 -18
- package/dist/cjs/decorators/applyAttribute.js.map +2 -2
- package/dist/cjs/decorators/applyClass.js +23 -22
- package/dist/cjs/decorators/applyClass.js.map +2 -2
- package/dist/cjs/decorators/applyNode.js +28 -26
- package/dist/cjs/decorators/applyNode.js.map +2 -2
- package/dist/cjs/decorators/applySlot.js +122 -0
- package/dist/cjs/decorators/applySlot.js.map +7 -0
- package/dist/cjs/decorators/applyStyle.js +20 -19
- package/dist/cjs/decorators/applyStyle.js.map +2 -2
- package/dist/cjs/decorators/attribute.js +16 -15
- package/dist/cjs/decorators/attribute.js.map +2 -2
- package/dist/cjs/decorators/{changedAttributeHost.js → changedAttributeThis.js} +6 -6
- package/dist/cjs/decorators/changedAttributeThis.js.map +7 -0
- package/dist/cjs/decorators/elementDefine.js +59 -50
- package/dist/cjs/decorators/elementDefine.js.map +2 -2
- package/dist/cjs/decorators/emitCustomEvent.js +18 -16
- package/dist/cjs/decorators/emitCustomEvent.js.map +2 -2
- package/dist/cjs/decorators/index.js +2 -1
- package/dist/cjs/decorators/index.js.map +2 -2
- package/dist/cjs/decorators/lifecycles.js +56 -8
- package/dist/cjs/decorators/lifecycles.js.map +2 -2
- package/dist/cjs/decorators/query.js +38 -60
- package/dist/cjs/decorators/query.js.map +2 -2
- package/dist/cjs/decorators/queryAll.js +31 -63
- package/dist/cjs/decorators/queryAll.js.map +2 -2
- package/dist/cjs/decorators/setProperty.js +13 -12
- package/dist/cjs/decorators/setProperty.js.map +2 -2
- package/dist/cjs/elements/{SwcAppMixin.js → SwcApp.js} +107 -57
- package/dist/cjs/elements/SwcApp.js.map +7 -0
- package/dist/cjs/elements/index.js +21 -2
- package/dist/cjs/elements/index.js.map +3 -3
- package/dist/cjs/elements/tt/SwcAppMixin.js +1 -0
- package/dist/cjs/elements/tt/SwcAppMixin.js.map +7 -0
- package/dist/cjs/elements/tt/SwcAsync.js +1 -0
- package/dist/cjs/elements/tt/SwcAsync.js.map +7 -0
- package/dist/cjs/elements/tt/SwcAsyncTemplate.js +1 -0
- package/dist/cjs/elements/tt/SwcAsyncTemplate.js.map +7 -0
- package/dist/cjs/elements/tt/SwcChoose.js +1 -0
- package/dist/cjs/elements/tt/SwcChoose.js.map +7 -0
- package/dist/cjs/elements/tt/SwcChooseTemplate.js +1 -0
- package/dist/cjs/elements/tt/SwcChooseTemplate.js.map +7 -0
- package/dist/cjs/elements/tt/SwcIf.js +1 -0
- package/dist/cjs/elements/tt/SwcIf.js.map +7 -0
- package/dist/cjs/elements/tt/SwcIfTemplate.js +1 -0
- package/dist/cjs/elements/tt/SwcIfTemplate.js.map +7 -0
- package/dist/cjs/elements/tt/SwcLoop.js +1 -0
- package/dist/cjs/elements/tt/SwcLoop.js.map +7 -0
- package/dist/cjs/elements/tt/SwcLoopTemplate.js +1 -0
- package/dist/cjs/elements/tt/SwcLoopTemplate.js.map +7 -0
- package/dist/cjs/elements/tt/SwcSubTemplates.js +1 -0
- package/dist/cjs/elements/tt/SwcSubTemplates.js.map +7 -0
- package/dist/cjs/elements/tt/register.js +1 -0
- package/dist/cjs/elements/tt/register.js.map +7 -0
- package/dist/cjs/index.js +12 -8
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/types/window.d.js +16 -0
- package/dist/cjs/types/window.d.js.map +7 -0
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/utils/Utils.js +22 -19
- package/dist/cjs/utils/Utils.js.map +2 -2
- package/dist/esm/{elements/SwcAppEngine.js → SwcAppEngine.js} +4 -4
- package/dist/esm/SwcAppEngine.js.map +7 -0
- package/dist/esm/decorators/addEventListener.js +12 -4
- package/dist/esm/decorators/addEventListener.js.map +2 -2
- package/dist/esm/decorators/applyAttribute.js +19 -18
- package/dist/esm/decorators/applyAttribute.js.map +2 -2
- package/dist/esm/decorators/applyClass.js +23 -22
- package/dist/esm/decorators/applyClass.js.map +2 -2
- package/dist/esm/decorators/applyNode.js +28 -26
- package/dist/esm/decorators/applyNode.js.map +2 -2
- package/dist/esm/decorators/applySlot.js +103 -0
- package/dist/esm/decorators/applySlot.js.map +7 -0
- package/dist/esm/decorators/applyStyle.js +20 -19
- package/dist/esm/decorators/applyStyle.js.map +2 -2
- package/dist/esm/decorators/attribute.js +16 -15
- package/dist/esm/decorators/attribute.js.map +2 -2
- package/dist/esm/decorators/{changedAttributeHost.js → changedAttributeThis.js} +3 -3
- package/dist/esm/decorators/changedAttributeThis.js.map +7 -0
- package/dist/esm/decorators/elementDefine.js +60 -51
- package/dist/esm/decorators/elementDefine.js.map +2 -2
- package/dist/esm/decorators/emitCustomEvent.js +18 -16
- package/dist/esm/decorators/emitCustomEvent.js.map +2 -2
- package/dist/esm/decorators/index.js +2 -1
- package/dist/esm/decorators/index.js.map +2 -2
- package/dist/esm/decorators/lifecycles.js +56 -8
- package/dist/esm/decorators/lifecycles.js.map +2 -2
- package/dist/esm/decorators/query.js +38 -60
- package/dist/esm/decorators/query.js.map +2 -2
- package/dist/esm/decorators/queryAll.js +31 -63
- package/dist/esm/decorators/queryAll.js.map +2 -2
- package/dist/esm/decorators/setProperty.js +13 -12
- package/dist/esm/decorators/setProperty.js.map +2 -2
- package/dist/esm/elements/{SwcAppMixin.js → SwcApp.js} +102 -53
- package/dist/esm/elements/SwcApp.js.map +7 -0
- package/dist/esm/elements/index.js +7 -1
- package/dist/esm/elements/index.js.map +2 -2
- package/dist/esm/elements/tt/SwcAppMixin.js +1 -0
- package/dist/esm/elements/tt/SwcAppMixin.js.map +7 -0
- package/dist/esm/elements/tt/SwcAsync.js +1 -0
- package/dist/esm/elements/tt/SwcAsync.js.map +7 -0
- package/dist/esm/elements/tt/SwcAsyncTemplate.js +1 -0
- package/dist/esm/elements/tt/SwcAsyncTemplate.js.map +7 -0
- package/dist/esm/elements/tt/SwcChoose.js +1 -0
- package/dist/esm/elements/tt/SwcChoose.js.map +7 -0
- package/dist/esm/elements/tt/SwcChooseTemplate.js +1 -0
- package/dist/esm/elements/tt/SwcChooseTemplate.js.map +7 -0
- package/dist/esm/elements/tt/SwcIf.js +1 -0
- package/dist/esm/elements/tt/SwcIf.js.map +7 -0
- package/dist/esm/elements/tt/SwcIfTemplate.js +1 -0
- package/dist/esm/elements/tt/SwcIfTemplate.js.map +7 -0
- package/dist/esm/elements/tt/SwcLoop.js +1 -0
- package/dist/esm/elements/tt/SwcLoop.js.map +7 -0
- package/dist/esm/elements/tt/SwcLoopTemplate.js +1 -0
- package/dist/esm/elements/tt/SwcLoopTemplate.js.map +7 -0
- package/dist/esm/elements/tt/SwcSubTemplates.js +1 -0
- package/dist/esm/elements/tt/SwcSubTemplates.js.map +7 -0
- package/dist/esm/elements/tt/register.js +1 -0
- package/dist/esm/elements/tt/register.js.map +7 -0
- package/dist/esm/index.js +13 -9
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/types/window.d.js +1 -0
- package/dist/esm/types/window.d.js.map +7 -0
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/utils/Utils.js +22 -19
- package/dist/esm/utils/Utils.js.map +2 -2
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +4189 -456
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
- package/dist/types/{elements/SwcAppEngine.d.ts → SwcAppEngine.d.ts} +9 -4
- package/dist/types/SwcAppEngine.d.ts.map +1 -0
- package/dist/types/decorators/addEventListener.d.ts +5 -7
- package/dist/types/decorators/addEventListener.d.ts.map +1 -1
- package/dist/types/decorators/applyAttribute.d.ts +4 -4
- package/dist/types/decorators/applyAttribute.d.ts.map +1 -1
- package/dist/types/decorators/applyClass.d.ts +6 -6
- package/dist/types/decorators/applyClass.d.ts.map +1 -1
- package/dist/types/decorators/applyNode.d.ts +9 -9
- package/dist/types/decorators/applyNode.d.ts.map +1 -1
- package/dist/types/decorators/applySlot.d.ts +27 -0
- package/dist/types/decorators/applySlot.d.ts.map +1 -0
- package/dist/types/decorators/applyStyle.d.ts +4 -4
- package/dist/types/decorators/applyStyle.d.ts.map +1 -1
- package/dist/types/decorators/attribute.d.ts +5 -5
- package/dist/types/decorators/attribute.d.ts.map +1 -1
- package/dist/types/decorators/changedAttributeThis.d.ts +18 -0
- package/dist/types/decorators/changedAttributeThis.d.ts.map +1 -0
- package/dist/types/decorators/elementDefine.d.ts.map +1 -1
- package/dist/types/decorators/emitCustomEvent.d.ts +4 -9
- package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
- package/dist/types/decorators/index.d.ts +2 -1
- package/dist/types/decorators/index.d.ts.map +1 -1
- package/dist/types/decorators/lifecycles.d.ts +21 -6
- package/dist/types/decorators/lifecycles.d.ts.map +1 -1
- package/dist/types/decorators/query.d.ts +17 -63
- package/dist/types/decorators/query.d.ts.map +1 -1
- package/dist/types/decorators/queryAll.d.ts +6 -63
- package/dist/types/decorators/queryAll.d.ts.map +1 -1
- package/dist/types/decorators/setProperty.d.ts +1 -1
- package/dist/types/decorators/setProperty.d.ts.map +1 -1
- package/dist/types/elements/SwcApp.d.ts +7 -0
- package/dist/types/elements/SwcApp.d.ts.map +1 -0
- package/dist/types/elements/index.d.ts +2 -1
- package/dist/types/elements/index.d.ts.map +1 -1
- package/dist/types/elements/tt/SwcAppMixin.d.ts +1 -0
- package/dist/types/elements/tt/SwcAppMixin.d.ts.map +1 -0
- package/dist/types/elements/tt/SwcAsync.d.ts +1 -0
- package/dist/types/elements/tt/SwcAsync.d.ts.map +1 -0
- package/dist/types/elements/tt/SwcAsyncTemplate.d.ts +1 -0
- package/dist/types/elements/tt/SwcAsyncTemplate.d.ts.map +1 -0
- package/dist/types/elements/tt/SwcChoose.d.ts +1 -0
- package/dist/types/elements/tt/SwcChoose.d.ts.map +1 -0
- package/dist/types/elements/tt/SwcChooseTemplate.d.ts +1 -0
- package/dist/types/elements/tt/SwcChooseTemplate.d.ts.map +1 -0
- package/dist/types/elements/tt/SwcIf.d.ts +1 -0
- package/dist/types/elements/{SwcIf.d.ts.map → tt/SwcIf.d.ts.map} +1 -1
- package/dist/types/elements/tt/SwcIfTemplate.d.ts +1 -0
- package/dist/types/elements/tt/SwcIfTemplate.d.ts.map +1 -0
- package/dist/types/elements/tt/SwcLoop.d.ts +1 -0
- package/dist/types/elements/tt/SwcLoop.d.ts.map +1 -0
- package/dist/types/elements/tt/SwcLoopTemplate.d.ts +1 -0
- package/dist/types/elements/tt/SwcLoopTemplate.d.ts.map +1 -0
- package/dist/types/elements/tt/SwcSubTemplates.d.ts +1 -0
- package/dist/types/elements/tt/SwcSubTemplates.d.ts.map +1 -0
- package/dist/types/elements/tt/register.d.ts +1 -0
- package/dist/types/elements/tt/register.d.ts.map +1 -0
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/types.d.ts +5 -5
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils/Utils.d.ts +13 -12
- package/dist/types/utils/Utils.d.ts.map +1 -1
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +4189 -456
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
- package/package.json +4 -4
- package/src/{elements/SwcAppEngine.ts → SwcAppEngine.ts} +12 -7
- package/src/decorators/addEventListener.ts +11 -9
- package/src/decorators/applyAttribute.ts +16 -15
- package/src/decorators/applyClass.ts +18 -17
- package/src/decorators/applyNode.ts +30 -27
- package/src/decorators/applySlot.ts +228 -0
- package/src/decorators/applyStyle.ts +17 -16
- package/src/decorators/attribute.ts +20 -19
- package/src/decorators/{changedAttributeHost.ts → changedAttributeThis.ts} +10 -12
- package/src/decorators/elementDefine.ts +80 -57
- package/src/decorators/emitCustomEvent.ts +21 -26
- package/src/decorators/index.ts +2 -1
- package/src/decorators/lifecycles.ts +76 -11
- package/src/decorators/query.ts +51 -124
- package/src/decorators/queryAll.ts +30 -127
- package/src/decorators/setProperty.ts +12 -11
- package/src/elements/{SwcAppMixin.ts → SwcApp.ts} +98 -31
- package/src/elements/index.ts +11 -1
- package/src/elements/tt/SwcAppMixin.ts +13 -0
- package/src/elements/tt/SwcAsync.ts +139 -0
- package/src/elements/tt/SwcAsyncTemplate.ts +126 -0
- package/src/elements/tt/SwcChoose.ts +182 -0
- package/src/elements/tt/SwcChooseTemplate.ts +229 -0
- package/src/elements/tt/SwcIf.ts +145 -0
- package/src/elements/tt/SwcIfTemplate.ts +158 -0
- package/src/elements/tt/SwcLoop.ts +222 -0
- package/src/elements/tt/SwcLoopTemplate.ts +255 -0
- package/src/elements/tt/SwcSubTemplates.ts +6 -0
- package/src/elements/tt/register.ts +720 -0
- package/src/index.ts +13 -9
- package/src/types/window.d.ts +43 -0
- package/src/types.ts +9 -8
- package/src/utils/Utils.ts +28 -24
- package/dist/cjs/decorators/changedAttributeHost.js.map +0 -7
- package/dist/cjs/elements/SwcAppEngine.js.map +0 -7
- package/dist/cjs/elements/SwcAppMixin.js.map +0 -7
- package/dist/cjs/elements/SwcAsync.js +0 -129
- package/dist/cjs/elements/SwcAsync.js.map +0 -7
- package/dist/cjs/elements/SwcChoose.js +0 -155
- package/dist/cjs/elements/SwcChoose.js.map +0 -7
- package/dist/cjs/elements/SwcIf.js +0 -117
- package/dist/cjs/elements/SwcIf.js.map +0 -7
- package/dist/cjs/elements/SwcLoop.js +0 -176
- package/dist/cjs/elements/SwcLoop.js.map +0 -7
- package/dist/cjs/elements/SwcSubTemplates.js +0 -13
- package/dist/cjs/elements/SwcSubTemplates.js.map +0 -7
- package/dist/cjs/elements/register.js +0 -1026
- package/dist/cjs/elements/register.js.map +0 -7
- package/dist/esm/decorators/changedAttributeHost.js.map +0 -7
- package/dist/esm/elements/SwcAppEngine.js.map +0 -7
- package/dist/esm/elements/SwcAppMixin.js.map +0 -7
- package/dist/esm/elements/SwcAsync.js +0 -129
- package/dist/esm/elements/SwcAsync.js.map +0 -7
- package/dist/esm/elements/SwcChoose.js +0 -155
- package/dist/esm/elements/SwcChoose.js.map +0 -7
- package/dist/esm/elements/SwcIf.js +0 -117
- package/dist/esm/elements/SwcIf.js.map +0 -7
- package/dist/esm/elements/SwcLoop.js +0 -176
- package/dist/esm/elements/SwcLoop.js.map +0 -7
- package/dist/esm/elements/SwcSubTemplates.js +0 -13
- package/dist/esm/elements/SwcSubTemplates.js.map +0 -7
- package/dist/esm/elements/register.js +0 -1007
- package/dist/esm/elements/register.js.map +0 -7
- package/dist/types/decorators/changedAttributeHost.d.ts +0 -20
- package/dist/types/decorators/changedAttributeHost.d.ts.map +0 -1
- package/dist/types/elements/SwcAppEngine.d.ts.map +0 -1
- package/dist/types/elements/SwcAppMixin.d.ts +0 -386
- package/dist/types/elements/SwcAppMixin.d.ts.map +0 -1
- package/dist/types/elements/SwcAsync.d.ts +0 -2
- package/dist/types/elements/SwcAsync.d.ts.map +0 -1
- package/dist/types/elements/SwcChoose.d.ts +0 -2
- package/dist/types/elements/SwcChoose.d.ts.map +0 -1
- package/dist/types/elements/SwcIf.d.ts +0 -2
- package/dist/types/elements/SwcLoop.d.ts +0 -2
- package/dist/types/elements/SwcLoop.d.ts.map +0 -1
- package/dist/types/elements/SwcSubTemplates.d.ts +0 -13
- package/dist/types/elements/SwcSubTemplates.d.ts.map +0 -1
- package/dist/types/elements/register.d.ts +0 -4
- package/dist/types/elements/register.d.ts.map +0 -1
- package/src/elements/SwcAsync.ts +0 -126
- package/src/elements/SwcChoose.ts +0 -190
- package/src/elements/SwcIf.ts +0 -124
- package/src/elements/SwcLoop.ts +0 -205
- package/src/elements/SwcSubTemplates.ts +0 -6
- package/src/elements/register.ts +0 -1022
|
@@ -1,14 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {debounceTimeIntervalLock, FunctionUtils, Subscription} from
|
|
5
|
-
import {RouterEventType} from
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import {SwcAppInterface, SwcAppMessage} from "../types";
|
|
2
|
+
import {elementDefine, findAllLifecycleMetadata, getSubscribeSwcAppMessageWhileConnectedMetadata, getSubscribeSwcAppRouteChangeWhileConnectedMetadata, ON_CONNECTED_SWC_APP_METADATA_KEY} from "../decorators";
|
|
3
|
+
import {SwcAppEngine, SwcAttributeConfigType, SwcConfigType} from "../SwcAppEngine";
|
|
4
|
+
import {debounceTimeIntervalLock, FunctionUtils, Subscription} from "@dooboostore/core";
|
|
5
|
+
import {RouterEventType} from "@dooboostore/core-web";
|
|
6
|
+
import {SwcUtils} from "../utils/Utils";
|
|
7
|
+
|
|
8
|
+
export const isSSR = (i: HTMLElement) => {
|
|
9
|
+
return i.hasAttribute('swc-use-ssr');
|
|
10
|
+
}
|
|
11
|
+
export const setSSRAttribute = (i: HTMLElement) => {
|
|
12
|
+
i.setAttribute('swc-use-ssr', (i as any)._swcId ?? '');
|
|
13
|
+
}
|
|
14
|
+
export const removeSSRAttribute = (i: HTMLElement) => {
|
|
15
|
+
i.removeAttribute('swc-use-ssr');
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
export const tagName = 'swc-app';
|
|
20
|
+
export default async (w: Window) => {
|
|
21
|
+
const existing = w.customElements.get(tagName);
|
|
22
|
+
if (existing) return existing;
|
|
23
|
+
|
|
24
|
+
@elementDefine(tagName, {window: w})
|
|
25
|
+
class SwcApp extends w.HTMLElement implements SwcAppInterface {
|
|
12
26
|
__swc_engine = new SwcAppEngine(this as any);
|
|
13
27
|
_swc_connected_instance = new Set<any>();
|
|
14
28
|
// _swc_notified_routes = new WeakMap<any, RouterEventType>();
|
|
@@ -26,7 +40,7 @@ export function SwcAppMixin<T extends { new(...args: any[]): HTMLElement }>(Base
|
|
|
26
40
|
이걸사용하는데 is 대응하는거다 그런데 이때 처리되는 순서가 크롬이나 표준에서는 부모부터 만들어지고 자식들이 만들어지는데
|
|
27
41
|
저 polyfill에서는 자식부터 만들어지고 부모가 만들어진다 is일때 아 .. 이문제때문에 자식이 _connected_safari 에 강제로 자기자식넣어준다
|
|
28
42
|
*/
|
|
29
|
-
|
|
43
|
+
_connected_safari_and_standby = [];
|
|
30
44
|
|
|
31
45
|
get simpleApplication() {
|
|
32
46
|
return this.__swc_engine.simpleApplication;
|
|
@@ -40,22 +54,23 @@ export function SwcAppMixin<T extends { new(...args: any[]): HTMLElement }>(Base
|
|
|
40
54
|
return this.__swc_engine?.router;
|
|
41
55
|
}
|
|
42
56
|
|
|
43
|
-
async _invokeRouteChangeSubscribers(instance:
|
|
57
|
+
async _invokeRouteChangeSubscribers(instance: HTMLElement, re: RouterEventType) {
|
|
44
58
|
if (instance.isConnected === false) return;
|
|
45
59
|
|
|
46
60
|
this._routeChangeInvocations++;
|
|
47
61
|
|
|
48
62
|
if (this._childrenRouteChangedInterval) {
|
|
49
|
-
clearInterval(this._childrenRouteChangedInterval);
|
|
63
|
+
this.config.window.clearInterval(this._childrenRouteChangedInterval);
|
|
50
64
|
}
|
|
65
|
+
const intervalConfig = {setInterval: this.config.window.setInterval.bind(this.config.window), clearInterval: this.config.window.clearInterval.bind(this.config.window)};
|
|
51
66
|
this._childrenRouteChangedInterval = debounceTimeIntervalLock(
|
|
52
67
|
() => this._routeChangeInvocations === 0,
|
|
53
68
|
() => {
|
|
54
69
|
this._childrenRouteChangedInterval = null;
|
|
55
|
-
this.config.onChildrenRouteChanged(re, this)
|
|
70
|
+
this.config.onChildrenRouteChanged?.(re, this)
|
|
56
71
|
},
|
|
57
72
|
this.config?.childrenConnectedDoneCheckIntervalTime ?? 30,
|
|
58
|
-
|
|
73
|
+
intervalConfig
|
|
59
74
|
// {setInterval: window.setInterval, clearInterval: window.clearInterval}
|
|
60
75
|
);
|
|
61
76
|
|
|
@@ -118,28 +133,50 @@ export function SwcAppMixin<T extends { new(...args: any[]): HTMLElement }>(Base
|
|
|
118
133
|
await Promise.allSettled(ps);
|
|
119
134
|
}
|
|
120
135
|
} finally {
|
|
121
|
-
this.
|
|
136
|
+
if (this.config?.ssr) {
|
|
137
|
+
setSSRAttribute(instance);
|
|
138
|
+
} else {
|
|
139
|
+
removeSSRAttribute(instance);
|
|
140
|
+
}
|
|
141
|
+
this._routeChangeInvocations = Math.max(0, this._routeChangeInvocations - 1);
|
|
122
142
|
}
|
|
123
143
|
}
|
|
124
144
|
|
|
125
|
-
async _connected(instance:
|
|
145
|
+
async _connected(instance: HTMLElement, option?: { noIncrements: boolean }) {
|
|
126
146
|
if (instance) {
|
|
127
|
-
this._connectedInvocations
|
|
147
|
+
// console.log('_connected-->', instance.tagName, this._connectedInvocations)
|
|
148
|
+
|
|
149
|
+
if (!this.simpleApplication && !this.config) {
|
|
150
|
+
this._connected_safari_and_standby.push(instance);
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
this.config.onConnectedChildBefore?.(instance);
|
|
155
|
+
if (!option?.noIncrements) {
|
|
156
|
+
this._connectedInvocations++;
|
|
157
|
+
}
|
|
128
158
|
this._swc_connected_instance.add(instance);
|
|
129
159
|
|
|
160
|
+
const connectedSwcAppCallBacks = findAllLifecycleMetadata(instance, ON_CONNECTED_SWC_APP_METADATA_KEY) ?? [];
|
|
161
|
+
for (let connectedSwcAppCallBack of connectedSwcAppCallBacks) {
|
|
162
|
+
await (instance as any)?._invokeLifecycleMethod?.(connectedSwcAppCallBack);
|
|
163
|
+
}
|
|
164
|
+
|
|
130
165
|
if (this._childrenConnectedDoneInterval) {
|
|
131
|
-
clearInterval(this._childrenConnectedDoneInterval);
|
|
166
|
+
this.config.window.clearInterval(this._childrenConnectedDoneInterval);
|
|
132
167
|
}
|
|
168
|
+
const intervalConfig = {setInterval: this.config.window.setInterval.bind(this.config.window), clearInterval: this.config.window.clearInterval.bind(this.config.window)};
|
|
133
169
|
this._childrenConnectedDoneInterval = debounceTimeIntervalLock(
|
|
134
170
|
() => this._connectedInvocations === 0,
|
|
135
171
|
() => {
|
|
136
172
|
this._childrenConnectedDoneInterval = null;
|
|
137
|
-
this.config.onChildrenConnectedDone(this)
|
|
173
|
+
this.config.onChildrenConnectedDone?.(this)
|
|
138
174
|
},
|
|
139
175
|
this.config?.childrenConnectedDoneCheckIntervalTime ?? 30,
|
|
140
|
-
|
|
176
|
+
intervalConfig
|
|
141
177
|
);
|
|
142
178
|
|
|
179
|
+
// console.log('onChildConnectedDone-->')
|
|
143
180
|
|
|
144
181
|
if (this.simpleApplication) {
|
|
145
182
|
try {
|
|
@@ -152,14 +189,25 @@ export function SwcAppMixin<T extends { new(...args: any[]): HTMLElement }>(Base
|
|
|
152
189
|
throw e;
|
|
153
190
|
}
|
|
154
191
|
}
|
|
192
|
+
|
|
193
|
+
if (this.config?.ssr) {
|
|
194
|
+
setSSRAttribute(instance);
|
|
195
|
+
} else {
|
|
196
|
+
removeSSRAttribute(instance);
|
|
197
|
+
}
|
|
155
198
|
}
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
this.config.onConnectedChildAfter?.(instance);
|
|
202
|
+
return this;
|
|
156
203
|
}
|
|
157
204
|
|
|
158
205
|
async _connectedDone(instance: any) {
|
|
159
206
|
try {
|
|
160
207
|
// 내부 연결 처리 로직이 있다면 여기에 추가
|
|
208
|
+
// console.log('_connectedDone-->', instance, this._connectedInvocations)
|
|
161
209
|
} finally {
|
|
162
|
-
this._connectedInvocations
|
|
210
|
+
this._connectedInvocations = Math.max(0, this._connectedInvocations - 1);
|
|
163
211
|
}
|
|
164
212
|
}
|
|
165
213
|
|
|
@@ -167,6 +215,7 @@ export function SwcAppMixin<T extends { new(...args: any[]): HTMLElement }>(Base
|
|
|
167
215
|
// console.log('_disconnected', instance);
|
|
168
216
|
if (instance) {
|
|
169
217
|
this._swc_connected_instance.delete(instance);
|
|
218
|
+
this.config?.onDisconnectedChildAfter?.(instance);
|
|
170
219
|
// this._swc_notified_routes.delete(instance);
|
|
171
220
|
}
|
|
172
221
|
}
|
|
@@ -184,6 +233,7 @@ export function SwcAppMixin<T extends { new(...args: any[]): HTMLElement }>(Base
|
|
|
184
233
|
}
|
|
185
234
|
|
|
186
235
|
async connect(config?: SwcAttributeConfigType) {
|
|
236
|
+
console.log('[SWC] connect')
|
|
187
237
|
const swcConfig = {
|
|
188
238
|
routeType: 'element',
|
|
189
239
|
window: config?.window,
|
|
@@ -192,9 +242,9 @@ export function SwcAppMixin<T extends { new(...args: any[]): HTMLElement }>(Base
|
|
|
192
242
|
|
|
193
243
|
const mode = config?.connectMode || 'direct';
|
|
194
244
|
|
|
195
|
-
if (mode === 'direct') {
|
|
245
|
+
if (mode === 'direct' || mode === 'hydrate') {
|
|
246
|
+
this.setAttribute('swc-connect-mode', mode);
|
|
196
247
|
await this.__swc_engine.connect(swcConfig);
|
|
197
|
-
this.setAttribute('swc-connect-mode', 'direct');
|
|
198
248
|
} else if (mode === 'swap' || mode === 'clear-swap') {
|
|
199
249
|
if (!this.parentNode) {
|
|
200
250
|
// 부모가 없으면 swap을 할 수 없으므로 direct로 폴백합니다.
|
|
@@ -233,9 +283,9 @@ export function SwcAppMixin<T extends { new(...args: any[]): HTMLElement }>(Base
|
|
|
233
283
|
}
|
|
234
284
|
|
|
235
285
|
// 사파리일떄 예외이다 is 일때 polyfill되는데 이떄 부모부터 만들어지는게 아니라 자식부터 만들어진다 그래서 부모가 만들어질때 자식들이 이미 만들어져있어서 부모가 자식들을 등록해주는 형태로 강제로 등록해준다
|
|
236
|
-
this.
|
|
286
|
+
this._connected_safari_and_standby.forEach((instance: any) => {
|
|
237
287
|
// console.log('safari!!!!!!!!!!', instance)
|
|
238
|
-
this._connected(instance);
|
|
288
|
+
this._connected(instance, {noIncrements: true});
|
|
239
289
|
// this._swc_connected_instance.add(instance);
|
|
240
290
|
});
|
|
241
291
|
// Invoke @onConnectedSwcApp lifecycle methods on all connected component instances
|
|
@@ -253,7 +303,7 @@ export function SwcAppMixin<T extends { new(...args: any[]): HTMLElement }>(Base
|
|
|
253
303
|
const config = this.__swc_engine.config;
|
|
254
304
|
|
|
255
305
|
this._routerSubscription = this.router.observable.subscribe(async (route: RouterEventType) => {
|
|
256
|
-
|
|
306
|
+
console.log('[SWC] Router event received:', route.triggerPoint);
|
|
257
307
|
if (route.triggerPoint === 'end') {
|
|
258
308
|
// 1. 모든 기존 연결된 자식들에게 라우트 이벤트 알림
|
|
259
309
|
await this._handleRouteChange(route);
|
|
@@ -262,8 +312,8 @@ export function SwcAppMixin<T extends { new(...args: any[]): HTMLElement }>(Base
|
|
|
262
312
|
|
|
263
313
|
// Navigate to initial path if specified
|
|
264
314
|
if (config?.path) {
|
|
265
|
-
|
|
266
|
-
this.router.go(config.path);
|
|
315
|
+
console.log('[DEBUG] Navigating to initial path:', config.path);
|
|
316
|
+
// this.router.go(config.path);
|
|
267
317
|
}
|
|
268
318
|
}
|
|
269
319
|
}
|
|
@@ -306,7 +356,10 @@ export function SwcAppMixin<T extends { new(...args: any[]): HTMLElement }>(Base
|
|
|
306
356
|
}
|
|
307
357
|
}
|
|
308
358
|
|
|
359
|
+
// 자기자신은 apphost로 포함이 도지않으니(부모) 내자신은 self로 넣는다
|
|
360
|
+
this._connected(this);
|
|
309
361
|
this.__swc_engine?.config?.onConnected?.(this);
|
|
362
|
+
this._connectedDone(this);
|
|
310
363
|
}
|
|
311
364
|
|
|
312
365
|
disconnectedCallback() {
|
|
@@ -317,6 +370,7 @@ export function SwcAppMixin<T extends { new(...args: any[]): HTMLElement }>(Base
|
|
|
317
370
|
this._lastRouterEvent = undefined;
|
|
318
371
|
this.__swc_engine.disconnect();
|
|
319
372
|
this.__swc_engine?.config?.onDisconnected?.(this);
|
|
373
|
+
this._disconnected(this);
|
|
320
374
|
}
|
|
321
375
|
|
|
322
376
|
async routing(path: string) {
|
|
@@ -335,6 +389,14 @@ export function SwcAppMixin<T extends { new(...args: any[]): HTMLElement }>(Base
|
|
|
335
389
|
this.router?.reload();
|
|
336
390
|
}
|
|
337
391
|
|
|
392
|
+
// async completedSwcApp() {
|
|
393
|
+
// const ss = Array.from(this._swc_connected_instance).flatMap((it) => {
|
|
394
|
+
// const ms = findAllLifecycleMetadata(it, ON_CONNECTED_COMPLETED_SWC_APP_METADATA_KEY) ?? [];
|
|
395
|
+
// return ms.map((sit) => it[sit](this));
|
|
396
|
+
// });
|
|
397
|
+
// await Promise.allSettled(ss);
|
|
398
|
+
// }
|
|
399
|
+
|
|
338
400
|
publishMessage(message: SwcAppMessage): void {
|
|
339
401
|
// 메시지를 모든 connected component instances로 분배
|
|
340
402
|
this._swc_connected_instance.forEach((instance: any) => {
|
|
@@ -373,4 +435,9 @@ export function SwcAppMixin<T extends { new(...args: any[]): HTMLElement }>(Base
|
|
|
373
435
|
}
|
|
374
436
|
}
|
|
375
437
|
};
|
|
376
|
-
|
|
438
|
+
|
|
439
|
+
|
|
440
|
+
return w.customElements.whenDefined(tagName);
|
|
441
|
+
|
|
442
|
+
|
|
443
|
+
}
|
package/src/elements/index.ts
CHANGED
|
@@ -1 +1,11 @@
|
|
|
1
|
-
export * from './register';
|
|
1
|
+
// export * from './tt/register';
|
|
2
|
+
import swcAppFactory from './SwcApp'
|
|
3
|
+
// import swcAsyncFactory from './SwcAsync'
|
|
4
|
+
// import swcLoopFactory from './SwcLoop'
|
|
5
|
+
// import swcIfFactory from './SwcIf'
|
|
6
|
+
export const registerSwcApp = swcAppFactory;
|
|
7
|
+
// export const registerSwcAsync = swcAsyncFactory;
|
|
8
|
+
// export const registerSwcLoop = swcLoopFactory;
|
|
9
|
+
// export const registerSwcIf = swcIfFactory;
|
|
10
|
+
|
|
11
|
+
export const register = [swcAppFactory];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// import {SwcAppEngine, SwcAttributeConfigType, SwcConfigType} from '../../SwcAppEngine';
|
|
2
|
+
// import {SwcAppInterface, SwcAppMessage} from '../../types';
|
|
3
|
+
// import {SwcUtils} from '../../utils/Utils';
|
|
4
|
+
// import {debounceTimeIntervalLock, FunctionUtils, Subscription} from '@dooboostore/core';
|
|
5
|
+
// import {RouterEventType} from '@dooboostore/core-web';
|
|
6
|
+
// import {getSubscribeSwcAppRouteChangeWhileConnectedMetadata} from '../../decorators/subscribeSwcAppRouteChangeWhileConnected';
|
|
7
|
+
// import {getSubscribeSwcAppMessageWhileConnectedMetadata} from '../../decorators/subscribeSwcAppMessageWhileConnected';
|
|
8
|
+
// import {findAllLifecycleMetadata, ON_CONNECTED_COMPLETED_SWC_APP_METADATA_KEY, ON_CONNECTED_INNER_HTML_METADATA_KEY, ON_CONNECTED_SWC_APP_METADATA_KEY} from "../../decorators";
|
|
9
|
+
//
|
|
10
|
+
// export function SwcAppMixin<T extends { new(...args: any[]): HTMLElement }>(Base: T) {
|
|
11
|
+
// //@ts-ignore
|
|
12
|
+
// return
|
|
13
|
+
// }
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
// import {SwcUtils} from '../../utils/Utils';
|
|
2
|
+
// import {ActionExpression, FunctionUtils} from '@dooboostore/core';
|
|
3
|
+
// import {ConvertUtils} from '@dooboostore/core-web';
|
|
4
|
+
// import {elementDefine} from "../../decorators";
|
|
5
|
+
//
|
|
6
|
+
// export default async (w: Window) => {
|
|
7
|
+
// const tagName = 'swc-async';
|
|
8
|
+
// const existing = w.customElements.get(tagName);
|
|
9
|
+
// if (existing) return existing;
|
|
10
|
+
//
|
|
11
|
+
// @elementDefine(tagName, { window: w })
|
|
12
|
+
// class SwcAsync extends w.HTMLElement {
|
|
13
|
+
// private _value: any;
|
|
14
|
+
// private _replaceWrapStart: string | null = null;
|
|
15
|
+
// private _replaceWrapEnd: string | null = null;
|
|
16
|
+
// private _nodes: Node[] = [];
|
|
17
|
+
// resultValue?: any;
|
|
18
|
+
//
|
|
19
|
+
// static get observedAttributes() {
|
|
20
|
+
// return ['value', 'replace-wrap-start', 'replace-wrap-end'];
|
|
21
|
+
// }
|
|
22
|
+
//
|
|
23
|
+
// get value(): boolean {
|
|
24
|
+
// return this._value;
|
|
25
|
+
// }
|
|
26
|
+
//
|
|
27
|
+
// set value(nv: any) {
|
|
28
|
+
// this.executeAsync(nv);
|
|
29
|
+
// }
|
|
30
|
+
//
|
|
31
|
+
// connectedCallback() {
|
|
32
|
+
// if (this.hasAttribute('value')) {
|
|
33
|
+
// this.executeAsync(this._value);
|
|
34
|
+
// }
|
|
35
|
+
// }
|
|
36
|
+
//
|
|
37
|
+
// attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null) {
|
|
38
|
+
// switch (name) {
|
|
39
|
+
// case 'value':
|
|
40
|
+
// this._value = newValue;
|
|
41
|
+
// this.executeAsync(this._value);
|
|
42
|
+
// break;
|
|
43
|
+
// case 'replace-wrap-start':
|
|
44
|
+
// this._replaceWrapStart = newValue;
|
|
45
|
+
// break;
|
|
46
|
+
// case 'replace-wrap-end':
|
|
47
|
+
// this._replaceWrapEnd = newValue;
|
|
48
|
+
// break;
|
|
49
|
+
// }
|
|
50
|
+
// }
|
|
51
|
+
//
|
|
52
|
+
// private executeAsync(result: any = this._value) {
|
|
53
|
+
// if (result === undefined || result === null) {
|
|
54
|
+
// this.refresh('default');
|
|
55
|
+
// return;
|
|
56
|
+
// }
|
|
57
|
+
// if (result instanceof Promise) {
|
|
58
|
+
// this.refresh('loading');
|
|
59
|
+
// result
|
|
60
|
+
// .then(v => {
|
|
61
|
+
// this.resultValue = v;
|
|
62
|
+
// this.refresh('success');
|
|
63
|
+
// })
|
|
64
|
+
// .catch(e => {
|
|
65
|
+
// console.error('[SWC-ASYNC] Promise rejected:', e);
|
|
66
|
+
// this.resultValue = e;
|
|
67
|
+
// this.refresh('error');
|
|
68
|
+
// });
|
|
69
|
+
// } else {
|
|
70
|
+
// this.resultValue = result;
|
|
71
|
+
// this.refresh('success');
|
|
72
|
+
// }
|
|
73
|
+
// }
|
|
74
|
+
//
|
|
75
|
+
// private replaceExpressions(html: string, groupArgs: any, context: any, wrap: { start: string, end: string }): string {
|
|
76
|
+
// let config: any = undefined;
|
|
77
|
+
// if (wrap) {
|
|
78
|
+
// config = {
|
|
79
|
+
// expression: {
|
|
80
|
+
// replace: {start: `${wrap.start}`, end: `${wrap.end}`},
|
|
81
|
+
// callReturn: {start: `${wrap.start}=`, end: `${wrap.end}`},
|
|
82
|
+
// call: {start: `${wrap.start}@`, end: `${wrap.end}`}
|
|
83
|
+
// }
|
|
84
|
+
// };
|
|
85
|
+
// }
|
|
86
|
+
// const ae = new ActionExpression(html, config);
|
|
87
|
+
// const win = this.ownerDocument?.defaultView || window;
|
|
88
|
+
// for (const expr of ae.getExpressions('replace')) {
|
|
89
|
+
// try {
|
|
90
|
+
// const value = FunctionUtils.executeReturn({
|
|
91
|
+
// script: ConvertUtils.decodeHtmlEntity(expr.script, win.document),
|
|
92
|
+
// context,
|
|
93
|
+
// args: groupArgs
|
|
94
|
+
// });
|
|
95
|
+
// ae.replace(expr, String(value));
|
|
96
|
+
// } catch (e) {
|
|
97
|
+
// console.error(`[SWC] Failed to execute ${expr.original}:`, e);
|
|
98
|
+
// }
|
|
99
|
+
// }
|
|
100
|
+
// return ae.getUnprocessedTemplate();
|
|
101
|
+
// }
|
|
102
|
+
//
|
|
103
|
+
// refresh(state: string = 'default') {
|
|
104
|
+
// this.cleanup();
|
|
105
|
+
// const portal = SwcUtils.getParentContainer(this);
|
|
106
|
+
// if (!portal) return;
|
|
107
|
+
// const win = this.ownerDocument?.defaultView || window;
|
|
108
|
+
// const helperSet = SwcUtils.getHelperAndHostSet(win, this);
|
|
109
|
+
// // HTMLElement에서는 children에서 template[is=swc-...] 찾기
|
|
110
|
+
// const t = Array.from(this.children).find(
|
|
111
|
+
// (el): el is HTMLTemplateElement => el.tagName === 'TEMPLATE' && el.getAttribute('is') === `swc-${state}`
|
|
112
|
+
// );
|
|
113
|
+
// if (t) {
|
|
114
|
+
// let htmlString = t.innerHTML;
|
|
115
|
+
// const groupArgs = {...helperSet, $value: this._value, $state: state, $templateHost: this};
|
|
116
|
+
// htmlString = this.replaceExpressions(htmlString, groupArgs, this, {start: this._replaceWrapStart ?? '{#{', end: this._replaceWrapEnd ?? '}#}'});
|
|
117
|
+
// const temp = this.ownerDocument?.createElement('template') || document.createElement('template');
|
|
118
|
+
// temp.innerHTML = htmlString;
|
|
119
|
+
// const content = temp.content;
|
|
120
|
+
// this._nodes = Array.from(content.childNodes);
|
|
121
|
+
// this._nodes.forEach((node: any) => {
|
|
122
|
+
// if (node instanceof HTMLElement) (node as any).__template_swc_host = this;
|
|
123
|
+
// });
|
|
124
|
+
// portal.insertBefore(content, this.nextSibling);
|
|
125
|
+
// }
|
|
126
|
+
// }
|
|
127
|
+
//
|
|
128
|
+
// private cleanup() {
|
|
129
|
+
// this._nodes.forEach(n => n.parentElement?.removeChild(n));
|
|
130
|
+
// this._nodes = [];
|
|
131
|
+
// }
|
|
132
|
+
//
|
|
133
|
+
// disconnectedCallback() {
|
|
134
|
+
// this.cleanup();
|
|
135
|
+
// }
|
|
136
|
+
// }
|
|
137
|
+
//
|
|
138
|
+
// return w.customElements.whenDefined(tagName);
|
|
139
|
+
// }
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
// import { changedAttributeThis } from '../../decorators/changedAttributeThis';
|
|
2
|
+
// import { SwcUtils } from '../../utils/Utils';
|
|
3
|
+
// import { FunctionUtils, ActionExpression } from '@dooboostore/core';
|
|
4
|
+
// import { ConvertUtils } from '@dooboostore/core-web';
|
|
5
|
+
// import { attributeThis } from '../../decorators';
|
|
6
|
+
//
|
|
7
|
+
// export class SwcAsyncTemplate extends HTMLTemplateElement {
|
|
8
|
+
// @attributeThis('value')
|
|
9
|
+
// _value: any;
|
|
10
|
+
// @attributeThis('replace-wrap-start')
|
|
11
|
+
// _replaceWrapStart: string | null;
|
|
12
|
+
// @attributeThis('replace-wrap-end')
|
|
13
|
+
// _replaceWrapEnd: string | null; resultValue?: any;
|
|
14
|
+
//
|
|
15
|
+
// get value(): boolean {
|
|
16
|
+
// return this._value;
|
|
17
|
+
// }
|
|
18
|
+
//
|
|
19
|
+
// set value(nv: any) {
|
|
20
|
+
// this.executeAsync(nv);
|
|
21
|
+
// }
|
|
22
|
+
//
|
|
23
|
+
// private _nodes: Node[] = [];
|
|
24
|
+
//
|
|
25
|
+
// @changedAttributeThis('value')
|
|
26
|
+
// private setValue(valueAttr?: string | null) {
|
|
27
|
+
// this.executeAsync(this._value);
|
|
28
|
+
// }
|
|
29
|
+
//
|
|
30
|
+
// // @changedAttributeThis('replace-wrap')
|
|
31
|
+
// // private setReplaceWrap() {
|
|
32
|
+
// // this.executeAsync(this._value);
|
|
33
|
+
// // }
|
|
34
|
+
//
|
|
35
|
+
// private executeAsync(result: any = this._value) {
|
|
36
|
+
// if (result === undefined || result === null) {
|
|
37
|
+
// this.refresh('default');
|
|
38
|
+
// return;
|
|
39
|
+
// }
|
|
40
|
+
//
|
|
41
|
+
// if (result instanceof Promise) {
|
|
42
|
+
// this.refresh('loading');
|
|
43
|
+
// result
|
|
44
|
+
// .then(v => {
|
|
45
|
+
// this.resultValue = v;
|
|
46
|
+
// this.refresh('success');
|
|
47
|
+
// })
|
|
48
|
+
// .catch(e => {
|
|
49
|
+
// console.error('[SWC-ASYNC] Promise rejected:', e);
|
|
50
|
+
// this.resultValue = e;
|
|
51
|
+
// this.refresh('error');
|
|
52
|
+
// });
|
|
53
|
+
// } else {
|
|
54
|
+
// this.resultValue = result;
|
|
55
|
+
// this.refresh('success');
|
|
56
|
+
// }
|
|
57
|
+
// }
|
|
58
|
+
//
|
|
59
|
+
// private replaceExpressions(html: string, groupArgs: any, context: any, wrap: {start: string, end: string}): string {
|
|
60
|
+
// let config: any = undefined;
|
|
61
|
+
// if (wrap) {
|
|
62
|
+
// config = {
|
|
63
|
+
// expression: {
|
|
64
|
+
// replace: { start: `${wrap.start}`, end: `${wrap.end}` },
|
|
65
|
+
// callReturn: { start: `${wrap.start}=`, end: `${wrap.end}` },
|
|
66
|
+
// call: { start: `${wrap.start}@`, end: `${wrap.end}` }
|
|
67
|
+
// }
|
|
68
|
+
// };
|
|
69
|
+
// }
|
|
70
|
+
// const ae = new ActionExpression(html, config);
|
|
71
|
+
// const win = this.ownerDocument?.defaultView || window;
|
|
72
|
+
//
|
|
73
|
+
// // @ts-ignore
|
|
74
|
+
// for (const expr of ae.getExpressions('replace')) {
|
|
75
|
+
// try {
|
|
76
|
+
// const value = FunctionUtils.executeReturn({
|
|
77
|
+
// script: ConvertUtils.decodeHtmlEntity(expr.script, win.document),
|
|
78
|
+
// context,
|
|
79
|
+
// args: groupArgs
|
|
80
|
+
// });
|
|
81
|
+
// ae.replace(expr, String(value));
|
|
82
|
+
// } catch (e) {
|
|
83
|
+
// console.error(`[SWC] Failed to execute ${expr.original}:`, e);
|
|
84
|
+
// }
|
|
85
|
+
// }
|
|
86
|
+
// return ae.getUnprocessedTemplate();
|
|
87
|
+
// }
|
|
88
|
+
//
|
|
89
|
+
// refresh(state: string = 'default') {
|
|
90
|
+
// // console.log('rrrrrrrrrrrrrrrrr', state);
|
|
91
|
+
// this.cleanup();
|
|
92
|
+
// const portal = SwcUtils.getParentContainer(this);
|
|
93
|
+
// if (!portal) return;
|
|
94
|
+
//
|
|
95
|
+
// const win = this.ownerDocument?.defaultView || window;
|
|
96
|
+
// const helperSet = SwcUtils.getHelperAndHostSet(win, this);
|
|
97
|
+
//
|
|
98
|
+
// const t = this.content.querySelector(`template[is="swc-${state}"]`) as HTMLTemplateElement;
|
|
99
|
+
// if (t) {
|
|
100
|
+
// let htmlString = t.innerHTML;
|
|
101
|
+
// const groupArgs = { ...helperSet, $value: this._value, $state: state, $templateHost: this };
|
|
102
|
+
//
|
|
103
|
+
// htmlString = this.replaceExpressions(htmlString, groupArgs, this, {start:this._replaceWrapStart ?? '{#{', end: this._replaceWrapEnd ?? '}#}'});
|
|
104
|
+
//
|
|
105
|
+
// const temp = this.ownerDocument?.createElement('template') || document.createElement('template');
|
|
106
|
+
// temp.innerHTML = htmlString;
|
|
107
|
+
// const content = temp.content;
|
|
108
|
+
//
|
|
109
|
+
// this._nodes = Array.from(content.childNodes);
|
|
110
|
+
// this._nodes.forEach((node: any) => {
|
|
111
|
+
// if (node instanceof HTMLElement) (node as any).__template_swc_host = this;
|
|
112
|
+
// });
|
|
113
|
+
//
|
|
114
|
+
// portal.insertBefore(content, this.nextSibling);
|
|
115
|
+
// }
|
|
116
|
+
// }
|
|
117
|
+
//
|
|
118
|
+
// private cleanup() {
|
|
119
|
+
// this._nodes.forEach(n => n.parentElement?.removeChild(n));
|
|
120
|
+
// this._nodes = [];
|
|
121
|
+
// }
|
|
122
|
+
//
|
|
123
|
+
// disconnectedCallback() {
|
|
124
|
+
// this.cleanup();
|
|
125
|
+
// }
|
|
126
|
+
// }
|