@dooboostore/simple-web-component 1.0.25 → 1.0.27
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 +284 -68
- package/dist/cjs/decorators/attribute.js +32 -43
- package/dist/cjs/decorators/attribute.js.map +3 -3
- package/dist/cjs/decorators/elementDefine.js +33 -19
- package/dist/cjs/decorators/elementDefine.js.map +2 -2
- package/dist/cjs/decorators/index.js +1 -0
- package/dist/cjs/decorators/index.js.map +2 -2
- package/dist/cjs/decorators/lifecycles.js +5 -5
- package/dist/cjs/decorators/lifecycles.js.map +2 -2
- package/dist/cjs/decorators/query.js +4 -4
- package/dist/cjs/decorators/query.js.map +2 -2
- package/dist/cjs/decorators/queryAll.js +4 -4
- package/dist/cjs/decorators/queryAll.js.map +2 -2
- package/dist/cjs/decorators/subscribeSwcAppRouteChange.js +59 -0
- package/dist/cjs/decorators/subscribeSwcAppRouteChange.js.map +7 -0
- package/dist/cjs/elements/SwcAppEngine.js +18 -63
- package/dist/cjs/elements/SwcAppEngine.js.map +3 -3
- package/dist/cjs/elements/SwcAppMixin.js +103 -24
- package/dist/cjs/elements/SwcAppMixin.js.map +2 -2
- package/dist/cjs/elements/register.js +0 -1
- package/dist/cjs/elements/register.js.map +2 -2
- package/dist/cjs/utils/Utils.js +18 -0
- package/dist/cjs/utils/Utils.js.map +3 -3
- package/dist/esm/decorators/attribute.js +32 -43
- package/dist/esm/decorators/attribute.js.map +3 -3
- package/dist/esm/decorators/elementDefine.js +34 -20
- package/dist/esm/decorators/elementDefine.js.map +2 -2
- package/dist/esm/decorators/index.js +1 -0
- package/dist/esm/decorators/index.js.map +2 -2
- package/dist/esm/decorators/lifecycles.js +5 -5
- package/dist/esm/decorators/lifecycles.js.map +2 -2
- package/dist/esm/decorators/query.js +4 -4
- package/dist/esm/decorators/query.js.map +2 -2
- package/dist/esm/decorators/queryAll.js +4 -4
- package/dist/esm/decorators/queryAll.js.map +2 -2
- package/dist/esm/decorators/subscribeSwcAppRouteChange.js +40 -0
- package/dist/esm/decorators/subscribeSwcAppRouteChange.js.map +7 -0
- package/dist/esm/elements/SwcAppEngine.js +18 -63
- package/dist/esm/elements/SwcAppEngine.js.map +2 -2
- package/dist/esm/elements/SwcAppMixin.js +103 -24
- package/dist/esm/elements/SwcAppMixin.js.map +2 -2
- package/dist/esm/elements/register.js +0 -1
- package/dist/esm/elements/register.js.map +2 -2
- package/dist/esm/utils/Utils.js +18 -0
- package/dist/esm/utils/Utils.js.map +3 -3
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +135 -2470
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
- package/dist/types/decorators/attribute.d.ts +0 -1
- package/dist/types/decorators/attribute.d.ts.map +1 -1
- package/dist/types/decorators/elementDefine.d.ts.map +1 -1
- package/dist/types/decorators/index.d.ts +1 -0
- package/dist/types/decorators/index.d.ts.map +1 -1
- package/dist/types/decorators/lifecycles.d.ts +2 -2
- package/dist/types/decorators/lifecycles.d.ts.map +1 -1
- package/dist/types/decorators/query.d.ts +1 -1
- package/dist/types/decorators/query.d.ts.map +1 -1
- package/dist/types/decorators/queryAll.d.ts +1 -1
- package/dist/types/decorators/queryAll.d.ts.map +1 -1
- package/dist/types/decorators/subscribeSwcAppRouteChange.d.ts +18 -0
- package/dist/types/decorators/subscribeSwcAppRouteChange.d.ts.map +1 -0
- package/dist/types/elements/SwcAppEngine.d.ts +3 -5
- package/dist/types/elements/SwcAppEngine.d.ts.map +1 -1
- package/dist/types/elements/SwcAppMixin.d.ts +9 -0
- package/dist/types/elements/SwcAppMixin.d.ts.map +1 -1
- package/dist/types/elements/register.d.ts +1 -1
- package/dist/types/elements/register.d.ts.map +1 -1
- package/dist/types/utils/Utils.d.ts +3 -0
- package/dist/types/utils/Utils.d.ts.map +1 -1
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +135 -2470
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
- package/package.json +3 -3
- package/src/decorators/attribute.ts +62 -53
- package/src/decorators/elementDefine.ts +79 -30
- package/src/decorators/index.ts +1 -0
- package/src/decorators/lifecycles.ts +2 -2
- package/src/decorators/query.ts +5 -5
- package/src/decorators/queryAll.ts +8 -7
- package/src/decorators/subscribeSwcAppRouteChange.ts +71 -0
- package/src/elements/SwcAppEngine.ts +25 -81
- package/src/elements/SwcAppMixin.ts +143 -28
- package/src/elements/register.ts +0 -2
- package/src/utils/Utils.ts +33 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReflectUtils } from "@dooboostore/core";
|
|
2
|
-
const
|
|
2
|
+
const ON_INITIALIZE_METADATA_KEY = Symbol.for("simple-web-component:on-constructor");
|
|
3
3
|
const ON_BEFORE_CONNECTED_METADATA_KEY = Symbol.for("simple-web-component:on-before-connected");
|
|
4
4
|
const ON_AFTER_CONNECTED_METADATA_KEY = Symbol.for("simple-web-component:on-after-connected");
|
|
5
5
|
const ON_BEFORE_DISCONNECTED_METADATA_KEY = Symbol.for("simple-web-component:on-before-disconnected");
|
|
@@ -20,7 +20,7 @@ function createLifecycleDecorator(metadataKey) {
|
|
|
20
20
|
list.push(propertyKey);
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
-
const
|
|
23
|
+
const onInitialize = createLifecycleDecorator(ON_INITIALIZE_METADATA_KEY);
|
|
24
24
|
const onBeforeConnected = createLifecycleDecorator(ON_BEFORE_CONNECTED_METADATA_KEY);
|
|
25
25
|
const onAfterConnected = createLifecycleDecorator(ON_AFTER_CONNECTED_METADATA_KEY);
|
|
26
26
|
const onConnected = onAfterConnected;
|
|
@@ -66,7 +66,7 @@ export {
|
|
|
66
66
|
ON_BEFORE_ADOPTED_METADATA_KEY,
|
|
67
67
|
ON_BEFORE_CONNECTED_METADATA_KEY,
|
|
68
68
|
ON_BEFORE_DISCONNECTED_METADATA_KEY,
|
|
69
|
-
|
|
69
|
+
ON_INITIALIZE_METADATA_KEY,
|
|
70
70
|
findAllLifecycleMetadata,
|
|
71
71
|
getOnConnectedInnerHtmlMetadata,
|
|
72
72
|
onAddEventListener,
|
|
@@ -79,7 +79,7 @@ export {
|
|
|
79
79
|
onBeforeDisconnected,
|
|
80
80
|
onConnected,
|
|
81
81
|
onConnectedInnerHtml,
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
onDisconnected,
|
|
83
|
+
onInitialize
|
|
84
84
|
};
|
|
85
85
|
//# sourceMappingURL=lifecycles.js.map
|
|
@@ -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
|
|
5
|
-
"mappings": "AAAA,SAAS,oBAAoB;AAEtB,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 INNER_HTML_METADATA_KEY = Symbol.for('simple-web-component:inner-html');\n\nexport const ATTRIBUTE_CHANGED_WILDCARD = '*';\n\nexport interface InnerHtmlOptions {\n useShadow?: boolean;\n}\n\nexport interface InnerHtmlMetadata {\n propertyKey: string | symbol;\n options: InnerHtmlOptions;\n}\n\nfunction createLifecycleDecorator(metadataKey: symbol): MethodDecorator {\n return (target: Object, propertyKey: string | symbol) => {\n const constructor = target.constructor;\n let list = ReflectUtils.getOwnMetadata(metadataKey, constructor) as (string | symbol)[];\n if (!list) {\n list = [];\n ReflectUtils.defineMetadata(metadataKey, list, constructor);\n }\n list.push(propertyKey);\n };\n}\n\nexport const onInitialize = createLifecycleDecorator(ON_INITIALIZE_METADATA_KEY);\nexport const onBeforeConnected = createLifecycleDecorator(ON_BEFORE_CONNECTED_METADATA_KEY);\nexport const onAfterConnected = createLifecycleDecorator(ON_AFTER_CONNECTED_METADATA_KEY);\nexport const onConnected = onAfterConnected;\n\nexport const onBeforeDisconnected = createLifecycleDecorator(ON_BEFORE_DISCONNECTED_METADATA_KEY);\nexport const onAfterDisconnected = createLifecycleDecorator(ON_AFTER_DISCONNECTED_METADATA_KEY);\nexport const onDisconnected = onAfterDisconnected;\n\nexport const onBeforeAdopted = createLifecycleDecorator(ON_BEFORE_ADOPTED_METADATA_KEY);\nexport const onAfterAdopted = createLifecycleDecorator(ON_AFTER_ADOPTED_METADATA_KEY);\nexport const onAdopted = onAfterAdopted;\n\nexport const onAddEventListener = createLifecycleDecorator(ON_ADD_EVENT_LISTENER_METADATA_KEY);\n\n/**\n * @onConnectedInnerHtml decorator to define the initial HTML content when connected.\n */\nexport function onConnectedInnerHtml(options: InnerHtmlOptions): MethodDecorator;\nexport function onConnectedInnerHtml(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function onConnectedInnerHtml(arg1?: InnerHtmlOptions | Object, arg2?: string | symbol, arg3?: PropertyDescriptor): MethodDecorator | void {\n const decorator = (options: InnerHtmlOptions, target: Object, propertyKey: string | symbol) => {\n const constructor = target.constructor;\n let list = ReflectUtils.getMetadata<InnerHtmlMetadata[]>(INNER_HTML_METADATA_KEY, constructor);\n if (!list) {\n list = [];\n ReflectUtils.defineMetadata(INNER_HTML_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 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 = <T = (string | symbol)[]>(target: any, metadataKey: symbol): T | undefined => {\n const results = ReflectUtils.findAllMetadataFlatten(metadataKey, target);\n return results.length > 0 ? (results as unknown as T) : undefined;\n};\n\nexport const getOnConnectedInnerHtmlMetadata = (target: any): InnerHtmlMetadata[] | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(INNER_HTML_METADATA_KEY, constructor);\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,0BAA0B,OAAO,IAAI,iCAAiC;AAE5E,MAAM,6BAA6B;AAW1C,SAAS,yBAAyB,aAAsC;AACtE,SAAO,CAAC,QAAgB,gBAAiC;AACvD,UAAM,cAAc,OAAO;AAC3B,QAAI,OAAO,aAAa,eAAe,aAAa,WAAW;AAC/D,QAAI,CAAC,MAAM;AACT,aAAO,CAAC;AACR,mBAAa,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orOrTarget, options = {}) {
|
|
|
95
95
|
});
|
|
96
96
|
};
|
|
97
97
|
}
|
|
98
|
-
const getQueryMetadata = (target) => {
|
|
99
|
-
const constructor = target instanceof Function ? target : target.constructor;
|
|
100
|
-
return ReflectUtils.getMetadata(QUERY_METADATA_KEY, constructor);
|
|
101
|
-
};
|
|
102
98
|
function queryHost(targetOrOptions, propertyKey) {
|
|
103
99
|
if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
104
100
|
return query(":host", {})(targetOrOptions, propertyKey);
|
|
@@ -170,6 +166,10 @@ function lastAppHost(targetOrOptions, propertyKey) {
|
|
|
170
166
|
return query(":lastAppHost", {});
|
|
171
167
|
}
|
|
172
168
|
}
|
|
169
|
+
const getQueryMetadata = (target) => {
|
|
170
|
+
const constructor = target instanceof Function ? target : target.constructor;
|
|
171
|
+
return ReflectUtils.getMetadata(QUERY_METADATA_KEY, constructor);
|
|
172
|
+
};
|
|
173
173
|
export {
|
|
174
174
|
QUERY_METADATA_KEY,
|
|
175
175
|
appHost,
|
|
@@ -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 } 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: SpecialSelector): PropertyDecorator;\nexport function query(selector: string, options?: SwcQueryOptions): PropertyDecorator;\n/**\n * @query decorator to inject a single element into a class property.\n */\nexport function query(selectorOrTarget: string, options: any = {}): PropertyDecorator {\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 });\n\n // const propertyType = Reflect.getMetadata(\"design:type\", targetObj, propertyKey);\n // console.log(`Property ${String(propertyKey)} type is:`, propertyType.name);\n Object.defineProperty(targetObj, propertyKey, {\n get(this: HTMLElement) {\n ensureInit(this);\n const selector = selectorOrTarget;\n\n const r = options.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; // query only returns one, so shadow preferred\n return t;\n };\n\n // --- Special Selectors: HostSet ---\n const hostSet = SwcUtils.getHostSet(this);\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 === ':host') return applyRoot(this);\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 !== ':host') return;\n\n const r = options.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\nexport const getQueryMetadata = (target: any): QueryMetadata[] | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(QUERY_METADATA_KEY, constructor);\n};\n\n/**\n * @queryHost decorator - simplified version of @query for :host selector\n * Usage: @queryHost testzzs: HTMLElement | undefined;\n * Usage: @queryHost() testzzs: HTMLElement | undefined;\n * Usage: @queryHost({ root: 'shadow' }) testzzs: HTMLElement | undefined;\n */\nexport function queryHost(target: Object, propertyKey: string | symbol): void;\nexport function queryHost(): PropertyDecorator;\nexport function queryHost(options: SwcQueryOptions): PropertyDecorator;\nexport function queryHost(targetOrOptions?: any, propertyKey?: string | symbol): any {\n // Direct decorator usage: @queryHost (no parentheses)\n if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return query(':host', {})(targetOrOptions, propertyKey);\n }\n\n // @queryHost() or @queryHost(options)\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {\n return query(':host', targetOrOptions as SwcQueryOptions);\n } else {\n return query(':host', {});\n }\n}\n\n/**\n * @host - Alias for @queryHost decorator\n * Usage: @host element: HTMLElement | undefined;\n * Usage: @host() element: HTMLElement | undefined;\n * Usage: @host({ root: 'shadow' }) element: HTMLElement | undefined;\n */\nexport const host = queryHost;\n\n/**\n * @parentHost - Query :parentHost (Direct parent SWC component)\n * Usage: @parentHost parent: HTMLElement | undefined;\n * Usage: @parentHost() parent: HTMLElement | undefined;\n * Usage: @parentHost({ root: 'shadow' }) parent: HTMLElement | undefined;\n */\nexport function parentHost(target: Object, propertyKey: string | symbol): void;\nexport function parentHost(): PropertyDecorator;\nexport function parentHost(options: SwcQueryOptions): PropertyDecorator;\nexport function parentHost(targetOrOptions?: any, propertyKey?: string | symbol): any {\n if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return query(':parentHost', {})(targetOrOptions, propertyKey);\n }\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {\n return query(':parentHost', targetOrOptions as SwcQueryOptions);\n } else {\n return query(':parentHost', {});\n }\n}\n\n/**\n * @appHost - Query :appHost (Nearest <swc-app>)\n * Usage: @appHost app: SwcAppInterface | undefined;\n * Usage: @appHost() app: SwcAppInterface | undefined;\n * Usage: @appHost({ root: 'shadow' }) app: SwcAppInterface | undefined;\n */\nexport function appHost(target: Object, propertyKey: string | symbol): void;\nexport function appHost(): PropertyDecorator;\nexport function appHost(options: SwcQueryOptions): PropertyDecorator;\nexport function appHost(targetOrOptions?: any, propertyKey?: string | symbol): any {\n if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return query(':appHost', {})(targetOrOptions, propertyKey);\n }\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {\n return query(':appHost', targetOrOptions as SwcQueryOptions);\n } else {\n return query(':appHost', {});\n }\n}\n\n/**\n * @firstHost - Query :firstHost (First component in hierarchy)\n * Usage: @firstHost first: HTMLElement | undefined;\n * Usage: @firstHost() first: HTMLElement | undefined;\n * Usage: @firstHost({ root: 'shadow' }) first: HTMLElement | undefined;\n */\nexport function firstHost(target: Object, propertyKey: string | symbol): void;\nexport function firstHost(): PropertyDecorator;\nexport function firstHost(options: SwcQueryOptions): PropertyDecorator;\nexport function firstHost(targetOrOptions?: any, propertyKey?: string | symbol): any {\n if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return query(':firstHost', {})(targetOrOptions, propertyKey);\n }\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {\n return query(':firstHost', targetOrOptions as SwcQueryOptions);\n } else {\n return query(':firstHost', {});\n }\n}\n\n/**\n * @lastHost - Query :lastHost (Last component in hierarchy)\n * Usage: @lastHost last: HTMLElement | undefined;\n * Usage: @lastHost() last: HTMLElement | undefined;\n * Usage: @lastHost({ root: 'shadow' }) last: HTMLElement | undefined;\n */\nexport function lastHost(target: Object, propertyKey: string | symbol): void;\nexport function lastHost(): PropertyDecorator;\nexport function lastHost(options: SwcQueryOptions): PropertyDecorator;\nexport function lastHost(targetOrOptions?: any, propertyKey?: string | symbol): any {\n if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return query(':lastHost', {})(targetOrOptions, propertyKey);\n }\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {\n return query(':lastHost', targetOrOptions as SwcQueryOptions);\n } else {\n return query(':lastHost', {});\n }\n}\n\n/**\n * @firstAppHost - Query :firstAppHost (First <swc-app> in hierarchy)\n * Usage: @firstAppHost app: SwcAppInterface | undefined;\n * Usage: @firstAppHost() app: SwcAppInterface | undefined;\n * Usage: @firstAppHost({ root: 'shadow' }) app: SwcAppInterface | undefined;\n */\nexport function firstAppHost(target: Object, propertyKey: string | symbol): void;\nexport function firstAppHost(): PropertyDecorator;\nexport function firstAppHost(options: SwcQueryOptions): PropertyDecorator;\nexport function firstAppHost(targetOrOptions?: any, propertyKey?: string | symbol): any {\n if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return query(':firstAppHost', {})(targetOrOptions, propertyKey);\n }\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {\n return query(':firstAppHost', targetOrOptions as SwcQueryOptions);\n } else {\n return query(':firstAppHost', {});\n }\n}\n\n/**\n * @lastAppHost - Query :lastAppHost (Last <swc-app> in hierarchy)\n * Usage: @lastAppHost app: SwcAppInterface | undefined;\n * Usage: @lastAppHost() app: SwcAppInterface | undefined;\n * Usage: @lastAppHost({ root: 'shadow' }) app: SwcAppInterface | undefined;\n */\nexport function lastAppHost(target: Object, propertyKey: string | symbol): void;\nexport function lastAppHost(): PropertyDecorator;\nexport function lastAppHost(options: SwcQueryOptions): PropertyDecorator;\nexport function lastAppHost(targetOrOptions?: any, propertyKey?: string | symbol): any {\n if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return query(':lastAppHost', {})(targetOrOptions, propertyKey);\n }\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {\n return query(':lastAppHost', targetOrOptions as SwcQueryOptions);\n } else {\n return query(':lastAppHost', {});\n }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB,kBAAkB;AAC7C,SAAS,gBAAgB;AASlB,MAAM,qBAAqB,OAAO,IAAI,4BAA4B;AAOnE,SAAU,MAAM,kBAA0B,UAAe,CAAA,GAAE;AAC/D,SAAO,CAAC,WAAmB,aAA8B,eAA4B;AACnF,QAAI,eAAe,QAAW;AAC5B,YAAM,IAAI,MAAM,wDAAwD,OAAO,WAAW,CAAC,GAAG;IAChG;AAEA,UAAM,cAAc,UAAU;AAC9B,QAAI,UAAU,aAAa,YAA6B,oBAAoB,WAAW;AACvF,QAAI,CAAC,SAAS;AACZ,gBAAU,CAAA;AACV,mBAAa,eAAe,oBAAoB,SAAS,WAAW;IACtE;AACA,YAAQ,KAAK,EAAE,aAAa,UAAU,kBAAkB,QAAO,CAAE;AAIjE,WAAO,eAAe,WAAW,aAAa;MAC5C,MAAG;AACD,mBAAW,IAAI;AACf,cAAM,WAAW;AAEjB,cAAM,IAAI,QAAQ,QAAQ;AAC1B,cAAM,YAAY,CAAC,MAAU;AAC3B,cAAI,CAAC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AAqB,CAAA;AAE3B,cAAI,MAAM,UAAU;AAClB,gBAAI,KAAK,YAAY,cAAc,QAAQ;AAAG,sBAAQ,KAAK,KAAK,WAAW,cAAc,QAAQ,CAAE;UACrG,WAAW,MAAM,SAAS;AACxB,gBAAI,KAAK,cAAc,QAAQ;AAAG,sBAAQ,KAAK,KAAK,cAAc,QAAQ,CAAE;UAC9E,WAAW,MAAM,OAAO;AACtB,gBAAI,KAAK,YAAY,cAAc,QAAQ;AAAG,sBAAQ,KAAK,KAAK,WAAW,cAAc,QAAQ,CAAE;AACnG,gBAAI,KAAK,cAAc,QAAQ;AAAG,sBAAQ,KAAK,KAAK,cAAc,QAAQ,CAAE;UAC9E,OAAO;AACL,kBAAM,MAAM,KAAK,cAAc,MAAM,cAAc,QAAQ;AAC3D,gBAAI;AAAI,sBAAQ,KAAK,EAAE;UACzB;AAEA,kBAAQ,QAAQ,OAAK,EAAE,OAAM,CAAE;QACjC;MACF;MACA,YAAY;MACZ,cAAc;KACf;EACH;AACF;
|
|
4
|
+
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { getElementConfig, ensureInit } from './elementDefine';\nimport { SwcUtils } from '../utils/Utils';\nimport { SpecialSelector, SwcQueryOptions } 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: SpecialSelector): PropertyDecorator;\nexport function query(selector: string, options?: SwcQueryOptions): PropertyDecorator;\n/**\n * @query decorator to inject a single element into a class property.\n */\nexport function query(selectorOrTarget: string, options: any = {}): PropertyDecorator {\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 });\n\n // const propertyType = Reflect.getMetadata(\"design:type\", targetObj, propertyKey);\n // console.log(`Property ${String(propertyKey)} type is:`, propertyType.name);\n Object.defineProperty(targetObj, propertyKey, {\n get(this: HTMLElement) {\n ensureInit(this);\n const selector = selectorOrTarget;\n\n const r = options.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; // query only returns one, so shadow preferred\n return t;\n };\n\n // --- Special Selectors: HostSet ---\n const hostSet = SwcUtils.getHostSet(this);\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 === ':host') return applyRoot(this);\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 !== ':host') return;\n\n const r = options.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\n/**\n * @queryHost decorator - simplified version of @query for :host selector\n * Usage: @queryHost testzzs: HTMLElement | undefined;\n * Usage: @queryHost() testzzs: HTMLElement | undefined;\n * Usage: @queryHost({ root: 'shadow' }) testzzs: HTMLElement | undefined;\n */\nexport function queryHost(target: Object, propertyKey: string | symbol): void;\nexport function queryHost(): PropertyDecorator;\nexport function queryHost(options: SwcQueryOptions): PropertyDecorator;\nexport function queryHost(targetOrOptions?: any, propertyKey?: string | symbol): any {\n // Direct decorator usage: @queryHost (no parentheses)\n if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return query(':host', {})(targetOrOptions, propertyKey);\n }\n\n // @queryHost() or @queryHost(options)\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {\n return query(':host', targetOrOptions as SwcQueryOptions);\n } else {\n return query(':host', {});\n }\n}\n\n/**\n * @host - Alias for @queryHost decorator\n * Usage: @host element: HTMLElement | undefined;\n * Usage: @host() element: HTMLElement | undefined;\n * Usage: @host({ root: 'shadow' }) element: HTMLElement | undefined;\n */\nexport const host = queryHost;\n\n/**\n * @parentHost - Query :parentHost (Direct parent SWC component)\n * Usage: @parentHost parent: HTMLElement | undefined;\n * Usage: @parentHost() parent: HTMLElement | undefined;\n * Usage: @parentHost({ root: 'shadow' }) parent: HTMLElement | undefined;\n */\nexport function parentHost(target: Object, propertyKey: string | symbol): void;\nexport function parentHost(): PropertyDecorator;\nexport function parentHost(options: SwcQueryOptions): PropertyDecorator;\nexport function parentHost(targetOrOptions?: any, propertyKey?: string | symbol): any {\n if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return query(':parentHost', {})(targetOrOptions, propertyKey);\n }\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {\n return query(':parentHost', targetOrOptions as SwcQueryOptions);\n } else {\n return query(':parentHost', {});\n }\n}\n\n/**\n * @appHost - Query :appHost (Nearest <swc-app>)\n * Usage: @appHost app: SwcAppInterface | undefined;\n * Usage: @appHost() app: SwcAppInterface | undefined;\n * Usage: @appHost({ root: 'shadow' }) app: SwcAppInterface | undefined;\n */\nexport function appHost(target: Object, propertyKey: string | symbol): void;\nexport function appHost(): PropertyDecorator;\nexport function appHost(options: SwcQueryOptions): PropertyDecorator;\nexport function appHost(targetOrOptions?: any, propertyKey?: string | symbol): any {\n if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return query(':appHost', {})(targetOrOptions, propertyKey);\n }\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {\n return query(':appHost', targetOrOptions as SwcQueryOptions);\n } else {\n return query(':appHost', {});\n }\n}\n\n/**\n * @firstHost - Query :firstHost (First component in hierarchy)\n * Usage: @firstHost first: HTMLElement | undefined;\n * Usage: @firstHost() first: HTMLElement | undefined;\n * Usage: @firstHost({ root: 'shadow' }) first: HTMLElement | undefined;\n */\nexport function firstHost(target: Object, propertyKey: string | symbol): void;\nexport function firstHost(): PropertyDecorator;\nexport function firstHost(options: SwcQueryOptions): PropertyDecorator;\nexport function firstHost(targetOrOptions?: any, propertyKey?: string | symbol): any {\n if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return query(':firstHost', {})(targetOrOptions, propertyKey);\n }\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {\n return query(':firstHost', targetOrOptions as SwcQueryOptions);\n } else {\n return query(':firstHost', {});\n }\n}\n\n/**\n * @lastHost - Query :lastHost (Last component in hierarchy)\n * Usage: @lastHost last: HTMLElement | undefined;\n * Usage: @lastHost() last: HTMLElement | undefined;\n * Usage: @lastHost({ root: 'shadow' }) last: HTMLElement | undefined;\n */\nexport function lastHost(target: Object, propertyKey: string | symbol): void;\nexport function lastHost(): PropertyDecorator;\nexport function lastHost(options: SwcQueryOptions): PropertyDecorator;\nexport function lastHost(targetOrOptions?: any, propertyKey?: string | symbol): any {\n if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return query(':lastHost', {})(targetOrOptions, propertyKey);\n }\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {\n return query(':lastHost', targetOrOptions as SwcQueryOptions);\n } else {\n return query(':lastHost', {});\n }\n}\n\n/**\n * @firstAppHost - Query :firstAppHost (First <swc-app> in hierarchy)\n * Usage: @firstAppHost app: SwcAppInterface | undefined;\n * Usage: @firstAppHost() app: SwcAppInterface | undefined;\n * Usage: @firstAppHost({ root: 'shadow' }) app: SwcAppInterface | undefined;\n */\nexport function firstAppHost(target: Object, propertyKey: string | symbol): void;\nexport function firstAppHost(): PropertyDecorator;\nexport function firstAppHost(options: SwcQueryOptions): PropertyDecorator;\nexport function firstAppHost(targetOrOptions?: any, propertyKey?: string | symbol): any {\n if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return query(':firstAppHost', {})(targetOrOptions, propertyKey);\n }\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {\n return query(':firstAppHost', targetOrOptions as SwcQueryOptions);\n } else {\n return query(':firstAppHost', {});\n }\n}\n\n/**\n * @lastAppHost - Query :lastAppHost (Last <swc-app> in hierarchy)\n * Usage: @lastAppHost app: SwcAppInterface | undefined;\n * Usage: @lastAppHost() app: SwcAppInterface | undefined;\n * Usage: @lastAppHost({ root: 'shadow' }) app: SwcAppInterface | undefined;\n */\nexport function lastAppHost(target: Object, propertyKey: string | symbol): void;\nexport function lastAppHost(): PropertyDecorator;\nexport function lastAppHost(options: SwcQueryOptions): PropertyDecorator;\nexport function lastAppHost(targetOrOptions?: any, propertyKey?: string | symbol): any {\n if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return query(':lastAppHost', {})(targetOrOptions, propertyKey);\n }\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {\n return query(':lastAppHost', targetOrOptions as SwcQueryOptions);\n } else {\n return query(':lastAppHost', {});\n }\n}\n\nexport const getQueryMetadata = (target: any): QueryMetadata[] | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(QUERY_METADATA_KEY, constructor);\n};"],
|
|
5
|
+
"mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB,kBAAkB;AAC7C,SAAS,gBAAgB;AASlB,MAAM,qBAAqB,OAAO,IAAI,4BAA4B;AAOnE,SAAU,MAAM,kBAA0B,UAAe,CAAA,GAAE;AAC/D,SAAO,CAAC,WAAmB,aAA8B,eAA4B;AACnF,QAAI,eAAe,QAAW;AAC5B,YAAM,IAAI,MAAM,wDAAwD,OAAO,WAAW,CAAC,GAAG;IAChG;AAEA,UAAM,cAAc,UAAU;AAC9B,QAAI,UAAU,aAAa,YAA6B,oBAAoB,WAAW;AACvF,QAAI,CAAC,SAAS;AACZ,gBAAU,CAAA;AACV,mBAAa,eAAe,oBAAoB,SAAS,WAAW;IACtE;AACA,YAAQ,KAAK,EAAE,aAAa,UAAU,kBAAkB,QAAO,CAAE;AAIjE,WAAO,eAAe,WAAW,aAAa;MAC5C,MAAG;AACD,mBAAW,IAAI;AACf,cAAM,WAAW;AAEjB,cAAM,IAAI,QAAQ,QAAQ;AAC1B,cAAM,YAAY,CAAC,MAAU;AAC3B,cAAI,CAAC,KAAK,EAAE,aAAa;AAAc,mBAAO;AAC9C,cAAI,MAAM;AAAQ,mBAAO,EAAE,cAAc;AACzC,cAAI,MAAM;AAAU,mBAAO,EAAE;AAC7B,cAAI,MAAM;A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,CAAE,EAAE,iBAAiB,WAAW;EAC/D;AACA,MAAI,OAAO,oBAAoB,YAAY,oBAAoB,MAAM;AACnE,WAAO,MAAM,gBAAgB,eAAkC;EACjE,OAAO;AACL,WAAO,MAAM,gBAAgB,CAAA,CAAE;EACjC;AACF;AAEO,MAAM,mBAAmB,CAAC,WAA4C;AAC3E,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,SAAO,aAAa,YAAY,oBAAoB,WAAW;AACjE;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -92,10 +92,6 @@ function queryAll(selectorOrTarget, options = {}) {
|
|
|
92
92
|
});
|
|
93
93
|
};
|
|
94
94
|
}
|
|
95
|
-
const getQueryAllMetadata = (target) => {
|
|
96
|
-
const constructor = target instanceof Function ? target : target.constructor;
|
|
97
|
-
return ReflectUtils.getMetadata(QUERY_ALL_METADATA_KEY, constructor);
|
|
98
|
-
};
|
|
99
95
|
function queryAllHost(targetOrOptions, propertyKey) {
|
|
100
96
|
if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
101
97
|
return queryAll(":host", {})(targetOrOptions, propertyKey);
|
|
@@ -167,6 +163,10 @@ function allLastAppHost(targetOrOptions, propertyKey) {
|
|
|
167
163
|
return queryAll(":lastAppHost", {});
|
|
168
164
|
}
|
|
169
165
|
}
|
|
166
|
+
const getQueryAllMetadata = (target) => {
|
|
167
|
+
const constructor = target instanceof Function ? target : target.constructor;
|
|
168
|
+
return ReflectUtils.getMetadata(QUERY_ALL_METADATA_KEY, constructor);
|
|
169
|
+
};
|
|
170
170
|
export {
|
|
171
171
|
QUERY_ALL_METADATA_KEY,
|
|
172
172
|
allAppHost,
|
|
@@ -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 } 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: SpecialSelector): PropertyDecorator;\nexport function queryAll(selector: string, options?: SwcQueryOptions): PropertyDecorator;\n/**\n * @queryAll decorator to inject a list of elements into a class property.\n */\nexport function queryAll(selectorOrTarget: string, options: any = {}): PropertyDecorator {\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 });\n\n Object.defineProperty(targetObj, propertyKey, {\n get(this: HTMLElement) {\n ensureInit(this);\n const selector = selectorOrTarget;\n\n const r = options.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\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 === ':host') 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 !== ':host') return;\n\n const r = options.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\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\n/**\n * @hostQueryAll decorator - simplified version of @queryAll for :host selector\n * Usage: @hostQueryAll()\n * Usage: @hostQueryAll({ root: 'shadow' })\n */\n/**\n * @queryAllHost decorator - simplified version of @queryAll for :host selector\n * Usage: @queryAllHost items: HTMLElement[];\n * Usage: @queryAllHost() items: HTMLElement[];\n * Usage: @queryAllHost({ root: 'shadow' }) items: HTMLElement[];\n */\nexport function queryAllHost(target: Object, propertyKey: string | symbol): void;\nexport function queryAllHost(): PropertyDecorator;\nexport function queryAllHost(options: SwcQueryOptions): PropertyDecorator;\nexport function queryAllHost(targetOrOptions?: any, propertyKey?: string | symbol): any {\n // Direct decorator usage: @queryAllHost (no parentheses)\n if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return queryAll(':host', {})(targetOrOptions, propertyKey);\n }\n\n // @queryAllHost() or @queryAllHost(options)\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {\n return queryAll(':host', targetOrOptions as SwcQueryOptions);\n } else {\n return queryAll(':host', {});\n }\n}\n\n/**\n * @allHost - Alias for @queryAllHost decorator\n * Usage: @allHost items: HTMLElement[];\n * Usage: @allHost() items: HTMLElement[];\n * Usage: @allHost({ root: 'shadow' }) items: HTMLElement[];\n */\nexport const allHost = queryAllHost;\n/**\n * @allParentHost - Query all :parentHost (All parent SWC components)\n * Usage: @allParentHost parents: HTMLElement[];\n * Usage: @allParentHost() parents: HTMLElement[];\n * Usage: @allParentHost({ root: 'shadow' }) parents: HTMLElement[];\n */\nexport function allParentHost(target: Object, propertyKey: string | symbol): void;\nexport function allParentHost(): PropertyDecorator;\nexport function allParentHost(options: SwcQueryOptions): PropertyDecorator;\nexport function allParentHost(targetOrOptions?: any, propertyKey?: string | symbol): any {\n if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return queryAll(':parentHost', {})(targetOrOptions, propertyKey);\n }\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {\n return queryAll(':parentHost', targetOrOptions as SwcQueryOptions);\n } else {\n return queryAll(':parentHost', {});\n }\n}\n\n/**\n * @allAppHost - Query all :appHost (All <swc-app> instances)\n * Usage: @allAppHost apps: SwcAppInterface[];\n * Usage: @allAppHost() apps: SwcAppInterface[];\n * Usage: @allAppHost({ root: 'shadow' }) apps: SwcAppInterface[];\n */\nexport function allAppHost(target: Object, propertyKey: string | symbol): void;\nexport function allAppHost(): PropertyDecorator;\nexport function allAppHost(options: SwcQueryOptions): PropertyDecorator;\nexport function allAppHost(targetOrOptions?: any, propertyKey?: string | symbol): any {\n if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return queryAll(':appHost', {})(targetOrOptions, propertyKey);\n }\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {\n return queryAll(':appHost', targetOrOptions as SwcQueryOptions);\n } else {\n return queryAll(':appHost', {});\n }\n}\n\n/**\n * @allFirstHost - Query all :firstHost (All first components in hierarchy)\n * Usage: @allFirstHost firsts: HTMLElement[];\n * Usage: @allFirstHost() firsts: HTMLElement[];\n * Usage: @allFirstHost({ root: 'shadow' }) firsts: HTMLElement[];\n */\nexport function allFirstHost(target: Object, propertyKey: string | symbol): void;\nexport function allFirstHost(): PropertyDecorator;\nexport function allFirstHost(options: SwcQueryOptions): PropertyDecorator;\nexport function allFirstHost(targetOrOptions?: any, propertyKey?: string | symbol): any {\n if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return queryAll(':firstHost', {})(targetOrOptions, propertyKey);\n }\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {\n return queryAll(':firstHost', targetOrOptions as SwcQueryOptions);\n } else {\n return queryAll(':firstHost', {});\n }\n}\n\n/**\n * @allLastHost - Query all :lastHost (All last components in hierarchy)\n * Usage: @allLastHost lasts: HTMLElement[];\n * Usage: @allLastHost() lasts: HTMLElement[];\n * Usage: @allLastHost({ root: 'shadow' }) lasts: HTMLElement[];\n */\nexport function allLastHost(target: Object, propertyKey: string | symbol): void;\nexport function allLastHost(): PropertyDecorator;\nexport function allLastHost(options: SwcQueryOptions): PropertyDecorator;\nexport function allLastHost(targetOrOptions?: any, propertyKey?: string | symbol): any {\n if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return queryAll(':lastHost', {})(targetOrOptions, propertyKey);\n }\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {\n return queryAll(':lastHost', targetOrOptions as SwcQueryOptions);\n } else {\n return queryAll(':lastHost', {});\n }\n}\n\n/**\n * @allFirstAppHost - Query all :firstAppHost (All first <swc-app> in hierarchy)\n * Usage: @allFirstAppHost apps: SwcAppInterface[];\n * Usage: @allFirstAppHost() apps: SwcAppInterface[];\n * Usage: @allFirstAppHost({ root: 'shadow' }) apps: SwcAppInterface[];\n */\nexport function allFirstAppHost(target: Object, propertyKey: string | symbol): void;\nexport function allFirstAppHost(): PropertyDecorator;\nexport function allFirstAppHost(options: SwcQueryOptions): PropertyDecorator;\nexport function allFirstAppHost(targetOrOptions?: any, propertyKey?: string | symbol): any {\n if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return queryAll(':firstAppHost', {})(targetOrOptions, propertyKey);\n }\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {\n return queryAll(':firstAppHost', targetOrOptions as SwcQueryOptions);\n } else {\n return queryAll(':firstAppHost', {});\n }\n}\n\n/**\n * @allLastAppHost - Query all :lastAppHost (All last <swc-app> in hierarchy)\n * Usage: @allLastAppHost apps: SwcAppInterface[];\n * Usage: @allLastAppHost() apps: SwcAppInterface[];\n * Usage: @allLastAppHost({ root: 'shadow' }) apps: SwcAppInterface[];\n */\nexport function allLastAppHost(target: Object, propertyKey: string | symbol): void;\nexport function allLastAppHost(): PropertyDecorator;\nexport function allLastAppHost(options: SwcQueryOptions): PropertyDecorator;\nexport function allLastAppHost(targetOrOptions?: any, propertyKey?: string | symbol): any {\n if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return queryAll(':lastAppHost', {})(targetOrOptions, propertyKey);\n }\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {\n return queryAll(':lastAppHost', targetOrOptions as SwcQueryOptions);\n } else {\n return queryAll(':lastAppHost', {});\n }\n}"],
|
|
5
|
-
"mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB,kBA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;AACzD,sBAAU,CAAC,GAAG,QAAQ,GAAG,MAAM;UACjC,OAAO;AACL,sBAAU,MAAM,MAAM,KAAK,cAAc,MAAM,iBAAiB,QAAQ,CAAC;UAC3E;AACA,kBAAQ,QAAQ,OAAM,EAAc,OAAM,CAAE;QAC9C;MACF;MACA,YAAY;MACZ,cAAc;KACf;EACH;AACF;
|
|
4
|
+
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { getElementConfig, ensureInit } from './elementDefine';\nimport { SwcUtils } from '../utils/Utils';\nimport { SpecialSelector, SwcQueryOptions } 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: SpecialSelector): PropertyDecorator;\nexport function queryAll(selector: string, options?: SwcQueryOptions): PropertyDecorator;\n/**\n * @queryAll decorator to inject a list of elements into a class property.\n */\nexport function queryAll(selectorOrTarget: string, options: any = {}): PropertyDecorator {\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 });\n\n Object.defineProperty(targetObj, propertyKey, {\n get(this: HTMLElement) {\n ensureInit(this);\n const selector = selectorOrTarget;\n\n const r = options.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\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 === ':host') 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 !== ':host') return;\n\n const r = options.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/**\n * @hostQueryAll decorator - simplified version of @queryAll for :host selector\n * Usage: @hostQueryAll()\n * Usage: @hostQueryAll({ root: 'shadow' })\n */\n/**\n * @queryAllHost decorator - simplified version of @queryAll for :host selector\n * Usage: @queryAllHost items: HTMLElement[];\n * Usage: @queryAllHost() items: HTMLElement[];\n * Usage: @queryAllHost({ root: 'shadow' }) items: HTMLElement[];\n */\nexport function queryAllHost(target: Object, propertyKey: string | symbol): void;\nexport function queryAllHost(): PropertyDecorator;\nexport function queryAllHost(options: SwcQueryOptions): PropertyDecorator;\nexport function queryAllHost(targetOrOptions?: any, propertyKey?: string | symbol): any {\n // Direct decorator usage: @queryAllHost (no parentheses)\n if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return queryAll(':host', {})(targetOrOptions, propertyKey);\n }\n\n // @queryAllHost() or @queryAllHost(options)\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {\n return queryAll(':host', targetOrOptions as SwcQueryOptions);\n } else {\n return queryAll(':host', {});\n }\n}\n\n/**\n * @allHost - Alias for @queryAllHost decorator\n * Usage: @allHost items: HTMLElement[];\n * Usage: @allHost() items: HTMLElement[];\n * Usage: @allHost({ root: 'shadow' }) items: HTMLElement[];\n */\nexport const allHost = queryAllHost;\n/**\n * @allParentHost - Query all :parentHost (All parent SWC components)\n * Usage: @allParentHost parents: HTMLElement[];\n * Usage: @allParentHost() parents: HTMLElement[];\n * Usage: @allParentHost({ root: 'shadow' }) parents: HTMLElement[];\n */\nexport function allParentHost(target: Object, propertyKey: string | symbol): void;\nexport function allParentHost(): PropertyDecorator;\nexport function allParentHost(options: SwcQueryOptions): PropertyDecorator;\nexport function allParentHost(targetOrOptions?: any, propertyKey?: string | symbol): any {\n if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return queryAll(':parentHost', {})(targetOrOptions, propertyKey);\n }\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {\n return queryAll(':parentHost', targetOrOptions as SwcQueryOptions);\n } else {\n return queryAll(':parentHost', {});\n }\n}\n\n/**\n * @allAppHost - Query all :appHost (All <swc-app> instances)\n * Usage: @allAppHost apps: SwcAppInterface[];\n * Usage: @allAppHost() apps: SwcAppInterface[];\n * Usage: @allAppHost({ root: 'shadow' }) apps: SwcAppInterface[];\n */\nexport function allAppHost(target: Object, propertyKey: string | symbol): void;\nexport function allAppHost(): PropertyDecorator;\nexport function allAppHost(options: SwcQueryOptions): PropertyDecorator;\nexport function allAppHost(targetOrOptions?: any, propertyKey?: string | symbol): any {\n if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return queryAll(':appHost', {})(targetOrOptions, propertyKey);\n }\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {\n return queryAll(':appHost', targetOrOptions as SwcQueryOptions);\n } else {\n return queryAll(':appHost', {});\n }\n}\n\n/**\n * @allFirstHost - Query all :firstHost (All first components in hierarchy)\n * Usage: @allFirstHost firsts: HTMLElement[];\n * Usage: @allFirstHost() firsts: HTMLElement[];\n * Usage: @allFirstHost({ root: 'shadow' }) firsts: HTMLElement[];\n */\nexport function allFirstHost(target: Object, propertyKey: string | symbol): void;\nexport function allFirstHost(): PropertyDecorator;\nexport function allFirstHost(options: SwcQueryOptions): PropertyDecorator;\nexport function allFirstHost(targetOrOptions?: any, propertyKey?: string | symbol): any {\n if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return queryAll(':firstHost', {})(targetOrOptions, propertyKey);\n }\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {\n return queryAll(':firstHost', targetOrOptions as SwcQueryOptions);\n } else {\n return queryAll(':firstHost', {});\n }\n}\n\n/**\n * @allLastHost - Query all :lastHost (All last components in hierarchy)\n * Usage: @allLastHost lasts: HTMLElement[];\n * Usage: @allLastHost() lasts: HTMLElement[];\n * Usage: @allLastHost({ root: 'shadow' }) lasts: HTMLElement[];\n */\nexport function allLastHost(target: Object, propertyKey: string | symbol): void;\nexport function allLastHost(): PropertyDecorator;\nexport function allLastHost(options: SwcQueryOptions): PropertyDecorator;\nexport function allLastHost(targetOrOptions?: any, propertyKey?: string | symbol): any {\n if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return queryAll(':lastHost', {})(targetOrOptions, propertyKey);\n }\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {\n return queryAll(':lastHost', targetOrOptions as SwcQueryOptions);\n } else {\n return queryAll(':lastHost', {});\n }\n}\n\n/**\n * @allFirstAppHost - Query all :firstAppHost (All first <swc-app> in hierarchy)\n * Usage: @allFirstAppHost apps: SwcAppInterface[];\n * Usage: @allFirstAppHost() apps: SwcAppInterface[];\n * Usage: @allFirstAppHost({ root: 'shadow' }) apps: SwcAppInterface[];\n */\nexport function allFirstAppHost(target: Object, propertyKey: string | symbol): void;\nexport function allFirstAppHost(): PropertyDecorator;\nexport function allFirstAppHost(options: SwcQueryOptions): PropertyDecorator;\nexport function allFirstAppHost(targetOrOptions?: any, propertyKey?: string | symbol): any {\n if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return queryAll(':firstAppHost', {})(targetOrOptions, propertyKey);\n }\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {\n return queryAll(':firstAppHost', targetOrOptions as SwcQueryOptions);\n } else {\n return queryAll(':firstAppHost', {});\n }\n}\n\n/**\n * @allLastAppHost - Query all :lastAppHost (All last <swc-app> in hierarchy)\n * Usage: @allLastAppHost apps: SwcAppInterface[];\n * Usage: @allLastAppHost() apps: SwcAppInterface[];\n * Usage: @allLastAppHost({ root: 'shadow' }) apps: SwcAppInterface[];\n */\nexport function allLastAppHost(target: Object, propertyKey: string | symbol): void;\nexport function allLastAppHost(): PropertyDecorator;\nexport function allLastAppHost(options: SwcQueryOptions): PropertyDecorator;\nexport function allLastAppHost(targetOrOptions?: any, propertyKey?: string | symbol): any {\n if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return queryAll(':lastAppHost', {})(targetOrOptions, propertyKey);\n }\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {\n return queryAll(':lastAppHost', targetOrOptions as SwcQueryOptions);\n } else {\n return queryAll(':lastAppHost', {});\n }\n}\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\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB,kBAAkB;AAC7C,SAAS,gBAAgB;AASlB,MAAM,yBAAyB,OAAO,IAAI,gCAAgC;AAO3E,SAAU,SAAS,kBAA0B,UAAe,CAAA,GAAE;AAClE,SAAO,CAAC,WAAmB,aAA8B,eAA4B;AACnF,QAAI,eAAe,QAAW;AAC5B,YAAM,IAAI,MAAM,2DAA2D,OAAO,WAAW,CAAC,GAAG;IACnG;AAEA,UAAM,cAAc,UAAU;AAC9B,QAAI,UAAU,aAAa,YAAgC,wBAAwB,WAAW;AAC9F,QAAI,CAAC,SAAS;AACZ,gBAAU,CAAA;AACV,mBAAa,eAAe,wBAAwB,SAAS,WAAW;IAC1E;AACA,YAAQ,KAAK,EAAE,aAAa,UAAU,kBAAkB,QAAO,CAAE;AAEjE,WAAO,eAAe,WAAW,aAAa;MAC5C,MAAG;AACD,mBAAW,IAAI;AACf,cAAM,WAAW;AAEjB,cAAM,IAAI,QAAQ,QAAQ;AAC1B,cAAM,YAAY,CAAC,MAAiB;AAClC,cAAI,CAAC;AAAG,mBAAO,CAAA;AACf,gBAAM,QAAQ,MAAM,QAAQ,CAAC,IAAI,IAAI,CAAC,CAAC;AACvC,gBAAM,UAAiB,CAAA;AACvB,gBAAM,QAAQ,QAAK;AACjB,gBAAI,EAAE,cAAc,cAAc;AAChC,sBAAQ,KAAK,EAAE;AACf;YACF;AACA,gBAAI,MAAM;AAAQ,sBAAQ,KAAK,GAAG,cAAc,EAAE;iBAC7C;AACH,kBAAI,MAAM,WAAW,MAAM;AAAO,wBAAQ,K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AAS,gBAAgB,CAAA,CAAE,EAAE,iBAAiB,WAAW;EAClE;AACA,MAAI,OAAO,oBAAoB,YAAY,oBAAoB,MAAM;AACnE,WAAO,SAAS,gBAAgB,eAAkC;EACpE,OAAO;AACL,WAAO,SAAS,gBAAgB,CAAA,CAAE;EACpC;AACF;AAGO,MAAM,sBAAsB,CAAC,WAA+C;AACjF,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,SAAO,aAAa,YAAY,wBAAwB,WAAW;AACrE;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ReflectUtils } from "@dooboostore/core";
|
|
2
|
+
const SUBSCRIBE_SWC_APP_ROUTE_CHANGE_METADATA_KEY = Symbol.for("simple-web-component:subscribe-swc-app-route-change");
|
|
3
|
+
function createSwcAppRouteChangeSubscriber(options) {
|
|
4
|
+
return (target, propertyKey, descriptor) => {
|
|
5
|
+
const pathPattern = options?.path;
|
|
6
|
+
const filter = options?.filter;
|
|
7
|
+
const constructor = target.constructor;
|
|
8
|
+
let list = ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_METADATA_KEY, constructor);
|
|
9
|
+
if (!list) {
|
|
10
|
+
list = [];
|
|
11
|
+
ReflectUtils.defineMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_METADATA_KEY, list, constructor);
|
|
12
|
+
}
|
|
13
|
+
list.push({ propertyKey, pathPattern, filter });
|
|
14
|
+
return descriptor;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function subscribeSwcAppRouteChange(targetOrOptions, propertyKey, descriptor) {
|
|
18
|
+
if (propertyKey && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
19
|
+
return createSwcAppRouteChangeSubscriber({})(targetOrOptions, propertyKey, descriptor);
|
|
20
|
+
}
|
|
21
|
+
let options = {};
|
|
22
|
+
if (Array.isArray(targetOrOptions)) {
|
|
23
|
+
options.path = targetOrOptions;
|
|
24
|
+
} else if (typeof targetOrOptions === "string") {
|
|
25
|
+
options.path = targetOrOptions;
|
|
26
|
+
} else if (targetOrOptions && typeof targetOrOptions === "object") {
|
|
27
|
+
options = targetOrOptions;
|
|
28
|
+
}
|
|
29
|
+
return createSwcAppRouteChangeSubscriber(options);
|
|
30
|
+
}
|
|
31
|
+
const getSubscribeSwcAppRouteChangeMetadata = (target) => {
|
|
32
|
+
const constructor = target instanceof Function ? target : target.constructor;
|
|
33
|
+
return ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_METADATA_KEY, constructor);
|
|
34
|
+
};
|
|
35
|
+
export {
|
|
36
|
+
SUBSCRIBE_SWC_APP_ROUTE_CHANGE_METADATA_KEY,
|
|
37
|
+
getSubscribeSwcAppRouteChangeMetadata,
|
|
38
|
+
subscribeSwcAppRouteChange
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=subscribeSwcAppRouteChange.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/decorators/subscribeSwcAppRouteChange.ts"],
|
|
4
|
+
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { Router } from '@dooboostore/core-web';\n\nexport const SUBSCRIBE_SWC_APP_ROUTE_CHANGE_METADATA_KEY = Symbol.for('simple-web-component:subscribe-swc-app-route-change');\n\nexport interface SwcAppRouteChangeSubscriberMetadata {\n propertyKey: string | symbol;\n pathPattern?: string | string[];\n filter?: (router: Router) => boolean;\n}\n\nexport interface SwcAppRouteChangeOptions {\n path?: string | string[];\n filter?: (router: Router) => boolean;\n}\n\nfunction createSwcAppRouteChangeSubscriber(options?: SwcAppRouteChangeOptions): MethodDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => {\n const pathPattern = options?.path;\n const filter = options?.filter;\n\n const constructor = target.constructor;\n let list = ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_METADATA_KEY, constructor) as SwcAppRouteChangeSubscriberMetadata[];\n if (!list) {\n list = [];\n ReflectUtils.defineMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_METADATA_KEY, list, constructor);\n }\n list.push({ propertyKey, pathPattern, filter });\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 subscribeSwcAppRouteChange(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 subscribeSwcAppRouteChange(): MethodDecorator;\nexport function subscribeSwcAppRouteChange(pathPattern: string): MethodDecorator;\nexport function subscribeSwcAppRouteChange(pathPatterns: string[]): MethodDecorator;\nexport function subscribeSwcAppRouteChange(options: SwcAppRouteChangeOptions): MethodDecorator;\n\n// \uC2E4\uC81C \uAD6C\uD604 (\uC774\uC911 \uBAA8\uB4DC)\nexport function subscribeSwcAppRouteChange(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n // \uC9C1\uC811 \uB370\uCF54\uB808\uC774\uD130\uB85C \uC0AC\uC6A9\uB41C \uACBD\uC6B0 (\uAD04\uD638 \uC5C6\uC74C): @subscribeSwcAppRouteChange\n // propertyKey\uAC00 string | symbol\uC774\uACE0 descriptor\uAC00 \uC788\uC73C\uBA74 \uC9C1\uC811 \uC0AC\uC6A9\n if (propertyKey && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return createSwcAppRouteChangeSubscriber({})(targetOrOptions, propertyKey, descriptor);\n }\n \n // \uD568\uC218\uB85C \uD638\uCD9C\uB41C \uACBD\uC6B0 (\uAD04\uD638 \uC788\uC74C): @subscribeSwcAppRouteChange() / @subscribeSwcAppRouteChange('/path')\n let options: SwcAppRouteChangeOptions = {};\n\n if (Array.isArray(targetOrOptions)) {\n // \uBC30\uC5F4: @subscribeSwcAppRouteChange(['/path1', '/path2'])\n options.path = targetOrOptions;\n } else if (typeof targetOrOptions === 'string') {\n // \uBB38\uC790\uC5F4: @subscribeSwcAppRouteChange('/path')\n options.path = targetOrOptions;\n } else if (targetOrOptions && typeof targetOrOptions === 'object') {\n // \uAC1D\uCCB4: @subscribeSwcAppRouteChange({ path: '/path', filter: ... })\n options = targetOrOptions;\n }\n\n return createSwcAppRouteChangeSubscriber(options);\n}\n\n// Helper function to retrieve route change subscribers metadata\nexport const getSubscribeSwcAppRouteChangeMetadata = (target: any): SwcAppRouteChangeSubscriberMetadata[] | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_METADATA_KEY, constructor);\n};\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,oBAAoB;AAGtB,MAAM,8CAA8C,OAAO,IAAI,qDAAqD;AAa3H,SAAS,kCAAkC,SAAqD;AAC9F,SAAO,CAAC,QAAgB,aAA8B,eAAoC;AACxF,UAAM,cAAc,SAAS;AAC7B,UAAM,SAAS,SAAS;AAExB,UAAM,cAAc,OAAO;AAC3B,QAAI,OAAO,aAAa,eAAe,6CAA6C,WAAW;AAC/F,QAAI,CAAC,MAAM;AACT,aAAO,CAAC;AACR,mBAAa,eAAe,6CAA6C,MAAM,WAAW;AAAA,IAC5F;AACA,SAAK,KAAK,EAAE,aAAa,aAAa,OAAO,CAAC;AAE9C,WAAO;AAAA,EACT;AACF;AAWO,SAAS,2BAA2B,iBAAuB,aAA+B,YAAsC;AAGrI,MAAI,gBAAgB,OAAO,gBAAgB,YAAY,OAAO,gBAAgB,WAAW;AACvF,WAAO,kCAAkC,CAAC,CAAC,EAAE,iBAAiB,aAAa,UAAU;AAAA,EACvF;AAGA,MAAI,UAAoC,CAAC;AAEzC,MAAI,MAAM,QAAQ,eAAe,GAAG;AAElC,YAAQ,OAAO;AAAA,EACjB,WAAW,OAAO,oBAAoB,UAAU;AAE9C,YAAQ,OAAO;AAAA,EACjB,WAAW,mBAAmB,OAAO,oBAAoB,UAAU;AAEjE,cAAU;AAAA,EACZ;AAEA,SAAO,kCAAkC,OAAO;AAClD;AAGO,MAAM,wCAAwC,CAAC,WAAmE;AACvH,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,SAAO,aAAa,eAAe,6CAA6C,WAAW;AAC7F;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -4,80 +4,35 @@ import { HashRouter } from "@dooboostore/core-web";
|
|
|
4
4
|
import { ElementRouter } from "../router/ElementRouter.js";
|
|
5
5
|
import { SimOption } from "@dooboostore/simple-boot/SimOption";
|
|
6
6
|
import { Router } from "@dooboostore/core-web";
|
|
7
|
-
import { FunctionUtils } from "@dooboostore/core";
|
|
8
|
-
import { SwcUtils } from "../utils/Utils.js";
|
|
9
|
-
import { Intent } from "@dooboostore/simple-boot";
|
|
10
7
|
class SwcAppEngine {
|
|
11
8
|
constructor(host) {
|
|
12
9
|
this.host = host;
|
|
13
|
-
this._isInitialized = false;
|
|
14
10
|
}
|
|
15
11
|
get config() {
|
|
16
12
|
return this._config;
|
|
17
13
|
}
|
|
18
14
|
async connect(config) {
|
|
19
|
-
if (this._isInitialized) return;
|
|
20
|
-
let userConfig = config;
|
|
21
|
-
const win = this.host.ownerDocument?.defaultView || window;
|
|
22
|
-
const Node = win.Node;
|
|
23
|
-
if (!userConfig) {
|
|
24
|
-
const configStr = this.host.getAttribute("swc-get-application-config");
|
|
25
|
-
if (configStr) {
|
|
26
|
-
try {
|
|
27
|
-
userConfig = FunctionUtils.executeReturn({
|
|
28
|
-
script: configStr,
|
|
29
|
-
context: this.host,
|
|
30
|
-
args: SwcUtils.getHelperAndHostSet(win, SwcUtils.findNearestSwcHost(this.host))
|
|
31
|
-
});
|
|
32
|
-
} catch (e) {
|
|
33
|
-
console.error("[SWC-APP-ENGINE] Script execution failed:", e);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
if (!userConfig) return;
|
|
38
|
-
this._isInitialized = true;
|
|
39
15
|
try {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
} else if (_config.routeType === "element") {
|
|
52
|
-
this.router = new ElementRouter({ window: _config.window, firstUrl: _config.path });
|
|
53
|
-
}
|
|
54
|
-
if (this.router) {
|
|
55
|
-
this.routerSubscription = this.router.observable.subscribe((route) => {
|
|
56
|
-
if (route.triggerPoint === "end") {
|
|
57
|
-
const targetPath = (route.path || "/") + route.search;
|
|
58
|
-
const intent = new Intent(targetPath);
|
|
59
|
-
this.simpleApplication?.routing(intent);
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
const containerSymbol = _config.container || this.host.getContainerSymbol?.();
|
|
64
|
-
this.simpleApplication = new SimpleApplication(new SimOption({
|
|
16
|
+
this._config = config;
|
|
17
|
+
if (this._config.routeType === "path") {
|
|
18
|
+
this.router = new PathRouter({ window: this._config.window, firstUrl: this._config.path });
|
|
19
|
+
} else if (this._config.routeType === "hash") {
|
|
20
|
+
this.router = new HashRouter({ window: this._config.window, firstUrl: this._config.path });
|
|
21
|
+
} else if (this._config.routeType === "element") {
|
|
22
|
+
this.router = new ElementRouter({ window: this._config.window, firstUrl: this._config.path });
|
|
23
|
+
}
|
|
24
|
+
const containerSymbol = this._config.container || this.host.getContainerSymbol?.();
|
|
25
|
+
this.simpleApplication = new SimpleApplication(
|
|
26
|
+
new SimOption({
|
|
65
27
|
excludeProxys: [Node],
|
|
66
|
-
rootRouter: _config.rootRouter,
|
|
67
28
|
container: containerSymbol
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
else this.host.replaceChildren(data);
|
|
76
|
-
}
|
|
77
|
-
if (_config.path) this.router?.go(_config.path);
|
|
78
|
-
if (_config.onStarted) {
|
|
79
|
-
_config.onStarted(this.host);
|
|
80
|
-
}
|
|
29
|
+
})
|
|
30
|
+
);
|
|
31
|
+
const otherInstanceSim = /* @__PURE__ */ new Map();
|
|
32
|
+
if (this.router) otherInstanceSim.set(Router, this.router);
|
|
33
|
+
this.simpleApplication.run(otherInstanceSim);
|
|
34
|
+
if (this._config.onEngineStarted) {
|
|
35
|
+
this._config.onEngineStarted(this.simpleApplication, this.host);
|
|
81
36
|
}
|
|
82
37
|
} catch (e) {
|
|
83
38
|
console.error("[SWC-APP-ENGINE] Init failed:", e);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/elements/SwcAppEngine.ts"],
|
|
4
|
-
"sourcesContent": ["import { SimpleApplication } from '@dooboostore/simple-boot/SimpleApplication';\nimport { PathRouter } from '@dooboostore/core-web';\nimport { HashRouter } from '@dooboostore/core-web';\nimport { ElementRouter } from '../router/ElementRouter';\nimport { SimOption } from '@dooboostore/simple-boot/SimOption';\nimport { Router, RouterEventType } from '@dooboostore/core-web';\nimport { Subscription } from '@dooboostore/core';\nimport { ConstructorType, OptionalType } from '@dooboostore/core';\nimport { FunctionUtils } from '@dooboostore/core';\nimport { SwcUtils } from '../utils/Utils';\n\nimport { SwcAppInterface } from '../types';\nimport {Intent} from \"@dooboostore/simple-boot\";\n\nexport type SwcConfigType = {\n
|
|
5
|
-
"mappings": "AAAA,SAAS,yBAAyB;AAClC,SAAS,kBAAkB;AAC3B,SAAS,kBAAkB;AAC3B,SAAS,qBAAqB;AAC9B,SAAS,iBAAiB;AAC1B,SAAS,cAA+B;
|
|
4
|
+
"sourcesContent": ["import { SimpleApplication } from '@dooboostore/simple-boot/SimpleApplication';\nimport { PathRouter } from '@dooboostore/core-web';\nimport { HashRouter } from '@dooboostore/core-web';\nimport { ElementRouter } from '../router/ElementRouter';\nimport { SimOption } from '@dooboostore/simple-boot/SimOption';\nimport { Router, RouterEventType } from '@dooboostore/core-web';\nimport { Subscription } from '@dooboostore/core';\nimport { ConstructorType, OptionalType } from '@dooboostore/core';\nimport { FunctionUtils } from '@dooboostore/core';\nimport { SwcUtils } from '../utils/Utils';\n\nimport { SwcAppInterface } from '../types';\nimport {Intent} from \"@dooboostore/simple-boot\";\n\nexport type SwcConfigType = {\n routeType: 'path' | 'hash' | 'element';\n connectMode?: 'direct' | 'swap';\n container?: symbol;\n path?: string;\n window: Window;\n onEngineStarted?: (sp: SimpleApplication, app: SwcAppInterface) => void;\n onConnected?: (app: SwcAppInterface) => void;\n onDisconnected?: (app: SwcAppInterface) => void;\n};\n\nexport type SwcAttributeConfigType = OptionalType<SwcConfigType, 'routeType' | 'window'>;\n\nexport class SwcAppEngine {\n public simpleApplication?: SimpleApplication;\n public router?: Router;\n private routerSubscription?: Subscription;\n private _config?: SwcConfigType;\n\n constructor(private host: HTMLElement) {}\n\n get config() {\n return this._config;\n }\n async connect(config: SwcConfigType) {\n try {\n this._config = config;\n\n // Router Selection\n if (this._config.routeType === 'path') {\n this.router = new PathRouter({ window: this._config.window, firstUrl: this._config.path });\n } else if (this._config.routeType === 'hash') {\n this.router = new HashRouter({ window: this._config.window, firstUrl: this._config.path });\n } else if (this._config.routeType === 'element') {\n this.router = new ElementRouter({ window: this._config.window, firstUrl: this._config.path });\n }\n\n // console.log('vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv', this.router)\n\n // App start\n const containerSymbol = this._config.container || (this.host as any).getContainerSymbol?.();\n this.simpleApplication = new SimpleApplication(\n new SimOption({\n excludeProxys: [Node],\n container: containerSymbol\n })\n );\n\n const otherInstanceSim = new Map<any, any>();\n if (this.router) otherInstanceSim.set(Router, this.router);\n this.simpleApplication.run(otherInstanceSim);\n\n if (this._config.onEngineStarted) {\n this._config.onEngineStarted(this.simpleApplication, this.host as unknown as SwcAppInterface);\n }\n } catch (e) {\n console.error('[SWC-APP-ENGINE] Init failed:', e);\n }\n }\n\n disconnect() {\n this.routerSubscription?.unsubscribe();\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,yBAAyB;AAClC,SAAS,kBAAkB;AAC3B,SAAS,kBAAkB;AAC3B,SAAS,qBAAqB;AAC9B,SAAS,iBAAiB;AAC1B,SAAS,cAA+B;AAsBjC,MAAM,aAAa;AAAA,EAMxB,YAAoB,MAAmB;AAAnB;AAAA,EAAoB;AAAA,EAExC,IAAI,SAAS;AACX,WAAO,KAAK;AAAA,EACd;AAAA,EACA,MAAM,QAAQ,QAAuB;AACnC,QAAI;AACF,WAAK,UAAU;AAGf,UAAI,KAAK,QAAQ,cAAc,QAAQ;AACrC,aAAK,SAAS,IAAI,WAAW,EAAE,QAAQ,KAAK,QAAQ,QAAQ,UAAU,KAAK,QAAQ,KAAK,CAAC;AAAA,MAC3F,WAAW,KAAK,QAAQ,cAAc,QAAQ;AAC5C,aAAK,SAAS,IAAI,WAAW,EAAE,QAAQ,KAAK,QAAQ,QAAQ,UAAU,KAAK,QAAQ,KAAK,CAAC;AAAA,MAC3F,WAAW,KAAK,QAAQ,cAAc,WAAW;AAC/C,aAAK,SAAS,IAAI,cAAc,EAAE,QAAQ,KAAK,QAAQ,QAAQ,UAAU,KAAK,QAAQ,KAAK,CAAC;AAAA,MAC9F;AAKA,YAAM,kBAAkB,KAAK,QAAQ,aAAc,KAAK,KAAa,qBAAqB;AAC1F,WAAK,oBAAoB,IAAI;AAAA,QAC3B,IAAI,UAAU;AAAA,UACZ,eAAe,CAAC,IAAI;AAAA,UACpB,WAAW;AAAA,QACb,CAAC;AAAA,MACH;AAEA,YAAM,mBAAmB,oBAAI,IAAc;AAC3C,UAAI,KAAK,OAAQ,kBAAiB,IAAI,QAAQ,KAAK,MAAM;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