@dooboostore/simple-web-component 1.0.49 → 1.0.50
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 +72 -0
- package/dist/cjs/decorators/addEventListener.js +1994 -9
- package/dist/cjs/decorators/addEventListener.js.map +2 -2
- package/dist/cjs/decorators/applyAttribute.js +10 -4
- package/dist/cjs/decorators/applyAttribute.js.map +2 -2
- package/dist/cjs/decorators/applyClass.js +10 -4
- package/dist/cjs/decorators/applyClass.js.map +2 -2
- package/dist/cjs/decorators/applyNode.js +10 -4
- package/dist/cjs/decorators/applyNode.js.map +2 -2
- package/dist/cjs/decorators/applyProperty.js +14 -8
- package/dist/cjs/decorators/applyProperty.js.map +2 -2
- package/dist/cjs/decorators/applySlot.js +6 -5
- package/dist/cjs/decorators/applySlot.js.map +2 -2
- package/dist/cjs/decorators/applyStyle.js +10 -4
- package/dist/cjs/decorators/applyStyle.js.map +2 -2
- package/dist/cjs/decorators/changedAttribute.js +22 -13
- package/dist/cjs/decorators/changedAttribute.js.map +2 -2
- package/dist/cjs/decorators/elementDefine.js +18 -3
- package/dist/cjs/decorators/elementDefine.js.map +2 -2
- package/dist/cjs/decorators/eventMedia.js +84 -0
- package/dist/cjs/decorators/eventMedia.js.map +7 -0
- package/dist/cjs/decorators/index.js +3 -0
- package/dist/cjs/decorators/index.js.map +2 -2
- package/dist/cjs/decorators/intersectionObserver.js +46 -55
- package/dist/cjs/decorators/intersectionObserver.js.map +2 -2
- package/dist/cjs/decorators/mutationObserver.js +46 -55
- package/dist/cjs/decorators/mutationObserver.js.map +2 -2
- package/dist/cjs/decorators/parameter.js +73 -0
- package/dist/cjs/decorators/parameter.js.map +7 -0
- package/dist/cjs/decorators/requestAnimationFrame.js +124 -0
- package/dist/cjs/decorators/requestAnimationFrame.js.map +7 -0
- package/dist/cjs/decorators/resizeObserver.js +46 -55
- package/dist/cjs/decorators/resizeObserver.js.map +2 -2
- package/dist/cjs/decorators/setInterval.js +46 -14
- package/dist/cjs/decorators/setInterval.js.map +2 -2
- package/dist/cjs/decorators/setTimeout.js +49 -14
- package/dist/cjs/decorators/setTimeout.js.map +2 -2
- package/dist/cjs/elements/SwcAppMixin.js +19 -3
- package/dist/cjs/elements/SwcAppMixin.js.map +2 -2
- package/dist/cjs/types/window.d.js.map +1 -1
- package/dist/esm/decorators/addEventListener.js +1994 -9
- package/dist/esm/decorators/addEventListener.js.map +2 -2
- package/dist/esm/decorators/applyAttribute.js +10 -4
- package/dist/esm/decorators/applyAttribute.js.map +2 -2
- package/dist/esm/decorators/applyClass.js +10 -4
- package/dist/esm/decorators/applyClass.js.map +2 -2
- package/dist/esm/decorators/applyNode.js +10 -4
- package/dist/esm/decorators/applyNode.js.map +2 -2
- package/dist/esm/decorators/applyProperty.js +14 -8
- package/dist/esm/decorators/applyProperty.js.map +2 -2
- package/dist/esm/decorators/applySlot.js +6 -5
- package/dist/esm/decorators/applySlot.js.map +2 -2
- package/dist/esm/decorators/applyStyle.js +10 -4
- package/dist/esm/decorators/applyStyle.js.map +2 -2
- package/dist/esm/decorators/changedAttribute.js +22 -13
- package/dist/esm/decorators/changedAttribute.js.map +2 -2
- package/dist/esm/decorators/elementDefine.js +18 -3
- package/dist/esm/decorators/elementDefine.js.map +2 -2
- package/dist/esm/decorators/eventMedia.js +66 -0
- package/dist/esm/decorators/eventMedia.js.map +7 -0
- package/dist/esm/decorators/index.js +3 -0
- package/dist/esm/decorators/index.js.map +2 -2
- package/dist/esm/decorators/intersectionObserver.js +46 -55
- package/dist/esm/decorators/intersectionObserver.js.map +2 -2
- package/dist/esm/decorators/mutationObserver.js +46 -55
- package/dist/esm/decorators/mutationObserver.js.map +2 -2
- package/dist/esm/decorators/parameter.js +54 -0
- package/dist/esm/decorators/parameter.js.map +7 -0
- package/dist/esm/decorators/requestAnimationFrame.js +105 -0
- package/dist/esm/decorators/requestAnimationFrame.js.map +7 -0
- package/dist/esm/decorators/resizeObserver.js +46 -55
- package/dist/esm/decorators/resizeObserver.js.map +2 -2
- package/dist/esm/decorators/setInterval.js +46 -15
- package/dist/esm/decorators/setInterval.js.map +2 -2
- package/dist/esm/decorators/setTimeout.js +49 -15
- package/dist/esm/decorators/setTimeout.js.map +2 -2
- package/dist/esm/elements/SwcAppMixin.js +20 -4
- package/dist/esm/elements/SwcAppMixin.js.map +2 -2
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +2813 -571
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
- package/dist/types/decorators/addEventListener.d.ts +962 -0
- package/dist/types/decorators/addEventListener.d.ts.map +1 -1
- package/dist/types/decorators/applyAttribute.d.ts +2 -0
- package/dist/types/decorators/applyAttribute.d.ts.map +1 -1
- package/dist/types/decorators/applyClass.d.ts +2 -0
- package/dist/types/decorators/applyClass.d.ts.map +1 -1
- package/dist/types/decorators/applyNode.d.ts +2 -0
- package/dist/types/decorators/applyNode.d.ts.map +1 -1
- package/dist/types/decorators/applyProperty.d.ts +4 -0
- 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 -0
- package/dist/types/decorators/applyStyle.d.ts.map +1 -1
- package/dist/types/decorators/changedAttribute.d.ts +1 -3
- package/dist/types/decorators/changedAttribute.d.ts.map +1 -1
- package/dist/types/decorators/elementDefine.d.ts.map +1 -1
- package/dist/types/decorators/eventMedia.d.ts +25 -0
- package/dist/types/decorators/eventMedia.d.ts.map +1 -0
- package/dist/types/decorators/index.d.ts +3 -0
- package/dist/types/decorators/index.d.ts.map +1 -1
- package/dist/types/decorators/intersectionObserver.d.ts +9 -0
- package/dist/types/decorators/intersectionObserver.d.ts.map +1 -1
- package/dist/types/decorators/mutationObserver.d.ts +10 -1
- package/dist/types/decorators/mutationObserver.d.ts.map +1 -1
- package/dist/types/decorators/parameter.d.ts +35 -0
- package/dist/types/decorators/parameter.d.ts.map +1 -0
- 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 +9 -0
- package/dist/types/decorators/resizeObserver.d.ts.map +1 -1
- package/dist/types/decorators/setInterval.d.ts +17 -5
- package/dist/types/decorators/setInterval.d.ts.map +1 -1
- package/dist/types/decorators/setTimeout.d.ts +17 -5
- package/dist/types/decorators/setTimeout.d.ts.map +1 -1
- package/dist/types/elements/SwcAppMixin.d.ts.map +1 -1
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +2813 -571
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
- package/package.json +3 -3
- package/src/decorators/addEventListener.ts +1060 -8
- package/src/decorators/applyAttribute.ts +14 -4
- package/src/decorators/applyClass.ts +14 -4
- package/src/decorators/applyNode.ts +14 -4
- package/src/decorators/applyProperty.ts +28 -8
- package/src/decorators/applySlot.ts +6 -5
- package/src/decorators/applyStyle.ts +14 -4
- package/src/decorators/changedAttribute.ts +30 -15
- package/src/decorators/elementDefine.ts +32 -5
- package/src/decorators/eventMedia.ts +78 -0
- package/src/decorators/index.ts +3 -0
- package/src/decorators/intersectionObserver.ts +77 -61
- package/src/decorators/mutationObserver.ts +78 -61
- package/src/decorators/parameter.ts +81 -0
- package/src/decorators/requestAnimationFrame.ts +158 -0
- package/src/decorators/resizeObserver.ts +76 -60
- package/src/decorators/setInterval.ts +71 -15
- package/src/decorators/setTimeout.ts +74 -15
- package/src/elements/SwcAppMixin.ts +20 -5
- package/src/types/window.d.ts +2 -18
- package/dist/cjs/examples/RxJSOperatorsExample.js +0 -285
- package/dist/cjs/examples/RxJSOperatorsExample.js.map +0 -7
- package/dist/esm/examples/RxJSOperatorsExample.js +0 -266
- package/dist/esm/examples/RxJSOperatorsExample.js.map +0 -7
- package/dist/types/examples/RxJSOperatorsExample.d.ts +0 -94
- package/dist/types/examples/RxJSOperatorsExample.d.ts.map +0 -1
- package/src/examples/RxJSOperatorsExample.ts +0 -279
|
@@ -29,110 +29,126 @@ export interface IntersectionObserverMetadata {
|
|
|
29
29
|
|
|
30
30
|
export const INTERSECTION_OBSERVER_METADATA_KEY = Symbol.for('simple-web-component:intersection-observer');
|
|
31
31
|
|
|
32
|
+
const applyIntersectionObserver = (selector: SwcSelector, options: IntersectionObserverOptions, targetObj: Object, propertyKey: string | symbol): void => {
|
|
33
|
+
const constructor = targetObj.constructor;
|
|
34
|
+
let observers = ReflectUtils.getMetadata<IntersectionObserverMetadata[]>(INTERSECTION_OBSERVER_METADATA_KEY, constructor);
|
|
35
|
+
if (!observers) {
|
|
36
|
+
observers = [];
|
|
37
|
+
ReflectUtils.defineMetadata(INTERSECTION_OBSERVER_METADATA_KEY, observers, constructor);
|
|
38
|
+
}
|
|
39
|
+
observers.push({ propertyKey, selector, options });
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const resolveIntersectionObserverArgs = (
|
|
43
|
+
selectorOrOptions: SwcSelector | IntersectionObserverOptions | undefined,
|
|
44
|
+
maybeOptions: IntersectionObserverOptions | undefined,
|
|
45
|
+
extra: Partial<IntersectionObserverOptions>
|
|
46
|
+
): { selector: SwcSelector; options: IntersectionObserverOptions } => {
|
|
47
|
+
if (typeof selectorOrOptions === 'string' || typeof selectorOrOptions === 'function') {
|
|
48
|
+
return { selector: selectorOrOptions, options: { ...(maybeOptions ?? {}), ...extra } };
|
|
49
|
+
}
|
|
50
|
+
return { selector: '$this', options: { ...(selectorOrOptions ?? {}), ...extra } };
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* bare(@decorator)와 factory(@decorator()/@decorator(...)) 호출을 모두 처리하는 공통 디스패처.
|
|
55
|
+
* extra는 Light/Shadow/All/Delegate 변형이 강제로 덧씌우는 옵션(root, delegate 등)이다.
|
|
56
|
+
*/
|
|
57
|
+
const dispatchIntersectionObserver = (
|
|
58
|
+
selectorOrOptionsOrTarget: SwcSelector | IntersectionObserverOptions | Object | undefined,
|
|
59
|
+
maybeOptionsOrPropertyKey: IntersectionObserverOptions | string | symbol | undefined,
|
|
60
|
+
descriptor: PropertyDescriptor | undefined,
|
|
61
|
+
extra: Partial<IntersectionObserverOptions>
|
|
62
|
+
): MethodDecorator | void => {
|
|
63
|
+
if ((typeof maybeOptionsOrPropertyKey === 'string' || typeof maybeOptionsOrPropertyKey === 'symbol') && descriptor !== undefined) {
|
|
64
|
+
// 옵션 없이: @decorator
|
|
65
|
+
applyIntersectionObserver('$this', { ...extra }, selectorOrOptionsOrTarget as Object, maybeOptionsOrPropertyKey);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
// 옵션과 함께: @decorator() / @decorator(selector, options) / @decorator(options)
|
|
69
|
+
const { selector, options } = resolveIntersectionObserverArgs(
|
|
70
|
+
selectorOrOptionsOrTarget as SwcSelector | IntersectionObserverOptions | undefined,
|
|
71
|
+
maybeOptionsOrPropertyKey as IntersectionObserverOptions | undefined,
|
|
72
|
+
extra
|
|
73
|
+
);
|
|
74
|
+
return (targetObj: Object, propertyKey: string | symbol) => {
|
|
75
|
+
applyIntersectionObserver(selector, options, targetObj, propertyKey);
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
|
|
32
79
|
export function intersectionObserver(target: SpecialSelector, options?: IntersectionObserverQueryOptions): MethodDecorator;
|
|
33
80
|
export function intersectionObserver(selector: string, options?: IntersectionObserverQueryOptions): MethodDecorator;
|
|
34
81
|
export function intersectionObserver(selector: SwcFnSelector, options?: IntersectionObserverNonQueryOptions): MethodDecorator;
|
|
35
82
|
export function intersectionObserver(options?: IntersectionObserverQueryOptions): MethodDecorator;
|
|
83
|
+
export function intersectionObserver(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
|
|
36
84
|
/**
|
|
37
85
|
* @intersectionObserver decorator to observe element intersection changes.
|
|
38
86
|
*
|
|
39
87
|
* IntersectionObserver 는 생성 시점에 옵션(threshold/rootMargin/root)이 고정되므로,
|
|
40
88
|
* 옵션별로 그룹을 만들어 observer 를 생성한다. 같은 옵션 그룹 안에서 delegate 동적 추적이 가능하다.
|
|
89
|
+
* 옵션 없이 `@intersectionObserver` 그대로 붙여도 되고, `@intersectionObserver(...)`처럼 셀렉터/옵션을 줄 수도 있다.
|
|
41
90
|
*/
|
|
42
|
-
export function intersectionObserver(
|
|
43
|
-
return (
|
|
44
|
-
let selector: SwcSelector = '$this';
|
|
45
|
-
let options: IntersectionObserverOptions = {};
|
|
46
|
-
|
|
47
|
-
if (typeof selectorOrOptions === 'string' || typeof selectorOrOptions === 'function') {
|
|
48
|
-
selector = selectorOrOptions;
|
|
49
|
-
options = maybeOptions ?? {};
|
|
50
|
-
} else {
|
|
51
|
-
selector = '$this';
|
|
52
|
-
options = selectorOrOptions ?? {};
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const constructor = targetObj.constructor;
|
|
56
|
-
|
|
57
|
-
let observers = ReflectUtils.getMetadata<IntersectionObserverMetadata[]>(INTERSECTION_OBSERVER_METADATA_KEY, constructor);
|
|
58
|
-
if (!observers) {
|
|
59
|
-
observers = [];
|
|
60
|
-
ReflectUtils.defineMetadata(INTERSECTION_OBSERVER_METADATA_KEY, observers, constructor);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
observers.push({ propertyKey, selector, options });
|
|
64
|
-
};
|
|
91
|
+
export function intersectionObserver(selectorOrOptionsOrTarget?: SwcSelector | IntersectionObserverOptions | Object, maybeOptionsOrPropertyKey?: IntersectionObserverOptions | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | void {
|
|
92
|
+
return dispatchIntersectionObserver(selectorOrOptionsOrTarget, maybeOptionsOrPropertyKey, descriptor, {});
|
|
65
93
|
}
|
|
66
94
|
|
|
67
|
-
export function intersectionObserverThis(options?: IntersectionObserverQueryOptions): MethodDecorator
|
|
68
|
-
|
|
95
|
+
export function intersectionObserverThis(options?: IntersectionObserverQueryOptions): MethodDecorator;
|
|
96
|
+
export function intersectionObserverThis(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
|
|
97
|
+
export function intersectionObserverThis(optionsOrTarget?: IntersectionObserverQueryOptions | Object, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | void {
|
|
98
|
+
return dispatchIntersectionObserver(optionsOrTarget, propertyKey, descriptor, {});
|
|
69
99
|
}
|
|
70
100
|
|
|
71
101
|
// ─── root별 delegate 헬퍼 (root 주입 → 문자열 셀렉터 전용) ───
|
|
72
102
|
|
|
73
103
|
export function intersectionObserverDelegateLight(selector: string, options?: Omit<IntersectionObserverQueryOptions, 'delegate'>): MethodDecorator;
|
|
74
104
|
export function intersectionObserverDelegateLight(options?: Omit<IntersectionObserverQueryOptions, 'delegate'>): MethodDecorator;
|
|
75
|
-
export function intersectionObserverDelegateLight(
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
return intersectionObserver({...selectorOrOptions ?? {}, root: 'light', delegate: true});
|
|
105
|
+
export function intersectionObserverDelegateLight(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
|
|
106
|
+
export function intersectionObserverDelegateLight(selectorOrOptionsOrTarget?: string | Omit<IntersectionObserverQueryOptions, 'delegate'> | Object, maybeOptionsOrPropertyKey?: Omit<IntersectionObserverQueryOptions, 'delegate'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | void {
|
|
107
|
+
return dispatchIntersectionObserver(selectorOrOptionsOrTarget as any, maybeOptionsOrPropertyKey as any, descriptor, { root: 'light', delegate: true });
|
|
80
108
|
}
|
|
81
109
|
|
|
82
110
|
export function intersectionObserverDelegateShadow(selector: string, options?: Omit<IntersectionObserverQueryOptions, 'delegate'>): MethodDecorator;
|
|
83
111
|
export function intersectionObserverDelegateShadow(options?: Omit<IntersectionObserverQueryOptions, 'delegate'>): MethodDecorator;
|
|
84
|
-
export function intersectionObserverDelegateShadow(
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
return intersectionObserver({...selectorOrOptions ?? {}, root: 'shadow', delegate: true});
|
|
112
|
+
export function intersectionObserverDelegateShadow(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
|
|
113
|
+
export function intersectionObserverDelegateShadow(selectorOrOptionsOrTarget?: string | Omit<IntersectionObserverQueryOptions, 'delegate'> | Object, maybeOptionsOrPropertyKey?: Omit<IntersectionObserverQueryOptions, 'delegate'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | void {
|
|
114
|
+
return dispatchIntersectionObserver(selectorOrOptionsOrTarget as any, maybeOptionsOrPropertyKey as any, descriptor, { root: 'shadow', delegate: true });
|
|
89
115
|
}
|
|
90
116
|
|
|
91
117
|
export function intersectionObserverDelegateAll(selector: string, options?: Omit<IntersectionObserverQueryOptions, 'delegate'>): MethodDecorator;
|
|
92
118
|
export function intersectionObserverDelegateAll(options?: Omit<IntersectionObserverQueryOptions, 'delegate'>): MethodDecorator;
|
|
93
|
-
export function intersectionObserverDelegateAll(
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
return intersectionObserver({...selectorOrOptions ?? {}, root: 'all', delegate: true});
|
|
119
|
+
export function intersectionObserverDelegateAll(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
|
|
120
|
+
export function intersectionObserverDelegateAll(selectorOrOptionsOrTarget?: string | Omit<IntersectionObserverQueryOptions, 'delegate'> | Object, maybeOptionsOrPropertyKey?: Omit<IntersectionObserverQueryOptions, 'delegate'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | void {
|
|
121
|
+
return dispatchIntersectionObserver(selectorOrOptionsOrTarget as any, maybeOptionsOrPropertyKey as any, descriptor, { root: 'all', delegate: true });
|
|
98
122
|
}
|
|
99
123
|
|
|
100
124
|
export function intersectionObserverDelegate(selector: string, options?: Omit<IntersectionObserverQueryOptions, 'delegate'>): MethodDecorator;
|
|
101
125
|
export function intersectionObserverDelegate(options?: Omit<IntersectionObserverQueryOptions, 'delegate'>): MethodDecorator;
|
|
102
|
-
export function intersectionObserverDelegate(
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
return intersectionObserver({...selectorOrOptions ?? {}, root: 'auto', delegate: true});
|
|
126
|
+
export function intersectionObserverDelegate(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
|
|
127
|
+
export function intersectionObserverDelegate(selectorOrOptionsOrTarget?: string | Omit<IntersectionObserverQueryOptions, 'delegate'> | Object, maybeOptionsOrPropertyKey?: Omit<IntersectionObserverQueryOptions, 'delegate'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | void {
|
|
128
|
+
return dispatchIntersectionObserver(selectorOrOptionsOrTarget as any, maybeOptionsOrPropertyKey as any, descriptor, { root: 'auto', delegate: true });
|
|
107
129
|
}
|
|
108
130
|
|
|
109
131
|
// ─── root별 일반 헬퍼 (delegate 없이, 셀렉터 생략 시 $this) ───
|
|
110
132
|
|
|
111
133
|
export function intersectionObserverLight(selector: string, options?: IntersectionObserverQueryOptions): MethodDecorator;
|
|
112
134
|
export function intersectionObserverLight(options?: IntersectionObserverQueryOptions): MethodDecorator;
|
|
113
|
-
export function intersectionObserverLight(
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
return intersectionObserver({...selectorOrOptions ?? {}, root: 'light'});
|
|
135
|
+
export function intersectionObserverLight(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
|
|
136
|
+
export function intersectionObserverLight(selectorOrOptionsOrTarget?: string | IntersectionObserverQueryOptions | Object, maybeOptionsOrPropertyKey?: IntersectionObserverQueryOptions | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | void {
|
|
137
|
+
return dispatchIntersectionObserver(selectorOrOptionsOrTarget as any, maybeOptionsOrPropertyKey as any, descriptor, { root: 'light' });
|
|
118
138
|
}
|
|
119
139
|
|
|
120
140
|
export function intersectionObserverShadow(selector: string, options?: IntersectionObserverQueryOptions): MethodDecorator;
|
|
121
141
|
export function intersectionObserverShadow(options?: IntersectionObserverQueryOptions): MethodDecorator;
|
|
122
|
-
export function intersectionObserverShadow(
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
return intersectionObserver({...selectorOrOptions ?? {}, root: 'shadow'});
|
|
142
|
+
export function intersectionObserverShadow(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
|
|
143
|
+
export function intersectionObserverShadow(selectorOrOptionsOrTarget?: string | IntersectionObserverQueryOptions | Object, maybeOptionsOrPropertyKey?: IntersectionObserverQueryOptions | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | void {
|
|
144
|
+
return dispatchIntersectionObserver(selectorOrOptionsOrTarget as any, maybeOptionsOrPropertyKey as any, descriptor, { root: 'shadow' });
|
|
127
145
|
}
|
|
128
146
|
|
|
129
147
|
export function intersectionObserverAll(selector: string, options?: IntersectionObserverQueryOptions): MethodDecorator;
|
|
130
148
|
export function intersectionObserverAll(options?: IntersectionObserverQueryOptions): MethodDecorator;
|
|
131
|
-
export function intersectionObserverAll(
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
return intersectionObserver({...selectorOrOptions ?? {}, root: 'all'});
|
|
149
|
+
export function intersectionObserverAll(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
|
|
150
|
+
export function intersectionObserverAll(selectorOrOptionsOrTarget?: string | IntersectionObserverQueryOptions | Object, maybeOptionsOrPropertyKey?: IntersectionObserverQueryOptions | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | void {
|
|
151
|
+
return dispatchIntersectionObserver(selectorOrOptionsOrTarget as any, maybeOptionsOrPropertyKey as any, descriptor, { root: 'all' });
|
|
136
152
|
}
|
|
137
153
|
|
|
138
154
|
export function getIntersectionObserverMetadata(target: any): IntersectionObserverMetadata[] | undefined {
|
|
@@ -256,4 +272,4 @@ export class IntersectionObserverLifeCycler implements ElementDefineLifeCycler {
|
|
|
256
272
|
}
|
|
257
273
|
this.removeObserverCallbacksMap.delete(inst);
|
|
258
274
|
}
|
|
259
|
-
}
|
|
275
|
+
}
|
|
@@ -24,107 +24,124 @@ export interface MutationObserverMetadata {
|
|
|
24
24
|
|
|
25
25
|
export const MUTATION_OBSERVER_METADATA_KEY = Symbol.for('simple-web-component:mutation-observer');
|
|
26
26
|
|
|
27
|
+
const applyMutationObserver = (selector: SwcSelector, options: MutationObserverQueryOptions, targetObj: Object, propertyKey: string | symbol): void => {
|
|
28
|
+
const constructor = targetObj.constructor;
|
|
29
|
+
let observers = ReflectUtils.getMetadata<MutationObserverMetadata[]>(MUTATION_OBSERVER_METADATA_KEY, constructor);
|
|
30
|
+
if (!observers) {
|
|
31
|
+
observers = [];
|
|
32
|
+
ReflectUtils.defineMetadata(MUTATION_OBSERVER_METADATA_KEY, observers, constructor);
|
|
33
|
+
}
|
|
34
|
+
observers.push({ propertyKey, selector, options });
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const resolveMutationObserverArgs = (
|
|
38
|
+
selectorOrOptions: SwcSelector | MutationObserverQueryOptions | undefined,
|
|
39
|
+
maybeOptions: MutationObserverQueryOptions | undefined,
|
|
40
|
+
extra: Partial<MutationObserverQueryOptions>
|
|
41
|
+
): { selector: SwcSelector; options: MutationObserverQueryOptions } => {
|
|
42
|
+
if (typeof selectorOrOptions === 'string' || typeof selectorOrOptions === 'function') {
|
|
43
|
+
return { selector: selectorOrOptions, options: { ...(maybeOptions ?? {}), ...extra } };
|
|
44
|
+
}
|
|
45
|
+
return { selector: '$this', options: { ...(selectorOrOptions ?? {}), ...extra } };
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* selectorOrOptionsOrTarget/maybeOptionsOrPropertyKey/descriptor을 받아 bare(@decorator)와
|
|
50
|
+
* factory(@decorator()/@decorator(...)) 호출을 모두 처리하는 공통 디스패처.
|
|
51
|
+
* extra는 Light/Shadow/All/Delegate 변형이 강제로 덧씌우는 옵션(root, delegate 등)이다.
|
|
52
|
+
*/
|
|
53
|
+
const dispatchMutationObserver = (
|
|
54
|
+
selectorOrOptionsOrTarget: SwcSelector | MutationObserverQueryOptions | Object | undefined,
|
|
55
|
+
maybeOptionsOrPropertyKey: MutationObserverQueryOptions | string | symbol | undefined,
|
|
56
|
+
descriptor: PropertyDescriptor | undefined,
|
|
57
|
+
extra: Partial<MutationObserverQueryOptions>
|
|
58
|
+
): MethodDecorator | void => {
|
|
59
|
+
if ((typeof maybeOptionsOrPropertyKey === 'string' || typeof maybeOptionsOrPropertyKey === 'symbol') && descriptor !== undefined) {
|
|
60
|
+
// 옵션 없이: @decorator
|
|
61
|
+
applyMutationObserver('$this', { ...extra }, selectorOrOptionsOrTarget as Object, maybeOptionsOrPropertyKey);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
// 옵션과 함께: @decorator() / @decorator(selector, options) / @decorator(options)
|
|
65
|
+
const { selector, options } = resolveMutationObserverArgs(
|
|
66
|
+
selectorOrOptionsOrTarget as SwcSelector | MutationObserverQueryOptions | undefined,
|
|
67
|
+
maybeOptionsOrPropertyKey as MutationObserverQueryOptions | undefined,
|
|
68
|
+
extra
|
|
69
|
+
);
|
|
70
|
+
return (targetObj: Object, propertyKey: string | symbol) => {
|
|
71
|
+
applyMutationObserver(selector, options, targetObj, propertyKey);
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
|
|
27
75
|
export function mutationObserver(target: SpecialSelector, options?: MutationObserverQueryOptions): MethodDecorator;
|
|
28
76
|
export function mutationObserver(selector: string, options?: MutationObserverQueryOptions): MethodDecorator;
|
|
29
77
|
export function mutationObserver(selector: SwcFnSelector, options?: MutationObserverNonQueryOptions): MethodDecorator;
|
|
30
78
|
export function mutationObserver(options?: MutationObserverQueryOptions): MethodDecorator;
|
|
79
|
+
export function mutationObserver(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
|
|
31
80
|
/**
|
|
32
81
|
* @mutationObserver decorator to observe DOM mutations.
|
|
82
|
+
* 옵션 없이 `@mutationObserver` 그대로 붙여도 되고, `@mutationObserver(...)`처럼 셀렉터/옵션을 줄 수도 있다.
|
|
33
83
|
*/
|
|
34
|
-
export function mutationObserver(
|
|
35
|
-
return (
|
|
36
|
-
let selector: SwcSelector = '$this';
|
|
37
|
-
let options: MutationObserverQueryOptions = {};
|
|
38
|
-
|
|
39
|
-
if (typeof selectorOrOptions === 'string' || typeof selectorOrOptions === 'function') {
|
|
40
|
-
selector = selectorOrOptions;
|
|
41
|
-
options = maybeOptions ?? {};
|
|
42
|
-
} else {
|
|
43
|
-
selector = '$this';
|
|
44
|
-
options = selectorOrOptions ?? {};
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const constructor = targetObj.constructor;
|
|
48
|
-
|
|
49
|
-
let observers = ReflectUtils.getMetadata<MutationObserverMetadata[]>(MUTATION_OBSERVER_METADATA_KEY, constructor);
|
|
50
|
-
if (!observers) {
|
|
51
|
-
observers = [];
|
|
52
|
-
ReflectUtils.defineMetadata(MUTATION_OBSERVER_METADATA_KEY, observers, constructor);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
observers.push({ propertyKey, selector, options });
|
|
56
|
-
};
|
|
84
|
+
export function mutationObserver(selectorOrOptionsOrTarget?: SwcSelector | MutationObserverQueryOptions | Object, maybeOptionsOrPropertyKey?: MutationObserverQueryOptions | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | void {
|
|
85
|
+
return dispatchMutationObserver(selectorOrOptionsOrTarget, maybeOptionsOrPropertyKey, descriptor, {});
|
|
57
86
|
}
|
|
58
87
|
|
|
59
|
-
export function mutationObserverThis
|
|
60
|
-
|
|
88
|
+
export function mutationObserverThis(options?: MutationObserverQueryOptions): MethodDecorator;
|
|
89
|
+
export function mutationObserverThis(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
|
|
90
|
+
export function mutationObserverThis(optionsOrTarget?: MutationObserverQueryOptions | Object, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | void {
|
|
91
|
+
return dispatchMutationObserver(optionsOrTarget, propertyKey, descriptor, {});
|
|
61
92
|
}
|
|
62
93
|
|
|
63
94
|
// ─── root별 delegate 헬퍼 (addEventListener와 동일 패턴) ───
|
|
64
95
|
|
|
65
96
|
export function mutationObserverDelegateLight(selector: string, options?: MutationObserverBaseOptions): MethodDecorator;
|
|
66
97
|
export function mutationObserverDelegateLight(options?: MutationObserverBaseOptions): MethodDecorator;
|
|
67
|
-
export function mutationObserverDelegateLight(
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
return mutationObserver({...selectorOrOptions ?? {}, root: 'light', delegate: true});
|
|
98
|
+
export function mutationObserverDelegateLight(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
|
|
99
|
+
export function mutationObserverDelegateLight(selectorOrOptionsOrTarget?: string | Omit<MutationObserverQueryOptions, 'root'> | Object, maybeOptionsOrPropertyKey?: Omit<MutationObserverQueryOptions, 'root'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | void {
|
|
100
|
+
return dispatchMutationObserver(selectorOrOptionsOrTarget as any, maybeOptionsOrPropertyKey as any, descriptor, { root: 'light', delegate: true });
|
|
72
101
|
}
|
|
73
102
|
|
|
74
103
|
export function mutationObserverDelegateShadow(selector: string, options?: MutationObserverBaseOptions): MethodDecorator;
|
|
75
104
|
export function mutationObserverDelegateShadow(options?: MutationObserverBaseOptions): MethodDecorator;
|
|
76
|
-
export function mutationObserverDelegateShadow(
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
return mutationObserver({...selectorOrOptions ?? {}, root: 'shadow', delegate: true});
|
|
105
|
+
export function mutationObserverDelegateShadow(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
|
|
106
|
+
export function mutationObserverDelegateShadow(selectorOrOptionsOrTarget?: string | Omit<MutationObserverQueryOptions, 'root'> | Object, maybeOptionsOrPropertyKey?: Omit<MutationObserverQueryOptions, 'root'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | void {
|
|
107
|
+
return dispatchMutationObserver(selectorOrOptionsOrTarget as any, maybeOptionsOrPropertyKey as any, descriptor, { root: 'shadow', delegate: true });
|
|
81
108
|
}
|
|
82
109
|
|
|
83
110
|
export function mutationObserverDelegateAll(selector: string, options?: MutationObserverBaseOptions): MethodDecorator;
|
|
84
111
|
export function mutationObserverDelegateAll(options?: MutationObserverBaseOptions): MethodDecorator;
|
|
85
|
-
export function mutationObserverDelegateAll(
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
return mutationObserver({...selectorOrOptions ?? {}, root: 'all', delegate: true});
|
|
112
|
+
export function mutationObserverDelegateAll(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
|
|
113
|
+
export function mutationObserverDelegateAll(selectorOrOptionsOrTarget?: string | Omit<MutationObserverQueryOptions, 'root'> | Object, maybeOptionsOrPropertyKey?: Omit<MutationObserverQueryOptions, 'root'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | void {
|
|
114
|
+
return dispatchMutationObserver(selectorOrOptionsOrTarget as any, maybeOptionsOrPropertyKey as any, descriptor, { root: 'all', delegate: true });
|
|
90
115
|
}
|
|
91
116
|
|
|
92
117
|
export function mutationObserverDelegate(selector: string, options?: MutationObserverBaseOptions): MethodDecorator;
|
|
93
118
|
export function mutationObserverDelegate(options?: MutationObserverBaseOptions): MethodDecorator;
|
|
94
|
-
export function mutationObserverDelegate(
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
return mutationObserver({...selectorOrOptions ?? {}, root: 'auto', delegate: true});
|
|
119
|
+
export function mutationObserverDelegate(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
|
|
120
|
+
export function mutationObserverDelegate(selectorOrOptionsOrTarget?: string | Omit<MutationObserverQueryOptions, 'root'> | Object, maybeOptionsOrPropertyKey?: Omit<MutationObserverQueryOptions, 'root'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | void {
|
|
121
|
+
return dispatchMutationObserver(selectorOrOptionsOrTarget as any, maybeOptionsOrPropertyKey as any, descriptor, { root: 'auto', delegate: true });
|
|
99
122
|
}
|
|
100
123
|
|
|
101
124
|
// ─── root별 일반 헬퍼 (delegate 없이, 셀렉터 생략 시 $this) ───
|
|
102
125
|
|
|
103
126
|
export function mutationObserverLight(selector: string, options?: Omit<MutationObserverQueryOptions, 'root'>): MethodDecorator;
|
|
104
127
|
export function mutationObserverLight(options?: Omit<MutationObserverQueryOptions, 'root'>): MethodDecorator;
|
|
105
|
-
export function mutationObserverLight(
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
return mutationObserver({...selectorOrOptions ?? {}, root: 'light'});
|
|
128
|
+
export function mutationObserverLight(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
|
|
129
|
+
export function mutationObserverLight(selectorOrOptionsOrTarget?: string | Omit<MutationObserverQueryOptions, 'root'> | Object, maybeOptionsOrPropertyKey?: Omit<MutationObserverQueryOptions, 'root'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | void {
|
|
130
|
+
return dispatchMutationObserver(selectorOrOptionsOrTarget as any, maybeOptionsOrPropertyKey as any, descriptor, { root: 'light' });
|
|
110
131
|
}
|
|
111
132
|
|
|
112
133
|
export function mutationObserverShadow(selector: string, options?: Omit<MutationObserverQueryOptions, 'root'>): MethodDecorator;
|
|
113
134
|
export function mutationObserverShadow(options?: Omit<MutationObserverQueryOptions, 'root'>): MethodDecorator;
|
|
114
|
-
export function mutationObserverShadow(
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
-
return mutationObserver({...selectorOrOptions ?? {}, root: 'shadow'});
|
|
135
|
+
export function mutationObserverShadow(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
|
|
136
|
+
export function mutationObserverShadow(selectorOrOptionsOrTarget?: string | Omit<MutationObserverQueryOptions, 'root'> | Object, maybeOptionsOrPropertyKey?: Omit<MutationObserverQueryOptions, 'root'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | void {
|
|
137
|
+
return dispatchMutationObserver(selectorOrOptionsOrTarget as any, maybeOptionsOrPropertyKey as any, descriptor, { root: 'shadow' });
|
|
119
138
|
}
|
|
120
139
|
|
|
121
140
|
export function mutationObserverAll(selector: string, options?: Omit<MutationObserverQueryOptions, 'root'>): MethodDecorator;
|
|
122
141
|
export function mutationObserverAll(options?: Omit<MutationObserverQueryOptions, 'root'>): MethodDecorator;
|
|
123
|
-
export function mutationObserverAll(
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
return mutationObserver({...selectorOrOptions ?? {}, root: 'all'});
|
|
142
|
+
export function mutationObserverAll(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
|
|
143
|
+
export function mutationObserverAll(selectorOrOptionsOrTarget?: string | Omit<MutationObserverQueryOptions, 'root'> | Object, maybeOptionsOrPropertyKey?: Omit<MutationObserverQueryOptions, 'root'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | void {
|
|
144
|
+
return dispatchMutationObserver(selectorOrOptionsOrTarget as any, maybeOptionsOrPropertyKey as any, descriptor, { root: 'all' });
|
|
128
145
|
}
|
|
129
146
|
|
|
130
147
|
export function getMutationObserverMetadata(target: any): MutationObserverMetadata[] | undefined {
|
|
@@ -301,4 +318,4 @@ export class MutationObserverLifeCycler implements ElementDefineLifeCycler {
|
|
|
301
318
|
}
|
|
302
319
|
this.removeObserverCallbacksMap.delete(inst);
|
|
303
320
|
}
|
|
304
|
-
}
|
|
321
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { ReflectUtils } from '@dooboostore/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @eventObject/@matchedElement/@hostSet/@helperHostSet/@helperSet/@routerEvent/@appMessage —
|
|
5
|
+
* @addEventListener/lifecycle/subscribeSwcAppRouteChangeWhileConnected/subscribeSwcAppMessageWhileConnected
|
|
6
|
+
* 계열 핸들러의 파라미터를 순서 무관하게 선언할 수 있게 해주는 파라미터 데코레이터.
|
|
7
|
+
* @dooboostore/simple-boot의 @Inject와 동일한 인덱스 기반 메타데이터 패턴을 따른다:
|
|
8
|
+
* 데코레이터가 실행되는 순서가 아니라 실제 parameterIndex로 슬롯을 매칭하므로,
|
|
9
|
+
* 사용자가 파라미터 선언 순서를 자유롭게 바꿔도 된다.
|
|
10
|
+
*/
|
|
11
|
+
export type SwcParamKind = 'event' | 'matched' | 'hostSet' | 'helperHostSet' | 'helperSet' | 'routerEvent' | 'appMessage';
|
|
12
|
+
|
|
13
|
+
const SWC_PARAMETER_METADATA_KEY = Symbol.for('simple-web-component:parameter');
|
|
14
|
+
|
|
15
|
+
type SaveParamConfig = { index: number; kind: SwcParamKind };
|
|
16
|
+
|
|
17
|
+
const registerParam = (kind: SwcParamKind, target: Object, propertyKey: string | symbol | undefined, parameterIndex: number) => {
|
|
18
|
+
if (!propertyKey) return;
|
|
19
|
+
const constructor = target.constructor;
|
|
20
|
+
const saves = (ReflectUtils.getOwnMetadata(SWC_PARAMETER_METADATA_KEY, constructor, propertyKey) ?? []) as SaveParamConfig[];
|
|
21
|
+
saves.push({ index: parameterIndex, kind });
|
|
22
|
+
ReflectUtils.defineMetadata(SWC_PARAMETER_METADATA_KEY, saves, constructor, propertyKey);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/** 이벤트 핸들러의 원본 Event 객체를 주입한다. */
|
|
26
|
+
export function eventObject(target: Object, propertyKey: string | symbol, parameterIndex: number): void {
|
|
27
|
+
registerParam('event', target, propertyKey, parameterIndex);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** delegate로 매칭된 실제 엘리먼트($matchedElement)를 주입한다. */
|
|
31
|
+
export function matchedElement(target: Object, propertyKey: string | symbol, parameterIndex: number): void {
|
|
32
|
+
registerParam('matched', target, propertyKey, parameterIndex);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** HostSet(호스트 트리 정보 — $host/$hosts/$firstHost/$appHost 등)을 주입한다. */
|
|
36
|
+
export function hostSet(target: Object, propertyKey: string | symbol, parameterIndex: number): void {
|
|
37
|
+
registerParam('hostSet', target, propertyKey, parameterIndex);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** HelperHostSet(HelperSet + HostSet + $this 전체 묶음)을 주입한다. */
|
|
41
|
+
export function helperHostSet(target: Object, propertyKey: string | symbol, parameterIndex: number): void {
|
|
42
|
+
registerParam('helperHostSet', target, propertyKey, parameterIndex);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** HelperSet($d/$w/$q/$qa/$qi 등 순수 DOM/window 헬퍼, 호스트 트리 정보 없음)을 주입한다. */
|
|
46
|
+
export function helperSet(target: Object, propertyKey: string | symbol, parameterIndex: number): void {
|
|
47
|
+
registerParam('helperSet', target, propertyKey, parameterIndex);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** @subscribeSwcAppRouteChangeWhileConnected 핸들러의 라우트 변경 이벤트({...RouterEventType, pathData})를 주입한다. */
|
|
51
|
+
export function routerEvent(target: Object, propertyKey: string | symbol, parameterIndex: number): void {
|
|
52
|
+
registerParam('routerEvent', target, propertyKey, parameterIndex);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** @subscribeSwcAppMessageWhileConnected 핸들러의 SwcAppMessage 페이로드를 주입한다. */
|
|
56
|
+
export function appMessage(target: Object, propertyKey: string | symbol, parameterIndex: number): void {
|
|
57
|
+
registerParam('appMessage', target, propertyKey, parameterIndex);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export const getParameterMetadata = (target: any, propertyKey: string | symbol): SaveParamConfig[] => {
|
|
61
|
+
const constructor = target instanceof Function ? target : target.constructor;
|
|
62
|
+
return ReflectUtils.getMetadata(SWC_PARAMETER_METADATA_KEY, constructor, propertyKey) ?? [];
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* 위 파라미터 데코레이터 메타데이터가 하나라도 있으면 kind별 값을 index 순서에 맞게
|
|
67
|
+
* 배열로 조립하고, 하나도 없으면 기존 위치 인자(legacyArgs)를 그대로 반환한다 — 완전 하위호환.
|
|
68
|
+
*/
|
|
69
|
+
export const buildSwcParameterArgs = (
|
|
70
|
+
target: any,
|
|
71
|
+
propertyKey: string | symbol,
|
|
72
|
+
kindValues: Partial<Record<SwcParamKind, any>>,
|
|
73
|
+
legacyArgs: any[]
|
|
74
|
+
): any[] => {
|
|
75
|
+
const saves = getParameterMetadata(target, propertyKey);
|
|
76
|
+
if (saves.length === 0) return legacyArgs;
|
|
77
|
+
const maxIndex = Math.max(...saves.map(s => s.index));
|
|
78
|
+
const args: any[] = new Array(maxIndex + 1);
|
|
79
|
+
for (const s of saves) args[s.index] = kindValues[s.kind];
|
|
80
|
+
return args;
|
|
81
|
+
};
|