@dooboostore/simple-web-component 1.0.42 → 1.0.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +689 -85
- package/dist/cjs/SwcAppEngine.js +3 -1
- package/dist/cjs/SwcAppEngine.js.map +2 -2
- package/dist/cjs/decorators/addEventListener.js +10 -0
- package/dist/cjs/decorators/addEventListener.js.map +2 -2
- package/dist/cjs/decorators/applyAttribute.js +41 -30
- package/dist/cjs/decorators/applyAttribute.js.map +2 -2
- package/dist/cjs/decorators/applyClass.js +66 -23
- package/dist/cjs/decorators/applyClass.js.map +3 -3
- package/dist/cjs/decorators/applyNode.js +176 -107
- package/dist/cjs/decorators/applyNode.js.map +2 -2
- package/dist/cjs/decorators/applyProperty.js +21 -30
- package/dist/cjs/decorators/applyProperty.js.map +2 -2
- package/dist/cjs/decorators/applySlot.js +11 -2
- package/dist/cjs/decorators/applySlot.js.map +2 -2
- package/dist/cjs/decorators/applyStyle.js +48 -17
- 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 +37 -6
- package/dist/cjs/decorators/elementDefine.js.map +3 -3
- package/dist/cjs/decorators/emitCustomEvent.js +58 -42
- 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 +37 -23
- package/dist/cjs/decorators/publishSwcAppMessage.js.map +3 -3
- package/dist/cjs/decorators/query.js +96 -145
- package/dist/cjs/decorators/query.js.map +3 -3
- package/dist/cjs/decorators/queryAll.js +104 -131
- 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/esm/SwcAppEngine.js +3 -1
- package/dist/esm/SwcAppEngine.js.map +2 -2
- package/dist/esm/decorators/addEventListener.js +10 -0
- package/dist/esm/decorators/addEventListener.js.map +2 -2
- package/dist/esm/decorators/applyAttribute.js +41 -30
- package/dist/esm/decorators/applyAttribute.js.map +2 -2
- package/dist/esm/decorators/applyClass.js +66 -23
- package/dist/esm/decorators/applyClass.js.map +3 -3
- package/dist/esm/decorators/applyNode.js +176 -107
- package/dist/esm/decorators/applyNode.js.map +2 -2
- package/dist/esm/decorators/applyProperty.js +21 -30
- package/dist/esm/decorators/applyProperty.js.map +2 -2
- package/dist/esm/decorators/applySlot.js +11 -2
- package/dist/esm/decorators/applySlot.js.map +2 -2
- package/dist/esm/decorators/applyStyle.js +48 -17
- 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 +35 -4
- package/dist/esm/decorators/elementDefine.js.map +2 -2
- package/dist/esm/decorators/emitCustomEvent.js +58 -42
- 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 +37 -23
- package/dist/esm/decorators/publishSwcAppMessage.js.map +3 -3
- package/dist/esm/decorators/query.js +96 -145
- package/dist/esm/decorators/query.js.map +3 -3
- package/dist/esm/decorators/queryAll.js +104 -131
- 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 +900 -578
- 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 +22 -14
- package/dist/types/decorators/addEventListener.d.ts.map +1 -1
- package/dist/types/decorators/applyAttribute.d.ts +61 -20
- package/dist/types/decorators/applyAttribute.d.ts.map +1 -1
- package/dist/types/decorators/applyClass.d.ts +22 -36
- package/dist/types/decorators/applyClass.d.ts.map +1 -1
- package/dist/types/decorators/applyNode.d.ts +178 -30
- package/dist/types/decorators/applyNode.d.ts.map +1 -1
- package/dist/types/decorators/applyProperty.d.ts +53 -18
- package/dist/types/decorators/applyProperty.d.ts.map +1 -1
- package/dist/types/decorators/applySlot.d.ts +6 -0
- package/dist/types/decorators/applySlot.d.ts.map +1 -1
- package/dist/types/decorators/applyStyle.d.ts +13 -7
- 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 +20 -10
- 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 +19 -0
- package/dist/types/decorators/publishSwcAppMessage.d.ts.map +1 -1
- package/dist/types/decorators/query.d.ts +3 -26
- package/dist/types/decorators/query.d.ts.map +1 -1
- package/dist/types/decorators/queryAll.d.ts +3 -20
- 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 +900 -578
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
- package/package.json +7 -9
- package/src/SwcAppEngine.ts +3 -1
- package/src/decorators/addEventListener.ts +35 -24
- package/src/decorators/applyAttribute.ts +167 -65
- package/src/decorators/applyClass.ts +113 -17
- package/src/decorators/applyNode.ts +383 -102
- package/src/decorators/applyProperty.ts +99 -65
- package/src/decorators/applySlot.ts +24 -10
- package/src/decorators/applyStyle.ts +83 -13
- package/src/decorators/{changedAttributeThis.ts → changedAttribute.ts} +1 -1
- package/src/decorators/elementDefine.ts +47 -4
- package/src/decorators/emitCustomEvent.ts +62 -35
- package/src/decorators/index.ts +1 -1
- package/src/decorators/publishSwcAppMessage.ts +71 -27
- package/src/decorators/query.ts +90 -159
- package/src/decorators/queryAll.ts +92 -134
- 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/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\ntype Options = (EmitCustomEventBaseOptions & SwcQueryOptions) | (EmitCustomEventBaseOptions & SwcQueryOptions & { attributeName?: string });\n\nexport interface EmitCustomEventMetadata {\n propertyKey: string | symbol;\n selector: string;\n type: string;\n options: Options;\n}\n\nexport const EMIT_CUSTOM_EVENT_METADATA_KEY = Symbol.for('simple-web-component:emit-custom-event');\n\nexport function emitCustomEvent(target:
|
|
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 interface EmitCustomEventBaseOptions {\n bubbles?: boolean;\n composed?: boolean;\n cancelable?: boolean;\n filter?: (target: EventTarget, detail: any, meta: { currentThis: any, helper: HelperHostSet }) => boolean;\n /**\n * Custom key to extract value from return object.\n * If not provided, uses EMIT_CUSTOM_EVENT_METADATA_KEY by default.\n * Useful when multiple @emitCustomEvent decorators are on the same method.\n * \n * Example:\n * @emitCustomEvent('$appHost', 'event1', { valueKey: 'detail1' })\n * @emitCustomEvent('$appHost', 'event2', { valueKey: 'detail2' })\n * myMethod() {\n * return {\n * detail1: { type: 'event1', data: 'value1' },\n * detail2: { type: 'event2', data: 'value2' }\n * };\n * }\n */\n valueKey?: symbol | string;\n}\n\ntype Options = (EmitCustomEventBaseOptions & SwcQueryOptions) | (EmitCustomEventBaseOptions & SwcQueryOptions & { attributeName?: string });\n\nexport interface EmitCustomEventMetadata {\n propertyKey: string | symbol;\n selector: string;\n type: string;\n options: Options;\n}\n\nexport const EMIT_CUSTOM_EVENT_METADATA_KEY = Symbol.for('simple-web-component:emit-custom-event');\n\nexport function emitCustomEvent(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;\nexport function emitCustomEvent(selector: string, 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('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 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: string, 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 hostSet = SwcUtils.getHostSet(this as any);\n const conf = getElementConfig(this);\n const currentWin = (this as any)._resolveWindow?.(conf) || ((typeof window !== 'undefined' ? window : undefined) as Window);\n\n const eventTargets: EventTarget[] = [];\n if (selector === '$window') eventTargets.push(currentWin);\n else if (selector === '$document') eventTargets.push(currentWin.document);\n else if (selector === '$host') {\n if (hostSet.$host) eventTargets.push(hostSet.$host);\n } else if (selector === '$parentHost') {\n if (hostSet.$parentHost) eventTargets.push(hostSet.$parentHost);\n } else if (selector === '$appHost') {\n if (hostSet.$appHost) eventTargets.push(hostSet.$appHost);\n } else if (selector === '$firstHost') {\n if (hostSet.$firstHost) eventTargets.push(hostSet.$firstHost);\n } else if (selector === '$lastHost') {\n if (hostSet.$lastHost) eventTargets.push(hostSet.$lastHost);\n } else if (selector === '$firstAppHost') {\n if (hostSet.$firstAppHost) eventTargets.push(hostSet.$firstAppHost);\n } else if (selector === '$lastAppHost') {\n if (hostSet.$lastAppHost) eventTargets.push(hostSet.$lastAppHost);\n } else if (selector === '$hosts') {\n hostSet.$hosts.forEach(h => eventTargets.push(h));\n } else if (selector === '$appHosts') {\n hostSet.$appHosts.forEach(h => eventTargets.push(h));\n } else if (selector === '$this' || !selector) {\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(selector).forEach(el => eventTargets.push(el));\n });\n }\n\n eventTargets.forEach(t => {\n if (fullOptions.filter && !fullOptions.filter(t, detail, {currentThis: this, helper: hostSet})) {\n return;\n }\n t.dispatchEvent(event);\n });\n\n return detail;\n };\n\n if (res instanceof Promise) {\n return res.then(handleResult);\n } else {\n return handleResult(res);\n }\n };\n };\n}\n\nexport const getEmitCustomEventMetadataList = (target: any): EmitCustomEventMetadata[] | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUt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AAI,MAAM;AAAQ,wBAAY,KAAK,KAAK,cAAe,IAAY;mBAC1D,MAAM;AAAS,wBAAY,KAAK,IAAW;mBAC3C,MAAM,YAAY,KAAK;AAAY,wBAAY,KAAK,KAAK,UAAU;mBACnE,MAAM,OAAO;AACpB,wBAAY,KAAK,IAAW;AAC5B,gBAAI,KAAK;AAAY,0BAAY,KAAK,KAAK,UAAU;UACvD;AAEA,sBAAY,QAAQ,QAAK;AACvB,eAAG,iBAAiB,QAAQ,EAAE,QAAQ,QAAM,aAAa,KAAK,EAAE,CAAC;UACnE,CAAC;QACH;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
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ReflectUtils } from "@dooboostore/core";
|
|
2
2
|
import { SwcUtils } from "../utils/Utils.js";
|
|
3
3
|
const PUBLISH_SWC_APP_MESSAGE_METADATA_KEY = Symbol.for("simple-web-component:publish-swc-app-message");
|
|
4
|
-
function createPublishSwcAppMessage(messageType) {
|
|
4
|
+
function createPublishSwcAppMessage(messageType, options) {
|
|
5
5
|
return (target, propertyKey, descriptor) => {
|
|
6
6
|
const constructor = target.constructor;
|
|
7
7
|
let list = ReflectUtils.getOwnMetadata(PUBLISH_SWC_APP_MESSAGE_METADATA_KEY, constructor);
|
|
@@ -16,45 +16,58 @@ function createPublishSwcAppMessage(messageType) {
|
|
|
16
16
|
const originalMethod = descriptor.value;
|
|
17
17
|
descriptor.value = function(...args) {
|
|
18
18
|
const result = originalMethod.apply(this, args);
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
}).catch((err) => {
|
|
30
|
-
console.warn("publishSwcAppMessage async error:", err);
|
|
31
|
-
});
|
|
32
|
-
} else {
|
|
19
|
+
const extractValue = (v) => {
|
|
20
|
+
const keyToUse = options?.valueKey ?? PUBLISH_SWC_APP_MESSAGE_METADATA_KEY;
|
|
21
|
+
if (v && typeof v === "object" && keyToUse in v) {
|
|
22
|
+
return v[keyToUse];
|
|
23
|
+
}
|
|
24
|
+
return v;
|
|
25
|
+
};
|
|
26
|
+
const publishMessage2 = (data) => {
|
|
33
27
|
const appHost = SwcUtils.getAppHost(this);
|
|
34
28
|
if (appHost) {
|
|
35
29
|
appHost.publishMessage({
|
|
36
30
|
publisher: this,
|
|
37
|
-
data
|
|
31
|
+
data,
|
|
38
32
|
type: messageType
|
|
39
33
|
});
|
|
40
34
|
}
|
|
35
|
+
};
|
|
36
|
+
if (result instanceof Promise) {
|
|
37
|
+
result.then((data) => {
|
|
38
|
+
const extracted = extractValue(data);
|
|
39
|
+
publishMessage2(extracted);
|
|
40
|
+
}).catch((err) => {
|
|
41
|
+
console.warn("publishSwcAppMessage async error:", err);
|
|
42
|
+
});
|
|
43
|
+
} else {
|
|
44
|
+
const extracted = extractValue(result);
|
|
45
|
+
publishMessage2(extracted);
|
|
41
46
|
}
|
|
42
47
|
return result;
|
|
43
48
|
};
|
|
44
49
|
return descriptor;
|
|
45
50
|
};
|
|
46
51
|
}
|
|
47
|
-
function publishSwcAppMessage(
|
|
48
|
-
if (
|
|
49
|
-
const target =
|
|
50
|
-
return createPublishSwcAppMessage()(target,
|
|
52
|
+
function publishSwcAppMessage(targetOrMessageTypeOrOptions, propertyKeyOrOptions, descriptor) {
|
|
53
|
+
if (targetOrMessageTypeOrOptions && typeof targetOrMessageTypeOrOptions === "object" && propertyKeyOrOptions && (typeof propertyKeyOrOptions === "string" || typeof propertyKeyOrOptions === "symbol") && descriptor) {
|
|
54
|
+
const target = targetOrMessageTypeOrOptions;
|
|
55
|
+
return createPublishSwcAppMessage()(target, propertyKeyOrOptions, descriptor);
|
|
51
56
|
}
|
|
52
57
|
let messageType;
|
|
53
|
-
|
|
54
|
-
|
|
58
|
+
let options;
|
|
59
|
+
if (typeof targetOrMessageTypeOrOptions === "string") {
|
|
60
|
+
messageType = targetOrMessageTypeOrOptions;
|
|
61
|
+
if (typeof propertyKeyOrOptions === "object" && propertyKeyOrOptions !== null) {
|
|
62
|
+
options = propertyKeyOrOptions;
|
|
63
|
+
}
|
|
64
|
+
} else if (typeof targetOrMessageTypeOrOptions === "object" && targetOrMessageTypeOrOptions !== null) {
|
|
65
|
+
options = targetOrMessageTypeOrOptions;
|
|
66
|
+
messageType = options.messageType;
|
|
55
67
|
}
|
|
56
|
-
return createPublishSwcAppMessage(messageType);
|
|
68
|
+
return createPublishSwcAppMessage(messageType, options);
|
|
57
69
|
}
|
|
70
|
+
const publishMessage = publishSwcAppMessage;
|
|
58
71
|
const getPublishSwcAppMessageMetadata = (target) => {
|
|
59
72
|
const constructor = target instanceof Function ? target : target.constructor;
|
|
60
73
|
return ReflectUtils.getOwnMetadata(PUBLISH_SWC_APP_MESSAGE_METADATA_KEY, constructor);
|
|
@@ -62,6 +75,7 @@ const getPublishSwcAppMessageMetadata = (target) => {
|
|
|
62
75
|
export {
|
|
63
76
|
PUBLISH_SWC_APP_MESSAGE_METADATA_KEY,
|
|
64
77
|
getPublishSwcAppMessageMetadata,
|
|
78
|
+
publishMessage,
|
|
65
79
|
publishSwcAppMessage
|
|
66
80
|
};
|
|
67
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\nfunction createPublishSwcAppMessage(messageType?: string): 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
|
|
5
|
-
"mappings": "AAAA,SAAQ,oBAAmB;AAC3B,SAAQ,gBAAe;AAEhB,MAAM,uCAAuC,OAAO,IAAI,8CAA8C;
|
|
6
|
-
"names": []
|
|
4
|
+
"sourcesContent": ["import {ReflectUtils} from '@dooboostore/core';\nimport {SwcUtils} from '../utils/Utils';\n\nexport const PUBLISH_SWC_APP_MESSAGE_METADATA_KEY = Symbol.for('simple-web-component:publish-swc-app-message');\n\nexport interface PublishSwcAppMessageMetadata {\n propertyKey: string | symbol;\n messageType?: string;\n}\n\nexport interface PublishSwcAppMessageOptions {\n messageType?: string;\n /**\n * Custom key to extract value from return object.\n * If not provided, uses PUBLISH_SWC_APP_MESSAGE_METADATA_KEY by default.\n * Useful when multiple @publishSwcAppMessage decorators are on the same method.\n * \n * Example:\n * @publishSwcAppMessage('event1', { valueKey: 'detail1' })\n * @publishSwcAppMessage('event2', { valueKey: 'detail2' })\n * myMethod() {\n * return {\n * detail1: { type: 'event1', data: 'value1' },\n * detail2: { type: 'event2', data: 'value2' }\n * };\n * }\n */\n valueKey?: symbol | string;\n}\n\nfunction createPublishSwcAppMessage(messageType?: string, options?: PublishSwcAppMessageOptions): MethodDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => {\n const constructor = target.constructor;\n let list = ReflectUtils.getOwnMetadata(PUBLISH_SWC_APP_MESSAGE_METADATA_KEY, constructor) as PublishSwcAppMessageMetadata[];\n if (!list) {\n list = [];\n ReflectUtils.defineMetadata(PUBLISH_SWC_APP_MESSAGE_METADATA_KEY, list, constructor);\n }\n list.push({ propertyKey, messageType });\n \n if (!descriptor) {\n return descriptor;\n }\n\n // \uBA54\uC11C\uB4DC \uB798\uD551 - \uC6D0\uBCF8 \uBA54\uC11C\uB4DC\uC758 \uBC18\uD658\uAC12\uC744 \uCEA1\uCC98\uD558\uC5EC \uBA54\uC2DC\uC9C0 \uBC1C\uD589\n const originalMethod = descriptor.value;\n descriptor.value = function (...args: any[]) {\n // \uC6D0\uBCF8 \uBA54\uC11C\uB4DC \uC2E4\uD589\n const result = originalMethod.apply(this, args);\n\n /**\n * Extract value for this decorator from method return value\n * \n * If return value is an object with this decorator's key,\n * use that value. Otherwise use the entire return value.\n * \n * Uses valueKey from options if provided, otherwise uses PUBLISH_SWC_APP_MESSAGE_METADATA_KEY.\n */\n const extractValue = (v: any) => {\n const keyToUse = options?.valueKey ?? PUBLISH_SWC_APP_MESSAGE_METADATA_KEY;\n if (v && typeof v === 'object' && keyToUse in v) {\n return v[keyToUse];\n }\n return v;\n };\n\n const publishMessage = (data: any) => {\n // appHost \uCC3E\uC544\uC11C \uBA54\uC2DC\uC9C0 \uBC1C\uD589\n const appHost = SwcUtils.getAppHost(this as HTMLElement);\n if (appHost) {\n appHost.publishMessage({\n publisher: this,\n data,\n type: messageType\n });\n }\n };\n \n // Promise \uCCB4\uD06C\n if (result instanceof Promise) {\n result.then((data) => {\n const extracted = extractValue(data);\n publishMessage(extracted);\n }).catch((err) => {\n console.warn('publishSwcAppMessage async error:', err);\n });\n } else {\n // \uB3D9\uAE30 \uD638\uCD9C - \uBC14\uB85C \uBA54\uC2DC\uC9C0 \uBC1C\uD589\n const extracted = extractValue(result);\n publishMessage(extracted);\n }\n \n return result;\n };\n\n return descriptor;\n };\n}\n\n// \uC624\uBC84\uB85C\uB4DC \uC2DC\uADF8\uB2C8\uCC98 - \uC9C1\uC811 \uC0AC\uC6A9 (\uAD04\uD638 \uC5C6\uC74C)\nexport function publishSwcAppMessage(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;\n// \uC624\uBC84\uB85C\uB4DC \uC2DC\uADF8\uB2C8\uCC98 - \uD568\uC218 \uD638\uCD9C (\uAD04\uD638 \uC788\uC74C)\nexport function publishSwcAppMessage(): MethodDecorator;\nexport function publishSwcAppMessage(messageType: string): MethodDecorator;\nexport function publishSwcAppMessage(messageType: string, options: PublishSwcAppMessageOptions): MethodDecorator;\nexport function publishSwcAppMessage(options: PublishSwcAppMessageOptions): MethodDecorator;\n\nexport function publishSwcAppMessage(targetOrMessageTypeOrOptions?: any, propertyKeyOrOptions?: string | symbol | PublishSwcAppMessageOptions, descriptor?: PropertyDescriptor): any {\n // \uC9C1\uC811 \uB370\uCF54\uB808\uC774\uD130\uB85C \uC0AC\uC6A9\uB41C \uACBD\uC6B0 (\uAD04\uD638 \uC5C6\uC74C): @publishSwcAppMessage\n if (targetOrMessageTypeOrOptions && typeof targetOrMessageTypeOrOptions === 'object' && \n propertyKeyOrOptions && (typeof propertyKeyOrOptions === 'string' || typeof propertyKeyOrOptions === 'symbol') &&\n descriptor) {\n const target = targetOrMessageTypeOrOptions;\n return createPublishSwcAppMessage()(target, propertyKeyOrOptions, descriptor);\n }\n\n // \uD568\uC218\uB85C \uD638\uCD9C\uB41C \uACBD\uC6B0 (\uAD04\uD638 \uC788\uC74C): @publishSwcAppMessage() / @publishSwcAppMessage('messageType') / @publishSwcAppMessage({...})\n let messageType: string | undefined;\n let options: PublishSwcAppMessageOptions | undefined;\n\n if (typeof targetOrMessageTypeOrOptions === 'string') {\n // \uBA54\uC2DC\uC9C0 \uD0C0\uC785 \uC804\uB2EC: @publishSwcAppMessage('messageType')\n messageType = targetOrMessageTypeOrOptions;\n if (typeof propertyKeyOrOptions === 'object' && propertyKeyOrOptions !== null) {\n options = propertyKeyOrOptions as PublishSwcAppMessageOptions;\n }\n } else if (typeof targetOrMessageTypeOrOptions === 'object' && targetOrMessageTypeOrOptions !== null) {\n // \uC635\uC158 \uAC1D\uCCB4 \uC804\uB2EC: @publishSwcAppMessage({...})\n options = targetOrMessageTypeOrOptions as PublishSwcAppMessageOptions;\n messageType = options.messageType;\n }\n\n return createPublishSwcAppMessage(messageType, options);\n}\n\n// --- Aliases: publish... ---\nexport const publishMessage = publishSwcAppMessage;\n\n// Helper function to retrieve publish message metadata\nexport const getPublishSwcAppMessageMetadata = (target: any): PublishSwcAppMessageMetadata[] | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getOwnMetadata(PUBLISH_SWC_APP_MESSAGE_METADATA_KEY, constructor);\n};\n"],
|
|
5
|
+
"mappings": "AAAA,SAAQ,oBAAmB;AAC3B,SAAQ,gBAAe;AAEhB,MAAM,uCAAuC,OAAO,IAAI,8CAA8C;AA2B7G,SAAS,2BAA2B,aAAsB,SAAwD;AAChH,SAAO,CAAC,QAAgB,aAA8B,eAAoC;AACxF,UAAM,cAAc,OAAO;AAC3B,QAAI,OAAO,aAAa,eAAe,sCAAsC,WAAW;AACxF,QAAI,CAAC,MAAM;AACT,aAAO,CAAC;AACR,mBAAa,eAAe,sCAAsC,MAAM,WAAW;AAAA,IACrF;AACA,SAAK,KAAK,EAAE,aAAa,YAAY,CAAC;AAEtC,QAA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,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,106 @@ 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
|
-
|
|
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") {
|
|
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 selector = selectorOrTarget;
|
|
25
|
+
const r = optionsOrPropertyKey?.root || "auto";
|
|
26
|
+
const applyRoot = (t) => {
|
|
27
|
+
if (!t || !(t instanceof HTMLElement))
|
|
28
|
+
return t;
|
|
29
|
+
if (r === "auto")
|
|
30
|
+
return t.shadowRoot || t;
|
|
31
|
+
if (r === "shadow")
|
|
32
|
+
return t.shadowRoot;
|
|
33
|
+
if (r === "light")
|
|
34
|
+
return t;
|
|
35
|
+
if (r === "all")
|
|
36
|
+
return t.shadowRoot || t;
|
|
24
37
|
return t;
|
|
25
|
-
|
|
26
|
-
|
|
38
|
+
};
|
|
39
|
+
const hostSet = SwcUtils.getHostSet(this);
|
|
40
|
+
if (selector === "$this")
|
|
41
|
+
return applyRoot(this);
|
|
42
|
+
if (selector === "$host")
|
|
43
|
+
return applyRoot(hostSet.$host);
|
|
44
|
+
if (selector === "$parentHost")
|
|
45
|
+
return applyRoot(hostSet.$parentHost);
|
|
46
|
+
if (selector === "$appHost")
|
|
47
|
+
return applyRoot(hostSet.$appHost);
|
|
48
|
+
if (selector === "$firstHost")
|
|
49
|
+
return applyRoot(hostSet.$firstHost);
|
|
50
|
+
if (selector === "$lastHost")
|
|
51
|
+
return applyRoot(hostSet.$lastHost);
|
|
52
|
+
if (selector === "$firstAppHost")
|
|
53
|
+
return applyRoot(hostSet.$firstAppHost);
|
|
54
|
+
if (selector === "$lastAppHost")
|
|
55
|
+
return applyRoot(hostSet.$lastAppHost);
|
|
56
|
+
const config = getElementConfig(this);
|
|
57
|
+
const win = config?.window || window;
|
|
58
|
+
if (selector === "$window")
|
|
59
|
+
return win;
|
|
60
|
+
if (selector === "$document")
|
|
61
|
+
return win.document;
|
|
27
62
|
if (r === "shadow")
|
|
28
|
-
return
|
|
63
|
+
return this.shadowRoot ? this.shadowRoot.querySelector(selector) : null;
|
|
29
64
|
if (r === "light")
|
|
30
|
-
return
|
|
31
|
-
if (r === "all")
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
};
|
|
35
|
-
const hostSet = SwcUtils.getHostSet(this);
|
|
36
|
-
if (selector === "$this")
|
|
37
|
-
return applyRoot(this);
|
|
38
|
-
if (selector === "$host")
|
|
39
|
-
return applyRoot(hostSet.$host);
|
|
40
|
-
if (selector === "$parentHost")
|
|
41
|
-
return applyRoot(hostSet.$parentHost);
|
|
42
|
-
if (selector === "$appHost")
|
|
43
|
-
return applyRoot(hostSet.$appHost);
|
|
44
|
-
if (selector === "$firstHost")
|
|
45
|
-
return applyRoot(hostSet.$firstHost);
|
|
46
|
-
if (selector === "$lastHost")
|
|
47
|
-
return applyRoot(hostSet.$lastHost);
|
|
48
|
-
if (selector === "$firstAppHost")
|
|
49
|
-
return applyRoot(hostSet.$firstAppHost);
|
|
50
|
-
if (selector === "$lastAppHost")
|
|
51
|
-
return applyRoot(hostSet.$lastAppHost);
|
|
52
|
-
const config = getElementConfig(this);
|
|
53
|
-
const win = config?.window || window;
|
|
54
|
-
if (selector === "$window")
|
|
55
|
-
return win;
|
|
56
|
-
if (selector === "$document")
|
|
57
|
-
return win.document;
|
|
58
|
-
if (r === "shadow")
|
|
59
|
-
return this.shadowRoot ? this.shadowRoot.querySelector(selector) : null;
|
|
60
|
-
if (r === "light")
|
|
61
|
-
return this.querySelector(selector);
|
|
62
|
-
if (r === "all") {
|
|
63
|
-
const shadowMatch = this.shadowRoot ? this.shadowRoot.querySelector(selector) : null;
|
|
64
|
-
return shadowMatch || this.querySelector(selector);
|
|
65
|
-
}
|
|
66
|
-
return (this.shadowRoot || this).querySelector(selector);
|
|
67
|
-
},
|
|
68
|
-
set(nv) {
|
|
69
|
-
ensureInit(this);
|
|
70
|
-
if (nv === null || nv === void 0) {
|
|
71
|
-
const selector = selectorOrTarget;
|
|
72
|
-
if (selector.startsWith("$") && selector !== "$this")
|
|
73
|
-
return;
|
|
74
|
-
const r = options.root || "auto";
|
|
75
|
-
const targets = [];
|
|
76
|
-
if (r === "shadow") {
|
|
77
|
-
if (this.shadowRoot?.querySelector(selector))
|
|
78
|
-
targets.push(this.shadowRoot.querySelector(selector));
|
|
79
|
-
} else if (r === "light") {
|
|
80
|
-
if (this.querySelector(selector))
|
|
81
|
-
targets.push(this.querySelector(selector));
|
|
82
|
-
} else if (r === "all") {
|
|
83
|
-
if (this.shadowRoot?.querySelector(selector))
|
|
84
|
-
targets.push(this.shadowRoot.querySelector(selector));
|
|
85
|
-
if (this.querySelector(selector))
|
|
86
|
-
targets.push(this.querySelector(selector));
|
|
87
|
-
} else {
|
|
88
|
-
const el = (this.shadowRoot || this).querySelector(selector);
|
|
89
|
-
if (el)
|
|
90
|
-
targets.push(el);
|
|
65
|
+
return this.querySelector(selector);
|
|
66
|
+
if (r === "all") {
|
|
67
|
+
const shadowMatch = this.shadowRoot ? this.shadowRoot.querySelector(selector) : null;
|
|
68
|
+
return shadowMatch || this.querySelector(selector);
|
|
91
69
|
}
|
|
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
|
-
return query("$document", targetOrOptions);
|
|
126
|
-
} else {
|
|
127
|
-
return query("$document", {});
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
function queryHost(targetOrOptions, propertyKey) {
|
|
131
|
-
if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
132
|
-
return query("$host", {})(targetOrOptions, propertyKey);
|
|
133
|
-
}
|
|
134
|
-
if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
|
|
135
|
-
return query("$host", targetOrOptions);
|
|
136
|
-
} else {
|
|
137
|
-
return query("$host", {});
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
function queryAppHost(targetOrOptions, propertyKey) {
|
|
141
|
-
if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
142
|
-
return query("$appHost", {})(targetOrOptions, propertyKey);
|
|
143
|
-
}
|
|
144
|
-
if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
|
|
145
|
-
return query("$appHost", targetOrOptions);
|
|
146
|
-
} else {
|
|
147
|
-
return query("$appHost", {});
|
|
70
|
+
return (this.shadowRoot || this).querySelector(selector);
|
|
71
|
+
},
|
|
72
|
+
set(nv) {
|
|
73
|
+
ensureInit(this);
|
|
74
|
+
if (nv === null || nv === void 0) {
|
|
75
|
+
const selector = selectorOrTarget;
|
|
76
|
+
if (selector.startsWith("$") && selector !== "$this")
|
|
77
|
+
return;
|
|
78
|
+
const r = optionsOrPropertyKey?.root || "auto";
|
|
79
|
+
const targets = [];
|
|
80
|
+
if (r === "shadow") {
|
|
81
|
+
if (this.shadowRoot?.querySelector(selector))
|
|
82
|
+
targets.push(this.shadowRoot.querySelector(selector));
|
|
83
|
+
} else if (r === "light") {
|
|
84
|
+
if (this.querySelector(selector))
|
|
85
|
+
targets.push(this.querySelector(selector));
|
|
86
|
+
} else if (r === "all") {
|
|
87
|
+
if (this.shadowRoot?.querySelector(selector))
|
|
88
|
+
targets.push(this.shadowRoot.querySelector(selector));
|
|
89
|
+
if (this.querySelector(selector))
|
|
90
|
+
targets.push(this.querySelector(selector));
|
|
91
|
+
} else {
|
|
92
|
+
const el = (this.shadowRoot || this).querySelector(selector);
|
|
93
|
+
if (el)
|
|
94
|
+
targets.push(el);
|
|
95
|
+
}
|
|
96
|
+
targets.forEach((t) => t.remove());
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
enumerable: true,
|
|
100
|
+
configurable: true
|
|
101
|
+
});
|
|
102
|
+
};
|
|
148
103
|
}
|
|
104
|
+
return query("$this", selectorOrTarget);
|
|
149
105
|
}
|
|
150
106
|
const getQueryMetadata = (target) => {
|
|
151
107
|
const constructor = target instanceof Function ? target : target.constructor;
|
|
@@ -154,11 +110,6 @@ const getQueryMetadata = (target) => {
|
|
|
154
110
|
export {
|
|
155
111
|
QUERY_METADATA_KEY,
|
|
156
112
|
getQueryMetadata,
|
|
157
|
-
query
|
|
158
|
-
queryAppHost,
|
|
159
|
-
queryDocument,
|
|
160
|
-
queryHost,
|
|
161
|
-
queryThis,
|
|
162
|
-
queryWindow
|
|
113
|
+
query
|
|
163
114
|
};
|
|
164
115
|
//# sourceMappingURL=query.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/decorators/query.ts"],
|
|
4
|
-
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { getElementConfig, ensureInit } from './elementDefine';\nimport { SwcUtils } from '../utils/Utils';\nimport { SpecialSelector, SwcQueryOptions, HelperHostSet } from '../types';\n\nexport interface QueryMetadata {\n propertyKey: string | symbol;\n selector: string;\n options: SwcQueryOptions ;\n}\n\nexport const QUERY_METADATA_KEY = Symbol.for('simple-web-component:query');\n\nexport function query(target:
|
|
5
|
-
"mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB,kBAAkB;AAC7C,SAAS,gBAAgB;AASlB,MAAM,qBAAqB,OAAO,IAAI,4BAA4B;
|
|
6
|
-
"names": []
|
|
4
|
+
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { getElementConfig, ensureInit } from './elementDefine';\nimport { SwcUtils } from '../utils/Utils';\nimport { SpecialSelector, SwcQueryOptions, HelperHostSet } from '../types';\n\nexport interface QueryMetadata {\n propertyKey: string | symbol;\n selector: string;\n options: SwcQueryOptions ;\n}\n\nexport const QUERY_METADATA_KEY = Symbol.for('simple-web-component:query');\n\nexport function query(target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor): PropertyDescriptor | void;\nexport function query(selector: string, options?: SwcQueryOptions): PropertyDecorator;\nexport function query(options?: SwcQueryOptions): PropertyDecorator;\n/**\n * @query decorator to inject a single element into a class property.\n */\nexport function query(selectorOrTarget?: string | Object, optionsOrPropertyKey?: SwcQueryOptions | 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') {\n return (targetObj: Object, propertyKey: string | symbol, descriptor?: never): void => {\n if (descriptor !== undefined) {\n throw new Error(`@query decorator cannot be used on methods. (Method: ${String(propertyKey)})`);\n }\n\n const constructor = targetObj.constructor;\n let queries = ReflectUtils.getMetadata<QueryMetadata[]>(QUERY_METADATA_KEY, constructor);\n if (!queries) {\n queries = [];\n ReflectUtils.defineMetadata(QUERY_METADATA_KEY, queries, constructor);\n }\n queries.push({ propertyKey, selector: selectorOrTarget, options: optionsOrPropertyKey as SwcQueryOptions || {} });\n\n Object.defineProperty(targetObj, propertyKey, {\n get(this: HTMLElement) {\n ensureInit(this);\n const selector = selectorOrTarget;\n\n const r = (optionsOrPropertyKey as SwcQueryOptions)?.root || 'auto';\n const applyRoot = (t: any) => {\n if (!t || !(t instanceof HTMLElement)) return t;\n if (r === 'auto') return t.shadowRoot || t;\n if (r === 'shadow') return t.shadowRoot;\n if (r === 'light') return t;\n if (r === 'all') return t.shadowRoot || t; \n return t;\n };\n\n // --- Special Selectors: HostSet ---\n const hostSet = SwcUtils.getHostSet(this);\n if (selector === '$this') return applyRoot(this);\n if (selector === '$host') return applyRoot(hostSet.$host);\n if (selector === '$parentHost') return applyRoot(hostSet.$parentHost);\n if (selector === '$appHost') return applyRoot(hostSet.$appHost);\n if (selector === '$firstHost') return applyRoot(hostSet.$firstHost);\n if (selector === '$lastHost') return applyRoot(hostSet.$lastHost);\n if (selector === '$firstAppHost') return applyRoot(hostSet.$firstAppHost);\n if (selector === '$lastAppHost') return applyRoot(hostSet.$lastAppHost);\n\n // --- Special Selectors: Env ---\n const config = getElementConfig(this);\n const win = config?.window || window;\n if (selector === '$window') return win;\n if (selector === '$document') return win.document;\n\n // --- Standard Selectors ---\n if (r === 'shadow') return this.shadowRoot ? this.shadowRoot.querySelector(selector) : null;\n if (r === 'light') return this.querySelector(selector);\n if (r === 'all') {\n const shadowMatch = this.shadowRoot ? this.shadowRoot.querySelector(selector) : null;\n return shadowMatch || this.querySelector(selector);\n }\n return (this.shadowRoot || this).querySelector(selector);\n },\n set(this: HTMLElement, nv: any) {\n ensureInit(this);\n if (nv === null || nv === undefined) {\n const selector = selectorOrTarget;\n if (selector.startsWith('$') && selector !== '$this') return;\n\n const r = (optionsOrPropertyKey as SwcQueryOptions)?.root || 'auto';\n const targets: Element[] = [];\n\n if (r === 'shadow') {\n if (this.shadowRoot?.querySelector(selector)) targets.push(this.shadowRoot.querySelector(selector)!);\n } else if (r === 'light') {\n if (this.querySelector(selector)) targets.push(this.querySelector(selector)!);\n } else if (r === 'all') {\n if (this.shadowRoot?.querySelector(selector)) targets.push(this.shadowRoot.querySelector(selector)!);\n if (this.querySelector(selector)) targets.push(this.querySelector(selector)!);\n } else {\n const el = (this.shadowRoot || this).querySelector(selector);\n if (el) targets.push(el);\n }\n\n targets.forEach(t => t.remove());\n }\n },\n enumerable: true,\n configurable: true\n });\n };\n }\n // 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;AASlB,MAAM,qBAAqB,OAAO,IAAI,4BAA4B;AAQnE,SAAU,MAAM,kBAAoC,sBAA0D,YAA+B;AAEjJ,MAAI,eAAe,WAAc,OAAO,yBAAyB,YAAY,OAAO,yBAAyB,WAAW;AACtH,UAAM,IAAI,MAAM,wDAAwD,OAAO,oBAAoB,CAAC,GAAG;EACzG;AAEA,MAAI,OAAO,qBAAqB,UAAU;AACxC,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,kBAAkB,SAAS,wBAA2C,CAAA,EAAE,CAAE;AAEhH,aAAO,eAAe,WAAW,aAAa;QAC5C,MAAG;AACD,qBAAW,IAAI;AACf,gBAAM,WAAW;AAEjB,gBAAM,IAAK,sBAA0C,QAAQ;AAC7D,gBAAM,YAAY,CAAC,MAAU;AAC3B,gBAAI,CAAC,KAAK,EAAE,aAAa;AAAc,qBAAO;AAC9C,gBAAI,MAAM;AAAQ,qBAAO,EAAE,cAAc;AACzC,gBAAI,MAAM;AAAU,qBAAO,EAAE;AAC7B,gBAAI,MAAM;AAAS,qBAAO;AAC1B,gBAAI,MAAM;AAAO,q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