@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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dooboostore/simple-web-component",
3
- "version": "1.0.41",
3
+ "version": "1.0.43",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/cjs/index.js",
@@ -112,8 +112,6 @@
112
112
  "publish:npm": "pnpm run build && cp package.json package.json.back && pnpm pack && TARBALL_NAME=$(ls dooboostore-simple-web-component-*.tgz | head -n 1) && tar -xzf \"$TARBALL_NAME\" -C . --strip-components=1 package/package.json && rm \"$TARBALL_NAME\" && (pnpm publish --no-git-checks || true) && cp package.json.back package.json && rm -rf package.json.back ",
113
113
  "ts:clean": "find . -name '*.js' -o -name '*.map' -o -name '*.d.ts' | xargs rm -f",
114
114
  "typecheck": "pnpm exec tsc --noEmit",
115
- "generate:is": "tsx generate-is.ts",
116
- "generate:is:watch": "node --import tsx --watch --watch-path=./src/elements/SwcIf.ts --watch-path=./src/elements/SwcLoop.ts --watch-path=./src/elements/SwcChoose.ts --watch-path=./src/elements/SwcAsync.ts --watch-path=./src/elements/SwcAppMixin.ts --watch-path=./generate-is.ts generate-is.ts",
117
115
  "test": "echo test",
118
116
  "test:bundle": "pnpm --filter @dooboostore/simple-web-component-bundle-test dev"
119
117
  }
@@ -59,6 +59,13 @@ export function addEventListenerDelegate(selector: string, type: string, options
59
59
  /**
60
60
  * @addEventListenerThis decorator - simplified version of @addEventListener for $this selector
61
61
  */
62
+
63
+ // --- Aliases: event... ---
64
+ export const event = addEventListener;
65
+ export const eventDelegateLightDom = addEventListenerDelegateLightDom;
66
+ export const eventDelegateShadowDom = addEventListenerDelegateShadowDom;
67
+ export const eventDelegateAllDom = addEventListenerDelegateAllDom;
68
+ export const eventDelegate = addEventListenerDelegate;
62
69
  export function addEventListenerThis(type: string, options?: AddEventListenerBaseOptions & SwcQueryOptions): MethodDecorator {
63
70
  return addEventListener('$this', type, options);
64
71
  }
@@ -12,6 +12,32 @@ export interface AttributeOptions extends SwcQueryOptions {
12
12
  name?: string;
13
13
  type?: typeof Number | typeof Boolean | typeof String;
14
14
  filter?: (target: HTMLElement, value: any, meta: { currentThis: any, helper: HelperHostSet }) => boolean;
15
+ /**
16
+ * Custom key to extract value from return object.
17
+ * If not provided, uses ATTRIBUTE_METADATA_KEY by default.
18
+ * Useful when multiple @setAttribute decorators are on the same method.
19
+ *
20
+ * Example:
21
+ * @setAttribute('selector1', { valueKey: 'attr1' })
22
+ * @setAttribute('selector2', { valueKey: 'attr2' })
23
+ * myMethod() {
24
+ * return {
25
+ * attr1: 'value1',
26
+ * attr2: 'value2'
27
+ * };
28
+ * }
29
+ *
30
+ * Or with symbols:
31
+ * @setAttribute('selector1', { valueKey: Symbol.for('attr1') })
32
+ * @setAttribute('selector2', { valueKey: Symbol.for('attr2') })
33
+ * myMethod() {
34
+ * return {
35
+ * [Symbol.for('attr1')]: 'value1',
36
+ * [Symbol.for('attr2')]: 'value2'
37
+ * };
38
+ * }
39
+ */
40
+ valueKey?: symbol | string;
15
41
  }
16
42
 
17
43
  export interface AttributeMetadata {
@@ -210,13 +236,43 @@ export function applyAttribute(selector: string, targetAttributeNameOrOptions?:
210
236
  ensureInit(this);
211
237
  const res = (original as any).apply(this, args);
212
238
 
239
+ /**
240
+ * Extract value for this decorator from method return value
241
+ *
242
+ * If return value is an object with this decorator's key,
243
+ * use that value. Otherwise use the entire return value.
244
+ *
245
+ * Uses valueKey from options if provided, otherwise uses ATTRIBUTE_METADATA_KEY.
246
+ *
247
+ * Example:
248
+ * @setAttribute('selector1', { valueKey: 'attr1' })
249
+ * @setAttribute('selector2', { valueKey: 'attr2' })
250
+ * myMethod() {
251
+ * return {
252
+ * attr1: 'attribute-value1',
253
+ * attr2: 'attribute-value2'
254
+ * };
255
+ * }
256
+ *
257
+ * First decorator will use 'attribute-value1', second will use 'attribute-value2'
258
+ */
259
+ const extractValue = (v: any) => {
260
+ const keyToUse = finalOptions.valueKey ?? ATTRIBUTE_METADATA_KEY;
261
+ if (v && typeof v === 'object' && keyToUse in v) {
262
+ return v[keyToUse];
263
+ }
264
+ return v;
265
+ };
266
+
213
267
  if (res instanceof Promise) {
214
268
  return res.then((v: any) => {
215
- applyValueToTargets(this, v);
269
+ const extracted = extractValue(v);
270
+ applyValueToTargets(this, extracted);
216
271
  return v;
217
272
  });
218
273
  } else {
219
- applyValueToTargets(this, res);
274
+ const extracted = extractValue(res);
275
+ applyValueToTargets(this, extracted);
220
276
  return res;
221
277
  }
222
278
  };
@@ -9,6 +9,12 @@ export type ClassAction = 'set' | 'update' | 'add' | 'remove' | 'toggle';
9
9
 
10
10
  export interface ClassApplyOptions extends SwcQueryOptions {
11
11
  filter?: (target: HTMLElement, value: any, meta: {currentThis: any, helper: HelperHostSet}) => boolean;
12
+ /**
13
+ * Custom key to extract value from return object.
14
+ * If not provided, uses CLASS_METADATA_KEY by default.
15
+ * Useful when multiple @applyClass decorators are on the same method.
16
+ */
17
+ valueKey?: symbol | string;
12
18
  }
13
19
 
14
20
  export interface ClassApplyMetadata {
@@ -44,6 +50,22 @@ function createClassDecorator(action: ClassAction) {
44
50
  ensureInit(this);
45
51
  const res = (original as any).apply(this, args);
46
52
 
53
+ /**
54
+ * Extract value for this decorator from method return value
55
+ *
56
+ * If return value is an object with this decorator's key,
57
+ * use that value. Otherwise use the entire return value.
58
+ *
59
+ * Uses valueKey from options if provided, otherwise uses CLASS_METADATA_KEY.
60
+ */
61
+ const extractValue = (v: any) => {
62
+ const keyToUse = finalOptions.valueKey ?? CLASS_METADATA_KEY;
63
+ if (v && typeof v === 'object' && keyToUse in v) {
64
+ return v[keyToUse];
65
+ }
66
+ return v;
67
+ };
68
+
47
69
  const handleResult = (resolvedValue: any) => {
48
70
  if (resolvedValue !== undefined) {
49
71
  const win = (this as any).ownerDocument?.defaultView || window;
@@ -131,9 +153,9 @@ function createClassDecorator(action: ClassAction) {
131
153
  };
132
154
 
133
155
  if (res instanceof Promise) {
134
- return res.then(handleResult);
156
+ return res.then((v: any) => handleResult(extractValue(v)));
135
157
  } else {
136
- return handleResult(res);
158
+ return handleResult(extractValue(res));
137
159
  }
138
160
  };
139
161
  return descriptor;
@@ -27,6 +27,12 @@ export interface ApplyNodeOptions {
27
27
  * Optional loading content to display while an async method is executing.
28
28
  */
29
29
  fallback?: (helper: HelperHostSet) => any;
30
+ /**
31
+ * Custom key to extract value from return object.
32
+ * If not provided, uses APPLY_NODE_METADATA_KEY by default.
33
+ * Useful when multiple @applyNode decorators are on the same method.
34
+ */
35
+ valueKey?: symbol | string;
30
36
  }
31
37
 
32
38
  export interface ApplyNodeMetadata {
@@ -140,6 +146,22 @@ export function applyNode(selector: string, options: ApplyNodeOptions = {positio
140
146
  const targetEl = getTarget();
141
147
  const res = original.apply(this, args);
142
148
 
149
+ /**
150
+ * Extract value for this decorator from method return value
151
+ *
152
+ * If return value is an object with this decorator's key,
153
+ * use that value. Otherwise use the entire return value.
154
+ *
155
+ * Uses valueKey from options if provided, otherwise uses APPLY_NODE_METADATA_KEY.
156
+ */
157
+ const extractValue = (v: any) => {
158
+ const keyToUse = options.valueKey ?? APPLY_NODE_METADATA_KEY;
159
+ if (v && typeof v === 'object' && keyToUse in v) {
160
+ return v[keyToUse];
161
+ }
162
+ return v;
163
+ };
164
+
143
165
  const runApply = (target: any, val: any) => {
144
166
  const pos = options.position || 'beforeEnd';
145
167
  // Delegate HTML/node processing to applyToDom which centralizes
@@ -163,12 +185,14 @@ export function applyNode(selector: string, options: ApplyNodeOptions = {positio
163
185
 
164
186
  if (res instanceof Promise) {
165
187
  return res.then(finalRes => {
188
+ const extracted = extractValue(finalRes);
166
189
  fallbackNodes.forEach((it: any)=>it.remove());
167
- if (finalRes !== undefined && targetEl) runApply(targetEl, finalRes);
190
+ if (extracted !== undefined && targetEl) runApply(targetEl, extracted);
168
191
  return finalRes;
169
192
  });
170
193
  } else {
171
- if (res !== undefined && targetEl) runApply(targetEl, res);
194
+ const extracted = extractValue(res);
195
+ if (extracted !== undefined && targetEl) runApply(targetEl, extracted);
172
196
  return res;
173
197
  }
174
198
  };
@@ -6,6 +6,32 @@ import { SwcQueryOptions, HelperHostSet } from '../types';
6
6
  export interface PropertyOptions extends SwcQueryOptions {
7
7
  name?: string | symbol;
8
8
  filter?: (target: HTMLElement, value: any, meta: {currentThis: any, helper: HelperHostSet}) => boolean;
9
+ /**
10
+ * Custom key to extract value from return object.
11
+ * If not provided, uses PROPERTY_METADATA_KEY by default.
12
+ * Useful when multiple @setProperty decorators are on the same method.
13
+ *
14
+ * Example:
15
+ * @setProperty('selector1', { valueKey: 'prop1' })
16
+ * @setProperty('selector2', { valueKey: 'prop2' })
17
+ * myMethod() {
18
+ * return {
19
+ * prop1: 'value1',
20
+ * prop2: 'value2'
21
+ * };
22
+ * }
23
+ *
24
+ * Or with symbols:
25
+ * @setProperty('selector1', { valueKey: Symbol.for('prop1') })
26
+ * @setProperty('selector2', { valueKey: Symbol.for('prop2') })
27
+ * myMethod() {
28
+ * return {
29
+ * [Symbol.for('prop1')]: 'value1',
30
+ * [Symbol.for('prop2')]: 'value2'
31
+ * };
32
+ * }
33
+ */
34
+ valueKey?: symbol | string;
9
35
  }
10
36
 
11
37
  export interface PropertyMetadata {
@@ -159,10 +185,39 @@ export function applyProperty(selector: string, targetPropertyKeyOrOptions?: str
159
185
  ensureInit(this);
160
186
  const res = (original as any).apply(this, args);
161
187
 
188
+ /**
189
+ * Extract value for this decorator from method return value
190
+ *
191
+ * If return value is an object with this decorator's symbol key,
192
+ * use that value. Otherwise use the entire return value.
193
+ *
194
+ * Example:
195
+ * @setProperty('selector')
196
+ * myMethod() {
197
+ * return {
198
+ * [PROPERTY_METADATA_KEY]: 'property-value',
199
+ * [OTHER_DECORATOR_KEY]: 'other-value'
200
+ * };
201
+ * }
202
+ *
203
+ * This decorator will use 'property-value'
204
+ */
205
+ const extractValue = (v: any) => {
206
+ if (v && typeof v === 'object' && PROPERTY_METADATA_KEY in v) {
207
+ return v[PROPERTY_METADATA_KEY];
208
+ }
209
+ return v;
210
+ };
211
+
162
212
  if (res instanceof Promise) {
163
- return res.then((v: any) => { applyValueToTargets(this, v); return v; });
213
+ return res.then((v: any) => {
214
+ const extracted = extractValue(v);
215
+ applyValueToTargets(this, extracted);
216
+ return v;
217
+ });
164
218
  } else {
165
- applyValueToTargets(this, res);
219
+ const extracted = extractValue(res);
220
+ applyValueToTargets(this, extracted);
166
221
  return res;
167
222
  }
168
223
  };
@@ -17,16 +17,12 @@ export type ApplySlotPosition = 'prepend' | 'prependHtml' | 'prependText' | 'app
17
17
  export interface ApplySlotOptions {
18
18
  position: ApplySlotPosition;
19
19
  fallback?: (helper: HelperHostSet) => string | Node;
20
- // root?: SwcRootType;
21
20
  /**
22
- * Filter function to determine whether to perform DOM operation.
23
- * If it returns false, the operation is skipped.
21
+ * Custom key to extract value from return object.
22
+ * If not provided, uses APPLY_SLOT_METADATA_KEY by default.
23
+ * Useful when multiple @applySlot decorators are on the same method.
24
24
  */
25
- // filter?: (target: HTMLElement | ShadowRoot, newValue: any, meta:{currentThis: any,helper: HelperHostSet}) => boolean;
26
- /**
27
- * Optional loading content to display while an async method is executing.
28
- */
29
- // loading?: (helper: HelperHostSet) => any;
25
+ valueKey?: symbol | string;
30
26
  }
31
27
 
32
28
  export interface ApplySlotMetadata {
@@ -144,15 +140,33 @@ export function applySlot(targetId: string, opt: OptionalType<ApplySlotOptions,
144
140
  applyToDom(swcId, targetId, options.position, nodes);
145
141
  }
146
142
 
143
+ /**
144
+ * Extract value for this decorator from method return value
145
+ *
146
+ * If return value is an object with this decorator's key,
147
+ * use that value. Otherwise use the entire return value.
148
+ *
149
+ * Uses valueKey from options if provided, otherwise uses APPLY_SLOT_METADATA_KEY.
150
+ */
151
+ const extractValue = (v: any) => {
152
+ const keyToUse = options.valueKey ?? APPLY_SLOT_METADATA_KEY;
153
+ if (v && typeof v === 'object' && keyToUse in v) {
154
+ return v[keyToUse];
155
+ }
156
+ return v;
157
+ };
158
+
147
159
  let res = original.apply(this, args);
148
160
  if (res instanceof Promise) {
149
161
  return res.then(asyncRes => {
150
- const nodes = resToNodes(asyncRes)
162
+ const extracted = extractValue(asyncRes);
163
+ const nodes = resToNodes(extracted)
151
164
  fallbackNodes.forEach((it: any) => it.remove());
152
165
  applyToDom(swcId, targetId, options.position, nodes);
153
166
  })
154
167
  } else {
155
- const nodes: Node[] = resToNodes(res);
168
+ const extracted = extractValue(res);
169
+ const nodes: Node[] = resToNodes(extracted);
156
170
  applyToDom(swcId, targetId, options.position, nodes);
157
171
  }
158
172
  };
@@ -7,6 +7,12 @@ export type StyleAction = 'set' | 'update' | 'remove';
7
7
 
8
8
  export interface StyleApplyOptions extends SwcQueryOptions {
9
9
  filter?: (target: HTMLElement, value: any, meta: {currentThis: any, helper: HelperHostSet}) => boolean;
10
+ /**
11
+ * Custom key to extract value from return object.
12
+ * If not provided, uses STYLE_METADATA_KEY by default.
13
+ * Useful when multiple @applyStyle decorators are on the same method.
14
+ */
15
+ valueKey?: symbol | string;
10
16
  }
11
17
 
12
18
  export interface StyleApplyMetadata {
@@ -34,6 +40,22 @@ function createStyleDecorator(action: StyleAction) {
34
40
  ensureInit(this);
35
41
  const res = (original as any).apply(this, args);
36
42
 
43
+ /**
44
+ * Extract value for this decorator from method return value
45
+ *
46
+ * If return value is an object with this decorator's key,
47
+ * use that value. Otherwise use the entire return value.
48
+ *
49
+ * Uses valueKey from options if provided, otherwise uses STYLE_METADATA_KEY.
50
+ */
51
+ const extractValue = (v: any) => {
52
+ const keyToUse = options.valueKey ?? STYLE_METADATA_KEY;
53
+ if (v && typeof v === 'object' && keyToUse in v) {
54
+ return v[keyToUse];
55
+ }
56
+ return v;
57
+ };
58
+
37
59
  const handleResult = (resolvedValue: any) => {
38
60
  if (resolvedValue !== undefined) {
39
61
  const win = (this as any).ownerDocument?.defaultView || window;
@@ -105,9 +127,9 @@ function createStyleDecorator(action: StyleAction) {
105
127
  };
106
128
 
107
129
  if (res instanceof Promise) {
108
- return res.then(handleResult);
130
+ return res.then((v: any) => handleResult(extractValue(v)));
109
131
  } else {
110
- return handleResult(res);
132
+ return handleResult(extractValue(res));
111
133
  }
112
134
  };
113
135
  return descriptor;
@@ -128,9 +128,7 @@ export const ensureInit = (inst: any) => { // HTMLElement
128
128
 
129
129
  // Call @onInitialize lifecycle methods
130
130
  const cMethods = findAllLifecycleMetadata(inst, ON_INITIALIZE_METADATA_KEY);
131
- if (cMethods) {
132
- for (const m of cMethods) inst._invokeLifecycleMethod(m, hostSet);
133
- }
131
+ for (const m of cMethods) inst._invokeLifecycleMethod(m.propertyKey, hostSet);
134
132
  }
135
133
  };
136
134
 
@@ -387,9 +385,7 @@ export const elementDefine =
387
385
 
388
386
  const bMethods = findAllOnConnectedBeforeMetadata(this).filter(it => useSsr ? !it.options.ssrFirst : true);
389
387
  // console.log('beforeConnected', bMethods)
390
- if (bMethods) {
391
- for (const m of bMethods) await (this as any)._invokeLifecycleMethod(m.propertyKey, helperHostSet);
392
- }
388
+ for (const m of bMethods) await (this as any)._invokeLifecycleMethod(m.propertyKey, helperHostSet);
393
389
  (this as any)._executeSwcScript('swc-on-before-connected', helperHostSet);
394
390
 
395
391
  // console.log('vvvvvvvvvvvvvvvu-seSsr-vvvvvvvvvv>', useSsr, this.tagName, this.getAttribute('seq'))
@@ -603,9 +599,7 @@ export const elementDefine =
603
599
  return useSsr ? !it.options.ssrFirst : true;
604
600
  });
605
601
  // console.log('afterConnected', this.tagName, aMethods, getOnConnectedAfterMetadata(this))
606
- if (aMethods) {
607
- for (const m of aMethods) await (this as any)._invokeLifecycleMethod(m.propertyKey, helperHostSet);
608
- }
602
+ for (const m of aMethods) await (this as any)._invokeLifecycleMethod(m.propertyKey, helperHostSet);
609
603
  (this as any)._executeSwcScript('swc-on-connected', helperHostSet);
610
604
  (this as any)._executeSwcScript('swc-on-after-connected', helperHostSet);
611
605
  (this as any).__swc_connected = true;
@@ -622,8 +616,8 @@ export const elementDefine =
622
616
  }
623
617
  }
624
618
  } finally {
625
- for (let mPropertyKey of findAllLifecycleMetadata(this, ON_CONNECTED_COMPLETED_METADATA_KEY)) {
626
- await (this as any)._invokeLifecycleMethod(mPropertyKey, helperHostSet);
619
+ for (let m of findAllLifecycleMetadata(this, ON_CONNECTED_COMPLETED_METADATA_KEY)) {
620
+ await (this as any)._invokeLifecycleMethod(m.propertyKey, helperHostSet);
627
621
  }
628
622
  if (appHost && typeof (appHost as any)._connectedDone === 'function') {
629
623
  await (appHost as any)._connectedDone(this);
@@ -643,9 +637,7 @@ export const elementDefine =
643
637
 
644
638
  (this as any)._executeSwcScript('swc-on-before-disconnected', helperHostSet);
645
639
  const bMethods = findAllLifecycleMetadata(this, ON_BEFORE_DISCONNECTED_METADATA_KEY);
646
- if (bMethods) {
647
- for (const m of bMethods) (this as any)._invokeLifecycleMethod(m, helperHostSet);
648
- }
640
+ for (const m of bMethods) (this as any)._invokeLifecycleMethod(m.propertyKey, helperHostSet);
649
641
 
650
642
  if ((this as any)._boundListeners) {
651
643
  (this as any)._boundListeners.forEach((l: any) => l.target.removeEventListener(l.type, l.handler, l.options));
@@ -669,9 +661,7 @@ export const elementDefine =
669
661
  if (originalDisconnected) originalDisconnected.apply(this);
670
662
 
671
663
  const aMethods = findAllLifecycleMetadata(this, ON_AFTER_DISCONNECTED_METADATA_KEY);
672
- if (aMethods) {
673
- for (const m of aMethods) (this as any)._invokeLifecycleMethod(m, helperHostSet);
674
- }
664
+ for (const m of aMethods) (this as any)._invokeLifecycleMethod(m.propertyKey, helperHostSet);
675
665
  (this as any)._executeSwcScript('swc-on-disconnected', helperHostSet);
676
666
  (this as any)._executeSwcScript('swc-on-after-disconnected', helperHostSet);
677
667
  (this as any).__swc_connected = false;
@@ -682,16 +672,12 @@ export const elementDefine =
682
672
  const hostSet = SwcUtils.getHostSet(this as any);
683
673
  (this as any)._executeSwcScript('swc-on-before-adopted', hostSet);
684
674
  const bMethods = findAllLifecycleMetadata(this, ON_BEFORE_ADOPTED_METADATA_KEY);
685
- if (bMethods) {
686
- for (const m of bMethods) (this as any)._invokeLifecycleMethod(m, hostSet);
687
- }
675
+ for (const m of bMethods) (this as any)._invokeLifecycleMethod(m.propertyKey, hostSet);
688
676
 
689
677
  if (originalAdopted) originalAdopted.apply(this);
690
678
 
691
679
  const aMethods = findAllLifecycleMetadata(this, ON_AFTER_ADOPTED_METADATA_KEY);
692
- if (aMethods) {
693
- for (const m of aMethods) (this as any)._invokeLifecycleMethod(m, hostSet);
694
- }
680
+ for (const m of aMethods) (this as any)._invokeLifecycleMethod(m.propertyKey, hostSet);
695
681
  (this as any)._executeSwcScript('swc-on-adopted', hostSet);
696
682
  (this as any)._executeSwcScript('swc-on-after-adopted', hostSet);
697
683
  };
@@ -8,6 +8,22 @@ export interface EmitCustomEventBaseOptions {
8
8
  composed?: boolean;
9
9
  cancelable?: boolean;
10
10
  filter?: (target: EventTarget, detail: any, meta: { currentThis: any, helper: HelperHostSet }) => boolean;
11
+ /**
12
+ * Custom key to extract value from return object.
13
+ * If not provided, uses EMIT_CUSTOM_EVENT_METADATA_KEY by default.
14
+ * Useful when multiple @emitCustomEvent decorators are on the same method.
15
+ *
16
+ * Example:
17
+ * @emitCustomEvent('$appHost', 'event1', { valueKey: 'detail1' })
18
+ * @emitCustomEvent('$appHost', 'event2', { valueKey: 'detail2' })
19
+ * myMethod() {
20
+ * return {
21
+ * detail1: { type: 'event1', data: 'value1' },
22
+ * detail2: { type: 'event2', data: 'value2' }
23
+ * };
24
+ * }
25
+ */
26
+ valueKey?: symbol | string;
11
27
  }
12
28
 
13
29
  type Options = (EmitCustomEventBaseOptions & SwcQueryOptions) | (EmitCustomEventBaseOptions & SwcQueryOptions & { attributeName?: string });
@@ -122,6 +138,9 @@ export const getEmitCustomEventMetadataList = (target: any): EmitCustomEventMeta
122
138
  return ReflectUtils.getMetadata(EMIT_CUSTOM_EVENT_METADATA_KEY, constructor);
123
139
  };
124
140
 
141
+ // --- Aliases: emit... ---
142
+ export const emit = emitCustomEvent;
143
+
125
144
  /**
126
145
  * @emitCustomEventThis decorator - simplified version of @emitCustomEvent for $this selector
127
146
  */