@dooboostore/simple-web-component 1.0.43 → 1.0.44

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 (144) hide show
  1. package/README.md +298 -49
  2. package/dist/cjs/SwcAppEngine.js +3 -1
  3. package/dist/cjs/SwcAppEngine.js.map +2 -2
  4. package/dist/cjs/decorators/addEventListener.js.map +2 -2
  5. package/dist/cjs/decorators/applyAttribute.js +30 -28
  6. package/dist/cjs/decorators/applyAttribute.js.map +2 -2
  7. package/dist/cjs/decorators/applyClass.js +57 -21
  8. package/dist/cjs/decorators/applyClass.js.map +3 -3
  9. package/dist/cjs/decorators/applyNode.js +165 -105
  10. package/dist/cjs/decorators/applyNode.js.map +2 -2
  11. package/dist/cjs/decorators/applyProperty.js +11 -28
  12. package/dist/cjs/decorators/applyProperty.js.map +2 -2
  13. package/dist/cjs/decorators/applyStyle.js +39 -15
  14. package/dist/cjs/decorators/applyStyle.js.map +3 -3
  15. package/dist/cjs/decorators/{changedAttributeThis.js → changedAttribute.js} +6 -6
  16. package/dist/cjs/decorators/changedAttribute.js.map +7 -0
  17. package/dist/cjs/decorators/elementDefine.js +37 -6
  18. package/dist/cjs/decorators/elementDefine.js.map +3 -3
  19. package/dist/cjs/decorators/emitCustomEvent.js +56 -42
  20. package/dist/cjs/decorators/emitCustomEvent.js.map +2 -2
  21. package/dist/cjs/decorators/index.js +1 -1
  22. package/dist/cjs/decorators/index.js.map +2 -2
  23. package/dist/cjs/decorators/publishSwcAppMessage.js +5 -5
  24. package/dist/cjs/decorators/publishSwcAppMessage.js.map +3 -3
  25. package/dist/cjs/decorators/query.js +96 -145
  26. package/dist/cjs/decorators/query.js.map +3 -3
  27. package/dist/cjs/decorators/queryAll.js +104 -131
  28. package/dist/cjs/decorators/queryAll.js.map +3 -3
  29. package/dist/cjs/decorators/subscribeSwcAppMessageWhileConnected.js +2 -0
  30. package/dist/cjs/decorators/subscribeSwcAppMessageWhileConnected.js.map +2 -2
  31. package/dist/cjs/decorators/subscribeSwcAppRouteChangeWhileConnected.js +2 -0
  32. package/dist/cjs/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +2 -2
  33. package/dist/cjs/elements/SwcAppMixin.js +17 -2
  34. package/dist/cjs/elements/SwcAppMixin.js.map +2 -2
  35. package/dist/cjs/examples/RxJSOperatorsExample.js +285 -0
  36. package/dist/cjs/examples/RxJSOperatorsExample.js.map +7 -0
  37. package/dist/cjs/index.js +1 -0
  38. package/dist/cjs/index.js.map +2 -2
  39. package/dist/cjs/router/ElementRouter.js +4 -0
  40. package/dist/cjs/router/ElementRouter.js.map +2 -2
  41. package/dist/esm/SwcAppEngine.js +3 -1
  42. package/dist/esm/SwcAppEngine.js.map +2 -2
  43. package/dist/esm/decorators/addEventListener.js.map +2 -2
  44. package/dist/esm/decorators/applyAttribute.js +30 -28
  45. package/dist/esm/decorators/applyAttribute.js.map +2 -2
  46. package/dist/esm/decorators/applyClass.js +57 -21
  47. package/dist/esm/decorators/applyClass.js.map +3 -3
  48. package/dist/esm/decorators/applyNode.js +165 -105
  49. package/dist/esm/decorators/applyNode.js.map +2 -2
  50. package/dist/esm/decorators/applyProperty.js +11 -28
  51. package/dist/esm/decorators/applyProperty.js.map +2 -2
  52. package/dist/esm/decorators/applyStyle.js +39 -15
  53. package/dist/esm/decorators/applyStyle.js.map +3 -3
  54. package/dist/esm/decorators/{changedAttributeThis.js → changedAttribute.js} +3 -3
  55. package/dist/esm/decorators/changedAttribute.js.map +7 -0
  56. package/dist/esm/decorators/elementDefine.js +35 -4
  57. package/dist/esm/decorators/elementDefine.js.map +2 -2
  58. package/dist/esm/decorators/emitCustomEvent.js +56 -42
  59. package/dist/esm/decorators/emitCustomEvent.js.map +2 -2
  60. package/dist/esm/decorators/index.js +1 -1
  61. package/dist/esm/decorators/index.js.map +1 -1
  62. package/dist/esm/decorators/publishSwcAppMessage.js +5 -5
  63. package/dist/esm/decorators/publishSwcAppMessage.js.map +3 -3
  64. package/dist/esm/decorators/query.js +96 -145
  65. package/dist/esm/decorators/query.js.map +3 -3
  66. package/dist/esm/decorators/queryAll.js +104 -131
  67. package/dist/esm/decorators/queryAll.js.map +3 -3
  68. package/dist/esm/decorators/subscribeSwcAppMessageWhileConnected.js +2 -0
  69. package/dist/esm/decorators/subscribeSwcAppMessageWhileConnected.js.map +2 -2
  70. package/dist/esm/decorators/subscribeSwcAppRouteChangeWhileConnected.js +2 -0
  71. package/dist/esm/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +2 -2
  72. package/dist/esm/elements/SwcAppMixin.js +18 -3
  73. package/dist/esm/elements/SwcAppMixin.js.map +2 -2
  74. package/dist/esm/examples/RxJSOperatorsExample.js +266 -0
  75. package/dist/esm/examples/RxJSOperatorsExample.js.map +7 -0
  76. package/dist/esm/index.js +1 -0
  77. package/dist/esm/index.js.map +2 -2
  78. package/dist/esm/router/ElementRouter.js +4 -0
  79. package/dist/esm/router/ElementRouter.js.map +2 -2
  80. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +759 -512
  81. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
  82. package/dist/types/SwcAppEngine.d.ts.map +1 -1
  83. package/dist/types/decorators/addEventListener.d.ts +17 -14
  84. package/dist/types/decorators/addEventListener.d.ts.map +1 -1
  85. package/dist/types/decorators/applyAttribute.d.ts +35 -20
  86. package/dist/types/decorators/applyAttribute.d.ts.map +1 -1
  87. package/dist/types/decorators/applyClass.d.ts +16 -36
  88. package/dist/types/decorators/applyClass.d.ts.map +1 -1
  89. package/dist/types/decorators/applyNode.d.ts +172 -30
  90. package/dist/types/decorators/applyNode.d.ts.map +1 -1
  91. package/dist/types/decorators/applyProperty.d.ts +27 -18
  92. package/dist/types/decorators/applyProperty.d.ts.map +1 -1
  93. package/dist/types/decorators/applyStyle.d.ts +7 -7
  94. package/dist/types/decorators/applyStyle.d.ts.map +1 -1
  95. package/dist/types/decorators/{changedAttributeThis.d.ts → changedAttribute.d.ts} +2 -2
  96. package/dist/types/decorators/changedAttribute.d.ts.map +1 -0
  97. package/dist/types/decorators/elementDefine.d.ts.map +1 -1
  98. package/dist/types/decorators/emitCustomEvent.d.ts +3 -10
  99. package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
  100. package/dist/types/decorators/index.d.ts +1 -1
  101. package/dist/types/decorators/index.d.ts.map +1 -1
  102. package/dist/types/decorators/publishSwcAppMessage.d.ts +1 -1
  103. package/dist/types/decorators/publishSwcAppMessage.d.ts.map +1 -1
  104. package/dist/types/decorators/query.d.ts +3 -26
  105. package/dist/types/decorators/query.d.ts.map +1 -1
  106. package/dist/types/decorators/queryAll.d.ts +3 -20
  107. package/dist/types/decorators/queryAll.d.ts.map +1 -1
  108. package/dist/types/decorators/subscribeSwcAppMessageWhileConnected.d.ts +1 -0
  109. package/dist/types/decorators/subscribeSwcAppMessageWhileConnected.d.ts.map +1 -1
  110. package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts +2 -0
  111. package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts.map +1 -1
  112. package/dist/types/elements/SwcAppMixin.d.ts +4 -4
  113. package/dist/types/elements/SwcAppMixin.d.ts.map +1 -1
  114. package/dist/types/examples/RxJSOperatorsExample.d.ts +94 -0
  115. package/dist/types/examples/RxJSOperatorsExample.d.ts.map +1 -0
  116. package/dist/types/index.d.ts +1 -0
  117. package/dist/types/index.d.ts.map +1 -1
  118. package/dist/types/router/ElementRouter.d.ts.map +1 -1
  119. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +759 -512
  120. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
  121. package/package.json +3 -3
  122. package/src/SwcAppEngine.ts +3 -1
  123. package/src/decorators/addEventListener.ts +28 -24
  124. package/src/decorators/applyAttribute.ts +109 -63
  125. package/src/decorators/applyClass.ts +89 -15
  126. package/src/decorators/applyNode.ts +357 -100
  127. package/src/decorators/applyProperty.ts +42 -63
  128. package/src/decorators/applyStyle.ts +59 -11
  129. package/src/decorators/{changedAttributeThis.ts → changedAttribute.ts} +1 -1
  130. package/src/decorators/elementDefine.ts +47 -4
  131. package/src/decorators/emitCustomEvent.ts +44 -36
  132. package/src/decorators/index.ts +1 -1
  133. package/src/decorators/publishSwcAppMessage.ts +1 -1
  134. package/src/decorators/query.ts +90 -159
  135. package/src/decorators/queryAll.ts +92 -134
  136. package/src/decorators/subscribeSwcAppMessageWhileConnected.ts +1 -0
  137. package/src/decorators/subscribeSwcAppRouteChangeWhileConnected.ts +3 -1
  138. package/src/elements/SwcAppMixin.ts +43 -24
  139. package/src/examples/RxJSOperatorsExample.ts +279 -0
  140. package/src/index.ts +2 -0
  141. package/src/router/ElementRouter.ts +4 -0
  142. package/dist/cjs/decorators/changedAttributeThis.js.map +0 -7
  143. package/dist/esm/decorators/changedAttributeThis.js.map +0 -7
  144. package/dist/types/decorators/changedAttributeThis.d.ts.map +0 -1
@@ -11,173 +11,104 @@ export interface QueryMetadata {
11
11
 
12
12
  export const QUERY_METADATA_KEY = Symbol.for('simple-web-component:query');
13
13
 
14
- export function query(target: SpecialSelector): PropertyDecorator;
14
+ export function query(target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor): PropertyDescriptor | void;
15
15
  export function query(selector: string, options?: SwcQueryOptions): PropertyDecorator;
16
+ export function query(options?: SwcQueryOptions): PropertyDecorator;
16
17
  /**
17
18
  * @query decorator to inject a single element into a class property.
18
19
  */
19
- export function query(selectorOrTarget: string, options: any = {}): PropertyDecorator {
20
- return (targetObj: Object, propertyKey: string | symbol, descriptor?: never): void => {
21
- if (descriptor !== undefined) {
22
- throw new Error(`@query decorator cannot be used on methods. (Method: ${String(propertyKey)})`);
23
- }
24
-
25
- const constructor = targetObj.constructor;
26
- let queries = ReflectUtils.getMetadata<QueryMetadata[]>(QUERY_METADATA_KEY, constructor);
27
- if (!queries) {
28
- queries = [];
29
- ReflectUtils.defineMetadata(QUERY_METADATA_KEY, queries, constructor);
30
- }
31
- queries.push({ propertyKey, selector: selectorOrTarget, options });
32
-
33
- Object.defineProperty(targetObj, propertyKey, {
34
- get(this: HTMLElement) {
35
- ensureInit(this);
36
- const selector = selectorOrTarget;
37
-
38
- const r = options.root || 'auto';
39
- const applyRoot = (t: any) => {
40
- if (!t || !(t instanceof HTMLElement)) return t;
41
- if (r === 'auto') return t.shadowRoot || t;
42
- if (r === 'shadow') return t.shadowRoot;
43
- if (r === 'light') return t;
44
- if (r === 'all') return t.shadowRoot || t;
45
- return t;
46
- };
47
-
48
- // --- Special Selectors: HostSet ---
49
- const hostSet = SwcUtils.getHostSet(this);
50
- if (selector === '$this') return applyRoot(this);
51
- if (selector === '$host') return applyRoot(hostSet.$host);
52
- if (selector === '$parentHost') return applyRoot(hostSet.$parentHost);
53
- if (selector === '$appHost') return applyRoot(hostSet.$appHost);
54
- if (selector === '$firstHost') return applyRoot(hostSet.$firstHost);
55
- if (selector === '$lastHost') return applyRoot(hostSet.$lastHost);
56
- if (selector === '$firstAppHost') return applyRoot(hostSet.$firstAppHost);
57
- if (selector === '$lastAppHost') return applyRoot(hostSet.$lastAppHost);
58
-
59
- // --- Special Selectors: Env ---
60
- const config = getElementConfig(this);
61
- const win = config?.window || window;
62
- if (selector === '$window') return win;
63
- if (selector === '$document') return win.document;
64
-
65
- // --- Standard Selectors ---
66
- if (r === 'shadow') return this.shadowRoot ? this.shadowRoot.querySelector(selector) : null;
67
- if (r === 'light') return this.querySelector(selector);
68
- if (r === 'all') {
69
- const shadowMatch = this.shadowRoot ? this.shadowRoot.querySelector(selector) : null;
70
- return shadowMatch || this.querySelector(selector);
71
- }
72
- return (this.shadowRoot || this).querySelector(selector);
73
- },
74
- set(this: HTMLElement, nv: any) {
75
- ensureInit(this);
76
- if (nv === null || nv === undefined) {
20
+ export function query(selectorOrTarget?: string | Object, optionsOrPropertyKey?: SwcQueryOptions | string | symbol, descriptor?: PropertyDescriptor): any {
21
+ // Bare decorator: @query
22
+ if (descriptor !== undefined && (typeof optionsOrPropertyKey === 'string' || typeof optionsOrPropertyKey === 'symbol')) {
23
+ throw new Error(`@query decorator cannot be used on methods. (Method: ${String(optionsOrPropertyKey)})`);
24
+ }
25
+ // With selector
26
+ if (typeof selectorOrTarget === 'string') {
27
+ return (targetObj: Object, propertyKey: string | symbol, descriptor?: never): void => {
28
+ if (descriptor !== undefined) {
29
+ throw new Error(`@query decorator cannot be used on methods. (Method: ${String(propertyKey)})`);
30
+ }
31
+
32
+ const constructor = targetObj.constructor;
33
+ let queries = ReflectUtils.getMetadata<QueryMetadata[]>(QUERY_METADATA_KEY, constructor);
34
+ if (!queries) {
35
+ queries = [];
36
+ ReflectUtils.defineMetadata(QUERY_METADATA_KEY, queries, constructor);
37
+ }
38
+ queries.push({ propertyKey, selector: selectorOrTarget, options: optionsOrPropertyKey as SwcQueryOptions || {} });
39
+
40
+ Object.defineProperty(targetObj, propertyKey, {
41
+ get(this: HTMLElement) {
42
+ ensureInit(this);
77
43
  const selector = selectorOrTarget;
78
- if (selector.startsWith('$') && selector !== '$this') return;
79
44
 
80
- const r = options.root || 'auto';
81
- const targets: Element[] = [];
82
-
83
- if (r === 'shadow') {
84
- if (this.shadowRoot?.querySelector(selector)) targets.push(this.shadowRoot.querySelector(selector)!);
85
- } else if (r === 'light') {
86
- if (this.querySelector(selector)) targets.push(this.querySelector(selector)!);
87
- } else if (r === 'all') {
88
- if (this.shadowRoot?.querySelector(selector)) targets.push(this.shadowRoot.querySelector(selector)!);
89
- if (this.querySelector(selector)) targets.push(this.querySelector(selector)!);
90
- } else {
91
- const el = (this.shadowRoot || this).querySelector(selector);
92
- if (el) targets.push(el);
45
+ const r = (optionsOrPropertyKey as SwcQueryOptions)?.root || 'auto';
46
+ const applyRoot = (t: any) => {
47
+ if (!t || !(t instanceof HTMLElement)) return t;
48
+ if (r === 'auto') return t.shadowRoot || t;
49
+ if (r === 'shadow') return t.shadowRoot;
50
+ if (r === 'light') return t;
51
+ if (r === 'all') return t.shadowRoot || t;
52
+ return t;
53
+ };
54
+
55
+ // --- Special Selectors: HostSet ---
56
+ const hostSet = SwcUtils.getHostSet(this);
57
+ if (selector === '$this') return applyRoot(this);
58
+ if (selector === '$host') return applyRoot(hostSet.$host);
59
+ if (selector === '$parentHost') return applyRoot(hostSet.$parentHost);
60
+ if (selector === '$appHost') return applyRoot(hostSet.$appHost);
61
+ if (selector === '$firstHost') return applyRoot(hostSet.$firstHost);
62
+ if (selector === '$lastHost') return applyRoot(hostSet.$lastHost);
63
+ if (selector === '$firstAppHost') return applyRoot(hostSet.$firstAppHost);
64
+ if (selector === '$lastAppHost') return applyRoot(hostSet.$lastAppHost);
65
+
66
+ // --- Special Selectors: Env ---
67
+ const config = getElementConfig(this);
68
+ const win = config?.window || window;
69
+ if (selector === '$window') return win;
70
+ if (selector === '$document') return win.document;
71
+
72
+ // --- Standard Selectors ---
73
+ if (r === 'shadow') return this.shadowRoot ? this.shadowRoot.querySelector(selector) : null;
74
+ if (r === 'light') return this.querySelector(selector);
75
+ if (r === 'all') {
76
+ const shadowMatch = this.shadowRoot ? this.shadowRoot.querySelector(selector) : null;
77
+ return shadowMatch || this.querySelector(selector);
93
78
  }
94
-
95
- targets.forEach(t => t.remove());
96
- }
97
- },
98
- enumerable: true,
99
- configurable: true
100
- });
101
- };
102
- }
103
-
104
- /**
105
- * @queryThis decorator - simplified version of @query for $this selector
106
- */
107
- export function queryThis(target: Object, propertyKey: string | symbol): void;
108
- export function queryThis(): PropertyDecorator;
109
- export function queryThis(options: SwcQueryOptions): PropertyDecorator;
110
- export function queryThis(targetOrOptions?: any, propertyKey?: string | symbol): any {
111
- if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {
112
- return query('$this', {})(targetOrOptions, propertyKey);
113
- }
114
- if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {
115
- return query('$this', targetOrOptions as SwcQueryOptions);
116
- } else {
117
- return query('$this', {});
118
- }
119
- }
120
-
121
-
122
- export function queryWindow(target: Object, propertyKey: string | symbol): void;
123
- export function queryWindow(): PropertyDecorator;
124
- export function queryWindow(options: SwcQueryOptions): PropertyDecorator;
125
- export function queryWindow(targetOrOptions?: any, propertyKey?: string | symbol): any {
126
- if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {
127
- return query('$window', {})(targetOrOptions, propertyKey);
128
- }
129
- if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {
130
- return query('$window', targetOrOptions as SwcQueryOptions);
131
- } else {
132
- return query('$window', {});
133
- }
134
- }
135
-
136
- export function queryDocument(target: Object, propertyKey: string | symbol): void;
137
- export function queryDocument(): PropertyDecorator;
138
- export function queryDocument(options: SwcQueryOptions): PropertyDecorator;
139
- export function queryDocument(targetOrOptions?: any, propertyKey?: string | symbol): any {
140
- if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {
141
- return query('$document', {})(targetOrOptions, propertyKey);
142
- }
143
- if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {
144
- return query('$document', targetOrOptions as SwcQueryOptions);
145
- } else {
146
- return query('$document', {});
147
- }
148
- }
149
- /**
150
- * @host - Query $host (Direct parent SWC component)
151
- */
152
- export function queryHost(target: Object, propertyKey: string | symbol): void;
153
- export function queryHost(): PropertyDecorator;
154
- export function queryHost(options: SwcQueryOptions): PropertyDecorator;
155
- export function queryHost(targetOrOptions?: any, propertyKey?: string | symbol): any {
156
- if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {
157
- return query('$host', {})(targetOrOptions, propertyKey);
158
- }
159
- if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {
160
- return query('$host', targetOrOptions as SwcQueryOptions);
161
- } else {
162
- return query('$host', {});
163
- }
164
- }
165
-
166
- /**
167
- * @appHost - Query $appHost (Nearest <swc-app>)
168
- */
169
- export function queryAppHost(target: Object, propertyKey: string | symbol): void;
170
- export function queryAppHost(): PropertyDecorator;
171
- export function queryAppHost(options: SwcQueryOptions): PropertyDecorator;
172
- export function queryAppHost(targetOrOptions?: any, propertyKey?: string | symbol): any {
173
- if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {
174
- return query('$appHost', {})(targetOrOptions, propertyKey);
175
- }
176
- if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {
177
- return query('$appHost', targetOrOptions as SwcQueryOptions);
178
- } else {
179
- return query('$appHost', {});
79
+ return (this.shadowRoot || this).querySelector(selector);
80
+ },
81
+ set(this: HTMLElement, nv: any) {
82
+ ensureInit(this);
83
+ if (nv === null || nv === undefined) {
84
+ const selector = selectorOrTarget;
85
+ if (selector.startsWith('$') && selector !== '$this') return;
86
+
87
+ const r = (optionsOrPropertyKey as SwcQueryOptions)?.root || 'auto';
88
+ const targets: Element[] = [];
89
+
90
+ if (r === 'shadow') {
91
+ if (this.shadowRoot?.querySelector(selector)) targets.push(this.shadowRoot.querySelector(selector)!);
92
+ } else if (r === 'light') {
93
+ if (this.querySelector(selector)) targets.push(this.querySelector(selector)!);
94
+ } else if (r === 'all') {
95
+ if (this.shadowRoot?.querySelector(selector)) targets.push(this.shadowRoot.querySelector(selector)!);
96
+ if (this.querySelector(selector)) targets.push(this.querySelector(selector)!);
97
+ } else {
98
+ const el = (this.shadowRoot || this).querySelector(selector);
99
+ if (el) targets.push(el);
100
+ }
101
+
102
+ targets.forEach(t => t.remove());
103
+ }
104
+ },
105
+ enumerable: true,
106
+ configurable: true
107
+ });
108
+ };
180
109
  }
110
+ // Without selector (defaults to $this)
111
+ return query('$this', selectorOrTarget as SwcQueryOptions);
181
112
  }
182
113
 
183
114
  export const getQueryMetadata = (target: any): QueryMetadata[] => {
@@ -11,155 +11,113 @@ export interface QueryAllMetadata {
11
11
 
12
12
  export const QUERY_ALL_METADATA_KEY = Symbol.for('simple-web-component:query-all');
13
13
 
14
- export function queryAll(target: SpecialSelector): PropertyDecorator;
14
+ export function queryAll(target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor): PropertyDescriptor | void;
15
15
  export function queryAll(selector: string, options?: SwcQueryOptions): PropertyDecorator;
16
+ export function queryAll(options?: SwcQueryOptions): PropertyDecorator;
16
17
  /**
17
18
  * @queryAll decorator to inject a list of elements into a class property.
18
19
  */
19
- export function queryAll(selectorOrTarget: string, options: any = {}): PropertyDecorator {
20
- return (targetObj: Object, propertyKey: string | symbol, descriptor?: never): void => {
21
- if (descriptor !== undefined) {
22
- throw new Error(`@queryAll decorator cannot be used on methods. (Method: ${String(propertyKey)})`);
23
- }
24
-
25
- const constructor = targetObj.constructor;
26
- let queries = ReflectUtils.getMetadata<QueryAllMetadata[]>(QUERY_ALL_METADATA_KEY, constructor);
27
- if (!queries) {
28
- queries = [];
29
- ReflectUtils.defineMetadata(QUERY_ALL_METADATA_KEY, queries, constructor);
30
- }
31
- queries.push({ propertyKey, selector: selectorOrTarget, options });
20
+ export function queryAll(selectorOrTarget?: string | Object, optionsOrPropertyKey?: SwcQueryOptions | string | symbol, descriptor?: PropertyDescriptor): any {
21
+ // Bare decorator: @queryAll
22
+ if (descriptor !== undefined && (typeof optionsOrPropertyKey === 'string' || typeof optionsOrPropertyKey === 'symbol')) {
23
+ throw new Error(`@queryAll decorator cannot be used on methods. (Method: ${String(optionsOrPropertyKey)})`);
24
+ }
25
+ // With selector
26
+ if (typeof selectorOrTarget === 'string') {
27
+ return (targetObj: Object, propertyKey: string | symbol, descriptor?: never): void => {
28
+ if (descriptor !== undefined) {
29
+ throw new Error(`@queryAll decorator cannot be used on methods. (Method: ${String(propertyKey)})`);
30
+ }
32
31
 
33
- Object.defineProperty(targetObj, propertyKey, {
34
- get(this: HTMLElement) {
35
- ensureInit(this);
36
- const selector = selectorOrTarget;
32
+ const constructor = targetObj.constructor;
33
+ let queries = ReflectUtils.getMetadata<QueryAllMetadata[]>(QUERY_ALL_METADATA_KEY, constructor);
34
+ if (!queries) {
35
+ queries = [];
36
+ ReflectUtils.defineMetadata(QUERY_ALL_METADATA_KEY, queries, constructor);
37
+ }
38
+ queries.push({ propertyKey, selector: selectorOrTarget, options: optionsOrPropertyKey as SwcQueryOptions || {} });
37
39
 
38
- const r = options.root || 'auto';
39
- const applyRoot = (t: any): any[] => {
40
- if (!t) return [];
41
- const items = Array.isArray(t) ? t : [t];
42
- const results: any[] = [];
43
- items.forEach(it => {
44
- if (!(it instanceof HTMLElement)) {
45
- results.push(it);
46
- return;
47
- }
48
- if (r === 'auto') results.push(it.shadowRoot || it);
49
- else {
50
- if (r === 'light' || r === 'all') results.push(it);
51
- if ((r === 'shadow' || r === 'all') && it.shadowRoot) results.push(it.shadowRoot);
52
- }
53
- });
54
- return results;
55
- };
40
+ Object.defineProperty(targetObj, propertyKey, {
41
+ get(this: HTMLElement) {
42
+ ensureInit(this);
43
+ const selector = selectorOrTarget;
56
44
 
57
- // --- Special Selectors: HostSet ---
58
- const hostSet = SwcUtils.getHostSet(this);
59
- if (selector === '$hosts') return applyRoot(hostSet.$hosts);
60
- if (selector === '$appHosts') return applyRoot(hostSet.$appHosts);
61
- if (selector === '$host') return applyRoot(hostSet.$host);
62
- if (selector === '$parentHost') return applyRoot(hostSet.$parentHost);
63
- if (selector === '$appHost') return applyRoot(hostSet.$appHost);
64
- if (selector === '$firstHost') return applyRoot(hostSet.$firstHost);
65
- if (selector === '$lastHost') return applyRoot(hostSet.$lastHost);
66
- if (selector === '$firstAppHost') return applyRoot(hostSet.$firstAppHost);
67
- if (selector === '$lastAppHost') return applyRoot(hostSet.$lastAppHost);
45
+ const r = (optionsOrPropertyKey as SwcQueryOptions)?.root || 'auto';
46
+ const applyRoot = (t: any): any[] => {
47
+ if (!t) return [];
48
+ const items = Array.isArray(t) ? t : [t];
49
+ const results: any[] = [];
50
+ items.forEach(it => {
51
+ if (!(it instanceof HTMLElement)) {
52
+ results.push(it);
53
+ return;
54
+ }
55
+ if (r === 'auto') results.push(it.shadowRoot || it);
56
+ else {
57
+ if (r === 'light' || r === 'all') results.push(it);
58
+ if ((r === 'shadow' || r === 'all') && it.shadowRoot) results.push(it.shadowRoot);
59
+ }
60
+ });
61
+ return results;
62
+ };
68
63
 
69
- // --- Special Selectors: Env ---
70
- const config = getElementConfig(this);
71
- const win = config?.window || window;
72
- if (selector === '$window') return [win];
73
- if (selector === '$document') return [win.document];
74
- if (selector === '$this') return applyRoot(this);
64
+ // --- Special Selectors: HostSet ---
65
+ const hostSet = SwcUtils.getHostSet(this);
66
+ if (selector === '$hosts') return applyRoot(hostSet.$hosts);
67
+ if (selector === '$appHosts') return applyRoot(hostSet.$appHosts);
68
+ if (selector === '$host') return applyRoot(hostSet.$host);
69
+ if (selector === '$parentHost') return applyRoot(hostSet.$parentHost);
70
+ if (selector === '$appHost') return applyRoot(hostSet.$appHost);
71
+ if (selector === '$firstHost') return applyRoot(hostSet.$firstHost);
72
+ if (selector === '$lastHost') return applyRoot(hostSet.$lastHost);
73
+ if (selector === '$firstAppHost') return applyRoot(hostSet.$firstAppHost);
74
+ if (selector === '$lastAppHost') return applyRoot(hostSet.$lastAppHost);
75
75
 
76
- // --- Standard Selectors ---
77
- if (r === 'shadow') return this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];
78
- if (r === 'light') return Array.from(this.querySelectorAll(selector));
79
- if (r === 'all') {
80
- const sNodes = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];
81
- const lNodes = Array.from(this.querySelectorAll(selector));
82
- return [...sNodes, ...lNodes];
83
- }
84
- const root = this.shadowRoot || this;
85
- return Array.from(root.querySelectorAll(selector));
86
- },
87
- set(this: HTMLElement, nv: any) {
88
- ensureInit(this);
89
- if (nv === null || nv === undefined || (Array.isArray(nv) && nv.length === 0)) {
90
- const selector = selectorOrTarget;
91
- if (selector.startsWith('$') && selector !== '$this') return;
76
+ // --- Special Selectors: Env ---
77
+ const config = getElementConfig(this);
78
+ const win = config?.window || window;
79
+ if (selector === '$window') return [win];
80
+ if (selector === '$document') return [win.document];
81
+ if (selector === '$this') return applyRoot(this);
92
82
 
93
- const r = options.root || 'auto';
94
- let targets: (Element | Node)[] = [];
95
- if (r === 'shadow') targets = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];
96
- else if (r === 'light') targets = Array.from(this.querySelectorAll(selector));
97
- else if (r === 'all') {
83
+ // --- Standard Selectors ---
84
+ if (r === 'shadow') return this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];
85
+ if (r === 'light') return Array.from(this.querySelectorAll(selector));
86
+ if (r === 'all') {
98
87
  const sNodes = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];
99
88
  const lNodes = Array.from(this.querySelectorAll(selector));
100
- targets = [...sNodes, ...lNodes];
101
- } else {
102
- targets = Array.from((this.shadowRoot || this).querySelectorAll(selector));
89
+ return [...sNodes, ...lNodes];
103
90
  }
104
- targets.forEach(t => (t as Element).remove());
105
- }
106
- },
107
- enumerable: true,
108
- configurable: true
109
- });
110
- };
111
- }
91
+ const root = this.shadowRoot || this;
92
+ return Array.from(root.querySelectorAll(selector));
93
+ },
94
+ set(this: HTMLElement, nv: any) {
95
+ ensureInit(this);
96
+ if (nv === null || nv === undefined || (Array.isArray(nv) && nv.length === 0)) {
97
+ const selector = selectorOrTarget;
98
+ if (selector.startsWith('$') && selector !== '$this') return;
112
99
 
113
- /**
114
- * @queryAllThis decorator - simplified version of @queryAll for $this selector
115
- */
116
- export function queryAllThis(target: Object, propertyKey: string | symbol): void;
117
- export function queryAllThis(): PropertyDecorator;
118
- export function queryAllThis(options: SwcQueryOptions): PropertyDecorator;
119
- export function queryAllThis(targetOrOptions?: any, propertyKey?: string | symbol): any {
120
- if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {
121
- return queryAll('$this', {})(targetOrOptions, propertyKey);
122
- }
123
-
124
- if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {
125
- return queryAll('$this', targetOrOptions as SwcQueryOptions);
126
- } else {
127
- return queryAll('$this', {});
128
- }
129
- }
130
-
131
- /**
132
- * @allParentHost - Query all parent SWC components
133
- */
134
- export function allParentHost(target: Object, propertyKey: string | symbol): void;
135
- export function allParentHost(): PropertyDecorator;
136
- export function allParentHost(options: SwcQueryOptions): PropertyDecorator;
137
- export function allParentHost(targetOrOptions?: any, propertyKey?: string | symbol): any {
138
- if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {
139
- return queryAll('$host', {})(targetOrOptions, propertyKey);
140
- }
141
- if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {
142
- return queryAll('$host', targetOrOptions as SwcQueryOptions);
143
- } else {
144
- return queryAll('$host', {});
145
- }
146
- }
147
-
148
- /**
149
- * @allAppHost - Query all $appHost (All <swc-app> instances)
150
- */
151
- export function allAppHost(target: Object, propertyKey: string | symbol): void;
152
- export function allAppHost(): PropertyDecorator;
153
- export function allAppHost(options: SwcQueryOptions): PropertyDecorator;
154
- export function allAppHost(targetOrOptions?: any, propertyKey?: string | symbol): any {
155
- if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {
156
- return queryAll('$appHost', {})(targetOrOptions, propertyKey);
157
- }
158
- if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {
159
- return queryAll('$appHost', targetOrOptions as SwcQueryOptions);
160
- } else {
161
- return queryAll('$appHost', {});
100
+ const r = (optionsOrPropertyKey as SwcQueryOptions)?.root || 'auto';
101
+ let targets: (Element | Node)[] = [];
102
+ if (r === 'shadow') targets = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];
103
+ else if (r === 'light') targets = Array.from(this.querySelectorAll(selector));
104
+ else if (r === 'all') {
105
+ const sNodes = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];
106
+ const lNodes = Array.from(this.querySelectorAll(selector));
107
+ targets = [...sNodes, ...lNodes];
108
+ } else {
109
+ targets = Array.from((this.shadowRoot || this).querySelectorAll(selector));
110
+ }
111
+ targets.forEach(t => (t as Element).remove());
112
+ }
113
+ },
114
+ enumerable: true,
115
+ configurable: true
116
+ });
117
+ };
162
118
  }
119
+ // Without selector (defaults to $this)
120
+ return queryAll('$this', selectorOrTarget as SwcQueryOptions);
163
121
  }
164
122
 
165
123
  export const getQueryAllMetadata = (target: any): QueryAllMetadata[] | undefined => {
@@ -66,6 +66,7 @@ export function subscribeSwcAppMessageWhileConnected(targetOrMessageTypeOrOption
66
66
  return createSubscribeSwcAppMessageWhileConnected(options, messageType);
67
67
  }
68
68
 
69
+ export const receiveMessage = subscribeSwcAppMessageWhileConnected;
69
70
  // Helper function to retrieve message subscribers metadata
70
71
  export const getSubscribeSwcAppMessageWhileConnectedMetadata = (target: any): SwcAppMessageSubscriberMetadata[] | undefined => {
71
72
  const constructor = target instanceof Function ? target : target.constructor;
@@ -13,8 +13,9 @@ export interface SwcAppRouteChangeSubscriberMetadata {
13
13
 
14
14
  export interface SwcAppRouteChangeOptions {
15
15
  path?: RoutePathType;
16
- filter?: (router: Router, meta: {currentThis: any, helper: HelperHostSet}) => boolean;
16
+ filter?: (router: Router, meta: { currentThis: any; helper: HelperHostSet }) => boolean;
17
17
  order?: number;
18
+ valueKey?: symbol | string;
18
19
  }
19
20
 
20
21
  function createSubscribeSwcAppRouteChangeWhileConnected(options?: SwcAppRouteChangeOptions): MethodDecorator {
@@ -74,6 +75,7 @@ export function subscribeSwcAppRouteChangeWhileConnected(targetOrOptions?: any,
74
75
 
75
76
  return createSubscribeSwcAppRouteChangeWhileConnected(options);
76
77
  }
78
+ export const changedRoute = subscribeSwcAppRouteChangeWhileConnected;
77
79
 
78
80
  // Helper function to retrieve route change subscribers metadata
79
81
  export const getSubscribeSwcAppRouteChangeWhileConnectedMetadata = (target: any): SwcAppRouteChangeSubscriberMetadata[] => {