@dooboostore/simple-web-component 1.0.41 → 1.0.43

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.
Files changed (95) hide show
  1. package/README.md +423 -68
  2. package/dist/cjs/decorators/addEventListener.js +10 -0
  3. package/dist/cjs/decorators/addEventListener.js.map +2 -2
  4. package/dist/cjs/decorators/applyAttribute.js +11 -2
  5. package/dist/cjs/decorators/applyAttribute.js.map +2 -2
  6. package/dist/cjs/decorators/applyClass.js +9 -2
  7. package/dist/cjs/decorators/applyClass.js.map +2 -2
  8. package/dist/cjs/decorators/applyNode.js +11 -2
  9. package/dist/cjs/decorators/applyNode.js.map +2 -2
  10. package/dist/cjs/decorators/applyProperty.js +10 -2
  11. package/dist/cjs/decorators/applyProperty.js.map +2 -2
  12. package/dist/cjs/decorators/applySlot.js +11 -2
  13. package/dist/cjs/decorators/applySlot.js.map +2 -2
  14. package/dist/cjs/decorators/applyStyle.js +9 -2
  15. package/dist/cjs/decorators/applyStyle.js.map +2 -2
  16. package/dist/cjs/decorators/elementDefine.js +9 -23
  17. package/dist/cjs/decorators/elementDefine.js.map +2 -2
  18. package/dist/cjs/decorators/emitCustomEvent.js +2 -0
  19. package/dist/cjs/decorators/emitCustomEvent.js.map +2 -2
  20. package/dist/cjs/decorators/lifecycles.js +78 -21
  21. package/dist/cjs/decorators/lifecycles.js.map +2 -2
  22. package/dist/cjs/decorators/publishSwcAppMessage.js +37 -23
  23. package/dist/cjs/decorators/publishSwcAppMessage.js.map +2 -2
  24. package/dist/cjs/decorators/subscribeSwcAppRouteChangeWhileConnected.js +3 -1
  25. package/dist/cjs/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +2 -2
  26. package/dist/cjs/elements/SwcAppMixin.js +4 -9
  27. package/dist/cjs/elements/SwcAppMixin.js.map +2 -2
  28. package/dist/esm/decorators/addEventListener.js +10 -0
  29. package/dist/esm/decorators/addEventListener.js.map +2 -2
  30. package/dist/esm/decorators/applyAttribute.js +11 -2
  31. package/dist/esm/decorators/applyAttribute.js.map +2 -2
  32. package/dist/esm/decorators/applyClass.js +9 -2
  33. package/dist/esm/decorators/applyClass.js.map +2 -2
  34. package/dist/esm/decorators/applyNode.js +11 -2
  35. package/dist/esm/decorators/applyNode.js.map +2 -2
  36. package/dist/esm/decorators/applyProperty.js +10 -2
  37. package/dist/esm/decorators/applyProperty.js.map +2 -2
  38. package/dist/esm/decorators/applySlot.js +11 -2
  39. package/dist/esm/decorators/applySlot.js.map +2 -2
  40. package/dist/esm/decorators/applyStyle.js +9 -2
  41. package/dist/esm/decorators/applyStyle.js.map +2 -2
  42. package/dist/esm/decorators/elementDefine.js +9 -23
  43. package/dist/esm/decorators/elementDefine.js.map +2 -2
  44. package/dist/esm/decorators/emitCustomEvent.js +2 -0
  45. package/dist/esm/decorators/emitCustomEvent.js.map +2 -2
  46. package/dist/esm/decorators/lifecycles.js +78 -21
  47. package/dist/esm/decorators/lifecycles.js.map +2 -2
  48. package/dist/esm/decorators/publishSwcAppMessage.js +37 -23
  49. package/dist/esm/decorators/publishSwcAppMessage.js.map +2 -2
  50. package/dist/esm/decorators/subscribeSwcAppRouteChangeWhileConnected.js +3 -1
  51. package/dist/esm/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +2 -2
  52. package/dist/esm/elements/SwcAppMixin.js +4 -9
  53. package/dist/esm/elements/SwcAppMixin.js.map +2 -2
  54. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +216 -126
  55. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +3 -3
  56. package/dist/types/decorators/addEventListener.d.ts +5 -0
  57. package/dist/types/decorators/addEventListener.d.ts.map +1 -1
  58. package/dist/types/decorators/applyAttribute.d.ts +26 -0
  59. package/dist/types/decorators/applyAttribute.d.ts.map +1 -1
  60. package/dist/types/decorators/applyClass.d.ts +6 -0
  61. package/dist/types/decorators/applyClass.d.ts.map +1 -1
  62. package/dist/types/decorators/applyNode.d.ts +6 -0
  63. package/dist/types/decorators/applyNode.d.ts.map +1 -1
  64. package/dist/types/decorators/applyProperty.d.ts +26 -0
  65. package/dist/types/decorators/applyProperty.d.ts.map +1 -1
  66. package/dist/types/decorators/applySlot.d.ts +6 -0
  67. package/dist/types/decorators/applySlot.d.ts.map +1 -1
  68. package/dist/types/decorators/applyStyle.d.ts +6 -0
  69. package/dist/types/decorators/applyStyle.d.ts.map +1 -1
  70. package/dist/types/decorators/elementDefine.d.ts.map +1 -1
  71. package/dist/types/decorators/emitCustomEvent.d.ts +17 -0
  72. package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
  73. package/dist/types/decorators/lifecycles.d.ts +25 -11
  74. package/dist/types/decorators/lifecycles.d.ts.map +1 -1
  75. package/dist/types/decorators/publishSwcAppMessage.d.ts +19 -0
  76. package/dist/types/decorators/publishSwcAppMessage.d.ts.map +1 -1
  77. package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts +1 -1
  78. package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts.map +1 -1
  79. package/dist/types/elements/SwcAppMixin.d.ts.map +1 -1
  80. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +216 -126
  81. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +3 -3
  82. package/package.json +1 -3
  83. package/src/decorators/addEventListener.ts +7 -0
  84. package/src/decorators/applyAttribute.ts +58 -2
  85. package/src/decorators/applyClass.ts +24 -2
  86. package/src/decorators/applyNode.ts +26 -2
  87. package/src/decorators/applyProperty.ts +57 -2
  88. package/src/decorators/applySlot.ts +24 -10
  89. package/src/decorators/applyStyle.ts +24 -2
  90. package/src/decorators/elementDefine.ts +9 -23
  91. package/src/decorators/emitCustomEvent.ts +19 -0
  92. package/src/decorators/lifecycles.ts +120 -26
  93. package/src/decorators/publishSwcAppMessage.ts +71 -27
  94. package/src/decorators/subscribeSwcAppRouteChangeWhileConnected.ts +6 -2
  95. package/src/elements/SwcAppMixin.ts +5 -11
@@ -26,12 +26,21 @@ export interface InnerHtmlMetadata {
26
26
 
27
27
  export interface OnConnectedOptions {
28
28
  ssrFirst?: boolean;
29
+ order?: number;
29
30
  }
30
31
  export interface OnConnectedMetadata {
31
32
  propertyKey: string | symbol;
32
33
  options: OnConnectedOptions;
33
34
  }
34
35
 
36
+ export interface LifecycleOptions {
37
+ order?: number;
38
+ }
39
+ export interface LifecycleMetadata {
40
+ propertyKey: string | symbol;
41
+ order?: number;
42
+ }
43
+
35
44
 
36
45
  export function onConnectedBefore(options: OnConnectedOptions): MethodDecorator;
37
46
  export function onConnectedBefore(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
@@ -78,35 +87,107 @@ export function onConnectedAfter(arg1?: OnConnectedOptions | Object, arg2?: stri
78
87
  }
79
88
 
80
89
 
81
- function createLifecycleDecorator(metadataKey: symbol): MethodDecorator {
82
- return (target: Object, propertyKey: string | symbol) => {
83
- const constructor = target.constructor;
84
- let list = ReflectUtils.getOwnMetadata(metadataKey, constructor) as (string | symbol)[];
85
- if (!list) {
86
- list = [];
87
- ReflectUtils.defineMetadata(metadataKey, list, constructor);
90
+ function createLifecycleDecorator(metadataKey: symbol): ((options?: LifecycleOptions) => MethodDecorator) & MethodDecorator {
91
+ const decorator = (options?: LifecycleOptions): MethodDecorator => {
92
+ return (target: Object, propertyKey: string | symbol) => {
93
+ const constructor = target.constructor;
94
+ let list = ReflectUtils.getOwnMetadata(metadataKey, constructor) as LifecycleMetadata[];
95
+ if (!list) {
96
+ list = [];
97
+ ReflectUtils.defineMetadata(metadataKey, list, constructor);
98
+ }
99
+ list.push({ propertyKey, order: options?.order ?? 0 });
100
+ };
101
+ };
102
+
103
+ // Support both @decorator and @decorator() syntax
104
+ return Object.assign(
105
+ (target: Object, propertyKey: string | symbol) => {
106
+ const constructor = target.constructor;
107
+ let list = ReflectUtils.getOwnMetadata(metadataKey, constructor) as LifecycleMetadata[];
108
+ if (!list) {
109
+ list = [];
110
+ ReflectUtils.defineMetadata(metadataKey, list, constructor);
111
+ }
112
+ list.push({ propertyKey, order: 0 });
113
+ },
114
+ { __isDecorator: true, __decorator: decorator }
115
+ ) as any;
116
+ }
117
+
118
+ // Helper to handle both @decorator and @decorator() syntax
119
+ function createLifecycleDecoratorWithOptions(metadataKey: symbol) {
120
+ return function(optionOrTarget?: LifecycleOptions | Object, propertyKey?: string | symbol): MethodDecorator | void {
121
+ if (propertyKey) {
122
+ // Direct decorator usage: @decorator
123
+ const constructor = (optionOrTarget as Object).constructor;
124
+ let list = ReflectUtils.getOwnMetadata(metadataKey, constructor) as LifecycleMetadata[];
125
+ if (!list) {
126
+ list = [];
127
+ ReflectUtils.defineMetadata(metadataKey, list, constructor);
128
+ }
129
+ list.push({ propertyKey, order: 0 });
130
+ return;
88
131
  }
89
- list.push(propertyKey);
132
+
133
+ // Decorator with options: @decorator({ order: 1 })
134
+ return (target: Object, propertyKey: string | symbol) => {
135
+ const constructor = target.constructor;
136
+ let list = ReflectUtils.getOwnMetadata(metadataKey, constructor) as LifecycleMetadata[];
137
+ if (!list) {
138
+ list = [];
139
+ ReflectUtils.defineMetadata(metadataKey, list, constructor);
140
+ }
141
+ list.push({ propertyKey, order: (optionOrTarget as LifecycleOptions)?.order ?? 0 });
142
+ };
90
143
  };
91
144
  }
92
145
 
93
- export const onInitialize = createLifecycleDecorator(ON_INITIALIZE_METADATA_KEY);
94
- // export const onConnectedBefore = createLifecycleDecorator(ON_BEFORE_CONNECTED_METADATA_KEY);
95
- // export const onConnectedAfter = createLifecycleDecorator(ON_AFTER_CONNECTED_METADATA_KEY);
96
- // export const onConnected = onConnectedAfter;
146
+ export function onInitialize(options?: LifecycleOptions): MethodDecorator;
147
+ export function onInitialize(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
148
+ export function onInitialize(optionOrTarget?: LifecycleOptions | Object, propertyKey?: string | symbol): MethodDecorator | void {
149
+ return createLifecycleDecoratorWithOptions(ON_INITIALIZE_METADATA_KEY)(optionOrTarget, propertyKey);
150
+ }
151
+
152
+ export function onDisconnectedBefore(options?: LifecycleOptions): MethodDecorator;
153
+ export function onDisconnectedBefore(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
154
+ export function onDisconnectedBefore(optionOrTarget?: LifecycleOptions | Object, propertyKey?: string | symbol): MethodDecorator | void {
155
+ return createLifecycleDecoratorWithOptions(ON_BEFORE_DISCONNECTED_METADATA_KEY)(optionOrTarget, propertyKey);
156
+ }
157
+
158
+ export function onDisconnectedAfter(options?: LifecycleOptions): MethodDecorator;
159
+ export function onDisconnectedAfter(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
160
+ export function onDisconnectedAfter(optionOrTarget?: LifecycleOptions | Object, propertyKey?: string | symbol): MethodDecorator | void {
161
+ return createLifecycleDecoratorWithOptions(ON_AFTER_DISCONNECTED_METADATA_KEY)(optionOrTarget, propertyKey);
162
+ }
97
163
 
98
- export const onDisconnectedBefore = createLifecycleDecorator(ON_BEFORE_DISCONNECTED_METADATA_KEY);
99
- export const onDisconnectedAfter = createLifecycleDecorator(ON_AFTER_DISCONNECTED_METADATA_KEY);
100
164
  export const onDisconnected = onDisconnectedAfter;
101
165
 
102
- export const onAdoptedBefore = createLifecycleDecorator(ON_BEFORE_ADOPTED_METADATA_KEY);
103
- export const onAdoptedAfter = createLifecycleDecorator(ON_AFTER_ADOPTED_METADATA_KEY);
166
+ export function onAdoptedBefore(options?: LifecycleOptions): MethodDecorator;
167
+ export function onAdoptedBefore(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
168
+ export function onAdoptedBefore(optionOrTarget?: LifecycleOptions | Object, propertyKey?: string | symbol): MethodDecorator | void {
169
+ return createLifecycleDecoratorWithOptions(ON_BEFORE_ADOPTED_METADATA_KEY)(optionOrTarget, propertyKey);
170
+ }
171
+
172
+ export function onAdoptedAfter(options?: LifecycleOptions): MethodDecorator;
173
+ export function onAdoptedAfter(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
174
+ export function onAdoptedAfter(optionOrTarget?: LifecycleOptions | Object, propertyKey?: string | symbol): MethodDecorator | void {
175
+ return createLifecycleDecoratorWithOptions(ON_AFTER_ADOPTED_METADATA_KEY)(optionOrTarget, propertyKey);
176
+ }
177
+
104
178
  export const onAdopted = onAdoptedAfter;
105
179
 
106
- export const onAddEventListener = createLifecycleDecorator(ON_ADD_EVENT_LISTENER_METADATA_KEY);
180
+ export function onConnectedSwcApp(options?: LifecycleOptions): MethodDecorator;
181
+ export function onConnectedSwcApp(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
182
+ export function onConnectedSwcApp(optionOrTarget?: LifecycleOptions | Object, propertyKey?: string | symbol): MethodDecorator | void {
183
+ return createLifecycleDecoratorWithOptions(ON_CONNECTED_SWC_APP_METADATA_KEY)(optionOrTarget, propertyKey);
184
+ }
107
185
 
108
- export const onConnectedSwcApp = createLifecycleDecorator(ON_CONNECTED_SWC_APP_METADATA_KEY);
109
- export const onConnectedCompleted = createLifecycleDecorator(ON_CONNECTED_COMPLETED_METADATA_KEY);
186
+ export function onConnectedCompleted(options?: LifecycleOptions): MethodDecorator;
187
+ export function onConnectedCompleted(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
188
+ export function onConnectedCompleted(optionOrTarget?: LifecycleOptions | Object, propertyKey?: string | symbol): MethodDecorator | void {
189
+ return createLifecycleDecoratorWithOptions(ON_CONNECTED_COMPLETED_METADATA_KEY)(optionOrTarget, propertyKey);
190
+ }
110
191
 
111
192
 
112
193
 
@@ -160,21 +241,34 @@ export function onConnected(optionOrTarget: InnerHtmlOptions | Object, propertyK
160
241
  /**
161
242
  * 프로토타입 체인을 순회하며 모든 라이프사이클 메서드를 수집합니다.
162
243
  */
163
- // export const findAllLifecycleMetadata = <T = (string | symbol)[]>(target: any, metadataKey: symbol): T | undefined => {
164
- export const findAllLifecycleMetadata = (target: any, metadataKey: symbol): (string | symbol)[] => {
165
- const results = ReflectUtils.findAllMetadataFlatten(metadataKey, target)??[];
166
- return results;
244
+ export const findAllLifecycleMetadata = (target: any, metadataKey: symbol): LifecycleMetadata[] => {
245
+ const constructor = target instanceof Function ? target : target.constructor;
246
+ const results = ReflectUtils.getOwnMetadata(metadataKey, constructor) as LifecycleMetadata[] ?? [];
247
+ // Sort by order (default 0 if not specified)
248
+ return [...results].sort((a, b) => (a.order ?? 0) - (b.order ?? 0));
167
249
  };
168
250
 
169
251
  export const findAllOnConnectedMetadata = (target: any): InnerHtmlMetadata[] => {
170
252
  const constructor = target instanceof Function ? target : target.constructor;
171
- return ReflectUtils.getMetadata(ON_CONNECTED_METADATA_KEY, constructor) ?? [];
253
+ const results = ReflectUtils.getMetadata(ON_CONNECTED_METADATA_KEY, constructor) ?? [];
254
+ // Sort by order (default 0 if not specified)
255
+ return [...results].sort((a, b) => {
256
+ const orderA = (a.options as any)?.order ?? 0;
257
+ const orderB = (b.options as any)?.order ?? 0;
258
+ return orderA - orderB;
259
+ });
172
260
  };
261
+
173
262
  export const findAllOnConnectedBeforeMetadata = (target: any): OnConnectedMetadata[] => {
174
263
  const constructor = target instanceof Function ? target : target.constructor;
175
- return ReflectUtils.getMetadata(ON_BEFORE_CONNECTED_METADATA_KEY, constructor) ?? [];
264
+ const results = ReflectUtils.getMetadata(ON_BEFORE_CONNECTED_METADATA_KEY, constructor) ?? [];
265
+ // Sort by order
266
+ return [...results].sort((a, b) => (a.options?.order ?? 0) - (b.options?.order ?? 0));
176
267
  };
268
+
177
269
  export const findAllOnConnectedAfterMetadata = (target: any): OnConnectedMetadata[] => {
178
270
  const constructor = target instanceof Function ? target : target.constructor;
179
- return ReflectUtils.getMetadata(ON_AFTER_CONNECTED_METADATA_KEY, constructor) ?? [];
271
+ const results = ReflectUtils.getMetadata(ON_AFTER_CONNECTED_METADATA_KEY, constructor) ?? [];
272
+ // Sort by order
273
+ return [...results].sort((a, b) => (a.options?.order ?? 0) - (b.options?.order ?? 0));
180
274
  };
@@ -10,9 +10,25 @@ export interface PublishSwcAppMessageMetadata {
10
10
 
11
11
  export interface PublishSwcAppMessageOptions {
12
12
  messageType?: string;
13
+ /**
14
+ * Custom key to extract value from return object.
15
+ * If not provided, uses PUBLISH_SWC_APP_MESSAGE_METADATA_KEY by default.
16
+ * Useful when multiple @publishSwcAppMessage decorators are on the same method.
17
+ *
18
+ * Example:
19
+ * @publishSwcAppMessage('event1', { valueKey: 'detail1' })
20
+ * @publishSwcAppMessage('event2', { valueKey: 'detail2' })
21
+ * myMethod() {
22
+ * return {
23
+ * detail1: { type: 'event1', data: 'value1' },
24
+ * detail2: { type: 'event2', data: 'value2' }
25
+ * };
26
+ * }
27
+ */
28
+ valueKey?: symbol | string;
13
29
  }
14
30
 
15
- function createPublishSwcAppMessage(messageType?: string): MethodDecorator {
31
+ function createPublishSwcAppMessage(messageType?: string, options?: PublishSwcAppMessageOptions): MethodDecorator {
16
32
  return (target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => {
17
33
  const constructor = target.constructor;
18
34
  let list = ReflectUtils.getOwnMetadata(PUBLISH_SWC_APP_MESSAGE_METADATA_KEY, constructor) as PublishSwcAppMessageMetadata[];
@@ -31,32 +47,47 @@ function createPublishSwcAppMessage(messageType?: string): MethodDecorator {
31
47
  descriptor.value = function (...args: any[]) {
32
48
  // 원본 메서드 실행
33
49
  const result = originalMethod.apply(this, args);
50
+
51
+ /**
52
+ * Extract value for this decorator from method return value
53
+ *
54
+ * If return value is an object with this decorator's key,
55
+ * use that value. Otherwise use the entire return value.
56
+ *
57
+ * Uses valueKey from options if provided, otherwise uses PUBLISH_SWC_APP_MESSAGE_METADATA_KEY.
58
+ */
59
+ const extractValue = (v: any) => {
60
+ const keyToUse = options?.valueKey ?? PUBLISH_SWC_APP_MESSAGE_METADATA_KEY;
61
+ if (v && typeof v === 'object' && keyToUse in v) {
62
+ return v[keyToUse];
63
+ }
64
+ return v;
65
+ };
66
+
67
+ const publishMessage = (data: any) => {
68
+ // appHost 찾아서 메시지 발행
69
+ const appHost = SwcUtils.getAppHost(this as HTMLElement);
70
+ if (appHost) {
71
+ appHost.publishMessage({
72
+ publisher: this,
73
+ data,
74
+ type: messageType
75
+ });
76
+ }
77
+ };
34
78
 
35
79
  // Promise 체크
36
80
  if (result instanceof Promise) {
37
81
  result.then((data) => {
38
- // appHost 찾아서 메시지 발행
39
- const appHost = SwcUtils.getAppHost(this as HTMLElement);
40
- if (appHost) {
41
- appHost.publishMessage({
42
- publisher: this,
43
- data,
44
- type: messageType
45
- });
46
- }
82
+ const extracted = extractValue(data);
83
+ publishMessage(extracted);
47
84
  }).catch((err) => {
48
85
  console.warn('publishSwcAppMessage async error:', err);
49
86
  });
50
87
  } else {
51
88
  // 동기 호출 - 바로 메시지 발행
52
- const appHost = SwcUtils.getAppHost(this as HTMLElement);
53
- if (appHost) {
54
- appHost.publishMessage({
55
- publisher: this,
56
- data: result,
57
- type: messageType
58
- });
59
- }
89
+ const extracted = extractValue(result);
90
+ publishMessage(extracted);
60
91
  }
61
92
 
62
93
  return result;
@@ -71,27 +102,40 @@ export function publishSwcAppMessage(target: Object, propertyKey: string | symbo
71
102
  // 오버로드 시그니처 - 함수 호출 (괄호 있음)
72
103
  export function publishSwcAppMessage(): MethodDecorator;
73
104
  export function publishSwcAppMessage(messageType: string): MethodDecorator;
105
+ export function publishSwcAppMessage(messageType: string, options: PublishSwcAppMessageOptions): MethodDecorator;
106
+ export function publishSwcAppMessage(options: PublishSwcAppMessageOptions): MethodDecorator;
74
107
 
75
- export function publishSwcAppMessage(targetOrMessageType?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {
108
+ export function publishSwcAppMessage(targetOrMessageTypeOrOptions?: any, propertyKeyOrOptions?: string | symbol | PublishSwcAppMessageOptions, descriptor?: PropertyDescriptor): any {
76
109
  // 직접 데코레이터로 사용된 경우 (괄호 없음): @publishSwcAppMessage
77
- if (targetOrMessageType && typeof targetOrMessageType === 'object' &&
78
- propertyKey && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol') &&
110
+ if (targetOrMessageTypeOrOptions && typeof targetOrMessageTypeOrOptions === 'object' &&
111
+ propertyKeyOrOptions && (typeof propertyKeyOrOptions === 'string' || typeof propertyKeyOrOptions === 'symbol') &&
79
112
  descriptor) {
80
- const target = targetOrMessageType;
81
- return createPublishSwcAppMessage()(target, propertyKey, descriptor);
113
+ const target = targetOrMessageTypeOrOptions;
114
+ return createPublishSwcAppMessage()(target, propertyKeyOrOptions, descriptor);
82
115
  }
83
116
 
84
- // 함수로 호출된 경우 (괄호 있음): @publishSwcAppMessage() / @publishSwcAppMessage('messageType')
117
+ // 함수로 호출된 경우 (괄호 있음): @publishSwcAppMessage() / @publishSwcAppMessage('messageType') / @publishSwcAppMessage({...})
85
118
  let messageType: string | undefined;
119
+ let options: PublishSwcAppMessageOptions | undefined;
86
120
 
87
- if (typeof targetOrMessageType === 'string') {
121
+ if (typeof targetOrMessageTypeOrOptions === 'string') {
88
122
  // 메시지 타입 전달: @publishSwcAppMessage('messageType')
89
- messageType = targetOrMessageType;
123
+ messageType = targetOrMessageTypeOrOptions;
124
+ if (typeof propertyKeyOrOptions === 'object' && propertyKeyOrOptions !== null) {
125
+ options = propertyKeyOrOptions as PublishSwcAppMessageOptions;
126
+ }
127
+ } else if (typeof targetOrMessageTypeOrOptions === 'object' && targetOrMessageTypeOrOptions !== null) {
128
+ // 옵션 객체 전달: @publishSwcAppMessage({...})
129
+ options = targetOrMessageTypeOrOptions as PublishSwcAppMessageOptions;
130
+ messageType = options.messageType;
90
131
  }
91
132
 
92
- return createPublishSwcAppMessage(messageType);
133
+ return createPublishSwcAppMessage(messageType, options);
93
134
  }
94
135
 
136
+ // --- Aliases: publish... ---
137
+ export const publish = publishSwcAppMessage;
138
+
95
139
  // Helper function to retrieve publish message metadata
96
140
  export const getPublishSwcAppMessageMetadata = (target: any): PublishSwcAppMessageMetadata[] | undefined => {
97
141
  const constructor = target instanceof Function ? target : target.constructor;
@@ -76,7 +76,11 @@ export function subscribeSwcAppRouteChangeWhileConnected(targetOrOptions?: any,
76
76
  }
77
77
 
78
78
  // Helper function to retrieve route change subscribers metadata
79
- export const getSubscribeSwcAppRouteChangeWhileConnectedMetadata = (target: any): SwcAppRouteChangeSubscriberMetadata[] | undefined => {
79
+ export const getSubscribeSwcAppRouteChangeWhileConnectedMetadata = (target: any): SwcAppRouteChangeSubscriberMetadata[] => {
80
80
  const constructor = target instanceof Function ? target : target.constructor;
81
- return ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY, constructor);
81
+ const results = ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY, constructor);
82
+ if (!results) return [];
83
+
84
+ // Sort by order (default 0 if not specified)
85
+ return [...results].sort((a, b) => (a.options?.order ?? 0) - (b.options?.order ?? 0));
82
86
  };
@@ -81,18 +81,12 @@ export function SwcAppMixin<T extends { new(...args: any[]): HTMLElement }>(Base
81
81
 
82
82
  try {
83
83
  const routeChangeSubscribers = getSubscribeSwcAppRouteChangeWhileConnectedMetadata(instance);
84
- if (routeChangeSubscribers && Array.isArray(routeChangeSubscribers)) {
84
+ if (routeChangeSubscribers.length > 0) {
85
85
  console.log('[SWC-MIXIN] Route change subscribers found')
86
86
 
87
- // Sort by order (default 0 if not specified)
88
- const sortedSubscribers = [...routeChangeSubscribers].sort((a, b) => {
89
- const orderA = a.options?.order ?? 0;
90
- const orderB = b.options?.order ?? 0;
91
- return orderA - orderB;
92
- });
93
-
87
+ // Subscribers are already sorted by order from getSubscribeSwcAppRouteChangeWhileConnectedMetadata
94
88
  // Execute subscribers in order, stop if one returns a value
95
- for (const metadata of sortedSubscribers) {
89
+ for (const metadata of routeChangeSubscribers) {
96
90
  const methodName = metadata.propertyKey;
97
91
  let pathPattern = metadata.options?.path as any;
98
92
  const filter = metadata.options?.filter;
@@ -156,9 +150,9 @@ export function SwcAppMixin<T extends { new(...args: any[]): HTMLElement }>(Base
156
150
  }
157
151
  this._swc_connected_instance.add(instance);
158
152
 
159
- const connectedSwcAppCallBacks = findAllLifecycleMetadata(instance, ON_CONNECTED_SWC_APP_METADATA_KEY) ?? [];
153
+ const connectedSwcAppCallBacks = findAllLifecycleMetadata(instance, ON_CONNECTED_SWC_APP_METADATA_KEY);
160
154
  for (let connectedSwcAppCallBack of connectedSwcAppCallBacks) {
161
- await (instance as any)?._invokeLifecycleMethod?.(connectedSwcAppCallBack);
155
+ await (instance as any)?._invokeLifecycleMethod?.(connectedSwcAppCallBack.propertyKey);
162
156
  }
163
157
 
164
158
  if (this._childrenConnectedDoneInterval) {