@dooboostore/simple-web-component 1.0.36 → 1.0.38

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 (281) hide show
  1. package/README.md +396 -68
  2. package/dist/cjs/{elements/SwcAppEngine.js → SwcAppEngine.js} +9 -6
  3. package/dist/cjs/SwcAppEngine.js.map +7 -0
  4. package/dist/cjs/decorators/addEventListener.js +20 -4
  5. package/dist/cjs/decorators/addEventListener.js.map +2 -2
  6. package/dist/cjs/decorators/applyAttribute.js.map +1 -1
  7. package/dist/cjs/decorators/applyClass.js.map +1 -1
  8. package/dist/cjs/decorators/applyNode.js +109 -26
  9. package/dist/cjs/decorators/applyNode.js.map +2 -2
  10. package/dist/cjs/decorators/applySlot.js +129 -0
  11. package/dist/cjs/decorators/applySlot.js.map +7 -0
  12. package/dist/cjs/decorators/applyStyle.js.map +2 -2
  13. package/dist/cjs/decorators/attribute.js.map +1 -1
  14. package/dist/cjs/decorators/elementDefine.js +90 -52
  15. package/dist/cjs/decorators/elementDefine.js.map +2 -2
  16. package/dist/cjs/decorators/emitCustomEvent.js.map +1 -1
  17. package/dist/cjs/decorators/index.js +2 -0
  18. package/dist/cjs/decorators/index.js.map +2 -2
  19. package/dist/cjs/decorators/lifecycles.js +88 -24
  20. package/dist/cjs/decorators/lifecycles.js.map +3 -3
  21. package/dist/cjs/decorators/publishSwcAppMessage.js.map +2 -2
  22. package/dist/cjs/decorators/query.js +1 -1
  23. package/dist/cjs/decorators/query.js.map +2 -2
  24. package/dist/cjs/decorators/queryAll.js.map +1 -1
  25. package/dist/cjs/decorators/setProperty.js.map +1 -1
  26. package/dist/cjs/decorators/state.js +84 -0
  27. package/dist/cjs/decorators/state.js.map +7 -0
  28. package/dist/cjs/decorators/subscribeSwcAppMessageWhileConnected.js.map +1 -1
  29. package/dist/cjs/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +2 -2
  30. package/dist/cjs/elements/SwcApp.js +231 -0
  31. package/dist/cjs/elements/SwcApp.js.map +7 -0
  32. package/dist/cjs/elements/SwcAppMixin.js +78 -80
  33. package/dist/cjs/elements/SwcAppMixin.js.map +2 -2
  34. package/dist/cjs/elements/index.js +2 -1
  35. package/dist/cjs/elements/index.js.map +2 -2
  36. package/dist/cjs/elements/tt/SwcAppMixin.js +1 -0
  37. package/dist/cjs/elements/tt/SwcAppMixin.js.map +7 -0
  38. package/dist/cjs/elements/tt/SwcAsync.js +1 -0
  39. package/dist/cjs/elements/tt/SwcAsync.js.map +7 -0
  40. package/dist/cjs/elements/tt/SwcAsyncTemplate.js +1 -0
  41. package/dist/cjs/elements/tt/SwcAsyncTemplate.js.map +7 -0
  42. package/dist/cjs/elements/tt/SwcChoose.js +1 -0
  43. package/dist/cjs/elements/tt/SwcChoose.js.map +7 -0
  44. package/dist/cjs/elements/tt/SwcChooseTemplate.js +1 -0
  45. package/dist/cjs/elements/tt/SwcChooseTemplate.js.map +7 -0
  46. package/dist/cjs/elements/tt/SwcIf.js +1 -0
  47. package/dist/cjs/elements/tt/SwcIf.js.map +7 -0
  48. package/dist/cjs/elements/tt/SwcIfTemplate.js +1 -0
  49. package/dist/cjs/elements/tt/SwcIfTemplate.js.map +7 -0
  50. package/dist/cjs/elements/tt/SwcLoop.js +1 -0
  51. package/dist/cjs/elements/tt/SwcLoop.js.map +7 -0
  52. package/dist/cjs/elements/tt/SwcLoopTemplate.js +1 -0
  53. package/dist/cjs/elements/tt/SwcLoopTemplate.js.map +7 -0
  54. package/dist/cjs/elements/tt/SwcSubTemplates.js +1 -0
  55. package/dist/cjs/elements/tt/SwcSubTemplates.js.map +7 -0
  56. package/dist/cjs/elements/tt/register.js +1 -0
  57. package/dist/cjs/elements/tt/register.js.map +7 -0
  58. package/dist/cjs/index.js +10 -8
  59. package/dist/cjs/index.js.map +2 -2
  60. package/dist/cjs/{types.js → types/index.js} +1 -1
  61. package/dist/cjs/types/index.js.map +7 -0
  62. package/dist/cjs/types/window.d.js +16 -0
  63. package/dist/cjs/types/window.d.js.map +7 -0
  64. package/dist/cjs/utils/Utils.js +168 -26
  65. package/dist/cjs/utils/Utils.js.map +3 -3
  66. package/dist/esm/{elements/SwcAppEngine.js → SwcAppEngine.js} +7 -4
  67. package/dist/esm/SwcAppEngine.js.map +7 -0
  68. package/dist/esm/decorators/addEventListener.js +20 -4
  69. package/dist/esm/decorators/addEventListener.js.map +2 -2
  70. package/dist/esm/decorators/applyAttribute.js.map +1 -1
  71. package/dist/esm/decorators/applyClass.js.map +1 -1
  72. package/dist/esm/decorators/applyNode.js +109 -26
  73. package/dist/esm/decorators/applyNode.js.map +2 -2
  74. package/dist/esm/decorators/applySlot.js +110 -0
  75. package/dist/esm/decorators/applySlot.js.map +7 -0
  76. package/dist/esm/decorators/applyStyle.js.map +2 -2
  77. package/dist/esm/decorators/attribute.js.map +1 -1
  78. package/dist/esm/decorators/elementDefine.js +96 -58
  79. package/dist/esm/decorators/elementDefine.js.map +2 -2
  80. package/dist/esm/decorators/emitCustomEvent.js.map +1 -1
  81. package/dist/esm/decorators/index.js +2 -0
  82. package/dist/esm/decorators/index.js.map +2 -2
  83. package/dist/esm/decorators/lifecycles.js +88 -24
  84. package/dist/esm/decorators/lifecycles.js.map +3 -3
  85. package/dist/esm/decorators/publishSwcAppMessage.js.map +2 -2
  86. package/dist/esm/decorators/query.js +1 -1
  87. package/dist/esm/decorators/query.js.map +2 -2
  88. package/dist/esm/decorators/queryAll.js.map +1 -1
  89. package/dist/esm/decorators/setProperty.js.map +1 -1
  90. package/dist/esm/decorators/state.js +65 -0
  91. package/dist/esm/decorators/state.js.map +7 -0
  92. package/dist/esm/decorators/subscribeSwcAppMessageWhileConnected.js.map +1 -1
  93. package/dist/esm/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +2 -2
  94. package/dist/esm/elements/SwcApp.js +212 -0
  95. package/dist/esm/elements/SwcApp.js.map +7 -0
  96. package/dist/esm/elements/SwcAppMixin.js +76 -78
  97. package/dist/esm/elements/SwcAppMixin.js.map +2 -2
  98. package/dist/esm/elements/index.js +2 -1
  99. package/dist/esm/elements/index.js.map +2 -2
  100. package/dist/esm/elements/tt/SwcAppMixin.js +1 -0
  101. package/dist/esm/elements/tt/SwcAppMixin.js.map +7 -0
  102. package/dist/esm/elements/tt/SwcAsync.js +1 -0
  103. package/dist/esm/elements/tt/SwcAsync.js.map +7 -0
  104. package/dist/esm/elements/tt/SwcAsyncTemplate.js +1 -0
  105. package/dist/esm/elements/tt/SwcAsyncTemplate.js.map +7 -0
  106. package/dist/esm/elements/tt/SwcChoose.js +1 -0
  107. package/dist/esm/elements/tt/SwcChoose.js.map +7 -0
  108. package/dist/esm/elements/tt/SwcChooseTemplate.js +1 -0
  109. package/dist/esm/elements/tt/SwcChooseTemplate.js.map +7 -0
  110. package/dist/esm/elements/tt/SwcIf.js +1 -0
  111. package/dist/esm/elements/tt/SwcIf.js.map +7 -0
  112. package/dist/esm/elements/tt/SwcIfTemplate.js +1 -0
  113. package/dist/esm/elements/tt/SwcIfTemplate.js.map +7 -0
  114. package/dist/esm/elements/tt/SwcLoop.js +1 -0
  115. package/dist/esm/elements/tt/SwcLoop.js.map +7 -0
  116. package/dist/esm/elements/tt/SwcLoopTemplate.js +1 -0
  117. package/dist/esm/elements/tt/SwcLoopTemplate.js.map +7 -0
  118. package/dist/esm/elements/tt/SwcSubTemplates.js +1 -0
  119. package/dist/esm/elements/tt/SwcSubTemplates.js.map +7 -0
  120. package/dist/esm/elements/tt/register.js +1 -0
  121. package/dist/esm/elements/tt/register.js.map +7 -0
  122. package/dist/esm/index.js +11 -9
  123. package/dist/esm/index.js.map +2 -2
  124. package/dist/esm/{types.js → types/index.js} +1 -1
  125. package/dist/esm/types/index.js.map +7 -0
  126. package/dist/esm/types/window.d.js +1 -0
  127. package/dist/esm/types/window.d.js.map +7 -0
  128. package/dist/esm/utils/Utils.js +168 -26
  129. package/dist/esm/utils/Utils.js.map +3 -3
  130. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +7477 -2828
  131. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
  132. package/dist/types/{elements/SwcAppEngine.d.ts → SwcAppEngine.d.ts} +9 -4
  133. package/dist/types/SwcAppEngine.d.ts.map +1 -0
  134. package/dist/types/decorators/addEventListener.d.ts +5 -2
  135. package/dist/types/decorators/addEventListener.d.ts.map +1 -1
  136. package/dist/types/decorators/applyAttribute.d.ts.map +1 -1
  137. package/dist/types/decorators/applyClass.d.ts.map +1 -1
  138. package/dist/types/decorators/applyNode.d.ts +24 -8
  139. package/dist/types/decorators/applyNode.d.ts.map +1 -1
  140. package/dist/types/decorators/applySlot.d.ts +27 -0
  141. package/dist/types/decorators/applySlot.d.ts.map +1 -0
  142. package/dist/types/decorators/applyStyle.d.ts.map +1 -1
  143. package/dist/types/decorators/attribute.d.ts.map +1 -1
  144. package/dist/types/decorators/elementDefine.d.ts.map +1 -1
  145. package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
  146. package/dist/types/decorators/index.d.ts +2 -0
  147. package/dist/types/decorators/index.d.ts.map +1 -1
  148. package/dist/types/decorators/lifecycles.d.ts +26 -15
  149. package/dist/types/decorators/lifecycles.d.ts.map +1 -1
  150. package/dist/types/decorators/publishSwcAppMessage.d.ts.map +1 -1
  151. package/dist/types/decorators/query.d.ts +1 -1
  152. package/dist/types/decorators/query.d.ts.map +1 -1
  153. package/dist/types/decorators/queryAll.d.ts.map +1 -1
  154. package/dist/types/decorators/setProperty.d.ts +1 -1
  155. package/dist/types/decorators/setProperty.d.ts.map +1 -1
  156. package/dist/types/decorators/state.d.ts +9 -0
  157. package/dist/types/decorators/state.d.ts.map +1 -0
  158. package/dist/types/decorators/subscribeSwcAppMessageWhileConnected.d.ts.map +1 -1
  159. package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts +5 -1
  160. package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts.map +1 -1
  161. package/dist/types/elements/SwcApp.d.ts +36 -0
  162. package/dist/types/elements/SwcApp.d.ts.map +1 -0
  163. package/dist/types/elements/SwcAppMixin.d.ts +26 -7
  164. package/dist/types/elements/SwcAppMixin.d.ts.map +1 -1
  165. package/dist/types/elements/index.d.ts +2 -1
  166. package/dist/types/elements/index.d.ts.map +1 -1
  167. package/dist/types/elements/tt/SwcAppMixin.d.ts +1 -0
  168. package/dist/types/elements/tt/SwcAppMixin.d.ts.map +1 -0
  169. package/dist/types/elements/tt/SwcAsync.d.ts +1 -0
  170. package/dist/types/elements/tt/SwcAsync.d.ts.map +1 -0
  171. package/dist/types/elements/tt/SwcAsyncTemplate.d.ts +1 -0
  172. package/dist/types/elements/tt/SwcAsyncTemplate.d.ts.map +1 -0
  173. package/dist/types/elements/tt/SwcChoose.d.ts +1 -0
  174. package/dist/types/elements/tt/SwcChoose.d.ts.map +1 -0
  175. package/dist/types/elements/tt/SwcChooseTemplate.d.ts +1 -0
  176. package/dist/types/elements/tt/SwcChooseTemplate.d.ts.map +1 -0
  177. package/dist/types/elements/tt/SwcIf.d.ts +1 -0
  178. package/dist/types/elements/{SwcIf.d.ts.map → tt/SwcIf.d.ts.map} +1 -1
  179. package/dist/types/elements/tt/SwcIfTemplate.d.ts +1 -0
  180. package/dist/types/elements/tt/SwcIfTemplate.d.ts.map +1 -0
  181. package/dist/types/elements/tt/SwcLoop.d.ts +1 -0
  182. package/dist/types/elements/tt/SwcLoop.d.ts.map +1 -0
  183. package/dist/types/elements/tt/SwcLoopTemplate.d.ts +1 -0
  184. package/dist/types/elements/tt/SwcLoopTemplate.d.ts.map +1 -0
  185. package/dist/types/elements/tt/SwcSubTemplates.d.ts +1 -0
  186. package/dist/types/elements/tt/SwcSubTemplates.d.ts.map +1 -0
  187. package/dist/types/elements/tt/register.d.ts +1 -0
  188. package/dist/types/elements/tt/register.d.ts.map +1 -0
  189. package/dist/types/index.d.ts +2 -2
  190. package/dist/types/index.d.ts.map +1 -1
  191. package/dist/types/{types.d.ts → types/index.d.ts} +12 -12
  192. package/dist/types/types/index.d.ts.map +1 -0
  193. package/dist/types/utils/Utils.d.ts +18 -5
  194. package/dist/types/utils/Utils.d.ts.map +1 -1
  195. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +7478 -2829
  196. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
  197. package/package.json +4 -4
  198. package/src/{elements/SwcAppEngine.ts → SwcAppEngine.ts} +17 -8
  199. package/src/decorators/addEventListener.ts +21 -5
  200. package/src/decorators/applyAttribute.ts +1 -1
  201. package/src/decorators/applyClass.ts +1 -1
  202. package/src/decorators/applyNode.ts +186 -66
  203. package/src/decorators/applySlot.ts +188 -0
  204. package/src/decorators/applyStyle.ts +4 -4
  205. package/src/decorators/attribute.ts +1 -1
  206. package/src/decorators/elementDefine.ts +142 -68
  207. package/src/decorators/emitCustomEvent.ts +1 -1
  208. package/src/decorators/index.ts +3 -0
  209. package/src/decorators/lifecycles.ts +119 -30
  210. package/src/decorators/publishSwcAppMessage.ts +2 -3
  211. package/src/decorators/query.ts +4 -4
  212. package/src/decorators/queryAll.ts +1 -1
  213. package/src/decorators/setProperty.ts +1 -1
  214. package/src/decorators/state.ts +84 -0
  215. package/src/decorators/subscribeSwcAppMessageWhileConnected.ts +1 -1
  216. package/src/decorators/subscribeSwcAppRouteChangeWhileConnected.ts +4 -3
  217. package/src/elements/SwcApp.ts +241 -0
  218. package/src/elements/SwcAppMixin.ts +98 -146
  219. package/src/elements/index.ts +4 -1
  220. package/src/elements/tt/SwcAppMixin.ts +13 -0
  221. package/src/elements/tt/SwcAsync.ts +139 -0
  222. package/src/elements/tt/SwcAsyncTemplate.ts +126 -0
  223. package/src/elements/tt/SwcChoose.ts +182 -0
  224. package/src/elements/tt/SwcChooseTemplate.ts +229 -0
  225. package/src/elements/tt/SwcIf.ts +145 -0
  226. package/src/elements/tt/SwcIfTemplate.ts +158 -0
  227. package/src/elements/tt/SwcLoop.ts +222 -0
  228. package/src/elements/tt/SwcLoopTemplate.ts +255 -0
  229. package/src/elements/tt/SwcSubTemplates.ts +6 -0
  230. package/src/elements/tt/register.ts +720 -0
  231. package/src/index.ts +11 -9
  232. package/src/{types.ts → types/index.ts} +15 -11
  233. package/src/types/window.d.ts +46 -0
  234. package/src/utils/Utils.ts +214 -24
  235. package/dist/cjs/elements/SwcAppEngine.js.map +0 -7
  236. package/dist/cjs/elements/SwcAsync.js +0 -129
  237. package/dist/cjs/elements/SwcAsync.js.map +0 -7
  238. package/dist/cjs/elements/SwcChoose.js +0 -155
  239. package/dist/cjs/elements/SwcChoose.js.map +0 -7
  240. package/dist/cjs/elements/SwcIf.js +0 -117
  241. package/dist/cjs/elements/SwcIf.js.map +0 -7
  242. package/dist/cjs/elements/SwcLoop.js +0 -176
  243. package/dist/cjs/elements/SwcLoop.js.map +0 -7
  244. package/dist/cjs/elements/SwcSubTemplates.js +0 -13
  245. package/dist/cjs/elements/SwcSubTemplates.js.map +0 -7
  246. package/dist/cjs/elements/register.js +0 -1026
  247. package/dist/cjs/elements/register.js.map +0 -7
  248. package/dist/cjs/types.js.map +0 -7
  249. package/dist/esm/elements/SwcAppEngine.js.map +0 -7
  250. package/dist/esm/elements/SwcAsync.js +0 -129
  251. package/dist/esm/elements/SwcAsync.js.map +0 -7
  252. package/dist/esm/elements/SwcChoose.js +0 -155
  253. package/dist/esm/elements/SwcChoose.js.map +0 -7
  254. package/dist/esm/elements/SwcIf.js +0 -117
  255. package/dist/esm/elements/SwcIf.js.map +0 -7
  256. package/dist/esm/elements/SwcLoop.js +0 -176
  257. package/dist/esm/elements/SwcLoop.js.map +0 -7
  258. package/dist/esm/elements/SwcSubTemplates.js +0 -13
  259. package/dist/esm/elements/SwcSubTemplates.js.map +0 -7
  260. package/dist/esm/elements/register.js +0 -1007
  261. package/dist/esm/elements/register.js.map +0 -7
  262. package/dist/esm/types.js.map +0 -7
  263. package/dist/types/elements/SwcAppEngine.d.ts.map +0 -1
  264. package/dist/types/elements/SwcAsync.d.ts +0 -2
  265. package/dist/types/elements/SwcAsync.d.ts.map +0 -1
  266. package/dist/types/elements/SwcChoose.d.ts +0 -2
  267. package/dist/types/elements/SwcChoose.d.ts.map +0 -1
  268. package/dist/types/elements/SwcIf.d.ts +0 -2
  269. package/dist/types/elements/SwcLoop.d.ts +0 -2
  270. package/dist/types/elements/SwcLoop.d.ts.map +0 -1
  271. package/dist/types/elements/SwcSubTemplates.d.ts +0 -13
  272. package/dist/types/elements/SwcSubTemplates.d.ts.map +0 -1
  273. package/dist/types/elements/register.d.ts +0 -4
  274. package/dist/types/elements/register.d.ts.map +0 -1
  275. package/dist/types/types.d.ts.map +0 -1
  276. package/src/elements/SwcAsync.ts +0 -126
  277. package/src/elements/SwcChoose.ts +0 -190
  278. package/src/elements/SwcIf.ts +0 -124
  279. package/src/elements/SwcLoop.ts +0 -205
  280. package/src/elements/SwcSubTemplates.ts +0 -6
  281. package/src/elements/register.ts +0 -1022
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/decorators/applyStyle.ts"],
4
- "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit } from './elementDefine';\nimport { SwcUtils } from '../utils/Utils';\nimport { SwcQueryOptions, HelperHostSet } from '../types';\n\nexport type StyleAction = 'set' | 'update' | 'remove';\n\nexport interface StyleApplyOptions extends SwcQueryOptions {\n filter?: (target: HTMLElement, value: any, meta: {currentThis: any, helper: HelperHostSet}) => boolean;\n}\n\nexport interface StyleApplyMetadata {\n propertyKey: string | symbol;\n selector: string;\n action: StyleAction;\n options: StyleApplyOptions;\n}\n\nexport const STYLE_METADATA_KEY = Symbol.for('simple-web-component:style');\n\nfunction createStyleDecorator(action: StyleAction) {\n return (selector: string, options: StyleApplyOptions = {}): MethodDecorator => {\n return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = target.constructor;\n let metaList = ReflectUtils.getOwnMetadata(STYLE_METADATA_KEY, constructor) as Map<string | symbol, StyleApplyMetadata>;\n if (!metaList) {\n metaList = new Map<string | symbol, StyleApplyMetadata>();\n ReflectUtils.defineMetadata(STYLE_METADATA_KEY, metaList, constructor);\n }\n metaList.set(propertyKey, { propertyKey, selector, action, options });\n\n const original = descriptor.value;\n descriptor.value = function (...args: any[]) {\n ensureInit(this);\n const res = (original as any).apply(this, args);\n\n const handleResult = (resolvedValue: any) => {\n if (resolvedValue !== undefined) {\n const win = (this as any).ownerDocument?.defaultView || window;\n const host = this as unknown as HTMLElement;\n const hostSet = { ...SwcUtils.getHelperAndHostSet(win, host), $this: this };\n const r = options.root || 'auto';\n const targetEls: HTMLElement[] = [];\n\n const applyRoot = (t: any) => {\n if (!t || !(t instanceof win.HTMLElement)) return;\n targetEls.push(t);\n };\n\n if (selector === '$this' || !selector) applyRoot(host);\n else if (selector === '$host') applyRoot(hostSet.$host);\n else if (selector === '$parentHost') applyRoot(hostSet.$parentHost);\n else if (selector === '$appHost') applyRoot(hostSet.$appHost);\n else if (selector === '$firstHost') applyRoot(hostSet.$firstHost);\n else if (selector === '$lastHost') applyRoot(hostSet.$lastHost);\n else if (selector === '$firstAppHost') applyRoot(hostSet.$firstAppHost);\n else if (selector === '$lastAppHost') applyRoot(hostSet.$lastAppHost);\n else if (selector === '$hosts') hostSet.$hosts.forEach(applyRoot);\n else if (selector === '$appHosts') hostSet.$appHosts.forEach(applyRoot);\n else {\n const targetRoot = r === 'auto' ? (host.shadowRoot || host) : (r === 'shadow' ? host.shadowRoot : host);\n if (targetRoot) {\n const found = targetRoot.querySelectorAll(selector);\n if (found) targetEls.push(...(Array.from(found) as HTMLElement[]));\n }\n }\n\n targetEls.forEach(targetEl => {\n if (options.filter && !options.filter(targetEl, resolvedValue, {currentThis: this, helper: hostSet})) {\n return;\n }\n const resolvedRes = typeof resolvedValue === 'function' ? (resolvedValue as any)(targetEl, hostSet) : resolvedValue;\n\n if (action === 'set' || action === 'update') {\n if (action === 'set') targetEl.style.cssText = '';\n \n if (typeof resolvedRes === 'object' && resolvedRes !== null && !Array.isArray(resolvedRes)) {\n Object.entries(resolvedRes as any).forEach(([prop, val]) => {\n const finalVal = typeof val === 'function' ? val(targetEl, hostSet) : val;\n if (finalVal === null || finalVal === undefined) {\n targetEl.style.removeProperty(prop);\n } else {\n targetEl.style[prop as any] = String(finalVal);\n }\n });\n } else if (typeof resolvedRes === 'string') {\n targetEl.style.cssText = resolvedRes;\n }\n } else if (action === 'remove') {\n if (typeof resolvedRes === 'object' && resolvedRes !== null && !Array.isArray(resolvedRes)) {\n Object.entries(resolvedRes as any).forEach(([prop, val]) => {\n const shouldRemove = typeof val === 'function' ? val(targetEl, hostSet) : !!val;\n if (shouldRemove) {\n targetEl.style.removeProperty(prop);\n }\n });\n } else {\n const props = Array.isArray(resolvedRes) ? resolvedRes : [resolvedRes];\n props.forEach(p => targetEl.style.removeProperty(String(p)));\n }\n }\n });\n }\n return resolvedValue;\n };\n\n if (res instanceof Promise) {\n return res.then(handleResult);\n } else {\n return handleResult(res);\n }\n };\n return descriptor;\n };\n };\n}\n\nexport function applyStyle(selector: string, action: StyleAction = 'update', options: StyleApplyOptions = {}): MethodDecorator {\n return createStyleDecorator(action)(selector, options);\n}\n\nexport const setStyle = (selector: string, options: StyleApplyOptions = {}) => createStyleDecorator('set')(selector, options);\nexport const updateStyle = (selector: string, options: StyleApplyOptions = {}) => createStyleDecorator('update')(selector, options);\nexport const removeStyle = (selector: string, options: StyleApplyOptions = {}) => createStyleDecorator('remove')(selector, options);\n\n// This versions\nexport function applyStyleThis(action: StyleAction = 'update', options: StyleApplyOptions = {}): MethodDecorator {\n return createStyleDecorator(action)('$this', options);\n}\nexport const setStyleThis = (options: StyleApplyOptions = {}) => createStyleDecorator('set')('$this', options);\nexport const updateStyleThis = (options: StyleApplyOptions = {}) => createStyleDecorator('update')('$this', options);\nexport const removeStyleThis = (options: StyleApplyOptions = {}) => createStyleDecorator('remove')('$this', options);\n\nexport const findAllStyleMetadata = (target: any): Map<string | symbol, StyleApplyMetadata> => {\n const result = new Map<string | symbol, StyleApplyMetadata>();\n const maps = ReflectUtils.findAllMetadata<Map<string | symbol, StyleApplyMetadata>>(STYLE_METADATA_KEY, target);\n maps.forEach(map => {\n if (map instanceof Map) {\n map.forEach((v, k) => result.set(k, v));\n }\n });\n return result;\n};\n"],
5
- "mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB;AAC3B,SAAS,gBAAgB;AAgBlB,MAAM,qBAAqB,OAAO,IAAI,4BAA4B;AAEzE,SAAS,qBAAqB,QAAqB;AACjD,SAAO,CAAC,UAAkB,UAA6B,CAAC,MAAuB;AAC7E,WAAO,CAAC,QAAgB,aAA8B,eAAmC;AACvF,YAAM,cAAc,OAAO;AAC3B,UAAI,WAAW,aAAa,eAAe,oBAAoB,WAAW;AAC1E,UAAI,CAAC,UAAU;AACb,mBAAW,oBAAI,IAAyC;AACxD,qBAAa,eAAe,oBAAoB,UAAU,WAAW;AAAA,MACvE;AACA,eAAS,IAAI,aAAa,EAAE,aAAa,UAAU,QAAQ,QAAQ,CAAC;AAEpE,YAAM,WAAW,WAAW;AAC5B,iBAAW,QAAQ,YAAa,MAAa;AAC3C,mBAAW,IAAI;AACf,cAAM,MAAO,SAAiB,MAAM,MAAM,IAAI;AAE9C,cAAM,eAAe,CAAC,kBAAuB;AAC3C,cAAI,kBAAkB,QAAW;AAC/B,kBAAM,MAAO,KAAa,eAAe,eAAe;AACxD,kBAAM,OAAO;AACb,kBAAM,UAAU,EAAE,GAAG,SAAS,oBAAoB,KAAK,IAAI,GAAG,OAAO,KAAK;AAC1E,kBAAM,IAAI,QAAQ,QAAQ;AAC1B,kBAAM,YAA2B,CAAC;AAElC,kBAAM,YAAY,CAAC,MAAW;AAC5B,kBAAI,CAAC,KAAK,EAAE,aAAa,IAAI,aAAc;AAC3C,wBAAU,KAAK,CAAC;AAAA,YAClB;AAEA,gBAAI,aAAa,WAAW,CAAC,SAAU,WAAU,IAAI;AAAA,qBAC5C,aAAa,QAAS,WAAU,QAAQ,KAAK;AAAA,qBAC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,SAAsB,UAAU,UAA6B,CAAC,GAAoB;AAC/G,SAAO,qBAAqB,MAAM,EAAE,SAAS,OAAO;AACtD;AACO,MAAM,eAAe,CAAC,UAA6B,CAAC,MAAM,qBAAqB,KAAK,EAAE,SAAS,OAAO;AACtG,MAAM,kBAAkB,CAAC,UAA6B,CAAC,MAAM,qBAAqB,QAAQ,EAAE,SAAS,OAAO;AAC5G,MAAM,kBAAkB,CAAC,UAA6B,CAAC,MAAM,qBAAqB,QAAQ,EAAE,SAAS,OAAO;AAE5G,MAAM,uBAAuB,CAAC,WAA0D;AAC7F,QAAM,SAAS,oBAAI,IAAyC;AAC5D,QAAM,OAAO,aAAa,gBAA0D,oBAAoB,MAAM;AAC9G,OAAK,QAAQ,SAAO;AAClB,QAAI,eAAe,KAAK;AACtB,UAAI,QAAQ,CAAC,GAAG,MAAM,OAAO,IAAI,GAAG,CAAC,CAAC;AAAA,IACxC;AAAA,EACF,CAAC;AACD,SAAO;AACT;",
4
+ "sourcesContent": ["import {ReflectUtils} from '@dooboostore/core';\nimport {ensureInit} from './elementDefine';\nimport {SwcUtils} from '../utils/Utils';\nimport { SpecialSelector, SwcQueryOptions, HelperHostSet } from '../types';\n\nexport type StyleAction = 'set' | 'update' | 'remove';\n\nexport interface StyleApplyOptions extends SwcQueryOptions {\n filter?: (target: HTMLElement, value: any, meta: {currentThis: any, helper: HelperHostSet}) => boolean;\n}\n\nexport interface StyleApplyMetadata {\n propertyKey: string | symbol;\n selector: string;\n action: StyleAction;\n options: StyleApplyOptions;\n}\n\nexport const STYLE_METADATA_KEY = Symbol.for('simple-web-component:style');\n\nfunction createStyleDecorator(action: StyleAction) {\n return (selector: string, options: StyleApplyOptions = {}): MethodDecorator => {\n return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = target.constructor;\n let metaList = ReflectUtils.getOwnMetadata(STYLE_METADATA_KEY, constructor) as Map<string | symbol, StyleApplyMetadata>;\n if (!metaList) {\n metaList = new Map<string | symbol, StyleApplyMetadata>();\n ReflectUtils.defineMetadata(STYLE_METADATA_KEY, metaList, constructor);\n }\n metaList.set(propertyKey, { propertyKey, selector, action, options });\n\n const original = descriptor.value;\n descriptor.value = function (...args: any[]) {\n ensureInit(this);\n const res = (original as any).apply(this, args);\n\n const handleResult = (resolvedValue: any) => {\n if (resolvedValue !== undefined) {\n const win = (this as any).ownerDocument?.defaultView || window;\n const host = this as unknown as HTMLElement;\n const hostSet = { ...SwcUtils.getHelperAndHostSet(win, host), $this: this };\n const r = options.root || 'auto';\n const targetEls: HTMLElement[] = [];\n\n const applyRoot = (t: any) => {\n if (!t || !(t instanceof win.HTMLElement)) return;\n targetEls.push(t);\n };\n\n if (selector === '$this' || !selector) applyRoot(host);\n else if (selector === '$host') applyRoot(hostSet.$host);\n else if (selector === '$parentHost') applyRoot(hostSet.$parentHost);\n else if (selector === '$appHost') applyRoot(hostSet.$appHost);\n else if (selector === '$firstHost') applyRoot(hostSet.$firstHost);\n else if (selector === '$lastHost') applyRoot(hostSet.$lastHost);\n else if (selector === '$firstAppHost') applyRoot(hostSet.$firstAppHost);\n else if (selector === '$lastAppHost') applyRoot(hostSet.$lastAppHost);\n else if (selector === '$hosts') hostSet.$hosts.forEach(applyRoot);\n else if (selector === '$appHosts') hostSet.$appHosts.forEach(applyRoot);\n else {\n const targetRoot = r === 'auto' ? (host.shadowRoot || host) : (r === 'shadow' ? host.shadowRoot : host);\n if (targetRoot) {\n const found = targetRoot.querySelectorAll(selector);\n if (found) targetEls.push(...(Array.from(found) as HTMLElement[]));\n }\n }\n\n targetEls.forEach(targetEl => {\n if (options.filter && !options.filter(targetEl, resolvedValue, {currentThis: this, helper: hostSet})) {\n return;\n }\n const resolvedRes = typeof resolvedValue === 'function' ? (resolvedValue as any)(targetEl, hostSet) : resolvedValue;\n\n if (action === 'set' || action === 'update') {\n if (action === 'set') targetEl.style.cssText = '';\n \n if (typeof resolvedRes === 'object' && resolvedRes !== null && !Array.isArray(resolvedRes)) {\n Object.entries(resolvedRes as any).forEach(([prop, val]) => {\n const finalVal = typeof val === 'function' ? val(targetEl, hostSet) : val;\n if (finalVal === null || finalVal === undefined) {\n targetEl.style.removeProperty(prop);\n } else {\n targetEl.style[prop as any] = String(finalVal);\n }\n });\n } else if (typeof resolvedRes === 'string') {\n targetEl.style.cssText = resolvedRes;\n }\n } else if (action === 'remove') {\n if (typeof resolvedRes === 'object' && resolvedRes !== null && !Array.isArray(resolvedRes)) {\n Object.entries(resolvedRes as any).forEach(([prop, val]) => {\n const shouldRemove = typeof val === 'function' ? val(targetEl, hostSet) : !!val;\n if (shouldRemove) {\n targetEl.style.removeProperty(prop);\n }\n });\n } else {\n const props = Array.isArray(resolvedRes) ? resolvedRes : [resolvedRes];\n props.forEach(p => targetEl.style.removeProperty(String(p)));\n }\n }\n });\n }\n return resolvedValue;\n };\n\n if (res instanceof Promise) {\n return res.then(handleResult);\n } else {\n return handleResult(res);\n }\n };\n return descriptor;\n };\n };\n}\n\nexport function applyStyle(selector: string, action: StyleAction = 'update', options: StyleApplyOptions = {}): MethodDecorator {\n return createStyleDecorator(action)(selector, options);\n}\n\nexport const setStyle = (selector: string, options: StyleApplyOptions = {}) => createStyleDecorator('set')(selector, options);\nexport const updateStyle = (selector: string, options: StyleApplyOptions = {}) => createStyleDecorator('update')(selector, options);\nexport const removeStyle = (selector: string, options: StyleApplyOptions = {}) => createStyleDecorator('remove')(selector, options);\n\n// This versions\nexport function applyStyleThis(action: StyleAction = 'update', options: StyleApplyOptions = {}): MethodDecorator {\n return createStyleDecorator(action)('$this', options);\n}\nexport const setStyleThis = (options: StyleApplyOptions = {}) => createStyleDecorator('set')('$this', options);\nexport const updateStyleThis = (options: StyleApplyOptions = {}) => createStyleDecorator('update')('$this', options);\nexport const removeStyleThis = (options: StyleApplyOptions = {}) => createStyleDecorator('remove')('$this', options);\n\nexport const findAllStyleMetadata = (target: any): Map<string | symbol, StyleApplyMetadata> => {\n const result = new Map<string | symbol, StyleApplyMetadata>();\n const maps = ReflectUtils.findAllMetadata<Map<string | symbol, StyleApplyMetadata>>(STYLE_METADATA_KEY, target);\n maps.forEach(map => {\n if (map instanceof Map) {\n map.forEach((v, k) => result.set(k, v));\n }\n });\n return result;\n};\n"],
5
+ "mappings": "AAAA,SAAQ,oBAAmB;AAC3B,SAAQ,kBAAiB;AACzB,SAAQ,gBAAe;AAgBhB,MAAM,qBAAqB,OAAO,IAAI,4BAA4B;AAEzE,SAAS,qBAAqB,QAAqB;AACjD,SAAO,CAAC,UAAkB,UAA6B,CAAC,MAAuB;AAC7E,WAAO,CAAC,QAAgB,aAA8B,eAAmC;AACvF,YAAM,cAAc,OAAO;AAC3B,UAAI,WAAW,aAAa,eAAe,oBAAoB,WAAW;AAC1E,UAAI,CAAC,UAAU;AACb,mBAAW,oBAAI,IAAyC;AACxD,qBAAa,eAAe,oBAAoB,UAAU,WAAW;AAAA,MACvE;AACA,eAAS,IAAI,aAAa,EAAE,aAAa,UAAU,QAAQ,QAAQ,CAAC;AAEpE,YAAM,WAAW,WAAW;AAC5B,iBAAW,QAAQ,YAAa,MAAa;AAC3C,mBAAW,IAAI;AACf,cAAM,MAAO,SAAiB,MAAM,MAAM,IAAI;AAE9C,cAAM,eAAe,CAAC,kBAAuB;AAC3C,cAAI,kBAAkB,QAAW;AAC/B,kBAAM,MAAO,KAAa,eAAe,eAAe;AACxD,kBAAM,OAAO;AACb,kBAAM,UAAU,EAAE,GAAG,SAAS,oBAAoB,KAAK,IAAI,GAAG,OAAO,KAAK;AAC1E,kBAAM,IAAI,QAAQ,QAAQ;AAC1B,kBAAM,YAA2B,CAAC;AAElC,kBAAM,YAAY,CAAC,MAAW;AAC5B,kBAAI,CAAC,KAAK,EAAE,aAAa,IAAI,aAAc;AAC3C,wBAAU,KAAK,CAAC;AAAA,YAClB;AAEA,gBAAI,aAAa,WAAW,CAAC,SAAU,WAAU,IAAI;AAAA,qBAC5C,aAAa,QAAS,WAAU,QAAQ,KAAK;AAAA,qBAC7C,aAAa,cAAe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UAA6B,CAAC,GAAoB;AAC/G,SAAO,qBAAqB,MAAM,EAAE,SAAS,OAAO;AACtD;AACO,MAAM,eAAe,CAAC,UAA6B,CAAC,MAAM,qBAAqB,KAAK,EAAE,SAAS,OAAO;AACtG,MAAM,kBAAkB,CAAC,UAA6B,CAAC,MAAM,qBAAqB,QAAQ,EAAE,SAAS,OAAO;AAC5G,MAAM,kBAAkB,CAAC,UAA6B,CAAC,MAAM,qBAAqB,QAAQ,EAAE,SAAS,OAAO;AAE5G,MAAM,uBAAuB,CAAC,WAA0D;AAC7F,QAAM,SAAS,oBAAI,IAAyC;AAC5D,QAAM,OAAO,aAAa,gBAA0D,oBAAoB,MAAM;AAC9G,OAAK,QAAQ,SAAO;AAClB,QAAI,eAAe,KAAK;AACtB,UAAI,QAAQ,CAAC,GAAG,MAAM,OAAO,IAAI,GAAG,CAAC,CAAC;AAAA,IACxC;AAAA,EACF,CAAC;AACD,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -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('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 === '$this' || !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 === '$host') applyRoot(hostSet.$host);\n else 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 * @attributeThis decorator to sync a field value with the $this element's attribute.\n */\nexport function attributeThis(target: Object, propertyKey: string | symbol): void;\nexport function attributeThis(options: AttributeFieldOptions): PropertyDecorator;\nexport function attributeThis(attrName: string): PropertyDecorator;\nexport function attributeThis(attrName: string, options: AttributeFieldOptions): PropertyDecorator;\nexport function attributeThis(targetOrAttrOrOptions?: any, propertyKeyOrOptions?: any): any {\n if (propertyKeyOrOptions !== undefined && (typeof propertyKeyOrOptions === 'string' || typeof propertyKeyOrOptions === 'symbol')) {\n return attribute('$this', { 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('$this', { ...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('$this', { ...options, name: String(propertyKey) })(target, propertyKey);\n };\n } else {\n return (target: Object, propertyKey: string | symbol) => {\n return attribute('$this', { 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"],
4
+ "sourcesContent": ["import { ReflectUtils, FunctionUtils, ActionExpression } from '@dooboostore/core';\nimport { ensureInit, getElementConfig } from './elementDefine';\nimport { SwcUtils } from '../utils/Utils';\nimport { SpecialSelector, SwcQueryOptions, HelperHostSet } 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 === '$this' || !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 === '$host') applyRoot(hostSet.$host);\n else 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 * @attributeThis decorator to sync a field value with the $this element's attribute.\n */\nexport function attributeThis(target: Object, propertyKey: string | symbol): void;\nexport function attributeThis(options: AttributeFieldOptions): PropertyDecorator;\nexport function attributeThis(attrName: string): PropertyDecorator;\nexport function attributeThis(attrName: string, options: AttributeFieldOptions): PropertyDecorator;\nexport function attributeThis(targetOrAttrOrOptions?: any, propertyKeyOrOptions?: any): any {\n if (propertyKeyOrOptions !== undefined && (typeof propertyKeyOrOptions === 'string' || typeof propertyKeyOrOptions === 'symbol')) {\n return attribute('$this', { 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('$this', { ...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('$this', { ...options, name: String(propertyKey) })(target, propertyKey);\n };\n } else {\n return (target: Object, propertyKey: string | symbol) => {\n return attribute('$this', { 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
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,Q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 -1,17 +1,20 @@
1
- import { ReflectUtils, FunctionUtils, ActionExpression } from "@dooboostore/core";
1
+ import { ActionExpression, FunctionUtils, ReflectUtils } from "@dooboostore/core";
2
2
  import { getAddEventListenerMetadata } from "./addEventListener.js";
3
- import { ON_INITIALIZE_METADATA_KEY, ON_BEFORE_CONNECTED_METADATA_KEY, ON_AFTER_CONNECTED_METADATA_KEY, ON_BEFORE_DISCONNECTED_METADATA_KEY, ON_AFTER_DISCONNECTED_METADATA_KEY, ON_BEFORE_ADOPTED_METADATA_KEY, ON_AFTER_ADOPTED_METADATA_KEY, findAllLifecycleMetadata, getOnConnectedInnerHtmlMetadata } from "./lifecycles.js";
3
+ import { findAllLifecycleMetadata, findAllOnConnectedAfterMetadata, findAllOnConnectedBeforeMetadata, findAllOnConnectedMetadata, ON_AFTER_ADOPTED_METADATA_KEY, ON_AFTER_DISCONNECTED_METADATA_KEY, ON_BEFORE_ADOPTED_METADATA_KEY, ON_BEFORE_DISCONNECTED_METADATA_KEY, ON_CONNECTED_COMPLETED_METADATA_KEY, ON_INITIALIZE_METADATA_KEY } from "./lifecycles.js";
4
4
  import { getEmitCustomEventMetadataList } from "./emitCustomEvent.js";
5
- import { findAllAttributeChangedMetadata, convertAttributeValue } from "./changedAttributeThis.js";
5
+ import { convertAttributeValue, findAllAttributeChangedMetadata } from "./changedAttributeThis.js";
6
6
  import { findAllAttributeApplyMetadata } from "./applyAttribute.js";
7
7
  import { findAllAttributeMetadata, getAttributeValue } from "./attribute.js";
8
8
  import { getQueryMetadata } from "./query.js";
9
9
  import { getQueryAllMetadata } from "./queryAll.js";
10
10
  import { SwcUtils } from "../utils/Utils.js";
11
- import { HTML_TAG_ENTRIES, DOM_EVENT_NAMES } from "../config/config.js";
11
+ import { DOM_EVENT_NAMES, HTML_TAG_ENTRIES } from "../config/config.js";
12
12
  import { SituationTypeContainer, SituationTypeContainers } from "@dooboostore/simple-boot/decorators/inject/Inject";
13
- import { InjectSituationType } from "../types.js";
14
- import { ConvertUtils } from "@dooboostore/core-web";
13
+ import { InjectSituationType } from "../types/index.js";
14
+ import { ConvertUtils, ElementApply, NodeSlot } from "@dooboostore/core-web";
15
+ import { isSSR } from "../elements/SwcAppMixin.js";
16
+ import { findAllApplySlotMetadata } from "./applySlot.js";
17
+ import { findAllStateMetadata } from "./state.js";
15
18
  const ELEMENT_CONFIG_KEY = Symbol.for("simple-web-component:element-config");
16
19
  const getElementConfig = (target) => {
17
20
  const constructor = target instanceof Function ? target : target.constructor;
@@ -19,14 +22,17 @@ const getElementConfig = (target) => {
19
22
  };
20
23
  const ensureInit = (inst) => {
21
24
  if (!inst.__swc_initialized) {
22
- inst._swcId = Math.random().toString(36).substring(2, 11);
25
+ inst._swcId = inst?.getAttribute?.("swc-use-ssr") ?? "s" + Math.random().toString(36).substring(2, 11).toLowerCase();
23
26
  inst._emitHandlers = /* @__PURE__ */ new Map();
24
27
  inst._boundListeners = [];
25
28
  inst.__swc_initialized = true;
26
29
  const target = inst instanceof Function ? inst : inst.constructor;
27
30
  const attributeList = findAllAttributeMetadata(target);
28
31
  attributeList.forEach((meta) => {
32
+ const initUserData = inst[meta.propertyKey];
29
33
  delete inst[meta.propertyKey];
34
+ if (initUserData !== void 0)
35
+ inst[meta.propertyKey] = initUserData;
30
36
  });
31
37
  const queryList = getQueryMetadata(target);
32
38
  if (queryList) {
@@ -40,6 +46,20 @@ const ensureInit = (inst) => {
40
46
  delete inst[meta.propertyKey];
41
47
  });
42
48
  }
49
+ const slotAllList = findAllApplySlotMetadata(target);
50
+ if (slotAllList) {
51
+ slotAllList.filter((it) => it.type === "property").forEach((meta) => {
52
+ delete inst[meta.propertyKey];
53
+ });
54
+ }
55
+ const stateAllList = findAllStateMetadata(target);
56
+ if (stateAllList) {
57
+ stateAllList.forEach((meta) => {
58
+ const initUserData = inst[meta.propertyKey];
59
+ delete inst[meta.propertyKey];
60
+ inst[meta.propertyKey] = initUserData;
61
+ });
62
+ }
43
63
  const hostSet = SwcUtils.getHostSet(inst);
44
64
  const appHosts = SwcUtils.findAllAppHostsIncludingSelfDirect(inst);
45
65
  inst._executeSwcScript?.("swc-on-constructor", hostSet);
@@ -82,9 +102,27 @@ const getHandlers = (inst) => {
82
102
  if (!inst.__swc_attributeEventHandlers) inst.__swc_attributeEventHandlers = /* @__PURE__ */ new Map();
83
103
  return inst.__swc_attributeEventHandlers;
84
104
  };
85
- const setupPrototype = (proto) => {
105
+ const setupPrototype = (proto, win) => {
86
106
  if (proto.__swc_proto_setup) return;
87
107
  proto.__swc_proto_setup = true;
108
+ proto.createSlotString = function(id) {
109
+ return NodeSlot.slot(`${this._swcId}-${id}`);
110
+ };
111
+ proto.createEaHtml = function(id, script) {
112
+ return ElementApply.html(id, script);
113
+ };
114
+ proto.createEaText = function(id, script) {
115
+ return ElementApply.text(id, script);
116
+ };
117
+ proto.createEaAttribute = function(id, name, script) {
118
+ return ElementApply.attribute(id, name, script);
119
+ };
120
+ proto.createEaEvent = function(id, name, script) {
121
+ return ElementApply.event(id, name, script);
122
+ };
123
+ proto.createEaProperty = function(id, name, script) {
124
+ return ElementApply.property(id, name, script);
125
+ };
88
126
  proto._executeSwcScript = function(attrName, hostSet, extraArgs = {}) {
89
127
  ensureInit(this);
90
128
  const script = this.getAttribute(attrName);
@@ -113,7 +151,7 @@ const setupPrototype = (proto) => {
113
151
  proto._invokeLifecycleMethod = function(methodName, hostSet, extraArgs = []) {
114
152
  ensureInit(this);
115
153
  if (typeof this[methodName] !== "function") return;
116
- const useHostSet = hostSet ?? SwcUtils.getHostSet(this);
154
+ const useHostSet = hostSet ?? SwcUtils.getHelperAndHostSet(win, this);
117
155
  const app = useHostSet?.$appHost?.simpleApplication;
118
156
  if (app) {
119
157
  const otherStorage = /* @__PURE__ */ new Map();
@@ -218,78 +256,75 @@ const elementDefine = (name, config = {}) => (constructor) => {
218
256
  const hostAttributes = attributeList.filter((it) => it.selector === "$this").map((it) => it.options.name || String(it.propertyKey));
219
257
  const originalStaticObservedAttributes = constructor.observedAttributes ?? [];
220
258
  const mergedObservedAttributes = [.../* @__PURE__ */ new Set([...metadata.observedAttributes ?? [], ...originalStaticObservedAttributes, ...attrChangeMap.keys(), ...attributeApplyNames, ...hostAttributes, ...emitHostCustomEventList.map((it) => it.options.attributeName).filter(Boolean), ...swcLifecycleAttributes, ...swcOnEvents])];
221
- const connectedInnerHtmlList = getOnConnectedInnerHtmlMetadata(constructor) || [];
222
259
  const proto = constructor.prototype;
223
- setupPrototype(proto);
260
+ setupPrototype(proto, win);
224
261
  let helperHostSet = null;
225
262
  const originalConnected = proto.connectedCallback;
226
263
  proto.connectedCallback = async function() {
227
264
  ensureInit(this);
228
265
  helperHostSet = SwcUtils.getHelperAndHostSet(win, this);
229
266
  const appHost = helperHostSet.$appHost;
267
+ const useSsr = isSSR(this);
230
268
  try {
231
269
  if (appHost && typeof appHost._connected === "function") {
232
270
  await appHost._connected(this);
233
271
  } else if (appHost && typeof appHost) {
234
- appHost._connected_safari ?? (appHost._connected_safari = []);
235
- appHost._connected_safari.push(this);
272
+ appHost._connected_safari_and_standby ?? (appHost._connected_safari_and_standby = []);
273
+ appHost._connected_safari_and_standby.push(this);
236
274
  }
237
275
  const conf = getElementConfig(this);
238
276
  const currentWin = this._resolveWindow(conf);
239
- const shadowMode = conf?.useShadow || connectedInnerHtmlList.find((it) => it.options.useShadow)?.options.useShadow;
277
+ const bMethods = findAllOnConnectedBeforeMetadata(this).filter((it) => useSsr ? !it.options.ssrFirst : true);
278
+ if (bMethods) {
279
+ for (const m of bMethods) await this._invokeLifecycleMethod(m.propertyKey, helperHostSet);
280
+ }
281
+ this._executeSwcScript("swc-on-before-connected", helperHostSet);
282
+ const targetConnectedList = findAllOnConnectedMetadata(constructor).filter((it) => useSsr ? !it.options.ssrFirst : true);
283
+ const shadowMode = conf?.useShadow || targetConnectedList.find((it) => it.options.useShadow)?.options.useShadow;
240
284
  if (shadowMode && !this.shadowRoot) {
241
285
  const mode = shadowMode === true ? "open" : shadowMode;
286
+ console.log("tagName=", this.tagName, "mode", mode, this.shadowRoot);
242
287
  this.attachShadow({ mode });
243
288
  }
244
- const bMethods = findAllLifecycleMetadata(this, ON_BEFORE_CONNECTED_METADATA_KEY);
245
- if (bMethods) {
246
- for (const m of bMethods) await this._invokeLifecycleMethod(m, helperHostSet);
247
- }
248
- this._executeSwcScript("swc-on-before-connected", helperHostSet);
249
- if (connectedInnerHtmlList.length > 0) {
250
- let sContent = "", lContent = "";
251
- for (const meta of connectedInnerHtmlList) {
289
+ const stateContext = { ...helperHostSet };
290
+ findAllStateMetadata(this).forEach((it) => {
291
+ stateContext[it.name] = this[it.propertyKey];
292
+ });
293
+ const shadowChildren = [];
294
+ const lightChildren = [];
295
+ console.log("targetConnectList", this.tagName, targetConnectedList.length);
296
+ if (targetConnectedList.length > 0) {
297
+ for (const meta of targetConnectedList) {
252
298
  let res = await this._invokeLifecycleMethod(meta.propertyKey, helperHostSet);
253
- const actionExpression = new ActionExpression(res, {
254
- expression: {
255
- replace: {
256
- start: meta.options.replaceWrap?.start || "{%{",
257
- end: meta.options.replaceWrap?.end || "}%}"
258
- },
259
- callReturn: {
260
- start: meta.options.replaceWrap?.start || "{%{=",
261
- end: meta.options.replaceWrap?.end || "}%}"
262
- },
263
- call: {
264
- start: meta.options.replaceWrap?.start || "{%{@",
265
- end: meta.options.replaceWrap?.end || "}%}"
266
- }
267
- }
268
- });
269
- actionExpression.getExpressions().filter((it) => it.type === "replace").forEach((it) => {
270
- try {
271
- const sr = FunctionUtils.executeReturn({ script: it.script, context: this, args: helperHostSet });
272
- actionExpression.replace(it, sr);
273
- } catch (e) {
274
- console.error(`[SWC] Failed to execute connectedInnerHTML:`, e);
299
+ if (typeof res === "string") {
300
+ const htmlTemplateElement = doc.createElement("template");
301
+ htmlTemplateElement.innerHTML = res;
302
+ res = htmlTemplateElement.content;
303
+ }
304
+ if (res) {
305
+ const nodes = Array.isArray(res) ? res : [res];
306
+ if (meta.options.useShadow || conf?.useShadow) {
307
+ shadowChildren.push(...nodes);
308
+ } else {
309
+ lightChildren.push(...nodes);
275
310
  }
276
- });
277
- res = actionExpression.getUnprocessedTemplate();
278
- if (res !== void 0) {
279
- if (meta.options.useShadow || conf?.useShadow) sContent += res;
280
- else lContent += res;
281
311
  }
282
312
  }
283
313
  try {
284
314
  if (this.shadowRoot) {
285
- this.shadowRoot.innerHTML = sContent;
315
+ const applyShadowChildren = SwcUtils.projectProcessHtml(this._swcId, shadowChildren, doc);
316
+ this.shadowRoot.replaceChildren(...applyShadowChildren);
286
317
  }
287
- if (lContent) {
288
- this.innerHTML = lContent;
318
+ if (lightChildren.length) {
319
+ const applyLightChildren = SwcUtils.projectProcessHtml(this._swcId, lightChildren, doc);
320
+ this.replaceChildren(...applyLightChildren);
289
321
  }
290
322
  } catch (e) {
291
323
  console.error("[ElementDefine] innerHTML setting error:", e);
292
324
  }
325
+ new ElementApply(this, { id: this._swcId }).apply({ context: stateContext, bind: this });
326
+ } else {
327
+ new ElementApply(this, { id: this._swcId }).apply({ exclude: { html: true, text: true, attribute: true }, context: stateContext, bind: this });
293
328
  }
294
329
  const root = this.getRootNode();
295
330
  if (!globalDelegatedRoots.has(root)) {
@@ -414,15 +449,15 @@ const elementDefine = (name, config = {}) => (constructor) => {
414
449
  await this[meta.propertyKey](event, { currentHostSet, $$matchedElement: event.currentTarget }, args);
415
450
  };
416
451
  t.addEventListener(type, handler, opts);
417
- if (options.removeOnDisconnected === true || t === currentWin || t === currentWin.document) {
418
- this._boundListeners.push({ target: t, type, handler, options: opts });
419
- }
452
+ this._boundListeners.push({ target: t, type, handler, options: opts });
420
453
  });
421
454
  });
422
455
  if (originalConnected) await originalConnected.apply(this);
423
- const aMethods = findAllLifecycleMetadata(this, ON_AFTER_CONNECTED_METADATA_KEY);
456
+ const aMethods = findAllOnConnectedAfterMetadata(this).filter((it) => {
457
+ return useSsr ? !it.options.ssrFirst : true;
458
+ });
424
459
  if (aMethods) {
425
- for (const m of aMethods) await this._invokeLifecycleMethod(m, helperHostSet);
460
+ for (const m of aMethods) await this._invokeLifecycleMethod(m.propertyKey, helperHostSet);
426
461
  }
427
462
  this._executeSwcScript("swc-on-connected", helperHostSet);
428
463
  this._executeSwcScript("swc-on-after-connected", helperHostSet);
@@ -438,6 +473,9 @@ const elementDefine = (name, config = {}) => (constructor) => {
438
473
  }
439
474
  }
440
475
  } finally {
476
+ for (let mPropertyKey of findAllLifecycleMetadata(this, ON_CONNECTED_COMPLETED_METADATA_KEY)) {
477
+ await this._invokeLifecycleMethod(mPropertyKey, helperHostSet);
478
+ }
441
479
  if (appHost && typeof appHost._connectedDone === "function") {
442
480
  await appHost._connectedDone(this);
443
481
  }
@@ -445,7 +483,6 @@ const elementDefine = (name, config = {}) => (constructor) => {
445
483
  };
446
484
  const originalDisconnected = proto.disconnectedCallback;
447
485
  proto.disconnectedCallback = function() {
448
- console.log("disconnnnnnnnnnnnnnnnnnn", helperHostSet, this);
449
486
  const appHost = helperHostSet.$appHost;
450
487
  if (appHost && typeof appHost._disconnected === "function") {
451
488
  appHost._disconnected(this);
@@ -459,6 +496,7 @@ const elementDefine = (name, config = {}) => (constructor) => {
459
496
  this._boundListeners.forEach((l) => l.target.removeEventListener(l.type, l.handler, l.options));
460
497
  this._boundListeners = [];
461
498
  }
499
+ new ElementApply(this, { id: this._swcId }).removeAllEventListener();
462
500
  if (originalDisconnected) originalDisconnected.apply(this);
463
501
  const aMethods = findAllLifecycleMetadata(this, ON_AFTER_DISCONNECTED_METADATA_KEY);
464
502
  if (aMethods) {