@dooboostore/simple-web-component 1.0.49 → 1.0.51
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 +790 -337
- package/dist/cjs/SwcAppEngine.js.map +2 -2
- package/dist/cjs/decorators/addEventListener.js +1925 -22
- package/dist/cjs/decorators/addEventListener.js.map +2 -2
- package/dist/cjs/decorators/applyAttribute.js +41 -47
- package/dist/cjs/decorators/applyAttribute.js.map +2 -2
- package/dist/cjs/decorators/applyClass.js +14 -11
- package/dist/cjs/decorators/applyClass.js.map +2 -2
- package/dist/cjs/decorators/applyNode.js +19 -21
- package/dist/cjs/decorators/applyNode.js.map +2 -2
- package/dist/cjs/decorators/applyProperty.js +24 -48
- package/dist/cjs/decorators/applyProperty.js.map +2 -2
- package/dist/cjs/decorators/applySlot.js +9 -8
- package/dist/cjs/decorators/applySlot.js.map +2 -2
- package/dist/cjs/decorators/applyStyle.js +14 -11
- package/dist/cjs/decorators/applyStyle.js.map +2 -2
- package/dist/cjs/decorators/around.js +124 -0
- package/dist/cjs/decorators/around.js.map +7 -0
- package/dist/cjs/decorators/changedAttribute.js +61 -24
- package/dist/cjs/decorators/changedAttribute.js.map +2 -2
- package/dist/cjs/decorators/elementDefine.js +240 -196
- package/dist/cjs/decorators/elementDefine.js.map +3 -3
- package/dist/cjs/decorators/emitCustomEvent.js +14 -12
- package/dist/cjs/decorators/emitCustomEvent.js.map +2 -2
- package/dist/cjs/decorators/eventMedia.js +112 -0
- package/dist/cjs/decorators/eventMedia.js.map +7 -0
- package/dist/cjs/decorators/fetch.js +278 -0
- package/dist/cjs/decorators/fetch.js.map +7 -0
- package/dist/cjs/decorators/index.js +8 -2
- package/dist/cjs/decorators/index.js.map +2 -2
- package/dist/cjs/decorators/intersectionObserver.js +76 -65
- package/dist/cjs/decorators/intersectionObserver.js.map +2 -2
- package/dist/cjs/decorators/lifecycles.js +11 -11
- package/dist/cjs/decorators/lifecycles.js.map +2 -2
- package/dist/cjs/decorators/mutationObserver.js +97 -90
- package/dist/cjs/decorators/mutationObserver.js.map +3 -3
- package/dist/cjs/decorators/parameter.js +156 -0
- package/dist/cjs/decorators/parameter.js.map +7 -0
- package/dist/cjs/decorators/publishSwcAppMessage.js +2 -2
- package/dist/cjs/decorators/publishSwcAppMessage.js.map +2 -2
- package/dist/cjs/decorators/query.js +11 -5
- package/dist/cjs/decorators/query.js.map +2 -2
- package/dist/cjs/decorators/requestAnimationFrame.js +115 -0
- package/dist/cjs/decorators/requestAnimationFrame.js.map +7 -0
- package/dist/cjs/decorators/resizeObserver.js +84 -69
- package/dist/cjs/decorators/resizeObserver.js.map +3 -3
- package/dist/cjs/decorators/setInterval.js +65 -22
- package/dist/cjs/decorators/setInterval.js.map +2 -2
- package/dist/cjs/decorators/setTimeout.js +68 -22
- package/dist/cjs/decorators/setTimeout.js.map +2 -2
- package/dist/cjs/decorators/state.js +13 -10
- package/dist/cjs/decorators/state.js.map +2 -2
- package/dist/cjs/decorators/{subscribeSwcAppMessageWhileConnected.js → subscribeSwcAppMessage.js} +20 -21
- package/dist/cjs/decorators/subscribeSwcAppMessage.js.map +7 -0
- package/dist/cjs/decorators/{subscribeSwcAppRouteChangeWhileConnected.js → subscribeSwcAppRouteChange.js} +23 -19
- package/dist/cjs/decorators/subscribeSwcAppRouteChange.js.map +7 -0
- package/dist/cjs/decorators/swcAppRoute.js +149 -0
- package/dist/cjs/decorators/swcAppRoute.js.map +7 -0
- package/dist/cjs/elements/SwcApp.js +70 -0
- package/dist/cjs/elements/SwcApp.js.map +2 -2
- package/dist/cjs/elements/SwcAppMixin.js +256 -67
- package/dist/cjs/elements/SwcAppMixin.js.map +3 -3
- package/dist/cjs/types/index.js +5 -1
- package/dist/cjs/types/index.js.map +2 -2
- package/dist/cjs/types/window.d.js.map +1 -1
- package/dist/cjs/utils/Utils.js +36 -15
- package/dist/cjs/utils/Utils.js.map +2 -2
- package/dist/esm/SwcAppEngine.js.map +2 -2
- package/dist/esm/decorators/addEventListener.js +1925 -22
- package/dist/esm/decorators/addEventListener.js.map +2 -2
- package/dist/esm/decorators/applyAttribute.js +41 -47
- package/dist/esm/decorators/applyAttribute.js.map +2 -2
- package/dist/esm/decorators/applyClass.js +14 -11
- package/dist/esm/decorators/applyClass.js.map +2 -2
- package/dist/esm/decorators/applyNode.js +20 -22
- package/dist/esm/decorators/applyNode.js.map +2 -2
- package/dist/esm/decorators/applyProperty.js +24 -48
- package/dist/esm/decorators/applyProperty.js.map +2 -2
- package/dist/esm/decorators/applySlot.js +9 -8
- package/dist/esm/decorators/applySlot.js.map +2 -2
- package/dist/esm/decorators/applyStyle.js +14 -11
- package/dist/esm/decorators/applyStyle.js.map +2 -2
- package/dist/esm/decorators/around.js +105 -0
- package/dist/esm/decorators/around.js.map +7 -0
- package/dist/esm/decorators/changedAttribute.js +61 -24
- package/dist/esm/decorators/changedAttribute.js.map +2 -2
- package/dist/esm/decorators/elementDefine.js +238 -194
- package/dist/esm/decorators/elementDefine.js.map +3 -3
- package/dist/esm/decorators/emitCustomEvent.js +15 -13
- package/dist/esm/decorators/emitCustomEvent.js.map +2 -2
- package/dist/esm/decorators/eventMedia.js +94 -0
- package/dist/esm/decorators/eventMedia.js.map +7 -0
- package/dist/esm/decorators/fetch.js +259 -0
- package/dist/esm/decorators/fetch.js.map +7 -0
- package/dist/esm/decorators/index.js +8 -2
- package/dist/esm/decorators/index.js.map +2 -2
- package/dist/esm/decorators/intersectionObserver.js +76 -65
- package/dist/esm/decorators/intersectionObserver.js.map +2 -2
- package/dist/esm/decorators/lifecycles.js +11 -11
- package/dist/esm/decorators/lifecycles.js.map +2 -2
- package/dist/esm/decorators/mutationObserver.js +97 -90
- package/dist/esm/decorators/mutationObserver.js.map +3 -3
- package/dist/esm/decorators/parameter.js +137 -0
- package/dist/esm/decorators/parameter.js.map +7 -0
- package/dist/esm/decorators/publishSwcAppMessage.js +2 -2
- package/dist/esm/decorators/publishSwcAppMessage.js.map +2 -2
- package/dist/esm/decorators/query.js +11 -5
- package/dist/esm/decorators/query.js.map +2 -2
- package/dist/esm/decorators/requestAnimationFrame.js +96 -0
- package/dist/esm/decorators/requestAnimationFrame.js.map +7 -0
- package/dist/esm/decorators/resizeObserver.js +84 -69
- package/dist/esm/decorators/resizeObserver.js.map +2 -2
- package/dist/esm/decorators/setInterval.js +65 -23
- package/dist/esm/decorators/setInterval.js.map +2 -2
- package/dist/esm/decorators/setTimeout.js +68 -23
- package/dist/esm/decorators/setTimeout.js.map +2 -2
- package/dist/esm/decorators/state.js +13 -10
- package/dist/esm/decorators/state.js.map +2 -2
- package/dist/esm/decorators/subscribeSwcAppMessage.js +53 -0
- package/dist/esm/decorators/subscribeSwcAppMessage.js.map +7 -0
- package/dist/esm/decorators/{subscribeSwcAppRouteChangeWhileConnected.js → subscribeSwcAppRouteChange.js} +20 -16
- package/dist/esm/decorators/subscribeSwcAppRouteChange.js.map +7 -0
- package/dist/esm/decorators/swcAppRoute.js +130 -0
- package/dist/esm/decorators/swcAppRoute.js.map +7 -0
- package/dist/esm/elements/SwcApp.js +70 -0
- package/dist/esm/elements/SwcApp.js.map +2 -2
- package/dist/esm/elements/SwcAppMixin.js +258 -69
- package/dist/esm/elements/SwcAppMixin.js.map +3 -3
- package/dist/esm/types/index.js +5 -1
- package/dist/esm/types/index.js.map +2 -2
- package/dist/esm/utils/Utils.js +36 -15
- package/dist/esm/utils/Utils.js.map +2 -2
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +4395 -1266
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
- package/dist/types/SwcAppEngine.d.ts +1 -0
- package/dist/types/SwcAppEngine.d.ts.map +1 -1
- package/dist/types/decorators/addEventListener.d.ts +936 -11
- package/dist/types/decorators/addEventListener.d.ts.map +1 -1
- package/dist/types/decorators/applyAttribute.d.ts +27 -37
- package/dist/types/decorators/applyAttribute.d.ts.map +1 -1
- package/dist/types/decorators/applyClass.d.ts +2 -2
- package/dist/types/decorators/applyClass.d.ts.map +1 -1
- package/dist/types/decorators/applyNode.d.ts +16 -16
- package/dist/types/decorators/applyNode.d.ts.map +1 -1
- package/dist/types/decorators/applyProperty.d.ts +28 -44
- package/dist/types/decorators/applyProperty.d.ts.map +1 -1
- package/dist/types/decorators/applySlot.d.ts.map +1 -1
- package/dist/types/decorators/applyStyle.d.ts +2 -2
- package/dist/types/decorators/applyStyle.d.ts.map +1 -1
- package/dist/types/decorators/around.d.ts +87 -0
- package/dist/types/decorators/around.d.ts.map +1 -0
- package/dist/types/decorators/changedAttribute.d.ts +22 -4
- package/dist/types/decorators/changedAttribute.d.ts.map +1 -1
- package/dist/types/decorators/elementDefine.d.ts.map +1 -1
- package/dist/types/decorators/emitCustomEvent.d.ts +0 -1
- package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
- package/dist/types/decorators/eventMedia.d.ts +48 -0
- package/dist/types/decorators/eventMedia.d.ts.map +1 -0
- package/dist/types/decorators/fetch.d.ts +139 -0
- package/dist/types/decorators/fetch.d.ts.map +1 -0
- package/dist/types/decorators/index.d.ts +8 -2
- package/dist/types/decorators/index.d.ts.map +1 -1
- package/dist/types/decorators/intersectionObserver.d.ts +32 -10
- package/dist/types/decorators/intersectionObserver.d.ts.map +1 -1
- package/dist/types/decorators/lifecycles.d.ts +8 -7
- package/dist/types/decorators/lifecycles.d.ts.map +1 -1
- package/dist/types/decorators/mutationObserver.d.ts +34 -12
- package/dist/types/decorators/mutationObserver.d.ts.map +1 -1
- package/dist/types/decorators/parameter.d.ts +113 -0
- package/dist/types/decorators/parameter.d.ts.map +1 -0
- package/dist/types/decorators/publishSwcAppMessage.d.ts +0 -1
- package/dist/types/decorators/publishSwcAppMessage.d.ts.map +1 -1
- package/dist/types/decorators/query.d.ts +7 -7
- package/dist/types/decorators/query.d.ts.map +1 -1
- package/dist/types/decorators/requestAnimationFrame.d.ts +47 -0
- package/dist/types/decorators/requestAnimationFrame.d.ts.map +1 -0
- package/dist/types/decorators/resizeObserver.d.ts +34 -12
- package/dist/types/decorators/resizeObserver.d.ts.map +1 -1
- package/dist/types/decorators/setInterval.d.ts +27 -5
- package/dist/types/decorators/setInterval.d.ts.map +1 -1
- package/dist/types/decorators/setTimeout.d.ts +27 -5
- package/dist/types/decorators/setTimeout.d.ts.map +1 -1
- package/dist/types/decorators/state.d.ts.map +1 -1
- package/dist/types/decorators/subscribeSwcAppMessage.d.ts +44 -0
- package/dist/types/decorators/subscribeSwcAppMessage.d.ts.map +1 -0
- package/dist/types/decorators/subscribeSwcAppRouteChange.d.ts +60 -0
- package/dist/types/decorators/subscribeSwcAppRouteChange.d.ts.map +1 -0
- package/dist/types/decorators/swcAppRoute.d.ts +94 -0
- package/dist/types/decorators/swcAppRoute.d.ts.map +1 -0
- package/dist/types/elements/SwcApp.d.ts.map +1 -1
- package/dist/types/elements/SwcAppMixin.d.ts +423 -388
- package/dist/types/elements/SwcAppMixin.d.ts.map +1 -1
- package/dist/types/types/index.d.ts +43 -4
- package/dist/types/types/index.d.ts.map +1 -1
- package/dist/types/utils/Utils.d.ts +15 -5
- package/dist/types/utils/Utils.d.ts.map +1 -1
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +4395 -1266
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
- package/package.json +8 -6
- package/src/SwcAppEngine.ts +1 -0
- package/src/decorators/addEventListener.ts +1086 -28
- package/src/decorators/applyAttribute.ts +82 -134
- package/src/decorators/applyClass.ts +14 -10
- package/src/decorators/applyNode.ts +39 -37
- package/src/decorators/applyProperty.ts +72 -100
- package/src/decorators/applySlot.ts +9 -8
- package/src/decorators/applyStyle.ts +14 -10
- package/src/decorators/around.ts +196 -0
- package/src/decorators/changedAttribute.ts +65 -26
- package/src/decorators/elementDefine.ts +298 -220
- package/src/decorators/emitCustomEvent.ts +17 -13
- package/src/decorators/eventMedia.ts +119 -0
- package/src/decorators/fetch.ts +454 -0
- package/src/decorators/index.ts +8 -2
- package/src/decorators/intersectionObserver.ts +108 -78
- package/src/decorators/lifecycles.ts +24 -22
- package/src/decorators/mutationObserver.ts +140 -104
- package/src/decorators/parameter.ts +212 -0
- package/src/decorators/publishSwcAppMessage.ts +3 -4
- package/src/decorators/query.ts +22 -14
- package/src/decorators/requestAnimationFrame.ts +149 -0
- package/src/decorators/resizeObserver.ts +119 -82
- package/src/decorators/setInterval.ts +90 -23
- package/src/decorators/setTimeout.ts +93 -23
- package/src/decorators/state.ts +19 -13
- package/src/decorators/subscribeSwcAppMessage.ts +106 -0
- package/src/decorators/subscribeSwcAppRouteChange.ts +131 -0
- package/src/decorators/swcAppRoute.ts +231 -0
- package/src/elements/SwcApp.ts +40 -10
- package/src/elements/SwcAppMixin.ts +329 -85
- package/src/types/index.ts +38 -5
- package/src/types/window.d.ts +2 -18
- package/src/utils/Utils.ts +50 -18
- package/dist/cjs/decorators/subscribeSwcAppMessageWhileConnected.js.map +0 -7
- package/dist/cjs/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +0 -7
- package/dist/cjs/examples/RxJSOperatorsExample.js +0 -285
- package/dist/cjs/examples/RxJSOperatorsExample.js.map +0 -7
- package/dist/esm/decorators/subscribeSwcAppMessageWhileConnected.js +0 -54
- package/dist/esm/decorators/subscribeSwcAppMessageWhileConnected.js.map +0 -7
- package/dist/esm/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +0 -7
- package/dist/esm/examples/RxJSOperatorsExample.js +0 -266
- package/dist/esm/examples/RxJSOperatorsExample.js.map +0 -7
- package/dist/types/decorators/subscribeSwcAppMessageWhileConnected.d.ts +0 -23
- package/dist/types/decorators/subscribeSwcAppMessageWhileConnected.d.ts.map +0 -1
- package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts +0 -31
- package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts.map +0 -1
- package/dist/types/examples/RxJSOperatorsExample.d.ts +0 -94
- package/dist/types/examples/RxJSOperatorsExample.d.ts.map +0 -1
- package/src/decorators/subscribeSwcAppMessageWhileConnected.ts +0 -91
- package/src/decorators/subscribeSwcAppRouteChangeWhileConnected.ts +0 -107
- package/src/examples/RxJSOperatorsExample.ts +0 -279
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import {ReflectUtils} from '@dooboostore/core';
|
|
2
|
+
import {Router} from '@dooboostore/core-web';
|
|
3
|
+
import {HelperHostSet} from '../types';
|
|
4
|
+
|
|
5
|
+
export const SUBSCRIBE_SWC_APP_ROUTE_CHANGE_METADATA_KEY = Symbol.for('simple-web-component:subscribe-swc-app-route-change');
|
|
6
|
+
|
|
7
|
+
export type RoutePathType = string | string[] | ((currentThis: any) => string | string[]);
|
|
8
|
+
|
|
9
|
+
export interface SwcAppRouteChangeSubscriberMetadata {
|
|
10
|
+
propertyKey: string | symbol;
|
|
11
|
+
options?: SwcAppRouteChangeOptions;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface SwcAppRouteChangeOptions<BeforeReturn = any, Result = any> {
|
|
15
|
+
path?: RoutePathType;
|
|
16
|
+
/** 라우트 변경 시 핸들러 실행 여부 게이트. Promise<boolean>도 되어 async 가드(인증 체크 등) 가능. false면 스킵. */
|
|
17
|
+
filter?: (router: Router, meta: { currentThis: any; helper: HelperHostSet }) => boolean | Promise<boolean>;
|
|
18
|
+
/** filter 통과 후 핸들러 직전 훅. await되고, 리턴값은 @routeChangeBeforeReturn 으로 핸들러에 주입된다. */
|
|
19
|
+
before?: (router: Router, meta: { currentThis: any; helper: HelperHostSet }) => BeforeReturn | Promise<BeforeReturn>;
|
|
20
|
+
/** 핸들러가 성공/실패해도 항상 실행되는 정리 훅. ctx로 핸들러 인자/결과/에러를 받는다. 에러는 삼키지 않고 전파. */
|
|
21
|
+
finally?: (router: Router, meta: { currentThis: any; helper: HelperHostSet }, ctx: { args: any[]; result?: Result; error?: any }) => any | Promise<any>;
|
|
22
|
+
order?: number;
|
|
23
|
+
valueKey?: symbol | string;
|
|
24
|
+
/**
|
|
25
|
+
* 늦게 붙은 인스턴스에 마지막 라우트 재생 시점. 기본 'connected'.
|
|
26
|
+
* - 'connectedDone': render 완료 후 (_connectedDone). DOM 타겟 필요한 핸들러용.
|
|
27
|
+
* - live 라우트 변경(전체 방송) 때는 항상 실행. replay에만 적용.
|
|
28
|
+
*/
|
|
29
|
+
trigger?: 'connected' | 'connectedDone';
|
|
30
|
+
/**
|
|
31
|
+
* 언제 실행할지. 기본 'match'(경로가 맞을 때마다 — 기존 동작).
|
|
32
|
+
* - 'enter': 안 맞다가 맞게 됐을 때 (처음 붙을 때의 재생 포함)
|
|
33
|
+
* - 'update': 계속 맞는데 경로나 query 가 바뀌었을 때
|
|
34
|
+
* - 'leave': 맞다가 안 맞게 됐을 때 (요소가 붙어 있을 때만 — 교체되는 페이지는 onDisconnected 가 담당)
|
|
35
|
+
* - 'beforeLeave': 이 경로를 떠나기 전. false(또는 Promise<false>)를 리턴하면 이동 취소 (router.go / 뒤로·앞으로 가기)
|
|
36
|
+
*/
|
|
37
|
+
on?: 'match' | 'enter' | 'update' | 'leave' | 'beforeLeave';
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function createSubscribeSwcAppRouteChange(options?: SwcAppRouteChangeOptions): MethodDecorator {
|
|
41
|
+
return (target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => {
|
|
42
|
+
const pathPattern = options?.path;
|
|
43
|
+
const filter = options?.filter;
|
|
44
|
+
|
|
45
|
+
const constructor = target.constructor;
|
|
46
|
+
let list = ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_METADATA_KEY, constructor) as SwcAppRouteChangeSubscriberMetadata[];
|
|
47
|
+
if (!list) {
|
|
48
|
+
list = [];
|
|
49
|
+
ReflectUtils.defineMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_METADATA_KEY, list, constructor);
|
|
50
|
+
}
|
|
51
|
+
list.push({ propertyKey, options });
|
|
52
|
+
|
|
53
|
+
return descriptor;
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// 오버로드 시그니처 - 직접 사용 (괄호 없음)
|
|
58
|
+
export function subscribeSwcAppRouteChange(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;
|
|
59
|
+
// 오버로드 시그니처 - 함수 호출 (괄호 있음)
|
|
60
|
+
export function subscribeSwcAppRouteChange(pathPattern: RoutePathType): MethodDecorator;
|
|
61
|
+
export function subscribeSwcAppRouteChange<BeforeReturn = any, Result = any>(pathPattern: RoutePathType, config: Omit<SwcAppRouteChangeOptions<NoInfer<BeforeReturn>, NoInfer<Result>>, 'path'>): MethodDecorator;
|
|
62
|
+
export function subscribeSwcAppRouteChange<BeforeReturn = any, Result = any>(options: SwcAppRouteChangeOptions<NoInfer<BeforeReturn>, NoInfer<Result>>): MethodDecorator;
|
|
63
|
+
|
|
64
|
+
// 실제 구현 (이중 모드)
|
|
65
|
+
export function subscribeSwcAppRouteChange(targetOrOptions?: any, propertyKeyOrConfig?: any, descriptor?: PropertyDescriptor): any {
|
|
66
|
+
// 직접 데코레이터로 사용된 경우 (괄호 없음): @subscribeSwcAppRouteChange
|
|
67
|
+
// propertyKey가 string | symbol이고 descriptor가 있으면 직접 사용
|
|
68
|
+
if (propertyKeyOrConfig && (typeof propertyKeyOrConfig === 'string' || typeof propertyKeyOrConfig === 'symbol')) {
|
|
69
|
+
return createSubscribeSwcAppRouteChange({})(targetOrOptions, propertyKeyOrConfig, descriptor);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// 함수로 호출된 경우 (인자 있음): @subscribeSwcAppRouteChange('/path')
|
|
73
|
+
let options: SwcAppRouteChangeOptions = {};
|
|
74
|
+
|
|
75
|
+
if (Array.isArray(targetOrOptions)) {
|
|
76
|
+
// 배열: @subscribeSwcAppRouteChange(['/path1', '/path2'])
|
|
77
|
+
// 또는: @subscribeSwcAppRouteChange(['/path1', '/path2'], { order: 1 })
|
|
78
|
+
options.path = targetOrOptions;
|
|
79
|
+
if (propertyKeyOrConfig && typeof propertyKeyOrConfig === 'object') {
|
|
80
|
+
options = { ...options, ...propertyKeyOrConfig };
|
|
81
|
+
}
|
|
82
|
+
} else if (typeof targetOrOptions === 'string' || typeof targetOrOptions === 'function') {
|
|
83
|
+
// 문자열 또는 함수: @subscribeSwcAppRouteChange('/path')
|
|
84
|
+
// 또는: @subscribeSwcAppRouteChange('/path', { order: 1 })
|
|
85
|
+
options.path = targetOrOptions;
|
|
86
|
+
if (propertyKeyOrConfig && typeof propertyKeyOrConfig === 'object') {
|
|
87
|
+
options = { ...options, ...propertyKeyOrConfig };
|
|
88
|
+
}
|
|
89
|
+
} else if (targetOrOptions && typeof targetOrOptions === 'object') {
|
|
90
|
+
// 객체: @subscribeSwcAppRouteChange({ path: '/path', filter: ..., order: 1 })
|
|
91
|
+
options = targetOrOptions;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return createSubscribeSwcAppRouteChange(options);
|
|
95
|
+
}
|
|
96
|
+
export const changedRoute = subscribeSwcAppRouteChange;
|
|
97
|
+
|
|
98
|
+
// 늦게 붙은 인스턴스도 렌더 완료 후 마지막 라우트를 재생 — DOM 타겟 핸들러용.
|
|
99
|
+
// @subscribeSwcAppRouteChange(path, { trigger: 'connectedDone' }) 의 단축형.
|
|
100
|
+
export function subscribeSwcAppRouteChangeConnectedDone<BeforeReturn = any, Result = any>(pathPattern: RoutePathType, config?: Omit<SwcAppRouteChangeOptions<NoInfer<BeforeReturn>, NoInfer<Result>>, 'path' | 'trigger'>): MethodDecorator {
|
|
101
|
+
return subscribeSwcAppRouteChange(pathPattern, { ...config, trigger: 'connectedDone' });
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Helper function to retrieve route change subscribers metadata
|
|
105
|
+
export const getSubscribeSwcAppRouteChangeMetadata = (target: any): SwcAppRouteChangeSubscriberMetadata[] => {
|
|
106
|
+
const constructor = typeof target === 'function' ? target : target.constructor;
|
|
107
|
+
const results = ReflectUtils.findAllMetadata<any[]>(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_METADATA_KEY, constructor).flat();
|
|
108
|
+
if (!results) return [];
|
|
109
|
+
|
|
110
|
+
// Sort by order (default 0 if not specified)
|
|
111
|
+
return [...results].sort((a, b) => (a.options?.order ?? 0) - (b.options?.order ?? 0));
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
115
|
+
// RouteSubscribeLifeCycler
|
|
116
|
+
// NOTE: 실제 구독 로직은 SwcAppMixin._connected 에서 처리된다.
|
|
117
|
+
// 이 cycler 는 메타데이터 접근 진입점 역할만 하며,
|
|
118
|
+
// 향후 SwcAppMixin 에서 로직을 분리할 때 이 클래스로 이전한다.
|
|
119
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
120
|
+
import { ElementDefineLifeCycler } from '../types';
|
|
121
|
+
|
|
122
|
+
export class RouteSubscribeLifeCycler implements ElementDefineLifeCycler {
|
|
123
|
+
onConnected(_helperHostSet: HelperHostSet): void {
|
|
124
|
+
// 실제 구독은 SwcAppMixin._connected 에서 처리
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** SwcAppMixin 이 구독 대상 메타를 꺼낼 때 사용 */
|
|
128
|
+
getMetadata(helperHostSet: HelperHostSet): SwcAppRouteChangeSubscriberMetadata[] {
|
|
129
|
+
return getSubscribeSwcAppRouteChangeMetadata(helperHostSet.$this);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import { ReflectUtils } from '@dooboostore/core';
|
|
2
|
+
import type { RouteAction, Router, RouterMethodOptions } from '@dooboostore/core-web';
|
|
3
|
+
import { SwcUtils } from '../utils/Utils';
|
|
4
|
+
import type { HelperHostSet } from '../types';
|
|
5
|
+
|
|
6
|
+
export const SWC_APP_ROUTE_METADATA_KEY = Symbol.for('simple-web-component:swc-app-route');
|
|
7
|
+
|
|
8
|
+
export interface SwcAppRouteMetadata {
|
|
9
|
+
propertyKey: string | symbol;
|
|
10
|
+
options?: SwcAppRouteOptions;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** router.go 의 이동 설정 (리턴값으로 직접 줄 때) */
|
|
14
|
+
export type SwcAppRouteGoConfig = { path: RouteAction; replace?: boolean; state?: RouterMethodOptions; scrollToTop?: boolean };
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* type 'go' 일 때 메서드 리턴값 → 이동할 곳.
|
|
18
|
+
* - string / RouteAction({ path, searchParams }) : router.go 로 이동
|
|
19
|
+
* - SwcAppRouteGoConfig({ path, replace, state, scrollToTop }) : 그대로 router.go
|
|
20
|
+
* - number : history 이동 (-1 = 뒤로)
|
|
21
|
+
* - undefined / null / false : 이동하지 않음 (조건부 이동)
|
|
22
|
+
*/
|
|
23
|
+
export type SwcAppRouteGoValue = RouteAction | SwcAppRouteGoConfig | number | undefined | null | false;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* 어떤 Router 메서드로 이동할지. 기본 'go'.
|
|
27
|
+
* - go: string / RouteAction / SwcAppRouteGoConfig / number (가드 적용)
|
|
28
|
+
* - push / replace: RouteAction (가드 적용)
|
|
29
|
+
* - pushDeleteSearchParam / replaceDeleteSearchParam / pushDeleteHashSearchParam / replaceDeleteHashSearchParam: string | string[]
|
|
30
|
+
* - pushAddSearchParam / replaceAddSearchParam: [[key, value], ...]
|
|
31
|
+
* - pushUpsertSearchParam / replaceUpsertSearchParam: { key: value | value[] }
|
|
32
|
+
* query 만 바꾸는 메서드는 경로가 그대로라 beforeLeave 가드 대상이 아니다.
|
|
33
|
+
* 어느 경우든 undefined / null / false 를 리턴하면 아무 것도 하지 않는다.
|
|
34
|
+
*/
|
|
35
|
+
export type SwcAppRouteType =
|
|
36
|
+
| 'go' | 'push' | 'replace'
|
|
37
|
+
| 'pushDeleteSearchParam' | 'pushDeleteHashSearchParam' | 'pushAddSearchParam' | 'pushUpsertSearchParam'
|
|
38
|
+
| 'replaceDeleteSearchParam' | 'replaceDeleteHashSearchParam' | 'replaceAddSearchParam' | 'replaceUpsertSearchParam';
|
|
39
|
+
|
|
40
|
+
export interface SwcAppRouteOptions {
|
|
41
|
+
/** Router 메서드. 기본 'go' */
|
|
42
|
+
type?: SwcAppRouteType;
|
|
43
|
+
/** 기본 replace (type 'go' 전용. 리턴값이 SwcAppRouteGoConfig 면 그쪽이 우선) */
|
|
44
|
+
replace?: boolean;
|
|
45
|
+
/** 기본 state (go 는 SwcAppRouteGoConfig 의 state, 나머지는 두 번째 인자) */
|
|
46
|
+
state?: RouterMethodOptions;
|
|
47
|
+
/** 기본 scrollToTop (type 'go' 전용. router.go 기본값 true) */
|
|
48
|
+
scrollToTop?: boolean;
|
|
49
|
+
/** false 를 리턴하면 이동하지 않는다. target = 이동을 하는 Router, value = valueKey 로 꺼낸 리턴값 */
|
|
50
|
+
filter?: (target: Router, value: any, meta: { currentThis: any; helper: HelperHostSet }) => boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Custom key to extract value from return object.
|
|
53
|
+
* If not provided, uses SWC_APP_ROUTE_METADATA_KEY by default.
|
|
54
|
+
* Useful when this decorator is stacked with others on the same method.
|
|
55
|
+
*
|
|
56
|
+
* Example:
|
|
57
|
+
* @swcAppRoute({ valueKey: 'go' })
|
|
58
|
+
* @publishSwcAppMessage('saved', { valueKey: 'saved' })
|
|
59
|
+
* save() {
|
|
60
|
+
* return { go: '/done', saved: { id: 1 } };
|
|
61
|
+
* }
|
|
62
|
+
*/
|
|
63
|
+
valueKey?: symbol | string;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const isGoConfig = (v: any): v is SwcAppRouteGoConfig =>
|
|
67
|
+
!!v && typeof v === 'object' && 'path' in v && ('replace' in v || 'state' in v || 'scrollToTop' in v || typeof v.path === 'object');
|
|
68
|
+
|
|
69
|
+
function createSwcAppRoute(options?: SwcAppRouteOptions): MethodDecorator {
|
|
70
|
+
return (target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => {
|
|
71
|
+
const constructor = target.constructor;
|
|
72
|
+
let list = ReflectUtils.getOwnMetadata(SWC_APP_ROUTE_METADATA_KEY, constructor) as SwcAppRouteMetadata[];
|
|
73
|
+
if (!list) {
|
|
74
|
+
list = [];
|
|
75
|
+
ReflectUtils.defineMetadata(SWC_APP_ROUTE_METADATA_KEY, list, constructor);
|
|
76
|
+
}
|
|
77
|
+
list.push({ propertyKey, options });
|
|
78
|
+
|
|
79
|
+
if (!descriptor) {
|
|
80
|
+
return descriptor;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// 메서드 래핑 - 원본 메서드의 반환값으로 이동 (DI 로 router 를 받을 필요 없음: 요소가 속한 SwcApp 의 router 사용)
|
|
84
|
+
const originalMethod = descriptor.value;
|
|
85
|
+
descriptor.value = function (...args: any[]) {
|
|
86
|
+
const result = originalMethod.apply(this, args);
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Extract value for this decorator from method return value
|
|
90
|
+
*
|
|
91
|
+
* If return value is an object with this decorator's key,
|
|
92
|
+
* use that value. Otherwise use the entire return value.
|
|
93
|
+
*
|
|
94
|
+
* Uses valueKey from options if provided, otherwise uses SWC_APP_ROUTE_METADATA_KEY.
|
|
95
|
+
*/
|
|
96
|
+
const extractValue = (v: any) => {
|
|
97
|
+
const keyToUse = options?.valueKey ?? SWC_APP_ROUTE_METADATA_KEY;
|
|
98
|
+
if (v && typeof v === 'object' && keyToUse in v) {
|
|
99
|
+
return v[keyToUse];
|
|
100
|
+
}
|
|
101
|
+
return v;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const route = (value: any) => {
|
|
105
|
+
if (value === undefined || value === null || value === false) return;
|
|
106
|
+
const router = SwcUtils.getAppHost(this as HTMLElement)?.router;
|
|
107
|
+
if (!router) {
|
|
108
|
+
console.warn('swcAppRoute: no SwcApp router found for', this);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
if (options?.filter) {
|
|
112
|
+
const helper = SwcUtils.getHelperAndHostSet(this as HTMLElement);
|
|
113
|
+
if (!options.filter(router, value, { currentThis: this, helper })) return;
|
|
114
|
+
}
|
|
115
|
+
const type = options?.type ?? 'go';
|
|
116
|
+
if (type === 'go') {
|
|
117
|
+
if (typeof value === 'number') return router.go(value);
|
|
118
|
+
const defaults = { replace: options?.replace, state: options?.state, scrollToTop: options?.scrollToTop };
|
|
119
|
+
return router.go(isGoConfig(value) ? { ...defaults, ...value } : { ...defaults, path: value as RouteAction });
|
|
120
|
+
}
|
|
121
|
+
const state = options?.state;
|
|
122
|
+
// push/replace 는 경로가 바뀌므로 go 와 같이 beforeLeave 가드를 거친다 (가드 없으면 동기)
|
|
123
|
+
if ((type === 'push' || type === 'replace') && router.hasLeaveGuards) {
|
|
124
|
+
return router.canLeave(router.getRouteData({ pathOrUrl: router.toUrl(value) }), router.value).then(ok => {
|
|
125
|
+
if (!ok) return;
|
|
126
|
+
if (type === 'push') router.push(value as RouteAction, state);
|
|
127
|
+
else router.replace(value as RouteAction, state);
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
switch (type) {
|
|
131
|
+
case 'push':
|
|
132
|
+
return router.push(value as RouteAction, state);
|
|
133
|
+
case 'replace':
|
|
134
|
+
return router.replace(value as RouteAction, state);
|
|
135
|
+
case 'pushDeleteSearchParam':
|
|
136
|
+
return router.pushDeleteSearchParam(value as string | string[], state);
|
|
137
|
+
case 'pushDeleteHashSearchParam':
|
|
138
|
+
return router.pushDeleteHashSearchParam(value as string | string[], state);
|
|
139
|
+
case 'pushAddSearchParam':
|
|
140
|
+
return router.pushAddSearchParam(value as [[string, string]], state);
|
|
141
|
+
case 'pushUpsertSearchParam':
|
|
142
|
+
return router.pushUpsertSearchParam(value as Record<string, string | string[]>, state);
|
|
143
|
+
case 'replaceDeleteSearchParam':
|
|
144
|
+
return router.replaceDeleteSearchParam(value as string | string[], state);
|
|
145
|
+
case 'replaceDeleteHashSearchParam':
|
|
146
|
+
return router.replaceDeleteHashSearchParam(value as string | string[], state);
|
|
147
|
+
case 'replaceAddSearchParam':
|
|
148
|
+
return router.replaceAddSearchParam(value as [[string, string]], state);
|
|
149
|
+
case 'replaceUpsertSearchParam':
|
|
150
|
+
return router.replaceUpsertSearchParam(value as Record<string, string | string[]>, state);
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
// Promise 체크
|
|
155
|
+
if (result instanceof Promise) {
|
|
156
|
+
result
|
|
157
|
+
.then(data => route(extractValue(data)))
|
|
158
|
+
.catch(err => {
|
|
159
|
+
console.warn('swcAppRoute async error:', err);
|
|
160
|
+
});
|
|
161
|
+
} else {
|
|
162
|
+
route(extractValue(result));
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return result;
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
return descriptor;
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// 오버로드 시그니처 - 직접 사용 (괄호 없음)
|
|
173
|
+
export function swcAppRoute(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;
|
|
174
|
+
// 오버로드 시그니처 - 함수 호출 (괄호 있음)
|
|
175
|
+
export function swcAppRoute(options: SwcAppRouteOptions): MethodDecorator;
|
|
176
|
+
|
|
177
|
+
export function swcAppRoute(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {
|
|
178
|
+
// 직접 데코레이터로 사용된 경우 (괄호 없음): @swcAppRoute
|
|
179
|
+
if (targetOrOptions && typeof targetOrOptions === 'object' && propertyKey && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol') && descriptor) {
|
|
180
|
+
return createSwcAppRoute()(targetOrOptions, propertyKey, descriptor);
|
|
181
|
+
}
|
|
182
|
+
// 함수로 호출된 경우 (인자 있음): @swcAppRoute({...})
|
|
183
|
+
return createSwcAppRoute(targetOrOptions as SwcAppRouteOptions | undefined);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// --- Aliases ---
|
|
187
|
+
|
|
188
|
+
/** type 을 고정한 별칭. @swcAppRoutePush / @swcAppRoutePush({ state }) 둘 다. replace/scrollToTop 은 go 전용 */
|
|
189
|
+
type SwcAppRouteTypedOptions<T extends SwcAppRouteType> = T extends 'go'
|
|
190
|
+
? Omit<SwcAppRouteOptions, 'type'>
|
|
191
|
+
: Omit<SwcAppRouteOptions, 'type' | 'replace' | 'scrollToTop'>;
|
|
192
|
+
type SwcAppRouteTypedDecorator<T extends SwcAppRouteType> = {
|
|
193
|
+
(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;
|
|
194
|
+
(options: SwcAppRouteTypedOptions<T>): MethodDecorator; // 빈 괄호 금지 — 인자가 없으면 bare
|
|
195
|
+
};
|
|
196
|
+
const typedRoute = <T extends SwcAppRouteType>(type: T): SwcAppRouteTypedDecorator<T> =>
|
|
197
|
+
((targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any => {
|
|
198
|
+
if (targetOrOptions && typeof targetOrOptions === 'object' && propertyKey && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol') && descriptor) {
|
|
199
|
+
return createSwcAppRoute({ type })(targetOrOptions, propertyKey, descriptor);
|
|
200
|
+
}
|
|
201
|
+
return createSwcAppRoute({ ...(targetOrOptions ?? {}), type });
|
|
202
|
+
}) as SwcAppRouteTypedDecorator<T>;
|
|
203
|
+
|
|
204
|
+
/** 리턴: string / RouteAction / SwcAppRouteGoConfig / number → router.go */
|
|
205
|
+
export const swcAppRouteGo = typedRoute('go');
|
|
206
|
+
/** 리턴: RouteAction → router.push */
|
|
207
|
+
export const swcAppRoutePush = typedRoute('push');
|
|
208
|
+
/** 리턴: RouteAction → router.replace */
|
|
209
|
+
export const swcAppRouteReplace = typedRoute('replace');
|
|
210
|
+
/** 리턴: string | string[] → router.pushDeleteSearchParam */
|
|
211
|
+
export const swcAppRoutePushDeleteSearchParam = typedRoute('pushDeleteSearchParam');
|
|
212
|
+
/** 리턴: string | string[] → router.pushDeleteHashSearchParam */
|
|
213
|
+
export const swcAppRoutePushDeleteHashSearchParam = typedRoute('pushDeleteHashSearchParam');
|
|
214
|
+
/** 리턴: [[key, value], ...] → router.pushAddSearchParam */
|
|
215
|
+
export const swcAppRoutePushAddSearchParam = typedRoute('pushAddSearchParam');
|
|
216
|
+
/** 리턴: { key: value | value[] } → router.pushUpsertSearchParam */
|
|
217
|
+
export const swcAppRoutePushUpsertSearchParam = typedRoute('pushUpsertSearchParam');
|
|
218
|
+
/** 리턴: string | string[] → router.replaceDeleteSearchParam */
|
|
219
|
+
export const swcAppRouteReplaceDeleteSearchParam = typedRoute('replaceDeleteSearchParam');
|
|
220
|
+
/** 리턴: string | string[] → router.replaceDeleteHashSearchParam */
|
|
221
|
+
export const swcAppRouteReplaceDeleteHashSearchParam = typedRoute('replaceDeleteHashSearchParam');
|
|
222
|
+
/** 리턴: [[key, value], ...] → router.replaceAddSearchParam */
|
|
223
|
+
export const swcAppRouteReplaceAddSearchParam = typedRoute('replaceAddSearchParam');
|
|
224
|
+
/** 리턴: { key: value | value[] } → router.replaceUpsertSearchParam */
|
|
225
|
+
export const swcAppRouteReplaceUpsertSearchParam = typedRoute('replaceUpsertSearchParam');
|
|
226
|
+
|
|
227
|
+
// Helper function to retrieve route metadata
|
|
228
|
+
export const getSwcAppRouteMetadata = (target: any): SwcAppRouteMetadata[] | undefined => {
|
|
229
|
+
const constructor = typeof target === 'function' ? target : target.constructor;
|
|
230
|
+
return ReflectUtils.findAllMetadata<any[]>(SWC_APP_ROUTE_METADATA_KEY, constructor).flat();
|
|
231
|
+
};
|
package/src/elements/SwcApp.ts
CHANGED
|
@@ -18,7 +18,10 @@ export const defineSwcApp = async (w: Window) => {
|
|
|
18
18
|
|
|
19
19
|
@elementDefine(swcAppTagName, {window: w})
|
|
20
20
|
class SwcAppImpl extends SwcAppMixin(w.HTMLElement) implements SwcAppInterface {
|
|
21
|
-
// SwcAppMixin에서 모든 기능을
|
|
21
|
+
// SwcAppMixin에서 모든 기능을 상속받음. 기본 요소라 훅에서 할 일은 없음.
|
|
22
|
+
onConnected(): void {}
|
|
23
|
+
onDisconnected(): void {}
|
|
24
|
+
onSwcAppConnected(): void {}
|
|
22
25
|
}
|
|
23
26
|
|
|
24
27
|
return w.customElements.whenDefined(swcAppTagName);
|
|
@@ -39,7 +42,10 @@ export const defineSwcAppBody = async (w: Window) => {
|
|
|
39
42
|
|
|
40
43
|
@elementDefine(swcAppBodyTagName, {window: w, extends: 'body'})
|
|
41
44
|
class SwcAppBodyImpl extends SwcAppMixin(w.HTMLBodyElement) implements SwcAppInterface {
|
|
42
|
-
// SwcAppMixin에서 모든 기능을
|
|
45
|
+
// SwcAppMixin에서 모든 기능을 상속받음. 기본 요소라 훅에서 할 일은 없음.
|
|
46
|
+
onConnected(): void {}
|
|
47
|
+
onDisconnected(): void {}
|
|
48
|
+
onSwcAppConnected(): void {}
|
|
43
49
|
}
|
|
44
50
|
return w.customElements.whenDefined(swcAppBodyTagName);
|
|
45
51
|
};
|
|
@@ -59,7 +65,10 @@ export const defineSwcAppDiv = async (w: Window) => {
|
|
|
59
65
|
|
|
60
66
|
@elementDefine(swcAppDivTagName, {window: w, extends: 'div'})
|
|
61
67
|
class SwcAppDivImpl extends SwcAppMixin(w.HTMLDivElement) implements SwcAppInterface {
|
|
62
|
-
// SwcAppMixin에서 모든 기능을
|
|
68
|
+
// SwcAppMixin에서 모든 기능을 상속받음. 기본 요소라 훅에서 할 일은 없음.
|
|
69
|
+
onConnected(): void {}
|
|
70
|
+
onDisconnected(): void {}
|
|
71
|
+
onSwcAppConnected(): void {}
|
|
63
72
|
}
|
|
64
73
|
|
|
65
74
|
return w.customElements.whenDefined(swcAppDivTagName);
|
|
@@ -80,7 +89,10 @@ export const defineSwcAppSection = async (w: Window) => {
|
|
|
80
89
|
|
|
81
90
|
@elementDefine(swcAppSectionTagName, {window: w, extends: 'section'})
|
|
82
91
|
class SwcAppSectionImpl extends SwcAppMixin(w.HTMLElement) implements SwcAppInterface {
|
|
83
|
-
// SwcAppMixin에서 모든 기능을
|
|
92
|
+
// SwcAppMixin에서 모든 기능을 상속받음. 기본 요소라 훅에서 할 일은 없음.
|
|
93
|
+
onConnected(): void {}
|
|
94
|
+
onDisconnected(): void {}
|
|
95
|
+
onSwcAppConnected(): void {}
|
|
84
96
|
}
|
|
85
97
|
|
|
86
98
|
return w.customElements.whenDefined(swcAppSectionTagName);
|
|
@@ -101,7 +113,10 @@ export const defineSwcAppMain = async (w: Window) => {
|
|
|
101
113
|
|
|
102
114
|
@elementDefine(swcAppMainTagName, {window: w, extends: 'main'})
|
|
103
115
|
class SwcAppMainImpl extends SwcAppMixin(w.HTMLElement) implements SwcAppInterface {
|
|
104
|
-
// SwcAppMixin에서 모든 기능을
|
|
116
|
+
// SwcAppMixin에서 모든 기능을 상속받음. 기본 요소라 훅에서 할 일은 없음.
|
|
117
|
+
onConnected(): void {}
|
|
118
|
+
onDisconnected(): void {}
|
|
119
|
+
onSwcAppConnected(): void {}
|
|
105
120
|
}
|
|
106
121
|
|
|
107
122
|
return w.customElements.whenDefined(swcAppMainTagName);
|
|
@@ -122,7 +137,10 @@ export const defineSwcAppArticle = async (w: Window) => {
|
|
|
122
137
|
|
|
123
138
|
@elementDefine(swcAppArticleTagName, {window: w, extends: 'article'})
|
|
124
139
|
class SwcAppArticleImpl extends SwcAppMixin(w.HTMLElement) implements SwcAppInterface {
|
|
125
|
-
// SwcAppMixin에서 모든 기능을
|
|
140
|
+
// SwcAppMixin에서 모든 기능을 상속받음. 기본 요소라 훅에서 할 일은 없음.
|
|
141
|
+
onConnected(): void {}
|
|
142
|
+
onDisconnected(): void {}
|
|
143
|
+
onSwcAppConnected(): void {}
|
|
126
144
|
}
|
|
127
145
|
|
|
128
146
|
return w.customElements.whenDefined(swcAppArticleTagName);
|
|
@@ -143,7 +161,10 @@ export const defineSwcAppHeader = async (w: Window) => {
|
|
|
143
161
|
|
|
144
162
|
@elementDefine(swcAppHeaderTagName, {window: w, extends: 'header'})
|
|
145
163
|
class SwcAppHeaderImpl extends SwcAppMixin(w.HTMLElement) implements SwcAppInterface {
|
|
146
|
-
// SwcAppMixin에서 모든 기능을
|
|
164
|
+
// SwcAppMixin에서 모든 기능을 상속받음. 기본 요소라 훅에서 할 일은 없음.
|
|
165
|
+
onConnected(): void {}
|
|
166
|
+
onDisconnected(): void {}
|
|
167
|
+
onSwcAppConnected(): void {}
|
|
147
168
|
}
|
|
148
169
|
|
|
149
170
|
return w.customElements.whenDefined(swcAppHeaderTagName);
|
|
@@ -164,7 +185,10 @@ export const defineSwcAppFooter = async (w: Window) => {
|
|
|
164
185
|
|
|
165
186
|
@elementDefine(swcAppFooterTagName, {window: w, extends: 'footer'})
|
|
166
187
|
class SwcAppFooterImpl extends SwcAppMixin(w.HTMLElement) implements SwcAppInterface {
|
|
167
|
-
// SwcAppMixin에서 모든 기능을
|
|
188
|
+
// SwcAppMixin에서 모든 기능을 상속받음. 기본 요소라 훅에서 할 일은 없음.
|
|
189
|
+
onConnected(): void {}
|
|
190
|
+
onDisconnected(): void {}
|
|
191
|
+
onSwcAppConnected(): void {}
|
|
168
192
|
}
|
|
169
193
|
|
|
170
194
|
return w.customElements.whenDefined(swcAppFooterTagName);
|
|
@@ -185,7 +209,10 @@ export const defineSwcAppNav = async (w: Window) => {
|
|
|
185
209
|
|
|
186
210
|
@elementDefine(swcAppNavTagName, {window: w, extends: 'nav'})
|
|
187
211
|
class SwcAppNavImpl extends SwcAppMixin(w.HTMLElement) implements SwcAppInterface {
|
|
188
|
-
// SwcAppMixin에서 모든 기능을
|
|
212
|
+
// SwcAppMixin에서 모든 기능을 상속받음. 기본 요소라 훅에서 할 일은 없음.
|
|
213
|
+
onConnected(): void {}
|
|
214
|
+
onDisconnected(): void {}
|
|
215
|
+
onSwcAppConnected(): void {}
|
|
189
216
|
}
|
|
190
217
|
|
|
191
218
|
return w.customElements.whenDefined(swcAppNavTagName);
|
|
@@ -206,7 +233,10 @@ export const defineSwcAppAside = async (w: Window) => {
|
|
|
206
233
|
|
|
207
234
|
@elementDefine(swcAppAsideTagName, {window: w, extends: 'aside'})
|
|
208
235
|
class SwcAppAsideImpl extends SwcAppMixin(w.HTMLElement) implements SwcAppInterface {
|
|
209
|
-
// SwcAppMixin에서 모든 기능을
|
|
236
|
+
// SwcAppMixin에서 모든 기능을 상속받음. 기본 요소라 훅에서 할 일은 없음.
|
|
237
|
+
onConnected(): void {}
|
|
238
|
+
onDisconnected(): void {}
|
|
239
|
+
onSwcAppConnected(): void {}
|
|
210
240
|
}
|
|
211
241
|
|
|
212
242
|
return w.customElements.whenDefined(swcAppAsideTagName);
|