@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
|
@@ -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
|
-
}
|
|
@@ -1,107 +0,0 @@
|
|
|
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_WHILE_CONNECTED_METADATA_KEY = Symbol.for('simple-web-component:subscribe-swc-app-route-change-while-connected');
|
|
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 {
|
|
15
|
-
path?: RoutePathType;
|
|
16
|
-
filter?: (router: Router, meta: { currentThis: any; helper: HelperHostSet }) => boolean;
|
|
17
|
-
order?: number;
|
|
18
|
-
valueKey?: symbol | string;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function createSubscribeSwcAppRouteChangeWhileConnected(options?: SwcAppRouteChangeOptions): MethodDecorator {
|
|
22
|
-
return (target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => {
|
|
23
|
-
const pathPattern = options?.path;
|
|
24
|
-
const filter = options?.filter;
|
|
25
|
-
|
|
26
|
-
const constructor = target.constructor;
|
|
27
|
-
let list = ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY, constructor) as SwcAppRouteChangeSubscriberMetadata[];
|
|
28
|
-
if (!list) {
|
|
29
|
-
list = [];
|
|
30
|
-
ReflectUtils.defineMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY, list, constructor);
|
|
31
|
-
}
|
|
32
|
-
list.push({ propertyKey, options });
|
|
33
|
-
|
|
34
|
-
return descriptor;
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// 오버로드 시그니처 - 직접 사용 (괄호 없음)
|
|
39
|
-
export function subscribeSwcAppRouteChangeWhileConnected(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;
|
|
40
|
-
// 오버로드 시그니처 - 함수 호출 (괄호 있음)
|
|
41
|
-
export function subscribeSwcAppRouteChangeWhileConnected(): MethodDecorator;
|
|
42
|
-
export function subscribeSwcAppRouteChangeWhileConnected(pathPattern: RoutePathType): MethodDecorator;
|
|
43
|
-
export function subscribeSwcAppRouteChangeWhileConnected(pathPattern: RoutePathType, config: Omit<SwcAppRouteChangeOptions, 'path'>): MethodDecorator;
|
|
44
|
-
export function subscribeSwcAppRouteChangeWhileConnected(options: SwcAppRouteChangeOptions): MethodDecorator;
|
|
45
|
-
|
|
46
|
-
// 실제 구현 (이중 모드)
|
|
47
|
-
export function subscribeSwcAppRouteChangeWhileConnected(targetOrOptions?: any, propertyKeyOrConfig?: any, descriptor?: PropertyDescriptor): any {
|
|
48
|
-
// 직접 데코레이터로 사용된 경우 (괄호 없음): @subscribeSwcAppRouteChangeWhileConnected
|
|
49
|
-
// propertyKey가 string | symbol이고 descriptor가 있으면 직접 사용
|
|
50
|
-
if (propertyKeyOrConfig && (typeof propertyKeyOrConfig === 'string' || typeof propertyKeyOrConfig === 'symbol')) {
|
|
51
|
-
return createSubscribeSwcAppRouteChangeWhileConnected({})(targetOrOptions, propertyKeyOrConfig, descriptor);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// 함수로 호출된 경우 (괄호 있음): @subscribeSwcAppRouteChangeWhileConnected() / @subscribeSwcAppRouteChangeWhileConnected('/path')
|
|
55
|
-
let options: SwcAppRouteChangeOptions = {};
|
|
56
|
-
|
|
57
|
-
if (Array.isArray(targetOrOptions)) {
|
|
58
|
-
// 배열: @subscribeSwcAppRouteChangeWhileConnected(['/path1', '/path2'])
|
|
59
|
-
// 또는: @subscribeSwcAppRouteChangeWhileConnected(['/path1', '/path2'], { order: 1 })
|
|
60
|
-
options.path = targetOrOptions;
|
|
61
|
-
if (propertyKeyOrConfig && typeof propertyKeyOrConfig === 'object') {
|
|
62
|
-
options = { ...options, ...propertyKeyOrConfig };
|
|
63
|
-
}
|
|
64
|
-
} else if (typeof targetOrOptions === 'string' || typeof targetOrOptions === 'function') {
|
|
65
|
-
// 문자열 또는 함수: @subscribeSwcAppRouteChangeWhileConnected('/path')
|
|
66
|
-
// 또는: @subscribeSwcAppRouteChangeWhileConnected('/path', { order: 1 })
|
|
67
|
-
options.path = targetOrOptions;
|
|
68
|
-
if (propertyKeyOrConfig && typeof propertyKeyOrConfig === 'object') {
|
|
69
|
-
options = { ...options, ...propertyKeyOrConfig };
|
|
70
|
-
}
|
|
71
|
-
} else if (targetOrOptions && typeof targetOrOptions === 'object') {
|
|
72
|
-
// 객체: @subscribeSwcAppRouteChangeWhileConnected({ path: '/path', filter: ..., order: 1 })
|
|
73
|
-
options = targetOrOptions;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return createSubscribeSwcAppRouteChangeWhileConnected(options);
|
|
77
|
-
}
|
|
78
|
-
export const changedRoute = subscribeSwcAppRouteChangeWhileConnected;
|
|
79
|
-
|
|
80
|
-
// Helper function to retrieve route change subscribers metadata
|
|
81
|
-
export const getSubscribeSwcAppRouteChangeWhileConnectedMetadata = (target: any): SwcAppRouteChangeSubscriberMetadata[] => {
|
|
82
|
-
const constructor = target instanceof Function ? target : target.constructor;
|
|
83
|
-
const results = ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY, constructor);
|
|
84
|
-
if (!results) return [];
|
|
85
|
-
|
|
86
|
-
// Sort by order (default 0 if not specified)
|
|
87
|
-
return [...results].sort((a, b) => (a.options?.order ?? 0) - (b.options?.order ?? 0));
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
91
|
-
// RouteSubscribeLifeCycler
|
|
92
|
-
// NOTE: 실제 구독 로직은 SwcAppMixin._connected 에서 처리된다.
|
|
93
|
-
// 이 cycler 는 메타데이터 접근 진입점 역할만 하며,
|
|
94
|
-
// 향후 SwcAppMixin 에서 로직을 분리할 때 이 클래스로 이전한다.
|
|
95
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
96
|
-
import { ElementDefineLifeCycler } from '../types';
|
|
97
|
-
|
|
98
|
-
export class RouteSubscribeLifeCycler implements ElementDefineLifeCycler {
|
|
99
|
-
onConnected(_helperHostSet: HelperHostSet): void {
|
|
100
|
-
// 실제 구독은 SwcAppMixin._connected 에서 처리
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/** SwcAppMixin 이 구독 대상 메타를 꺼낼 때 사용 */
|
|
104
|
-
getMetadata(helperHostSet: HelperHostSet): SwcAppRouteChangeSubscriberMetadata[] {
|
|
105
|
-
return getSubscribeSwcAppRouteChangeWhileConnectedMetadata(helperHostSet.$this);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
@@ -1,279 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Example: Using RxJS-like Operators with @addEventListener
|
|
3
|
-
*
|
|
4
|
-
* This example demonstrates how to use debounceTime, throttleTime, and distinctUntilChanged
|
|
5
|
-
* operators with the @addEventListener decorator.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { elementDefine, addEventListener } from '../decorators';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Example 1: Search Component with Debounce
|
|
12
|
-
*
|
|
13
|
-
* Waits 1 second after user stops typing before performing search.
|
|
14
|
-
* Prevents excessive API calls during typing.
|
|
15
|
-
*/
|
|
16
|
-
@elementDefine('search-component')
|
|
17
|
-
export class SearchComponent extends HTMLElement {
|
|
18
|
-
private results: any[] = [];
|
|
19
|
-
|
|
20
|
-
@addEventListener('$this', 'input', { debounceTime: 1000 })
|
|
21
|
-
async onSearchInput(event: Event) {
|
|
22
|
-
const input = event.target as HTMLInputElement;
|
|
23
|
-
const query = input.value.trim();
|
|
24
|
-
|
|
25
|
-
if (query.length > 2) {
|
|
26
|
-
try {
|
|
27
|
-
// Simulate API call
|
|
28
|
-
const response = await fetch(`/api/search?q=${encodeURIComponent(query)}`);
|
|
29
|
-
this.results = await response.json();
|
|
30
|
-
this.renderResults();
|
|
31
|
-
} catch (error) {
|
|
32
|
-
console.error('Search failed:', error);
|
|
33
|
-
}
|
|
34
|
-
} else {
|
|
35
|
-
this.results = [];
|
|
36
|
-
this.renderResults();
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
private renderResults() {
|
|
41
|
-
// Render search results
|
|
42
|
-
console.log('Rendering results:', this.results);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Example 2: Window Resize Handler with Throttle
|
|
48
|
-
*
|
|
49
|
-
* Recalculates layout at most 4 times per second (every 250ms).
|
|
50
|
-
* Prevents performance issues from excessive resize calculations.
|
|
51
|
-
*/
|
|
52
|
-
@elementDefine('responsive-layout')
|
|
53
|
-
export class ResponsiveLayout extends HTMLElement {
|
|
54
|
-
@addEventListener('$window', 'resize', { throttleTime: 250 })
|
|
55
|
-
onWindowResize(event: Event) {
|
|
56
|
-
const width = window.innerWidth;
|
|
57
|
-
const height = window.innerHeight;
|
|
58
|
-
|
|
59
|
-
console.log(`Window resized to: ${width}x${height}`);
|
|
60
|
-
this.updateLayout(width, height);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
private updateLayout(width: number, height: number) {
|
|
64
|
-
// Update layout based on new dimensions
|
|
65
|
-
if (width < 768) {
|
|
66
|
-
this.classList.add('mobile');
|
|
67
|
-
this.classList.remove('desktop');
|
|
68
|
-
} else {
|
|
69
|
-
this.classList.add('desktop');
|
|
70
|
-
this.classList.remove('mobile');
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Example 3: Form Input with Debounce + Distinct
|
|
77
|
-
*
|
|
78
|
-
* Validates field only when:
|
|
79
|
-
* 1. User stops typing (debounce 300ms)
|
|
80
|
-
* 2. AND the value actually changed (distinct)
|
|
81
|
-
*/
|
|
82
|
-
@elementDefine('form-input')
|
|
83
|
-
export class FormInput extends HTMLElement {
|
|
84
|
-
@addEventListener('$this', 'input', {
|
|
85
|
-
debounceTime: 300,
|
|
86
|
-
distinctUntilChanged: true
|
|
87
|
-
})
|
|
88
|
-
onFormInput(event: Event) {
|
|
89
|
-
const input = event.target as HTMLInputElement;
|
|
90
|
-
const fieldName = input.name;
|
|
91
|
-
const value = input.value;
|
|
92
|
-
|
|
93
|
-
console.log(`Validating ${fieldName}: ${value}`);
|
|
94
|
-
this.validateField(fieldName, value);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
private validateField(name: string, value: string) {
|
|
98
|
-
// Perform validation
|
|
99
|
-
const isValid = value.length > 0;
|
|
100
|
-
console.log(`Field ${name} is ${isValid ? 'valid' : 'invalid'}`);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Example 4: Scroll Event with Throttle
|
|
106
|
-
*
|
|
107
|
-
* Checks if user scrolled to bottom at most 10 times per second.
|
|
108
|
-
* Prevents excessive "load more" API calls.
|
|
109
|
-
*/
|
|
110
|
-
@elementDefine('infinite-scroll')
|
|
111
|
-
export class InfiniteScroll extends HTMLElement {
|
|
112
|
-
private isLoading = false;
|
|
113
|
-
|
|
114
|
-
@addEventListener('$window', 'scroll', { throttleTime: 100 })
|
|
115
|
-
onScroll(event: Event) {
|
|
116
|
-
if (this.isLoading) return;
|
|
117
|
-
|
|
118
|
-
if (this.isNearBottom()) {
|
|
119
|
-
console.log('Near bottom, loading more content...');
|
|
120
|
-
this.loadMoreContent();
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
private isNearBottom(): boolean {
|
|
125
|
-
const scrollTop = window.scrollY;
|
|
126
|
-
const windowHeight = window.innerHeight;
|
|
127
|
-
const documentHeight = document.documentElement.scrollHeight;
|
|
128
|
-
|
|
129
|
-
return scrollTop + windowHeight >= documentHeight - 500;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
private async loadMoreContent() {
|
|
133
|
-
this.isLoading = true;
|
|
134
|
-
try {
|
|
135
|
-
// Simulate API call
|
|
136
|
-
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
137
|
-
console.log('Content loaded');
|
|
138
|
-
} finally {
|
|
139
|
-
this.isLoading = false;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Example 5: Custom Comparison with Distinct
|
|
146
|
-
*
|
|
147
|
-
* Only fires when the input value length changes.
|
|
148
|
-
* Ignores changes that don't affect the length.
|
|
149
|
-
*/
|
|
150
|
-
@elementDefine('length-tracker')
|
|
151
|
-
export class LengthTracker extends HTMLElement {
|
|
152
|
-
@addEventListener('$this', 'input', {
|
|
153
|
-
distinctUntilChanged: (prev: any, curr: any) => {
|
|
154
|
-
// Only consider it changed if the length differs
|
|
155
|
-
return prev?.length === curr?.length;
|
|
156
|
-
}
|
|
157
|
-
})
|
|
158
|
-
onInputChange(event: Event) {
|
|
159
|
-
const input = event.target as HTMLInputElement;
|
|
160
|
-
const length = input.value.length;
|
|
161
|
-
|
|
162
|
-
console.log(`Input length changed to: ${length}`);
|
|
163
|
-
this.updateLengthDisplay(length);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
private updateLengthDisplay(length: number) {
|
|
167
|
-
// Update UI with new length
|
|
168
|
-
const display = this.querySelector('.length-display');
|
|
169
|
-
if (display) {
|
|
170
|
-
display.textContent = `${length} characters`;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* Example 6: Complex Scenario - Auto-save with Multiple Operators
|
|
177
|
-
*
|
|
178
|
-
* Combines debounce and distinct for intelligent auto-save:
|
|
179
|
-
* - Waits 2 seconds after user stops typing
|
|
180
|
-
* - Only saves if content actually changed
|
|
181
|
-
* - Prevents unnecessary save operations
|
|
182
|
-
*/
|
|
183
|
-
@elementDefine('auto-save-editor')
|
|
184
|
-
export class AutoSaveEditor extends HTMLElement {
|
|
185
|
-
private lastSavedContent = '';
|
|
186
|
-
|
|
187
|
-
@addEventListener('$this', 'input', {
|
|
188
|
-
debounceTime: 2000,
|
|
189
|
-
distinctUntilChanged: (prev: any, curr: any) => {
|
|
190
|
-
// Consider changed if the content is different
|
|
191
|
-
return prev === curr;
|
|
192
|
-
}
|
|
193
|
-
})
|
|
194
|
-
async onContentChange(event: Event) {
|
|
195
|
-
const textarea = event.target as HTMLTextAreaElement;
|
|
196
|
-
const content = textarea.value;
|
|
197
|
-
|
|
198
|
-
if (content !== this.lastSavedContent) {
|
|
199
|
-
console.log('Auto-saving content...');
|
|
200
|
-
await this.saveContent(content);
|
|
201
|
-
this.lastSavedContent = content;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
private async saveContent(content: string) {
|
|
206
|
-
try {
|
|
207
|
-
// Simulate API call
|
|
208
|
-
const response = await fetch('/api/save', {
|
|
209
|
-
method: 'POST',
|
|
210
|
-
headers: { 'Content-Type': 'application/json' },
|
|
211
|
-
body: JSON.stringify({ content })
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
if (response.ok) {
|
|
215
|
-
console.log('Content saved successfully');
|
|
216
|
-
this.showSaveIndicator();
|
|
217
|
-
}
|
|
218
|
-
} catch (error) {
|
|
219
|
-
console.error('Save failed:', error);
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
private showSaveIndicator() {
|
|
224
|
-
const indicator = this.querySelector('.save-indicator');
|
|
225
|
-
if (indicator) {
|
|
226
|
-
indicator.classList.add('show');
|
|
227
|
-
setTimeout(() => indicator.classList.remove('show'), 2000);
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
/**
|
|
233
|
-
* Example 7: Keyboard Shortcut Handler with Throttle
|
|
234
|
-
*
|
|
235
|
-
* Prevents rapid repeated execution of keyboard shortcuts.
|
|
236
|
-
*/
|
|
237
|
-
@elementDefine('keyboard-handler')
|
|
238
|
-
export class KeyboardHandler extends HTMLElement {
|
|
239
|
-
@addEventListener('$document', 'keydown', {
|
|
240
|
-
throttleTime: 500,
|
|
241
|
-
filter: (event: KeyboardEvent) => {
|
|
242
|
-
// Only handle Ctrl+S or Cmd+S
|
|
243
|
-
return (event.ctrlKey || event.metaKey) && event.key === 's';
|
|
244
|
-
}
|
|
245
|
-
})
|
|
246
|
-
onSaveShortcut(event: KeyboardEvent) {
|
|
247
|
-
event.preventDefault();
|
|
248
|
-
console.log('Save shortcut triggered');
|
|
249
|
-
this.handleSave();
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
private handleSave() {
|
|
253
|
-
// Handle save operation
|
|
254
|
-
console.log('Saving...');
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
/**
|
|
259
|
-
* Example 8: Mouse Move Tracking with Throttle
|
|
260
|
-
*
|
|
261
|
-
* Tracks mouse position at most 10 times per second.
|
|
262
|
-
* Useful for analytics or interactive features.
|
|
263
|
-
*/
|
|
264
|
-
@elementDefine('mouse-tracker')
|
|
265
|
-
export class MouseTracker extends HTMLElement {
|
|
266
|
-
@addEventListener('$document', 'mousemove', { throttleTime: 100 })
|
|
267
|
-
onMouseMove(event: MouseEvent) {
|
|
268
|
-
const x = event.clientX;
|
|
269
|
-
const y = event.clientY;
|
|
270
|
-
|
|
271
|
-
// Update cursor position indicator
|
|
272
|
-
this.updateCursorPosition(x, y);
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
private updateCursorPosition(x: number, y: number) {
|
|
276
|
-
// Update UI with cursor position
|
|
277
|
-
console.log(`Cursor at: ${x}, ${y}`);
|
|
278
|
-
}
|
|
279
|
-
}
|