@dooboostore/simple-web-component 1.0.43 → 1.0.45

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 (146) hide show
  1. package/README.md +312 -63
  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 +66 -43
  6. package/dist/cjs/decorators/applyAttribute.js.map +2 -2
  7. package/dist/cjs/decorators/applyClass.js +110 -43
  8. package/dist/cjs/decorators/applyClass.js.map +3 -3
  9. package/dist/cjs/decorators/applyNode.js +200 -112
  10. package/dist/cjs/decorators/applyNode.js.map +2 -2
  11. package/dist/cjs/decorators/applyProperty.js +49 -45
  12. package/dist/cjs/decorators/applyProperty.js.map +2 -2
  13. package/dist/cjs/decorators/applyStyle.js +92 -37
  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 +81 -31
  18. package/dist/cjs/decorators/elementDefine.js.map +3 -3
  19. package/dist/cjs/decorators/emitCustomEvent.js +80 -52
  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 +133 -147
  26. package/dist/cjs/decorators/query.js.map +3 -3
  27. package/dist/cjs/decorators/queryAll.js +143 -132
  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/cjs/types/window.d.js.map +1 -1
  42. package/dist/esm/SwcAppEngine.js +3 -1
  43. package/dist/esm/SwcAppEngine.js.map +2 -2
  44. package/dist/esm/decorators/addEventListener.js.map +2 -2
  45. package/dist/esm/decorators/applyAttribute.js +66 -43
  46. package/dist/esm/decorators/applyAttribute.js.map +2 -2
  47. package/dist/esm/decorators/applyClass.js +110 -43
  48. package/dist/esm/decorators/applyClass.js.map +3 -3
  49. package/dist/esm/decorators/applyNode.js +200 -112
  50. package/dist/esm/decorators/applyNode.js.map +2 -2
  51. package/dist/esm/decorators/applyProperty.js +49 -45
  52. package/dist/esm/decorators/applyProperty.js.map +2 -2
  53. package/dist/esm/decorators/applyStyle.js +92 -37
  54. package/dist/esm/decorators/applyStyle.js.map +3 -3
  55. package/dist/esm/decorators/{changedAttributeThis.js → changedAttribute.js} +3 -3
  56. package/dist/esm/decorators/changedAttribute.js.map +7 -0
  57. package/dist/esm/decorators/elementDefine.js +79 -29
  58. package/dist/esm/decorators/elementDefine.js.map +2 -2
  59. package/dist/esm/decorators/emitCustomEvent.js +80 -52
  60. package/dist/esm/decorators/emitCustomEvent.js.map +2 -2
  61. package/dist/esm/decorators/index.js +1 -1
  62. package/dist/esm/decorators/index.js.map +1 -1
  63. package/dist/esm/decorators/publishSwcAppMessage.js +5 -5
  64. package/dist/esm/decorators/publishSwcAppMessage.js.map +3 -3
  65. package/dist/esm/decorators/query.js +133 -147
  66. package/dist/esm/decorators/query.js.map +3 -3
  67. package/dist/esm/decorators/queryAll.js +143 -132
  68. package/dist/esm/decorators/queryAll.js.map +3 -3
  69. package/dist/esm/decorators/subscribeSwcAppMessageWhileConnected.js +2 -0
  70. package/dist/esm/decorators/subscribeSwcAppMessageWhileConnected.js.map +2 -2
  71. package/dist/esm/decorators/subscribeSwcAppRouteChangeWhileConnected.js +2 -0
  72. package/dist/esm/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +2 -2
  73. package/dist/esm/elements/SwcAppMixin.js +18 -3
  74. package/dist/esm/elements/SwcAppMixin.js.map +2 -2
  75. package/dist/esm/examples/RxJSOperatorsExample.js +266 -0
  76. package/dist/esm/examples/RxJSOperatorsExample.js.map +7 -0
  77. package/dist/esm/index.js +1 -0
  78. package/dist/esm/index.js.map +2 -2
  79. package/dist/esm/router/ElementRouter.js +4 -0
  80. package/dist/esm/router/ElementRouter.js.map +2 -2
  81. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +1118 -633
  82. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
  83. package/dist/types/SwcAppEngine.d.ts.map +1 -1
  84. package/dist/types/decorators/addEventListener.d.ts +19 -15
  85. package/dist/types/decorators/addEventListener.d.ts.map +1 -1
  86. package/dist/types/decorators/applyAttribute.d.ts +45 -26
  87. package/dist/types/decorators/applyAttribute.d.ts.map +1 -1
  88. package/dist/types/decorators/applyClass.d.ts +19 -38
  89. package/dist/types/decorators/applyClass.d.ts.map +1 -1
  90. package/dist/types/decorators/applyNode.d.ts +175 -32
  91. package/dist/types/decorators/applyNode.d.ts.map +1 -1
  92. package/dist/types/decorators/applyProperty.d.ts +38 -25
  93. package/dist/types/decorators/applyProperty.d.ts.map +1 -1
  94. package/dist/types/decorators/applyStyle.d.ts +10 -9
  95. package/dist/types/decorators/applyStyle.d.ts.map +1 -1
  96. package/dist/types/decorators/{changedAttributeThis.d.ts → changedAttribute.d.ts} +2 -2
  97. package/dist/types/decorators/changedAttribute.d.ts.map +1 -0
  98. package/dist/types/decorators/elementDefine.d.ts.map +1 -1
  99. package/dist/types/decorators/emitCustomEvent.d.ts +6 -12
  100. package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
  101. package/dist/types/decorators/index.d.ts +1 -1
  102. package/dist/types/decorators/index.d.ts.map +1 -1
  103. package/dist/types/decorators/publishSwcAppMessage.d.ts +1 -1
  104. package/dist/types/decorators/publishSwcAppMessage.d.ts.map +1 -1
  105. package/dist/types/decorators/query.d.ts +16 -29
  106. package/dist/types/decorators/query.d.ts.map +1 -1
  107. package/dist/types/decorators/queryAll.d.ts +16 -23
  108. package/dist/types/decorators/queryAll.d.ts.map +1 -1
  109. package/dist/types/decorators/subscribeSwcAppMessageWhileConnected.d.ts +1 -0
  110. package/dist/types/decorators/subscribeSwcAppMessageWhileConnected.d.ts.map +1 -1
  111. package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts +2 -0
  112. package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts.map +1 -1
  113. package/dist/types/elements/SwcAppMixin.d.ts +4 -4
  114. package/dist/types/elements/SwcAppMixin.d.ts.map +1 -1
  115. package/dist/types/examples/RxJSOperatorsExample.d.ts +94 -0
  116. package/dist/types/examples/RxJSOperatorsExample.d.ts.map +1 -0
  117. package/dist/types/index.d.ts +1 -0
  118. package/dist/types/index.d.ts.map +1 -1
  119. package/dist/types/router/ElementRouter.d.ts.map +1 -1
  120. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +1118 -633
  121. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
  122. package/package.json +1 -1
  123. package/src/SwcAppEngine.ts +3 -1
  124. package/src/decorators/addEventListener.ts +31 -25
  125. package/src/decorators/applyAttribute.ts +164 -86
  126. package/src/decorators/applyClass.ts +161 -41
  127. package/src/decorators/applyNode.ts +408 -108
  128. package/src/decorators/applyProperty.ts +100 -89
  129. package/src/decorators/applyStyle.ts +131 -37
  130. package/src/decorators/{changedAttributeThis.ts → changedAttribute.ts} +1 -1
  131. package/src/decorators/elementDefine.ts +96 -30
  132. package/src/decorators/emitCustomEvent.ts +92 -60
  133. package/src/decorators/index.ts +1 -1
  134. package/src/decorators/publishSwcAppMessage.ts +1 -1
  135. package/src/decorators/query.ts +155 -162
  136. package/src/decorators/queryAll.ts +157 -139
  137. package/src/decorators/subscribeSwcAppMessageWhileConnected.ts +1 -0
  138. package/src/decorators/subscribeSwcAppRouteChangeWhileConnected.ts +3 -1
  139. package/src/elements/SwcAppMixin.ts +43 -24
  140. package/src/examples/RxJSOperatorsExample.ts +279 -0
  141. package/src/index.ts +2 -0
  142. package/src/router/ElementRouter.ts +4 -0
  143. package/src/types/window.d.ts +3 -0
  144. package/dist/cjs/decorators/changedAttributeThis.js.map +0 -7
  145. package/dist/esm/decorators/changedAttributeThis.js.map +0 -7
  146. package/dist/types/decorators/changedAttributeThis.d.ts.map +0 -1
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/decorators/emitCustomEvent.ts"],
4
- "sourcesContent": ["import {ReflectUtils} from '@dooboostore/core';\nimport { SpecialSelector, SwcQueryOptions, HelperHostSet } from '../types';\nimport {ensureInit, getElementConfig} from './elementDefine';\nimport {SwcUtils} from '../utils/Utils';\n\nexport interface EmitCustomEventBaseOptions {\n bubbles?: boolean;\n composed?: boolean;\n cancelable?: boolean;\n filter?: (target: EventTarget, detail: any, meta: { currentThis: any, helper: HelperHostSet }) => boolean;\n /**\n * Custom key to extract value from return object.\n * If not provided, uses EMIT_CUSTOM_EVENT_METADATA_KEY by default.\n * Useful when multiple @emitCustomEvent decorators are on the same method.\n * \n * Example:\n * @emitCustomEvent('$appHost', 'event1', { valueKey: 'detail1' })\n * @emitCustomEvent('$appHost', 'event2', { valueKey: 'detail2' })\n * myMethod() {\n * return {\n * detail1: { type: 'event1', data: 'value1' },\n * detail2: { type: 'event2', data: 'value2' }\n * };\n * }\n */\n valueKey?: symbol | string;\n}\n\ntype Options = (EmitCustomEventBaseOptions & SwcQueryOptions) | (EmitCustomEventBaseOptions & SwcQueryOptions & { attributeName?: string });\n\nexport interface EmitCustomEventMetadata {\n propertyKey: string | symbol;\n selector: string;\n type: string;\n options: Options;\n}\n\nexport const EMIT_CUSTOM_EVENT_METADATA_KEY = Symbol.for('simple-web-component:emit-custom-event');\n\nexport function emitCustomEvent(target: SpecialSelector, type: string, options?: Options): MethodDecorator;\nexport function emitCustomEvent(selector: string, type: string, options?: Options): MethodDecorator;\n/**\n * @emitCustomEvent decorator to dispatch custom events to a target.\n */\nexport function emitCustomEvent(selectorOrTarget: string, type: string, options: any = {}): MethodDecorator {\n return (targetObj: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = targetObj.constructor;\n\n const fullOptions: any = {...options, type};\n\n if (fullOptions.bubbles === undefined) fullOptions.bubbles = true;\n if (fullOptions.composed === undefined) fullOptions.composed = true;\n\n let list = ReflectUtils.getMetadata<EmitCustomEventMetadata[]>(EMIT_CUSTOM_EVENT_METADATA_KEY, constructor);\n if (!list) {\n list = [];\n ReflectUtils.defineMetadata(EMIT_CUSTOM_EVENT_METADATA_KEY, list, constructor);\n }\n list.push({propertyKey, selector: selectorOrTarget, type, options: fullOptions});\n\n const original = descriptor.value;\n descriptor.value = function (...args: any[]) {\n ensureInit(this);\n const res = original.apply(this, args);\n\n const handleResult = (detail: any) => {\n const event = new CustomEvent(type, {\n detail,\n bubbles: fullOptions.bubbles,\n composed: fullOptions.composed,\n cancelable: fullOptions.cancelable\n });\n\n const hostSet = SwcUtils.getHostSet(this as any);\n const conf = getElementConfig(this);\n const currentWin = (this as any)._resolveWindow?.(conf) || ((typeof window !== 'undefined' ? window : undefined) as Window);\n\n const eventTargets: EventTarget[] = [];\n if (selectorOrTarget === '$window') eventTargets.push(currentWin);\n else if (selectorOrTarget === '$document') eventTargets.push(currentWin.document);\n else if (selectorOrTarget === '$host') {\n if (hostSet.$host) eventTargets.push(hostSet.$host);\n } else if (selectorOrTarget === '$parentHost') {\n if (hostSet.$parentHost) eventTargets.push(hostSet.$parentHost);\n } else if (selectorOrTarget === '$appHost') {\n if (hostSet.$appHost) eventTargets.push(hostSet.$appHost);\n } else if (selectorOrTarget === '$firstHost') {\n if (hostSet.$firstHost) eventTargets.push(hostSet.$firstHost);\n } else if (selectorOrTarget === '$lastHost') {\n if (hostSet.$lastHost) eventTargets.push(hostSet.$lastHost);\n } else if (selectorOrTarget === '$firstAppHost') {\n if (hostSet.$firstAppHost) eventTargets.push(hostSet.$firstAppHost);\n } else if (selectorOrTarget === '$lastAppHost') {\n if (hostSet.$lastAppHost) eventTargets.push(hostSet.$lastAppHost);\n } else if (selectorOrTarget === '$hosts') {\n hostSet.$hosts.forEach(h => eventTargets.push(h));\n } else if (selectorOrTarget === '$appHosts') {\n hostSet.$appHosts.forEach(h => eventTargets.push(h));\n } else if (selectorOrTarget === '$this' || !selectorOrTarget) {\n eventTargets.push(this as any);\n } else {\n const r = fullOptions.root || 'auto';\n const searchRoots: (HTMLElement | ShadowRoot)[] = [];\n if (r === 'auto') searchRoots.push(this.shadowRoot || (this as any));\n else if (r === 'light') searchRoots.push(this as any);\n else if (r === 'shadow' && this.shadowRoot) searchRoots.push(this.shadowRoot);\n else if (r === 'all') {\n searchRoots.push(this as any);\n if (this.shadowRoot) searchRoots.push(this.shadowRoot);\n }\n\n searchRoots.forEach(sr => {\n sr.querySelectorAll(selectorOrTarget).forEach(el => eventTargets.push(el));\n });\n }\n\n eventTargets.forEach(t => {\n if (fullOptions.filter && !fullOptions.filter(t, detail, {currentThis: this, helper: hostSet})) {\n return;\n }\n t.dispatchEvent(event);\n });\n\n return detail;\n };\n\n if (res instanceof Promise) {\n return res.then(handleResult);\n } else {\n return handleResult(res);\n }\n };\n };\n}\n\nexport const getEmitCustomEventMetadataList = (target: any): EmitCustomEventMetadata[] | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(EMIT_CUSTOM_EVENT_METADATA_KEY, constructor);\n};\n\n// --- Aliases: emit... ---\nexport const emit = emitCustomEvent;\n\n/**\n * @emitCustomEventThis decorator - simplified version of @emitCustomEvent for $this selector\n */\nexport function emitCustomEventThis(type: string, options: EmitCustomEventBaseOptions & SwcQueryOptions & { attributeName?: string }): MethodDecorator ;\nexport function emitCustomEventThis(type: string, attributeName: string): MethodDecorator ;\nexport function emitCustomEventThis(type: string): MethodDecorator;\nexport function emitCustomEventThis(type: string, optionsOrAttributeaName?: string | (EmitCustomEventBaseOptions & SwcQueryOptions & { attributeName?: string })): MethodDecorator {\n if (optionsOrAttributeaName && typeof optionsOrAttributeaName === 'string') {\n return emitCustomEventThis(type, {attributeName: optionsOrAttributeaName});\n } else if (optionsOrAttributeaName && typeof optionsOrAttributeaName === 'object') {\n if (!optionsOrAttributeaName.attributeName) {\n optionsOrAttributeaName.attributeName = `on-emit-${type}`;\n }\n return emitCustomEvent('$this', type, optionsOrAttributeaName);\n } else {\n return emitCustomEvent('$this', type, {attributeName: `on-emit-${type}`});\n }\n}\n"],
5
- "mappings": "AAAA,SAAQ,oBAAmB;AAE3B,SAAQ,YAAY,wBAAuB;AAC3C,SAAQ,gBAAe;AAkChB,MAAM,iCAAiC,OAAO,IAAI,wCAAwC;AAO1F,SAAS,gBAAgB,kBAA0B,MAAc,UAAe,CAAC,GAAoB;AAC1G,SAAO,CAAC,WAAmB,aAA8B,eAAmC;AAC1F,UAAM,cAAc,UAAU;AAE9B,UAAM,cAAmB,EAAC,GAAG,SAAS,KAAI;AAE1C,QAAI,YAAY,YAAY,OAAW,aAAY,UAAU;AAC7D,QAAI,YAAY,aAAa,OAAW,aAAY,WAAW;AAE/D,QAAI,OAAO,aAAa,YAAuC,gCAAgC,WAAW;AAC1G,QAAI,CAAC,MAAM;AACT,aAAO,CAAC;AACR,mBAAa,eAAe,gCAAgC,MAAM,WAAW;AAAA,I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,yBAAiI;AACjL,MAAI,2BAA2B,OAAO,4BAA4B,UAAU;AAC1E,WAAO,oBAAoB,MAAM,EAAC,eAAe,wBAAuB,CAAC;AAAA,EAC3E,WAAW,2BAA2B,OAAO,4BAA4B,UAAU;AACjF,QAAI,CAAC,wBAAwB,eAAe;AAC1C,8BAAwB,gBAAgB,WAAW,IAAI;AAAA,IACzD;AACA,WAAO,gBAAgB,SAAS,MAAM,uBAAuB;AAAA,EAC/D,OAAO;AACL,WAAO,gBAAgB,SAAS,MAAM,EAAC,eAAe,WAAW,IAAI,GAAE,CAAC;AAAA,EAC1E;AACF;",
4
+ "sourcesContent": ["import {ReflectUtils} from '@dooboostore/core';\nimport { SpecialSelector, SwcQueryOptions, HelperHostSet } from '../types';\nimport {ensureInit, getElementConfig} from './elementDefine';\nimport {SwcUtils} from '../utils/Utils';\n\nexport type EmitCustomEventSelector = string | ((currentThis: any, helper: HelperHostSet) => NodeList | Element | Element[] | null);\n\nexport interface EmitCustomEventBaseOptions {\n bubbles?: boolean;\n composed?: boolean;\n cancelable?: boolean;\n filter?: (target: EventTarget, detail: any, meta: { currentThis: any, helper: HelperHostSet }) => boolean;\n /**\n * Custom key to extract value from return object.\n * If not provided, uses EMIT_CUSTOM_EVENT_METADATA_KEY by default.\n * Useful when multiple @emitCustomEvent decorators are on the same method.\n * \n * Example:\n * @emitCustomEvent('$appHost', 'event1', { valueKey: 'detail1' })\n * @emitCustomEvent('$appHost', 'event2', { valueKey: 'detail2' })\n * myMethod() {\n * return {\n * detail1: { type: 'event1', data: 'value1' },\n * detail2: { type: 'event2', data: 'value2' }\n * };\n * }\n */\n valueKey?: symbol | string;\n}\n\ntype Options = (EmitCustomEventBaseOptions & SwcQueryOptions) | (EmitCustomEventBaseOptions & SwcQueryOptions & { attributeName?: string });\n\nexport interface EmitCustomEventMetadata {\n propertyKey: string | symbol;\n selector: EmitCustomEventSelector;\n type: string;\n options: Options;\n}\n\nexport const EMIT_CUSTOM_EVENT_METADATA_KEY = Symbol.for('simple-web-component:emit-custom-event');\n\nexport function emitCustomEvent(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;\nexport function emitCustomEvent(selector: EmitCustomEventSelector, type: string, options?: Options): MethodDecorator;\nexport function emitCustomEvent(type: string, options?: Options): MethodDecorator;\n/**\n * @emitCustomEvent decorator to dispatch custom events to a target.\n * \n * Usage:\n * - @emitCustomEvent('$this', 'event-name', options) - Emit from $this\n * - @emitCustomEvent('$appHost', 'event-name', options) - Emit from $appHost\n * - @emitCustomEvent((this, helper) => '.button', 'event-name', options) - Function-based selector\n * - @emitCustomEvent('event-name', options) - Emit from $this (defaults to $this)\n * - @emitCustomEvent('event-name') - Emit from $this with no options\n */\nexport function emitCustomEvent(selectorOrTarget: any, typeOrPropertyKey?: any, optionsOrDescriptor?: any): any {\n // Case 1: Bare decorator on property\n if (typeof selectorOrTarget === 'object' && typeof typeOrPropertyKey === 'string' && typeof optionsOrDescriptor === 'object' && 'value' in optionsOrDescriptor) {\n throw new Error(`@emitCustomEvent decorator cannot be used on properties. (Property: ${String(typeOrPropertyKey)})`);\n }\n\n // Case 2: With selector and type - @emitCustomEvent('selector', 'event-name', options)\n if ((typeof selectorOrTarget === 'string' || typeof selectorOrTarget === 'function') && typeof typeOrPropertyKey === 'string') {\n return createEmitDecorator(selectorOrTarget, typeOrPropertyKey, optionsOrDescriptor as Options);\n }\n\n // Case 3: Without selector (type only) - @emitCustomEvent('event-name', options)\n if (typeof selectorOrTarget === 'string' && typeOrPropertyKey !== 'string') {\n return createEmitDecorator('$this', selectorOrTarget, typeOrPropertyKey as Options);\n }\n\n // Fallback\n throw new Error('Invalid @emitCustomEvent usage');\n}\n\nfunction createEmitDecorator(selector: EmitCustomEventSelector, type: string, options?: Options) {\n return (targetObj: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = targetObj.constructor;\n\n const fullOptions: any = {...(options || {}), type};\n\n if (fullOptions.bubbles === undefined) fullOptions.bubbles = true;\n if (fullOptions.composed === undefined) fullOptions.composed = true;\n\n let list = ReflectUtils.getMetadata<EmitCustomEventMetadata[]>(EMIT_CUSTOM_EVENT_METADATA_KEY, constructor);\n if (!list) {\n list = [];\n ReflectUtils.defineMetadata(EMIT_CUSTOM_EVENT_METADATA_KEY, list, constructor);\n }\n list.push({propertyKey, selector, type, options: fullOptions});\n\n const original = descriptor.value;\n descriptor.value = function (...args: any[]) {\n ensureInit(this);\n const res = original.apply(this, args);\n\n const handleResult = (detail: any) => {\n const event = new CustomEvent(type, {\n detail,\n bubbles: fullOptions.bubbles,\n composed: fullOptions.composed,\n cancelable: fullOptions.cancelable\n });\n\n const conf = getElementConfig(this);\n const currentWin = (this as any)._resolveWindow?.(conf) || ((typeof window !== 'undefined' ? window : undefined) as Window);\n const hostSet = SwcUtils.getHelperAndHostSet(currentWin, this as any);\n\n const eventTargets: EventTarget[] = [];\n \n // Resolve selector if it's a function\n let resolvedSelector: string | Element | NodeList | Element[] | null = selector as any;\n if (typeof selector === 'function') {\n resolvedSelector = selector(this, hostSet);\n }\n\n // If selector function returned elements directly, use them\n if (resolvedSelector instanceof currentWin.Element) {\n eventTargets.push(resolvedSelector as EventTarget);\n } else if (resolvedSelector instanceof currentWin.NodeList) {\n eventTargets.push(...Array.from(resolvedSelector as EventTarget[]));\n } else if (Array.isArray(resolvedSelector)) {\n eventTargets.push(...(resolvedSelector as EventTarget[]));\n } else if (resolvedSelector === null) {\n // No targets\n } else {\n // Handle string selector\n const stringSelector = resolvedSelector as string;\n \n if (stringSelector === '$window') eventTargets.push(currentWin);\n else if (stringSelector === '$document') eventTargets.push(currentWin.document);\n else if (stringSelector === '$host') {\n if (hostSet.$host) eventTargets.push(hostSet.$host);\n } else if (stringSelector === '$parentHost') {\n if (hostSet.$parentHost) eventTargets.push(hostSet.$parentHost);\n } else if (stringSelector === '$appHost') {\n if (hostSet.$appHost) eventTargets.push(hostSet.$appHost);\n } else if (stringSelector === '$firstHost') {\n if (hostSet.$firstHost) eventTargets.push(hostSet.$firstHost);\n } else if (stringSelector === '$lastHost') {\n if (hostSet.$lastHost) eventTargets.push(hostSet.$lastHost);\n } else if (stringSelector === '$firstAppHost') {\n if (hostSet.$firstAppHost) eventTargets.push(hostSet.$firstAppHost);\n } else if (stringSelector === '$lastAppHost') {\n if (hostSet.$lastAppHost) eventTargets.push(hostSet.$lastAppHost);\n } else if (stringSelector === '$hosts') {\n hostSet.$hosts.forEach(h => eventTargets.push(h));\n } else if (stringSelector === '$appHosts') {\n hostSet.$appHosts.forEach(h => eventTargets.push(h));\n } else if (stringSelector === '$this' || !stringSelector) {\n eventTargets.push(this as any);\n } else {\n const r = fullOptions.root || 'auto';\n const searchRoots: (HTMLElement | ShadowRoot)[] = [];\n if (r === 'auto') searchRoots.push(this.shadowRoot || (this as any));\n else if (r === 'light') searchRoots.push(this as any);\n else if (r === 'shadow' && this.shadowRoot) searchRoots.push(this.shadowRoot);\n else if (r === 'all') {\n searchRoots.push(this as any);\n if (this.shadowRoot) searchRoots.push(this.shadowRoot);\n }\n\n searchRoots.forEach(sr => {\n sr.querySelectorAll(stringSelector).forEach(el => eventTargets.push(el));\n });\n }\n }\n\n eventTargets.forEach(t => {\n if (fullOptions.filter && !fullOptions.filter(t, detail, {currentThis: this, helper: hostSet})) {\n return;\n }\n t.dispatchEvent(event);\n });\n\n return detail;\n };\n\n if (res instanceof Promise) {\n return res.then(handleResult);\n } else {\n return handleResult(res);\n }\n };\n };\n}\n\nexport const getEmitCustomEventMetadataList = (target: any): EmitCustomEventMetadata[] | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(EMIT_CUSTOM_EVENT_METADATA_KEY, constructor);\n};\n\n// --- Aliases: emit... ---\nexport const emit = emitCustomEvent;\n"],
5
+ "mappings": "AAAA,SAAQ,oBAAmB;AAE3B,SAAQ,YAAY,wBAAuB;AAC3C,SAAQ,gBAAe;AAoChB,MAAM,iCAAiC,OAAO,IAAI,wCAAwC;AAe3F,S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a;AACzC,oBAAQ,UAAU,QAAQ,OAAK,aAAa,KAAK,CAAC,CAAC;UACrD,WAAW,mBAAmB,WAAW,CAAC,gBAAgB;AACxD,yBAAa,KAAK,IAAW;UAC/B,OAAO;AACL,kBAAM,IAAI,YAAY,QAAQ;AAC9B,kBAAM,cAA4C,CAAA;AAClD,gBAAI,MAAM;AAAQ,0BAAY,KAAK,KAAK,cAAe,IAAY;qBAC1D,MAAM;AAAS,0BAAY,KAAK,IAAW;qBAC3C,MAAM,YAAY,KAAK;AAAY,0BAAY,KAAK,KAAK,UAAU;qBACnE,MAAM,OAAO;AACpB,0BAAY,KAAK,IAAW;AAC5B,kBAAI,KAAK;AAAY,4BAAY,KAAK,KAAK,UAAU;YACvD;AAEA,wBAAY,QAAQ,QAAK;AACvB,iBAAG,iBAAiB,cAAc,EAAE,QAAQ,QAAM,aAAa,KAAK,EAAE,CAAC;YACzE,CAAC;UACH;QACF;AAEA,qBAAa,QAAQ,OAAI;AACvB,cAAI,YAAY,UAAU,CAAC,YAAY,OAAO,GAAG,QAAQ,EAAC,aAAa,MAAM,QAAQ,QAAO,CAAC,GAAG;AAC9F;UACF;AACA,YAAE,cAAc,KAAK;QACvB,CAAC;AAED,eAAO;MACT;AAEA,UAAI,eAAe,SAAS;AAC1B,eAAO,IAAI,KAAK,YAAY;MAC9B,OAAO;AACL,eAAO,aAAa,GAAG;MACzB;IACF;EACF;AACF;AAEO,MAAM,iCAAiC,CAAC,WAAsD;AACnG,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,SAAO,aAAa,YAAY,gCAAgC,WAAW;AAC7E;AAGO,MAAM,OAAO;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  export * from "./addEventListener.js";
2
2
  export * from "./applyAttribute.js";
3
3
  export * from "./elementDefine.js";
4
- export * from "./changedAttributeThis.js";
4
+ export * from "./changedAttribute.js";
5
5
  export * from "./emitCustomEvent.js";
6
6
  export * from "./applyNode.js";
7
7
  export * from "./lifecycles.js";
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/decorators/index.ts"],
4
- "sourcesContent": ["export * from './addEventListener';\nexport * from './applyAttribute';\nexport * from './elementDefine';\nexport * from './changedAttributeThis';\nexport * from './emitCustomEvent';\nexport * from './applyNode';\nexport * from './lifecycles';\nexport * from './query';\nexport * from './queryAll';\nexport * from './applyClass';\nexport * from './applyStyle';\nexport * from './applyAttribute';\nexport * from './applyProperty';\nexport * from './subscribeSwcAppRouteChangeWhileConnected';\nexport * from './subscribeSwcAppMessageWhileConnected';\nexport * from './publishSwcAppMessage';\nexport * from './applySlot';\nexport * from './state';\n"],
4
+ "sourcesContent": ["export * from './addEventListener';\nexport * from './applyAttribute';\nexport * from './elementDefine';\nexport * from './changedAttribute';\nexport * from './emitCustomEvent';\nexport * from './applyNode';\nexport * from './lifecycles';\nexport * from './query';\nexport * from './queryAll';\nexport * from './applyClass';\nexport * from './applyStyle';\nexport * from './applyAttribute';\nexport * from './applyProperty';\nexport * from './subscribeSwcAppRouteChangeWhileConnected';\nexport * from './subscribeSwcAppMessageWhileConnected';\nexport * from './publishSwcAppMessage';\nexport * from './applySlot';\nexport * from './state';\n"],
5
5
  "mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;",
6
6
  "names": []
7
7
  }
@@ -23,7 +23,7 @@ function createPublishSwcAppMessage(messageType, options) {
23
23
  }
24
24
  return v;
25
25
  };
26
- const publishMessage = (data) => {
26
+ const publishMessage2 = (data) => {
27
27
  const appHost = SwcUtils.getAppHost(this);
28
28
  if (appHost) {
29
29
  appHost.publishMessage({
@@ -36,13 +36,13 @@ function createPublishSwcAppMessage(messageType, options) {
36
36
  if (result instanceof Promise) {
37
37
  result.then((data) => {
38
38
  const extracted = extractValue(data);
39
- publishMessage(extracted);
39
+ publishMessage2(extracted);
40
40
  }).catch((err) => {
41
41
  console.warn("publishSwcAppMessage async error:", err);
42
42
  });
43
43
  } else {
44
44
  const extracted = extractValue(result);
45
- publishMessage(extracted);
45
+ publishMessage2(extracted);
46
46
  }
47
47
  return result;
48
48
  };
@@ -67,7 +67,7 @@ function publishSwcAppMessage(targetOrMessageTypeOrOptions, propertyKeyOrOptions
67
67
  }
68
68
  return createPublishSwcAppMessage(messageType, options);
69
69
  }
70
- const publish = publishSwcAppMessage;
70
+ const publishMessage = publishSwcAppMessage;
71
71
  const getPublishSwcAppMessageMetadata = (target) => {
72
72
  const constructor = target instanceof Function ? target : target.constructor;
73
73
  return ReflectUtils.getOwnMetadata(PUBLISH_SWC_APP_MESSAGE_METADATA_KEY, constructor);
@@ -75,7 +75,7 @@ const getPublishSwcAppMessageMetadata = (target) => {
75
75
  export {
76
76
  PUBLISH_SWC_APP_MESSAGE_METADATA_KEY,
77
77
  getPublishSwcAppMessageMetadata,
78
- publish,
78
+ publishMessage,
79
79
  publishSwcAppMessage
80
80
  };
81
81
  //# sourceMappingURL=publishSwcAppMessage.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/decorators/publishSwcAppMessage.ts"],
4
- "sourcesContent": ["import {ReflectUtils} from '@dooboostore/core';\nimport {SwcUtils} from '../utils/Utils';\n\nexport const PUBLISH_SWC_APP_MESSAGE_METADATA_KEY = Symbol.for('simple-web-component:publish-swc-app-message');\n\nexport interface PublishSwcAppMessageMetadata {\n propertyKey: string | symbol;\n messageType?: string;\n}\n\nexport interface PublishSwcAppMessageOptions {\n messageType?: string;\n /**\n * Custom key to extract value from return object.\n * If not provided, uses PUBLISH_SWC_APP_MESSAGE_METADATA_KEY by default.\n * Useful when multiple @publishSwcAppMessage decorators are on the same method.\n * \n * Example:\n * @publishSwcAppMessage('event1', { valueKey: 'detail1' })\n * @publishSwcAppMessage('event2', { valueKey: 'detail2' })\n * myMethod() {\n * return {\n * detail1: { type: 'event1', data: 'value1' },\n * detail2: { type: 'event2', data: 'value2' }\n * };\n * }\n */\n valueKey?: symbol | string;\n}\n\nfunction createPublishSwcAppMessage(messageType?: string, options?: PublishSwcAppMessageOptions): MethodDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => {\n const constructor = target.constructor;\n let list = ReflectUtils.getOwnMetadata(PUBLISH_SWC_APP_MESSAGE_METADATA_KEY, constructor) as PublishSwcAppMessageMetadata[];\n if (!list) {\n list = [];\n ReflectUtils.defineMetadata(PUBLISH_SWC_APP_MESSAGE_METADATA_KEY, list, constructor);\n }\n list.push({ propertyKey, messageType });\n \n if (!descriptor) {\n return descriptor;\n }\n\n // \uBA54\uC11C\uB4DC \uB798\uD551 - \uC6D0\uBCF8 \uBA54\uC11C\uB4DC\uC758 \uBC18\uD658\uAC12\uC744 \uCEA1\uCC98\uD558\uC5EC \uBA54\uC2DC\uC9C0 \uBC1C\uD589\n const originalMethod = descriptor.value;\n descriptor.value = function (...args: any[]) {\n // \uC6D0\uBCF8 \uBA54\uC11C\uB4DC \uC2E4\uD589\n const result = originalMethod.apply(this, args);\n\n /**\n * Extract value for this decorator from method return value\n * \n * If return value is an object with this decorator's key,\n * use that value. Otherwise use the entire return value.\n * \n * Uses valueKey from options if provided, otherwise uses PUBLISH_SWC_APP_MESSAGE_METADATA_KEY.\n */\n const extractValue = (v: any) => {\n const keyToUse = options?.valueKey ?? PUBLISH_SWC_APP_MESSAGE_METADATA_KEY;\n if (v && typeof v === 'object' && keyToUse in v) {\n return v[keyToUse];\n }\n return v;\n };\n\n const publishMessage = (data: any) => {\n // appHost \uCC3E\uC544\uC11C \uBA54\uC2DC\uC9C0 \uBC1C\uD589\n const appHost = SwcUtils.getAppHost(this as HTMLElement);\n if (appHost) {\n appHost.publishMessage({\n publisher: this,\n data,\n type: messageType\n });\n }\n };\n \n // Promise \uCCB4\uD06C\n if (result instanceof Promise) {\n result.then((data) => {\n const extracted = extractValue(data);\n publishMessage(extracted);\n }).catch((err) => {\n console.warn('publishSwcAppMessage async error:', err);\n });\n } else {\n // \uB3D9\uAE30 \uD638\uCD9C - \uBC14\uB85C \uBA54\uC2DC\uC9C0 \uBC1C\uD589\n const extracted = extractValue(result);\n publishMessage(extracted);\n }\n \n return result;\n };\n\n return descriptor;\n };\n}\n\n// \uC624\uBC84\uB85C\uB4DC \uC2DC\uADF8\uB2C8\uCC98 - \uC9C1\uC811 \uC0AC\uC6A9 (\uAD04\uD638 \uC5C6\uC74C)\nexport function publishSwcAppMessage(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;\n// \uC624\uBC84\uB85C\uB4DC \uC2DC\uADF8\uB2C8\uCC98 - \uD568\uC218 \uD638\uCD9C (\uAD04\uD638 \uC788\uC74C)\nexport function publishSwcAppMessage(): MethodDecorator;\nexport function publishSwcAppMessage(messageType: string): MethodDecorator;\nexport function publishSwcAppMessage(messageType: string, options: PublishSwcAppMessageOptions): MethodDecorator;\nexport function publishSwcAppMessage(options: PublishSwcAppMessageOptions): MethodDecorator;\n\nexport function publishSwcAppMessage(targetOrMessageTypeOrOptions?: any, propertyKeyOrOptions?: string | symbol | PublishSwcAppMessageOptions, descriptor?: PropertyDescriptor): any {\n // \uC9C1\uC811 \uB370\uCF54\uB808\uC774\uD130\uB85C \uC0AC\uC6A9\uB41C \uACBD\uC6B0 (\uAD04\uD638 \uC5C6\uC74C): @publishSwcAppMessage\n if (targetOrMessageTypeOrOptions && typeof targetOrMessageTypeOrOptions === 'object' && \n propertyKeyOrOptions && (typeof propertyKeyOrOptions === 'string' || typeof propertyKeyOrOptions === 'symbol') &&\n descriptor) {\n const target = targetOrMessageTypeOrOptions;\n return createPublishSwcAppMessage()(target, propertyKeyOrOptions, descriptor);\n }\n\n // \uD568\uC218\uB85C \uD638\uCD9C\uB41C \uACBD\uC6B0 (\uAD04\uD638 \uC788\uC74C): @publishSwcAppMessage() / @publishSwcAppMessage('messageType') / @publishSwcAppMessage({...})\n let messageType: string | undefined;\n let options: PublishSwcAppMessageOptions | undefined;\n\n if (typeof targetOrMessageTypeOrOptions === 'string') {\n // \uBA54\uC2DC\uC9C0 \uD0C0\uC785 \uC804\uB2EC: @publishSwcAppMessage('messageType')\n messageType = targetOrMessageTypeOrOptions;\n if (typeof propertyKeyOrOptions === 'object' && propertyKeyOrOptions !== null) {\n options = propertyKeyOrOptions as PublishSwcAppMessageOptions;\n }\n } else if (typeof targetOrMessageTypeOrOptions === 'object' && targetOrMessageTypeOrOptions !== null) {\n // \uC635\uC158 \uAC1D\uCCB4 \uC804\uB2EC: @publishSwcAppMessage({...})\n options = targetOrMessageTypeOrOptions as PublishSwcAppMessageOptions;\n messageType = options.messageType;\n }\n\n return createPublishSwcAppMessage(messageType, options);\n}\n\n// --- Aliases: publish... ---\nexport const publish = publishSwcAppMessage;\n\n// Helper function to retrieve publish message metadata\nexport const getPublishSwcAppMessageMetadata = (target: any): PublishSwcAppMessageMetadata[] | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getOwnMetadata(PUBLISH_SWC_APP_MESSAGE_METADATA_KEY, constructor);\n};\n"],
5
- "mappings": "AAAA,SAAQ,oBAAmB;AAC3B,SAAQ,gBAAe;AAEhB,MAAM,uCAAuC,OAAO,IAAI,8CAA8C;AA2B7G,SAAS,2BAA2B,aAAsB,SAAwD;AAChH,SAAO,CAAC,QAAgB,aAA8B,eAAoC;AACxF,UAAM,cAAc,OAAO;AAC3B,QAAI,OAAO,aAAa,eAAe,sCAAsC,WAAW;AACxF,QAAI,CAAC,MAAM;AACT,aAAO,CAAC;AACR,mBAAa,eAAe,sCAAsC,MAAM,WAAW;AAAA,IACrF;AACA,SAAK,KAAK,EAAE,aAAa,YAAY,CAAC;AAEtC,QAAI,CAAC,YAAY;AACf,aAAO;AAAA,IACT;AAGA,UAAM,iBAAiB,WAAW;A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;AAEA,SAAO,2BAA2B,aAAa,OAAO;AACxD;AAGO,MAAM,UAAU;AAGhB,MAAM,kCAAkC,CAAC,WAA4D;AAC1G,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,SAAO,aAAa,eAAe,sCAAsC,WAAW;AACtF;",
6
- "names": []
4
+ "sourcesContent": ["import {ReflectUtils} from '@dooboostore/core';\nimport {SwcUtils} from '../utils/Utils';\n\nexport const PUBLISH_SWC_APP_MESSAGE_METADATA_KEY = Symbol.for('simple-web-component:publish-swc-app-message');\n\nexport interface PublishSwcAppMessageMetadata {\n propertyKey: string | symbol;\n messageType?: string;\n}\n\nexport interface PublishSwcAppMessageOptions {\n messageType?: string;\n /**\n * Custom key to extract value from return object.\n * If not provided, uses PUBLISH_SWC_APP_MESSAGE_METADATA_KEY by default.\n * Useful when multiple @publishSwcAppMessage decorators are on the same method.\n * \n * Example:\n * @publishSwcAppMessage('event1', { valueKey: 'detail1' })\n * @publishSwcAppMessage('event2', { valueKey: 'detail2' })\n * myMethod() {\n * return {\n * detail1: { type: 'event1', data: 'value1' },\n * detail2: { type: 'event2', data: 'value2' }\n * };\n * }\n */\n valueKey?: symbol | string;\n}\n\nfunction createPublishSwcAppMessage(messageType?: string, options?: PublishSwcAppMessageOptions): MethodDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => {\n const constructor = target.constructor;\n let list = ReflectUtils.getOwnMetadata(PUBLISH_SWC_APP_MESSAGE_METADATA_KEY, constructor) as PublishSwcAppMessageMetadata[];\n if (!list) {\n list = [];\n ReflectUtils.defineMetadata(PUBLISH_SWC_APP_MESSAGE_METADATA_KEY, list, constructor);\n }\n list.push({ propertyKey, messageType });\n \n if (!descriptor) {\n return descriptor;\n }\n\n // \uBA54\uC11C\uB4DC \uB798\uD551 - \uC6D0\uBCF8 \uBA54\uC11C\uB4DC\uC758 \uBC18\uD658\uAC12\uC744 \uCEA1\uCC98\uD558\uC5EC \uBA54\uC2DC\uC9C0 \uBC1C\uD589\n const originalMethod = descriptor.value;\n descriptor.value = function (...args: any[]) {\n // \uC6D0\uBCF8 \uBA54\uC11C\uB4DC \uC2E4\uD589\n const result = originalMethod.apply(this, args);\n\n /**\n * Extract value for this decorator from method return value\n * \n * If return value is an object with this decorator's key,\n * use that value. Otherwise use the entire return value.\n * \n * Uses valueKey from options if provided, otherwise uses PUBLISH_SWC_APP_MESSAGE_METADATA_KEY.\n */\n const extractValue = (v: any) => {\n const keyToUse = options?.valueKey ?? PUBLISH_SWC_APP_MESSAGE_METADATA_KEY;\n if (v && typeof v === 'object' && keyToUse in v) {\n return v[keyToUse];\n }\n return v;\n };\n\n const publishMessage = (data: any) => {\n // appHost \uCC3E\uC544\uC11C \uBA54\uC2DC\uC9C0 \uBC1C\uD589\n const appHost = SwcUtils.getAppHost(this as HTMLElement);\n if (appHost) {\n appHost.publishMessage({\n publisher: this,\n data,\n type: messageType\n });\n }\n };\n \n // Promise \uCCB4\uD06C\n if (result instanceof Promise) {\n result.then((data) => {\n const extracted = extractValue(data);\n publishMessage(extracted);\n }).catch((err) => {\n console.warn('publishSwcAppMessage async error:', err);\n });\n } else {\n // \uB3D9\uAE30 \uD638\uCD9C - \uBC14\uB85C \uBA54\uC2DC\uC9C0 \uBC1C\uD589\n const extracted = extractValue(result);\n publishMessage(extracted);\n }\n \n return result;\n };\n\n return descriptor;\n };\n}\n\n// \uC624\uBC84\uB85C\uB4DC \uC2DC\uADF8\uB2C8\uCC98 - \uC9C1\uC811 \uC0AC\uC6A9 (\uAD04\uD638 \uC5C6\uC74C)\nexport function publishSwcAppMessage(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;\n// \uC624\uBC84\uB85C\uB4DC \uC2DC\uADF8\uB2C8\uCC98 - \uD568\uC218 \uD638\uCD9C (\uAD04\uD638 \uC788\uC74C)\nexport function publishSwcAppMessage(): MethodDecorator;\nexport function publishSwcAppMessage(messageType: string): MethodDecorator;\nexport function publishSwcAppMessage(messageType: string, options: PublishSwcAppMessageOptions): MethodDecorator;\nexport function publishSwcAppMessage(options: PublishSwcAppMessageOptions): MethodDecorator;\n\nexport function publishSwcAppMessage(targetOrMessageTypeOrOptions?: any, propertyKeyOrOptions?: string | symbol | PublishSwcAppMessageOptions, descriptor?: PropertyDescriptor): any {\n // \uC9C1\uC811 \uB370\uCF54\uB808\uC774\uD130\uB85C \uC0AC\uC6A9\uB41C \uACBD\uC6B0 (\uAD04\uD638 \uC5C6\uC74C): @publishSwcAppMessage\n if (targetOrMessageTypeOrOptions && typeof targetOrMessageTypeOrOptions === 'object' && \n propertyKeyOrOptions && (typeof propertyKeyOrOptions === 'string' || typeof propertyKeyOrOptions === 'symbol') &&\n descriptor) {\n const target = targetOrMessageTypeOrOptions;\n return createPublishSwcAppMessage()(target, propertyKeyOrOptions, descriptor);\n }\n\n // \uD568\uC218\uB85C \uD638\uCD9C\uB41C \uACBD\uC6B0 (\uAD04\uD638 \uC788\uC74C): @publishSwcAppMessage() / @publishSwcAppMessage('messageType') / @publishSwcAppMessage({...})\n let messageType: string | undefined;\n let options: PublishSwcAppMessageOptions | undefined;\n\n if (typeof targetOrMessageTypeOrOptions === 'string') {\n // \uBA54\uC2DC\uC9C0 \uD0C0\uC785 \uC804\uB2EC: @publishSwcAppMessage('messageType')\n messageType = targetOrMessageTypeOrOptions;\n if (typeof propertyKeyOrOptions === 'object' && propertyKeyOrOptions !== null) {\n options = propertyKeyOrOptions as PublishSwcAppMessageOptions;\n }\n } else if (typeof targetOrMessageTypeOrOptions === 'object' && targetOrMessageTypeOrOptions !== null) {\n // \uC635\uC158 \uAC1D\uCCB4 \uC804\uB2EC: @publishSwcAppMessage({...})\n options = targetOrMessageTypeOrOptions as PublishSwcAppMessageOptions;\n messageType = options.messageType;\n }\n\n return createPublishSwcAppMessage(messageType, options);\n}\n\n// --- Aliases: publish... ---\nexport const publishMessage = publishSwcAppMessage;\n\n// Helper function to retrieve publish message metadata\nexport const getPublishSwcAppMessageMetadata = (target: any): PublishSwcAppMessageMetadata[] | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getOwnMetadata(PUBLISH_SWC_APP_MESSAGE_METADATA_KEY, constructor);\n};\n"],
5
+ "mappings": "AAAA,SAAQ,oBAAmB;AAC3B,SAAQ,gBAAe;AAEhB,MAAM,uCAAuC,OAAO,IAAI,8CAA8C;AA2B7G,SAAS,2BAA2B,aAAsB,SAAwD;AAChH,SAAO,CAAC,QAAgB,aAA8B,eAAoC;AACxF,UAAM,cAAc,OAAO;AAC3B,QAAI,OAAO,aAAa,eAAe,sCAAsC,WAAW;AACxF,QAAI,CAAC,MAAM;AACT,aAAO,CAAC;AACR,mBAAa,eAAe,sCAAsC,MAAM,WAAW;AAAA,IACrF;AACA,SAAK,KAAK,EAAE,aAAa,YAAY,CAAC;AAEtC,QAAI,CAAC,YAAY;AACf,aAAO;AAAA,IACT;AAGA,UAAM,iBAAiB,WAAW;AAClC,eAAW,QAAQ,YAAa,MAAa;AAE3C,YAAM,SAAS,eAAe,MAAM,MAAM,IAAI;AAU9C,YAAM,eAAe,CAAC,MAAW;AAC/B,cAAM,WAAW,SAAS,YAAY;AACtC,YAAI,KAAK,OAAO,MAAM,YAAY,YAAY,GAAG;AAC/C,iBAAO,EAAE,QAAQ;AAAA,QACnB;AACA,eAAO;AAAA,MACT;AAEA,YAAMA,kBAAiB,CAAC,SAAc;AAEpC,cAAM,UAAU,SAAS,WAAW,IAAmB;AACvD,YAAI,SAAS;AACX,kBAAQ,eAAe;AAAA,YACrB,WAAW;AAAA,YACX;AAAA,YACA,MAAM;AAAA,UACR,CAAC;AAAA,QACH;AAAA,MACF;AAGA,UAAI,kBAAkB,SAAS;AAC7B,eAAO,KAAK,CAAC,SAAS;AACpB,gBAAM,YAAY,aAAa,IAAI;AACnC,UAAAA,gBAAe,SAAS;AAAA,QAC1B,CAAC,EAAE,MAAM,CAAC,QAAQ;AAChB,kBAAQ,KAAK,qCAAqC,GAAG;AAAA,QACvD,CAAC;AAAA,MACH,OAAO;AAEL,cAAM,YAAY,aAAa,MAAM;AACrC,QAAAA,gBAAe,SAAS;AAAA,MAC1B;AAEA,aAAO;AAAA,IACT;AAEA,WAAO;AAAA,EACT;AACF;AAUO,SAAS,qBAAqB,8BAAoC,sBAAsE,YAAsC;AAEnL,MAAI,gCAAgC,OAAO,iCAAiC,YACxE,yBAAyB,OAAO,yBAAyB,YAAY,OAAO,yBAAyB,aACrG,YAAY;AACd,UAAM,SAAS;AACf,WAAO,2BAA2B,EAAE,QAAQ,sBAAsB,UAAU;AAAA,EAC9E;AAGA,MAAI;AACJ,MAAI;AAEJ,MAAI,OAAO,iCAAiC,UAAU;AAEpD,kBAAc;AACd,QAAI,OAAO,yBAAyB,YAAY,yBAAyB,MAAM;AAC7E,gBAAU;AAAA,IACZ;AAAA,EACF,WAAW,OAAO,iCAAiC,YAAY,iCAAiC,MAAM;AAEpG,cAAU;AACV,kBAAc,QAAQ;AAAA,EACxB;AAEA,SAAO,2BAA2B,aAAa,OAAO;AACxD;AAGO,MAAM,iBAAiB;AAGvB,MAAM,kCAAkC,CAAC,WAA4D;AAC1G,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,SAAO,aAAa,eAAe,sCAAsC,WAAW;AACtF;",
6
+ "names": ["publishMessage"]
7
7
  }
@@ -2,150 +2,141 @@ import { ReflectUtils } from "@dooboostore/core";
2
2
  import { getElementConfig, ensureInit } from "./elementDefine.js";
3
3
  import { SwcUtils } from "../utils/Utils.js";
4
4
  const QUERY_METADATA_KEY = Symbol.for("simple-web-component:query");
5
- function query(selectorOrTarget, options = {}) {
6
- return (targetObj, propertyKey, descriptor) => {
7
- if (descriptor !== void 0) {
8
- throw new Error(`@query decorator cannot be used on methods. (Method: ${String(propertyKey)})`);
9
- }
10
- const constructor = targetObj.constructor;
11
- let queries = ReflectUtils.getMetadata(QUERY_METADATA_KEY, constructor);
12
- if (!queries) {
13
- queries = [];
14
- ReflectUtils.defineMetadata(QUERY_METADATA_KEY, queries, constructor);
15
- }
16
- queries.push({ propertyKey, selector: selectorOrTarget, options });
17
- Object.defineProperty(targetObj, propertyKey, {
18
- get() {
19
- ensureInit(this);
20
- const selector = selectorOrTarget;
21
- const r = options.root || "auto";
22
- const applyRoot = (t) => {
23
- if (!t || !(t instanceof HTMLElement))
24
- return t;
25
- if (r === "auto")
26
- return t.shadowRoot || t;
27
- if (r === "shadow")
28
- return t.shadowRoot;
29
- if (r === "light")
30
- return t;
31
- if (r === "all")
32
- return t.shadowRoot || t;
33
- return t;
34
- };
35
- const hostSet = SwcUtils.getHostSet(this);
36
- if (selector === "$this")
37
- return applyRoot(this);
38
- if (selector === "$host")
39
- return applyRoot(hostSet.$host);
40
- if (selector === "$parentHost")
41
- return applyRoot(hostSet.$parentHost);
42
- if (selector === "$appHost")
43
- return applyRoot(hostSet.$appHost);
44
- if (selector === "$firstHost")
45
- return applyRoot(hostSet.$firstHost);
46
- if (selector === "$lastHost")
47
- return applyRoot(hostSet.$lastHost);
48
- if (selector === "$firstAppHost")
49
- return applyRoot(hostSet.$firstAppHost);
50
- if (selector === "$lastAppHost")
51
- return applyRoot(hostSet.$lastAppHost);
52
- const config = getElementConfig(this);
53
- const win = config?.window || window;
54
- if (selector === "$window")
55
- return win;
56
- if (selector === "$document")
57
- return win.document;
58
- if (r === "shadow")
59
- return this.shadowRoot ? this.shadowRoot.querySelector(selector) : null;
60
- if (r === "light")
61
- return this.querySelector(selector);
62
- if (r === "all") {
63
- const shadowMatch = this.shadowRoot ? this.shadowRoot.querySelector(selector) : null;
64
- return shadowMatch || this.querySelector(selector);
65
- }
66
- return (this.shadowRoot || this).querySelector(selector);
67
- },
68
- set(nv) {
69
- ensureInit(this);
70
- if (nv === null || nv === void 0) {
71
- const selector = selectorOrTarget;
72
- if (selector.startsWith("$") && selector !== "$this")
73
- return;
74
- const r = options.root || "auto";
75
- const targets = [];
76
- if (r === "shadow") {
77
- if (this.shadowRoot?.querySelector(selector))
78
- targets.push(this.shadowRoot.querySelector(selector));
79
- } else if (r === "light") {
80
- if (this.querySelector(selector))
81
- targets.push(this.querySelector(selector));
82
- } else if (r === "all") {
83
- if (this.shadowRoot?.querySelector(selector))
84
- targets.push(this.shadowRoot.querySelector(selector));
85
- if (this.querySelector(selector))
86
- targets.push(this.querySelector(selector));
5
+ function query(selectorOrTarget, optionsOrPropertyKey, descriptor) {
6
+ if (descriptor !== void 0 && (typeof optionsOrPropertyKey === "string" || typeof optionsOrPropertyKey === "symbol")) {
7
+ throw new Error(`@query decorator cannot be used on methods. (Method: ${String(optionsOrPropertyKey)})`);
8
+ }
9
+ if (typeof selectorOrTarget === "string" || typeof selectorOrTarget === "function") {
10
+ return (targetObj, propertyKey, descriptor2) => {
11
+ if (descriptor2 !== void 0) {
12
+ throw new Error(`@query decorator cannot be used on methods. (Method: ${String(propertyKey)})`);
13
+ }
14
+ const constructor = targetObj.constructor;
15
+ let queries = ReflectUtils.getMetadata(QUERY_METADATA_KEY, constructor);
16
+ if (!queries) {
17
+ queries = [];
18
+ ReflectUtils.defineMetadata(QUERY_METADATA_KEY, queries, constructor);
19
+ }
20
+ queries.push({ propertyKey, selector: selectorOrTarget, options: optionsOrPropertyKey || {} });
21
+ Object.defineProperty(targetObj, propertyKey, {
22
+ get() {
23
+ ensureInit(this);
24
+ const config = getElementConfig(this);
25
+ const win = config?.window || window;
26
+ const hostSet = SwcUtils.getHelperAndHostSet(win, this);
27
+ let resolvedSelector;
28
+ let resolvedElement = null;
29
+ if (typeof selectorOrTarget === "function") {
30
+ const result = selectorOrTarget(this, hostSet);
31
+ if (result instanceof win.Node || result instanceof win.Element) {
32
+ resolvedElement = result instanceof win.HTMLElement ? result : null;
33
+ } else if (result instanceof win.NodeList || Array.isArray(result)) {
34
+ resolvedElement = result.length > 0 && result[0] instanceof win.HTMLElement ? result[0] : null;
35
+ }
87
36
  } else {
88
- const el = (this.shadowRoot || this).querySelector(selector);
89
- if (el)
90
- targets.push(el);
37
+ resolvedSelector = selectorOrTarget;
38
+ const r = optionsOrPropertyKey?.root || "auto";
39
+ const applyRoot = (t) => {
40
+ if (!t || !(t instanceof HTMLElement))
41
+ return t;
42
+ if (r === "auto")
43
+ return t.shadowRoot || t;
44
+ if (r === "shadow")
45
+ return t.shadowRoot;
46
+ if (r === "light")
47
+ return t;
48
+ if (r === "all")
49
+ return t.shadowRoot || t;
50
+ return t;
51
+ };
52
+ if (resolvedSelector === "$this")
53
+ resolvedElement = applyRoot(this);
54
+ else if (resolvedSelector === "$host")
55
+ resolvedElement = applyRoot(hostSet.$host);
56
+ else if (resolvedSelector === "$parentHost")
57
+ resolvedElement = applyRoot(hostSet.$parentHost);
58
+ else if (resolvedSelector === "$appHost")
59
+ resolvedElement = applyRoot(hostSet.$appHost);
60
+ else if (resolvedSelector === "$firstHost")
61
+ resolvedElement = applyRoot(hostSet.$firstHost);
62
+ else if (resolvedSelector === "$lastHost")
63
+ resolvedElement = applyRoot(hostSet.$lastHost);
64
+ else if (resolvedSelector === "$firstAppHost")
65
+ resolvedElement = applyRoot(hostSet.$firstAppHost);
66
+ else if (resolvedSelector === "$lastAppHost")
67
+ resolvedElement = applyRoot(hostSet.$lastAppHost);
68
+ else if (resolvedSelector === "$window")
69
+ return win;
70
+ else if (resolvedSelector === "$document")
71
+ return win.document;
72
+ else {
73
+ if (r === "shadow")
74
+ resolvedElement = this.shadowRoot ? this.shadowRoot.querySelector(resolvedSelector) : null;
75
+ else if (r === "light")
76
+ resolvedElement = this.querySelector(resolvedSelector);
77
+ else if (r === "all") {
78
+ const shadowMatch = this.shadowRoot ? this.shadowRoot.querySelector(resolvedSelector) : null;
79
+ resolvedElement = shadowMatch || this.querySelector(resolvedSelector);
80
+ } else
81
+ resolvedElement = (this.shadowRoot || this).querySelector(resolvedSelector);
82
+ }
91
83
  }
92
- targets.forEach((t) => t.remove());
93
- }
94
- },
95
- enumerable: true,
96
- configurable: true
97
- });
98
- };
99
- }
100
- function queryThis(targetOrOptions, propertyKey) {
101
- if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
102
- return query("$this", {})(targetOrOptions, propertyKey);
103
- }
104
- if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
105
- return query("$this", targetOrOptions);
106
- } else {
107
- return query("$this", {});
108
- }
109
- }
110
- function queryWindow(targetOrOptions, propertyKey) {
111
- if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
112
- return query("$window", {})(targetOrOptions, propertyKey);
113
- }
114
- if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
115
- return query("$window", targetOrOptions);
116
- } else {
117
- return query("$window", {});
118
- }
119
- }
120
- function queryDocument(targetOrOptions, propertyKey) {
121
- if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
122
- return query("$document", {})(targetOrOptions, propertyKey);
123
- }
124
- if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
125
- return query("$document", targetOrOptions);
126
- } else {
127
- return query("$document", {});
128
- }
129
- }
130
- function queryHost(targetOrOptions, propertyKey) {
131
- if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
132
- return query("$host", {})(targetOrOptions, propertyKey);
133
- }
134
- if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
135
- return query("$host", targetOrOptions);
136
- } else {
137
- return query("$host", {});
138
- }
139
- }
140
- function queryAppHost(targetOrOptions, propertyKey) {
141
- if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
142
- return query("$appHost", {})(targetOrOptions, propertyKey);
143
- }
144
- if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
145
- return query("$appHost", targetOrOptions);
146
- } else {
147
- return query("$appHost", {});
84
+ if (resolvedElement instanceof win.HTMLElement && optionsOrPropertyKey?.filter) {
85
+ const shouldInclude = optionsOrPropertyKey.filter(resolvedElement, { currentThis: this, helper: hostSet });
86
+ if (!shouldInclude) {
87
+ return null;
88
+ }
89
+ }
90
+ return resolvedElement;
91
+ },
92
+ set(nv) {
93
+ ensureInit(this);
94
+ if (nv === null || nv === void 0) {
95
+ const config = getElementConfig(this);
96
+ const win = config?.window || window;
97
+ const hostSet = SwcUtils.getHelperAndHostSet(win, this);
98
+ if (typeof selectorOrTarget === "function") {
99
+ const result = selectorOrTarget(this, hostSet);
100
+ if (result instanceof win.Element) {
101
+ result.remove();
102
+ } else if (result instanceof win.NodeList || Array.isArray(result)) {
103
+ const el = result.length > 0 ? result[0] : null;
104
+ if (el instanceof win.Element) {
105
+ el.remove();
106
+ }
107
+ }
108
+ return;
109
+ }
110
+ const resolvedSelector = selectorOrTarget;
111
+ if (resolvedSelector.startsWith("$") && resolvedSelector !== "$this")
112
+ return;
113
+ const r = optionsOrPropertyKey?.root || "auto";
114
+ const targets = [];
115
+ if (r === "shadow") {
116
+ if (this.shadowRoot?.querySelector(resolvedSelector))
117
+ targets.push(this.shadowRoot.querySelector(resolvedSelector));
118
+ } else if (r === "light") {
119
+ if (this.querySelector(resolvedSelector))
120
+ targets.push(this.querySelector(resolvedSelector));
121
+ } else if (r === "all") {
122
+ if (this.shadowRoot?.querySelector(resolvedSelector))
123
+ targets.push(this.shadowRoot.querySelector(resolvedSelector));
124
+ if (this.querySelector(resolvedSelector))
125
+ targets.push(this.querySelector(resolvedSelector));
126
+ } else {
127
+ const el = (this.shadowRoot || this).querySelector(resolvedSelector);
128
+ if (el)
129
+ targets.push(el);
130
+ }
131
+ targets.forEach((t) => t.remove());
132
+ }
133
+ },
134
+ enumerable: true,
135
+ configurable: true
136
+ });
137
+ };
148
138
  }
139
+ return query("$this", selectorOrTarget);
149
140
  }
150
141
  const getQueryMetadata = (target) => {
151
142
  const constructor = target instanceof Function ? target : target.constructor;
@@ -154,11 +145,6 @@ const getQueryMetadata = (target) => {
154
145
  export {
155
146
  QUERY_METADATA_KEY,
156
147
  getQueryMetadata,
157
- query,
158
- queryAppHost,
159
- queryDocument,
160
- queryHost,
161
- queryThis,
162
- queryWindow
148
+ query
163
149
  };
164
150
  //# sourceMappingURL=query.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/decorators/query.ts"],
4
- "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { getElementConfig, ensureInit } from './elementDefine';\nimport { SwcUtils } from '../utils/Utils';\nimport { SpecialSelector, SwcQueryOptions, HelperHostSet } from '../types';\n\nexport interface QueryMetadata {\n propertyKey: string | symbol;\n selector: string;\n options: SwcQueryOptions ;\n}\n\nexport const QUERY_METADATA_KEY = Symbol.for('simple-web-component:query');\n\nexport function query(target: SpecialSelector): PropertyDecorator;\nexport function query(selector: string, options?: SwcQueryOptions): PropertyDecorator;\n/**\n * @query decorator to inject a single element into a class property.\n */\nexport function query(selectorOrTarget: string, options: any = {}): PropertyDecorator {\n return (targetObj: Object, propertyKey: string | symbol, descriptor?: never): void => {\n if (descriptor !== undefined) {\n throw new Error(`@query decorator cannot be used on methods. (Method: ${String(propertyKey)})`);\n }\n\n const constructor = targetObj.constructor;\n let queries = ReflectUtils.getMetadata<QueryMetadata[]>(QUERY_METADATA_KEY, constructor);\n if (!queries) {\n queries = [];\n ReflectUtils.defineMetadata(QUERY_METADATA_KEY, queries, constructor);\n }\n queries.push({ propertyKey, selector: selectorOrTarget, options });\n\n Object.defineProperty(targetObj, propertyKey, {\n get(this: HTMLElement) {\n ensureInit(this);\n const selector = selectorOrTarget;\n\n const r = options.root || 'auto';\n const applyRoot = (t: any) => {\n if (!t || !(t instanceof HTMLElement)) return t;\n if (r === 'auto') return t.shadowRoot || t;\n if (r === 'shadow') return t.shadowRoot;\n if (r === 'light') return t;\n if (r === 'all') return t.shadowRoot || t; \n return t;\n };\n\n // --- Special Selectors: HostSet ---\n const hostSet = SwcUtils.getHostSet(this);\n if (selector === '$this') return applyRoot(this);\n if (selector === '$host') return applyRoot(hostSet.$host);\n if (selector === '$parentHost') return applyRoot(hostSet.$parentHost);\n if (selector === '$appHost') return applyRoot(hostSet.$appHost);\n if (selector === '$firstHost') return applyRoot(hostSet.$firstHost);\n if (selector === '$lastHost') return applyRoot(hostSet.$lastHost);\n if (selector === '$firstAppHost') return applyRoot(hostSet.$firstAppHost);\n if (selector === '$lastAppHost') return applyRoot(hostSet.$lastAppHost);\n\n // --- Special Selectors: Env ---\n const config = getElementConfig(this);\n const win = config?.window || window;\n if (selector === '$window') return win;\n if (selector === '$document') return win.document;\n\n // --- Standard Selectors ---\n if (r === 'shadow') return this.shadowRoot ? this.shadowRoot.querySelector(selector) : null;\n if (r === 'light') return this.querySelector(selector);\n if (r === 'all') {\n const shadowMatch = this.shadowRoot ? this.shadowRoot.querySelector(selector) : null;\n return shadowMatch || this.querySelector(selector);\n }\n return (this.shadowRoot || this).querySelector(selector);\n },\n set(this: HTMLElement, nv: any) {\n ensureInit(this);\n if (nv === null || nv === undefined) {\n const selector = selectorOrTarget;\n if (selector.startsWith('$') && selector !== '$this') return;\n\n const r = options.root || 'auto';\n const targets: Element[] = [];\n\n if (r === 'shadow') {\n if (this.shadowRoot?.querySelector(selector)) targets.push(this.shadowRoot.querySelector(selector)!);\n } else if (r === 'light') {\n if (this.querySelector(selector)) targets.push(this.querySelector(selector)!);\n } else if (r === 'all') {\n if (this.shadowRoot?.querySelector(selector)) targets.push(this.shadowRoot.querySelector(selector)!);\n if (this.querySelector(selector)) targets.push(this.querySelector(selector)!);\n } else {\n const el = (this.shadowRoot || this).querySelector(selector);\n if (el) targets.push(el);\n }\n\n targets.forEach(t => t.remove());\n }\n },\n enumerable: true,\n configurable: true\n });\n };\n}\n\n/**\n * @queryThis decorator - simplified version of @query for $this selector\n */\nexport function queryThis(target: Object, propertyKey: string | symbol): void;\nexport function queryThis(): PropertyDecorator;\nexport function queryThis(options: SwcQueryOptions): PropertyDecorator;\nexport function queryThis(targetOrOptions?: any, propertyKey?: string | symbol): any {\n if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return query('$this', {})(targetOrOptions, propertyKey);\n }\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {\n return query('$this', targetOrOptions as SwcQueryOptions);\n } else {\n return query('$this', {});\n }\n}\n\n\nexport function queryWindow(target: Object, propertyKey: string | symbol): void;\nexport function queryWindow(): PropertyDecorator;\nexport function queryWindow(options: SwcQueryOptions): PropertyDecorator;\nexport function queryWindow(targetOrOptions?: any, propertyKey?: string | symbol): any {\n if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return query('$window', {})(targetOrOptions, propertyKey);\n }\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {\n return query('$window', targetOrOptions as SwcQueryOptions);\n } else {\n return query('$window', {});\n }\n}\n\nexport function queryDocument(target: Object, propertyKey: string | symbol): void;\nexport function queryDocument(): PropertyDecorator;\nexport function queryDocument(options: SwcQueryOptions): PropertyDecorator;\nexport function queryDocument(targetOrOptions?: any, propertyKey?: string | symbol): any {\n if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return query('$document', {})(targetOrOptions, propertyKey);\n }\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {\n return query('$document', targetOrOptions as SwcQueryOptions);\n } else {\n return query('$document', {});\n }\n}\n/**\n * @host - Query $host (Direct parent SWC component)\n */\nexport function queryHost(target: Object, propertyKey: string | symbol): void;\nexport function queryHost(): PropertyDecorator;\nexport function queryHost(options: SwcQueryOptions): PropertyDecorator;\nexport function queryHost(targetOrOptions?: any, propertyKey?: string | symbol): any {\n if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return query('$host', {})(targetOrOptions, propertyKey);\n }\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {\n return query('$host', targetOrOptions as SwcQueryOptions);\n } else {\n return query('$host', {});\n }\n}\n\n/**\n * @appHost - Query $appHost (Nearest <swc-app>)\n */\nexport function queryAppHost(target: Object, propertyKey: string | symbol): void;\nexport function queryAppHost(): PropertyDecorator;\nexport function queryAppHost(options: SwcQueryOptions): PropertyDecorator;\nexport function queryAppHost(targetOrOptions?: any, propertyKey?: string | symbol): any {\n if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return query('$appHost', {})(targetOrOptions, propertyKey);\n }\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {\n return query('$appHost', targetOrOptions as SwcQueryOptions);\n } else {\n return query('$appHost', {});\n }\n}\n\nexport const getQueryMetadata = (target: any): QueryMetadata[] => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(QUERY_METADATA_KEY, constructor) ?? [];\n};\n"],
5
- "mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB,kBAAkB;AAC7C,SAAS,gBAAgB;AASlB,MAAM,qBAAqB,OAAO,IAAI,4BAA4B;AAOnE,SAAU,MAAM,kBAA0B,UAAe,CAAA,GAAE;AAC/D,SAAO,CAAC,WAAmB,aAA8B,eAA4B;AACnF,QAAI,eAAe,QAAW;AAC5B,YAAM,IAAI,MAAM,wDAAwD,OAAO,WAAW,CAAC,GAAG;IAChG;AAEA,UAAM,cAAc,UAAU;AAC9B,QAAI,UAAU,aAAa,YAA6B,oBAAoB,WAAW;AACvF,QAAI,CAAC,SAAS;AACZ,gBAAU,CAAA;AACV,mBAAa,eAAe,oBAAoB,SAAS,WAAW;IACtE;AACA,YAAQ,KAAK,EAAE,aAAa,UAAU,kBAAkB,QAAO,CAAE;AAEjE,WAAO,eAAe,WAAW,aAAa;MAC5C,MAAG;AACD,mBAAW,IAAI;AACf,cAAM,WAAW;AAEjB,cAAM,IAAI,QAAQ,QAAQ;AAC1B,cAAM,YAAY,CAAC,MAAU;AAC3B,cAAI,CAAC,KAAK,EAAE,aAAa;AAAc,mBAAO;AAC9C,cAAI,MAAM;AAAQ,mBAAO,EAAE,cAAc;AACzC,cAAI,MAAM;AAAU,mBAAO,EAAE;AAC7B,cAAI,MAAM;AAAS,mBAAO;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AAW;AACrG,WAAO,MAAM,aAAa,CAAA,CAAE,EAAE,iBAAiB,WAAW;EAC5D;AACA,MAAI,OAAO,oBAAoB,YAAY,oBAAoB,MAAM;AACnE,WAAO,MAAM,aAAa,eAAkC;EAC9D,OAAO;AACL,WAAO,MAAM,aAAa,CAAA,CAAE;EAC9B;AACF;AAOM,SAAU,UAAU,iBAAuB,aAA6B;AAC5E,MAAI,gBAAgB,WAAc,OAAO,gBAAgB,YAAY,OAAO,gBAAgB,WAAW;AACrG,WAAO,MAAM,SAAS,CAAA,CAAE,EAAE,iBAAiB,WAAW;EACxD;AACA,MAAI,OAAO,oBAAoB,YAAY,oBAAoB,MAAM;AACnE,WAAO,MAAM,SAAS,eAAkC;EAC1D,OAAO;AACL,WAAO,MAAM,SAAS,CAAA,CAAE;EAC1B;AACF;AAQM,SAAU,aAAa,iBAAuB,aAA6B;AAC/E,MAAI,gBAAgB,WAAc,OAAO,gBAAgB,YAAY,OAAO,gBAAgB,WAAW;AACrG,WAAO,MAAM,YAAY,CAAA,CAAE,EAAE,iBAAiB,WAAW;EAC3D;AACA,MAAI,OAAO,oBAAoB,YAAY,oBAAoB,MAAM;AACnE,WAAO,MAAM,YAAY,eAAkC;EAC7D,OAAO;AACL,WAAO,MAAM,YAAY,CAAA,CAAE;EAC7B;AACF;AAEO,MAAM,mBAAmB,CAAC,WAAiC;AAChE,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,SAAO,aAAa,YAAY,oBAAoB,WAAW,KAAK,CAAA;AACtE;",
6
- "names": []
4
+ "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { getElementConfig, ensureInit } from './elementDefine';\nimport { SwcUtils } from '../utils/Utils';\nimport { SwcQueryOptions, HelperHostSet } from '../types';\n\nexport interface QueryOptions extends SwcQueryOptions {\n /**\n * Filter function to determine whether to include the element.\n * If it returns false, the element is skipped.\n */\n filter?: (target: HTMLElement, meta: { currentThis: any, helper: HelperHostSet }) => boolean;\n}\n\nexport interface QueryMetadata {\n propertyKey: string | symbol;\n selector: string | ((currentThis: any, helper: HelperHostSet) => Node | NodeList | Element | Element[] | null);\n options: QueryOptions ;\n}\n\nexport const QUERY_METADATA_KEY = Symbol.for('simple-web-component:query');\n\nexport function query(target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor): PropertyDescriptor | void;\nexport function query(selector: string | ((currentThis: any, helper: HelperHostSet) => Node | NodeList | Element | Element[] | null), options?: QueryOptions): PropertyDecorator;\nexport function query(options?: QueryOptions): PropertyDecorator;\n/**\n * @query decorator to inject a single element into a class property.\n * \n * Supports both string selectors and function-based selectors:\n * - String selector: @query('#my-element')\n * - Function selector: @query((currentThis, helper) => currentThis.shadowRoot?.querySelector('.item'))\n * \n * Supports filtering:\n * - @query('#my-element', { filter: (target, meta) => target.hasAttribute('active') })\n */\nexport function query(selectorOrTarget?: string | ((currentThis: any, helper: HelperHostSet) => Node | NodeList | Element | Element[] | null) | Object, optionsOrPropertyKey?: QueryOptions | string | symbol, descriptor?: PropertyDescriptor): any {\n // Bare decorator: @query\n if (descriptor !== undefined && (typeof optionsOrPropertyKey === 'string' || typeof optionsOrPropertyKey === 'symbol')) {\n throw new Error(`@query decorator cannot be used on methods. (Method: ${String(optionsOrPropertyKey)})`);\n }\n // With selector\n if (typeof selectorOrTarget === 'string' || typeof selectorOrTarget === 'function') {\n return (targetObj: Object, propertyKey: string | symbol, descriptor?: never): void => {\n if (descriptor !== undefined) {\n throw new Error(`@query decorator cannot be used on methods. (Method: ${String(propertyKey)})`);\n }\n\n const constructor = targetObj.constructor;\n let queries = ReflectUtils.getMetadata<QueryMetadata[]>(QUERY_METADATA_KEY, constructor);\n if (!queries) {\n queries = [];\n ReflectUtils.defineMetadata(QUERY_METADATA_KEY, queries, constructor);\n }\n queries.push({ propertyKey, selector: selectorOrTarget as any, options: optionsOrPropertyKey as QueryOptions || {} });\n\n Object.defineProperty(targetObj, propertyKey, {\n get(this: HTMLElement) {\n ensureInit(this);\n const config = getElementConfig(this);\n const win = config?.window || window;\n const hostSet = SwcUtils.getHelperAndHostSet(win, this);\n \n // Resolve selector - can be string or function\n let resolvedSelector: string;\n let resolvedElement: HTMLElement | null = null;\n \n if (typeof selectorOrTarget === 'function') {\n const result = (selectorOrTarget as any)(this, hostSet);\n // If function returns a Node/Element, return it directly\n if (result instanceof win.Node || result instanceof win.Element) {\n resolvedElement = result instanceof win.HTMLElement ? (result as HTMLElement) : null;\n }\n // If function returns NodeList or Element[], return first element\n else if (result instanceof win.NodeList || Array.isArray(result)) {\n resolvedElement = result.length > 0 && result[0] instanceof win.HTMLElement ? (result[0] as HTMLElement) : null;\n }\n } else {\n resolvedSelector = selectorOrTarget;\n\n const r = (optionsOrPropertyKey as QueryOptions)?.root || 'auto';\n const applyRoot = (t: any) => {\n if (!t || !(t instanceof HTMLElement)) return t;\n if (r === 'auto') return t.shadowRoot || t;\n if (r === 'shadow') return t.shadowRoot;\n if (r === 'light') return t;\n if (r === 'all') return t.shadowRoot || t; \n return t;\n };\n\n // --- Special Selectors: HostSet ---\n if (resolvedSelector === '$this') resolvedElement = applyRoot(this);\n else if (resolvedSelector === '$host') resolvedElement = applyRoot(hostSet.$host);\n else if (resolvedSelector === '$parentHost') resolvedElement = applyRoot(hostSet.$parentHost);\n else if (resolvedSelector === '$appHost') resolvedElement = applyRoot(hostSet.$appHost);\n else if (resolvedSelector === '$firstHost') resolvedElement = applyRoot(hostSet.$firstHost);\n else if (resolvedSelector === '$lastHost') resolvedElement = applyRoot(hostSet.$lastHost);\n else if (resolvedSelector === '$firstAppHost') resolvedElement = applyRoot(hostSet.$firstAppHost);\n else if (resolvedSelector === '$lastAppHost') resolvedElement = applyRoot(hostSet.$lastAppHost);\n // --- Special Selectors: Env ---\n else if (resolvedSelector === '$window') return win;\n else if (resolvedSelector === '$document') return win.document;\n // --- Standard Selectors ---\n else {\n if (r === 'shadow') resolvedElement = this.shadowRoot ? (this.shadowRoot.querySelector(resolvedSelector) as HTMLElement | null) : null;\n else if (r === 'light') resolvedElement = this.querySelector(resolvedSelector) as HTMLElement | null;\n else if (r === 'all') {\n const shadowMatch = this.shadowRoot ? (this.shadowRoot.querySelector(resolvedSelector) as HTMLElement | null) : null;\n resolvedElement = shadowMatch || (this.querySelector(resolvedSelector) as HTMLElement | null);\n }\n else resolvedElement = ((this.shadowRoot || this).querySelector(resolvedSelector) as HTMLElement | null);\n }\n }\n\n // Apply filter if provided\n if (resolvedElement instanceof win.HTMLElement && (optionsOrPropertyKey as QueryOptions)?.filter) {\n const shouldInclude = (optionsOrPropertyKey as QueryOptions).filter!(resolvedElement, { currentThis: this, helper: hostSet });\n if (!shouldInclude) {\n return null;\n }\n }\n\n return resolvedElement;\n },\n set(this: HTMLElement, nv: any) {\n ensureInit(this);\n if (nv === null || nv === undefined) {\n const config = getElementConfig(this);\n const win = config?.window || window;\n const hostSet = SwcUtils.getHelperAndHostSet(win, this);\n \n // Resolve selector - can be string or function\n if (typeof selectorOrTarget === 'function') {\n // Get the element from function and remove it\n const result = (selectorOrTarget as any)(this, hostSet);\n if (result instanceof win.Element) {\n (result as Element).remove();\n } else if (result instanceof win.NodeList || Array.isArray(result)) {\n const el = result.length > 0 ? result[0] : null;\n if (el instanceof win.Element) {\n (el as Element).remove();\n }\n }\n return;\n }\n \n const resolvedSelector = selectorOrTarget;\n \n if (resolvedSelector.startsWith('$') && resolvedSelector !== '$this') return;\n\n const r = (optionsOrPropertyKey as QueryOptions)?.root || 'auto';\n const targets: Element[] = [];\n\n if (r === 'shadow') {\n if (this.shadowRoot?.querySelector(resolvedSelector)) targets.push(this.shadowRoot.querySelector(resolvedSelector)!);\n } else if (r === 'light') {\n if (this.querySelector(resolvedSelector)) targets.push(this.querySelector(resolvedSelector)!);\n } else if (r === 'all') {\n if (this.shadowRoot?.querySelector(resolvedSelector)) targets.push(this.shadowRoot.querySelector(resolvedSelector)!);\n if (this.querySelector(resolvedSelector)) targets.push(this.querySelector(resolvedSelector)!);\n } else {\n const el = (this.shadowRoot || this).querySelector(resolvedSelector);\n if (el) targets.push(el);\n }\n\n targets.forEach(t => t.remove());\n }\n },\n enumerable: true,\n configurable: true\n });\n };\n }\n // Without selector (defaults to $this)\n return query('$this', selectorOrTarget as SwcQueryOptions);\n}\n\nexport const getQueryMetadata = (target: any): QueryMetadata[] => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(QUERY_METADATA_KEY, constructor) ?? [];\n};\n"],
5
+ "mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB,kBAAkB;AAC7C,SAAS,gBAAgB;AAiBlB,MAAM,qBAAqB,OAAO,IAAI,4BAA4B;AAenE,SAAU,MAAM,kBAAkI,sBAAuD,YAA+B;AAE5O,MAAI,eAAe,WAAc,OAAO,yBAAyB,YAAY,OAAO,yBAAyB,WAAW;AACtH,UAAM,IAAI,MAAM,wDAAwD,OAAO,oBAAoB,CAAC,GAAG;EACzG;AAEA,MAAI,OAAO,qBAAqB,YAAY,OAAO,qBAAqB,YAAY;AAClF,WAAO,CAAC,WAAmB,aAA8BA,gBAA4B;AACnF,UAAIA,gBAAe,QAAW;AAC5B,cAAM,IAAI,MAAM,wDAAwD,OAAO,WAAW,CAAC,GAAG;MAChG;AAEA,YAAM,cAAc,UAAU;AAC9B,UAAI,UAAU,aAAa,YAA6B,oBAAoB,WAAW;AACvF,UAAI,CAAC,SAAS;AACZ,kBAAU,CAAA;AACV,qBAAa,eAAe,oBAAoB,SAAS,WAAW;MACtE;AACA,cAAQ,KAAK,EAAE,aAAa,UAAU,kBAAyB,SAAS,wBAAwC,CAAA,EAAE,CAAE;AAEpH,aAAO,eAAe,WAAW,aAAa;QAC5C,MAAG;AACD,qBAAW,IAAI;AACf,gBAAM,SAAS,iBAAiB,IAAI;AACpC,gBAAM,MAAM,QAAQ,UAAU;AAC9B,gBAAM,UAAU,SAAS,oBAAoB,KAAK,IAAI;AAGtD,cAAI;AACJ,cAAI,kBAAsC;AAE1C,cAAI,OAAO,qBAAqB,Y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