@dooboostore/simple-web-component 1.0.50 → 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 +735 -354
- package/dist/cjs/SwcAppEngine.js.map +2 -2
- package/dist/cjs/decorators/addEventListener.js +64 -146
- package/dist/cjs/decorators/addEventListener.js.map +2 -2
- package/dist/cjs/decorators/applyAttribute.js +36 -48
- package/dist/cjs/decorators/applyAttribute.js.map +2 -2
- package/dist/cjs/decorators/applyClass.js +9 -12
- package/dist/cjs/decorators/applyClass.js.map +2 -2
- package/dist/cjs/decorators/applyNode.js +14 -22
- package/dist/cjs/decorators/applyNode.js.map +2 -2
- package/dist/cjs/decorators/applyProperty.js +12 -42
- package/dist/cjs/decorators/applyProperty.js.map +2 -2
- package/dist/cjs/decorators/applySlot.js +3 -3
- package/dist/cjs/decorators/applySlot.js.map +2 -2
- package/dist/cjs/decorators/applyStyle.js +9 -12
- 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 +40 -12
- package/dist/cjs/decorators/changedAttribute.js.map +2 -2
- package/dist/cjs/decorators/elementDefine.js +224 -195
- 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 +36 -8
- package/dist/cjs/decorators/eventMedia.js.map +2 -2
- package/dist/cjs/decorators/fetch.js +278 -0
- package/dist/cjs/decorators/fetch.js.map +7 -0
- package/dist/cjs/decorators/index.js +5 -2
- package/dist/cjs/decorators/index.js.map +2 -2
- package/dist/cjs/decorators/intersectionObserver.js +33 -13
- 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 +55 -39
- package/dist/cjs/decorators/mutationObserver.js.map +3 -3
- package/dist/cjs/decorators/parameter.js +92 -9
- package/dist/cjs/decorators/parameter.js.map +2 -2
- 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 +7 -16
- package/dist/cjs/decorators/requestAnimationFrame.js.map +2 -2
- package/dist/cjs/decorators/resizeObserver.js +41 -17
- package/dist/cjs/decorators/resizeObserver.js.map +3 -3
- package/dist/cjs/decorators/setInterval.js +36 -25
- package/dist/cjs/decorators/setInterval.js.map +2 -2
- package/dist/cjs/decorators/setTimeout.js +36 -25
- 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 -83
- 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/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 +64 -146
- package/dist/esm/decorators/addEventListener.js.map +2 -2
- package/dist/esm/decorators/applyAttribute.js +36 -48
- package/dist/esm/decorators/applyAttribute.js.map +2 -2
- package/dist/esm/decorators/applyClass.js +9 -12
- package/dist/esm/decorators/applyClass.js.map +2 -2
- package/dist/esm/decorators/applyNode.js +15 -23
- package/dist/esm/decorators/applyNode.js.map +2 -2
- package/dist/esm/decorators/applyProperty.js +12 -42
- package/dist/esm/decorators/applyProperty.js.map +2 -2
- package/dist/esm/decorators/applySlot.js +3 -3
- package/dist/esm/decorators/applySlot.js.map +2 -2
- package/dist/esm/decorators/applyStyle.js +9 -12
- 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 +40 -12
- package/dist/esm/decorators/changedAttribute.js.map +2 -2
- package/dist/esm/decorators/elementDefine.js +222 -193
- 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 +36 -8
- package/dist/esm/decorators/eventMedia.js.map +2 -2
- package/dist/esm/decorators/fetch.js +259 -0
- package/dist/esm/decorators/fetch.js.map +7 -0
- package/dist/esm/decorators/index.js +5 -2
- package/dist/esm/decorators/index.js.map +2 -2
- package/dist/esm/decorators/intersectionObserver.js +33 -13
- 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 +55 -39
- package/dist/esm/decorators/mutationObserver.js.map +3 -3
- package/dist/esm/decorators/parameter.js +92 -9
- package/dist/esm/decorators/parameter.js.map +2 -2
- 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 +8 -17
- package/dist/esm/decorators/requestAnimationFrame.js.map +2 -2
- package/dist/esm/decorators/resizeObserver.js +41 -17
- package/dist/esm/decorators/resizeObserver.js.map +2 -2
- package/dist/esm/decorators/setInterval.js +37 -26
- package/dist/esm/decorators/setInterval.js.map +2 -2
- package/dist/esm/decorators/setTimeout.js +37 -26
- 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 -85
- 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 +1886 -999
- 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 +923 -960
- package/dist/types/decorators/addEventListener.d.ts.map +1 -1
- package/dist/types/decorators/applyAttribute.d.ts +26 -38
- package/dist/types/decorators/applyAttribute.d.ts.map +1 -1
- package/dist/types/decorators/applyClass.d.ts +1 -3
- package/dist/types/decorators/applyClass.d.ts.map +1 -1
- package/dist/types/decorators/applyNode.d.ts +15 -17
- package/dist/types/decorators/applyNode.d.ts.map +1 -1
- package/dist/types/decorators/applyProperty.d.ts +25 -45
- package/dist/types/decorators/applyProperty.d.ts.map +1 -1
- package/dist/types/decorators/applyStyle.d.ts +1 -3
- 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 +21 -1
- 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 +24 -1
- package/dist/types/decorators/eventMedia.d.ts.map +1 -1
- 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 +5 -2
- package/dist/types/decorators/index.d.ts.map +1 -1
- package/dist/types/decorators/intersectionObserver.d.ts +24 -11
- 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 +26 -13
- package/dist/types/decorators/mutationObserver.d.ts.map +1 -1
- package/dist/types/decorators/parameter.d.ts +84 -6
- package/dist/types/decorators/parameter.d.ts.map +1 -1
- 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 +1 -1
- package/dist/types/decorators/requestAnimationFrame.d.ts.map +1 -1
- package/dist/types/decorators/resizeObserver.d.ts +26 -13
- package/dist/types/decorators/resizeObserver.d.ts.map +1 -1
- package/dist/types/decorators/setInterval.d.ts +10 -0
- package/dist/types/decorators/setInterval.d.ts.map +1 -1
- package/dist/types/decorators/setTimeout.d.ts +10 -0
- 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 +1886 -999
- 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 +102 -96
- package/src/decorators/applyAttribute.ts +76 -138
- package/src/decorators/applyClass.ts +8 -14
- package/src/decorators/applyNode.ts +33 -41
- package/src/decorators/applyProperty.ts +51 -99
- package/src/decorators/applySlot.ts +3 -3
- package/src/decorators/applyStyle.ts +8 -14
- package/src/decorators/around.ts +196 -0
- package/src/decorators/changedAttribute.ts +39 -15
- package/src/decorators/elementDefine.ts +270 -219
- package/src/decorators/emitCustomEvent.ts +17 -13
- package/src/decorators/eventMedia.ts +50 -9
- package/src/decorators/fetch.ts +454 -0
- package/src/decorators/index.ts +5 -2
- package/src/decorators/intersectionObserver.ts +38 -24
- package/src/decorators/lifecycles.ts +24 -22
- package/src/decorators/mutationObserver.ts +71 -52
- package/src/decorators/parameter.ts +145 -14
- package/src/decorators/publishSwcAppMessage.ts +3 -4
- package/src/decorators/query.ts +22 -14
- package/src/decorators/requestAnimationFrame.ts +10 -19
- package/src/decorators/resizeObserver.ts +50 -29
- package/src/decorators/setInterval.ts +37 -26
- package/src/decorators/setTimeout.ts +37 -26
- 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 +330 -101
- package/src/types/index.ts +38 -5
- 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/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/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/src/decorators/subscribeSwcAppMessageWhileConnected.ts +0 -91
- package/src/decorators/subscribeSwcAppRouteChangeWhileConnected.ts +0 -107
package/src/types/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { SimpleApplication } from '@dooboostore/simple-boot';
|
|
2
2
|
import { Router } from '@dooboostore/core-web';
|
|
3
|
+
import type { Observable } from '@dooboostore/core';
|
|
3
4
|
import {SwcAttributeConfigType, SwcConfigType} from "../SwcAppEngine";
|
|
4
5
|
|
|
5
6
|
export enum InjectSituationType {
|
|
@@ -55,10 +56,21 @@ export type SwcAppMessage<T = any> = {
|
|
|
55
56
|
type?: string;
|
|
56
57
|
};
|
|
57
58
|
|
|
59
|
+
/**
|
|
60
|
+
* 늦게 연결/구독한 쪽에 과거 메시지를 재생하는 방식 (@subscribeSwcAppMessage, observeMessage 공통).
|
|
61
|
+
* - 'subject' 또는 미지정: live만
|
|
62
|
+
* - 'behavior': 버퍼의 마지막 1개 먼저
|
|
63
|
+
* - 'replay': 버퍼 전체를 시간순으로 먼저
|
|
64
|
+
*/
|
|
65
|
+
export type SwcAppMessageSubject = 'subject' | 'behavior' | 'replay';
|
|
66
|
+
|
|
67
|
+
/** observeMessage 옵션. type이 없으면 전 타입 live (타입별 버퍼라 재생은 type이 있을 때만). */
|
|
68
|
+
export type SwcAppMessageObserveOptions = { type?: string; subject?: SwcAppMessageSubject };
|
|
58
69
|
|
|
59
|
-
|
|
70
|
+
|
|
71
|
+
export interface SwcAppInterface extends HTMLElement, SwcElement {
|
|
60
72
|
simpleApplication?: SimpleApplication;
|
|
61
|
-
config?:
|
|
73
|
+
config?: SwcConfigType;
|
|
62
74
|
router?: Router;
|
|
63
75
|
connect(config?: SwcAttributeConfigType): Promise<void>;
|
|
64
76
|
routing(path: string): Promise<void>;
|
|
@@ -66,10 +78,23 @@ export interface SwcAppInterface extends HTMLElement {
|
|
|
66
78
|
back(): void;
|
|
67
79
|
forward(): void;
|
|
68
80
|
publishMessage(message: SwcAppMessage): void;
|
|
81
|
+
/** 코드로 메시지 구독 (RxJS 스타일). 반환된 Observable을 subscribe하고, 끝나면 unsubscribe. */
|
|
82
|
+
observeMessage<T = any>(): Observable<SwcAppMessage<T>>;
|
|
83
|
+
observeMessage<T = any>(type: string): Observable<SwcAppMessage<T>>;
|
|
84
|
+
observeMessage<T = any>(type: string, options: Omit<SwcAppMessageObserveOptions, 'type'>): Observable<SwcAppMessage<T>>;
|
|
85
|
+
observeMessage<T = any>(options: SwcAppMessageObserveOptions): Observable<SwcAppMessage<T>>;
|
|
86
|
+
/** 현재 연결된 자식 엘리먼트 목록 */
|
|
87
|
+
connectedElements(): Array<HTMLElement & SwcElement>;
|
|
69
88
|
}
|
|
70
89
|
|
|
71
90
|
export interface SwcElement {
|
|
72
|
-
_swcId
|
|
91
|
+
_swcId?: string;
|
|
92
|
+
__swc_initialized?: boolean;
|
|
93
|
+
__swc_proto_setup?: boolean;
|
|
94
|
+
__swc_observers?: (MutationObserver | ResizeObserver | IntersectionObserver)[];
|
|
95
|
+
_emitHandlers?: Map<any, any>;
|
|
96
|
+
__swc_attributeEventHandlers?: Map<any, any>;
|
|
97
|
+
// __swc_handled?: any;
|
|
73
98
|
// createSlotString(id: string): string
|
|
74
99
|
// createEaHtml(id: string, script: string): string
|
|
75
100
|
// createEaText(id: string, script: string): string
|
|
@@ -170,7 +195,7 @@ export interface OnConnectedResult {
|
|
|
170
195
|
* const cyclers: ElementDefineLifeCycler[] = [eventCycler, ...]; // elementDefine 시 1회 생성
|
|
171
196
|
*
|
|
172
197
|
* proto.connectedCallback = async function () {
|
|
173
|
-
* const helperHostSet = SwcUtils.getHelperAndHostSet(
|
|
198
|
+
* const helperHostSet = SwcUtils.getHelperAndHostSet(this);
|
|
174
199
|
* const results = await Promise.all(cyclers.map(c => c.onConnected?.(helperHostSet)));
|
|
175
200
|
* // results 에서 mutationObserverSet / resizeObserverSet 수집
|
|
176
201
|
* // → 필요한 경우에만 MutationObserver / ResizeObserver 생성
|
|
@@ -180,6 +205,13 @@ export interface OnConnectedResult {
|
|
|
180
205
|
* };
|
|
181
206
|
* ```
|
|
182
207
|
*/
|
|
208
|
+
// observer 메타 phase 분류: 자기 자신(bare/$this, non-delegate)은 렌더 전에, 나머지는 렌더 후에 붙는다.
|
|
209
|
+
export type ObserverScope = 'self' | 'rest';
|
|
210
|
+
export const isSelfObserverMeta = (m: { selector?: unknown; options?: { delegate?: boolean } }): boolean =>
|
|
211
|
+
!m.options?.delegate && (m.selector === '$this' || m.selector === '');
|
|
212
|
+
export const inObserverScope = (m: { selector?: unknown; options?: { delegate?: boolean } }, scope?: ObserverScope): boolean =>
|
|
213
|
+
!scope || (scope === 'self') === isSelfObserverMeta(m);
|
|
214
|
+
|
|
183
215
|
export interface ElementDefineLifeCycler {
|
|
184
216
|
/**
|
|
185
217
|
* connectedCallback 시 호출.
|
|
@@ -187,8 +219,9 @@ export interface ElementDefineLifeCycler {
|
|
|
187
219
|
* 필요 없으면 void / undefined 를 반환한다.
|
|
188
220
|
* @param helperHostSet 현재 엘리먼트 인스턴스($this)를 포함한 컨텍스트
|
|
189
221
|
* @param resizeObserverSet 이전 시클러가 반환한 resize observer set (mutation 시클러가 주입받아 사용)
|
|
222
|
+
* @param scope observer 시클러 전용 — 'self'(렌더 전, 자기 자신 메타만) / 'rest'(렌더 후, 나머지). 없으면 전부.
|
|
190
223
|
*/
|
|
191
|
-
onConnected?(helperHostSet: HelperHostSet, resizeObserverSet?: ResizeObserverSet): OnConnectedResult | void | Promise<OnConnectedResult | void>;
|
|
224
|
+
onConnected?(helperHostSet: HelperHostSet, resizeObserverSet?: ResizeObserverSet, scope?: ObserverScope): OnConnectedResult | void | Promise<OnConnectedResult | void>;
|
|
192
225
|
|
|
193
226
|
/** disconnectedCallback 시 호출. 등록한 리소스를 해제한다. */
|
|
194
227
|
onDisconnected?(helperHostSet: HelperHostSet): void;
|
package/src/utils/Utils.ts
CHANGED
|
@@ -213,7 +213,18 @@ export namespace SwcUtils {
|
|
|
213
213
|
} as const;
|
|
214
214
|
};
|
|
215
215
|
|
|
216
|
-
|
|
216
|
+
/** el 의 window — 자기 elementDefine 설정 → 가까운 조상 SWC 호스트 설정 → 전역 window 순. */
|
|
217
|
+
export const resolveWindow = (el: HTMLElement | Node): Window => {
|
|
218
|
+
const hosts = findAllSwcHostsIncludingSelf(el);
|
|
219
|
+
for (let i = hosts.length - 1; i >= 0; i--) {
|
|
220
|
+
const w = getElementConfig(hosts[i])?.window;
|
|
221
|
+
if (w) return w;
|
|
222
|
+
}
|
|
223
|
+
return (typeof window !== 'undefined' ? window : undefined) as Window;
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
/** win 생략 시 resolveWindow(el). el 이 SWC 요소가 아니면(이벤트 target 등) 호스트의 window 를 넘긴다. */
|
|
227
|
+
export const getHelperAndHostSet = (el: HTMLElement, win: Window = resolveWindow(el)): HelperHostSet => {
|
|
217
228
|
const helperSet = getHelperSet(win);
|
|
218
229
|
const hostSet = getHostSet(el);
|
|
219
230
|
return {
|
|
@@ -237,17 +248,19 @@ export namespace SwcUtils {
|
|
|
237
248
|
};
|
|
238
249
|
|
|
239
250
|
/**
|
|
240
|
-
* Finds the nearest logical SWC host for an element.
|
|
241
|
-
* Checks __swc_host property first, then climbs the DOM tree.
|
|
251
|
+
* Finds the nearest logical SWC host for an element (excluding self).
|
|
252
|
+
* Checks __swc_host property first, then climbs the DOM tree from the parent.
|
|
242
253
|
*/
|
|
243
|
-
export const
|
|
254
|
+
export const findNearestSwcAncestorHost = (el: HTMLElement | Node): HTMLElement | undefined => {
|
|
244
255
|
const el1 = el as any;
|
|
245
256
|
if (el1.__swc_host) return el1.__swc_host;
|
|
246
257
|
|
|
247
258
|
let current: any = el.parentElement || (el.getRootNode?.() as any)?.host;
|
|
248
259
|
const doc = el.ownerDocument;
|
|
249
260
|
const win = doc?.defaultView || ((typeof window !== 'undefined' ? window : undefined) as any);
|
|
261
|
+
let guard = 0;
|
|
250
262
|
while (current && current !== doc && current !== win) {
|
|
263
|
+
if (++guard > 50) break;
|
|
251
264
|
if (current.__swc_host) return current.__swc_host;
|
|
252
265
|
if (getElementConfig(current)) return current as HTMLElement;
|
|
253
266
|
current = current.parentElement || (current.getRootNode?.() as any)?.host;
|
|
@@ -256,28 +269,24 @@ export namespace SwcUtils {
|
|
|
256
269
|
};
|
|
257
270
|
|
|
258
271
|
/**
|
|
259
|
-
* Returns all SWC
|
|
272
|
+
* Returns all SWC hosts in [root, ..., parent, self] order (self only when el is an SWC element).
|
|
260
273
|
*/
|
|
261
274
|
export const findAllSwcHostsIncludingSelf = (el: HTMLElement | Node): HTMLElement[] => {
|
|
262
|
-
const hosts: HTMLElement[] = [];
|
|
263
|
-
let current =
|
|
275
|
+
const hosts: HTMLElement[] = getElementConfig(el) ? [el as HTMLElement] : [];
|
|
276
|
+
let current = findNearestSwcAncestorHost(el);
|
|
264
277
|
while (current) {
|
|
265
278
|
hosts.push(current);
|
|
266
279
|
// To find the next ancestor, we must start searching from the PARENT of the found host
|
|
267
|
-
current =
|
|
280
|
+
current = findNearestSwcAncestorHost(current);
|
|
268
281
|
}
|
|
269
282
|
return hosts.reverse();
|
|
270
283
|
};
|
|
271
284
|
|
|
272
|
-
export const getHosts = (el: HTMLElement): HTMLElement[] =>
|
|
273
|
-
const ancestors = findAllSwcHostsIncludingSelf(el);
|
|
274
|
-
if (getElementConfig(el)) return [...ancestors, el];
|
|
275
|
-
return ancestors;
|
|
276
|
-
};
|
|
285
|
+
export const getHosts = (el: HTMLElement): HTMLElement[] => findAllSwcHostsIncludingSelf(el);
|
|
277
286
|
|
|
278
287
|
export const getHost = (el: HTMLElement): HTMLElement | undefined => {
|
|
279
288
|
if (getElementConfig(el)) return el;
|
|
280
|
-
return
|
|
289
|
+
return findNearestSwcAncestorHost(el);
|
|
281
290
|
};
|
|
282
291
|
|
|
283
292
|
|
|
@@ -305,7 +314,6 @@ export namespace SwcUtils {
|
|
|
305
314
|
t = SwcUtils.processHtml(id, t, {
|
|
306
315
|
document: document,
|
|
307
316
|
replaceWrap: {start: /a::\w+=\s*"/, end: /"\s/}, replacer: (id, script, er) => {
|
|
308
|
-
console.log('start: /a-->', er)
|
|
309
317
|
const match = er.expressionStart.match(/^\w+::(\w+)="/)
|
|
310
318
|
const name = match?.[1];
|
|
311
319
|
return ElementApply.attribute(id, name, script)
|
|
@@ -317,7 +325,6 @@ export namespace SwcUtils {
|
|
|
317
325
|
t = SwcUtils.processHtml(id, t, {
|
|
318
326
|
document: document,
|
|
319
327
|
replaceWrap: {start: /e::\w+=\s*"/, end: /"\s/}, replacer: (id, script, er) => {
|
|
320
|
-
console.log('start: /e-->', er)
|
|
321
328
|
const match = er.expressionStart.match(/^\w+::(\w+)="/)
|
|
322
329
|
const name = match?.[1];
|
|
323
330
|
return ElementApply.event(id, name, script)
|
|
@@ -330,7 +337,6 @@ export namespace SwcUtils {
|
|
|
330
337
|
t = SwcUtils.processHtml(id, t, {
|
|
331
338
|
document: document,
|
|
332
339
|
replaceWrap: {start: /p:\w+=\s*"/, end: /"\s/}, replacer: (id, script, er) => {
|
|
333
|
-
console.log('start: /p-->', er)
|
|
334
340
|
const match = er.expressionStart.match(/^\w+:(\w+)="/)
|
|
335
341
|
const name = match?.[1];
|
|
336
342
|
return ElementApply.property(id, name, script)
|
|
@@ -497,6 +503,9 @@ export namespace SwcUtils {
|
|
|
497
503
|
// el 자체부터 시작 (el이 app host일 수도 있음)
|
|
498
504
|
let current: HTMLElement | null = el;
|
|
499
505
|
|
|
506
|
+
// NOTE: 이름으로만 찾는다. define 전에는 껍데기 엘리먼트라 메서드·instanceof로
|
|
507
|
+
// 판별 불가 (Safari 폴리필은 업그레이드 순서도 child-first). 'swc-app' 태그 또는
|
|
508
|
+
// is="swc-app-*" 속성이 유일한 단서. 커스텀 호스트도 반드시 이 prefix를 쓸 것.
|
|
500
509
|
while (current) {
|
|
501
510
|
const isAppHost =
|
|
502
511
|
current.tagName.toLowerCase() === 'swc-app' ||
|
|
@@ -525,7 +534,8 @@ export namespace SwcUtils {
|
|
|
525
534
|
};
|
|
526
535
|
|
|
527
536
|
export const getHostSet = (el: HTMLElement): HostSet => {
|
|
528
|
-
const
|
|
537
|
+
const hosts = findAllSwcHostsIncludingSelf(el);
|
|
538
|
+
const ancestors = hosts[hosts.length - 1] === el ? hosts.slice(0, -1) : hosts; // [root, ..., parent] — $host 는 자기 자신이 아닌 부모
|
|
529
539
|
|
|
530
540
|
const $host = ancestors.length > 0 ? ancestors[ancestors.length - 1] : null;
|
|
531
541
|
const $parentHost = ancestors.length > 1 ? ancestors[ancestors.length - 2] : null;
|
|
@@ -595,6 +605,28 @@ export namespace SwcUtils {
|
|
|
595
605
|
return result;
|
|
596
606
|
};
|
|
597
607
|
|
|
608
|
+
/**
|
|
609
|
+
* parsePathPattern 과 같은 매칭이지만, 같은 이름의 변수가 여러 번 나오면 모든 값을 순서대로 모은다.
|
|
610
|
+
* '/a/{id}/b/{id}' ← '/a/1/b/2' → { id: ['1', '2'] } (parsePathPattern 은 마지막 값 '2' 로 덮어씀)
|
|
611
|
+
*/
|
|
612
|
+
export const parsePathPatternAll = (pattern: string | undefined, currentPath: string): { [key: string]: string[] } | null => {
|
|
613
|
+
if (pattern === null || pattern === undefined) return {};
|
|
614
|
+
const trimmedPattern = pattern.trim();
|
|
615
|
+
if (trimmedPattern === '' && pattern !== '') return {};
|
|
616
|
+
const paramNames: string[] = [];
|
|
617
|
+
const regexPattern = trimmedPattern.replace(/{(\w+)(?::(.+?))?}/g, (match, paramName, customRegex) => {
|
|
618
|
+
paramNames.push(paramName);
|
|
619
|
+
return `(${customRegex || '[^/]+'})`;
|
|
620
|
+
});
|
|
621
|
+
const match = currentPath.match(new RegExp(`^${regexPattern}$`));
|
|
622
|
+
if (!match) return null;
|
|
623
|
+
const result: { [key: string]: string[] } = {};
|
|
624
|
+
paramNames.forEach((name, index) => {
|
|
625
|
+
(result[name] ??= []).push(match[index + 1]);
|
|
626
|
+
});
|
|
627
|
+
return result;
|
|
628
|
+
};
|
|
629
|
+
|
|
598
630
|
|
|
599
631
|
}
|
|
600
632
|
;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/decorators/subscribeSwcAppMessageWhileConnected.ts"],
|
|
4
|
-
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { SwcAppMessage, SpecialSelector, SwcQueryOptions, HelperHostSet } from '../types';\n\nexport const SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY = Symbol.for('simple-web-component:subscribe-swc-app-message-while-connected');\n\nexport interface SwcAppMessageSubscriberMetadata {\n propertyKey: string | symbol;\n messageType?: string;\n filter?: (message: SwcAppMessage, currentThis: any) => boolean;\n}\n\nexport interface SwcAppMessageOptions {\n filter?: (message: SwcAppMessage, currentThis: any) => boolean;\n}\n\nfunction createSubscribeSwcAppMessageWhileConnected(options?: SwcAppMessageOptions, messageType?: string): MethodDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => {\n const filter = options?.filter;\n\n const constructor = target.constructor;\n let list = ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY, constructor) as SwcAppMessageSubscriberMetadata[];\n if (!list) {\n list = [];\n ReflectUtils.defineMetadata(SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY, list, constructor);\n }\n list.push({ propertyKey, messageType, filter });\n \n return descriptor;\n };\n}\n\n// \uC624\uBC84\uB85C\uB4DC \uC2DC\uADF8\uB2C8\uCC98 - \uC9C1\uC811 \uC0AC\uC6A9 (\uAD04\uD638 \uC5C6\uC74C)\nexport function subscribeSwcAppMessageWhileConnected(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;\n// \uC624\uBC84\uB85C\uB4DC \uC2DC\uADF8\uB2C8\uCC98 - \uD568\uC218 \uD638\uCD9C (\uAD04\uD638 \uC788\uC74C) - \uBA54\uC2DC\uC9C0 \uD0C0\uC785\uB9CC\nexport function subscribeSwcAppMessageWhileConnected(messageType: string): MethodDecorator;\n// \uC624\uBC84\uB85C\uB4DC \uC2DC\uADF8\uB2C8\uCC98 - \uD568\uC218 \uD638\uCD9C (\uAD04\uD638 \uC788\uC74C) - \uC635\uC158\uB9CC\nexport function subscribeSwcAppMessageWhileConnected(options: SwcAppMessageOptions): MethodDecorator;\n// \uC624\uBC84\uB85C\uB4DC \uC2DC\uADF8\uB2C8\uCC98 - \uD568\uC218 \uD638\uCD9C (\uAD04\uD638 \uC788\uC74C) - \uBA54\uC2DC\uC9C0 \uD0C0\uC785 + \uC635\uC158\nexport function subscribeSwcAppMessageWhileConnected(messageType: string, options: SwcAppMessageOptions): MethodDecorator;\n\nexport function subscribeSwcAppMessageWhileConnected(targetOrMessageTypeOrOptions?: any, optionsOrPropertyKey?: any, descriptor?: PropertyDescriptor): any {\n // \uC9C1\uC811 \uB370\uCF54\uB808\uC774\uD130\uB85C \uC0AC\uC6A9\uB41C \uACBD\uC6B0 (\uAD04\uD638 \uC5C6\uC74C): @subscribeSwcAppMessageWhileConnected\n if (targetOrMessageTypeOrOptions && typeof targetOrMessageTypeOrOptions === 'object' && \n optionsOrPropertyKey && (typeof optionsOrPropertyKey === 'string' || typeof optionsOrPropertyKey === 'symbol') &&\n descriptor) {\n const target = targetOrMessageTypeOrOptions;\n const propertyKey = optionsOrPropertyKey;\n return createSubscribeSwcAppMessageWhileConnected({})(target, propertyKey, descriptor);\n }\n\n // \uD568\uC218\uB85C \uD638\uCD9C\uB41C \uACBD\uC6B0 (\uAD04\uD638 \uC788\uC74C)\n let messageType: string | undefined;\n let options: SwcAppMessageOptions = {};\n\n if (typeof targetOrMessageTypeOrOptions === 'string') {\n // \uBA54\uC2DC\uC9C0 \uD0C0\uC785 \uC804\uB2EC: @subscribeSwcAppMessageWhileConnected('messageType') \uB610\uB294 @subscribeSwcAppMessageWhileConnected('messageType', options)\n messageType = targetOrMessageTypeOrOptions;\n if (optionsOrPropertyKey && typeof optionsOrPropertyKey === 'object') {\n options = optionsOrPropertyKey;\n }\n } else if (targetOrMessageTypeOrOptions && typeof targetOrMessageTypeOrOptions === 'object') {\n // \uC635\uC158\uB9CC \uC804\uB2EC: @subscribeSwcAppMessageWhileConnected({ filter: ... })\n options = targetOrMessageTypeOrOptions;\n }\n\n return createSubscribeSwcAppMessageWhileConnected(options, messageType);\n}\n\nexport const receiveMessage = subscribeSwcAppMessageWhileConnected;\n// Helper function to retrieve message subscribers metadata\nexport const getSubscribeSwcAppMessageWhileConnectedMetadata = (target: any): SwcAppMessageSubscriberMetadata[] | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY, constructor);\n};\n\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n// MessageSubscribeLifeCycler\n// NOTE: \uC2E4\uC81C \uAD6C\uB3C5 \uB85C\uC9C1\uC740 SwcAppMixin._connected \uC5D0\uC11C \uCC98\uB9AC\uB41C\uB2E4.\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nimport { ElementDefineLifeCycler } from '../types';\n\nexport class MessageSubscribeLifeCycler implements ElementDefineLifeCycler {\n onConnected(_helperHostSet: HelperHostSet): void {\n // \uC2E4\uC81C \uAD6C\uB3C5\uC740 SwcAppMixin._connected \uC5D0\uC11C \uCC98\uB9AC\n }\n\n /** SwcAppMixin \uC774 \uAD6C\uB3C5 \uB300\uC0C1 \uBA54\uD0C0\uB97C \uAEBC\uB0BC \uB54C \uC0AC\uC6A9 */\n getMetadata(helperHostSet: HelperHostSet): SwcAppMessageSubscriberMetadata[] | undefined {\n return getSubscribeSwcAppMessageWhileConnectedMetadata(helperHostSet.$this);\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA6B;AAGtB,MAAM,yDAAyD,OAAO,IAAI,gEAAgE;AAYjJ,SAAS,2CAA2C,SAAgC,aAAuC;AACzH,SAAO,CAAC,QAAgB,aAA8B,eAAoC;AACxF,UAAM,SAAS,SAAS;AAExB,UAAM,cAAc,OAAO;AAC3B,QAAI,OAAO,yBAAa,eAAe,wDAAwD,WAAW;AAC1G,QAAI,CAAC,MAAM;AACT,aAAO,CAAC;AACR,+BAAa,eAAe,wDAAwD,MAAM,WAAW;AAAA,IACvG;AACA,SAAK,KAAK,EAAE,aAAa,aAAa,OAAO,CAAC;AAE9C,WAAO;AAAA,EACT;AACF;AAWO,SAAS,qCAAqC,8BAAoC,sBAA4B,YAAsC;AAEzJ,MAAI,gCAAgC,OAAO,iCAAiC,YACxE,yBAAyB,OAAO,yBAAyB,YAAY,OAAO,yBAAyB,aACrG,YAAY;AACd,UAAM,SAAS;AACf,UAAM,cAAc;AACpB,WAAO,2CAA2C,CAAC,CAAC,EAAE,QAAQ,aAAa,UAAU;AAAA,EACvF;AAGA,MAAI;AACJ,MAAI,UAAgC,CAAC;AAErC,MAAI,OAAO,iCAAiC,UAAU;AAEpD,kBAAc;AACd,QAAI,wBAAwB,OAAO,yBAAyB,UAAU;AACpE,gBAAU;AAAA,IACZ;AAAA,EACF,WAAW,gCAAgC,OAAO,iCAAiC,UAAU;AAE3F,cAAU;AAAA,EACZ;AAEA,SAAO,2CAA2C,SAAS,WAAW;AACxE;AAEO,MAAM,iBAAiB;AAEvB,MAAM,kDAAkD,CAAC,WAA+D;AAC7H,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,SAAO,yBAAa,eAAe,wDAAwD,WAAW;AACxG;AAQO,MAAM,2BAA8D;AAAA,EACzE,YAAY,gBAAqC;AAAA,EAEjD;AAAA;AAAA,EAGA,YAAY,eAA6E;AACvF,WAAO,gDAAgD,cAAc,KAAK;AAAA,EAC5E;AACF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/decorators/subscribeSwcAppRouteChangeWhileConnected.ts"],
|
|
4
|
-
"sourcesContent": ["import {ReflectUtils} from '@dooboostore/core';\nimport {Router} from '@dooboostore/core-web';\nimport {HelperHostSet} from '../types';\n\nexport const SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY = Symbol.for('simple-web-component:subscribe-swc-app-route-change-while-connected');\n\nexport type RoutePathType = string | string[] | ((currentThis: any) => string | string[]);\n\nexport interface SwcAppRouteChangeSubscriberMetadata {\n propertyKey: string | symbol;\n options?: SwcAppRouteChangeOptions;\n}\n\nexport interface SwcAppRouteChangeOptions {\n path?: RoutePathType;\n filter?: (router: Router, meta: { currentThis: any; helper: HelperHostSet }) => boolean;\n order?: number;\n valueKey?: symbol | string;\n}\n\nfunction createSubscribeSwcAppRouteChangeWhileConnected(options?: SwcAppRouteChangeOptions): MethodDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => {\n const pathPattern = options?.path;\n const filter = options?.filter;\n\n const constructor = target.constructor;\n let list = ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY, constructor) as SwcAppRouteChangeSubscriberMetadata[];\n if (!list) {\n list = [];\n ReflectUtils.defineMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY, list, constructor);\n }\n list.push({ propertyKey, options });\n\n return descriptor;\n };\n}\n\n// \uC624\uBC84\uB85C\uB4DC \uC2DC\uADF8\uB2C8\uCC98 - \uC9C1\uC811 \uC0AC\uC6A9 (\uAD04\uD638 \uC5C6\uC74C)\nexport function subscribeSwcAppRouteChangeWhileConnected(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;\n// \uC624\uBC84\uB85C\uB4DC \uC2DC\uADF8\uB2C8\uCC98 - \uD568\uC218 \uD638\uCD9C (\uAD04\uD638 \uC788\uC74C)\nexport function subscribeSwcAppRouteChangeWhileConnected(): MethodDecorator;\nexport function subscribeSwcAppRouteChangeWhileConnected(pathPattern: RoutePathType): MethodDecorator;\nexport function subscribeSwcAppRouteChangeWhileConnected(pathPattern: RoutePathType, config: Omit<SwcAppRouteChangeOptions, 'path'>): MethodDecorator;\nexport function subscribeSwcAppRouteChangeWhileConnected(options: SwcAppRouteChangeOptions): MethodDecorator;\n\n// \uC2E4\uC81C \uAD6C\uD604 (\uC774\uC911 \uBAA8\uB4DC)\nexport function subscribeSwcAppRouteChangeWhileConnected(targetOrOptions?: any, propertyKeyOrConfig?: any, descriptor?: PropertyDescriptor): any {\n // \uC9C1\uC811 \uB370\uCF54\uB808\uC774\uD130\uB85C \uC0AC\uC6A9\uB41C \uACBD\uC6B0 (\uAD04\uD638 \uC5C6\uC74C): @subscribeSwcAppRouteChangeWhileConnected\n // propertyKey\uAC00 string | symbol\uC774\uACE0 descriptor\uAC00 \uC788\uC73C\uBA74 \uC9C1\uC811 \uC0AC\uC6A9\n if (propertyKeyOrConfig && (typeof propertyKeyOrConfig === 'string' || typeof propertyKeyOrConfig === 'symbol')) {\n return createSubscribeSwcAppRouteChangeWhileConnected({})(targetOrOptions, propertyKeyOrConfig, descriptor);\n }\n\n // \uD568\uC218\uB85C \uD638\uCD9C\uB41C \uACBD\uC6B0 (\uAD04\uD638 \uC788\uC74C): @subscribeSwcAppRouteChangeWhileConnected() / @subscribeSwcAppRouteChangeWhileConnected('/path')\n let options: SwcAppRouteChangeOptions = {};\n\n if (Array.isArray(targetOrOptions)) {\n // \uBC30\uC5F4: @subscribeSwcAppRouteChangeWhileConnected(['/path1', '/path2'])\n // \uB610\uB294: @subscribeSwcAppRouteChangeWhileConnected(['/path1', '/path2'], { order: 1 })\n options.path = targetOrOptions;\n if (propertyKeyOrConfig && typeof propertyKeyOrConfig === 'object') {\n options = { ...options, ...propertyKeyOrConfig };\n }\n } else if (typeof targetOrOptions === 'string' || typeof targetOrOptions === 'function') {\n // \uBB38\uC790\uC5F4 \uB610\uB294 \uD568\uC218: @subscribeSwcAppRouteChangeWhileConnected('/path')\n // \uB610\uB294: @subscribeSwcAppRouteChangeWhileConnected('/path', { order: 1 })\n options.path = targetOrOptions;\n if (propertyKeyOrConfig && typeof propertyKeyOrConfig === 'object') {\n options = { ...options, ...propertyKeyOrConfig };\n }\n } else if (targetOrOptions && typeof targetOrOptions === 'object') {\n // \uAC1D\uCCB4: @subscribeSwcAppRouteChangeWhileConnected({ path: '/path', filter: ..., order: 1 })\n options = targetOrOptions;\n }\n\n return createSubscribeSwcAppRouteChangeWhileConnected(options);\n}\nexport const changedRoute = subscribeSwcAppRouteChangeWhileConnected;\n\n// Helper function to retrieve route change subscribers metadata\nexport const getSubscribeSwcAppRouteChangeWhileConnectedMetadata = (target: any): SwcAppRouteChangeSubscriberMetadata[] => {\n const constructor = target instanceof Function ? target : target.constructor;\n const results = ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY, constructor);\n if (!results) return [];\n \n // Sort by order (default 0 if not specified)\n return [...results].sort((a, b) => (a.options?.order ?? 0) - (b.options?.order ?? 0));\n};\n\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n// RouteSubscribeLifeCycler\n// NOTE: \uC2E4\uC81C \uAD6C\uB3C5 \uB85C\uC9C1\uC740 SwcAppMixin._connected \uC5D0\uC11C \uCC98\uB9AC\uB41C\uB2E4.\n// \uC774 cycler \uB294 \uBA54\uD0C0\uB370\uC774\uD130 \uC811\uADFC \uC9C4\uC785\uC810 \uC5ED\uD560\uB9CC \uD558\uBA70,\n// \uD5A5\uD6C4 SwcAppMixin \uC5D0\uC11C \uB85C\uC9C1\uC744 \uBD84\uB9AC\uD560 \uB54C \uC774 \uD074\uB798\uC2A4\uB85C \uC774\uC804\uD55C\uB2E4.\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nimport { ElementDefineLifeCycler } from '../types';\n\nexport class RouteSubscribeLifeCycler implements ElementDefineLifeCycler {\n onConnected(_helperHostSet: HelperHostSet): void {\n // \uC2E4\uC81C \uAD6C\uB3C5\uC740 SwcAppMixin._connected \uC5D0\uC11C \uCC98\uB9AC\n }\n\n /** SwcAppMixin \uC774 \uAD6C\uB3C5 \uB300\uC0C1 \uBA54\uD0C0\uB97C \uAEBC\uB0BC \uB54C \uC0AC\uC6A9 */\n getMetadata(helperHostSet: HelperHostSet): SwcAppRouteChangeSubscriberMetadata[] {\n return getSubscribeSwcAppRouteChangeWhileConnectedMetadata(helperHostSet.$this);\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA2B;AAIpB,MAAM,8DAA8D,OAAO,IAAI,qEAAqE;AAgB3J,SAAS,+CAA+C,SAAqD;AAC3G,SAAO,CAAC,QAAgB,aAA8B,eAAoC;AACxF,UAAM,cAAc,SAAS;AAC7B,UAAM,SAAS,SAAS;AAExB,UAAM,cAAc,OAAO;AAC3B,QAAI,OAAO,yBAAa,eAAe,6DAA6D,WAAW;AAC/G,QAAI,CAAC,MAAM;AACT,aAAO,CAAC;AACR,+BAAa,eAAe,6DAA6D,MAAM,WAAW;AAAA,IAC5G;AACA,SAAK,KAAK,EAAE,aAAa,QAAQ,CAAC;AAElC,WAAO;AAAA,EACT;AACF;AAWO,SAAS,yCAAyC,iBAAuB,qBAA2B,YAAsC;AAG/I,MAAI,wBAAwB,OAAO,wBAAwB,YAAY,OAAO,wBAAwB,WAAW;AAC/G,WAAO,+CAA+C,CAAC,CAAC,EAAE,iBAAiB,qBAAqB,UAAU;AAAA,EAC5G;AAGA,MAAI,UAAoC,CAAC;AAEzC,MAAI,MAAM,QAAQ,eAAe,GAAG;AAGlC,YAAQ,OAAO;AACf,QAAI,uBAAuB,OAAO,wBAAwB,UAAU;AAClE,gBAAU,EAAE,GAAG,SAAS,GAAG,oBAAoB;AAAA,IACjD;AAAA,EACF,WAAW,OAAO,oBAAoB,YAAY,OAAO,oBAAoB,YAAY;AAGvF,YAAQ,OAAO;AACf,QAAI,uBAAuB,OAAO,wBAAwB,UAAU;AAClE,gBAAU,EAAE,GAAG,SAAS,GAAG,oBAAoB;AAAA,IACjD;AAAA,EACF,WAAW,mBAAmB,OAAO,oBAAoB,UAAU;AAEjE,cAAU;AAAA,EACZ;AAEA,SAAO,+CAA+C,OAAO;AAC/D;AACO,MAAM,eAAe;AAGrB,MAAM,sDAAsD,CAAC,WAAuD;AACzH,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,QAAM,UAAU,yBAAa,eAAe,6DAA6D,WAAW;AACpH,MAAI,CAAC,QAAS,QAAO,CAAC;AAGtB,SAAO,CAAC,GAAG,OAAO,EAAE,KAAK,CAAC,GAAG,OAAO,EAAE,SAAS,SAAS,MAAM,EAAE,SAAS,SAAS,EAAE;AACtF;AAUO,MAAM,yBAA4D;AAAA,EACvE,YAAY,gBAAqC;AAAA,EAEjD;AAAA;AAAA,EAGA,YAAY,eAAqE;AAC/E,WAAO,oDAAoD,cAAc,KAAK;AAAA,EAChF;AACF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { ReflectUtils } from "@dooboostore/core";
|
|
2
|
-
const SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY = Symbol.for("simple-web-component:subscribe-swc-app-message-while-connected");
|
|
3
|
-
function createSubscribeSwcAppMessageWhileConnected(options, messageType) {
|
|
4
|
-
return (target, propertyKey, descriptor) => {
|
|
5
|
-
const filter = options?.filter;
|
|
6
|
-
const constructor = target.constructor;
|
|
7
|
-
let list = ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY, constructor);
|
|
8
|
-
if (!list) {
|
|
9
|
-
list = [];
|
|
10
|
-
ReflectUtils.defineMetadata(SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY, list, constructor);
|
|
11
|
-
}
|
|
12
|
-
list.push({ propertyKey, messageType, filter });
|
|
13
|
-
return descriptor;
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
function subscribeSwcAppMessageWhileConnected(targetOrMessageTypeOrOptions, optionsOrPropertyKey, descriptor) {
|
|
17
|
-
if (targetOrMessageTypeOrOptions && typeof targetOrMessageTypeOrOptions === "object" && optionsOrPropertyKey && (typeof optionsOrPropertyKey === "string" || typeof optionsOrPropertyKey === "symbol") && descriptor) {
|
|
18
|
-
const target = targetOrMessageTypeOrOptions;
|
|
19
|
-
const propertyKey = optionsOrPropertyKey;
|
|
20
|
-
return createSubscribeSwcAppMessageWhileConnected({})(target, propertyKey, descriptor);
|
|
21
|
-
}
|
|
22
|
-
let messageType;
|
|
23
|
-
let options = {};
|
|
24
|
-
if (typeof targetOrMessageTypeOrOptions === "string") {
|
|
25
|
-
messageType = targetOrMessageTypeOrOptions;
|
|
26
|
-
if (optionsOrPropertyKey && typeof optionsOrPropertyKey === "object") {
|
|
27
|
-
options = optionsOrPropertyKey;
|
|
28
|
-
}
|
|
29
|
-
} else if (targetOrMessageTypeOrOptions && typeof targetOrMessageTypeOrOptions === "object") {
|
|
30
|
-
options = targetOrMessageTypeOrOptions;
|
|
31
|
-
}
|
|
32
|
-
return createSubscribeSwcAppMessageWhileConnected(options, messageType);
|
|
33
|
-
}
|
|
34
|
-
const receiveMessage = subscribeSwcAppMessageWhileConnected;
|
|
35
|
-
const getSubscribeSwcAppMessageWhileConnectedMetadata = (target) => {
|
|
36
|
-
const constructor = target instanceof Function ? target : target.constructor;
|
|
37
|
-
return ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY, constructor);
|
|
38
|
-
};
|
|
39
|
-
class MessageSubscribeLifeCycler {
|
|
40
|
-
onConnected(_helperHostSet) {
|
|
41
|
-
}
|
|
42
|
-
/** SwcAppMixin 이 구독 대상 메타를 꺼낼 때 사용 */
|
|
43
|
-
getMetadata(helperHostSet) {
|
|
44
|
-
return getSubscribeSwcAppMessageWhileConnectedMetadata(helperHostSet.$this);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
export {
|
|
48
|
-
MessageSubscribeLifeCycler,
|
|
49
|
-
SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY,
|
|
50
|
-
getSubscribeSwcAppMessageWhileConnectedMetadata,
|
|
51
|
-
receiveMessage,
|
|
52
|
-
subscribeSwcAppMessageWhileConnected
|
|
53
|
-
};
|
|
54
|
-
//# sourceMappingURL=subscribeSwcAppMessageWhileConnected.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/decorators/subscribeSwcAppMessageWhileConnected.ts"],
|
|
4
|
-
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { SwcAppMessage, SpecialSelector, SwcQueryOptions, HelperHostSet } from '../types';\n\nexport const SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY = Symbol.for('simple-web-component:subscribe-swc-app-message-while-connected');\n\nexport interface SwcAppMessageSubscriberMetadata {\n propertyKey: string | symbol;\n messageType?: string;\n filter?: (message: SwcAppMessage, currentThis: any) => boolean;\n}\n\nexport interface SwcAppMessageOptions {\n filter?: (message: SwcAppMessage, currentThis: any) => boolean;\n}\n\nfunction createSubscribeSwcAppMessageWhileConnected(options?: SwcAppMessageOptions, messageType?: string): MethodDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => {\n const filter = options?.filter;\n\n const constructor = target.constructor;\n let list = ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY, constructor) as SwcAppMessageSubscriberMetadata[];\n if (!list) {\n list = [];\n ReflectUtils.defineMetadata(SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY, list, constructor);\n }\n list.push({ propertyKey, messageType, filter });\n \n return descriptor;\n };\n}\n\n// \uC624\uBC84\uB85C\uB4DC \uC2DC\uADF8\uB2C8\uCC98 - \uC9C1\uC811 \uC0AC\uC6A9 (\uAD04\uD638 \uC5C6\uC74C)\nexport function subscribeSwcAppMessageWhileConnected(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;\n// \uC624\uBC84\uB85C\uB4DC \uC2DC\uADF8\uB2C8\uCC98 - \uD568\uC218 \uD638\uCD9C (\uAD04\uD638 \uC788\uC74C) - \uBA54\uC2DC\uC9C0 \uD0C0\uC785\uB9CC\nexport function subscribeSwcAppMessageWhileConnected(messageType: string): MethodDecorator;\n// \uC624\uBC84\uB85C\uB4DC \uC2DC\uADF8\uB2C8\uCC98 - \uD568\uC218 \uD638\uCD9C (\uAD04\uD638 \uC788\uC74C) - \uC635\uC158\uB9CC\nexport function subscribeSwcAppMessageWhileConnected(options: SwcAppMessageOptions): MethodDecorator;\n// \uC624\uBC84\uB85C\uB4DC \uC2DC\uADF8\uB2C8\uCC98 - \uD568\uC218 \uD638\uCD9C (\uAD04\uD638 \uC788\uC74C) - \uBA54\uC2DC\uC9C0 \uD0C0\uC785 + \uC635\uC158\nexport function subscribeSwcAppMessageWhileConnected(messageType: string, options: SwcAppMessageOptions): MethodDecorator;\n\nexport function subscribeSwcAppMessageWhileConnected(targetOrMessageTypeOrOptions?: any, optionsOrPropertyKey?: any, descriptor?: PropertyDescriptor): any {\n // \uC9C1\uC811 \uB370\uCF54\uB808\uC774\uD130\uB85C \uC0AC\uC6A9\uB41C \uACBD\uC6B0 (\uAD04\uD638 \uC5C6\uC74C): @subscribeSwcAppMessageWhileConnected\n if (targetOrMessageTypeOrOptions && typeof targetOrMessageTypeOrOptions === 'object' && \n optionsOrPropertyKey && (typeof optionsOrPropertyKey === 'string' || typeof optionsOrPropertyKey === 'symbol') &&\n descriptor) {\n const target = targetOrMessageTypeOrOptions;\n const propertyKey = optionsOrPropertyKey;\n return createSubscribeSwcAppMessageWhileConnected({})(target, propertyKey, descriptor);\n }\n\n // \uD568\uC218\uB85C \uD638\uCD9C\uB41C \uACBD\uC6B0 (\uAD04\uD638 \uC788\uC74C)\n let messageType: string | undefined;\n let options: SwcAppMessageOptions = {};\n\n if (typeof targetOrMessageTypeOrOptions === 'string') {\n // \uBA54\uC2DC\uC9C0 \uD0C0\uC785 \uC804\uB2EC: @subscribeSwcAppMessageWhileConnected('messageType') \uB610\uB294 @subscribeSwcAppMessageWhileConnected('messageType', options)\n messageType = targetOrMessageTypeOrOptions;\n if (optionsOrPropertyKey && typeof optionsOrPropertyKey === 'object') {\n options = optionsOrPropertyKey;\n }\n } else if (targetOrMessageTypeOrOptions && typeof targetOrMessageTypeOrOptions === 'object') {\n // \uC635\uC158\uB9CC \uC804\uB2EC: @subscribeSwcAppMessageWhileConnected({ filter: ... })\n options = targetOrMessageTypeOrOptions;\n }\n\n return createSubscribeSwcAppMessageWhileConnected(options, messageType);\n}\n\nexport const receiveMessage = subscribeSwcAppMessageWhileConnected;\n// Helper function to retrieve message subscribers metadata\nexport const getSubscribeSwcAppMessageWhileConnectedMetadata = (target: any): SwcAppMessageSubscriberMetadata[] | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY, constructor);\n};\n\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n// MessageSubscribeLifeCycler\n// NOTE: \uC2E4\uC81C \uAD6C\uB3C5 \uB85C\uC9C1\uC740 SwcAppMixin._connected \uC5D0\uC11C \uCC98\uB9AC\uB41C\uB2E4.\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nimport { ElementDefineLifeCycler } from '../types';\n\nexport class MessageSubscribeLifeCycler implements ElementDefineLifeCycler {\n onConnected(_helperHostSet: HelperHostSet): void {\n // \uC2E4\uC81C \uAD6C\uB3C5\uC740 SwcAppMixin._connected \uC5D0\uC11C \uCC98\uB9AC\n }\n\n /** SwcAppMixin \uC774 \uAD6C\uB3C5 \uB300\uC0C1 \uBA54\uD0C0\uB97C \uAEBC\uB0BC \uB54C \uC0AC\uC6A9 */\n getMetadata(helperHostSet: HelperHostSet): SwcAppMessageSubscriberMetadata[] | undefined {\n return getSubscribeSwcAppMessageWhileConnectedMetadata(helperHostSet.$this);\n }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,oBAAoB;AAGtB,MAAM,yDAAyD,OAAO,IAAI,gEAAgE;AAYjJ,SAAS,2CAA2C,SAAgC,aAAuC;AACzH,SAAO,CAAC,QAAgB,aAA8B,eAAoC;AACxF,UAAM,SAAS,SAAS;AAExB,UAAM,cAAc,OAAO;AAC3B,QAAI,OAAO,aAAa,eAAe,wDAAwD,WAAW;AAC1G,QAAI,CAAC,MAAM;AACT,aAAO,CAAC;AACR,mBAAa,eAAe,wDAAwD,MAAM,WAAW;AAAA,IACvG;AACA,SAAK,KAAK,EAAE,aAAa,aAAa,OAAO,CAAC;AAE9C,WAAO;AAAA,EACT;AACF;AAWO,SAAS,qCAAqC,8BAAoC,sBAA4B,YAAsC;AAEzJ,MAAI,gCAAgC,OAAO,iCAAiC,YACxE,yBAAyB,OAAO,yBAAyB,YAAY,OAAO,yBAAyB,aACrG,YAAY;AACd,UAAM,SAAS;AACf,UAAM,cAAc;AACpB,WAAO,2CAA2C,CAAC,CAAC,EAAE,QAAQ,aAAa,UAAU;AAAA,EACvF;AAGA,MAAI;AACJ,MAAI,UAAgC,CAAC;AAErC,MAAI,OAAO,iCAAiC,UAAU;AAEpD,kBAAc;AACd,QAAI,wBAAwB,OAAO,yBAAyB,UAAU;AACpE,gBAAU;AAAA,IACZ;AAAA,EACF,WAAW,gCAAgC,OAAO,iCAAiC,UAAU;AAE3F,cAAU;AAAA,EACZ;AAEA,SAAO,2CAA2C,SAAS,WAAW;AACxE;AAEO,MAAM,iBAAiB;AAEvB,MAAM,kDAAkD,CAAC,WAA+D;AAC7H,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,SAAO,aAAa,eAAe,wDAAwD,WAAW;AACxG;AAQO,MAAM,2BAA8D;AAAA,EACzE,YAAY,gBAAqC;AAAA,EAEjD;AAAA;AAAA,EAGA,YAAY,eAA6E;AACvF,WAAO,gDAAgD,cAAc,KAAK;AAAA,EAC5E;AACF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/decorators/subscribeSwcAppRouteChangeWhileConnected.ts"],
|
|
4
|
-
"sourcesContent": ["import {ReflectUtils} from '@dooboostore/core';\nimport {Router} from '@dooboostore/core-web';\nimport {HelperHostSet} from '../types';\n\nexport const SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY = Symbol.for('simple-web-component:subscribe-swc-app-route-change-while-connected');\n\nexport type RoutePathType = string | string[] | ((currentThis: any) => string | string[]);\n\nexport interface SwcAppRouteChangeSubscriberMetadata {\n propertyKey: string | symbol;\n options?: SwcAppRouteChangeOptions;\n}\n\nexport interface SwcAppRouteChangeOptions {\n path?: RoutePathType;\n filter?: (router: Router, meta: { currentThis: any; helper: HelperHostSet }) => boolean;\n order?: number;\n valueKey?: symbol | string;\n}\n\nfunction createSubscribeSwcAppRouteChangeWhileConnected(options?: SwcAppRouteChangeOptions): MethodDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => {\n const pathPattern = options?.path;\n const filter = options?.filter;\n\n const constructor = target.constructor;\n let list = ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY, constructor) as SwcAppRouteChangeSubscriberMetadata[];\n if (!list) {\n list = [];\n ReflectUtils.defineMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY, list, constructor);\n }\n list.push({ propertyKey, options });\n\n return descriptor;\n };\n}\n\n// \uC624\uBC84\uB85C\uB4DC \uC2DC\uADF8\uB2C8\uCC98 - \uC9C1\uC811 \uC0AC\uC6A9 (\uAD04\uD638 \uC5C6\uC74C)\nexport function subscribeSwcAppRouteChangeWhileConnected(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;\n// \uC624\uBC84\uB85C\uB4DC \uC2DC\uADF8\uB2C8\uCC98 - \uD568\uC218 \uD638\uCD9C (\uAD04\uD638 \uC788\uC74C)\nexport function subscribeSwcAppRouteChangeWhileConnected(): MethodDecorator;\nexport function subscribeSwcAppRouteChangeWhileConnected(pathPattern: RoutePathType): MethodDecorator;\nexport function subscribeSwcAppRouteChangeWhileConnected(pathPattern: RoutePathType, config: Omit<SwcAppRouteChangeOptions, 'path'>): MethodDecorator;\nexport function subscribeSwcAppRouteChangeWhileConnected(options: SwcAppRouteChangeOptions): MethodDecorator;\n\n// \uC2E4\uC81C \uAD6C\uD604 (\uC774\uC911 \uBAA8\uB4DC)\nexport function subscribeSwcAppRouteChangeWhileConnected(targetOrOptions?: any, propertyKeyOrConfig?: any, descriptor?: PropertyDescriptor): any {\n // \uC9C1\uC811 \uB370\uCF54\uB808\uC774\uD130\uB85C \uC0AC\uC6A9\uB41C \uACBD\uC6B0 (\uAD04\uD638 \uC5C6\uC74C): @subscribeSwcAppRouteChangeWhileConnected\n // propertyKey\uAC00 string | symbol\uC774\uACE0 descriptor\uAC00 \uC788\uC73C\uBA74 \uC9C1\uC811 \uC0AC\uC6A9\n if (propertyKeyOrConfig && (typeof propertyKeyOrConfig === 'string' || typeof propertyKeyOrConfig === 'symbol')) {\n return createSubscribeSwcAppRouteChangeWhileConnected({})(targetOrOptions, propertyKeyOrConfig, descriptor);\n }\n\n // \uD568\uC218\uB85C \uD638\uCD9C\uB41C \uACBD\uC6B0 (\uAD04\uD638 \uC788\uC74C): @subscribeSwcAppRouteChangeWhileConnected() / @subscribeSwcAppRouteChangeWhileConnected('/path')\n let options: SwcAppRouteChangeOptions = {};\n\n if (Array.isArray(targetOrOptions)) {\n // \uBC30\uC5F4: @subscribeSwcAppRouteChangeWhileConnected(['/path1', '/path2'])\n // \uB610\uB294: @subscribeSwcAppRouteChangeWhileConnected(['/path1', '/path2'], { order: 1 })\n options.path = targetOrOptions;\n if (propertyKeyOrConfig && typeof propertyKeyOrConfig === 'object') {\n options = { ...options, ...propertyKeyOrConfig };\n }\n } else if (typeof targetOrOptions === 'string' || typeof targetOrOptions === 'function') {\n // \uBB38\uC790\uC5F4 \uB610\uB294 \uD568\uC218: @subscribeSwcAppRouteChangeWhileConnected('/path')\n // \uB610\uB294: @subscribeSwcAppRouteChangeWhileConnected('/path', { order: 1 })\n options.path = targetOrOptions;\n if (propertyKeyOrConfig && typeof propertyKeyOrConfig === 'object') {\n options = { ...options, ...propertyKeyOrConfig };\n }\n } else if (targetOrOptions && typeof targetOrOptions === 'object') {\n // \uAC1D\uCCB4: @subscribeSwcAppRouteChangeWhileConnected({ path: '/path', filter: ..., order: 1 })\n options = targetOrOptions;\n }\n\n return createSubscribeSwcAppRouteChangeWhileConnected(options);\n}\nexport const changedRoute = subscribeSwcAppRouteChangeWhileConnected;\n\n// Helper function to retrieve route change subscribers metadata\nexport const getSubscribeSwcAppRouteChangeWhileConnectedMetadata = (target: any): SwcAppRouteChangeSubscriberMetadata[] => {\n const constructor = target instanceof Function ? target : target.constructor;\n const results = ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY, constructor);\n if (!results) return [];\n \n // Sort by order (default 0 if not specified)\n return [...results].sort((a, b) => (a.options?.order ?? 0) - (b.options?.order ?? 0));\n};\n\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n// RouteSubscribeLifeCycler\n// NOTE: \uC2E4\uC81C \uAD6C\uB3C5 \uB85C\uC9C1\uC740 SwcAppMixin._connected \uC5D0\uC11C \uCC98\uB9AC\uB41C\uB2E4.\n// \uC774 cycler \uB294 \uBA54\uD0C0\uB370\uC774\uD130 \uC811\uADFC \uC9C4\uC785\uC810 \uC5ED\uD560\uB9CC \uD558\uBA70,\n// \uD5A5\uD6C4 SwcAppMixin \uC5D0\uC11C \uB85C\uC9C1\uC744 \uBD84\uB9AC\uD560 \uB54C \uC774 \uD074\uB798\uC2A4\uB85C \uC774\uC804\uD55C\uB2E4.\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nimport { ElementDefineLifeCycler } from '../types';\n\nexport class RouteSubscribeLifeCycler implements ElementDefineLifeCycler {\n onConnected(_helperHostSet: HelperHostSet): void {\n // \uC2E4\uC81C \uAD6C\uB3C5\uC740 SwcAppMixin._connected \uC5D0\uC11C \uCC98\uB9AC\n }\n\n /** SwcAppMixin \uC774 \uAD6C\uB3C5 \uB300\uC0C1 \uBA54\uD0C0\uB97C \uAEBC\uB0BC \uB54C \uC0AC\uC6A9 */\n getMetadata(helperHostSet: HelperHostSet): SwcAppRouteChangeSubscriberMetadata[] {\n return getSubscribeSwcAppRouteChangeWhileConnectedMetadata(helperHostSet.$this);\n }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAQ,oBAAmB;AAIpB,MAAM,8DAA8D,OAAO,IAAI,qEAAqE;AAgB3J,SAAS,+CAA+C,SAAqD;AAC3G,SAAO,CAAC,QAAgB,aAA8B,eAAoC;AACxF,UAAM,cAAc,SAAS;AAC7B,UAAM,SAAS,SAAS;AAExB,UAAM,cAAc,OAAO;AAC3B,QAAI,OAAO,aAAa,eAAe,6DAA6D,WAAW;AAC/G,QAAI,CAAC,MAAM;AACT,aAAO,CAAC;AACR,mBAAa,eAAe,6DAA6D,MAAM,WAAW;AAAA,IAC5G;AACA,SAAK,KAAK,EAAE,aAAa,QAAQ,CAAC;AAElC,WAAO;AAAA,EACT;AACF;AAWO,SAAS,yCAAyC,iBAAuB,qBAA2B,YAAsC;AAG/I,MAAI,wBAAwB,OAAO,wBAAwB,YAAY,OAAO,wBAAwB,WAAW;AAC/G,WAAO,+CAA+C,CAAC,CAAC,EAAE,iBAAiB,qBAAqB,UAAU;AAAA,EAC5G;AAGA,MAAI,UAAoC,CAAC;AAEzC,MAAI,MAAM,QAAQ,eAAe,GAAG;AAGlC,YAAQ,OAAO;AACf,QAAI,uBAAuB,OAAO,wBAAwB,UAAU;AAClE,gBAAU,EAAE,GAAG,SAAS,GAAG,oBAAoB;AAAA,IACjD;AAAA,EACF,WAAW,OAAO,oBAAoB,YAAY,OAAO,oBAAoB,YAAY;AAGvF,YAAQ,OAAO;AACf,QAAI,uBAAuB,OAAO,wBAAwB,UAAU;AAClE,gBAAU,EAAE,GAAG,SAAS,GAAG,oBAAoB;AAAA,IACjD;AAAA,EACF,WAAW,mBAAmB,OAAO,oBAAoB,UAAU;AAEjE,cAAU;AAAA,EACZ;AAEA,SAAO,+CAA+C,OAAO;AAC/D;AACO,MAAM,eAAe;AAGrB,MAAM,sDAAsD,CAAC,WAAuD;AACzH,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,QAAM,UAAU,aAAa,eAAe,6DAA6D,WAAW;AACpH,MAAI,CAAC,QAAS,QAAO,CAAC;AAGtB,SAAO,CAAC,GAAG,OAAO,EAAE,KAAK,CAAC,GAAG,OAAO,EAAE,SAAS,SAAS,MAAM,EAAE,SAAS,SAAS,EAAE;AACtF;AAUO,MAAM,yBAA4D;AAAA,EACvE,YAAY,gBAAqC;AAAA,EAEjD;AAAA;AAAA,EAGA,YAAY,eAAqE;AAC/E,WAAO,oDAAoD,cAAc,KAAK;AAAA,EAChF;AACF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { SwcAppMessage, HelperHostSet } from '../types';
|
|
2
|
-
export declare const SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY: unique symbol;
|
|
3
|
-
export interface SwcAppMessageSubscriberMetadata {
|
|
4
|
-
propertyKey: string | symbol;
|
|
5
|
-
messageType?: string;
|
|
6
|
-
filter?: (message: SwcAppMessage, currentThis: any) => boolean;
|
|
7
|
-
}
|
|
8
|
-
export interface SwcAppMessageOptions {
|
|
9
|
-
filter?: (message: SwcAppMessage, currentThis: any) => boolean;
|
|
10
|
-
}
|
|
11
|
-
export declare function subscribeSwcAppMessageWhileConnected(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;
|
|
12
|
-
export declare function subscribeSwcAppMessageWhileConnected(messageType: string): MethodDecorator;
|
|
13
|
-
export declare function subscribeSwcAppMessageWhileConnected(options: SwcAppMessageOptions): MethodDecorator;
|
|
14
|
-
export declare function subscribeSwcAppMessageWhileConnected(messageType: string, options: SwcAppMessageOptions): MethodDecorator;
|
|
15
|
-
export declare const receiveMessage: typeof subscribeSwcAppMessageWhileConnected;
|
|
16
|
-
export declare const getSubscribeSwcAppMessageWhileConnectedMetadata: (target: any) => SwcAppMessageSubscriberMetadata[] | undefined;
|
|
17
|
-
import { ElementDefineLifeCycler } from '../types';
|
|
18
|
-
export declare class MessageSubscribeLifeCycler implements ElementDefineLifeCycler {
|
|
19
|
-
onConnected(_helperHostSet: HelperHostSet): void;
|
|
20
|
-
/** SwcAppMixin 이 구독 대상 메타를 꺼낼 때 사용 */
|
|
21
|
-
getMetadata(helperHostSet: HelperHostSet): SwcAppMessageSubscriberMetadata[] | undefined;
|
|
22
|
-
}
|
|
23
|
-
//# sourceMappingURL=subscribeSwcAppMessageWhileConnected.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"subscribeSwcAppMessageWhileConnected.d.ts","sourceRoot":"","sources":["../../../src/decorators/subscribeSwcAppMessageWhileConnected.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAoC,aAAa,EAAE,MAAM,UAAU,CAAC;AAE1F,eAAO,MAAM,sDAAsD,eAA+E,CAAC;AAEnJ,MAAM,WAAW,+BAA+B;IAC9C,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,GAAG,KAAK,OAAO,CAAC;CAChE;AAED,MAAM,WAAW,oBAAoB;IACnC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,GAAG,KAAK,OAAO,CAAC;CAChE;AAmBD,wBAAgB,oCAAoC,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,UAAU,EAAE,kBAAkB,GAAG,kBAAkB,GAAG,IAAI,CAAC;AAE9J,wBAAgB,oCAAoC,CAAC,WAAW,EAAE,MAAM,GAAG,eAAe,CAAC;AAE3F,wBAAgB,oCAAoC,CAAC,OAAO,EAAE,oBAAoB,GAAG,eAAe,CAAC;AAErG,wBAAgB,oCAAoC,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,oBAAoB,GAAG,eAAe,CAAC;AA8B1H,eAAO,MAAM,cAAc,6CAAuC,CAAC;AAEnE,eAAO,MAAM,+CAA+C,GAAI,QAAQ,GAAG,KAAG,+BAA+B,EAAE,GAAG,SAGjH,CAAC;AAMF,OAAO,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAEnD,qBAAa,0BAA2B,YAAW,uBAAuB;IACxE,WAAW,CAAC,cAAc,EAAE,aAAa,GAAG,IAAI;IAIhD,sCAAsC;IACtC,WAAW,CAAC,aAAa,EAAE,aAAa,GAAG,+BAA+B,EAAE,GAAG,SAAS;CAGzF"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { Router } from '@dooboostore/core-web';
|
|
2
|
-
import { HelperHostSet } from '../types';
|
|
3
|
-
export declare const SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY: unique symbol;
|
|
4
|
-
export type RoutePathType = string | string[] | ((currentThis: any) => string | string[]);
|
|
5
|
-
export interface SwcAppRouteChangeSubscriberMetadata {
|
|
6
|
-
propertyKey: string | symbol;
|
|
7
|
-
options?: SwcAppRouteChangeOptions;
|
|
8
|
-
}
|
|
9
|
-
export interface SwcAppRouteChangeOptions {
|
|
10
|
-
path?: RoutePathType;
|
|
11
|
-
filter?: (router: Router, meta: {
|
|
12
|
-
currentThis: any;
|
|
13
|
-
helper: HelperHostSet;
|
|
14
|
-
}) => boolean;
|
|
15
|
-
order?: number;
|
|
16
|
-
valueKey?: symbol | string;
|
|
17
|
-
}
|
|
18
|
-
export declare function subscribeSwcAppRouteChangeWhileConnected(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;
|
|
19
|
-
export declare function subscribeSwcAppRouteChangeWhileConnected(): MethodDecorator;
|
|
20
|
-
export declare function subscribeSwcAppRouteChangeWhileConnected(pathPattern: RoutePathType): MethodDecorator;
|
|
21
|
-
export declare function subscribeSwcAppRouteChangeWhileConnected(pathPattern: RoutePathType, config: Omit<SwcAppRouteChangeOptions, 'path'>): MethodDecorator;
|
|
22
|
-
export declare function subscribeSwcAppRouteChangeWhileConnected(options: SwcAppRouteChangeOptions): MethodDecorator;
|
|
23
|
-
export declare const changedRoute: typeof subscribeSwcAppRouteChangeWhileConnected;
|
|
24
|
-
export declare const getSubscribeSwcAppRouteChangeWhileConnectedMetadata: (target: any) => SwcAppRouteChangeSubscriberMetadata[];
|
|
25
|
-
import { ElementDefineLifeCycler } from '../types';
|
|
26
|
-
export declare class RouteSubscribeLifeCycler implements ElementDefineLifeCycler {
|
|
27
|
-
onConnected(_helperHostSet: HelperHostSet): void;
|
|
28
|
-
/** SwcAppMixin 이 구독 대상 메타를 꺼낼 때 사용 */
|
|
29
|
-
getMetadata(helperHostSet: HelperHostSet): SwcAppRouteChangeSubscriberMetadata[];
|
|
30
|
-
}
|
|
31
|
-
//# sourceMappingURL=subscribeSwcAppRouteChangeWhileConnected.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"subscribeSwcAppRouteChangeWhileConnected.d.ts","sourceRoot":"","sources":["../../../src/decorators/subscribeSwcAppRouteChangeWhileConnected.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,MAAM,EAAC,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAC,aAAa,EAAC,MAAM,UAAU,CAAC;AAEvC,eAAO,MAAM,2DAA2D,eAAoF,CAAC;AAE7J,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,CAAC,WAAW,EAAE,GAAG,KAAK,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;AAE1F,MAAM,WAAW,mCAAmC;IAClD,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC;IAC7B,OAAO,CAAC,EAAE,wBAAwB,CAAC;CACpC;AAED,MAAM,WAAW,wBAAwB;IACvC,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE;QAAE,WAAW,EAAE,GAAG,CAAC;QAAC,MAAM,EAAE,aAAa,CAAA;KAAE,KAAK,OAAO,CAAC;IACxF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAC5B;AAoBD,wBAAgB,wCAAwC,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,UAAU,EAAE,kBAAkB,GAAG,kBAAkB,GAAG,IAAI,CAAC;AAElK,wBAAgB,wCAAwC,IAAI,eAAe,CAAC;AAC5E,wBAAgB,wCAAwC,CAAC,WAAW,EAAE,aAAa,GAAG,eAAe,CAAC;AACtG,wBAAgB,wCAAwC,CAAC,WAAW,EAAE,aAAa,EAAE,MAAM,EAAE,IAAI,CAAC,wBAAwB,EAAE,MAAM,CAAC,GAAG,eAAe,CAAC;AACtJ,wBAAgB,wCAAwC,CAAC,OAAO,EAAE,wBAAwB,GAAG,eAAe,CAAC;AAkC7G,eAAO,MAAM,YAAY,iDAA2C,CAAC;AAGrE,eAAO,MAAM,mDAAmD,GAAI,QAAQ,GAAG,KAAG,mCAAmC,EAOpH,CAAC;AAQF,OAAO,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAEnD,qBAAa,wBAAyB,YAAW,uBAAuB;IACtE,WAAW,CAAC,cAAc,EAAE,aAAa,GAAG,IAAI;IAIhD,sCAAsC;IACtC,WAAW,CAAC,aAAa,EAAE,aAAa,GAAG,mCAAmC,EAAE;CAGjF"}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { ReflectUtils } from '@dooboostore/core';
|
|
2
|
-
import { SwcAppMessage, SpecialSelector, SwcQueryOptions, HelperHostSet } from '../types';
|
|
3
|
-
|
|
4
|
-
export const SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY = Symbol.for('simple-web-component:subscribe-swc-app-message-while-connected');
|
|
5
|
-
|
|
6
|
-
export interface SwcAppMessageSubscriberMetadata {
|
|
7
|
-
propertyKey: string | symbol;
|
|
8
|
-
messageType?: string;
|
|
9
|
-
filter?: (message: SwcAppMessage, currentThis: any) => boolean;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface SwcAppMessageOptions {
|
|
13
|
-
filter?: (message: SwcAppMessage, currentThis: any) => boolean;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function createSubscribeSwcAppMessageWhileConnected(options?: SwcAppMessageOptions, messageType?: string): MethodDecorator {
|
|
17
|
-
return (target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => {
|
|
18
|
-
const filter = options?.filter;
|
|
19
|
-
|
|
20
|
-
const constructor = target.constructor;
|
|
21
|
-
let list = ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY, constructor) as SwcAppMessageSubscriberMetadata[];
|
|
22
|
-
if (!list) {
|
|
23
|
-
list = [];
|
|
24
|
-
ReflectUtils.defineMetadata(SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY, list, constructor);
|
|
25
|
-
}
|
|
26
|
-
list.push({ propertyKey, messageType, filter });
|
|
27
|
-
|
|
28
|
-
return descriptor;
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// 오버로드 시그니처 - 직접 사용 (괄호 없음)
|
|
33
|
-
export function subscribeSwcAppMessageWhileConnected(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;
|
|
34
|
-
// 오버로드 시그니처 - 함수 호출 (괄호 있음) - 메시지 타입만
|
|
35
|
-
export function subscribeSwcAppMessageWhileConnected(messageType: string): MethodDecorator;
|
|
36
|
-
// 오버로드 시그니처 - 함수 호출 (괄호 있음) - 옵션만
|
|
37
|
-
export function subscribeSwcAppMessageWhileConnected(options: SwcAppMessageOptions): MethodDecorator;
|
|
38
|
-
// 오버로드 시그니처 - 함수 호출 (괄호 있음) - 메시지 타입 + 옵션
|
|
39
|
-
export function subscribeSwcAppMessageWhileConnected(messageType: string, options: SwcAppMessageOptions): MethodDecorator;
|
|
40
|
-
|
|
41
|
-
export function subscribeSwcAppMessageWhileConnected(targetOrMessageTypeOrOptions?: any, optionsOrPropertyKey?: any, descriptor?: PropertyDescriptor): any {
|
|
42
|
-
// 직접 데코레이터로 사용된 경우 (괄호 없음): @subscribeSwcAppMessageWhileConnected
|
|
43
|
-
if (targetOrMessageTypeOrOptions && typeof targetOrMessageTypeOrOptions === 'object' &&
|
|
44
|
-
optionsOrPropertyKey && (typeof optionsOrPropertyKey === 'string' || typeof optionsOrPropertyKey === 'symbol') &&
|
|
45
|
-
descriptor) {
|
|
46
|
-
const target = targetOrMessageTypeOrOptions;
|
|
47
|
-
const propertyKey = optionsOrPropertyKey;
|
|
48
|
-
return createSubscribeSwcAppMessageWhileConnected({})(target, propertyKey, descriptor);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// 함수로 호출된 경우 (괄호 있음)
|
|
52
|
-
let messageType: string | undefined;
|
|
53
|
-
let options: SwcAppMessageOptions = {};
|
|
54
|
-
|
|
55
|
-
if (typeof targetOrMessageTypeOrOptions === 'string') {
|
|
56
|
-
// 메시지 타입 전달: @subscribeSwcAppMessageWhileConnected('messageType') 또는 @subscribeSwcAppMessageWhileConnected('messageType', options)
|
|
57
|
-
messageType = targetOrMessageTypeOrOptions;
|
|
58
|
-
if (optionsOrPropertyKey && typeof optionsOrPropertyKey === 'object') {
|
|
59
|
-
options = optionsOrPropertyKey;
|
|
60
|
-
}
|
|
61
|
-
} else if (targetOrMessageTypeOrOptions && typeof targetOrMessageTypeOrOptions === 'object') {
|
|
62
|
-
// 옵션만 전달: @subscribeSwcAppMessageWhileConnected({ filter: ... })
|
|
63
|
-
options = targetOrMessageTypeOrOptions;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return createSubscribeSwcAppMessageWhileConnected(options, messageType);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export const receiveMessage = subscribeSwcAppMessageWhileConnected;
|
|
70
|
-
// Helper function to retrieve message subscribers metadata
|
|
71
|
-
export const getSubscribeSwcAppMessageWhileConnectedMetadata = (target: any): SwcAppMessageSubscriberMetadata[] | undefined => {
|
|
72
|
-
const constructor = target instanceof Function ? target : target.constructor;
|
|
73
|
-
return ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY, constructor);
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
77
|
-
// MessageSubscribeLifeCycler
|
|
78
|
-
// NOTE: 실제 구독 로직은 SwcAppMixin._connected 에서 처리된다.
|
|
79
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
80
|
-
import { ElementDefineLifeCycler } from '../types';
|
|
81
|
-
|
|
82
|
-
export class MessageSubscribeLifeCycler implements ElementDefineLifeCycler {
|
|
83
|
-
onConnected(_helperHostSet: HelperHostSet): void {
|
|
84
|
-
// 실제 구독은 SwcAppMixin._connected 에서 처리
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/** SwcAppMixin 이 구독 대상 메타를 꺼낼 때 사용 */
|
|
88
|
-
getMetadata(helperHostSet: HelperHostSet): SwcAppMessageSubscriberMetadata[] | undefined {
|
|
89
|
-
return getSubscribeSwcAppMessageWhileConnectedMetadata(helperHostSet.$this);
|
|
90
|
-
}
|
|
91
|
-
}
|