@dooboostore/simple-web-component 1.0.45 → 1.0.46
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.
- package/dist/cjs/decorators/applyAttribute.js.map +2 -2
- package/dist/cjs/decorators/applyNode.js +3 -1
- package/dist/cjs/decorators/applyNode.js.map +2 -2
- package/dist/cjs/decorators/applyProperty.js.map +2 -2
- package/dist/cjs/decorators/elementDefine.js +5 -8
- package/dist/cjs/decorators/elementDefine.js.map +3 -3
- package/dist/cjs/decorators/lifecycles.js +11 -36
- package/dist/cjs/decorators/lifecycles.js.map +2 -2
- package/dist/cjs/elements/SwcAppMixin.js +6 -2
- package/dist/cjs/elements/SwcAppMixin.js.map +2 -2
- package/dist/esm/decorators/applyAttribute.js.map +2 -2
- package/dist/esm/decorators/applyNode.js +3 -1
- package/dist/esm/decorators/applyNode.js.map +2 -2
- package/dist/esm/decorators/applyProperty.js.map +2 -2
- package/dist/esm/decorators/elementDefine.js +6 -9
- package/dist/esm/decorators/elementDefine.js.map +2 -2
- package/dist/esm/decorators/lifecycles.js +11 -36
- package/dist/esm/decorators/lifecycles.js.map +2 -2
- package/dist/esm/elements/SwcAppMixin.js +6 -2
- package/dist/esm/elements/SwcAppMixin.js.map +2 -2
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +41 -27
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +3 -3
- package/dist/types/decorators/applyAttribute.d.ts +1 -0
- package/dist/types/decorators/applyAttribute.d.ts.map +1 -1
- package/dist/types/decorators/applyNode.d.ts.map +1 -1
- package/dist/types/decorators/applyProperty.d.ts +1 -0
- package/dist/types/decorators/applyProperty.d.ts.map +1 -1
- package/dist/types/decorators/elementDefine.d.ts.map +1 -1
- package/dist/types/decorators/lifecycles.d.ts +12 -13
- package/dist/types/decorators/lifecycles.d.ts.map +1 -1
- package/dist/types/elements/SwcAppMixin.d.ts.map +1 -1
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +41 -27
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +3 -3
- package/package.json +3 -3
- package/src/decorators/applyAttribute.ts +1 -0
- package/src/decorators/applyNode.ts +3 -1
- package/src/decorators/applyProperty.ts +1 -0
- package/src/decorators/elementDefine.ts +8 -11
- package/src/decorators/lifecycles.ts +53 -52
- package/src/elements/SwcAppMixin.ts +7 -3
- package/dist/cjs/examples/RxJSOperatorsExample.js +0 -285
- package/dist/cjs/examples/RxJSOperatorsExample.js.map +0 -7
- package/dist/esm/examples/RxJSOperatorsExample.js +0 -266
- package/dist/esm/examples/RxJSOperatorsExample.js.map +0 -7
- package/dist/types/examples/RxJSOperatorsExample.d.ts +0 -94
- package/dist/types/examples/RxJSOperatorsExample.d.ts.map +0 -1
- package/src/examples/RxJSOperatorsExample.ts +0 -279
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/elements/SwcAppMixin.ts"],
|
|
4
|
-
"sourcesContent": ["import { SwcAppInterface, SwcAppMessage } from '../types';\nimport { APPLY_NODE_METADATA_KEY, findAllLifecycleMetadata, getSubscribeSwcAppMessageWhileConnectedMetadata, getSubscribeSwcAppRouteChangeWhileConnectedMetadata, ON_CONNECTED_SWC_APP_METADATA_KEY, SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY } from '../decorators';\nimport { SwcAppEngine, SwcAttributeConfigType, SwcConfigType } from '../SwcAppEngine';\nimport { debounceTimeIntervalLock, FunctionUtils, Subscription } from '@dooboostore/core';\nimport { RouterEventType } from '@dooboostore/core-web';\nimport { SwcUtils } from '../utils/Utils';\n\nexport const isSSR = (i: HTMLElement) => {\n return i.hasAttribute('swc-use-ssr');\n};\nexport const setSSRAttribute = (i: HTMLElement) => {\n i.setAttribute('swc-use-ssr', (i as any)._swcId ?? '');\n};\nexport const removeSSRAttribute = (i: HTMLElement) => {\n i.removeAttribute('swc-use-ssr');\n};\n\n/**\n * SwcAppMixin: SwcApp \uAE30\uB2A5\uC744 \uBAA8\uB4E0 HTMLElement\uC5D0 \uCD94\uAC00\uD560 \uC218 \uC788\uB294 Mixin\n *\n * \uC0AC\uC6A9 \uC608:\n * @elementDefine('custom-app', { window: w })\n * class CustomApp extends SwcAppMixin(w.HTMLElement) implements SwcAppInterface {\n * // \uCD94\uAC00 \uAE30\uB2A5 \uAD6C\uD604\n * }\n */\nexport function SwcAppMixin<T extends { new (...args: any[]): HTMLElement }>(Base: T) {\n return class SwcAppMixinClass extends Base implements SwcAppInterface {\n __swc_engine = new SwcAppEngine(this as any);\n _swc_connected_instance = new Set<any>();\n _routerSubscription?: Subscription;\n _lastRouterEvent?: RouterEventType;\n _routeChangeInvocations = 0;\n _connectedInvocations = 0;\n\n _childrenRouteChangedInterval: any;\n _childrenConnectedDoneInterval: any;\n\n /**\n * Safari is \uC18D\uC131 \uCC98\uB9AC\n * Safari polyfill\uC5D0\uC11C\uB294 \uC790\uC2DD\uBD80\uD130 \uB9CC\uB4E4\uC5B4\uC9C0\uACE0 \uBD80\uBAA8\uAC00 \uB9CC\uB4E4\uC5B4\uC9C0\uBBC0\uB85C\n * \uBD80\uBAA8\uAC00 \uC790\uC2DD\uB4E4\uC744 \uAC15\uC81C\uB85C \uB4F1\uB85D\uD574\uC8FC\uB294 \uD615\uD0DC\uB85C \uCC98\uB9AC\n */\n _connected_safari_and_standby = [];\n\n constructor(...args: any[]) {\n super(...args);\n console.log('[SWC-APP-MIXIN] constructor');\n }\n\n get simpleApplication() {\n return this.__swc_engine.simpleApplication;\n }\n\n get config() {\n return this.__swc_engine?.config;\n }\n\n get router() {\n return this.__swc_engine?.router;\n }\n\n async _invokeRouteChangeSubscribers(instance: HTMLElement, re: RouterEventType) {\n if (instance.isConnected === false) return;\n\n this._routeChangeInvocations++;\n\n if (this._childrenRouteChangedInterval) {\n this.config.window.clearInterval(this._childrenRouteChangedInterval);\n }\n const intervalConfig = { setInterval: this.config.window.setInterval.bind(this.config.window), clearInterval: this.config.window.clearInterval.bind(this.config.window) };\n this._childrenRouteChangedInterval = debounceTimeIntervalLock(\n () => this._routeChangeInvocations === 0,\n () => {\n this._childrenRouteChangedInterval = null;\n this.config.onChildrenRouteChanged?.(re, this);\n },\n this.config?.childrenConnectedDoneCheckIntervalTime ?? 30,\n intervalConfig\n );\n\n try {\n const routeChangeSubscribers = getSubscribeSwcAppRouteChangeWhileConnectedMetadata(instance);\n\n if (routeChangeSubscribers.length > 0) {\n console.log('[SWC-MIXIN] Route change subscribers found');\n\n // Subscribers are already sorted by order from getSubscribeSwcAppRouteChangeWhileConnectedMetadata\n // Execute subscribers in order, stop if one returns a value\n for (const metadata of routeChangeSubscribers) {\n const methodName = metadata.propertyKey;\n let pathPattern = metadata.options?.path as any;\n const filter = metadata.options?.filter;\n const extractValue = (v: any) => {\n const keyToUse = metadata.options?.valueKey ?? SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY;\n if (v && typeof v === 'object' && keyToUse in v) {\n return v[keyToUse];\n }\n return v;\n };\n\n if (typeof pathPattern === 'function') {\n pathPattern = (pathPattern as Function)(instance);\n }\n\n let pathMatched = false;\n let pathData: any = null;\n\n if (!pathPattern) {\n pathMatched = true;\n pathData = {};\n } else if (Array.isArray(pathPattern)) {\n for (const pattern of pathPattern) {\n const data = SwcUtils.parsePathPattern(pattern, re.path || '/');\n if (data !== null) {\n pathMatched = true;\n pathData = data;\n break;\n }\n }\n } else {\n pathData = SwcUtils.parsePathPattern(pathPattern, re.path || '/');\n pathMatched = pathData !== null;\n }\n\n const hostSet = SwcUtils.getHelperAndHostSet(this.config.window, this);\n const filterPassed = !filter || filter(this.router!, { helper: hostSet, currentThis: instance });\n\n if (pathMatched && filterPassed && instance[methodName]) {\n const result = extractValue(await instance[methodName]({ ...re, pathData: pathData }));\n // if (typeof result === 'object'\n // If handler returns a value, stop propagation to next handlers\n if (result !== undefined && result !== null) {\n break;\n }\n }\n }\n }\n } finally {\n if (this.config?.ssr) {\n setSSRAttribute(instance);\n } else {\n removeSSRAttribute(instance);\n }\n this._routeChangeInvocations = Math.max(0, this._routeChangeInvocations - 1);\n }\n }\n\n async _connected(instance: HTMLElement, option?: { noIncrements: boolean }) {\n if (instance) {\n if (!this.simpleApplication && !this.config) {\n this._connected_safari_and_standby.push(instance);\n return;\n }\n\n this.config.onConnectedChildBefore?.(instance);\n if (!option?.noIncrements) {\n this._connectedInvocations++;\n }\n this._swc_connected_instance.add(instance);\n\n const connectedSwcAppCallBacks = findAllLifecycleMetadata(instance, ON_CONNECTED_SWC_APP_METADATA_KEY);\n for (let connectedSwcAppCallBack of connectedSwcAppCallBacks) {\n await (instance as any)?._invokeLifecycleMethod?.(connectedSwcAppCallBack.propertyKey);\n }\n\n if (this._childrenConnectedDoneInterval) {\n this.config.window.clearInterval(this._childrenConnectedDoneInterval);\n }\n const intervalConfig = { setInterval: this.config.window.setInterval.bind(this.config.window), clearInterval: this.config.window.clearInterval.bind(this.config.window) };\n this._childrenConnectedDoneInterval = debounceTimeIntervalLock(\n () => this._connectedInvocations === 0,\n () => {\n this._childrenConnectedDoneInterval = null;\n this.config.onChildrenConnectedDone?.(this);\n },\n this.config?.childrenConnectedDoneCheckIntervalTime ?? 30,\n intervalConfig\n );\n\n if (this.simpleApplication) {\n try {\n if (this.router && this._lastRouterEvent) {\n await this._invokeRouteChangeSubscribers(instance, this._lastRouterEvent!);\n }\n } catch (e) {\n throw e;\n }\n }\n\n if (this.config?.ssr) {\n setSSRAttribute(instance);\n } else {\n removeSSRAttribute(instance);\n }\n }\n\n this.config.onConnectedChildAfter?.(instance);\n return this;\n }\n\n async _connectedDone(instance: any) {\n try {\n // \uB0B4\uBD80 \uC5F0\uACB0 \uCC98\uB9AC \uB85C\uC9C1\n } finally {\n this._connectedInvocations = Math.max(0, this._connectedInvocations - 1);\n }\n }\n\n _disconnected(instance: any) {\n if (instance) {\n this._swc_connected_instance.delete(instance);\n this.config?.onDisconnectedChildAfter?.(instance);\n }\n }\n\n async _handleRouteChange(route: RouterEventType) {\n this._lastRouterEvent = route;\n const swcConnectedInstance = Array.from(this._swc_connected_instance);\n const ps = swcConnectedInstance.map((instance: any) => this._invokeRouteChangeSubscribers(instance, route));\n await Promise.allSettled(ps);\n }\n\n async connect(config?: SwcAttributeConfigType) {\n console.log('[SWC-MIXIN] connect');\n const swcConfig = {\n routeType: 'element',\n window: config?.window,\n ...config\n } as SwcConfigType;\n\n await this.__swc_engine.connect(swcConfig);\n\n // Safari is \uC18D\uC131 \uCC98\uB9AC\n this._connected_safari_and_standby.forEach((instance: any) => {\n this._connected(instance, { noIncrements: true });\n });\n\n // \uB77C\uC6B0\uD130 \uBCC0\uACBD \uAD6C\uB3C5\n if (!this._routerSubscription && this.router) {\n const config = this.__swc_engine.config;\n\n this._routerSubscription = this.router.observable.subscribe(async (route: RouterEventType) => {\n console.log('[SWC-MIXIN] Router event received:', route.triggerPoint);\n if (route.triggerPoint === 'end') {\n await this._handleRouteChange(route);\n }\n });\n\n if (config?.path) {\n console.log('[DEBUG] Navigating to initial path:', config.path);\n }\n }\n }\n\n connectedCallback() {\n // \uBD80\uBAA8 \uD074\uB798\uC2A4\uC758 connectedCallback \uD638\uCD9C\n // @ts-ignore\n super.connectedCallback?.();\n\n const configStr = this.getAttribute('swc-get-application-config');\n const win = this.ownerDocument?.defaultView || window;\n if (configStr && win) {\n try {\n const userConfig = FunctionUtils.executeReturn({\n script: configStr,\n context: this,\n args: SwcUtils.getHelperAndHostSet(win, this)\n });\n if (userConfig instanceof Promise) {\n userConfig\n .then(resolvedConfig => {\n this.connect(resolvedConfig);\n })\n .catch(e => {\n console.error('[SWC-MIXIN] Script execution failed:', e);\n });\n } else {\n this.connect(userConfig);\n }\n } catch (e) {\n console.error('[SWC-MIXIN] Script execution failed:', e);\n }\n }\n\n this._connected(this);\n this.__swc_engine?.config?.onConnected?.(this);\n this._connectedDone(this);\n }\n\n disconnectedCallback() {\n // \uBD80\uBAA8 \uD074\uB798\uC2A4\uC758 disconnectedCallback \uD638\uCD9C\n // @ts-ignore\n super.disconnectedCallback?.();\n\n this._routerSubscription?.unsubscribe();\n this._routerSubscription = undefined;\n this._lastRouterEvent = undefined;\n this.__swc_engine.disconnect();\n this.__swc_engine?.config?.onDisconnected?.(this);\n this._disconnected(this);\n }\n\n async routing(path: string) {\n await this.router?.go(path);\n }\n\n back(): void {\n this.router?.back();\n }\n\n forward(): void {\n this.router?.forward();\n }\n\n reload(): void {\n this.router?.reload();\n }\n\n publishMessage(message: SwcAppMessage): void {\n this._swc_connected_instance.forEach((instance: any) => {\n this._invokeMessageSubscribers(instance, message);\n });\n }\n\n _invokeMessageSubscribers(instance: any, message: SwcAppMessage) {\n const messageSubscribers = getSubscribeSwcAppMessageWhileConnectedMetadata(instance);\n if (messageSubscribers && Array.isArray(messageSubscribers)) {\n messageSubscribers.forEach(metadata => {\n const methodName = metadata.propertyKey;\n const messageType = metadata.messageType;\n const filter = metadata.filter;\n\n let typeMatched = false;\n if (!messageType) {\n typeMatched = true;\n } else if (message.type === messageType) {\n typeMatched = true;\n }\n\n let filterMatched = true;\n if (filter && typeMatched) {\n filterMatched = filter(message, instance);\n }\n\n if (typeMatched && filterMatched && typeof instance[methodName] === 'function') {\n instance[methodName](message);\n }\n });\n }\n }\n };\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,wBAAwQ;AACxQ,0BAAoE;AACpE,kBAAsE;
|
|
4
|
+
"sourcesContent": ["import { SwcAppInterface, SwcAppMessage } from '../types';\nimport { APPLY_NODE_METADATA_KEY, findAllLifecycleMetadata, getSubscribeSwcAppMessageWhileConnectedMetadata, getSubscribeSwcAppRouteChangeWhileConnectedMetadata, ON_CONNECTED_SWC_APP_METADATA_KEY, SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY } from '../decorators';\nimport { SwcAppEngine, SwcAttributeConfigType, SwcConfigType } from '../SwcAppEngine';\nimport { debounceTimeIntervalLock, FunctionUtils, Subscription } from '@dooboostore/core';\nimport {RouterEventType, ValidUtils} from '@dooboostore/core-web';\nimport { SwcUtils } from '../utils/Utils';\n\nexport const isSSR = (i: HTMLElement) => {\n return i.hasAttribute('swc-use-ssr');\n};\nexport const setSSRAttribute = (i: HTMLElement) => {\n i.setAttribute('swc-use-ssr', (i as any)._swcId ?? '');\n};\nexport const removeSSRAttribute = (i: HTMLElement) => {\n i.removeAttribute('swc-use-ssr');\n};\n\n/**\n * SwcAppMixin: SwcApp \uAE30\uB2A5\uC744 \uBAA8\uB4E0 HTMLElement\uC5D0 \uCD94\uAC00\uD560 \uC218 \uC788\uB294 Mixin\n *\n * \uC0AC\uC6A9 \uC608:\n * @elementDefine('custom-app', { window: w })\n * class CustomApp extends SwcAppMixin(w.HTMLElement) implements SwcAppInterface {\n * // \uCD94\uAC00 \uAE30\uB2A5 \uAD6C\uD604\n * }\n */\nexport function SwcAppMixin<T extends { new (...args: any[]): HTMLElement }>(Base: T) {\n return class SwcAppMixinClass extends Base implements SwcAppInterface {\n __swc_engine = new SwcAppEngine(this as any);\n _swc_connected_instance = new Set<any>();\n _routerSubscription?: Subscription;\n _lastRouterEvent?: RouterEventType;\n _routeChangeInvocations = 0;\n _connectedInvocations = 0;\n\n _childrenRouteChangedInterval: any;\n _childrenConnectedDoneInterval: any;\n\n /**\n * Safari is \uC18D\uC131 \uCC98\uB9AC\n * Safari polyfill\uC5D0\uC11C\uB294 \uC790\uC2DD\uBD80\uD130 \uB9CC\uB4E4\uC5B4\uC9C0\uACE0 \uBD80\uBAA8\uAC00 \uB9CC\uB4E4\uC5B4\uC9C0\uBBC0\uB85C\n * \uBD80\uBAA8\uAC00 \uC790\uC2DD\uB4E4\uC744 \uAC15\uC81C\uB85C \uB4F1\uB85D\uD574\uC8FC\uB294 \uD615\uD0DC\uB85C \uCC98\uB9AC\n */\n _connected_safari_and_standby = [];\n\n constructor(...args: any[]) {\n super(...args);\n console.log('[SWC-APP-MIXIN] constructor');\n }\n\n get simpleApplication() {\n return this.__swc_engine.simpleApplication;\n }\n\n get config() {\n return this.__swc_engine?.config;\n }\n\n get router() {\n return this.__swc_engine?.router;\n }\n\n async _invokeRouteChangeSubscribers(instance: HTMLElement, re: RouterEventType) {\n if (instance.isConnected === false) return;\n\n this._routeChangeInvocations++;\n\n if (this._childrenRouteChangedInterval) {\n this.config.window.clearInterval(this._childrenRouteChangedInterval);\n }\n const intervalConfig = { setInterval: this.config.window.setInterval.bind(this.config.window), clearInterval: this.config.window.clearInterval.bind(this.config.window) };\n this._childrenRouteChangedInterval = debounceTimeIntervalLock(\n () => this._routeChangeInvocations === 0,\n () => {\n this._childrenRouteChangedInterval = null;\n this.config.onChildrenRouteChanged?.(re, this);\n },\n this.config?.childrenConnectedDoneCheckIntervalTime ?? 30,\n intervalConfig\n );\n\n try {\n const routeChangeSubscribers = getSubscribeSwcAppRouteChangeWhileConnectedMetadata(instance);\n\n if (routeChangeSubscribers.length > 0) {\n console.log('[SWC-MIXIN] Route change subscribers found');\n\n // Subscribers are already sorted by order from getSubscribeSwcAppRouteChangeWhileConnectedMetadata\n // Execute subscribers in order, stop if one returns a value\n for (const metadata of routeChangeSubscribers) {\n const methodName = metadata.propertyKey;\n let pathPattern = metadata.options?.path as any;\n const filter = metadata.options?.filter;\n const extractValue = (v: any) => {\n const keyToUse = metadata.options?.valueKey ?? SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY;\n if (v && typeof v === 'object' && keyToUse in v) {\n return v[keyToUse];\n }\n return v;\n };\n\n if (typeof pathPattern === 'function') {\n pathPattern = (pathPattern as Function)(instance);\n }\n\n let pathMatched = false;\n let pathData: any = null;\n\n if (!pathPattern) {\n pathMatched = true;\n pathData = {};\n } else if (Array.isArray(pathPattern)) {\n for (const pattern of pathPattern) {\n const data = SwcUtils.parsePathPattern(pattern, re.path || '/');\n if (data !== null) {\n pathMatched = true;\n pathData = data;\n break;\n }\n }\n } else {\n pathData = SwcUtils.parsePathPattern(pathPattern, re.path || '/');\n pathMatched = pathData !== null;\n }\n\n const hostSet = SwcUtils.getHelperAndHostSet(this.config.window, this);\n const filterPassed = !filter || filter(this.router!, { helper: hostSet, currentThis: instance });\n\n if (pathMatched && filterPassed && instance[methodName]) {\n const result = extractValue(await instance[methodName]({ ...re, pathData: pathData }));\n // if (typeof result === 'object'\n // If handler returns a value, stop propagation to next handlers\n if (result !== undefined && result !== null) {\n break;\n }\n }\n }\n }\n } finally {\n // this.config?.window\n const isBrowser = ValidUtils.isBrowser();\n if (!isBrowser && this.config?.ssr) {\n setSSRAttribute(instance);\n } else {\n removeSSRAttribute(instance);\n }\n this._routeChangeInvocations = Math.max(0, this._routeChangeInvocations - 1);\n }\n }\n\n async _connected(instance: HTMLElement, option?: { noIncrements: boolean }) {\n if (instance) {\n if (!this.simpleApplication && !this.config) {\n this._connected_safari_and_standby.push(instance);\n return;\n }\n\n this.config.onConnectedChildBefore?.(instance);\n if (!option?.noIncrements) {\n this._connectedInvocations++;\n }\n this._swc_connected_instance.add(instance);\n\n const connectedSwcAppCallBacks = findAllLifecycleMetadata(instance, ON_CONNECTED_SWC_APP_METADATA_KEY);\n for (let connectedSwcAppCallBack of connectedSwcAppCallBacks) {\n await (instance as any)?._invokeLifecycleMethod?.(connectedSwcAppCallBack.propertyKey);\n }\n\n if (this._childrenConnectedDoneInterval) {\n this.config.window.clearInterval(this._childrenConnectedDoneInterval);\n }\n const intervalConfig = { setInterval: this.config.window.setInterval.bind(this.config.window), clearInterval: this.config.window.clearInterval.bind(this.config.window) };\n this._childrenConnectedDoneInterval = debounceTimeIntervalLock(\n () => this._connectedInvocations === 0,\n () => {\n this._childrenConnectedDoneInterval = null;\n this.config.onChildrenConnectedDone?.(this);\n },\n this.config?.childrenConnectedDoneCheckIntervalTime ?? 30,\n intervalConfig\n );\n\n if (this.simpleApplication) {\n try {\n if (this.router && this._lastRouterEvent) {\n await this._invokeRouteChangeSubscribers(instance, this._lastRouterEvent!);\n }\n } catch (e) {\n throw e;\n }\n }\n\n const isBrowser = ValidUtils.isBrowser();\n console.log('------>', isBrowser, this.config?.ssr)\n if (!isBrowser && this.config?.ssr) {\n setSSRAttribute(instance);\n } else {\n removeSSRAttribute(instance);\n }\n }\n\n this.config.onConnectedChildAfter?.(instance);\n return this;\n }\n\n async _connectedDone(instance: any) {\n try {\n // \uB0B4\uBD80 \uC5F0\uACB0 \uCC98\uB9AC \uB85C\uC9C1\n } finally {\n this._connectedInvocations = Math.max(0, this._connectedInvocations - 1);\n }\n }\n\n _disconnected(instance: any) {\n if (instance) {\n this._swc_connected_instance.delete(instance);\n this.config?.onDisconnectedChildAfter?.(instance);\n }\n }\n\n async _handleRouteChange(route: RouterEventType) {\n this._lastRouterEvent = route;\n const swcConnectedInstance = Array.from(this._swc_connected_instance);\n const ps = swcConnectedInstance.map((instance: any) => this._invokeRouteChangeSubscribers(instance, route));\n await Promise.allSettled(ps);\n }\n\n async connect(config?: SwcAttributeConfigType) {\n console.log('[SWC-MIXIN] connect');\n const swcConfig = {\n routeType: 'element',\n window: config?.window,\n ...config\n } as SwcConfigType;\n\n await this.__swc_engine.connect(swcConfig);\n\n // Safari is \uC18D\uC131 \uCC98\uB9AC\n this._connected_safari_and_standby.forEach((instance: any) => {\n this._connected(instance, { noIncrements: true });\n });\n\n // \uB77C\uC6B0\uD130 \uBCC0\uACBD \uAD6C\uB3C5\n if (!this._routerSubscription && this.router) {\n const config = this.__swc_engine.config;\n\n this._routerSubscription = this.router.observable.subscribe(async (route: RouterEventType) => {\n console.log('[SWC-MIXIN] Router event received:', route.triggerPoint);\n if (route.triggerPoint === 'end') {\n await this._handleRouteChange(route);\n }\n });\n\n if (config?.path) {\n console.log('[DEBUG] Navigating to initial path:', config.path);\n }\n }\n }\n\n connectedCallback() {\n // \uBD80\uBAA8 \uD074\uB798\uC2A4\uC758 connectedCallback \uD638\uCD9C\n // @ts-ignore\n super.connectedCallback?.();\n\n const configStr = this.getAttribute('swc-get-application-config');\n const win = this.ownerDocument?.defaultView || window;\n if (configStr && win) {\n try {\n const userConfig = FunctionUtils.executeReturn({\n script: configStr,\n context: this,\n args: SwcUtils.getHelperAndHostSet(win, this)\n });\n if (userConfig instanceof Promise) {\n userConfig\n .then(resolvedConfig => {\n this.connect(resolvedConfig);\n })\n .catch(e => {\n console.error('[SWC-MIXIN] Script execution failed:', e);\n });\n } else {\n this.connect(userConfig);\n }\n } catch (e) {\n console.error('[SWC-MIXIN] Script execution failed:', e);\n }\n }\n\n this._connected(this);\n this.__swc_engine?.config?.onConnected?.(this);\n this._connectedDone(this);\n }\n\n disconnectedCallback() {\n // \uBD80\uBAA8 \uD074\uB798\uC2A4\uC758 disconnectedCallback \uD638\uCD9C\n // @ts-ignore\n super.disconnectedCallback?.();\n\n this._routerSubscription?.unsubscribe();\n this._routerSubscription = undefined;\n this._lastRouterEvent = undefined;\n this.__swc_engine.disconnect();\n this.__swc_engine?.config?.onDisconnected?.(this);\n this._disconnected(this);\n }\n\n async routing(path: string) {\n await this.router?.go(path);\n }\n\n back(): void {\n this.router?.back();\n }\n\n forward(): void {\n this.router?.forward();\n }\n\n reload(): void {\n this.router?.reload();\n }\n\n publishMessage(message: SwcAppMessage): void {\n this._swc_connected_instance.forEach((instance: any) => {\n this._invokeMessageSubscribers(instance, message);\n });\n }\n\n _invokeMessageSubscribers(instance: any, message: SwcAppMessage) {\n const messageSubscribers = getSubscribeSwcAppMessageWhileConnectedMetadata(instance);\n if (messageSubscribers && Array.isArray(messageSubscribers)) {\n messageSubscribers.forEach(metadata => {\n const methodName = metadata.propertyKey;\n const messageType = metadata.messageType;\n const filter = metadata.filter;\n\n let typeMatched = false;\n if (!messageType) {\n typeMatched = true;\n } else if (message.type === messageType) {\n typeMatched = true;\n }\n\n let filterMatched = true;\n if (filter && typeMatched) {\n filterMatched = filter(message, instance);\n }\n\n if (typeMatched && filterMatched && typeof instance[method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2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/decorators/applyAttribute.ts"],
|
|
4
|
-
"sourcesContent": ["import {ReflectUtils, FunctionUtils, ActionExpression} from '@dooboostore/core';\nimport {ensureInit, getElementConfig} from './elementDefine';\nimport {SwcUtils} from '../utils/Utils';\nimport {SwcQueryOptions, HelperHostSet} from '../types';\nimport {ConvertUtils} from '@dooboostore/core-web';\n\n// ============================================\n// Types & Interfaces\n// ============================================\n\nexport interface AttributeOptions extends SwcQueryOptions {\n name?: string;\n type?: typeof Number | typeof Boolean | typeof String;\n filter?: (target: HTMLElement, value: any, meta: { currentThis: any, helper: HelperHostSet }) => boolean;\n /**\n * Custom key to extract value from return object.\n * If not provided, uses ATTRIBUTE_METADATA_KEY by default.\n * Useful when multiple @setAttribute decorators are on the same method.\n * \n * Example:\n * @setAttribute('selector1', { valueKey: 'attr1' })\n * @setAttribute('selector2', { valueKey: 'attr2' })\n * myMethod() {\n * return {\n * attr1: 'value1',\n * attr2: 'value2'\n * };\n * }\n * \n * Or with symbols:\n * @setAttribute('selector1', { valueKey: Symbol.for('attr1') })\n * @setAttribute('selector2', { valueKey: Symbol.for('attr2') })\n * myMethod() {\n * return {\n * [Symbol.for('attr1')]: 'value1',\n * [Symbol.for('attr2')]: 'value2'\n * };\n * }\n */\n valueKey?: symbol | string;\n}\n\nexport type AttributeSelector = string | ((currentThis: any, helper: HelperHostSet) => NodeList | Element | Element[] | null);\n\nexport interface AttributeMetadata {\n propertyKey: string | symbol;\n selector: AttributeSelector;\n targetAttributeName: string;\n options: AttributeOptions;\n type: 'property' | 'method';\n}\n\nexport const ATTRIBUTE_METADATA_KEY = Symbol.for('simple-web-component:attribute');\n\n// ============================================\n// Utilities\n// ============================================\n\n/**\n * Determine if a string is a CSS selector or an attribute name\n * \n * CSS selectors typically:\n * - Start with: #, ., [, :, >, +, ~\n * - Contain special chars: >, +, ~, :, [, ]\n * - Are special keywords: $this, $host, $parentHost, etc.\n * \n * Attribute names are typically:\n * - kebab-case (lowercase with hyphens)\n * - No special selector syntax\n * \n * @param str - String to check\n * @returns true if it's a CSS selector, false if it's an attribute name\n */\nconst isCssSelector = (str: string): boolean => {\n if (!str) return false;\n \n // Special keywords\n if (str.startsWith('$')) return true;\n \n // CSS selector syntax\n if (/^[#.\\[\\:>+~]/.test(str)) return true;\n \n // Contains CSS combinator or pseudo-selector syntax\n if (/[>+~:\\[\\]]/.test(str)) return true;\n \n return false;\n};\n\nconst convertValue = (val: string | null, type: any): any => {\n if (val === null || val === undefined) return val;\n if (type === Number) return Number(val);\n if (type === Boolean) return val === 'false' || val === '0' ? false : true;\n return val;\n};\n\nexport {convertValue};\n\nexport const getAttributeValue = (inst: any, attrName: string, options?: AttributeOptions & { selector?: AttributeSelector }): any => {\n const conf = getElementConfig(inst);\n const currentWin = inst._resolveWindow?.(conf) || ((typeof window !== 'undefined' ? window : undefined) as any);\n\n // If selector is not provided, use inst itself\n const targets = options?.selector ? resolveAttributeTargets(inst, options.selector, options) : [inst];\n\n const primaryTarget = targets[0];\n\n if (primaryTarget && typeof (primaryTarget as any).hasAttribute === 'function' && (primaryTarget as any).hasAttribute(attrName)) {\n let domVal = (primaryTarget as any).getAttribute(attrName);\n\n // \uD45C\uD604\uC2DD \uCCB4\uD06C\n const ae = new ActionExpression(domVal);\n const expr = ae.getFirstExpression('callReturn');\n if (expr) {\n try {\n const result = FunctionUtils.executeReturn({\n script: ConvertUtils.decodeHtmlEntity(expr.script, currentWin.document),\n context: inst,\n args: SwcUtils.getHelperAndHostSet(currentWin, inst)\n });\n return convertValue(result, options?.type);\n } catch (err) {\n console.error(`[SWC] Failed to execute directive {{= ${expr.script} }}:`, err);\n return convertValue(domVal, options?.type);\n }\n }\n\n return convertValue(domVal, options?.type);\n }\n\n // If no target found, return null\n return null;\n};\n\n/**\n * Resolve target elements based on selector and options\n * Handles special selectors ($this, $host, etc.), CSS selectors, and function-based selectors\n * Returns HTMLElement[] for attribute operations\n */\nexport const resolveAttributeTargets = (inst: any, selector: AttributeSelector, options: AttributeOptions): HTMLElement[] => {\n const conf = getElementConfig(inst);\n const currentWin = conf.window;\n const r = options.root || 'auto';\n const results: HTMLElement[] = [];\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 const hostSet = SwcUtils.getHelperAndHostSet(currentWin, inst);\n resolvedSelector = selector(inst, hostSet);\n }\n\n // If selector function returned elements directly, use them\n if (resolvedSelector instanceof currentWin.Element) {\n results.push(resolvedSelector as HTMLElement);\n return results;\n }\n if (resolvedSelector instanceof currentWin.NodeList) {\n results.push(...(Array.from(resolvedSelector) as HTMLElement[]));\n return results;\n }\n if (Array.isArray(resolvedSelector)) {\n results.push(...(resolvedSelector as HTMLElement[]));\n return results;\n }\n if (resolvedSelector === null) {\n return results;\n }\n\n // Handle string selector\n const stringSelector = resolvedSelector as string;\n\n const applyRoot = (target: any) => {\n if (!target) return;\n if (r === 'auto') {\n results.push(target);\n } else {\n if (r === 'light' || r === 'all') results.push(target);\n if ((r === 'shadow' || r === 'all') && target.shadowRoot) results.push(target.shadowRoot);\n }\n };\n\n if (stringSelector === '$this' || !stringSelector) {\n applyRoot(inst);\n } else {\n const hostSet = SwcUtils.getHostSet(inst);\n if (stringSelector === '$host') applyRoot(hostSet.$host);\n else if (stringSelector === '$parentHost') applyRoot(hostSet.$parentHost);\n else if (stringSelector === '$appHost') applyRoot(hostSet.$appHost as any);\n else if (stringSelector === '$firstHost') applyRoot(hostSet.$firstHost);\n else if (stringSelector === '$lastHost') applyRoot(hostSet.$lastHost);\n else if (stringSelector === '$firstAppHost') applyRoot(hostSet.$firstAppHost as any);\n else if (stringSelector === '$lastAppHost') applyRoot(hostSet.$lastAppHost as any);\n else if (stringSelector === '$hosts') hostSet.$hosts.forEach(applyRoot);\n else if (stringSelector === '$appHosts') hostSet.$appHosts.forEach(applyRoot);\n else {\n if (r === 'shadow') {\n const found = inst.shadowRoot?.querySelectorAll(stringSelector);\n if (found) results.push(...found);\n } else if (r === 'light') {\n const found = inst.querySelectorAll(stringSelector);\n if (found) results.push(...found);\n } else if (r === 'all') {\n const sMatch = inst.shadowRoot?.querySelectorAll(stringSelector);\n const lMatch = inst.querySelectorAll(stringSelector);\n if (sMatch) results.push(...sMatch);\n if (lMatch) results.push(...lMatch);\n } else {\n const found = (inst.shadowRoot || inst).querySelectorAll(stringSelector);\n if (found) results.push(...found);\n }\n }\n }\n return results;\n};\n\n/**\n * @applyAttribute decorator - set/get element attributes\n *\n * Usage:\n * - @applyAttribute('selector', 'attrName') - Set attribute with explicit name\n * - @applyAttribute('selector') - Use property name as attribute name\n * - @applyAttribute('selector', { name: 'attrName' }) - Set attribute via options\n * - @applyAttribute((this, helper) => 'selector', 'attrName') - Function-based selector\n * - Return null to remove attribute\n */\nexport function applyAttribute(selector: AttributeSelector, targetAttributeName: string, options?: AttributeOptions): MethodDecorator & PropertyDecorator;\nexport function applyAttribute(selector: AttributeSelector, options?: AttributeOptions): MethodDecorator & PropertyDecorator;\nexport function applyAttribute(selector: AttributeSelector, targetAttributeNameOrOptions?: string | AttributeOptions, options?: AttributeOptions): MethodDecorator & PropertyDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => {\n // ensureInit(target as any);\n\n const constructor = target.constructor;\n const designType = (Reflect as any).getMetadata('design:type', target, propertyKey);\n const metaType: 'property' | 'method' = descriptor && typeof descriptor.value === 'function' ? 'method' : 'property';\n\n // Parse arguments\n let finalOptions: AttributeOptions = {};\n let targetAttributeName: string;\n\n if (typeof targetAttributeNameOrOptions === 'string') {\n // applyAttribute('selector', 'attrName', options?)\n targetAttributeName = targetAttributeNameOrOptions;\n finalOptions = options || {};\n } else if (targetAttributeNameOrOptions) {\n // applyAttribute('selector', options)\n finalOptions = targetAttributeNameOrOptions;\n targetAttributeName = finalOptions.name || String(propertyKey);\n } else {\n // applyAttribute('selector')\n targetAttributeName = String(propertyKey);\n }\n\n // Store metadata\n let metaList = ReflectUtils.getOwnMetadata(ATTRIBUTE_METADATA_KEY, constructor) as AttributeMetadata[];\n if (!metaList) {\n metaList = [];\n ReflectUtils.defineMetadata(ATTRIBUTE_METADATA_KEY, metaList, constructor);\n }\n metaList.push({\n propertyKey,\n selector: selector as AttributeSelector,\n targetAttributeName,\n options: finalOptions,\n type: metaType\n });\n\n // Helper: Apply resolved value to targets\n const applyValueToTargets = (inst: any, resolvedValue: any) => {\n const conf = getElementConfig(inst);\n const currentWin = conf.window;\n const targetEls = resolveAttributeTargets(inst, selector, finalOptions);\n const hostSet = SwcUtils.getHelperAndHostSet(currentWin, inst);\n\n targetEls.forEach(targetEl => {\n // Apply filter if provided\n if (finalOptions.filter && !finalOptions.filter(targetEl, resolvedValue, {currentThis: inst, helper: hostSet})) {\n return;\n }\n\n if (resolvedValue === null) {\n // Remove attribute if value is null\n targetEl.removeAttribute(targetAttributeName);\n } else if (resolvedValue !== undefined) {\n // Set attribute\n targetEl.setAttribute(targetAttributeName, resolvedValue === true ? '' : String(resolvedValue));\n }\n });\n\n return resolvedValue;\n };\n\n // Method decorator: wrap method to apply its return value to attributes\n if (descriptor && typeof descriptor.value === 'function') {\n const original = descriptor.value;\n descriptor.value = function (...args: any[]) {\n ensureInit(this);\n const res = (original as any).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 ATTRIBUTE_METADATA_KEY.\n * \n * Example:\n * @setAttribute('selector1', { valueKey: 'attr1' })\n * @setAttribute('selector2', { valueKey: 'attr2' })\n * myMethod() {\n * return {\n * attr1: 'attribute-value1',\n * attr2: 'attribute-value2'\n * };\n * }\n * \n * First decorator will use 'attribute-value1', second will use 'attribute-value2'\n */\n const extractValue = (v: any) => {\n const keyToUse = finalOptions.valueKey ?? ATTRIBUTE_METADATA_KEY;\n if (v && typeof v === 'object' && keyToUse in v) {\n return v[keyToUse];\n }\n return v;\n };\n\n if (res instanceof Promise) {\n return res.then((v: any) => {\n const extracted = extractValue(v);\n applyValueToTargets(this, extracted);\n return v;\n });\n } else {\n const extracted = extractValue(res);\n applyValueToTargets(this, extracted);\n return res;\n }\n };\n return;\n }\n\n // Property decorator: define getter/setter to proxy to element attributes\n Object.defineProperty(target, propertyKey, {\n configurable: true,\n enumerable: true,\n get(this: any) {\n ensureInit(this);\n const mergedOptions = {...finalOptions, selector, type: finalOptions.type || designType};\n return getAttributeValue(this, targetAttributeName, mergedOptions);\n },\n set(this: any, value: any) {\n ensureInit(this);\n\n if (value instanceof Promise) {\n value.then((v: any) => applyValueToTargets(this, v)).catch(() => { /* swallow */\n });\n } else {\n applyValueToTargets(this, value);\n }\n }\n });\n };\n}\n\n// ============================================\n// Convenience Aliases\n// ============================================\n\n/**\n * @attribute - Field decorator for binding element attributes (read/write)\n * \n * Intelligently distinguishes between attribute names and CSS selectors:\n * \n * Usage patterns:\n * - @attribute('product-id') - Attribute name on $this (auto-detected)\n * - @attribute('#user', 'product-id') - Attribute name on selector\n * - @attribute('product-id', options) - Attribute name on $this with options\n * - @attribute('#user', 'product-id', options) - Attribute name on selector with options\n * - @attribute((this, helper) => 'selector', 'product-id') - Function-based selector\n * - @attribute - Bare decorator (uses property name as attribute on $this)\n * \n * Note: This decorator is for FIELDS ONLY. For methods, use @setAttribute.\n */\nexport function attribute(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;\nexport function attribute(attributeName: string, options?: AttributeOptions): PropertyDecorator;\nexport function attribute(selector: AttributeSelector, attributeName: string, options?: AttributeOptions): PropertyDecorator;\nexport function attribute(selectorOrAttributeOrTarget?: AttributeSelector | Object, attributeNameOrOptions?: any, optionsOrDescriptor?: any): any {\n // Bare decorator: @attribute\n if (optionsOrDescriptor !== undefined && (typeof attributeNameOrOptions === 'string' || typeof attributeNameOrOptions === 'symbol')) {\n return applyAttribute('$this', undefined as any, {})(selectorOrAttributeOrTarget as Object, attributeNameOrOptions, optionsOrDescriptor as PropertyDescriptor);\n }\n \n // With string as first parameter\n if (typeof selectorOrAttributeOrTarget === 'string') {\n // Check if first parameter is a CSS selector or attribute name\n const isSelector = isCssSelector(selectorOrAttributeOrTarget);\n \n if (isSelector) {\n // First param is a selector: @attribute('#user', 'product-id', options?)\n return applyAttribute(selectorOrAttributeOrTarget, attributeNameOrOptions as any, optionsOrDescriptor as AttributeOptions);\n } else {\n // First param is an attribute name: @attribute('product-id', options?)\n // Treat as attribute name on $this\n const options = (typeof attributeNameOrOptions === 'object' && attributeNameOrOptions !== null) \n ? attributeNameOrOptions \n : {};\n return applyAttribute('$this', selectorOrAttributeOrTarget, options);\n }\n }\n \n // Without selector (defaults to $this with options)\n return applyAttribute('$this', undefined as any, selectorOrAttributeOrTarget as AttributeOptions);\n}\n\n/**\n * @setAttribute - Method decorator for setting element attributes from method return value\n * \n * Intelligently distinguishes between attribute names and CSS selectors:\n * \n * Usage patterns:\n * - @setAttribute('data-id') - Attribute name on $this (auto-detected)\n * - @setAttribute('#user', 'data-id') - Attribute name on selector\n * - @setAttribute('data-id', options) - Attribute name on $this with options\n * - @setAttribute('#user', 'data-id', options) - Attribute name on selector with options\n * - @setAttribute((this, helper) => 'selector', 'data-id') - Function-based selector\n * - @setAttribute - Bare decorator (uses method name as attribute on $this)\n * \n * Note: This decorator is for METHODS ONLY. For fields, use @attribute.\n * \n * Example:\n * @setAttribute('data-status')\n * updateStatus() {\n * return 'active';\n * }\n */\nexport function setAttribute(selector: AttributeSelector, attributeName: string, options?: AttributeOptions): MethodDecorator;\nexport function setAttribute(attributeName: string, options?: AttributeOptions): MethodDecorator;\nexport function setAttribute(selectorOrAttributeOrOptions?: AttributeSelector | AttributeOptions, attributeNameOrOptions?: any, optionsOrUndefined?: AttributeOptions): MethodDecorator {\n // With string as first parameter\n if (typeof selectorOrAttributeOrOptions === 'string') {\n // Check if first parameter is a CSS selector or attribute name\n const isSelector = isCssSelector(selectorOrAttributeOrOptions);\n \n if (isSelector) {\n // First param is a selector: @setAttribute('#user', 'data-id', options?)\n return applyAttribute(selectorOrAttributeOrOptions, attributeNameOrOptions as any, optionsOrUndefined as AttributeOptions) as MethodDecorator;\n } else {\n // First param is an attribute name: @setAttribute('data-id', options?)\n // Treat as attribute name on $this\n const options = (typeof attributeNameOrOptions === 'object' && attributeNameOrOptions !== null) \n ? attributeNameOrOptions \n : {};\n return applyAttribute('$this', selectorOrAttributeOrOptions, options) as MethodDecorator;\n }\n }\n \n // Without selector (defaults to $this with options)\n return applyAttribute('$this', undefined as any, selectorOrAttributeOrOptions as AttributeOptions) as MethodDecorator;\n}\n\n// ============================================\n// Metadata Helpers\n// ============================================\n\nexport const findAllAttributeMetadata = (target: any): AttributeMetadata[] => {\n const actualTarget = target instanceof Function ? target : target.constructor;\n return ReflectUtils.findAllMetadata<AttributeMetadata[]>(ATTRIBUTE_METADATA_KEY, actualTarget).flat();\n};\n\n// Backward compatibility alias\nexport const findAllAttributeApplyMetadata = (target: any): Map<string | symbol, AttributeMetadata> => {\n const result = new Map<string | symbol, AttributeMetadata>();\n findAllAttributeMetadata(target).forEach(meta => {\n result.set(meta.propertyKey, meta);\n });\n return result;\n};\n\n\nexport default applyAttribute;\n"],
|
|
5
|
-
"mappings": "AAAA,SAAQ,cAAc,eAAe,wBAAuB;AAC5D,SAAQ,YAAY,wBAAuB;AAC3C,SAAQ,gBAAe;AAEvB,SAAQ,oBAAmB;AAgDpB,MAAM,yBAAyB,OAAO,IAAI,gCAAgC;AAqBjF,MAAM,gBAAgB,CAAC,QAAyB;AAC9C,MAAI,CAAC,IAAK,QAAO;AAGjB,MAAI,IAAI,WAAW,GAAG,EAAG,QAAO;AAGhC,MAAI,eAAe,KAAK,GAAG,EAAG,QAAO;AAGrC,MAAI,aAAa,KAAK,GAAG,EAAG,QAAO;AAEnC,SAAO;AACT;AAEA,MAAM,eAAe,CAAC,KAAoB,SAAmB;AAC3D,MAAI,QAAQ,QAAQ,QAAQ,OAAW,QAAO;AAC9C,MAAI,SAAS,OAA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AAA,QACT;AAAA,MACF;AACA;AAAA,IACF;AAGA,WAAO,eAAe,QAAQ,aAAa;AAAA,MACzC,cAAc;AAAA,MACd,YAAY;AAAA,MACZ,MAAe;AACb,mBAAW,IAAI;AACf,cAAM,gBAAgB,EAAC,GAAG,cAAc,UAAU,MAAM,aAAa,QAAQ,WAAU;AACvF,eAAO,kBAAkB,MAAM,qBAAqB,aAAa;AAAA,MACnE;AAAA,MACA,IAAe,OAAY;AACzB,mBAAW,IAAI;AAEf,YAAI,iBAAiB,SAAS;AAC5B,gBAAM,KAAK,CAAC,MAAW,oBAAoB,MAAM,CAAC,CAAC,EAAE,MAAM,MAAM;AAAA,UACjE,CAAC;AAAA,QACH,OAAO;AACL,8BAAoB,MAAM,KAAK;AAAA,QACjC;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH;AACF;
|
|
4
|
+
"sourcesContent": ["import {ReflectUtils, FunctionUtils, ActionExpression} from '@dooboostore/core';\nimport {ensureInit, getElementConfig} from './elementDefine';\nimport {SwcUtils} from '../utils/Utils';\nimport {SwcQueryOptions, HelperHostSet} from '../types';\nimport {ConvertUtils} from '@dooboostore/core-web';\n\n// ============================================\n// Types & Interfaces\n// ============================================\n\nexport interface AttributeOptions extends SwcQueryOptions {\n name?: string;\n type?: typeof Number | typeof Boolean | typeof String;\n filter?: (target: HTMLElement, value: any, meta: { currentThis: any, helper: HelperHostSet }) => boolean;\n /**\n * Custom key to extract value from return object.\n * If not provided, uses ATTRIBUTE_METADATA_KEY by default.\n * Useful when multiple @setAttribute decorators are on the same method.\n * \n * Example:\n * @setAttribute('selector1', { valueKey: 'attr1' })\n * @setAttribute('selector2', { valueKey: 'attr2' })\n * myMethod() {\n * return {\n * attr1: 'value1',\n * attr2: 'value2'\n * };\n * }\n * \n * Or with symbols:\n * @setAttribute('selector1', { valueKey: Symbol.for('attr1') })\n * @setAttribute('selector2', { valueKey: Symbol.for('attr2') })\n * myMethod() {\n * return {\n * [Symbol.for('attr1')]: 'value1',\n * [Symbol.for('attr2')]: 'value2'\n * };\n * }\n */\n valueKey?: symbol | string;\n}\n\nexport type AttributeSelector = string | ((currentThis: any, helper: HelperHostSet) => NodeList | Element | Element[] | null);\n\nexport interface AttributeMetadata {\n propertyKey: string | symbol;\n selector: AttributeSelector;\n targetAttributeName: string;\n options: AttributeOptions;\n type: 'property' | 'method';\n}\n\nexport const ATTRIBUTE_METADATA_KEY = Symbol.for('simple-web-component:attribute');\n\n// ============================================\n// Utilities\n// ============================================\n\n/**\n * Determine if a string is a CSS selector or an attribute name\n * \n * CSS selectors typically:\n * - Start with: #, ., [, :, >, +, ~\n * - Contain special chars: >, +, ~, :, [, ]\n * - Are special keywords: $this, $host, $parentHost, etc.\n * \n * Attribute names are typically:\n * - kebab-case (lowercase with hyphens)\n * - No special selector syntax\n * \n * @param str - String to check\n * @returns true if it's a CSS selector, false if it's an attribute name\n */\nconst isCssSelector = (str: string): boolean => {\n if (!str) return false;\n \n // Special keywords\n if (str.startsWith('$')) return true;\n \n // CSS selector syntax\n if (/^[#.\\[\\:>+~]/.test(str)) return true;\n \n // Contains CSS combinator or pseudo-selector syntax\n if (/[>+~:\\[\\]]/.test(str)) return true;\n \n return false;\n};\n\nconst convertValue = (val: string | null, type: any): any => {\n if (val === null || val === undefined) return val;\n if (type === Number) return Number(val);\n if (type === Boolean) return val === 'false' || val === '0' ? false : true;\n return val;\n};\n\nexport {convertValue};\n\nexport const getAttributeValue = (inst: any, attrName: string, options?: AttributeOptions & { selector?: AttributeSelector }): any => {\n const conf = getElementConfig(inst);\n const currentWin = inst._resolveWindow?.(conf) || ((typeof window !== 'undefined' ? window : undefined) as any);\n\n // If selector is not provided, use inst itself\n const targets = options?.selector ? resolveAttributeTargets(inst, options.selector, options) : [inst];\n\n const primaryTarget = targets[0];\n\n if (primaryTarget && typeof (primaryTarget as any).hasAttribute === 'function' && (primaryTarget as any).hasAttribute(attrName)) {\n let domVal = (primaryTarget as any).getAttribute(attrName);\n\n // \uD45C\uD604\uC2DD \uCCB4\uD06C\n const ae = new ActionExpression(domVal);\n const expr = ae.getFirstExpression('callReturn');\n if (expr) {\n try {\n const result = FunctionUtils.executeReturn({\n script: ConvertUtils.decodeHtmlEntity(expr.script, currentWin.document),\n context: inst,\n args: SwcUtils.getHelperAndHostSet(currentWin, inst)\n });\n return convertValue(result, options?.type);\n } catch (err) {\n console.error(`[SWC] Failed to execute directive {{= ${expr.script} }}:`, err);\n return convertValue(domVal, options?.type);\n }\n }\n\n return convertValue(domVal, options?.type);\n }\n\n // If no target found, return null\n return null;\n};\n\n/**\n * Resolve target elements based on selector and options\n * Handles special selectors ($this, $host, etc.), CSS selectors, and function-based selectors\n * Returns HTMLElement[] for attribute operations\n */\nexport const resolveAttributeTargets = (inst: any, selector: AttributeSelector, options: AttributeOptions): HTMLElement[] => {\n const conf = getElementConfig(inst);\n const currentWin = conf.window;\n const r = options.root || 'auto';\n const results: HTMLElement[] = [];\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 const hostSet = SwcUtils.getHelperAndHostSet(currentWin, inst);\n resolvedSelector = selector(inst, hostSet);\n }\n\n // If selector function returned elements directly, use them\n if (resolvedSelector instanceof currentWin.Element) {\n results.push(resolvedSelector as HTMLElement);\n return results;\n }\n if (resolvedSelector instanceof currentWin.NodeList) {\n results.push(...(Array.from(resolvedSelector) as HTMLElement[]));\n return results;\n }\n if (Array.isArray(resolvedSelector)) {\n results.push(...(resolvedSelector as HTMLElement[]));\n return results;\n }\n if (resolvedSelector === null) {\n return results;\n }\n\n // Handle string selector\n const stringSelector = resolvedSelector as string;\n\n const applyRoot = (target: any) => {\n if (!target) return;\n if (r === 'auto') {\n results.push(target);\n } else {\n if (r === 'light' || r === 'all') results.push(target);\n if ((r === 'shadow' || r === 'all') && target.shadowRoot) results.push(target.shadowRoot);\n }\n };\n\n if (stringSelector === '$this' || !stringSelector) {\n applyRoot(inst);\n } else {\n const hostSet = SwcUtils.getHostSet(inst);\n if (stringSelector === '$host') applyRoot(hostSet.$host);\n else if (stringSelector === '$parentHost') applyRoot(hostSet.$parentHost);\n else if (stringSelector === '$appHost') applyRoot(hostSet.$appHost as any);\n else if (stringSelector === '$firstHost') applyRoot(hostSet.$firstHost);\n else if (stringSelector === '$lastHost') applyRoot(hostSet.$lastHost);\n else if (stringSelector === '$firstAppHost') applyRoot(hostSet.$firstAppHost as any);\n else if (stringSelector === '$lastAppHost') applyRoot(hostSet.$lastAppHost as any);\n else if (stringSelector === '$hosts') hostSet.$hosts.forEach(applyRoot);\n else if (stringSelector === '$appHosts') hostSet.$appHosts.forEach(applyRoot);\n else {\n if (r === 'shadow') {\n const found = inst.shadowRoot?.querySelectorAll(stringSelector);\n if (found) results.push(...found);\n } else if (r === 'light') {\n const found = inst.querySelectorAll(stringSelector);\n if (found) results.push(...found);\n } else if (r === 'all') {\n const sMatch = inst.shadowRoot?.querySelectorAll(stringSelector);\n const lMatch = inst.querySelectorAll(stringSelector);\n if (sMatch) results.push(...sMatch);\n if (lMatch) results.push(...lMatch);\n } else {\n const found = (inst.shadowRoot || inst).querySelectorAll(stringSelector);\n if (found) results.push(...found);\n }\n }\n }\n return results;\n};\n\n/**\n * @applyAttribute decorator - set/get element attributes\n *\n * Usage:\n * - @applyAttribute('selector', 'attrName') - Set attribute with explicit name\n * - @applyAttribute('selector') - Use property name as attribute name\n * - @applyAttribute('selector', { name: 'attrName' }) - Set attribute via options\n * - @applyAttribute((this, helper) => 'selector', 'attrName') - Function-based selector\n * - Return null to remove attribute\n */\nexport function applyAttribute(selector: AttributeSelector, targetAttributeName: string, options?: AttributeOptions): MethodDecorator & PropertyDecorator;\nexport function applyAttribute(selector: AttributeSelector, options?: AttributeOptions): MethodDecorator & PropertyDecorator;\nexport function applyAttribute(selector: AttributeSelector, targetAttributeNameOrOptions?: string | AttributeOptions, options?: AttributeOptions): MethodDecorator & PropertyDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => {\n // ensureInit(target as any);\n\n const constructor = target.constructor;\n const designType = (Reflect as any).getMetadata('design:type', target, propertyKey);\n const metaType: 'property' | 'method' = descriptor && typeof descriptor.value === 'function' ? 'method' : 'property';\n\n // Parse arguments\n let finalOptions: AttributeOptions = {};\n let targetAttributeName: string;\n\n if (typeof targetAttributeNameOrOptions === 'string') {\n // applyAttribute('selector', 'attrName', options?)\n targetAttributeName = targetAttributeNameOrOptions;\n finalOptions = options || {};\n } else if (targetAttributeNameOrOptions) {\n // applyAttribute('selector', options)\n finalOptions = targetAttributeNameOrOptions;\n targetAttributeName = finalOptions.name || String(propertyKey);\n } else {\n // applyAttribute('selector')\n targetAttributeName = String(propertyKey);\n }\n\n // Store metadata\n let metaList = ReflectUtils.getOwnMetadata(ATTRIBUTE_METADATA_KEY, constructor) as AttributeMetadata[];\n if (!metaList) {\n metaList = [];\n ReflectUtils.defineMetadata(ATTRIBUTE_METADATA_KEY, metaList, constructor);\n }\n metaList.push({\n propertyKey,\n selector: selector as AttributeSelector,\n targetAttributeName,\n options: finalOptions,\n type: metaType\n });\n\n // Helper: Apply resolved value to targets\n const applyValueToTargets = (inst: any, resolvedValue: any) => {\n const conf = getElementConfig(inst);\n const currentWin = conf.window;\n const targetEls = resolveAttributeTargets(inst, selector, finalOptions);\n const hostSet = SwcUtils.getHelperAndHostSet(currentWin, inst);\n\n targetEls.forEach(targetEl => {\n // Apply filter if provided\n if (finalOptions.filter && !finalOptions.filter(targetEl, resolvedValue, {currentThis: inst, helper: hostSet})) {\n return;\n }\n\n if (resolvedValue === null) {\n // Remove attribute if value is null\n targetEl.removeAttribute(targetAttributeName);\n } else if (resolvedValue !== undefined) {\n // Set attribute\n targetEl.setAttribute(targetAttributeName, resolvedValue === true ? '' : String(resolvedValue));\n }\n });\n\n return resolvedValue;\n };\n\n // Method decorator: wrap method to apply its return value to attributes\n if (descriptor && typeof descriptor.value === 'function') {\n const original = descriptor.value;\n descriptor.value = function (...args: any[]) {\n ensureInit(this);\n const res = (original as any).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 ATTRIBUTE_METADATA_KEY.\n * \n * Example:\n * @setAttribute('selector1', { valueKey: 'attr1' })\n * @setAttribute('selector2', { valueKey: 'attr2' })\n * myMethod() {\n * return {\n * attr1: 'attribute-value1',\n * attr2: 'attribute-value2'\n * };\n * }\n * \n * First decorator will use 'attribute-value1', second will use 'attribute-value2'\n */\n const extractValue = (v: any) => {\n const keyToUse = finalOptions.valueKey ?? ATTRIBUTE_METADATA_KEY;\n if (v && typeof v === 'object' && keyToUse in v) {\n return v[keyToUse];\n }\n return v;\n };\n\n if (res instanceof Promise) {\n return res.then((v: any) => {\n const extracted = extractValue(v);\n applyValueToTargets(this, extracted);\n return v;\n });\n } else {\n const extracted = extractValue(res);\n applyValueToTargets(this, extracted);\n return res;\n }\n };\n return;\n }\n\n // Property decorator: define getter/setter to proxy to element attributes\n Object.defineProperty(target, propertyKey, {\n configurable: true,\n enumerable: true,\n get(this: any) {\n ensureInit(this);\n const mergedOptions = {...finalOptions, selector, type: finalOptions.type || designType};\n return getAttributeValue(this, targetAttributeName, mergedOptions);\n },\n set(this: any, value: any) {\n ensureInit(this);\n\n if (value instanceof Promise) {\n value.then((v: any) => applyValueToTargets(this, v)).catch(() => { /* swallow */\n });\n } else {\n applyValueToTargets(this, value);\n }\n }\n });\n };\n}\n\n// ============================================\n// Convenience Aliases\n// ============================================\n\n/**\n * @attribute - Field decorator for binding element attributes (read/write)\n * \n * Intelligently distinguishes between attribute names and CSS selectors:\n * \n * Usage patterns:\n * - @attribute('product-id') - Attribute name on $this (auto-detected)\n * - @attribute('#user', 'product-id') - Attribute name on selector\n * - @attribute('product-id', options) - Attribute name on $this with options\n * - @attribute('#user', 'product-id', options) - Attribute name on selector with options\n * - @attribute((this, helper) => 'selector', 'product-id') - Function-based selector\n * - @attribute - Bare decorator (uses property name as attribute on $this)\n * \n * Note: This decorator is for FIELDS ONLY. For methods, use @setAttribute.\n */\nexport function attribute(target: Object, propertyKey: string | symbol): void;\nexport function attribute(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;\nexport function attribute(attributeName: string, options?: AttributeOptions): PropertyDecorator;\nexport function attribute(selector: AttributeSelector, attributeName: string, options?: AttributeOptions): PropertyDecorator;\nexport function attribute(selectorOrAttributeOrTarget?: AttributeSelector | Object, attributeNameOrOptions?: any, optionsOrDescriptor?: any): any {\n // Bare decorator: @attribute\n if (optionsOrDescriptor !== undefined && (typeof attributeNameOrOptions === 'string' || typeof attributeNameOrOptions === 'symbol')) {\n return applyAttribute('$this', undefined as any, {})(selectorOrAttributeOrTarget as Object, attributeNameOrOptions, optionsOrDescriptor as PropertyDescriptor);\n }\n \n // With string as first parameter\n if (typeof selectorOrAttributeOrTarget === 'string') {\n // Check if first parameter is a CSS selector or attribute name\n const isSelector = isCssSelector(selectorOrAttributeOrTarget);\n \n if (isSelector) {\n // First param is a selector: @attribute('#user', 'product-id', options?)\n return applyAttribute(selectorOrAttributeOrTarget, attributeNameOrOptions as any, optionsOrDescriptor as AttributeOptions);\n } else {\n // First param is an attribute name: @attribute('product-id', options?)\n // Treat as attribute name on $this\n const options = (typeof attributeNameOrOptions === 'object' && attributeNameOrOptions !== null) \n ? attributeNameOrOptions \n : {};\n return applyAttribute('$this', selectorOrAttributeOrTarget, options);\n }\n }\n \n // Without selector (defaults to $this with options)\n return applyAttribute('$this', undefined as any, selectorOrAttributeOrTarget as AttributeOptions);\n}\n\n/**\n * @setAttribute - Method decorator for setting element attributes from method return value\n * \n * Intelligently distinguishes between attribute names and CSS selectors:\n * \n * Usage patterns:\n * - @setAttribute('data-id') - Attribute name on $this (auto-detected)\n * - @setAttribute('#user', 'data-id') - Attribute name on selector\n * - @setAttribute('data-id', options) - Attribute name on $this with options\n * - @setAttribute('#user', 'data-id', options) - Attribute name on selector with options\n * - @setAttribute((this, helper) => 'selector', 'data-id') - Function-based selector\n * - @setAttribute - Bare decorator (uses method name as attribute on $this)\n * \n * Note: This decorator is for METHODS ONLY. For fields, use @attribute.\n * \n * Example:\n * @setAttribute('data-status')\n * updateStatus() {\n * return 'active';\n * }\n */\nexport function setAttribute(selector: AttributeSelector, attributeName: string, options?: AttributeOptions): MethodDecorator;\nexport function setAttribute(attributeName: string, options?: AttributeOptions): MethodDecorator;\nexport function setAttribute(selectorOrAttributeOrOptions?: AttributeSelector | AttributeOptions, attributeNameOrOptions?: any, optionsOrUndefined?: AttributeOptions): MethodDecorator {\n // With string as first parameter\n if (typeof selectorOrAttributeOrOptions === 'string') {\n // Check if first parameter is a CSS selector or attribute name\n const isSelector = isCssSelector(selectorOrAttributeOrOptions);\n \n if (isSelector) {\n // First param is a selector: @setAttribute('#user', 'data-id', options?)\n return applyAttribute(selectorOrAttributeOrOptions, attributeNameOrOptions as any, optionsOrUndefined as AttributeOptions) as MethodDecorator;\n } else {\n // First param is an attribute name: @setAttribute('data-id', options?)\n // Treat as attribute name on $this\n const options = (typeof attributeNameOrOptions === 'object' && attributeNameOrOptions !== null) \n ? attributeNameOrOptions \n : {};\n return applyAttribute('$this', selectorOrAttributeOrOptions, options) as MethodDecorator;\n }\n }\n \n // Without selector (defaults to $this with options)\n return applyAttribute('$this', undefined as any, selectorOrAttributeOrOptions as AttributeOptions) as MethodDecorator;\n}\n\n// ============================================\n// Metadata Helpers\n// ============================================\n\nexport const findAllAttributeMetadata = (target: any): AttributeMetadata[] => {\n const actualTarget = target instanceof Function ? target : target.constructor;\n return ReflectUtils.findAllMetadata<AttributeMetadata[]>(ATTRIBUTE_METADATA_KEY, actualTarget).flat();\n};\n\n// Backward compatibility alias\nexport const findAllAttributeApplyMetadata = (target: any): Map<string | symbol, AttributeMetadata> => {\n const result = new Map<string | symbol, AttributeMetadata>();\n findAllAttributeMetadata(target).forEach(meta => {\n result.set(meta.propertyKey, meta);\n });\n return result;\n};\n\n\nexport default applyAttribute;\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,OAAO,gCAAgC,UAAU;AAEnD,UAAM,aAAa,cAAc,2BAA2B;AAE5D,QAAI,YAAY;AAEd,aAAO,eAAe,6BAA6B,wBAA+B,mBAAuC;AAAA,IAC3H,OAAO;AAGL,YAAM,UAAW,OAAO,2BAA2B,YAAY,2BAA2B,OACtF,yBACA,CAAC;AACL,aAAO,eAAe,SAAS,6BAA6B,OAAO;AAAA,IACrE;AAAA,EACF;AAGA,SAAO,eAAe,SAAS,QAAkB,2BAA+C;AAClG;AAyBO,SAAS,aAAa,8BAAqE,wBAA8B,oBAAwD;AAEtL,MAAI,OAAO,iCAAiC,UAAU;AAEpD,UAAM,aAAa,cAAc,4BAA4B;AAE7D,QAAI,YAAY;AAEd,aAAO,eAAe,8BAA8B,wBAA+B,kBAAsC;AAAA,IAC3H,OAAO;AAGL,YAAM,UAAW,OAAO,2BAA2B,YAAY,2BAA2B,OACtF,yBACA,CAAC;AACL,aAAO,eAAe,SAAS,8BAA8B,OAAO;AAAA,IACtE;AAAA,EACF;AAGA,SAAO,eAAe,SAAS,QAAkB,4BAAgD;AACnG;AAMO,MAAM,2BAA2B,CAAC,WAAqC;AAC5E,QAAM,eAAe,kBAAkB,WAAW,SAAS,OAAO;AAClE,SAAO,aAAa,gBAAqC,wBAAwB,YAAY,EAAE,KAAK;AACtG;AAGO,MAAM,gCAAgC,CAAC,WAAyD;AACrG,QAAM,SAAS,oBAAI,IAAwC;AAC3D,2BAAyB,MAAM,EAAE,QAAQ,UAAQ;AAC/C,WAAO,IAAI,KAAK,aAAa,IAAI;AAAA,EACnC,CAAC;AACD,SAAO;AACT;AAGA,IAAO,yBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -34,7 +34,9 @@ const applyToDom = (currentThis, targetEl, res, pos, win, host) => {
|
|
|
34
34
|
const hostSet = SwcUtils.getHelperAndHostSet(win, currentThis);
|
|
35
35
|
const id = currentThis._swcId;
|
|
36
36
|
const nodes = [];
|
|
37
|
-
if (
|
|
37
|
+
if (res instanceof win.Node) {
|
|
38
|
+
nodes.push(res);
|
|
39
|
+
} else if (typeof res === "string" && pos === "innerHtml") {
|
|
38
40
|
const t = win.document.createElement("template");
|
|
39
41
|
t.innerHTML = res;
|
|
40
42
|
nodes.push(...Array.from(t.content.childNodes));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/decorators/applyNode.ts"],
|
|
4
|
-
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit, getElementConfig } from './elementDefine';\nimport {SpecialSelector, SwcQueryOptions, HelperHostSet, SwcRootType} from '../types';\nimport { SwcUtils} from \"../utils/Utils\";\nimport {findAllStateMetadata} from \"./state\";\nimport {ElementApply} from \"@dooboostore/core-web\";\n/*\n<!-- beforebegin -->\n<p> <-- it's me\n <!-- afterbegin -->\n foo\n <!-- beforeend -->\n</p>\n<!-- afterend -->\n */\nexport type ApplyNodePosition = 'beforeBegin' | 'afterBegin' | 'beforeEnd' | 'afterEnd' | 'replace' | 'replaceChildren' | 'innerHtml' | 'innerText' | 'remove' | 'clearChildren';\n\nexport type ApplyNodeSelector = string | ((currentThis: any, helper: HelperHostSet) => NodeList | Element | Element[] | null);\n\nexport interface ApplyNodeOptions {\n position?: ApplyNodePosition;\n root?: SwcRootType;\n /**\n * Filter function to determine whether to perform DOM operation.\n * If it returns false, the operation is skipped.\n */\n filter?: (target: HTMLElement | ShadowRoot, newValue: any, meta: { currentThis: any, helper: HelperHostSet }) => boolean;\n /**\n * Optional loading content to display while an async method is executing.\n */\n fallback?: (helper: HelperHostSet) => any;\n /**\n * Custom key to extract value from return object.\n * If not provided, uses APPLY_NODE_METADATA_KEY by default.\n * Useful when multiple @applyNode decorators are on the same method.\n */\n valueKey?: symbol | string;\n}\n\nexport interface ApplyNodeMetadata {\n propertyKey: string | symbol;\n selector: ApplyNodeSelector;\n options: ApplyNodeOptions;\n}\n\nexport const APPLY_NODE_METADATA_KEY = Symbol.for('simple-web-component:apply-node');\n\n/**\n * Resolve selector to string or elements\n * Handles function-based selectors and returns elements if applicable\n */\nconst resolveSelector = (selector: ApplyNodeSelector, inst: any, win: Window): string | HTMLElement | null => {\n if (typeof selector === 'function') {\n const hostSet = SwcUtils.getHelperAndHostSet(win, inst);\n const result = selector(inst, hostSet);\n \n if (result instanceof win.Element) {\n return result as HTMLElement;\n }\n if (result instanceof win.NodeList) {\n return result.length > 0 ? (result[0] as HTMLElement) : null;\n }\n if (Array.isArray(result)) {\n return result.length > 0 ? (result[0] as HTMLElement) : null;\n }\n if (result === null) {\n return null;\n }\n // result must be a string at this point\n return result as unknown as string;\n }\n return selector as string;\n};\n\n// const normalizeNodes = (res: any, doc: Document): Node[] => {\n// const items = Array.isArray(res) ? res : [res];\n// return items.map(it => {\n// if (it instanceof Node) return it;\n// return doc.createTextNode(it !== undefined && it !== null ? String(it) : '');\n// });\n// };\n\nconst applyToDom = (currentThis: any, targetEl: HTMLElement, res: Node | string, pos: ApplyNodePosition, win: Window, host?: any) => {\n if (!targetEl) return;\n \n // Handle clearChildren - ignore return value and always clear\n if (pos === 'clearChildren') {\n targetEl.replaceChildren();\n return [];\n }\n \n const doc = win.document;\n const hostSet = SwcUtils.getHelperAndHostSet(win, currentThis);\n const id = currentThis._swcId;\n\n const nodes: Node[] = [];\n\n if (typeof res === 'string' && pos === 'innerHtml') {\n const t = win.document.createElement('template');\n t.innerHTML = res;\n nodes.push(...Array.from(t.content.childNodes));\n } else if (typeof res === 'string' && pos === 'innerText') {\n nodes.push(win.document.createTextNode(res));\n }\n\n SwcUtils.projectProcessHtml(id, nodes, doc);\n\n const isShadowRoot = targetEl instanceof win.ShadowRoot;\n // const nodes = normalizeNodes(res, doc);\n if (pos === 'replace') {\n if (!isShadowRoot) targetEl.replaceWith(...nodes);\n } else if (pos === 'innerHtml') {\n targetEl.replaceChildren(...nodes);\n } else if (pos === 'innerText') {\n targetEl.replaceChildren(...nodes);\n } else if (pos === 'replaceChildren') {\n targetEl.replaceChildren(...nodes);\n } else {\n if (pos === 'beforeEnd') {\n targetEl.append(...nodes)\n }\n else if (pos === 'afterBegin') targetEl.prepend(...nodes);\n else if (pos === 'beforeBegin' && !isShadowRoot) targetEl.before(...nodes);\n else if (pos === 'afterEnd' && !isShadowRoot) targetEl.after(...nodes);\n }\n\n const stateContext: any = {...hostSet};\n findAllStateMetadata(currentThis).forEach(it => {\n stateContext[it.name] = currentThis[it.propertyKey]\n })\n new ElementApply(targetEl, {id: id}).apply({target: 'noInitialized', context: stateContext, bind: currentThis});\n return nodes;\n};\n\n/**\n * @applyNode decorator to surgically add/replace nodes to a target element.\n * \n * Overloads:\n * - applyNode(selector, options) - Apply to specific selector\n * - applyNode(options) - Apply to $this (current element)\n */\nexport function applyNode(selector: ApplyNodeSelector, options?: ApplyNodeOptions): MethodDecorator;\nexport function applyNode(options: ApplyNodeOptions): MethodDecorator;\nexport function applyNode(selectorOrOptions: ApplyNodeSelector | ApplyNodeOptions, maybeOptions?: ApplyNodeOptions): MethodDecorator {\n // Determine selector and options based on overload\n let selector: ApplyNodeSelector;\n let options: ApplyNodeOptions;\n\n if (typeof selectorOrOptions === 'string' || typeof selectorOrOptions === 'function') {\n // First overload: applyNode(selector, options)\n selector = selectorOrOptions;\n options = maybeOptions || {position: 'replaceChildren'};\n } else {\n // Second overload: applyNode(options) - default to $this\n selector = '$this';\n options = selectorOrOptions || {position: 'replaceChildren'};\n }\n\n return (targetObj: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = targetObj.constructor;\n let metaList = ReflectUtils.getOwnMetadata(APPLY_NODE_METADATA_KEY, constructor) as Map<string | symbol, ApplyNodeMetadata>;\n if (!metaList) {\n metaList = new Map<string | symbol, ApplyNodeMetadata>();\n ReflectUtils.defineMetadata(APPLY_NODE_METADATA_KEY, metaList, constructor);\n }\n metaList.set(propertyKey, {propertyKey, selector, options});\n\n const original = descriptor.value;\n descriptor.value = function (...args: any[]) {\n ensureInit(this);\n\n const conf = getElementConfig(this);\n const currentWin = (this as any)._resolveWindow?.(conf) || ((typeof window !== 'undefined' ? window : undefined) as Window);\n const currentDoc = currentWin.document;\n const hostSet = SwcUtils.getHelperAndHostSet(currentWin, this);\n\n const getTarget = () => {\n const r = options.root || 'auto';\n const applyRoot = (t: any) => {\n if (!t) 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 // Resolve selector if it's a function\n const resolved = resolveSelector(selector, this, currentWin);\n \n // If selector function returned an element directly, use it\n if (resolved instanceof currentWin.Element) {\n return applyRoot(resolved);\n }\n if (resolved === null) {\n return null;\n }\n\n // Handle string selector\n const stringSelector = resolved as string;\n\n if (stringSelector === '$this') return applyRoot(this);\n if (stringSelector === '$host') return applyRoot(hostSet.$host);\n if (stringSelector === '$parentHost') return applyRoot(hostSet.$parentHost);\n if (stringSelector === '$appHost') return applyRoot(hostSet.$appHost);\n if (stringSelector === '$firstHost') return applyRoot(hostSet.$firstHost);\n if (stringSelector === '$lastHost') return applyRoot(hostSet.$lastHost);\n\n const targetRoot = applyRoot(this);\n return targetRoot ? targetRoot.querySelector(stringSelector) : null;\n };\n\n const targetEl = getTarget();\n const res = original.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 APPLY_NODE_METADATA_KEY.\n */\n const extractValue = (v: any) => {\n const keyToUse = options.valueKey ?? APPLY_NODE_METADATA_KEY;\n if (v && typeof v === 'object' && keyToUse in v) {\n return v[keyToUse];\n }\n return v;\n };\n\n const runApply = (target: any, val: any) => {\n const pos = options.position || 'beforeEnd';\n // Delegate HTML/node processing to applyToDom which centralizes\n // processing. runApply should not call processHtml itself to avoid\n // duplicate processing.\n const processedVal = val;\n\n // \uC0AC\uC6A9\uC790\uAC00 filter\uB97C \uBA85\uC2DC\uD558\uBA74 \uADF8 \uC870\uAC74\uC73C\uB85C, \uC544\uB2C8\uBA74 \uD56D\uC0C1 \uC801\uC6A9\n if (!options.filter || options.filter(target, processedVal, {currentThis: this, helper: hostSet})) {\n applyToDom(this, target, processedVal, pos, currentWin);\n }\n };\n\n\n const fallbackNodes: Node[] = [];\n if (targetEl && options.fallback) {\n const loadingRes = options.fallback.call(this, hostSet);\n // applyToDom expects a Window as the 4th argument\n fallbackNodes.push(...applyToDom(this, targetEl, loadingRes, options.position || 'beforeEnd', currentWin));\n }\n\n if (res instanceof Promise) {\n return res.then(finalRes => {\n const extracted = extractValue(finalRes);\n fallbackNodes.forEach((it: any)=>it.remove());\n if (extracted !== undefined && targetEl) runApply(targetEl, extracted);\n return finalRes;\n });\n } else {\n const extracted = extractValue(res);\n if (extracted !== undefined && targetEl) runApply(targetEl, extracted);\n return res;\n }\n };\n };\n}\n\n// --- Overloaded convenience functions for common patterns ---\n\n/**\n * @replaceChildrenNode decorator - replaces children of target element\n * \n * Overloads:\n * - replaceChildrenNode(selector, options) - Replace children of specific selector\n * - replaceChildrenNode(options) - Replace children of $this (current element)\n * - @replaceChildrenNode - Bare decorator, replaces children of $this\n */\nexport function replaceChildren(selector: ApplyNodeSelector, options?: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;\nexport function replaceChildren(options: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;\nexport function replaceChildren(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;\nexport function replaceChildren(selectorOrOptions?: ApplyNodeSelector | Omit<ApplyNodeOptions, 'position'> | Object, maybeOptions?: Omit<ApplyNodeOptions, 'position'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {\n // Bare decorator usage: @replaceChildrenNode\n if (descriptor !== undefined && (typeof maybeOptions === 'symbol' || typeof maybeOptions === 'string')) {\n return applyNode({position: 'replaceChildren'})(selectorOrOptions, maybeOptions, descriptor);\n }\n \n if (typeof selectorOrOptions === 'string' || typeof selectorOrOptions === 'function') {\n return applyNode(selectorOrOptions as ApplyNodeSelector, {...maybeOptions as Omit<ApplyNodeOptions, 'position'>, position: 'replaceChildren'});\n }\n return applyNode({...selectorOrOptions as Omit<ApplyNodeOptions, 'position'>, position: 'replaceChildren'});\n}\n\n/**\n * @clearChildrenNode decorator - clears all children of target element\n * \n * Overloads:\n * - clearChildrenNode(selector, options) - Clear children of specific selector\n * - clearChildrenNode(options) - Clear children of $this (current element)\n * - @clearChildrenNode - Bare decorator, clears children of $this\n */\nexport function clearChildrenNode(selector: ApplyNodeSelector, options?: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;\nexport function clearChildrenNode(options?: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;\nexport function clearChildrenNode(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;\nexport function clearChildrenNode(selectorOrOptions?: ApplyNodeSelector | Omit<ApplyNodeOptions, 'position'> | Object, maybeOptions?: Omit<ApplyNodeOptions, 'position'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {\n // Bare decorator usage: @clearChildrenNode\n if (descriptor !== undefined && (typeof maybeOptions === 'symbol' || typeof maybeOptions === 'string')) {\n return applyNode({position: 'clearChildren'})(selectorOrOptions, maybeOptions, descriptor);\n }\n \n if (typeof selectorOrOptions === 'string' || typeof selectorOrOptions === 'function') {\n return applyNode(selectorOrOptions as ApplyNodeSelector, {...maybeOptions as Omit<ApplyNodeOptions, 'position'>, position: 'clearChildren'});\n }\n return applyNode({...selectorOrOptions as Omit<ApplyNodeOptions, 'position'>, position: 'clearChildren'});\n}\n\n// Alias for clearChildrenNode\nexport const clearNode = clearChildrenNode;\n\n/**\n * @innerHtmlNode decorator - sets innerHTML of target element\n * \n * Overloads:\n * - innerHtmlNode(selector, options) - Set innerHTML of specific selector\n * - innerHtmlNode(options) - Set innerHTML of $this (current element)\n * - @innerHtmlNode - Bare decorator, sets innerHTML of $this\n */\nexport function innerHtml(selector: ApplyNodeSelector, options?: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;\nexport function innerHtml(options?: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;\nexport function innerHtml(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;\nexport function innerHtml(selectorOrOptions?: ApplyNodeSelector | Omit<ApplyNodeOptions, 'position'> | Object, maybeOptions?: Omit<ApplyNodeOptions, 'position'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {\n // Bare decorator usage: @innerHtmlNode\n if (descriptor !== undefined && (typeof maybeOptions === 'symbol' || typeof maybeOptions === 'string')) {\n return applyNode({position: 'innerHtml'})(selectorOrOptions, maybeOptions, descriptor);\n }\n \n if (typeof selectorOrOptions === 'string' || typeof selectorOrOptions === 'function') {\n return applyNode(selectorOrOptions as ApplyNodeSelector, {...maybeOptions as Omit<ApplyNodeOptions, 'position'>, position: 'innerHtml'});\n }\n return applyNode({...selectorOrOptions as Omit<ApplyNodeOptions, 'position'>, position: 'innerHtml'});\n}\n\n// Alias for innerHtmlNode\n// export const setHtmlNode = innerHtml;\n\n/**\n * @innerHtmlLightNode decorator - sets innerHTML of light DOM element\n * \n * Overloads:\n * - innerHtmlLightNode(selector, options) - Set innerHTML of specific selector in light DOM\n * - innerHtmlLightNode(options) - Set innerHTML of $this in light DOM\n * - @innerHtmlLightNode - Bare decorator, sets innerHTML of $this in light DOM\n */\nexport function innerHtmlLight(selector: ApplyNodeSelector, options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;\nexport function innerHtmlLight(options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;\nexport function innerHtmlLight(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;\nexport function innerHtmlLight(selectorOrOptions?: ApplyNodeSelector | Omit<ApplyNodeOptions, 'position' | 'root'> | Object, maybeOptions?: Omit<ApplyNodeOptions, 'position' | 'root'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {\n // Bare decorator usage: @innerHtmlLightNode\n if (descriptor !== undefined && (typeof maybeOptions === 'symbol' || typeof maybeOptions === 'string')) {\n return applyNode({position: 'innerHtml', root: 'light'})(selectorOrOptions, maybeOptions, descriptor);\n }\n \n if (typeof selectorOrOptions === 'string' || typeof selectorOrOptions === 'function') {\n return applyNode(selectorOrOptions as ApplyNodeSelector, {...maybeOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'innerHtml', root: 'light'});\n }\n return applyNode({...selectorOrOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'innerHtml', root: 'light'});\n}\n\n\n/**\n * @innerHtmlShadowNode decorator - sets innerHTML of shadow DOM element\n * \n * Overloads:\n * - innerHtmlShadowNode(selector, options) - Set innerHTML of specific selector in shadow DOM\n * - innerHtmlShadowNode(options) - Set innerHTML of $this in shadow DOM\n * - @innerHtmlShadowNode - Bare decorator, sets innerHTML of $this in shadow DOM\n */\nexport function innerHtmlShadow(selector: ApplyNodeSelector, options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;\nexport function innerHtmlShadow(options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;\nexport function innerHtmlShadow(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;\nexport function innerHtmlShadow(selectorOrOptions?: ApplyNodeSelector | Omit<ApplyNodeOptions, 'position' | 'root'> | Object, maybeOptions?: Omit<ApplyNodeOptions, 'position' | 'root'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {\n // Bare decorator usage: @innerHtmlShadowNode\n if (descriptor !== undefined && (typeof maybeOptions === 'symbol' || typeof maybeOptions === 'string')) {\n return applyNode({position: 'innerHtml', root: 'shadow'})(selectorOrOptions, maybeOptions, descriptor);\n }\n \n if (typeof selectorOrOptions === 'string' || typeof selectorOrOptions === 'function') {\n return applyNode(selectorOrOptions as ApplyNodeSelector, {...maybeOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'innerHtml', root: 'shadow'});\n }\n return applyNode({...selectorOrOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'innerHtml', root: 'shadow'});\n}\n\n\n/**\n * @innerTextNode decorator - sets innerText of target element\n * \n * Overloads:\n * - innerTextNode(selector, options) - Set innerText of specific selector\n * - innerTextNode(options) - Set innerText of $this (current element)\n * - @innerTextNode - Bare decorator, sets innerText of $this\n */\nexport function innerText(selector: ApplyNodeSelector, options?: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;\nexport function innerText(options?: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;\nexport function innerText(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;\nexport function innerText(selectorOrOptions?: ApplyNodeSelector | Omit<ApplyNodeOptions, 'position'> | Object, maybeOptions?: Omit<ApplyNodeOptions, 'position'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {\n // Bare decorator usage: @innerTextNode\n if (descriptor !== undefined && (typeof maybeOptions === 'symbol' || typeof maybeOptions === 'string')) {\n return applyNode({position: 'innerText'})(selectorOrOptions, maybeOptions, descriptor);\n }\n \n if (typeof selectorOrOptions === 'string' || typeof selectorOrOptions === 'function') {\n return applyNode(selectorOrOptions as ApplyNodeSelector, {...maybeOptions as Omit<ApplyNodeOptions, 'position'>, position: 'innerText'});\n }\n return applyNode({...selectorOrOptions as Omit<ApplyNodeOptions, 'position'>, position: 'innerText'});\n}\n\n\n/**\n * @innerTextLightNode decorator - sets innerText of light DOM element\n * \n * Overloads:\n * - innerTextLightNode(selector, options) - Set innerText of specific selector in light DOM\n * - innerTextLightNode(options) - Set innerText of $this in light DOM\n * - @innerTextLightNode - Bare decorator, sets innerText of $this in light DOM\n */\nexport function innerTextLight(selector: ApplyNodeSelector, options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;\nexport function innerTextLight(options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;\nexport function innerTextLight(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;\nexport function innerTextLight(selectorOrOptions?: ApplyNodeSelector | Omit<ApplyNodeOptions, 'position' | 'root'> | Object, maybeOptions?: Omit<ApplyNodeOptions, 'position' | 'root'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {\n // Bare decorator usage: @innerTextLightNode\n if (descriptor !== undefined && (typeof maybeOptions === 'symbol' || typeof maybeOptions === 'string')) {\n return applyNode({position: 'innerText', root: 'light'})(selectorOrOptions, maybeOptions, descriptor);\n }\n \n if (typeof selectorOrOptions === 'string' || typeof selectorOrOptions === 'function') {\n return applyNode(selectorOrOptions as ApplyNodeSelector, {...maybeOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'innerText', root: 'light'});\n }\n return applyNode({...selectorOrOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'innerText', root: 'light'});\n}\n\n/**\n * @innerTextShadowNode decorator - sets innerText of shadow DOM element\n * \n * Overloads:\n * - innerTextShadowNode(selector, options) - Set innerText of specific selector in shadow DOM\n * - innerTextShadowNode(options) - Set innerText of $this in shadow DOM\n * - @innerTextShadowNode - Bare decorator, sets innerText of $this in shadow DOM\n */\nexport function innerTextShadow(selector: ApplyNodeSelector, options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;\nexport function innerTextShadow(options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;\nexport function innerTextShadow(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;\nexport function innerTextShadow(selectorOrOptions?: ApplyNodeSelector | Omit<ApplyNodeOptions, 'position' | 'root'> | Object, maybeOptions?: Omit<ApplyNodeOptions, 'position' | 'root'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {\n // Bare decorator usage: @innerTextShadowNode\n if (descriptor !== undefined && (typeof maybeOptions === 'symbol' || typeof maybeOptions === 'string')) {\n return applyNode({position: 'innerText', root: 'shadow'})(selectorOrOptions, maybeOptions, descriptor);\n }\n \n if (typeof selectorOrOptions === 'string' || typeof selectorOrOptions === 'function') {\n return applyNode(selectorOrOptions as ApplyNodeSelector, {...maybeOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'innerText', root: 'shadow'});\n }\n return applyNode({...selectorOrOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'innerText', root: 'shadow'});\n}\n\n/**\n * @beforeEndNode decorator - appends nodes to target element\n * \n * Overloads:\n * - beforeEndNode(selector, options) - Append to specific selector\n * - beforeEndNode(options) - Append to $this (current element)\n * - @beforeEndNode - Bare decorator, appends to $this\n */\nexport function insertBeforeEnd(selector: ApplyNodeSelector, options?: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;\nexport function insertBeforeEnd(options?: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;\nexport function insertBeforeEnd(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;\nexport function insertBeforeEnd(selectorOrOptions?: ApplyNodeSelector | Omit<ApplyNodeOptions, 'position'> | Object, maybeOptions?: Omit<ApplyNodeOptions, 'position'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {\n // Bare decorator usage: @beforeEndNode\n if (descriptor !== undefined && (typeof maybeOptions === 'symbol' || typeof maybeOptions === 'string')) {\n return applyNode({position: 'beforeEnd'})(selectorOrOptions, maybeOptions, descriptor);\n }\n \n if (typeof selectorOrOptions === 'string' || typeof selectorOrOptions === 'function') {\n return applyNode(selectorOrOptions as ApplyNodeSelector, {...maybeOptions as Omit<ApplyNodeOptions, 'position'>, position: 'beforeEnd'});\n }\n return applyNode({...selectorOrOptions as Omit<ApplyNodeOptions, 'position'>, position: 'beforeEnd'});\n}\n\n\n/**\n * @beforeEndLightNode decorator - appends nodes to light DOM element\n * \n * Overloads:\n * - beforeEndLightNode(selector, options) - Append to specific selector in light DOM\n * - beforeEndLightNode(options) - Append to $this in light DOM\n * - @beforeEndLightNode - Bare decorator, appends to $this in light DOM\n */\nexport function insertBeforeEndLight(selector: ApplyNodeSelector, options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;\nexport function insertBeforeEndLight(options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;\nexport function insertBeforeEndLight(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;\nexport function insertBeforeEndLight(selectorOrOptions?: ApplyNodeSelector | Omit<ApplyNodeOptions, 'position' | 'root'> | Object, maybeOptions?: Omit<ApplyNodeOptions, 'position' | 'root'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {\n // Bare decorator usage: @beforeEndLightNode\n if (descriptor !== undefined && (typeof maybeOptions === 'symbol' || typeof maybeOptions === 'string')) {\n return applyNode({position: 'beforeEnd', root: 'light'})(selectorOrOptions, maybeOptions, descriptor);\n }\n \n if (typeof selectorOrOptions === 'string' || typeof selectorOrOptions === 'function') {\n return applyNode(selectorOrOptions as ApplyNodeSelector, {...maybeOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'beforeEnd', root: 'light'});\n }\n return applyNode({...selectorOrOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'beforeEnd', root: 'light'});\n}\n\n\n/**\n * @beforeEndShadowNode decorator - appends nodes to shadow DOM element\n * \n * Overloads:\n * - beforeEndShadowNode(selector, options) - Append to specific selector in shadow DOM\n * - beforeEndShadowNode(options) - Append to $this in shadow DOM\n * - @beforeEndShadowNode - Bare decorator, appends to $this in shadow DOM\n */\nexport function insertBeforeEndShadow(selector: ApplyNodeSelector, options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;\nexport function insertBeforeEndShadow(options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;\nexport function insertBeforeEndShadow(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;\nexport function insertBeforeEndShadow(selectorOrOptions?: ApplyNodeSelector | Omit<ApplyNodeOptions, 'position' | 'root'> | Object, maybeOptions?: Omit<ApplyNodeOptions, 'position' | 'root'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {\n // Bare decorator usage: @beforeEndShadowNode\n if (descriptor !== undefined && (typeof maybeOptions === 'symbol' || typeof maybeOptions === 'string')) {\n return applyNode({position: 'beforeEnd', root: 'shadow'})(selectorOrOptions, maybeOptions, descriptor);\n }\n \n if (typeof selectorOrOptions === 'string' || typeof selectorOrOptions === 'function') {\n return applyNode(selectorOrOptions as ApplyNodeSelector, {...maybeOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'beforeEnd', root: 'shadow'});\n }\n return applyNode({...selectorOrOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'beforeEnd', root: 'shadow'});\n}\n\n\n/**\n * @afterBeginNode decorator - prepends nodes to target element\n * \n * Overloads:\n * - afterBeginNode(selector, options) - Prepend to specific selector\n * - afterBeginNode(options) - Prepend to $this (current element)\n * - @afterBeginNode - Bare decorator, prepends to $this\n */\nexport function insertAfterBegin(selector: ApplyNodeSelector, options?: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;\nexport function insertAfterBegin(options?: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;\nexport function insertAfterBegin(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;\nexport function insertAfterBegin(selectorOrOptions?: ApplyNodeSelector | Omit<ApplyNodeOptions, 'position'> | Object, maybeOptions?: Omit<ApplyNodeOptions, 'position'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {\n // Bare decorator usage: @afterBeginNode\n if (descriptor !== undefined && (typeof maybeOptions === 'symbol' || typeof maybeOptions === 'string')) {\n return applyNode({position: 'afterBegin'})(selectorOrOptions, maybeOptions, descriptor);\n }\n \n if (typeof selectorOrOptions === 'string' || typeof selectorOrOptions === 'function') {\n return applyNode(selectorOrOptions as ApplyNodeSelector, {...maybeOptions as Omit<ApplyNodeOptions, 'position'>, position: 'afterBegin'});\n }\n return applyNode({...selectorOrOptions as Omit<ApplyNodeOptions, 'position'>, position: 'afterBegin'});\n}\n\n\n/**\n * @afterBeginLightNode decorator - prepends nodes to light DOM element\n * \n * Overloads:\n * - afterBeginLightNode(selector, options) - Prepend to specific selector in light DOM\n * - afterBeginLightNode(options) - Prepend to $this in light DOM\n * - @afterBeginLightNode - Bare decorator, prepends to $this in light DOM\n */\nexport function insertAfterBeginLight(selector: ApplyNodeSelector, options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;\nexport function insertAfterBeginLight(options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;\nexport function insertAfterBeginLight(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;\nexport function insertAfterBeginLight(selectorOrOptions?: ApplyNodeSelector | Omit<ApplyNodeOptions, 'position' | 'root'> | Object, maybeOptions?: Omit<ApplyNodeOptions, 'position' | 'root'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {\n // Bare decorator usage: @afterBeginLightNode\n if (descriptor !== undefined && (typeof maybeOptions === 'symbol' || typeof maybeOptions === 'string')) {\n return applyNode({position: 'afterBegin', root: 'light'})(selectorOrOptions, maybeOptions, descriptor);\n }\n \n if (typeof selectorOrOptions === 'string' || typeof selectorOrOptions === 'function') {\n return applyNode(selectorOrOptions as ApplyNodeSelector, {...maybeOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'afterBegin', root: 'light'});\n }\n return applyNode({...selectorOrOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'afterBegin', root: 'light'});\n}\n\n\n/**\n * @replaceChildrenLightNode decorator - replaces children of light DOM element\n * \n * Overloads:\n * - replaceChildrenLightNode(selector, options) - Replace children of specific selector in light DOM\n * - replaceChildrenLightNode(options) - Replace children of $this in light DOM\n * - @replaceChildrenLightNode - Bare decorator, replaces children of $this in light DOM\n */\nexport function replaceChildrenLight(selector: ApplyNodeSelector, options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;\nexport function replaceChildrenLight(options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;\nexport function replaceChildrenLight(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;\nexport function replaceChildrenLight(selectorOrOptions?: ApplyNodeSelector | Omit<ApplyNodeOptions, 'position' | 'root'> | Object, maybeOptions?: Omit<ApplyNodeOptions, 'position' | 'root'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {\n // Bare decorator usage: @replaceChildrenLightNode\n if (descriptor !== undefined && (typeof maybeOptions === 'symbol' || typeof maybeOptions === 'string')) {\n return applyNode({position: 'replaceChildren', root: 'light'})(selectorOrOptions, maybeOptions, descriptor);\n }\n \n if (typeof selectorOrOptions === 'string' || typeof selectorOrOptions === 'function') {\n return applyNode(selectorOrOptions as ApplyNodeSelector, {...maybeOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'replaceChildren', root: 'light'});\n }\n return applyNode({...selectorOrOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'replaceChildren', root: 'light'});\n}\n\n/**\n * @clearChildrenLightNode decorator - clears children of light DOM element\n * \n * Overloads:\n * - clearChildrenLightNode(selector, options) - Clear children of specific selector in light DOM\n * - clearChildrenLightNode(options) - Clear children of $this in light DOM\n * - @clearChildrenLightNode - Bare decorator, clears children of $this in light DOM\n */\nexport function clearChildrenLight(selector: ApplyNodeSelector, options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;\nexport function clearChildrenLight(options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;\nexport function clearChildrenLight(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;\nexport function clearChildrenLight(selectorOrOptions?: ApplyNodeSelector | Omit<ApplyNodeOptions, 'position' | 'root'> | Object, maybeOptions?: Omit<ApplyNodeOptions, 'position' | 'root'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {\n // Bare decorator usage: @clearChildrenLightNode\n if (descriptor !== undefined && (typeof maybeOptions === 'symbol' || typeof maybeOptions === 'string')) {\n return applyNode({position: 'clearChildren', root: 'light'})(selectorOrOptions, maybeOptions, descriptor);\n }\n \n if (typeof selectorOrOptions === 'string' || typeof selectorOrOptions === 'function') {\n return applyNode(selectorOrOptions as ApplyNodeSelector, {...maybeOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'clearChildren', root: 'light'});\n }\n return applyNode({...selectorOrOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'clearChildren', root: 'light'});\n}\n\n\n\n\nexport const findAllApplyNodeMetadata = (target: any): Map<string | symbol, ApplyNodeMetadata> => {\n const result = new Map<string | symbol, ApplyNodeMetadata>();\n const maps = ReflectUtils.findAllMetadata<Map<string | symbol, ApplyNodeMetadata>>(APPLY_NODE_METADATA_KEY, target);\n maps.forEach(map => {\n if (map instanceof Map) {\n map.forEach((v, k) => result.set(k, v));\n }\n });\n return result;\n};"],
|
|
5
|
-
"mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,YAAY,wBAAwB;AAE7C,SAAS,gBAAe;AACxB,SAAQ,4BAA2B;AACnC,SAAQ,oBAAmB;AAwCpB,MAAM,0BAA0B,OAAO,IAAI,iCAAiC;AAMnF,MAAM,kBAAkB,CAAC,UAA6B,MAAW,QAA6C;AAC5G,MAAI,OAAO,aAAa,YAAY;AAClC,UAAM,UAAU,SAAS,oBAAoB,KAAK,IAAI;AACtD,UAAM,SAAS,SAAS,MAAM,OAAO;AAErC,QAAI,kBAAkB,IAAI,SAAS;AACjC,aAAO;AAAA,IACT;AACA,QAAI,kBAAkB,IAAI,UAAU;AAClC,aAAO,OAAO,SAAS,IAAK,OAAO,CAAC,IAAoB;AAAA,IAC1D;AACA,QAAI,MAAM,QAAQ,MAAM,GAAG;AACzB,aAAO,OAAO,SAAS,IAAK,OAAO,CAAC,IAAoB;AAAA,IAC1D;AACA,QAAI,WAAW,MAAM;AACnB,aAAO;AAAA,IACT;AAEA,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAUA,MAAM,aAAa,CAAC,aAAkB,UAAuB,KAAoB,KAAwB,KAAa,SAAe;AACnI,MAAI,CAAC,SAAU;AAGf,MAAI,QAAQ,iBAAiB;AAC3B,aAAS,gBAAgB;AACzB,WAAO,CAAC;AAAA,EACV;AAEA,QAAM,MAAM,IAAI;AAChB,QAAM,UAAU,SAAS,oBAAoB,KAAK,WAAW;AAC7D,QAAM,KAAK,YAAY;AAEvB,QAAM,QAAgB,CAAC;AAEvB,MAAI,OAAO,QAAQ,YAAY,QAAQ,aAAa;
|
|
4
|
+
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit, getElementConfig } from './elementDefine';\nimport {SpecialSelector, SwcQueryOptions, HelperHostSet, SwcRootType} from '../types';\nimport { SwcUtils} from \"../utils/Utils\";\nimport {findAllStateMetadata} from \"./state\";\nimport {ElementApply} from \"@dooboostore/core-web\";\n/*\n<!-- beforebegin -->\n<p> <-- it's me\n <!-- afterbegin -->\n foo\n <!-- beforeend -->\n</p>\n<!-- afterend -->\n */\nexport type ApplyNodePosition = 'beforeBegin' | 'afterBegin' | 'beforeEnd' | 'afterEnd' | 'replace' | 'replaceChildren' | 'innerHtml' | 'innerText' | 'remove' | 'clearChildren';\n\nexport type ApplyNodeSelector = string | ((currentThis: any, helper: HelperHostSet) => NodeList | Element | Element[] | null);\n\nexport interface ApplyNodeOptions {\n position?: ApplyNodePosition;\n root?: SwcRootType;\n /**\n * Filter function to determine whether to perform DOM operation.\n * If it returns false, the operation is skipped.\n */\n filter?: (target: HTMLElement | ShadowRoot, newValue: any, meta: { currentThis: any, helper: HelperHostSet }) => boolean;\n /**\n * Optional loading content to display while an async method is executing.\n */\n fallback?: (helper: HelperHostSet) => any;\n /**\n * Custom key to extract value from return object.\n * If not provided, uses APPLY_NODE_METADATA_KEY by default.\n * Useful when multiple @applyNode decorators are on the same method.\n */\n valueKey?: symbol | string;\n}\n\nexport interface ApplyNodeMetadata {\n propertyKey: string | symbol;\n selector: ApplyNodeSelector;\n options: ApplyNodeOptions;\n}\n\nexport const APPLY_NODE_METADATA_KEY = Symbol.for('simple-web-component:apply-node');\n\n/**\n * Resolve selector to string or elements\n * Handles function-based selectors and returns elements if applicable\n */\nconst resolveSelector = (selector: ApplyNodeSelector, inst: any, win: Window): string | HTMLElement | null => {\n if (typeof selector === 'function') {\n const hostSet = SwcUtils.getHelperAndHostSet(win, inst);\n const result = selector(inst, hostSet);\n \n if (result instanceof win.Element) {\n return result as HTMLElement;\n }\n if (result instanceof win.NodeList) {\n return result.length > 0 ? (result[0] as HTMLElement) : null;\n }\n if (Array.isArray(result)) {\n return result.length > 0 ? (result[0] as HTMLElement) : null;\n }\n if (result === null) {\n return null;\n }\n // result must be a string at this point\n return result as unknown as string;\n }\n return selector as string;\n};\n\n// const normalizeNodes = (res: any, doc: Document): Node[] => {\n// const items = Array.isArray(res) ? res : [res];\n// return items.map(it => {\n// if (it instanceof Node) return it;\n// return doc.createTextNode(it !== undefined && it !== null ? String(it) : '');\n// });\n// };\n\nconst applyToDom = (currentThis: any, targetEl: HTMLElement, res: Node | string, pos: ApplyNodePosition, win: Window, host?: any) => {\n if (!targetEl) return;\n \n // Handle clearChildren - ignore return value and always clear\n if (pos === 'clearChildren') {\n targetEl.replaceChildren();\n return [];\n }\n \n const doc = win.document;\n const hostSet = SwcUtils.getHelperAndHostSet(win, currentThis);\n const id = currentThis._swcId;\n\n const nodes: Node[] = [];\n\n if (res instanceof win.Node) {\n nodes.push(res);\n } else if (typeof res === 'string' && pos === 'innerHtml') {\n const t = win.document.createElement('template');\n t.innerHTML = res;\n nodes.push(...Array.from(t.content.childNodes));\n } else if (typeof res === 'string' && pos === 'innerText') {\n nodes.push(win.document.createTextNode(res));\n }\n\n SwcUtils.projectProcessHtml(id, nodes, doc);\n\n const isShadowRoot = targetEl instanceof win.ShadowRoot;\n // const nodes = normalizeNodes(res, doc);\n if (pos === 'replace') {\n if (!isShadowRoot) targetEl.replaceWith(...nodes);\n } else if (pos === 'innerHtml') {\n targetEl.replaceChildren(...nodes);\n } else if (pos === 'innerText') {\n targetEl.replaceChildren(...nodes);\n } else if (pos === 'replaceChildren') {\n targetEl.replaceChildren(...nodes);\n } else {\n if (pos === 'beforeEnd') {\n targetEl.append(...nodes)\n }\n else if (pos === 'afterBegin') targetEl.prepend(...nodes);\n else if (pos === 'beforeBegin' && !isShadowRoot) targetEl.before(...nodes);\n else if (pos === 'afterEnd' && !isShadowRoot) targetEl.after(...nodes);\n }\n\n const stateContext: any = {...hostSet};\n findAllStateMetadata(currentThis).forEach(it => {\n stateContext[it.name] = currentThis[it.propertyKey]\n })\n new ElementApply(targetEl, {id: id}).apply({target: 'noInitialized', context: stateContext, bind: currentThis});\n return nodes;\n};\n\n/**\n * @applyNode decorator to surgically add/replace nodes to a target element.\n * \n * Overloads:\n * - applyNode(selector, options) - Apply to specific selector\n * - applyNode(options) - Apply to $this (current element)\n */\nexport function applyNode(selector: ApplyNodeSelector, options?: ApplyNodeOptions): MethodDecorator;\nexport function applyNode(options: ApplyNodeOptions): MethodDecorator;\nexport function applyNode(selectorOrOptions: ApplyNodeSelector | ApplyNodeOptions, maybeOptions?: ApplyNodeOptions): MethodDecorator {\n // Determine selector and options based on overload\n let selector: ApplyNodeSelector;\n let options: ApplyNodeOptions;\n\n if (typeof selectorOrOptions === 'string' || typeof selectorOrOptions === 'function') {\n // First overload: applyNode(selector, options)\n selector = selectorOrOptions;\n options = maybeOptions || {position: 'replaceChildren'};\n } else {\n // Second overload: applyNode(options) - default to $this\n selector = '$this';\n options = selectorOrOptions || {position: 'replaceChildren'};\n }\n\n return (targetObj: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = targetObj.constructor;\n let metaList = ReflectUtils.getOwnMetadata(APPLY_NODE_METADATA_KEY, constructor) as Map<string | symbol, ApplyNodeMetadata>;\n if (!metaList) {\n metaList = new Map<string | symbol, ApplyNodeMetadata>();\n ReflectUtils.defineMetadata(APPLY_NODE_METADATA_KEY, metaList, constructor);\n }\n metaList.set(propertyKey, {propertyKey, selector, options});\n\n const original = descriptor.value;\n descriptor.value = function (...args: any[]) {\n ensureInit(this);\n\n const conf = getElementConfig(this);\n const currentWin = (this as any)._resolveWindow?.(conf) || ((typeof window !== 'undefined' ? window : undefined) as Window);\n const currentDoc = currentWin.document;\n const hostSet = SwcUtils.getHelperAndHostSet(currentWin, this);\n\n const getTarget = () => {\n const r = options.root || 'auto';\n const applyRoot = (t: any) => {\n if (!t) 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 // Resolve selector if it's a function\n const resolved = resolveSelector(selector, this, currentWin);\n \n // If selector function returned an element directly, use it\n if (resolved instanceof currentWin.Element) {\n return applyRoot(resolved);\n }\n if (resolved === null) {\n return null;\n }\n\n // Handle string selector\n const stringSelector = resolved as string;\n\n if (stringSelector === '$this') return applyRoot(this);\n if (stringSelector === '$host') return applyRoot(hostSet.$host);\n if (stringSelector === '$parentHost') return applyRoot(hostSet.$parentHost);\n if (stringSelector === '$appHost') return applyRoot(hostSet.$appHost);\n if (stringSelector === '$firstHost') return applyRoot(hostSet.$firstHost);\n if (stringSelector === '$lastHost') return applyRoot(hostSet.$lastHost);\n\n const targetRoot = applyRoot(this);\n return targetRoot ? targetRoot.querySelector(stringSelector) : null;\n };\n\n const targetEl = getTarget();\n const res = original.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 APPLY_NODE_METADATA_KEY.\n */\n const extractValue = (v: any) => {\n const keyToUse = options.valueKey ?? APPLY_NODE_METADATA_KEY;\n if (v && typeof v === 'object' && keyToUse in v) {\n return v[keyToUse];\n }\n return v;\n };\n\n const runApply = (target: any, val: any) => {\n const pos = options.position || 'beforeEnd';\n // Delegate HTML/node processing to applyToDom which centralizes\n // processing. runApply should not call processHtml itself to avoid\n // duplicate processing.\n const processedVal = val;\n\n // \uC0AC\uC6A9\uC790\uAC00 filter\uB97C \uBA85\uC2DC\uD558\uBA74 \uADF8 \uC870\uAC74\uC73C\uB85C, \uC544\uB2C8\uBA74 \uD56D\uC0C1 \uC801\uC6A9\n if (!options.filter || options.filter(target, processedVal, {currentThis: this, helper: hostSet})) {\n applyToDom(this, target, processedVal, pos, currentWin);\n }\n };\n\n\n const fallbackNodes: Node[] = [];\n if (targetEl && options.fallback) {\n const loadingRes = options.fallback.call(this, hostSet);\n // applyToDom expects a Window as the 4th argument\n fallbackNodes.push(...applyToDom(this, targetEl, loadingRes, options.position || 'beforeEnd', currentWin));\n }\n\n if (res instanceof Promise) {\n return res.then(finalRes => {\n const extracted = extractValue(finalRes);\n fallbackNodes.forEach((it: any)=>it.remove());\n if (extracted !== undefined && targetEl) runApply(targetEl, extracted);\n return finalRes;\n });\n } else {\n const extracted = extractValue(res);\n if (extracted !== undefined && targetEl) runApply(targetEl, extracted);\n return res;\n }\n };\n };\n}\n\n// --- Overloaded convenience functions for common patterns ---\n\n/**\n * @replaceChildrenNode decorator - replaces children of target element\n * \n * Overloads:\n * - replaceChildrenNode(selector, options) - Replace children of specific selector\n * - replaceChildrenNode(options) - Replace children of $this (current element)\n * - @replaceChildrenNode - Bare decorator, replaces children of $this\n */\nexport function replaceChildren(selector: ApplyNodeSelector, options?: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;\nexport function replaceChildren(options: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;\nexport function replaceChildren(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;\nexport function replaceChildren(selectorOrOptions?: ApplyNodeSelector | Omit<ApplyNodeOptions, 'position'> | Object, maybeOptions?: Omit<ApplyNodeOptions, 'position'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {\n // Bare decorator usage: @replaceChildrenNode\n if (descriptor !== undefined && (typeof maybeOptions === 'symbol' || typeof maybeOptions === 'string')) {\n return applyNode({position: 'replaceChildren'})(selectorOrOptions, maybeOptions, descriptor);\n }\n \n if (typeof selectorOrOptions === 'string' || typeof selectorOrOptions === 'function') {\n return applyNode(selectorOrOptions as ApplyNodeSelector, {...maybeOptions as Omit<ApplyNodeOptions, 'position'>, position: 'replaceChildren'});\n }\n return applyNode({...selectorOrOptions as Omit<ApplyNodeOptions, 'position'>, position: 'replaceChildren'});\n}\n\n/**\n * @clearChildrenNode decorator - clears all children of target element\n * \n * Overloads:\n * - clearChildrenNode(selector, options) - Clear children of specific selector\n * - clearChildrenNode(options) - Clear children of $this (current element)\n * - @clearChildrenNode - Bare decorator, clears children of $this\n */\nexport function clearChildrenNode(selector: ApplyNodeSelector, options?: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;\nexport function clearChildrenNode(options?: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;\nexport function clearChildrenNode(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;\nexport function clearChildrenNode(selectorOrOptions?: ApplyNodeSelector | Omit<ApplyNodeOptions, 'position'> | Object, maybeOptions?: Omit<ApplyNodeOptions, 'position'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {\n // Bare decorator usage: @clearChildrenNode\n if (descriptor !== undefined && (typeof maybeOptions === 'symbol' || typeof maybeOptions === 'string')) {\n return applyNode({position: 'clearChildren'})(selectorOrOptions, maybeOptions, descriptor);\n }\n \n if (typeof selectorOrOptions === 'string' || typeof selectorOrOptions === 'function') {\n return applyNode(selectorOrOptions as ApplyNodeSelector, {...maybeOptions as Omit<ApplyNodeOptions, 'position'>, position: 'clearChildren'});\n }\n return applyNode({...selectorOrOptions as Omit<ApplyNodeOptions, 'position'>, position: 'clearChildren'});\n}\n\n// Alias for clearChildrenNode\nexport const clearNode = clearChildrenNode;\n\n/**\n * @innerHtmlNode decorator - sets innerHTML of target element\n * \n * Overloads:\n * - innerHtmlNode(selector, options) - Set innerHTML of specific selector\n * - innerHtmlNode(options) - Set innerHTML of $this (current element)\n * - @innerHtmlNode - Bare decorator, sets innerHTML of $this\n */\nexport function innerHtml(selector: ApplyNodeSelector, options?: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;\nexport function innerHtml(options?: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;\nexport function innerHtml(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;\nexport function innerHtml(selectorOrOptions?: ApplyNodeSelector | Omit<ApplyNodeOptions, 'position'> | Object, maybeOptions?: Omit<ApplyNodeOptions, 'position'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {\n // Bare decorator usage: @innerHtmlNode\n if (descriptor !== undefined && (typeof maybeOptions === 'symbol' || typeof maybeOptions === 'string')) {\n return applyNode({position: 'innerHtml'})(selectorOrOptions, maybeOptions, descriptor);\n }\n \n if (typeof selectorOrOptions === 'string' || typeof selectorOrOptions === 'function') {\n return applyNode(selectorOrOptions as ApplyNodeSelector, {...maybeOptions as Omit<ApplyNodeOptions, 'position'>, position: 'innerHtml'});\n }\n return applyNode({...selectorOrOptions as Omit<ApplyNodeOptions, 'position'>, position: 'innerHtml'});\n}\n\n// Alias for innerHtmlNode\n// export const setHtmlNode = innerHtml;\n\n/**\n * @innerHtmlLightNode decorator - sets innerHTML of light DOM element\n * \n * Overloads:\n * - innerHtmlLightNode(selector, options) - Set innerHTML of specific selector in light DOM\n * - innerHtmlLightNode(options) - Set innerHTML of $this in light DOM\n * - @innerHtmlLightNode - Bare decorator, sets innerHTML of $this in light DOM\n */\nexport function innerHtmlLight(selector: ApplyNodeSelector, options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;\nexport function innerHtmlLight(options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;\nexport function innerHtmlLight(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;\nexport function innerHtmlLight(selectorOrOptions?: ApplyNodeSelector | Omit<ApplyNodeOptions, 'position' | 'root'> | Object, maybeOptions?: Omit<ApplyNodeOptions, 'position' | 'root'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {\n // Bare decorator usage: @innerHtmlLightNode\n if (descriptor !== undefined && (typeof maybeOptions === 'symbol' || typeof maybeOptions === 'string')) {\n return applyNode({position: 'innerHtml', root: 'light'})(selectorOrOptions, maybeOptions, descriptor);\n }\n \n if (typeof selectorOrOptions === 'string' || typeof selectorOrOptions === 'function') {\n return applyNode(selectorOrOptions as ApplyNodeSelector, {...maybeOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'innerHtml', root: 'light'});\n }\n return applyNode({...selectorOrOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'innerHtml', root: 'light'});\n}\n\n\n/**\n * @innerHtmlShadowNode decorator - sets innerHTML of shadow DOM element\n * \n * Overloads:\n * - innerHtmlShadowNode(selector, options) - Set innerHTML of specific selector in shadow DOM\n * - innerHtmlShadowNode(options) - Set innerHTML of $this in shadow DOM\n * - @innerHtmlShadowNode - Bare decorator, sets innerHTML of $this in shadow DOM\n */\nexport function innerHtmlShadow(selector: ApplyNodeSelector, options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;\nexport function innerHtmlShadow(options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;\nexport function innerHtmlShadow(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;\nexport function innerHtmlShadow(selectorOrOptions?: ApplyNodeSelector | Omit<ApplyNodeOptions, 'position' | 'root'> | Object, maybeOptions?: Omit<ApplyNodeOptions, 'position' | 'root'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {\n // Bare decorator usage: @innerHtmlShadowNode\n if (descriptor !== undefined && (typeof maybeOptions === 'symbol' || typeof maybeOptions === 'string')) {\n return applyNode({position: 'innerHtml', root: 'shadow'})(selectorOrOptions, maybeOptions, descriptor);\n }\n \n if (typeof selectorOrOptions === 'string' || typeof selectorOrOptions === 'function') {\n return applyNode(selectorOrOptions as ApplyNodeSelector, {...maybeOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'innerHtml', root: 'shadow'});\n }\n return applyNode({...selectorOrOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'innerHtml', root: 'shadow'});\n}\n\n\n/**\n * @innerTextNode decorator - sets innerText of target element\n * \n * Overloads:\n * - innerTextNode(selector, options) - Set innerText of specific selector\n * - innerTextNode(options) - Set innerText of $this (current element)\n * - @innerTextNode - Bare decorator, sets innerText of $this\n */\nexport function innerText(selector: ApplyNodeSelector, options?: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;\nexport function innerText(options?: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;\nexport function innerText(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;\nexport function innerText(selectorOrOptions?: ApplyNodeSelector | Omit<ApplyNodeOptions, 'position'> | Object, maybeOptions?: Omit<ApplyNodeOptions, 'position'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {\n // Bare decorator usage: @innerTextNode\n if (descriptor !== undefined && (typeof maybeOptions === 'symbol' || typeof maybeOptions === 'string')) {\n return applyNode({position: 'innerText'})(selectorOrOptions, maybeOptions, descriptor);\n }\n \n if (typeof selectorOrOptions === 'string' || typeof selectorOrOptions === 'function') {\n return applyNode(selectorOrOptions as ApplyNodeSelector, {...maybeOptions as Omit<ApplyNodeOptions, 'position'>, position: 'innerText'});\n }\n return applyNode({...selectorOrOptions as Omit<ApplyNodeOptions, 'position'>, position: 'innerText'});\n}\n\n\n/**\n * @innerTextLightNode decorator - sets innerText of light DOM element\n * \n * Overloads:\n * - innerTextLightNode(selector, options) - Set innerText of specific selector in light DOM\n * - innerTextLightNode(options) - Set innerText of $this in light DOM\n * - @innerTextLightNode - Bare decorator, sets innerText of $this in light DOM\n */\nexport function innerTextLight(selector: ApplyNodeSelector, options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;\nexport function innerTextLight(options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;\nexport function innerTextLight(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;\nexport function innerTextLight(selectorOrOptions?: ApplyNodeSelector | Omit<ApplyNodeOptions, 'position' | 'root'> | Object, maybeOptions?: Omit<ApplyNodeOptions, 'position' | 'root'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {\n // Bare decorator usage: @innerTextLightNode\n if (descriptor !== undefined && (typeof maybeOptions === 'symbol' || typeof maybeOptions === 'string')) {\n return applyNode({position: 'innerText', root: 'light'})(selectorOrOptions, maybeOptions, descriptor);\n }\n \n if (typeof selectorOrOptions === 'string' || typeof selectorOrOptions === 'function') {\n return applyNode(selectorOrOptions as ApplyNodeSelector, {...maybeOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'innerText', root: 'light'});\n }\n return applyNode({...selectorOrOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'innerText', root: 'light'});\n}\n\n/**\n * @innerTextShadowNode decorator - sets innerText of shadow DOM element\n * \n * Overloads:\n * - innerTextShadowNode(selector, options) - Set innerText of specific selector in shadow DOM\n * - innerTextShadowNode(options) - Set innerText of $this in shadow DOM\n * - @innerTextShadowNode - Bare decorator, sets innerText of $this in shadow DOM\n */\nexport function innerTextShadow(selector: ApplyNodeSelector, options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;\nexport function innerTextShadow(options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;\nexport function innerTextShadow(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;\nexport function innerTextShadow(selectorOrOptions?: ApplyNodeSelector | Omit<ApplyNodeOptions, 'position' | 'root'> | Object, maybeOptions?: Omit<ApplyNodeOptions, 'position' | 'root'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {\n // Bare decorator usage: @innerTextShadowNode\n if (descriptor !== undefined && (typeof maybeOptions === 'symbol' || typeof maybeOptions === 'string')) {\n return applyNode({position: 'innerText', root: 'shadow'})(selectorOrOptions, maybeOptions, descriptor);\n }\n \n if (typeof selectorOrOptions === 'string' || typeof selectorOrOptions === 'function') {\n return applyNode(selectorOrOptions as ApplyNodeSelector, {...maybeOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'innerText', root: 'shadow'});\n }\n return applyNode({...selectorOrOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'innerText', root: 'shadow'});\n}\n\n/**\n * @beforeEndNode decorator - appends nodes to target element\n * \n * Overloads:\n * - beforeEndNode(selector, options) - Append to specific selector\n * - beforeEndNode(options) - Append to $this (current element)\n * - @beforeEndNode - Bare decorator, appends to $this\n */\nexport function insertBeforeEnd(selector: ApplyNodeSelector, options?: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;\nexport function insertBeforeEnd(options?: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;\nexport function insertBeforeEnd(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;\nexport function insertBeforeEnd(selectorOrOptions?: ApplyNodeSelector | Omit<ApplyNodeOptions, 'position'> | Object, maybeOptions?: Omit<ApplyNodeOptions, 'position'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {\n // Bare decorator usage: @beforeEndNode\n if (descriptor !== undefined && (typeof maybeOptions === 'symbol' || typeof maybeOptions === 'string')) {\n return applyNode({position: 'beforeEnd'})(selectorOrOptions, maybeOptions, descriptor);\n }\n \n if (typeof selectorOrOptions === 'string' || typeof selectorOrOptions === 'function') {\n return applyNode(selectorOrOptions as ApplyNodeSelector, {...maybeOptions as Omit<ApplyNodeOptions, 'position'>, position: 'beforeEnd'});\n }\n return applyNode({...selectorOrOptions as Omit<ApplyNodeOptions, 'position'>, position: 'beforeEnd'});\n}\n\n\n/**\n * @beforeEndLightNode decorator - appends nodes to light DOM element\n * \n * Overloads:\n * - beforeEndLightNode(selector, options) - Append to specific selector in light DOM\n * - beforeEndLightNode(options) - Append to $this in light DOM\n * - @beforeEndLightNode - Bare decorator, appends to $this in light DOM\n */\nexport function insertBeforeEndLight(selector: ApplyNodeSelector, options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;\nexport function insertBeforeEndLight(options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;\nexport function insertBeforeEndLight(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;\nexport function insertBeforeEndLight(selectorOrOptions?: ApplyNodeSelector | Omit<ApplyNodeOptions, 'position' | 'root'> | Object, maybeOptions?: Omit<ApplyNodeOptions, 'position' | 'root'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {\n // Bare decorator usage: @beforeEndLightNode\n if (descriptor !== undefined && (typeof maybeOptions === 'symbol' || typeof maybeOptions === 'string')) {\n return applyNode({position: 'beforeEnd', root: 'light'})(selectorOrOptions, maybeOptions, descriptor);\n }\n \n if (typeof selectorOrOptions === 'string' || typeof selectorOrOptions === 'function') {\n return applyNode(selectorOrOptions as ApplyNodeSelector, {...maybeOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'beforeEnd', root: 'light'});\n }\n return applyNode({...selectorOrOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'beforeEnd', root: 'light'});\n}\n\n\n/**\n * @beforeEndShadowNode decorator - appends nodes to shadow DOM element\n * \n * Overloads:\n * - beforeEndShadowNode(selector, options) - Append to specific selector in shadow DOM\n * - beforeEndShadowNode(options) - Append to $this in shadow DOM\n * - @beforeEndShadowNode - Bare decorator, appends to $this in shadow DOM\n */\nexport function insertBeforeEndShadow(selector: ApplyNodeSelector, options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;\nexport function insertBeforeEndShadow(options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;\nexport function insertBeforeEndShadow(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;\nexport function insertBeforeEndShadow(selectorOrOptions?: ApplyNodeSelector | Omit<ApplyNodeOptions, 'position' | 'root'> | Object, maybeOptions?: Omit<ApplyNodeOptions, 'position' | 'root'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {\n // Bare decorator usage: @beforeEndShadowNode\n if (descriptor !== undefined && (typeof maybeOptions === 'symbol' || typeof maybeOptions === 'string')) {\n return applyNode({position: 'beforeEnd', root: 'shadow'})(selectorOrOptions, maybeOptions, descriptor);\n }\n \n if (typeof selectorOrOptions === 'string' || typeof selectorOrOptions === 'function') {\n return applyNode(selectorOrOptions as ApplyNodeSelector, {...maybeOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'beforeEnd', root: 'shadow'});\n }\n return applyNode({...selectorOrOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'beforeEnd', root: 'shadow'});\n}\n\n\n/**\n * @afterBeginNode decorator - prepends nodes to target element\n * \n * Overloads:\n * - afterBeginNode(selector, options) - Prepend to specific selector\n * - afterBeginNode(options) - Prepend to $this (current element)\n * - @afterBeginNode - Bare decorator, prepends to $this\n */\nexport function insertAfterBegin(selector: ApplyNodeSelector, options?: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;\nexport function insertAfterBegin(options?: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;\nexport function insertAfterBegin(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;\nexport function insertAfterBegin(selectorOrOptions?: ApplyNodeSelector | Omit<ApplyNodeOptions, 'position'> | Object, maybeOptions?: Omit<ApplyNodeOptions, 'position'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {\n // Bare decorator usage: @afterBeginNode\n if (descriptor !== undefined && (typeof maybeOptions === 'symbol' || typeof maybeOptions === 'string')) {\n return applyNode({position: 'afterBegin'})(selectorOrOptions, maybeOptions, descriptor);\n }\n \n if (typeof selectorOrOptions === 'string' || typeof selectorOrOptions === 'function') {\n return applyNode(selectorOrOptions as ApplyNodeSelector, {...maybeOptions as Omit<ApplyNodeOptions, 'position'>, position: 'afterBegin'});\n }\n return applyNode({...selectorOrOptions as Omit<ApplyNodeOptions, 'position'>, position: 'afterBegin'});\n}\n\n\n/**\n * @afterBeginLightNode decorator - prepends nodes to light DOM element\n * \n * Overloads:\n * - afterBeginLightNode(selector, options) - Prepend to specific selector in light DOM\n * - afterBeginLightNode(options) - Prepend to $this in light DOM\n * - @afterBeginLightNode - Bare decorator, prepends to $this in light DOM\n */\nexport function insertAfterBeginLight(selector: ApplyNodeSelector, options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;\nexport function insertAfterBeginLight(options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;\nexport function insertAfterBeginLight(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;\nexport function insertAfterBeginLight(selectorOrOptions?: ApplyNodeSelector | Omit<ApplyNodeOptions, 'position' | 'root'> | Object, maybeOptions?: Omit<ApplyNodeOptions, 'position' | 'root'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {\n // Bare decorator usage: @afterBeginLightNode\n if (descriptor !== undefined && (typeof maybeOptions === 'symbol' || typeof maybeOptions === 'string')) {\n return applyNode({position: 'afterBegin', root: 'light'})(selectorOrOptions, maybeOptions, descriptor);\n }\n \n if (typeof selectorOrOptions === 'string' || typeof selectorOrOptions === 'function') {\n return applyNode(selectorOrOptions as ApplyNodeSelector, {...maybeOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'afterBegin', root: 'light'});\n }\n return applyNode({...selectorOrOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'afterBegin', root: 'light'});\n}\n\n\n/**\n * @replaceChildrenLightNode decorator - replaces children of light DOM element\n * \n * Overloads:\n * - replaceChildrenLightNode(selector, options) - Replace children of specific selector in light DOM\n * - replaceChildrenLightNode(options) - Replace children of $this in light DOM\n * - @replaceChildrenLightNode - Bare decorator, replaces children of $this in light DOM\n */\nexport function replaceChildrenLight(selector: ApplyNodeSelector, options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;\nexport function replaceChildrenLight(options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;\nexport function replaceChildrenLight(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;\nexport function replaceChildrenLight(selectorOrOptions?: ApplyNodeSelector | Omit<ApplyNodeOptions, 'position' | 'root'> | Object, maybeOptions?: Omit<ApplyNodeOptions, 'position' | 'root'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {\n // Bare decorator usage: @replaceChildrenLightNode\n if (descriptor !== undefined && (typeof maybeOptions === 'symbol' || typeof maybeOptions === 'string')) {\n return applyNode({position: 'replaceChildren', root: 'light'})(selectorOrOptions, maybeOptions, descriptor);\n }\n \n if (typeof selectorOrOptions === 'string' || typeof selectorOrOptions === 'function') {\n return applyNode(selectorOrOptions as ApplyNodeSelector, {...maybeOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'replaceChildren', root: 'light'});\n }\n return applyNode({...selectorOrOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'replaceChildren', root: 'light'});\n}\n\n/**\n * @clearChildrenLightNode decorator - clears children of light DOM element\n * \n * Overloads:\n * - clearChildrenLightNode(selector, options) - Clear children of specific selector in light DOM\n * - clearChildrenLightNode(options) - Clear children of $this in light DOM\n * - @clearChildrenLightNode - Bare decorator, clears children of $this in light DOM\n */\nexport function clearChildrenLight(selector: ApplyNodeSelector, options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;\nexport function clearChildrenLight(options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;\nexport function clearChildrenLight(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;\nexport function clearChildrenLight(selectorOrOptions?: ApplyNodeSelector | Omit<ApplyNodeOptions, 'position' | 'root'> | Object, maybeOptions?: Omit<ApplyNodeOptions, 'position' | 'root'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {\n // Bare decorator usage: @clearChildrenLightNode\n if (descriptor !== undefined && (typeof maybeOptions === 'symbol' || typeof maybeOptions === 'string')) {\n return applyNode({position: 'clearChildren', root: 'light'})(selectorOrOptions, maybeOptions, descriptor);\n }\n \n if (typeof selectorOrOptions === 'string' || typeof selectorOrOptions === 'function') {\n return applyNode(selectorOrOptions as ApplyNodeSelector, {...maybeOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'clearChildren', root: 'light'});\n }\n return applyNode({...selectorOrOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'clearChildren', root: 'light'});\n}\n\n\n\n\nexport const findAllApplyNodeMetadata = (target: any): Map<string | symbol, ApplyNodeMetadata> => {\n const result = new Map<string | symbol, ApplyNodeMetadata>();\n const maps = ReflectUtils.findAllMetadata<Map<string | symbol, ApplyNodeMetadata>>(APPLY_NODE_METADATA_KEY, target);\n maps.forEach(map => {\n if (map instanceof Map) {\n map.forEach((v, k) => result.set(k, v));\n }\n });\n return result;\n};"],
|
|
5
|
+
"mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,YAAY,wBAAwB;AAE7C,SAAS,gBAAe;AAC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AO,IAAI,GAAG,CAAC,CAAC;AAAA,IACxC;AAAA,EACF,CAAC;AACD,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/decorators/applyProperty.ts"],
|
|
4
|
-
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit, getElementConfig } from './elementDefine';\nimport { SwcUtils } from '../utils/Utils';\nimport { SwcQueryOptions, HelperHostSet } from '../types';\n\nexport interface PropertyOptions extends SwcQueryOptions {\n name?: string | symbol;\n filter?: (target: HTMLElement, value: any, meta: {currentThis: any, helper: HelperHostSet}) => boolean;\n /**\n * Custom key to extract value from return object.\n * If not provided, uses PROPERTY_METADATA_KEY by default.\n * Useful when multiple @setProperty decorators are on the same method.\n * \n * Example:\n * @setProperty('selector1', { valueKey: 'prop1' })\n * @setProperty('selector2', { valueKey: 'prop2' })\n * myMethod() {\n * return {\n * prop1: 'value1',\n * prop2: 'value2'\n * };\n * }\n * \n * Or with symbols:\n * @setProperty('selector1', { valueKey: Symbol.for('prop1') })\n * @setProperty('selector2', { valueKey: Symbol.for('prop2') })\n * myMethod() {\n * return {\n * [Symbol.for('prop1')]: 'value1',\n * [Symbol.for('prop2')]: 'value2'\n * };\n * }\n */\n valueKey?: symbol | string;\n}\n\nexport type PropertySelector = string | ((currentThis: any, helper: HelperHostSet) => NodeList | Element | Element[] | null);\n\nexport interface PropertyMetadata {\n propertyKey: string | symbol;\n selector: PropertySelector;\n targetPropertyKey: string | symbol;\n options: PropertyOptions;\n type: 'property' | 'method';\n}\n\nexport const PROPERTY_METADATA_KEY = Symbol.for('simple-web-component:property');\n\n// ============================================\n// Utilities\n// ============================================\n\n/**\n * Resolve target elements based on selector and options\n * Handles special selectors ($this, $host, etc.), CSS selectors, and function-based selectors\n * Returns HTMLElement[] but can include Window and Document for property access\n */\nexport const resolvePropertyTargets = (inst: any, selector: PropertySelector, options: PropertyOptions): any[] => {\n const conf = getElementConfig(inst);\n const currentWin = conf.window;\n const r = options.root || 'auto';\n const results: any[] = [];\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 const hostSet = SwcUtils.getHelperAndHostSet(currentWin, inst);\n resolvedSelector = selector(inst, hostSet);\n }\n\n // If selector function returned elements directly, use them\n if (resolvedSelector instanceof currentWin.Element) {\n results.push(resolvedSelector);\n return results;\n }\n if (resolvedSelector instanceof currentWin.NodeList) {\n results.push(...Array.from(resolvedSelector));\n return results;\n }\n if (Array.isArray(resolvedSelector)) {\n results.push(...resolvedSelector);\n return results;\n }\n if (resolvedSelector === null) {\n return results;\n }\n\n // Handle string selector\n const stringSelector = resolvedSelector as string;\n\n const applyRoot = (target: any) => {\n if (!target) return;\n if (r === 'auto') {\n results.push(target);\n } else {\n if (r === 'light' || r === 'all') results.push(target);\n if ((r === 'shadow' || r === 'all') && target.shadowRoot) results.push(target.shadowRoot);\n }\n };\n\n if (stringSelector === '$this' || !stringSelector) {\n applyRoot(inst);\n } else if (stringSelector === '$window') {\n results.push(currentWin);\n } else if (stringSelector === '$document') {\n results.push(currentWin.document);\n } else {\n const hostSet = SwcUtils.getHostSet(inst);\n if (stringSelector === '$host') applyRoot(hostSet.$host);\n else if (stringSelector === '$parentHost') applyRoot(hostSet.$parentHost);\n else if (stringSelector === '$appHost') applyRoot(hostSet.$appHost as any);\n else if (stringSelector === '$firstHost') applyRoot(hostSet.$firstHost);\n else if (stringSelector === '$lastHost') applyRoot(hostSet.$lastHost);\n else if (stringSelector === '$firstAppHost') applyRoot(hostSet.$firstAppHost as any);\n else if (stringSelector === '$lastAppHost') applyRoot(hostSet.$lastAppHost as any);\n else if (stringSelector === '$hosts') hostSet.$hosts.forEach(applyRoot);\n else if (stringSelector === '$appHosts') hostSet.$appHosts.forEach(applyRoot);\n else {\n if (r === 'shadow') {\n const found = inst.shadowRoot?.querySelectorAll(stringSelector);\n if (found) results.push(...found);\n } else if (r === 'light') {\n const found = inst.querySelectorAll(stringSelector);\n if (found) results.push(...found);\n } else if (r === 'all') {\n const sMatch = inst.shadowRoot?.querySelectorAll(stringSelector);\n const lMatch = inst.querySelectorAll(stringSelector);\n if (sMatch) results.push(...sMatch);\n if (lMatch) results.push(...lMatch);\n } else {\n const found = (inst.shadowRoot || inst).querySelectorAll(stringSelector);\n if (found) results.push(...found);\n }\n }\n }\n return results;\n};\n\n/**\n * @applyProperty decorator - set/get element properties\n * \n * Usage:\n * - @applyProperty('selector', 'propertyName') - Set property with explicit name\n * - @applyProperty('selector') - Use property name as target property name\n * - @applyProperty('selector', { name: 'propertyName' }) - Set property via options\n * - @applyProperty((this, helper) => 'selector', 'propertyName') - Function-based selector\n * - Return null/undefined to skip setting\n */\nexport function applyProperty(selector: PropertySelector, targetPropertyKey: string | symbol, options?: PropertyOptions): MethodDecorator & PropertyDecorator;\nexport function applyProperty(selector: PropertySelector, options?: PropertyOptions): MethodDecorator & PropertyDecorator;\nexport function applyProperty(selector: PropertySelector, targetPropertyKeyOrOptions?: string | symbol | PropertyOptions, options?: PropertyOptions): MethodDecorator & PropertyDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => {\n // ensureInit(target as any);\n \n const constructor = target.constructor;\n const metaType: 'property' | 'method' = descriptor && typeof descriptor.value === 'function' ? 'method' : 'property';\n \n // Parse arguments\n let finalOptions: PropertyOptions = {};\n let targetPropertyKey: string | symbol;\n \n if (typeof targetPropertyKeyOrOptions === 'string' || typeof targetPropertyKeyOrOptions === 'symbol') {\n // applyProperty('selector', 'propertyName', options?)\n targetPropertyKey = targetPropertyKeyOrOptions;\n finalOptions = options || {};\n } else if (targetPropertyKeyOrOptions) {\n // applyProperty('selector', options)\n finalOptions = targetPropertyKeyOrOptions;\n targetPropertyKey = finalOptions.name || propertyKey;\n } else {\n // applyProperty('selector')\n targetPropertyKey = propertyKey;\n }\n\n // Store metadata\n let metaList = ReflectUtils.getOwnMetadata(PROPERTY_METADATA_KEY, constructor) as PropertyMetadata[];\n if (!metaList) {\n metaList = [];\n ReflectUtils.defineMetadata(PROPERTY_METADATA_KEY, metaList, constructor);\n }\n metaList.push({\n propertyKey,\n selector: selector as PropertySelector,\n targetPropertyKey,\n options: finalOptions,\n type: metaType\n });\n\n // Helper: apply resolved value to targets\n const applyValueToTargets = (inst: any, resolvedValue: any) => {\n if (resolvedValue === undefined) return resolvedValue;\n\n const targetEls = resolvePropertyTargets(inst, selector, finalOptions);\n const conf = getElementConfig(inst);\n const currentWin = conf.window;\n const hostSet = SwcUtils.getHelperAndHostSet(currentWin, inst);\n\n targetEls.forEach(targetEl => {\n // Apply filter if provided\n if (finalOptions.filter && !finalOptions.filter(targetEl, resolvedValue, { currentThis: inst, helper: hostSet })) {\n return;\n }\n\n const resolvedRes = typeof resolvedValue === 'function' ? (resolvedValue as any)(targetEl, hostSet) : resolvedValue;\n (targetEl as any)[targetPropertyKey] = resolvedRes;\n });\n\n return resolvedValue;\n };\n\n // Method decorator: wrap method to apply its return value to properties\n if (descriptor && typeof descriptor.value === 'function') {\n const original = descriptor.value;\n descriptor.value = function (...args: any[]) {\n ensureInit(this);\n const res = (original as any).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 symbol key,\n * use that value. Otherwise use the entire return value.\n * \n * Example:\n * @setProperty('selector')\n * myMethod() {\n * return {\n * [PROPERTY_METADATA_KEY]: 'property-value',\n * [OTHER_DECORATOR_KEY]: 'other-value'\n * };\n * }\n * \n * This decorator will use 'property-value'\n */\n const extractValue = (v: any) => {\n if (v && typeof v === 'object' && PROPERTY_METADATA_KEY in v) {\n return v[PROPERTY_METADATA_KEY];\n }\n return v;\n };\n\n if (res instanceof Promise) {\n return res.then((v: any) => { \n const extracted = extractValue(v);\n applyValueToTargets(this, extracted); \n return v; \n });\n } else {\n const extracted = extractValue(res);\n applyValueToTargets(this, extracted);\n return res;\n }\n };\n return;\n }\n\n // Property decorator: define getter/setter to proxy to element properties\n Object.defineProperty(target, propertyKey, {\n configurable: true,\n enumerable: true,\n get(this: any) {\n ensureInit(this);\n // Read from matched elements\n const targetEls = resolvePropertyTargets(this, selector, finalOptions);\n const conf = getElementConfig(this);\n const currentWin = conf.window;\n const hostSet = SwcUtils.getHelperAndHostSet(currentWin, this);\n\n // Apply filter\n const filtered = targetEls.filter(el => {\n if (finalOptions.filter && !finalOptions.filter(el, (el as any)[targetPropertyKey], { currentThis: this, helper: hostSet })) {\n return false;\n }\n return true;\n });\n\n const values = filtered.map(el => (el as any)[targetPropertyKey]);\n return values.length === 1 ? values[0] : values;\n },\n set(this: any, value: any) {\n ensureInit(this);\n applyValueToTargets(this, value);\n }\n });\n };\n}\n\n// ============================================\n// Convenience Aliases\n// ============================================\n\n/**\n * @property - Field decorator for binding element properties (read/write)\n * \n * Usage:\n * - @property('selector', 'propertyName') - Bind to specific property\n * - @property('selector') - Use field name as property name\n * - @property('selector', options) - Bind with options\n * - @property((this, helper) => 'selector', 'propertyName') - Function-based selector\n * - @property - Bare decorator (binds to $this with field name)\n * \n * Note: This decorator is for FIELDS ONLY. For methods, use @setProperty.\n */\nexport function property(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;\nexport function property(selector: PropertySelector, targetPropertyKey: string | symbol, options?: PropertyOptions): PropertyDecorator;\nexport function property(selector: PropertySelector, options?: PropertyOptions): PropertyDecorator;\nexport function property(selectorOrTarget?: PropertySelector | Object, targetPropertyKeyOrOptions?: any, optionsOrDescriptor?: any): any {\n // Bare decorator: @property\n if (optionsOrDescriptor !== undefined && (typeof targetPropertyKeyOrOptions === 'string' || typeof targetPropertyKeyOrOptions === 'symbol')) {\n return applyProperty('$this', undefined as any, {})(selectorOrTarget as Object, targetPropertyKeyOrOptions, optionsOrDescriptor as PropertyDescriptor);\n }\n // With selector\n if (typeof selectorOrTarget === 'string') {\n return applyProperty(selectorOrTarget, targetPropertyKeyOrOptions as any, optionsOrDescriptor as PropertyOptions);\n }\n // Without selector (defaults to $this)\n return applyProperty('$this', undefined as any, selectorOrTarget as PropertyOptions);\n}\n\n/**\n * @setProperty - Method decorator for setting element properties from method return value\n * \n * Usage:\n * - @setProperty('selector', 'propertyName') - Set specific property\n * - @setProperty('selector') - Use method name as property name\n * - @setProperty('selector', options) - Set with options\n * - @setProperty((this, helper) => 'selector', 'propertyName') - Function-based selector\n * - @setProperty - Bare decorator (sets on $this with method name)\n * \n * Note: This decorator is for METHODS ONLY. For fields, use @property.\n * \n * Example:\n * @setProperty('selector', 'disabled')\n * disableElement() {\n * return true;\n * }\n */\nexport function setProperty(selector: PropertySelector, targetPropertyKey: string | symbol, options?: PropertyOptions): MethodDecorator;\nexport function setProperty(selector: PropertySelector, options?: PropertyOptions): MethodDecorator;\nexport function setProperty(selectorOrOptions?: PropertySelector | PropertyOptions, targetPropertyKeyOrOptions?: any, optionsOrUndefined?: PropertyOptions): MethodDecorator {\n // With selector\n if (typeof selectorOrOptions === 'string') {\n return applyProperty(selectorOrOptions, targetPropertyKeyOrOptions as any, optionsOrUndefined as PropertyOptions) as MethodDecorator;\n }\n // Without selector (defaults to $this)\n return applyProperty('$this', undefined as any, selectorOrOptions as PropertyOptions) as MethodDecorator;\n}\n\n// ============================================\n// Metadata Helpers\n// ============================================\n\nexport const findAllPropertyMetadata = (target: any): PropertyMetadata[] => {\n const actualTarget = target instanceof Function ? target : target.constructor;\n return ReflectUtils.findAllMetadata<PropertyMetadata[]>(PROPERTY_METADATA_KEY, actualTarget).flat();\n};\n\n// Backward compatibility alias\nexport const findAllPropertyApplyMetadata = (target: any): Map<string | symbol, PropertyMetadata> => {\n const result = new Map<string | symbol, PropertyMetadata>();\n findAllPropertyMetadata(target).forEach(meta => {\n result.set(meta.propertyKey, meta);\n });\n return result;\n};\n\n\nexport default applyProperty;\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,YAAY,wBAAwB;AA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,qBAAqB;AAAA,UAChC;AACA,iBAAO;AAAA,QACT;AAEA,YAAI,eAAe,SAAS;AAC1B,iBAAO,IAAI,KAAK,CAAC,MAAW;AAC1B,kBAAM,YAAY,aAAa,CAAC;AAChC,gCAAoB,MAAM,SAAS;AACnC,mBAAO;AAAA,UACT,CAAC;AAAA,QACH,OAAO;AACL,gBAAM,YAAY,aAAa,GAAG;AAClC,8BAAoB,MAAM,SAAS;AACnC,iBAAO;AAAA,QACT;AAAA,MACF;AACA;AAAA,IACF;AAGA,WAAO,eAAe,QAAQ,aAAa;AAAA,MACzC,cAAc;AAAA,MACd,YAAY;AAAA,MACZ,MAAe;AACb,mBAAW,IAAI;AAEf,cAAM,YAAY,uBAAuB,MAAM,UAAU,YAAY;AACrE,cAAM,OAAO,iBAAiB,IAAI;AAClC,cAAM,aAAa,KAAK;AACxB,cAAM,UAAU,SAAS,oBAAoB,YAAY,IAAI;AAG7D,cAAM,WAAW,UAAU,OAAO,QAAM;AACtC,cAAI,aAAa,UAAU,CAAC,aAAa,OAAO,IAAK,GAAW,iBAAiB,GAAG,EAAE,aAAa,MAAM,QAAQ,QAAQ,CAAC,GAAG;AAC3H,mBAAO;AAAA,UACT;AACA,iBAAO;AAAA,QACT,CAAC;AAED,cAAM,SAAS,SAAS,IAAI,QAAO,GAAW,iBAAiB,CAAC;AAChE,eAAO,OAAO,WAAW,IAAI,OAAO,CAAC,IAAI;AAAA,MAC3C;AAAA,MACA,IAAe,OAAY;AACzB,mBAAW,IAAI;AACf,4BAAoB,MAAM,KAAK;AAAA,MACjC;AAAA,IACF,CAAC;AAAA,EACH;AACF;
|
|
4
|
+
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit, getElementConfig } from './elementDefine';\nimport { SwcUtils } from '../utils/Utils';\nimport { SwcQueryOptions, HelperHostSet } from '../types';\n\nexport interface PropertyOptions extends SwcQueryOptions {\n name?: string | symbol;\n filter?: (target: HTMLElement, value: any, meta: {currentThis: any, helper: HelperHostSet}) => boolean;\n /**\n * Custom key to extract value from return object.\n * If not provided, uses PROPERTY_METADATA_KEY by default.\n * Useful when multiple @setProperty decorators are on the same method.\n * \n * Example:\n * @setProperty('selector1', { valueKey: 'prop1' })\n * @setProperty('selector2', { valueKey: 'prop2' })\n * myMethod() {\n * return {\n * prop1: 'value1',\n * prop2: 'value2'\n * };\n * }\n * \n * Or with symbols:\n * @setProperty('selector1', { valueKey: Symbol.for('prop1') })\n * @setProperty('selector2', { valueKey: Symbol.for('prop2') })\n * myMethod() {\n * return {\n * [Symbol.for('prop1')]: 'value1',\n * [Symbol.for('prop2')]: 'value2'\n * };\n * }\n */\n valueKey?: symbol | string;\n}\n\nexport type PropertySelector = string | ((currentThis: any, helper: HelperHostSet) => NodeList | Element | Element[] | null);\n\nexport interface PropertyMetadata {\n propertyKey: string | symbol;\n selector: PropertySelector;\n targetPropertyKey: string | symbol;\n options: PropertyOptions;\n type: 'property' | 'method';\n}\n\nexport const PROPERTY_METADATA_KEY = Symbol.for('simple-web-component:property');\n\n// ============================================\n// Utilities\n// ============================================\n\n/**\n * Resolve target elements based on selector and options\n * Handles special selectors ($this, $host, etc.), CSS selectors, and function-based selectors\n * Returns HTMLElement[] but can include Window and Document for property access\n */\nexport const resolvePropertyTargets = (inst: any, selector: PropertySelector, options: PropertyOptions): any[] => {\n const conf = getElementConfig(inst);\n const currentWin = conf.window;\n const r = options.root || 'auto';\n const results: any[] = [];\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 const hostSet = SwcUtils.getHelperAndHostSet(currentWin, inst);\n resolvedSelector = selector(inst, hostSet);\n }\n\n // If selector function returned elements directly, use them\n if (resolvedSelector instanceof currentWin.Element) {\n results.push(resolvedSelector);\n return results;\n }\n if (resolvedSelector instanceof currentWin.NodeList) {\n results.push(...Array.from(resolvedSelector));\n return results;\n }\n if (Array.isArray(resolvedSelector)) {\n results.push(...resolvedSelector);\n return results;\n }\n if (resolvedSelector === null) {\n return results;\n }\n\n // Handle string selector\n const stringSelector = resolvedSelector as string;\n\n const applyRoot = (target: any) => {\n if (!target) return;\n if (r === 'auto') {\n results.push(target);\n } else {\n if (r === 'light' || r === 'all') results.push(target);\n if ((r === 'shadow' || r === 'all') && target.shadowRoot) results.push(target.shadowRoot);\n }\n };\n\n if (stringSelector === '$this' || !stringSelector) {\n applyRoot(inst);\n } else if (stringSelector === '$window') {\n results.push(currentWin);\n } else if (stringSelector === '$document') {\n results.push(currentWin.document);\n } else {\n const hostSet = SwcUtils.getHostSet(inst);\n if (stringSelector === '$host') applyRoot(hostSet.$host);\n else if (stringSelector === '$parentHost') applyRoot(hostSet.$parentHost);\n else if (stringSelector === '$appHost') applyRoot(hostSet.$appHost as any);\n else if (stringSelector === '$firstHost') applyRoot(hostSet.$firstHost);\n else if (stringSelector === '$lastHost') applyRoot(hostSet.$lastHost);\n else if (stringSelector === '$firstAppHost') applyRoot(hostSet.$firstAppHost as any);\n else if (stringSelector === '$lastAppHost') applyRoot(hostSet.$lastAppHost as any);\n else if (stringSelector === '$hosts') hostSet.$hosts.forEach(applyRoot);\n else if (stringSelector === '$appHosts') hostSet.$appHosts.forEach(applyRoot);\n else {\n if (r === 'shadow') {\n const found = inst.shadowRoot?.querySelectorAll(stringSelector);\n if (found) results.push(...found);\n } else if (r === 'light') {\n const found = inst.querySelectorAll(stringSelector);\n if (found) results.push(...found);\n } else if (r === 'all') {\n const sMatch = inst.shadowRoot?.querySelectorAll(stringSelector);\n const lMatch = inst.querySelectorAll(stringSelector);\n if (sMatch) results.push(...sMatch);\n if (lMatch) results.push(...lMatch);\n } else {\n const found = (inst.shadowRoot || inst).querySelectorAll(stringSelector);\n if (found) results.push(...found);\n }\n }\n }\n return results;\n};\n\n/**\n * @applyProperty decorator - set/get element properties\n * \n * Usage:\n * - @applyProperty('selector', 'propertyName') - Set property with explicit name\n * - @applyProperty('selector') - Use property name as target property name\n * - @applyProperty('selector', { name: 'propertyName' }) - Set property via options\n * - @applyProperty((this, helper) => 'selector', 'propertyName') - Function-based selector\n * - Return null/undefined to skip setting\n */\nexport function applyProperty(selector: PropertySelector, targetPropertyKey: string | symbol, options?: PropertyOptions): MethodDecorator & PropertyDecorator;\nexport function applyProperty(selector: PropertySelector, options?: PropertyOptions): MethodDecorator & PropertyDecorator;\nexport function applyProperty(selector: PropertySelector, targetPropertyKeyOrOptions?: string | symbol | PropertyOptions, options?: PropertyOptions): MethodDecorator & PropertyDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => {\n // ensureInit(target as any);\n \n const constructor = target.constructor;\n const metaType: 'property' | 'method' = descriptor && typeof descriptor.value === 'function' ? 'method' : 'property';\n \n // Parse arguments\n let finalOptions: PropertyOptions = {};\n let targetPropertyKey: string | symbol;\n \n if (typeof targetPropertyKeyOrOptions === 'string' || typeof targetPropertyKeyOrOptions === 'symbol') {\n // applyProperty('selector', 'propertyName', options?)\n targetPropertyKey = targetPropertyKeyOrOptions;\n finalOptions = options || {};\n } else if (targetPropertyKeyOrOptions) {\n // applyProperty('selector', options)\n finalOptions = targetPropertyKeyOrOptions;\n targetPropertyKey = finalOptions.name || propertyKey;\n } else {\n // applyProperty('selector')\n targetPropertyKey = propertyKey;\n }\n\n // Store metadata\n let metaList = ReflectUtils.getOwnMetadata(PROPERTY_METADATA_KEY, constructor) as PropertyMetadata[];\n if (!metaList) {\n metaList = [];\n ReflectUtils.defineMetadata(PROPERTY_METADATA_KEY, metaList, constructor);\n }\n metaList.push({\n propertyKey,\n selector: selector as PropertySelector,\n targetPropertyKey,\n options: finalOptions,\n type: metaType\n });\n\n // Helper: apply resolved value to targets\n const applyValueToTargets = (inst: any, resolvedValue: any) => {\n if (resolvedValue === undefined) return resolvedValue;\n\n const targetEls = resolvePropertyTargets(inst, selector, finalOptions);\n const conf = getElementConfig(inst);\n const currentWin = conf.window;\n const hostSet = SwcUtils.getHelperAndHostSet(currentWin, inst);\n\n targetEls.forEach(targetEl => {\n // Apply filter if provided\n if (finalOptions.filter && !finalOptions.filter(targetEl, resolvedValue, { currentThis: inst, helper: hostSet })) {\n return;\n }\n\n const resolvedRes = typeof resolvedValue === 'function' ? (resolvedValue as any)(targetEl, hostSet) : resolvedValue;\n (targetEl as any)[targetPropertyKey] = resolvedRes;\n });\n\n return resolvedValue;\n };\n\n // Method decorator: wrap method to apply its return value to properties\n if (descriptor && typeof descriptor.value === 'function') {\n const original = descriptor.value;\n descriptor.value = function (...args: any[]) {\n ensureInit(this);\n const res = (original as any).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 symbol key,\n * use that value. Otherwise use the entire return value.\n * \n * Example:\n * @setProperty('selector')\n * myMethod() {\n * return {\n * [PROPERTY_METADATA_KEY]: 'property-value',\n * [OTHER_DECORATOR_KEY]: 'other-value'\n * };\n * }\n * \n * This decorator will use 'property-value'\n */\n const extractValue = (v: any) => {\n if (v && typeof v === 'object' && PROPERTY_METADATA_KEY in v) {\n return v[PROPERTY_METADATA_KEY];\n }\n return v;\n };\n\n if (res instanceof Promise) {\n return res.then((v: any) => { \n const extracted = extractValue(v);\n applyValueToTargets(this, extracted); \n return v; \n });\n } else {\n const extracted = extractValue(res);\n applyValueToTargets(this, extracted);\n return res;\n }\n };\n return;\n }\n\n // Property decorator: define getter/setter to proxy to element properties\n Object.defineProperty(target, propertyKey, {\n configurable: true,\n enumerable: true,\n get(this: any) {\n ensureInit(this);\n // Read from matched elements\n const targetEls = resolvePropertyTargets(this, selector, finalOptions);\n const conf = getElementConfig(this);\n const currentWin = conf.window;\n const hostSet = SwcUtils.getHelperAndHostSet(currentWin, this);\n\n // Apply filter\n const filtered = targetEls.filter(el => {\n if (finalOptions.filter && !finalOptions.filter(el, (el as any)[targetPropertyKey], { currentThis: this, helper: hostSet })) {\n return false;\n }\n return true;\n });\n\n const values = filtered.map(el => (el as any)[targetPropertyKey]);\n return values.length === 1 ? values[0] : values;\n },\n set(this: any, value: any) {\n ensureInit(this);\n applyValueToTargets(this, value);\n }\n });\n };\n}\n\n// ============================================\n// Convenience Aliases\n// ============================================\n\n/**\n * @property - Field decorator for binding element properties (read/write)\n * \n * Usage:\n * - @property('selector', 'propertyName') - Bind to specific property\n * - @property('selector') - Use field name as property name\n * - @property('selector', options) - Bind with options\n * - @property((this, helper) => 'selector', 'propertyName') - Function-based selector\n * - @property - Bare decorator (binds to $this with field name)\n * \n * Note: This decorator is for FIELDS ONLY. For methods, use @setProperty.\n */\nexport function property(target: Object, propertyKey: string | symbol): void;\nexport function property(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;\nexport function property(selector: PropertySelector, targetPropertyKey: string | symbol, options?: PropertyOptions): PropertyDecorator;\nexport function property(selector: PropertySelector, options?: PropertyOptions): PropertyDecorator;\nexport function property(selectorOrTarget?: PropertySelector | Object, targetPropertyKeyOrOptions?: any, optionsOrDescriptor?: any): any {\n // Bare decorator: @property\n if (optionsOrDescriptor !== undefined && (typeof targetPropertyKeyOrOptions === 'string' || typeof targetPropertyKeyOrOptions === 'symbol')) {\n return applyProperty('$this', undefined as any, {})(selectorOrTarget as Object, targetPropertyKeyOrOptions, optionsOrDescriptor as PropertyDescriptor);\n }\n // With selector\n if (typeof selectorOrTarget === 'string') {\n return applyProperty(selectorOrTarget, targetPropertyKeyOrOptions as any, optionsOrDescriptor as PropertyOptions);\n }\n // Without selector (defaults to $this)\n return applyProperty('$this', undefined as any, selectorOrTarget as PropertyOptions);\n}\n\n/**\n * @setProperty - Method decorator for setting element properties from method return value\n * \n * Usage:\n * - @setProperty('selector', 'propertyName') - Set specific property\n * - @setProperty('selector') - Use method name as property name\n * - @setProperty('selector', options) - Set with options\n * - @setProperty((this, helper) => 'selector', 'propertyName') - Function-based selector\n * - @setProperty - Bare decorator (sets on $this with method name)\n * \n * Note: This decorator is for METHODS ONLY. For fields, use @property.\n * \n * Example:\n * @setProperty('selector', 'disabled')\n * disableElement() {\n * return true;\n * }\n */\nexport function setProperty(selector: PropertySelector, targetPropertyKey: string | symbol, options?: PropertyOptions): MethodDecorator;\nexport function setProperty(selector: PropertySelector, options?: PropertyOptions): MethodDecorator;\nexport function setProperty(selectorOrOptions?: PropertySelector | PropertyOptions, targetPropertyKeyOrOptions?: any, optionsOrUndefined?: PropertyOptions): MethodDecorator {\n // With selector\n if (typeof selectorOrOptions === 'string') {\n return applyProperty(selectorOrOptions, targetPropertyKeyOrOptions as any, optionsOrUndefined as PropertyOptions) as MethodDecorator;\n }\n // Without selector (defaults to $this)\n return applyProperty('$this', undefined as any, selectorOrOptions as PropertyOptions) as MethodDecorator;\n}\n\n// ============================================\n// Metadata Helpers\n// ============================================\n\nexport const findAllPropertyMetadata = (target: any): PropertyMetadata[] => {\n const actualTarget = target instanceof Function ? target : target.constructor;\n return ReflectUtils.findAllMetadata<PropertyMetadata[]>(PROPERTY_METADATA_KEY, actualTarget).flat();\n};\n\n// Backward compatibility alias\nexport const findAllPropertyApplyMetadata = (target: any): Map<string | symbol, PropertyMetadata> => {\n const result = new Map<string | symbol, PropertyMetadata>();\n findAllPropertyMetadata(target).forEach(meta => {\n result.set(meta.propertyKey, meta);\n });\n return result;\n};\n\n\nexport default applyProperty;\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,YAAY,wBAAwB;AAC7C,SAAS,gBAAgB;AA4ClB,MAAM,wBAAwB,OAAO,IAAI,+BAA+B;AAWxE,MAAM,yBAAyB,CAAC,MAAW,UAA4B,YAAoC;AAChH,QAAM,OAAO,iBAAiB,IAAI;AAClC,QAAM,aAAa,KAAK;AACxB,QAAM,IAAI,QAAQ,QAAQ;AAC1B,QAAM,UAAiB,CAAC;AAGxB,MAAI,mBAAmE;AACvE,MAAI,OAAO,aAAa,YAAY;AAClC,UAAM,UAAU,SAAS,oBAAoB,YAAY,IAAI;AAC7D,uBAAmB,SAAS,MAAM,OAAO;AAAA,EAC3C;AAGA,MAAI,4BAA4B,WAAW,SAAS;AAClD,YA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