@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/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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA2B;AAC3B,mBAAuB;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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA2B;AAC3B,mBAAuB;AAEhB,MAAM,uCAAuC,OAAO,IAAI,8CAA8C;AA2B7G,SAAS,2BAA2B,aAAsB,SAAwD;AAChH,SAAO,CAAC,QAAgB,aAA8B,eAAoC;AACxF,UAAM,cAAc,OAAO;AAC3B,QAAI,OAAO,yBAAa,eAAe,sCAAsC,WAAW;AACxF,QAAI,CAAC,MAAM;AACT,aAAO,CAAC;AACR,+BAAa,eAAe,sCAAsC,MAAM,WAAW;AAAA,IACrF;AACA,SAAK,KAAK,EAAE,aAAa,YAAY,CAAC;AAEtC,QAAI,CAAC,YAAY;AACf,aAAO;AAAA,IACT;AAGA,UAAM,iBAAiB,WAAW;AAClC,eAAW,QAAQ,YAAa,MAAa;AAE3C,YAAM,SAAS,eAAe,MAAM,MAAM,IAAI;AAU9C,YAAM,eAAe,CAAC,MAAW;AAC/B,cAAM,WAAW,SAAS,YAAY;AACtC,YAAI,KAAK,OAAO,MAAM,YAAY,YAAY,GAAG;AAC/C,iBAAO,EAAE,QAAQ;AAAA,QACnB;AACA,eAAO;AAAA,MACT;AAEA,YAAMA,kBAAiB,CAAC,SAAc;AAEpC,cAAM,UAAU,sBAAS,WAAW,IAAmB;AACvD,YAAI,SAAS;AACX,kBAAQ,eA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KEY,
|
|
21
21
|
getQueryMetadata: () => getQueryMetadata,
|
|
22
|
-
query: () => query
|
|
23
|
-
queryAppHost: () => queryAppHost,
|
|
24
|
-
queryDocument: () => queryDocument,
|
|
25
|
-
queryHost: () => queryHost,
|
|
26
|
-
queryThis: () => queryThis,
|
|
27
|
-
queryWindow: () => queryWindow
|
|
22
|
+
query: () => query
|
|
28
23
|
});
|
|
29
24
|
module.exports = __toCommonJS(query_exports);
|
|
30
25
|
var import_core = require("@dooboostore/core");
|
|
31
26
|
var import_elementDefine = require("./elementDefine");
|
|
32
27
|
var import_Utils = require("../utils/Utils");
|
|
33
28
|
const QUERY_METADATA_KEY = Symbol.for("simple-web-component:query");
|
|
34
|
-
function query(selectorOrTarget,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
29
|
+
function query(selectorOrTarget, optionsOrPropertyKey, descriptor) {
|
|
30
|
+
if (descriptor !== void 0 && (typeof optionsOrPropertyKey === "string" || typeof optionsOrPropertyKey === "symbol")) {
|
|
31
|
+
throw new Error(`@query decorator cannot be used on methods. (Method: ${String(optionsOrPropertyKey)})`);
|
|
32
|
+
}
|
|
33
|
+
if (typeof selectorOrTarget === "string") {
|
|
34
|
+
return (targetObj, propertyKey, descriptor2) => {
|
|
35
|
+
if (descriptor2 !== void 0) {
|
|
36
|
+
throw new Error(`@query decorator cannot be used on methods. (Method: ${String(propertyKey)})`);
|
|
37
|
+
}
|
|
38
|
+
const constructor = targetObj.constructor;
|
|
39
|
+
let queries = import_core.ReflectUtils.getMetadata(QUERY_METADATA_KEY, constructor);
|
|
40
|
+
if (!queries) {
|
|
41
|
+
queries = [];
|
|
42
|
+
import_core.ReflectUtils.defineMetadata(QUERY_METADATA_KEY, queries, constructor);
|
|
43
|
+
}
|
|
44
|
+
queries.push({ propertyKey, selector: selectorOrTarget, options: optionsOrPropertyKey || {} });
|
|
45
|
+
Object.defineProperty(targetObj, propertyKey, {
|
|
46
|
+
get() {
|
|
47
|
+
(0, import_elementDefine.ensureInit)(this);
|
|
48
|
+
const selector = selectorOrTarget;
|
|
49
|
+
const r = optionsOrPropertyKey?.root || "auto";
|
|
50
|
+
const applyRoot = (t) => {
|
|
51
|
+
if (!t || !(t instanceof HTMLElement))
|
|
52
|
+
return t;
|
|
53
|
+
if (r === "auto")
|
|
54
|
+
return t.shadowRoot || t;
|
|
55
|
+
if (r === "shadow")
|
|
56
|
+
return t.shadowRoot;
|
|
57
|
+
if (r === "light")
|
|
58
|
+
return t;
|
|
59
|
+
if (r === "all")
|
|
60
|
+
return t.shadowRoot || t;
|
|
53
61
|
return t;
|
|
54
|
-
|
|
55
|
-
|
|
62
|
+
};
|
|
63
|
+
const hostSet = import_Utils.SwcUtils.getHostSet(this);
|
|
64
|
+
if (selector === "$this")
|
|
65
|
+
return applyRoot(this);
|
|
66
|
+
if (selector === "$host")
|
|
67
|
+
return applyRoot(hostSet.$host);
|
|
68
|
+
if (selector === "$parentHost")
|
|
69
|
+
return applyRoot(hostSet.$parentHost);
|
|
70
|
+
if (selector === "$appHost")
|
|
71
|
+
return applyRoot(hostSet.$appHost);
|
|
72
|
+
if (selector === "$firstHost")
|
|
73
|
+
return applyRoot(hostSet.$firstHost);
|
|
74
|
+
if (selector === "$lastHost")
|
|
75
|
+
return applyRoot(hostSet.$lastHost);
|
|
76
|
+
if (selector === "$firstAppHost")
|
|
77
|
+
return applyRoot(hostSet.$firstAppHost);
|
|
78
|
+
if (selector === "$lastAppHost")
|
|
79
|
+
return applyRoot(hostSet.$lastAppHost);
|
|
80
|
+
const config = (0, import_elementDefine.getElementConfig)(this);
|
|
81
|
+
const win = config?.window || window;
|
|
82
|
+
if (selector === "$window")
|
|
83
|
+
return win;
|
|
84
|
+
if (selector === "$document")
|
|
85
|
+
return win.document;
|
|
56
86
|
if (r === "shadow")
|
|
57
|
-
return
|
|
87
|
+
return this.shadowRoot ? this.shadowRoot.querySelector(selector) : null;
|
|
58
88
|
if (r === "light")
|
|
59
|
-
return
|
|
60
|
-
if (r === "all")
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
};
|
|
64
|
-
const hostSet = import_Utils.SwcUtils.getHostSet(this);
|
|
65
|
-
if (selector === "$this")
|
|
66
|
-
return applyRoot(this);
|
|
67
|
-
if (selector === "$host")
|
|
68
|
-
return applyRoot(hostSet.$host);
|
|
69
|
-
if (selector === "$parentHost")
|
|
70
|
-
return applyRoot(hostSet.$parentHost);
|
|
71
|
-
if (selector === "$appHost")
|
|
72
|
-
return applyRoot(hostSet.$appHost);
|
|
73
|
-
if (selector === "$firstHost")
|
|
74
|
-
return applyRoot(hostSet.$firstHost);
|
|
75
|
-
if (selector === "$lastHost")
|
|
76
|
-
return applyRoot(hostSet.$lastHost);
|
|
77
|
-
if (selector === "$firstAppHost")
|
|
78
|
-
return applyRoot(hostSet.$firstAppHost);
|
|
79
|
-
if (selector === "$lastAppHost")
|
|
80
|
-
return applyRoot(hostSet.$lastAppHost);
|
|
81
|
-
const config = (0, import_elementDefine.getElementConfig)(this);
|
|
82
|
-
const win = config?.window || window;
|
|
83
|
-
if (selector === "$window")
|
|
84
|
-
return win;
|
|
85
|
-
if (selector === "$document")
|
|
86
|
-
return win.document;
|
|
87
|
-
if (r === "shadow")
|
|
88
|
-
return this.shadowRoot ? this.shadowRoot.querySelector(selector) : null;
|
|
89
|
-
if (r === "light")
|
|
90
|
-
return this.querySelector(selector);
|
|
91
|
-
if (r === "all") {
|
|
92
|
-
const shadowMatch = this.shadowRoot ? this.shadowRoot.querySelector(selector) : null;
|
|
93
|
-
return shadowMatch || this.querySelector(selector);
|
|
94
|
-
}
|
|
95
|
-
return (this.shadowRoot || this).querySelector(selector);
|
|
96
|
-
},
|
|
97
|
-
set(nv) {
|
|
98
|
-
(0, import_elementDefine.ensureInit)(this);
|
|
99
|
-
if (nv === null || nv === void 0) {
|
|
100
|
-
const selector = selectorOrTarget;
|
|
101
|
-
if (selector.startsWith("$") && selector !== "$this")
|
|
102
|
-
return;
|
|
103
|
-
const r = options.root || "auto";
|
|
104
|
-
const targets = [];
|
|
105
|
-
if (r === "shadow") {
|
|
106
|
-
if (this.shadowRoot?.querySelector(selector))
|
|
107
|
-
targets.push(this.shadowRoot.querySelector(selector));
|
|
108
|
-
} else if (r === "light") {
|
|
109
|
-
if (this.querySelector(selector))
|
|
110
|
-
targets.push(this.querySelector(selector));
|
|
111
|
-
} else if (r === "all") {
|
|
112
|
-
if (this.shadowRoot?.querySelector(selector))
|
|
113
|
-
targets.push(this.shadowRoot.querySelector(selector));
|
|
114
|
-
if (this.querySelector(selector))
|
|
115
|
-
targets.push(this.querySelector(selector));
|
|
116
|
-
} else {
|
|
117
|
-
const el = (this.shadowRoot || this).querySelector(selector);
|
|
118
|
-
if (el)
|
|
119
|
-
targets.push(el);
|
|
89
|
+
return this.querySelector(selector);
|
|
90
|
+
if (r === "all") {
|
|
91
|
+
const shadowMatch = this.shadowRoot ? this.shadowRoot.querySelector(selector) : null;
|
|
92
|
+
return shadowMatch || this.querySelector(selector);
|
|
120
93
|
}
|
|
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
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
return query("$document", targetOrOptions);
|
|
155
|
-
} else {
|
|
156
|
-
return query("$document", {});
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
function queryHost(targetOrOptions, propertyKey) {
|
|
160
|
-
if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
161
|
-
return query("$host", {})(targetOrOptions, propertyKey);
|
|
162
|
-
}
|
|
163
|
-
if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
|
|
164
|
-
return query("$host", targetOrOptions);
|
|
165
|
-
} else {
|
|
166
|
-
return query("$host", {});
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
function queryAppHost(targetOrOptions, propertyKey) {
|
|
170
|
-
if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
171
|
-
return query("$appHost", {})(targetOrOptions, propertyKey);
|
|
172
|
-
}
|
|
173
|
-
if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
|
|
174
|
-
return query("$appHost", targetOrOptions);
|
|
175
|
-
} else {
|
|
176
|
-
return query("$appHost", {});
|
|
94
|
+
return (this.shadowRoot || this).querySelector(selector);
|
|
95
|
+
},
|
|
96
|
+
set(nv) {
|
|
97
|
+
(0, import_elementDefine.ensureInit)(this);
|
|
98
|
+
if (nv === null || nv === void 0) {
|
|
99
|
+
const selector = selectorOrTarget;
|
|
100
|
+
if (selector.startsWith("$") && selector !== "$this")
|
|
101
|
+
return;
|
|
102
|
+
const r = optionsOrPropertyKey?.root || "auto";
|
|
103
|
+
const targets = [];
|
|
104
|
+
if (r === "shadow") {
|
|
105
|
+
if (this.shadowRoot?.querySelector(selector))
|
|
106
|
+
targets.push(this.shadowRoot.querySelector(selector));
|
|
107
|
+
} else if (r === "light") {
|
|
108
|
+
if (this.querySelector(selector))
|
|
109
|
+
targets.push(this.querySelector(selector));
|
|
110
|
+
} else if (r === "all") {
|
|
111
|
+
if (this.shadowRoot?.querySelector(selector))
|
|
112
|
+
targets.push(this.shadowRoot.querySelector(selector));
|
|
113
|
+
if (this.querySelector(selector))
|
|
114
|
+
targets.push(this.querySelector(selector));
|
|
115
|
+
} else {
|
|
116
|
+
const el = (this.shadowRoot || this).querySelector(selector);
|
|
117
|
+
if (el)
|
|
118
|
+
targets.push(el);
|
|
119
|
+
}
|
|
120
|
+
targets.forEach((t) => t.remove());
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
enumerable: true,
|
|
124
|
+
configurable: true
|
|
125
|
+
});
|
|
126
|
+
};
|
|
177
127
|
}
|
|
128
|
+
return query("$this", selectorOrTarget);
|
|
178
129
|
}
|
|
179
130
|
const getQueryMetadata = (target) => {
|
|
180
131
|
const constructor = target instanceof Function ? target : target.constructor;
|
|
@@ -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
|
|
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;;;;;;;kBAA6B;AAC7B,2BAA6C;AAC7C,mBAAyB;AASlB,MAAM,qBAAqB,OAAO,IAAI,4BAA4B;AAQnE,SAAU,MAAM,kBAAoC,sBAA0D,YAA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cAAc,MAAM,cAAc,QAAQ;AAC3D,kBAAI;AAAI,wBAAQ,KAAK,EAAE;YACzB;AAEA,oBAAQ,QAAQ,OAAK,EAAE,OAAM,CAAE;UACjC;QACF;QACA,YAAY;QACZ,cAAc;OACf;IACH;EACF;AAEA,SAAO,MAAM,SAAS,gBAAmC;AAC3D;AAEO,MAAM,mBAAmB,CAAC,WAAiC;AAChE,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,SAAO,yBAAa,YAAY,oBAAoB,WAAW,KAAK,CAAA;AACtE;",
|
|
6
|
+
"names": ["descriptor"]
|
|
7
7
|
}
|
|
@@ -18,150 +18,123 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
18
18
|
var queryAll_exports = {};
|
|
19
19
|
__export(queryAll_exports, {
|
|
20
20
|
QUERY_ALL_METADATA_KEY: () => QUERY_ALL_METADATA_KEY,
|
|
21
|
-
allAppHost: () => allAppHost,
|
|
22
|
-
allParentHost: () => allParentHost,
|
|
23
21
|
getQueryAllMetadata: () => getQueryAllMetadata,
|
|
24
|
-
queryAll: () => queryAll
|
|
25
|
-
queryAllThis: () => queryAllThis
|
|
22
|
+
queryAll: () => queryAll
|
|
26
23
|
});
|
|
27
24
|
module.exports = __toCommonJS(queryAll_exports);
|
|
28
25
|
var import_core = require("@dooboostore/core");
|
|
29
26
|
var import_elementDefine = require("./elementDefine");
|
|
30
27
|
var import_Utils = require("../utils/Utils");
|
|
31
28
|
const QUERY_ALL_METADATA_KEY = Symbol.for("simple-web-component:query-all");
|
|
32
|
-
function queryAll(selectorOrTarget,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return [];
|
|
52
|
-
const items = Array.isArray(t) ? t : [t];
|
|
53
|
-
const results = [];
|
|
54
|
-
items.forEach((it) => {
|
|
55
|
-
if (!(it instanceof HTMLElement)) {
|
|
56
|
-
results.push(it);
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
if (r === "auto")
|
|
60
|
-
results.push(it.shadowRoot || it);
|
|
61
|
-
else {
|
|
62
|
-
if (r === "light" || r === "all")
|
|
63
|
-
results.push(it);
|
|
64
|
-
if ((r === "shadow" || r === "all") && it.shadowRoot)
|
|
65
|
-
results.push(it.shadowRoot);
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
return results;
|
|
69
|
-
};
|
|
70
|
-
const hostSet = import_Utils.SwcUtils.getHostSet(this);
|
|
71
|
-
if (selector === "$hosts")
|
|
72
|
-
return applyRoot(hostSet.$hosts);
|
|
73
|
-
if (selector === "$appHosts")
|
|
74
|
-
return applyRoot(hostSet.$appHosts);
|
|
75
|
-
if (selector === "$host")
|
|
76
|
-
return applyRoot(hostSet.$host);
|
|
77
|
-
if (selector === "$parentHost")
|
|
78
|
-
return applyRoot(hostSet.$parentHost);
|
|
79
|
-
if (selector === "$appHost")
|
|
80
|
-
return applyRoot(hostSet.$appHost);
|
|
81
|
-
if (selector === "$firstHost")
|
|
82
|
-
return applyRoot(hostSet.$firstHost);
|
|
83
|
-
if (selector === "$lastHost")
|
|
84
|
-
return applyRoot(hostSet.$lastHost);
|
|
85
|
-
if (selector === "$firstAppHost")
|
|
86
|
-
return applyRoot(hostSet.$firstAppHost);
|
|
87
|
-
if (selector === "$lastAppHost")
|
|
88
|
-
return applyRoot(hostSet.$lastAppHost);
|
|
89
|
-
const config = (0, import_elementDefine.getElementConfig)(this);
|
|
90
|
-
const win = config?.window || window;
|
|
91
|
-
if (selector === "$window")
|
|
92
|
-
return [win];
|
|
93
|
-
if (selector === "$document")
|
|
94
|
-
return [win.document];
|
|
95
|
-
if (selector === "$this")
|
|
96
|
-
return applyRoot(this);
|
|
97
|
-
if (r === "shadow")
|
|
98
|
-
return this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];
|
|
99
|
-
if (r === "light")
|
|
100
|
-
return Array.from(this.querySelectorAll(selector));
|
|
101
|
-
if (r === "all") {
|
|
102
|
-
const sNodes = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];
|
|
103
|
-
const lNodes = Array.from(this.querySelectorAll(selector));
|
|
104
|
-
return [...sNodes, ...lNodes];
|
|
105
|
-
}
|
|
106
|
-
const root = this.shadowRoot || this;
|
|
107
|
-
return Array.from(root.querySelectorAll(selector));
|
|
108
|
-
},
|
|
109
|
-
set(nv) {
|
|
110
|
-
(0, import_elementDefine.ensureInit)(this);
|
|
111
|
-
if (nv === null || nv === void 0 || Array.isArray(nv) && nv.length === 0) {
|
|
29
|
+
function queryAll(selectorOrTarget, optionsOrPropertyKey, descriptor) {
|
|
30
|
+
if (descriptor !== void 0 && (typeof optionsOrPropertyKey === "string" || typeof optionsOrPropertyKey === "symbol")) {
|
|
31
|
+
throw new Error(`@queryAll decorator cannot be used on methods. (Method: ${String(optionsOrPropertyKey)})`);
|
|
32
|
+
}
|
|
33
|
+
if (typeof selectorOrTarget === "string") {
|
|
34
|
+
return (targetObj, propertyKey, descriptor2) => {
|
|
35
|
+
if (descriptor2 !== void 0) {
|
|
36
|
+
throw new Error(`@queryAll decorator cannot be used on methods. (Method: ${String(propertyKey)})`);
|
|
37
|
+
}
|
|
38
|
+
const constructor = targetObj.constructor;
|
|
39
|
+
let queries = import_core.ReflectUtils.getMetadata(QUERY_ALL_METADATA_KEY, constructor);
|
|
40
|
+
if (!queries) {
|
|
41
|
+
queries = [];
|
|
42
|
+
import_core.ReflectUtils.defineMetadata(QUERY_ALL_METADATA_KEY, queries, constructor);
|
|
43
|
+
}
|
|
44
|
+
queries.push({ propertyKey, selector: selectorOrTarget, options: optionsOrPropertyKey || {} });
|
|
45
|
+
Object.defineProperty(targetObj, propertyKey, {
|
|
46
|
+
get() {
|
|
47
|
+
(0, import_elementDefine.ensureInit)(this);
|
|
112
48
|
const selector = selectorOrTarget;
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
49
|
+
const r = optionsOrPropertyKey?.root || "auto";
|
|
50
|
+
const applyRoot = (t) => {
|
|
51
|
+
if (!t)
|
|
52
|
+
return [];
|
|
53
|
+
const items = Array.isArray(t) ? t : [t];
|
|
54
|
+
const results = [];
|
|
55
|
+
items.forEach((it) => {
|
|
56
|
+
if (!(it instanceof HTMLElement)) {
|
|
57
|
+
results.push(it);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (r === "auto")
|
|
61
|
+
results.push(it.shadowRoot || it);
|
|
62
|
+
else {
|
|
63
|
+
if (r === "light" || r === "all")
|
|
64
|
+
results.push(it);
|
|
65
|
+
if ((r === "shadow" || r === "all") && it.shadowRoot)
|
|
66
|
+
results.push(it.shadowRoot);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
return results;
|
|
70
|
+
};
|
|
71
|
+
const hostSet = import_Utils.SwcUtils.getHostSet(this);
|
|
72
|
+
if (selector === "$hosts")
|
|
73
|
+
return applyRoot(hostSet.$hosts);
|
|
74
|
+
if (selector === "$appHosts")
|
|
75
|
+
return applyRoot(hostSet.$appHosts);
|
|
76
|
+
if (selector === "$host")
|
|
77
|
+
return applyRoot(hostSet.$host);
|
|
78
|
+
if (selector === "$parentHost")
|
|
79
|
+
return applyRoot(hostSet.$parentHost);
|
|
80
|
+
if (selector === "$appHost")
|
|
81
|
+
return applyRoot(hostSet.$appHost);
|
|
82
|
+
if (selector === "$firstHost")
|
|
83
|
+
return applyRoot(hostSet.$firstHost);
|
|
84
|
+
if (selector === "$lastHost")
|
|
85
|
+
return applyRoot(hostSet.$lastHost);
|
|
86
|
+
if (selector === "$firstAppHost")
|
|
87
|
+
return applyRoot(hostSet.$firstAppHost);
|
|
88
|
+
if (selector === "$lastAppHost")
|
|
89
|
+
return applyRoot(hostSet.$lastAppHost);
|
|
90
|
+
const config = (0, import_elementDefine.getElementConfig)(this);
|
|
91
|
+
const win = config?.window || window;
|
|
92
|
+
if (selector === "$window")
|
|
93
|
+
return [win];
|
|
94
|
+
if (selector === "$document")
|
|
95
|
+
return [win.document];
|
|
96
|
+
if (selector === "$this")
|
|
97
|
+
return applyRoot(this);
|
|
117
98
|
if (r === "shadow")
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
99
|
+
return this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];
|
|
100
|
+
if (r === "light")
|
|
101
|
+
return Array.from(this.querySelectorAll(selector));
|
|
102
|
+
if (r === "all") {
|
|
122
103
|
const sNodes = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];
|
|
123
104
|
const lNodes = Array.from(this.querySelectorAll(selector));
|
|
124
|
-
|
|
125
|
-
} else {
|
|
126
|
-
targets = Array.from((this.shadowRoot || this).querySelectorAll(selector));
|
|
105
|
+
return [...sNodes, ...lNodes];
|
|
127
106
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
158
|
-
return queryAll("$appHost", {})(targetOrOptions, propertyKey);
|
|
159
|
-
}
|
|
160
|
-
if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
|
|
161
|
-
return queryAll("$appHost", targetOrOptions);
|
|
162
|
-
} else {
|
|
163
|
-
return queryAll("$appHost", {});
|
|
107
|
+
const root = this.shadowRoot || this;
|
|
108
|
+
return Array.from(root.querySelectorAll(selector));
|
|
109
|
+
},
|
|
110
|
+
set(nv) {
|
|
111
|
+
(0, import_elementDefine.ensureInit)(this);
|
|
112
|
+
if (nv === null || nv === void 0 || Array.isArray(nv) && nv.length === 0) {
|
|
113
|
+
const selector = selectorOrTarget;
|
|
114
|
+
if (selector.startsWith("$") && selector !== "$this")
|
|
115
|
+
return;
|
|
116
|
+
const r = optionsOrPropertyKey?.root || "auto";
|
|
117
|
+
let targets = [];
|
|
118
|
+
if (r === "shadow")
|
|
119
|
+
targets = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];
|
|
120
|
+
else if (r === "light")
|
|
121
|
+
targets = Array.from(this.querySelectorAll(selector));
|
|
122
|
+
else if (r === "all") {
|
|
123
|
+
const sNodes = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];
|
|
124
|
+
const lNodes = Array.from(this.querySelectorAll(selector));
|
|
125
|
+
targets = [...sNodes, ...lNodes];
|
|
126
|
+
} else {
|
|
127
|
+
targets = Array.from((this.shadowRoot || this).querySelectorAll(selector));
|
|
128
|
+
}
|
|
129
|
+
targets.forEach((t) => t.remove());
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
enumerable: true,
|
|
133
|
+
configurable: true
|
|
134
|
+
});
|
|
135
|
+
};
|
|
164
136
|
}
|
|
137
|
+
return queryAll("$this", selectorOrTarget);
|
|
165
138
|
}
|
|
166
139
|
const getQueryAllMetadata = (target) => {
|
|
167
140
|
const constructor = target instanceof Function ? target : target.constructor;
|