@dooboostore/simple-web-component 1.0.23 → 1.0.24

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.
Files changed (78) hide show
  1. package/README.md +238 -44
  2. package/dist/cjs/decorators/applyNode.js +129 -34
  3. package/dist/cjs/decorators/applyNode.js.map +2 -2
  4. package/dist/cjs/decorators/attribute.js +21 -2
  5. package/dist/cjs/decorators/attribute.js.map +2 -2
  6. package/dist/cjs/decorators/changedAttributeHost.js.map +2 -2
  7. package/dist/cjs/decorators/classList.js +60 -17
  8. package/dist/cjs/decorators/classList.js.map +2 -2
  9. package/dist/cjs/decorators/query.js +77 -2
  10. package/dist/cjs/decorators/query.js.map +2 -2
  11. package/dist/cjs/decorators/queryAll.js +77 -2
  12. package/dist/cjs/decorators/queryAll.js.map +2 -2
  13. package/dist/cjs/decorators/setAttribute.js +4 -4
  14. package/dist/cjs/decorators/setAttribute.js.map +2 -2
  15. package/dist/cjs/decorators/style.js +46 -15
  16. package/dist/cjs/decorators/style.js.map +2 -2
  17. package/dist/cjs/index.js +4 -4
  18. package/dist/cjs/index.js.map +2 -2
  19. package/dist/cjs/utils/Utils.js +140 -1
  20. package/dist/cjs/utils/Utils.js.map +2 -2
  21. package/dist/esm/decorators/applyNode.js +129 -34
  22. package/dist/esm/decorators/applyNode.js.map +2 -2
  23. package/dist/esm/decorators/attribute.js +21 -2
  24. package/dist/esm/decorators/attribute.js.map +2 -2
  25. package/dist/esm/decorators/changedAttributeHost.js.map +2 -2
  26. package/dist/esm/decorators/classList.js +60 -17
  27. package/dist/esm/decorators/classList.js.map +2 -2
  28. package/dist/esm/decorators/query.js +77 -2
  29. package/dist/esm/decorators/query.js.map +2 -2
  30. package/dist/esm/decorators/queryAll.js +77 -2
  31. package/dist/esm/decorators/queryAll.js.map +2 -2
  32. package/dist/esm/decorators/setAttribute.js +4 -4
  33. package/dist/esm/decorators/setAttribute.js.map +2 -2
  34. package/dist/esm/decorators/style.js +46 -15
  35. package/dist/esm/decorators/style.js.map +2 -2
  36. package/dist/esm/index.js +4 -4
  37. package/dist/esm/index.js.map +2 -2
  38. package/dist/esm/utils/Utils.js +140 -1
  39. package/dist/esm/utils/Utils.js.map +2 -2
  40. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +542 -155
  41. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
  42. package/dist/types/decorators/applyNode.d.ts +49 -27
  43. package/dist/types/decorators/applyNode.d.ts.map +1 -1
  44. package/dist/types/decorators/attribute.d.ts +11 -4
  45. package/dist/types/decorators/attribute.d.ts.map +1 -1
  46. package/dist/types/decorators/classList.d.ts +15 -5
  47. package/dist/types/decorators/classList.d.ts.map +1 -1
  48. package/dist/types/decorators/query.d.ts +68 -4
  49. package/dist/types/decorators/query.d.ts.map +1 -1
  50. package/dist/types/decorators/queryAll.d.ts +70 -1
  51. package/dist/types/decorators/queryAll.d.ts.map +1 -1
  52. package/dist/types/decorators/setAttribute.d.ts.map +1 -1
  53. package/dist/types/decorators/style.d.ts +17 -8
  54. package/dist/types/decorators/style.d.ts.map +1 -1
  55. package/dist/types/index.d.ts +1 -2
  56. package/dist/types/index.d.ts.map +1 -1
  57. package/dist/types/utils/Utils.d.ts +49 -0
  58. package/dist/types/utils/Utils.d.ts.map +1 -1
  59. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +542 -155
  60. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
  61. package/package.json +3 -3
  62. package/src/decorators/applyNode.ts +179 -60
  63. package/src/decorators/attribute.ts +43 -10
  64. package/src/decorators/changedAttributeHost.ts +1 -1
  65. package/src/decorators/classList.ts +79 -17
  66. package/src/decorators/query.ts +147 -5
  67. package/src/decorators/queryAll.ts +148 -2
  68. package/src/decorators/setAttribute.ts +6 -5
  69. package/src/decorators/style.ts +67 -22
  70. package/src/index.ts +6 -6
  71. package/src/utils/Utils.ts +144 -0
  72. package/dist/cjs/utils/TemplateUtils.js +0 -109
  73. package/dist/cjs/utils/TemplateUtils.js.map +0 -7
  74. package/dist/esm/utils/TemplateUtils.js +0 -90
  75. package/dist/esm/utils/TemplateUtils.js.map +0 -7
  76. package/dist/types/utils/TemplateUtils.d.ts +0 -59
  77. package/dist/types/utils/TemplateUtils.d.ts.map +0 -1
  78. package/src/utils/TemplateUtils.ts +0 -92
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/utils/Utils.ts"],
4
- "sourcesContent": ["import { SwcAppInterface, HostSet, HelperSet, HelperHostSet } from '../types';\nimport {getElementConfig} from \"../decorators\";\n\nexport const SWC_NOT_FOUND = Symbol('SWC_NOT_FOUND');\n\nexport namespace SwcUtils {\n export const getHelperSet = (win: Window): HelperSet => {\n const doc: Document = win.document;\n return {\n $d: doc,\n $w: win,\n $q: (sel: string, root?: Element | Document | ShadowRoot) => (root ?? doc).querySelector(sel),\n $qa: (sel: string, root?: Element | Document | ShadowRoot) => Array.from((root ?? doc).querySelectorAll(sel)) as HTMLElement[],\n $qi: (id: string, root?: Document | ShadowRoot) => (root ?? doc).getElementById(id) as HTMLElement\n } as const;\n };\n\n export const getHelperAndHostSet = (win: Window, el: HTMLElement): HelperHostSet => {\n const helperSet = getHelperSet(win);\n const hostSet = getHostSet(el);\n return {\n ...helperSet,\n ...hostSet\n };\n };\n\n export const getValueByPath = (obj: any, path: string, rootName: string) => {\n if (!obj || !path) return SWC_NOT_FOUND;\n\n const parts = path.split('.');\n let current = obj;\n\n for (const part of parts) {\n if (current === null || current === undefined) return SWC_NOT_FOUND;\n current = current[part];\n }\n return current;\n };\n\n /**\n * Finds the nearest logical SWC host for an element.\n * Checks __swc_host property first, then climbs the DOM tree.\n */\n export const findNearestSwcHost = (el: HTMLElement | Node): HTMLElement | undefined => {\n if ((el as any).__swc_host) return (el as any).__swc_host;\n\n let current: any = el.parentElement || (el.getRootNode?.() as any)?.host;\n const doc = el.ownerDocument;\n const win = doc?.defaultView || ((typeof window !== 'undefined' ? window : undefined) as any);\n while (current && current !== doc && current !== win) {\n if (current.__swc_host) return current.__swc_host;\n if (getElementConfig(current)) return current as HTMLElement;\n current = current.parentElement || (current.getRootNode?.() as any)?.host;\n }\n return undefined;\n };\n\n /**\n * Returns all SWC ancestors (excluding self) in [root, ..., parent] order.\n */\n export const findAllSwcHosts = (el: HTMLElement | Node): HTMLElement[] => {\n const hosts: HTMLElement[] = [];\n let current = findNearestSwcHost(el);\n while (current) {\n hosts.push(current);\n // To find the next ancestor, we must start searching from the PARENT of the found host\n current = findNearestSwcHost(current);\n }\n return hosts.reverse();\n };\n\n export const getHosts = (el: HTMLElement): HTMLElement[] => {\n const ancestors = findAllSwcHosts(el);\n if (getElementConfig(el)) return [...ancestors, el];\n return ancestors;\n };\n\n export const getHost = (el: HTMLElement): HTMLElement | undefined => {\n if (getElementConfig(el)) return el;\n return findNearestSwcHost(el);\n };\n\n export const getAppHosts = (el: HTMLElement): SwcAppInterface[] => {\n const hosts = getHosts(el);\n return hosts.filter(host => host.tagName.toLowerCase() === 'swc-app' || host.getAttribute('is')?.startsWith('swc-app-')) as SwcAppInterface[];\n };\n\n export const getAppHost = (el: HTMLElement): SwcAppInterface | undefined => {\n const appHosts = getAppHosts(el);\n const appHostsWithoutSelf = appHosts.filter(h => h !== el);\n return appHostsWithoutSelf.length > 0 ? appHostsWithoutSelf[appHostsWithoutSelf.length - 1] : undefined;\n };\n\n export const getHostSet = (el: HTMLElement): HostSet => {\n const isSwc = !!getElementConfig(el);\n const ancestors = findAllSwcHosts(el); // [root, ..., parent]\n\n let $host: HTMLElement;\n let $parentHost: HTMLElement | null;\n\n if (isSwc) {\n $host = el;\n $parentHost = ancestors.length > 0 ? ancestors[ancestors.length - 1] : null;\n } else {\n $host = ancestors.length > 0 ? ancestors[ancestors.length - 1] : el;\n $parentHost = ancestors.length > 1 ? ancestors[ancestors.length - 2] : null;\n }\n\n const $hosts = isSwc ? [...ancestors, el] : ancestors;\n const $firstHost = $hosts.length > 0 ? $hosts[0] : null;\n\n // Collect loop contexts\n const loopContext: Record<string, any> = {};\n let curr: any = el;\n const rootEl = el.ownerDocument?.documentElement;\n while (curr && curr !== rootEl) {\n if (curr.__swc_loop_context) {\n Object.assign(loopContext, curr.__swc_loop_context);\n }\n curr = curr.parentElement || (curr.getRootNode() as any).host;\n }\n\n const $appHosts = $hosts.filter(h => h.tagName.toLowerCase() === 'swc-app' || h.getAttribute('is')?.startsWith('swc-app-')) as SwcAppInterface[];\n const $appHost = $appHosts.length > 0 ? ($appHosts[$appHosts.length - 1] === el ? ($appHosts.length > 1 ? $appHosts[$appHosts.length - 2] : null) : $appHosts[$appHosts.length - 1]) : null;\n const $firstAppHost = $appHosts.length > 0 ? $appHosts[0] : null;\n\n return {\n $host,\n $parentHost,\n $hosts,\n $firstHost,\n $lastHost: $parentHost,\n $appHost,\n $appHosts,\n $firstAppHost,\n $lastAppHost: $appHost,\n ...loopContext\n } as any;\n };\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,wBAA+B;AAExB,MAAM,gBAAgB,OAAO,eAAe;AAE5C,IAAU;AAAA,CAAV,CAAUA,cAAV;AACE,EAAMA,UAAA,eAAe,CAAC,QAA2B;AACtD,UAAM,MAAgB,IAAI;AAC1B,WAAO;AAAA,MACL,IAAI;AAAA,MACJ,IAAI;AAAA,MACJ,IAAI,CAAC,KAAa,UAA4C,QAAQ,KAAK,cAAc,GAAG;AAAA,MAC5F,KAAK,CAAC,KAAa,SAA2C,MAAM,MAAM,QAAQ,KAAK,iBAAiB,GAAG,CAAC;AAAA,MAC5G,KAAK,CAAC,IAAY,UAAkC,QAAQ,KAAK,eAAe,EAAE;AAAA,IACpF;AAAA,EACF;AAEO,EAAMA,UAAA,sBAAsB,CAAC,KAAa,OAAmC;AAClF,UAAM,gBAAYA,UAAA,cAAa,GAAG;AAClC,UAAM,cAAUA,UAAA,YAAW,EAAE;AAC7B,WAAO;AAAA,M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AY,MAAM,aAAa,EAAE,aAAa,IAAI,GAAG,WAAW,UAAU,CAAC;AAC1H,UAAM,WAAW,UAAU,SAAS,IAAK,UAAU,UAAU,SAAS,CAAC,MAAM,KAAM,UAAU,SAAS,IAAI,UAAU,UAAU,SAAS,CAAC,IAAI,OAAQ,UAAU,UAAU,SAAS,CAAC,IAAK;AACvL,UAAM,gBAAgB,UAAU,SAAS,IAAI,UAAU,CAAC,IAAI;AAE5D,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,WAAW;AAAA,MACX;AAAA,MACA;AAAA,MACA;AAAA,MACA,cAAc;AAAA,MACd,GAAG;AAAA,IACL;AAAA,EACF;AAAA,GArIe;",
4
+ "sourcesContent": ["import { SwcAppInterface, HostSet, HelperSet, HelperHostSet } from '../types';\nimport {getElementConfig} from \"../decorators\";\n\nexport const SWC_NOT_FOUND = Symbol('SWC_NOT_FOUND');\n\n// DOM Creation Utilities\nexport const htmlFragment = (html: string, doc?: Document): DocumentFragment => {\n const d = doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const template = d.createElement('template');\n template.innerHTML = html.trim();\n return template.content;\n};\n\nexport const textNode = (text: string | any, doc?: Document): Text => {\n const d = doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n return d.createTextNode(text !== undefined && text !== null ? String(text) : '');\n};\n\nexport const commentNode = (comment: string | any, doc?: Document): Comment => {\n const d = doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n return d.createComment(comment !== undefined && comment !== null ? String(comment) : '');\n};\n\nexport const createElement = <T extends HTMLElement>(\n tagName: string,\n options?: { html?: string; attrs?: Record<string, any>; doc?: Document }\n): T => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement(tagName) as T;\n if (options?.html) el.innerHTML = options.html;\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\n// Element factory functions\nexport const htmlDivElement = (html: string, options?: { doc?: Document; attrs?: Record<string, any> }): HTMLDivElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('div') as HTMLDivElement;\n el.innerHTML = html.trim();\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlSpanElement = (html: string, options?: { doc?: Document; attrs?: Record<string, any> }): HTMLSpanElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('span') as HTMLSpanElement;\n el.innerHTML = html.trim();\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlButtonElement = (html: string, options?: { doc?: Document; attrs?: Record<string, any> }): HTMLButtonElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('button') as HTMLButtonElement;\n el.innerHTML = html.trim();\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlUlElement = (options?: { doc?: Document; attrs?: Record<string, any> }): HTMLUListElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('ul') as HTMLUListElement;\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlLiElement = (html: string, options?: { doc?: Document; attrs?: Record<string, any> }): HTMLLIElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('li') as HTMLLIElement;\n el.innerHTML = html.trim();\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlAElement = (html: string, options?: { href?: string; doc?: Document; attrs?: Record<string, any> }): HTMLAnchorElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('a') as HTMLAnchorElement;\n el.innerHTML = html.trim();\n if (options?.href) el.href = options.href;\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlPElement = (html: string, options?: { doc?: Document; attrs?: Record<string, any> }): HTMLParagraphElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('p') as HTMLParagraphElement;\n el.innerHTML = html.trim();\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlHeadingElement = (level: 1 | 2 | 3 | 4 | 5 | 6, html: string, options?: { doc?: Document; attrs?: Record<string, any> }): HTMLHeadingElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement(`h${level}`) as HTMLHeadingElement;\n el.innerHTML = html.trim();\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlSectionElement = (options?: { doc?: Document; attrs?: Record<string, any> }): HTMLElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('section');\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlArticleElement = (options?: { doc?: Document; attrs?: Record<string, any> }): HTMLElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('article');\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport namespace SwcUtils {\n export const getHelperSet = (win: Window): HelperSet => {\n const doc: Document = win.document;\n return {\n $d: doc,\n $w: win,\n $q: (sel: string, root?: Element | Document | ShadowRoot) => (root ?? doc).querySelector(sel),\n $qa: (sel: string, root?: Element | Document | ShadowRoot) => Array.from((root ?? doc).querySelectorAll(sel)) as HTMLElement[],\n $qi: (id: string, root?: Document | ShadowRoot) => (root ?? doc).getElementById(id) as HTMLElement\n } as const;\n };\n\n export const getHelperAndHostSet = (win: Window, el: HTMLElement): HelperHostSet => {\n const helperSet = getHelperSet(win);\n const hostSet = getHostSet(el);\n return {\n ...helperSet,\n ...hostSet\n };\n };\n\n export const getValueByPath = (obj: any, path: string, rootName: string) => {\n if (!obj || !path) return SWC_NOT_FOUND;\n\n const parts = path.split('.');\n let current = obj;\n\n for (const part of parts) {\n if (current === null || current === undefined) return SWC_NOT_FOUND;\n current = current[part];\n }\n return current;\n };\n\n /**\n * Finds the nearest logical SWC host for an element.\n * Checks __swc_host property first, then climbs the DOM tree.\n */\n export const findNearestSwcHost = (el: HTMLElement | Node): HTMLElement | undefined => {\n if ((el as any).__swc_host) return (el as any).__swc_host;\n\n let current: any = el.parentElement || (el.getRootNode?.() as any)?.host;\n const doc = el.ownerDocument;\n const win = doc?.defaultView || ((typeof window !== 'undefined' ? window : undefined) as any);\n while (current && current !== doc && current !== win) {\n if (current.__swc_host) return current.__swc_host;\n if (getElementConfig(current)) return current as HTMLElement;\n current = current.parentElement || (current.getRootNode?.() as any)?.host;\n }\n return undefined;\n };\n\n /**\n * Returns all SWC ancestors (excluding self) in [root, ..., parent] order.\n */\n export const findAllSwcHosts = (el: HTMLElement | Node): HTMLElement[] => {\n const hosts: HTMLElement[] = [];\n let current = findNearestSwcHost(el);\n while (current) {\n hosts.push(current);\n // To find the next ancestor, we must start searching from the PARENT of the found host\n current = findNearestSwcHost(current);\n }\n return hosts.reverse();\n };\n\n export const getHosts = (el: HTMLElement): HTMLElement[] => {\n const ancestors = findAllSwcHosts(el);\n if (getElementConfig(el)) return [...ancestors, el];\n return ancestors;\n };\n\n export const getHost = (el: HTMLElement): HTMLElement | undefined => {\n if (getElementConfig(el)) return el;\n return findNearestSwcHost(el);\n };\n\n export const getAppHosts = (el: HTMLElement): SwcAppInterface[] => {\n const hosts = getHosts(el);\n return hosts.filter(host => host.tagName.toLowerCase() === 'swc-app' || host.getAttribute('is')?.startsWith('swc-app-')) as SwcAppInterface[];\n };\n\n export const getAppHost = (el: HTMLElement): SwcAppInterface | undefined => {\n const appHosts = getAppHosts(el);\n const appHostsWithoutSelf = appHosts.filter(h => h !== el);\n return appHostsWithoutSelf.length > 0 ? appHostsWithoutSelf[appHostsWithoutSelf.length - 1] : undefined;\n };\n\n export const getHostSet = (el: HTMLElement): HostSet => {\n const isSwc = !!getElementConfig(el);\n const ancestors = findAllSwcHosts(el); // [root, ..., parent]\n\n let $host: HTMLElement;\n let $parentHost: HTMLElement | null;\n\n if (isSwc) {\n $host = el;\n $parentHost = ancestors.length > 0 ? ancestors[ancestors.length - 1] : null;\n } else {\n $host = ancestors.length > 0 ? ancestors[ancestors.length - 1] : el;\n $parentHost = ancestors.length > 1 ? ancestors[ancestors.length - 2] : null;\n }\n\n const $hosts = isSwc ? [...ancestors, el] : ancestors;\n const $firstHost = $hosts.length > 0 ? $hosts[0] : null;\n\n // Collect loop contexts\n const loopContext: Record<string, any> = {};\n let curr: any = el;\n const rootEl = el.ownerDocument?.documentElement;\n while (curr && curr !== rootEl) {\n if (curr.__swc_loop_context) {\n Object.assign(loopContext, curr.__swc_loop_context);\n }\n curr = curr.parentElement || (curr.getRootNode() as any).host;\n }\n\n const $appHosts = $hosts.filter(h => h.tagName.toLowerCase() === 'swc-app' || h.getAttribute('is')?.startsWith('swc-app-')) as SwcAppInterface[];\n const $appHost = $appHosts.length > 0 ? ($appHosts[$appHosts.length - 1] === el ? ($appHosts.length > 1 ? $appHosts[$appHosts.length - 2] : null) : $appHosts[$appHosts.length - 1]) : null;\n const $firstAppHost = $appHosts.length > 0 ? $appHosts[0] : null;\n\n return {\n $host,\n $parentHost,\n $hosts,\n $firstHost,\n $lastHost: $parentHost,\n $appHost,\n $appHosts,\n $firstAppHost,\n $lastAppHost: $appHost,\n ...loopContext\n } as any;\n };\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,wBAA+B;AAExB,MAAM,gBAAgB,OAAO,eAAe;AAG5C,MAAM,eAAe,CAAC,MAAc,QAAqC;AAC9E,QAAM,IAAI,QAAQ,OAAO,aAAa,cAAc,WAAW;AAC/D,MAAI,CAAC,EAAG,OAAM,IAAI,MAAM,2BAA2B;AACnD,QAAM,WAAW,EAAE,cAAc,UAAU;AAC3C,WAAS,YAAY,KAAK,KAAK;AAC/B,SAAO,SAAS;AAClB;AAEO,MAAM,WAAW,CAAC,MAAoB,QAAyB;AACpE,QAAM,IAAI,QAAQ,OAAO,aAAa,cAAc,WAAW;AAC/D,MAAI,CAAC,EAAG,OAAM,IAAI,MAAM,2BAA2B;AACnD,SAAO,EAAE,eAAe,SAAS,UAAa,SAAS,OAAO,OAAO,IAAI,IAAI,EAAE;AACjF;AAEO,MAAM,cAAc,CAAC,SAAuB,QAA4B;AAC7E,QAAM,IAAI,QAAQ,OAAO,aAAa,cAAc,WAAW;AAC/D,MAAI,CAAC,EAAG,OAAM,IAAI,MAAM,2BAA2B;AACnD,SAAO,EAAE,cAAc,YAAY,UAAa,YAAY,OAAO,OAAO,OAAO,IAAI,EAAE;AACzF;AAEO,MAAM,gBAAgB,CAC3B,SACA,YACM;AACN,QAAM,IAAI,SAAS,QAAQ,OAAO,aAAa,cAAc,WAAW;AACxE,MAAI,CAAC,EAAG,OAAM,I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;AAAA,MACA;AAAA,MACA;AAAA,MACA,cAAc;AAAA,MACd,GAAG;AAAA,IACL;AAAA,EACF;AAAA,GArIe;",
6
6
  "names": ["SwcUtils"]
7
7
  }
@@ -1,5 +1,6 @@
1
1
  import { ReflectUtils } from "@dooboostore/core";
2
2
  import { ensureInit, getElementConfig } from "./elementDefine.js";
3
+ import { SwcUtils } from "../utils/Utils.js";
3
4
  const APPLY_NODE_METADATA_KEY = Symbol("simple-web-component:apply-node");
4
5
  const normalizeNodes = (res, doc) => {
5
6
  const items = Array.isArray(res) ? res : [res];
@@ -28,15 +29,20 @@ function applyNode(selector, options = { position: "beforeEnd" }) {
28
29
  const currentDoc = currentWin.document;
29
30
  const pos = options.position || "beforeEnd";
30
31
  const r = options.root || "auto";
31
- const getTargetRoot = () => {
32
+ const applyRoot = (t) => {
33
+ if (!t || !(t instanceof HTMLElement))
34
+ return t;
35
+ if (r === "auto")
36
+ return t.shadowRoot || t;
32
37
  if (r === "shadow")
33
- return this.shadowRoot;
38
+ return t.shadowRoot;
34
39
  if (r === "light")
35
- return this;
40
+ return t;
36
41
  if (r === "all")
37
- return this.shadowRoot || this;
38
- return this.shadowRoot || this;
42
+ return t.shadowRoot || t;
43
+ return t;
39
44
  };
45
+ const hostSet = SwcUtils.getHostSet(this);
40
46
  if (pos === "remove") {
41
47
  if (res) {
42
48
  if (selector === ":host" || !selector) {
@@ -46,7 +52,7 @@ function applyNode(selector, options = { position: "beforeEnd" }) {
46
52
  this.remove();
47
53
  }
48
54
  } else {
49
- const targetRoot = getTargetRoot();
55
+ const targetRoot = applyRoot(this);
50
56
  if (targetRoot) {
51
57
  const targets = targetRoot.querySelectorAll(selector);
52
58
  targets.forEach((el) => el.remove());
@@ -55,14 +61,22 @@ function applyNode(selector, options = { position: "beforeEnd" }) {
55
61
  }
56
62
  } else {
57
63
  let targetEl = null;
58
- if (selector === ":host" || !selector) {
59
- if (r === "shadow") {
60
- targetEl = this.shadowRoot;
61
- } else {
62
- targetEl = this;
63
- }
64
+ if (selector === ":host") {
65
+ targetEl = applyRoot(this);
66
+ } else if (selector === ":parentHost") {
67
+ targetEl = applyRoot(hostSet.$parentHost);
68
+ } else if (selector === ":appHost") {
69
+ targetEl = applyRoot(hostSet.$appHost);
70
+ } else if (selector === ":firstHost") {
71
+ targetEl = applyRoot(hostSet.$firstHost);
72
+ } else if (selector === ":lastHost") {
73
+ targetEl = applyRoot(hostSet.$lastHost);
74
+ } else if (selector === ":firstAppHost") {
75
+ targetEl = applyRoot(hostSet.$firstHost);
76
+ } else if (selector === ":lastAppHost") {
77
+ targetEl = applyRoot(hostSet.$lastAppHost);
64
78
  } else {
65
- const targetRoot = getTargetRoot();
79
+ const targetRoot = applyRoot(this);
66
80
  targetEl = targetRoot ? targetRoot.querySelector(selector) : null;
67
81
  }
68
82
  if (targetEl) {
@@ -107,27 +121,108 @@ const findAllApplyNodeMetadata = (target) => {
107
121
  });
108
122
  return result;
109
123
  };
110
- function applyNodeHost(options = { position: "beforeEnd" }) {
111
- return applyNode(":host", options);
112
- }
113
- const applyBeforeBeginNode = (selector, options = {}) => applyNode(selector, { ...options, position: "beforeBegin" });
114
- const applyAfterBeginNode = (selector, options = {}) => applyNode(selector, { ...options, position: "afterBegin" });
115
- const applyBeforeEndNode = (selector, options = {}) => applyNode(selector, { ...options, position: "beforeEnd" });
116
- const applyAfterEndNode = (selector, options = {}) => applyNode(selector, { ...options, position: "afterEnd" });
117
- const applyReplaceNode = (selector, options = {}) => applyNode(selector, { ...options, position: "replace" });
118
- const applyReplaceChildrenNode = (selector, options = {}) => applyNode(selector, { ...options, position: "replaceChildren" });
119
- const applyInnerHtmlNode = (selector, options = {}) => applyNode(selector, { ...options, position: "innerHtml" });
120
- const applyInnerTextNode = (selector, options = {}) => applyNode(selector, { ...options, position: "innerText" });
121
- const applyRemoveNode = (selector, options = {}) => applyNode(selector, { ...options, position: "remove" });
122
- const applyBeforeBeginNodeHost = (options = {}) => applyNode(":host", { ...options, position: "beforeBegin" });
123
- const applyAfterBeginNodeHost = (options = {}) => applyNode(":host", { ...options, position: "afterBegin" });
124
- const applyBeforeEndNodeHost = (options = {}) => applyNode(":host", { ...options, position: "beforeEnd" });
125
- const applyAfterEndNodeHost = (options = {}) => applyNode(":host", { ...options, position: "afterEnd" });
126
- const applyReplaceNodeHost = (options = {}) => applyNode(":host", { ...options, position: "replace" });
127
- const applyReplaceChildrenNodeHost = (options = {}) => applyNode(":host", { ...options, position: "replaceChildren" });
128
- const applyInnerHtmlNodeHost = (options = {}) => applyNode(":host", { ...options, position: "innerHtml" });
129
- const applyInnerTextNodeHost = (options = {}) => applyNode(":host", { ...options, position: "innerText" });
130
- const applyRemoveNodeHost = (options = {}) => applyNode(":host", { ...options, position: "remove" });
124
+ function applyNodeHost(targetOrOptions, propertyKey, descriptor) {
125
+ console.log("vvvvv");
126
+ if (propertyKey !== void 0 && typeof propertyKey === "string" || typeof propertyKey === "symbol") {
127
+ return applyNode(":host", { position: "beforeEnd" })(targetOrOptions, propertyKey, descriptor);
128
+ }
129
+ if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
130
+ const options = targetOrOptions;
131
+ return applyNode(":host", { ...options, position: options.position || "beforeEnd" });
132
+ } else {
133
+ return applyNode(":host", { position: "beforeEnd" });
134
+ }
135
+ }
136
+ function applyBeforeBeginNode(selector, options) {
137
+ return applyNode(selector, { ...options, position: "beforeBegin" });
138
+ }
139
+ function applyAfterBeginNode(selector, options) {
140
+ return applyNode(selector, { ...options, position: "afterBegin" });
141
+ }
142
+ function applyBeforeEndNode(selector, options) {
143
+ return applyNode(selector, { ...options, position: "beforeEnd" });
144
+ }
145
+ function applyAfterEndNode(selector, options) {
146
+ return applyNode(selector, { ...options, position: "afterEnd" });
147
+ }
148
+ function applyReplaceNode(selector, options) {
149
+ return applyNode(selector, { ...options, position: "replace" });
150
+ }
151
+ function applyReplaceChildrenNode(selector, options) {
152
+ return applyNode(selector, { ...options, position: "replaceChildren" });
153
+ }
154
+ function applyInnerHtmlNode(selector, options) {
155
+ return applyNode(selector, { ...options, position: "innerHtml" });
156
+ }
157
+ function applyInnerTextNode(selector, options) {
158
+ return applyNode(selector, { ...options, position: "innerText" });
159
+ }
160
+ function applyRemoveNode(selector, options) {
161
+ return applyNode(selector, { ...options, position: "remove" });
162
+ }
163
+ function applyBeforeBeginNodeHost(targetOrOptions, propertyKey, descriptor) {
164
+ if (propertyKey !== void 0) {
165
+ const decorator = applyNode(":host", { position: "beforeBegin" });
166
+ return decorator(targetOrOptions, propertyKey, descriptor);
167
+ }
168
+ return applyNode(":host", { ...targetOrOptions || {}, position: "beforeBegin" });
169
+ }
170
+ function applyAfterBeginNodeHost(optionsOrTarget, propertyKey, descriptor) {
171
+ if (propertyKey !== void 0) {
172
+ const decorator = applyNode(":host", { position: "afterBegin" });
173
+ return decorator(optionsOrTarget, propertyKey, descriptor);
174
+ }
175
+ return applyNode(":host", { ...optionsOrTarget || {}, position: "afterBegin" });
176
+ }
177
+ function applyBeforeEndNodeHost(optionsOrTarget, propertyKey, descriptor) {
178
+ if (propertyKey !== void 0) {
179
+ const decorator = applyNode(":host", { position: "beforeEnd" });
180
+ return decorator(optionsOrTarget, propertyKey, descriptor);
181
+ }
182
+ return applyNode(":host", { ...optionsOrTarget || {}, position: "beforeEnd" });
183
+ }
184
+ function applyAfterEndNodeHost(optionsOrTarget, propertyKey, descriptor) {
185
+ if (propertyKey !== void 0) {
186
+ const decorator = applyNode(":host", { position: "afterEnd" });
187
+ return decorator(optionsOrTarget, propertyKey, descriptor);
188
+ }
189
+ return applyNode(":host", { ...optionsOrTarget || {}, position: "afterEnd" });
190
+ }
191
+ function applyReplaceNodeHost(optionsOrTarget, propertyKey, descriptor) {
192
+ if (propertyKey !== void 0) {
193
+ const decorator = applyNode(":host", { position: "replace" });
194
+ return decorator(optionsOrTarget, propertyKey, descriptor);
195
+ }
196
+ return applyNode(":host", { ...optionsOrTarget || {}, position: "replace" });
197
+ }
198
+ function applyReplaceChildrenNodeHost(optionsOrTarget, propertyKey, descriptor) {
199
+ if (propertyKey !== void 0) {
200
+ const decorator = applyNode(":host", { position: "replaceChildren" });
201
+ return decorator(optionsOrTarget, propertyKey, descriptor);
202
+ }
203
+ return applyNode(":host", { ...optionsOrTarget || {}, position: "replaceChildren" });
204
+ }
205
+ function applyInnerHtmlNodeHost(optionsOrTarget, propertyKey, descriptor) {
206
+ if (propertyKey !== void 0) {
207
+ const decorator = applyNode(":host", { position: "innerHtml" });
208
+ return decorator(optionsOrTarget, propertyKey, descriptor);
209
+ }
210
+ return applyNode(":host", { ...optionsOrTarget || {}, position: "innerHtml" });
211
+ }
212
+ function applyInnerTextNodeHost(optionsOrTarget, propertyKey, descriptor) {
213
+ if (propertyKey !== void 0) {
214
+ const decorator = applyNode(":host", { position: "innerText" });
215
+ return decorator(optionsOrTarget, propertyKey, descriptor);
216
+ }
217
+ return applyNode(":host", { ...optionsOrTarget || {}, position: "innerText" });
218
+ }
219
+ function applyRemoveNodeHost(optionsOrTarget, propertyKey, descriptor) {
220
+ if (propertyKey !== void 0) {
221
+ const decorator = applyNode(":host", { position: "remove" });
222
+ return decorator(optionsOrTarget, propertyKey, descriptor);
223
+ }
224
+ return applyNode(":host", { ...optionsOrTarget || {}, position: "remove" });
225
+ }
131
226
  export {
132
227
  APPLY_NODE_METADATA_KEY,
133
228
  applyAfterBeginNode,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/decorators/applyNode.ts"],
4
- "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit, getElementConfig } from './elementDefine';\nimport { SwcRootType } from '../types';\n\nexport type ApplyNodePosition = 'beforeBegin' | 'afterBegin' | 'beforeEnd' | 'afterEnd' | 'replace' | 'replaceChildren' | 'innerHtml' | 'innerText' | 'remove';\n\nexport interface ApplyNodeOptions {\n position?: ApplyNodePosition;\n root?: SwcRootType;\n}\n\nexport interface ApplyNodeMetadata {\n propertyKey: string | symbol;\n selector: string;\n options: ApplyNodeOptions;\n}\n\nexport const APPLY_NODE_METADATA_KEY = Symbol('simple-web-component:apply-node');\n\nconst 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/**\n * @applyNode decorator to surgically add/replace nodes to a target element.\n * \n * Usage examples:\n * @applyNode('#list') addItem() { return '<li>New Item</li>'; } // append at end\n * @applyNode('#header', { position: 'afterBegin' }) prependItem() { return '<h1>Title</h1>'; } // prepend at start\n * @applyNode('#item', { position: 'replace' }) replaceItem() { return '<div>Replaced</div>'; } // replace element\n * @applyNode('#list', { position: 'replaceChildren' }) updateList() { return [item1, item2]; } // replace all children\n * @applyNode('#notification', { position: 'remove' }) dismissNotification() { return shouldDismiss; } // remove if truthy\n * @applyNode('.items', { position: 'remove', root: 'shadow' }) clearItems() { return true; } // remove shadow DOM elements\n * \n * Positions:\n * - 'beforeEnd' (default): Append at end of target\n * - 'afterBegin': Prepend at start of target\n * - 'beforeBegin': Insert before target\n * - 'afterEnd': Insert after target\n * - 'replace': Replace the entire target element\n * - 'replaceChildren': Replace all children of target element\n * - 'innerHtml': Set target's innerHTML\n * - 'innerText': Set target's innerText\n * - 'remove': Remove target element if returned value is truthy\n * \n * Root Options:\n * - 'auto' (default): Search shadow DOM first, then light DOM\n * - 'shadow': Search only in shadow DOM\n * - 'light': Search only in light DOM\n * - 'all': Use both (shadow preferred for query, both for remove)\n */\nexport function applyNode(selector: string, options: ApplyNodeOptions = { position: 'beforeEnd' }): MethodDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = target.constructor;\n let metaList = ReflectUtils.getOwnMetadata(APPLY_NODE_METADATA_KEY, constructor) as Map<string | symbol, ApplyNodeMetadata>;\n if (!metaList) {\n metaList = new Map<string | symbol, ApplyNodeMetadata>();\n ReflectUtils.defineMetadata(APPLY_NODE_METADATA_KEY, metaList, constructor);\n }\n metaList.set(propertyKey, { propertyKey, selector, options });\n\n const original = descriptor.value;\n descriptor.value = async function (...args: any[]) {\n ensureInit(this);\n const res = await original.apply(this, args);\n if (res !== undefined) {\n const conf = getElementConfig(this);\n const currentWin = (this as any)._resolveWindow?.(conf) || ((typeof window !== 'undefined' ? window : undefined) as Window);\n const currentDoc = currentWin.document;\n\n const pos = options.position || 'beforeEnd';\n const r = options.root || 'auto';\n\n const getTargetRoot = () => {\n if (r === 'shadow') return this.shadowRoot;\n if (r === 'light') return this as any;\n if (r === 'all') return this.shadowRoot || (this as any);\n return this.shadowRoot || (this as any); // auto\n };\n\n if (pos === 'remove') {\n // Remove element(s) if returned value is truthy\n if (res) {\n if (selector === ':host' || !selector) {\n if (r === 'shadow' && this.shadowRoot) {\n // Remove all children from shadow DOM\n this.shadowRoot.replaceChildren();\n } else {\n // Remove the component itself\n (this as any).remove();\n }\n } else {\n const targetRoot = getTargetRoot();\n if (targetRoot) {\n const targets = targetRoot.querySelectorAll(selector);\n targets.forEach((el: Element) => el.remove());\n }\n }\n }\n } else {\n let targetEl: any = null;\n if (selector === ':host' || !selector) {\n if (r === 'shadow') {\n targetEl = this.shadowRoot; // Target shadow DOM root\n } else {\n targetEl = this as any; // Target the component itself\n }\n } else {\n const targetRoot = getTargetRoot();\n targetEl = targetRoot ? targetRoot.querySelector(selector) : null;\n }\n\n if (targetEl) {\n const isShadowRoot = targetEl instanceof ShadowRoot;\n const nodes = normalizeNodes(res, currentDoc);\n\n if (pos === 'replace') {\n // ShadowRoot doesn't support replaceWith\n if (!isShadowRoot) {\n targetEl.replaceWith(...nodes);\n }\n } else if (pos === 'replaceChildren') {\n // Replace all children of target element\n targetEl.replaceChildren(...nodes);\n } else if (pos === 'innerHtml') {\n // Set innerHTML\n targetEl.innerHTML = res !== undefined && res !== null ? String(res) : '';\n } else if (pos === 'innerText') {\n // Set innerText\n if (targetEl.innerText !== undefined) {\n targetEl.innerText = res !== undefined && res !== null ? String(res) : '';\n }\n } else {\n /*\n <!-- beforebegin -->\n <p>\n <!-- afterbegin -->\n foo\n <!-- beforeend -->\n </p>\n <!-- afterend -->\n */\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 }\n }\n return res;\n };\n };\n}\n\nexport const findAllApplyNodeMetadata = (target: any): Map<string | symbol, ApplyNodeMetadata> => {\n const result = new Map<string | symbol, ApplyNodeMetadata>();\n const maps = ReflectUtils.findAllMetadata<Map<string | symbol, ApplyNodeMetadata>>(APPLY_NODE_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\n/**\n * @applyNodeHost decorator - simplified version of @applyNode for :host selector\n * Usage: @applyNodeHost() addItem() { return '<li>New Item</li>'; }\n * Usage: @applyNodeHost({ position: 'afterBegin' }) prependItem() { return '<h1>Title</h1>'; }\n */\nexport function applyNodeHost(options: ApplyNodeOptions = { position: 'beforeEnd' }): MethodDecorator {\n return applyNode(':host', options);\n}\n\n// Convenience decorators for specific positions\n\n/**\n * @applyBeforeBeginNode - Insert before target element\n */\nexport const applyBeforeBeginNode = (selector: string, options: ApplyNodeOptions = {}) => \n applyNode(selector, { ...options, position: 'beforeBegin' });\n\n/**\n * @applyAfterBeginNode - Prepend to target element\n */\nexport const applyAfterBeginNode = (selector: string, options: ApplyNodeOptions = {}) => \n applyNode(selector, { ...options, position: 'afterBegin' });\n\n/**\n * @applyBeforeEndNode - Append to target element (default)\n */\nexport const applyBeforeEndNode = (selector: string, options: ApplyNodeOptions = {}) => \n applyNode(selector, { ...options, position: 'beforeEnd' });\n\n/**\n * @applyAfterEndNode - Insert after target element\n */\nexport const applyAfterEndNode = (selector: string, options: ApplyNodeOptions = {}) => \n applyNode(selector, { ...options, position: 'afterEnd' });\n\n/**\n * @applyReplaceNode - Replace entire target element\n */\nexport const applyReplaceNode = (selector: string, options: ApplyNodeOptions = {}) => \n applyNode(selector, { ...options, position: 'replace' });\n\n/**\n * @applyReplaceChildrenNode - Replace all children of target element\n */\nexport const applyReplaceChildrenNode = (selector: string, options: ApplyNodeOptions = {}) => \n applyNode(selector, { ...options, position: 'replaceChildren' });\n\n/**\n * @applyInnerHtmlNode - Set target's innerHTML\n */\nexport const applyInnerHtmlNode = (selector: string, options: ApplyNodeOptions = {}) => \n applyNode(selector, { ...options, position: 'innerHtml' });\n\n/**\n * @applyInnerTextNode - Set target's innerText\n */\nexport const applyInnerTextNode = (selector: string, options: ApplyNodeOptions = {}) => \n applyNode(selector, { ...options, position: 'innerText' });\n\n/**\n * @applyRemoveNode - Remove target element if truthy\n */\nexport const applyRemoveNode = (selector: string, options: ApplyNodeOptions = {}) => \n applyNode(selector, { ...options, position: 'remove' });\n\n// Host versions\n\n/**\n * @applyBeforeBeginNodeHost - Insert before :host\n */\nexport const applyBeforeBeginNodeHost = (options: ApplyNodeOptions = {}) => \n applyNode(':host', { ...options, position: 'beforeBegin' });\n\n/**\n * @applyAfterBeginNodeHost - Prepend to :host\n */\nexport const applyAfterBeginNodeHost = (options: ApplyNodeOptions = {}) => \n applyNode(':host', { ...options, position: 'afterBegin' });\n\n/**\n * @applyBeforeEndNodeHost - Append to :host\n */\nexport const applyBeforeEndNodeHost = (options: ApplyNodeOptions = {}) => \n applyNode(':host', { ...options, position: 'beforeEnd' });\n\n/**\n * @applyAfterEndNodeHost - Insert after :host\n */\nexport const applyAfterEndNodeHost = (options: ApplyNodeOptions = {}) => \n applyNode(':host', { ...options, position: 'afterEnd' });\n\n/**\n * @applyReplaceNodeHost - Replace :host\n */\nexport const applyReplaceNodeHost = (options: ApplyNodeOptions = {}) => \n applyNode(':host', { ...options, position: 'replace' });\n\n/**\n * @applyReplaceChildrenNodeHost - Replace children of :host\n */\nexport const applyReplaceChildrenNodeHost = (options: ApplyNodeOptions = {}) => \n applyNode(':host', { ...options, position: 'replaceChildren' });\n\n/**\n * @applyInnerHtmlNodeHost - Set :host innerHTML\n */\nexport const applyInnerHtmlNodeHost = (options: ApplyNodeOptions = {}) => \n applyNode(':host', { ...options, position: 'innerHtml' });\n\n/**\n * @applyInnerTextNodeHost - Set :host innerText\n */\nexport const applyInnerTextNodeHost = (options: ApplyNodeOptions = {}) => \n applyNode(':host', { ...options, position: 'innerText' });\n\n/**\n * @applyRemoveNodeHost - Remove :host if truthy\n */\nexport const applyRemoveNodeHost = (options: ApplyNodeOptions = {}) => \n applyNode(':host', { ...options, position: 'remove' });\n"],
5
- "mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,YAAY,wBAAwB;AAgBtC,MAAM,0BAA0B,OAAO,iCAAiC;AAE/E,MAAM,iBAAiB,CAAC,KAAU,QAAyB;AACzD,QAAM,QAAQ,MAAM,QAAQ,GAAG,IAAI,MAAM,CAAC,GAAG;AAC7C,SAAO,MAAM,IAAI,QAAK;AACpB,QAAI,cAAc;AAAM,aAAO;AAC/B,WAAO,IAAI,eAAe,OAAO,UAAa,OAAO,OAAO,OAAO,EAAE,IAAI,EAAE;EAC7E,CAAC;AACH;AA8BM,SAAU,UAAU,UAAkB,UAA4B,EAAE,UAAU,YAAW,GAAE;AAC/F,SAAO,CAAC,QAAgB,aAA8B,eAAkC;AACtF,UAAM,cAAc,OAAO;AAC3B,QAAI,WAAW,aAAa,eAAe,yBAAyB,WAAW;AAC/E,QAAI,CAAC,UAAU;AACb,iBAAW,oBAAI,IAAG;AAClB,mBAAa,eAAe,yBAAyB,UAAU,WAAW;IAC5E;AACA,aAAS,IAAI,aAAa,EAAE,aAAa,UAAU,QAAO,CAAE;AAE5D,UAAM,WAAW,WAAW;AAC5B,eAAW,QAAQ,kBAAmB,MAAW;AAC/C,iBAAW,IAAI;AACf,YAAM,MAAM,MAAM,SAAS,MAAM,MAAM,IAAI;AAC3C,UAAI,QAAQ,QAAW;AACrB,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AAE;AAKnD,MAAM,sBAAsB,CAAC,UAA4B,CAAA,MAC9D,UAAU,SAAS,EAAE,GAAG,SAAS,UAAU,SAAQ,CAAE;",
4
+ "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit, getElementConfig } from './elementDefine';\nimport { SwcRootType } from '../types';\nimport {SwcUtils} from \"../utils/Utils\";\n\nexport type ApplyNodePosition = 'beforeBegin' | 'afterBegin' | 'beforeEnd' | 'afterEnd' | 'replace' | 'replaceChildren' | 'innerHtml' | 'innerText' | 'remove';\n\nexport interface ApplyNodeOptions {\n position?: ApplyNodePosition;\n root?: SwcRootType;\n}\n\nexport interface ApplyNodeMetadata {\n propertyKey: string | symbol;\n selector: string;\n options: ApplyNodeOptions;\n}\n\nexport const APPLY_NODE_METADATA_KEY = Symbol('simple-web-component:apply-node');\n\nconst 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/**\n * @applyNode decorator to surgically add/replace nodes to a target element.\n * \n * Usage examples:\n * @applyNode('#list') addItem() { return '<li>New Item</li>'; } // append at end\n * @applyNode('#header', { position: 'afterBegin' }) prependItem() { return '<h1>Title</h1>'; } // prepend at start\n * @applyNode('#item', { position: 'replace' }) replaceItem() { return '<div>Replaced</div>'; } // replace element\n * @applyNode('#list', { position: 'replaceChildren' }) updateList() { return [item1, item2]; } // replace all children\n * @applyNode('#notification', { position: 'remove' }) dismissNotification() { return shouldDismiss; } // remove if truthy\n * @applyNode('.items', { position: 'remove', root: 'shadow' }) clearItems() { return true; } // remove shadow DOM elements\n * \n * Positions:\n * - 'beforeEnd' (default): Append at end of target\n * - 'afterBegin': Prepend at start of target\n * - 'beforeBegin': Insert before target\n * - 'afterEnd': Insert after target\n * - 'replace': Replace the entire target element\n * - 'replaceChildren': Replace all children of target element\n * - 'innerHtml': Set target's innerHTML\n * - 'innerText': Set target's innerText\n * - 'remove': Remove target element if returned value is truthy\n * \n * Root Options:\n * - 'auto' (default): Search shadow DOM first, then light DOM\n * - 'shadow': Search only in shadow DOM\n * - 'light': Search only in light DOM\n * - 'all': Use both (shadow preferred for query, both for remove)\n */\nexport function applyNode(selector: string, options: ApplyNodeOptions = { position: 'beforeEnd' }): MethodDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = target.constructor;\n let metaList = ReflectUtils.getOwnMetadata(APPLY_NODE_METADATA_KEY, constructor) as Map<string | symbol, ApplyNodeMetadata>;\n if (!metaList) {\n metaList = new Map<string | symbol, ApplyNodeMetadata>();\n ReflectUtils.defineMetadata(APPLY_NODE_METADATA_KEY, metaList, constructor);\n }\n metaList.set(propertyKey, { propertyKey, selector, options });\n\n const original = descriptor.value;\n descriptor.value = async function (...args: any[]) {\n ensureInit(this);\n const res = await original.apply(this, args);\n if (res !== undefined) {\n const conf = getElementConfig(this);\n const currentWin = (this as any)._resolveWindow?.(conf) || ((typeof window !== 'undefined' ? window : undefined) as Window);\n const currentDoc = currentWin.document;\n\n const pos = options.position || 'beforeEnd';\n const r = options.root || 'auto';\n const applyRoot = (t: any) => {\n if (!t || !(t instanceof HTMLElement)) return t;\n if (r === 'auto') return t.shadowRoot || t;\n if (r === 'shadow') return t.shadowRoot;\n if (r === 'light') return t;\n if (r === 'all') return t.shadowRoot || t; // query only returns one, so shadow preferred\n return t;\n };\n\n const hostSet = SwcUtils.getHostSet(this);\n // const getTargetRoot = () => {\n // if (r === 'shadow') return this.shadowRoot;\n // if (r === 'light') return this as any;\n // if (r === 'all') return this.shadowRoot || (this as any);\n // return this.shadowRoot || (this as any); // auto\n // };\n\n if (pos === 'remove') {\n // Remove element(s) if returned value is truthy\n if (res) {\n if (selector === ':host' || !selector) {\n if (r === 'shadow' && this.shadowRoot) {\n // Remove all children from shadow DOM\n this.shadowRoot.replaceChildren();\n } else {\n // Remove the component itself\n (this as any).remove();\n }\n } else {\n const targetRoot = applyRoot(this);\n if (targetRoot) {\n const targets = targetRoot.querySelectorAll(selector);\n targets.forEach((el: Element) => el.remove());\n }\n }\n }\n } else {\n let targetEl: any = null;\n\n if (selector === ':host') {\n targetEl = applyRoot(this)\n } else if (selector === ':parentHost') {\n targetEl = applyRoot(hostSet.$parentHost)\n } else if (selector === ':appHost') {\n targetEl = applyRoot(hostSet.$appHost)\n } else if (selector === ':firstHost') {\n targetEl = applyRoot(hostSet.$firstHost)\n } else if (selector === ':lastHost') {\n targetEl = applyRoot(hostSet.$lastHost)\n } else if (selector === ':firstAppHost') {\n targetEl = applyRoot(hostSet.$firstHost)\n } else if (selector === ':lastAppHost') {\n targetEl = applyRoot(hostSet.$lastAppHost);\n } else {\n const targetRoot = applyRoot(this);\n targetEl = targetRoot ? targetRoot.querySelector(selector) : null;\n }\n\n if (targetEl) {\n const isShadowRoot = targetEl instanceof ShadowRoot;\n const nodes = normalizeNodes(res, currentDoc);\n\n if (pos === 'replace') {\n // ShadowRoot doesn't support replaceWith\n if (!isShadowRoot) {\n targetEl.replaceWith(...nodes);\n }\n } else if (pos === 'replaceChildren') {\n // Replace all children of target element\n targetEl.replaceChildren(...nodes);\n } else if (pos === 'innerHtml') {\n // Set innerHTML\n targetEl.innerHTML = res !== undefined && res !== null ? String(res) : '';\n } else if (pos === 'innerText') {\n // Set innerText\n if (targetEl.innerText !== undefined) {\n targetEl.innerText = res !== undefined && res !== null ? String(res) : '';\n }\n } else {\n /*\n <!-- beforebegin -->\n <p>\n <!-- afterbegin -->\n foo\n <!-- beforeend -->\n </p>\n <!-- afterend -->\n */\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 }\n }\n return res;\n };\n };\n}\n\nexport const findAllApplyNodeMetadata = (target: any): Map<string | symbol, ApplyNodeMetadata> => {\n const result = new Map<string | symbol, ApplyNodeMetadata>();\n const maps = ReflectUtils.findAllMetadata<Map<string | symbol, ApplyNodeMetadata>>(APPLY_NODE_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\n/**\n * @applyNodeHost decorator - simplified version of @applyNode for :host selector\n * Usage: @applyNodeHost addItem() { return '<li>New Item</li>'; }\n * Usage: @applyNodeHost() addItem() { return '<li>New Item</li>'; }\n * Usage: @applyNodeHost({ position: 'afterBegin' }) prependItem() { return '<h1>Title</h1>'; }\n */\nexport function applyNodeHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function applyNodeHost(): MethodDecorator;\nexport function applyNodeHost(options: ApplyNodeOptions): MethodDecorator;\nexport function applyNodeHost(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n // Direct decorator usage: @applyNodeHost (no parentheses)\n console.log('vvvvv')\n if (propertyKey !== undefined && typeof propertyKey === 'string' || typeof propertyKey === 'symbol') {\n return applyNode(':host', { position: 'beforeEnd' })(targetOrOptions, propertyKey, descriptor);\n }\n\n // @applyNodeHost() or @applyNodeHost(options)\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {\n const options = targetOrOptions as ApplyNodeOptions;\n return applyNode(':host', { ...options, position: options.position || 'beforeEnd' });\n } else {\n // @applyNodeHost() - use default position\n return applyNode(':host', { position: 'beforeEnd' });\n }\n}\n\n// Convenience decorators for specific positions\n\n/**\n * @applyBeforeBeginNode - Insert before target element\n */\nexport function applyBeforeBeginNode(selector: string): MethodDecorator;\nexport function applyBeforeBeginNode(selector: string, options: ApplyNodeOptions): MethodDecorator;\nexport function applyBeforeBeginNode(selector: string, options?: ApplyNodeOptions): any {\n return applyNode(selector, { ...options, position: 'beforeBegin' });\n}\n\n/**\n * @applyAfterBeginNode - Prepend to target element\n */\nexport function applyAfterBeginNode(selector: string): MethodDecorator;\nexport function applyAfterBeginNode(selector: string, options: ApplyNodeOptions): MethodDecorator;\nexport function applyAfterBeginNode(selector: string, options?: ApplyNodeOptions): any {\n return applyNode(selector, { ...options, position: 'afterBegin' });\n}\n\n/**\n * @applyBeforeEndNode - Append to target element (default)\n */\nexport function applyBeforeEndNode(selector: string): MethodDecorator;\nexport function applyBeforeEndNode(selector: string, options: ApplyNodeOptions): MethodDecorator;\nexport function applyBeforeEndNode(selector: string, options?: ApplyNodeOptions): any {\n return applyNode(selector, { ...options, position: 'beforeEnd' });\n}\n\n/**\n * @applyAfterEndNode - Insert after target element\n */\nexport function applyAfterEndNode(selector: string): MethodDecorator;\nexport function applyAfterEndNode(selector: string, options: ApplyNodeOptions): MethodDecorator;\nexport function applyAfterEndNode(selector: string, options?: ApplyNodeOptions): any {\n return applyNode(selector, { ...options, position: 'afterEnd' });\n}\n\n/**\n * @applyReplaceNode - Replace entire target element\n */\nexport function applyReplaceNode(selector: string): MethodDecorator;\nexport function applyReplaceNode(selector: string, options: ApplyNodeOptions): MethodDecorator;\nexport function applyReplaceNode(selector: string, options?: ApplyNodeOptions): any {\n return applyNode(selector, { ...options, position: 'replace' });\n}\n\n/**\n * @applyReplaceChildrenNode - Replace all children of target element\n */\nexport function applyReplaceChildrenNode(selector: string): MethodDecorator;\nexport function applyReplaceChildrenNode(selector: string, options: ApplyNodeOptions): MethodDecorator;\nexport function applyReplaceChildrenNode(selector: string, options?: ApplyNodeOptions): any {\n return applyNode(selector, { ...options, position: 'replaceChildren' });\n}\n\n/**\n * @applyInnerHtmlNode - Set target's innerHTML\n */\nexport function applyInnerHtmlNode(selector: string): MethodDecorator;\nexport function applyInnerHtmlNode(selector: string, options: ApplyNodeOptions): MethodDecorator;\nexport function applyInnerHtmlNode(selector: string, options?: ApplyNodeOptions): any {\n return applyNode(selector, { ...options, position: 'innerHtml' });\n}\n\n/**\n * @applyInnerTextNode - Set target's innerText\n */\nexport function applyInnerTextNode(selector: string): MethodDecorator;\nexport function applyInnerTextNode(selector: string, options: ApplyNodeOptions): MethodDecorator;\nexport function applyInnerTextNode(selector: string, options?: ApplyNodeOptions): any {\n return applyNode(selector, { ...options, position: 'innerText' });\n}\n\n/**\n * @applyRemoveNode - Remove target element if truthy\n */\nexport function applyRemoveNode(selector: string): MethodDecorator;\nexport function applyRemoveNode(selector: string, options: ApplyNodeOptions): MethodDecorator;\nexport function applyRemoveNode(selector: string, options?: ApplyNodeOptions): any {\n return applyNode(selector, { ...options, position: 'remove' });\n}\n\n// Host versions\n\n/**\n * @applyBeforeBeginNodeHost - Insert before :host\n */\nexport function applyBeforeBeginNodeHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): any;\nexport function applyBeforeBeginNodeHost(): MethodDecorator;\nexport function applyBeforeBeginNodeHost(options: ApplyNodeOptions): MethodDecorator;\nexport function applyBeforeBeginNodeHost(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n if (propertyKey !== undefined) {\n const decorator = applyNode(':host', { position: 'beforeBegin' });\n return decorator(targetOrOptions, propertyKey, descriptor);\n }\n return applyNode(':host', { ...(targetOrOptions as ApplyNodeOptions || {}), position: 'beforeBegin' });\n}\n\n/**\n * @applyAfterBeginNodeHost - Prepend to :host\n */export function applyAfterBeginNodeHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): any;export function applyAfterBeginNodeHost(): MethodDecorator;\nexport function applyAfterBeginNodeHost(options: ApplyNodeOptions): MethodDecorator;\nexport function applyAfterBeginNodeHost(optionsOrTarget?: ApplyNodeOptions | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n if (propertyKey !== undefined) {\n const decorator = applyNode(':host', { position: 'afterBegin' });\n return decorator(optionsOrTarget, propertyKey, descriptor);\n }\n return applyNode(':host', { ...(optionsOrTarget as ApplyNodeOptions || {}), position: 'afterBegin' });\n}\n\n/**\n * @applyBeforeEndNodeHost - Append to :host\n */export function applyBeforeEndNodeHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): any;export function applyBeforeEndNodeHost(): MethodDecorator;\nexport function applyBeforeEndNodeHost(options: ApplyNodeOptions): MethodDecorator;\nexport function applyBeforeEndNodeHost(optionsOrTarget?: ApplyNodeOptions | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n if (propertyKey !== undefined) {\n const decorator = applyNode(':host', { position: 'beforeEnd' });\n return decorator(optionsOrTarget, propertyKey, descriptor);\n }\n return applyNode(':host', { ...(optionsOrTarget as ApplyNodeOptions || {}), position: 'beforeEnd' });\n}\n\n/**\n * @applyAfterEndNodeHost - Insert after :host\n */export function applyAfterEndNodeHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): any;export function applyAfterEndNodeHost(): MethodDecorator;\nexport function applyAfterEndNodeHost(options: ApplyNodeOptions): MethodDecorator;\nexport function applyAfterEndNodeHost(optionsOrTarget?: ApplyNodeOptions | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n if (propertyKey !== undefined) {\n const decorator = applyNode(':host', { position: 'afterEnd' });\n return decorator(optionsOrTarget, propertyKey, descriptor);\n }\n return applyNode(':host', { ...(optionsOrTarget as ApplyNodeOptions || {}), position: 'afterEnd' });\n}\n\n/**\n * @applyReplaceNodeHost - Replace :host\n */export function applyReplaceNodeHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): any;export function applyReplaceNodeHost(): MethodDecorator;\nexport function applyReplaceNodeHost(options: ApplyNodeOptions): MethodDecorator;\nexport function applyReplaceNodeHost(optionsOrTarget?: ApplyNodeOptions | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n if (propertyKey !== undefined) {\n const decorator = applyNode(':host', { position: 'replace' });\n return decorator(optionsOrTarget, propertyKey, descriptor);\n }\n return applyNode(':host', { ...(optionsOrTarget as ApplyNodeOptions || {}), position: 'replace' });\n}\n\n/**\n * @applyReplaceChildrenNodeHost - Replace children of :host\n */export function applyReplaceChildrenNodeHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): any;export function applyReplaceChildrenNodeHost(): MethodDecorator;\nexport function applyReplaceChildrenNodeHost(options: ApplyNodeOptions): MethodDecorator;\nexport function applyReplaceChildrenNodeHost(optionsOrTarget?: ApplyNodeOptions | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n if (propertyKey !== undefined) {\n const decorator = applyNode(':host', { position: 'replaceChildren' });\n return decorator(optionsOrTarget, propertyKey, descriptor);\n }\n return applyNode(':host', { ...(optionsOrTarget as ApplyNodeOptions || {}), position: 'replaceChildren' });\n}\n\n/**\n * @applyInnerHtmlNodeHost - Set :host innerHTML\n */export function applyInnerHtmlNodeHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): any;export function applyInnerHtmlNodeHost(): MethodDecorator;\nexport function applyInnerHtmlNodeHost(options: ApplyNodeOptions): MethodDecorator;\nexport function applyInnerHtmlNodeHost(optionsOrTarget?: ApplyNodeOptions | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n if (propertyKey !== undefined) {\n const decorator = applyNode(':host', { position: 'innerHtml' });\n return decorator(optionsOrTarget, propertyKey, descriptor);\n }\n return applyNode(':host', { ...(optionsOrTarget as ApplyNodeOptions || {}), position: 'innerHtml' });\n}\n\n/**\n * @applyInnerTextNodeHost - Set :host innerText\n */export function applyInnerTextNodeHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): any;export function applyInnerTextNodeHost(): MethodDecorator;\nexport function applyInnerTextNodeHost(options: ApplyNodeOptions): MethodDecorator;\nexport function applyInnerTextNodeHost(optionsOrTarget?: ApplyNodeOptions | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n if (propertyKey !== undefined) {\n const decorator = applyNode(':host', { position: 'innerText' });\n return decorator(optionsOrTarget, propertyKey, descriptor);\n }\n return applyNode(':host', { ...(optionsOrTarget as ApplyNodeOptions || {}), position: 'innerText' });\n}\n\n/**\n * @applyRemoveNodeHost - Remove :host if truthy\n */export function applyRemoveNodeHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): any;export function applyRemoveNodeHost(): MethodDecorator;\nexport function applyRemoveNodeHost(options: ApplyNodeOptions): MethodDecorator;\nexport function applyRemoveNodeHost(optionsOrTarget?: ApplyNodeOptions | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n if (propertyKey !== undefined) {\n const decorator = applyNode(':host', { position: 'remove' });\n return decorator(optionsOrTarget, propertyKey, descriptor);\n }\n return applyNode(':host', { ...(optionsOrTarget as ApplyNodeOptions || {}), position: 'remove' });\n}\n"],
5
+ "mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,YAAY,wBAAwB;AAE7C,SAAQ,gBAAe;AAehB,MAAM,0BAA0B,OAAO,iCAAiC;AAE/E,MAAM,iBAAiB,CAAC,KAAU,QAAyB;AACzD,QAAM,QAAQ,MAAM,QAAQ,GAAG,IAAI,MAAM,CAAC,GAAG;AAC7C,SAAO,MAAM,IAAI,QAAK;AACpB,QAAI,cAAc;AAAM,aAAO;AAC/B,WAAO,IAAI,eAAe,OAAO,UAAa,OAAO,OAAO,OAAO,EAAE,IAAI,EAAE;EAC7E,CAAC;AACH;AA8BM,SAAU,UAAU,UAAkB,UAA4B,EAAE,UAAU,YAAW,GAAE;AAC/F,SAAO,CAAC,QAAgB,aAA8B,eAAkC;AACtF,UAAM,cAAc,OAAO;AAC3B,QAAI,WAAW,aAAa,eAAe,yBAAyB,WAAW;AAC/E,QAAI,CAAC,UAAU;AACb,iBAAW,oBAAI,IAAG;AAClB,mBAAa,eAAe,yBAAyB,UAAU,WAAW;IAC5E;AACA,aAAS,IAAI,aAAa,EAAE,aAAa,UAAU,QAAO,CAAE;AAE5D,UAAM,WAAW,WAAW;AAC5B,eAAW,QAAQ,kBAAmB,MAAW;AAC/C,iBAAW,IAAI;AACf,YAAM,MAAM,MAAM,SAAS,MAAM,MAAM,IAAI;AAC3C,UAAI,QAAQ,QAAW;AACrB,cAAM,OAAO,iBAAiB,IAAI;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AACnG;AAMM,SAAU,6BAA6B,iBAA0C,aAA+B,YAA+B;AACnJ,MAAI,gBAAgB,QAAW;AAC7B,UAAM,YAAY,UAAU,SAAS,EAAE,UAAU,kBAAiB,CAAE;AACpE,WAAO,UAAU,iBAAiB,aAAa,UAAU;EAC3D;AACA,SAAO,UAAU,SAAS,EAAE,GAAI,mBAAuC,CAAA,GAAK,UAAU,kBAAiB,CAAE;AAC3G;AAMM,SAAU,uBAAuB,iBAA0C,aAA+B,YAA+B;AAC7I,MAAI,gBAAgB,QAAW;AAC7B,UAAM,YAAY,UAAU,SAAS,EAAE,UAAU,YAAW,CAAE;AAC9D,WAAO,UAAU,iBAAiB,aAAa,UAAU;EAC3D;AACA,SAAO,UAAU,SAAS,EAAE,GAAI,mBAAuC,CAAA,GAAK,UAAU,YAAW,CAAE;AACrG;AAMM,SAAU,uBAAuB,iBAA0C,aAA+B,YAA+B;AAC7I,MAAI,gBAAgB,QAAW;AAC7B,UAAM,YAAY,UAAU,SAAS,EAAE,UAAU,YAAW,CAAE;AAC9D,WAAO,UAAU,iBAAiB,aAAa,UAAU;EAC3D;AACA,SAAO,UAAU,SAAS,EAAE,GAAI,mBAAuC,CAAA,GAAK,UAAU,YAAW,CAAE;AACrG;AAMM,SAAU,oBAAoB,iBAA0C,aAA+B,YAA+B;AAC1I,MAAI,gBAAgB,QAAW;AAC7B,UAAM,YAAY,UAAU,SAAS,EAAE,UAAU,SAAQ,CAAE;AAC3D,WAAO,UAAU,iBAAiB,aAAa,UAAU;EAC3D;AACA,SAAO,UAAU,SAAS,EAAE,GAAI,mBAAuC,CAAA,GAAK,UAAU,SAAQ,CAAE;AAClG;",
6
6
  "names": []
7
7
  }
@@ -129,8 +129,27 @@ function attribute(selector, options = {}) {
129
129
  const findAllAttributeMetadata = (target) => {
130
130
  return ReflectUtils.findAllMetadata(ATTRIBUTE_METADATA_KEY, target).flat();
131
131
  };
132
- function attributeHost(attrName, options = {}) {
133
- return attribute(":host", { ...options, name: attrName });
132
+ function attributeHost(targetOrAttrOrOptions, propertyKeyOrOptions) {
133
+ if (propertyKeyOrOptions !== void 0 && (typeof propertyKeyOrOptions === "string" || typeof propertyKeyOrOptions === "symbol")) {
134
+ const fieldName = String(propertyKeyOrOptions);
135
+ return attribute(":host", { name: fieldName })(targetOrAttrOrOptions, propertyKeyOrOptions);
136
+ }
137
+ if (typeof targetOrAttrOrOptions === "string") {
138
+ const attrName = targetOrAttrOrOptions;
139
+ const options = typeof propertyKeyOrOptions === "object" ? propertyKeyOrOptions : {};
140
+ return attribute(":host", { ...options, name: attrName });
141
+ } else if (typeof targetOrAttrOrOptions === "object") {
142
+ const options = targetOrAttrOrOptions;
143
+ return (target, propertyKey) => {
144
+ const fieldName = String(propertyKey);
145
+ return attribute(":host", { ...options, name: fieldName })(target, propertyKey);
146
+ };
147
+ } else {
148
+ return (target, propertyKey) => {
149
+ const fieldName = String(propertyKey);
150
+ return attribute(":host", { name: fieldName })(target, propertyKey);
151
+ };
152
+ }
134
153
  }
135
154
  export {
136
155
  ATTRIBUTE_METADATA_KEY,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/decorators/attribute.ts"],
4
- "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit, getElementConfig } from './elementDefine';\nimport { SwcUtils } from '../utils/Utils';\nimport { SpecialSelector, SwcQueryOptions } from '../types';\n\nexport interface AttributeOptions extends SwcQueryOptions {\n name?: string;\n connectedInitialize?: boolean;\n type?: typeof Number | typeof Boolean | typeof String;\n}\n\nexport interface AttributeMetadata {\n propertyKey: string | symbol;\n selector: string;\n options: AttributeOptions;\n privateKey: symbol; // Added to bypass getter during initialization\n}\n\nexport const ATTRIBUTE_METADATA_KEY = Symbol('simple-web-component:attribute');\n\n/**\n * Helper to perform type conversion from string to target type\n */\nconst convertValue = (val: string | null, type: any): any => {\n if (val === null || val === undefined) return val;\n if (type === Number) return Number(val);\n if (type === Boolean) return val === 'false' || val === '0' ? false : true;\n return val;\n};\n\n/**\n * Helper to resolve target elements based on selector and root options\n */\nexport const resolveTargetEls = (inst: any, selector: string, options: AttributeOptions, currentWin: any): HTMLElement[] => {\n const r = options.root || 'auto';\n const results: HTMLElement[] = [];\n\n const applyRoot = (target: any) => {\n if (!target) return;\n if (r === 'auto') {\n // Attributes belong to the ELEMENT, not the ShadowRoot.\n // So for :host and direct attribute sync, we mostly want the element itself.\n results.push(target);\n } else {\n if (r === 'light' || r === 'all') results.push(target);\n if ((r === 'shadow' || r === 'all') && target.shadowRoot) results.push(target.shadowRoot);\n }\n };\n\n if (selector === ':host' || !selector) {\n applyRoot(inst);\n } else if (selector === ':window') {\n results.push(currentWin);\n } else if (selector === ':document') {\n results.push(currentWin.document);\n } else {\n const hostSet = SwcUtils.getHostSet(inst);\n if (selector === ':parentHost') applyRoot(hostSet.$parentHost);\n else if (selector === ':appHost') applyRoot(hostSet.$appHost as any);\n else if (selector === ':firstHost') applyRoot(hostSet.$firstHost);\n else if (selector === ':lastHost') applyRoot(hostSet.$lastHost);\n else if (selector === ':firstAppHost') applyRoot(hostSet.$firstAppHost as any);\n else if (selector === ':lastAppHost') applyRoot(hostSet.$lastAppHost as any);\n else {\n if (r === 'shadow') {\n const found = inst.shadowRoot?.querySelectorAll(selector);\n if (found) results.push(...found);\n } else if (r === 'light') {\n const found = inst.querySelectorAll(selector);\n if (found) results.push(...found);\n } else if (r === 'all') {\n const sMatch = inst.shadowRoot?.querySelectorAll(selector);\n const lMatch = inst.querySelectorAll(selector);\n if (sMatch) results.push(...sMatch);\n if (lMatch) results.push(...lMatch);\n } else {\n const found = (inst.shadowRoot || inst).querySelectorAll(selector);\n if (found) results.push(...found);\n }\n }\n }\n return results;\n};\n\n/**\n * @attribute decorator to sync a field value with an element's attribute.\n */\nexport function attribute(selector: string, options: AttributeOptions = {}): PropertyDecorator {\n return (target: Object, propertyKey: string | symbol) => {\n const constructor = target.constructor;\n const privateKey = Symbol(String(propertyKey));\n\n const designType = (Reflect as any).getMetadata('design:type', target, propertyKey);\n\n let metaList = ReflectUtils.getOwnMetadata(ATTRIBUTE_METADATA_KEY, constructor) as AttributeMetadata[];\n if (!metaList) {\n metaList = [];\n ReflectUtils.defineMetadata(ATTRIBUTE_METADATA_KEY, metaList, constructor);\n }\n metaList.push({ propertyKey, selector, options, privateKey });\n\n // Helper function to apply setAttribute to targets\n const applySetAttribute = (inst: any, targets: HTMLElement[], attrName: string, nv: any) => {\n targets.forEach(it => {\n console.log('----->', it)\n if (it && typeof (it as any).setAttribute === 'function') {\n if (nv === null) {\n (it as any).removeAttribute(attrName);\n } else {\n (it as any).setAttribute(attrName, String(nv));\n }\n } else {\n inst[privateKey] = nv;\n }\n });\n };\n\n Object.defineProperty(target, propertyKey, {\n get(this: any) {\n const attrName = options.name || String(propertyKey);\n const conf = getElementConfig(this);\n const currentWin = this._resolveWindow?.(conf) || ((typeof window !== 'undefined' ? window : undefined) as any);\n const targetType = options.type || designType;\n\n console.log('type-->', propertyKey, targetType);\n // During early init phase, if syncing memory to DOM, return memory.\n if (this.__swc_syncing_init || (options.connectedInitialize && !this.__swc_connected)) {\n return convertValue(this[privateKey], targetType);\n }\n\n const targets = resolveTargetEls(this, selector, options, currentWin);\n const primaryTarget = targets[0];\n\n if (primaryTarget && typeof (primaryTarget as any).hasAttribute === 'function') {\n if ((primaryTarget as any).hasAttribute(attrName)) {\n const domVal = (primaryTarget as any).getAttribute(attrName);\n return convertValue(domVal, targetType);\n }\n return null;\n }\n\n return convertValue(this[privateKey], targetType);\n },\n set(this: any, nv: any) {\n const targetType = options.type || designType;\n // console.log('---set', propertyKey, targetType, nv, this, this.__swc_syncing_init);\n\n const attrName = options.name || String(propertyKey);\n const conf = getElementConfig(this);\n const currentWin = this._resolveWindow?.(conf) || ((typeof window !== 'undefined' ? window : undefined) as any);\n\n // During initialization/syncing phase\n if (this.__swc_syncing_init) {\n // If connectedInitialize is enabled, force setAttribute (JS -> DOM)\n if (options.connectedInitialize === true) {\n const targets = resolveTargetEls(this, selector, options, currentWin);\n applySetAttribute(this, targets, attrName, nv);\n } else {\n // Otherwise just update memory\n this[privateKey] = nv;\n }\n return;\n }\n\n // Before connected, save to memory only\n if (!this.__swc_connected) {\n this[privateKey] = nv;\n return;\n }\n\n // After connected, normal setAttribute\n const targets = resolveTargetEls(this, selector, options, currentWin);\n applySetAttribute(this, targets, attrName, nv);\n },\n enumerable: true,\n configurable: true\n });\n };\n}\n\nexport const findAllAttributeMetadata = (target: any): AttributeMetadata[] => {\n return ReflectUtils.findAllMetadata<AttributeMetadata[]>(ATTRIBUTE_METADATA_KEY, target).flat();\n};\n\n/**\n * @hostAttribute decorator - simplified version of @attribute for :host selector\n * Usage: @hostAttribute('data-product-id')\n * Usage: @hostAttribute('disabled', { type: Boolean })\n */\nexport function attributeHost(attrName: string, options: AttributeOptions = {}): PropertyDecorator {\n return attribute(':host', { ...options, name: attrName });\n}\n"],
5
- "mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAqB,wBAAwB;AAC7C,SAAS,gBAAgB;AAgBlB,MAAM,yBAAyB,OAAO,gCAAgC;AAK7E,MAAM,eAAe,CAAC,KAAoB,SAAmB;AAC3D,MAAI,QAAQ,QAAQ,QAAQ,OAAW,QAAO;AAC9C,MAAI,SAAS,OAAQ,QAAO,OAAO,GAAG;AACtC,MAAI,SAAS,QAAS,QAAO,QAAQ,WAAW,QAAQ,MAAM,QAAQ;AACtE,SAAO;AACT;AAKO,MAAM,mBAAmB,CAAC,MAAW,UAAkB,SAA2B,eAAmC;AAC1H,QAAM,IAAI,QAAQ,QAAQ;AAC1B,QAAM,UAAyB,CAAC;AAEhC,QAAM,YAAY,CAAC,WAAgB;AACjC,QAAI,CAAC,OAAQ;AACb,QAAI,MAAM,QAAQ;AAGhB,cAAQ,KAAK,MAAM;AAAA,IACrB,OAAO;AACL,UAAI,MAAM,WAAW,MAAM,MAAO,SAAQ,KAAK,MAAM;AACrD,WAAK,MAAM,YAAY,MAAM,UAAU,OAAO,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aAAa,QAAQ,GAAG;AACjD,kBAAM,SAAU,cAAsB,aAAa,QAAQ;AAC3D,mBAAO,aAAa,QAAQ,UAAU;AAAA,UACxC;AACA,iBAAO;AAAA,QACT;AAEA,eAAO,aAAa,KAAK,UAAU,GAAG,UAAU;AAAA,MAClD;AAAA,MACA,IAAe,IAAS;AACtB,cAAM,aAAa,QAAQ,QAAQ;AAGnC,cAAM,WAAW,QAAQ,QAAQ,OAAO,WAAW;AACnD,cAAM,OAAO,iBAAiB,IAAI;AAClC,cAAM,aAAa,KAAK,iBAAiB,IAAI,MAAO,OAAO,WAAW,cAAc,SAAS;AAG7F,YAAI,KAAK,oBAAoB;AAE3B,cAAI,QAAQ,wBAAwB,MAAM;AACxC,kBAAMA,WAAU,iBAAiB,MAAM,UAAU,SAAS,UAAU;AACpE,8BAAkB,MAAMA,UAAS,UAAU,EAAE;AAAA,UAC/C,OAAO;AAEL,iBAAK,UAAU,IAAI;AAAA,UACrB;AACA;AAAA,QACF;AAGA,YAAI,CAAC,KAAK,iBAAiB;AACzB,eAAK,UAAU,IAAI;AACnB;AAAA,QACF;AAGA,cAAM,UAAU,iBAAiB,MAAM,UAAU,SAAS,UAAU;AACpE,0BAAkB,MAAM,SAAS,UAAU,EAAE;AAAA,MAC/C;AAAA,MACA,YAAY;AAAA,MACZ,cAAc;AAAA,IAChB,CAAC;AAAA,EACH;AACF;AAEO,MAAM,2BAA2B,CAAC,WAAqC;AAC5E,SAAO,aAAa,gBAAqC,wBAAwB,MAAM,EAAE,KAAK;AAChG;AAOO,SAAS,cAAc,UAAkB,UAA4B,CAAC,GAAsB;AACjG,SAAO,UAAU,SAAS,EAAE,GAAG,SAAS,MAAM,SAAS,CAAC;AAC1D;",
4
+ "sourcesContent": ["import {ReflectUtils} from '@dooboostore/core';\nimport {ensureInit, getElementConfig} from './elementDefine';\nimport {SwcUtils} from '../utils/Utils';\nimport {SpecialSelector, SwcQueryOptions} from '../types';\n\nexport interface AttributeOptions extends SwcQueryOptions {\n name?: string;\n connectedInitialize?: boolean;\n type?: typeof Number | typeof Boolean | typeof String;\n}\n\nexport interface AttributeMetadata {\n propertyKey: string | symbol;\n selector: string;\n options: AttributeOptions;\n privateKey: symbol; // Added to bypass getter during initialization\n}\n\nexport const ATTRIBUTE_METADATA_KEY = Symbol('simple-web-component:attribute');\n\n/**\n * Helper to perform type conversion from string to target type\n */\nconst convertValue = (val: string | null, type: any): any => {\n if (val === null || val === undefined) return val;\n if (type === Number) return Number(val);\n if (type === Boolean) return val === 'false' || val === '0' ? false : true;\n return val;\n};\n\n/**\n * Helper to resolve target elements based on selector and root options\n */\nexport const resolveTargetEls = (inst: any, selector: string, options: AttributeOptions, currentWin: any): HTMLElement[] => {\n const r = options.root || 'auto';\n const results: HTMLElement[] = [];\n\n const applyRoot = (target: any) => {\n if (!target) return;\n if (r === 'auto') {\n // Attributes belong to the ELEMENT, not the ShadowRoot.\n // So for :host and direct attribute sync, we mostly want the element itself.\n results.push(target);\n } else {\n if (r === 'light' || r === 'all') results.push(target);\n if ((r === 'shadow' || r === 'all') && target.shadowRoot) results.push(target.shadowRoot);\n }\n };\n\n if (selector === ':host' || !selector) {\n applyRoot(inst);\n } else if (selector === ':window') {\n results.push(currentWin);\n } else if (selector === ':document') {\n results.push(currentWin.document);\n } else {\n const hostSet = SwcUtils.getHostSet(inst);\n if (selector === ':parentHost') applyRoot(hostSet.$parentHost);\n else if (selector === ':appHost') applyRoot(hostSet.$appHost as any);\n else if (selector === ':firstHost') applyRoot(hostSet.$firstHost);\n else if (selector === ':lastHost') applyRoot(hostSet.$lastHost);\n else if (selector === ':firstAppHost') applyRoot(hostSet.$firstAppHost as any);\n else if (selector === ':lastAppHost') applyRoot(hostSet.$lastAppHost as any);\n else {\n if (r === 'shadow') {\n const found = inst.shadowRoot?.querySelectorAll(selector);\n if (found) results.push(...found);\n } else if (r === 'light') {\n const found = inst.querySelectorAll(selector);\n if (found) results.push(...found);\n } else if (r === 'all') {\n const sMatch = inst.shadowRoot?.querySelectorAll(selector);\n const lMatch = inst.querySelectorAll(selector);\n if (sMatch) results.push(...sMatch);\n if (lMatch) results.push(...lMatch);\n } else {\n const found = (inst.shadowRoot || inst).querySelectorAll(selector);\n if (found) results.push(...found);\n }\n }\n }\n return results;\n};\n\n/**\n * @attribute decorator to sync a field value with an element's attribute.\n */\nexport function attribute(selector: string, options: AttributeOptions = {}): PropertyDecorator {\n return (target: Object, propertyKey: string | symbol) => {\n const constructor = target.constructor;\n const privateKey = Symbol(String(propertyKey));\n\n const designType = (Reflect as any).getMetadata('design:type', target, propertyKey);\n\n let metaList = ReflectUtils.getOwnMetadata(ATTRIBUTE_METADATA_KEY, constructor) as AttributeMetadata[];\n if (!metaList) {\n metaList = [];\n ReflectUtils.defineMetadata(ATTRIBUTE_METADATA_KEY, metaList, constructor);\n }\n metaList.push({propertyKey, selector, options, privateKey});\n\n // Helper function to apply setAttribute to targets\n const applySetAttribute = (inst: any, targets: HTMLElement[], attrName: string, nv: any) => {\n targets.forEach(it => {\n console.log('----->', it)\n if (it && typeof (it as any).setAttribute === 'function') {\n if (nv === null) {\n (it as any).removeAttribute(attrName);\n } else {\n (it as any).setAttribute(attrName, String(nv));\n }\n } else {\n inst[privateKey] = nv;\n }\n });\n };\n\n Object.defineProperty(target, propertyKey, {\n get(this: any) {\n const attrName = options.name || String(propertyKey);\n const conf = getElementConfig(this);\n const currentWin = this._resolveWindow?.(conf) || ((typeof window !== 'undefined' ? window : undefined) as any);\n const targetType = options.type || designType;\n\n console.log('type-->', propertyKey, targetType);\n // During early init phase, if syncing memory to DOM, return memory.\n if (this.__swc_syncing_init || (options.connectedInitialize && !this.__swc_connected)) {\n return convertValue(this[privateKey], targetType);\n }\n\n const targets = resolveTargetEls(this, selector, options, currentWin);\n const primaryTarget = targets[0];\n\n if (primaryTarget && typeof (primaryTarget as any).hasAttribute === 'function') {\n if ((primaryTarget as any).hasAttribute(attrName)) {\n const domVal = (primaryTarget as any).getAttribute(attrName);\n return convertValue(domVal, targetType);\n }\n return null;\n }\n\n return convertValue(this[privateKey], targetType);\n },\n set(this: any, nv: any) {\n const targetType = options.type || designType;\n // console.log('---set', propertyKey, targetType, nv, this, this.__swc_syncing_init);\n\n const attrName = options.name || String(propertyKey);\n const conf = getElementConfig(this);\n const currentWin = this._resolveWindow?.(conf) || ((typeof window !== 'undefined' ? window : undefined) as any);\n\n // During initialization/syncing phase\n if (this.__swc_syncing_init) {\n // If connectedInitialize is enabled, force setAttribute (JS -> DOM)\n if (options.connectedInitialize === true) {\n const targets = resolveTargetEls(this, selector, options, currentWin);\n applySetAttribute(this, targets, attrName, nv);\n } else {\n // Otherwise just update memory\n this[privateKey] = nv;\n }\n return;\n }\n\n // Before connected, save to memory only\n if (!this.__swc_connected) {\n this[privateKey] = nv;\n return;\n }\n\n // After connected, normal setAttribute\n const targets = resolveTargetEls(this, selector, options, currentWin);\n applySetAttribute(this, targets, attrName, nv);\n },\n enumerable: true,\n configurable: true\n });\n };\n}\n\nexport const findAllAttributeMetadata = (target: any): AttributeMetadata[] => {\n return ReflectUtils.findAllMetadata<AttributeMetadata[]>(ATTRIBUTE_METADATA_KEY, target).flat();\n};\n\n/**\n * @attributeHost decorator - simplified version of @attribute for :host selector\n * Usage: @attributeHost - uses field name as attribute name\n * Usage: @attributeHost() - uses field name as attribute name\n * Usage: @attributeHost('data-id') - uses custom attribute name\n * Usage: @attributeHost({ type: Boolean }) - uses field name with options\n * Usage: @attributeHost('data-id', { type: Boolean }) - uses custom name with options\n */\nexport function attributeHost(target: Object, propertyKey: string | symbol): void;\nexport function attributeHost(): PropertyDecorator;\nexport function attributeHost(options: AttributeOptions): PropertyDecorator;\nexport function attributeHost(attrName: string): PropertyDecorator;\nexport function attributeHost(attrName: string, options: AttributeOptions): PropertyDecorator;\nexport function attributeHost(targetOrAttrOrOptions?: any, propertyKeyOrOptions?: any): any {\n // Direct decorator usage: @attributeHost (no parentheses)\n if (propertyKeyOrOptions !== undefined && (typeof propertyKeyOrOptions === 'string' || typeof propertyKeyOrOptions === 'symbol')) {\n const fieldName = String(propertyKeyOrOptions);\n return attribute(':host', { name: fieldName })(targetOrAttrOrOptions, propertyKeyOrOptions);\n }\n\n // @attributeHost() or @attributeHost(options) or @attributeHost('name')\n if (typeof targetOrAttrOrOptions === 'string') {\n // @attributeHost('customName') or @attributeHost('customName', options)\n const attrName = targetOrAttrOrOptions;\n const options = (typeof propertyKeyOrOptions === 'object' ? propertyKeyOrOptions : {}) as AttributeOptions;\n return attribute(':host', { ...options, name: attrName });\n } else if (typeof targetOrAttrOrOptions === 'object') {\n // @attributeHost(options) - use field name as attribute name\n const options = targetOrAttrOrOptions as AttributeOptions;\n return (target: Object, propertyKey: string | symbol) => {\n const fieldName = String(propertyKey);\n return attribute(':host', { ...options, name: fieldName })(target, propertyKey);\n };\n } else {\n // @attributeHost() - use field name as attribute name\n return (target: Object, propertyKey: string | symbol) => {\n const fieldName = String(propertyKey);\n return attribute(':host', { name: fieldName })(target, propertyKey);\n };\n }\n}\n"],
5
+ "mappings": "AAAA,SAAQ,oBAAmB;AAC3B,SAAoB,wBAAuB;AAC3C,SAAQ,gBAAe;AAgBhB,MAAM,yBAAyB,OAAO,gCAAgC;AAK7E,MAAM,eAAe,CAAC,KAAoB,SAAmB;AAC3D,MAAI,QAAQ,QAAQ,QAAQ,OAAW,QAAO;AAC9C,MAAI,SAAS,OAAQ,QAAO,OAAO,GAAG;AACtC,MAAI,SAAS,QAAS,QAAO,QAAQ,WAAW,QAAQ,MAAM,QAAQ;AACtE,SAAO;AACT;AAKO,MAAM,mBAAmB,CAAC,MAAW,UAAkB,SAA2B,eAAmC;AAC1H,QAAM,IAAI,QAAQ,QAAQ;AAC1B,QAAM,UAAyB,CAAC;AAEhC,QAAM,YAAY,CAAC,WAAgB;AACjC,QAAI,CAAC,OAAQ;AACb,QAAI,MAAM,QAAQ;AAGhB,cAAQ,KAAK,MAAM;AAAA,IACrB,OAAO;AACL,UAAI,MAAM,WAAW,MAAM,MAAO,SAAQ,KA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I,OAAO,0BAA0B,UAAU;AAE7C,UAAM,WAAW;AACjB,UAAM,UAAW,OAAO,yBAAyB,WAAW,uBAAuB,CAAC;AACpF,WAAO,UAAU,SAAS,EAAE,GAAG,SAAS,MAAM,SAAS,CAAC;AAAA,EAC1D,WAAW,OAAO,0BAA0B,UAAU;AAEpD,UAAM,UAAU;AAChB,WAAO,CAAC,QAAgB,gBAAiC;AACvD,YAAM,YAAY,OAAO,WAAW;AACpC,aAAO,UAAU,SAAS,EAAE,GAAG,SAAS,MAAM,UAAU,CAAC,EAAE,QAAQ,WAAW;AAAA,IAChF;AAAA,EACF,OAAO;AAEL,WAAO,CAAC,QAAgB,gBAAiC;AACvD,YAAM,YAAY,OAAO,WAAW;AACpC,aAAO,UAAU,SAAS,EAAE,MAAM,UAAU,CAAC,EAAE,QAAQ,WAAW;AAAA,IACpE;AAAA,EACF;AACF;",
6
6
  "names": ["targets"]
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/decorators/changedAttributeHost.ts"],
4
- "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\n\nexport const ON_ATTRIBUTE_CHANGED_METADATA_KEY = Symbol('simple-web-component:on-attribute-changed');\n\n/**\n * @changedAttributeHost decorator - fires when any attribute on :host changes\n * Usage: @changedAttributeHost('data-product-id')\n */\nexport function changedAttributeHost(attributeName?: string): MethodDecorator {\n return (target: Object, propertyKey: string | symbol) => {\n const constructor = target.constructor;\n let meta = ReflectUtils.getOwnMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor) as Map<string, (string | symbol)[]>;\n if (!meta) {\n meta = new Map<string, (string | symbol)[]>();\n ReflectUtils.defineMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, meta, constructor);\n }\n\n const name = attributeName || String(propertyKey);\n let methods = meta.get(name);\n if (!methods) {\n methods = [];\n meta.set(name, methods);\n }\n if (!methods.includes(propertyKey)) methods.push(propertyKey);\n };\n}\n\nexport const getChangedAttributeMetadata = (target: any): Map<string, (string | symbol)[]> | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor);\n};\n\nexport const findAllAttributeChangedMetadata = (target: any): Map<string, (string | symbol)[]> => {\n return ReflectUtils.findAllMapMetadata<string, string | symbol>(ON_ATTRIBUTE_CHANGED_METADATA_KEY, target);\n};\n"],
5
- "mappings": "AAAA,SAAS,oBAAoB;AAEtB,MAAM,oCAAoC,OAAO,2CAA2C;AAM5F,SAAS,qBAAqB,eAAyC;AAC5E,SAAO,CAAC,QAAgB,gBAAiC;AACvD,UAAM,cAAc,OAAO;AAC3B,QAAI,OAAO,aAAa,eAAe,mCAAmC,WAAW;AACrF,QAAI,CAAC,MAAM;AACT,aAAO,oBAAI,IAAiC;AAC5C,mBAAa,eAAe,mCAAmC,MAAM,WAAW;AAAA,IAClF;AAEA,UAAM,OAAO,iBAAiB,OAAO,WAAW;AAChD,QAAI,UAAU,KAAK,IAAI,IAAI;AAC3B,QAAI,CAAC,SAAS;AACZ,gBAAU,CAAC;AACX,WAAK,IAAI,MAAM,OAAO;AAAA,IACxB;AACA,QAAI,CAAC,QAAQ,SAAS,WAAW,EAAG,SAAQ,KAAK,WAAW;AAAA,EAC9D;AACF;AAEO,MAAM,8BAA8B,CAAC,WAA8D;AACxG,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,SAAO,aAAa,YAAY,mCAAmC,WAAW;AAChF;AAEO,MAAM,kCAAkC,CAAC,WAAkD;AAChG,SAAO,aAAa,mBAA4C,mCAAmC,MAAM;AAC3G;",
4
+ "sourcesContent": ["import {ReflectUtils} from '@dooboostore/core';\n\nexport const ON_ATTRIBUTE_CHANGED_METADATA_KEY = Symbol('simple-web-component:on-attribute-changed');\n\n/**\n * @changedAttributeHost decorator - fires when any attribute on :host changes\n * Usage: @changedAttributeHost('data-product-id')\n */\nexport function changedAttributeHost(attributeName?: string): MethodDecorator {\n return (target: Object, propertyKey: string | symbol) => {\n const constructor = target.constructor;\n let meta = ReflectUtils.getOwnMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor) as Map<string, (string | symbol)[]>;\n if (!meta) {\n meta = new Map<string, (string | symbol)[]>();\n ReflectUtils.defineMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, meta, constructor);\n }\n\n const name = attributeName || String(propertyKey);\n let methods = meta.get(name);\n if (!methods) {\n methods = [];\n meta.set(name, methods);\n }\n if (!methods.includes(propertyKey)) methods.push(propertyKey);\n };\n}\n\nexport const getChangedAttributeMetadata = (target: any): Map<string, (string | symbol)[]> | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor);\n};\n\nexport const findAllAttributeChangedMetadata = (target: any): Map<string, (string | symbol)[]> => {\n return ReflectUtils.findAllMapMetadata<string, string | symbol>(ON_ATTRIBUTE_CHANGED_METADATA_KEY, target);\n};\n"],
5
+ "mappings": "AAAA,SAAQ,oBAAmB;AAEpB,MAAM,oCAAoC,OAAO,2CAA2C;AAM5F,SAAS,qBAAqB,eAAyC;AAC5E,SAAO,CAAC,QAAgB,gBAAiC;AACvD,UAAM,cAAc,OAAO;AAC3B,QAAI,OAAO,aAAa,eAAe,mCAAmC,WAAW;AACrF,QAAI,CAAC,MAAM;AACT,aAAO,oBAAI,IAAiC;AAC5C,mBAAa,eAAe,mCAAmC,MAAM,WAAW;AAAA,IAClF;AAEA,UAAM,OAAO,iBAAiB,OAAO,WAAW;AAChD,QAAI,UAAU,KAAK,IAAI,IAAI;AAC3B,QAAI,CAAC,SAAS;AACZ,gBAAU,CAAC;AACX,WAAK,IAAI,MAAM,OAAO;AAAA,IACxB;AACA,QAAI,CAAC,QAAQ,SAAS,WAAW,EAAG,SAAQ,KAAK,WAAW;AAAA,EAC9D;AACF;AAEO,MAAM,8BAA8B,CAAC,WAA8D;AACxG,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,SAAO,aAAa,YAAY,mCAAmC,WAAW;AAChF;AAEO,MAAM,kCAAkC,CAAC,WAAkD;AAChG,SAAO,aAAa,mBAA4C,mCAAmC,MAAM;AAC3G;",
6
6
  "names": []
7
7
  }