@dooboostore/simple-web-component 1.0.34 → 1.0.35

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 (107) hide show
  1. package/README.md +23 -30
  2. package/dist/cjs/decorators/applyNode.js +4 -0
  3. package/dist/cjs/decorators/applyNode.js.map +2 -2
  4. package/dist/cjs/decorators/attribute.js +1 -1
  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/elementDefine.js +225 -180
  8. package/dist/cjs/decorators/elementDefine.js.map +2 -2
  9. package/dist/cjs/decorators/emitCustomEvent.js +10 -4
  10. package/dist/cjs/decorators/emitCustomEvent.js.map +2 -2
  11. package/dist/cjs/decorators/lifecycles.js +15 -17
  12. package/dist/cjs/decorators/lifecycles.js.map +2 -2
  13. package/dist/cjs/decorators/subscribeSwcAppRouteChangeWhileConnected.js +2 -2
  14. package/dist/cjs/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +2 -2
  15. package/dist/cjs/elements/SwcAppEngine.js +8 -2
  16. package/dist/cjs/elements/SwcAppEngine.js.map +2 -2
  17. package/dist/cjs/elements/SwcAppMixin.js +120 -65
  18. package/dist/cjs/elements/SwcAppMixin.js.map +2 -2
  19. package/dist/cjs/elements/SwcAsync.js +28 -18
  20. package/dist/cjs/elements/SwcAsync.js.map +2 -2
  21. package/dist/cjs/elements/SwcChoose.js +51 -32
  22. package/dist/cjs/elements/SwcChoose.js.map +2 -2
  23. package/dist/cjs/elements/SwcIf.js +52 -30
  24. package/dist/cjs/elements/SwcIf.js.map +2 -2
  25. package/dist/cjs/elements/SwcLoop.js +109 -35
  26. package/dist/cjs/elements/SwcLoop.js.map +2 -2
  27. package/dist/cjs/elements/register.js +244 -117
  28. package/dist/cjs/elements/register.js.map +2 -2
  29. package/dist/cjs/router/ElementRouter.js +4 -2
  30. package/dist/cjs/router/ElementRouter.js.map +1 -1
  31. package/dist/cjs/types.js.map +1 -1
  32. package/dist/cjs/utils/Utils.js +18 -4
  33. package/dist/cjs/utils/Utils.js.map +2 -2
  34. package/dist/esm/decorators/applyNode.js +4 -0
  35. package/dist/esm/decorators/applyNode.js.map +2 -2
  36. package/dist/esm/decorators/attribute.js +1 -1
  37. package/dist/esm/decorators/attribute.js.map +2 -2
  38. package/dist/esm/decorators/changedAttributeHost.js.map +2 -2
  39. package/dist/esm/decorators/elementDefine.js +226 -181
  40. package/dist/esm/decorators/elementDefine.js.map +2 -2
  41. package/dist/esm/decorators/emitCustomEvent.js +10 -4
  42. package/dist/esm/decorators/emitCustomEvent.js.map +2 -2
  43. package/dist/esm/decorators/lifecycles.js +15 -17
  44. package/dist/esm/decorators/lifecycles.js.map +2 -2
  45. package/dist/esm/decorators/subscribeSwcAppRouteChangeWhileConnected.js +2 -2
  46. package/dist/esm/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +2 -2
  47. package/dist/esm/elements/SwcAppEngine.js +9 -2
  48. package/dist/esm/elements/SwcAppEngine.js.map +2 -2
  49. package/dist/esm/elements/SwcAppMixin.js +122 -66
  50. package/dist/esm/elements/SwcAppMixin.js.map +2 -2
  51. package/dist/esm/elements/SwcAsync.js +28 -18
  52. package/dist/esm/elements/SwcAsync.js.map +2 -2
  53. package/dist/esm/elements/SwcChoose.js +51 -32
  54. package/dist/esm/elements/SwcChoose.js.map +2 -2
  55. package/dist/esm/elements/SwcIf.js +53 -31
  56. package/dist/esm/elements/SwcIf.js.map +2 -2
  57. package/dist/esm/elements/SwcLoop.js +110 -36
  58. package/dist/esm/elements/SwcLoop.js.map +2 -2
  59. package/dist/esm/elements/register.js +244 -117
  60. package/dist/esm/elements/register.js.map +2 -2
  61. package/dist/esm/router/ElementRouter.js +5 -2
  62. package/dist/esm/router/ElementRouter.js.map +1 -1
  63. package/dist/esm/types.js.map +1 -1
  64. package/dist/esm/utils/Utils.js +18 -4
  65. package/dist/esm/utils/Utils.js.map +2 -2
  66. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +319 -276
  67. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
  68. package/dist/types/decorators/applyNode.d.ts +1 -0
  69. package/dist/types/decorators/applyNode.d.ts.map +1 -1
  70. package/dist/types/decorators/changedAttributeHost.d.ts +1 -0
  71. package/dist/types/decorators/changedAttributeHost.d.ts.map +1 -1
  72. package/dist/types/decorators/elementDefine.d.ts.map +1 -1
  73. package/dist/types/decorators/emitCustomEvent.d.ts +10 -6
  74. package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
  75. package/dist/types/decorators/lifecycles.d.ts +10 -7
  76. package/dist/types/decorators/lifecycles.d.ts.map +1 -1
  77. package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts +4 -5
  78. package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts.map +1 -1
  79. package/dist/types/elements/SwcAppEngine.d.ts +4 -1
  80. package/dist/types/elements/SwcAppEngine.d.ts.map +1 -1
  81. package/dist/types/elements/SwcAppMixin.d.ts +11 -8
  82. package/dist/types/elements/SwcAppMixin.d.ts.map +1 -1
  83. package/dist/types/elements/register.d.ts.map +1 -1
  84. package/dist/types/types.d.ts +1 -0
  85. package/dist/types/types.d.ts.map +1 -1
  86. package/dist/types/utils/Utils.d.ts +4 -1
  87. package/dist/types/utils/Utils.d.ts.map +1 -1
  88. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +319 -276
  89. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
  90. package/package.json +4 -4
  91. package/src/decorators/applyNode.ts +13 -1
  92. package/src/decorators/attribute.ts +1 -1
  93. package/src/decorators/changedAttributeHost.ts +3 -2
  94. package/src/decorators/elementDefine.ts +397 -354
  95. package/src/decorators/emitCustomEvent.ts +29 -15
  96. package/src/decorators/lifecycles.ts +11 -10
  97. package/src/decorators/subscribeSwcAppRouteChangeWhileConnected.ts +10 -10
  98. package/src/elements/SwcAppEngine.ts +10 -3
  99. package/src/elements/SwcAppMixin.ts +177 -97
  100. package/src/elements/SwcAsync.ts +28 -17
  101. package/src/elements/SwcChoose.ts +71 -34
  102. package/src/elements/SwcIf.ts +59 -22
  103. package/src/elements/SwcLoop.ts +140 -27
  104. package/src/elements/register.ts +296 -98
  105. package/src/types.ts +1 -0
  106. package/src/utils/Utils.ts +23 -5
  107. package/tsconfig.json +2 -2
@@ -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 { HelperHostSet, 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 * Filter function to determine whether to perform DOM operation.\n * If it returns false, the operation is skipped.\n */\n filter?: (target: HTMLElement | ShadowRoot, newValue: any, meta:{currentThis: any,helper: HelperHostSet}) => boolean;\n /**\n * Optional loading content to display while an async method is executing.\n */\n loading?: (helper: HelperHostSet) => any;\n}\n\nexport interface ApplyNodeMetadata {\n propertyKey: string | symbol;\n selector: string;\n options: ApplyNodeOptions;\n}\n\nexport const APPLY_NODE_METADATA_KEY = Symbol.for('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\nconst applyToDom = (targetEl: any, res: any, pos: ApplyNodePosition, doc: Document) => {\n if (!targetEl) return;\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 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\n/**\n * @applyNode decorator to surgically add/replace nodes to a target element.\n */\nexport function applyNode(selector: string, options: ApplyNodeOptions = { position: 'beforeEnd' }): MethodDecorator {\n return (targetObj: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = targetObj.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 = function (...args: any[]) {\n ensureInit(this);\n \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 const hostSet = SwcUtils.getHelperAndHostSet(currentWin, this);\n \n const getTarget = () => {\n const r = options.root || 'auto';\n const applyRoot = (t: any) => {\n if (!t) return t;\n if (r === 'auto') return t.shadowRoot || t;\n if (r === 'shadow') return t.shadowRoot;\n if (r === 'light') return t;\n if (r === 'all') return t.shadowRoot || t;\n return t;\n };\n\n if (selector === ':host') return applyRoot(this);\n if (selector === ':parentHost') return applyRoot(hostSet.$parentHost);\n if (selector === ':appHost') return applyRoot(hostSet.$appHost);\n if (selector === ':firstHost') return applyRoot(hostSet.$firstHost);\n if (selector === ':lastHost') return applyRoot(hostSet.$lastHost);\n \n const targetRoot = applyRoot(this);\n return targetRoot ? targetRoot.querySelector(selector) : null;\n };\n\n const targetEl = getTarget();\n const res = original.apply(this, args);\n\n const runApply = (target: any, val: any) => {\n const pos = options.position || 'beforeEnd';\n \n // \uC0AC\uC6A9\uC790\uAC00 filter\uB97C \uBA85\uC2DC\uD558\uBA74 \uADF8 \uC870\uAC74\uC73C\uB85C, \uC544\uB2C8\uBA74 \uD56D\uC0C1 \uC801\uC6A9\n if (!options.filter || options.filter(target, val, {currentThis: this, helper: hostSet})) {\n applyToDom(target, val, pos, currentDoc);\n }\n };\n\n if (res instanceof Promise) {\n // \uBE44\uB3D9\uAE30\uC77C \uB54C\uB9CC \uB85C\uB529 \uD45C\uC2DC\n if (targetEl && options.loading) {\n const loadingRes = options.loading.call(this, hostSet);\n applyToDom(targetEl, loadingRes, options.position || 'beforeEnd', currentDoc);\n }\n\n return res.then(finalRes => {\n if (finalRes !== undefined && targetEl) runApply(targetEl, finalRes);\n return finalRes;\n });\n } else {\n if (res !== undefined && targetEl) runApply(targetEl, res);\n return res;\n }\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\nexport function applyNodeHost(options: ApplyNodeOptions): MethodDecorator;\nexport function applyNodeHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function applyNodeHost(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n if (propertyKey !== undefined) return applyNode(':host', { position: 'beforeEnd' })(targetOrOptions, propertyKey, descriptor);\n const opt = targetOrOptions || {};\n return applyNode(':host', { position: 'beforeEnd', ...opt });\n}\n\nexport function applyReplaceChildrenNodeHost(options: ApplyNodeOptions): MethodDecorator;\nexport function applyReplaceChildrenNodeHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function applyReplaceChildrenNodeHost(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n if (propertyKey !== undefined) return applyNode(':host', { position: 'replaceChildren' })(targetOrOptions, propertyKey, descriptor);\n const opt = targetOrOptions || {};\n return applyNode(':host', { position: 'replaceChildren', ...opt });\n}\n\nexport function applyInnerHtmlNodeHost(options: ApplyNodeOptions): MethodDecorator;\nexport function applyInnerHtmlNodeHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function applyInnerHtmlNodeHost(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n if (propertyKey !== undefined) return applyNode(':host', { position: 'innerHtml' })(targetOrOptions, propertyKey, descriptor);\n const opt = targetOrOptions || {};\n return applyNode(':host', { position: 'innerHtml', ...opt });\n}\n\nexport function applyReplaceChildrenNode(selector: string, options: ApplyNodeOptions = {}): MethodDecorator {\n return applyNode(selector, { ...options, position: 'replaceChildren' });\n}\n\nexport function applyInnerHtmlNode(selector: string, options: ApplyNodeOptions = {}): MethodDecorator {\n return applyNode(selector, { ...options, position: 'innerHtml' });\n}\n"],
5
- "mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,YAAY,wBAAwB;AAE7C,SAAS,gBAAgB;AAwBlB,MAAM,0BAA0B,OAAO,IAAI,iCAAiC;AAEnF,MAAM,iBAAiB,CAAC,KAAU,QAA0B;AAC1D,QAAM,QAAQ,MAAM,QAAQ,GAAG,IAAI,MAAM,CAAC,GAAG;AAC7C,SAAO,MAAM,IAAI,QAAM;AACrB,QAAI,cAAc,KAAM,QAAO;AAC/B,WAAO,IAAI,eAAe,OAAO,UA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AAU,SAAS,EAAE,UAAU,aAAa,GAAG,IAAI,CAAC;AAC7D;AAEO,SAAS,yBAAyB,UAAkB,UAA4B,CAAC,GAAoB;AACxG,SAAO,UAAU,UAAU,EAAE,GAAG,SAAS,UAAU,kBAAkB,CAAC;AAC1E;AAEO,SAAS,mBAAmB,UAAkB,UAA4B,CAAC,GAAoB;AAClG,SAAO,UAAU,UAAU,EAAE,GAAG,SAAS,UAAU,YAAY,CAAC;AACpE;",
4
+ "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit, getElementConfig } from './elementDefine';\nimport { HelperHostSet, SwcRootType } from '../types';\nimport { SwcUtils } from \"../utils/Utils\";\n/*\n<!-- beforebegin -->\n<p>\n <!-- afterbegin -->\n foo\n <!-- beforeend -->\n</p>\n<!-- afterend -->\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 * Filter function to determine whether to perform DOM operation.\n * If it returns false, the operation is skipped.\n */\n filter?: (target: HTMLElement | ShadowRoot, newValue: any, meta:{currentThis: any,helper: HelperHostSet}) => boolean;\n /**\n * Optional loading content to display while an async method is executing.\n */\n loading?: (helper: HelperHostSet) => any;\n}\n\nexport interface ApplyNodeMetadata {\n propertyKey: string | symbol;\n selector: string;\n options: ApplyNodeOptions;\n}\n\nexport const APPLY_NODE_METADATA_KEY = Symbol.for('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\nconst applyToDom = (targetEl: any, res: any, pos: ApplyNodePosition, doc: Document) => {\n if (!targetEl) return;\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 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\n/**\n * @applyNode decorator to surgically add/replace nodes to a target element.\n */\nexport function applyNode(selector: string, options: ApplyNodeOptions = { position: 'beforeEnd' }): MethodDecorator {\n return (targetObj: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = targetObj.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 = function (...args: any[]) {\n ensureInit(this);\n \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 const hostSet = SwcUtils.getHelperAndHostSet(currentWin, this);\n \n const getTarget = () => {\n const r = options.root || 'auto';\n const applyRoot = (t: any) => {\n if (!t) return t;\n if (r === 'auto') return t.shadowRoot || t;\n if (r === 'shadow') return t.shadowRoot;\n if (r === 'light') return t;\n if (r === 'all') return t.shadowRoot || t;\n return t;\n };\n\n if (selector === ':host') return applyRoot(this);\n if (selector === ':parentHost') return applyRoot(hostSet.$parentHost);\n if (selector === ':appHost') return applyRoot(hostSet.$appHost);\n if (selector === ':firstHost') return applyRoot(hostSet.$firstHost);\n if (selector === ':lastHost') return applyRoot(hostSet.$lastHost);\n \n const targetRoot = applyRoot(this);\n return targetRoot ? targetRoot.querySelector(selector) : null;\n };\n\n const targetEl = getTarget();\n const res = original.apply(this, args);\n\n const runApply = (target: any, val: any) => {\n const pos = options.position || 'beforeEnd';\n \n // \uC0AC\uC6A9\uC790\uAC00 filter\uB97C \uBA85\uC2DC\uD558\uBA74 \uADF8 \uC870\uAC74\uC73C\uB85C, \uC544\uB2C8\uBA74 \uD56D\uC0C1 \uC801\uC6A9\n if (!options.filter || options.filter(target, val, {currentThis: this, helper: hostSet})) {\n applyToDom(target, val, pos, currentDoc);\n }\n };\n\n if (res instanceof Promise) {\n // \uBE44\uB3D9\uAE30\uC77C \uB54C\uB9CC \uB85C\uB529 \uD45C\uC2DC\n if (targetEl && options.loading) {\n const loadingRes = options.loading.call(this, hostSet);\n applyToDom(targetEl, loadingRes, options.position || 'beforeEnd', currentDoc);\n }\n\n return res.then(finalRes => {\n if (finalRes !== undefined && targetEl) runApply(targetEl, finalRes);\n return finalRes;\n });\n } else {\n if (res !== undefined && targetEl) runApply(targetEl, res);\n return res;\n }\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\nexport function applyNodeHost(options: ApplyNodeOptions): MethodDecorator;\nexport function applyNodeHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function applyNodeHost(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n if (propertyKey !== undefined) return applyNode(':host', { position: 'beforeEnd' })(targetOrOptions, propertyKey, descriptor);\n const opt = targetOrOptions || {};\n return applyNode(':host', { position: 'beforeEnd', ...opt });\n}\n\nexport function applyReplaceChildrenNodeHost(options: ApplyNodeOptions): MethodDecorator;\nexport function applyReplaceChildrenNodeHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function applyReplaceChildrenNodeHost(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n if (propertyKey !== undefined) return applyNode(':host', { position: 'replaceChildren' })(targetOrOptions, propertyKey, descriptor);\n const opt = targetOrOptions || {};\n return applyNode(':host', { position: 'replaceChildren', ...opt });\n}\n\nexport function applyInnerHtmlNodeHost(options: ApplyNodeOptions): MethodDecorator;\nexport function applyInnerHtmlNodeHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function applyInnerHtmlNodeHost(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n if (propertyKey !== undefined) return applyNode(':host', { position: 'innerHtml' })(targetOrOptions, propertyKey, descriptor);\n const opt = targetOrOptions || {};\n return applyNode(':host', { position: 'innerHtml', ...opt });\n}\n\nexport function applyReplaceChildrenNode(selector: string, options: ApplyNodeOptions = {}): MethodDecorator {\n return applyNode(selector, { ...options, position: 'replaceChildren' });\n}\n\nexport function applyInnerHtmlNode(selector: string, options: ApplyNodeOptions = {}): MethodDecorator {\n return applyNode(selector, { ...options, position: 'innerHtml' });\n}\n\nexport function applyInnerTextNode(selector: string, options: ApplyNodeOptions = {}): MethodDecorator {\n return applyNode(selector, { ...options, position: 'innerText' });\n}\n"],
5
+ "mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,YAAY,wBAAwB;AAE7C,SAAS,gBAAgB;AAgClB,MAAM,0BAA0B,OAAO,IAAI,iCAAiC;AAEnF,MAAM,iBAAiB,CAAC,KAAU,QAA0B;AAC1D,QAAM,QAAQ,MAAM,QAA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BAAgB,OAAW,QAAO,UAAU,SAAS,EAAE,UAAU,YAAY,CAAC,EAAE,iBAAiB,aAAa,UAAU;AAC5H,QAAM,MAAM,mBAAmB,CAAC;AAChC,SAAO,UAAU,SAAS,EAAE,UAAU,aAAa,GAAG,IAAI,CAAC;AAC7D;AAEO,SAAS,yBAAyB,UAAkB,UAA4B,CAAC,GAAoB;AACxG,SAAO,UAAU,UAAU,EAAE,GAAG,SAAS,UAAU,kBAAkB,CAAC;AAC1E;AAEO,SAAS,mBAAmB,UAAkB,UAA4B,CAAC,GAAoB;AAClG,SAAO,UAAU,UAAU,EAAE,GAAG,SAAS,UAAU,YAAY,CAAC;AACpE;AAEO,SAAS,mBAAmB,UAAkB,UAA4B,CAAC,GAAoB;AAClG,SAAO,UAAU,UAAU,EAAE,GAAG,SAAS,UAAU,YAAY,CAAC;AACpE;",
6
6
  "names": []
7
7
  }
@@ -17,7 +17,7 @@ const getAttributeValue = (inst, attrName, options) => {
17
17
  if (primaryTarget && typeof primaryTarget.hasAttribute === "function" && primaryTarget.hasAttribute(attrName)) {
18
18
  let domVal = primaryTarget.getAttribute(attrName);
19
19
  const ae = new ActionExpression(domVal);
20
- const expr = ae.getFirstExpression("call-return");
20
+ const expr = ae.getFirstExpression("callReturn");
21
21
  if (expr) {
22
22
  try {
23
23
  const result = FunctionUtils.executeReturn({
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/decorators/attribute.ts"],
4
- "sourcesContent": ["import { ReflectUtils, FunctionUtils, ActionExpression } from '@dooboostore/core';\nimport { ensureInit, getElementConfig } from './elementDefine';\nimport { SwcUtils } from '../utils/Utils';\nimport { SpecialSelector, SwcQueryOptions } from '../types';\nimport { ConvertUtils } from '@dooboostore/core-web';\nexport interface AttributeFieldOptions extends SwcQueryOptions {\n name?: string;\n // connectedInitialize?: boolean;\n type?: typeof Number | typeof Boolean | typeof String;\n}\n\nexport interface AttributeFieldMetadata {\n propertyKey: string | symbol;\n selector: string;\n options: AttributeFieldOptions;\n privateKey: symbol;\n}\n\nexport const ATTRIBUTE_FIELD_METADATA_KEY = Symbol.for('simple-web-component:attribute-field');\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\nexport { convertValue };\n\nexport const getAttributeValue = (inst: any, attrName: string, options?: AttributeFieldOptions & { selector?: string }): any => {\n const conf = getElementConfig(inst);\n const currentWin = inst._resolveWindow?.(conf) || ((typeof window !== 'undefined' ? window : undefined) as any);\n\n // If selector is not provided, use inst itself\n const targets = options?.selector ? resolveTargetEls(inst, options.selector, options, currentWin) : [inst];\n\n const primaryTarget = targets[0];\n\n if (primaryTarget && typeof (primaryTarget as any).hasAttribute === 'function' && (primaryTarget as any).hasAttribute(attrName)) {\n let domVal = (primaryTarget as any).getAttribute(attrName);\n\n // \uD45C\uD604\uC2DD \uCCB4\uD06C\n const ae = new ActionExpression(domVal);\n const expr = ae.getFirstExpression('call-return');\n if (expr) {\n try {\n const result = FunctionUtils.executeReturn({\n script: ConvertUtils.decodeHtmlEntity(expr.script, currentWin.document),\n context: inst,\n args: SwcUtils.getHelperAndHostSet(currentWin, inst)\n });\n return convertValue(result, options?.type);\n } catch (e) {\n console.error(`[SWC] Failed to execute directive {{= ${expr.script} }}:`, e);\n return convertValue(domVal, options?.type);\n }\n }\n\n return convertValue(domVal, options?.type);\n }\n\n // If no target found, return null\n return null;\n};\n\nexport const resolveTargetEls = (inst: any, selector: string, options: AttributeFieldOptions, 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 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: AttributeFieldOptions = {}): 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_FIELD_METADATA_KEY, constructor) as AttributeFieldMetadata[];\n if (!metaList) {\n metaList = [];\n ReflectUtils.defineMetadata(ATTRIBUTE_FIELD_METADATA_KEY, metaList, constructor);\n }\n metaList.push({ propertyKey, selector, options, privateKey });\n\n const applySetAttribute = (inst: any, targets: HTMLElement[], attrName: string, nv: any) => {\n targets.forEach(it => {\n // console.log('sssssssssssss', it, attrName, nv);\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 try {\n // Own property\uB97C \uC0AD\uC81C\uD558\uC5EC getter\uAC00 \uC791\uB3D9\uD558\uB3C4\uB85D \uD568\n // delete target[propertyKey];\n\n // const defineTarget = target instanceof Function ? target : (target as any).constructor;\n\n Object.defineProperty(target, propertyKey, {\n get(this: any) {\n const attrName = options.name || String(propertyKey);\n\n // Merge designType fallback into options once\n const mergedOptions = {\n ...options,\n selector,\n type: options.type || designType\n };\n\n const result = getAttributeValue(this, attrName, mergedOptions);\n return result !== null ? result : this[privateKey];\n },\n set(this: any, nv: any) {\n // this[propertyKey] = nv;\n // console.log('------>??settttt', this, nv, propertyKey);\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 // if (!this.__swc_connected) {\n // this[privateKey] = nv;\n // return;\n // }\n\n const targets = resolveTargetEls(this, selector, options, currentWin);\n applySetAttribute(this, targets, attrName, nv);\n },\n enumerable: true,\n configurable: true\n });\n } catch (err) {\n console.error('[SWC] defineProperty error:', err);\n }\n };\n}\n\n/**\n * @attributeHost decorator to sync a field value with the :host element's attribute.\n */\nexport function attributeHost(target: Object, propertyKey: string | symbol): void;\nexport function attributeHost(options: AttributeFieldOptions): PropertyDecorator;\nexport function attributeHost(attrName: string): PropertyDecorator;\nexport function attributeHost(attrName: string, options: AttributeFieldOptions): PropertyDecorator;\nexport function attributeHost(targetOrAttrOrOptions?: any, propertyKeyOrOptions?: any): any {\n if (propertyKeyOrOptions !== undefined && (typeof propertyKeyOrOptions === 'string' || typeof propertyKeyOrOptions === 'symbol')) {\n return attribute(':host', { name: String(propertyKeyOrOptions) })(targetOrAttrOrOptions, propertyKeyOrOptions);\n }\n\n if (typeof targetOrAttrOrOptions === 'string') {\n const attrName = targetOrAttrOrOptions;\n const options = (typeof propertyKeyOrOptions === 'object' ? propertyKeyOrOptions : {}) as AttributeFieldOptions;\n return attribute(':host', { ...options, name: attrName });\n } else if (typeof targetOrAttrOrOptions === 'object') {\n const options = targetOrAttrOrOptions as AttributeFieldOptions;\n return (target: Object, propertyKey: string | symbol) => {\n return attribute(':host', { ...options, name: String(propertyKey) })(target, propertyKey);\n };\n } else {\n return (target: Object, propertyKey: string | symbol) => {\n return attribute(':host', { name: String(propertyKey) })(target, propertyKey);\n };\n }\n}\n\nexport const findAllAttributeMetadata = (target: any): AttributeFieldMetadata[] => {\n const actualTarget = target instanceof Function ? target : target.constructor;\n return ReflectUtils.findAllMetadata<AttributeFieldMetadata[]>(ATTRIBUTE_FIELD_METADATA_KEY, actualTarget).flat();\n};\n"],
5
- "mappings": "AAAA,SAAS,cAAc,eAAe,wBAAwB;AAC9D,SAAqB,wBAAwB;AAC7C,SAAS,gBAAgB;AAEzB,SAAS,oBAAoB;AActB,MAAM,+BAA+B,OAAO,IAAI,sCAAsC;AAE7F,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;AAIO,MAAM,oBAAoB,CAAC,MAAW,UAAkB,YAAiE;AAC9H,QAAM,OAAO,iBAAiB,IAAI;AAClC,QAAM,aAAa,KAAK,iBAAiB,IAAI,MAAO,OAAO,WAAW,cAAc,SAAS;AAG7F,QAAM,UAAU,SAAS,WAAW,iBAAiB,MAAM,QAAQ,UAAU,SAAS,UAAU,IAAI,CAAC,IAAI;AAEzG,QAAM,gBAAgB,QAAQ,CAAC;AAE/B,MAAI,iBAAiB,OAAQ,cAAsB,iBAAiB,cAAe,cAAsB,aAAa,QAAQ,GAAG;AAC/H,QAAI,SAAU,cAAsB,aAAa,QAAQ;AAGzD,UAAM,KAAK,IAAI,iBAAiB,MAAM;AACtC,UAAM,OAAO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uBAAuB,CAAC;AACpF,WAAO,UAAU,SAAS,EAAE,GAAG,SAAS,MAAM,SAAS,CAAC;AAAA,EAC1D,WAAW,OAAO,0BAA0B,UAAU;AACpD,UAAM,UAAU;AAChB,WAAO,CAAC,QAAgB,gBAAiC;AACvD,aAAO,UAAU,SAAS,EAAE,GAAG,SAAS,MAAM,OAAO,WAAW,EAAE,CAAC,EAAE,QAAQ,WAAW;AAAA,IAC1F;AAAA,EACF,OAAO;AACL,WAAO,CAAC,QAAgB,gBAAiC;AACvD,aAAO,UAAU,SAAS,EAAE,MAAM,OAAO,WAAW,EAAE,CAAC,EAAE,QAAQ,WAAW;AAAA,IAC9E;AAAA,EACF;AACF;AAEO,MAAM,2BAA2B,CAAC,WAA0C;AACjF,QAAM,eAAe,kBAAkB,WAAW,SAAS,OAAO;AAClE,SAAO,aAAa,gBAA0C,8BAA8B,YAAY,EAAE,KAAK;AACjH;",
4
+ "sourcesContent": ["import { ReflectUtils, FunctionUtils, ActionExpression } from '@dooboostore/core';\nimport { ensureInit, getElementConfig } from './elementDefine';\nimport { SwcUtils } from '../utils/Utils';\nimport { SpecialSelector, SwcQueryOptions } from '../types';\nimport { ConvertUtils } from '@dooboostore/core-web';\nexport interface AttributeFieldOptions extends SwcQueryOptions {\n name?: string;\n // connectedInitialize?: boolean;\n type?: typeof Number | typeof Boolean | typeof String;\n}\n\nexport interface AttributeFieldMetadata {\n propertyKey: string | symbol;\n selector: string;\n options: AttributeFieldOptions;\n privateKey: symbol;\n}\n\nexport const ATTRIBUTE_FIELD_METADATA_KEY = Symbol.for('simple-web-component:attribute-field');\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\nexport { convertValue };\n\nexport const getAttributeValue = (inst: any, attrName: string, options?: AttributeFieldOptions & { selector?: string }): any => {\n const conf = getElementConfig(inst);\n const currentWin = inst._resolveWindow?.(conf) || ((typeof window !== 'undefined' ? window : undefined) as any);\n\n // If selector is not provided, use inst itself\n const targets = options?.selector ? resolveTargetEls(inst, options.selector, options, currentWin) : [inst];\n\n const primaryTarget = targets[0];\n\n if (primaryTarget && typeof (primaryTarget as any).hasAttribute === 'function' && (primaryTarget as any).hasAttribute(attrName)) {\n let domVal = (primaryTarget as any).getAttribute(attrName);\n\n // \uD45C\uD604\uC2DD \uCCB4\uD06C\n const ae = new ActionExpression(domVal);\n const expr = ae.getFirstExpression('callReturn');\n if (expr) {\n try {\n const result = FunctionUtils.executeReturn({\n script: ConvertUtils.decodeHtmlEntity(expr.script, currentWin.document),\n context: inst,\n args: SwcUtils.getHelperAndHostSet(currentWin, inst)\n });\n return convertValue(result, options?.type);\n } catch (e) {\n console.error(`[SWC] Failed to execute directive {{= ${expr.script} }}:`, e);\n return convertValue(domVal, options?.type);\n }\n }\n\n return convertValue(domVal, options?.type);\n }\n\n // If no target found, return null\n return null;\n};\n\nexport const resolveTargetEls = (inst: any, selector: string, options: AttributeFieldOptions, 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 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: AttributeFieldOptions = {}): 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_FIELD_METADATA_KEY, constructor) as AttributeFieldMetadata[];\n if (!metaList) {\n metaList = [];\n ReflectUtils.defineMetadata(ATTRIBUTE_FIELD_METADATA_KEY, metaList, constructor);\n }\n metaList.push({ propertyKey, selector, options, privateKey });\n\n const applySetAttribute = (inst: any, targets: HTMLElement[], attrName: string, nv: any) => {\n targets.forEach(it => {\n // console.log('sssssssssssss', it, attrName, nv);\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 try {\n // Own property\uB97C \uC0AD\uC81C\uD558\uC5EC getter\uAC00 \uC791\uB3D9\uD558\uB3C4\uB85D \uD568\n // delete target[propertyKey];\n\n // const defineTarget = target instanceof Function ? target : (target as any).constructor;\n\n Object.defineProperty(target, propertyKey, {\n get(this: any) {\n const attrName = options.name || String(propertyKey);\n\n // Merge designType fallback into options once\n const mergedOptions = {\n ...options,\n selector,\n type: options.type || designType\n };\n\n const result = getAttributeValue(this, attrName, mergedOptions);\n return result !== null ? result : this[privateKey];\n },\n set(this: any, nv: any) {\n // this[propertyKey] = nv;\n // console.log('------>??settttt', this, nv, propertyKey);\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 // if (!this.__swc_connected) {\n // this[privateKey] = nv;\n // return;\n // }\n\n const targets = resolveTargetEls(this, selector, options, currentWin);\n applySetAttribute(this, targets, attrName, nv);\n },\n enumerable: true,\n configurable: true\n });\n } catch (err) {\n console.error('[SWC] defineProperty error:', err);\n }\n };\n}\n\n/**\n * @attributeHost decorator to sync a field value with the :host element's attribute.\n */\nexport function attributeHost(target: Object, propertyKey: string | symbol): void;\nexport function attributeHost(options: AttributeFieldOptions): PropertyDecorator;\nexport function attributeHost(attrName: string): PropertyDecorator;\nexport function attributeHost(attrName: string, options: AttributeFieldOptions): PropertyDecorator;\nexport function attributeHost(targetOrAttrOrOptions?: any, propertyKeyOrOptions?: any): any {\n if (propertyKeyOrOptions !== undefined && (typeof propertyKeyOrOptions === 'string' || typeof propertyKeyOrOptions === 'symbol')) {\n return attribute(':host', { name: String(propertyKeyOrOptions) })(targetOrAttrOrOptions, propertyKeyOrOptions);\n }\n\n if (typeof targetOrAttrOrOptions === 'string') {\n const attrName = targetOrAttrOrOptions;\n const options = (typeof propertyKeyOrOptions === 'object' ? propertyKeyOrOptions : {}) as AttributeFieldOptions;\n return attribute(':host', { ...options, name: attrName });\n } else if (typeof targetOrAttrOrOptions === 'object') {\n const options = targetOrAttrOrOptions as AttributeFieldOptions;\n return (target: Object, propertyKey: string | symbol) => {\n return attribute(':host', { ...options, name: String(propertyKey) })(target, propertyKey);\n };\n } else {\n return (target: Object, propertyKey: string | symbol) => {\n return attribute(':host', { name: String(propertyKey) })(target, propertyKey);\n };\n }\n}\n\nexport const findAllAttributeMetadata = (target: any): AttributeFieldMetadata[] => {\n const actualTarget = target instanceof Function ? target : target.constructor;\n return Refl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AAS,EAAE,MAAM,OAAO,WAAW,EAAE,CAAC,EAAE,QAAQ,WAAW;AAAA,IAC9E;AAAA,EACF;AACF;AAEO,MAAM,2BAA2B,CAAC,WAA0C;AACjF,QAAM,eAAe,kBAAkB,WAAW,SAAS,OAAO;AAClE,SAAO,aAAa,gBAA0C,8BAA8B,YAAY,EAAE,KAAK;AACjH;",
6
6
  "names": []
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.for('simple-web-component:on-attribute-changed');\n\nexport interface ChangedAttributeHostOptions {\n type?: typeof Number | typeof Boolean | typeof String;\n}\n\nexport interface ChangedAttributeHostMetadata {\n attributeName: string;\n propertyKey: string | symbol;\n options: ChangedAttributeHostOptions;\n}\n\nconst convertValue = (val: any, 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 * @changedAttributeHost decorator - fires when any attribute on :host changes\n * Usage: @changedAttributeHost('data-product-id')\n * @changedAttributeHost('count', { type: Number })\n */\nexport function changedAttributeHost(attributeName?: string, options: ChangedAttributeHostOptions = {}): MethodDecorator {\n return (target: Object, propertyKey: string | symbol) => {\n const constructor = target.constructor;\n let metaList = ReflectUtils.getOwnMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor) as ChangedAttributeHostMetadata[];\n if (!metaList) {\n metaList = [];\n ReflectUtils.defineMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, metaList, constructor);\n }\n\n const name = attributeName || String(propertyKey);\n metaList.push({\n attributeName: name,\n propertyKey,\n options\n });\n };\n}\n\nexport const getChangedAttributeMetadata = (target: any): ChangedAttributeHostMetadata[] | 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, ChangedAttributeHostMetadata[]> => {\n const constructor = target instanceof Function ? target : target.constructor;\n const metaList = ReflectUtils.findAllMetadata<ChangedAttributeHostMetadata[]>(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor) || [];\n \n const result = new Map<string, ChangedAttributeHostMetadata[]>();\n metaList.forEach(meta => {\n meta.forEach(item => {\n if (!result.has(item.attributeName)) {\n result.set(item.attributeName, []);\n }\n result.get(item.attributeName)!.push(item);\n });\n });\n return result;\n};\n\nexport const convertAttributeValue = (val: any, type?: typeof Number | typeof Boolean | typeof String): any => {\n return convertValue(val, type);\n};\n"],
5
- "mappings": "AAAA,SAAQ,oBAAmB;AAEpB,MAAM,oCAAoC,OAAO,IAAI,2CAA2C;AAYvG,MAAM,eAAe,CAAC,KAAU,SAAmB;AACjD,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;AAOO,SAAS,qBAAqB,eAAwB,UAAuC,CAAC,GAAoB;AACvH,SAAO,CAAC,QAAgB,gBAAiC;AACvD,UAAM,cAAc,OAAO;AAC3B,QAAI,WAAW,aAAa,eAAe,mCAAmC,WAAW;AACzF,QAAI,CAAC,UAAU;AACb,iBAAW,CAAC;AACZ,mBAAa,eAAe,mCAAmC,UAAU,WAAW;AAAA,IACtF;AAEA,UAAM,OAAO,iBAAiB,OAAO,WAAW;AAChD,aAAS,KAAK;AAAA,MACZ,eAAe;AAAA,MACf;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH;AACF;AAEO,MAAM,8BAA8B,CAAC,WAA4D;AACtG,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,SAAO,aAAa,YAAY,mCAAmC,WAAW;AAChF;AAEO,MAAM,kCAAkC,CAAC,WAA6D;AAC3G,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,QAAM,WAAW,aAAa,gBAAgD,mCAAmC,WAAW,KAAK,CAAC;AAElI,QAAM,SAAS,oBAAI,IAA4C;AAC/D,WAAS,QAAQ,UAAQ;AACvB,SAAK,QAAQ,UAAQ;AACnB,UAAI,CAAC,OAAO,IAAI,KAAK,aAAa,GAAG;AACnC,eAAO,IAAI,KAAK,eAAe,CAAC,CAAC;AAAA,MACnC;AACA,aAAO,IAAI,KAAK,aAAa,EAAG,KAAK,IAAI;AAAA,IAC3C,CAAC;AAAA,EACH,CAAC;AACD,SAAO;AACT;AAEO,MAAM,wBAAwB,CAAC,KAAU,SAA+D;AAC7G,SAAO,aAAa,KAAK,IAAI;AAC/B;",
4
+ "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\n\nexport const ON_ATTRIBUTE_CHANGED_METADATA_KEY = Symbol.for('simple-web-component:on-attribute-changed');\n\nexport interface ChangedAttributeHostOptions {\n type?: typeof Number | typeof Boolean | typeof String;\n while?: 'connected';\n}\n\nexport interface ChangedAttributeHostMetadata {\n attributeName: string;\n propertyKey: string | symbol;\n options: ChangedAttributeHostOptions;\n}\n\nconst convertValue = (val: any, 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 * @changedAttributeHost decorator - fires when any attribute on :host changes\n * Usage: @changedAttributeHost('data-product-id')\n * @changedAttributeHost('count', { type: Number })\n */\nexport function changedAttributeHost(attributeName?: string, options: ChangedAttributeHostOptions = {}): MethodDecorator {\n return (target: Object, propertyKey: string | symbol) => {\n const constructor = target.constructor;\n let metaList = ReflectUtils.getOwnMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor) as ChangedAttributeHostMetadata[];\n if (!metaList) {\n metaList = [];\n ReflectUtils.defineMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, metaList, constructor);\n }\n\n const name = attributeName || String(propertyKey);\n metaList.push({\n attributeName: name,\n propertyKey,\n options\n });\n };\n}\n\nexport const getChangedAttributeMetadata = (target: any): ChangedAttributeHostMetadata[] | 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, ChangedAttributeHostMetadata[]> => {\n const constructor = target instanceof Function ? target : target.constructor;\n const metaList = ReflectUtils.findAllMetadata<ChangedAttributeHostMetadata[]>(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor) || [];\n\n const result = new Map<string, ChangedAttributeHostMetadata[]>();\n metaList.forEach(meta => {\n meta.forEach(item => {\n if (!result.has(item.attributeName)) {\n result.set(item.attributeName, []);\n }\n result.get(item.attributeName)!.push(item);\n });\n });\n return result;\n};\n\nexport const convertAttributeValue = (val: any, type?: typeof Number | typeof Boolean | typeof String): any => {\n return convertValue(val, type);\n};\n"],
5
+ "mappings": "AAAA,SAAS,oBAAoB;AAEtB,MAAM,oCAAoC,OAAO,IAAI,2CAA2C;AAavG,MAAM,eAAe,CAAC,KAAU,SAAmB;AACjD,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;AAOO,SAAS,qBAAqB,eAAwB,UAAuC,CAAC,GAAoB;AACvH,SAAO,CAAC,QAAgB,gBAAiC;AACvD,UAAM,cAAc,OAAO;AAC3B,QAAI,WAAW,aAAa,eAAe,mCAAmC,WAAW;AACzF,QAAI,CAAC,UAAU;AACb,iBAAW,CAAC;AACZ,mBAAa,eAAe,mCAAmC,UAAU,WAAW;AAAA,IACtF;AAEA,UAAM,OAAO,iBAAiB,OAAO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