@dooboostore/simple-web-component 1.0.19 → 1.0.22

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 (174) hide show
  1. package/README.md +2759 -201
  2. package/dist/cjs/decorators/addEventListener.js +8 -4
  3. package/dist/cjs/decorators/addEventListener.js.map +2 -2
  4. package/dist/cjs/decorators/{appendChild.js → applyNode.js} +26 -18
  5. package/dist/cjs/decorators/applyNode.js.map +7 -0
  6. package/dist/cjs/decorators/attribute.js +162 -0
  7. package/dist/cjs/decorators/attribute.js.map +7 -0
  8. package/dist/cjs/decorators/{changedAttribute.js → changedAttributeHost.js} +11 -11
  9. package/dist/cjs/decorators/changedAttributeHost.js.map +7 -0
  10. package/dist/cjs/decorators/classList.js +15 -5
  11. package/dist/cjs/decorators/classList.js.map +2 -2
  12. package/dist/cjs/decorators/elementDefine.js +124 -46
  13. package/dist/cjs/decorators/elementDefine.js.map +3 -3
  14. package/dist/cjs/decorators/emitCustomEvent.js +8 -7
  15. package/dist/cjs/decorators/emitCustomEvent.js.map +2 -2
  16. package/dist/cjs/decorators/index.js +3 -3
  17. package/dist/cjs/decorators/index.js.map +2 -2
  18. package/dist/cjs/decorators/lifecycles.js +8 -4
  19. package/dist/cjs/decorators/lifecycles.js.map +2 -2
  20. package/dist/cjs/decorators/onConnectedInnerHtml.js +4 -4
  21. package/dist/cjs/decorators/onConnectedInnerHtml.js.map +2 -2
  22. package/dist/cjs/decorators/query.js +9 -5
  23. package/dist/cjs/decorators/query.js.map +2 -2
  24. package/dist/cjs/decorators/queryAll.js +9 -5
  25. package/dist/cjs/decorators/queryAll.js.map +2 -2
  26. package/dist/cjs/decorators/setAttribute.js +51 -21
  27. package/dist/cjs/decorators/setAttribute.js.map +2 -2
  28. package/dist/cjs/decorators/style.js +4 -4
  29. package/dist/cjs/decorators/style.js.map +2 -2
  30. package/dist/cjs/elements/SwcAppEngine.js +8 -8
  31. package/dist/cjs/elements/SwcAppEngine.js.map +3 -3
  32. package/dist/cjs/elements/SwcAppMixin.js +28 -1
  33. package/dist/cjs/elements/SwcAppMixin.js.map +2 -2
  34. package/dist/cjs/elements/SwcAsync.js +6 -6
  35. package/dist/cjs/elements/SwcAsync.js.map +2 -2
  36. package/dist/cjs/elements/SwcChoose.js +6 -6
  37. package/dist/cjs/elements/SwcChoose.js.map +2 -2
  38. package/dist/cjs/elements/SwcIf.js +6 -6
  39. package/dist/cjs/elements/SwcIf.js.map +2 -2
  40. package/dist/cjs/elements/SwcLoop.js +6 -6
  41. package/dist/cjs/elements/SwcLoop.js.map +2 -2
  42. package/dist/cjs/elements/register.js +19 -18
  43. package/dist/cjs/elements/register.js.map +2 -2
  44. package/dist/cjs/index.js +6 -17
  45. package/dist/cjs/index.js.map +2 -2
  46. package/dist/cjs/router/ElementRouter.js +7 -7
  47. package/dist/cjs/router/ElementRouter.js.map +2 -2
  48. package/dist/cjs/types.js.map +2 -2
  49. package/dist/esm/decorators/addEventListener.js +5 -1
  50. package/dist/esm/decorators/addEventListener.js.map +2 -2
  51. package/dist/esm/decorators/{appendChild.js → applyNode.js} +23 -15
  52. package/dist/esm/decorators/applyNode.js.map +7 -0
  53. package/dist/esm/decorators/attribute.js +143 -0
  54. package/dist/esm/decorators/attribute.js.map +7 -0
  55. package/dist/esm/decorators/{changedAttribute.js → changedAttributeHost.js} +4 -4
  56. package/dist/esm/decorators/changedAttributeHost.js.map +7 -0
  57. package/dist/esm/decorators/classList.js +12 -2
  58. package/dist/esm/decorators/classList.js.map +2 -2
  59. package/dist/esm/decorators/elementDefine.js +119 -41
  60. package/dist/esm/decorators/elementDefine.js.map +2 -2
  61. package/dist/esm/decorators/emitCustomEvent.js +5 -4
  62. package/dist/esm/decorators/emitCustomEvent.js.map +2 -2
  63. package/dist/esm/decorators/index.js +3 -3
  64. package/dist/esm/decorators/index.js.map +1 -1
  65. package/dist/esm/decorators/lifecycles.js +5 -1
  66. package/dist/esm/decorators/lifecycles.js.map +2 -2
  67. package/dist/esm/decorators/onConnectedInnerHtml.js +1 -1
  68. package/dist/esm/decorators/onConnectedInnerHtml.js.map +1 -1
  69. package/dist/esm/decorators/query.js +6 -2
  70. package/dist/esm/decorators/query.js.map +2 -2
  71. package/dist/esm/decorators/queryAll.js +6 -2
  72. package/dist/esm/decorators/queryAll.js.map +2 -2
  73. package/dist/esm/decorators/setAttribute.js +47 -17
  74. package/dist/esm/decorators/setAttribute.js.map +2 -2
  75. package/dist/esm/decorators/style.js +1 -1
  76. package/dist/esm/decorators/style.js.map +1 -1
  77. package/dist/esm/elements/SwcAppEngine.js +4 -4
  78. package/dist/esm/elements/SwcAppEngine.js.map +2 -2
  79. package/dist/esm/elements/SwcAppMixin.js +28 -1
  80. package/dist/esm/elements/SwcAppMixin.js.map +2 -2
  81. package/dist/esm/elements/SwcAsync.js +3 -3
  82. package/dist/esm/elements/SwcAsync.js.map +2 -2
  83. package/dist/esm/elements/SwcChoose.js +3 -3
  84. package/dist/esm/elements/SwcChoose.js.map +2 -2
  85. package/dist/esm/elements/SwcIf.js +3 -3
  86. package/dist/esm/elements/SwcIf.js.map +2 -2
  87. package/dist/esm/elements/SwcLoop.js +3 -3
  88. package/dist/esm/elements/SwcLoop.js.map +2 -2
  89. package/dist/esm/elements/register.js +7 -6
  90. package/dist/esm/elements/register.js.map +2 -2
  91. package/dist/esm/index.js +6 -17
  92. package/dist/esm/index.js.map +2 -2
  93. package/dist/esm/router/ElementRouter.js +2 -2
  94. package/dist/esm/router/ElementRouter.js.map +1 -1
  95. package/dist/esm/types.js.map +2 -2
  96. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +5444 -3317
  97. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
  98. package/dist/types/decorators/addEventListener.d.ts +6 -0
  99. package/dist/types/decorators/addEventListener.d.ts.map +1 -1
  100. package/dist/types/decorators/applyNode.d.ts +38 -0
  101. package/dist/types/decorators/applyNode.d.ts.map +1 -0
  102. package/dist/types/decorators/attribute.d.ts +29 -0
  103. package/dist/types/decorators/attribute.d.ts.map +1 -0
  104. package/dist/types/decorators/{changedAttribute.d.ts → changedAttributeHost.d.ts} +6 -2
  105. package/dist/types/decorators/changedAttributeHost.d.ts.map +1 -0
  106. package/dist/types/decorators/classList.d.ts +25 -0
  107. package/dist/types/decorators/classList.d.ts.map +1 -1
  108. package/dist/types/decorators/elementDefine.d.ts.map +1 -1
  109. package/dist/types/decorators/emitCustomEvent.d.ts +14 -2
  110. package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
  111. package/dist/types/decorators/index.d.ts +3 -3
  112. package/dist/types/decorators/index.d.ts.map +1 -1
  113. package/dist/types/decorators/lifecycles.d.ts +2 -0
  114. package/dist/types/decorators/lifecycles.d.ts.map +1 -1
  115. package/dist/types/decorators/query.d.ts +6 -0
  116. package/dist/types/decorators/query.d.ts.map +1 -1
  117. package/dist/types/decorators/queryAll.d.ts +6 -0
  118. package/dist/types/decorators/queryAll.d.ts.map +1 -1
  119. package/dist/types/decorators/setAttribute.d.ts +8 -0
  120. package/dist/types/decorators/setAttribute.d.ts.map +1 -1
  121. package/dist/types/elements/SwcAppEngine.d.ts +5 -4
  122. package/dist/types/elements/SwcAppEngine.d.ts.map +1 -1
  123. package/dist/types/elements/SwcAppMixin.d.ts +1 -1
  124. package/dist/types/elements/SwcAppMixin.d.ts.map +1 -1
  125. package/dist/types/elements/register.d.ts +1 -1
  126. package/dist/types/elements/register.d.ts.map +1 -1
  127. package/dist/types/index.d.ts +3 -14
  128. package/dist/types/index.d.ts.map +1 -1
  129. package/dist/types/router/ElementRouter.d.ts +1 -1
  130. package/dist/types/router/ElementRouter.d.ts.map +1 -1
  131. package/dist/types/types.d.ts +3 -1
  132. package/dist/types/types.d.ts.map +1 -1
  133. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +5444 -3317
  134. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
  135. package/package.json +10 -5
  136. package/src/decorators/addEventListener.ts +10 -1
  137. package/src/decorators/applyNode.ts +127 -0
  138. package/src/decorators/attribute.ts +192 -0
  139. package/src/decorators/{changedAttribute.ts → changedAttributeHost.ts} +6 -2
  140. package/src/decorators/classList.ts +33 -1
  141. package/src/decorators/elementDefine.ts +148 -47
  142. package/src/decorators/emitCustomEvent.ts +14 -6
  143. package/src/decorators/index.ts +3 -3
  144. package/src/decorators/lifecycles.ts +4 -2
  145. package/src/decorators/onConnectedInnerHtml.ts +1 -1
  146. package/src/decorators/query.ts +10 -1
  147. package/src/decorators/queryAll.ts +10 -1
  148. package/src/decorators/setAttribute.ts +57 -17
  149. package/src/decorators/style.ts +1 -1
  150. package/src/elements/SwcAppEngine.ts +10 -8
  151. package/src/elements/SwcAppMixin.ts +34 -2
  152. package/src/elements/SwcAsync.ts +3 -3
  153. package/src/elements/SwcChoose.ts +3 -3
  154. package/src/elements/SwcIf.ts +3 -3
  155. package/src/elements/SwcLoop.ts +3 -3
  156. package/src/elements/register.ts +8 -6
  157. package/src/index.ts +8 -16
  158. package/src/router/ElementRouter.ts +2 -2
  159. package/src/types.ts +3 -1
  160. package/dist/cjs/decorators/appendChild.js.map +0 -7
  161. package/dist/cjs/decorators/changedAttribute.js.map +0 -7
  162. package/dist/cjs/decorators/replaceChildren.js +0 -79
  163. package/dist/cjs/decorators/replaceChildren.js.map +0 -7
  164. package/dist/esm/decorators/appendChild.js.map +0 -7
  165. package/dist/esm/decorators/changedAttribute.js.map +0 -7
  166. package/dist/esm/decorators/replaceChildren.js +0 -60
  167. package/dist/esm/decorators/replaceChildren.js.map +0 -7
  168. package/dist/types/decorators/appendChild.d.ts +0 -17
  169. package/dist/types/decorators/appendChild.d.ts.map +0 -1
  170. package/dist/types/decorators/changedAttribute.d.ts.map +0 -1
  171. package/dist/types/decorators/replaceChildren.d.ts +0 -9
  172. package/dist/types/decorators/replaceChildren.d.ts.map +0 -1
  173. package/src/decorators/appendChild.ts +0 -86
  174. package/src/decorators/replaceChildren.ts +0 -64
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/decorators/setAttribute.ts"],
4
- "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core/reflect/ReflectUtils';\nimport { ensureInit, getElementConfig } from './elementDefine';\nimport { SwcUtils } from '../utils/Utils';\n\nexport interface SetAttributeMetadata {\n propertyKey: string | symbol;\n selector: string;\n name: string;\n}\n\nexport const SET_ATTRIBUTE_METADATA_KEY = Symbol('simple-web-component:set-attribute');\n\n/**\n * @setAttribute decorator to surgically update an attribute of a target element.\n * Usage: @setAttribute(':host', 'count')\n * Usage: @setAttribute('#child', 'disabled')\n */\nexport function setAttribute(selector: string, name: string): MethodDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = target.constructor;\n let metaList = ReflectUtils.getOwnMetadata(SET_ATTRIBUTE_METADATA_KEY, constructor) as Map<string | symbol, SetAttributeMetadata>;\n if (!metaList) {\n metaList = new Map<string | symbol, SetAttributeMetadata>();\n ReflectUtils.defineMetadata(SET_ATTRIBUTE_METADATA_KEY, metaList, constructor);\n }\n metaList.set(propertyKey, { propertyKey, selector, name });\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 hostSet = SwcUtils.getHostSet(this as any);\n const conf = getElementConfig(this);\n const currentWin = (this as any)._resolveWindow?.(conf) || ((typeof window !== 'undefined' ? window : undefined) as Window);\n\n let targetEl: HTMLElement | null = null;\n if (selector === ':host' || !selector) targetEl = this as any;\n else if (selector === ':window') targetEl = currentWin as any;\n else if (selector === ':document') targetEl = currentWin.document as any;\n else if (selector === ':parentHost') targetEl = hostSet.$parentHost;\n else if (selector === ':appHost') targetEl = hostSet.$appHost;\n else if (selector === ':firstHost') targetEl = hostSet.$firstHost;\n else if (selector === ':lastHost') targetEl = hostSet.$lastHost;\n else if (selector === ':firstAppHost') targetEl = hostSet.$firstAppHost;\n else if (selector === ':lastAppHost') targetEl = hostSet.$lastAppHost;\n else targetEl = (this.shadowRoot || (this as any)).querySelector(selector);\n\n if (targetEl) {\n if (res === null) targetEl.removeAttribute(name);\n else targetEl.setAttribute(name, String(res));\n }\n }\n return res;\n };\n };\n}\n\nexport const getSetAttributeMetadata = (target: any): Map<string | symbol, SetAttributeMetadata> | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(SET_ATTRIBUTE_METADATA_KEY, constructor);\n};\n\nexport const findAllSetAttributeMetadata = (target: any): Map<string | symbol, SetAttributeMetadata> => {\n const result = new Map<string | symbol, SetAttributeMetadata>();\n const maps = ReflectUtils.findAllMetadata<Map<string | symbol, SetAttributeMetadata>>(SET_ATTRIBUTE_METADATA_KEY, target);\n maps.forEach(map => {\n if (map instanceof Map) {\n map.forEach((v, k) => result.set(k, v));\n }\n });\n return result;\n};\n"],
5
- "mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,YAAY,wBAAwB;AAC7C,SAAS,gBAAgB;AAQlB,MAAM,6BAA6B,OAAO,oCAAoC;AAO9E,SAAS,aAAa,UAAkB,MAA+B;AAC5E,SAAO,CAAC,QAAgB,aAA8B,eAAmC;AACvF,UAAM,cAAc,OAAO;AAC3B,QAAI,WAAW,aAAa,eAAe,4BAA4B,WAAW;AAClF,QAAI,CAAC,UAAU;AACb,iBAAW,oBAAI,IAA2C;AAC1D,mBAAa,eAAe,4BAA4B,UAAU,WAAW;AAAA,IAC/E;AACA,aAAS,IAAI,aAAa,EAAE,aAAa,UAAU,KAAK,CAAC;AAEzD,UAAM,WAAW,WAAW;AAC5B,eAAW,QAAQ,kBAAmB,MAAa;AACjD,iBAAW,IAAI;AACf,YAAM,MAAM,MAAM,SAAS,MAAM,MAAM,IAAI;AAC3C,UAAI,QAAQ,QAAW;AACrB,cAAM,UAAU,SAAS,WAAW,IAAW;AAC/C,cAAM,OAAO,iBAAiB,IAAI;AAClC,cAAM,aAAc,KAAa,iBAAiB,IAAI,MAAO,OAAO,WAAW,cAAc,SAAS;AAEtG,YAAI,WAA+B;AACnC,YAAI,aAAa,WAAW,CAAC,SAAU,YAAW;AAAA,iBACzC,aAAa,UAAW,YAAW;AAAA,iBACnC,aAAa,YAAa,YAAW,WAAW;AAAA,iBAChD,aAAa,cAAe,YAAW,QAAQ;AAAA,iBAC/C,aAAa,WAAY,YAAW,QAAQ;AAAA,iBAC5C,aAAa,aAAc,YAAW,QAAQ;AAAA,iBAC9C,aAAa,YAAa,YAAW,QAAQ;AAAA,iBAC7C,aAAa,gBAAiB,YAAW,QAAQ;AAAA,iBACjD,aAAa,eAAgB,YAAW,QAAQ;AAAA,YACpD,aAAY,KAAK,cAAe,MAAc,cAAc,QAAQ;AAEzE,YAAI,UAAU;AACZ,cAAI,QAAQ,KAAM,UAAS,gBAAgB,IAAI;AAAA,cAC1C,UAAS,aAAa,MAAM,OAAO,GAAG,CAAC;AAAA,QAC9C;AAAA,MACF;AACA,aAAO;AAAA,IACT;AAAA,EACF;AACF;AAEO,MAAM,0BAA0B,CAAC,WAAwE;AAC9G,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,SAAO,aAAa,YAAY,4BAA4B,WAAW;AACzE;AAEO,MAAM,8BAA8B,CAAC,WAA4D;AACtG,QAAM,SAAS,oBAAI,IAA2C;AAC9D,QAAM,OAAO,aAAa,gBAA4D,4BAA4B,MAAM;AACxH,OAAK,QAAQ,SAAO;AAClB,QAAI,eAAe,KAAK;AACtB,UAAI,QAAQ,CAAC,GAAG,MAAM,OAAO,IAAI,GAAG,CAAC,CAAC;AAAA,IACxC;AAAA,EACF,CAAC;AACD,SAAO;AACT;",
4
+ "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit, getElementConfig } from './elementDefine';\nimport { SwcUtils } from '../utils/Utils';\nimport { SwcQueryOptions } from '../types';\n\nexport interface SetAttributeMetadata {\n propertyKey: string | symbol;\n selector: string;\n name: string;\n options: SwcQueryOptions;\n}\n\nexport const SET_ATTRIBUTE_METADATA_KEY = Symbol('simple-web-component:set-attribute');\n\n/**\n * @setAttribute decorator to surgically update an attribute of a target element.\n * Usage: @setAttribute(':host', 'count')\n * Usage: @setAttribute('#child', 'disabled')\n */\nexport function setAttribute(selector: string, name: string): MethodDecorator;\nexport function setAttribute(selector: string, name: string, options?: SwcQueryOptions): MethodDecorator;\nexport function setAttribute(selector: string, name: string, options: SwcQueryOptions = {}): MethodDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = target.constructor;\n let metaList = ReflectUtils.getOwnMetadata(SET_ATTRIBUTE_METADATA_KEY, constructor) as Map<string | symbol, SetAttributeMetadata>;\n if (!metaList) {\n metaList = new Map<string | symbol, SetAttributeMetadata>();\n ReflectUtils.defineMetadata(SET_ATTRIBUTE_METADATA_KEY, metaList, constructor);\n }\n metaList.set(propertyKey, { propertyKey, selector, name, 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 hostSet = SwcUtils.getHostSet(this as any);\n const conf = getElementConfig(this);\n const currentWin = (this as any)._resolveWindow?.(conf) || ((typeof window !== 'undefined' ? window : undefined) as Window);\n\n const targetEls: any[] = [];\n const r = options.root || 'auto';\n\n const applyRoot = (t: any) => {\n if (!t) return;\n if (r === 'auto') {\n targetEls.push((t as any).shadowRoot || t);\n return;\n }\n if (r === 'light' || r === 'all') targetEls.push(t);\n if ((r === 'shadow' || r === 'all') && (t as any).shadowRoot) targetEls.push((t as any).shadowRoot);\n };\n\n if (selector === ':window') targetEls.push(currentWin);\n else if (selector === ':document') targetEls.push(currentWin.document as any);\n else if (selector === ':parentHost') applyRoot(hostSet.$parentHost);\n else if (selector === ':appHost') applyRoot(hostSet.$appHost);\n else if (selector === ':firstHost') applyRoot(hostSet.$firstHost);\n else if (selector === ':lastHost') applyRoot(hostSet.$lastHost);\n else if (selector === ':firstAppHost') applyRoot(hostSet.$firstAppHost);\n else if (selector === ':lastAppHost') applyRoot(hostSet.$lastAppHost);\n else if (selector === ':hosts') hostSet.$hosts.forEach(applyRoot);\n else if (selector === ':appHosts') hostSet.$appHosts.forEach(applyRoot);\n else if (selector === ':host' || !selector) applyRoot(this);\n else {\n const roots: any[] = [];\n if (r === 'shadow') {\n if ((this as any).shadowRoot) roots.push((this as any).shadowRoot);\n } else if (r === 'light') {\n roots.push(this as any);\n } else if (r === 'all') {\n roots.push(this as any);\n if ((this as any).shadowRoot) roots.push((this as any).shadowRoot);\n } else {\n roots.push((this as any).shadowRoot || (this as any));\n }\n roots.forEach(root => targetEls.push(...root.querySelectorAll(selector)));\n }\n\n targetEls.forEach(targetEl => {\n if (!targetEl || typeof (targetEl as any).setAttribute !== 'function') return;\n if (res === null) (targetEl as any).removeAttribute(name);\n else (targetEl as any).setAttribute(name, String(res));\n })\n }\n return res;\n };\n };\n}\n\nexport const getSetAttributeMetadata = (target: any): Map<string | symbol, SetAttributeMetadata> | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(SET_ATTRIBUTE_METADATA_KEY, constructor);\n};\n\nexport const findAllSetAttributeMetadata = (target: any): Map<string | symbol, SetAttributeMetadata> => {\n const result = new Map<string | symbol, SetAttributeMetadata>();\n const maps = ReflectUtils.findAllMetadata<Map<string | symbol, SetAttributeMetadata>>(SET_ATTRIBUTE_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 * @setAttributeHost decorator - simplified version of @setAttribute for :host selector\n * Usage: @setAttributeHost('aria-disabled')\n */\nexport function setAttributeHost(name: string, options?: SwcQueryOptions): MethodDecorator {\n return setAttribute(':host', name, options);\n}\n"],
5
+ "mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,YAAY,wBAAwB;AAC7C,SAAS,gBAAgB;AAUlB,MAAM,6BAA6B,OAAO,oCAAoC;AAS9E,SAAS,aAAa,UAAkB,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GAAG,CAAC,CAAC;AAAA,IACxC;AAAA,EACF,CAAC;AACD,SAAO;AACT;AAMO,SAAS,iBAAiB,MAAc,SAA4C;AACzF,SAAO,aAAa,SAAS,MAAM,OAAO;AAC5C;",
6
6
  "names": []
7
7
  }
@@ -1,4 +1,4 @@
1
- import { ReflectUtils } from "@dooboostore/core/reflect/ReflectUtils";
1
+ import { ReflectUtils } from "@dooboostore/core";
2
2
  import { ensureInit } from "./elementDefine.js";
3
3
  import { SwcUtils } from "../utils/Utils.js";
4
4
  const STYLE_METADATA_KEY = Symbol("simple-web-component:style");
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/decorators/style.ts"],
4
- "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core/reflect/ReflectUtils';\nimport { ensureInit } from './elementDefine';\nimport { SwcUtils } from '../utils/Utils';\n\nexport type StyleAction = 'set' | 'update' | 'remove';\n\nexport interface StyleMetadata {\n propertyKey: string | symbol;\n selector: string;\n action: StyleAction;\n}\n\nexport const STYLE_METADATA_KEY = Symbol('simple-web-component:style');\n\nfunction createStyleDecorator(action: StyleAction) {\n return (selector: string): MethodDecorator => {\n return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = target.constructor;\n let metaList = ReflectUtils.getOwnMetadata(STYLE_METADATA_KEY, constructor) as Map<string | symbol, StyleMetadata>;\n if (!metaList) {\n metaList = new Map<string | symbol, StyleMetadata>();\n ReflectUtils.defineMetadata(STYLE_METADATA_KEY, metaList, constructor);\n }\n metaList.set(propertyKey, { propertyKey, selector, action });\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 hostSet = SwcUtils.getHostSet(this as any);\n let targetEl: HTMLElement | null = null;\n if (selector === ':host' || !selector) targetEl = this as any;\n else if (selector === ':parentHost') targetEl = hostSet.$parentHost;\n else if (selector === ':appHost') targetEl = hostSet.$appHost;\n else targetEl = (this.shadowRoot || (this as any)).querySelector(selector);\n\n if (targetEl) {\n if (action === 'set') {\n targetEl.style.cssText = '';\n if (typeof res === 'object' && res !== null) {\n Object.assign(targetEl.style, res);\n } else if (typeof res === 'string') {\n targetEl.style.cssText = res;\n }\n } else if (action === 'update') {\n if (typeof res === 'object' && res !== null) {\n Object.assign(targetEl.style, res);\n }\n } else if (action === 'remove') {\n const props = Array.isArray(res) ? res : [res];\n props.forEach(p => targetEl!.style.removeProperty(String(p)));\n }\n }\n }\n return res;\n };\n };\n };\n}\n\n/**\n * @setStyle decorator to surgically set styles on a target element (replaces all existing styles).\n * Usage: @setStyle('#box') getStyles() { return { color: 'red', display: 'block' }; }\n */\nexport const setStyle = createStyleDecorator('set');\n\n/**\n * @updateStyle decorator to surgically update styles on a target element (merges with existing styles).\n * Usage: @updateStyle('#box') updateStyles() { return { color: 'blue' }; }\n */\nexport const updateStyle = createStyleDecorator('update');\n\n/**\n * @removeStyle decorator to surgically remove styles from a target element.\n * Usage: @removeStyle('#box') clearStyles() { return ['color', 'display']; }\n */\nexport const removeStyle = createStyleDecorator('remove');\n\nexport const findAllStyleMetadata = (target: any): Map<string | symbol, StyleMetadata> => {\n const result = new Map<string | symbol, StyleMetadata>();\n const maps = ReflectUtils.findAllMetadata<Map<string | symbol, StyleMetadata>>(STYLE_METADATA_KEY, target);\n maps.forEach(map => {\n if (map instanceof Map) {\n map.forEach((v, k) => result.set(k, v));\n }\n });\n return result;\n};\n"],
4
+ "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit } from './elementDefine';\nimport { SwcUtils } from '../utils/Utils';\n\nexport type StyleAction = 'set' | 'update' | 'remove';\n\nexport interface StyleMetadata {\n propertyKey: string | symbol;\n selector: string;\n action: StyleAction;\n}\n\nexport const STYLE_METADATA_KEY = Symbol('simple-web-component:style');\n\nfunction createStyleDecorator(action: StyleAction) {\n return (selector: string): MethodDecorator => {\n return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = target.constructor;\n let metaList = ReflectUtils.getOwnMetadata(STYLE_METADATA_KEY, constructor) as Map<string | symbol, StyleMetadata>;\n if (!metaList) {\n metaList = new Map<string | symbol, StyleMetadata>();\n ReflectUtils.defineMetadata(STYLE_METADATA_KEY, metaList, constructor);\n }\n metaList.set(propertyKey, { propertyKey, selector, action });\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 hostSet = SwcUtils.getHostSet(this as any);\n let targetEl: HTMLElement | null = null;\n if (selector === ':host' || !selector) targetEl = this as any;\n else if (selector === ':parentHost') targetEl = hostSet.$parentHost;\n else if (selector === ':appHost') targetEl = hostSet.$appHost;\n else targetEl = (this.shadowRoot || (this as any)).querySelector(selector);\n\n if (targetEl) {\n if (action === 'set') {\n targetEl.style.cssText = '';\n if (typeof res === 'object' && res !== null) {\n Object.assign(targetEl.style, res);\n } else if (typeof res === 'string') {\n targetEl.style.cssText = res;\n }\n } else if (action === 'update') {\n if (typeof res === 'object' && res !== null) {\n Object.assign(targetEl.style, res);\n }\n } else if (action === 'remove') {\n const props = Array.isArray(res) ? res : [res];\n props.forEach(p => targetEl!.style.removeProperty(String(p)));\n }\n }\n }\n return res;\n };\n };\n };\n}\n\n/**\n * @setStyle decorator to surgically set styles on a target element (replaces all existing styles).\n * Usage: @setStyle('#box') getStyles() { return { color: 'red', display: 'block' }; }\n */\nexport const setStyle = createStyleDecorator('set');\n\n/**\n * @updateStyle decorator to surgically update styles on a target element (merges with existing styles).\n * Usage: @updateStyle('#box') updateStyles() { return { color: 'blue' }; }\n */\nexport const updateStyle = createStyleDecorator('update');\n\n/**\n * @removeStyle decorator to surgically remove styles from a target element.\n * Usage: @removeStyle('#box') clearStyles() { return ['color', 'display']; }\n */\nexport const removeStyle = createStyleDecorator('remove');\n\nexport const findAllStyleMetadata = (target: any): Map<string | symbol, StyleMetadata> => {\n const result = new Map<string | symbol, StyleMetadata>();\n const maps = ReflectUtils.findAllMetadata<Map<string | symbol, StyleMetadata>>(STYLE_METADATA_KEY, target);\n maps.forEach(map => {\n if (map instanceof Map) {\n map.forEach((v, k) => result.set(k, v));\n }\n });\n return result;\n};\n"],
5
5
  "mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB;AAC3B,SAAS,gBAAgB;AAUlB,MAAM,qBAAqB,OAAO,4BAA4B;AAErE,SAAS,qBAAqB,QAAqB;AACjD,SAAO,CAAC,aAAsC;AAC5C,WAAO,CAAC,QAAgB,aAA8B,eAAmC;AACvF,YAAM,cAAc,OAAO;AAC3B,UAAI,WAAW,aAAa,eAAe,oBAAoB,WAAW;AAC1E,UAAI,CAAC,UAAU;AACb,mBAAW,oBAAI,IAAoC;AACnD,qBAAa,eAAe,oBAAoB,UAAU,WAAW;AAAA,MACvE;AACA,eAAS,IAAI,aAAa,EAAE,aAAa,UAAU,OAAO,CAAC;AAE3D,YAAM,WAAW,WAAW;AAC5B,iBAAW,QAAQ,kBAAmB,MAAa;AACjD,mBAAW,IAAI;AACf,cAAM,MAAM,MAAM,SAAS,MAAM,MAAM,IAAI;AAC3C,YAAI,QAAQ,QAAW;AACrB,gBAAM,UAAU,SAAS,WAAW,IAAW;AAC/C,cAAI,WAA+B;AACnC,cAAI,aAAa,WAAW,CAAC,SAAU,YAAW;AAAA,mBACzC,aAAa,cAAe,YAAW,QAAQ;AAAA,mBAC/C,aAAa,WAAY,YAAW,QAAQ;AAAA,cAChD,aAAY,KAAK,cAAe,MAAc,cAAc,QAAQ;AAEzE,cAAI,UAAU;AACZ,gBAAI,WAAW,OAAO;AACpB,uBAAS,MAAM,UAAU;AACzB,kBAAI,OAAO,QAAQ,YAAY,QAAQ,MAAM;AAC3C,uBAAO,OAAO,SAAS,OAAO,GAAG;AAAA,cACnC,WAAW,OAAO,QAAQ,UAAU;AAClC,yBAAS,MAAM,UAAU;AAAA,cAC3B;AAAA,YACF,WAAW,WAAW,UAAU;AAC9B,kBAAI,OAAO,QAAQ,YAAY,QAAQ,MAAM;AAC3C,uBAAO,OAAO,SAAS,OAAO,GAAG;AAAA,cACnC;AAAA,YACF,WAAW,WAAW,UAAU;AAC9B,oBAAM,QAAQ,MAAM,QAAQ,GAAG,IAAI,MAAM,CAAC,GAAG;AAC7C,oBAAM,QAAQ,OAAK,SAAU,MAAM,eAAe,OAAO,CAAC,CAAC,CAAC;AAAA,YAC9D;AAAA,UACF;AAAA,QACF;AACA,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACF;AAMO,MAAM,WAAW,qBAAqB,KAAK;AAM3C,MAAM,cAAc,qBAAqB,QAAQ;AAMjD,MAAM,cAAc,qBAAqB,QAAQ;AAEjD,MAAM,uBAAuB,CAAC,WAAqD;AACxF,QAAM,SAAS,oBAAI,IAAoC;AACvD,QAAM,OAAO,aAAa,gBAAqD,oBAAoB,MAAM;AACzG,OAAK,QAAQ,SAAO;AAClB,QAAI,eAAe,KAAK;AACtB,UAAI,QAAQ,CAAC,GAAG,MAAM,OAAO,IAAI,GAAG,CAAC,CAAC;AAAA,IACxC;AAAA,EACF,CAAC;AACD,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -1,10 +1,10 @@
1
1
  import { SimpleApplication } from "@dooboostore/simple-boot/SimpleApplication";
2
- import { PathRouter } from "@dooboostore/core-web/routers/PathRouter";
3
- import { HashRouter } from "@dooboostore/core-web/routers/HashRouter";
2
+ import { PathRouter } from "@dooboostore/core-web";
3
+ import { HashRouter } from "@dooboostore/core-web";
4
4
  import { ElementRouter } from "../router/ElementRouter.js";
5
5
  import { SimOption } from "@dooboostore/simple-boot/SimOption";
6
- import { Router } from "@dooboostore/core-web/routers/Router";
7
- import { FunctionUtils } from "@dooboostore/core/function/FunctionUtils";
6
+ import { Router } from "@dooboostore/core-web";
7
+ import { FunctionUtils } from "@dooboostore/core";
8
8
  import { SwcUtils } from "../utils/Utils.js";
9
9
  class SwcAppEngine {
10
10
  constructor(host) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/elements/SwcAppEngine.ts"],
4
- "sourcesContent": ["import { SimpleApplication } from '@dooboostore/simple-boot/SimpleApplication';\nimport { PathRouter } from '@dooboostore/core-web/routers/PathRouter';\nimport { HashRouter } from '@dooboostore/core-web/routers/HashRouter';\nimport { ElementRouter } from '../router/ElementRouter';\nimport { SimOption } from '@dooboostore/simple-boot/SimOption';\nimport { Router, RouterEventType } from '@dooboostore/core-web/routers/Router';\nimport { Subscription } from '@dooboostore/core/message/Subscription';\nimport { ConstructorType, Optional } from '@dooboostore/core/types';\nimport { FunctionUtils } from '@dooboostore/core/function/FunctionUtils';\nimport { SwcUtils } from '../utils/Utils';\n\nexport type SwcConfigType = {\n rootRouter: ConstructorType<any> | Symbol;\n routeType: 'path' | 'hash' | 'element';\n path?: string;\n window: Window;\n};\n\nexport type SwcAttributeConfigType = Optional<SwcConfigType, 'routeType' | 'window'>;\n\nexport class SwcAppEngine {\n public simpleApplication?: SimpleApplication;\n public router?: Router;\n private routerSubscription?: Subscription;\n private _isInitialized = false;\n\n constructor(private host: HTMLElement) {}\n\n async connect(config?: SwcAttributeConfigType) {\n if (this._isInitialized) return;\n\n let userConfig = config;\n const win = this.host.ownerDocument?.defaultView || window;\n const Node = (win as any).Node as typeof globalThis.Node;\n if (!userConfig) {\n const configStr = this.host.getAttribute('swc-get-application-config');\n if (configStr) {\n try {\n userConfig = FunctionUtils.executeReturn({\n script: configStr,\n context: this.host,\n args: SwcUtils.getHelperAndHostSet(win, this.host)\n });\n } catch (e) {\n console.error('[SWC-APP-ENGINE] Script execution failed:', e);\n }\n }\n }\n\n if (!userConfig) return;\n this._isInitialized = true;\n\n try {\n if (userConfig.rootRouter) {\n const _config: SwcConfigType = {\n routeType: 'element',\n window: win,\n ...userConfig\n } as SwcConfigType;\n\n // Router Selection\n if (_config.routeType === 'path') {\n this.router = new PathRouter({ window: _config.window, firstUrl: _config.path });\n } else if (_config.routeType === 'hash') {\n this.router = new HashRouter({ window: _config.window, firstUrl: _config.path });\n } else if (_config.routeType === 'element') {\n this.router = new ElementRouter({ window: _config.window, firstUrl: _config.path });\n }\n\n // Routing sync\n if (this.router) {\n this.routerSubscription = this.router.observable.subscribe((route: RouterEventType) => {\n if (route.triggerPoint === 'end') {\n this.simpleApplication?.routing(route.path);\n }\n });\n }\n\n\n // App start\n this.simpleApplication = new SimpleApplication(new SimOption({ excludeProxys: [Node], rootRouter: _config.rootRouter }));\n\n const otherInstanceSim = new Map<any, any>();\n if (this.router) otherInstanceSim.set(Router, this.router);\n this.simpleApplication.run(otherInstanceSim);\n\n // Rendering\n const data = this.simpleApplication.sim(_config.rootRouter);\n if (data instanceof Node) {\n if (this.host.shadowRoot) this.host.shadowRoot.replaceChildren(data);\n else this.host.replaceChildren(data);\n }\n\n if (_config.path) this.router?.go(_config.path);\n }\n } catch (e) {\n console.error('[SWC-APP-ENGINE] Init failed:', e);\n }\n }\n\n disconnect() {\n this.routerSubscription?.unsubscribe();\n }\n}\n"],
5
- "mappings": "AAAA,SAAS,yBAAyB;AAClC,SAAS,kBAAkB;AAC3B,SAAS,kBAAkB;AAC3B,SAAS,qBAAqB;AAC9B,SAAS,iBAAiB;AAC1B,SAAS,cAA+B;AAGxC,SAAS,qBAAqB;AAC9B,SAAS,gBAAgB;AAWlB,MAAM,aAAa;AAAA,EAMxB,YAAoB,MAAmB;AAAnB;AAFpB,SAAQ,iBAAiB;AAAA,EAEe;AAAA,EAExC,MAAM,QAAQ,QAAiC;AAC7C,QAAI,KAAK,eAAgB;AAEzB,QAAI,aAAa;AACjB,UAAM,MAAM,KAAK,KAAK,eAAe,eAAe;AACpD,UAAM,OAAQ,IAAY;AAC1B,QAAI,CAAC,YAAY;AACf,YAAM,YAAY,KAAK,KAAK,aAAa,4BAA4B;AACrE,UAAI,WAAW;AACb,YAAI;AACF,uBAAa,cAAc,cAAc;AAAA,YACvC,QAAQ;AAAA,YACR,SAAS,KAAK;AAAA,YACd,M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K,KAAK,WAAW,gBAAgB,IAAI;AAAA,cAC9D,MAAK,KAAK,gBAAgB,IAAI;AAAA,QACrC;AAEA,YAAI,QAAQ,KAAM,MAAK,QAAQ,GAAG,QAAQ,IAAI;AAAA,MAChD;AAAA,IACF,SAAS,GAAG;AACV,cAAQ,MAAM,iCAAiC,CAAC;AAAA,IAClD;AAAA,EACF;AAAA,EAEA,aAAa;AACX,SAAK,oBAAoB,YAAY;AAAA,EACvC;AACF;",
4
+ "sourcesContent": ["import { SimpleApplication } from '@dooboostore/simple-boot/SimpleApplication';\nimport { PathRouter } from '@dooboostore/core-web';\nimport { HashRouter } from '@dooboostore/core-web';\nimport { ElementRouter } from '../router/ElementRouter';\nimport { SimOption } from '@dooboostore/simple-boot/SimOption';\nimport { Router, RouterEventType } from '@dooboostore/core-web';\nimport { Subscription } from '@dooboostore/core';\nimport { ConstructorType, OptionalType } from '@dooboostore/core';\nimport { FunctionUtils } from '@dooboostore/core';\nimport { SwcUtils } from '../utils/Utils';\n\nexport type SwcConfigType = {\n rootRouter: ConstructorType<any> | symbol;\n routeType: 'path' | 'hash' | 'element';\n connectMode?: 'direct' | 'swap';\n path?: string;\n window: Window;\n};\n\nexport type SwcAttributeConfigType = OptionalType<SwcConfigType, 'routeType' | 'window'>;\n\nexport class SwcAppEngine {\n public simpleApplication?: SimpleApplication;\n public router?: Router;\n private routerSubscription?: Subscription;\n private _isInitialized = false;\n\n constructor(private host: HTMLElement) {}\n\n async connect(config?: SwcAttributeConfigType) {\n if (this._isInitialized) return;\n\n let userConfig = config;\n const win = this.host.ownerDocument?.defaultView || window;\n const Node = (win as any).Node as typeof globalThis.Node;\n if (!userConfig) {\n const configStr = this.host.getAttribute('swc-get-application-config');\n if (configStr) {\n try {\n userConfig = FunctionUtils.executeReturn({\n script: configStr,\n context: this.host,\n args: SwcUtils.getHelperAndHostSet(win, this.host)\n });\n } catch (e) {\n console.error('[SWC-APP-ENGINE] Script execution failed:', e);\n }\n }\n }\n\n if (!userConfig) return;\n this._isInitialized = true;\n\n try {\n if (userConfig.rootRouter) {\n const _config: SwcConfigType = {\n routeType: 'element',\n window: win,\n ...userConfig\n } as SwcConfigType;\n\n // Router Selection\n if (_config.routeType === 'path') {\n this.router = new PathRouter({ window: _config.window, firstUrl: _config.path });\n } else if (_config.routeType === 'hash') {\n this.router = new HashRouter({ window: _config.window, firstUrl: _config.path });\n } else if (_config.routeType === 'element') {\n this.router = new ElementRouter({ window: _config.window, firstUrl: _config.path });\n }\n\n // Routing sync\n if (this.router) {\n this.routerSubscription = this.router.observable.subscribe((route: RouterEventType) => {\n if (route.triggerPoint === 'end') {\n this.simpleApplication?.routing(route.path);\n }\n });\n }\n\n\n // App start\n this.simpleApplication = new SimpleApplication(new SimOption({ excludeProxys: [Node], rootRouter: _config.rootRouter }));\n\n const otherInstanceSim = new Map<any, any>();\n if (this.router) otherInstanceSim.set(Router, this.router);\n this.simpleApplication.run(otherInstanceSim);\n\n // Rendering\n const data = this.simpleApplication.sim(_config.rootRouter);\n if (data instanceof Node) {\n // console.warn('[SWC-APP-ENGINE] Rendering failed: Root element is not a DocumentFragment.', data);\n if (this.host.shadowRoot) this.host.shadowRoot.replaceChildren(data);\n else this.host.replaceChildren(data);\n }\n\n if (_config.path) this.router?.go(_config.path);\n }\n } catch (e) {\n console.error('[SWC-APP-ENGINE] Init failed:', e);\n }\n }\n\n disconnect() {\n this.routerSubscription?.unsubscribe();\n }\n}\n"],
5
+ "mappings": "AAAA,SAAS,yBAAyB;AAClC,SAAS,kBAAkB;AAC3B,SAAS,kBAAkB;AAC3B,SAAS,qBAAqB;AAC9B,SAAS,iBAAiB;AAC1B,SAAS,cAA+B;AAGxC,SAAS,qBAAqB;AAC9B,SAAS,gBAAgB;AAYlB,MAAM,aAAa;AAAA,EAMxB,YAAoB,MAAmB;AAAnB;AAFpB,SAAQ,iBAAiB;AAAA,EAEe;AAAA,EAExC,MAAM,QAAQ,QAAiC;AAC7C,QAAI,KAAK,eAAgB;AAEzB,QAA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,CAAC;AAEvH,cAAM,mBAAmB,oBAAI,IAAc;AAC3C,YAAI,KAAK,OAAQ,kBAAiB,IAAI,QAAQ,KAAK,MAAM;AACzD,aAAK,kBAAkB,IAAI,gBAAgB;AAG3C,cAAM,OAAO,KAAK,kBAAkB,IAAI,QAAQ,UAAU;AAC1D,YAAI,gBAAgB,MAAM;AAExB,cAAI,KAAK,KAAK,WAAY,MAAK,KAAK,WAAW,gBAAgB,IAAI;AAAA,cAC9D,MAAK,KAAK,gBAAgB,IAAI;AAAA,QACrC;AAEA,YAAI,QAAQ,KAAM,MAAK,QAAQ,GAAG,QAAQ,IAAI;AAAA,MAChD;AAAA,IACF,SAAS,GAAG;AACV,cAAQ,MAAM,iCAAiC,CAAC;AAAA,IAClD;AAAA,EACF;AAAA,EAEA,aAAa;AACX,SAAK,oBAAoB,YAAY;AAAA,EACvC;AACF;",
6
6
  "names": []
7
7
  }
@@ -12,7 +12,34 @@ function SwcAppMixin(Base) {
12
12
  return this.__swc_engine.router;
13
13
  }
14
14
  async connect(config) {
15
- await this.__swc_engine.connect(config);
15
+ const mode = config?.connectMode || "direct";
16
+ if (mode !== "swap") {
17
+ await this.__swc_engine.connect(config);
18
+ this.setAttribute("swc-connect-mode", "direct");
19
+ return;
20
+ }
21
+ const parent = this.parentNode;
22
+ if (!parent) {
23
+ await this.__swc_engine.connect(config);
24
+ this.setAttribute("swc-connect-mode", "direct");
25
+ return;
26
+ }
27
+ const clonedApp = this.cloneNode(true);
28
+ clonedApp.style.display = "none";
29
+ parent.insertBefore(clonedApp, this.nextSibling);
30
+ try {
31
+ await clonedApp.connect({ ...config || {}, connectMode: "direct" });
32
+ if (this.parentNode) {
33
+ this.parentNode.removeChild(this);
34
+ }
35
+ clonedApp.setAttribute("swc-connect-mode", "swap");
36
+ clonedApp.style.display = "";
37
+ } catch (e) {
38
+ if (clonedApp.parentNode) {
39
+ clonedApp.parentNode.removeChild(clonedApp);
40
+ }
41
+ throw e;
42
+ }
16
43
  }
17
44
  connectedCallback() {
18
45
  if (super.connectedCallback) super.connectedCallback();
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/elements/SwcAppMixin.ts"],
4
- "sourcesContent": ["import { SwcAppEngine, SwcAttributeConfigType } from './SwcAppEngine';\n\nexport function SwcAppMixin<T extends { new (...args: any[]): HTMLElement }>(Base: T) {\n return class extends Base {\n __swc_engine = new SwcAppEngine(this as any);\n\n get simpleApplication() {\n return this.__swc_engine.simpleApplication;\n }\n get router() {\n return this.__swc_engine.router;\n }\n\n async connect(config?: SwcAttributeConfigType) {\n await this.__swc_engine.connect(config);\n }\n\n connectedCallback() {\n // @ts-ignore\n if (super.connectedCallback) super.connectedCallback();\n this.connect();\n }\n\n disconnectedCallback() {\n // @ts-ignore\n if (super.disconnectedCallback) super.disconnectedCallback();\n this.__swc_engine.disconnect();\n }\n\n async routing(path: string) {\n await this.__swc_engine.router?.go(path);\n }\n };\n}\n"],
5
- "mappings": "AAAA,SAAS,oBAA4C;AAE9C,SAAS,YAA6D,MAAS;AACpF,SAAO,cAAc,KAAK;AAAA,IAAnB;AAAA;AACL,0BAAe,IAAI,aAAa,IAAW;AAAA;AAAA,IAE3C,IAAI,oBAAoB;AACtB,aAAO,KAAK,aAAa;AAAA,IAC3B;AAAA,IACA,IAAI,SAAS;AACX,aAAO,KAAK,aAAa;AAAA,IAC3B;AAAA,IAEA,MAAM,QAAQ,QAAiC;AAC7C,YAAM,KAAK,aAAa,QAAQ,MAAM;AAAA,IACxC;AAAA,IAEA,oBAAoB;AAElB,UAAI,MAAM,kBAAmB,OAAM,kBAAkB;AACrD,WAAK,QAAQ;AAAA,IACf;AAAA,IAEA,uBAAuB;AAErB,UAAI,MAAM,qBAAsB,OAAM,qBAAqB;AAC3D,WAAK,aAAa,WAAW;AAAA,IAC/B;AAAA,IAEA,MAAM,QAAQ,MAAc;AAC1B,YAAM,KAAK,aAAa,QAAQ,GAAG,IAAI;AAAA,IACzC;AAAA,EACF;AACF;",
4
+ "sourcesContent": ["import { SwcAppEngine, SwcAttributeConfigType } from './SwcAppEngine';\nimport {SwcAppInterface} from \"../types\";\n\nexport function SwcAppMixin<T extends { new (...args: any[]): HTMLElement }>(Base: T) {\n return class extends Base implements SwcAppInterface{\n __swc_engine = new SwcAppEngine(this as any);\n\n get simpleApplication() {\n return this.__swc_engine.simpleApplication;\n }\n get router() {\n return this.__swc_engine.router;\n }\n\n async connect(config?: SwcAttributeConfigType) {\n const mode = config?.connectMode || 'direct';\n\n if (mode !== 'swap') {\n await this.__swc_engine.connect(config);\n this.setAttribute('swc-connect-mode', 'direct');\n return;\n }\n\n const parent = this.parentNode;\n if (!parent) {\n await this.__swc_engine.connect(config);\n this.setAttribute('swc-connect-mode', 'direct');\n return;\n }\n\n const clonedApp = this.cloneNode(true) as any;\n clonedApp.style.display = 'none';\n parent.insertBefore(clonedApp, this.nextSibling);\n\n try {\n await clonedApp.connect({ ...(config || {}), connectMode: 'direct' });\n if (this.parentNode) {\n this.parentNode.removeChild(this);\n }\n clonedApp.setAttribute('swc-connect-mode', 'swap');\n clonedApp.style.display = '';\n } catch (e) {\n if (clonedApp.parentNode) {\n clonedApp.parentNode.removeChild(clonedApp);\n }\n throw e;\n }\n }\n\n connectedCallback() {\n // @ts-ignore\n if (super.connectedCallback) super.connectedCallback();\n this.connect();\n }\n\n disconnectedCallback() {\n // @ts-ignore\n if (super.disconnectedCallback) super.disconnectedCallback();\n this.__swc_engine.disconnect();\n }\n\n async routing(path: string) {\n await this.__swc_engine.router?.go(path);\n }\n };\n}\n"],
5
+ "mappings": "AAAA,SAAS,oBAA4C;AAG9C,SAAS,YAA6D,MAAS;AACpF,SAAO,cAAc,KAA+B;AAAA,IAA7C;AAAA;AACL,0BAAe,IAAI,aAAa,IAAW;AAAA;AAAA,IAE3C,IAAI,oBAAoB;AACtB,aAAO,KAAK,aAAa;AAAA,IAC3B;AAAA,IACA,IAAI,SAAS;AACX,aAAO,KAAK,aAAa;AAAA,IAC3B;AAAA,IAEA,MAAM,QAAQ,QAAiC;AAC7C,YAAM,OAAO,QAAQ,eAAe;AAEpC,UAAI,SAAS,QAAQ;AACnB,cAAM,KAAK,aAAa,QAAQ,MAAM;AACtC,aAAK,aAAa,oBAAoB,QAAQ;AAC9C;AAAA,MACF;AAEA,YAAM,SAAS,KAAK;AACpB,UAAI,CAAC,QAAQ;AACX,cAAM,KAAK,aAAa,QAAQ,MAAM;AACtC,aAAK,aAAa,oBAAoB,QAAQ;AAC9C;AAAA,MACF;AAEA,YAAM,YAAY,KAAK,UAAU,IAAI;AACrC,gBAAU,MAAM,UAAU;AAC1B,aAAO,aAAa,WAAW,KAAK,WAAW;AAE/C,UAAI;AACF,cAAM,UAAU,QAAQ,EAAE,GAAI,UAAU,CAAC,GAAI,aAAa,SAAS,CAAC;AACpE,YAAI,KAAK,YAAY;AACnB,eAAK,WAAW,YAAY,IAAI;AAAA,QAClC;AACA,kBAAU,aAAa,oBAAoB,MAAM;AACjD,kBAAU,MAAM,UAAU;AAAA,MAC5B,SAAS,GAAG;AACV,YAAI,UAAU,YAAY;AACxB,oBAAU,WAAW,YAAY,SAAS;AAAA,QAC5C;AACA,cAAM;AAAA,MACR;AAAA,IACF;AAAA,IAEA,oBAAoB;AAElB,UAAI,MAAM,kBAAmB,OAAM,kBAAkB;AACrD,WAAK,QAAQ;AAAA,IACf;AAAA,IAEA,uBAAuB;AAErB,UAAI,MAAM,qBAAsB,OAAM,qBAAqB;AAC3D,WAAK,aAAa,WAAW;AAAA,IAC/B;AAAA,IAEA,MAAM,QAAQ,MAAc;AAC1B,YAAM,KAAK,aAAa,QAAQ,GAAG,IAAI;AAAA,IACzC;AAAA,EACF;AACF;",
6
6
  "names": []
7
7
  }
@@ -7,9 +7,9 @@ var __decorate = function(decorators, target, key, desc) {
7
7
  var __metadata = function(k, v) {
8
8
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
9
  };
10
- import { changedAttribute } from "../decorators/changedAttribute.js";
10
+ import { changedAttributeHost } from "../decorators/changedAttributeHost.js";
11
11
  import { SwcUtils } from "../utils/Utils.js";
12
- import { FunctionUtils } from "@dooboostore/core/function/FunctionUtils";
12
+ import { FunctionUtils } from "@dooboostore/core";
13
13
  class SwcAsync extends HTMLTemplateElement {
14
14
  constructor() {
15
15
  super(...arguments);
@@ -93,7 +93,7 @@ class SwcAsync extends HTMLTemplateElement {
93
93
  }
94
94
  }
95
95
  __decorate([
96
- changedAttribute("on-get-value"),
96
+ changedAttributeHost("on-get-value"),
97
97
  __metadata("design:type", Function),
98
98
  __metadata("design:paramtypes", []),
99
99
  __metadata("design:returntype", void 0)
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/elements/SwcAsync.ts"],
4
- "sourcesContent": ["import { changedAttribute } from '../decorators/changedAttribute';\nimport { SwcUtils } from '../utils/Utils';\nimport { FunctionUtils } from '@dooboostore/core/function/FunctionUtils';\n\nexport class SwcAsync extends HTMLTemplateElement {\n private _nodes: Node[] = [];\n private _value: any = null;\n\n private _resolvePortal(): Element | null {\n const portalScript = this.getAttribute('on-get-portal');\n if (!portalScript) return this.parentElement;\n\n const win = this.ownerDocument?.defaultView || window;\n const res = FunctionUtils.executeReturn({\n script: portalScript,\n context: this,\n args: SwcUtils.getHelperAndHostSet(win, this)\n });\n\n if (res instanceof HTMLElement) return res;\n if (typeof res === 'string') return win.document.querySelector(res);\n return this.parentElement;\n }\n\n private _executeCloneCallback(attr: string, args: any) {\n const script = this.getAttribute(attr);\n if (!script) return;\n FunctionUtils.execute({ script, context: this, args });\n }\n\n @changedAttribute('on-get-value')\n private refresh() {\n const script = this.getAttribute('on-get-value');\n if (!script) return;\n const win = this.ownerDocument?.defaultView || window;\n const result = FunctionUtils.executeReturn({ script, context: this, args: SwcUtils.getHelperAndHostSet(win, this) });\n\n if (result instanceof Promise) {\n this.render('loading');\n result\n .then(v => {\n this._value = v;\n this.render('success');\n })\n .catch(e => this.render('error'));\n } else {\n this._value = result;\n this.render('success');\n }\n }\n\n private render(state: string) {\n this.cleanup();\n const portal = this._resolvePortal();\n if (!portal) return;\n\n const win = this.ownerDocument?.defaultView || window;\n const helperSet = SwcUtils.getHelperAndHostSet(win, this);\n\n const t = this.content.querySelector(`template[is=\"swc-${state}\"]`) as HTMLTemplateElement;\n if (t) {\n const clone = t.content.cloneNode(true) as DocumentFragment;\n this._nodes = Array.from(clone.childNodes);\n const elements = this._nodes.filter(n => n.nodeType === 1) as HTMLElement[];\n const groupArgs = { ...helperSet, $value: this._value, $nodes: this._nodes, $elements: elements, $firstElement: elements[0], $state: state };\n\n this._nodes.forEach((n, nodeIdx) => {\n if (n instanceof HTMLElement) (n as any).__swc_host = this;\n this._executeCloneCallback('on-clone-node', { ...groupArgs, $node: n, $nodeIndex: nodeIdx, $isElement: n.nodeType === 1 });\n });\n\n this._executeCloneCallback('on-clone-nodes', groupArgs);\n\n if (portal === this.parentElement) {\n portal.insertBefore(clone, this.nextSibling);\n } else {\n portal.appendChild(clone);\n }\n }\n }\n\n private cleanup() {\n this._nodes.forEach(n => n.parentElement?.removeChild(n));\n this._nodes = [];\n }\n\n connectedCallback() {\n this.refresh();\n }\n disconnectedCallback() {\n this.cleanup();\n }\n}\n"],
5
- "mappings": ";;;;;;;;;AAAA,SAAS,wBAAwB;AACjC,SAAS,gBAAgB;AACzB,SAAS,qBAAqB;AAExB,MAAO,iBAAiB,oBAAmB;EAAjD,cAAA;;AACU,SAAA,SAAiB,CAAA;AACjB,SAAA,SAAc;EAsFxB;EApFU,iBAAc;AACpB,UAAM,eAAe,KAAK,aAAa,eAAe;AACtD,QAAI,CAAC;AAAc,aAAO,KAAK;AAE/B,UAAM,MAAM,KAAK,eAAe,eAAe;AAC/C,UAAM,MAAM,cAAc,cAAc;MACtC,QAAQ;MACR,SAAS;MACT,MAAM,SAAS,oBAAoB,KAAK,IAAI;KAC7C;AAED,QAAI,eAAe;AAAa,aAAO;AACvC,QAAI,OAAO,Q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YAAI,aAAa;AAAc,YAAU,aAAa;AACtD,aAAK,sBAAsB,iBAAiB,EAAE,GAAG,WAAW,OAAO,GAAG,YAAY,SAAS,YAAY,EAAE,aAAa,EAAC,CAAE;MAC3H,CAAC;AAED,WAAK,sBAAsB,kBAAkB,SAAS;AAEtD,UAAI,WAAW,KAAK,eAAe;AACjC,eAAO,aAAa,OAAO,KAAK,WAAW;MAC7C,OAAO;AACL,eAAO,YAAY,KAAK;MAC1B;IACF;EACF;EAEQ,UAAO;AACb,SAAK,OAAO,QAAQ,OAAK,EAAE,eAAe,YAAY,CAAC,CAAC;AACxD,SAAK,SAAS,CAAA;EAChB;EAEA,oBAAiB;AACf,SAAK,QAAO;EACd;EACA,uBAAoB;AAClB,SAAK,QAAO;EACd;;AA5DQ,WAAA;EADP,iBAAiB,cAAc;;;;;",
4
+ "sourcesContent": ["import { changedAttributeHost } from '../decorators/changedAttributeHost';\nimport { SwcUtils } from '../utils/Utils';\nimport { FunctionUtils } from '@dooboostore/core';\n\nexport class SwcAsync extends HTMLTemplateElement {\n private _nodes: Node[] = [];\n private _value: any = null;\n\n private _resolvePortal(): Element | null {\n const portalScript = this.getAttribute('on-get-portal');\n if (!portalScript) return this.parentElement;\n\n const win = this.ownerDocument?.defaultView || window;\n const res = FunctionUtils.executeReturn({\n script: portalScript,\n context: this,\n args: SwcUtils.getHelperAndHostSet(win, this)\n });\n\n if (res instanceof HTMLElement) return res;\n if (typeof res === 'string') return win.document.querySelector(res);\n return this.parentElement;\n }\n\n private _executeCloneCallback(attr: string, args: any) {\n const script = this.getAttribute(attr);\n if (!script) return;\n FunctionUtils.execute({ script, context: this, args });\n }\n\n @changedAttributeHost('on-get-value')\n private refresh() {\n const script = this.getAttribute('on-get-value');\n if (!script) return;\n const win = this.ownerDocument?.defaultView || window;\n const result = FunctionUtils.executeReturn({ script, context: this, args: SwcUtils.getHelperAndHostSet(win, this) });\n\n if (result instanceof Promise) {\n this.render('loading');\n result\n .then(v => {\n this._value = v;\n this.render('success');\n })\n .catch(e => this.render('error'));\n } else {\n this._value = result;\n this.render('success');\n }\n }\n\n private render(state: string) {\n this.cleanup();\n const portal = this._resolvePortal();\n if (!portal) return;\n\n const win = this.ownerDocument?.defaultView || window;\n const helperSet = SwcUtils.getHelperAndHostSet(win, this);\n\n const t = this.content.querySelector(`template[is=\"swc-${state}\"]`) as HTMLTemplateElement;\n if (t) {\n const clone = t.content.cloneNode(true) as DocumentFragment;\n this._nodes = Array.from(clone.childNodes);\n const elements = this._nodes.filter(n => n.nodeType === 1) as HTMLElement[];\n const groupArgs = { ...helperSet, $value: this._value, $nodes: this._nodes, $elements: elements, $firstElement: elements[0], $state: state };\n\n this._nodes.forEach((n, nodeIdx) => {\n if (n instanceof HTMLElement) (n as any).__swc_host = this;\n this._executeCloneCallback('on-clone-node', { ...groupArgs, $node: n, $nodeIndex: nodeIdx, $isElement: n.nodeType === 1 });\n });\n\n this._executeCloneCallback('on-clone-nodes', groupArgs);\n\n if (portal === this.parentElement) {\n portal.insertBefore(clone, this.nextSibling);\n } else {\n portal.appendChild(clone);\n }\n }\n }\n\n private cleanup() {\n this._nodes.forEach(n => n.parentElement?.removeChild(n));\n this._nodes = [];\n }\n\n connectedCallback() {\n this.refresh();\n }\n disconnectedCallback() {\n this.cleanup();\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;AAAA,SAAS,4BAA4B;AACrC,SAAS,gBAAgB;AACzB,SAAS,qBAAqB;AAExB,MAAO,iBAAiB,oBAAmB;EAAjD,cAAA;;AACU,SAAA,SAAiB,CAAA;AACjB,SAAA,SAAc;EAsFxB;EApFU,iBAAc;AACpB,UAAM,eAAe,KAAK,aAAa,eAAe;AACtD,QAAI,CAAC;AAAc,aAAO,KAAK;AAE/B,UAAM,MAAM,KAAK,eAAe,eAAe;AAC/C,UAAM,MAAM,cAAc,cAAc;MACtC,QAAQ;MACR,SAAS;MACT,MAAM,SAAS,oBAAoB,KAAK,IAAI;KAC7C;AAED,QAAI,eAAe;AAAa,a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CAAC,GAAG,YAAW;AACjC,YAAI,aAAa;AAAc,YAAU,aAAa;AACtD,aAAK,sBAAsB,iBAAiB,EAAE,GAAG,WAAW,OAAO,GAAG,YAAY,SAAS,YAAY,EAAE,aAAa,EAAC,CAAE;MAC3H,CAAC;AAED,WAAK,sBAAsB,kBAAkB,SAAS;AAEtD,UAAI,WAAW,KAAK,eAAe;AACjC,eAAO,aAAa,OAAO,KAAK,WAAW;MAC7C,OAAO;AACL,eAAO,YAAY,KAAK;MAC1B;IACF;EACF;EAEQ,UAAO;AACb,SAAK,OAAO,QAAQ,OAAK,EAAE,eAAe,YAAY,CAAC,CAAC;AACxD,SAAK,SAAS,CAAA;EAChB;EAEA,oBAAiB;AACf,SAAK,QAAO;EACd;EACA,uBAAoB;AAClB,SAAK,QAAO;EACd;;AA5DQ,WAAA;EADP,qBAAqB,cAAc;;;;;",
6
6
  "names": []
7
7
  }
@@ -7,9 +7,9 @@ var __decorate = function(decorators, target, key, desc) {
7
7
  var __metadata = function(k, v) {
8
8
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
9
  };
10
- import { changedAttribute } from "../decorators/changedAttribute.js";
10
+ import { changedAttributeHost } from "../decorators/changedAttributeHost.js";
11
11
  import { SwcUtils } from "../utils/Utils.js";
12
- import { FunctionUtils } from "@dooboostore/core/function/FunctionUtils";
12
+ import { FunctionUtils } from "@dooboostore/core";
13
13
  class SwcChoose extends HTMLTemplateElement {
14
14
  constructor() {
15
15
  super(...arguments);
@@ -101,7 +101,7 @@ class SwcChoose extends HTMLTemplateElement {
101
101
  }
102
102
  }
103
103
  __decorate([
104
- changedAttribute("on-get-value"),
104
+ changedAttributeHost("on-get-value"),
105
105
  __metadata("design:type", Function),
106
106
  __metadata("design:paramtypes", []),
107
107
  __metadata("design:returntype", void 0)
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/elements/SwcChoose.ts"],
4
- "sourcesContent": ["import { changedAttribute } from '../decorators/changedAttribute';\nimport { SwcUtils } from '../utils/Utils';\nimport { FunctionUtils } from '@dooboostore/core/function/FunctionUtils';\n\nexport class SwcChoose extends HTMLTemplateElement {\n private _nodes: Node[] = [];\n private _value: any = null;\n\n get value(): any {\n return this._value;\n }\n set value(nv: any) {\n this._value = nv;\n this.render();\n }\n\n private _resolvePortal(): Element | null {\n const portalScript = this.getAttribute('on-get-portal');\n if (!portalScript) return this.parentElement;\n\n const win = this.ownerDocument?.defaultView || window;\n const res = FunctionUtils.executeReturn({\n script: portalScript,\n context: this,\n args: SwcUtils.getHelperAndHostSet(win, this)\n });\n\n if (res instanceof HTMLElement) return res;\n if (typeof res === 'string') return win.document.querySelector(res);\n return this.parentElement;\n }\n\n private _executeCloneCallback(attr: string, args: any) {\n const script = this.getAttribute(attr);\n if (!script) return;\n FunctionUtils.execute({ script, context: this, args });\n }\n\n @changedAttribute('on-get-value')\n private refresh() {\n const script = this.getAttribute('on-get-value');\n if (!script) {\n this.value = null;\n return;\n }\n const win = this.ownerDocument?.defaultView || window;\n const result = FunctionUtils.executeReturn({ script, context: this, args: SwcUtils.getHelperAndHostSet(win, this) });\n this.value = result;\n }\n\n private render() {\n this.cleanup();\n const portal = this._resolvePortal();\n if (!portal) return;\n\n const win = this.ownerDocument?.defaultView || window;\n const helperSet = SwcUtils.getHelperAndHostSet(win, this);\n\n const templates = Array.from(this.content.querySelectorAll('template'));\n let selected: HTMLTemplateElement | null = null;\n for (const t of templates) {\n if (t.getAttribute('is') === 'swc-when' && String(t.getAttribute('value')) === String(this._value)) {\n selected = t;\n break;\n }\n }\n const target = selected || (this.content.querySelector('template[is=\"swc-otherwise\"]') as HTMLTemplateElement);\n\n if (target) {\n const clone = target.content.cloneNode(true) as DocumentFragment;\n this._nodes = Array.from(clone.childNodes);\n const elements = this._nodes.filter(n => n.nodeType === 1) as HTMLElement[];\n const groupArgs = { ...helperSet, $value: this._value, $nodes: this._nodes, $elements: elements, $firstElement: elements[0] };\n\n this._nodes.forEach((n, nodeIdx) => {\n if (n instanceof HTMLElement) (n as any).__swc_host = this;\n this._executeCloneCallback('on-clone-node', { ...groupArgs, $node: n, $nodeIndex: nodeIdx, $isElement: n.nodeType === 1 });\n });\n\n this._executeCloneCallback('on-clone-nodes', groupArgs);\n\n if (portal === this.parentElement) {\n portal.insertBefore(clone, this.nextSibling);\n } else {\n portal.appendChild(clone);\n }\n }\n }\n\n private cleanup() {\n this._nodes.forEach(n => n.parentElement?.removeChild(n));\n this._nodes = [];\n }\n\n connectedCallback() {\n this.refresh();\n }\n disconnectedCallback() {\n this.cleanup();\n }\n}\n"],
5
- "mappings": ";;;;;;;;;AAAA,SAAS,wBAAwB;AACjC,SAAS,gBAAgB;AACzB,SAAS,qBAAqB;AAExB,MAAO,kBAAkB,oBAAmB;EAAlD,cAAA;;AACU,SAAA,SAAiB,CAAA;AACjB,SAAA,SAAc;EA8FxB;EA5FE,IAAI,QAAK;AACP,WAAO,KAAK;EACd;EACA,IAAI,MAAM,IAAO;AACf,SAAK,SAAS;AACd,SAAK,OAAM;EACb;EAEQ,iBAAc;AACpB,UAAM,eAAe,KAAK,aAAa,eAAe;AACtD,QAAI,CAAC;AAAc,aAAO,KAAK;AAE/B,UAAM,MAAM,KAAK,eAAe,eAAe;AAC/C,UAAM,MAAM,cAAc,cAAc;MACtC,QAAQ;MACR,SAAS;MACT,MAAM,SAAS,oBAAoB,KAAK,IAAI;KAC7C;AAED,QAAI,eAAe;AAAa,aAAO;AACvC,QAAI,OAAO,QAAQ;AAAU,aAAO,IAAI,SAAS,cAAc,GAAG;AAClE,WAAO,KAAK;EACd;EAEQ,sBAAsB,MAAc,MAAS;AACnD,UAAM,SAAS,KAAK,aAAa,IAAI;AACrC,QAAI,CAAC;AAAQ;AACb,kBAAc,QAAQ,EAAE,QAAQ,SAAS,MAAM,KAAI,CAAE;EACvD;EAGQ,UAAO;AACb,UAAM,SAAS,KAAK,aAAa,cAAc;AAC/C,QAAI,CAAC,QAAQ;AACX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L,eAAO,YAAY,KAAK;MAC1B;IACF;EACF;EAEQ,UAAO;AACb,SAAK,OAAO,QAAQ,OAAK,EAAE,eAAe,YAAY,CAAC,CAAC;AACxD,SAAK,SAAS,CAAA;EAChB;EAEA,oBAAiB;AACf,SAAK,QAAO;EACd;EACA,uBAAoB;AAClB,SAAK,QAAO;EACd;;AA5DQ,WAAA;EADP,iBAAiB,cAAc;;;;;",
4
+ "sourcesContent": ["import { changedAttributeHost } from '../decorators/changedAttributeHost';\nimport { SwcUtils } from '../utils/Utils';\nimport { FunctionUtils } from '@dooboostore/core';\n\nexport class SwcChoose extends HTMLTemplateElement {\n private _nodes: Node[] = [];\n private _value: any = null;\n\n get value(): any {\n return this._value;\n }\n set value(nv: any) {\n this._value = nv;\n this.render();\n }\n\n private _resolvePortal(): Element | null {\n const portalScript = this.getAttribute('on-get-portal');\n if (!portalScript) return this.parentElement;\n\n const win = this.ownerDocument?.defaultView || window;\n const res = FunctionUtils.executeReturn({\n script: portalScript,\n context: this,\n args: SwcUtils.getHelperAndHostSet(win, this)\n });\n\n if (res instanceof HTMLElement) return res;\n if (typeof res === 'string') return win.document.querySelector(res);\n return this.parentElement;\n }\n\n private _executeCloneCallback(attr: string, args: any) {\n const script = this.getAttribute(attr);\n if (!script) return;\n FunctionUtils.execute({ script, context: this, args });\n }\n\n @changedAttributeHost('on-get-value')\n private refresh() {\n const script = this.getAttribute('on-get-value');\n if (!script) {\n this.value = null;\n return;\n }\n const win = this.ownerDocument?.defaultView || window;\n const result = FunctionUtils.executeReturn({ script, context: this, args: SwcUtils.getHelperAndHostSet(win, this) });\n this.value = result;\n }\n\n private render() {\n this.cleanup();\n const portal = this._resolvePortal();\n if (!portal) return;\n\n const win = this.ownerDocument?.defaultView || window;\n const helperSet = SwcUtils.getHelperAndHostSet(win, this);\n\n const templates = Array.from(this.content.querySelectorAll('template'));\n let selected: HTMLTemplateElement | null = null;\n for (const t of templates) {\n if (t.getAttribute('is') === 'swc-when' && String(t.getAttribute('value')) === String(this._value)) {\n selected = t;\n break;\n }\n }\n const target = selected || (this.content.querySelector('template[is=\"swc-otherwise\"]') as HTMLTemplateElement);\n\n if (target) {\n const clone = target.content.cloneNode(true) as DocumentFragment;\n this._nodes = Array.from(clone.childNodes);\n const elements = this._nodes.filter(n => n.nodeType === 1) as HTMLElement[];\n const groupArgs = { ...helperSet, $value: this._value, $nodes: this._nodes, $elements: elements, $firstElement: elements[0] };\n\n this._nodes.forEach((n, nodeIdx) => {\n if (n instanceof HTMLElement) (n as any).__swc_host = this;\n this._executeCloneCallback('on-clone-node', { ...groupArgs, $node: n, $nodeIndex: nodeIdx, $isElement: n.nodeType === 1 });\n });\n\n this._executeCloneCallback('on-clone-nodes', groupArgs);\n\n if (portal === this.parentElement) {\n portal.insertBefore(clone, this.nextSibling);\n } else {\n portal.appendChild(clone);\n }\n }\n }\n\n private cleanup() {\n this._nodes.forEach(n => n.parentElement?.removeChild(n));\n this._nodes = [];\n }\n\n connectedCallback() {\n this.refresh();\n }\n disconnectedCallback() {\n this.cleanup();\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;AAAA,SAAS,4BAA4B;AACrC,SAAS,gBAAgB;AACzB,SAAS,qBAAqB;AAExB,MAAO,kBAAkB,oBAAmB;EAAlD,cAAA;;AACU,SAAA,SAAiB,CAAA;AACjB,SAAA,SAAc;EA8FxB;EA5FE,IAAI,QAAK;AACP,WAAO,KAAK;EACd;EACA,IAAI,MAAM,IAAO;AACf,SAAK,SAAS;AACd,SAAK,OAAM;EACb;EAEQ,iBAAc;AACpB,UAAM,eAAe,KAAK,aAAa,eAAe;AACtD,QAAI,CAAC;AAAc,aAAO,KAAK;AAE/B,UAAM,MAAM,KAAK,eAAe,eAAe;AAC/C,UAAM,MAAM,cAAc,cAAc;MACtC,QAAQ;MACR,SAAS;MACT,MAAM,SAAS,oBAAoB,KAAK,IAAI;KAC7C;AAED,QAAI,eAAe;AAAa,aAAO;AACvC,QAAI,OAAO,QAAQ;AAAU,aAAO,IA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,YAAW;AACjC,YAAI,aAAa;AAAc,YAAU,aAAa;AACtD,aAAK,sBAAsB,iBAAiB,EAAE,GAAG,WAAW,OAAO,GAAG,YAAY,SAAS,YAAY,EAAE,aAAa,EAAC,CAAE;MAC3H,CAAC;AAED,WAAK,sBAAsB,kBAAkB,SAAS;AAEtD,UAAI,WAAW,KAAK,eAAe;AACjC,eAAO,aAAa,OAAO,KAAK,WAAW;MAC7C,OAAO;AACL,eAAO,YAAY,KAAK;MAC1B;IACF;EACF;EAEQ,UAAO;AACb,SAAK,OAAO,QAAQ,OAAK,EAAE,eAAe,YAAY,CAAC,CAAC;AACxD,SAAK,SAAS,CAAA;EAChB;EAEA,oBAAiB;AACf,SAAK,QAAO;EACd;EACA,uBAAoB;AAClB,SAAK,QAAO;EACd;;AA5DQ,WAAA;EADP,qBAAqB,cAAc;;;;;",
6
6
  "names": []
7
7
  }
@@ -7,9 +7,9 @@ var __decorate = function(decorators, target, key, desc) {
7
7
  var __metadata = function(k, v) {
8
8
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
9
  };
10
- import { changedAttribute } from "../decorators/changedAttribute.js";
10
+ import { changedAttributeHost } from "../decorators/changedAttributeHost.js";
11
11
  import { SwcUtils } from "../utils/Utils.js";
12
- import { FunctionUtils } from "@dooboostore/core/function/FunctionUtils";
12
+ import { FunctionUtils } from "@dooboostore/core";
13
13
  class SwcIf extends HTMLTemplateElement {
14
14
  constructor() {
15
15
  super(...arguments);
@@ -109,7 +109,7 @@ class SwcIf extends HTMLTemplateElement {
109
109
  }
110
110
  }
111
111
  __decorate([
112
- changedAttribute("on-get-value"),
112
+ changedAttributeHost("on-get-value"),
113
113
  __metadata("design:type", Function),
114
114
  __metadata("design:paramtypes", []),
115
115
  __metadata("design:returntype", void 0)
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/elements/SwcIf.ts"],
4
- "sourcesContent": ["import { changedAttribute } from '../decorators/changedAttribute';\nimport { SwcUtils } from '../utils/Utils';\nimport { FunctionUtils } from '@dooboostore/core/function/FunctionUtils';\n\nexport class SwcIf extends HTMLTemplateElement {\n private _value = false;\n private _nodes: Node[] = [];\n\n get value(): boolean {\n return this._value;\n }\n set value(nv: any) {\n this._value = Boolean(nv);\n this.render();\n }\n\n private _resolvePortal(): Element | null {\n const portalScript = this.getAttribute('on-get-portal');\n if (!portalScript) return this.parentElement;\n\n const win = this.ownerDocument?.defaultView || window;\n const res = FunctionUtils.executeReturn({\n script: portalScript,\n context: this,\n args: SwcUtils.getHelperAndHostSet(win, this)\n });\n\n if (res instanceof HTMLElement) return res;\n if (typeof res === 'string') return win.document.querySelector(res);\n return this.parentElement;\n }\n\n private _executeCloneCallback(attr: string, args: any) {\n const script = this.getAttribute(attr);\n if (!script) return;\n FunctionUtils.execute({ script, context: this, args });\n }\n\n @changedAttribute('on-get-value')\n private refreshValue() {\n const script = this.getAttribute('on-get-value');\n if (!script) {\n this.value = false;\n return;\n }\n const win = this.ownerDocument?.defaultView || window;\n const res = FunctionUtils.executeReturn({\n script,\n context: this,\n args: SwcUtils.getHelperAndHostSet(win, this)\n });\n\n if (res instanceof Promise) {\n res.then(v => (this.value = v)).catch(() => (this.value = false));\n } else {\n this.value = res;\n }\n }\n\n private render() {\n this.cleanup();\n const portal = this._resolvePortal();\n if (!portal) return;\n\n const win = this.ownerDocument?.defaultView || window;\n const helperSet = SwcUtils.getHelperAndHostSet(win, this);\n\n let targetTpl: HTMLTemplateElement | null = null;\n if (this._value) {\n targetTpl = this;\n } else {\n targetTpl = this.content.querySelector('template[is=\"swc-default\"]') as HTMLTemplateElement;\n }\n\n if (targetTpl) {\n const clone = targetTpl.content.cloneNode(true) as DocumentFragment;\n // If it's the host template, remove sub-templates from clone\n if (targetTpl === this) {\n clone.querySelectorAll('template[is^=\"swc-\"]').forEach(t => t.remove());\n }\n\n this._nodes = Array.from(clone.childNodes);\n const elements = this._nodes.filter(n => n.nodeType === 1) as HTMLElement[];\n const groupArgs = { ...helperSet, $value: this._value, $nodes: this._nodes, $elements: elements, $firstElement: elements[0] };\n\n this._nodes.forEach((node, nodeIdx) => {\n if (node instanceof HTMLElement) (node as any).__swc_host = this;\n this._executeCloneCallback('on-clone-node', { ...groupArgs, $node: node, $nodeIndex: nodeIdx, $isElement: node.nodeType === 1 });\n });\n\n this._executeCloneCallback('on-clone-nodes', groupArgs);\n\n if (portal === this.parentElement) {\n portal.insertBefore(clone, this.nextSibling);\n } else {\n portal.appendChild(clone);\n }\n }\n }\n\n private cleanup() {\n this._nodes.forEach(n => n.parentElement?.removeChild(n));\n this._nodes = [];\n }\n\n connectedCallback() {\n this.refreshValue();\n }\n disconnectedCallback() {\n this.cleanup();\n }\n}\n"],
5
- "mappings": ";;;;;;;;;AAAA,SAAS,wBAAwB;AACjC,SAAS,gBAAgB;AACzB,SAAS,qBAAqB;AAExB,MAAO,cAAc,oBAAmB;EAA9C,cAAA;;AACU,SAAA,SAAS;AACT,SAAA,SAAiB,CAAA;EAyG3B;EAvGE,IAAI,QAAK;AACP,WAAO,KAAK;EACd;EACA,IAAI,MAAM,IAAO;AACf,SAAK,SAAS,QAAQ,EAAE;AACxB,SAAK,OAAM;EACb;EAEQ,iBAAc;AACpB,UAAM,eAAe,KAAK,aAAa,eAAe;AACtD,QAAI,CAAC;AAAc,aAAO,KAAK;AAE/B,UAAM,MAAM,KAAK,eAAe,eAAe;AAC/C,UAAM,MAAM,cAAc,cAAc;MACtC,QAAQ;MACR,SAAS;MACT,MAAM,SAAS,oBAAoB,KAAK,IAAI;KAC7C;AAED,QAAI,eAAe;AAAa,aAAO;AACvC,QAAI,OAAO,QAAQ;AAAU,aAAO,IAAI,SAAS,cAAc,GAAG;AAClE,WAAO,KAAK;EACd;EAEQ,sBAAsB,MAAc,MAAS;AACnD,UAAM,SAAS,KAAK,aAAa,IAAI;AACrC,QAAI,CAAC;AAAQ;AACb,kBAAc,QAAQ,EAAE,QAAQ,SAAS,MAAM,KAAI,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jI,CAAC;AAED,WAAK,sBAAsB,kBAAkB,SAAS;AAEtD,UAAI,WAAW,KAAK,eAAe;AACjC,eAAO,aAAa,OAAO,KAAK,WAAW;MAC7C,OAAO;AACL,eAAO,YAAY,KAAK;MAC1B;IACF;EACF;EAEQ,UAAO;AACb,SAAK,OAAO,QAAQ,OAAK,EAAE,eAAe,YAAY,CAAC,CAAC;AACxD,SAAK,SAAS,CAAA;EAChB;EAEA,oBAAiB;AACf,SAAK,aAAY;EACnB;EACA,uBAAoB;AAClB,SAAK,QAAO;EACd;;AAvEQ,WAAA;EADP,iBAAiB,cAAc;;;;;",
4
+ "sourcesContent": ["import { changedAttributeHost } from '../decorators/changedAttributeHost';\nimport { SwcUtils } from '../utils/Utils';\nimport { FunctionUtils } from '@dooboostore/core';\n\nexport class SwcIf extends HTMLTemplateElement {\n private _value = false;\n private _nodes: Node[] = [];\n\n get value(): boolean {\n return this._value;\n }\n set value(nv: any) {\n this._value = Boolean(nv);\n this.render();\n }\n\n private _resolvePortal(): Element | null {\n const portalScript = this.getAttribute('on-get-portal');\n if (!portalScript) return this.parentElement;\n\n const win = this.ownerDocument?.defaultView || window;\n const res = FunctionUtils.executeReturn({\n script: portalScript,\n context: this,\n args: SwcUtils.getHelperAndHostSet(win, this)\n });\n\n if (res instanceof HTMLElement) return res;\n if (typeof res === 'string') return win.document.querySelector(res);\n return this.parentElement;\n }\n\n private _executeCloneCallback(attr: string, args: any) {\n const script = this.getAttribute(attr);\n if (!script) return;\n FunctionUtils.execute({ script, context: this, args });\n }\n\n @changedAttributeHost('on-get-value')\n private refreshValue() {\n const script = this.getAttribute('on-get-value');\n if (!script) {\n this.value = false;\n return;\n }\n const win = this.ownerDocument?.defaultView || window;\n const res = FunctionUtils.executeReturn({\n script,\n context: this,\n args: SwcUtils.getHelperAndHostSet(win, this)\n });\n\n if (res instanceof Promise) {\n res.then(v => (this.value = v)).catch(() => (this.value = false));\n } else {\n this.value = res;\n }\n }\n\n private render() {\n this.cleanup();\n const portal = this._resolvePortal();\n if (!portal) return;\n\n const win = this.ownerDocument?.defaultView || window;\n const helperSet = SwcUtils.getHelperAndHostSet(win, this);\n\n let targetTpl: HTMLTemplateElement | null = null;\n if (this._value) {\n targetTpl = this;\n } else {\n targetTpl = this.content.querySelector('template[is=\"swc-default\"]') as HTMLTemplateElement;\n }\n\n if (targetTpl) {\n const clone = targetTpl.content.cloneNode(true) as DocumentFragment;\n // If it's the host template, remove sub-templates from clone\n if (targetTpl === this) {\n clone.querySelectorAll('template[is^=\"swc-\"]').forEach(t => t.remove());\n }\n\n this._nodes = Array.from(clone.childNodes);\n const elements = this._nodes.filter(n => n.nodeType === 1) as HTMLElement[];\n const groupArgs = { ...helperSet, $value: this._value, $nodes: this._nodes, $elements: elements, $firstElement: elements[0] };\n\n this._nodes.forEach((node, nodeIdx) => {\n if (node instanceof HTMLElement) (node as any).__swc_host = this;\n this._executeCloneCallback('on-clone-node', { ...groupArgs, $node: node, $nodeIndex: nodeIdx, $isElement: node.nodeType === 1 });\n });\n\n this._executeCloneCallback('on-clone-nodes', groupArgs);\n\n if (portal === this.parentElement) {\n portal.insertBefore(clone, this.nextSibling);\n } else {\n portal.appendChild(clone);\n }\n }\n }\n\n private cleanup() {\n this._nodes.forEach(n => n.parentElement?.removeChild(n));\n this._nodes = [];\n }\n\n connectedCallback() {\n this.refreshValue();\n }\n disconnectedCallback() {\n this.cleanup();\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;AAAA,SAAS,4BAA4B;AACrC,SAAS,gBAAgB;AACzB,SAAS,qBAAqB;AAExB,MAAO,cAAc,oBAAmB;EAA9C,cAAA;;AACU,SAAA,SAAS;AACT,SAAA,SAAiB,CAAA;EAyG3B;EAvGE,IAAI,QAAK;AACP,WAAO,KAAK;EACd;EACA,IAAI,MAAM,IAAO;AACf,SAAK,SAAS,QAAQ,EAAE;AACxB,SAAK,OAAM;EACb;EAEQ,iBAAc;AACpB,UAAM,eAAe,KAAK,aAAa,eAAe;AACtD,QAA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,CAAE;MACxE;AAEA,WAAK,SAAS,MAAM,KAAK,MAAM,UAAU;AACzC,YAAM,WAAW,KAAK,OAAO,OAAO,OAAK,EAAE,aAAa,CAAC;AACzD,YAAM,YAAY,EAAE,GAAG,WAAW,QAAQ,KAAK,QAAQ,QAAQ,KAAK,QAAQ,WAAW,UAAU,eAAe,SAAS,CAAC,EAAC;AAE3H,WAAK,OAAO,QAAQ,CAAC,MAAM,YAAW;AACpC,YAAI,gBAAgB;AAAc,eAAa,aAAa;AAC5D,aAAK,sBAAsB,iBAAiB,EAAE,GAAG,WAAW,OAAO,MAAM,YAAY,SAAS,YAAY,KAAK,aAAa,EAAC,CAAE;MACjI,CAAC;AAED,WAAK,sBAAsB,kBAAkB,SAAS;AAEtD,UAAI,WAAW,KAAK,eAAe;AACjC,eAAO,aAAa,OAAO,KAAK,WAAW;MAC7C,OAAO;AACL,eAAO,YAAY,KAAK;MAC1B;IACF;EACF;EAEQ,UAAO;AACb,SAAK,OAAO,QAAQ,OAAK,EAAE,eAAe,YAAY,CAAC,CAAC;AACxD,SAAK,SAAS,CAAA;EAChB;EAEA,oBAAiB;AACf,SAAK,aAAY;EACnB;EACA,uBAAoB;AAClB,SAAK,QAAO;EACd;;AAvEQ,WAAA;EADP,qBAAqB,cAAc;;;;;",
6
6
  "names": []
7
7
  }
@@ -7,9 +7,9 @@ var __decorate = function(decorators, target, key, desc) {
7
7
  var __metadata = function(k, v) {
8
8
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
9
  };
10
- import { changedAttribute } from "../decorators/changedAttribute.js";
10
+ import { changedAttributeHost } from "../decorators/changedAttributeHost.js";
11
11
  import { SwcUtils } from "../utils/Utils.js";
12
- import { FunctionUtils } from "@dooboostore/core/function/FunctionUtils";
12
+ import { FunctionUtils } from "@dooboostore/core";
13
13
  class SwcLoop extends HTMLTemplateElement {
14
14
  constructor() {
15
15
  super(...arguments);
@@ -115,7 +115,7 @@ class SwcLoop extends HTMLTemplateElement {
115
115
  }
116
116
  }
117
117
  __decorate([
118
- changedAttribute("on-get-value"),
118
+ changedAttributeHost("on-get-value"),
119
119
  __metadata("design:type", Function),
120
120
  __metadata("design:paramtypes", []),
121
121
  __metadata("design:returntype", void 0)
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/elements/SwcLoop.ts"],
4
- "sourcesContent": ["import { changedAttribute } from '../decorators/changedAttribute';\nimport { SwcUtils } from '../utils/Utils';\nimport { FunctionUtils } from '@dooboostore/core/function/FunctionUtils';\n\nexport class SwcLoop extends HTMLTemplateElement {\n private _value: any[] = [];\n private _nodeGroups: Node[][] = [];\n\n get value(): any[] {\n return this._value;\n }\n set value(nv: any[]) {\n this._value = Array.isArray(nv) ? [...nv] : [];\n this.render();\n }\n\n private _resolvePortal(): Element | null {\n const portalScript = this.getAttribute('on-get-portal');\n if (!portalScript) return this.parentElement;\n\n const win = this.ownerDocument?.defaultView || window;\n const res = FunctionUtils.executeReturn({\n script: portalScript,\n context: this,\n args: SwcUtils.getHelperAndHostSet(win, this)\n });\n\n if (res instanceof HTMLElement) return res;\n if (typeof res === 'string') return win.document.querySelector(res);\n return this.parentElement;\n }\n\n private _executeCloneCallback(attr: string, args: any) {\n const script = this.getAttribute(attr);\n if (!script) return;\n FunctionUtils.execute({ script, context: this, args });\n }\n\n private _cleanup() {\n this._nodeGroups.forEach(nodes => nodes.forEach(n => n.parentElement?.removeChild(n)));\n this._nodeGroups = [];\n }\n\n @changedAttribute('on-get-value')\n private refreshValue() {\n const script = this.getAttribute('on-get-value');\n if (!script) {\n this.value = [];\n return;\n }\n const win = this.ownerDocument?.defaultView || window;\n const res = FunctionUtils.executeReturn({\n script,\n context: this,\n args: SwcUtils.getHelperAndHostSet(win, this)\n });\n\n if (res instanceof Promise) {\n res.then(v => (this.value = v)).catch(() => (this.value = []));\n } else {\n this.value = res;\n }\n }\n\n render() {\n this._cleanup();\n const portal = this._resolvePortal();\n if (!portal) return;\n\n const win = this.ownerDocument?.defaultView || window;\n const helperSet = SwcUtils.getHelperAndHostSet(win, this);\n const fragment = win.document.createDocumentFragment();\n\n if (this._value.length === 0) {\n const defaultTpl = this.content.querySelector('template[is=\"swc-default\"]') as HTMLTemplateElement;\n if (defaultTpl) {\n const clone = defaultTpl.content.cloneNode(true);\n const nodes = Array.from(clone.childNodes);\n this._nodeGroups.push(nodes);\n fragment.appendChild(clone);\n }\n } else {\n this._value.forEach((item, index) => {\n const clone = this.content.cloneNode(true) as DocumentFragment;\n // Filter out sub-templates\n const subTemplates = clone.querySelectorAll('template[is^=\"swc-\"]');\n subTemplates.forEach(t => t.remove());\n\n const nodes = Array.from(clone.childNodes);\n const elements = nodes.filter(n => n.nodeType === 1) as HTMLElement[];\n\n const groupArgs = { ...helperSet, $item: item, $index: index, $value: this._value, $nodes: nodes, $elements: elements, $firstElement: elements[0] };\n\n nodes.forEach((node, nodeIdx) => {\n if (node instanceof HTMLElement) (node as any).__swc_host = this;\n this._executeCloneCallback('on-clone-node', { ...groupArgs, $node: node, $nodeIndex: nodeIdx, $isElement: node.nodeType === 1 });\n });\n\n this._executeCloneCallback('on-clone-nodes', groupArgs);\n this._nodeGroups.push(nodes);\n fragment.appendChild(clone);\n });\n }\n\n if (portal === this.parentElement) {\n portal.insertBefore(fragment, this.nextSibling);\n } else {\n portal.appendChild(fragment);\n }\n }\n\n connectedCallback() {\n this.refreshValue();\n }\n disconnectedCallback() {\n this._cleanup();\n }\n}\n"],
5
- "mappings": ";;;;;;;;;AAAA,SAAS,wBAAwB;AACjC,SAAS,gBAAgB;AACzB,SAAS,qBAAqB;AAExB,MAAO,gBAAgB,oBAAmB;EAAhD,cAAA;;AACU,SAAA,SAAgB,CAAA;AAChB,SAAA,cAAwB,CAAA;EA+GlC;EA7GE,IAAI,QAAK;AACP,WAAO,KAAK;EACd;EACA,IAAI,MAAM,IAAS;AACjB,SAAK,SAAS,MAAM,QAAQ,EAAE,IAAI,CAAC,GAAG,EAAE,I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ent": ["import { changedAttributeHost } from '../decorators/changedAttributeHost';\nimport { SwcUtils } from '../utils/Utils';\nimport { FunctionUtils } from '@dooboostore/core';\n\nexport class SwcLoop extends HTMLTemplateElement {\n private _value: any[] = [];\n private _nodeGroups: Node[][] = [];\n\n get value(): any[] {\n return this._value;\n }\n set value(nv: any[]) {\n this._value = Array.isArray(nv) ? [...nv] : [];\n this.render();\n }\n\n private _resolvePortal(): Element | null {\n const portalScript = this.getAttribute('on-get-portal');\n if (!portalScript) return this.parentElement;\n\n const win = this.ownerDocument?.defaultView || window;\n const res = FunctionUtils.executeReturn({\n script: portalScript,\n context: this,\n args: SwcUtils.getHelperAndHostSet(win, this)\n });\n\n if (res instanceof HTMLElement) return res;\n if (typeof res === 'string') return win.document.querySelector(res);\n return this.parentElement;\n }\n\n private _executeCloneCallback(attr: string, args: any) {\n const script = this.getAttribute(attr);\n if (!script) return;\n FunctionUtils.execute({ script, context: this, args });\n }\n\n private _cleanup() {\n this._nodeGroups.forEach(nodes => nodes.forEach(n => n.parentElement?.removeChild(n)));\n this._nodeGroups = [];\n }\n\n @changedAttributeHost('on-get-value')\n private refreshValue() {\n const script = this.getAttribute('on-get-value');\n if (!script) {\n this.value = [];\n return;\n }\n const win = this.ownerDocument?.defaultView || window;\n const res = FunctionUtils.executeReturn({\n script,\n context: this,\n args: SwcUtils.getHelperAndHostSet(win, this)\n });\n\n if (res instanceof Promise) {\n res.then(v => (this.value = v)).catch(() => (this.value = []));\n } else {\n this.value = res;\n }\n }\n\n render() {\n this._cleanup();\n const portal = this._resolvePortal();\n if (!portal) return;\n\n const win = this.ownerDocument?.defaultView || window;\n const helperSet = SwcUtils.getHelperAndHostSet(win, this);\n const fragment = win.document.createDocumentFragment();\n\n if (this._value.length === 0) {\n const defaultTpl = this.content.querySelector('template[is=\"swc-default\"]') as HTMLTemplateElement;\n if (defaultTpl) {\n const clone = defaultTpl.content.cloneNode(true);\n const nodes = Array.from(clone.childNodes);\n this._nodeGroups.push(nodes);\n fragment.appendChild(clone);\n }\n } else {\n this._value.forEach((item, index) => {\n const clone = this.content.cloneNode(true) as DocumentFragment;\n // Filter out sub-templates\n const subTemplates = clone.querySelectorAll('template[is^=\"swc-\"]');\n subTemplates.forEach(t => t.remove());\n\n const nodes = Array.from(clone.childNodes);\n const elements = nodes.filter(n => n.nodeType === 1) as HTMLElement[];\n\n const groupArgs = { ...helperSet, $item: item, $index: index, $value: this._value, $nodes: nodes, $elements: elements, $firstElement: elements[0] };\n\n nodes.forEach((node, nodeIdx) => {\n if (node instanceof HTMLElement) (node as any).__swc_host = this;\n this._executeCloneCallback('on-clone-node', { ...groupArgs, $node: node, $nodeIndex: nodeIdx, $isElement: node.nodeType === 1 });\n });\n\n this._executeCloneCallback('on-clone-nodes', groupArgs);\n this._nodeGroups.push(nodes);\n fragment.appendChild(clone);\n });\n }\n\n if (portal === this.parentElement) {\n portal.insertBefore(fragment, this.nextSibling);\n } else {\n portal.appendChild(fragment);\n }\n }\n\n connectedCallback() {\n this.refreshValue();\n }\n disconnectedCallback() {\n this._cleanup();\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;AAAA,SAAS,4BAA4B;AACrC,SAAS,gBAAgB;AACzB,SAAS,qBAAqB;AAExB,MAAO,gBAAgB,oBAAmB;EAAhD,cAAA;;AACU,SAAA,SAAgB,CAAA;AAChB,SAAA,cAAwB,CAAA;EA+GlC;EA7GE,IAAI,QAAK;AACP,WAAO,KAAK;EACd;EACA,IAAI,MAAM,IAAS;AACjB,SAAK,SAAS,MAAM,QAAQ,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,CAAA;AAC5C,SAAK,OAAM;EACb;EAEQ,iBAAc;AACpB,UAAM,eAAe,KAAK,aAAa,eAAe;AACtD,QAAI,CAAC;AAAc,aAAO,KAAK;AAE/B,UAAM,MAAM,KAAK,eAAe,eAAe;AAC/C,UAAM,MAAM,cAAc,cAAc;MACtC,QAAQ;MACR,SAAS;MACT,MAAM,SAAS,oBAAoB,KAAK,IAAI;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YAAY,KAAK;MAC5B;IACF,OAAO;AACL,WAAK,OAAO,QAAQ,CAAC,MAAM,UAAS;AAClC,cAAM,QAAQ,KAAK,QAAQ,UAAU,IAAI;AAEzC,cAAM,eAAe,MAAM,iBAAiB,sBAAsB;AAClE,qBAAa,QAAQ,OAAK,EAAE,OAAM,CAAE;AAEpC,cAAM,QAAQ,MAAM,KAAK,MAAM,UAAU;AACzC,cAAM,WAAW,MAAM,OAAO,OAAK,EAAE,aAAa,CAAC;AAEnD,cAAM,YAAY,EAAE,GAAG,WAAW,OAAO,MAAM,QAAQ,OAAO,QAAQ,KAAK,QAAQ,QAAQ,OAAO,WAAW,UAAU,eAAe,SAAS,CAAC,EAAC;AAEjJ,cAAM,QAAQ,CAAC,MAAM,YAAW;AAC9B,cAAI,gBAAgB;AAAc,iBAAa,aAAa;AAC5D,eAAK,sBAAsB,iBAAiB,EAAE,GAAG,WAAW,OAAO,MAAM,YAAY,SAAS,YAAY,KAAK,aAAa,EAAC,CAAE;QACjI,CAAC;AAED,aAAK,sBAAsB,kBAAkB,SAAS;AACtD,aAAK,YAAY,KAAK,KAAK;AAC3B,iBAAS,YAAY,KAAK;MAC5B,CAAC;IACH;AAEA,QAAI,WAAW,KAAK,eAAe;AACjC,aAAO,aAAa,UAAU,KAAK,WAAW;IAChD,OAAO;AACL,aAAO,YAAY,QAAQ;IAC7B;EACF;EAEA,oBAAiB;AACf,SAAK,aAAY;EACnB;EACA,uBAAoB;AAClB,SAAK,SAAQ;EACf;;AAxEQ,WAAA;EADP,qBAAqB,cAAc;;;;;",
6
6
  "names": []
7
7
  }
@@ -10,8 +10,8 @@ var __metadata = function(k, v) {
10
10
  import { elementDefine } from "../decorators/elementDefine.js";
11
11
  import { SwcAppMixin } from "./SwcAppMixin.js";
12
12
  import { SwcUtils } from "../utils/Utils.js";
13
- import { FunctionUtils } from "@dooboostore/core/function/FunctionUtils";
14
- import { changedAttribute } from "../decorators/changedAttribute.js";
13
+ import { FunctionUtils } from "@dooboostore/core";
14
+ import { changedAttributeHost } from "../decorators/changedAttributeHost.js";
15
15
  const registerAllElements = (w) => {
16
16
  const { HTMLElement: _HTMLElement, HTMLTemplateElement: _HTMLTemplateElement, DocumentFragment: _DocumentFragment, Node: _Node, Element: _Element, HTMLAnchorElement: _HTMLAnchorElement, HTMLAreaElement: _HTMLAreaElement, HTMLAudioElement: _HTMLAudioElement, HTMLBaseElement: _HTMLBaseElement, HTMLButtonElement: _HTMLButtonElement, HTMLCanvasElement: _HTMLCanvasElement, HTMLDataElement: _HTMLDataElement, HTMLDataListElement: _HTMLDataListElement, HTMLDetailsElement: _HTMLDetailsElement, HTMLDialogElement: _HTMLDialogElement, HTMLDivElement: _HTMLDivElement, HTMLDListElement: _HTMLDListElement, HTMLEmbedElement: _HTMLEmbedElement, HTMLFieldSetElement: _HTMLFieldSetElement, HTMLFormElement: _HTMLFormElement, HTMLHRElement: _HTMLHRElement, HTMLIFrameElement: _HTMLIFrameElement, HTMLImageElement: _HTMLImageElement, HTMLInputElement: _HTMLInputElement, HTMLLabelElement: _HTMLLabelElement, HTMLLegendElement: _HTMLLegendElement, HTMLLIElement: _HTMLLIElement, HTMLLinkElement: _HTMLLinkElement, HTMLMapElement: _HTMLMapElement, HTMLMetaElement: _HTMLMetaElement, HTMLMeterElement: _HTMLMeterElement, HTMLModElement: _HTMLModElement, HTMLObjectElement: _HTMLObjectElement, HTMLOListElement: _HTMLOListElement, HTMLOptGroupElement: _HTMLOptGroupElement, HTMLOptionElement: _HTMLOptionElement, HTMLOutputElement: _HTMLOutputElement, HTMLParagraphElement: _HTMLParagraphElement, HTMLParamElement: _HTMLParamElement, HTMLPictureElement: _HTMLPictureElement, HTMLPreElement: _HTMLPreElement, HTMLProgressElement: _HTMLProgressElement, HTMLQuoteElement: _HTMLQuoteElement, HTMLScriptElement: _HTMLScriptElement, HTMLSelectElement: _HTMLSelectElement, HTMLSlotElement: _HTMLSlotElement, HTMLSourceElement: _HTMLSourceElement, HTMLSpanElement: _HTMLSpanElement, HTMLStyleElement: _HTMLStyleElement, HTMLTableElement: _HTMLTableElement, HTMLTableSectionElement: _HTMLTableSectionElement, HTMLTableCellElement: _HTMLTableCellElement, HTMLTextAreaElement: _HTMLTextAreaElement, HTMLTimeElement: _HTMLTimeElement, HTMLTitleElement: _HTMLTitleElement, HTMLTableRowElement: _HTMLTableRowElement, HTMLTrackElement: _HTMLTrackElement, HTMLUListElement: _HTMLUListElement, HTMLVideoElement: _HTMLVideoElement, HTMLHeadingElement: _HTMLHeadingElement, HTMLBodyElement: _HTMLBodyElement } = w;
17
17
  const HTMLElement = _HTMLElement;
@@ -209,7 +209,7 @@ const registerAllElements = (w) => {
209
209
  }
210
210
  };
211
211
  __decorate([
212
- changedAttribute("on-get-value"),
212
+ changedAttributeHost("on-get-value"),
213
213
  __metadata("design:type", Function),
214
214
  __metadata("design:paramtypes", []),
215
215
  __metadata("design:returntype", void 0)
@@ -322,7 +322,7 @@ const registerAllElements = (w) => {
322
322
  }
323
323
  };
324
324
  __decorate([
325
- changedAttribute("on-get-value"),
325
+ changedAttributeHost("on-get-value"),
326
326
  __metadata("design:type", Function),
327
327
  __metadata("design:paramtypes", []),
328
328
  __metadata("design:returntype", void 0)
@@ -421,7 +421,7 @@ const registerAllElements = (w) => {
421
421
  }
422
422
  };
423
423
  __decorate([
424
- changedAttribute("on-get-value"),
424
+ changedAttributeHost("on-get-value"),
425
425
  __metadata("design:type", Function),
426
426
  __metadata("design:paramtypes", []),
427
427
  __metadata("design:returntype", void 0)
@@ -512,7 +512,7 @@ const registerAllElements = (w) => {
512
512
  }
513
513
  };
514
514
  __decorate([
515
- changedAttribute("on-get-value"),
515
+ changedAttributeHost("on-get-value"),
516
516
  __metadata("design:type", Function),
517
517
  __metadata("design:paramtypes", []),
518
518
  __metadata("design:returntype", void 0)
@@ -805,6 +805,7 @@ const registerAllElements = (w) => {
805
805
  SwcAppBody = __decorate([
806
806
  elementDefine("swc-app-body", { extends: "body", window: w })
807
807
  ], SwcAppBody);
808
+ return [];
808
809
  };
809
810
  export {
810
811
  registerAllElements