@dooboostore/simple-web-component 1.0.36 → 1.0.38
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 +396 -68
- package/dist/cjs/{elements/SwcAppEngine.js → SwcAppEngine.js} +9 -6
- package/dist/cjs/SwcAppEngine.js.map +7 -0
- package/dist/cjs/decorators/addEventListener.js +20 -4
- package/dist/cjs/decorators/addEventListener.js.map +2 -2
- package/dist/cjs/decorators/applyAttribute.js.map +1 -1
- package/dist/cjs/decorators/applyClass.js.map +1 -1
- package/dist/cjs/decorators/applyNode.js +109 -26
- package/dist/cjs/decorators/applyNode.js.map +2 -2
- package/dist/cjs/decorators/applySlot.js +129 -0
- package/dist/cjs/decorators/applySlot.js.map +7 -0
- package/dist/cjs/decorators/applyStyle.js.map +2 -2
- package/dist/cjs/decorators/attribute.js.map +1 -1
- package/dist/cjs/decorators/elementDefine.js +90 -52
- package/dist/cjs/decorators/elementDefine.js.map +2 -2
- package/dist/cjs/decorators/emitCustomEvent.js.map +1 -1
- package/dist/cjs/decorators/index.js +2 -0
- package/dist/cjs/decorators/index.js.map +2 -2
- package/dist/cjs/decorators/lifecycles.js +88 -24
- package/dist/cjs/decorators/lifecycles.js.map +3 -3
- package/dist/cjs/decorators/publishSwcAppMessage.js.map +2 -2
- package/dist/cjs/decorators/query.js +1 -1
- package/dist/cjs/decorators/query.js.map +2 -2
- package/dist/cjs/decorators/queryAll.js.map +1 -1
- package/dist/cjs/decorators/setProperty.js.map +1 -1
- package/dist/cjs/decorators/state.js +84 -0
- package/dist/cjs/decorators/state.js.map +7 -0
- package/dist/cjs/decorators/subscribeSwcAppMessageWhileConnected.js.map +1 -1
- package/dist/cjs/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +2 -2
- package/dist/cjs/elements/SwcApp.js +231 -0
- package/dist/cjs/elements/SwcApp.js.map +7 -0
- package/dist/cjs/elements/SwcAppMixin.js +78 -80
- package/dist/cjs/elements/SwcAppMixin.js.map +2 -2
- package/dist/cjs/elements/index.js +2 -1
- package/dist/cjs/elements/index.js.map +2 -2
- 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 +10 -8
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/{types.js → types/index.js} +1 -1
- package/dist/cjs/types/index.js.map +7 -0
- package/dist/cjs/types/window.d.js +16 -0
- package/dist/cjs/types/window.d.js.map +7 -0
- package/dist/cjs/utils/Utils.js +168 -26
- package/dist/cjs/utils/Utils.js.map +3 -3
- package/dist/esm/{elements/SwcAppEngine.js → SwcAppEngine.js} +7 -4
- package/dist/esm/SwcAppEngine.js.map +7 -0
- package/dist/esm/decorators/addEventListener.js +20 -4
- package/dist/esm/decorators/addEventListener.js.map +2 -2
- package/dist/esm/decorators/applyAttribute.js.map +1 -1
- package/dist/esm/decorators/applyClass.js.map +1 -1
- package/dist/esm/decorators/applyNode.js +109 -26
- package/dist/esm/decorators/applyNode.js.map +2 -2
- package/dist/esm/decorators/applySlot.js +110 -0
- package/dist/esm/decorators/applySlot.js.map +7 -0
- package/dist/esm/decorators/applyStyle.js.map +2 -2
- package/dist/esm/decorators/attribute.js.map +1 -1
- package/dist/esm/decorators/elementDefine.js +96 -58
- package/dist/esm/decorators/elementDefine.js.map +2 -2
- package/dist/esm/decorators/emitCustomEvent.js.map +1 -1
- package/dist/esm/decorators/index.js +2 -0
- package/dist/esm/decorators/index.js.map +2 -2
- package/dist/esm/decorators/lifecycles.js +88 -24
- package/dist/esm/decorators/lifecycles.js.map +3 -3
- package/dist/esm/decorators/publishSwcAppMessage.js.map +2 -2
- package/dist/esm/decorators/query.js +1 -1
- package/dist/esm/decorators/query.js.map +2 -2
- package/dist/esm/decorators/queryAll.js.map +1 -1
- package/dist/esm/decorators/setProperty.js.map +1 -1
- package/dist/esm/decorators/state.js +65 -0
- package/dist/esm/decorators/state.js.map +7 -0
- package/dist/esm/decorators/subscribeSwcAppMessageWhileConnected.js.map +1 -1
- package/dist/esm/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +2 -2
- package/dist/esm/elements/SwcApp.js +212 -0
- package/dist/esm/elements/SwcApp.js.map +7 -0
- package/dist/esm/elements/SwcAppMixin.js +76 -78
- package/dist/esm/elements/SwcAppMixin.js.map +2 -2
- package/dist/esm/elements/index.js +2 -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 +11 -9
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/{types.js → types/index.js} +1 -1
- package/dist/esm/types/index.js.map +7 -0
- package/dist/esm/types/window.d.js +1 -0
- package/dist/esm/types/window.d.js.map +7 -0
- package/dist/esm/utils/Utils.js +168 -26
- package/dist/esm/utils/Utils.js.map +3 -3
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +7477 -2828
- 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 -2
- package/dist/types/decorators/addEventListener.d.ts.map +1 -1
- package/dist/types/decorators/applyAttribute.d.ts.map +1 -1
- package/dist/types/decorators/applyClass.d.ts.map +1 -1
- package/dist/types/decorators/applyNode.d.ts +24 -8
- 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.map +1 -1
- package/dist/types/decorators/attribute.d.ts.map +1 -1
- package/dist/types/decorators/elementDefine.d.ts.map +1 -1
- package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
- package/dist/types/decorators/index.d.ts +2 -0
- package/dist/types/decorators/index.d.ts.map +1 -1
- package/dist/types/decorators/lifecycles.d.ts +26 -15
- package/dist/types/decorators/lifecycles.d.ts.map +1 -1
- package/dist/types/decorators/publishSwcAppMessage.d.ts.map +1 -1
- package/dist/types/decorators/query.d.ts +1 -1
- package/dist/types/decorators/query.d.ts.map +1 -1
- 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/decorators/state.d.ts +9 -0
- package/dist/types/decorators/state.d.ts.map +1 -0
- package/dist/types/decorators/subscribeSwcAppMessageWhileConnected.d.ts.map +1 -1
- package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts +5 -1
- package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts.map +1 -1
- package/dist/types/elements/SwcApp.d.ts +36 -0
- package/dist/types/elements/SwcApp.d.ts.map +1 -0
- package/dist/types/elements/SwcAppMixin.d.ts +26 -7
- package/dist/types/elements/SwcAppMixin.d.ts.map +1 -1
- 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 → types/index.d.ts} +12 -12
- package/dist/types/types/index.d.ts.map +1 -0
- package/dist/types/utils/Utils.d.ts +18 -5
- package/dist/types/utils/Utils.d.ts.map +1 -1
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +7478 -2829
- 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} +17 -8
- package/src/decorators/addEventListener.ts +21 -5
- package/src/decorators/applyAttribute.ts +1 -1
- package/src/decorators/applyClass.ts +1 -1
- package/src/decorators/applyNode.ts +186 -66
- package/src/decorators/applySlot.ts +188 -0
- package/src/decorators/applyStyle.ts +4 -4
- package/src/decorators/attribute.ts +1 -1
- package/src/decorators/elementDefine.ts +142 -68
- package/src/decorators/emitCustomEvent.ts +1 -1
- package/src/decorators/index.ts +3 -0
- package/src/decorators/lifecycles.ts +119 -30
- package/src/decorators/publishSwcAppMessage.ts +2 -3
- package/src/decorators/query.ts +4 -4
- package/src/decorators/queryAll.ts +1 -1
- package/src/decorators/setProperty.ts +1 -1
- package/src/decorators/state.ts +84 -0
- package/src/decorators/subscribeSwcAppMessageWhileConnected.ts +1 -1
- package/src/decorators/subscribeSwcAppRouteChangeWhileConnected.ts +4 -3
- package/src/elements/SwcApp.ts +241 -0
- package/src/elements/SwcAppMixin.ts +98 -146
- package/src/elements/index.ts +4 -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 +11 -9
- package/src/{types.ts → types/index.ts} +15 -11
- package/src/types/window.d.ts +46 -0
- package/src/utils/Utils.ts +214 -24
- package/dist/cjs/elements/SwcAppEngine.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/cjs/types.js.map +0 -7
- package/dist/esm/elements/SwcAppEngine.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/esm/types.js.map +0 -7
- package/dist/types/elements/SwcAppEngine.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/dist/types/types.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,17 +1,33 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {debounceTimeIntervalLock, FunctionUtils, Subscription} from
|
|
5
|
-
import {RouterEventType} from
|
|
6
|
-
import {
|
|
7
|
-
|
|
1
|
+
import {SwcAppInterface, SwcAppMessage} from "../types";
|
|
2
|
+
import {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
|
+
}
|
|
8
17
|
|
|
18
|
+
/**
|
|
19
|
+
* SwcAppMixin: SwcApp 기능을 모든 HTMLElement에 추가할 수 있는 Mixin
|
|
20
|
+
*
|
|
21
|
+
* 사용 예:
|
|
22
|
+
* @elementDefine('custom-app', { window: w })
|
|
23
|
+
* class CustomApp extends SwcAppMixin(w.HTMLElement) implements SwcAppInterface {
|
|
24
|
+
* // 추가 기능 구현
|
|
25
|
+
* }
|
|
26
|
+
*/
|
|
9
27
|
export function SwcAppMixin<T extends { new(...args: any[]): HTMLElement }>(Base: T) {
|
|
10
|
-
|
|
11
|
-
return class extends Base implements SwcAppInterface {
|
|
28
|
+
return class SwcAppMixinClass extends Base implements SwcAppInterface {
|
|
12
29
|
__swc_engine = new SwcAppEngine(this as any);
|
|
13
30
|
_swc_connected_instance = new Set<any>();
|
|
14
|
-
// _swc_notified_routes = new WeakMap<any, RouterEventType>();
|
|
15
31
|
_routerSubscription?: Subscription;
|
|
16
32
|
_lastRouterEvent?: RouterEventType;
|
|
17
33
|
_routeChangeInvocations = 0;
|
|
@@ -20,13 +36,17 @@ export function SwcAppMixin<T extends { new(...args: any[]): HTMLElement }>(Base
|
|
|
20
36
|
_childrenRouteChangedInterval: any;
|
|
21
37
|
_childrenConnectedDoneInterval: any;
|
|
22
38
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
저 polyfill에서는 자식부터 만들어지고 부모가 만들어진다 is일때 아 .. 이문제때문에 자식이 _connected_safari 에 강제로 자기자식넣어준다
|
|
39
|
+
/**
|
|
40
|
+
* Safari is 속성 처리
|
|
41
|
+
* Safari polyfill에서는 자식부터 만들어지고 부모가 만들어지므로
|
|
42
|
+
* 부모가 자식들을 강제로 등록해주는 형태로 처리
|
|
28
43
|
*/
|
|
29
|
-
|
|
44
|
+
_connected_safari_and_standby = [];
|
|
45
|
+
|
|
46
|
+
constructor(...args: any[]) {
|
|
47
|
+
super(...args);
|
|
48
|
+
console.log('[SWC-APP-MIXIN] constructor')
|
|
49
|
+
}
|
|
30
50
|
|
|
31
51
|
get simpleApplication() {
|
|
32
52
|
return this.__swc_engine.simpleApplication;
|
|
@@ -40,46 +60,29 @@ export function SwcAppMixin<T extends { new(...args: any[]): HTMLElement }>(Base
|
|
|
40
60
|
return this.__swc_engine?.router;
|
|
41
61
|
}
|
|
42
62
|
|
|
43
|
-
async _invokeRouteChangeSubscribers(instance:
|
|
63
|
+
async _invokeRouteChangeSubscribers(instance: HTMLElement, re: RouterEventType) {
|
|
44
64
|
if (instance.isConnected === false) return;
|
|
45
65
|
|
|
46
66
|
this._routeChangeInvocations++;
|
|
47
67
|
|
|
48
68
|
if (this._childrenRouteChangedInterval) {
|
|
49
|
-
clearInterval(this._childrenRouteChangedInterval);
|
|
69
|
+
this.config.window.clearInterval(this._childrenRouteChangedInterval);
|
|
50
70
|
}
|
|
71
|
+
const intervalConfig = {setInterval: this.config.window.setInterval.bind(this.config.window), clearInterval: this.config.window.clearInterval.bind(this.config.window)};
|
|
51
72
|
this._childrenRouteChangedInterval = debounceTimeIntervalLock(
|
|
52
73
|
() => this._routeChangeInvocations === 0,
|
|
53
74
|
() => {
|
|
54
75
|
this._childrenRouteChangedInterval = null;
|
|
55
|
-
this.config.onChildrenRouteChanged(re, this)
|
|
76
|
+
this.config.onChildrenRouteChanged?.(re, this)
|
|
56
77
|
},
|
|
57
78
|
this.config?.childrenConnectedDoneCheckIntervalTime ?? 30,
|
|
58
|
-
|
|
59
|
-
// {setInterval: window.setInterval, clearInterval: window.clearInterval}
|
|
79
|
+
intervalConfig
|
|
60
80
|
);
|
|
61
81
|
|
|
62
|
-
|
|
63
|
-
// debounceTimeIntervalLock({
|
|
64
|
-
// unlockChecker: () => this._routeChangeInvocations === 0,
|
|
65
|
-
// unlocked: () => this.config.onChildrenRouteChanged(re, this)
|
|
66
|
-
// }, {
|
|
67
|
-
// intervalId: this._childrenRouteChangedInterval,
|
|
68
|
-
// setIntervalId: (id) => this._childrenRouteChangedInterval = id,
|
|
69
|
-
// intervalTime: this.config?.childrenRouteChangedCheckIntervalTime ?? 30
|
|
70
|
-
// }, {
|
|
71
|
-
// setInterval: window.setInterval,
|
|
72
|
-
// clearInterval: window.clearInterval
|
|
73
|
-
// });
|
|
74
|
-
|
|
75
82
|
try {
|
|
76
|
-
// if (this._swc_notified_routes.get(instance) === re) {
|
|
77
|
-
// return;
|
|
78
|
-
// }
|
|
79
|
-
// this._swc_notified_routes.set(instance, re);
|
|
80
|
-
|
|
81
83
|
const routeChangeSubscribers = getSubscribeSwcAppRouteChangeWhileConnectedMetadata(instance);
|
|
82
84
|
if (routeChangeSubscribers && Array.isArray(routeChangeSubscribers)) {
|
|
85
|
+
console.log('[SWC-MIXIN] Route change subscribers found')
|
|
83
86
|
const ps = routeChangeSubscribers.map(async metadata => {
|
|
84
87
|
const methodName = metadata.propertyKey;
|
|
85
88
|
let pathPattern = metadata.options?.path as any;
|
|
@@ -109,7 +112,8 @@ export function SwcAppMixin<T extends { new(...args: any[]): HTMLElement }>(Base
|
|
|
109
112
|
pathMatched = pathData !== null;
|
|
110
113
|
}
|
|
111
114
|
|
|
112
|
-
const
|
|
115
|
+
const hostSet = SwcUtils.getHelperAndHostSet(this.config.window, this);
|
|
116
|
+
const filterPassed = !filter || filter(this.router!, {helper:hostSet, currentThis:instance});
|
|
113
117
|
|
|
114
118
|
if (pathMatched && filterPassed && instance[methodName]) {
|
|
115
119
|
await instance[methodName]({...re, pathData: pathData});
|
|
@@ -118,33 +122,49 @@ export function SwcAppMixin<T extends { new(...args: any[]): HTMLElement }>(Base
|
|
|
118
122
|
await Promise.allSettled(ps);
|
|
119
123
|
}
|
|
120
124
|
} finally {
|
|
121
|
-
this.
|
|
125
|
+
if (this.config?.ssr) {
|
|
126
|
+
setSSRAttribute(instance);
|
|
127
|
+
} else {
|
|
128
|
+
removeSSRAttribute(instance);
|
|
129
|
+
}
|
|
130
|
+
this._routeChangeInvocations = Math.max(0, this._routeChangeInvocations - 1);
|
|
122
131
|
}
|
|
123
132
|
}
|
|
124
133
|
|
|
125
|
-
async _connected(instance:
|
|
134
|
+
async _connected(instance: HTMLElement, option?: { noIncrements: boolean }) {
|
|
126
135
|
if (instance) {
|
|
127
|
-
this.
|
|
136
|
+
if (!this.simpleApplication && !this.config) {
|
|
137
|
+
this._connected_safari_and_standby.push(instance);
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
this.config.onConnectedChildBefore?.(instance);
|
|
142
|
+
if (!option?.noIncrements) {
|
|
143
|
+
this._connectedInvocations++;
|
|
144
|
+
}
|
|
128
145
|
this._swc_connected_instance.add(instance);
|
|
129
146
|
|
|
147
|
+
const connectedSwcAppCallBacks = findAllLifecycleMetadata(instance, ON_CONNECTED_SWC_APP_METADATA_KEY) ?? [];
|
|
148
|
+
for (let connectedSwcAppCallBack of connectedSwcAppCallBacks) {
|
|
149
|
+
await (instance as any)?._invokeLifecycleMethod?.(connectedSwcAppCallBack);
|
|
150
|
+
}
|
|
151
|
+
|
|
130
152
|
if (this._childrenConnectedDoneInterval) {
|
|
131
|
-
clearInterval(this._childrenConnectedDoneInterval);
|
|
153
|
+
this.config.window.clearInterval(this._childrenConnectedDoneInterval);
|
|
132
154
|
}
|
|
155
|
+
const intervalConfig = {setInterval: this.config.window.setInterval.bind(this.config.window), clearInterval: this.config.window.clearInterval.bind(this.config.window)};
|
|
133
156
|
this._childrenConnectedDoneInterval = debounceTimeIntervalLock(
|
|
134
157
|
() => this._connectedInvocations === 0,
|
|
135
158
|
() => {
|
|
136
159
|
this._childrenConnectedDoneInterval = null;
|
|
137
|
-
this.config.onChildrenConnectedDone(this)
|
|
160
|
+
this.config.onChildrenConnectedDone?.(this)
|
|
138
161
|
},
|
|
139
162
|
this.config?.childrenConnectedDoneCheckIntervalTime ?? 30,
|
|
140
|
-
|
|
163
|
+
intervalConfig
|
|
141
164
|
);
|
|
142
165
|
|
|
143
|
-
|
|
144
166
|
if (this.simpleApplication) {
|
|
145
167
|
try {
|
|
146
|
-
// await this._invokeOnConnectedSwcAppStarted(instance);
|
|
147
|
-
|
|
148
168
|
if (this.router && this._lastRouterEvent) {
|
|
149
169
|
await this._invokeRouteChangeSubscribers(instance, this._lastRouterEvent!);
|
|
150
170
|
}
|
|
@@ -152,149 +172,81 @@ export function SwcAppMixin<T extends { new(...args: any[]): HTMLElement }>(Base
|
|
|
152
172
|
throw e;
|
|
153
173
|
}
|
|
154
174
|
}
|
|
175
|
+
|
|
176
|
+
if (this.config?.ssr) {
|
|
177
|
+
setSSRAttribute(instance);
|
|
178
|
+
} else {
|
|
179
|
+
removeSSRAttribute(instance);
|
|
180
|
+
}
|
|
155
181
|
}
|
|
182
|
+
|
|
183
|
+
this.config.onConnectedChildAfter?.(instance);
|
|
184
|
+
return this;
|
|
156
185
|
}
|
|
157
186
|
|
|
158
187
|
async _connectedDone(instance: any) {
|
|
159
188
|
try {
|
|
160
|
-
// 내부 연결 처리
|
|
189
|
+
// 내부 연결 처리 로직
|
|
161
190
|
} finally {
|
|
162
|
-
this._connectedInvocations
|
|
191
|
+
this._connectedInvocations = Math.max(0, this._connectedInvocations - 1);
|
|
163
192
|
}
|
|
164
193
|
}
|
|
165
194
|
|
|
166
195
|
_disconnected(instance: any) {
|
|
167
|
-
// console.log('_disconnected', instance);
|
|
168
196
|
if (instance) {
|
|
169
197
|
this._swc_connected_instance.delete(instance);
|
|
170
|
-
|
|
198
|
+
this.config?.onDisconnectedChildAfter?.(instance);
|
|
171
199
|
}
|
|
172
200
|
}
|
|
173
201
|
|
|
174
202
|
async _handleRouteChange(route: RouterEventType) {
|
|
175
|
-
// Save last router event
|
|
176
203
|
this._lastRouterEvent = route;
|
|
177
|
-
// if (route.triggerPoint === 'end') {
|
|
178
|
-
// Iterate through all connected component instances
|
|
179
204
|
const swcConnectedInstance = Array.from(this._swc_connected_instance);
|
|
180
|
-
// console.log('routing handle-->', swcConnectedInstance)
|
|
181
205
|
const ps = swcConnectedInstance.map((instance: any) => this._invokeRouteChangeSubscribers(instance, route));
|
|
182
206
|
await Promise.allSettled(ps);
|
|
183
|
-
// }
|
|
184
207
|
}
|
|
185
208
|
|
|
186
209
|
async connect(config?: SwcAttributeConfigType) {
|
|
210
|
+
console.log('[SWC-MIXIN] connect')
|
|
187
211
|
const swcConfig = {
|
|
188
212
|
routeType: 'element',
|
|
189
213
|
window: config?.window,
|
|
190
214
|
...config
|
|
191
215
|
} as SwcConfigType;
|
|
192
216
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
if (mode === 'direct') {
|
|
196
|
-
await this.__swc_engine.connect(swcConfig);
|
|
197
|
-
this.setAttribute('swc-connect-mode', 'direct');
|
|
198
|
-
} else if (mode === 'swap' || mode === 'clear-swap') {
|
|
199
|
-
if (!this.parentNode) {
|
|
200
|
-
// 부모가 없으면 swap을 할 수 없으므로 direct로 폴백합니다.
|
|
201
|
-
await this.__swc_engine.connect(swcConfig);
|
|
202
|
-
this.setAttribute('swc-connect-mode', 'direct');
|
|
203
|
-
} else {
|
|
204
|
-
// 1. 현재 SSR 상태(화면)를 그대로 유지한 채로, 백그라운드용 클론을 만듭니다.
|
|
205
|
-
const clonedApp = this.cloneNode(mode === 'swap') as any; // clear-swap 모드면 자식 노드를 클론하지 않음(false)
|
|
206
|
-
clonedApp.style.display = 'none';
|
|
207
|
-
|
|
208
|
-
// 2. DOM에 클론을 몰래 붙입니다.
|
|
209
|
-
this.parentNode.insertBefore(clonedApp, this.nextSibling);
|
|
210
|
-
|
|
211
|
-
try {
|
|
212
|
-
// 3. 클론을 direct 모드로 연결(초기화/렌더링) 시킵니다.
|
|
213
|
-
await clonedApp.connect({...(config || {}), connectMode: 'direct'});
|
|
214
|
-
|
|
215
|
-
// 4. 클론의 렌더링이 완전히 끝나면, 기존 SSR 화면(this)을 지우고 클론을 보여줍니다.
|
|
216
|
-
if (this.parentNode) {
|
|
217
|
-
this.parentNode.removeChild(this);
|
|
218
|
-
}
|
|
219
|
-
clonedApp.style.display = '';
|
|
220
|
-
clonedApp.setAttribute('swc-connect-mode', mode);
|
|
221
|
-
|
|
222
|
-
// ★ 매우 중요: 교체가 완료되었으므로 기존 앱(this)은 여기서 즉시 종료하여 불필요한 라우터/이벤트 구독을 막아야 합니다!
|
|
223
|
-
return;
|
|
224
|
-
} catch (e) {
|
|
225
|
-
// 실패 시 클론을 지우고 원본을 direct로 강제 연결합니다.
|
|
226
|
-
if (clonedApp.parentNode) {
|
|
227
|
-
clonedApp.parentNode.removeChild(clonedApp);
|
|
228
|
-
}
|
|
229
|
-
await this.__swc_engine.connect(swcConfig);
|
|
230
|
-
this.setAttribute('swc-connect-mode', 'direct');
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
}
|
|
217
|
+
await this.__swc_engine.connect(swcConfig);
|
|
234
218
|
|
|
235
|
-
//
|
|
236
|
-
this.
|
|
237
|
-
|
|
238
|
-
this._connected(instance);
|
|
239
|
-
// this._swc_connected_instance.add(instance);
|
|
219
|
+
// Safari is 속성 처리
|
|
220
|
+
this._connected_safari_and_standby.forEach((instance: any) => {
|
|
221
|
+
this._connected(instance, {noIncrements: true});
|
|
240
222
|
});
|
|
241
|
-
// Invoke @onConnectedSwcApp lifecycle methods on all connected component instances
|
|
242
|
-
// const hostSet = SwcUtils.getHostSet(this as any);
|
|
243
|
-
|
|
244
|
-
// const scis = Array.from(this._swc_connected_instance);
|
|
245
|
-
// await Promise.allSettled(scis.map(instance => this._invokeOnConnectedSwcAppStarted(instance)));
|
|
246
223
|
|
|
247
|
-
//
|
|
248
|
-
// this._invokeOnConnectedSwcAppStarted(instance);
|
|
249
|
-
// });
|
|
250
|
-
|
|
251
|
-
// Subscribe to router changes after connect
|
|
224
|
+
// 라우터 변경 구독
|
|
252
225
|
if (!this._routerSubscription && this.router) {
|
|
253
226
|
const config = this.__swc_engine.config;
|
|
254
227
|
|
|
255
228
|
this._routerSubscription = this.router.observable.subscribe(async (route: RouterEventType) => {
|
|
256
|
-
|
|
229
|
+
console.log('[SWC-MIXIN] Router event received:', route.triggerPoint);
|
|
257
230
|
if (route.triggerPoint === 'end') {
|
|
258
|
-
// 1. 모든 기존 연결된 자식들에게 라우트 이벤트 알림
|
|
259
231
|
await this._handleRouteChange(route);
|
|
260
232
|
}
|
|
261
233
|
});
|
|
262
234
|
|
|
263
|
-
// Navigate to initial path if specified
|
|
264
235
|
if (config?.path) {
|
|
265
|
-
|
|
266
|
-
this.router.go(config.path);
|
|
236
|
+
console.log('[DEBUG] Navigating to initial path:', config.path);
|
|
267
237
|
}
|
|
268
238
|
}
|
|
269
239
|
}
|
|
270
240
|
|
|
271
|
-
// async _invokeOnConnectedSwcAppStarted(instance: any) {
|
|
272
|
-
// this._swcAppStartedInvocations++;
|
|
273
|
-
// try {
|
|
274
|
-
// // 이미 시작된 인스턴스라면 스킵 (비동기 병렬 중복 호출 방지)
|
|
275
|
-
// if (this._swc_started_instances.has(instance)) return;
|
|
276
|
-
// this._swc_started_instances.add(instance);
|
|
277
|
-
//
|
|
278
|
-
// const startedMethods = findAllLifecycleMetadata(instance, ON_CONNECTED_SWC_APP_METADATA_KEY);
|
|
279
|
-
// if (startedMethods) {
|
|
280
|
-
// const ps = startedMethods.map(m => instance._invokeLifecycleMethod(m));
|
|
281
|
-
// await Promise.allSettled(ps);
|
|
282
|
-
// }
|
|
283
|
-
// } finally {
|
|
284
|
-
// this._swcAppStartedInvocations--;
|
|
285
|
-
// }
|
|
286
|
-
// }
|
|
287
|
-
|
|
288
241
|
connectedCallback() {
|
|
289
|
-
//
|
|
242
|
+
// 부모 클래스의 connectedCallback 호출
|
|
290
243
|
// @ts-ignore
|
|
291
|
-
|
|
244
|
+
super.connectedCallback?.();
|
|
292
245
|
|
|
293
246
|
const configStr = this.getAttribute('swc-get-application-config');
|
|
294
247
|
const win = this.ownerDocument?.defaultView || window;
|
|
295
248
|
if (configStr && win) {
|
|
296
249
|
try {
|
|
297
|
-
// console.log('vvvvvvvvvvvvvvvv->>>>', SwcUtils.findNearestSwcHost(this.host), SwcUtils.getHostSet(this.host))
|
|
298
250
|
const userConfig = FunctionUtils.executeReturn({
|
|
299
251
|
script: configStr,
|
|
300
252
|
context: this,
|
|
@@ -302,21 +254,26 @@ export function SwcAppMixin<T extends { new(...args: any[]): HTMLElement }>(Base
|
|
|
302
254
|
});
|
|
303
255
|
this.connect(userConfig);
|
|
304
256
|
} catch (e) {
|
|
305
|
-
console.error('[SWC-
|
|
257
|
+
console.error('[SWC-MIXIN] Script execution failed:', e);
|
|
306
258
|
}
|
|
307
259
|
}
|
|
308
260
|
|
|
261
|
+
this._connected(this);
|
|
309
262
|
this.__swc_engine?.config?.onConnected?.(this);
|
|
263
|
+
this._connectedDone(this);
|
|
310
264
|
}
|
|
311
265
|
|
|
312
266
|
disconnectedCallback() {
|
|
267
|
+
// 부모 클래스의 disconnectedCallback 호출
|
|
313
268
|
// @ts-ignore
|
|
314
|
-
|
|
269
|
+
super.disconnectedCallback?.();
|
|
270
|
+
|
|
315
271
|
this._routerSubscription?.unsubscribe();
|
|
316
272
|
this._routerSubscription = undefined;
|
|
317
273
|
this._lastRouterEvent = undefined;
|
|
318
274
|
this.__swc_engine.disconnect();
|
|
319
275
|
this.__swc_engine?.config?.onDisconnected?.(this);
|
|
276
|
+
this._disconnected(this);
|
|
320
277
|
}
|
|
321
278
|
|
|
322
279
|
async routing(path: string) {
|
|
@@ -336,7 +293,6 @@ export function SwcAppMixin<T extends { new(...args: any[]): HTMLElement }>(Base
|
|
|
336
293
|
}
|
|
337
294
|
|
|
338
295
|
publishMessage(message: SwcAppMessage): void {
|
|
339
|
-
// 메시지를 모든 connected component instances로 분배
|
|
340
296
|
this._swc_connected_instance.forEach((instance: any) => {
|
|
341
297
|
this._invokeMessageSubscribers(instance, message);
|
|
342
298
|
});
|
|
@@ -350,22 +306,18 @@ export function SwcAppMixin<T extends { new(...args: any[]): HTMLElement }>(Base
|
|
|
350
306
|
const messageType = metadata.messageType;
|
|
351
307
|
const filter = metadata.filter;
|
|
352
308
|
|
|
353
|
-
// 메시지 타입 확인
|
|
354
309
|
let typeMatched = false;
|
|
355
310
|
if (!messageType) {
|
|
356
|
-
// messageType이 없으면 모든 메시지 매칭 (와일드카드)
|
|
357
311
|
typeMatched = true;
|
|
358
312
|
} else if (message.type === messageType) {
|
|
359
313
|
typeMatched = true;
|
|
360
314
|
}
|
|
361
315
|
|
|
362
|
-
// 필터 적용
|
|
363
316
|
let filterMatched = true;
|
|
364
317
|
if (filter && typeMatched) {
|
|
365
318
|
filterMatched = filter(message, instance);
|
|
366
319
|
}
|
|
367
320
|
|
|
368
|
-
// 조건을 만족하면 메서드 호출
|
|
369
321
|
if (typeMatched && filterMatched && typeof instance[methodName] === 'function') {
|
|
370
322
|
instance[methodName](message);
|
|
371
323
|
}
|
package/src/elements/index.ts
CHANGED
|
@@ -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
|
+
// }
|