@dooboostore/simple-web-component 1.0.39 → 1.0.40

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 (85) hide show
  1. package/LICENSE.md +7 -0
  2. package/README.md +65 -46
  3. package/dist/cjs/SwcAppEngine.js.map +2 -2
  4. package/dist/cjs/decorators/applyAttribute.js +194 -111
  5. package/dist/cjs/decorators/applyAttribute.js.map +2 -2
  6. package/dist/cjs/decorators/applyNode.js +58 -43
  7. package/dist/cjs/decorators/applyNode.js.map +2 -2
  8. package/dist/cjs/decorators/applyProperty.js +213 -0
  9. package/dist/cjs/decorators/applyProperty.js.map +7 -0
  10. package/dist/cjs/decorators/applySlot.js +32 -26
  11. package/dist/cjs/decorators/applySlot.js.map +2 -2
  12. package/dist/cjs/decorators/changedAttributeThis.js.map +1 -1
  13. package/dist/cjs/decorators/elementDefine.js +17 -30
  14. package/dist/cjs/decorators/elementDefine.js.map +2 -2
  15. package/dist/cjs/decorators/index.js +2 -2
  16. package/dist/cjs/decorators/index.js.map +2 -2
  17. package/dist/cjs/decorators/lifecycles.js +4 -4
  18. package/dist/cjs/decorators/lifecycles.js.map +2 -2
  19. package/dist/cjs/elements/SwcApp.js.map +2 -2
  20. package/dist/cjs/types/index.js.map +1 -1
  21. package/dist/esm/SwcAppEngine.js.map +2 -2
  22. package/dist/esm/decorators/applyAttribute.js +196 -113
  23. package/dist/esm/decorators/applyAttribute.js.map +2 -2
  24. package/dist/esm/decorators/applyNode.js +58 -43
  25. package/dist/esm/decorators/applyNode.js.map +2 -2
  26. package/dist/esm/decorators/applyProperty.js +194 -0
  27. package/dist/esm/decorators/applyProperty.js.map +7 -0
  28. package/dist/esm/decorators/applySlot.js +32 -26
  29. package/dist/esm/decorators/applySlot.js.map +2 -2
  30. package/dist/esm/decorators/changedAttributeThis.js.map +1 -1
  31. package/dist/esm/decorators/elementDefine.js +17 -30
  32. package/dist/esm/decorators/elementDefine.js.map +2 -2
  33. package/dist/esm/decorators/index.js +2 -2
  34. package/dist/esm/decorators/index.js.map +1 -1
  35. package/dist/esm/decorators/lifecycles.js +4 -4
  36. package/dist/esm/decorators/lifecycles.js.map +2 -2
  37. package/dist/esm/elements/SwcApp.js.map +2 -2
  38. package/dist/esm/types/index.js.map +1 -1
  39. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +421 -394
  40. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
  41. package/dist/types/SwcAppEngine.d.ts.map +1 -1
  42. package/dist/types/decorators/applyAttribute.d.ts +56 -15
  43. package/dist/types/decorators/applyAttribute.d.ts.map +1 -1
  44. package/dist/types/decorators/applyNode.d.ts +28 -24
  45. package/dist/types/decorators/applyNode.d.ts.map +1 -1
  46. package/dist/types/decorators/applyProperty.d.ts +61 -0
  47. package/dist/types/decorators/applyProperty.d.ts.map +1 -0
  48. package/dist/types/decorators/applySlot.d.ts +10 -10
  49. package/dist/types/decorators/applySlot.d.ts.map +1 -1
  50. package/dist/types/decorators/elementDefine.d.ts.map +1 -1
  51. package/dist/types/decorators/index.d.ts +2 -2
  52. package/dist/types/decorators/index.d.ts.map +1 -1
  53. package/dist/types/decorators/lifecycles.d.ts +4 -4
  54. package/dist/types/decorators/lifecycles.d.ts.map +1 -1
  55. package/dist/types/elements/SwcApp.d.ts.map +1 -1
  56. package/dist/types/types/index.d.ts +1 -6
  57. package/dist/types/types/index.d.ts.map +1 -1
  58. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +421 -394
  59. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
  60. package/package.json +3 -3
  61. package/src/SwcAppEngine.ts +1 -0
  62. package/src/decorators/applyAttribute.ts +311 -126
  63. package/src/decorators/applyNode.ts +68 -57
  64. package/src/decorators/applyProperty.ts +302 -0
  65. package/src/decorators/applySlot.ts +25 -18
  66. package/src/decorators/changedAttributeThis.ts +1 -1
  67. package/src/decorators/elementDefine.ts +41 -30
  68. package/src/decorators/index.ts +2 -3
  69. package/src/decorators/lifecycles.ts +6 -6
  70. package/src/elements/SwcApp.ts +0 -1
  71. package/src/types/index.ts +7 -7
  72. package/dist/cjs/decorators/attribute.js +0 -187
  73. package/dist/cjs/decorators/attribute.js.map +0 -7
  74. package/dist/cjs/decorators/setProperty.js +0 -109
  75. package/dist/cjs/decorators/setProperty.js.map +0 -7
  76. package/dist/esm/decorators/attribute.js +0 -168
  77. package/dist/esm/decorators/attribute.js.map +0 -7
  78. package/dist/esm/decorators/setProperty.js +0 -90
  79. package/dist/esm/decorators/setProperty.js.map +0 -7
  80. package/dist/types/decorators/attribute.d.ts +0 -31
  81. package/dist/types/decorators/attribute.d.ts.map +0 -1
  82. package/dist/types/decorators/setProperty.d.ts +0 -17
  83. package/dist/types/decorators/setProperty.d.ts.map +0 -1
  84. package/src/decorators/attribute.ts +0 -223
  85. package/src/decorators/setProperty.ts +0 -112
@@ -137,8 +137,6 @@ export function applyNode(selector: string, options: ApplyNodeOptions = {positio
137
137
  return targetRoot ? targetRoot.querySelector(selector) : null;
138
138
  };
139
139
 
140
-
141
- console.log('fffffffffff')
142
140
  const targetEl = getTarget();
143
141
  const res = original.apply(this, args);
144
142
 
@@ -177,17 +175,6 @@ export function applyNode(selector: string, options: ApplyNodeOptions = {positio
177
175
  };
178
176
  }
179
177
 
180
- export const findAllApplyNodeMetadata = (target: any): Map<string | symbol, ApplyNodeMetadata> => {
181
- const result = new Map<string | symbol, ApplyNodeMetadata>();
182
- const maps = ReflectUtils.findAllMetadata<Map<string | symbol, ApplyNodeMetadata>>(APPLY_NODE_METADATA_KEY, target);
183
- maps.forEach(map => {
184
- if (map instanceof Map) {
185
- map.forEach((v, k) => result.set(k, v));
186
- }
187
- });
188
- return result;
189
- };
190
-
191
178
  export function applyNodeThis(options: ApplyNodeOptions): MethodDecorator;
192
179
  export function applyNodeThis(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
193
180
  export function applyNodeThis(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {
@@ -197,111 +184,135 @@ export function applyNodeThis(targetOrOptions?: any, propertyKey?: string | symb
197
184
  return applyNode('$this', {...option, ...opt});
198
185
  }
199
186
 
200
- export function applyNodeThisReplaceChildren(options: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;
201
- export function applyNodeThisReplaceChildren(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
202
- export function applyNodeThisReplaceChildren(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {
187
+ export function replaceChildrenNodeThis(options: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;
188
+ export function replaceChildrenNodeThis(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
189
+ export function replaceChildrenNodeThis(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {
203
190
  const option: ApplyNodeOptions = {position: 'replaceChildren'};
204
191
  if (propertyKey !== undefined) return applyNode('$this', option)(targetOrOptions, propertyKey, descriptor);
205
192
  const opt = targetOrOptions || {};
206
193
  return applyNode('$this', {...opt, ...option});
207
194
  }
208
195
 
209
- export function applyNodeThisReplaceChildrenLightDom(options: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;
210
- export function applyNodeThisReplaceChildrenLightDom(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
211
- export function applyNodeThisReplaceChildrenLightDom(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {
212
- const options: ApplyNodeOptions = {position: 'replaceChildren', root: 'light'};
213
- if (propertyKey !== undefined) return applyNode('$this', options)(targetOrOptions, propertyKey, descriptor);
214
- const opt = targetOrOptions || {};
215
- return applyNode('$this', {...opt, ...options});
216
- }
217
196
 
218
- export function applyNodeThisBeforeEnd(options: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;
219
- export function applyNodeThisBeforeEnd(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
220
- export function applyNodeThisBeforeEnd(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {
197
+
198
+ export function beforeEndNodeThis(options: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;
199
+ export function beforeEndNodeThis(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
200
+ export function beforeEndNodeThis(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {
221
201
  const options: ApplyNodeOptions = {position: 'beforeEnd'};
222
202
  if (propertyKey !== undefined) return applyNode('$this', options)(targetOrOptions, propertyKey, descriptor);
223
203
  const opt = targetOrOptions || {};
224
204
  return applyNode('$this', {...opt, ...options});
225
205
  }
226
206
 
227
- export function applyNodeThisBeforeEndLightDom(options: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;
228
- export function applyNodeThisBeforeEndLightDom(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
229
- export function applyNodeThisBeforeEndLightDom(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {
207
+ export function beforeEndLightNodeThis(options: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;
208
+ export function beforeEndLightNodeThis(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
209
+ export function beforeEndLightNodeThis(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {
230
210
  const option: ApplyNodeOptions = {position: 'beforeEnd', root: 'light'}
231
211
  if (propertyKey !== undefined) return applyNode('$this', option)(targetOrOptions, propertyKey, descriptor);
232
212
  const opt = targetOrOptions || {};
233
213
  return applyNode('$this', {...opt, ...option});
234
214
  }
235
- export function applyNodeThisBeforeEndShadow(options: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;
236
- export function applyNodeThisBeforeEndShadow(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
237
- export function applyNodeThisBeforeEndShadow(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {
215
+
216
+ export function beforeEndShadowNodeThis(options: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;
217
+ export function beforeEndShadowNodeThis(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
218
+ export function beforeEndShadowNodeThis(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {
238
219
  const option: ApplyNodeOptions = {position: 'beforeEnd', root: 'shadow'}
239
220
  if (propertyKey !== undefined) return applyNode('$this', option)(targetOrOptions, propertyKey, descriptor);
240
221
  const opt = targetOrOptions || {};
241
222
  return applyNode('$this', {...opt, ...option});
242
223
  }
243
224
 
244
- export function applyNodeThisAfterBegin(options: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;
245
- export function applyNodeThisAfterBegin(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
246
- export function applyNodeThisAfterBegin(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {
225
+ export function afterBeginNodeThis(options: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;
226
+ export function afterBeginNodeThis(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
227
+ export function afterBeginNodeThis(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {
247
228
  const option: ApplyNodeOptions = {position: 'afterBegin'};
248
229
  if (propertyKey !== undefined) return applyNode('$this', option)(targetOrOptions, propertyKey, descriptor);
249
230
  const opt = targetOrOptions || {};
250
231
  return applyNode('$this', {...opt, ...option});
251
232
  }
252
233
 
253
- export function applyNodeThisAfterBeginLightDom(options: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;
254
- export function applyNodeThisAfterBeginLightDom(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
255
- export function applyNodeThisAfterBeginLightDom(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {
234
+ export function afterBeginLightNodeThis(options: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;
235
+ export function afterBeginLightNodeThis(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
236
+ export function afterBeginLightNodeThis(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {
256
237
  const option: ApplyNodeOptions = {position: 'afterBegin', root: 'light'}
257
238
  if (propertyKey !== undefined) return applyNode('$this', option)(targetOrOptions, propertyKey, descriptor);
258
239
  const opt = targetOrOptions || {};
259
240
  return applyNode('$this', {...opt, ...option});
260
241
  }
261
242
 
262
- export function applyNodeThisInnerHtml(options: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;
263
- export function applyNodeThisInnerHtml(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
264
- export function applyNodeThisInnerHtml(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {
243
+ export function innerHtmlNodeThis(options: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;
244
+ export function innerHtmlNodeThis(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
245
+ export function innerHtmlNodeThis(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {
265
246
  const option: ApplyNodeOptions = {position: 'innerHtml'}
266
247
  if (propertyKey !== undefined) return applyNode('$this', option)(targetOrOptions, propertyKey, descriptor);
267
248
  const opt = targetOrOptions || {};
268
249
  return applyNode('$this', {...opt, ...option});
269
250
  }
270
251
 
271
- export function applyThisInnerHtmlNodeLightDom(options: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;
272
- export function applyThisInnerHtmlNodeLightDom(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
273
- export function applyThisInnerHtmlNodeLightDom(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {
252
+ export function innerTextNodeThis(options: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;
253
+ export function innerTextNodeThis(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
254
+ export function innerTextNodeThis(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {
255
+ const option: ApplyNodeOptions = {position: 'innerText'}
256
+ if (propertyKey !== undefined) return applyNode('$this', option)(targetOrOptions, propertyKey, descriptor);
257
+ const opt = targetOrOptions || {};
258
+ return applyNode('$this', {...opt, ...option});
259
+ }
260
+
261
+ export function innerHtmlLightNodeThis(options: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;
262
+ export function innerHtmlLightNodeThis(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
263
+ export function innerHtmlLightNodeThis(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {
274
264
  const option: ApplyNodeOptions = {position: 'innerHtml', root: 'light'};
275
265
  if (propertyKey !== undefined) return applyNode('$this', option)(targetOrOptions, propertyKey, descriptor);
276
266
  const opt = targetOrOptions || {};
277
267
  return applyNode('$this', {...opt, ...option});
278
268
  }
279
269
 
280
- export function applyThisReplaceChildrenNodeLightDom(options: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;
281
- export function applyThisReplaceChildrenNodeLightDom(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
282
- export function applyThisReplaceChildrenNodeLightDom(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {
270
+ export function replaceChildrenLightNodeThis(options: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;
271
+ export function replaceChildrenLightNodeThis(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
272
+ export function replaceChildrenLightNodeThis(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {
283
273
  const option: ApplyNodeOptions = {position: 'replaceChildren', root: 'light'};
284
274
  if (propertyKey !== undefined) return applyNode('$this', option)(targetOrOptions, propertyKey, descriptor);
285
275
  const opt = targetOrOptions || {};
286
276
  return applyNode('$this', {...opt, ...option});
287
277
  }
288
278
 
289
- export function applyNodeReplaceChildren(selector: string, options: Omit<ApplyNodeOptions, 'position'> = {}): MethodDecorator {
279
+ export function replaceChildrenNode(selector: string, options: Omit<ApplyNodeOptions, 'position'> = {}): MethodDecorator {
290
280
  return applyNode(selector, {...options, position: 'replaceChildren'});
291
281
  }
292
282
 
293
- export function applyNodeInnerHtml(selector: string, options: Omit<ApplyNodeOptions, 'position'> = {}): MethodDecorator {
283
+ export function innerHtmlNode(selector: string, options: Omit<ApplyNodeOptions, 'position'> = {}): MethodDecorator {
294
284
  return applyNode(selector, {...options, position: 'innerHtml'});
295
285
  }
296
286
 
297
- // export function applyNodeInnerHtmlLightDom(selector: string, options: Omit<ApplyNodeOptions, 'position' | 'root'> = {}): MethodDecorator {
298
- // return applyNode(selector, {...options, position: 'innerHtml', root: 'light'});
299
- // }
287
+ export function innerHtmlLightNode(selector: string, options: Omit<ApplyNodeOptions, 'position' | 'root'> = {}): MethodDecorator {
288
+ return applyNode(selector, {...options, position: 'innerHtml', root: 'light'});
289
+ }
290
+
291
+ export function innerHtmlShadowNode(selector: string, options: Omit<ApplyNodeOptions, 'position' | 'root'> = {}): MethodDecorator {
292
+ return applyNode(selector, {...options, position: 'innerHtml', root: 'shadow'});
293
+ }
300
294
 
301
- export function applyNodeInnerText(selector: string, options: Omit<ApplyNodeOptions, 'position'> = {}): MethodDecorator {
295
+ export function innerTextNode(selector: string, options: Omit<ApplyNodeOptions, 'position'> = {}): MethodDecorator {
302
296
  return applyNode(selector, {...options, position: 'innerText'});
303
297
  }
304
298
 
305
- // export function applyNodeInnerTextLightDom(selector: string, options: Omit<ApplyNodeOptions, 'position' | 'root'> = {}): MethodDecorator {
306
- // return applyNode(selector, {...options, position: 'innerText', root: 'light'});
307
- // }
299
+ export function innerTextLightNode(selector: string, options: Omit<ApplyNodeOptions, 'position' | 'root'> = {}): MethodDecorator {
300
+ return applyNode(selector, {...options, position: 'innerText', root: 'light'});
301
+ }
302
+
303
+ export function innerTextShadowNode(selector: string, options: Omit<ApplyNodeOptions, 'position' | 'root'> = {}): MethodDecorator {
304
+ return applyNode(selector, {...options, position: 'innerText', root: 'shadow'});
305
+ }
306
+
307
+
308
+
309
+ export const findAllApplyNodeMetadata = (target: any): Map<string | symbol, ApplyNodeMetadata> => {
310
+ const result = new Map<string | symbol, ApplyNodeMetadata>();
311
+ const maps = ReflectUtils.findAllMetadata<Map<string | symbol, ApplyNodeMetadata>>(APPLY_NODE_METADATA_KEY, target);
312
+ maps.forEach(map => {
313
+ if (map instanceof Map) {
314
+ map.forEach((v, k) => result.set(k, v));
315
+ }
316
+ });
317
+ return result;
318
+ };
@@ -0,0 +1,302 @@
1
+ import { ReflectUtils } from '@dooboostore/core';
2
+ import { ensureInit, getElementConfig } from './elementDefine';
3
+ import { SwcUtils } from '../utils/Utils';
4
+ import { SwcQueryOptions, HelperHostSet } from '../types';
5
+
6
+ export interface PropertyOptions extends SwcQueryOptions {
7
+ name?: string | symbol;
8
+ filter?: (target: HTMLElement, value: any, meta: {currentThis: any, helper: HelperHostSet}) => boolean;
9
+ }
10
+
11
+ export interface PropertyMetadata {
12
+ propertyKey: string | symbol;
13
+ selector: string;
14
+ targetPropertyKey: string | symbol;
15
+ options: PropertyOptions;
16
+ type: 'property' | 'method';
17
+ }
18
+
19
+ export const PROPERTY_METADATA_KEY = Symbol.for('simple-web-component:property');
20
+
21
+ // ============================================
22
+ // Utilities
23
+ // ============================================
24
+
25
+ /**
26
+ * Resolve target elements based on selector and options
27
+ * Handles special selectors ($this, $host, etc.) and CSS selectors
28
+ * Returns HTMLElement[] but can include Window and Document for property access
29
+ */
30
+ export const resolvePropertyTargets = (inst: any, selector: string, options: PropertyOptions): any[] => {
31
+ const conf = getElementConfig(inst);
32
+ const currentWin = conf.window;
33
+ const r = options.root || 'auto';
34
+ const results: any[] = [];
35
+
36
+ const applyRoot = (target: any) => {
37
+ if (!target) return;
38
+ if (r === 'auto') {
39
+ results.push(target);
40
+ } else {
41
+ if (r === 'light' || r === 'all') results.push(target);
42
+ if ((r === 'shadow' || r === 'all') && target.shadowRoot) results.push(target.shadowRoot);
43
+ }
44
+ };
45
+
46
+ if (selector === '$this' || !selector) {
47
+ applyRoot(inst);
48
+ } else if (selector === '$window') {
49
+ results.push(currentWin);
50
+ } else if (selector === '$document') {
51
+ results.push(currentWin.document);
52
+ } else {
53
+ const hostSet = SwcUtils.getHostSet(inst);
54
+ if (selector === '$host') applyRoot(hostSet.$host);
55
+ else if (selector === '$parentHost') applyRoot(hostSet.$parentHost);
56
+ else if (selector === '$appHost') applyRoot(hostSet.$appHost as any);
57
+ else if (selector === '$firstHost') applyRoot(hostSet.$firstHost);
58
+ else if (selector === '$lastHost') applyRoot(hostSet.$lastHost);
59
+ else if (selector === '$firstAppHost') applyRoot(hostSet.$firstAppHost as any);
60
+ else if (selector === '$lastAppHost') applyRoot(hostSet.$lastAppHost as any);
61
+ else if (selector === '$hosts') hostSet.$hosts.forEach(applyRoot);
62
+ else if (selector === '$appHosts') hostSet.$appHosts.forEach(applyRoot);
63
+ else {
64
+ if (r === 'shadow') {
65
+ const found = inst.shadowRoot?.querySelectorAll(selector);
66
+ if (found) results.push(...found);
67
+ } else if (r === 'light') {
68
+ const found = inst.querySelectorAll(selector);
69
+ if (found) results.push(...found);
70
+ } else if (r === 'all') {
71
+ const sMatch = inst.shadowRoot?.querySelectorAll(selector);
72
+ const lMatch = inst.querySelectorAll(selector);
73
+ if (sMatch) results.push(...sMatch);
74
+ if (lMatch) results.push(...lMatch);
75
+ } else {
76
+ const found = (inst.shadowRoot || inst).querySelectorAll(selector);
77
+ if (found) results.push(...found);
78
+ }
79
+ }
80
+ }
81
+ return results;
82
+ };
83
+
84
+ /**
85
+ * @applyProperty decorator - set/get element properties
86
+ *
87
+ * Usage:
88
+ * - @applyProperty('selector', 'propertyName') - Set property with explicit name
89
+ * - @applyProperty('selector') - Use property name as target property name
90
+ * - @applyProperty('selector', { name: 'propertyName' }) - Set property via options
91
+ * - Return null/undefined to skip setting
92
+ */
93
+ export function applyProperty(selector: string, targetPropertyKey: string | symbol, options?: PropertyOptions): MethodDecorator & PropertyDecorator;
94
+ export function applyProperty(selector: string, options?: PropertyOptions): MethodDecorator & PropertyDecorator;
95
+ export function applyProperty(selector: string, targetPropertyKeyOrOptions?: string | symbol | PropertyOptions, options?: PropertyOptions): MethodDecorator & PropertyDecorator {
96
+ return (target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => {
97
+ // ensureInit(target as any);
98
+
99
+ const constructor = target.constructor;
100
+ const metaType: 'property' | 'method' = descriptor && typeof descriptor.value === 'function' ? 'method' : 'property';
101
+
102
+ // Parse arguments
103
+ let finalOptions: PropertyOptions = {};
104
+ let targetPropertyKey: string | symbol;
105
+
106
+ if (typeof targetPropertyKeyOrOptions === 'string' || typeof targetPropertyKeyOrOptions === 'symbol') {
107
+ // applyProperty('selector', 'propertyName', options?)
108
+ targetPropertyKey = targetPropertyKeyOrOptions;
109
+ finalOptions = options || {};
110
+ } else if (targetPropertyKeyOrOptions) {
111
+ // applyProperty('selector', options)
112
+ finalOptions = targetPropertyKeyOrOptions;
113
+ targetPropertyKey = finalOptions.name || propertyKey;
114
+ } else {
115
+ // applyProperty('selector')
116
+ targetPropertyKey = propertyKey;
117
+ }
118
+
119
+ // Store metadata
120
+ let metaList = ReflectUtils.getOwnMetadata(PROPERTY_METADATA_KEY, constructor) as PropertyMetadata[];
121
+ if (!metaList) {
122
+ metaList = [];
123
+ ReflectUtils.defineMetadata(PROPERTY_METADATA_KEY, metaList, constructor);
124
+ }
125
+ metaList.push({
126
+ propertyKey,
127
+ selector,
128
+ targetPropertyKey,
129
+ options: finalOptions,
130
+ type: metaType
131
+ });
132
+
133
+ // Helper: apply resolved value to targets
134
+ const applyValueToTargets = (inst: any, resolvedValue: any) => {
135
+ if (resolvedValue === undefined) return resolvedValue;
136
+
137
+ const targetEls = resolvePropertyTargets(inst, selector, finalOptions);
138
+ const conf = getElementConfig(inst);
139
+ const currentWin = conf.window;
140
+ const hostSet = SwcUtils.getHelperAndHostSet(currentWin, inst);
141
+
142
+ targetEls.forEach(targetEl => {
143
+ // Apply filter if provided
144
+ if (finalOptions.filter && !finalOptions.filter(targetEl, resolvedValue, { currentThis: inst, helper: hostSet })) {
145
+ return;
146
+ }
147
+
148
+ const resolvedRes = typeof resolvedValue === 'function' ? (resolvedValue as any)(targetEl, hostSet) : resolvedValue;
149
+ (targetEl as any)[targetPropertyKey] = resolvedRes;
150
+ });
151
+
152
+ return resolvedValue;
153
+ };
154
+
155
+ // Method decorator: wrap method to apply its return value to properties
156
+ if (descriptor && typeof descriptor.value === 'function') {
157
+ const original = descriptor.value;
158
+ descriptor.value = function (...args: any[]) {
159
+ ensureInit(this);
160
+ const res = (original as any).apply(this, args);
161
+
162
+ if (res instanceof Promise) {
163
+ return res.then((v: any) => { applyValueToTargets(this, v); return v; });
164
+ } else {
165
+ applyValueToTargets(this, res);
166
+ return res;
167
+ }
168
+ };
169
+ return;
170
+ }
171
+
172
+ // Property decorator: define getter/setter to proxy to element properties
173
+ Object.defineProperty(target, propertyKey, {
174
+ configurable: true,
175
+ enumerable: true,
176
+ get(this: any) {
177
+ ensureInit(this);
178
+ // Read from matched elements
179
+ const targetEls = resolvePropertyTargets(this, selector, finalOptions);
180
+ const conf = getElementConfig(this);
181
+ const currentWin = conf.window;
182
+ const hostSet = SwcUtils.getHelperAndHostSet(currentWin, this);
183
+
184
+ // Apply filter
185
+ const filtered = targetEls.filter(el => {
186
+ if (finalOptions.filter && !finalOptions.filter(el, (el as any)[targetPropertyKey], { currentThis: this, helper: hostSet })) {
187
+ return false;
188
+ }
189
+ return true;
190
+ });
191
+
192
+ const values = filtered.map(el => (el as any)[targetPropertyKey]);
193
+ return values.length === 1 ? values[0] : values;
194
+ },
195
+ set(this: any, value: any) {
196
+ ensureInit(this);
197
+ applyValueToTargets(this, value);
198
+ }
199
+ });
200
+ };
201
+ }
202
+
203
+ // ============================================
204
+ // Convenience Aliases
205
+ // ============================================
206
+
207
+ /**
208
+ * @property - Alias for @applyProperty
209
+ */
210
+ export function property(selector: string, targetPropertyKey: string | symbol, options?: PropertyOptions): MethodDecorator & PropertyDecorator;
211
+ export function property(selector: string, options?: PropertyOptions): MethodDecorator & PropertyDecorator;
212
+ export function property(selector: string, targetPropertyKeyOrOptions?: string | symbol | PropertyOptions, options?: PropertyOptions): MethodDecorator & PropertyDecorator {
213
+ return applyProperty(selector, targetPropertyKeyOrOptions as any, options);
214
+ }
215
+
216
+ /**
217
+ * @propertyThis - Apply property on $this element
218
+ * Can be used as: @propertyThis or @propertyThis('propertyName') or @propertyThis({ name: 'propertyName' })
219
+ */
220
+ export function propertyThis(target: Object, propertyKey: string | symbol): void;
221
+ export function propertyThis(targetPropertyKey: string | symbol, options?: PropertyOptions): MethodDecorator & PropertyDecorator;
222
+ export function propertyThis(options?: PropertyOptions): MethodDecorator & PropertyDecorator;
223
+ export function propertyThis(targetOrOptions?: any, propertyKeyOrOptions?: any, descriptor?: PropertyDescriptor): any {
224
+ // Direct decorator usage: @propertyThis
225
+ if (typeof targetOrOptions === 'object' && targetOrOptions !== null && !Array.isArray(targetOrOptions) &&
226
+ (typeof propertyKeyOrOptions === 'string' || typeof propertyKeyOrOptions === 'symbol')) {
227
+ // Called as @propertyThis (target, propertyKey)
228
+ return applyProperty('$this', undefined as any, {})(targetOrOptions, propertyKeyOrOptions, descriptor);
229
+ }
230
+
231
+ // Called with parameters
232
+ if (typeof targetOrOptions === 'string' || typeof targetOrOptions === 'symbol') {
233
+ // @propertyThis('propertyName', options?)
234
+ return applyProperty('$this', targetOrOptions, propertyKeyOrOptions);
235
+ } else if (targetOrOptions && typeof targetOrOptions === 'object') {
236
+ // @propertyThis({ name: 'propertyName' })
237
+ return applyProperty('$this', undefined as any, targetOrOptions);
238
+ } else {
239
+ // @propertyThis() or @propertyThis
240
+ return applyProperty('$this', undefined as any, {});
241
+ }
242
+ }
243
+
244
+ /**
245
+ * @setProperty - Alias for @applyProperty (method-decorator semantics)
246
+ */
247
+ export function setProperty(selector: string, targetPropertyKey: string | symbol, options?: PropertyOptions): MethodDecorator;
248
+ export function setProperty(selector: string, options?: PropertyOptions): MethodDecorator;
249
+ export function setProperty(selector: string, targetPropertyKeyOrOptions?: string | symbol | PropertyOptions, options?: PropertyOptions): MethodDecorator {
250
+ return applyProperty(selector, targetPropertyKeyOrOptions as any, options) as MethodDecorator;
251
+ }
252
+
253
+ /**
254
+ * @setPropertyThis - Set property on $this element
255
+ * Can be used as: @setPropertyThis or @setPropertyThis('propertyName') or @setPropertyThis({ name: 'propertyName' })
256
+ */
257
+ export function setPropertyThis(target: Object, propertyKey: string | symbol): void;
258
+ export function setPropertyThis(targetPropertyKey: string | symbol, options?: PropertyOptions): MethodDecorator;
259
+ export function setPropertyThis(options?: PropertyOptions): MethodDecorator;
260
+ export function setPropertyThis(targetOrOptions?: any, propertyKeyOrOptions?: any, descriptor?: PropertyDescriptor): any {
261
+ // Direct decorator usage: @setPropertyThis
262
+ if (typeof targetOrOptions === 'object' && targetOrOptions !== null && !Array.isArray(targetOrOptions) &&
263
+ (typeof propertyKeyOrOptions === 'string' || typeof propertyKeyOrOptions === 'symbol')) {
264
+ // Called as @setPropertyThis (target, propertyKey)
265
+ return applyProperty('$this', undefined as any, {})(targetOrOptions, propertyKeyOrOptions, descriptor);
266
+ }
267
+
268
+ // Called with parameters
269
+ if (typeof targetOrOptions === 'string' || typeof targetOrOptions === 'symbol') {
270
+ // @setPropertyThis('propertyName', options?)
271
+ return applyProperty('$this', targetOrOptions, propertyKeyOrOptions) as MethodDecorator;
272
+ } else if (targetOrOptions && typeof targetOrOptions === 'object') {
273
+ // @setPropertyThis({ name: 'propertyName' })
274
+ return applyProperty('$this', undefined as any, targetOrOptions) as MethodDecorator;
275
+ } else {
276
+ // @setPropertyThis() or @setPropertyThis
277
+ return applyProperty('$this', undefined as any, {}) as MethodDecorator;
278
+ }
279
+ }
280
+
281
+
282
+
283
+ // ============================================
284
+ // Metadata Helpers
285
+ // ============================================
286
+
287
+ export const findAllPropertyMetadata = (target: any): PropertyMetadata[] => {
288
+ const actualTarget = target instanceof Function ? target : target.constructor;
289
+ return ReflectUtils.findAllMetadata<PropertyMetadata[]>(PROPERTY_METADATA_KEY, actualTarget).flat();
290
+ };
291
+
292
+ // Backward compatibility alias
293
+ export const findAllPropertyApplyMetadata = (target: any): Map<string | symbol, PropertyMetadata> => {
294
+ const result = new Map<string | symbol, PropertyMetadata>();
295
+ findAllPropertyMetadata(target).forEach(meta => {
296
+ result.set(meta.propertyKey, meta);
297
+ });
298
+ return result;
299
+ };
300
+
301
+
302
+ export default applyProperty;
@@ -89,6 +89,7 @@ const applyToDom = (swcId: string, id: string, pos: ApplySlotPosition, nodes: No
89
89
  nodeSlot.clear(id);
90
90
  }
91
91
  }
92
+
92
93
  /**
93
94
  * @applyNode decorator to surgically add/replace nodes to a target element.
94
95
  */
@@ -96,7 +97,7 @@ export function applySlot(targetId: string, opt: OptionalType<ApplySlotOptions,
96
97
  return (targetObj: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<any>) => {
97
98
 
98
99
 
99
- const options: ApplySlotOptions = {position: 'replaceChildrenHtml', ...opt};
100
+ const options: ApplySlotOptions = {position: 'replaceChildren', ...opt};
100
101
 
101
102
 
102
103
  const constructor = targetObj.constructor;
@@ -147,7 +148,7 @@ export function applySlot(targetId: string, opt: OptionalType<ApplySlotOptions,
147
148
  if (res instanceof Promise) {
148
149
  return res.then(asyncRes => {
149
150
  const nodes = resToNodes(asyncRes)
150
- fallbackNodes.forEach((it: any)=>it.remove());
151
+ fallbackNodes.forEach((it: any) => it.remove());
151
152
  applyToDom(swcId, targetId, options.position, nodes);
152
153
  })
153
154
  } else {
@@ -158,42 +159,48 @@ export function applySlot(targetId: string, opt: OptionalType<ApplySlotOptions,
158
159
  };
159
160
  }
160
161
 
161
- // export const findAllApplySlotMetadata = (target: any): Map<string | symbol, ApplySlotMetadata> => {
162
- export const findAllApplySlotMetadata = (target: any): ApplySlotMetadata[] => {
163
- const constructor = target instanceof Function ? target : target.constructor;
164
- return ReflectUtils.getMetadata(APPLY_SLOT_METADATA_KEY, constructor);
165
- };
166
-
167
- export function applySlotClear(targetId: string): MethodDecorator {
162
+ export function clearSlot(targetId: string): MethodDecorator {
168
163
  return applySlot(targetId, {position: 'clear'});
169
164
  }
170
165
 
171
- export function applySlotPrependHtml(targetId: string): MethodDecorator {
166
+ export function prependHtmlSlot(targetId: string): MethodDecorator {
172
167
  return applySlot(targetId, {position: 'prependHtml'});
173
168
  }
174
169
 
175
- export const applySlotPrepend = applySlotPrependHtml;
170
+ export function prependSlot(targetId: string): MethodDecorator {
171
+ return applySlot(targetId, {position: 'prepend'});
172
+ }
176
173
 
177
- export function applySlotPrependText(targetId: string): MethodDecorator {
174
+ export function prependTextSlot(targetId: string): MethodDecorator {
178
175
  return applySlot(targetId, {position: 'prependText'});
179
176
  }
180
177
 
181
- export function applySlotAppendHtml(targetId: string): MethodDecorator {
178
+ export function appendHtmlSlot(targetId: string): MethodDecorator {
182
179
  return applySlot(targetId, {position: 'appendHtml'});
183
180
  }
184
181
 
185
- export function applySlotAppendText(targetId: string): MethodDecorator {
182
+ export function appendTextSlot(targetId: string): MethodDecorator {
186
183
  return applySlot(targetId, {position: 'appendText'});
187
184
  }
188
185
 
189
- export const applySlotAppend = applySlotAppendHtml;
186
+ export function appendSlot(targetId: string): MethodDecorator {
187
+ return applySlot(targetId, {position: 'append'});
188
+ }
190
189
 
191
- export function applySlotReplaceChildrenHtml(targetId: string): MethodDecorator {
190
+ export function replaceChildrenHtmlSlot(targetId: string): MethodDecorator {
192
191
  return applySlot(targetId, {position: 'replaceChildrenHtml'});
193
192
  }
194
193
 
195
- export const applySlotReplaceChildren = applySlotReplaceChildrenHtml;
194
+ export function replaceChildrenSlot(targetId: string): MethodDecorator {
195
+ return applySlot(targetId, {position: 'replaceChildren'});
196
+ }
196
197
 
197
- export function applySlotReplaceChildrenText(targetId: string): MethodDecorator {
198
+ export function replaceChildrenTextSlot(targetId: string): MethodDecorator {
198
199
  return applySlot(targetId, {position: 'replaceChildrenText'});
199
200
  }
201
+
202
+ // export const findAllApplySlotMetadata = (target: any): Map<string | symbol, ApplySlotMetadata> => {
203
+ export const findAllApplySlotMetadata = (target: any): ApplySlotMetadata[] => {
204
+ const constructor = target instanceof Function ? target : target.constructor;
205
+ return ReflectUtils.getMetadata(APPLY_SLOT_METADATA_KEY, constructor);
206
+ };
@@ -2,7 +2,7 @@ import { ReflectUtils } from '@dooboostore/core';
2
2
 
3
3
  export const ON_ATTRIBUTE_CHANGED_METADATA_KEY = Symbol.for('simple-web-component:on-attribute-changed');
4
4
 
5
- export interface ChangedAttributeThisOptions {
5
+ export interface ChangedAttributeThisOptions {
6
6
  type?: typeof Number | typeof Boolean | typeof String;
7
7
  while?: 'connected';
8
8
  }