@dooboostore/simple-web-component 1.0.35 → 1.0.37

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 (284) hide show
  1. package/README.md +58 -21
  2. package/dist/cjs/{elements/SwcAppEngine.js → SwcAppEngine.js} +6 -6
  3. package/dist/cjs/SwcAppEngine.js.map +7 -0
  4. package/dist/cjs/decorators/addEventListener.js +12 -4
  5. package/dist/cjs/decorators/addEventListener.js.map +2 -2
  6. package/dist/cjs/decorators/applyAttribute.js +19 -18
  7. package/dist/cjs/decorators/applyAttribute.js.map +2 -2
  8. package/dist/cjs/decorators/applyClass.js +23 -22
  9. package/dist/cjs/decorators/applyClass.js.map +2 -2
  10. package/dist/cjs/decorators/applyNode.js +28 -26
  11. package/dist/cjs/decorators/applyNode.js.map +2 -2
  12. package/dist/cjs/decorators/applySlot.js +122 -0
  13. package/dist/cjs/decorators/applySlot.js.map +7 -0
  14. package/dist/cjs/decorators/applyStyle.js +20 -19
  15. package/dist/cjs/decorators/applyStyle.js.map +2 -2
  16. package/dist/cjs/decorators/attribute.js +16 -15
  17. package/dist/cjs/decorators/attribute.js.map +2 -2
  18. package/dist/cjs/decorators/{changedAttributeHost.js → changedAttributeThis.js} +6 -6
  19. package/dist/cjs/decorators/changedAttributeThis.js.map +7 -0
  20. package/dist/cjs/decorators/elementDefine.js +59 -50
  21. package/dist/cjs/decorators/elementDefine.js.map +2 -2
  22. package/dist/cjs/decorators/emitCustomEvent.js +18 -16
  23. package/dist/cjs/decorators/emitCustomEvent.js.map +2 -2
  24. package/dist/cjs/decorators/index.js +2 -1
  25. package/dist/cjs/decorators/index.js.map +2 -2
  26. package/dist/cjs/decorators/lifecycles.js +56 -8
  27. package/dist/cjs/decorators/lifecycles.js.map +2 -2
  28. package/dist/cjs/decorators/query.js +38 -60
  29. package/dist/cjs/decorators/query.js.map +2 -2
  30. package/dist/cjs/decorators/queryAll.js +31 -63
  31. package/dist/cjs/decorators/queryAll.js.map +2 -2
  32. package/dist/cjs/decorators/setProperty.js +13 -12
  33. package/dist/cjs/decorators/setProperty.js.map +2 -2
  34. package/dist/cjs/elements/{SwcAppMixin.js → SwcApp.js} +107 -57
  35. package/dist/cjs/elements/SwcApp.js.map +7 -0
  36. package/dist/cjs/elements/index.js +21 -2
  37. package/dist/cjs/elements/index.js.map +3 -3
  38. package/dist/cjs/elements/tt/SwcAppMixin.js +1 -0
  39. package/dist/cjs/elements/tt/SwcAppMixin.js.map +7 -0
  40. package/dist/cjs/elements/tt/SwcAsync.js +1 -0
  41. package/dist/cjs/elements/tt/SwcAsync.js.map +7 -0
  42. package/dist/cjs/elements/tt/SwcAsyncTemplate.js +1 -0
  43. package/dist/cjs/elements/tt/SwcAsyncTemplate.js.map +7 -0
  44. package/dist/cjs/elements/tt/SwcChoose.js +1 -0
  45. package/dist/cjs/elements/tt/SwcChoose.js.map +7 -0
  46. package/dist/cjs/elements/tt/SwcChooseTemplate.js +1 -0
  47. package/dist/cjs/elements/tt/SwcChooseTemplate.js.map +7 -0
  48. package/dist/cjs/elements/tt/SwcIf.js +1 -0
  49. package/dist/cjs/elements/tt/SwcIf.js.map +7 -0
  50. package/dist/cjs/elements/tt/SwcIfTemplate.js +1 -0
  51. package/dist/cjs/elements/tt/SwcIfTemplate.js.map +7 -0
  52. package/dist/cjs/elements/tt/SwcLoop.js +1 -0
  53. package/dist/cjs/elements/tt/SwcLoop.js.map +7 -0
  54. package/dist/cjs/elements/tt/SwcLoopTemplate.js +1 -0
  55. package/dist/cjs/elements/tt/SwcLoopTemplate.js.map +7 -0
  56. package/dist/cjs/elements/tt/SwcSubTemplates.js +1 -0
  57. package/dist/cjs/elements/tt/SwcSubTemplates.js.map +7 -0
  58. package/dist/cjs/elements/tt/register.js +1 -0
  59. package/dist/cjs/elements/tt/register.js.map +7 -0
  60. package/dist/cjs/index.js +12 -8
  61. package/dist/cjs/index.js.map +2 -2
  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/types.js.map +1 -1
  65. package/dist/cjs/utils/Utils.js +22 -19
  66. package/dist/cjs/utils/Utils.js.map +2 -2
  67. package/dist/esm/{elements/SwcAppEngine.js → SwcAppEngine.js} +4 -4
  68. package/dist/esm/SwcAppEngine.js.map +7 -0
  69. package/dist/esm/decorators/addEventListener.js +12 -4
  70. package/dist/esm/decorators/addEventListener.js.map +2 -2
  71. package/dist/esm/decorators/applyAttribute.js +19 -18
  72. package/dist/esm/decorators/applyAttribute.js.map +2 -2
  73. package/dist/esm/decorators/applyClass.js +23 -22
  74. package/dist/esm/decorators/applyClass.js.map +2 -2
  75. package/dist/esm/decorators/applyNode.js +28 -26
  76. package/dist/esm/decorators/applyNode.js.map +2 -2
  77. package/dist/esm/decorators/applySlot.js +103 -0
  78. package/dist/esm/decorators/applySlot.js.map +7 -0
  79. package/dist/esm/decorators/applyStyle.js +20 -19
  80. package/dist/esm/decorators/applyStyle.js.map +2 -2
  81. package/dist/esm/decorators/attribute.js +16 -15
  82. package/dist/esm/decorators/attribute.js.map +2 -2
  83. package/dist/esm/decorators/{changedAttributeHost.js → changedAttributeThis.js} +3 -3
  84. package/dist/esm/decorators/changedAttributeThis.js.map +7 -0
  85. package/dist/esm/decorators/elementDefine.js +60 -51
  86. package/dist/esm/decorators/elementDefine.js.map +2 -2
  87. package/dist/esm/decorators/emitCustomEvent.js +18 -16
  88. package/dist/esm/decorators/emitCustomEvent.js.map +2 -2
  89. package/dist/esm/decorators/index.js +2 -1
  90. package/dist/esm/decorators/index.js.map +2 -2
  91. package/dist/esm/decorators/lifecycles.js +56 -8
  92. package/dist/esm/decorators/lifecycles.js.map +2 -2
  93. package/dist/esm/decorators/query.js +38 -60
  94. package/dist/esm/decorators/query.js.map +2 -2
  95. package/dist/esm/decorators/queryAll.js +31 -63
  96. package/dist/esm/decorators/queryAll.js.map +2 -2
  97. package/dist/esm/decorators/setProperty.js +13 -12
  98. package/dist/esm/decorators/setProperty.js.map +2 -2
  99. package/dist/esm/elements/{SwcAppMixin.js → SwcApp.js} +102 -53
  100. package/dist/esm/elements/SwcApp.js.map +7 -0
  101. package/dist/esm/elements/index.js +7 -1
  102. package/dist/esm/elements/index.js.map +2 -2
  103. package/dist/esm/elements/tt/SwcAppMixin.js +1 -0
  104. package/dist/esm/elements/tt/SwcAppMixin.js.map +7 -0
  105. package/dist/esm/elements/tt/SwcAsync.js +1 -0
  106. package/dist/esm/elements/tt/SwcAsync.js.map +7 -0
  107. package/dist/esm/elements/tt/SwcAsyncTemplate.js +1 -0
  108. package/dist/esm/elements/tt/SwcAsyncTemplate.js.map +7 -0
  109. package/dist/esm/elements/tt/SwcChoose.js +1 -0
  110. package/dist/esm/elements/tt/SwcChoose.js.map +7 -0
  111. package/dist/esm/elements/tt/SwcChooseTemplate.js +1 -0
  112. package/dist/esm/elements/tt/SwcChooseTemplate.js.map +7 -0
  113. package/dist/esm/elements/tt/SwcIf.js +1 -0
  114. package/dist/esm/elements/tt/SwcIf.js.map +7 -0
  115. package/dist/esm/elements/tt/SwcIfTemplate.js +1 -0
  116. package/dist/esm/elements/tt/SwcIfTemplate.js.map +7 -0
  117. package/dist/esm/elements/tt/SwcLoop.js +1 -0
  118. package/dist/esm/elements/tt/SwcLoop.js.map +7 -0
  119. package/dist/esm/elements/tt/SwcLoopTemplate.js +1 -0
  120. package/dist/esm/elements/tt/SwcLoopTemplate.js.map +7 -0
  121. package/dist/esm/elements/tt/SwcSubTemplates.js +1 -0
  122. package/dist/esm/elements/tt/SwcSubTemplates.js.map +7 -0
  123. package/dist/esm/elements/tt/register.js +1 -0
  124. package/dist/esm/elements/tt/register.js.map +7 -0
  125. package/dist/esm/index.js +13 -9
  126. package/dist/esm/index.js.map +2 -2
  127. package/dist/esm/types/window.d.js +1 -0
  128. package/dist/esm/types/window.d.js.map +7 -0
  129. package/dist/esm/types.js.map +1 -1
  130. package/dist/esm/utils/Utils.js +22 -19
  131. package/dist/esm/utils/Utils.js.map +2 -2
  132. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +4189 -456
  133. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
  134. package/dist/types/{elements/SwcAppEngine.d.ts → SwcAppEngine.d.ts} +9 -4
  135. package/dist/types/SwcAppEngine.d.ts.map +1 -0
  136. package/dist/types/decorators/addEventListener.d.ts +5 -7
  137. package/dist/types/decorators/addEventListener.d.ts.map +1 -1
  138. package/dist/types/decorators/applyAttribute.d.ts +4 -4
  139. package/dist/types/decorators/applyAttribute.d.ts.map +1 -1
  140. package/dist/types/decorators/applyClass.d.ts +6 -6
  141. package/dist/types/decorators/applyClass.d.ts.map +1 -1
  142. package/dist/types/decorators/applyNode.d.ts +9 -9
  143. package/dist/types/decorators/applyNode.d.ts.map +1 -1
  144. package/dist/types/decorators/applySlot.d.ts +27 -0
  145. package/dist/types/decorators/applySlot.d.ts.map +1 -0
  146. package/dist/types/decorators/applyStyle.d.ts +4 -4
  147. package/dist/types/decorators/applyStyle.d.ts.map +1 -1
  148. package/dist/types/decorators/attribute.d.ts +5 -5
  149. package/dist/types/decorators/attribute.d.ts.map +1 -1
  150. package/dist/types/decorators/changedAttributeThis.d.ts +18 -0
  151. package/dist/types/decorators/changedAttributeThis.d.ts.map +1 -0
  152. package/dist/types/decorators/elementDefine.d.ts.map +1 -1
  153. package/dist/types/decorators/emitCustomEvent.d.ts +4 -9
  154. package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
  155. package/dist/types/decorators/index.d.ts +2 -1
  156. package/dist/types/decorators/index.d.ts.map +1 -1
  157. package/dist/types/decorators/lifecycles.d.ts +21 -6
  158. package/dist/types/decorators/lifecycles.d.ts.map +1 -1
  159. package/dist/types/decorators/query.d.ts +17 -63
  160. package/dist/types/decorators/query.d.ts.map +1 -1
  161. package/dist/types/decorators/queryAll.d.ts +6 -63
  162. package/dist/types/decorators/queryAll.d.ts.map +1 -1
  163. package/dist/types/decorators/setProperty.d.ts +1 -1
  164. package/dist/types/decorators/setProperty.d.ts.map +1 -1
  165. package/dist/types/elements/SwcApp.d.ts +7 -0
  166. package/dist/types/elements/SwcApp.d.ts.map +1 -0
  167. package/dist/types/elements/index.d.ts +2 -1
  168. package/dist/types/elements/index.d.ts.map +1 -1
  169. package/dist/types/elements/tt/SwcAppMixin.d.ts +1 -0
  170. package/dist/types/elements/tt/SwcAppMixin.d.ts.map +1 -0
  171. package/dist/types/elements/tt/SwcAsync.d.ts +1 -0
  172. package/dist/types/elements/tt/SwcAsync.d.ts.map +1 -0
  173. package/dist/types/elements/tt/SwcAsyncTemplate.d.ts +1 -0
  174. package/dist/types/elements/tt/SwcAsyncTemplate.d.ts.map +1 -0
  175. package/dist/types/elements/tt/SwcChoose.d.ts +1 -0
  176. package/dist/types/elements/tt/SwcChoose.d.ts.map +1 -0
  177. package/dist/types/elements/tt/SwcChooseTemplate.d.ts +1 -0
  178. package/dist/types/elements/tt/SwcChooseTemplate.d.ts.map +1 -0
  179. package/dist/types/elements/tt/SwcIf.d.ts +1 -0
  180. package/dist/types/elements/{SwcIf.d.ts.map → tt/SwcIf.d.ts.map} +1 -1
  181. package/dist/types/elements/tt/SwcIfTemplate.d.ts +1 -0
  182. package/dist/types/elements/tt/SwcIfTemplate.d.ts.map +1 -0
  183. package/dist/types/elements/tt/SwcLoop.d.ts +1 -0
  184. package/dist/types/elements/tt/SwcLoop.d.ts.map +1 -0
  185. package/dist/types/elements/tt/SwcLoopTemplate.d.ts +1 -0
  186. package/dist/types/elements/tt/SwcLoopTemplate.d.ts.map +1 -0
  187. package/dist/types/elements/tt/SwcSubTemplates.d.ts +1 -0
  188. package/dist/types/elements/tt/SwcSubTemplates.d.ts.map +1 -0
  189. package/dist/types/elements/tt/register.d.ts +1 -0
  190. package/dist/types/elements/tt/register.d.ts.map +1 -0
  191. package/dist/types/index.d.ts +2 -2
  192. package/dist/types/index.d.ts.map +1 -1
  193. package/dist/types/types.d.ts +5 -5
  194. package/dist/types/types.d.ts.map +1 -1
  195. package/dist/types/utils/Utils.d.ts +13 -12
  196. package/dist/types/utils/Utils.d.ts.map +1 -1
  197. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +4189 -456
  198. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
  199. package/package.json +4 -4
  200. package/src/{elements/SwcAppEngine.ts → SwcAppEngine.ts} +12 -7
  201. package/src/decorators/addEventListener.ts +11 -9
  202. package/src/decorators/applyAttribute.ts +16 -15
  203. package/src/decorators/applyClass.ts +18 -17
  204. package/src/decorators/applyNode.ts +30 -27
  205. package/src/decorators/applySlot.ts +228 -0
  206. package/src/decorators/applyStyle.ts +17 -16
  207. package/src/decorators/attribute.ts +20 -19
  208. package/src/decorators/{changedAttributeHost.ts → changedAttributeThis.ts} +10 -12
  209. package/src/decorators/elementDefine.ts +80 -57
  210. package/src/decorators/emitCustomEvent.ts +21 -26
  211. package/src/decorators/index.ts +2 -1
  212. package/src/decorators/lifecycles.ts +76 -11
  213. package/src/decorators/query.ts +51 -124
  214. package/src/decorators/queryAll.ts +30 -127
  215. package/src/decorators/setProperty.ts +12 -11
  216. package/src/elements/{SwcAppMixin.ts → SwcApp.ts} +98 -31
  217. package/src/elements/index.ts +11 -1
  218. package/src/elements/tt/SwcAppMixin.ts +13 -0
  219. package/src/elements/tt/SwcAsync.ts +139 -0
  220. package/src/elements/tt/SwcAsyncTemplate.ts +126 -0
  221. package/src/elements/tt/SwcChoose.ts +182 -0
  222. package/src/elements/tt/SwcChooseTemplate.ts +229 -0
  223. package/src/elements/tt/SwcIf.ts +145 -0
  224. package/src/elements/tt/SwcIfTemplate.ts +158 -0
  225. package/src/elements/tt/SwcLoop.ts +222 -0
  226. package/src/elements/tt/SwcLoopTemplate.ts +255 -0
  227. package/src/elements/tt/SwcSubTemplates.ts +6 -0
  228. package/src/elements/tt/register.ts +720 -0
  229. package/src/index.ts +13 -9
  230. package/src/types/window.d.ts +43 -0
  231. package/src/types.ts +9 -8
  232. package/src/utils/Utils.ts +28 -24
  233. package/dist/cjs/decorators/changedAttributeHost.js.map +0 -7
  234. package/dist/cjs/elements/SwcAppEngine.js.map +0 -7
  235. package/dist/cjs/elements/SwcAppMixin.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/esm/decorators/changedAttributeHost.js.map +0 -7
  249. package/dist/esm/elements/SwcAppEngine.js.map +0 -7
  250. package/dist/esm/elements/SwcAppMixin.js.map +0 -7
  251. package/dist/esm/elements/SwcAsync.js +0 -129
  252. package/dist/esm/elements/SwcAsync.js.map +0 -7
  253. package/dist/esm/elements/SwcChoose.js +0 -155
  254. package/dist/esm/elements/SwcChoose.js.map +0 -7
  255. package/dist/esm/elements/SwcIf.js +0 -117
  256. package/dist/esm/elements/SwcIf.js.map +0 -7
  257. package/dist/esm/elements/SwcLoop.js +0 -176
  258. package/dist/esm/elements/SwcLoop.js.map +0 -7
  259. package/dist/esm/elements/SwcSubTemplates.js +0 -13
  260. package/dist/esm/elements/SwcSubTemplates.js.map +0 -7
  261. package/dist/esm/elements/register.js +0 -1007
  262. package/dist/esm/elements/register.js.map +0 -7
  263. package/dist/types/decorators/changedAttributeHost.d.ts +0 -20
  264. package/dist/types/decorators/changedAttributeHost.d.ts.map +0 -1
  265. package/dist/types/elements/SwcAppEngine.d.ts.map +0 -1
  266. package/dist/types/elements/SwcAppMixin.d.ts +0 -386
  267. package/dist/types/elements/SwcAppMixin.d.ts.map +0 -1
  268. package/dist/types/elements/SwcAsync.d.ts +0 -2
  269. package/dist/types/elements/SwcAsync.d.ts.map +0 -1
  270. package/dist/types/elements/SwcChoose.d.ts +0 -2
  271. package/dist/types/elements/SwcChoose.d.ts.map +0 -1
  272. package/dist/types/elements/SwcIf.d.ts +0 -2
  273. package/dist/types/elements/SwcLoop.d.ts +0 -2
  274. package/dist/types/elements/SwcLoop.d.ts.map +0 -1
  275. package/dist/types/elements/SwcSubTemplates.d.ts +0 -13
  276. package/dist/types/elements/SwcSubTemplates.d.ts.map +0 -1
  277. package/dist/types/elements/register.d.ts +0 -4
  278. package/dist/types/elements/register.d.ts.map +0 -1
  279. package/src/elements/SwcAsync.ts +0 -126
  280. package/src/elements/SwcChoose.ts +0 -190
  281. package/src/elements/SwcIf.ts +0 -124
  282. package/src/elements/SwcLoop.ts +0 -205
  283. package/src/elements/SwcSubTemplates.ts +0 -6
  284. package/src/elements/register.ts +0 -1022
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dooboostore/simple-web-component",
3
- "version": "1.0.35",
3
+ "version": "1.0.37",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/cjs/index.js",
@@ -92,10 +92,10 @@
92
92
  "webpack": "^5.93.0",
93
93
  "webpack-cli": "^5.1.4",
94
94
  "webpack-dev-server": "^5.2.0",
95
- "@dooboostore/simple-boot": "1.0.55",
96
- "@dooboostore/core-node": "1.0.12",
97
95
  "@dooboostore/core": "1.0.31",
98
- "@dooboostore/core-web": "1.0.10"
96
+ "@dooboostore/core-node": "1.0.12",
97
+ "@dooboostore/core-web": "1.0.11",
98
+ "@dooboostore/simple-boot": "1.0.55"
99
99
  },
100
100
  "scripts": {
101
101
  "clean": "rm -rf dist",
@@ -1,22 +1,27 @@
1
- import { SimpleApplication } from '@dooboostore/simple-boot/SimpleApplication';
1
+ import { SimpleApplication } from '@dooboostore/simple-boot';
2
2
  import { HashRouter, PathRouter, Router, RouterEventType } from '@dooboostore/core-web';
3
- import { ElementRouter } from '../router/ElementRouter';
4
- import { SimOption } from '@dooboostore/simple-boot/SimOption';
3
+ import { ElementRouter } from './router/ElementRouter';
4
+ import { SimOption } from '@dooboostore/simple-boot';
5
5
  import { ConstructorType, OptionalType, Subscription } from '@dooboostore/core';
6
6
 
7
- import { SwcAppInterface } from '../types';
7
+ import { SwcAppInterface } from './types';
8
8
  import { SimConfig } from '@dooboostore/simple-boot';
9
9
 
10
10
  export type SwcConfigType = {
11
11
  routeType: 'path' | 'hash' | 'element';
12
- connectMode?: 'direct' | 'swap' | 'clear-swap';
12
+ connectMode?: 'direct' | 'swap' | 'clear-swap' | 'hydrate'; // hydrate 아직 개발중
13
13
  container?: symbol;
14
14
  otherInstanceSim?: Map<ConstructorType<any> | Function | SimConfig | symbol, any>;
15
15
  path?: string;
16
16
  window: Window;
17
- onEngineStarted?: (sp: SimpleApplication, app: SwcAppInterface) => void;
17
+ onEngineStarted?: (sp: SimpleApplication, app: SwcAppInterface) => Promise<void> | void;
18
+ onConnectedChildAfter?: (swcEl: HTMLElement) => void;
19
+ onConnectedChildBefore?: (swcEl: HTMLElement) => void;
20
+ onDisconnectedChildAfter?: (swcEl: HTMLElement) => void;
21
+ onDisconnectedChildBefore?: (swcEl: HTMLElement) => void;
18
22
  onConnected?: (app: SwcAppInterface) => void;
19
23
  onDisconnected?: (app: SwcAppInterface) => void;
24
+ ssr?: boolean;
20
25
 
21
26
  onChildrenConnectedDone?: (app: SwcAppInterface) => void;
22
27
  // onChildrenSwcAppStartedDone?: (app: SwcAppInterface) => void;
@@ -71,7 +76,7 @@ export class SwcAppEngine {
71
76
  this.simpleApplication.run(otherInstanceSim);
72
77
 
73
78
  if (this._config.onEngineStarted) {
74
- this._config.onEngineStarted(this.simpleApplication, this.host as unknown as SwcAppInterface);
79
+ await this._config.onEngineStarted(this.simpleApplication, this.host as unknown as SwcAppInterface);
75
80
  }
76
81
  } catch (e) {
77
82
  console.error('[SWC-APP-ENGINE] Init failed:', e, this._config);
@@ -47,19 +47,21 @@ export const getAddEventListenerMetadata = (target: any): AddEventListenerMetada
47
47
  };
48
48
 
49
49
  /**
50
- * @addEventListenerHost decorator - simplified version of @addEventListener for :host selector
51
- * Usage: @addEventListenerHost('click')
52
- * Usage: @addEventListenerHost('click', { stopPropagation: true })
50
+ * @addEventListenerThis decorator - simplified version of @addEventListener for $this selector
53
51
  */
54
- export function addEventListenerHost(type: string, options?: AddEventListenerBaseOptions & SwcQueryOptions): MethodDecorator {
55
- return addEventListener(':host', type, options);
52
+ export function addEventListenerThis(type: string, options?: AddEventListenerBaseOptions & SwcQueryOptions): MethodDecorator {
53
+ return addEventListener('$this', type, options);
56
54
  }
57
55
 
58
56
  /**
59
- * @addEventListenerAppHost decorator - simplified version of @addEventListener for :appHost selector
60
- * Usage: @addEventListenerAppHost('click')
61
- * Usage: @addEventListenerAppHost('click', { stopPropagation: true })
57
+ * @addEventListenerAppHost decorator - simplified version of @addEventListener for $appHost selector
62
58
  */
63
59
  export function addEventListenerAppHost(type: string, options?: AddEventListenerBaseOptions & SwcQueryOptions): MethodDecorator {
64
- return addEventListener(':appHost', type, options);
60
+ return addEventListener('$appHost', type, options);
61
+ }
62
+ export function addEventListenerWindow(type: string, options?: AddEventListenerBaseOptions & SwcQueryOptions): MethodDecorator {
63
+ return addEventListener('$window', type, options);
64
+ }
65
+ export function addEventListenerDocument(type: string, options?: AddEventListenerBaseOptions & SwcQueryOptions): MethodDecorator {
66
+ return addEventListener('$document', type, options);
65
67
  }
@@ -61,15 +61,16 @@ function createAttributeDecorator(action: AttributeAction) {
61
61
  targetEls.push(t);
62
62
  };
63
63
 
64
- if (selector === ':parentHost') applyRoot(hostSet.$parentHost);
65
- else if (selector === ':appHost') applyRoot(hostSet.$appHost);
66
- else if (selector === ':firstHost') applyRoot(hostSet.$firstHost);
67
- else if (selector === ':lastHost') applyRoot(hostSet.$lastHost);
68
- else if (selector === ':firstAppHost') applyRoot(hostSet.$firstAppHost);
69
- else if (selector === ':lastAppHost') applyRoot(hostSet.$lastAppHost);
70
- else if (selector === ':hosts') hostSet.$hosts.forEach(applyRoot);
71
- else if (selector === ':appHosts') hostSet.$appHosts.forEach(applyRoot);
72
- else if (selector === ':host' || !selector) applyRoot(host);
64
+ if (selector === '$this' || !selector) applyRoot(host);
65
+ else if (selector === '$host') applyRoot(hostSet.$host);
66
+ else if (selector === '$parentHost') applyRoot(hostSet.$parentHost);
67
+ else if (selector === '$appHost') applyRoot(hostSet.$appHost);
68
+ else if (selector === '$firstHost') applyRoot(hostSet.$firstHost);
69
+ else if (selector === '$lastHost') applyRoot(hostSet.$lastHost);
70
+ else if (selector === '$firstAppHost') applyRoot(hostSet.$firstAppHost);
71
+ else if (selector === '$lastAppHost') applyRoot(hostSet.$lastAppHost);
72
+ else if (selector === '$hosts') hostSet.$hosts.forEach(applyRoot);
73
+ else if (selector === '$appHosts') hostSet.$appHosts.forEach(applyRoot);
73
74
  else {
74
75
  const targetRoot = r === 'auto' ? (host.shadowRoot || host) : (r === 'shadow' ? host.shadowRoot : host);
75
76
  if (targetRoot) {
@@ -140,13 +141,13 @@ export const setAttribute = (selector: string, nameOrOptions?: string | Attribut
140
141
  export const updateAttribute = (selector: string, nameOrOptions?: string | AttributeApplyOptions, options: AttributeApplyOptions = {}) => createAttributeDecorator('update')(selector, nameOrOptions, options);
141
142
  export const removeAttribute = (selector: string, nameOrOptions?: string | AttributeApplyOptions, options: AttributeApplyOptions = {}) => createAttributeDecorator('remove')(selector, nameOrOptions, options);
142
143
 
143
- // Host versions
144
- export function applyAttributeHost(action: AttributeAction = 'update', options: AttributeApplyOptions = {}): MethodDecorator {
145
- return createAttributeDecorator(action)(':host', options);
144
+ // This versions
145
+ export function applyAttributeThis(action: AttributeAction = 'update', options: AttributeApplyOptions = {}): MethodDecorator {
146
+ return createAttributeDecorator(action)('$this', options);
146
147
  }
147
- export const setAttributeHost = (nameOrOptions: string | AttributeApplyOptions, options: AttributeApplyOptions = {}) => createAttributeDecorator('set')(':host', nameOrOptions, options);
148
- export const updateAttributeHost = (nameOrOptions: string | AttributeApplyOptions, options: AttributeApplyOptions = {}) => createAttributeDecorator('update')(':host', nameOrOptions, options);
149
- export const removeAttributeHost = (nameOrOptions?: string | AttributeApplyOptions, options: AttributeApplyOptions = {}) => createAttributeDecorator('remove')(':host', nameOrOptions, options);
148
+ export const setAttributeThis = (nameOrOptions: string | AttributeApplyOptions, options: AttributeApplyOptions = {}) => createAttributeDecorator('set')('$this', nameOrOptions, options);
149
+ export const updateAttributeThis = (nameOrOptions: string | AttributeApplyOptions, options: AttributeApplyOptions = {}) => createAttributeDecorator('update')('$this', nameOrOptions, options);
150
+ export const removeAttributeThis = (nameOrOptions?: string | AttributeApplyOptions, options: AttributeApplyOptions = {}) => createAttributeDecorator('remove')('$this', nameOrOptions, options);
150
151
 
151
152
  export const findAllAttributeApplyMetadata = (target: any): Map<string | symbol, AttributeApplyMetadata> => {
152
153
  const result = new Map<string | symbol, AttributeApplyMetadata>();
@@ -57,15 +57,16 @@ function createClassDecorator(action: ClassAction) {
57
57
  targetEls.push(t);
58
58
  };
59
59
 
60
- if (selector === ':parentHost') applyRoot(hostSet.$parentHost);
61
- else if (selector === ':appHost') applyRoot(hostSet.$appHost);
62
- else if (selector === ':firstHost') applyRoot(hostSet.$firstHost);
63
- else if (selector === ':lastHost') applyRoot(hostSet.$lastHost);
64
- else if (selector === ':firstAppHost') applyRoot(hostSet.$firstAppHost);
65
- else if (selector === ':lastAppHost') applyRoot(hostSet.$lastAppHost);
66
- else if (selector === ':hosts') hostSet.$hosts.forEach(applyRoot);
67
- else if (selector === ':appHosts') hostSet.$appHosts.forEach(applyRoot);
68
- else if (selector === ':host' || !selector) applyRoot(host);
60
+ if (selector === '$this' || !selector) applyRoot(host);
61
+ else if (selector === '$host') applyRoot(hostSet.$host);
62
+ else if (selector === '$parentHost') applyRoot(hostSet.$parentHost);
63
+ else if (selector === '$appHost') applyRoot(hostSet.$appHost);
64
+ else if (selector === '$firstHost') applyRoot(hostSet.$firstHost);
65
+ else if (selector === '$lastHost') applyRoot(hostSet.$lastHost);
66
+ else if (selector === '$firstAppHost') applyRoot(hostSet.$firstAppHost);
67
+ else if (selector === '$lastAppHost') applyRoot(hostSet.$lastAppHost);
68
+ else if (selector === '$hosts') hostSet.$hosts.forEach(applyRoot);
69
+ else if (selector === '$appHosts') hostSet.$appHosts.forEach(applyRoot);
69
70
  else {
70
71
  const targetRoot = r === 'auto' ? (host.shadowRoot || host) : (r === 'shadow' ? host.shadowRoot : host);
71
72
  if (targetRoot) {
@@ -150,15 +151,15 @@ export const addClass = (selector: string, classMapOrOptions?: string | { [class
150
151
  export const removeClass = (selector: string, classMapOrOptions?: string | { [className: string]: (el: HTMLElement, value: any, helper: HelperHostSet & { $this: any }) => boolean } | ClassApplyOptions, options: ClassApplyOptions = {}) => createClassDecorator('remove')(selector, classMapOrOptions, options);
151
152
  export const toggleClass = (selector: string, classMapOrOptions?: string | { [className: string]: (el: HTMLElement, value: any, helper: HelperHostSet & { $this: any }) => boolean } | ClassApplyOptions, options: ClassApplyOptions = {}) => createClassDecorator('toggle')(selector, classMapOrOptions, options);
152
153
 
153
- // Host versions
154
- export function applyClassHost(action: ClassAction = 'update', options: ClassApplyOptions = {}): MethodDecorator {
155
- return createClassDecorator(action)(':host', options);
154
+ // This versions
155
+ export function applyClassThis(action: ClassAction = 'update', options: ClassApplyOptions = {}): MethodDecorator {
156
+ return createClassDecorator(action)('$this', options);
156
157
  }
157
- export const setClassHost = (classMapOrOptions?: string | { [className: string]: (el: HTMLElement, value: any, helper: HelperHostSet & { $this: any }) => boolean } | ClassApplyOptions, options: ClassApplyOptions = {}) => createClassDecorator('set')(':host', classMapOrOptions, options);
158
- export const updateClassHost = (classMapOrOptions?: string | { [className: string]: (el: HTMLElement, value: any, helper: HelperHostSet & { $this: any }) => boolean } | ClassApplyOptions, options: ClassApplyOptions = {}) => createClassDecorator('update')(':host', classMapOrOptions, options);
159
- export const addClassHost = (classMapOrOptions?: string | { [className: string]: (el: HTMLElement, value: any, helper: HelperHostSet & { $this: any }) => boolean } | ClassApplyOptions, options: ClassApplyOptions = {}) => createClassDecorator('add')(':host', classMapOrOptions, options);
160
- export const removeClassHost = (classMapOrOptions?: string | { [className: string]: (el: HTMLElement, value: any, helper: HelperHostSet & { $this: any }) => boolean } | ClassApplyOptions, options: ClassApplyOptions = {}) => createClassDecorator('remove')(':host', classMapOrOptions, options);
161
- export const toggleClassHost = (classMapOrOptions?: string | { [className: string]: (el: HTMLElement, value: any, helper: HelperHostSet & { $this: any }) => boolean } | ClassApplyOptions, options: ClassApplyOptions = {}) => createClassDecorator('toggle')(':host', classMapOrOptions, options);
158
+ export const setClassThis = (classMapOrOptions?: string | { [className: string]: (el: HTMLElement, value: any, helper: HelperHostSet & { $this: any }) => boolean } | ClassApplyOptions, options: ClassApplyOptions = {}) => createClassDecorator('set')('$this', classMapOrOptions, options);
159
+ export const updateClassThis = (classMapOrOptions?: string | { [className: string]: (el: HTMLElement, value: any, helper: HelperHostSet & { $this: any }) => boolean } | ClassApplyOptions, options: ClassApplyOptions = {}) => createClassDecorator('update')('$this', classMapOrOptions, options);
160
+ export const addClassThis = (classMapOrOptions?: string | { [className: string]: (el: HTMLElement, value: any, helper: HelperHostSet & { $this: any }) => boolean } | ClassApplyOptions, options: ClassApplyOptions = {}) => createClassDecorator('add')('$this', classMapOrOptions, options);
161
+ export const removeClassThis = (classMapOrOptions?: string | { [className: string]: (el: HTMLElement, value: any, helper: HelperHostSet & { $this: any }) => boolean } | ClassApplyOptions, options: ClassApplyOptions = {}) => createClassDecorator('remove')('$this', classMapOrOptions, options);
162
+ export const toggleClassThis = (classMapOrOptions?: string | { [className: string]: (el: HTMLElement, value: any, helper: HelperHostSet & { $this: any }) => boolean } | ClassApplyOptions, options: ClassApplyOptions = {}) => createClassDecorator('toggle')('$this', classMapOrOptions, options);
162
163
 
163
164
  export const findAllClassMetadata = (target: any): Map<string | symbol, ClassApplyMetadata> => {
164
165
  const result = new Map<string | symbol, ClassApplyMetadata>();
@@ -4,7 +4,7 @@ import { HelperHostSet, SwcRootType } from '../types';
4
4
  import { SwcUtils } from "../utils/Utils";
5
5
  /*
6
6
  <!-- beforebegin -->
7
- <p>
7
+ <p> <-- it's me
8
8
  <!-- afterbegin -->
9
9
  foo
10
10
  <!-- beforeend -->
@@ -43,8 +43,10 @@ const normalizeNodes = (res: any, doc: Document): Node[] => {
43
43
  });
44
44
  };
45
45
 
46
- const applyToDom = (targetEl: any, res: any, pos: ApplyNodePosition, doc: Document) => {
46
+ const applyToDom = (targetEl: any, res: any, pos: ApplyNodePosition, win: Window) => {
47
47
  if (!targetEl) return;
48
+
49
+ const doc = win.document;
48
50
 
49
51
  if (pos === 'innerHtml') {
50
52
  targetEl.innerHTML = res !== undefined && res !== null ? String(res) : '';
@@ -58,7 +60,7 @@ const applyToDom = (targetEl: any, res: any, pos: ApplyNodePosition, doc: Docume
58
60
  return;
59
61
  }
60
62
 
61
- const isShadowRoot = targetEl instanceof ShadowRoot;
63
+ const isShadowRoot = targetEl instanceof win.ShadowRoot;
62
64
  const nodes = normalizeNodes(res, doc);
63
65
  if (pos === 'replace') {
64
66
  if (!isShadowRoot) targetEl.replaceWith(...nodes);
@@ -105,11 +107,12 @@ export function applyNode(selector: string, options: ApplyNodeOptions = { positi
105
107
  return t;
106
108
  };
107
109
 
108
- if (selector === ':host') return applyRoot(this);
109
- if (selector === ':parentHost') return applyRoot(hostSet.$parentHost);
110
- if (selector === ':appHost') return applyRoot(hostSet.$appHost);
111
- if (selector === ':firstHost') return applyRoot(hostSet.$firstHost);
112
- if (selector === ':lastHost') return applyRoot(hostSet.$lastHost);
110
+ if (selector === '$this') return applyRoot(this);
111
+ if (selector === '$host') return applyRoot(hostSet.$host);
112
+ if (selector === '$parentHost') return applyRoot(hostSet.$parentHost);
113
+ if (selector === '$appHost') return applyRoot(hostSet.$appHost);
114
+ if (selector === '$firstHost') return applyRoot(hostSet.$firstHost);
115
+ if (selector === '$lastHost') return applyRoot(hostSet.$lastHost);
113
116
 
114
117
  const targetRoot = applyRoot(this);
115
118
  return targetRoot ? targetRoot.querySelector(selector) : null;
@@ -123,7 +126,7 @@ export function applyNode(selector: string, options: ApplyNodeOptions = { positi
123
126
 
124
127
  // 사용자가 filter를 명시하면 그 조건으로, 아니면 항상 적용
125
128
  if (!options.filter || options.filter(target, val, {currentThis: this, helper: hostSet})) {
126
- applyToDom(target, val, pos, currentDoc);
129
+ applyToDom(target, val, pos, currentWin);
127
130
  }
128
131
  };
129
132
 
@@ -157,38 +160,38 @@ export const findAllApplyNodeMetadata = (target: any): Map<string | symbol, Appl
157
160
  return result;
158
161
  };
159
162
 
160
- export function applyNodeHost(options: ApplyNodeOptions): MethodDecorator;
161
- export function applyNodeHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
162
- export function applyNodeHost(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {
163
- if (propertyKey !== undefined) return applyNode(':host', { position: 'beforeEnd' })(targetOrOptions, propertyKey, descriptor);
163
+ export function applyNodeThis(options: ApplyNodeOptions): MethodDecorator;
164
+ export function applyNodeThis(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
165
+ export function applyNodeThis(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {
166
+ if (propertyKey !== undefined) return applyNode('$this', { position: 'beforeEnd' })(targetOrOptions, propertyKey, descriptor);
164
167
  const opt = targetOrOptions || {};
165
- return applyNode(':host', { position: 'beforeEnd', ...opt });
168
+ return applyNode('$this', { position: 'beforeEnd', ...opt });
166
169
  }
167
170
 
168
- export function applyReplaceChildrenNodeHost(options: ApplyNodeOptions): MethodDecorator;
169
- export function applyReplaceChildrenNodeHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
170
- export function applyReplaceChildrenNodeHost(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {
171
- if (propertyKey !== undefined) return applyNode(':host', { position: 'replaceChildren' })(targetOrOptions, propertyKey, descriptor);
171
+ export function applyNodeThisReplaceChildren(options: ApplyNodeOptions): MethodDecorator;
172
+ export function applyNodeThisReplaceChildren(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
173
+ export function applyNodeThisReplaceChildren(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {
174
+ if (propertyKey !== undefined) return applyNode('$this', { position: 'replaceChildren' })(targetOrOptions, propertyKey, descriptor);
172
175
  const opt = targetOrOptions || {};
173
- return applyNode(':host', { position: 'replaceChildren', ...opt });
176
+ return applyNode('$this', { position: 'replaceChildren', ...opt });
174
177
  }
175
178
 
176
- export function applyInnerHtmlNodeHost(options: ApplyNodeOptions): MethodDecorator;
177
- export function applyInnerHtmlNodeHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
178
- export function applyInnerHtmlNodeHost(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {
179
- if (propertyKey !== undefined) return applyNode(':host', { position: 'innerHtml' })(targetOrOptions, propertyKey, descriptor);
179
+ export function applyThisInnerHtmlNode(options: ApplyNodeOptions): MethodDecorator;
180
+ export function applyThisInnerHtmlNode(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
181
+ export function applyThisInnerHtmlNode(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {
182
+ if (propertyKey !== undefined) return applyNode('$this', { position: 'innerHtml' })(targetOrOptions, propertyKey, descriptor);
180
183
  const opt = targetOrOptions || {};
181
- return applyNode(':host', { position: 'innerHtml', ...opt });
184
+ return applyNode('$this', { position: 'innerHtml', ...opt });
182
185
  }
183
186
 
184
- export function applyReplaceChildrenNode(selector: string, options: ApplyNodeOptions = {}): MethodDecorator {
187
+ export function applyNodeReplaceChildren(selector: string, options: ApplyNodeOptions = {}): MethodDecorator {
185
188
  return applyNode(selector, { ...options, position: 'replaceChildren' });
186
189
  }
187
190
 
188
- export function applyInnerHtmlNode(selector: string, options: ApplyNodeOptions = {}): MethodDecorator {
191
+ export function applyNodeInnerHtml(selector: string, options: ApplyNodeOptions = {}): MethodDecorator {
189
192
  return applyNode(selector, { ...options, position: 'innerHtml' });
190
193
  }
191
194
 
192
- export function applyInnerTextNode(selector: string, options: ApplyNodeOptions = {}): MethodDecorator {
195
+ export function applyNodeInnerText(selector: string, options: ApplyNodeOptions = {}): MethodDecorator {
193
196
  return applyNode(selector, { ...options, position: 'innerText' });
194
197
  }
@@ -0,0 +1,228 @@
1
+ import { ReflectUtils } from '@dooboostore/core';
2
+ import { ensureInit, getElementConfig } from './elementDefine';
3
+ import { HelperHostSet, SwcRootType } from '../types';
4
+ import { SwcUtils } from "../utils/Utils";
5
+ import {NodeSlot} from "@dooboostore/core-web";
6
+ /*
7
+ <!-- beforebegin -->
8
+ <p> <-- it's me
9
+ <!-- afterbegin -->
10
+ foo
11
+ <!-- beforeend -->
12
+ </p>
13
+ <!-- afterend -->
14
+ */
15
+ export type ApplySlotPosition = 'prependHtml' | 'prependText' | 'appendHtml' | 'appendText' | 'replaceChildrenHtml' | 'replaceChildrenText' | 'clear';
16
+
17
+ export interface ApplySlotOptions {
18
+ position?: ApplySlotPosition;
19
+ // root?: SwcRootType;
20
+ /**
21
+ * Filter function to determine whether to perform DOM operation.
22
+ * If it returns false, the operation is skipped.
23
+ */
24
+ // filter?: (target: HTMLElement | ShadowRoot, newValue: any, meta:{currentThis: any,helper: HelperHostSet}) => boolean;
25
+ /**
26
+ * Optional loading content to display while an async method is executing.
27
+ */
28
+ // loading?: (helper: HelperHostSet) => any;
29
+ }
30
+
31
+ export interface ApplySlotMetadata {
32
+ propertyKey: string | symbol;
33
+ id: string;
34
+ type: 'method' | 'property';
35
+ options: ApplySlotOptions;
36
+ }
37
+
38
+ export const APPLY_SLOT_METADATA_KEY = Symbol.for('simple-web-component:apply-slot');
39
+
40
+ // const normalizeNodes = (res: any, doc: Document): Node[] => {
41
+ // const items = Array.isArray(res) ? res : [res];
42
+ // return items.map(it => {
43
+ // if (it instanceof Node) return it;
44
+ // return doc.createTextNode(it !== undefined && it !== null ? String(it) : '');
45
+ // });
46
+ // };
47
+
48
+ // const applyToDom = (targetEl: any, res: any, pos: ApplyNodePosition, win: Window) => {
49
+ // if (!targetEl) return;
50
+ //
51
+ // const doc = win.document;
52
+ //
53
+ // if (pos === 'innerHtml') {
54
+ // targetEl.innerHTML = res !== undefined && res !== null ? String(res) : '';
55
+ // return;
56
+ // }
57
+ //
58
+ // if (pos === 'innerText') {
59
+ // if (targetEl.innerText !== undefined) {
60
+ // targetEl.innerText = res !== undefined && res !== null ? String(res) : '';
61
+ // }
62
+ // return;
63
+ // }
64
+ //
65
+ // const isShadowRoot = targetEl instanceof win.ShadowRoot;
66
+ // const nodes = normalizeNodes(res, doc);
67
+ // if (pos === 'replace') {
68
+ // if (!isShadowRoot) targetEl.replaceWith(...nodes);
69
+ // } else if (pos === 'replaceChildren') {
70
+ // targetEl.replaceChildren(...nodes);
71
+ // } else {
72
+ // if (pos === 'beforeEnd') targetEl.append(...nodes);
73
+ // else if (pos === 'afterBegin') targetEl.prepend(...nodes);
74
+ // else if (pos === 'beforeBegin' && !isShadowRoot) targetEl.before(...nodes);
75
+ // else if (pos === 'afterEnd' && !isShadowRoot) targetEl.after(...nodes);
76
+ // }
77
+ // };
78
+
79
+ /**
80
+ * @applyNode decorator to surgically add/replace nodes to a target element.
81
+ */
82
+ export function applySlot(id: string, options: ApplySlotOptions = { position: 'replaceChildrenHtml' }): MethodDecorator & PropertyDecorator {
83
+ return (targetObj: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => {
84
+ const type = descriptor === undefined ? 'property' : 'method';
85
+
86
+ if (type === 'property') {
87
+ Object.defineProperty(targetObj, propertyKey, {
88
+ get(this: any) {
89
+ const nodeSlot = new NodeSlot(this, `${this._swcId}-${id}`);
90
+ return nodeSlot;
91
+ },
92
+ configurable: true,
93
+ enumerable: true,
94
+ })
95
+ // return nodeSlot;
96
+ // return;
97
+ }
98
+
99
+ const constructor = targetObj.constructor;
100
+ let metaList = ReflectUtils.getOwnMetadata(APPLY_SLOT_METADATA_KEY, constructor) as ApplySlotMetadata[];
101
+ if (!metaList) {
102
+ metaList = []
103
+ ReflectUtils.defineMetadata(APPLY_SLOT_METADATA_KEY, metaList, constructor);
104
+ }
105
+ metaList.push({ propertyKey, id, type, options });
106
+
107
+
108
+
109
+ if (type === 'method') {
110
+ const original = descriptor.value;
111
+ descriptor.value = function (...args: any[]) {
112
+ ensureInit(this);
113
+
114
+ const conf = getElementConfig(this);
115
+ const currentWin = (this as any)._resolveWindow?.(conf) || ((typeof window !== 'undefined' ? window : undefined) as Window);
116
+ const currentDoc = currentWin.document;
117
+ const hostSet = SwcUtils.getHelperAndHostSet(currentWin, this);
118
+
119
+
120
+ // const getTarget = () => {
121
+ // const r = options.root || 'auto';
122
+ // const applyRoot = (t: any) => {
123
+ // if (!t) return t;
124
+ // if (r === 'auto') return t.shadowRoot || t;
125
+ // if (r === 'shadow') return t.shadowRoot;
126
+ // if (r === 'light') return t;
127
+ // if (r === 'all') return t.shadowRoot || t;
128
+ // return t;
129
+ // };
130
+ //
131
+ // if (selector === '$this') return applyRoot(this);
132
+ // if (selector === '$host') return applyRoot(hostSet.$host);
133
+ // if (selector === '$parentHost') return applyRoot(hostSet.$parentHost);
134
+ // if (selector === '$appHost') return applyRoot(hostSet.$appHost);
135
+ // if (selector === '$firstHost') return applyRoot(hostSet.$firstHost);
136
+ // if (selector === '$lastHost') return applyRoot(hostSet.$lastHost);
137
+ //
138
+ // const targetRoot = applyRoot(this);
139
+ // return targetRoot ? targetRoot.querySelector(selector) : null;
140
+ // };
141
+
142
+ // const targetEl = getTarget();
143
+ const res = original.apply(this, args);
144
+
145
+ // const runApply = (target: any, val: any) => {
146
+ // const pos = options.position || 'beforeEnd';
147
+ //
148
+ // // 사용자가 filter를 명시하면 그 조건으로, 아니면 항상 적용
149
+ // if (!options.filter || options.filter(target, val, {currentThis: this, helper: hostSet})) {
150
+ // applyToDom(target, val, pos, currentWin);
151
+ // }
152
+ // };
153
+
154
+ // if (res instanceof Promise) {
155
+ // // 비동기일 때만 로딩 표시
156
+ // if (targetEl && options.loading) {
157
+ // const loadingRes = options.loading.call(this, hostSet);
158
+ // applyToDom(targetEl, loadingRes, options.position || 'beforeEnd', currentDoc);
159
+ // }
160
+ //
161
+ // return res.then(finalRes => {
162
+ // if (finalRes !== undefined && targetEl) runApply(targetEl, finalRes);
163
+ // return finalRes;
164
+ // });
165
+ // } else {
166
+ // if (res !== undefined && targetEl) runApply(targetEl, res);
167
+ // return res;
168
+ // }
169
+ if (res) {
170
+ const nodeSlot = new NodeSlot(this, `${this._swcId}-${id}`);
171
+ const pos = options.position || 'replaceChildrenHtml';
172
+ const doc = currentWin.document;
173
+
174
+
175
+ // const isShadowRoot = targetEl instanceof win.ShadowRoot;
176
+ // const nodes = normalizeNodes(res, doc);
177
+ if (pos === 'replaceChildrenHtml') {
178
+ nodeSlot.replaceChildrenHtml(res);
179
+ } else if (pos === 'replaceChildrenText') {
180
+ nodeSlot.replaceChildrenText(res);
181
+ } else if (pos === 'appendHtml') {
182
+ nodeSlot.appendHtml(res);
183
+ } else if (pos === 'appendText') {
184
+ nodeSlot.appendText(res);
185
+ } else if (pos === 'prependHtml') {
186
+ nodeSlot.prependHtml(res);
187
+ } else if (pos === 'prependText') {
188
+ nodeSlot.prependText(res);
189
+ } else if (pos === 'clear') {
190
+ nodeSlot.clear();
191
+ }
192
+ }
193
+ return res;
194
+ };
195
+ }
196
+ };
197
+ }
198
+
199
+ // export const findAllApplySlotMetadata = (target: any): Map<string | symbol, ApplySlotMetadata> => {
200
+ export const findAllApplySlotMetadata = (target: any): ApplySlotMetadata[] => {
201
+ const constructor = target instanceof Function ? target : target.constructor;
202
+ return ReflectUtils.getMetadata(APPLY_SLOT_METADATA_KEY, constructor);
203
+ };
204
+
205
+ export function applySlotClear(id: string): MethodDecorator {
206
+ return applySlot(id, { position: 'clear' });
207
+ }
208
+ export function applySlotPrependHtml(id: string): MethodDecorator {
209
+ return applySlot(id, { position: 'prependHtml' });
210
+ }
211
+ export const applySlotPrepend = applySlotPrependHtml;
212
+ export function applySlotPrependText(id: string): MethodDecorator {
213
+ return applySlot(id, { position: 'prependText' });
214
+ }
215
+ export function applySlotAppendHtml(id: string): MethodDecorator {
216
+ return applySlot(id, { position: 'appendHtml' });
217
+ }
218
+ export function applySlotAppendText(id: string): MethodDecorator {
219
+ return applySlot(id, { position: 'appendText' });
220
+ }
221
+ export const applySlotAppend = applySlotAppendHtml;
222
+ export function applySlotReplaceChildrenHtml(id: string): MethodDecorator {
223
+ return applySlot(id, { position: 'replaceChildrenHtml' });
224
+ }
225
+ export const applySlotReplaceChildren = applySlotReplaceChildrenHtml;
226
+ export function applySlotReplaceChildrenText(id: string): MethodDecorator {
227
+ return applySlot(id, { position: 'replaceChildrenText' });
228
+ }
@@ -38,7 +38,7 @@ function createStyleDecorator(action: StyleAction) {
38
38
  if (resolvedValue !== undefined) {
39
39
  const win = (this as any).ownerDocument?.defaultView || window;
40
40
  const host = this as unknown as HTMLElement;
41
- const hostSet = SwcUtils.getHelperAndHostSet(win, host);
41
+ const hostSet = { ...SwcUtils.getHelperAndHostSet(win, host), $this: this };
42
42
  const r = options.root || 'auto';
43
43
  const targetEls: HTMLElement[] = [];
44
44
 
@@ -47,15 +47,16 @@ function createStyleDecorator(action: StyleAction) {
47
47
  targetEls.push(t);
48
48
  };
49
49
 
50
- if (selector === ':parentHost') applyRoot(hostSet.$parentHost);
51
- else if (selector === ':appHost') applyRoot(hostSet.$appHost);
52
- else if (selector === ':firstHost') applyRoot(hostSet.$firstHost);
53
- else if (selector === ':lastHost') applyRoot(hostSet.$lastHost);
54
- else if (selector === ':firstAppHost') applyRoot(hostSet.$firstAppHost);
55
- else if (selector === ':lastAppHost') applyRoot(hostSet.$lastAppHost);
56
- else if (selector === ':hosts') hostSet.$hosts.forEach(applyRoot);
57
- else if (selector === ':appHosts') hostSet.$appHosts.forEach(applyRoot);
58
- else if (selector === ':host' || !selector) applyRoot(host);
50
+ if (selector === '$this' || !selector) applyRoot(host);
51
+ else if (selector === '$host') applyRoot(hostSet.$host);
52
+ else if (selector === '$parentHost') applyRoot(hostSet.$parentHost);
53
+ else if (selector === '$appHost') applyRoot(hostSet.$appHost);
54
+ else if (selector === '$firstHost') applyRoot(hostSet.$firstHost);
55
+ else if (selector === '$lastHost') applyRoot(hostSet.$lastHost);
56
+ else if (selector === '$firstAppHost') applyRoot(hostSet.$firstAppHost);
57
+ else if (selector === '$lastAppHost') applyRoot(hostSet.$lastAppHost);
58
+ else if (selector === '$hosts') hostSet.$hosts.forEach(applyRoot);
59
+ else if (selector === '$appHosts') hostSet.$appHosts.forEach(applyRoot);
59
60
  else {
60
61
  const targetRoot = r === 'auto' ? (host.shadowRoot || host) : (r === 'shadow' ? host.shadowRoot : host);
61
62
  if (targetRoot) {
@@ -122,13 +123,13 @@ export const setStyle = (selector: string, options: StyleApplyOptions = {}) => c
122
123
  export const updateStyle = (selector: string, options: StyleApplyOptions = {}) => createStyleDecorator('update')(selector, options);
123
124
  export const removeStyle = (selector: string, options: StyleApplyOptions = {}) => createStyleDecorator('remove')(selector, options);
124
125
 
125
- // Host versions
126
- export function applyStyleHost(action: StyleAction = 'update', options: StyleApplyOptions = {}): MethodDecorator {
127
- return createStyleDecorator(action)(':host', options);
126
+ // This versions
127
+ export function applyStyleThis(action: StyleAction = 'update', options: StyleApplyOptions = {}): MethodDecorator {
128
+ return createStyleDecorator(action)('$this', options);
128
129
  }
129
- export const setStyleHost = (options: StyleApplyOptions = {}) => createStyleDecorator('set')(':host', options);
130
- export const updateStyleHost = (options: StyleApplyOptions = {}) => createStyleDecorator('update')(':host', options);
131
- export const removeStyleHost = (options: StyleApplyOptions = {}) => createStyleDecorator('remove')(':host', options);
130
+ export const setStyleThis = (options: StyleApplyOptions = {}) => createStyleDecorator('set')('$this', options);
131
+ export const updateStyleThis = (options: StyleApplyOptions = {}) => createStyleDecorator('update')('$this', options);
132
+ export const removeStyleThis = (options: StyleApplyOptions = {}) => createStyleDecorator('remove')('$this', options);
132
133
 
133
134
  export const findAllStyleMetadata = (target: any): Map<string | symbol, StyleApplyMetadata> => {
134
135
  const result = new Map<string | symbol, StyleApplyMetadata>();