@dooboostore/simple-web-component 1.0.41 → 1.0.43
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 +423 -68
- package/dist/cjs/decorators/addEventListener.js +10 -0
- package/dist/cjs/decorators/addEventListener.js.map +2 -2
- package/dist/cjs/decorators/applyAttribute.js +11 -2
- package/dist/cjs/decorators/applyAttribute.js.map +2 -2
- package/dist/cjs/decorators/applyClass.js +9 -2
- package/dist/cjs/decorators/applyClass.js.map +2 -2
- package/dist/cjs/decorators/applyNode.js +11 -2
- package/dist/cjs/decorators/applyNode.js.map +2 -2
- package/dist/cjs/decorators/applyProperty.js +10 -2
- package/dist/cjs/decorators/applyProperty.js.map +2 -2
- package/dist/cjs/decorators/applySlot.js +11 -2
- package/dist/cjs/decorators/applySlot.js.map +2 -2
- package/dist/cjs/decorators/applyStyle.js +9 -2
- package/dist/cjs/decorators/applyStyle.js.map +2 -2
- package/dist/cjs/decorators/elementDefine.js +9 -23
- package/dist/cjs/decorators/elementDefine.js.map +2 -2
- package/dist/cjs/decorators/emitCustomEvent.js +2 -0
- package/dist/cjs/decorators/emitCustomEvent.js.map +2 -2
- package/dist/cjs/decorators/lifecycles.js +78 -21
- package/dist/cjs/decorators/lifecycles.js.map +2 -2
- package/dist/cjs/decorators/publishSwcAppMessage.js +37 -23
- package/dist/cjs/decorators/publishSwcAppMessage.js.map +2 -2
- package/dist/cjs/decorators/subscribeSwcAppRouteChangeWhileConnected.js +3 -1
- package/dist/cjs/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +2 -2
- package/dist/cjs/elements/SwcAppMixin.js +4 -9
- package/dist/cjs/elements/SwcAppMixin.js.map +2 -2
- package/dist/esm/decorators/addEventListener.js +10 -0
- package/dist/esm/decorators/addEventListener.js.map +2 -2
- package/dist/esm/decorators/applyAttribute.js +11 -2
- package/dist/esm/decorators/applyAttribute.js.map +2 -2
- package/dist/esm/decorators/applyClass.js +9 -2
- package/dist/esm/decorators/applyClass.js.map +2 -2
- package/dist/esm/decorators/applyNode.js +11 -2
- package/dist/esm/decorators/applyNode.js.map +2 -2
- package/dist/esm/decorators/applyProperty.js +10 -2
- package/dist/esm/decorators/applyProperty.js.map +2 -2
- package/dist/esm/decorators/applySlot.js +11 -2
- package/dist/esm/decorators/applySlot.js.map +2 -2
- package/dist/esm/decorators/applyStyle.js +9 -2
- package/dist/esm/decorators/applyStyle.js.map +2 -2
- package/dist/esm/decorators/elementDefine.js +9 -23
- package/dist/esm/decorators/elementDefine.js.map +2 -2
- package/dist/esm/decorators/emitCustomEvent.js +2 -0
- package/dist/esm/decorators/emitCustomEvent.js.map +2 -2
- package/dist/esm/decorators/lifecycles.js +78 -21
- package/dist/esm/decorators/lifecycles.js.map +2 -2
- package/dist/esm/decorators/publishSwcAppMessage.js +37 -23
- package/dist/esm/decorators/publishSwcAppMessage.js.map +2 -2
- package/dist/esm/decorators/subscribeSwcAppRouteChangeWhileConnected.js +3 -1
- package/dist/esm/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +2 -2
- package/dist/esm/elements/SwcAppMixin.js +4 -9
- package/dist/esm/elements/SwcAppMixin.js.map +2 -2
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +216 -126
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +3 -3
- package/dist/types/decorators/addEventListener.d.ts +5 -0
- package/dist/types/decorators/addEventListener.d.ts.map +1 -1
- package/dist/types/decorators/applyAttribute.d.ts +26 -0
- package/dist/types/decorators/applyAttribute.d.ts.map +1 -1
- package/dist/types/decorators/applyClass.d.ts +6 -0
- package/dist/types/decorators/applyClass.d.ts.map +1 -1
- package/dist/types/decorators/applyNode.d.ts +6 -0
- package/dist/types/decorators/applyNode.d.ts.map +1 -1
- package/dist/types/decorators/applyProperty.d.ts +26 -0
- package/dist/types/decorators/applyProperty.d.ts.map +1 -1
- package/dist/types/decorators/applySlot.d.ts +6 -0
- package/dist/types/decorators/applySlot.d.ts.map +1 -1
- package/dist/types/decorators/applyStyle.d.ts +6 -0
- package/dist/types/decorators/applyStyle.d.ts.map +1 -1
- package/dist/types/decorators/elementDefine.d.ts.map +1 -1
- package/dist/types/decorators/emitCustomEvent.d.ts +17 -0
- package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
- package/dist/types/decorators/lifecycles.d.ts +25 -11
- package/dist/types/decorators/lifecycles.d.ts.map +1 -1
- package/dist/types/decorators/publishSwcAppMessage.d.ts +19 -0
- package/dist/types/decorators/publishSwcAppMessage.d.ts.map +1 -1
- package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts +1 -1
- package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts.map +1 -1
- package/dist/types/elements/SwcAppMixin.d.ts.map +1 -1
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +216 -126
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +3 -3
- package/package.json +1 -3
- package/src/decorators/addEventListener.ts +7 -0
- package/src/decorators/applyAttribute.ts +58 -2
- package/src/decorators/applyClass.ts +24 -2
- package/src/decorators/applyNode.ts +26 -2
- package/src/decorators/applyProperty.ts +57 -2
- package/src/decorators/applySlot.ts +24 -10
- package/src/decorators/applyStyle.ts +24 -2
- package/src/decorators/elementDefine.ts +9 -23
- package/src/decorators/emitCustomEvent.ts +19 -0
- package/src/decorators/lifecycles.ts +120 -26
- package/src/decorators/publishSwcAppMessage.ts +71 -27
- package/src/decorators/subscribeSwcAppRouteChangeWhileConnected.ts +6 -2
- package/src/elements/SwcAppMixin.ts +5 -11
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/decorators/applySlot.ts"],
|
|
4
|
-
"sourcesContent": ["import {OptionalType, ReflectUtils} from '@dooboostore/core';\nimport {ensureInit, getElementConfig} from './elementDefine';\nimport {SwcUtils} from \"../utils/Utils\";\nimport {NodeSlot} from \"@dooboostore/core-web\";\nimport {HelperHostSet} from \"../types\";\n/*\n<!-- beforebegin -->\n<p> <-- it's me\n <!-- afterbegin -->\n foo\n <!-- beforeend -->\n</p>\n<!-- afterend -->\n */\nexport type ApplySlotPosition = 'prepend' | 'prependHtml' | 'prependText' | 'append' | 'appendHtml' | 'appendText' | 'replaceChildren' | 'replaceChildrenHtml' | 'replaceChildrenText' | 'clear';\n\nexport interface ApplySlotOptions {\n position: ApplySlotPosition;\n fallback?: (helper: HelperHostSet) => string | Node;\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAyC;AACzC,2BAA2C;AAC3C,mBAAuB;AACvB,sBAAuB;
|
|
4
|
+
"sourcesContent": ["import {OptionalType, ReflectUtils} from '@dooboostore/core';\nimport {ensureInit, getElementConfig} from './elementDefine';\nimport {SwcUtils} from \"../utils/Utils\";\nimport {NodeSlot} from \"@dooboostore/core-web\";\nimport {HelperHostSet} from \"../types\";\n/*\n<!-- beforebegin -->\n<p> <-- it's me\n <!-- afterbegin -->\n foo\n <!-- beforeend -->\n</p>\n<!-- afterend -->\n */\nexport type ApplySlotPosition = 'prepend' | 'prependHtml' | 'prependText' | 'append' | 'appendHtml' | 'appendText' | 'replaceChildren' | 'replaceChildrenHtml' | 'replaceChildrenText' | 'clear';\n\nexport interface ApplySlotOptions {\n position: ApplySlotPosition;\n fallback?: (helper: HelperHostSet) => string | Node;\n /**\n * Custom key to extract value from return object.\n * If not provided, uses APPLY_SLOT_METADATA_KEY by default.\n * Useful when multiple @applySlot decorators are on the same method.\n */\n valueKey?: symbol | string;\n}\n\nexport interface ApplySlotMetadata {\n propertyKey: string | symbol;\n targetId: string;\n // type: 'method' | 'property';\n options: ApplySlotOptions;\n}\n\nexport const APPLY_SLOT_METADATA_KEY = Symbol.for('simple-web-component:apply-slot');\n\n// const normalizeNodes = (res: any, doc: Document): Node[] => {\n// const items = Array.isArray(res) ? res : [res];\n// return items.map(it => {\n// if (it instanceof Node) return it;\n// return doc.createTextNode(it !== undefined && it !== null ? String(it) : '');\n// });\n// };\n\n// const applyToDom = (targetEl: any, res: any, pos: ApplyNodePosition, win: Window) => {\n// if (!targetEl) return;\n//\n// const doc = win.document;\n//\n// if (pos === 'innerHtml') {\n// targetEl.innerHTML = res !== undefined && res !== null ? String(res) : '';\n// return;\n// }\n//\n// if (pos === 'innerText') {\n// if (targetEl.innerText !== undefined) {\n// targetEl.innerText = res !== undefined && res !== null ? String(res) : '';\n// }\n// return;\n// }\n//\n// const isShadowRoot = targetEl instanceof win.ShadowRoot;\n// const nodes = normalizeNodes(res, doc);\n// if (pos === 'replace') {\n// if (!isShadowRoot) targetEl.replaceWith(...nodes);\n// } else if (pos === 'replaceChildren') {\n// targetEl.replaceChildren(...nodes);\n// } else {\n// if (pos === 'beforeEnd') targetEl.append(...nodes);\n// else if (pos === 'afterBegin') targetEl.prepend(...nodes);\n// else if (pos === 'beforeBegin' && !isShadowRoot) targetEl.before(...nodes);\n// else if (pos === 'afterEnd' && !isShadowRoot) targetEl.after(...nodes);\n// }\n// };\n\nconst applyToDom = (swcId: string, id: string, pos: ApplySlotPosition, nodes: Node[]) => {\n const nodeSlot = new NodeSlot(this, swcId);\n if (pos === 'replaceChildrenText' || pos === 'replaceChildren' || pos === 'replaceChildrenHtml') {\n nodeSlot.replaceChildren(id, ...nodes);\n } else if (pos === 'appendHtml' || pos === 'append' || pos === 'appendText') {\n nodeSlot.append(id, ...nodes);\n } else if (pos === 'prependHtml' || pos === 'prepend' || pos === 'prependText') {\n nodeSlot.prepend(id, ...nodes);\n } else if (pos === 'clear') {\n nodeSlot.clear(id);\n }\n}\n\n/**\n * @applyNode decorator to surgically add/replace nodes to a target element.\n */\nexport function applySlot(targetId: string, opt: OptionalType<ApplySlotOptions, 'position'>): MethodDecorator {\n return (targetObj: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<any>) => {\n\n\n const options: ApplySlotOptions = {position: 'replaceChildren', ...opt};\n\n\n const constructor = targetObj.constructor;\n let metaList = ReflectUtils.getOwnMetadata(APPLY_SLOT_METADATA_KEY, constructor) as ApplySlotMetadata[];\n if (!metaList) {\n metaList = []\n ReflectUtils.defineMetadata(APPLY_SLOT_METADATA_KEY, metaList, constructor);\n }\n metaList.push({propertyKey, targetId, options});\n\n\n const original = descriptor.value;\n descriptor.value = function (...args: any[]) {\n ensureInit(this);\n\n const conf = getElementConfig(this);\n const currentWin = conf.window;\n const swcId = this._swcId;\n const currentDoc = currentWin.document;\n const hostSet = SwcUtils.getHelperAndHostSet(currentWin, this);\n const pos = options.position;\n\n const resToNodes = (res: string | Node) => {\n const nodes: Node[] = [];\n\n if (typeof res === 'string' && (pos === 'replaceChildrenHtml' || pos === 'appendHtml' || pos === 'prependHtml')) {\n const t = currentWin.document.createElement('template');\n t.innerHTML = res;\n nodes.push(...Array.from(t.content.childNodes));\n } else if (typeof res === 'string' && (pos === 'replaceChildrenText' || pos === 'prependText' || pos === 'appendText')) {\n nodes.push(currentWin.document.createTextNode(res));\n } else if (typeof res === 'object') {\n nodes.push(res);\n }\n SwcUtils.projectProcessHtml(swcId, nodes, currentDoc);\n return nodes;\n }\n\n const fallbackNodes: Node[] = [];\n if (options.fallback) {\n const res: string | Node = options.fallback.call(this, hostSet);\n const nodes: Node[] = resToNodes(res);\n fallbackNodes.push(...nodes);\n applyToDom(swcId, targetId, options.position, nodes);\n }\n\n /**\n * Extract value for this decorator from method return value\n * \n * If return value is an object with this decorator's key,\n * use that value. Otherwise use the entire return value.\n * \n * Uses valueKey from options if provided, otherwise uses APPLY_SLOT_METADATA_KEY.\n */\n const extractValue = (v: any) => {\n const keyToUse = options.valueKey ?? APPLY_SLOT_METADATA_KEY;\n if (v && typeof v === 'object' && keyToUse in v) {\n return v[keyToUse];\n }\n return v;\n };\n\n let res = original.apply(this, args);\n if (res instanceof Promise) {\n return res.then(asyncRes => {\n const extracted = extractValue(asyncRes);\n const nodes = resToNodes(extracted)\n fallbackNodes.forEach((it: any) => it.remove());\n applyToDom(swcId, targetId, options.position, nodes);\n })\n } else {\n const extracted = extractValue(res);\n const nodes: Node[] = resToNodes(extracted);\n applyToDom(swcId, targetId, options.position, nodes);\n }\n };\n };\n}\n\nexport function clearSlot(targetId: string): MethodDecorator {\n return applySlot(targetId, {position: 'clear'});\n}\n\nexport function prependHtmlSlot(targetId: string): MethodDecorator {\n return applySlot(targetId, {position: 'prependHtml'});\n}\n\nexport function prependSlot(targetId: string): MethodDecorator {\n return applySlot(targetId, {position: 'prepend'});\n}\n\nexport function prependTextSlot(targetId: string): MethodDecorator {\n return applySlot(targetId, {position: 'prependText'});\n}\n\nexport function appendHtmlSlot(targetId: string): MethodDecorator {\n return applySlot(targetId, {position: 'appendHtml'});\n}\n\nexport function appendTextSlot(targetId: string): MethodDecorator {\n return applySlot(targetId, {position: 'appendText'});\n}\n\nexport function appendSlot(targetId: string): MethodDecorator {\n return applySlot(targetId, {position: 'append'});\n}\n\nexport function replaceChildrenHtmlSlot(targetId: string): MethodDecorator {\n return applySlot(targetId, {position: 'replaceChildrenHtml'});\n}\n\nexport function replaceChildrenSlot(targetId: string): MethodDecorator {\n return applySlot(targetId, {position: 'replaceChildren'});\n}\n\nexport function replaceChildrenTextSlot(targetId: string): MethodDecorator {\n return applySlot(targetId, {position: 'replaceChildrenText'});\n}\n\n// export const findAllApplySlotMetadata = (target: any): Map<string | symbol, ApplySlotMetadata> => {\nexport const findAllApplySlotMetadata = (target: any): ApplySlotMetadata[] => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(APPLY_SLOT_METADATA_KEY, constructor);\n};"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAyC;AACz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U,QAAQ,UAAU,KAAK;AAAA,MACrD;AAAA,IACF;AAAA,EACF;AACF;AAEO,SAAS,UAAU,UAAmC;AAC3D,SAAO,UAAU,UAAU,EAAC,UAAU,QAAO,CAAC;AAChD;AAEO,SAAS,gBAAgB,UAAmC;AACjE,SAAO,UAAU,UAAU,EAAC,UAAU,cAAa,CAAC;AACtD;AAEO,SAAS,YAAY,UAAmC;AAC7D,SAAO,UAAU,UAAU,EAAC,UAAU,UAAS,CAAC;AAClD;AAEO,SAAS,gBAAgB,UAAmC;AACjE,SAAO,UAAU,UAAU,EAAC,UAAU,cAAa,CAAC;AACtD;AAEO,SAAS,eAAe,UAAmC;AAChE,SAAO,UAAU,UAAU,EAAC,UAAU,aAAY,CAAC;AACrD;AAEO,SAAS,eAAe,UAAmC;AAChE,SAAO,UAAU,UAAU,EAAC,UAAU,aAAY,CAAC;AACrD;AAEO,SAAS,WAAW,UAAmC;AAC5D,SAAO,UAAU,UAAU,EAAC,UAAU,SAAQ,CAAC;AACjD;AAEO,SAAS,wBAAwB,UAAmC;AACzE,SAAO,UAAU,UAAU,EAAC,UAAU,sBAAqB,CAAC;AAC9D;AAEO,SAAS,oBAAoB,UAAmC;AACrE,SAAO,UAAU,UAAU,EAAC,UAAU,kBAAiB,CAAC;AAC1D;AAEO,SAAS,wBAAwB,UAAmC;AACzE,SAAO,UAAU,UAAU,EAAC,UAAU,sBAAqB,CAAC;AAC9D;AAGO,MAAM,2BAA2B,CAAC,WAAqC;AAC5E,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,SAAO,yBAAa,YAAY,yBAAyB,WAAW;AACtE;",
|
|
6
6
|
"names": ["res"]
|
|
7
7
|
}
|
|
@@ -47,6 +47,13 @@ function createStyleDecorator(action) {
|
|
|
47
47
|
descriptor.value = function(...args) {
|
|
48
48
|
(0, import_elementDefine.ensureInit)(this);
|
|
49
49
|
const res = original.apply(this, args);
|
|
50
|
+
const extractValue = (v) => {
|
|
51
|
+
const keyToUse = options.valueKey ?? STYLE_METADATA_KEY;
|
|
52
|
+
if (v && typeof v === "object" && keyToUse in v) {
|
|
53
|
+
return v[keyToUse];
|
|
54
|
+
}
|
|
55
|
+
return v;
|
|
56
|
+
};
|
|
50
57
|
const handleResult = (resolvedValue) => {
|
|
51
58
|
if (resolvedValue !== void 0) {
|
|
52
59
|
const win = this.ownerDocument?.defaultView || window;
|
|
@@ -112,9 +119,9 @@ function createStyleDecorator(action) {
|
|
|
112
119
|
return resolvedValue;
|
|
113
120
|
};
|
|
114
121
|
if (res instanceof Promise) {
|
|
115
|
-
return res.then(handleResult);
|
|
122
|
+
return res.then((v) => handleResult(extractValue(v)));
|
|
116
123
|
} else {
|
|
117
|
-
return handleResult(res);
|
|
124
|
+
return handleResult(extractValue(res));
|
|
118
125
|
}
|
|
119
126
|
};
|
|
120
127
|
return descriptor;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/decorators/applyStyle.ts"],
|
|
4
|
-
"sourcesContent": ["import {ReflectUtils} from '@dooboostore/core';\nimport {ensureInit} from './elementDefine';\nimport {SwcUtils} from '../utils/Utils';\nimport { SpecialSelector, SwcQueryOptions, HelperHostSet } from '../types';\n\nexport type StyleAction = 'set' | 'update' | 'remove';\n\nexport interface StyleApplyOptions extends SwcQueryOptions {\n filter?: (target: HTMLElement, value: any, meta: {currentThis: any, helper: HelperHostSet}) => boolean;\n}\n\nexport interface StyleApplyMetadata {\n propertyKey: string | symbol;\n selector: string;\n action: StyleAction;\n options: StyleApplyOptions;\n}\n\nexport const STYLE_METADATA_KEY = Symbol.for('simple-web-component:style');\n\nfunction createStyleDecorator(action: StyleAction) {\n return (selector: string, options: StyleApplyOptions = {}): MethodDecorator => {\n return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = target.constructor;\n let metaList = ReflectUtils.getOwnMetadata(STYLE_METADATA_KEY, constructor) as Map<string | symbol, StyleApplyMetadata>;\n if (!metaList) {\n metaList = new Map<string | symbol, StyleApplyMetadata>();\n ReflectUtils.defineMetadata(STYLE_METADATA_KEY, metaList, constructor);\n }\n metaList.set(propertyKey, { propertyKey, selector, action, options });\n\n const original = descriptor.value;\n descriptor.value = function (...args: any[]) {\n ensureInit(this);\n const res = (original as any).apply(this, args);\n\n const handleResult = (resolvedValue: any) => {\n if (resolvedValue !== undefined) {\n const win = (this as any).ownerDocument?.defaultView || window;\n const host = this as unknown as HTMLElement;\n const hostSet = { ...SwcUtils.getHelperAndHostSet(win, host), $this: this };\n const r = options.root || 'auto';\n const targetEls: HTMLElement[] = [];\n\n const applyRoot = (t: any) => {\n if (!t || !(t instanceof win.HTMLElement)) return;\n targetEls.push(t);\n };\n\n if (selector === '$this' || !selector) applyRoot(host);\n else if (selector === '$host') applyRoot(hostSet.$host);\n else if (selector === '$parentHost') applyRoot(hostSet.$parentHost);\n else if (selector === '$appHost') applyRoot(hostSet.$appHost);\n else if (selector === '$firstHost') applyRoot(hostSet.$firstHost);\n else if (selector === '$lastHost') applyRoot(hostSet.$lastHost);\n else if (selector === '$firstAppHost') applyRoot(hostSet.$firstAppHost);\n else if (selector === '$lastAppHost') applyRoot(hostSet.$lastAppHost);\n else if (selector === '$hosts') hostSet.$hosts.forEach(applyRoot);\n else if (selector === '$appHosts') hostSet.$appHosts.forEach(applyRoot);\n else {\n const targetRoot = r === 'auto' ? (host.shadowRoot || host) : (r === 'shadow' ? host.shadowRoot : host);\n if (targetRoot) {\n const found = targetRoot.querySelectorAll(selector);\n if (found) targetEls.push(...(Array.from(found) as HTMLElement[]));\n }\n }\n\n targetEls.forEach(targetEl => {\n if (options.filter && !options.filter(targetEl, resolvedValue, {currentThis: this, helper: hostSet})) {\n return;\n }\n const resolvedRes = typeof resolvedValue === 'function' ? (resolvedValue as any)(targetEl, hostSet) : resolvedValue;\n\n if (action === 'set' || action === 'update') {\n if (action === 'set') targetEl.style.cssText = '';\n \n if (typeof resolvedRes === 'object' && resolvedRes !== null && !Array.isArray(resolvedRes)) {\n Object.entries(resolvedRes as any).forEach(([prop, val]) => {\n const finalVal = typeof val === 'function' ? val(targetEl, hostSet) : val;\n if (finalVal === null || finalVal === undefined) {\n targetEl.style.removeProperty(prop);\n } else {\n targetEl.style[prop as any] = String(finalVal);\n }\n });\n } else if (typeof resolvedRes === 'string') {\n targetEl.style.cssText = resolvedRes;\n }\n } else if (action === 'remove') {\n if (typeof resolvedRes === 'object' && resolvedRes !== null && !Array.isArray(resolvedRes)) {\n Object.entries(resolvedRes as any).forEach(([prop, val]) => {\n const shouldRemove = typeof val === 'function' ? val(targetEl, hostSet) : !!val;\n if (shouldRemove) {\n targetEl.style.removeProperty(prop);\n }\n });\n } else {\n const props = Array.isArray(resolvedRes) ? resolvedRes : [resolvedRes];\n props.forEach(p => targetEl.style.removeProperty(String(p)));\n }\n }\n });\n }\n return resolvedValue;\n };\n\n if (res instanceof Promise) {\n return res.then(handleResult);\n } else {\n return handleResult(res);\n }\n };\n return descriptor;\n };\n };\n}\n\nexport function applyStyle(selector: string, action: StyleAction = 'update', options: StyleApplyOptions = {}): MethodDecorator {\n return createStyleDecorator(action)(selector, options);\n}\n\nexport const setStyle = (selector: string, options: StyleApplyOptions = {}) => createStyleDecorator('set')(selector, options);\nexport const updateStyle = (selector: string, options: StyleApplyOptions = {}) => createStyleDecorator('update')(selector, options);\nexport const removeStyle = (selector: string, options: StyleApplyOptions = {}) => createStyleDecorator('remove')(selector, options);\n\n// This versions\nexport function applyStyleThis(action: StyleAction = 'update', options: StyleApplyOptions = {}): MethodDecorator {\n return createStyleDecorator(action)('$this', options);\n}\nexport const setStyleThis = (options: StyleApplyOptions = {}) => createStyleDecorator('set')('$this', options);\nexport const updateStyleThis = (options: StyleApplyOptions = {}) => createStyleDecorator('update')('$this', options);\nexport const removeStyleThis = (options: StyleApplyOptions = {}) => createStyleDecorator('remove')('$this', options);\n\nexport const findAllStyleMetadata = (target: any): Map<string | symbol, StyleApplyMetadata> => {\n const result = new Map<string | symbol, StyleApplyMetadata>();\n const maps = ReflectUtils.findAllMetadata<Map<string | symbol, StyleApplyMetadata>>(STYLE_METADATA_KEY, target);\n maps.forEach(map => {\n if (map instanceof Map) {\n map.forEach((v, k) => result.set(k, v));\n }\n });\n return result;\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA2B;AAC3B,2BAAyB;AACzB,mBAAuB;
|
|
4
|
+
"sourcesContent": ["import {ReflectUtils} from '@dooboostore/core';\nimport {ensureInit} from './elementDefine';\nimport {SwcUtils} from '../utils/Utils';\nimport { SpecialSelector, SwcQueryOptions, HelperHostSet } from '../types';\n\nexport type StyleAction = 'set' | 'update' | 'remove';\n\nexport interface StyleApplyOptions extends SwcQueryOptions {\n filter?: (target: HTMLElement, value: any, meta: {currentThis: any, helper: HelperHostSet}) => boolean;\n /**\n * Custom key to extract value from return object.\n * If not provided, uses STYLE_METADATA_KEY by default.\n * Useful when multiple @applyStyle decorators are on the same method.\n */\n valueKey?: symbol | string;\n}\n\nexport interface StyleApplyMetadata {\n propertyKey: string | symbol;\n selector: string;\n action: StyleAction;\n options: StyleApplyOptions;\n}\n\nexport const STYLE_METADATA_KEY = Symbol.for('simple-web-component:style');\n\nfunction createStyleDecorator(action: StyleAction) {\n return (selector: string, options: StyleApplyOptions = {}): MethodDecorator => {\n return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = target.constructor;\n let metaList = ReflectUtils.getOwnMetadata(STYLE_METADATA_KEY, constructor) as Map<string | symbol, StyleApplyMetadata>;\n if (!metaList) {\n metaList = new Map<string | symbol, StyleApplyMetadata>();\n ReflectUtils.defineMetadata(STYLE_METADATA_KEY, metaList, constructor);\n }\n metaList.set(propertyKey, { propertyKey, selector, action, options });\n\n const original = descriptor.value;\n descriptor.value = function (...args: any[]) {\n ensureInit(this);\n const res = (original as any).apply(this, args);\n\n /**\n * Extract value for this decorator from method return value\n * \n * If return value is an object with this decorator's key,\n * use that value. Otherwise use the entire return value.\n * \n * Uses valueKey from options if provided, otherwise uses STYLE_METADATA_KEY.\n */\n const extractValue = (v: any) => {\n const keyToUse = options.valueKey ?? STYLE_METADATA_KEY;\n if (v && typeof v === 'object' && keyToUse in v) {\n return v[keyToUse];\n }\n return v;\n };\n\n const handleResult = (resolvedValue: any) => {\n if (resolvedValue !== undefined) {\n const win = (this as any).ownerDocument?.defaultView || window;\n const host = this as unknown as HTMLElement;\n const hostSet = { ...SwcUtils.getHelperAndHostSet(win, host), $this: this };\n const r = options.root || 'auto';\n const targetEls: HTMLElement[] = [];\n\n const applyRoot = (t: any) => {\n if (!t || !(t instanceof win.HTMLElement)) return;\n targetEls.push(t);\n };\n\n if (selector === '$this' || !selector) applyRoot(host);\n else if (selector === '$host') applyRoot(hostSet.$host);\n else if (selector === '$parentHost') applyRoot(hostSet.$parentHost);\n else if (selector === '$appHost') applyRoot(hostSet.$appHost);\n else if (selector === '$firstHost') applyRoot(hostSet.$firstHost);\n else if (selector === '$lastHost') applyRoot(hostSet.$lastHost);\n else if (selector === '$firstAppHost') applyRoot(hostSet.$firstAppHost);\n else if (selector === '$lastAppHost') applyRoot(hostSet.$lastAppHost);\n else if (selector === '$hosts') hostSet.$hosts.forEach(applyRoot);\n else if (selector === '$appHosts') hostSet.$appHosts.forEach(applyRoot);\n else {\n const targetRoot = r === 'auto' ? (host.shadowRoot || host) : (r === 'shadow' ? host.shadowRoot : host);\n if (targetRoot) {\n const found = targetRoot.querySelectorAll(selector);\n if (found) targetEls.push(...(Array.from(found) as HTMLElement[]));\n }\n }\n\n targetEls.forEach(targetEl => {\n if (options.filter && !options.filter(targetEl, resolvedValue, {currentThis: this, helper: hostSet})) {\n return;\n }\n const resolvedRes = typeof resolvedValue === 'function' ? (resolvedValue as any)(targetEl, hostSet) : resolvedValue;\n\n if (action === 'set' || action === 'update') {\n if (action === 'set') targetEl.style.cssText = '';\n \n if (typeof resolvedRes === 'object' && resolvedRes !== null && !Array.isArray(resolvedRes)) {\n Object.entries(resolvedRes as any).forEach(([prop, val]) => {\n const finalVal = typeof val === 'function' ? val(targetEl, hostSet) : val;\n if (finalVal === null || finalVal === undefined) {\n targetEl.style.removeProperty(prop);\n } else {\n targetEl.style[prop as any] = String(finalVal);\n }\n });\n } else if (typeof resolvedRes === 'string') {\n targetEl.style.cssText = resolvedRes;\n }\n } else if (action === 'remove') {\n if (typeof resolvedRes === 'object' && resolvedRes !== null && !Array.isArray(resolvedRes)) {\n Object.entries(resolvedRes as any).forEach(([prop, val]) => {\n const shouldRemove = typeof val === 'function' ? val(targetEl, hostSet) : !!val;\n if (shouldRemove) {\n targetEl.style.removeProperty(prop);\n }\n });\n } else {\n const props = Array.isArray(resolvedRes) ? resolvedRes : [resolvedRes];\n props.forEach(p => targetEl.style.removeProperty(String(p)));\n }\n }\n });\n }\n return resolvedValue;\n };\n\n if (res instanceof Promise) {\n return res.then((v: any) => handleResult(extractValue(v)));\n } else {\n return handleResult(extractValue(res));\n }\n };\n return descriptor;\n };\n };\n}\n\nexport function applyStyle(selector: string, action: StyleAction = 'update', options: StyleApplyOptions = {}): MethodDecorator {\n return createStyleDecorator(action)(selector, options);\n}\n\nexport const setStyle = (selector: string, options: StyleApplyOptions = {}) => createStyleDecorator('set')(selector, options);\nexport const updateStyle = (selector: string, options: StyleApplyOptions = {}) => createStyleDecorator('update')(selector, options);\nexport const removeStyle = (selector: string, options: StyleApplyOptions = {}) => createStyleDecorator('remove')(selector, options);\n\n// This versions\nexport function applyStyleThis(action: StyleAction = 'update', options: StyleApplyOptions = {}): MethodDecorator {\n return createStyleDecorator(action)('$this', options);\n}\nexport const setStyleThis = (options: StyleApplyOptions = {}) => createStyleDecorator('set')('$this', options);\nexport const updateStyleThis = (options: StyleApplyOptions = {}) => createStyleDecorator('update')('$this', options);\nexport const removeStyleThis = (options: StyleApplyOptions = {}) => createStyleDecorator('remove')('$this', options);\n\nexport const findAllStyleMetadata = (target: any): Map<string | symbol, StyleApplyMetadata> => {\n const result = new Map<string | symbol, StyleApplyMetadata>();\n const maps = ReflectUtils.findAllMetadata<Map<string | symbol, StyleApplyMetadata>>(STYLE_METADATA_KEY, target);\n maps.forEach(map => {\n if (map instanceof Map) {\n map.forEach((v, k) => result.set(k, v));\n }\n });\n return result;\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA2B;AAC3B,2BAAyB;AACzB,mBAAuB;AAsBhB,MAAM,qBAAqB,OAAO,IAAI,4BAA4B;AAEzE,SAAS,qBAAqB,QAAqB;AACjD,SAAO,CAAC,UAAkB,UAA6B,CAAC,MAAuB;AAC7E,WAAO,CAAC,QAAgB,aAA8B,eAAmC;AACvF,YAAM,cAAc,OAAO;AAC3B,UAAI,WAAW,yBAAa,eAAe,oBAAoB,WAAW;AAC1E,UAAI,CAAC,UAAU;AACb,mBAAW,oBAAI,IAAyC;AACxD,iCAAa,eAAe,oBAAoB,UAAU,WAAW;AAAA,MACvE;AACA,eAAS,IAAI,aAAa,EAAE,aAAa,UAAU,QAAQ,QAAQ,CAAC;AAEpE,YAAM,WAAW,WAAW;AAC5B,iBAAW,QAAQ,YAAa,MAAa;AAC3C,6CAAW,IAAI;AACf,cAAM,MAAO,SAAiB,MAAM,MAAM,IAAI;AAU9C,cAAM,eAAe,CAAC,MAAW;AAC/B,gBAAM,WAAW,QAAQ,YAAY;AACrC,cAAI,KAAK,OAAO,MAAM,YAAY,YAAY,GAAG;AAC/C,mBAAO,EAAE,QAAQ;AAAA,UACnB;AACA,iBAAO;AAAA,QACT;AAEA,cAAM,eAAe,CAAC,kBAAuB;AAC3C,cAAI,kBAAkB,QAAW;AAC/B,kBAAM,MAAO,KAAa,eAAe,eAAe;AACxD,kBAAM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;AACA,aAAO;AAAA,IACT;AAAA,EACF;AACF;AAEO,SAAS,WAAW,UAAkB,SAAsB,UAAU,UAA6B,CAAC,GAAoB;AAC7H,SAAO,qBAAqB,MAAM,EAAE,UAAU,OAAO;AACvD;AAEO,MAAM,WAAW,CAAC,UAAkB,UAA6B,CAAC,MAAM,qBAAqB,KAAK,EAAE,UAAU,OAAO;AACrH,MAAM,cAAc,CAAC,UAAkB,UAA6B,CAAC,MAAM,qBAAqB,QAAQ,EAAE,UAAU,OAAO;AAC3H,MAAM,cAAc,CAAC,UAAkB,UAA6B,CAAC,MAAM,qBAAqB,QAAQ,EAAE,UAAU,OAAO;AAG3H,SAAS,eAAe,SAAsB,UAAU,UAA6B,CAAC,GAAoB;AAC/G,SAAO,qBAAqB,MAAM,EAAE,SAAS,OAAO;AACtD;AACO,MAAM,eAAe,CAAC,UAA6B,CAAC,MAAM,qBAAqB,KAAK,EAAE,SAAS,OAAO;AACtG,MAAM,kBAAkB,CAAC,UAA6B,CAAC,MAAM,qBAAqB,QAAQ,EAAE,SAAS,OAAO;AAC5G,MAAM,kBAAkB,CAAC,UAA6B,CAAC,MAAM,qBAAqB,QAAQ,EAAE,SAAS,OAAO;AAE5G,MAAM,uBAAuB,CAAC,WAA0D;AAC7F,QAAM,SAAS,oBAAI,IAAyC;AAC5D,QAAM,OAAO,yBAAa,gBAA0D,oBAAoB,MAAM;AAC9G,OAAK,QAAQ,SAAO;AAClB,QAAI,eAAe,KAAK;AACtB,UAAI,QAAQ,CAAC,GAAG,MAAM,OAAO,IAAI,GAAG,CAAC,CAAC;AAAA,IACxC;AAAA,EACF,CAAC;AACD,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -87,9 +87,7 @@ const ensureInit = (inst) => {
|
|
|
87
87
|
const appHosts = import_Utils.SwcUtils.findAllAppHostsIncludingSelfDirect(inst);
|
|
88
88
|
inst._executeSwcScript?.("swc-on-constructor", hostSet);
|
|
89
89
|
const cMethods = (0, import_lifecycles.findAllLifecycleMetadata)(inst, import_lifecycles.ON_INITIALIZE_METADATA_KEY);
|
|
90
|
-
|
|
91
|
-
for (const m of cMethods) inst._invokeLifecycleMethod(m, hostSet);
|
|
92
|
-
}
|
|
90
|
+
for (const m of cMethods) inst._invokeLifecycleMethod(m.propertyKey, hostSet);
|
|
93
91
|
}
|
|
94
92
|
};
|
|
95
93
|
const globalDelegatedRoots = /* @__PURE__ */ new WeakSet();
|
|
@@ -280,9 +278,7 @@ const elementDefine = (name, config = {}) => (constructor) => {
|
|
|
280
278
|
const conf = getElementConfig(this);
|
|
281
279
|
const currentWin = this._resolveWindow(conf);
|
|
282
280
|
const bMethods = (0, import_lifecycles.findAllOnConnectedBeforeMetadata)(this).filter((it) => useSsr ? !it.options.ssrFirst : true);
|
|
283
|
-
|
|
284
|
-
for (const m of bMethods) await this._invokeLifecycleMethod(m.propertyKey, helperHostSet);
|
|
285
|
-
}
|
|
281
|
+
for (const m of bMethods) await this._invokeLifecycleMethod(m.propertyKey, helperHostSet);
|
|
286
282
|
this._executeSwcScript("swc-on-before-connected", helperHostSet);
|
|
287
283
|
const targetConnectedList = (0, import_lifecycles.findAllOnConnectedMetadata)(constructor).filter((it) => useSsr ? !it.options.ssrFirst : true);
|
|
288
284
|
const shadowMode = conf?.useShadow || targetConnectedList.find((it) => it.options.useShadow)?.options.useShadow;
|
|
@@ -461,9 +457,7 @@ const elementDefine = (name, config = {}) => (constructor) => {
|
|
|
461
457
|
const aMethods = (0, import_lifecycles.findAllOnConnectedAfterMetadata)(this).filter((it) => {
|
|
462
458
|
return useSsr ? !it.options.ssrFirst : true;
|
|
463
459
|
});
|
|
464
|
-
|
|
465
|
-
for (const m of aMethods) await this._invokeLifecycleMethod(m.propertyKey, helperHostSet);
|
|
466
|
-
}
|
|
460
|
+
for (const m of aMethods) await this._invokeLifecycleMethod(m.propertyKey, helperHostSet);
|
|
467
461
|
this._executeSwcScript("swc-on-connected", helperHostSet);
|
|
468
462
|
this._executeSwcScript("swc-on-after-connected", helperHostSet);
|
|
469
463
|
this.__swc_connected = true;
|
|
@@ -478,8 +472,8 @@ const elementDefine = (name, config = {}) => (constructor) => {
|
|
|
478
472
|
}
|
|
479
473
|
}
|
|
480
474
|
} finally {
|
|
481
|
-
for (let
|
|
482
|
-
await this._invokeLifecycleMethod(
|
|
475
|
+
for (let m of (0, import_lifecycles.findAllLifecycleMetadata)(this, import_lifecycles.ON_CONNECTED_COMPLETED_METADATA_KEY)) {
|
|
476
|
+
await this._invokeLifecycleMethod(m.propertyKey, helperHostSet);
|
|
483
477
|
}
|
|
484
478
|
if (appHost && typeof appHost._connectedDone === "function") {
|
|
485
479
|
await appHost._connectedDone(this);
|
|
@@ -494,9 +488,7 @@ const elementDefine = (name, config = {}) => (constructor) => {
|
|
|
494
488
|
}
|
|
495
489
|
this._executeSwcScript("swc-on-before-disconnected", helperHostSet);
|
|
496
490
|
const bMethods = (0, import_lifecycles.findAllLifecycleMetadata)(this, import_lifecycles.ON_BEFORE_DISCONNECTED_METADATA_KEY);
|
|
497
|
-
|
|
498
|
-
for (const m of bMethods) this._invokeLifecycleMethod(m, helperHostSet);
|
|
499
|
-
}
|
|
491
|
+
for (const m of bMethods) this._invokeLifecycleMethod(m.propertyKey, helperHostSet);
|
|
500
492
|
if (this._boundListeners) {
|
|
501
493
|
this._boundListeners.forEach((l) => l.target.removeEventListener(l.type, l.handler, l.options));
|
|
502
494
|
this._boundListeners = [];
|
|
@@ -504,9 +496,7 @@ const elementDefine = (name, config = {}) => (constructor) => {
|
|
|
504
496
|
new import_core_web.ElementApply(this, { id: this._swcId }).removeAllEventListener();
|
|
505
497
|
if (originalDisconnected) originalDisconnected.apply(this);
|
|
506
498
|
const aMethods = (0, import_lifecycles.findAllLifecycleMetadata)(this, import_lifecycles.ON_AFTER_DISCONNECTED_METADATA_KEY);
|
|
507
|
-
|
|
508
|
-
for (const m of aMethods) this._invokeLifecycleMethod(m, helperHostSet);
|
|
509
|
-
}
|
|
499
|
+
for (const m of aMethods) this._invokeLifecycleMethod(m.propertyKey, helperHostSet);
|
|
510
500
|
this._executeSwcScript("swc-on-disconnected", helperHostSet);
|
|
511
501
|
this._executeSwcScript("swc-on-after-disconnected", helperHostSet);
|
|
512
502
|
this.__swc_connected = false;
|
|
@@ -516,14 +506,10 @@ const elementDefine = (name, config = {}) => (constructor) => {
|
|
|
516
506
|
const hostSet = import_Utils.SwcUtils.getHostSet(this);
|
|
517
507
|
this._executeSwcScript("swc-on-before-adopted", hostSet);
|
|
518
508
|
const bMethods = (0, import_lifecycles.findAllLifecycleMetadata)(this, import_lifecycles.ON_BEFORE_ADOPTED_METADATA_KEY);
|
|
519
|
-
|
|
520
|
-
for (const m of bMethods) this._invokeLifecycleMethod(m, hostSet);
|
|
521
|
-
}
|
|
509
|
+
for (const m of bMethods) this._invokeLifecycleMethod(m.propertyKey, hostSet);
|
|
522
510
|
if (originalAdopted) originalAdopted.apply(this);
|
|
523
511
|
const aMethods = (0, import_lifecycles.findAllLifecycleMetadata)(this, import_lifecycles.ON_AFTER_ADOPTED_METADATA_KEY);
|
|
524
|
-
|
|
525
|
-
for (const m of aMethods) this._invokeLifecycleMethod(m, hostSet);
|
|
526
|
-
}
|
|
512
|
+
for (const m of aMethods) this._invokeLifecycleMethod(m.propertyKey, hostSet);
|
|
527
513
|
this._executeSwcScript("swc-on-adopted", hostSet);
|
|
528
514
|
this._executeSwcScript("swc-on-after-adopted", hostSet);
|
|
529
515
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/decorators/elementDefine.ts"],
|
|
4
|
-
"sourcesContent": ["import {ActionExpression, FunctionUtils, ReflectUtils} from '@dooboostore/core';\nimport {getAddEventListenerMetadata} from './addEventListener';\nimport {findAllLifecycleMetadata, findAllOnConnectedAfterMetadata, findAllOnConnectedBeforeMetadata, findAllOnConnectedMetadata, ON_AFTER_ADOPTED_METADATA_KEY, ON_AFTER_DISCONNECTED_METADATA_KEY, ON_BEFORE_ADOPTED_METADATA_KEY, ON_BEFORE_DISCONNECTED_METADATA_KEY, ON_CONNECTED_COMPLETED_METADATA_KEY, ON_INITIALIZE_METADATA_KEY} from './lifecycles';\nimport {getEmitCustomEventMetadataList} from './emitCustomEvent';\nimport {convertAttributeValue, findAllAttributeChangedMetadata} from './changedAttributeThis';\nimport {findAllAttributeApplyMetadata, findAllAttributeMetadata, getAttributeValue} from './applyAttribute';\nimport {getQueryMetadata} from './query';\nimport {getQueryAllMetadata} from './queryAll';\nimport {SwcUtils} from '../utils/Utils';\nimport {DOM_EVENT_NAMES, HTML_TAG_ENTRIES} from '../config/config';\nimport {SituationTypeContainer, SituationTypeContainers} from '@dooboostore/simple-boot/decorators/inject/Inject';\nimport {HelperHostSet, HostSet, InjectSituationType} from '../types';\nimport {ConvertUtils, ElementApply, NodeSlot} from '@dooboostore/core-web';\nimport {isSSR} from \"../elements/SwcAppMixin\";\nimport {findAllApplySlotMetadata} from \"./applySlot\";\nimport {findAllStateMetadata} from \"./state\";\nimport {findAllPropertyMetadata} from \"./applyProperty\";\n\n// --- Core Interfaces & Types ---\n\nexport const ELEMENT_CONFIG_KEY = Symbol.for('simple-web-component:element-config');\n\nexport interface ElementConfig {\n extends?: string;\n observedAttributes?: string[];\n customElementRegistry?: any;\n window?: Window;\n useShadow?: boolean | 'open' | 'closed';\n}\n\nexport interface ElementMetadata extends Omit<ElementConfig, 'window'> {\n name: string;\n window: Window;\n}\n\nexport const getElementConfig = (target: any): ElementMetadata | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(ELEMENT_CONFIG_KEY, constructor);\n};\n\nexport const ensureInit = (inst: any) => { // HTMLElement\n if (!inst.__swc_initialized) {\n inst._swcId = inst?.getAttribute?.('swc-use-ssr') ?? 's' + Math.random().toString(36).substring(2, 11).toLowerCase();\n inst._emitHandlers = new Map();\n inst._boundListeners = [];\n inst.__swc_initialized = true;\n // const attributeList = findAllQ(inst);\n // attributeList.forEach(meta => {\n // delete (inst as any)[meta.propertyKey];\n // });\n\n const target = inst instanceof Function ? inst : inst.constructor;\n\n // \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557\n // \u2551 decorator \uD544\uB4DC\uC758 own property \uC0AD\uC81C \u2551\n // \u2551 \u2551\n // \u2551 \uC774\uC720: own property\uAC00 \uC788\uC73C\uBA74 prototype\uC758 getter/setter\uB294 \uC808\uB300 \uC548 \uD0C4\uB2E4 \u2551\n // \u2551 1. TypeScript\uB294 \uCD08\uAE30\uAC12\uC774 \uC788\uB294 \uD544\uB4DC\uB97C constructor\uC5D0\uC11C own property\uB85C \uC0DD\uC131 \u2551\n // \u2551 @attributeThis('id') myId: string = \"default\" \u2192 this.myId = \"default\" \u2551\n // \u2551 \u2551\n // \u2551 2. JavaScript\uC758 property lookup\uC740 own property\uB97C \uBA3C\uC800 \uCC3E\uC74C \u2551\n // \u2551 - this.myId \uC811\uADFC \u2551\n // \u2551 - 1\uC21C\uC704: instance\uC758 own property \uC788\uB098? \u2192 \uC788\uC73C\uBA74 \uADF8\uAC83 \uBC18\uD658 \u2551\n // \u2551 - 2\uC21C\uC704: prototype\uC758 getter \uC788\uB098? \u2192 \uC788\uC73C\uBA74 \uD638\uCD9C \u2551\n // \u2551 \u2551\n // \u2551 3. own property\uAC00 \uC788\uC73C\uBA74 prototype\uC758 getter\uB294 \uC808\uB300 \uD638\uCD9C\uB418\uC9C0 \uC54A\uC74C \u2551\n // \u2551 \uB530\uB77C\uC11C getter\uC5D0\uC11C \uC815\uC758\uB41C DOM \uB3D9\uAE30\uD654 \uB85C\uC9C1\uC774 \uC791\uB3D9\uD558\uC9C0 \uC54A\uC74C \u2551\n // \u2551 \u2551\n // \u2551 4. own property\uB97C \uC0AD\uC81C\uD558\uBA74 JavaScript\uAC00 prototype\uC758 getter\uB97C \uCC3E\uAC8C \uB428 \u2551\n // \u2551 \u2192 getter \uD638\uCD9C\uB428 \u2192 DOM \uC18D\uC131 \uAC12 \uB3D9\uAE30\uD654\uB428 \u2551\n // \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D\n // \uD568\uC218\uB294 decorator\uC5D0\uC11C \uAC12\uC790\uCCB4\uB97C descriptor.value = function (...args: any[]) {...\n\n // @attribute \uD544\uB4DC\uC758 own property \uC0AD\uC81C \u2192 getter/setter \uC791\uB3D9\n // const attributeList = findAllAttributeMetadata(target);\n const attributeAllList = findAllAttributeMetadata(target).filter(it => it.type === 'property');\n if (attributeAllList) {\n attributeAllList.forEach(meta => {\n // const initUserData = (inst as any)[meta.propertyKey];\n delete (inst as any)[meta.propertyKey];\n // (inst as any)[meta.propertyKey] = initUserData;\n });\n }\n\n // @query \uD544\uB4DC\uC758 own property \uC0AD\uC81C \u2192 getter \uC791\uB3D9\n const queryList = getQueryMetadata(target);\n if (queryList) {\n queryList.forEach(meta => {\n delete (inst as any)[meta.propertyKey];\n });\n }\n\n // @queryAll \uD544\uB4DC\uC758 own property \uC0AD\uC81C \u2192 getter \uC791\uB3D9\n const queryAllList = getQueryAllMetadata(target);\n if (queryAllList) {\n queryAllList.forEach(meta => {\n delete (inst as any)[meta.propertyKey];\n });\n }\n // const slotAllList = findAllApplySlotMetadata(target);\n // if (slotAllList) {\n // slotAllList.filter(it => it.type === 'property').forEach(meta => {\n // delete (inst as any)[meta.propertyKey];\n // });\n // }\n\n\n const propertyAllList = findAllPropertyMetadata(target).filter(it => it.type === 'property');\n if (propertyAllList) {\n propertyAllList.forEach(meta => {\n delete (inst as any)[meta.propertyKey];\n });\n }\n\n const stateAllList = findAllStateMetadata(target);\n if (stateAllList) {\n stateAllList.forEach(meta => {\n const initUserData = (inst as any)[meta.propertyKey];\n delete (inst as any)[meta.propertyKey];\n (inst as any)[meta.propertyKey] = initUserData;\n });\n }\n\n // Call constructor script if present\n const hostSet = SwcUtils.getHostSet(inst);\n const appHosts = SwcUtils.findAllAppHostsIncludingSelfDirect(inst);\n inst._executeSwcScript?.('swc-on-constructor', hostSet);\n\n // Call @onInitialize lifecycle methods\n const cMethods = findAllLifecycleMetadata(inst, ON_INITIALIZE_METADATA_KEY);\n if (cMethods) {\n for (const m of cMethods) inst._invokeLifecycleMethod(m, hostSet);\n }\n }\n};\n\n\n// \uD6D4 \uC774\uAC8C\uB9DE\uB098?? global\uB85C \uAD00\uB9AC\uD558\uB294\uAC8C..\uD6D4... \uC65C\uC774\uB807\uAC8C \uD588\uC744\uAE4C..\n// --- Global Event Handling ---\nconst globalDelegatedRoots = new WeakSet<Node>();\n// \uC5EC\uAE30\uC5D0\uC11C \uC911\uBCF5 \uD638\uCD9C\uC548\uB418\uAC8C \uC798\uB9C9\uC544\uC900\uB2E4 ..\nconst handleGlobalSwcEvent = async (event: Event) => {\n if ((event as any).__swc_handled) return;\n const path = event.composedPath();\n const type = event.type;\n const attrName = `swc-on-${type}`;\n\n for (const node of path) {\n if (!(node instanceof HTMLElement)) continue;\n const script = node.getAttribute?.(attrName);\n if (script && !getElementConfig(node)) {\n const host: any = SwcUtils.findNearestSwcHostIncludingSelf(node);\n if (host && host.isConnected && typeof host.__swc_executeAttributeEvent === 'function') {\n await host.__swc_executeAttributeEvent(node, attrName, script, event);\n (event as any).__swc_handled = true;\n break;\n }\n }\n }\n};\n\nfunction buildEnv(configWindow: Window) {\n const win: Window = configWindow;\n const doc: Document = win?.document;\n const builtInTagMap = new Map<any, string>();\n for (const [cls, tag] of HTML_TAG_ENTRIES) {\n if ((win as any)?.[cls]) builtInTagMap.set((win as any)[cls], tag);\n }\n const domHelpers = SwcUtils.getHelperSet(win);\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\nconst setupPrototype = (proto: any, win: Window) => {\n if (proto.__swc_proto_setup) return;\n proto.__swc_proto_setup = true;\n\n\n // proto.createSlotString = function (id: string) {\n // return NodeSlot.slot(`${this._swcId}-${id}`);\n // }\n // proto.createEaHtml = function (id: string, script: string) {\n // return ElementApply.html(id, script);\n // }\n // proto.createEaText = function (id: string, script: string) {\n // return ElementApply.text(id, script);\n // }\n // proto.createEaAttribute = function (id: string, name: string, script: string) {\n // return ElementApply.attribute(id, name, script);\n // }\n // proto.createEaEvent = function (id: string, name: string, script: string) {\n // return ElementApply.event(id, name, script);\n // }\n // proto.createEaProperty = function (id: string, name: string, script: string) {\n // return ElementApply.property(id, name, script);\n // }\n\n // swc-id-asdasdasdasd-click=\" :value=\"\" {: value fsdfsdafsad :} {html: aaa :} {text: asdas :}\n\n proto._executeSwcScript = function (attrName: string, hostSet: HostSet, extraArgs: Record<string, any> = {}) {\n ensureInit(this);\n const script = this.getAttribute(attrName);\n if (script) {\n try {\n const conf = getElementConfig(this);\n const currentWin = (this as any)._resolveWindow(conf);\n const helpers = SwcUtils.getHelperSet(currentWin);\n const args = {...hostSet, ...helpers, ...extraArgs, $el: this, $root: this.getRootNode()};\n FunctionUtils.execute({script, context: this, args});\n } catch (e) {\n console.error(`[SWC] Failed to execute ${attrName}:`, e);\n }\n }\n };\n\n proto._resolveWindow = function (localConfig?: ElementConfig): Window {\n ensureInit(this);\n if (localConfig?.window) return localConfig.window;\n const ancestors = SwcUtils.findAllSwcHostsIncludingSelf(this as any);\n for (let i = ancestors.length - 1; i >= 0; i--) {\n const aConf = getElementConfig(ancestors[i]);\n if (aConf?.window) return aConf.window;\n }\n return getElementConfig(this).window ?? ((typeof window !== 'undefined' ? window : undefined) as Window);\n };\n\n proto._invokeLifecycleMethod = function (methodName: string | symbol, hostSet?: HostSet, extraArgs: any[] = []) {\n ensureInit(this);\n if (typeof (this as any)[methodName] !== 'function') return;\n const useHostSet = hostSet ?? SwcUtils.getHelperAndHostSet(win, this);\n const app = useHostSet?.$appHost?.simpleApplication;\n // console.log('---->hh',app, this, methodName);\n if (app) {\n const otherStorage = new Map<any, any>();\n const situations = new SituationTypeContainers([new SituationTypeContainer({situationType: InjectSituationType.HOST_SET, data: useHostSet}), new SituationTypeContainer({situationType: InjectSituationType.APP_HOST, data: useHostSet.$appHost}), new SituationTypeContainer({situationType: InjectSituationType.APP_HOSTS, data: useHostSet.$appHosts}), new SituationTypeContainer({\n situationType: InjectSituationType.HOST,\n data: useHostSet.$host\n }), new SituationTypeContainer({situationType: InjectSituationType.HOSTS, data: useHostSet.$hosts}), new SituationTypeContainer({situationType: InjectSituationType.FIRST_HOST, data: useHostSet.$firstHost}), new SituationTypeContainer({situationType: InjectSituationType.LAST_HOST, data: useHostSet.$lastHost}), new SituationTypeContainer({\n situationType: InjectSituationType.FIRST_APP_HOST,\n data: useHostSet.$firstAppHost\n }), new SituationTypeContainer({situationType: InjectSituationType.LAST_APP_HOST, data: useHostSet.$lastAppHost})]);\n otherStorage.set(SituationTypeContainers, situations);\n\n return app.simstanceManager.executeBindParameterSim(\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 proto._bindAttributeEvent = function (el: HTMLElement, attrName: string, script: string, eventName?: string) {\n ensureInit(this);\n if (!eventName) {\n if (!attrName.startsWith('swc-on-')) return;\n eventName = attrName.substring(7);\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 = async (event: any) => {\n const hostSet = SwcUtils.getHostSet(el);\n const conf = getElementConfig(this);\n const currentWin = (this as any)._resolveWindow(conf);\n const helpers = SwcUtils.getHelperSet(currentWin);\n const args = {\n event,\n $data: (event as CustomEvent).detail,\n ...hostSet,\n ...helpers,\n $el: el,\n $root: this.getRootNode()\n };\n await FunctionUtils.execute({script, context: el, args});\n };\n\n el.addEventListener(eventName, handler);\n handlers.set(attrName, handler);\n };\n\n proto.__swc_executeAttributeEvent = async function (el: HTMLElement, attrName: string, script: string, event: Event) {\n ensureInit(this);\n\n const hostSet = SwcUtils.getHostSet(el);\n const conf = getElementConfig(this);\n const currentWin = (this as any)._resolveWindow(conf);\n const currentHelpers = SwcUtils.getHelperSet(currentWin);\n const detail = (event as CustomEvent).detail;\n const args = {\n event,\n $event: event,\n $data: detail,\n $detail: detail,\n ...hostSet,\n ...currentHelpers,\n $el: el,\n $root: this.getRootNode()\n };\n await FunctionUtils.execute({script, context: el, args});\n };\n};\n\nexport const elementDefine =\n (name: string, config: Partial<ElementConfig> = {}): ClassDecorator =>\n (constructor: any) => {\n const {win, doc, builtInTagMap: BUILT_IN_TAG_MAP, domHelpers: SWC_DOM_HELPERS} = buildEnv(config.window);\n const metadata: ElementMetadata = {...config, name, window: win};\n\n if (!metadata.window) {\n throw new Error('window is required');\n }\n\n let extendsTagName = metadata.extends;\n if (!extendsTagName) {\n let proto = constructor;\n const BaseHTMLElement = (win as any).HTMLElement;\n while (proto && proto !== BaseHTMLElement && proto !== Function.prototype) {\n extendsTagName = BUILT_IN_TAG_MAP.get(proto);\n if (extendsTagName) break;\n proto = Object.getPrototypeOf(proto);\n }\n metadata.extends = extendsTagName;\n }\n\n const emitCustomEventList = getEmitCustomEventMetadataList(constructor) || [];\n const emitHostCustomEventList = emitCustomEventList.filter(meta => meta.selector === '$this' || meta.selector === '');\n const addEventListenerList = getAddEventListenerMetadata(constructor) || [];\n const attrChangeMap = findAllAttributeChangedMetadata(constructor);\n const attributeList = findAllAttributeMetadata(constructor);\n const applyAttributeMap = findAllAttributeApplyMetadata(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 attributeApplyNames = Array.from(applyAttributeMap.values())\n .map(it => it.targetAttributeName)\n .filter(Boolean) as string[];\n const hostAttributes = attributeList.filter(it => it.selector === '$this').map(it => it.propertyKey || String(it.propertyKey));\n // Get original static observedAttributes before they're overwritten by Object.defineProperty\n const originalStaticObservedAttributes = (constructor.observedAttributes ?? []) as string[];\n const mergedObservedAttributes = [...new Set([...(metadata.observedAttributes ?? []), ...originalStaticObservedAttributes, ...attrChangeMap.keys(), ...attributeApplyNames, ...hostAttributes, ...emitHostCustomEventList.map(it => (it.options as any).attributeName).filter(Boolean), ...swcLifecycleAttributes, ...swcOnEvents])];\n // const connectedInnerHtmlList = getOnConnectedInnerHtmlMetadata(constructor) || [];\n\n const proto = constructor.prototype;\n setupPrototype(proto, win);\n\n // \uAC12\uC744 \uAE30\uB300\uD558\uC9C0\uC54A\uB294\uB2E4.\n let helperHostSet: HelperHostSet | null = null;\n const originalConnected = proto.connectedCallback;\n proto.connectedCallback = async function () {\n ensureInit(this);\n // connected \uB410\uC744\uC2DC \uCD5C\uC2E0\uD654\n helperHostSet = SwcUtils.getHelperAndHostSet(win, this as any);\n const appHost = helperHostSet.$appHost;\n const useSsr = isSSR(this);\n // console.log('isSsr', useSsr, this);\n // console.log('----helperHostSet--->', this, helperHostSet, useSsr)\n // let connectedApp: SwcAppInterface |undefined;\n try {\n if (appHost && typeof (appHost as any)._connected === 'function') {\n await (appHost as any)._connected(this);\n } else if (appHost && typeof (appHost as any)) {\n (appHost as any)._connected_safari_and_standby ??= [];\n (appHost as any)._connected_safari_and_standby.push(this);\n }\n\n // const hostSet = SwcUtils.getHostSet(this as any);\n const conf = getElementConfig(this);\n const currentWin = (this as any)._resolveWindow(conf);\n\n const bMethods = findAllOnConnectedBeforeMetadata(this).filter(it => useSsr ? !it.options.ssrFirst : true);\n // console.log('beforeConnected', bMethods)\n if (bMethods) {\n for (const m of bMethods) await (this as any)._invokeLifecycleMethod(m.propertyKey, helperHostSet);\n }\n (this as any)._executeSwcScript('swc-on-before-connected', helperHostSet);\n\n // console.log('vvvvvvvvvvvvvvvu-seSsr-vvvvvvvvvv>', useSsr, this.tagName, this.getAttribute('seq'))\n // // ssr \uCC98\uB9AC\uB77C\uC11C \uC774\uBBF8 \uB0B4\uB824\uC900\uAC70\uADF8\uB300\uB85C \uC0C1\uC694\uD558\uBA74\uB41C\uB2E4 \uB530\uB77C\uC11C \uD638\uCD9C\uC548\uD55C\uB2E4\n const targetConnectedList = findAllOnConnectedMetadata(constructor).filter(it => useSsr ? !it.options.ssrFirst : true);\n const shadowMode = conf?.useShadow || targetConnectedList.find(it => it.options.useShadow)?.options.useShadow;\n // console.log('--------->', this.tagName, shadowMode && !this.shadowRoot)\n if (shadowMode && !this.shadowRoot) {\n const mode = shadowMode === true ? 'open' : shadowMode;\n console.log('tagName=', this.tagName, 'mode', mode, this.shadowRoot);\n // if (this.tagName!=='INDEX-ROUTER') {\n this.attachShadow({mode: mode as ShadowRootMode});\n // }\n }\n\n const stateContext: any = {...helperHostSet};\n findAllStateMetadata(this).forEach(it => {\n stateContext[it.name] = this[it.propertyKey]\n })\n\n const shadowChildren: Node[] = [];\n const lightChildren: Node[] = [];\n\n console.log('targetConnectList', this.tagName, targetConnectedList.length)\n if (targetConnectedList.length > 0) {\n // let sContent = '',\n // lContent = '';\n for (const meta of targetConnectedList) {\n // const res = (this as any)[meta.propertyKey]();\n let res = await (this as any)._invokeLifecycleMethod(meta.propertyKey, helperHostSet);\n // res = SwcUtils.projectProcessHtml(this, res);\n if (typeof res === 'string') {\n const htmlTemplateElement = doc.createElement('template');\n htmlTemplateElement.innerHTML = res;//SwcUtils.projectProcessHtml(this._swcId, res, doc);\n res = htmlTemplateElement.content;\n }\n\n if (res) {\n const nodes = Array.isArray(res) ? res : [res];\n if (meta.options.useShadow || conf?.useShadow) {\n shadowChildren.push(...nodes);\n }else {\n lightChildren.push(...nodes);\n }\n }\n }\n try {\n if (this.shadowRoot) {\n const applyShadowChildren = SwcUtils.projectProcessHtml(this._swcId, shadowChildren, doc);\n this.shadowRoot.replaceChildren(...applyShadowChildren)\n }\n if (lightChildren.length) {\n const applyLightChildren = SwcUtils.projectProcessHtml(this._swcId, lightChildren, doc);\n this.replaceChildren(...applyLightChildren)\n }\n\n } catch (e) {\n console.error('[ElementDefine] innerHTML setting error:', e);\n }\n new ElementApply(this, {id: this._swcId}).apply({context: stateContext, bind: this});\n } else {\n new ElementApply(this, {id: this._swcId}).apply({exclude: {html: true, text: true, attribute: true}, context: stateContext, bind: this});\n }\n\n // global delegate event\n const root = this.getRootNode()\n if (!globalDelegatedRoots.has(root)) {\n DOM_EVENT_NAMES.forEach(type => {\n root.addEventListener(type, handleGlobalSwcEvent);\n });\n globalDelegatedRoots.add(root);\n }\n\n\n // Separate delegate and non-delegate listeners\n const delegateListeners: typeof addEventListenerList = [];\n const nonDelegateListeners: typeof addEventListenerList = [];\n\n addEventListenerList.forEach(meta => {\n if (meta.options.delegate && meta.selector !== '$window' && meta.selector !== '$document' && meta.selector !== '$host' && meta.selector !== '$appHost' && meta.selector !== '$firstHost' && meta.selector !== '$lastHost' && meta.selector !== '$firstAppHost' && meta.selector !== '$lastAppHost' && meta.selector !== '$hosts' && meta.selector !== '$appHosts' && meta.selector !== '$this' && meta.selector !== '') {\n delegateListeners.push(meta);\n } else {\n nonDelegateListeners.push(meta);\n }\n });\n\n const delegatesByTypeAndRoot = new Map<string, any[]>();\n delegateListeners.forEach(meta => {\n const r = meta.options.root || 'auto';\n const rootKey = `${meta.type}:${r}`;\n if (!delegatesByTypeAndRoot.has(rootKey)) {\n delegatesByTypeAndRoot.set(rootKey, []);\n }\n delegatesByTypeAndRoot.get(rootKey)!.push(meta);\n });\n\n delegatesByTypeAndRoot.forEach((metaList, typeRootKey) => {\n const [type, rStr] = typeRootKey.split(':');\n const r = rStr === 'auto' ? 'auto' : rStr;\n const opts = {capture: metaList[0].options.capture, once: metaList[0].options.once, passive: metaList[0].options.passive};\n\n const bindRoots: (HTMLElement | ShadowRoot)[] = [];\n if (r === 'auto') bindRoots.push(this.shadowRoot || (this as any));\n else if (r === 'light') bindRoots.push(this as any);\n else if (r === 'shadow' && this.shadowRoot) bindRoots.push(this.shadowRoot);\n else if (r === 'all') {\n bindRoots.push(this as any);\n if (this.shadowRoot) bindRoots.push(this.shadowRoot);\n }\n\n bindRoots.forEach(br => {\n const sortedMetaList = [...metaList].sort((a, b) => {\n const aStop = a.options.stopPropagation ? 1 : 0;\n const bStop = b.options.stopPropagation ? 1 : 0;\n return bStop - aStop;\n });\n\n const unifiedHandler = async (event: Event) => {\n for (const meta of sortedMetaList) {\n const {selector, options} = meta;\n const matchedEl = (event.target as HTMLElement).closest(selector);\n if (matchedEl && (br as any).contains(matchedEl)) {\n // Apply filter if specified\n if (options.filter) {\n const helper = SwcUtils.getHelperAndHostSet(currentWin, matchedEl);\n if (!options.filter(event, helper)) {\n continue; // Skip this listener if filter returns false\n }\n }\n if (options.stopPropagation) event.stopPropagation();\n if (options.stopImmediatePropagation) event.stopImmediatePropagation();\n if (options.preventDefault) event.preventDefault();\n const currentHostSet = SwcUtils.getHostSet(this as any);\n const args = {event, ...currentHostSet, $el: matchedEl, $root: br};\n await (this as any)[meta.propertyKey](event, {...currentHostSet, $matchedElement: matchedEl}, args);\n if ((event as any).cancelBubble) break;\n }\n }\n };\n br.addEventListener(type, unifiedHandler, opts);\n (this as any)._boundListeners.push({target: br, type, handler: unifiedHandler, options: opts});\n });\n });\n\n nonDelegateListeners.forEach(meta => {\n const {selector, type, options} = meta;\n const opts = {capture: options.capture, once: options.once, passive: options.passive};\n const bindTargets: EventTarget[] = [];\n const r = options.root || 'auto';\n const applyRootOption = (target: any) => {\n if (!target) return;\n if (r === 'auto') {\n bindTargets.push(target.shadowRoot || target);\n } else {\n if (r === 'light' || r === 'all') bindTargets.push(target);\n if ((r === 'shadow' || r === 'all') && target.shadowRoot) bindTargets.push(target.shadowRoot);\n }\n };\n\n if (selector === '$window') bindTargets.push(currentWin);\n else if (selector === '$document') bindTargets.push(currentWin.document);\n else if (selector === '$host') applyRootOption(helperHostSet.$host);\n else if (selector === '$parentHost') applyRootOption(helperHostSet.$parentHost);\n else if (selector === '$appHost') applyRootOption(helperHostSet.$appHost);\n else if (selector === '$firstHost') applyRootOption(helperHostSet.$firstHost);\n else if (selector === '$lastHost') applyRootOption(helperHostSet.$lastHost);\n else if (selector === '$firstAppHost') applyRootOption(helperHostSet.$firstAppHost);\n else if (selector === '$lastAppHost') applyRootOption(helperHostSet.$lastAppHost);\n else if (selector === '$hosts') helperHostSet.$hosts.forEach(applyRootOption);\n else if (selector === '$appHosts') helperHostSet.$appHosts.forEach(applyRootOption);\n else if (selector === '$this' || !selector) applyRootOption(this);\n else {\n const searchRoots: (HTMLElement | ShadowRoot)[] = [];\n if (r === 'auto') searchRoots.push(this.shadowRoot || (this as any));\n else if (r === 'light') searchRoots.push(this as any);\n else if (r === 'shadow' && this.shadowRoot) searchRoots.push(this.shadowRoot);\n else if (r === 'all') {\n searchRoots.push(this as any);\n if (this.shadowRoot) searchRoots.push(this.shadowRoot);\n }\n\n searchRoots.forEach(sr => {\n sr.querySelectorAll(selector).forEach(el => bindTargets.push(el));\n });\n }\n\n bindTargets.forEach(t => {\n const handler = async (event: Event) => {\n // Apply filter if specified\n if (options.filter) {\n const helper = SwcUtils.getHelperAndHostSet(currentWin, t as HTMLElement);\n if (!options.filter(event, {currentThis: this, helper})) {\n return; // Skip if filter returns false\n }\n }\n if (options.stopPropagation) event.stopPropagation();\n if (options.stopImmediatePropagation) event.stopImmediatePropagation();\n if (options.preventDefault) event.preventDefault();\n const currentHostSet = SwcUtils.getHostSet(this as any);\n const args = {event, ...currentHostSet, $el: t, $root: t};\n await (this as any)[meta.propertyKey](event, {currentHostSet, $$matchedElement: event.currentTarget}, args);\n };\n t.addEventListener(type, handler, opts);\n (this as any)._boundListeners.push({target: t, type, handler, options: opts});\n });\n });\n\n if (originalConnected) await (originalConnected.apply(this));\n\n const aMethods = findAllOnConnectedAfterMetadata(this).filter(it => {\n return useSsr ? !it.options.ssrFirst : true;\n });\n // console.log('afterConnected', this.tagName, aMethods, getOnConnectedAfterMetadata(this))\n if (aMethods) {\n for (const m of aMethods) await (this as any)._invokeLifecycleMethod(m.propertyKey, helperHostSet);\n }\n (this as any)._executeSwcScript('swc-on-connected', helperHostSet);\n (this as any)._executeSwcScript('swc-on-after-connected', helperHostSet);\n (this as any).__swc_connected = true;\n\n // Trigger @changedAttributeThis with while: 'connected'\n for (let [name, metaList] of Array.from(attrChangeMap)) {\n for (const meta of metaList) {\n if (meta.options.while === 'connected') {\n const val = getAttributeValue(this, name, {type: meta.options.type});\n if (val !== null) {\n await ((this as any)[meta.propertyKey](val, null, name, helperHostSet));\n }\n }\n }\n }\n } finally {\n for (let mPropertyKey of findAllLifecycleMetadata(this, ON_CONNECTED_COMPLETED_METADATA_KEY)) {\n await (this as any)._invokeLifecycleMethod(mPropertyKey, helperHostSet);\n }\n if (appHost && typeof (appHost as any)._connectedDone === 'function') {\n await (appHost as any)._connectedDone(this);\n }\n }\n };\n\n const originalDisconnected = proto.disconnectedCallback;\n proto.disconnectedCallback = function () {\n // const helperHostSet = SwcUtils.getHelperAndHostSet(win, this as any);\n // Remove from appHost LAST when disconnected\n // console.log('disconnnnnnnnnnnnnnnnnnn', helperHostSet, this)\n const appHost = helperHostSet.$appHost;\n if (appHost && typeof (appHost as any)._disconnected === 'function') {\n (appHost as any)._disconnected(this);\n }\n\n (this as any)._executeSwcScript('swc-on-before-disconnected', helperHostSet);\n const bMethods = findAllLifecycleMetadata(this, ON_BEFORE_DISCONNECTED_METADATA_KEY);\n if (bMethods) {\n for (const m of bMethods) (this as any)._invokeLifecycleMethod(m, helperHostSet);\n }\n\n if ((this as any)._boundListeners) {\n (this as any)._boundListeners.forEach((l: any) => l.target.removeEventListener(l.type, l.handler, l.options));\n (this as any)._boundListeners = [];\n }\n\n new ElementApply(this, {id: this._swcId}).removeAllEventListener();\n\n // globalDelegatedRoots remove\n // const roots = [this, this.getRootNode()];\n // if (this.shadowRoot) {\n // roots.push(this.shadowRoot);\n // }\n // roots.forEach(root => {\n // DOM_EVENT_NAMES.forEach(type => {\n // root.removeEventListener(type, handleGlobalSwcEvent);\n // });\n // }\n // )\n\n if (originalDisconnected) originalDisconnected.apply(this);\n\n const aMethods = findAllLifecycleMetadata(this, ON_AFTER_DISCONNECTED_METADATA_KEY);\n if (aMethods) {\n for (const m of aMethods) (this as any)._invokeLifecycleMethod(m, helperHostSet);\n }\n (this as any)._executeSwcScript('swc-on-disconnected', helperHostSet);\n (this as any)._executeSwcScript('swc-on-after-disconnected', helperHostSet);\n (this as any).__swc_connected = false;\n };\n\n const originalAdopted = proto.adoptedCallback;\n proto.adoptedCallback = function () {\n const hostSet = SwcUtils.getHostSet(this as any);\n (this as any)._executeSwcScript('swc-on-before-adopted', hostSet);\n const bMethods = findAllLifecycleMetadata(this, ON_BEFORE_ADOPTED_METADATA_KEY);\n if (bMethods) {\n for (const m of bMethods) (this as any)._invokeLifecycleMethod(m, hostSet);\n }\n\n if (originalAdopted) originalAdopted.apply(this);\n\n const aMethods = findAllLifecycleMetadata(this, ON_AFTER_ADOPTED_METADATA_KEY);\n if (aMethods) {\n for (const m of aMethods) (this as any)._invokeLifecycleMethod(m, hostSet);\n }\n (this as any)._executeSwcScript('swc-on-adopted', hostSet);\n (this as any)._executeSwcScript('swc-on-after-adopted', hostSet);\n };\n\n const originalAttributeChanged = proto.attributeChangedCallback;\n proto.attributeChangedCallback = function (name: string, old: string | null, newVal: string | null) {\n if (originalAttributeChanged) originalAttributeChanged.apply(this, [name, old, newVal]);\n\n const hSet = SwcUtils.getHostSet(this as any);\n\n // Process expression directive before passing to handlers\n let processedVal: any = newVal;\n if (newVal !== null) {\n const ae = new ActionExpression(newVal);\n const expr = ae.getFirstExpression('callReturn');\n if (expr) {\n const win = (this as any)._resolveWindow?.() || ((typeof window !== 'undefined' ? window : undefined) as any);\n const helperAndHostSet = SwcUtils.getHelperAndHostSet(win, this as any);\n const script = ConvertUtils.decodeHtmlEntity(expr.script, win.document);\n try {\n const result = FunctionUtils.executeReturn({\n script: script,\n context: this,\n args: helperAndHostSet\n });\n // Pass the result object directly without serialization\n processedVal = result;\n } catch (e) {\n console.error(`[SWC] Failed to execute directive {{= ${expr.script} }} on attribute ${name}: ${helperAndHostSet}`, e);\n processedVal = newVal;\n }\n }\n }\n\n if (name.startsWith('swc-on-') && !swcLifecycleAttributes.includes(name)) {\n if (newVal !== null) {\n const eventName = name.substring(7);\n (this as any)._bindAttributeEvent(this as any, name, newVal, eventName);\n }\n }\n\n const hostCustomEventMeta = emitHostCustomEventList.find(it => (it.options as any).attributeName === name);\n if (hostCustomEventMeta && newVal !== null) {\n (this as any)._bindAttributeEvent(this as any, name, newVal, hostCustomEventMeta.type);\n }\n\n const metaList = attrChangeMap.get(name);\n if (metaList && Array.isArray(metaList)) {\n for (const meta of metaList) {\n if (meta.options.while === 'connected' && !(this as any).__swc_connected) {\n continue;\n }\n const convertedVal = convertAttributeValue(processedVal, meta.options.type);\n (this as any)[meta.propertyKey](convertedVal, old, name, hSet);\n }\n }\n };\n\n Object.defineProperty(constructor, 'observedAttributes', {\n get: () => mergedObservedAttributes,\n configurable: true\n });\n\n ReflectUtils.defineMetadata(ELEMENT_CONFIG_KEY, metadata, constructor);\n const registry = metadata.customElementRegistry || (win as any)?.customElements;\n if (registry && !registry.get(metadata.name)) {\n registry.define(metadata.name, constructor as any, metadata.extends ? {extends: metadata.extends} : undefined);\n }\n return constructor;\n };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA4D;AAC5D,8BAA0C;AAC1C,wBAA+U;AAC/U,6BAA6C;AAC7C,kCAAqE;AACrE,4BAAyF;AACzF,mBAA+B;AAC/B,sBAAkC;AAClC,mBAAuB;AACvB,oBAAgD;AAChD,oBAA8D;AAC9D,mBAA0D;AAC1D,sBAAmD;AACnD,yBAAoB;AAEpB,mBAAmC;AACnC,2BAAsC;AAI/B,MAAM,qBAAqB,OAAO,IAAI,qCAAqC;AAe3E,MAAM,mBAAmB,CAAC,WAA6C;AAC5E,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,SAAO,yBAAa,YAAY,oBAAoB,WAAW;AACjE;AAEO,MAAM,aAAa,CAAC,SAAc;AACvC,MAAI,CAAC,KAAK,mBAAmB;AAC3B,SAAK,SAAS,MAAM,eAAe,aAAa,KAAK,MAAM,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,UAAU,GAAG,EAAE,EAAE,YAAY;AACnH,SAAK,gBAAgB,oBAAI,IAAI;AAC7B,SAAK,kBAAkB,CAAC;AACxB,SAAK,oBAAoB;AAMzB,UAAM,SAAS,gBAAgB,WAAW,OAAO,KAAK;AAwBtD,UAAM,uBAAmB,gDAAyB,MAAM,EAAE,OAAO,QAAM,GAAG,SAAS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oBAAoB,UAAU,WAAW;AACrE,QAAM,WAAW,SAAS,yBAA0B,KAAa;AACjE,MAAI,YAAY,CAAC,SAAS,IAAI,SAAS,IAAI,GAAG;AAC5C,aAAS,OAAO,SAAS,MAAM,aAAoB,SAAS,UAAU,EAAC,SAAS,SAAS,QAAO,IAAI,MAAS;AAAA,EAC/G;AACA,SAAO;AACT;",
|
|
4
|
+
"sourcesContent": ["import {ActionExpression, FunctionUtils, ReflectUtils} from '@dooboostore/core';\nimport {getAddEventListenerMetadata} from './addEventListener';\nimport {findAllLifecycleMetadata, findAllOnConnectedAfterMetadata, findAllOnConnectedBeforeMetadata, findAllOnConnectedMetadata, ON_AFTER_ADOPTED_METADATA_KEY, ON_AFTER_DISCONNECTED_METADATA_KEY, ON_BEFORE_ADOPTED_METADATA_KEY, ON_BEFORE_DISCONNECTED_METADATA_KEY, ON_CONNECTED_COMPLETED_METADATA_KEY, ON_INITIALIZE_METADATA_KEY} from './lifecycles';\nimport {getEmitCustomEventMetadataList} from './emitCustomEvent';\nimport {convertAttributeValue, findAllAttributeChangedMetadata} from './changedAttributeThis';\nimport {findAllAttributeApplyMetadata, findAllAttributeMetadata, getAttributeValue} from './applyAttribute';\nimport {getQueryMetadata} from './query';\nimport {getQueryAllMetadata} from './queryAll';\nimport {SwcUtils} from '../utils/Utils';\nimport {DOM_EVENT_NAMES, HTML_TAG_ENTRIES} from '../config/config';\nimport {SituationTypeContainer, SituationTypeContainers} from '@dooboostore/simple-boot/decorators/inject/Inject';\nimport {HelperHostSet, HostSet, InjectSituationType} from '../types';\nimport {ConvertUtils, ElementApply, NodeSlot} from '@dooboostore/core-web';\nimport {isSSR} from \"../elements/SwcAppMixin\";\nimport {findAllApplySlotMetadata} from \"./applySlot\";\nimport {findAllStateMetadata} from \"./state\";\nimport {findAllPropertyMetadata} from \"./applyProperty\";\n\n// --- Core Interfaces & Types ---\n\nexport const ELEMENT_CONFIG_KEY = Symbol.for('simple-web-component:element-config');\n\nexport interface ElementConfig {\n extends?: string;\n observedAttributes?: string[];\n customElementRegistry?: any;\n window?: Window;\n useShadow?: boolean | 'open' | 'closed';\n}\n\nexport interface ElementMetadata extends Omit<ElementConfig, 'window'> {\n name: string;\n window: Window;\n}\n\nexport const getElementConfig = (target: any): ElementMetadata | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(ELEMENT_CONFIG_KEY, constructor);\n};\n\nexport const ensureInit = (inst: any) => { // HTMLElement\n if (!inst.__swc_initialized) {\n inst._swcId = inst?.getAttribute?.('swc-use-ssr') ?? 's' + Math.random().toString(36).substring(2, 11).toLowerCase();\n inst._emitHandlers = new Map();\n inst._boundListeners = [];\n inst.__swc_initialized = true;\n // const attributeList = findAllQ(inst);\n // attributeList.forEach(meta => {\n // delete (inst as any)[meta.propertyKey];\n // });\n\n const target = inst instanceof Function ? inst : inst.constructor;\n\n // \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557\n // \u2551 decorator \uD544\uB4DC\uC758 own property \uC0AD\uC81C \u2551\n // \u2551 \u2551\n // \u2551 \uC774\uC720: own property\uAC00 \uC788\uC73C\uBA74 prototype\uC758 getter/setter\uB294 \uC808\uB300 \uC548 \uD0C4\uB2E4 \u2551\n // \u2551 1. TypeScript\uB294 \uCD08\uAE30\uAC12\uC774 \uC788\uB294 \uD544\uB4DC\uB97C constructor\uC5D0\uC11C own property\uB85C \uC0DD\uC131 \u2551\n // \u2551 @attributeThis('id') myId: string = \"default\" \u2192 this.myId = \"default\" \u2551\n // \u2551 \u2551\n // \u2551 2. JavaScript\uC758 property lookup\uC740 own property\uB97C \uBA3C\uC800 \uCC3E\uC74C \u2551\n // \u2551 - this.myId \uC811\uADFC \u2551\n // \u2551 - 1\uC21C\uC704: instance\uC758 own property \uC788\uB098? \u2192 \uC788\uC73C\uBA74 \uADF8\uAC83 \uBC18\uD658 \u2551\n // \u2551 - 2\uC21C\uC704: prototype\uC758 getter \uC788\uB098? \u2192 \uC788\uC73C\uBA74 \uD638\uCD9C \u2551\n // \u2551 \u2551\n // \u2551 3. own property\uAC00 \uC788\uC73C\uBA74 prototype\uC758 getter\uB294 \uC808\uB300 \uD638\uCD9C\uB418\uC9C0 \uC54A\uC74C \u2551\n // \u2551 \uB530\uB77C\uC11C getter\uC5D0\uC11C \uC815\uC758\uB41C DOM \uB3D9\uAE30\uD654 \uB85C\uC9C1\uC774 \uC791\uB3D9\uD558\uC9C0 \uC54A\uC74C \u2551\n // \u2551 \u2551\n // \u2551 4. own property\uB97C \uC0AD\uC81C\uD558\uBA74 JavaScript\uAC00 prototype\uC758 getter\uB97C \uCC3E\uAC8C \uB428 \u2551\n // \u2551 \u2192 getter \uD638\uCD9C\uB428 \u2192 DOM \uC18D\uC131 \uAC12 \uB3D9\uAE30\uD654\uB428 \u2551\n // \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D\n // \uD568\uC218\uB294 decorator\uC5D0\uC11C \uAC12\uC790\uCCB4\uB97C descriptor.value = function (...args: any[]) {...\n\n // @attribute \uD544\uB4DC\uC758 own property \uC0AD\uC81C \u2192 getter/setter \uC791\uB3D9\n // const attributeList = findAllAttributeMetadata(target);\n const attributeAllList = findAllAttributeMetadata(target).filter(it => it.type === 'property');\n if (attributeAllList) {\n attributeAllList.forEach(meta => {\n // const initUserData = (inst as any)[meta.propertyKey];\n delete (inst as any)[meta.propertyKey];\n // (inst as any)[meta.propertyKey] = initUserData;\n });\n }\n\n // @query \uD544\uB4DC\uC758 own property \uC0AD\uC81C \u2192 getter \uC791\uB3D9\n const queryList = getQueryMetadata(target);\n if (queryList) {\n queryList.forEach(meta => {\n delete (inst as any)[meta.propertyKey];\n });\n }\n\n // @queryAll \uD544\uB4DC\uC758 own property \uC0AD\uC81C \u2192 getter \uC791\uB3D9\n const queryAllList = getQueryAllMetadata(target);\n if (queryAllList) {\n queryAllList.forEach(meta => {\n delete (inst as any)[meta.propertyKey];\n });\n }\n // const slotAllList = findAllApplySlotMetadata(target);\n // if (slotAllList) {\n // slotAllList.filter(it => it.type === 'property').forEach(meta => {\n // delete (inst as any)[meta.propertyKey];\n // });\n // }\n\n\n const propertyAllList = findAllPropertyMetadata(target).filter(it => it.type === 'property');\n if (propertyAllList) {\n propertyAllList.forEach(meta => {\n delete (inst as any)[meta.propertyKey];\n });\n }\n\n const stateAllList = findAllStateMetadata(target);\n if (stateAllList) {\n stateAllList.forEach(meta => {\n const initUserData = (inst as any)[meta.propertyKey];\n delete (inst as any)[meta.propertyKey];\n (inst as any)[meta.propertyKey] = initUserData;\n });\n }\n\n // Call constructor script if present\n const hostSet = SwcUtils.getHostSet(inst);\n const appHosts = SwcUtils.findAllAppHostsIncludingSelfDirect(inst);\n inst._executeSwcScript?.('swc-on-constructor', hostSet);\n\n // Call @onInitialize lifecycle methods\n const cMethods = findAllLifecycleMetadata(inst, ON_INITIALIZE_METADATA_KEY);\n for (const m of cMethods) inst._invokeLifecycleMethod(m.propertyKey, hostSet);\n }\n};\n\n\n// \uD6D4 \uC774\uAC8C\uB9DE\uB098?? global\uB85C \uAD00\uB9AC\uD558\uB294\uAC8C..\uD6D4... \uC65C\uC774\uB807\uAC8C \uD588\uC744\uAE4C..\n// --- Global Event Handling ---\nconst globalDelegatedRoots = new WeakSet<Node>();\n// \uC5EC\uAE30\uC5D0\uC11C \uC911\uBCF5 \uD638\uCD9C\uC548\uB418\uAC8C \uC798\uB9C9\uC544\uC900\uB2E4 ..\nconst handleGlobalSwcEvent = async (event: Event) => {\n if ((event as any).__swc_handled) return;\n const path = event.composedPath();\n const type = event.type;\n const attrName = `swc-on-${type}`;\n\n for (const node of path) {\n if (!(node instanceof HTMLElement)) continue;\n const script = node.getAttribute?.(attrName);\n if (script && !getElementConfig(node)) {\n const host: any = SwcUtils.findNearestSwcHostIncludingSelf(node);\n if (host && host.isConnected && typeof host.__swc_executeAttributeEvent === 'function') {\n await host.__swc_executeAttributeEvent(node, attrName, script, event);\n (event as any).__swc_handled = true;\n break;\n }\n }\n }\n};\n\nfunction buildEnv(configWindow: Window) {\n const win: Window = configWindow;\n const doc: Document = win?.document;\n const builtInTagMap = new Map<any, string>();\n for (const [cls, tag] of HTML_TAG_ENTRIES) {\n if ((win as any)?.[cls]) builtInTagMap.set((win as any)[cls], tag);\n }\n const domHelpers = SwcUtils.getHelperSet(win);\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\nconst setupPrototype = (proto: any, win: Window) => {\n if (proto.__swc_proto_setup) return;\n proto.__swc_proto_setup = true;\n\n\n // proto.createSlotString = function (id: string) {\n // return NodeSlot.slot(`${this._swcId}-${id}`);\n // }\n // proto.createEaHtml = function (id: string, script: string) {\n // return ElementApply.html(id, script);\n // }\n // proto.createEaText = function (id: string, script: string) {\n // return ElementApply.text(id, script);\n // }\n // proto.createEaAttribute = function (id: string, name: string, script: string) {\n // return ElementApply.attribute(id, name, script);\n // }\n // proto.createEaEvent = function (id: string, name: string, script: string) {\n // return ElementApply.event(id, name, script);\n // }\n // proto.createEaProperty = function (id: string, name: string, script: string) {\n // return ElementApply.property(id, name, script);\n // }\n\n // swc-id-asdasdasdasd-click=\" :value=\"\" {: value fsdfsdafsad :} {html: aaa :} {text: asdas :}\n\n proto._executeSwcScript = function (attrName: string, hostSet: HostSet, extraArgs: Record<string, any> = {}) {\n ensureInit(this);\n const script = this.getAttribute(attrName);\n if (script) {\n try {\n const conf = getElementConfig(this);\n const currentWin = (this as any)._resolveWindow(conf);\n const helpers = SwcUtils.getHelperSet(currentWin);\n const args = {...hostSet, ...helpers, ...extraArgs, $el: this, $root: this.getRootNode()};\n FunctionUtils.execute({script, context: this, args});\n } catch (e) {\n console.error(`[SWC] Failed to execute ${attrName}:`, e);\n }\n }\n };\n\n proto._resolveWindow = function (localConfig?: ElementConfig): Window {\n ensureInit(this);\n if (localConfig?.window) return localConfig.window;\n const ancestors = SwcUtils.findAllSwcHostsIncludingSelf(this as any);\n for (let i = ancestors.length - 1; i >= 0; i--) {\n const aConf = getElementConfig(ancestors[i]);\n if (aConf?.window) return aConf.window;\n }\n return getElementConfig(this).window ?? ((typeof window !== 'undefined' ? window : undefined) as Window);\n };\n\n proto._invokeLifecycleMethod = function (methodName: string | symbol, hostSet?: HostSet, extraArgs: any[] = []) {\n ensureInit(this);\n if (typeof (this as any)[methodName] !== 'function') return;\n const useHostSet = hostSet ?? SwcUtils.getHelperAndHostSet(win, this);\n const app = useHostSet?.$appHost?.simpleApplication;\n // console.log('---->hh',app, this, methodName);\n if (app) {\n const otherStorage = new Map<any, any>();\n const situations = new SituationTypeContainers([new SituationTypeContainer({situationType: InjectSituationType.HOST_SET, data: useHostSet}), new SituationTypeContainer({situationType: InjectSituationType.APP_HOST, data: useHostSet.$appHost}), new SituationTypeContainer({situationType: InjectSituationType.APP_HOSTS, data: useHostSet.$appHosts}), new SituationTypeContainer({\n situationType: InjectSituationType.HOST,\n data: useHostSet.$host\n }), new SituationTypeContainer({situationType: InjectSituationType.HOSTS, data: useHostSet.$hosts}), new SituationTypeContainer({situationType: InjectSituationType.FIRST_HOST, data: useHostSet.$firstHost}), new SituationTypeContainer({situationType: InjectSituationType.LAST_HOST, data: useHostSet.$lastHost}), new SituationTypeContainer({\n situationType: InjectSituationType.FIRST_APP_HOST,\n data: useHostSet.$firstAppHost\n }), new SituationTypeContainer({situationType: InjectSituationType.LAST_APP_HOST, data: useHostSet.$lastAppHost})]);\n otherStorage.set(SituationTypeContainers, situations);\n\n return app.simstanceManager.executeBindParameterSim(\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 proto._bindAttributeEvent = function (el: HTMLElement, attrName: string, script: string, eventName?: string) {\n ensureInit(this);\n if (!eventName) {\n if (!attrName.startsWith('swc-on-')) return;\n eventName = attrName.substring(7);\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 = async (event: any) => {\n const hostSet = SwcUtils.getHostSet(el);\n const conf = getElementConfig(this);\n const currentWin = (this as any)._resolveWindow(conf);\n const helpers = SwcUtils.getHelperSet(currentWin);\n const args = {\n event,\n $data: (event as CustomEvent).detail,\n ...hostSet,\n ...helpers,\n $el: el,\n $root: this.getRootNode()\n };\n await FunctionUtils.execute({script, context: el, args});\n };\n\n el.addEventListener(eventName, handler);\n handlers.set(attrName, handler);\n };\n\n proto.__swc_executeAttributeEvent = async function (el: HTMLElement, attrName: string, script: string, event: Event) {\n ensureInit(this);\n\n const hostSet = SwcUtils.getHostSet(el);\n const conf = getElementConfig(this);\n const currentWin = (this as any)._resolveWindow(conf);\n const currentHelpers = SwcUtils.getHelperSet(currentWin);\n const detail = (event as CustomEvent).detail;\n const args = {\n event,\n $event: event,\n $data: detail,\n $detail: detail,\n ...hostSet,\n ...currentHelpers,\n $el: el,\n $root: this.getRootNode()\n };\n await FunctionUtils.execute({script, context: el, args});\n };\n};\n\nexport const elementDefine =\n (name: string, config: Partial<ElementConfig> = {}): ClassDecorator =>\n (constructor: any) => {\n const {win, doc, builtInTagMap: BUILT_IN_TAG_MAP, domHelpers: SWC_DOM_HELPERS} = buildEnv(config.window);\n const metadata: ElementMetadata = {...config, name, window: win};\n\n if (!metadata.window) {\n throw new Error('window is required');\n }\n\n let extendsTagName = metadata.extends;\n if (!extendsTagName) {\n let proto = constructor;\n const BaseHTMLElement = (win as any).HTMLElement;\n while (proto && proto !== BaseHTMLElement && proto !== Function.prototype) {\n extendsTagName = BUILT_IN_TAG_MAP.get(proto);\n if (extendsTagName) break;\n proto = Object.getPrototypeOf(proto);\n }\n metadata.extends = extendsTagName;\n }\n\n const emitCustomEventList = getEmitCustomEventMetadataList(constructor) || [];\n const emitHostCustomEventList = emitCustomEventList.filter(meta => meta.selector === '$this' || meta.selector === '');\n const addEventListenerList = getAddEventListenerMetadata(constructor) || [];\n const attrChangeMap = findAllAttributeChangedMetadata(constructor);\n const attributeList = findAllAttributeMetadata(constructor);\n const applyAttributeMap = findAllAttributeApplyMetadata(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 attributeApplyNames = Array.from(applyAttributeMap.values())\n .map(it => it.targetAttributeName)\n .filter(Boolean) as string[];\n const hostAttributes = attributeList.filter(it => it.selector === '$this').map(it => it.propertyKey || String(it.propertyKey));\n // Get original static observedAttributes before they're overwritten by Object.defineProperty\n const originalStaticObservedAttributes = (constructor.observedAttributes ?? []) as string[];\n const mergedObservedAttributes = [...new Set([...(metadata.observedAttributes ?? []), ...originalStaticObservedAttributes, ...attrChangeMap.keys(), ...attributeApplyNames, ...hostAttributes, ...emitHostCustomEventList.map(it => (it.options as any).attributeName).filter(Boolean), ...swcLifecycleAttributes, ...swcOnEvents])];\n // const connectedInnerHtmlList = getOnConnectedInnerHtmlMetadata(constructor) || [];\n\n const proto = constructor.prototype;\n setupPrototype(proto, win);\n\n // \uAC12\uC744 \uAE30\uB300\uD558\uC9C0\uC54A\uB294\uB2E4.\n let helperHostSet: HelperHostSet | null = null;\n const originalConnected = proto.connectedCallback;\n proto.connectedCallback = async function () {\n ensureInit(this);\n // connected \uB410\uC744\uC2DC \uCD5C\uC2E0\uD654\n helperHostSet = SwcUtils.getHelperAndHostSet(win, this as any);\n const appHost = helperHostSet.$appHost;\n const useSsr = isSSR(this);\n // console.log('isSsr', useSsr, this);\n // console.log('----helperHostSet--->', this, helperHostSet, useSsr)\n // let connectedApp: SwcAppInterface |undefined;\n try {\n if (appHost && typeof (appHost as any)._connected === 'function') {\n await (appHost as any)._connected(this);\n } else if (appHost && typeof (appHost as any)) {\n (appHost as any)._connected_safari_and_standby ??= [];\n (appHost as any)._connected_safari_and_standby.push(this);\n }\n\n // const hostSet = SwcUtils.getHostSet(this as any);\n const conf = getElementConfig(this);\n const currentWin = (this as any)._resolveWindow(conf);\n\n const bMethods = findAllOnConnectedBeforeMetadata(this).filter(it => useSsr ? !it.options.ssrFirst : true);\n // console.log('beforeConnected', bMethods)\n for (const m of bMethods) await (this as any)._invokeLifecycleMethod(m.propertyKey, helperHostSet);\n (this as any)._executeSwcScript('swc-on-before-connected', helperHostSet);\n\n // console.log('vvvvvvvvvvvvvvvu-seSsr-vvvvvvvvvv>', useSsr, this.tagName, this.getAttribute('seq'))\n // // ssr \uCC98\uB9AC\uB77C\uC11C \uC774\uBBF8 \uB0B4\uB824\uC900\uAC70\uADF8\uB300\uB85C \uC0C1\uC694\uD558\uBA74\uB41C\uB2E4 \uB530\uB77C\uC11C \uD638\uCD9C\uC548\uD55C\uB2E4\n const targetConnectedList = findAllOnConnectedMetadata(constructor).filter(it => useSsr ? !it.options.ssrFirst : true);\n const shadowMode = conf?.useShadow || targetConnectedList.find(it => it.options.useShadow)?.options.useShadow;\n // console.log('--------->', this.tagName, shadowMode && !this.shadowRoot)\n if (shadowMode && !this.shadowRoot) {\n const mode = shadowMode === true ? 'open' : shadowMode;\n console.log('tagName=', this.tagName, 'mode', mode, this.shadowRoot);\n // if (this.tagName!=='INDEX-ROUTER') {\n this.attachShadow({mode: mode as ShadowRootMode});\n // }\n }\n\n const stateContext: any = {...helperHostSet};\n findAllStateMetadata(this).forEach(it => {\n stateContext[it.name] = this[it.propertyKey]\n })\n\n const shadowChildren: Node[] = [];\n const lightChildren: Node[] = [];\n\n console.log('targetConnectList', this.tagName, targetConnectedList.length)\n if (targetConnectedList.length > 0) {\n // let sContent = '',\n // lContent = '';\n for (const meta of targetConnectedList) {\n // const res = (this as any)[meta.propertyKey]();\n let res = await (this as any)._invokeLifecycleMethod(meta.propertyKey, helperHostSet);\n // res = SwcUtils.projectProcessHtml(this, res);\n if (typeof res === 'string') {\n const htmlTemplateElement = doc.createElement('template');\n htmlTemplateElement.innerHTML = res;//SwcUtils.projectProcessHtml(this._swcId, res, doc);\n res = htmlTemplateElement.content;\n }\n\n if (res) {\n const nodes = Array.isArray(res) ? res : [res];\n if (meta.options.useShadow || conf?.useShadow) {\n shadowChildren.push(...nodes);\n }else {\n lightChildren.push(...nodes);\n }\n }\n }\n try {\n if (this.shadowRoot) {\n const applyShadowChildren = SwcUtils.projectProcessHtml(this._swcId, shadowChildren, doc);\n this.shadowRoot.replaceChildren(...applyShadowChildren)\n }\n if (lightChildren.length) {\n const applyLightChildren = SwcUtils.projectProcessHtml(this._swcId, lightChildren, doc);\n this.replaceChildren(...applyLightChildren)\n }\n\n } catch (e) {\n console.error('[ElementDefine] innerHTML setting error:', e);\n }\n new ElementApply(this, {id: this._swcId}).apply({context: stateContext, bind: this});\n } else {\n new ElementApply(this, {id: this._swcId}).apply({exclude: {html: true, text: true, attribute: true}, context: stateContext, bind: this});\n }\n\n // global delegate event\n const root = this.getRootNode()\n if (!globalDelegatedRoots.has(root)) {\n DOM_EVENT_NAMES.forEach(type => {\n root.addEventListener(type, handleGlobalSwcEvent);\n });\n globalDelegatedRoots.add(root);\n }\n\n\n // Separate delegate and non-delegate listeners\n const delegateListeners: typeof addEventListenerList = [];\n const nonDelegateListeners: typeof addEventListenerList = [];\n\n addEventListenerList.forEach(meta => {\n if (meta.options.delegate && meta.selector !== '$window' && meta.selector !== '$document' && meta.selector !== '$host' && meta.selector !== '$appHost' && meta.selector !== '$firstHost' && meta.selector !== '$lastHost' && meta.selector !== '$firstAppHost' && meta.selector !== '$lastAppHost' && meta.selector !== '$hosts' && meta.selector !== '$appHosts' && meta.selector !== '$this' && meta.selector !== '') {\n delegateListeners.push(meta);\n } else {\n nonDelegateListeners.push(meta);\n }\n });\n\n const delegatesByTypeAndRoot = new Map<string, any[]>();\n delegateListeners.forEach(meta => {\n const r = meta.options.root || 'auto';\n const rootKey = `${meta.type}:${r}`;\n if (!delegatesByTypeAndRoot.has(rootKey)) {\n delegatesByTypeAndRoot.set(rootKey, []);\n }\n delegatesByTypeAndRoot.get(rootKey)!.push(meta);\n });\n\n delegatesByTypeAndRoot.forEach((metaList, typeRootKey) => {\n const [type, rStr] = typeRootKey.split(':');\n const r = rStr === 'auto' ? 'auto' : rStr;\n const opts = {capture: metaList[0].options.capture, once: metaList[0].options.once, passive: metaList[0].options.passive};\n\n const bindRoots: (HTMLElement | ShadowRoot)[] = [];\n if (r === 'auto') bindRoots.push(this.shadowRoot || (this as any));\n else if (r === 'light') bindRoots.push(this as any);\n else if (r === 'shadow' && this.shadowRoot) bindRoots.push(this.shadowRoot);\n else if (r === 'all') {\n bindRoots.push(this as any);\n if (this.shadowRoot) bindRoots.push(this.shadowRoot);\n }\n\n bindRoots.forEach(br => {\n const sortedMetaList = [...metaList].sort((a, b) => {\n const aStop = a.options.stopPropagation ? 1 : 0;\n const bStop = b.options.stopPropagation ? 1 : 0;\n return bStop - aStop;\n });\n\n const unifiedHandler = async (event: Event) => {\n for (const meta of sortedMetaList) {\n const {selector, options} = meta;\n const matchedEl = (event.target as HTMLElement).closest(selector);\n if (matchedEl && (br as any).contains(matchedEl)) {\n // Apply filter if specified\n if (options.filter) {\n const helper = SwcUtils.getHelperAndHostSet(currentWin, matchedEl);\n if (!options.filter(event, helper)) {\n continue; // Skip this listener if filter returns false\n }\n }\n if (options.stopPropagation) event.stopPropagation();\n if (options.stopImmediatePropagation) event.stopImmediatePropagation();\n if (options.preventDefault) event.preventDefault();\n const currentHostSet = SwcUtils.getHostSet(this as any);\n const args = {event, ...currentHostSet, $el: matchedEl, $root: br};\n await (this as any)[meta.propertyKey](event, {...currentHostSet, $matchedElement: matchedEl}, args);\n if ((event as any).cancelBubble) break;\n }\n }\n };\n br.addEventListener(type, unifiedHandler, opts);\n (this as any)._boundListeners.push({target: br, type, handler: unifiedHandler, options: opts});\n });\n });\n\n nonDelegateListeners.forEach(meta => {\n const {selector, type, options} = meta;\n const opts = {capture: options.capture, once: options.once, passive: options.passive};\n const bindTargets: EventTarget[] = [];\n const r = options.root || 'auto';\n const applyRootOption = (target: any) => {\n if (!target) return;\n if (r === 'auto') {\n bindTargets.push(target.shadowRoot || target);\n } else {\n if (r === 'light' || r === 'all') bindTargets.push(target);\n if ((r === 'shadow' || r === 'all') && target.shadowRoot) bindTargets.push(target.shadowRoot);\n }\n };\n\n if (selector === '$window') bindTargets.push(currentWin);\n else if (selector === '$document') bindTargets.push(currentWin.document);\n else if (selector === '$host') applyRootOption(helperHostSet.$host);\n else if (selector === '$parentHost') applyRootOption(helperHostSet.$parentHost);\n else if (selector === '$appHost') applyRootOption(helperHostSet.$appHost);\n else if (selector === '$firstHost') applyRootOption(helperHostSet.$firstHost);\n else if (selector === '$lastHost') applyRootOption(helperHostSet.$lastHost);\n else if (selector === '$firstAppHost') applyRootOption(helperHostSet.$firstAppHost);\n else if (selector === '$lastAppHost') applyRootOption(helperHostSet.$lastAppHost);\n else if (selector === '$hosts') helperHostSet.$hosts.forEach(applyRootOption);\n else if (selector === '$appHosts') helperHostSet.$appHosts.forEach(applyRootOption);\n else if (selector === '$this' || !selector) applyRootOption(this);\n else {\n const searchRoots: (HTMLElement | ShadowRoot)[] = [];\n if (r === 'auto') searchRoots.push(this.shadowRoot || (this as any));\n else if (r === 'light') searchRoots.push(this as any);\n else if (r === 'shadow' && this.shadowRoot) searchRoots.push(this.shadowRoot);\n else if (r === 'all') {\n searchRoots.push(this as any);\n if (this.shadowRoot) searchRoots.push(this.shadowRoot);\n }\n\n searchRoots.forEach(sr => {\n sr.querySelectorAll(selector).forEach(el => bindTargets.push(el));\n });\n }\n\n bindTargets.forEach(t => {\n const handler = async (event: Event) => {\n // Apply filter if specified\n if (options.filter) {\n const helper = SwcUtils.getHelperAndHostSet(currentWin, t as HTMLElement);\n if (!options.filter(event, {currentThis: this, helper})) {\n return; // Skip if filter returns false\n }\n }\n if (options.stopPropagation) event.stopPropagation();\n if (options.stopImmediatePropagation) event.stopImmediatePropagation();\n if (options.preventDefault) event.preventDefault();\n const currentHostSet = SwcUtils.getHostSet(this as any);\n const args = {event, ...currentHostSet, $el: t, $root: t};\n await (this as any)[meta.propertyKey](event, {currentHostSet, $$matchedElement: event.currentTarget}, args);\n };\n t.addEventListener(type, handler, opts);\n (this as any)._boundListeners.push({target: t, type, handler, options: opts});\n });\n });\n\n if (originalConnected) await (originalConnected.apply(this));\n\n const aMethods = findAllOnConnectedAfterMetadata(this).filter(it => {\n return useSsr ? !it.options.ssrFirst : true;\n });\n // console.log('afterConnected', this.tagName, aMethods, getOnConnectedAfterMetadata(this))\n for (const m of aMethods) await (this as any)._invokeLifecycleMethod(m.propertyKey, helperHostSet);\n (this as any)._executeSwcScript('swc-on-connected', helperHostSet);\n (this as any)._executeSwcScript('swc-on-after-connected', helperHostSet);\n (this as any).__swc_connected = true;\n\n // Trigger @changedAttributeThis with while: 'connected'\n for (let [name, metaList] of Array.from(attrChangeMap)) {\n for (const meta of metaList) {\n if (meta.options.while === 'connected') {\n const val = getAttributeValue(this, name, {type: meta.options.type});\n if (val !== null) {\n await ((this as any)[meta.propertyKey](val, null, name, helperHostSet));\n }\n }\n }\n }\n } finally {\n for (let m of findAllLifecycleMetadata(this, ON_CONNECTED_COMPLETED_METADATA_KEY)) {\n await (this as any)._invokeLifecycleMethod(m.propertyKey, helperHostSet);\n }\n if (appHost && typeof (appHost as any)._connectedDone === 'function') {\n await (appHost as any)._connectedDone(this);\n }\n }\n };\n\n const originalDisconnected = proto.disconnectedCallback;\n proto.disconnectedCallback = function () {\n // const helperHostSet = SwcUtils.getHelperAndHostSet(win, this as any);\n // Remove from appHost LAST when disconnected\n // console.log('disconnnnnnnnnnnnnnnnnnn', helperHostSet, this)\n const appHost = helperHostSet.$appHost;\n if (appHost && typeof (appHost as any)._disconnected === 'function') {\n (appHost as any)._disconnected(this);\n }\n\n (this as any)._executeSwcScript('swc-on-before-disconnected', helperHostSet);\n const bMethods = findAllLifecycleMetadata(this, ON_BEFORE_DISCONNECTED_METADATA_KEY);\n for (const m of bMethods) (this as any)._invokeLifecycleMethod(m.propertyKey, helperHostSet);\n\n if ((this as any)._boundListeners) {\n (this as any)._boundListeners.forEach((l: any) => l.target.removeEventListener(l.type, l.handler, l.options));\n (this as any)._boundListeners = [];\n }\n\n new ElementApply(this, {id: this._swcId}).removeAllEventListener();\n\n // globalDelegatedRoots remove\n // const roots = [this, this.getRootNode()];\n // if (this.shadowRoot) {\n // roots.push(this.shadowRoot);\n // }\n // roots.forEach(root => {\n // DOM_EVENT_NAMES.forEach(type => {\n // root.removeEventListener(type, handleGlobalSwcEvent);\n // });\n // }\n // )\n\n if (originalDisconnected) originalDisconnected.apply(this);\n\n const aMethods = findAllLifecycleMetadata(this, ON_AFTER_DISCONNECTED_METADATA_KEY);\n for (const m of aMethods) (this as any)._invokeLifecycleMethod(m.propertyKey, helperHostSet);\n (this as any)._executeSwcScript('swc-on-disconnected', helperHostSet);\n (this as any)._executeSwcScript('swc-on-after-disconnected', helperHostSet);\n (this as any).__swc_connected = false;\n };\n\n const originalAdopted = proto.adoptedCallback;\n proto.adoptedCallback = function () {\n const hostSet = SwcUtils.getHostSet(this as any);\n (this as any)._executeSwcScript('swc-on-before-adopted', hostSet);\n const bMethods = findAllLifecycleMetadata(this, ON_BEFORE_ADOPTED_METADATA_KEY);\n for (const m of bMethods) (this as any)._invokeLifecycleMethod(m.propertyKey, hostSet);\n\n if (originalAdopted) originalAdopted.apply(this);\n\n const aMethods = findAllLifecycleMetadata(this, ON_AFTER_ADOPTED_METADATA_KEY);\n for (const m of aMethods) (this as any)._invokeLifecycleMethod(m.propertyKey, hostSet);\n (this as any)._executeSwcScript('swc-on-adopted', hostSet);\n (this as any)._executeSwcScript('swc-on-after-adopted', hostSet);\n };\n\n const originalAttributeChanged = proto.attributeChangedCallback;\n proto.attributeChangedCallback = function (name: string, old: string | null, newVal: string | null) {\n if (originalAttributeChanged) originalAttributeChanged.apply(this, [name, old, newVal]);\n\n const hSet = SwcUtils.getHostSet(this as any);\n\n // Process expression directive before passing to handlers\n let processedVal: any = newVal;\n if (newVal !== null) {\n const ae = new ActionExpression(newVal);\n const expr = ae.getFirstExpression('callReturn');\n if (expr) {\n const win = (this as any)._resolveWindow?.() || ((typeof window !== 'undefined' ? window : undefined) as any);\n const helperAndHostSet = SwcUtils.getHelperAndHostSet(win, this as any);\n const script = ConvertUtils.decodeHtmlEntity(expr.script, win.document);\n try {\n const result = FunctionUtils.executeReturn({\n script: script,\n context: this,\n args: helperAndHostSet\n });\n // Pass the result object directly without serialization\n processedVal = result;\n } catch (e) {\n console.error(`[SWC] Failed to execute directive {{= ${expr.script} }} on attribute ${name}: ${helperAndHostSet}`, e);\n processedVal = newVal;\n }\n }\n }\n\n if (name.startsWith('swc-on-') && !swcLifecycleAttributes.includes(name)) {\n if (newVal !== null) {\n const eventName = name.substring(7);\n (this as any)._bindAttributeEvent(this as any, name, newVal, eventName);\n }\n }\n\n const hostCustomEventMeta = emitHostCustomEventList.find(it => (it.options as any).attributeName === name);\n if (hostCustomEventMeta && newVal !== null) {\n (this as any)._bindAttributeEvent(this as any, name, newVal, hostCustomEventMeta.type);\n }\n\n const metaList = attrChangeMap.get(name);\n if (metaList && Array.isArray(metaList)) {\n for (const meta of metaList) {\n if (meta.options.while === 'connected' && !(this as any).__swc_connected) {\n continue;\n }\n const convertedVal = convertAttributeValue(processedVal, meta.options.type);\n (this as any)[meta.propertyKey](convertedVal, old, name, hSet);\n }\n }\n };\n\n Object.defineProperty(constructor, 'observedAttributes', {\n get: () => mergedObservedAttributes,\n configurable: true\n });\n\n ReflectUtils.defineMetadata(ELEMENT_CONFIG_KEY, metadata, constructor);\n const registry = metadata.customElementRegistry || (win as any)?.customElements;\n if (registry && !registry.get(metadata.name)) {\n registry.define(metadata.name, constructor as any, metadata.extends ? {extends: metadata.extends} : undefined);\n }\n return constructor;\n };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA4D;AAC5D,8BAA0C;AAC1C,wBAA+U;AAC/U,6BAA6C;AAC7C,kCAAqE;AACrE,4BAAyF;AACzF,mBAA+B;AAC/B,sBAAkC;AAClC,mBAAuB;AACvB,oBAAgD;AAChD,oBAA8D;AAC9D,mBAA0D;AAC1D,sBAAmD;AACnD,yBAAoB;AAEpB,mBAAmC;AACnC,2BAAsC;AAI/B,MAAM,qBAAqB,OAAO,IAAI,qCAAqC;AAe3E,MAAM,mBAAmB,CAAC,WAA6C;AAC5E,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,SAAO,yBAAa,YAAY,oBAAoB,WAAW;AACjE;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,KAAa,KAAK,WAAW,EAAE,cAAc,KAAKA,OAAM,IAAI;AAAA,MAC/D;AAAA,IACF;AAAA,EACF;AAEA,SAAO,eAAe,aAAa,sBAAsB;AAAA,IACvD,KAAK,MAAM;AAAA,IACX,cAAc;AAAA,EAChB,CAAC;AAED,2BAAa,eAAe,oBAAoB,UAAU,WAAW;AACrE,QAAM,WAAW,SAAS,yBAA0B,KAAa;AACjE,MAAI,YAAY,CAAC,SAAS,IAAI,SAAS,IAAI,GAAG;AAC5C,aAAS,OAAO,SAAS,MAAM,aAAoB,SAAS,UAAU,EAAC,SAAS,SAAS,QAAO,IAAI,MAAS;AAAA,EAC/G;AACA,SAAO;AACT;",
|
|
6
6
|
"names": ["proto", "name", "win"]
|
|
7
7
|
}
|
|
@@ -18,6 +18,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
18
18
|
var emitCustomEvent_exports = {};
|
|
19
19
|
__export(emitCustomEvent_exports, {
|
|
20
20
|
EMIT_CUSTOM_EVENT_METADATA_KEY: () => EMIT_CUSTOM_EVENT_METADATA_KEY,
|
|
21
|
+
emit: () => emit,
|
|
21
22
|
emitCustomEvent: () => emitCustomEvent,
|
|
22
23
|
emitCustomEventThis: () => emitCustomEventThis,
|
|
23
24
|
getEmitCustomEventMetadataList: () => getEmitCustomEventMetadataList
|
|
@@ -110,6 +111,7 @@ const getEmitCustomEventMetadataList = (target) => {
|
|
|
110
111
|
const constructor = target instanceof Function ? target : target.constructor;
|
|
111
112
|
return import_core.ReflectUtils.getMetadata(EMIT_CUSTOM_EVENT_METADATA_KEY, constructor);
|
|
112
113
|
};
|
|
114
|
+
const emit = emitCustomEvent;
|
|
113
115
|
function emitCustomEventThis(type, optionsOrAttributeaName) {
|
|
114
116
|
if (optionsOrAttributeaName && typeof optionsOrAttributeaName === "string") {
|
|
115
117
|
return emitCustomEventThis(type, { attributeName: optionsOrAttributeaName });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/decorators/emitCustomEvent.ts"],
|
|
4
|
-
"sourcesContent": ["import {ReflectUtils} from '@dooboostore/core';\nimport { SpecialSelector, SwcQueryOptions, HelperHostSet } from '../types';\nimport {ensureInit, getElementConfig} from './elementDefine';\nimport {SwcUtils} from '../utils/Utils';\n\nexport interface EmitCustomEventBaseOptions {\n bubbles?: boolean;\n composed?: boolean;\n cancelable?: boolean;\n filter?: (target: EventTarget, detail: any, meta: { currentThis: any, helper: HelperHostSet }) => boolean;\n}\n\ntype Options = (EmitCustomEventBaseOptions & SwcQueryOptions) | (EmitCustomEventBaseOptions & SwcQueryOptions & { attributeName?: string });\n\nexport interface EmitCustomEventMetadata {\n propertyKey: string | symbol;\n selector: string;\n type: string;\n options: Options;\n}\n\nexport const EMIT_CUSTOM_EVENT_METADATA_KEY = Symbol.for('simple-web-component:emit-custom-event');\n\nexport function emitCustomEvent(target: SpecialSelector, type: string, options?: Options): MethodDecorator;\nexport function emitCustomEvent(selector: string, type: string, options?: Options): MethodDecorator;\n/**\n * @emitCustomEvent decorator to dispatch custom events to a target.\n */\nexport function emitCustomEvent(selectorOrTarget: string, type: string, options: any = {}): MethodDecorator {\n return (targetObj: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = targetObj.constructor;\n\n const fullOptions: any = {...options, type};\n\n if (fullOptions.bubbles === undefined) fullOptions.bubbles = true;\n if (fullOptions.composed === undefined) fullOptions.composed = true;\n\n let list = ReflectUtils.getMetadata<EmitCustomEventMetadata[]>(EMIT_CUSTOM_EVENT_METADATA_KEY, constructor);\n if (!list) {\n list = [];\n ReflectUtils.defineMetadata(EMIT_CUSTOM_EVENT_METADATA_KEY, list, constructor);\n }\n list.push({propertyKey, selector: selectorOrTarget, type, options: fullOptions});\n\n const original = descriptor.value;\n descriptor.value = function (...args: any[]) {\n ensureInit(this);\n const res = original.apply(this, args);\n\n const handleResult = (detail: any) => {\n const event = new CustomEvent(type, {\n detail,\n bubbles: fullOptions.bubbles,\n composed: fullOptions.composed,\n cancelable: fullOptions.cancelable\n });\n\n const hostSet = SwcUtils.getHostSet(this as any);\n const conf = getElementConfig(this);\n const currentWin = (this as any)._resolveWindow?.(conf) || ((typeof window !== 'undefined' ? window : undefined) as Window);\n\n const eventTargets: EventTarget[] = [];\n if (selectorOrTarget === '$window') eventTargets.push(currentWin);\n else if (selectorOrTarget === '$document') eventTargets.push(currentWin.document);\n else if (selectorOrTarget === '$host') {\n if (hostSet.$host) eventTargets.push(hostSet.$host);\n } else if (selectorOrTarget === '$parentHost') {\n if (hostSet.$parentHost) eventTargets.push(hostSet.$parentHost);\n } else if (selectorOrTarget === '$appHost') {\n if (hostSet.$appHost) eventTargets.push(hostSet.$appHost);\n } else if (selectorOrTarget === '$firstHost') {\n if (hostSet.$firstHost) eventTargets.push(hostSet.$firstHost);\n } else if (selectorOrTarget === '$lastHost') {\n if (hostSet.$lastHost) eventTargets.push(hostSet.$lastHost);\n } else if (selectorOrTarget === '$firstAppHost') {\n if (hostSet.$firstAppHost) eventTargets.push(hostSet.$firstAppHost);\n } else if (selectorOrTarget === '$lastAppHost') {\n if (hostSet.$lastAppHost) eventTargets.push(hostSet.$lastAppHost);\n } else if (selectorOrTarget === '$hosts') {\n hostSet.$hosts.forEach(h => eventTargets.push(h));\n } else if (selectorOrTarget === '$appHosts') {\n hostSet.$appHosts.forEach(h => eventTargets.push(h));\n } else if (selectorOrTarget === '$this' || !selectorOrTarget) {\n eventTargets.push(this as any);\n } else {\n const r = fullOptions.root || 'auto';\n const searchRoots: (HTMLElement | ShadowRoot)[] = [];\n if (r === 'auto') searchRoots.push(this.shadowRoot || (this as any));\n else if (r === 'light') searchRoots.push(this as any);\n else if (r === 'shadow' && this.shadowRoot) searchRoots.push(this.shadowRoot);\n else if (r === 'all') {\n searchRoots.push(this as any);\n if (this.shadowRoot) searchRoots.push(this.shadowRoot);\n }\n\n searchRoots.forEach(sr => {\n sr.querySelectorAll(selectorOrTarget).forEach(el => eventTargets.push(el));\n });\n }\n\n eventTargets.forEach(t => {\n if (fullOptions.filter && !fullOptions.filter(t, detail, {currentThis: this, helper: hostSet})) {\n return;\n }\n t.dispatchEvent(event);\n });\n\n return detail;\n };\n\n if (res instanceof Promise) {\n return res.then(handleResult);\n } else {\n return handleResult(res);\n }\n };\n };\n}\n\nexport const getEmitCustomEventMetadataList = (target: any): EmitCustomEventMetadata[] | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(EMIT_CUSTOM_EVENT_METADATA_KEY, constructor);\n};\n\n/**\n * @emitCustomEventThis decorator - simplified version of @emitCustomEvent for $this selector\n */\nexport function emitCustomEventThis(type: string, options: EmitCustomEventBaseOptions & SwcQueryOptions & { attributeName?: string }): MethodDecorator ;\nexport function emitCustomEventThis(type: string, attributeName: string): MethodDecorator ;\nexport function emitCustomEventThis(type: string): MethodDecorator;\nexport function emitCustomEventThis(type: string, optionsOrAttributeaName?: string | (EmitCustomEventBaseOptions & SwcQueryOptions & { attributeName?: string })): MethodDecorator {\n if (optionsOrAttributeaName && typeof optionsOrAttributeaName === 'string') {\n return emitCustomEventThis(type, {attributeName: optionsOrAttributeaName});\n } else if (optionsOrAttributeaName && typeof optionsOrAttributeaName === 'object') {\n if (!optionsOrAttributeaName.attributeName) {\n optionsOrAttributeaName.attributeName = `on-emit-${type}`;\n }\n return emitCustomEvent('$this', type, optionsOrAttributeaName);\n } else {\n return emitCustomEvent('$this', type, {attributeName: `on-emit-${type}`});\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA2B;AAE3B,2BAA2C;AAC3C,mBAAuB;
|
|
4
|
+
"sourcesContent": ["import {ReflectUtils} from '@dooboostore/core';\nimport { SpecialSelector, SwcQueryOptions, HelperHostSet } from '../types';\nimport {ensureInit, getElementConfig} from './elementDefine';\nimport {SwcUtils} from '../utils/Utils';\n\nexport interface EmitCustomEventBaseOptions {\n bubbles?: boolean;\n composed?: boolean;\n cancelable?: boolean;\n filter?: (target: EventTarget, detail: any, meta: { currentThis: any, helper: HelperHostSet }) => boolean;\n /**\n * Custom key to extract value from return object.\n * If not provided, uses EMIT_CUSTOM_EVENT_METADATA_KEY by default.\n * Useful when multiple @emitCustomEvent decorators are on the same method.\n * \n * Example:\n * @emitCustomEvent('$appHost', 'event1', { valueKey: 'detail1' })\n * @emitCustomEvent('$appHost', 'event2', { valueKey: 'detail2' })\n * myMethod() {\n * return {\n * detail1: { type: 'event1', data: 'value1' },\n * detail2: { type: 'event2', data: 'value2' }\n * };\n * }\n */\n valueKey?: symbol | string;\n}\n\ntype Options = (EmitCustomEventBaseOptions & SwcQueryOptions) | (EmitCustomEventBaseOptions & SwcQueryOptions & { attributeName?: string });\n\nexport interface EmitCustomEventMetadata {\n propertyKey: string | symbol;\n selector: string;\n type: string;\n options: Options;\n}\n\nexport const EMIT_CUSTOM_EVENT_METADATA_KEY = Symbol.for('simple-web-component:emit-custom-event');\n\nexport function emitCustomEvent(target: SpecialSelector, type: string, options?: Options): MethodDecorator;\nexport function emitCustomEvent(selector: string, type: string, options?: Options): MethodDecorator;\n/**\n * @emitCustomEvent decorator to dispatch custom events to a target.\n */\nexport function emitCustomEvent(selectorOrTarget: string, type: string, options: any = {}): MethodDecorator {\n return (targetObj: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = targetObj.constructor;\n\n const fullOptions: any = {...options, type};\n\n if (fullOptions.bubbles === undefined) fullOptions.bubbles = true;\n if (fullOptions.composed === undefined) fullOptions.composed = true;\n\n let list = ReflectUtils.getMetadata<EmitCustomEventMetadata[]>(EMIT_CUSTOM_EVENT_METADATA_KEY, constructor);\n if (!list) {\n list = [];\n ReflectUtils.defineMetadata(EMIT_CUSTOM_EVENT_METADATA_KEY, list, constructor);\n }\n list.push({propertyKey, selector: selectorOrTarget, type, options: fullOptions});\n\n const original = descriptor.value;\n descriptor.value = function (...args: any[]) {\n ensureInit(this);\n const res = original.apply(this, args);\n\n const handleResult = (detail: any) => {\n const event = new CustomEvent(type, {\n detail,\n bubbles: fullOptions.bubbles,\n composed: fullOptions.composed,\n cancelable: fullOptions.cancelable\n });\n\n const hostSet = SwcUtils.getHostSet(this as any);\n const conf = getElementConfig(this);\n const currentWin = (this as any)._resolveWindow?.(conf) || ((typeof window !== 'undefined' ? window : undefined) as Window);\n\n const eventTargets: EventTarget[] = [];\n if (selectorOrTarget === '$window') eventTargets.push(currentWin);\n else if (selectorOrTarget === '$document') eventTargets.push(currentWin.document);\n else if (selectorOrTarget === '$host') {\n if (hostSet.$host) eventTargets.push(hostSet.$host);\n } else if (selectorOrTarget === '$parentHost') {\n if (hostSet.$parentHost) eventTargets.push(hostSet.$parentHost);\n } else if (selectorOrTarget === '$appHost') {\n if (hostSet.$appHost) eventTargets.push(hostSet.$appHost);\n } else if (selectorOrTarget === '$firstHost') {\n if (hostSet.$firstHost) eventTargets.push(hostSet.$firstHost);\n } else if (selectorOrTarget === '$lastHost') {\n if (hostSet.$lastHost) eventTargets.push(hostSet.$lastHost);\n } else if (selectorOrTarget === '$firstAppHost') {\n if (hostSet.$firstAppHost) eventTargets.push(hostSet.$firstAppHost);\n } else if (selectorOrTarget === '$lastAppHost') {\n if (hostSet.$lastAppHost) eventTargets.push(hostSet.$lastAppHost);\n } else if (selectorOrTarget === '$hosts') {\n hostSet.$hosts.forEach(h => eventTargets.push(h));\n } else if (selectorOrTarget === '$appHosts') {\n hostSet.$appHosts.forEach(h => eventTargets.push(h));\n } else if (selectorOrTarget === '$this' || !selectorOrTarget) {\n eventTargets.push(this as any);\n } else {\n const r = fullOptions.root || 'auto';\n const searchRoots: (HTMLElement | ShadowRoot)[] = [];\n if (r === 'auto') searchRoots.push(this.shadowRoot || (this as any));\n else if (r === 'light') searchRoots.push(this as any);\n else if (r === 'shadow' && this.shadowRoot) searchRoots.push(this.shadowRoot);\n else if (r === 'all') {\n searchRoots.push(this as any);\n if (this.shadowRoot) searchRoots.push(this.shadowRoot);\n }\n\n searchRoots.forEach(sr => {\n sr.querySelectorAll(selectorOrTarget).forEach(el => eventTargets.push(el));\n });\n }\n\n eventTargets.forEach(t => {\n if (fullOptions.filter && !fullOptions.filter(t, detail, {currentThis: this, helper: hostSet})) {\n return;\n }\n t.dispatchEvent(event);\n });\n\n return detail;\n };\n\n if (res instanceof Promise) {\n return res.then(handleResult);\n } else {\n return handleResult(res);\n }\n };\n };\n}\n\nexport const getEmitCustomEventMetadataList = (target: any): EmitCustomEventMetadata[] | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(EMIT_CUSTOM_EVENT_METADATA_KEY, constructor);\n};\n\n// --- Aliases: emit... ---\nexport const emit = emitCustomEvent;\n\n/**\n * @emitCustomEventThis decorator - simplified version of @emitCustomEvent for $this selector\n */\nexport function emitCustomEventThis(type: string, options: EmitCustomEventBaseOptions & SwcQueryOptions & { attributeName?: string }): MethodDecorator ;\nexport function emitCustomEventThis(type: string, attributeName: string): MethodDecorator ;\nexport function emitCustomEventThis(type: string): MethodDecorator;\nexport function emitCustomEventThis(type: string, optionsOrAttributeaName?: string | (EmitCustomEventBaseOptions & SwcQueryOptions & { attributeName?: string })): MethodDecorator {\n if (optionsOrAttributeaName && typeof optionsOrAttributeaName === 'string') {\n return emitCustomEventThis(type, {attributeName: optionsOrAttributeaName});\n } else if (optionsOrAttributeaName && typeof optionsOrAttributeaName === 'object') {\n if (!optionsOrAttributeaName.attributeName) {\n optionsOrAttributeaName.attributeName = `on-emit-${type}`;\n }\n return emitCustomEvent('$this', type, optionsOrAttributeaName);\n } else {\n return emitCustomEvent('$this', type, {attributeName: `on-emit-${type}`});\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA2B;AAE3B,2BAA2C;AAC3C,mB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