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