@dooboostore/simple-web-component 1.0.15 → 1.0.16
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 +183 -92
- package/dist/cjs/decorators/addEventListener.js +2 -3
- package/dist/cjs/decorators/addEventListener.js.map +2 -2
- package/dist/cjs/decorators/elementDefine.js +89 -33
- package/dist/cjs/decorators/elementDefine.js.map +2 -2
- package/dist/cjs/decorators/emitCustomEvent.js +2 -14
- package/dist/cjs/decorators/emitCustomEvent.js.map +2 -2
- package/dist/cjs/decorators/query.js +25 -36
- package/dist/cjs/decorators/query.js.map +2 -2
- package/dist/cjs/decorators/queryAll.js +28 -36
- package/dist/cjs/decorators/queryAll.js.map +2 -2
- package/dist/cjs/types.js +1 -0
- package/dist/cjs/types.js.map +2 -2
- package/dist/cjs/utils/Utils.js +36 -143
- package/dist/cjs/utils/Utils.js.map +2 -2
- package/dist/esm/decorators/addEventListener.js +2 -3
- package/dist/esm/decorators/addEventListener.js.map +2 -2
- package/dist/esm/decorators/elementDefine.js +89 -33
- package/dist/esm/decorators/elementDefine.js.map +2 -2
- package/dist/esm/decorators/emitCustomEvent.js +2 -14
- package/dist/esm/decorators/emitCustomEvent.js.map +2 -2
- package/dist/esm/decorators/query.js +25 -36
- package/dist/esm/decorators/query.js.map +2 -2
- package/dist/esm/decorators/queryAll.js +28 -36
- package/dist/esm/decorators/queryAll.js.map +2 -2
- package/dist/esm/types.js +1 -0
- package/dist/esm/types.js.map +2 -2
- package/dist/esm/utils/Utils.js +36 -143
- package/dist/esm/utils/Utils.js.map +2 -2
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +183 -266
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +3 -3
- package/dist/types/decorators/addEventListener.d.ts +9 -4
- package/dist/types/decorators/addEventListener.d.ts.map +1 -1
- package/dist/types/decorators/elementDefine.d.ts.map +1 -1
- package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
- package/dist/types/decorators/query.d.ts +6 -5
- package/dist/types/decorators/query.d.ts.map +1 -1
- package/dist/types/decorators/queryAll.d.ts +6 -5
- package/dist/types/decorators/queryAll.d.ts.map +1 -1
- package/dist/types/types.d.ts +3 -1
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils/Utils.d.ts +6 -14
- package/dist/types/utils/Utils.d.ts.map +1 -1
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +183 -266
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +3 -3
- package/package.json +3 -3
- package/src/decorators/addEventListener.ts +10 -7
- package/src/decorators/elementDefine.ts +86 -31
- package/src/decorators/emitCustomEvent.ts +5 -21
- package/src/decorators/query.ts +33 -46
- package/src/decorators/queryAll.ts +36 -46
- package/src/types.ts +6 -4
- package/src/utils/Utils.ts +40 -176
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/decorators/elementDefine.ts"],
|
|
4
|
-
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core/reflect/ReflectUtils';\nimport { getInnerHtmlMetadataList } from './innerHtml';\nimport { getQueryMetadata } from './query';\nimport { getQueryAllMetadata } from './queryAll';\nimport { getAddEventListenerMetadata } from './addEventListener';\nimport { ON_BEFORE_CONNECTED_METADATA_KEY, ON_AFTER_CONNECTED_METADATA_KEY, ON_BEFORE_DISCONNECTED_METADATA_KEY, ON_AFTER_DISCONNECTED_METADATA_KEY, ON_BEFORE_ADOPTED_METADATA_KEY, ON_AFTER_ADOPTED_METADATA_KEY, ON_ADD_EVENT_LISTENER_METADATA_KEY, ATTRIBUTE_CHANGED_WILDCARD, findAllLifecycleMetadata } from './lifecycles';\nimport { getEmitCustomEventMetadataList } from './emitCustomEvent';\nimport { changedAttribute, findAllAttributeChangedMetadata } from './changedAttribute';\nimport { setAttribute, findAllSetAttributeMetadata } from './setAttribute';\nimport { SwcUtils } from '../utils/Utils';\nimport { HTML_TAG_ENTRIES, DOM_EVENT_NAMES } from '../config/config';\nimport { SituationType, SituationTypeContainer, SituationTypeContainers } from '@dooboostore/simple-boot/decorators/inject/Inject';\nimport { ConstructorType } from '@dooboostore/core/types';\nimport { InjectSituationType, HostSet, SwcAppInterface } from '../types';\n\n// --- Core Interfaces & Types (Integrated) ---\n\nexport interface ElementConfig {\n name: string;\n extends?: string;\n observedAttributes?: string[];\n customElementRegistry?: CustomElementRegistry;\n window?: Window;\n}\n\nexport const ELEMENT_CONFIG_KEY = Symbol('simple-web-component:element-config');\n\n// --- Environment Initialization Helper ---\n\nfunction buildEnv(configWindow?: Window) {\n const win: any = configWindow || (typeof window !== 'undefined' ? window : undefined);\n const doc: Document = win?.document;\n\n const builtInTagMap = new Map<any, string>();\n for (const [cls, tag] of HTML_TAG_ENTRIES) {\n if (win?.[cls]) builtInTagMap.set(win[cls], tag);\n }\n\n const domHelpers = {\n $d: doc,\n $w: win,\n $q: (sel: string, root?: Element | Document | ShadowRoot) => (root ?? doc).querySelector(sel),\n $qa: (sel: string, root?: Element | Document | ShadowRoot) => Array.from((root ?? doc).querySelectorAll(sel)),\n $qi: (id: string, root?: Document | ShadowRoot) => (root ?? doc).getElementById(id)\n } as const;\n\n return { win, doc, builtInTagMap, domHelpers };\n}\n\nconst getHandlers = (inst: any) => {\n if (!inst.__swc_attributeEventHandlers) inst.__swc_attributeEventHandlers = new Map();\n return inst.__swc_attributeEventHandlers;\n};\n\nexport const elementDefine =\n (inConfig: ElementConfig | string): ClassDecorator =>\n (constructor: any) => {\n const config: ElementConfig = typeof inConfig === 'string' ? { name: inConfig } : inConfig;\n const { win, doc, builtInTagMap: BUILT_IN_TAG_MAP, domHelpers: SWC_DOM_HELPERS } = buildEnv(config.window);\n config.window = win;\n const SWC_DOM_HELPER_KEYS = Object.keys(SWC_DOM_HELPERS) as (keyof typeof SWC_DOM_HELPERS)[];\n const SWC_DOM_HELPER_VALS = () => SWC_DOM_HELPER_KEYS.map(k => (SWC_DOM_HELPERS as any)[k]);\n\n let extendsTagName = config.extends;\n if (!extendsTagName) {\n let proto = constructor;\n while (proto && proto !== HTMLElement && proto !== Function.prototype) {\n extendsTagName = BUILT_IN_TAG_MAP.get(proto);\n if (extendsTagName) break;\n proto = Object.getPrototypeOf(proto);\n }\n config.extends = extendsTagName;\n }\n\n const emitCustomEventList = getEmitCustomEventMetadataList(constructor) || [];\n const addEventListenerList = getAddEventListenerMetadata(constructor) || [];\n const attrChangeMap = findAllAttributeChangedMetadata(constructor);\n const setAttrMap = findAllSetAttributeMetadata(constructor);\n\n const swcLifecycleAttributes = ['swc-on-constructor', 'swc-on-connected', 'swc-on-disconnected', 'swc-on-before-connected', 'swc-on-after-connected', 'swc-on-before-disconnected', 'swc-on-after-disconnected', 'swc-on-before-adopted', 'swc-on-after-adopted', 'swc-on-attribute-changed'];\n const swcOnEvents = DOM_EVENT_NAMES.map(e => `swc-on-${e}`);\n\n const mergedObservedAttributes = [...new Set([...(config.observedAttributes ?? []), ...attrChangeMap.keys(), ...setAttrMap.keys(), ...emitCustomEventList.map(it => it.options.attributeName!), ...swcLifecycleAttributes, ...swcOnEvents])];\n const innerHtmlList = getInnerHtmlMetadataList(constructor) || [];\n\n const NewClass = class extends (constructor as any) {\n private _swcId = Math.random().toString(36).substring(2, 11);\n private _emitHandlers = new Map<string, EventListener>();\n\n private _executeSwcScript(attrName: string, hostSet: HostSet, extraArgs: Record<string, any> = {}) {\n const script = this.getAttribute(attrName);\n if (script) {\n try {\n const args = { ...hostSet, ...SWC_DOM_HELPERS, ...extraArgs };\n const argNames = Object.keys(args);\n const argValues = Object.values(args);\n new Function(...argNames, script).apply(this, argValues);\n } catch (e) {\n console.error(`[SWC] Failed to execute ${attrName}:`, e);\n }\n }\n }\n\n private async _invokeLifecycleMethod(methodName: string | symbol, hostSet: HostSet, extraArgs: any[] = []) {\n if (typeof (this as any)[methodName] !== 'function') return;\n const app = hostSet.$appHost?.simpleApplication;\n\n if (app) {\n const otherStorage = new Map<any, any>();\n const situations = new SituationTypeContainers([new SituationTypeContainer({ situationType: InjectSituationType.HOST_SET, data: hostSet }), new SituationTypeContainer({ situationType: InjectSituationType.APP_HOST, data: hostSet.$appHost }), new SituationTypeContainer({ situationType: InjectSituationType.APP_HOSTS, data: hostSet.$appHosts }), new SituationTypeContainer({ situationType: InjectSituationType.HOST, data: hostSet.$host }), new SituationTypeContainer({ situationType: InjectSituationType.HOSTS, data: hostSet.$hosts }), new SituationTypeContainer({ situationType: InjectSituationType.FIRST_HOST, data: hostSet.$firstHost }), new SituationTypeContainer({ situationType: InjectSituationType.LAST_HOST, data: hostSet.$lastHost }), new SituationTypeContainer({ situationType: InjectSituationType.FIRST_APP_HOST, data: hostSet.$firstAppHost }), new SituationTypeContainer({ situationType: InjectSituationType.LAST_APP_HOST, data: hostSet.$lastAppHost })]);\n otherStorage.set(SituationTypeContainers, situations);\n\n return app.simstanceManager.executeBindParameterSimPromise(\n {\n target: this,\n targetKey: methodName,\n inputParameters: extraArgs\n },\n otherStorage\n );\n } else {\n return (this as any)[methodName](...extraArgs);\n }\n }\n\n private _bindAttributeEvent(el: HTMLElement, attrName: string, script: string) {\n if (!attrName.startsWith('swc-on-')) return;\n const eventName = attrName.substring(7);\n if (swcLifecycleAttributes.includes(attrName)) return;\n\n const elHandlers = getHandlers(this);\n let handlers = elHandlers.get(el);\n if (!handlers) {\n handlers = new Map();\n elHandlers.set(el, handlers);\n }\n\n const oldHandler = handlers.get(attrName);\n if (oldHandler) el.removeEventListener(eventName, oldHandler);\n\n const handler = (event: any) => {\n const hostSet = SwcUtils.getHostSet(el);\n const argNames = Object.keys(hostSet);\n const argValues = Object.values(hostSet);\n new Function('event', '$data', ...argNames, ...SWC_DOM_HELPER_KEYS, script).call(el, event, (event as CustomEvent).detail, ...argValues, ...SWC_DOM_HELPER_VALS());\n };\n\n el.addEventListener(eventName, handler);\n handlers.set(attrName, handler);\n }\n\n constructor(...args: any[]) {\n super(...args);\n const hostSet = SwcUtils.getHostSet(this as any);\n this._executeSwcScript('swc-on-constructor', hostSet);\n\n if (innerHtmlList.some(it => it.options.useShadow === true) && !this.shadowRoot) {\n this.attachShadow({ mode: 'open' });\n }\n }\n\n static get observedAttributes() {\n return mergedObservedAttributes;\n }\n\n async connectedCallback() {\n const hostSet = SwcUtils.getHostSet(this as any);\n\n this._executeSwcScript('swc-on-before-connected', hostSet);\n const bMethods = findAllLifecycleMetadata(this, ON_BEFORE_CONNECTED_METADATA_KEY);\n if (bMethods) {\n for (const m of bMethods) await this._invokeLifecycleMethod(m, hostSet);\n }\n\n if (typeof (this as any).initCore === 'function') (this as any).initCore();\n\n if (innerHtmlList.length > 0) {\n let sContent = '',\n lContent = '';\n for (const meta of innerHtmlList) {\n const res = await (this as any)[meta.propertyKey]();\n if (res !== undefined) {\n if (meta.options.useShadow) sContent += res;\n else lContent += res;\n }\n }\n if (this.shadowRoot) this.shadowRoot.innerHTML = sContent;\n if (lContent) this.innerHTML = lContent;\n }\n\n // --- @addEventListener binding ---\n addEventListenerList.forEach(meta => {\n const { type, query, root, capture, once, passive, stopPropagation, stopImmediatePropagation, preventDefault } = meta.options;\n const targetEls: (HTMLElement | Element | Document | ShadowRoot | Window)[] = [];\n\n if (!query) {\n targetEls.push(this as any);\n } else {\n const searchRoots: (HTMLElement | ShadowRoot)[] = [];\n const r = root || 'auto';\n if (r === 'auto') {\n searchRoots.push((this.shadowRoot || (this as any)) as any);\n } else if (r === 'light') {\n searchRoots.push(this as any);\n } else if (r === 'shadow') {\n if (this.shadowRoot) searchRoots.push(this.shadowRoot as any);\n } else if (r === 'all') {\n searchRoots.push(this as any);\n if (this.shadowRoot) searchRoots.push(this.shadowRoot as any);\n }\n\n searchRoots.forEach(sr => {\n const found = sr.querySelectorAll(query);\n found.forEach(el => targetEls.push(el as any));\n });\n }\n\n targetEls.forEach(el => {\n const handler = (event: Event) => {\n if (stopPropagation) event.stopPropagation();\n if (stopImmediatePropagation) event.stopImmediatePropagation();\n if (preventDefault) event.preventDefault();\n\n const hostSet = SwcUtils.getHostSet(this as any);\n this._invokeLifecycleMethod(meta.propertyKey, hostSet, [event, hostSet]);\n };\n const options = { capture, once, passive };\n el.addEventListener(type, handler, options);\n });\n });\n\n if (super.connectedCallback) await super.connectedCallback();\n const aMethods = findAllLifecycleMetadata(this, ON_AFTER_CONNECTED_METADATA_KEY);\n if (aMethods) {\n for (const m of aMethods) await this._invokeLifecycleMethod(m, hostSet);\n }\n\n this._executeSwcScript('swc-on-connected', hostSet);\n this._executeSwcScript('swc-on-after-connected', hostSet);\n }\n\n disconnectedCallback() {\n const hostSet = SwcUtils.getHostSet(this as any);\n this._executeSwcScript('swc-on-before-disconnected', hostSet);\n const bMethods = findAllLifecycleMetadata(this, ON_BEFORE_DISCONNECTED_METADATA_KEY);\n if (bMethods) bMethods.forEach(m => this._invokeLifecycleMethod(m, hostSet));\n\n if (super.disconnectedCallback) super.disconnectedCallback();\n\n const aMethods = findAllLifecycleMetadata(this, ON_AFTER_DISCONNECTED_METADATA_KEY);\n if (aMethods) aMethods.forEach(m => this._invokeLifecycleMethod(m, hostSet));\n this._executeSwcScript('swc-on-disconnected', hostSet);\n this._executeSwcScript('swc-on-after-disconnected', hostSet);\n }\n\n adoptedCallback() {\n const hostSet = SwcUtils.getHostSet(this as any);\n this._executeSwcScript('swc-on-before-adopted', hostSet);\n const bMethods = findAllLifecycleMetadata(this, ON_BEFORE_ADOPTED_METADATA_KEY);\n if (bMethods) bMethods.forEach(m => this._invokeLifecycleMethod(m, hostSet));\n\n if (super.adoptedCallback) super.adoptedCallback();\n\n const aMethods = findAllLifecycleMetadata(this, ON_AFTER_ADOPTED_METADATA_KEY);\n if (aMethods) aMethods.forEach(m => this._invokeLifecycleMethod(m, hostSet));\n this._executeSwcScript('swc-on-adopted', hostSet);\n this._executeSwcScript('swc-on-after-adopted', hostSet);\n }\n\n attributeChangedCallback(name: string, old: string | null, newVal: string | null) {\n if (super.attributeChangedCallback) super.attributeChangedCallback(name, old, newVal);\n\n if (name.startsWith('swc-on-') && !swcLifecycleAttributes.includes(name)) {\n if (newVal !== null) {\n this._bindAttributeEvent(this as any, name, newVal);\n }\n }\n\n const mKeys = attrChangeMap.get(name);\n if (mKeys && Array.isArray(mKeys)) {\n const hSet = SwcUtils.getHostSet(this as any);\n mKeys.forEach(key => this._invokeLifecycleMethod(key, hSet, [newVal, old, name]));\n }\n }\n };\n\n // --- @setAttribute wrapping logic ---\n setAttrMap.forEach((methodName, attrName) => {\n const original = NewClass.prototype[methodName as any];\n if (typeof original === 'function') {\n NewClass.prototype[methodName as any] = function (...args: any[]) {\n const res = original.apply(this, args);\n if (res !== undefined) {\n if (res === null) this.removeAttribute(attrName);\n else this.setAttribute(attrName, String(res));\n }\n return res;\n };\n }\n });\n\n const originalProto = constructor.prototype;\n const newProto = NewClass.prototype;\n Object.getOwnPropertyNames(originalProto).forEach(name => {\n if (name === 'constructor') return;\n const keys = Reflect.getMetadataKeys(originalProto, name);\n keys.forEach(key => Reflect.defineMetadata(key, Reflect.getMetadata(key, originalProto, name), newProto, name));\n });\n\n ReflectUtils.defineMetadata(ELEMENT_CONFIG_KEY, config, NewClass);\n ReflectUtils.defineMetadata(ELEMENT_CONFIG_KEY, config, constructor);\n const registry = config.customElementRegistry || (win as any)?.customElements;\n if (registry && !registry.get(config.name)) {\n registry.define(config.name, NewClass as any, config.extends ? { extends: config.extends } : undefined);\n }\n return NewClass as any;\n };\n\nexport const getElementConfig = (target: any): ElementConfig | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(ELEMENT_CONFIG_KEY, constructor);\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;;;;;;;0BAA6B;AAC7B,uBAAyC;AAGzC,8BAA4C;AAC5C,wBAAoT;AACpT,6BAA+C;AAC/C,8BAAkE;AAClE,0BAA0D;AAC1D,mBAAyB;AACzB,oBAAkD;AAClD,oBAA+E;AAE/E,mBAA8D;AAYvD,MAAM,qBAAqB,OAAO,q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C,IAAI,qCAAuB,EAAE,eAAe,iCAAoB,UAAU,MAAM,QAAO,CAAE,GAAG,IAAI,qCAAuB,EAAE,eAAe,iCAAoB,UAAU,MAAM,QAAQ,SAAQ,CAAE,GAAG,IAAI,qCAAuB,EAAE,eAAe,iCAAoB,WAAW,MAAM,QAAQ,UAAS,CAAE,GAAG,IAAI,qCAAuB,EAAE,eAAe,iCAAoB,MAAM,MAAM,QAAQ,MAAK,CAAE,GAAG,IAAI,qCAAuB,EAAE,eAAe,iCAAoB,OAAO,MAAM,QAAQ,OAAM,CAAE,GAAG,IAAI,qCAAuB,EAAE,eAAe,iCAAoB,YAAY,MAAM,QAAQ,WAAU,CAAE,GAAG,IAAI,qCAAuB,EAAE,eAAe,iCAAoB,WAAW,MAAM,QAAQ,UAAS,CAAE,GAAG,IAAI,qCAAuB,EAAE,eAAe,iCAAoB,gBAAgB,MAAM,QAAQ,cAAa,CAAE,GAAG,IAAI,qCAAuB,EAAE,eAAe,iCAAoB,eAAe,MAAM,QAAQ,aAAY,CAAE,CAAC,CAAC;AACn8B,qBAAa,IAAI,uCAAyB,UAAU;AAEpD,eAAO,IAAI,iBAAiB,+BAC1B;UACE,QAAQ;UACR,WAAW;UACX,iBAAiB;WAEnB,YAAY;MAEhB,OAAO;AACL,eAAQ,KAAa,UAAU,EAAE,GAAG,SAAS;MAC/C;IACF;IAEQ,oBAAoB,IAAiB,UAAkB,
|
|
4
|
+
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core/reflect/ReflectUtils';\nimport { getInnerHtmlMetadataList } from './innerHtml';\nimport { getQueryMetadata } from './query';\nimport { getQueryAllMetadata } from './queryAll';\nimport { getAddEventListenerMetadata } from './addEventListener';\nimport { ON_BEFORE_CONNECTED_METADATA_KEY, ON_AFTER_CONNECTED_METADATA_KEY, ON_BEFORE_DISCONNECTED_METADATA_KEY, ON_AFTER_DISCONNECTED_METADATA_KEY, ON_BEFORE_ADOPTED_METADATA_KEY, ON_AFTER_ADOPTED_METADATA_KEY, ON_ADD_EVENT_LISTENER_METADATA_KEY, ATTRIBUTE_CHANGED_WILDCARD, findAllLifecycleMetadata } from './lifecycles';\nimport { getEmitCustomEventMetadataList } from './emitCustomEvent';\nimport { changedAttribute, findAllAttributeChangedMetadata } from './changedAttribute';\nimport { setAttribute, findAllSetAttributeMetadata } from './setAttribute';\nimport { SwcUtils } from '../utils/Utils';\nimport { HTML_TAG_ENTRIES, DOM_EVENT_NAMES } from '../config/config';\nimport { SituationType, SituationTypeContainer, SituationTypeContainers } from '@dooboostore/simple-boot/decorators/inject/Inject';\nimport { ConstructorType } from '@dooboostore/core/types';\nimport { InjectSituationType, HostSet, SwcAppInterface } from '../types';\n\n// --- Core Interfaces & Types (Integrated) ---\n\nexport interface ElementConfig {\n name: string;\n extends?: string;\n observedAttributes?: string[];\n customElementRegistry?: CustomElementRegistry;\n window?: Window;\n}\n\nexport const ELEMENT_CONFIG_KEY = Symbol('simple-web-component:element-config');\n\n// --- Environment Initialization Helper ---\n\nfunction buildEnv(configWindow?: Window) {\n const win: any = configWindow || (typeof window !== 'undefined' ? window : undefined);\n const doc: Document = win?.document;\n\n const builtInTagMap = new Map<any, string>();\n for (const [cls, tag] of HTML_TAG_ENTRIES) {\n if (win?.[cls]) builtInTagMap.set(win[cls], tag);\n }\n\n const domHelpers = {\n $d: doc,\n $w: win,\n $q: (sel: string, root?: Element | Document | ShadowRoot) => (root ?? doc).querySelector(sel),\n $qa: (sel: string, root?: Element | Document | ShadowRoot) => Array.from((root ?? doc).querySelectorAll(sel)),\n $qi: (id: string, root?: Document | ShadowRoot) => (root ?? doc).getElementById(id)\n } as const;\n\n return { win, doc, builtInTagMap, domHelpers };\n}\n\nconst getHandlers = (inst: any) => {\n if (!inst.__swc_attributeEventHandlers) inst.__swc_attributeEventHandlers = new Map();\n return inst.__swc_attributeEventHandlers;\n};\n\nexport const elementDefine =\n (inConfig: ElementConfig | string): ClassDecorator =>\n (constructor: any) => {\n const config: ElementConfig = typeof inConfig === 'string' ? { name: inConfig } : inConfig;\n const { win, doc, builtInTagMap: BUILT_IN_TAG_MAP, domHelpers: SWC_DOM_HELPERS } = buildEnv(config.window);\n config.window = win;\n const SWC_DOM_HELPER_KEYS = Object.keys(SWC_DOM_HELPERS) as (keyof typeof SWC_DOM_HELPERS)[];\n const SWC_DOM_HELPER_VALS = () => SWC_DOM_HELPER_KEYS.map(k => (SWC_DOM_HELPERS as any)[k]);\n\n let extendsTagName = config.extends;\n if (!extendsTagName) {\n let proto = constructor;\n while (proto && proto !== HTMLElement && proto !== Function.prototype) {\n extendsTagName = BUILT_IN_TAG_MAP.get(proto);\n if (extendsTagName) break;\n proto = Object.getPrototypeOf(proto);\n }\n config.extends = extendsTagName;\n }\n\n const emitCustomEventList = getEmitCustomEventMetadataList(constructor) || [];\n const addEventListenerList = getAddEventListenerMetadata(constructor) || [];\n const attrChangeMap = findAllAttributeChangedMetadata(constructor);\n const setAttrMap = findAllSetAttributeMetadata(constructor);\n\n const swcLifecycleAttributes = ['swc-on-constructor', 'swc-on-connected', 'swc-on-disconnected', 'swc-on-before-connected', 'swc-on-after-connected', 'swc-on-before-disconnected', 'swc-on-after-disconnected', 'swc-on-before-adopted', 'swc-on-after-adopted', 'swc-on-attribute-changed'];\n const swcOnEvents = DOM_EVENT_NAMES.map(e => `swc-on-${e}`);\n\n const mergedObservedAttributes = [...new Set([...(config.observedAttributes ?? []), ...attrChangeMap.keys(), ...setAttrMap.keys(), ...emitCustomEventList.map(it => it.options.attributeName!), ...swcLifecycleAttributes, ...swcOnEvents])];\n const innerHtmlList = getInnerHtmlMetadataList(constructor) || [];\n\n const NewClass = class extends (constructor as any) {\n private _swcId = Math.random().toString(36).substring(2, 11);\n private _emitHandlers = new Map<string, EventListener>();\n\n private _executeSwcScript(attrName: string, hostSet: HostSet, extraArgs: Record<string, any> = {}) {\n const script = this.getAttribute(attrName);\n if (script) {\n try {\n const args = { ...hostSet, ...SWC_DOM_HELPERS, ...extraArgs };\n const argNames = Object.keys(args);\n const argValues = Object.values(args);\n new Function(...argNames, script).apply(this, argValues);\n } catch (e) {\n console.error(`[SWC] Failed to execute ${attrName}:`, e);\n }\n }\n }\n\n private async _invokeLifecycleMethod(methodName: string | symbol, hostSet: HostSet, extraArgs: any[] = []) {\n if (typeof (this as any)[methodName] !== 'function') return;\n const app = hostSet.$appHost?.simpleApplication;\n\n if (app) {\n const otherStorage = new Map<any, any>();\n const situations = new SituationTypeContainers([new SituationTypeContainer({ situationType: InjectSituationType.HOST_SET, data: hostSet }), new SituationTypeContainer({ situationType: InjectSituationType.APP_HOST, data: hostSet.$appHost }), new SituationTypeContainer({ situationType: InjectSituationType.APP_HOSTS, data: hostSet.$appHosts }), new SituationTypeContainer({ situationType: InjectSituationType.HOST, data: hostSet.$host }), new SituationTypeContainer({ situationType: InjectSituationType.HOSTS, data: hostSet.$hosts }), new SituationTypeContainer({ situationType: InjectSituationType.FIRST_HOST, data: hostSet.$firstHost }), new SituationTypeContainer({ situationType: InjectSituationType.LAST_HOST, data: hostSet.$lastHost }), new SituationTypeContainer({ situationType: InjectSituationType.FIRST_APP_HOST, data: hostSet.$firstAppHost }), new SituationTypeContainer({ situationType: InjectSituationType.LAST_APP_HOST, data: hostSet.$lastAppHost })]);\n otherStorage.set(SituationTypeContainers, situations);\n\n return app.simstanceManager.executeBindParameterSimPromise(\n {\n target: this,\n targetKey: methodName,\n inputParameters: extraArgs\n },\n otherStorage\n );\n } else {\n return (this as any)[methodName](...extraArgs);\n }\n }\n\n private _bindAttributeEvent(el: HTMLElement, attrName: string, script: string, eventName?: string) {\n if (!eventName) {\n if (!attrName.startsWith('swc-on-')) return;\n eventName = attrName.substring(7);\n }\n if (swcLifecycleAttributes.includes(attrName)) return;\n\n const elHandlers = getHandlers(this);\n let handlers = elHandlers.get(el);\n if (!handlers) {\n handlers = new Map();\n elHandlers.set(el, handlers);\n }\n\n const oldHandler = handlers.get(attrName);\n if (oldHandler) el.removeEventListener(eventName, oldHandler);\n\n const handler = (event: any) => {\n const hostSet = SwcUtils.getHostSet(el);\n const argNames = Object.keys(hostSet);\n const argValues = Object.values(hostSet);\n new Function('event', '$data', ...argNames, ...SWC_DOM_HELPER_KEYS, script).call(el, event, (event as CustomEvent).detail, ...argValues, ...SWC_DOM_HELPER_VALS());\n };\n\n el.addEventListener(eventName, handler);\n handlers.set(attrName, handler);\n }\n\n constructor(...args: any[]) {\n super(...args);\n const hostSet = SwcUtils.getHostSet(this as any);\n this._executeSwcScript('swc-on-constructor', hostSet);\n\n if (innerHtmlList.some(it => it.options.useShadow === true) && !this.shadowRoot) {\n this.attachShadow({ mode: 'open' });\n }\n }\n\n static get observedAttributes() {\n return mergedObservedAttributes;\n }\n\n async connectedCallback() {\n const hostSet = SwcUtils.getHostSet(this as any);\n\n this._executeSwcScript('swc-on-before-connected', hostSet);\n const bMethods = findAllLifecycleMetadata(this, ON_BEFORE_CONNECTED_METADATA_KEY);\n if (bMethods) {\n for (const m of bMethods) await this._invokeLifecycleMethod(m, hostSet);\n }\n\n if (typeof (this as any).initCore === 'function') (this as any).initCore();\n\n if (innerHtmlList.length > 0) {\n let sContent = '',\n lContent = '';\n for (const meta of innerHtmlList) {\n const res = await (this as any)[meta.propertyKey]();\n if (res !== undefined) {\n if (meta.options.useShadow) sContent += res;\n else lContent += res;\n }\n }\n if (this.shadowRoot) this.shadowRoot.innerHTML = sContent;\n if (lContent) this.innerHTML = lContent;\n }\n\n // --- @addEventListener binding ---\n addEventListenerList.forEach(meta => {\n const { selector, type, options } = meta;\n const { root, capture, once, passive, stopPropagation, stopImmediatePropagation, preventDefault, delegate } = options;\n\n if (delegate && selector && selector !== ':host') {\n const bindRoots: (HTMLElement | ShadowRoot)[] = [];\n const r = root || 'auto';\n if (r === 'auto') {\n bindRoots.push(this.shadowRoot || (this as any));\n } else if (r === 'light') {\n bindRoots.push(this as any);\n } else if (r === 'shadow') {\n if (this.shadowRoot) bindRoots.push(this.shadowRoot as any);\n } else if (r === 'all') {\n bindRoots.push(this as any);\n if (this.shadowRoot) bindRoots.push(this.shadowRoot as any);\n }\n\n bindRoots.forEach(bindRoot => {\n const handler = (event: Event) => {\n const target = event.target as HTMLElement;\n const matchedEl = target.closest(selector);\n if (matchedEl && (bindRoot as any).contains(matchedEl)) {\n if (stopPropagation) event.stopPropagation();\n if (stopImmediatePropagation) event.stopImmediatePropagation();\n if (preventDefault) event.preventDefault();\n\n const hostSet = SwcUtils.getHostSet(this as any);\n this._invokeLifecycleMethod(meta.propertyKey, hostSet, [event, hostSet, matchedEl]);\n }\n };\n bindRoot.addEventListener(type, handler, { capture, once, passive });\n });\n } else {\n const targetEls: (HTMLElement | Element | Document | ShadowRoot | Window)[] = [];\n if (!selector || selector === ':host') {\n targetEls.push(this as any);\n } else {\n const searchRoots: (HTMLElement | ShadowRoot)[] = [];\n const r = root || 'auto';\n if (r === 'auto') {\n searchRoots.push((this.shadowRoot || (this as any)) as any);\n } else if (r === 'light') {\n searchRoots.push(this as any);\n } else if (r === 'shadow') {\n if (this.shadowRoot) searchRoots.push(this.shadowRoot as any);\n } else if (r === 'all') {\n searchRoots.push(this as any);\n if (this.shadowRoot) searchRoots.push(this.shadowRoot as any);\n }\n\n searchRoots.forEach(sr => {\n const found = sr.querySelectorAll(selector);\n found.forEach(el => targetEls.push(el as any));\n });\n }\n\n targetEls.forEach(el => {\n const handler = (event: Event) => {\n if (stopPropagation) event.stopPropagation();\n if (stopImmediatePropagation) event.stopImmediatePropagation();\n if (preventDefault) event.preventDefault();\n\n const hostSet = SwcUtils.getHostSet(this as any);\n this._invokeLifecycleMethod(meta.propertyKey, hostSet, [event, hostSet]);\n };\n const opts = { capture, once, passive };\n el.addEventListener(type, handler, opts);\n });\n }\n });\n\n if (super.connectedCallback) await super.connectedCallback();\n const aMethods = findAllLifecycleMetadata(this, ON_AFTER_CONNECTED_METADATA_KEY);\n if (aMethods) {\n for (const m of aMethods) await this._invokeLifecycleMethod(m, hostSet);\n }\n\n this._executeSwcScript('swc-on-connected', hostSet);\n this._executeSwcScript('swc-on-after-connected', hostSet);\n }\n\n disconnectedCallback() {\n const hostSet = SwcUtils.getHostSet(this as any);\n this._executeSwcScript('swc-on-before-disconnected', hostSet);\n const bMethods = findAllLifecycleMetadata(this, ON_BEFORE_DISCONNECTED_METADATA_KEY);\n if (bMethods) bMethods.forEach(m => this._invokeLifecycleMethod(m, hostSet));\n\n if (super.disconnectedCallback) super.disconnectedCallback();\n\n const aMethods = findAllLifecycleMetadata(this, ON_AFTER_DISCONNECTED_METADATA_KEY);\n if (aMethods) aMethods.forEach(m => this._invokeLifecycleMethod(m, hostSet));\n this._executeSwcScript('swc-on-disconnected', hostSet);\n this._executeSwcScript('swc-on-after-disconnected', hostSet);\n }\n\n adoptedCallback() {\n const hostSet = SwcUtils.getHostSet(this as any);\n this._executeSwcScript('swc-on-before-adopted', hostSet);\n const bMethods = findAllLifecycleMetadata(this, ON_BEFORE_ADOPTED_METADATA_KEY);\n if (bMethods) bMethods.forEach(m => this._invokeLifecycleMethod(m, hostSet));\n\n if (super.adoptedCallback) super.adoptedCallback();\n\n const aMethods = findAllLifecycleMetadata(this, ON_AFTER_ADOPTED_METADATA_KEY);\n if (aMethods) aMethods.forEach(m => this._invokeLifecycleMethod(m, hostSet));\n this._executeSwcScript('swc-on-adopted', hostSet);\n this._executeSwcScript('swc-on-after-adopted', hostSet);\n }\n\n attributeChangedCallback(name: string, old: string | null, newVal: string | null) {\n if (super.attributeChangedCallback) super.attributeChangedCallback(name, old, newVal);\n\n if (name.startsWith('swc-on-') && !swcLifecycleAttributes.includes(name)) {\n if (newVal !== null) {\n const customEventMeta = emitCustomEventList.find(it => it.options.attributeName === name);\n const eventName = customEventMeta ? customEventMeta.options.type : name.substring(7);\n this._bindAttributeEvent(this as any, name, newVal, eventName);\n }\n }\n\n const mKeys = attrChangeMap.get(name);\n if (mKeys && Array.isArray(mKeys)) {\n const hSet = SwcUtils.getHostSet(this as any);\n mKeys.forEach(key => this._invokeLifecycleMethod(key, hSet, [newVal, old, name]));\n }\n }\n };\n\n // --- @setAttribute wrapping logic ---\n setAttrMap.forEach((methodName, attrName) => {\n const original = NewClass.prototype[methodName as any];\n if (typeof original === 'function') {\n NewClass.prototype[methodName as any] = function (...args: any[]) {\n const res = original.apply(this, args);\n if (res !== undefined) {\n if (res === null) this.removeAttribute(attrName);\n else this.setAttribute(attrName, String(res));\n }\n return res;\n };\n }\n });\n\n // --- @emitCustomEvent wrapping logic ---\n emitCustomEventList.forEach(meta => {\n const { propertyKey, options } = meta;\n const original = NewClass.prototype[propertyKey as any];\n if (typeof original === 'function') {\n NewClass.prototype[propertyKey as any] = function (...args: any[]) {\n const detail = original.apply(this, args);\n const event = new CustomEvent(options.type, {\n detail,\n bubbles: options.bubbles,\n composed: options.composed,\n cancelable: options.cancelable\n });\n this.dispatchEvent(event);\n return detail;\n };\n }\n });\n\n const originalProto = constructor.prototype;\n const newProto = NewClass.prototype;\n Object.getOwnPropertyNames(originalProto).forEach(name => {\n if (name === 'constructor') return;\n const keys = Reflect.getMetadataKeys(originalProto, name);\n keys.forEach(key => Reflect.defineMetadata(key, Reflect.getMetadata(key, originalProto, name), newProto, name));\n });\n\n ReflectUtils.defineMetadata(ELEMENT_CONFIG_KEY, config, NewClass);\n ReflectUtils.defineMetadata(ELEMENT_CONFIG_KEY, config, constructor);\n const registry = config.customElementRegistry || (win as any)?.customElements;\n if (registry && !registry.get(config.name)) {\n registry.define(config.name, NewClass as any, config.extends ? { extends: config.extends } : undefined);\n }\n return NewClass as any;\n };\n\nexport const getElementConfig = (target: any): ElementConfig | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(ELEMENT_CONFIG_KEY, constructor);\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;;;;;;;0BAA6B;AAC7B,uBAAyC;AAGzC,8BAA4C;AAC5C,wBAAoT;AACpT,6BAA+C;AAC/C,8BAAkE;AAClE,0BAA0D;AAC1D,mBAAyB;AACzB,oBAAkD;AAClD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eAAe,oBAAoB,QAAQ,QAAQ;AAChE,mCAAa,eAAe,oBAAoB,QAAQ,WAAW;AACnE,QAAM,WAAW,OAAO,yBAA0B,KAAa;AAC/D,MAAI,YAAY,CAAC,SAAS,IAAI,OAAO,IAAI,GAAG;AAC1C,aAAS,OAAO,OAAO,MAAM,UAAiB,OAAO,UAAU,EAAE,SAAS,OAAO,QAAO,IAAK,MAAS;EACxG;AACA,SAAO;AACT;AAEK,MAAM,mBAAmB,CAAC,WAA0C;AACzE,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,SAAO,iCAAa,YAAY,oBAAoB,WAAW;AACjE;",
|
|
6
6
|
"names": ["hostSet"]
|
|
7
7
|
}
|
|
@@ -25,11 +25,11 @@ module.exports = __toCommonJS(emitCustomEvent_exports);
|
|
|
25
25
|
var import_ReflectUtils = require("@dooboostore/core/reflect/ReflectUtils");
|
|
26
26
|
const EMIT_CUSTOM_EVENT_METADATA_KEY = Symbol("simple-web-component:emit-custom-event");
|
|
27
27
|
function emitCustomEvent(typeOrOptions) {
|
|
28
|
-
return (target, propertyKey
|
|
28
|
+
return (target, propertyKey) => {
|
|
29
29
|
const constructor = target.constructor;
|
|
30
30
|
const options = typeof typeOrOptions === "string" ? { type: typeOrOptions } : typeOrOptions;
|
|
31
31
|
if (!options.attributeName) {
|
|
32
|
-
options.attributeName = `on
|
|
32
|
+
options.attributeName = `swc-on-${options.type}`;
|
|
33
33
|
}
|
|
34
34
|
if (options.bubbles === void 0) options.bubbles = true;
|
|
35
35
|
if (options.composed === void 0) options.composed = true;
|
|
@@ -39,18 +39,6 @@ function emitCustomEvent(typeOrOptions) {
|
|
|
39
39
|
import_ReflectUtils.ReflectUtils.defineMetadata(EMIT_CUSTOM_EVENT_METADATA_KEY, list, constructor);
|
|
40
40
|
}
|
|
41
41
|
list.push({ propertyKey, options });
|
|
42
|
-
const originalMethod = descriptor.value;
|
|
43
|
-
descriptor.value = function(...args) {
|
|
44
|
-
const detail = originalMethod.apply(this, args);
|
|
45
|
-
const event = new CustomEvent(options.type, {
|
|
46
|
-
detail,
|
|
47
|
-
bubbles: options.bubbles,
|
|
48
|
-
composed: options.composed,
|
|
49
|
-
cancelable: options.cancelable
|
|
50
|
-
});
|
|
51
|
-
this.dispatchEvent(event);
|
|
52
|
-
return detail;
|
|
53
|
-
};
|
|
54
42
|
};
|
|
55
43
|
}
|
|
56
44
|
const getEmitCustomEventMetadataList = (target) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/decorators/emitCustomEvent.ts"],
|
|
4
|
-
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core/reflect/ReflectUtils';\n\nexport interface EmitCustomEventOptions {\n type: string;\n attributeName?: string
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAA6B;AAetB,MAAM,iCAAiC,OAAO,wCAAwC;AAEtF,SAAS,gBAAgB,eAAiE;AAC/F,SAAO,CAAC,QAAgB,
|
|
4
|
+
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core/reflect/ReflectUtils';\n\nexport interface EmitCustomEventOptions {\n type: string;\n attributeName?: string;\n bubbles?: boolean;\n composed?: boolean;\n cancelable?: boolean;\n}\n\nexport interface EmitCustomEventMetadata {\n propertyKey: string | symbol;\n options: EmitCustomEventOptions;\n}\n\nexport const EMIT_CUSTOM_EVENT_METADATA_KEY = Symbol('simple-web-component:emit-custom-event');\n\nexport function emitCustomEvent(typeOrOptions: string | EmitCustomEventOptions): MethodDecorator {\n return (target: Object, propertyKey: string | symbol) => {\n const constructor = target.constructor;\n const options: EmitCustomEventOptions = typeof typeOrOptions === 'string' ? { type: typeOrOptions } : typeOrOptions;\n\n if (!options.attributeName) {\n options.attributeName = `swc-on-${options.type}`;\n }\n if (options.bubbles === undefined) options.bubbles = true;\n if (options.composed === undefined) options.composed = true;\n\n let list = ReflectUtils.getMetadata<EmitCustomEventMetadata[]>(EMIT_CUSTOM_EVENT_METADATA_KEY, constructor);\n if (!list) {\n list = [];\n ReflectUtils.defineMetadata(EMIT_CUSTOM_EVENT_METADATA_KEY, list, constructor);\n }\n list.push({ propertyKey, options });\n };\n}\n\nexport const getEmitCustomEventMetadataList = (target: any): EmitCustomEventMetadata[] | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(EMIT_CUSTOM_EVENT_METADATA_KEY, constructor);\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAA6B;AAetB,MAAM,iCAAiC,OAAO,wCAAwC;AAEtF,SAAS,gBAAgB,eAAiE;AAC/F,SAAO,CAAC,QAAgB,gBAAiC;AACvD,UAAM,cAAc,OAAO;AAC3B,UAAM,UAAkC,OAAO,kBAAkB,WAAW,EAAE,MAAM,cAAc,IAAI;AAEtG,QAAI,CAAC,QAAQ,eAAe;AAC1B,cAAQ,gBAAgB,UAAU,QAAQ,IAAI;AAAA,IAChD;AACA,QAAI,QAAQ,YAAY,OAAW,SAAQ,UAAU;AACrD,QAAI,QAAQ,aAAa,OAAW,SAAQ,WAAW;AAEvD,QAAI,OAAO,iCAAa,YAAuC,gCAAgC,WAAW;AAC1G,QAAI,CAAC,MAAM;AACT,aAAO,CAAC;AACR,uCAAa,eAAe,gCAAgC,MAAM,WAAW;AAAA,IAC/E;AACA,SAAK,KAAK,EAAE,aAAa,QAAQ,CAAC;AAAA,EACpC;AACF;AAEO,MAAM,iCAAiC,CAAC,WAAuD;AACpG,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,SAAO,iCAAa,YAAY,gCAAgC,WAAW;AAC7E;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -24,48 +24,37 @@ __export(query_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(query_exports);
|
|
25
25
|
var import_ReflectUtils = require("@dooboostore/core/reflect/ReflectUtils");
|
|
26
26
|
const QUERY_METADATA_KEY = Symbol("simple-web-component:query");
|
|
27
|
-
function query(
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
function query(selector, options = {}) {
|
|
28
|
+
return (target, propertyKey, descriptor) => {
|
|
29
|
+
if (descriptor !== void 0) {
|
|
30
|
+
throw new Error(`@query decorator cannot be used on methods. (Method: ${String(propertyKey)})`);
|
|
31
|
+
}
|
|
30
32
|
const constructor = target.constructor;
|
|
31
33
|
let queries = import_ReflectUtils.ReflectUtils.getMetadata(QUERY_METADATA_KEY, constructor);
|
|
32
34
|
if (!queries) {
|
|
33
35
|
queries = [];
|
|
34
36
|
import_ReflectUtils.ReflectUtils.defineMetadata(QUERY_METADATA_KEY, queries, constructor);
|
|
35
37
|
}
|
|
36
|
-
queries.push({ selector, options, propertyKey
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
return
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
if (arg1 && typeof arg2 === "string") {
|
|
57
|
-
return decorator("", {}, arg1, arg2);
|
|
58
|
-
}
|
|
59
|
-
return (target, propertyKey, descriptor) => {
|
|
60
|
-
let selector = "";
|
|
61
|
-
let options = {};
|
|
62
|
-
if (typeof arg1 === "string") {
|
|
63
|
-
selector = arg1;
|
|
64
|
-
} else if (typeof arg1 === "object") {
|
|
65
|
-
options = arg1;
|
|
66
|
-
selector = options.selector || "";
|
|
67
|
-
}
|
|
68
|
-
decorator(selector, options, target, propertyKey, descriptor);
|
|
38
|
+
queries.push({ selector, options, propertyKey });
|
|
39
|
+
Object.defineProperty(target, propertyKey, {
|
|
40
|
+
get() {
|
|
41
|
+
if (!selector || selector === ":host")
|
|
42
|
+
return this;
|
|
43
|
+
const r = options.root || "auto";
|
|
44
|
+
if (r === "shadow") {
|
|
45
|
+
return this.shadowRoot ? this.shadowRoot.querySelector(selector) : null;
|
|
46
|
+
}
|
|
47
|
+
if (r === "light") {
|
|
48
|
+
return this.querySelector(selector);
|
|
49
|
+
}
|
|
50
|
+
if (r === "all") {
|
|
51
|
+
return this.shadowRoot?.querySelector(selector) || this.querySelector(selector);
|
|
52
|
+
}
|
|
53
|
+
return (this.shadowRoot || this).querySelector(selector);
|
|
54
|
+
},
|
|
55
|
+
enumerable: true,
|
|
56
|
+
configurable: true
|
|
57
|
+
});
|
|
69
58
|
};
|
|
70
59
|
}
|
|
71
60
|
const getQueryMetadata = (target) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/decorators/query.ts"],
|
|
4
|
-
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core/reflect/ReflectUtils';\n\nexport interface QueryOptions {\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;;;;;;;0BAA6B;
|
|
4
|
+
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core/reflect/ReflectUtils';\n\nexport interface QueryOptions {\n root?: 'light' | 'shadow' | 'all' | 'auto';\n}\n\nexport interface QueryMetadata {\n selector: string;\n options: QueryOptions;\n propertyKey: string | symbol;\n}\n\nexport const QUERY_METADATA_KEY = Symbol('simple-web-component:query');\n\n/**\n * @query decorator to inject a single element into a class property.\n * Usage: @query('.my-class') myEl!: HTMLElement;\n * Usage: @query('#my-id', { root: 'shadow' }) myEl!: HTMLElement;\n */\nexport function query(selector: string, options: QueryOptions = {}): PropertyDecorator {\n return (target: 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 = target.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({ selector, options, propertyKey });\n\n Object.defineProperty(target, propertyKey, {\n get(this: HTMLElement) {\n if (!selector || selector === ':host') return this;\n const r = options.root || 'auto';\n\n if (r === 'shadow') {\n return this.shadowRoot ? this.shadowRoot.querySelector(selector) : null;\n }\n if (r === 'light') {\n return this.querySelector(selector);\n }\n if (r === 'all') {\n return this.shadowRoot?.querySelector(selector) || this.querySelector(selector);\n }\n // auto\n return (this.shadowRoot || this).querySelector(selector);\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"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;;;;;;;0BAA6B;AAYtB,MAAM,qBAAqB,OAAO,4BAA4B;AAO/D,SAAU,MAAM,UAAkB,UAAwB,CAAA,GAAE;AAChE,SAAO,CAAC,QAAgB,aAA8B,eAA4B;AAChF,QAAI,eAAe,QAAW;AAC5B,YAAM,IAAI,MAAM,wDAAwD,OAAO,WAAW,CAAC,GAAG;IAChG;AAEA,UAAM,cAAc,OAAO;AAC3B,QAAI,UAAU,iCAAa,YAA6B,oBAAoB,WAAW;AACvF,QAAI,CAAC,SAAS;AACZ,gBAAU,CAAA;AACV,uCAAa,eAAe,oBAAoB,SAAS,WAAW;IACtE;AACA,YAAQ,KAAK,EAAE,UAAU,SAAS,YAAW,CAAE;AAE/C,WAAO,eAAe,QAAQ,aAAa;MACzC,MAAG;AACD,YAAI,CAAC,YAAY,aAAa;AAAS,iBAAO;AAC9C,cAAM,IAAI,QAAQ,QAAQ;AAE1B,YAAI,MAAM,UAAU;AAClB,iBAAO,KAAK,aAAa,KAAK,WAAW,cAAc,QAAQ,IAAI;QACrE;AACA,YAAI,MAAM,SAAS;AACjB,iBAAO,KAAK,cAAc,QAAQ;QACpC;AACA,YAAI,MAAM,OAAO;AACf,iBAAO,KAAK,YAAY,cAAc,QAAQ,KAAK,KAAK,cAAc,QAAQ;QAChF;AAEA,gBAAQ,KAAK,cAAc,MAAM,cAAc,QAAQ;MACzD;MACA,YAAY;MACZ,cAAc;KACf;EACH;AACF;AAEO,MAAM,mBAAmB,CAAC,WAA4C;AAC3E,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,SAAO,iCAAa,YAAY,oBAAoB,WAAW;AACjE;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -24,48 +24,40 @@ __export(queryAll_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(queryAll_exports);
|
|
25
25
|
var import_ReflectUtils = require("@dooboostore/core/reflect/ReflectUtils");
|
|
26
26
|
const QUERY_ALL_METADATA_KEY = Symbol("simple-web-component:query-all");
|
|
27
|
-
function queryAll(
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
function queryAll(selector, options = {}) {
|
|
28
|
+
return (target, propertyKey, descriptor) => {
|
|
29
|
+
if (descriptor !== void 0) {
|
|
30
|
+
throw new Error(`@queryAll decorator cannot be used on methods. (Method: ${String(propertyKey)})`);
|
|
31
|
+
}
|
|
30
32
|
const constructor = target.constructor;
|
|
31
33
|
let queries = import_ReflectUtils.ReflectUtils.getMetadata(QUERY_ALL_METADATA_KEY, constructor);
|
|
32
34
|
if (!queries) {
|
|
33
35
|
queries = [];
|
|
34
36
|
import_ReflectUtils.ReflectUtils.defineMetadata(QUERY_ALL_METADATA_KEY, queries, constructor);
|
|
35
37
|
}
|
|
36
|
-
queries.push({ selector, options, propertyKey
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
return (target, propertyKey, descriptor) => {
|
|
60
|
-
let selector = "";
|
|
61
|
-
let options = {};
|
|
62
|
-
if (typeof arg1 === "string") {
|
|
63
|
-
selector = arg1;
|
|
64
|
-
} else if (typeof arg1 === "object") {
|
|
65
|
-
options = arg1;
|
|
66
|
-
selector = options.selector || "";
|
|
67
|
-
}
|
|
68
|
-
decorator(selector, options, target, propertyKey, descriptor);
|
|
38
|
+
queries.push({ selector, options, propertyKey });
|
|
39
|
+
Object.defineProperty(target, propertyKey, {
|
|
40
|
+
get() {
|
|
41
|
+
if (!selector || selector === ":host")
|
|
42
|
+
return [this];
|
|
43
|
+
const r = options.root || "auto";
|
|
44
|
+
if (r === "shadow") {
|
|
45
|
+
return this.shadowRoot ? this.shadowRoot.querySelectorAll(selector) : [];
|
|
46
|
+
}
|
|
47
|
+
if (r === "light") {
|
|
48
|
+
return this.querySelectorAll(selector);
|
|
49
|
+
}
|
|
50
|
+
if (r === "all") {
|
|
51
|
+
const sNodes = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];
|
|
52
|
+
const lNodes = Array.from(this.querySelectorAll(selector));
|
|
53
|
+
return [...sNodes, ...lNodes];
|
|
54
|
+
}
|
|
55
|
+
const root = this.shadowRoot || this;
|
|
56
|
+
return root.querySelectorAll(selector);
|
|
57
|
+
},
|
|
58
|
+
enumerable: true,
|
|
59
|
+
configurable: true
|
|
60
|
+
});
|
|
69
61
|
};
|
|
70
62
|
}
|
|
71
63
|
const getQueryAllMetadata = (target) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/decorators/queryAll.ts"],
|
|
4
|
-
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core/reflect/ReflectUtils';\n\nexport interface QueryAllOptions {\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;;;;;;;0BAA6B;
|
|
4
|
+
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core/reflect/ReflectUtils';\n\nexport interface QueryAllOptions {\n root?: 'light' | 'shadow' | 'all' | 'auto';\n}\n\nexport interface QueryAllMetadata {\n selector: string;\n options: QueryAllOptions;\n propertyKey: string | symbol;\n}\n\nexport const QUERY_ALL_METADATA_KEY = Symbol('simple-web-component:query-all');\n\n/**\n * @queryAll decorator to inject a list of elements into a class property.\n * Usage: @queryAll('.items') list!: NodeListOf<HTMLElement>;\n * Usage: @queryAll('li', { root: 'shadow' }) list!: HTMLElement[];\n */\nexport function queryAll(selector: string, options: QueryAllOptions = {}): PropertyDecorator {\n return (target: 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 = target.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({ selector, options, propertyKey });\n\n Object.defineProperty(target, propertyKey, {\n get(this: HTMLElement) {\n if (!selector || selector === ':host') return [this];\n const r = options.root || 'auto';\n\n if (r === 'shadow') {\n return this.shadowRoot ? this.shadowRoot.querySelectorAll(selector) : [];\n }\n if (r === 'light') {\n return this.querySelectorAll(selector);\n }\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 // auto\n const root = this.shadowRoot || this;\n return root.querySelectorAll(selector);\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.const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S,OAAO;AACjE,SAAO,iCAAa,YAAY,wBAAwB,WAAW;AACrE;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/cjs/types.js
CHANGED
|
@@ -25,6 +25,7 @@ var InjectSituationType = /* @__PURE__ */ ((InjectSituationType2) => {
|
|
|
25
25
|
InjectSituationType2["APP_HOST"] = "SIMPLE_WEB_COMPONENT://APPHOST";
|
|
26
26
|
InjectSituationType2["APP_HOSTS"] = "SIMPLE_WEB_COMPONENT://APPHOSTS";
|
|
27
27
|
InjectSituationType2["HOST"] = "SIMPLE_WEB_COMPONENT://HOST";
|
|
28
|
+
InjectSituationType2["PARENT_HOST"] = "SIMPLE_WEB_COMPONENT://PARENTHOST";
|
|
28
29
|
InjectSituationType2["HOSTS"] = "SIMPLE_WEB_COMPONENT://HOSTS";
|
|
29
30
|
InjectSituationType2["FIRST_HOST"] = "SIMPLE_WEB_COMPONENT://FIRSTHOST";
|
|
30
31
|
InjectSituationType2["LAST_HOST"] = "SIMPLE_WEB_COMPONENT://LASTHOST";
|
package/dist/cjs/types.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/types.ts"],
|
|
4
|
-
"sourcesContent": ["import { SimpleApplication } from '@dooboostore/simple-boot/SimpleApplication';\nimport { Router } from '@dooboostore/core-web/routers/Router';\n\nexport enum InjectSituationType {\n HOST_SET = 'SIMPLE_WEB_COMPONENT://HOSTSET',\n APP_HOST = 'SIMPLE_WEB_COMPONENT://APPHOST',\n APP_HOSTS = 'SIMPLE_WEB_COMPONENT://APPHOSTS',\n HOST = 'SIMPLE_WEB_COMPONENT://HOST',\n HOSTS = 'SIMPLE_WEB_COMPONENT://HOSTS',\n FIRST_HOST = 'SIMPLE_WEB_COMPONENT://FIRSTHOST',\n LAST_HOST = 'SIMPLE_WEB_COMPONENT://LASTHOST',\n FIRST_APP_HOST = 'SIMPLE_WEB_COMPONENT://FIRSTAPPHOST',\n LAST_APP_HOST = 'SIMPLE_WEB_COMPONENT://LASTAPPHOST'\n}\n\nexport type HostSet = {\n $host: HTMLElement | null
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,IAAK,sBAAL,kBAAKA,yBAAL;AACL,EAAAA,qBAAA,cAAW;AACX,EAAAA,qBAAA,cAAW;AACX,EAAAA,qBAAA,eAAY;AACZ,EAAAA,qBAAA,UAAO;AACP,EAAAA,qBAAA,WAAQ;AACR,EAAAA,qBAAA,gBAAa;AACb,EAAAA,qBAAA,eAAY;AACZ,EAAAA,qBAAA,oBAAiB;AACjB,EAAAA,qBAAA,mBAAgB;
|
|
4
|
+
"sourcesContent": ["import { SimpleApplication } from '@dooboostore/simple-boot/SimpleApplication';\nimport { Router } from '@dooboostore/core-web/routers/Router';\n\nexport enum InjectSituationType {\n HOST_SET = 'SIMPLE_WEB_COMPONENT://HOSTSET',\n APP_HOST = 'SIMPLE_WEB_COMPONENT://APPHOST',\n APP_HOSTS = 'SIMPLE_WEB_COMPONENT://APPHOSTS',\n HOST = 'SIMPLE_WEB_COMPONENT://HOST',\n PARENT_HOST = 'SIMPLE_WEB_COMPONENT://PARENTHOST',\n HOSTS = 'SIMPLE_WEB_COMPONENT://HOSTS',\n FIRST_HOST = 'SIMPLE_WEB_COMPONENT://FIRSTHOST',\n LAST_HOST = 'SIMPLE_WEB_COMPONENT://LASTHOST',\n FIRST_APP_HOST = 'SIMPLE_WEB_COMPONENT://FIRSTAPPHOST',\n LAST_APP_HOST = 'SIMPLE_WEB_COMPONENT://LASTAPPHOST'\n}\n\nexport type HostSet = {\n $host: HTMLElement; // Current component itself\n $parentHost: HTMLElement | null; // Nearest parent SWC component\n $hosts: HTMLElement[]; // [self, parent, ..., top]\n $firstHost: HTMLElement | null; // Top-most SWC ancestor\n $lastHost: HTMLElement | null; // Same as $parentHost (for backward compatibility or clarity)\n $appHost: SwcAppInterface | null;\n $appHosts: SwcAppInterface[];\n $firstAppHost: SwcAppInterface | null;\n $lastAppHost: SwcAppInterface | null;\n};\n\nexport interface SwcAppInterface extends HTMLElement {\n simpleApplication?: SimpleApplication;\n router?: Router;\n routing(path: string): Promise<void>;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,IAAK,sBAAL,kBAAKA,yBAAL;AACL,EAAAA,qBAAA,cAAW;AACX,EAAAA,qBAAA,cAAW;AACX,EAAAA,qBAAA,eAAY;AACZ,EAAAA,qBAAA,UAAO;AACP,EAAAA,qBAAA,iBAAc;AACd,EAAAA,qBAAA,WAAQ;AACR,EAAAA,qBAAA,gBAAa;AACb,EAAAA,qBAAA,eAAY;AACZ,EAAAA,qBAAA,oBAAiB;AACjB,EAAAA,qBAAA,mBAAgB;AAVN,SAAAA;AAAA,GAAA;",
|
|
6
6
|
"names": ["InjectSituationType"]
|
|
7
7
|
}
|