@dooboostore/simple-web-component 1.0.44 → 1.0.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -25
- package/dist/cjs/decorators/addEventListener.js.map +2 -2
- package/dist/cjs/decorators/applyAttribute.js +36 -15
- package/dist/cjs/decorators/applyAttribute.js.map +2 -2
- package/dist/cjs/decorators/applyClass.js +53 -22
- package/dist/cjs/decorators/applyClass.js.map +2 -2
- package/dist/cjs/decorators/applyNode.js +54 -24
- package/dist/cjs/decorators/applyNode.js.map +2 -2
- package/dist/cjs/decorators/applyProperty.js +38 -17
- package/dist/cjs/decorators/applyProperty.js.map +2 -2
- package/dist/cjs/decorators/applyStyle.js +53 -22
- package/dist/cjs/decorators/applyStyle.js.map +2 -2
- package/dist/cjs/decorators/elementDefine.js +49 -33
- package/dist/cjs/decorators/elementDefine.js.map +3 -3
- package/dist/cjs/decorators/emitCustomEvent.js +61 -47
- package/dist/cjs/decorators/emitCustomEvent.js.map +2 -2
- package/dist/cjs/decorators/lifecycles.js +11 -36
- package/dist/cjs/decorators/lifecycles.js.map +2 -2
- package/dist/cjs/decorators/query.js +91 -56
- package/dist/cjs/decorators/query.js.map +2 -2
- package/dist/cjs/decorators/queryAll.js +104 -66
- package/dist/cjs/decorators/queryAll.js.map +2 -2
- package/dist/cjs/elements/SwcAppMixin.js +6 -2
- package/dist/cjs/elements/SwcAppMixin.js.map +2 -2
- package/dist/cjs/types/window.d.js.map +1 -1
- package/dist/esm/decorators/addEventListener.js.map +2 -2
- package/dist/esm/decorators/applyAttribute.js +36 -15
- package/dist/esm/decorators/applyAttribute.js.map +2 -2
- package/dist/esm/decorators/applyClass.js +53 -22
- package/dist/esm/decorators/applyClass.js.map +2 -2
- package/dist/esm/decorators/applyNode.js +54 -24
- package/dist/esm/decorators/applyNode.js.map +2 -2
- package/dist/esm/decorators/applyProperty.js +38 -17
- package/dist/esm/decorators/applyProperty.js.map +2 -2
- package/dist/esm/decorators/applyStyle.js +53 -22
- package/dist/esm/decorators/applyStyle.js.map +2 -2
- package/dist/esm/decorators/elementDefine.js +50 -34
- package/dist/esm/decorators/elementDefine.js.map +2 -2
- package/dist/esm/decorators/emitCustomEvent.js +61 -47
- package/dist/esm/decorators/emitCustomEvent.js.map +2 -2
- package/dist/esm/decorators/lifecycles.js +11 -36
- package/dist/esm/decorators/lifecycles.js.map +2 -2
- package/dist/esm/decorators/query.js +91 -56
- package/dist/esm/decorators/query.js.map +2 -2
- package/dist/esm/decorators/queryAll.js +104 -66
- package/dist/esm/decorators/queryAll.js.map +2 -2
- package/dist/esm/elements/SwcAppMixin.js +6 -2
- package/dist/esm/elements/SwcAppMixin.js.map +2 -2
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +572 -320
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +3 -3
- package/dist/types/decorators/addEventListener.d.ts +7 -6
- package/dist/types/decorators/addEventListener.d.ts.map +1 -1
- package/dist/types/decorators/applyAttribute.d.ts +13 -8
- package/dist/types/decorators/applyAttribute.d.ts.map +1 -1
- package/dist/types/decorators/applyClass.d.ts +8 -7
- package/dist/types/decorators/applyClass.d.ts.map +1 -1
- package/dist/types/decorators/applyNode.d.ts +18 -17
- package/dist/types/decorators/applyNode.d.ts.map +1 -1
- package/dist/types/decorators/applyProperty.d.ts +14 -9
- package/dist/types/decorators/applyProperty.d.ts.map +1 -1
- package/dist/types/decorators/applyStyle.d.ts +6 -5
- package/dist/types/decorators/applyStyle.d.ts.map +1 -1
- package/dist/types/decorators/elementDefine.d.ts.map +1 -1
- package/dist/types/decorators/emitCustomEvent.d.ts +3 -2
- package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
- package/dist/types/decorators/lifecycles.d.ts +12 -13
- package/dist/types/decorators/lifecycles.d.ts.map +1 -1
- package/dist/types/decorators/query.d.ts +15 -5
- package/dist/types/decorators/query.d.ts.map +1 -1
- package/dist/types/decorators/queryAll.d.ts +15 -5
- package/dist/types/decorators/queryAll.d.ts.map +1 -1
- package/dist/types/elements/SwcAppMixin.d.ts.map +1 -1
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +572 -320
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +3 -3
- package/package.json +3 -3
- package/src/decorators/addEventListener.ts +9 -7
- package/src/decorators/applyAttribute.ts +60 -27
- package/src/decorators/applyClass.ts +78 -32
- package/src/decorators/applyNode.ts +118 -73
- package/src/decorators/applyProperty.ts +63 -30
- package/src/decorators/applyStyle.ts +76 -30
- package/src/decorators/elementDefine.ts +57 -37
- package/src/decorators/emitCustomEvent.ts +63 -39
- package/src/decorators/lifecycles.ts +53 -52
- package/src/decorators/query.ts +111 -49
- package/src/decorators/queryAll.ts +121 -61
- package/src/elements/SwcAppMixin.ts +7 -3
- package/src/types/window.d.ts +3 -0
- package/dist/cjs/examples/RxJSOperatorsExample.js +0 -285
- package/dist/cjs/examples/RxJSOperatorsExample.js.map +0 -7
- package/dist/esm/examples/RxJSOperatorsExample.js +0 -266
- package/dist/esm/examples/RxJSOperatorsExample.js.map +0 -7
- package/dist/types/examples/RxJSOperatorsExample.d.ts +0 -94
- package/dist/types/examples/RxJSOperatorsExample.d.ts.map +0 -1
- package/src/examples/RxJSOperatorsExample.ts +0 -279
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/decorators/lifecycles.ts"],
|
|
4
|
-
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\n\nexport const ON_INITIALIZE_METADATA_KEY = Symbol.for('simple-web-component:on-constructor');\nexport const ON_BEFORE_CONNECTED_METADATA_KEY = Symbol.for('simple-web-component:on-before-connected');\nexport const ON_AFTER_CONNECTED_METADATA_KEY = Symbol.for('simple-web-component:on-after-connected');\nexport const ON_BEFORE_DISCONNECTED_METADATA_KEY = Symbol.for('simple-web-component:on-before-disconnected');\nexport const ON_AFTER_DISCONNECTED_METADATA_KEY = Symbol.for('simple-web-component:on-after-disconnected');\nexport const ON_BEFORE_ADOPTED_METADATA_KEY = Symbol.for('simple-web-component:on-before-adopted');\nexport const ON_AFTER_ADOPTED_METADATA_KEY = Symbol.for('simple-web-component:on-after-adopted');\nexport const ON_ADD_EVENT_LISTENER_METADATA_KEY = Symbol.for('simple-web-component:on-add-event-listener');\nexport const ON_CONNECTED_METADATA_KEY = Symbol.for('simple-web-component');\nexport const ON_CONNECTED_SWC_APP_METADATA_KEY = Symbol.for('simple-web-component:on-connected-swc-app');\nexport const ON_CONNECTED_COMPLETED_METADATA_KEY = Symbol.for('simple-web-component:on-completed');\n\nexport const ATTRIBUTE_CHANGED_WILDCARD = '*';\n\nexport interface InnerHtmlOptions {\n ssrFirst?: boolean;\n // replaceWrap?:{ start: string, end:string},\n useShadow?: boolean;\n}\nexport interface InnerHtmlMetadata {\n propertyKey: string | symbol;\n options: InnerHtmlOptions;\n}\n\nexport interface OnConnectedOptions {\n ssrFirst?: boolean;\n order?: number;\n}\nexport interface OnConnectedMetadata {\n propertyKey: string | symbol;\n options: OnConnectedOptions;\n}\n\nexport interface LifecycleOptions {\n order?: number;\n}\nexport interface LifecycleMetadata {\n propertyKey: string | symbol;\n order?: number;\n}\n\n\nexport function onConnectedBefore(options: OnConnectedOptions): MethodDecorator;\nexport function onConnectedBefore(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function onConnectedBefore(arg1?: OnConnectedOptions | Object, arg2?: string | symbol, arg3?: PropertyDescriptor): MethodDecorator | void {\n const decorator = (options: OnConnectedOptions, target: Object, propertyKey: string | symbol) => {\n const constructor = target.constructor;\n let list = ReflectUtils.getMetadata<OnConnectedMetadata[]>(ON_BEFORE_CONNECTED_METADATA_KEY, constructor);\n if (!list) {\n list = [];\n ReflectUtils.defineMetadata(ON_BEFORE_CONNECTED_METADATA_KEY, list, constructor);\n }\n list.push({ propertyKey, options });\n };\n\n if (arg2) {\n return decorator({}, arg1!, arg2);\n }\n\n return (target: Object, propertyKey: string | symbol) => {\n decorator((arg1 as OnConnectedOptions) || {}, target, propertyKey);\n };\n}\n\nexport function onConnectedAfter(options: OnConnectedOptions): MethodDecorator;\nexport function onConnectedAfter(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function onConnectedAfter(arg1?: OnConnectedOptions | Object, arg2?: string | symbol, arg3?: PropertyDescriptor): MethodDecorator | void {\n const decorator = (options: OnConnectedOptions, target: Object, propertyKey: string | symbol) => {\n const constructor = target.constructor;\n let list = ReflectUtils.getMetadata<OnConnectedMetadata[]>(ON_AFTER_CONNECTED_METADATA_KEY, constructor);\n if (!list) {\n list = [];\n ReflectUtils.defineMetadata(ON_AFTER_CONNECTED_METADATA_KEY, list, constructor);\n }\n list.push({ propertyKey, options });\n };\n\n if (arg2) {\n return decorator({}, arg1!, arg2);\n }\n\n return (target: Object, propertyKey: string | symbol) => {\n decorator((arg1 as OnConnectedOptions) || {}, target, propertyKey);\n };\n}\n\n\nfunction createLifecycleDecorator(metadataKey: symbol): ((options?: LifecycleOptions) => MethodDecorator) & MethodDecorator {\n const decorator = (options?: LifecycleOptions): MethodDecorator => {\n return (target: Object, propertyKey: string | symbol) => {\n const constructor = target.constructor;\n let list = ReflectUtils.getOwnMetadata(metadataKey, constructor) as LifecycleMetadata[];\n if (!list) {\n list = [];\n ReflectUtils.defineMetadata(metadataKey, list, constructor);\n }\n list.push({ propertyKey, order: options?.order ?? 0 });\n };\n };\n\n // Support both @decorator and @decorator() syntax\n return Object.assign(\n (target: Object, propertyKey: string | symbol) => {\n const constructor = target.constructor;\n let list = ReflectUtils.getOwnMetadata(metadataKey, constructor) as LifecycleMetadata[];\n if (!list) {\n list = [];\n ReflectUtils.defineMetadata(metadataKey, list, constructor);\n }\n list.push({ propertyKey, order: 0 });\n },\n { __isDecorator: true, __decorator: decorator }\n ) as any;\n}\n\n// Helper to handle both @decorator and @decorator() syntax\nfunction createLifecycleDecoratorWithOptions(metadataKey: symbol) {\n return function(optionOrTarget?: LifecycleOptions | Object, propertyKey?: string | symbol): MethodDecorator | void {\n if (propertyKey) {\n // Direct decorator usage: @decorator\n const constructor = (optionOrTarget as Object).constructor;\n let list = ReflectUtils.getOwnMetadata(metadataKey, constructor) as LifecycleMetadata[];\n if (!list) {\n list = [];\n ReflectUtils.defineMetadata(metadataKey, list, constructor);\n }\n list.push({ propertyKey, order: 0 });\n return;\n }\n\n // Decorator with options: @decorator({ order: 1 })\n return (target: Object, propertyKey: string | symbol) => {\n const constructor = target.constructor;\n let list = ReflectUtils.getOwnMetadata(metadataKey, constructor) as LifecycleMetadata[];\n if (!list) {\n list = [];\n ReflectUtils.defineMetadata(metadataKey, list, constructor);\n }\n list.push({ propertyKey, order: (optionOrTarget as LifecycleOptions)?.order ?? 0 });\n };\n };\n}\n\nexport function onInitialize(options?: LifecycleOptions): MethodDecorator;\nexport function onInitialize(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function onInitialize(optionOrTarget?: LifecycleOptions | Object, propertyKey?: string | symbol): MethodDecorator | void {\n return createLifecycleDecoratorWithOptions(ON_INITIALIZE_METADATA_KEY)(optionOrTarget, propertyKey);\n}\n\nexport function onDisconnectedBefore(options?: LifecycleOptions): MethodDecorator;\nexport function onDisconnectedBefore(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function onDisconnectedBefore(optionOrTarget?: LifecycleOptions | Object, propertyKey?: string | symbol): MethodDecorator | void {\n return createLifecycleDecoratorWithOptions(ON_BEFORE_DISCONNECTED_METADATA_KEY)(optionOrTarget, propertyKey);\n}\n\nexport function onDisconnectedAfter(options?: LifecycleOptions): MethodDecorator;\nexport function onDisconnectedAfter(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function onDisconnectedAfter(optionOrTarget?: LifecycleOptions | Object, propertyKey?: string | symbol): MethodDecorator | void {\n return createLifecycleDecoratorWithOptions(ON_AFTER_DISCONNECTED_METADATA_KEY)(optionOrTarget, propertyKey);\n}\n\nexport const onDisconnected = onDisconnectedAfter;\n\nexport function onAdoptedBefore(options?: LifecycleOptions): MethodDecorator;\nexport function onAdoptedBefore(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function onAdoptedBefore(optionOrTarget?: LifecycleOptions | Object, propertyKey?: string | symbol): MethodDecorator | void {\n return createLifecycleDecoratorWithOptions(ON_BEFORE_ADOPTED_METADATA_KEY)(optionOrTarget, propertyKey);\n}\n\nexport function onAdoptedAfter(options?: LifecycleOptions): MethodDecorator;\nexport function onAdoptedAfter(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function onAdoptedAfter(optionOrTarget?: LifecycleOptions | Object, propertyKey?: string | symbol): MethodDecorator | void {\n return createLifecycleDecoratorWithOptions(ON_AFTER_ADOPTED_METADATA_KEY)(optionOrTarget, propertyKey);\n}\n\nexport const onAdopted = onAdoptedAfter;\n\nexport function onConnectedSwcApp(options?: LifecycleOptions): MethodDecorator;\nexport function onConnectedSwcApp(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function onConnectedSwcApp(optionOrTarget?: LifecycleOptions | Object, propertyKey?: string | symbol): MethodDecorator | void {\n return createLifecycleDecoratorWithOptions(ON_CONNECTED_SWC_APP_METADATA_KEY)(optionOrTarget, propertyKey);\n}\n\nexport function onConnectedCompleted(options?: LifecycleOptions): MethodDecorator;\nexport function onConnectedCompleted(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function onConnectedCompleted(optionOrTarget?: LifecycleOptions | Object, propertyKey?: string | symbol): MethodDecorator | void {\n return createLifecycleDecoratorWithOptions(ON_CONNECTED_COMPLETED_METADATA_KEY)(optionOrTarget, propertyKey);\n}\n\n\n\n\n\nconst decorator = (options: InnerHtmlOptions, target: Object, propertyKey: string | symbol) => {\n const constructor = target.constructor;\n let list = ReflectUtils.getMetadata<InnerHtmlMetadata[]>(ON_CONNECTED_METADATA_KEY, constructor);\n if (!list) {\n list = [];\n ReflectUtils.defineMetadata(ON_CONNECTED_METADATA_KEY, list, constructor);\n }\n list.push({ propertyKey, options });\n};\n\nexport function onConnectedShadow(options: Omit<InnerHtmlOptions, 'useShadow'>): MethodDecorator; // \uD30C\uB77C\uBBF8\uD130\uC788\uC74C\nexport function onConnectedShadow(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void; // \uD30C\uB77C\uBBF8\uD130\uC5C6\uC74C\nexport function onConnectedShadow(optionOrTarget: Omit<InnerHtmlOptions, 'useShadow'> | Object, propertyKey?: string | symbol, arg3?: PropertyDescriptor): MethodDecorator | void {\n if (propertyKey) { // no parameter option @decorator\n return decorator({useShadow: true}, optionOrTarget!, propertyKey);\n }\n // parameter option @decorator()\n return (target: Object, propertyKey: string | symbol) => {\n decorator({...optionOrTarget??{}, useShadow: true}, target, propertyKey);\n };\n}\n\nexport function onConnectedLight(options: Omit<InnerHtmlOptions, 'useShadow'>): MethodDecorator; // \uD30C\uB77C\uBBF8\uD130\uC788\uC74C\nexport function onConnectedLight(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void; // \uD30C\uB77C\uBBF8\uD130\uC5C6\uC74C\nexport function onConnectedLight(optionOrTarget: Omit<InnerHtmlOptions, 'useShadow'> | Object, propertyKey?: string | symbol, arg3?: PropertyDescriptor): MethodDecorator | void {\n if (propertyKey) { // no parameter option @decorator\n return decorator({useShadow: false}, optionOrTarget!, propertyKey);\n }\n // parameter option @decorator()\n return (target: Object, propertyKey: string | symbol) => {\n decorator({...optionOrTarget??{}, useShadow: false}, target, propertyKey);\n };\n}\nexport function onConnected(options: InnerHtmlOptions): MethodDecorator;\nexport function onConnected(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function onConnected(optionOrTarget: InnerHtmlOptions | Object, propertyKey?: string | symbol, arg3?: PropertyDescriptor): MethodDecorator | void {\n if (propertyKey) { // no parameter option @decorator\n return decorator({}, optionOrTarget!, propertyKey);\n }\n // parameter option @decorator()\n return (target: Object, propertyKey: string | symbol) => {\n decorator((optionOrTarget as InnerHtmlOptions) || {}, target, propertyKey);\n };\n}\n\n/**\n * \uD504\uB85C\uD1A0\uD0C0\uC785 \uCCB4\uC778\uC744 \uC21C\uD68C\uD558\uBA70 \uBAA8\uB4E0 \uB77C\uC774\uD504\uC0AC\uC774\uD074 \uBA54\uC11C\uB4DC\uB97C \uC218\uC9D1\uD569\uB2C8\uB2E4.\n */\nexport const findAllLifecycleMetadata = (target: any, metadataKey: symbol): LifecycleMetadata[] => {\n const constructor = target instanceof Function ? target : target.constructor;\n const results = ReflectUtils.getOwnMetadata(metadataKey, constructor) as LifecycleMetadata[] ?? [];\n // Sort by order (default 0 if not specified)\n return [...results].sort((a, b) => (a.order ?? 0) - (b.order ?? 0));\n};\n\nexport const findAllOnConnectedMetadata = (target: any): InnerHtmlMetadata[] => {\n const constructor = target instanceof Function ? target : target.constructor;\n const results = ReflectUtils.getMetadata(ON_CONNECTED_METADATA_KEY, constructor) ?? [];\n // Sort by order (default 0 if not specified)\n return [...results].sort((a, b) => {\n const orderA = (a.options as any)?.order ?? 0;\n const orderB = (b.options as any)?.order ?? 0;\n return orderA - orderB;\n });\n};\n\nexport const findAllOnConnectedBeforeMetadata = (target: any): OnConnectedMetadata[] => {\n const constructor = target instanceof Function ? target : target.constructor;\n const results = ReflectUtils.getMetadata(ON_BEFORE_CONNECTED_METADATA_KEY, constructor) ?? [];\n // Sort by order\n return [...results].sort((a, b) => (a.options?.order ?? 0) - (b.options?.order ?? 0));\n};\n\nexport const findAllOnConnectedAfterMetadata = (target: any): OnConnectedMetadata[] => {\n const constructor = target instanceof Function ? target : target.constructor;\n const results = ReflectUtils.getMetadata(ON_AFTER_CONNECTED_METADATA_KEY, constructor) ?? [];\n // Sort by order\n return [...results].sort((a, b) => (a.options?.order ?? 0) - (b.options?.order ?? 0));\n};\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,oBAAoB;AAEtB,MAAM,6BAA6B,OAAO,IAAI,qCAAqC;AACnF,MAAM,mCAAmC,OAAO,IAAI,0CAA0C;AAC9F,MAAM,kCAAkC,OAAO,IAAI,yCAAyC;AAC5F,MAAM,sCAAsC,OAAO,IAAI,6CAA6C;AACpG,MAAM,qCAAqC,OAAO,IAAI,4CAA4C;AAClG,MAAM,iCAAiC,OAAO,IAAI,wCAAwC;AAC1F,MAAM,gCAAgC,OAAO,IAAI,uCAAuC;AACxF,MAAM,qCAAqC,OAAO,IAAI,4CAA4C;AAClG,MAAM,
|
|
4
|
+
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\n\nexport const ON_INITIALIZE_METADATA_KEY = Symbol.for('simple-web-component:on-constructor');\nexport const ON_BEFORE_CONNECTED_METADATA_KEY = Symbol.for('simple-web-component:on-before-connected');\nexport const ON_AFTER_CONNECTED_METADATA_KEY = Symbol.for('simple-web-component:on-after-connected');\nexport const ON_BEFORE_DISCONNECTED_METADATA_KEY = Symbol.for('simple-web-component:on-before-disconnected');\nexport const ON_AFTER_DISCONNECTED_METADATA_KEY = Symbol.for('simple-web-component:on-after-disconnected');\nexport const ON_BEFORE_ADOPTED_METADATA_KEY = Symbol.for('simple-web-component:on-before-adopted');\nexport const ON_AFTER_ADOPTED_METADATA_KEY = Symbol.for('simple-web-component:on-after-adopted');\nexport const ON_ADD_EVENT_LISTENER_METADATA_KEY = Symbol.for('simple-web-component:on-add-event-listener');\nexport const ON_CONNECTED_BODY_METADATA_KEY = Symbol.for('simple-web-component:on-connected-body');\nexport const ON_CONNECTED_SWC_APP_METADATA_KEY = Symbol.for('simple-web-component:on-connected-swc-app');\nexport const ON_CONNECTED_COMPLETED_METADATA_KEY = Symbol.for('simple-web-component:on-completed');\n\nexport const ATTRIBUTE_CHANGED_WILDCARD = '*';\n\nexport interface OnConnectedAppendChildOptions {\n // ssrFirst?: boolean;\n // replaceWrap?:{ start: string, end:string},\n useShadow?: boolean;\n order?: number;\n}\nexport interface OnConnectedAppendChildOptionsMetadata {\n propertyKey: string | symbol;\n options: OnConnectedAppendChildOptions;\n}\n\nexport interface OnConnectedOptions {\n // ssrFirst?: boolean;\n order?: number;\n}\nexport interface OnConnectedMetadata {\n propertyKey: string | symbol;\n options: OnConnectedOptions;\n}\n\nexport interface LifecycleOptions {\n order?: number;\n}\nexport interface LifecycleMetadata {\n propertyKey: string | symbol;\n order?: number;\n}\n\n\nexport function onConnectedBefore(options: OnConnectedOptions): MethodDecorator;\nexport function onConnectedBefore(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function onConnectedBefore(arg1?: OnConnectedOptions | Object, arg2?: string | symbol, arg3?: PropertyDescriptor): MethodDecorator | void {\n const decorator = (options: OnConnectedOptions, target: Object, propertyKey: string | symbol) => {\n const constructor = target.constructor;\n let list = ReflectUtils.getMetadata<OnConnectedMetadata[]>(ON_BEFORE_CONNECTED_METADATA_KEY, constructor);\n if (!list) {\n list = [];\n ReflectUtils.defineMetadata(ON_BEFORE_CONNECTED_METADATA_KEY, list, constructor);\n }\n list.push({ propertyKey, options });\n };\n\n if (arg2) {\n return decorator({}, arg1!, arg2);\n }\n\n return (target: Object, propertyKey: string | symbol) => {\n decorator((arg1 as OnConnectedOptions) || {}, target, propertyKey);\n };\n}\n\nexport function onConnectedAfter(options: OnConnectedOptions): MethodDecorator;\nexport function onConnectedAfter(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function onConnectedAfter(arg1?: OnConnectedOptions | Object, arg2?: string | symbol, arg3?: PropertyDescriptor): MethodDecorator | void {\n const decorator = (options: OnConnectedOptions, target: Object, propertyKey: string | symbol) => {\n const constructor = target.constructor;\n let list = ReflectUtils.getMetadata<OnConnectedMetadata[]>(ON_AFTER_CONNECTED_METADATA_KEY, constructor);\n if (!list) {\n list = [];\n ReflectUtils.defineMetadata(ON_AFTER_CONNECTED_METADATA_KEY, list, constructor);\n }\n list.push({ propertyKey, options });\n };\n\n if (arg2) {\n return decorator({}, arg1!, arg2);\n }\n\n return (target: Object, propertyKey: string | symbol) => {\n decorator((arg1 as OnConnectedOptions) || {}, target, propertyKey);\n };\n}\n\n\n// function createLifecycleDecorator(metadataKey: symbol): ((options?: LifecycleOptions) => MethodDecorator) & MethodDecorator {\n// const decorator = (options?: LifecycleOptions): MethodDecorator => {\n// return (target: Object, propertyKey: string | symbol) => {\n// const constructor = target.constructor;\n// let list = ReflectUtils.getOwnMetadata(metadataKey, constructor) as LifecycleMetadata[];\n// if (!list) {\n// list = [];\n// ReflectUtils.defineMetadata(metadataKey, list, constructor);\n// }\n// list.push({ propertyKey, order: options?.order ?? 0 });\n// };\n// };\n//\n// // Support both @decorator and @decorator() syntax\n// return Object.assign(\n// (target: Object, propertyKey: string | symbol) => {\n// const constructor = target.constructor;\n// let list = ReflectUtils.getOwnMetadata(metadataKey, constructor) as LifecycleMetadata[];\n// if (!list) {\n// list = [];\n// ReflectUtils.defineMetadata(metadataKey, list, constructor);\n// }\n// list.push({ propertyKey, order: 0 });\n// },\n// { __isDecorator: true, __decorator: decorator }\n// ) as any;\n// }\n\n// Helper to handle both @decorator and @decorator() syntax\nfunction createLifecycleDecoratorWithOptions(metadataKey: symbol) {\n return function(optionOrTarget?: LifecycleOptions | Object, propertyKey?: string | symbol): MethodDecorator | void {\n if (propertyKey) {\n // Direct decorator usage: @decorator\n const constructor = (optionOrTarget as Object).constructor;\n let list = ReflectUtils.getOwnMetadata(metadataKey, constructor) as LifecycleMetadata[];\n if (!list) {\n list = [];\n ReflectUtils.defineMetadata(metadataKey, list, constructor);\n }\n list.push({ propertyKey, order: 0 });\n return;\n }\n\n // Decorator with options: @decorator({ order: 1 })\n return (target: Object, propertyKey: string | symbol) => {\n const constructor = target.constructor;\n let list = ReflectUtils.getOwnMetadata(metadataKey, constructor) as LifecycleMetadata[];\n if (!list) {\n list = [];\n ReflectUtils.defineMetadata(metadataKey, list, constructor);\n }\n list.push({ propertyKey, order: (optionOrTarget as LifecycleOptions)?.order ?? 0 });\n };\n };\n}\n\nexport function onInitialize(options?: LifecycleOptions): MethodDecorator;\nexport function onInitialize(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function onInitialize(optionOrTarget?: LifecycleOptions | Object, propertyKey?: string | symbol): MethodDecorator | void {\n return createLifecycleDecoratorWithOptions(ON_INITIALIZE_METADATA_KEY)(optionOrTarget, propertyKey);\n}\n\nexport function onDisconnectedBefore(options?: LifecycleOptions): MethodDecorator;\nexport function onDisconnectedBefore(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function onDisconnectedBefore(optionOrTarget?: LifecycleOptions | Object, propertyKey?: string | symbol): MethodDecorator | void {\n return createLifecycleDecoratorWithOptions(ON_BEFORE_DISCONNECTED_METADATA_KEY)(optionOrTarget, propertyKey);\n}\n\nexport function onDisconnectedAfter(options?: LifecycleOptions): MethodDecorator;\nexport function onDisconnectedAfter(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function onDisconnectedAfter(optionOrTarget?: LifecycleOptions | Object, propertyKey?: string | symbol): MethodDecorator | void {\n return createLifecycleDecoratorWithOptions(ON_AFTER_DISCONNECTED_METADATA_KEY)(optionOrTarget, propertyKey);\n}\n\nexport const onDisconnected = onDisconnectedAfter;\n\nexport function onAdoptedBefore(options?: LifecycleOptions): MethodDecorator;\nexport function onAdoptedBefore(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function onAdoptedBefore(optionOrTarget?: LifecycleOptions | Object, propertyKey?: string | symbol): MethodDecorator | void {\n return createLifecycleDecoratorWithOptions(ON_BEFORE_ADOPTED_METADATA_KEY)(optionOrTarget, propertyKey);\n}\n\nexport function onAdoptedAfter(options?: LifecycleOptions): MethodDecorator;\nexport function onAdoptedAfter(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function onAdoptedAfter(optionOrTarget?: LifecycleOptions | Object, propertyKey?: string | symbol): MethodDecorator | void {\n return createLifecycleDecoratorWithOptions(ON_AFTER_ADOPTED_METADATA_KEY)(optionOrTarget, propertyKey);\n}\n\nexport const onAdopted = onAdoptedAfter;\n\nexport function onConnectedSwcApp(options?: LifecycleOptions): MethodDecorator;\nexport function onConnectedSwcApp(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function onConnectedSwcApp(optionOrTarget?: LifecycleOptions | Object, propertyKey?: string | symbol): MethodDecorator | void {\n return createLifecycleDecoratorWithOptions(ON_CONNECTED_SWC_APP_METADATA_KEY)(optionOrTarget, propertyKey);\n}\n\nexport function onConnectedCompleted(options?: LifecycleOptions): MethodDecorator;\nexport function onConnectedCompleted(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function onConnectedCompleted(optionOrTarget?: LifecycleOptions | Object, propertyKey?: string | symbol): MethodDecorator | void {\n return createLifecycleDecoratorWithOptions(ON_CONNECTED_COMPLETED_METADATA_KEY)(optionOrTarget, propertyKey);\n}\n\n\n\n\n\nconst decorator = (options: OnConnectedAppendChildOptions, target: Object, propertyKey: string | symbol) => {\n const constructor = target.constructor;\n let list = ReflectUtils.getMetadata<OnConnectedAppendChildOptionsMetadata[]>(ON_CONNECTED_BODY_METADATA_KEY, constructor);\n if (!list) {\n list = [];\n ReflectUtils.defineMetadata(ON_CONNECTED_BODY_METADATA_KEY, list, constructor);\n }\n list.push({ propertyKey, options });\n};\n\nexport function onConnectedBodyShadow(options: Omit<OnConnectedAppendChildOptions, 'useShadow'>): MethodDecorator; // \uD30C\uB77C\uBBF8\uD130\uC788\uC74C\nexport function onConnectedBodyShadow(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void; // \uD30C\uB77C\uBBF8\uD130\uC5C6\uC74C\nexport function onConnectedBodyShadow(optionOrTarget: Omit<OnConnectedAppendChildOptions, 'useShadow'> | Object, propertyKey?: string | symbol, arg3?: PropertyDescriptor): MethodDecorator | void {\n if (propertyKey) { // no parameter option @decorator\n return decorator({useShadow: true}, optionOrTarget!, propertyKey);\n }\n // parameter option @decorator()\n return (target: Object, propertyKey: string | symbol) => {\n decorator({...optionOrTarget??{}, useShadow: true}, target, propertyKey);\n };\n}\n\nexport function onConnectedBodyLight(options: Omit<OnConnectedAppendChildOptions, 'useShadow'>): MethodDecorator; // \uD30C\uB77C\uBBF8\uD130\uC788\uC74C\nexport function onConnectedBodyLight(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void; // \uD30C\uB77C\uBBF8\uD130\uC5C6\uC74C\nexport function onConnectedBodyLight(optionOrTarget: Omit<OnConnectedAppendChildOptions, 'useShadow'> | Object, propertyKey?: string | symbol, arg3?: PropertyDescriptor): MethodDecorator | void {\n if (propertyKey) { // no parameter option @decorator\n return decorator({useShadow: false}, optionOrTarget!, propertyKey);\n }\n // parameter option @decorator()\n return (target: Object, propertyKey: string | symbol) => {\n decorator({...optionOrTarget??{}, useShadow: false}, target, propertyKey);\n };\n}\nexport function onConnectedBody(options: OnConnectedAppendChildOptions): MethodDecorator;\nexport function onConnectedBody(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function onConnectedBody(optionOrTarget: OnConnectedAppendChildOptions | Object, propertyKey?: string | symbol, arg3?: PropertyDescriptor): MethodDecorator | void {\n if (propertyKey) { // no parameter option @decorator\n return decorator({}, optionOrTarget!, propertyKey);\n }\n // parameter option @decorator()\n return (target: Object, propertyKey: string | symbol) => {\n decorator((optionOrTarget as OnConnectedAppendChildOptions) || {}, target, propertyKey);\n };\n}\n\n/**\n * \uD504\uB85C\uD1A0\uD0C0\uC785 \uCCB4\uC778\uC744 \uC21C\uD68C\uD558\uBA70 \uBAA8\uB4E0 \uB77C\uC774\uD504\uC0AC\uC774\uD074 \uBA54\uC11C\uB4DC\uB97C \uC218\uC9D1\uD569\uB2C8\uB2E4.\n */\nexport const findAllLifecycleMetadata = (target: any, metadataKey: symbol): LifecycleMetadata[] => {\n const constructor = target instanceof Function ? target : target.constructor;\n const results = ReflectUtils.getOwnMetadata(metadataKey, constructor) as LifecycleMetadata[] ?? [];\n // Sort by order (default 0 if not specified)\n return [...results].sort((a, b) => (a.order ?? 0) - (b.order ?? 0));\n};\n\nexport const findAllOnConnectedMetadata = (target: any): OnConnectedAppendChildOptionsMetadata[] => {\n const constructor = target instanceof Function ? target : target.constructor;\n const results = ReflectUtils.getMetadata<OnConnectedAppendChildOptionsMetadata[]>(ON_CONNECTED_BODY_METADATA_KEY, constructor) ?? [];\n // Sort by order (default 0 if not specified)\n return [...results].sort((a, b) => {\n const orderA = a.options?.order ?? 0;\n const orderB = b.options?.order ?? 0;\n return orderA - orderB;\n });\n};\n\nexport const findAllOnConnectedBeforeMetadata = (target: any): OnConnectedMetadata[] => {\n const constructor = target instanceof Function ? target : target.constructor;\n const results = ReflectUtils.getMetadata<OnConnectedMetadata[]>(ON_BEFORE_CONNECTED_METADATA_KEY, constructor) ?? [];\n // Sort by order\n return [...results].sort((a, b) => (a.options?.order ?? 0) - (b.options?.order ?? 0));\n};\n\nexport const findAllOnConnectedAfterMetadata = (target: any): OnConnectedMetadata[] => {\n const constructor = target instanceof Function ? target : target.constructor;\n const results = ReflectUtils.getMetadata<OnConnectedMetadata[]>(ON_AFTER_CONNECTED_METADATA_KEY, constructor) ?? [];\n // Sort by order\n return [...results].sort((a, b) => (a.options?.order ?? 0) - (b.options?.order ?? 0));\n};\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,oBAAoB;AAEtB,MAAM,6BAA6B,OAAO,IAAI,qCAAqC;AACnF,MAAM,mCAAmC,OAAO,IAAI,0CAA0C;AAC9F,MAAM,kCAAkC,OAAO,IAAI,yCAAyC;AAC5F,MAAM,sCAAsC,OAAO,IAAI,6CAA6C;AACpG,MAAM,qCAAqC,OAAO,IAAI,4CAA4C;AAClG,MAAM,iCAAiC,OAAO,IAAI,wCAAwC;AAC1F,MAAM,gCAAgC,OAAO,IAAI,uCAAuC;AACxF,MAAM,qCAAqC,OAAO,IAAI,4CAA4C;AAClG,MAAM,iCAAiC,OAAO,IAAI,wCAAwC;AAC1F,MAAM,oCAAoC,OAAO,IAAI,2CAA2C;AAChG,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,OAAO,EAAE,KAAK,CAAC,GAAG,MAAM;AACjC,UAAM,SAAS,EAAE,SAAS,SAAS;AACnC,UAAM,SAAS,EAAE,SAAS,SAAS;AACnC,WAAO,SAAS;AAAA,EAClB,CAAC;AACH;AAEO,MAAM,mCAAmC,CAAC,WAAuC;AACtF,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,QAAM,UAAU,aAAa,YAAmC,kCAAkC,WAAW,KAAK,CAAC;AAEnH,SAAO,CAAC,GAAG,OAAO,EAAE,KAAK,CAAC,GAAG,OAAO,EAAE,SAAS,SAAS,MAAM,EAAE,SAAS,SAAS,EAAE;AACtF;AAEO,MAAM,kCAAkC,CAAC,WAAuC;AACrF,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,QAAM,UAAU,aAAa,YAAmC,iCAAiC,WAAW,KAAK,CAAC;AAElH,SAAO,CAAC,GAAG,OAAO,EAAE,KAAK,CAAC,GAAG,OAAO,EAAE,SAAS,SAAS,MAAM,EAAE,SAAS,SAAS,EAAE;AACtF;",
|
|
6
6
|
"names": ["decorator", "propertyKey"]
|
|
7
7
|
}
|
|
@@ -6,7 +6,7 @@ function query(selectorOrTarget, optionsOrPropertyKey, descriptor) {
|
|
|
6
6
|
if (descriptor !== void 0 && (typeof optionsOrPropertyKey === "string" || typeof optionsOrPropertyKey === "symbol")) {
|
|
7
7
|
throw new Error(`@query decorator cannot be used on methods. (Method: ${String(optionsOrPropertyKey)})`);
|
|
8
8
|
}
|
|
9
|
-
if (typeof selectorOrTarget === "string") {
|
|
9
|
+
if (typeof selectorOrTarget === "string" || typeof selectorOrTarget === "function") {
|
|
10
10
|
return (targetObj, propertyKey, descriptor2) => {
|
|
11
11
|
if (descriptor2 !== void 0) {
|
|
12
12
|
throw new Error(`@query decorator cannot be used on methods. (Method: ${String(propertyKey)})`);
|
|
@@ -21,75 +21,110 @@ function query(selectorOrTarget, optionsOrPropertyKey, descriptor) {
|
|
|
21
21
|
Object.defineProperty(targetObj, propertyKey, {
|
|
22
22
|
get() {
|
|
23
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;
|
|
37
|
-
return t;
|
|
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
24
|
const config = getElementConfig(this);
|
|
57
25
|
const win = config?.window || window;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
|
+
}
|
|
36
|
+
} else {
|
|
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
|
+
}
|
|
83
|
+
}
|
|
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
|
+
}
|
|
69
89
|
}
|
|
70
|
-
return
|
|
90
|
+
return resolvedElement;
|
|
71
91
|
},
|
|
72
92
|
set(nv) {
|
|
73
93
|
ensureInit(this);
|
|
74
94
|
if (nv === null || nv === void 0) {
|
|
75
|
-
const
|
|
76
|
-
|
|
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")
|
|
77
112
|
return;
|
|
78
113
|
const r = optionsOrPropertyKey?.root || "auto";
|
|
79
114
|
const targets = [];
|
|
80
115
|
if (r === "shadow") {
|
|
81
|
-
if (this.shadowRoot?.querySelector(
|
|
82
|
-
targets.push(this.shadowRoot.querySelector(
|
|
116
|
+
if (this.shadowRoot?.querySelector(resolvedSelector))
|
|
117
|
+
targets.push(this.shadowRoot.querySelector(resolvedSelector));
|
|
83
118
|
} else if (r === "light") {
|
|
84
|
-
if (this.querySelector(
|
|
85
|
-
targets.push(this.querySelector(
|
|
119
|
+
if (this.querySelector(resolvedSelector))
|
|
120
|
+
targets.push(this.querySelector(resolvedSelector));
|
|
86
121
|
} else if (r === "all") {
|
|
87
|
-
if (this.shadowRoot?.querySelector(
|
|
88
|
-
targets.push(this.shadowRoot.querySelector(
|
|
89
|
-
if (this.querySelector(
|
|
90
|
-
targets.push(this.querySelector(
|
|
122
|
+
if (this.shadowRoot?.querySelector(resolvedSelector))
|
|
123
|
+
targets.push(this.shadowRoot.querySelector(resolvedSelector));
|
|
124
|
+
if (this.querySelector(resolvedSelector))
|
|
125
|
+
targets.push(this.querySelector(resolvedSelector));
|
|
91
126
|
} else {
|
|
92
|
-
const el = (this.shadowRoot || this).querySelector(
|
|
127
|
+
const el = (this.shadowRoot || this).querySelector(resolvedSelector);
|
|
93
128
|
if (el)
|
|
94
129
|
targets.push(el);
|
|
95
130
|
}
|
|
@@ -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;
|
|
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;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AM;gBACxB;cACF;AACA;YACF;AAEA,kBAAM,mBAAmB;AAEzB,gBAAI,iBAAiB,WAAW,GAAG,KAAK,qBAAqB;AAAS;AAEtE,kBAAM,IAAK,sBAAuC,QAAQ;AAC1D,kBAAM,UAAqB,CAAA;AAE3B,gBAAI,MAAM,UAAU;AAClB,kBAAI,KAAK,YAAY,cAAc,gBAAgB;AAAG,wBAAQ,KAAK,KAAK,WAAW,cAAc,gBAAgB,CAAE;YACrH,WAAW,MAAM,SAAS;AACxB,kBAAI,KAAK,cAAc,gBAAgB;AAAG,wBAAQ,KAAK,KAAK,cAAc,gBAAgB,CAAE;YAC9F,WAAW,MAAM,OAAO;AACtB,kBAAI,KAAK,YAAY,cAAc,gBAAgB;AAAG,wBAAQ,KAAK,KAAK,WAAW,cAAc,gBAAgB,CAAE;AACnH,kBAAI,KAAK,cAAc,gBAAgB;AAAG,wBAAQ,KAAK,KAAK,cAAc,gBAAgB,CAAE;YAC9F,OAAO;AACL,oBAAM,MAAM,KAAK,cAAc,MAAM,cAAc,gBAAgB;AACnE,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,aAAa,YAAY,oBAAoB,WAAW,KAAK,CAAA;AACtE;",
|
|
6
6
|
"names": ["descriptor"]
|
|
7
7
|
}
|
|
@@ -6,7 +6,7 @@ function queryAll(selectorOrTarget, optionsOrPropertyKey, descriptor) {
|
|
|
6
6
|
if (descriptor !== void 0 && (typeof optionsOrPropertyKey === "string" || typeof optionsOrPropertyKey === "symbol")) {
|
|
7
7
|
throw new Error(`@queryAll decorator cannot be used on methods. (Method: ${String(optionsOrPropertyKey)})`);
|
|
8
8
|
}
|
|
9
|
-
if (typeof selectorOrTarget === "string") {
|
|
9
|
+
if (typeof selectorOrTarget === "string" || typeof selectorOrTarget === "function") {
|
|
10
10
|
return (targetObj, propertyKey, descriptor2) => {
|
|
11
11
|
if (descriptor2 !== void 0) {
|
|
12
12
|
throw new Error(`@queryAll decorator cannot be used on methods. (Method: ${String(propertyKey)})`);
|
|
@@ -21,86 +21,124 @@ function queryAll(selectorOrTarget, optionsOrPropertyKey, descriptor) {
|
|
|
21
21
|
Object.defineProperty(targetObj, propertyKey, {
|
|
22
22
|
get() {
|
|
23
23
|
ensureInit(this);
|
|
24
|
-
const selector = selectorOrTarget;
|
|
25
|
-
const r = optionsOrPropertyKey?.root || "auto";
|
|
26
|
-
const applyRoot = (t) => {
|
|
27
|
-
if (!t)
|
|
28
|
-
return [];
|
|
29
|
-
const items = Array.isArray(t) ? t : [t];
|
|
30
|
-
const results = [];
|
|
31
|
-
items.forEach((it) => {
|
|
32
|
-
if (!(it instanceof HTMLElement)) {
|
|
33
|
-
results.push(it);
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
if (r === "auto")
|
|
37
|
-
results.push(it.shadowRoot || it);
|
|
38
|
-
else {
|
|
39
|
-
if (r === "light" || r === "all")
|
|
40
|
-
results.push(it);
|
|
41
|
-
if ((r === "shadow" || r === "all") && it.shadowRoot)
|
|
42
|
-
results.push(it.shadowRoot);
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
return results;
|
|
46
|
-
};
|
|
47
|
-
const hostSet = SwcUtils.getHostSet(this);
|
|
48
|
-
if (selector === "$hosts")
|
|
49
|
-
return applyRoot(hostSet.$hosts);
|
|
50
|
-
if (selector === "$appHosts")
|
|
51
|
-
return applyRoot(hostSet.$appHosts);
|
|
52
|
-
if (selector === "$host")
|
|
53
|
-
return applyRoot(hostSet.$host);
|
|
54
|
-
if (selector === "$parentHost")
|
|
55
|
-
return applyRoot(hostSet.$parentHost);
|
|
56
|
-
if (selector === "$appHost")
|
|
57
|
-
return applyRoot(hostSet.$appHost);
|
|
58
|
-
if (selector === "$firstHost")
|
|
59
|
-
return applyRoot(hostSet.$firstHost);
|
|
60
|
-
if (selector === "$lastHost")
|
|
61
|
-
return applyRoot(hostSet.$lastHost);
|
|
62
|
-
if (selector === "$firstAppHost")
|
|
63
|
-
return applyRoot(hostSet.$firstAppHost);
|
|
64
|
-
if (selector === "$lastAppHost")
|
|
65
|
-
return applyRoot(hostSet.$lastAppHost);
|
|
66
24
|
const config = getElementConfig(this);
|
|
67
25
|
const win = config?.window || window;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
const
|
|
81
|
-
|
|
26
|
+
const hostSet = SwcUtils.getHelperAndHostSet(win, this);
|
|
27
|
+
let resolvedSelector;
|
|
28
|
+
let resolvedElements = [];
|
|
29
|
+
if (typeof selectorOrTarget === "function") {
|
|
30
|
+
const result = selectorOrTarget(this, hostSet);
|
|
31
|
+
if (result instanceof win.NodeList) {
|
|
32
|
+
resolvedElements = Array.from(result).filter((el) => el instanceof win.HTMLElement);
|
|
33
|
+
} else if (Array.isArray(result)) {
|
|
34
|
+
resolvedElements = result.filter((el) => el instanceof win.HTMLElement);
|
|
35
|
+
}
|
|
36
|
+
} else {
|
|
37
|
+
resolvedSelector = selectorOrTarget;
|
|
38
|
+
const r = optionsOrPropertyKey?.root || "auto";
|
|
39
|
+
const applyRoot = (t) => {
|
|
40
|
+
if (!t)
|
|
41
|
+
return [];
|
|
42
|
+
const items = Array.isArray(t) ? t : [t];
|
|
43
|
+
const results = [];
|
|
44
|
+
items.forEach((it) => {
|
|
45
|
+
if (!(it instanceof HTMLElement)) {
|
|
46
|
+
results.push(it);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (r === "auto")
|
|
50
|
+
results.push(it.shadowRoot || it);
|
|
51
|
+
else {
|
|
52
|
+
if (r === "light" || r === "all")
|
|
53
|
+
results.push(it);
|
|
54
|
+
if ((r === "shadow" || r === "all") && it.shadowRoot)
|
|
55
|
+
results.push(it.shadowRoot);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
return results;
|
|
59
|
+
};
|
|
60
|
+
if (resolvedSelector === "$hosts")
|
|
61
|
+
resolvedElements = applyRoot(hostSet.$hosts).filter((el) => el instanceof HTMLElement);
|
|
62
|
+
else if (resolvedSelector === "$appHosts")
|
|
63
|
+
resolvedElements = applyRoot(hostSet.$appHosts).filter((el) => el instanceof HTMLElement);
|
|
64
|
+
else if (resolvedSelector === "$host")
|
|
65
|
+
resolvedElements = applyRoot(hostSet.$host).filter((el) => el instanceof HTMLElement);
|
|
66
|
+
else if (resolvedSelector === "$parentHost")
|
|
67
|
+
resolvedElements = applyRoot(hostSet.$parentHost).filter((el) => el instanceof HTMLElement);
|
|
68
|
+
else if (resolvedSelector === "$appHost")
|
|
69
|
+
resolvedElements = applyRoot(hostSet.$appHost).filter((el) => el instanceof HTMLElement);
|
|
70
|
+
else if (resolvedSelector === "$firstHost")
|
|
71
|
+
resolvedElements = applyRoot(hostSet.$firstHost).filter((el) => el instanceof HTMLElement);
|
|
72
|
+
else if (resolvedSelector === "$lastHost")
|
|
73
|
+
resolvedElements = applyRoot(hostSet.$lastHost).filter((el) => el instanceof HTMLElement);
|
|
74
|
+
else if (resolvedSelector === "$firstAppHost")
|
|
75
|
+
resolvedElements = applyRoot(hostSet.$firstAppHost).filter((el) => el instanceof HTMLElement);
|
|
76
|
+
else if (resolvedSelector === "$lastAppHost")
|
|
77
|
+
resolvedElements = applyRoot(hostSet.$lastAppHost).filter((el) => el instanceof HTMLElement);
|
|
78
|
+
else if (resolvedSelector === "$window")
|
|
79
|
+
return [win];
|
|
80
|
+
else if (resolvedSelector === "$document")
|
|
81
|
+
return [win.document];
|
|
82
|
+
else if (resolvedSelector === "$this")
|
|
83
|
+
resolvedElements = applyRoot(this).filter((el) => el instanceof HTMLElement);
|
|
84
|
+
else {
|
|
85
|
+
if (r === "shadow")
|
|
86
|
+
resolvedElements = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(resolvedSelector)) : [];
|
|
87
|
+
else if (r === "light")
|
|
88
|
+
resolvedElements = Array.from(this.querySelectorAll(resolvedSelector));
|
|
89
|
+
else if (r === "all") {
|
|
90
|
+
const sNodes = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(resolvedSelector)) : [];
|
|
91
|
+
const lNodes = Array.from(this.querySelectorAll(resolvedSelector));
|
|
92
|
+
resolvedElements = [...sNodes, ...lNodes];
|
|
93
|
+
} else
|
|
94
|
+
resolvedElements = Array.from((this.shadowRoot || this).querySelectorAll(resolvedSelector));
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (optionsOrPropertyKey?.filter) {
|
|
98
|
+
resolvedElements = resolvedElements.filter((el) => {
|
|
99
|
+
if (!(el instanceof win.HTMLElement))
|
|
100
|
+
return true;
|
|
101
|
+
return optionsOrPropertyKey.filter(el, { currentThis: this, helper: hostSet });
|
|
102
|
+
});
|
|
82
103
|
}
|
|
83
|
-
|
|
84
|
-
return Array.from(root.querySelectorAll(selector));
|
|
104
|
+
return resolvedElements;
|
|
85
105
|
},
|
|
86
106
|
set(nv) {
|
|
87
107
|
ensureInit(this);
|
|
88
108
|
if (nv === null || nv === void 0 || Array.isArray(nv) && nv.length === 0) {
|
|
89
|
-
const
|
|
90
|
-
|
|
109
|
+
const config = getElementConfig(this);
|
|
110
|
+
const win = config?.window || window;
|
|
111
|
+
const hostSet = SwcUtils.getHelperAndHostSet(win, this);
|
|
112
|
+
if (typeof selectorOrTarget === "function") {
|
|
113
|
+
const result = selectorOrTarget(this, hostSet);
|
|
114
|
+
if (result instanceof win.NodeList) {
|
|
115
|
+
Array.from(result).forEach((el) => {
|
|
116
|
+
if (el instanceof win.Element)
|
|
117
|
+
el.remove();
|
|
118
|
+
});
|
|
119
|
+
} else if (Array.isArray(result)) {
|
|
120
|
+
result.forEach((el) => {
|
|
121
|
+
if (el instanceof win.Element)
|
|
122
|
+
el.remove();
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
const resolvedSelector = selectorOrTarget;
|
|
128
|
+
if (resolvedSelector.startsWith("$") && resolvedSelector !== "$this")
|
|
91
129
|
return;
|
|
92
130
|
const r = optionsOrPropertyKey?.root || "auto";
|
|
93
131
|
let targets = [];
|
|
94
132
|
if (r === "shadow")
|
|
95
|
-
targets = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(
|
|
133
|
+
targets = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(resolvedSelector)) : [];
|
|
96
134
|
else if (r === "light")
|
|
97
|
-
targets = Array.from(this.querySelectorAll(
|
|
135
|
+
targets = Array.from(this.querySelectorAll(resolvedSelector));
|
|
98
136
|
else if (r === "all") {
|
|
99
|
-
const sNodes = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(
|
|
100
|
-
const lNodes = Array.from(this.querySelectorAll(
|
|
137
|
+
const sNodes = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(resolvedSelector)) : [];
|
|
138
|
+
const lNodes = Array.from(this.querySelectorAll(resolvedSelector));
|
|
101
139
|
targets = [...sNodes, ...lNodes];
|
|
102
140
|
} else {
|
|
103
|
-
targets = Array.from((this.shadowRoot || this).querySelectorAll(
|
|
141
|
+
targets = Array.from((this.shadowRoot || this).querySelectorAll(resolvedSelector));
|
|
104
142
|
}
|
|
105
143
|
targets.forEach((t) => t.remove());
|
|
106
144
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/decorators/queryAll.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 QueryAllMetadata {\n propertyKey: string | symbol;\n selector: string;\n options: SwcQueryOptions;\n}\n\nexport const QUERY_ALL_METADATA_KEY = Symbol.for('simple-web-component:query-all');\n\nexport function queryAll(target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor): PropertyDescriptor | void;\nexport function queryAll(selector: string, options?: SwcQueryOptions): PropertyDecorator;\nexport function queryAll(options?: SwcQueryOptions): PropertyDecorator;\n/**\n * @queryAll decorator to inject a list of elements into a class property.\n */\nexport function queryAll(selectorOrTarget?: string | Object, optionsOrPropertyKey?: SwcQueryOptions | string | symbol, descriptor?: PropertyDescriptor): any {\n // Bare decorator: @queryAll\n if (descriptor !== undefined && (typeof optionsOrPropertyKey === 'string' || typeof optionsOrPropertyKey === 'symbol')) {\n throw new Error(`@queryAll 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(`@queryAll decorator cannot be used on methods. (Method: ${String(propertyKey)})`);\n }\n\n const constructor = targetObj.constructor;\n let queries = ReflectUtils.getMetadata<QueryAllMetadata[]>(QUERY_ALL_METADATA_KEY, constructor);\n if (!queries) {\n queries = [];\n ReflectUtils.defineMetadata(QUERY_ALL_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): any[] => {\n if (!t) return [];\n const items = Array.isArray(t) ? t : [t];\n const results: any[] = [];\n items.forEach(it => {\n if (!(it instanceof HTMLElement)) {\n results.push(it);\n return;\n }\n if (r === 'auto') results.push(it.shadowRoot || it);\n else {\n if (r === 'light' || r === 'all') results.push(it);\n if ((r === 'shadow' || r === 'all') && it.shadowRoot) results.push(it.shadowRoot);\n }\n });\n return results;\n };\n\n // --- Special Selectors: HostSet ---\n const hostSet = SwcUtils.getHostSet(this);\n if (selector === '$hosts') return applyRoot(hostSet.$hosts);\n if (selector === '$appHosts') return applyRoot(hostSet.$appHosts);\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 if (selector === '$this') return applyRoot(this);\n\n // --- Standard Selectors ---\n if (r === 'shadow') return this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];\n if (r === 'light') return Array.from(this.querySelectorAll(selector));\n if (r === 'all') {\n const sNodes = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];\n const lNodes = Array.from(this.querySelectorAll(selector));\n return [...sNodes, ...lNodes];\n }\n const root = this.shadowRoot || this;\n return Array.from(root.querySelectorAll(selector));\n },\n set(this: HTMLElement, nv: any) {\n ensureInit(this);\n if (nv === null || nv === undefined || (Array.isArray(nv) && nv.length === 0)) {\n const selector = selectorOrTarget;\n if (selector.startsWith('$') && selector !== '$this') return;\n\n const r = (optionsOrPropertyKey as SwcQueryOptions)?.root || 'auto';\n let targets: (Element | Node)[] = [];\n if (r === 'shadow') targets = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];\n else if (r === 'light') targets = Array.from(this.querySelectorAll(selector));\n else if (r === 'all') {\n const sNodes = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];\n const lNodes = Array.from(this.querySelectorAll(selector));\n targets = [...sNodes, ...lNodes];\n } else {\n targets = Array.from((this.shadowRoot || this).querySelectorAll(selector));\n }\n targets.forEach(t => (t as Element).remove());\n }\n },\n enumerable: true,\n configurable: true\n });\n };\n }\n // Without selector (defaults to $this)\n return queryAll('$this', selectorOrTarget as SwcQueryOptions);\n}\n\nexport const getQueryAllMetadata = (target: any): QueryAllMetadata[] | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(QUERY_ALL_METADATA_KEY, constructor);\n};\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB,kBAAkB;AAC7C,SAAS,gBAAgB;
|
|
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 QueryAllOptions 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 QueryAllMetadata {\n propertyKey: string | symbol;\n selector: string | ((currentThis: any, helper: HelperHostSet) => NodeList | Element | Element[] | null);\n options: QueryAllOptions;\n}\n\nexport const QUERY_ALL_METADATA_KEY = Symbol.for('simple-web-component:query-all');\n\nexport function queryAll(target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor): PropertyDescriptor | void;\nexport function queryAll(selector: string | ((currentThis: any, helper: HelperHostSet) => NodeList | Element | Element[] | null), options?: QueryAllOptions): PropertyDecorator;\nexport function queryAll(options?: QueryAllOptions): PropertyDecorator;\n/**\n * @queryAll decorator to inject a list of elements into a class property.\n * \n * Supports both string selectors and function-based selectors:\n * - String selector: @queryAll('.item')\n * - Function selector: @queryAll((currentThis, helper) => currentThis.shadowRoot?.querySelectorAll('.item'))\n * \n * Supports filtering:\n * - @queryAll('.item', { filter: (target, meta) => target.hasAttribute('active') })\n */\nexport function queryAll(selectorOrTarget?: string | ((currentThis: any, helper: HelperHostSet) => NodeList | Element | Element[] | null) | Object, optionsOrPropertyKey?: QueryAllOptions | string | symbol, descriptor?: PropertyDescriptor): any {\n // Bare decorator: @queryAll\n if (descriptor !== undefined && (typeof optionsOrPropertyKey === 'string' || typeof optionsOrPropertyKey === 'symbol')) {\n throw new Error(`@queryAll 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(`@queryAll decorator cannot be used on methods. (Method: ${String(propertyKey)})`);\n }\n\n const constructor = targetObj.constructor;\n let queries = ReflectUtils.getMetadata<QueryAllMetadata[]>(QUERY_ALL_METADATA_KEY, constructor);\n if (!queries) {\n queries = [];\n ReflectUtils.defineMetadata(QUERY_ALL_METADATA_KEY, queries, constructor);\n }\n queries.push({ propertyKey, selector: selectorOrTarget as any, options: optionsOrPropertyKey as QueryAllOptions || {} });\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 resolvedElements: HTMLElement[] = [];\n \n if (typeof selectorOrTarget === 'function') {\n const result = (selectorOrTarget as any)(this, hostSet);\n // If function returns NodeList or Element[], convert to array\n if (result instanceof win.NodeList) {\n resolvedElements = Array.from(result).filter(el => el instanceof win.HTMLElement) as HTMLElement[];\n } else if (Array.isArray(result)) {\n resolvedElements = result.filter(el => el instanceof win.HTMLElement) as HTMLElement[];\n }\n } else {\n resolvedSelector = selectorOrTarget;\n\n const r = (optionsOrPropertyKey as QueryAllOptions)?.root || 'auto';\n const applyRoot = (t: any): any[] => {\n if (!t) return [];\n const items = Array.isArray(t) ? t : [t];\n const results: any[] = [];\n items.forEach(it => {\n if (!(it instanceof HTMLElement)) {\n results.push(it);\n return;\n }\n if (r === 'auto') results.push(it.shadowRoot || it);\n else {\n if (r === 'light' || r === 'all') results.push(it);\n if ((r === 'shadow' || r === 'all') && it.shadowRoot) results.push(it.shadowRoot);\n }\n });\n return results;\n };\n\n // --- Special Selectors: HostSet ---\n if (resolvedSelector === '$hosts') resolvedElements = applyRoot(hostSet.$hosts).filter(el => el instanceof HTMLElement);\n else if (resolvedSelector === '$appHosts') resolvedElements = applyRoot(hostSet.$appHosts).filter(el => el instanceof HTMLElement);\n else if (resolvedSelector === '$host') resolvedElements = applyRoot(hostSet.$host).filter(el => el instanceof HTMLElement);\n else if (resolvedSelector === '$parentHost') resolvedElements = applyRoot(hostSet.$parentHost).filter(el => el instanceof HTMLElement);\n else if (resolvedSelector === '$appHost') resolvedElements = applyRoot(hostSet.$appHost).filter(el => el instanceof HTMLElement);\n else if (resolvedSelector === '$firstHost') resolvedElements = applyRoot(hostSet.$firstHost).filter(el => el instanceof HTMLElement);\n else if (resolvedSelector === '$lastHost') resolvedElements = applyRoot(hostSet.$lastHost).filter(el => el instanceof HTMLElement);\n else if (resolvedSelector === '$firstAppHost') resolvedElements = applyRoot(hostSet.$firstAppHost).filter(el => el instanceof HTMLElement);\n else if (resolvedSelector === '$lastAppHost') resolvedElements = applyRoot(hostSet.$lastAppHost).filter(el => el instanceof HTMLElement);\n // --- Special Selectors: Env ---\n else if (resolvedSelector === '$window') return [win];\n else if (resolvedSelector === '$document') return [win.document];\n else if (resolvedSelector === '$this') resolvedElements = applyRoot(this).filter(el => el instanceof HTMLElement);\n // --- Standard Selectors ---\n else {\n if (r === 'shadow') resolvedElements = this.shadowRoot ? (Array.from(this.shadowRoot.querySelectorAll(resolvedSelector)) as HTMLElement[]) : [];\n else if (r === 'light') resolvedElements = Array.from(this.querySelectorAll(resolvedSelector)) as HTMLElement[];\n else if (r === 'all') {\n const sNodes = this.shadowRoot ? (Array.from(this.shadowRoot.querySelectorAll(resolvedSelector)) as HTMLElement[]) : [];\n const lNodes = Array.from(this.querySelectorAll(resolvedSelector)) as HTMLElement[];\n resolvedElements = [...sNodes, ...lNodes];\n }\n else resolvedElements = (Array.from((this.shadowRoot || this).querySelectorAll(resolvedSelector)) as HTMLElement[]);\n }\n }\n\n // Apply filter if provided\n if ((optionsOrPropertyKey as QueryAllOptions)?.filter) {\n resolvedElements = resolvedElements.filter(el => {\n if (!(el instanceof win.HTMLElement)) return true;\n return (optionsOrPropertyKey as QueryAllOptions).filter!(el, { currentThis: this, helper: hostSet });\n });\n }\n\n return resolvedElements;\n },\n set(this: HTMLElement, nv: any) {\n ensureInit(this);\n if (nv === null || nv === undefined || (Array.isArray(nv) && nv.length === 0)) {\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 elements from function and remove them\n const result = (selectorOrTarget as any)(this, hostSet);\n if (result instanceof win.NodeList) {\n Array.from(result).forEach(el => {\n if (el instanceof win.Element) (el as Element).remove();\n });\n } else if (Array.isArray(result)) {\n result.forEach(el => {\n if (el instanceof win.Element) (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 SwcQueryOptions)?.root || 'auto';\n let targets: (Element | Node)[] = [];\n if (r === 'shadow') targets = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(resolvedSelector)) : [];\n else if (r === 'light') targets = Array.from(this.querySelectorAll(resolvedSelector));\n else if (r === 'all') {\n const sNodes = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(resolvedSelector)) : [];\n const lNodes = Array.from(this.querySelectorAll(resolvedSelector));\n targets = [...sNodes, ...lNodes];\n } else {\n targets = Array.from((this.shadowRoot || this).querySelectorAll(resolvedSelector));\n }\n targets.forEach(t => (t as Element).remove());\n }\n },\n enumerable: true,\n configurable: true\n });\n };\n }\n // Without selector (defaults to $this)\n return queryAll('$this', selectorOrTarget as SwcQueryOptions);\n}\n\nexport const getQueryAllMetadata = (target: any): QueryAllMetadata[] | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(QUERY_ALL_METADATA_KEY, constructor);\n};\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB,kBAAkB;AAC7C,SAAS,gBAAgB;AAiBlB,MAAM,yBAAyB,OAAO,IAAI,gCAAgC;AAe3E,SAAU,SAAS,kBAA2H,sBAA0D,YAA+B;AAE3O,MAAI,eAAe,WAAc,OAAO,yBAAyB,YAAY,OAAO,yBAAyB,WAAW;AACtH,UAAM,IAAI,MAAM,2DAA2D,OAAO,oBAAoB,CAAC,GAAG;EAC5G;AAEA,MAAI,OAAO,qBAAqB,YAAY,OAAO,qBAAqB,YAAY;AAClF,WAAO,CAAC,WAAmB,aAA8BA,gBAA4B;AACnF,UAAIA,gBAAe,QAAW;AAC5B,cAAM,IAAI,MAAM,2DAA2D,OAAO,WAAW,CAAC,GAAG;MACnG;AAEA,YAAM,cAAc,UAAU;AAC9B,UAAI,UAAU,aAAa,YAAgC,wBAAwB,WAAW;AAC9F,UAAI,CAAC,SAAS;AACZ,kBAAU,CAAA;AACV,qBAAa,eAAe,wBAAwB,SAAS,WAAW;MAC1E;AACA,cAAQ,KAAK,EAAE,aAAa,UAAU,kBAAyB,SAAS,wBAA2C,CAAA,EAAE,CAAE;AAEvH,aAAO,eAAe,WAAW,aAAa;QAC5C,MAAG;AACD,qBAAW,IAAI;AACf,gBAAM,SAAS,iBAAiB,IAAI;AACpC,gBAAM,MAAM,QAAQ,UAAU;AAC9B,gBAAM,UAAU,SA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