@dooboostore/simple-web-component 1.0.36 → 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 (210) hide show
  1. package/README.md +41 -4
  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/applyNode.js +14 -13
  5. package/dist/cjs/decorators/applyNode.js.map +2 -2
  6. package/dist/cjs/decorators/applySlot.js +122 -0
  7. package/dist/cjs/decorators/applySlot.js.map +7 -0
  8. package/dist/cjs/decorators/elementDefine.js +38 -30
  9. package/dist/cjs/decorators/elementDefine.js.map +2 -2
  10. package/dist/cjs/decorators/index.js +1 -0
  11. package/dist/cjs/decorators/index.js.map +2 -2
  12. package/dist/cjs/decorators/lifecycles.js +56 -8
  13. package/dist/cjs/decorators/lifecycles.js.map +2 -2
  14. package/dist/cjs/elements/{SwcAppMixin.js → SwcApp.js} +107 -57
  15. package/dist/cjs/elements/SwcApp.js.map +7 -0
  16. package/dist/cjs/elements/index.js +21 -2
  17. package/dist/cjs/elements/index.js.map +3 -3
  18. package/dist/cjs/elements/tt/SwcAppMixin.js +1 -0
  19. package/dist/cjs/elements/tt/SwcAppMixin.js.map +7 -0
  20. package/dist/cjs/elements/tt/SwcAsync.js +1 -0
  21. package/dist/cjs/elements/tt/SwcAsync.js.map +7 -0
  22. package/dist/cjs/elements/tt/SwcAsyncTemplate.js +1 -0
  23. package/dist/cjs/elements/tt/SwcAsyncTemplate.js.map +7 -0
  24. package/dist/cjs/elements/tt/SwcChoose.js +1 -0
  25. package/dist/cjs/elements/tt/SwcChoose.js.map +7 -0
  26. package/dist/cjs/elements/tt/SwcChooseTemplate.js +1 -0
  27. package/dist/cjs/elements/tt/SwcChooseTemplate.js.map +7 -0
  28. package/dist/cjs/elements/tt/SwcIf.js +1 -0
  29. package/dist/cjs/elements/tt/SwcIf.js.map +7 -0
  30. package/dist/cjs/elements/tt/SwcIfTemplate.js +1 -0
  31. package/dist/cjs/elements/tt/SwcIfTemplate.js.map +7 -0
  32. package/dist/cjs/elements/tt/SwcLoop.js +1 -0
  33. package/dist/cjs/elements/tt/SwcLoop.js.map +7 -0
  34. package/dist/cjs/elements/tt/SwcLoopTemplate.js +1 -0
  35. package/dist/cjs/elements/tt/SwcLoopTemplate.js.map +7 -0
  36. package/dist/cjs/elements/tt/SwcSubTemplates.js +1 -0
  37. package/dist/cjs/elements/tt/SwcSubTemplates.js.map +7 -0
  38. package/dist/cjs/elements/tt/register.js +1 -0
  39. package/dist/cjs/elements/tt/register.js.map +7 -0
  40. package/dist/cjs/index.js +12 -8
  41. package/dist/cjs/index.js.map +2 -2
  42. package/dist/cjs/types/window.d.js +16 -0
  43. package/dist/cjs/types/window.d.js.map +7 -0
  44. package/dist/cjs/types.js.map +1 -1
  45. package/dist/cjs/utils/Utils.js +9 -6
  46. package/dist/cjs/utils/Utils.js.map +2 -2
  47. package/dist/esm/{elements/SwcAppEngine.js → SwcAppEngine.js} +4 -4
  48. package/dist/esm/SwcAppEngine.js.map +7 -0
  49. package/dist/esm/decorators/applyNode.js +14 -13
  50. package/dist/esm/decorators/applyNode.js.map +2 -2
  51. package/dist/esm/decorators/applySlot.js +103 -0
  52. package/dist/esm/decorators/applySlot.js.map +7 -0
  53. package/dist/esm/decorators/elementDefine.js +41 -33
  54. package/dist/esm/decorators/elementDefine.js.map +2 -2
  55. package/dist/esm/decorators/index.js +1 -0
  56. package/dist/esm/decorators/index.js.map +2 -2
  57. package/dist/esm/decorators/lifecycles.js +56 -8
  58. package/dist/esm/decorators/lifecycles.js.map +2 -2
  59. package/dist/esm/elements/{SwcAppMixin.js → SwcApp.js} +102 -53
  60. package/dist/esm/elements/SwcApp.js.map +7 -0
  61. package/dist/esm/elements/index.js +7 -1
  62. package/dist/esm/elements/index.js.map +2 -2
  63. package/dist/esm/elements/tt/SwcAppMixin.js +1 -0
  64. package/dist/esm/elements/tt/SwcAppMixin.js.map +7 -0
  65. package/dist/esm/elements/tt/SwcAsync.js +1 -0
  66. package/dist/esm/elements/tt/SwcAsync.js.map +7 -0
  67. package/dist/esm/elements/tt/SwcAsyncTemplate.js +1 -0
  68. package/dist/esm/elements/tt/SwcAsyncTemplate.js.map +7 -0
  69. package/dist/esm/elements/tt/SwcChoose.js +1 -0
  70. package/dist/esm/elements/tt/SwcChoose.js.map +7 -0
  71. package/dist/esm/elements/tt/SwcChooseTemplate.js +1 -0
  72. package/dist/esm/elements/tt/SwcChooseTemplate.js.map +7 -0
  73. package/dist/esm/elements/tt/SwcIf.js +1 -0
  74. package/dist/esm/elements/tt/SwcIf.js.map +7 -0
  75. package/dist/esm/elements/tt/SwcIfTemplate.js +1 -0
  76. package/dist/esm/elements/tt/SwcIfTemplate.js.map +7 -0
  77. package/dist/esm/elements/tt/SwcLoop.js +1 -0
  78. package/dist/esm/elements/tt/SwcLoop.js.map +7 -0
  79. package/dist/esm/elements/tt/SwcLoopTemplate.js +1 -0
  80. package/dist/esm/elements/tt/SwcLoopTemplate.js.map +7 -0
  81. package/dist/esm/elements/tt/SwcSubTemplates.js +1 -0
  82. package/dist/esm/elements/tt/SwcSubTemplates.js.map +7 -0
  83. package/dist/esm/elements/tt/register.js +1 -0
  84. package/dist/esm/elements/tt/register.js.map +7 -0
  85. package/dist/esm/index.js +13 -9
  86. package/dist/esm/index.js.map +2 -2
  87. package/dist/esm/types/window.d.js +1 -0
  88. package/dist/esm/types/window.d.js.map +7 -0
  89. package/dist/esm/types.js.map +1 -1
  90. package/dist/esm/utils/Utils.js +9 -6
  91. package/dist/esm/utils/Utils.js.map +2 -2
  92. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +3867 -97
  93. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
  94. package/dist/types/{elements/SwcAppEngine.d.ts → SwcAppEngine.d.ts} +9 -4
  95. package/dist/types/SwcAppEngine.d.ts.map +1 -0
  96. package/dist/types/decorators/applyNode.d.ts +7 -7
  97. package/dist/types/decorators/applyNode.d.ts.map +1 -1
  98. package/dist/types/decorators/applySlot.d.ts +27 -0
  99. package/dist/types/decorators/applySlot.d.ts.map +1 -0
  100. package/dist/types/decorators/elementDefine.d.ts.map +1 -1
  101. package/dist/types/decorators/index.d.ts +1 -0
  102. package/dist/types/decorators/index.d.ts.map +1 -1
  103. package/dist/types/decorators/lifecycles.d.ts +21 -6
  104. package/dist/types/decorators/lifecycles.d.ts.map +1 -1
  105. package/dist/types/elements/SwcApp.d.ts +7 -0
  106. package/dist/types/elements/SwcApp.d.ts.map +1 -0
  107. package/dist/types/elements/index.d.ts +2 -1
  108. package/dist/types/elements/index.d.ts.map +1 -1
  109. package/dist/types/elements/tt/SwcAppMixin.d.ts +1 -0
  110. package/dist/types/elements/tt/SwcAppMixin.d.ts.map +1 -0
  111. package/dist/types/elements/tt/SwcAsync.d.ts +1 -0
  112. package/dist/types/elements/tt/SwcAsync.d.ts.map +1 -0
  113. package/dist/types/elements/tt/SwcAsyncTemplate.d.ts +1 -0
  114. package/dist/types/elements/tt/SwcAsyncTemplate.d.ts.map +1 -0
  115. package/dist/types/elements/tt/SwcChoose.d.ts +1 -0
  116. package/dist/types/elements/tt/SwcChoose.d.ts.map +1 -0
  117. package/dist/types/elements/tt/SwcChooseTemplate.d.ts +1 -0
  118. package/dist/types/elements/tt/SwcChooseTemplate.d.ts.map +1 -0
  119. package/dist/types/elements/tt/SwcIf.d.ts +1 -0
  120. package/dist/types/elements/{SwcIf.d.ts.map → tt/SwcIf.d.ts.map} +1 -1
  121. package/dist/types/elements/tt/SwcIfTemplate.d.ts +1 -0
  122. package/dist/types/elements/tt/SwcIfTemplate.d.ts.map +1 -0
  123. package/dist/types/elements/tt/SwcLoop.d.ts +1 -0
  124. package/dist/types/elements/tt/SwcLoop.d.ts.map +1 -0
  125. package/dist/types/elements/tt/SwcLoopTemplate.d.ts +1 -0
  126. package/dist/types/elements/tt/SwcLoopTemplate.d.ts.map +1 -0
  127. package/dist/types/elements/tt/SwcSubTemplates.d.ts +1 -0
  128. package/dist/types/elements/tt/SwcSubTemplates.d.ts.map +1 -0
  129. package/dist/types/elements/tt/register.d.ts +1 -0
  130. package/dist/types/elements/tt/register.d.ts.map +1 -0
  131. package/dist/types/index.d.ts +2 -2
  132. package/dist/types/index.d.ts.map +1 -1
  133. package/dist/types/types.d.ts +3 -3
  134. package/dist/types/types.d.ts.map +1 -1
  135. package/dist/types/utils/Utils.d.ts +6 -5
  136. package/dist/types/utils/Utils.d.ts.map +1 -1
  137. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +3867 -97
  138. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
  139. package/package.json +2 -2
  140. package/src/{elements/SwcAppEngine.ts → SwcAppEngine.ts} +12 -7
  141. package/src/decorators/applyNode.ts +15 -13
  142. package/src/decorators/applySlot.ts +228 -0
  143. package/src/decorators/elementDefine.ts +59 -37
  144. package/src/decorators/index.ts +1 -0
  145. package/src/decorators/lifecycles.ts +76 -11
  146. package/src/elements/{SwcAppMixin.ts → SwcApp.ts} +98 -31
  147. package/src/elements/index.ts +11 -1
  148. package/src/elements/tt/SwcAppMixin.ts +13 -0
  149. package/src/elements/tt/SwcAsync.ts +139 -0
  150. package/src/elements/tt/SwcAsyncTemplate.ts +126 -0
  151. package/src/elements/tt/SwcChoose.ts +182 -0
  152. package/src/elements/tt/SwcChooseTemplate.ts +229 -0
  153. package/src/elements/tt/SwcIf.ts +145 -0
  154. package/src/elements/tt/SwcIfTemplate.ts +158 -0
  155. package/src/elements/tt/SwcLoop.ts +222 -0
  156. package/src/elements/tt/SwcLoopTemplate.ts +255 -0
  157. package/src/elements/tt/SwcSubTemplates.ts +6 -0
  158. package/src/elements/tt/register.ts +720 -0
  159. package/src/index.ts +13 -9
  160. package/src/types/window.d.ts +43 -0
  161. package/src/types.ts +4 -3
  162. package/src/utils/Utils.ts +11 -6
  163. package/dist/cjs/elements/SwcAppEngine.js.map +0 -7
  164. package/dist/cjs/elements/SwcAppMixin.js.map +0 -7
  165. package/dist/cjs/elements/SwcAsync.js +0 -129
  166. package/dist/cjs/elements/SwcAsync.js.map +0 -7
  167. package/dist/cjs/elements/SwcChoose.js +0 -155
  168. package/dist/cjs/elements/SwcChoose.js.map +0 -7
  169. package/dist/cjs/elements/SwcIf.js +0 -117
  170. package/dist/cjs/elements/SwcIf.js.map +0 -7
  171. package/dist/cjs/elements/SwcLoop.js +0 -176
  172. package/dist/cjs/elements/SwcLoop.js.map +0 -7
  173. package/dist/cjs/elements/SwcSubTemplates.js +0 -13
  174. package/dist/cjs/elements/SwcSubTemplates.js.map +0 -7
  175. package/dist/cjs/elements/register.js +0 -1026
  176. package/dist/cjs/elements/register.js.map +0 -7
  177. package/dist/esm/elements/SwcAppEngine.js.map +0 -7
  178. package/dist/esm/elements/SwcAppMixin.js.map +0 -7
  179. package/dist/esm/elements/SwcAsync.js +0 -129
  180. package/dist/esm/elements/SwcAsync.js.map +0 -7
  181. package/dist/esm/elements/SwcChoose.js +0 -155
  182. package/dist/esm/elements/SwcChoose.js.map +0 -7
  183. package/dist/esm/elements/SwcIf.js +0 -117
  184. package/dist/esm/elements/SwcIf.js.map +0 -7
  185. package/dist/esm/elements/SwcLoop.js +0 -176
  186. package/dist/esm/elements/SwcLoop.js.map +0 -7
  187. package/dist/esm/elements/SwcSubTemplates.js +0 -13
  188. package/dist/esm/elements/SwcSubTemplates.js.map +0 -7
  189. package/dist/esm/elements/register.js +0 -1007
  190. package/dist/esm/elements/register.js.map +0 -7
  191. package/dist/types/elements/SwcAppEngine.d.ts.map +0 -1
  192. package/dist/types/elements/SwcAppMixin.d.ts +0 -386
  193. package/dist/types/elements/SwcAppMixin.d.ts.map +0 -1
  194. package/dist/types/elements/SwcAsync.d.ts +0 -2
  195. package/dist/types/elements/SwcAsync.d.ts.map +0 -1
  196. package/dist/types/elements/SwcChoose.d.ts +0 -2
  197. package/dist/types/elements/SwcChoose.d.ts.map +0 -1
  198. package/dist/types/elements/SwcIf.d.ts +0 -2
  199. package/dist/types/elements/SwcLoop.d.ts +0 -2
  200. package/dist/types/elements/SwcLoop.d.ts.map +0 -1
  201. package/dist/types/elements/SwcSubTemplates.d.ts +0 -13
  202. package/dist/types/elements/SwcSubTemplates.d.ts.map +0 -1
  203. package/dist/types/elements/register.d.ts +0 -4
  204. package/dist/types/elements/register.d.ts.map +0 -1
  205. package/src/elements/SwcAsync.ts +0 -126
  206. package/src/elements/SwcChoose.ts +0 -190
  207. package/src/elements/SwcIf.ts +0 -124
  208. package/src/elements/SwcLoop.ts +0 -205
  209. package/src/elements/SwcSubTemplates.ts +0 -6
  210. package/src/elements/register.ts +0 -1022
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/types.ts"],
4
- "sourcesContent": ["import { SimpleApplication } from '@dooboostore/simple-boot/SimpleApplication';\nimport { Router } from '@dooboostore/core-web';\nimport {SwcAttributeConfigType} from \"./elements/SwcAppEngine\";\n\nexport enum InjectSituationType {\n HOST_SET = 'SIMPLE_WEB_COMPONENT://HOSTSET',\n APP_HOST = 'SIMPLE_WEB_COMPONENT://APPHOST',\n APP_HOSTS = 'SIMPLE_WEB_COMPONENT://APPHOSTS',\n HOST = 'SIMPLE_WEB_COMPONENT://HOST',\n PARENT_HOST = 'SIMPLE_WEB_COMPONENT://PARENTHOST',\n HOSTS = 'SIMPLE_WEB_COMPONENT://HOSTS',\n FIRST_HOST = 'SIMPLE_WEB_COMPONENT://FIRSTHOST',\n LAST_HOST = 'SIMPLE_WEB_COMPONENT://LASTHOST',\n FIRST_APP_HOST = 'SIMPLE_WEB_COMPONENT://FIRSTAPPHOST',\n LAST_APP_HOST = 'SIMPLE_WEB_COMPONENT://LASTAPPHOST'\n}\n\nexport type SwcRootType = 'light' | 'shadow' | 'all' | 'auto';\n\nexport type SpecialSelector = '$this' | '$window' | '$document' | '$host' | '$appHost' | '$firstHost' | '$lastHost' | '$firstAppHost' | '$lastAppHost' | '$hosts' | '$appHosts';\n\nexport type SwcQueryOptions = { root?: SwcRootType };\n\nexport type HelperSet = {\n $d: Document;\n $w: Window;\n $q: (selector: string, root?: Element | Document | ShadowRoot) => HTMLElement | null;\n $qa: (selector: string, root?: Element | Document | ShadowRoot) => HTMLElement[];\n $qi: (id: string, root?: Document | ShadowRoot) => HTMLElement | null;\n};\n\nexport type HostSet = {\n $host: HTMLElement | null; // Nearest parent SWC component\n $parentHost: HTMLElement | null; // Grandparent SWC ancestor\n $hosts: HTMLElement[]; // All SWC ancestors [root, ..., parent]\n $firstHost: HTMLElement | null; // Top-most SWC ancestor\n $lastHost: HTMLElement | null; // Same as $host\n $templateHost: HTMLTemplateElement | null | undefined;\n $appHost: SwcAppInterface | null;\n $appHosts: SwcAppInterface[];\n $firstAppHost: SwcAppInterface | null;\n $lastAppHost: SwcAppInterface | null;\n};\n\nexport type HelperHostSet = HelperSet & HostSet & {$this: any};\n\nexport type SwcAppMessage<T = any> = {\n publisher?: any;\n data?: T;\n type?: string;\n};\n\nexport interface SwcChooseInterface extends HTMLTemplateElement {\n value: any;\n refresh(): void;\n}\nexport interface SwcIfInterface extends HTMLTemplateElement {\n value: any;\n refresh(): void;\n}\nexport interface SwcAppInterface extends HTMLElement {\n simpleApplication?: SimpleApplication;\n router?: Router;\n connect(config?: SwcAttributeConfigType): Promise<void>;\n routing(path: string): Promise<void>;\n reload(): void;\n back(): void;\n forward(): void;\n publishMessage(message: SwcAppMessage): void;\n}\n"],
4
+ "sourcesContent": ["import { SimpleApplication } from '@dooboostore/simple-boot/SimpleApplication';\nimport { Router } from '@dooboostore/core-web';\nimport {SwcAttributeConfigType, SwcConfigType} from \"./SwcAppEngine\";\n\nexport enum InjectSituationType {\n HOST_SET = 'SIMPLE_WEB_COMPONENT://HOSTSET',\n APP_HOST = 'SIMPLE_WEB_COMPONENT://APPHOST',\n APP_HOSTS = 'SIMPLE_WEB_COMPONENT://APPHOSTS',\n HOST = 'SIMPLE_WEB_COMPONENT://HOST',\n PARENT_HOST = 'SIMPLE_WEB_COMPONENT://PARENTHOST',\n HOSTS = 'SIMPLE_WEB_COMPONENT://HOSTS',\n FIRST_HOST = 'SIMPLE_WEB_COMPONENT://FIRSTHOST',\n LAST_HOST = 'SIMPLE_WEB_COMPONENT://LASTHOST',\n FIRST_APP_HOST = 'SIMPLE_WEB_COMPONENT://FIRSTAPPHOST',\n LAST_APP_HOST = 'SIMPLE_WEB_COMPONENT://LASTAPPHOST'\n}\n\nexport type SwcRootType = 'light' | 'shadow' | 'all' | 'auto';\n\nexport type SpecialSelector = '$this' | '$window' | '$document' | '$host' | '$appHost' | '$firstHost' | '$lastHost' | '$firstAppHost' | '$lastAppHost' | '$hosts' | '$appHosts';\n\nexport type SwcQueryOptions = { root?: SwcRootType };\n\nexport type HelperSet = {\n $d: Document;\n $w: Window;\n $q: (selector: string, root?: Element | Document | ShadowRoot) => HTMLElement | null;\n $qa: (selector: string, root?: Element | Document | ShadowRoot) => HTMLElement[];\n $qi: (id: string, root?: Document | ShadowRoot) => HTMLElement | null;\n};\n\nexport type HostSet = {\n $host: HTMLElement | null; // Nearest parent SWC component\n $parentHost: HTMLElement | null; // Grandparent SWC ancestor\n $hosts: HTMLElement[]; // All SWC ancestors [root, ..., parent]\n $firstHost: HTMLElement | null; // Top-most SWC ancestor\n $lastHost: HTMLElement | null; // Same as $host\n // $templateHost: HTMLTemplateElement | null | undefined;\n $appHost: SwcAppInterface | null;\n $appHosts: SwcAppInterface[];\n $firstAppHost: SwcAppInterface | null;\n $lastAppHost: SwcAppInterface | null;\n};\n\nexport type HelperHostSet = HelperSet & HostSet & {$this: any};\n\nexport type SwcAppMessage<T = any> = {\n publisher?: any;\n data?: T;\n type?: string;\n};\n\nexport interface SwcChooseInterface extends HTMLTemplateElement {\n value: any;\n refresh(a: any): void;\n}\nexport interface SwcIfInterface extends HTMLTemplateElement {\n value: any;\n refresh(): void;\n}\nexport interface SwcAppInterface extends HTMLElement {\n simpleApplication?: SimpleApplication;\n config?: SwcConfigType;\n router?: Router;\n connect(config?: SwcAttributeConfigType): Promise<void>;\n routing(path: string): Promise<void>;\n reload(): void;\n back(): void;\n forward(): void;\n publishMessage(message: SwcAppMessage): void;\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIO,IAAK,sBAAL,kBAAKA,yBAAL;AACL,EAAAA,qBAAA,cAAW;AACX,EAAAA,qBAAA,cAAW;AACX,EAAAA,qBAAA,eAAY;AACZ,EAAAA,qBAAA,UAAO;AACP,EAAAA,qBAAA,iBAAc;AACd,EAAAA,qBAAA,WAAQ;AACR,EAAAA,qBAAA,gBAAa;AACb,EAAAA,qBAAA,eAAY;AACZ,EAAAA,qBAAA,oBAAiB;AACjB,EAAAA,qBAAA,mBAAgB;AAVN,SAAAA;AAAA,GAAA;",
6
6
  "names": ["InjectSituationType"]
7
7
  }
@@ -54,14 +54,17 @@ const commentNode = (comment, doc) => {
54
54
  if (!d) throw new Error("Document is not available");
55
55
  return d.createComment(comment !== void 0 && comment !== null ? String(comment) : "");
56
56
  };
57
- const createElement = (tagName, options) => {
58
- const d = options?.doc || (typeof document !== "undefined" ? document : void 0);
59
- if (!d) throw new Error("Document is not available");
60
- const el = d.createElement(tagName);
61
- if (options?.html) el.innerHTML = options.html;
57
+ const createElement = (documentOrWindow, tagName, options) => {
58
+ const doc = "document" in documentOrWindow ? documentOrWindow.document : documentOrWindow;
59
+ if (!doc) throw new Error("Document is not available");
60
+ const el = doc.createElement(tagName);
61
+ if (options?.innerHtml) el.innerHTML = options.innerHtml;
62
62
  if (options?.attrs) {
63
63
  Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));
64
64
  }
65
+ if (options?.property) {
66
+ Object.entries(options.property).forEach(([k, v]) => el[k] = v);
67
+ }
65
68
  return el;
66
69
  };
67
70
  const htmlDivElement = (html, options) => {
@@ -315,7 +318,7 @@ var SwcUtils;
315
318
  $hosts,
316
319
  $firstHost,
317
320
  $lastHost: $host,
318
- $templateHost: el.__swc_template_host,
321
+ // $templateHost: (el as any).__swc_template_host,
319
322
  $appHost,
320
323
  $appHosts,
321
324
  $firstAppHost,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/utils/Utils.ts"],
4
- "sourcesContent": ["import { SwcAppInterface, HostSet, HelperSet, HelperHostSet } from '../types';\nimport {getElementConfig} from \"../decorators\";\nimport { getExpression, ExpressionResult, GetExpressionConfig, GetExpressionResult } from '@dooboostore/core';\nimport {Router} from \"@dooboostore/core-web\";\n\nexport const SWC_NOT_FOUND = Symbol.for('simple-web-component:not-found');\n\n// DOM Creation Utilities\nexport const htmlFragment = (html: string, doc?: Document): DocumentFragment => {\n const d = doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const template = d.createElement('template');\n template.innerHTML = html.trim();\n return template.content;\n};\n\nexport const textNode = (text: string | any, doc?: Document): Text => {\n const d = doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n return d.createTextNode(text !== undefined && text !== null ? String(text) : '');\n};\n\nexport const commentNode = (comment: string | any, doc?: Document): Comment => {\n const d = doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n return d.createComment(comment !== undefined && comment !== null ? String(comment) : '');\n};\n\nexport const createElement = <T extends HTMLElement>(\n tagName: string,\n options?: { html?: string; attrs?: Record<string, any>; doc?: Document }\n): T => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement(tagName) as T;\n if (options?.html) el.innerHTML = options.html;\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\n// Element factory functions\nexport const htmlDivElement = (html: string, options?: { doc?: Document; attrs?: Record<string, any> }): HTMLDivElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('div') as HTMLDivElement;\n el.innerHTML = html.trim();\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlSpanElement = (html: string, options?: { doc?: Document; attrs?: Record<string, any> }): HTMLSpanElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('span') as HTMLSpanElement;\n el.innerHTML = html.trim();\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlButtonElement = (html: string, options?: { doc?: Document; attrs?: Record<string, any> }): HTMLButtonElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('button') as HTMLButtonElement;\n el.innerHTML = html.trim();\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlUlElement = (options?: { doc?: Document; attrs?: Record<string, any> }): HTMLUListElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('ul') as HTMLUListElement;\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlLiElement = (html: string, options?: { doc?: Document; attrs?: Record<string, any> }): HTMLLIElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('li') as HTMLLIElement;\n el.innerHTML = html.trim();\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlAElement = (html: string, options?: { href?: string; doc?: Document; attrs?: Record<string, any> }): HTMLAnchorElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('a') as HTMLAnchorElement;\n el.innerHTML = html.trim();\n if (options?.href) el.href = options.href;\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlPElement = (html: string, options?: { doc?: Document; attrs?: Record<string, any> }): HTMLParagraphElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('p') as HTMLParagraphElement;\n el.innerHTML = html.trim();\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlHeadingElement = (level: 1 | 2 | 3 | 4 | 5 | 6, html: string, options?: { doc?: Document; attrs?: Record<string, any> }): HTMLHeadingElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement(`h${level}`) as HTMLHeadingElement;\n el.innerHTML = html.trim();\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlSectionElement = (options?: { doc?: Document; attrs?: Record<string, any> }): HTMLElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('section');\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlArticleElement = (options?: { doc?: Document; attrs?: Record<string, any> }): HTMLElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('article');\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport namespace SwcUtils {\n\n\n export const getParentContainer = (e: Node) => {\n return e.parentElement ?? e.getRootNode() as any;\n }\n\n export const parsePathPatternsSetAttributeString = (pathPattern: string[], path: string) => {\n return JSON.stringify(SwcUtils.parsePathPatternsSet(pathPattern, path)).replace(/\"/g, \"'\");\n }\n\n export const parsePathPatternsSet = (pathPattern: string[], urlAndRouter?: string | Router) => {\n // if (!path) {\n // return;\n // }\n urlAndRouter ??= '/'\n const p = typeof urlAndRouter === 'string' ? urlAndRouter : urlAndRouter.value.url;\n const searchParams = new URLSearchParams();\n const qs = p.split('?')[1];\n qs?.split('&').forEach(it => {\n const [k, v] = it.split('=');\n searchParams.set(k,v);\n })\n return {\n path: p,\n searchParams,\n pathData: SwcUtils.parsePathPatterns(pathPattern, p)\n };\n };\n export const parsePathPatterns = (pathPattern: string[], path: string) => {\n for (const pattern of pathPattern) {\n const data = SwcUtils.parsePathPattern(pattern, path || '/');\n if (data !== null) {\n return data;\n }\n }\n };\n\n export const getHelperSet = (win: Window): HelperSet => {\n const doc: Document = win.document;\n return {\n $d: doc,\n $w: win,\n $q: (sel: string, root?: Element | Document | ShadowRoot) => (root ?? doc).querySelector(sel),\n $qa: (sel: string, root?: Element | Document | ShadowRoot) => Array.from((root ?? doc).querySelectorAll(sel)) as HTMLElement[],\n $qi: (id: string, root?: Document | ShadowRoot) => (root ?? doc).getElementById(id) as HTMLElement\n } as const;\n };\n\n export const getHelperAndHostSet = (win: Window, el: HTMLElement): HelperHostSet => {\n const helperSet = getHelperSet(win);\n const hostSet = getHostSet(el);\n return {\n ...helperSet,\n ...hostSet,\n $this: el,\n };\n };\n\n export const getValueByPath = (obj: any, path: string, rootName: string) => {\n if (!obj || !path) return SWC_NOT_FOUND;\n\n const parts = path.split('.');\n let current = obj;\n\n for (const part of parts) {\n if (current === null || current === undefined) return SWC_NOT_FOUND;\n current = current[part];\n }\n return current;\n };\n\n /**\n * Finds the nearest logical SWC host for an element.\n * Checks __swc_host property first, then climbs the DOM tree.\n */\n export const findNearestSwcHostIncludingSelf = (el: HTMLElement | Node): HTMLElement | undefined => {\n const el1 = el as any;\n if (el1.__swc_host) return el1.__swc_host;\n\n let current: any = el.parentElement || (el.getRootNode?.() as any)?.host;\n const doc = el.ownerDocument;\n const win = doc?.defaultView || ((typeof window !== 'undefined' ? window : undefined) as any);\n while (current && current !== doc && current !== win) {\n if (current.__swc_host) return current.__swc_host;\n if (getElementConfig(current)) return current as HTMLElement;\n current = current.parentElement || (current.getRootNode?.() as any)?.host;\n }\n return undefined;\n };\n\n /**\n * Returns all SWC ancestors (excluding self) in [root, ..., parent] order.\n */\n export const findAllSwcHostsIncludingSelf = (el: HTMLElement | Node): HTMLElement[] => {\n const hosts: HTMLElement[] = [];\n let current = findNearestSwcHostIncludingSelf(el);\n while (current) {\n hosts.push(current);\n // To find the next ancestor, we must start searching from the PARENT of the found host\n current = findNearestSwcHostIncludingSelf(current);\n }\n return hosts.reverse();\n };\n\n export const getHosts = (el: HTMLElement): HTMLElement[] => {\n const ancestors = findAllSwcHostsIncludingSelf(el);\n if (getElementConfig(el)) return [...ancestors, el];\n return ancestors;\n };\n\n export const getHost = (el: HTMLElement): HTMLElement | undefined => {\n if (getElementConfig(el)) return el;\n return findNearestSwcHostIncludingSelf(el);\n };\n\n export const getAppHosts = (el: HTMLElement): SwcAppInterface[] => {\n // const hosts = getHosts(el);\n // return hosts.filter(host => host.tagName.toLowerCase() === 'swc-app' || host.getAttribute('is')?.startsWith('swc-app-')) as SwcAppInterface[];\n const hosts = SwcUtils.findAllAppHostsIncludingSelfDirect(el);\n return hosts;\n };\n\n export const getAppHost = (el: HTMLElement): SwcAppInterface | undefined => {\n const appHosts = getAppHosts(el);\n const appHostsWithoutSelf = appHosts.filter(h => h !== el);\n return appHostsWithoutSelf.length > 0 ? appHostsWithoutSelf[appHostsWithoutSelf.length - 1] : undefined;\n };\n\n /**\n * Find the closest app host by traversing DOM tree directly, including the element itself.\n * Only checks tagName and is attribute - no SWC host discovery.\n * Useful for Safari polyfill compatibility where is=\"\" elements upgrade in child-first order.\n */\n export const findAppHostIncludingSelfDirect = (el: HTMLElement): SwcAppInterface | null => {\n const appHosts = findAllAppHostsIncludingSelfDirect(el);\n return appHosts.length > 0 ? appHosts[appHosts.length - 1] : null;\n };\n\n /**\n * Find all app hosts by traversing DOM tree directly, including the element itself.\n * Returns array of all app hosts in [root, ..., closest-parent-or-self] order.\n * Only checks tagName and is attribute - no SWC host discovery.\n * Useful for Safari polyfill compatibility where is=\"\" elements upgrade in child-first order.\n */\n export const findAllAppHostsIncludingSelfDirect = (el: HTMLElement): SwcAppInterface[] => {\n const appHosts: SwcAppInterface[] = [];\n\n const w = el.ownerDocument?.defaultView || ((typeof window !== 'undefined' ? window : undefined) as any);\n\n // Guard against SSR environment where window might be undefined\n if (!w) {\n return appHosts;\n }\n\n // console.log('------?',w.ShadowRoot);\n // el \uC790\uCCB4\uBD80\uD130 \uC2DC\uC791 (el\uC774 app host\uC77C \uC218\uB3C4 \uC788\uC74C)\n let current: HTMLElement | null = el;\n\n while (current) {\n const isAppHost =\n current.tagName.toLowerCase() === 'swc-app' ||\n current.getAttribute('is')?.startsWith('swc-app-');\n if (isAppHost) {\n appHosts.push(current as SwcAppInterface);\n }\n\n // \uB2E4\uC74C \uBD80\uBAA8 \uCC3E\uAE30\n if (current.parentElement) {\n // Light DOM: \uC815\uC0C1\uC801\uC778 \uBD80\uBAA8 \uC694\uC18C\n current = current.parentElement;\n } else {\n // parentElement\uAC00 \uC5C6\uC74C = Shadow root\uC758 \uC9C1\uC811 \uC790\uC2DD\uC77C \uC218 \uC788\uC74C\n const root = current.getRootNode();\n if (w.ShadowRoot && root instanceof w.ShadowRoot) {\n // Shadow host\uB85C \uC62C\uB77C\uAC00\uAE30\n current = (root as ShadowRoot).host as HTMLElement;\n } else {\n // Document root \uB3C4\uB2EC\n break;\n }\n }\n }\n return appHosts.reverse(); // [root, ..., closest-parent-or-self]\n };\n\n export const getHostSet = (el: HTMLElement): HostSet => {\n const ancestors = findAllSwcHostsIncludingSelf(el); // [root, ..., parent]\n \n const $host = ancestors.length > 0 ? ancestors[ancestors.length - 1] : null;\n const $parentHost = ancestors.length > 1 ? ancestors[ancestors.length - 2] : null;\n const $hosts = ancestors;\n const $firstHost = ancestors.length > 0 ? ancestors[0] : null;\n\n // Collect loop contexts\n const loopContext: Record<string, any> = {};\n let curr: any = el;\n const rootEl = el.ownerDocument?.documentElement;\n while (curr && curr !== rootEl) {\n if (curr.__swc_loop_context) {\n Object.assign(loopContext, curr.__swc_loop_context);\n }\n curr = curr.parentElement || (curr.getRootNode() as any).host;\n }\n\n const $appHosts = SwcUtils.findAllAppHostsIncludingSelfDirect(el);\n const $appHost = $appHosts.length > 0 ? ($appHosts[$appHosts.length - 1] === el ? ($appHosts.length > 1 ? $appHosts[$appHosts.length - 2] : null) : $appHosts[$appHosts.length - 1]) : null;\n const $firstAppHost = $appHosts.length > 0 ? $appHosts[0] : null;\n\n return {\n $host,\n $parentHost,\n $hosts,\n $firstHost,\n $lastHost: $host,\n $templateHost: (el as any).__swc_template_host,\n $appHost,\n $appHosts,\n $firstAppHost,\n $lastAppHost: $appHost,\n ...loopContext\n } as any;\n };\n\n export const parsePathPattern = (pattern: string | undefined, currentPath: string): { [key: string]: string } | null => {\n // pattern\uC774 null/undefined\uBA74 \uC640\uC77C\uB4DC\uCE74\uB4DC (\uBAA8\uB4E0 \uACBD\uB85C \uB9E4\uCE6D)\n if (pattern === null || pattern === undefined) return {};\n \n // \uACF5\uBC31\uB9CC \uC788\uB294 \uD328\uD134\uB3C4 \uC640\uC77C\uB4DC\uCE74\uB4DC\n const trimmedPattern = pattern.trim();\n if (trimmedPattern === '' && pattern !== '') return {}; // \uACF5\uBC31 \uBB38\uC790\uB9CC \uC788\uB294 \uACBD\uC6B0\n \n // \uD328\uD134\uC744 \uC815\uADDC\uC2DD\uC73C\uB85C \uBCC0\uD658\n // \uC9C0\uC6D0 \uD615\uC2DD:\n // {id} \u2192 ([^/]+) \uAE30\uBCF8 (/ \uC81C\uC678\uD55C \uBAA8\uB4E0 \uBB38\uC790)\n // {tail:.*} \u2192 (.*) \uC815\uADDC\uD45C\uD604\uC2DD \uC9C1\uC811 \uC9C0\uC815\n // {slug:[a-z0-9-]+} \u2192 ([a-z0-9-]+)\n const paramNames: string[] = [];\n const regexPattern = trimmedPattern.replace(/{(\\w+)(?::(.+?))?}/g, (match, paramName, customRegex) => {\n paramNames.push(paramName);\n // customRegex\uAC00 \uC788\uC73C\uBA74 \uC0AC\uC6A9, \uC5C6\uC73C\uBA74 \uAE30\uBCF8\uAC12 ([^/]+)\n return `(${customRegex || '[^/]+'})`;\n });\n \n const regex = new RegExp(`^${regexPattern}$`);\n const match = currentPath.match(regex);\n \n if (!match) return null;\n \n const result: { [key: string]: string } = {};\n paramNames.forEach((name, index) => {\n result[name] = match[index + 1];\n });\n \n return result;\n };\n\n\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,wBAA+B;AAIxB,MAAM,gBAAgB,OAAO,IAAI,gCAAgC;AAGjE,MAAM,eAAe,CAAC,MAAc,QAAqC;AAC9E,QAAM,IAAI,QAAQ,OAAO,aAAa,cAAc,WAAW;AAC/D,MAAI,CAAC,EAAG,OAAM,IAAI,MAAM,2BAA2B;AACnD,QAAM,WAAW,EAAE,cAAc,UAAU;AAC3C,WAAS,YAAY,KAAK,KAAK;AAC/B,SAAO,SAAS;AAClB;AAEO,MAAM,WAAW,CAAC,MAAoB,QAAyB;AACpE,QAAM,IAAI,QAAQ,OAAO,aAAa,cAAc,WAAW;AAC/D,MAAI,CAAC,EAAG,OAAM,IAAI,MAAM,2BAA2B;AACnD,SAAO,EAAE,eAAe,SAAS,UAAa,SAAS,OAAO,OAAO,IAAI,IAAI,EAAE;AACjF;AAEO,MAAM,cAAc,CAAC,SAAuB,QAA4B;AAC7E,QAAM,IAAI,QAAQ,OAAO,aAAa,cAAc,WAAW;AAC/D,MAAI,C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A,UAAS,mCAAmC,EAAE;AAChE,UAAM,WAAW,UAAU,SAAS,IAAK,UAAU,UAAU,SAAS,CAAC,MAAM,KAAM,UAAU,SAAS,IAAI,UAAU,UAAU,SAAS,CAAC,IAAI,OAAQ,UAAU,UAAU,SAAS,CAAC,IAAK;AACvL,UAAM,gBAAgB,UAAU,SAAS,IAAI,UAAU,CAAC,IAAI;AAE5D,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,WAAW;AAAA,MACX,eAAgB,GAAW;AAAA,MAC3B;AAAA,MACA;AAAA,MACA;AAAA,MACA,cAAc;AAAA,MACd,GAAG;AAAA,IACL;AAAA,EACF;AAEO,EAAMA,UAAA,mBAAmB,CAAC,SAA6B,gBAA0D;AAEtH,QAAI,YAAY,QAAQ,YAAY,OAAW,QAAO,CAAC;AAGvD,UAAM,iBAAiB,QAAQ,KAAK;AACpC,QAAI,mBAAmB,MAAM,YAAY,GAAI,QAAO,CAAC;AAOrD,UAAM,aAAuB,CAAC;AAC9B,UAAM,eAAe,eAAe,QAAQ,uBAAuB,CAACC,QAAO,WAAW,gBAAgB;AACpG,iBAAW,KAAK,SAAS;AAEzB,aAAO,IAAI,eAAe,OAAO;AAAA,IACnC,CAAC;AAED,UAAM,QAAQ,IAAI,OAAO,IAAI,YAAY,GAAG;AAC5C,UAAM,QAAQ,YAAY,MAAM,KAAK;AAErC,QAAI,CAAC,MAAO,QAAO;AAEnB,UAAM,SAAoC,CAAC;AAC3C,eAAW,QAAQ,CAAC,MAAM,UAAU;AAClC,aAAO,IAAI,IAAI,MAAM,QAAQ,CAAC;AAAA,IAChC,CAAC;AAED,WAAO;AAAA,EACT;AAAA,GA/Pe;AAkQhB;",
4
+ "sourcesContent": ["import { SwcAppInterface, HostSet, HelperSet, HelperHostSet } from '../types';\nimport {getElementConfig} from \"../decorators\";\nimport { getExpression, ExpressionResult, GetExpressionConfig, GetExpressionResult } from '@dooboostore/core';\nimport {Router} from \"@dooboostore/core-web\";\n\nexport const SWC_NOT_FOUND = Symbol.for('simple-web-component:not-found');\n\n// DOM Creation Utilities\nexport const htmlFragment = (html: string, doc?: Document): DocumentFragment => {\n const d = doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const template = d.createElement('template');\n template.innerHTML = html.trim();\n return template.content;\n};\n\nexport const textNode = (text: string | any, doc?: Document): Text => {\n const d = doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n return d.createTextNode(text !== undefined && text !== null ? String(text) : '');\n};\n\nexport const commentNode = (comment: string | any, doc?: Document): Comment => {\n const d = doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n return d.createComment(comment !== undefined && comment !== null ? String(comment) : '');\n};\n\nexport type CreateElementConfig = { innerHtml?: string; property?: Record<string, any>, attrs?: Record<string, string>; };\nexport const createElement = <T extends HTMLElement>(\n documentOrWindow: Document | Window,\n tagName: string,\n options?: CreateElementConfig\n): T => {\n const doc = 'document' in documentOrWindow ? documentOrWindow.document : documentOrWindow;\n if (!doc) throw new Error('Document is not available');\n const el = doc.createElement(tagName) as T;\n if (options?.innerHtml) el.innerHTML = options.innerHtml;\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n if (options?.property) {\n Object.entries(options.property).forEach(([k, v]) => el[k] =v);\n }\n return el;\n};\n\n// Element factory functions\nexport const htmlDivElement = (html: string, options?: { doc?: Document; attrs?: Record<string, any> }): HTMLDivElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('div') as HTMLDivElement;\n el.innerHTML = html.trim();\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlSpanElement = (html: string, options?: { doc?: Document; attrs?: Record<string, any> }): HTMLSpanElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('span') as HTMLSpanElement;\n el.innerHTML = html.trim();\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlButtonElement = (html: string, options?: { doc?: Document; attrs?: Record<string, any> }): HTMLButtonElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('button') as HTMLButtonElement;\n el.innerHTML = html.trim();\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlUlElement = (options?: { doc?: Document; attrs?: Record<string, any> }): HTMLUListElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('ul') as HTMLUListElement;\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlLiElement = (html: string, options?: { doc?: Document; attrs?: Record<string, any> }): HTMLLIElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('li') as HTMLLIElement;\n el.innerHTML = html.trim();\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlAElement = (html: string, options?: { href?: string; doc?: Document; attrs?: Record<string, any> }): HTMLAnchorElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('a') as HTMLAnchorElement;\n el.innerHTML = html.trim();\n if (options?.href) el.href = options.href;\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlPElement = (html: string, options?: { doc?: Document; attrs?: Record<string, any> }): HTMLParagraphElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('p') as HTMLParagraphElement;\n el.innerHTML = html.trim();\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlHeadingElement = (level: 1 | 2 | 3 | 4 | 5 | 6, html: string, options?: { doc?: Document; attrs?: Record<string, any> }): HTMLHeadingElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement(`h${level}`) as HTMLHeadingElement;\n el.innerHTML = html.trim();\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlSectionElement = (options?: { doc?: Document; attrs?: Record<string, any> }): HTMLElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('section');\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlArticleElement = (options?: { doc?: Document; attrs?: Record<string, any> }): HTMLElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('article');\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport namespace SwcUtils {\n\n\n export const getParentContainer = (e: Node) => {\n return e.parentElement ?? e.getRootNode() as any;\n }\n\n export const parsePathPatternsSetAttributeString = (pathPattern: string[], path: string) => {\n return JSON.stringify(SwcUtils.parsePathPatternsSet(pathPattern, path)).replace(/\"/g, \"'\");\n }\n\n export const parsePathPatternsSet = (pathPattern: string[], urlAndRouter?: string | Router) => {\n // if (!path) {\n // return;\n // }\n urlAndRouter ??= '/'\n const p = typeof urlAndRouter === 'string' ? urlAndRouter : urlAndRouter.value.url;\n const searchParams = new URLSearchParams();\n const qs = p.split('?')[1];\n qs?.split('&').forEach(it => {\n const [k, v] = it.split('=');\n searchParams.set(k,v);\n })\n return {\n path: p,\n searchParams,\n pathData: SwcUtils.parsePathPatterns(pathPattern, p)\n };\n };\n export const parsePathPatterns = (pathPattern: string[], path: string) => {\n for (const pattern of pathPattern) {\n const data = SwcUtils.parsePathPattern(pattern, path || '/');\n if (data !== null) {\n return data;\n }\n }\n };\n\n export const getHelperSet = (win: Window): HelperSet => {\n const doc: Document = win.document;\n return {\n $d: doc,\n $w: win,\n $q: (sel: string, root?: Element | Document | ShadowRoot) => (root ?? doc).querySelector(sel),\n $qa: (sel: string, root?: Element | Document | ShadowRoot) => Array.from((root ?? doc).querySelectorAll(sel)) as HTMLElement[],\n $qi: (id: string, root?: Document | ShadowRoot) => (root ?? doc).getElementById(id) as HTMLElement\n } as const;\n };\n\n export const getHelperAndHostSet = (win: Window, el: HTMLElement): HelperHostSet => {\n const helperSet = getHelperSet(win);\n const hostSet = getHostSet(el);\n return {\n ...helperSet,\n ...hostSet,\n $this: el,\n };\n };\n\n export const getValueByPath = (obj: any, path: string, rootName: string) => {\n if (!obj || !path) return SWC_NOT_FOUND;\n\n const parts = path.split('.');\n let current = obj;\n\n for (const part of parts) {\n if (current === null || current === undefined) return SWC_NOT_FOUND;\n current = current[part];\n }\n return current;\n };\n\n /**\n * Finds the nearest logical SWC host for an element.\n * Checks __swc_host property first, then climbs the DOM tree.\n */\n export const findNearestSwcHostIncludingSelf = (el: HTMLElement | Node): HTMLElement | undefined => {\n const el1 = el as any;\n if (el1.__swc_host) return el1.__swc_host;\n\n let current: any = el.parentElement || (el.getRootNode?.() as any)?.host;\n const doc = el.ownerDocument;\n const win = doc?.defaultView || ((typeof window !== 'undefined' ? window : undefined) as any);\n while (current && current !== doc && current !== win) {\n if (current.__swc_host) return current.__swc_host;\n if (getElementConfig(current)) return current as HTMLElement;\n current = current.parentElement || (current.getRootNode?.() as any)?.host;\n }\n return undefined;\n };\n\n /**\n * Returns all SWC ancestors (excluding self) in [root, ..., parent] order.\n */\n export const findAllSwcHostsIncludingSelf = (el: HTMLElement | Node): HTMLElement[] => {\n const hosts: HTMLElement[] = [];\n let current = findNearestSwcHostIncludingSelf(el);\n while (current) {\n hosts.push(current);\n // To find the next ancestor, we must start searching from the PARENT of the found host\n current = findNearestSwcHostIncludingSelf(current);\n }\n return hosts.reverse();\n };\n\n export const getHosts = (el: HTMLElement): HTMLElement[] => {\n const ancestors = findAllSwcHostsIncludingSelf(el);\n if (getElementConfig(el)) return [...ancestors, el];\n return ancestors;\n };\n\n export const getHost = (el: HTMLElement): HTMLElement | undefined => {\n if (getElementConfig(el)) return el;\n return findNearestSwcHostIncludingSelf(el);\n };\n\n export const getAppHosts = (el: HTMLElement): SwcAppInterface[] => {\n // const hosts = getHosts(el);\n // return hosts.filter(host => host.tagName.toLowerCase() === 'swc-app' || host.getAttribute('is')?.startsWith('swc-app-')) as SwcAppInterface[];\n const hosts = SwcUtils.findAllAppHostsIncludingSelfDirect(el);\n return hosts;\n };\n\n export const getAppHost = (el: HTMLElement): SwcAppInterface | undefined => {\n const appHosts = getAppHosts(el);\n const appHostsWithoutSelf = appHosts.filter(h => h !== el);\n return appHostsWithoutSelf.length > 0 ? appHostsWithoutSelf[appHostsWithoutSelf.length - 1] : undefined;\n };\n\n /**\n * Find the closest app host by traversing DOM tree directly, including the element itself.\n * Only checks tagName and is attribute - no SWC host discovery.\n * Useful for Safari polyfill compatibility where is=\"\" elements upgrade in child-first order.\n */\n export const findAppHostIncludingSelfDirect = (el: HTMLElement): SwcAppInterface | null => {\n const appHosts = findAllAppHostsIncludingSelfDirect(el);\n return appHosts.length > 0 ? appHosts[appHosts.length - 1] : null;\n };\n\n /**\n * Find all app hosts by traversing DOM tree directly, including the element itself.\n * Returns array of all app hosts in [root, ..., closest-parent-or-self] order.\n * Only checks tagName and is attribute - no SWC host discovery.\n * Useful for Safari polyfill compatibility where is=\"\" elements upgrade in child-first order.\n */\n export const findAllAppHostsIncludingSelfDirect = (el: HTMLElement): SwcAppInterface[] => {\n const appHosts: SwcAppInterface[] = [];\n\n const w = el.ownerDocument?.defaultView || ((typeof window !== 'undefined' ? window : undefined) as any);\n\n // Guard against SSR environment where window might be undefined\n if (!w) {\n return appHosts;\n }\n\n // console.log('------?',w.ShadowRoot);\n // el \uC790\uCCB4\uBD80\uD130 \uC2DC\uC791 (el\uC774 app host\uC77C \uC218\uB3C4 \uC788\uC74C)\n let current: HTMLElement | null = el;\n\n while (current) {\n const isAppHost =\n current.tagName.toLowerCase() === 'swc-app' ||\n current.getAttribute('is')?.startsWith('swc-app-');\n if (isAppHost) {\n appHosts.push(current as SwcAppInterface);\n }\n\n // \uB2E4\uC74C \uBD80\uBAA8 \uCC3E\uAE30\n if (current.parentElement) {\n // Light DOM: \uC815\uC0C1\uC801\uC778 \uBD80\uBAA8 \uC694\uC18C\n current = current.parentElement;\n } else {\n // parentElement\uAC00 \uC5C6\uC74C = Shadow root\uC758 \uC9C1\uC811 \uC790\uC2DD\uC77C \uC218 \uC788\uC74C\n const root = current.getRootNode();\n if (w.ShadowRoot && root instanceof w.ShadowRoot) {\n // Shadow host\uB85C \uC62C\uB77C\uAC00\uAE30\n current = (root as ShadowRoot).host as HTMLElement;\n } else {\n // Document root \uB3C4\uB2EC\n break;\n }\n }\n }\n return appHosts.reverse(); // [root, ..., closest-parent-or-self]\n };\n\n export const getHostSet = (el: HTMLElement): HostSet => {\n const ancestors = findAllSwcHostsIncludingSelf(el); // [root, ..., parent]\n \n const $host = ancestors.length > 0 ? ancestors[ancestors.length - 1] : null;\n const $parentHost = ancestors.length > 1 ? ancestors[ancestors.length - 2] : null;\n const $hosts = ancestors;\n const $firstHost = ancestors.length > 0 ? ancestors[0] : null;\n\n // Collect loop contexts\n const loopContext: Record<string, any> = {};\n let curr: any = el;\n const rootEl = el.ownerDocument?.documentElement;\n while (curr && curr !== rootEl) {\n if (curr.__swc_loop_context) {\n Object.assign(loopContext, curr.__swc_loop_context);\n }\n curr = curr.parentElement || (curr.getRootNode() as any).host;\n }\n\n const $appHosts = SwcUtils.findAllAppHostsIncludingSelfDirect(el);\n const $appHost = $appHosts.length > 0 ? ($appHosts[$appHosts.length - 1] === el ? ($appHosts.length > 1 ? $appHosts[$appHosts.length - 2] : null) : $appHosts[$appHosts.length - 1]) : null;\n const $firstAppHost = $appHosts.length > 0 ? $appHosts[0] : null;\n\n return {\n $host,\n $parentHost,\n $hosts,\n $firstHost,\n $lastHost: $host,\n // $templateHost: (el as any).__swc_template_host,\n $appHost,\n $appHosts,\n $firstAppHost,\n $lastAppHost: $appHost,\n ...loopContext\n } as any;\n };\n\n export const parsePathPattern = (pattern: string | undefined, currentPath: string): { [key: string]: string } | null => {\n // pattern\uC774 null/undefined\uBA74 \uC640\uC77C\uB4DC\uCE74\uB4DC (\uBAA8\uB4E0 \uACBD\uB85C \uB9E4\uCE6D)\n if (pattern === null || pattern === undefined) return {};\n \n // \uACF5\uBC31\uB9CC \uC788\uB294 \uD328\uD134\uB3C4 \uC640\uC77C\uB4DC\uCE74\uB4DC\n const trimmedPattern = pattern.trim();\n if (trimmedPattern === '' && pattern !== '') return {}; // \uACF5\uBC31 \uBB38\uC790\uB9CC \uC788\uB294 \uACBD\uC6B0\n \n // \uD328\uD134\uC744 \uC815\uADDC\uC2DD\uC73C\uB85C \uBCC0\uD658\n // \uC9C0\uC6D0 \uD615\uC2DD:\n // {id} \u2192 ([^/]+) \uAE30\uBCF8 (/ \uC81C\uC678\uD55C \uBAA8\uB4E0 \uBB38\uC790)\n // {tail:.*} \u2192 (.*) \uC815\uADDC\uD45C\uD604\uC2DD \uC9C1\uC811 \uC9C0\uC815\n // {slug:[a-z0-9-]+} \u2192 ([a-z0-9-]+)\n const paramNames: string[] = [];\n const regexPattern = trimmedPattern.replace(/{(\\w+)(?::(.+?))?}/g, (match, paramName, customRegex) => {\n paramNames.push(paramName);\n // customRegex\uAC00 \uC788\uC73C\uBA74 \uC0AC\uC6A9, \uC5C6\uC73C\uBA74 \uAE30\uBCF8\uAC12 ([^/]+)\n return `(${customRegex || '[^/]+'})`;\n });\n \n const regex = new RegExp(`^${regexPattern}$`);\n const match = currentPath.match(regex);\n \n if (!match) return null;\n \n const result: { [key: string]: string } = {};\n paramNames.forEach((name, index) => {\n result[name] = match[index + 1];\n });\n \n return result;\n };\n\n\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,wBAA+B;AAIxB,MAAM,gBAAgB,OAAO,IAAI,gCAAgC;AAGjE,MAAM,eAAe,CAAC,MAAc,QAAqC;AAC9E,QAAM,IAAI,QAAQ,OAAO,aAAa,cAAc,WAAW;AAC/D,MAAI,CAAC,EAAG,OAAM,IAAI,MAAM,2BAA2B;AACnD,QAAM,WAAW,EAAE,cAAc,UAAU;AAC3C,WAAS,YAAY,KAAK,KAAK;AAC/B,SAAO,SAAS;AAClB;AAEO,MAAM,WAAW,CAAC,MAAoB,QAAyB;AACpE,QAAM,IAAI,QAAQ,OAAO,aAAa,cAAc,WAAW;AAC/D,MAAI,CAAC,EAAG,OAAM,IAAI,MAAM,2BAA2B;AACnD,SAAO,EAAE,eAAe,SAAS,UAAa,SAAS,OAAO,OAAO,IAAI,IAAI,EAAE;AACjF;AAEO,MAAM,cAAc,CAAC,SAAuB,QAA4B;AAC7E,QAAM,IAAI,QAAQ,OAAO,aAAa,cAAc,WAAW;AAC/D,MAAI,CAAC,EAAG,OAAM,IAAI,MAAM,2BAA2B;AACnD,SAAO,EAAE,cAAc,YAAY,UAAa,YAAY,OAAO,OAAO,OAAO,IAAI,EAAE;AACzF;AAGO,MAAM,gBAAgB,CAC3B,kBACA,SACA,YACM;AACN,QAAM,MAAM,cAAc,mBAAmB,iBAAiB,WAAW;AACzE,MAAI,CAAC,IAAK,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,UAAU,SAAS,IAAI,UAAU,UAAU,SAAS,CAAC,IAAI,OAAQ,UAAU,UAAU,SAAS,CAAC,IAAK;AACvL,UAAM,gBAAgB,UAAU,SAAS,IAAI,UAAU,CAAC,IAAI;AAE5D,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,WAAW;AAAA;AAAA,MAEX;AAAA,MACA;AAAA,MACA;AAAA,MACA,cAAc;AAAA,MACd,GAAG;AAAA,IACL;AAAA,EACF;AAEO,EAAMA,UAAA,mBAAmB,CAAC,SAA6B,gBAA0D;AAEtH,QAAI,YAAY,QAAQ,YAAY,OAAW,QAAO,CAAC;AAGvD,UAAM,iBAAiB,QAAQ,KAAK;AACpC,QAAI,mBAAmB,MAAM,YAAY,GAAI,QAAO,CAAC;AAOrD,UAAM,aAAuB,CAAC;AAC9B,UAAM,eAAe,eAAe,QAAQ,uBAAuB,CAACC,QAAO,WAAW,gBAAgB;AACpG,iBAAW,KAAK,SAAS;AAEzB,aAAO,IAAI,eAAe,OAAO;AAAA,IACnC,CAAC;AAED,UAAM,QAAQ,IAAI,OAAO,IAAI,YAAY,GAAG;AAC5C,UAAM,QAAQ,YAAY,MAAM,KAAK;AAErC,QAAI,CAAC,MAAO,QAAO;AAEnB,UAAM,SAAoC,CAAC;AAC3C,eAAW,QAAQ,CAAC,MAAM,UAAU;AAClC,aAAO,IAAI,IAAI,MAAM,QAAQ,CAAC;AAAA,IAChC,CAAC;AAED,WAAO;AAAA,EACT;AAAA,GA/Pe;AAkQhB;",
6
6
  "names": ["SwcUtils", "match"]
7
7
  }
@@ -1,10 +1,10 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- import { SimpleApplication } from "@dooboostore/simple-boot/SimpleApplication";
4
+ import { SimpleApplication } from "@dooboostore/simple-boot";
5
5
  import { HashRouter, PathRouter, Router } from "@dooboostore/core-web";
6
- import { ElementRouter } from "../router/ElementRouter.js";
7
- import { SimOption } from "@dooboostore/simple-boot/SimOption";
6
+ import { ElementRouter } from "./router/ElementRouter.js";
7
+ import { SimOption } from "@dooboostore/simple-boot";
8
8
  class SwcAppEngine {
9
9
  constructor(host) {
10
10
  this.host = host;
@@ -39,7 +39,7 @@ class SwcAppEngine {
39
39
  if (this.router) otherInstanceSim.set(Router, this.router);
40
40
  this.simpleApplication.run(otherInstanceSim);
41
41
  if (this._config.onEngineStarted) {
42
- this._config.onEngineStarted(this.simpleApplication, this.host);
42
+ await this._config.onEngineStarted(this.simpleApplication, this.host);
43
43
  }
44
44
  } catch (e) {
45
45
  console.error("[SWC-APP-ENGINE] Init failed:", e, this._config);
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/SwcAppEngine.ts"],
4
+ "sourcesContent": ["import { SimpleApplication } from '@dooboostore/simple-boot';\nimport { HashRouter, PathRouter, Router, RouterEventType } from '@dooboostore/core-web';\nimport { ElementRouter } from './router/ElementRouter';\nimport { SimOption } from '@dooboostore/simple-boot';\nimport { ConstructorType, OptionalType, Subscription } from '@dooboostore/core';\n\nimport { SwcAppInterface } from './types';\nimport { SimConfig } from '@dooboostore/simple-boot';\n\nexport type SwcConfigType = {\n routeType: 'path' | 'hash' | 'element';\n connectMode?: 'direct' | 'swap' | 'clear-swap' | 'hydrate'; // hydrate \uC544\uC9C1 \uAC1C\uBC1C\uC911\n container?: symbol;\n otherInstanceSim?: Map<ConstructorType<any> | Function | SimConfig | symbol, any>;\n path?: string;\n window: Window;\n onEngineStarted?: (sp: SimpleApplication, app: SwcAppInterface) => Promise<void> | void;\n onConnectedChildAfter?: (swcEl: HTMLElement) => void;\n onConnectedChildBefore?: (swcEl: HTMLElement) => void;\n onDisconnectedChildAfter?: (swcEl: HTMLElement) => void;\n onDisconnectedChildBefore?: (swcEl: HTMLElement) => void;\n onConnected?: (app: SwcAppInterface) => void;\n onDisconnected?: (app: SwcAppInterface) => void;\n ssr?: boolean;\n\n onChildrenConnectedDone?: (app: SwcAppInterface) => void;\n // onChildrenSwcAppStartedDone?: (app: SwcAppInterface) => void;\n // childrenSwcAppStartedDoneCheckIntervalTime?: number;\n onChildrenRouteChanged?: (event: RouterEventType, app: SwcAppInterface) => void;\n childrenRouteChangedCheckIntervalTime?: number; // \uC790\uC2DD \uC5F0\uACB0 \uC644\uB8CC \uC774\uBCA4\uD2B8 \uB514\uBC14\uC6B4\uC2A4 \uD0C0\uC784 (ms)\n childrenConnectedDoneCheckIntervalTime?: number;\n};\n\nexport type SwcAttributeConfigType = OptionalType<SwcConfigType, 'routeType' | 'window'>;\n\nexport class SwcAppEngine {\n public simpleApplication?: SimpleApplication;\n public router?: Router;\n private routerSubscription?: Subscription;\n private _config?: SwcConfigType;\n\n constructor(private host: HTMLElement) {}\n\n get config() {\n return this._config;\n }\n\n async connect(config: SwcConfigType) {\n try {\n this._config = config;\n\n // Router Selection\n if (this._config.routeType === 'path') {\n this.router = new PathRouter({ window: this._config.window, firstUrl: this._config.path });\n } else if (this._config.routeType === 'hash') {\n this.router = new HashRouter({ window: this._config.window, firstUrl: this._config.path });\n } else if (this._config.routeType === 'element') {\n this.router = new ElementRouter({ window: this._config.window, firstUrl: this._config.path });\n }\n\n // console.log('vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv', this.router)\n\n // App start\n this.simpleApplication = new SimpleApplication(\n new SimOption({\n excludeProxys: [(this._config.window as any).Node],\n container: this._config.container\n })\n );\n\n const otherInstanceSim = new Map<any, any>();\n this.config?.otherInstanceSim?.forEach((v, k) => {\n otherInstanceSim.set(k, v);\n });\n if (this.router) otherInstanceSim.set(Router, this.router);\n this.simpleApplication.run(otherInstanceSim);\n\n if (this._config.onEngineStarted) {\n await this._config.onEngineStarted(this.simpleApplication, this.host as unknown as SwcAppInterface);\n }\n } catch (e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zD,WAAK,kBAAkB,IAAI,gBAAgB;AAE3C,UAAI,KAAK,QAAQ,iBAAiB;AAChC,cAAM,KAAK,QAAQ,gBAAgB,KAAK,mBAAmB,KAAK,IAAkC;AAAA,MACpG;AAAA,IACF,SAAS,GAAG;AACV,cAAQ,MAAM,iCAAiC,GAAG,KAAK,OAAO;AAAA,IAChE;AAAA,EACF;AAAA,EAEA,aAAa;AACX,SAAK,oBAAoB,YAAY;AAAA,EACvC;AACF;",
6
+ "names": []
7
+ }
@@ -9,8 +9,9 @@ const normalizeNodes = (res, doc) => {
9
9
  return doc.createTextNode(it !== void 0 && it !== null ? String(it) : "");
10
10
  });
11
11
  };
12
- const applyToDom = (targetEl, res, pos, doc) => {
12
+ const applyToDom = (targetEl, res, pos, win) => {
13
13
  if (!targetEl) return;
14
+ const doc = win.document;
14
15
  if (pos === "innerHtml") {
15
16
  targetEl.innerHTML = res !== void 0 && res !== null ? String(res) : "";
16
17
  return;
@@ -21,7 +22,7 @@ const applyToDom = (targetEl, res, pos, doc) => {
21
22
  }
22
23
  return;
23
24
  }
24
- const isShadowRoot = targetEl instanceof ShadowRoot;
25
+ const isShadowRoot = targetEl instanceof win.ShadowRoot;
25
26
  const nodes = normalizeNodes(res, doc);
26
27
  if (pos === "replace") {
27
28
  if (!isShadowRoot) targetEl.replaceWith(...nodes);
@@ -74,7 +75,7 @@ function applyNode(selector, options = { position: "beforeEnd" }) {
74
75
  const runApply = (target, val) => {
75
76
  const pos = options.position || "beforeEnd";
76
77
  if (!options.filter || options.filter(target, val, { currentThis: this, helper: hostSet })) {
77
- applyToDom(target, val, pos, currentDoc);
78
+ applyToDom(target, val, pos, currentWin);
78
79
  }
79
80
  };
80
81
  if (res instanceof Promise) {
@@ -108,34 +109,34 @@ function applyNodeThis(targetOrOptions, propertyKey, descriptor) {
108
109
  const opt = targetOrOptions || {};
109
110
  return applyNode("$this", { position: "beforeEnd", ...opt });
110
111
  }
111
- function applyReplaceChildrenNodeThis(targetOrOptions, propertyKey, descriptor) {
112
+ function applyNodeThisReplaceChildren(targetOrOptions, propertyKey, descriptor) {
112
113
  if (propertyKey !== void 0) return applyNode("$this", { position: "replaceChildren" })(targetOrOptions, propertyKey, descriptor);
113
114
  const opt = targetOrOptions || {};
114
115
  return applyNode("$this", { position: "replaceChildren", ...opt });
115
116
  }
116
- function applyInnerHtmlNodeThis(targetOrOptions, propertyKey, descriptor) {
117
+ function applyThisInnerHtmlNode(targetOrOptions, propertyKey, descriptor) {
117
118
  if (propertyKey !== void 0) return applyNode("$this", { position: "innerHtml" })(targetOrOptions, propertyKey, descriptor);
118
119
  const opt = targetOrOptions || {};
119
120
  return applyNode("$this", { position: "innerHtml", ...opt });
120
121
  }
121
- function applyReplaceChildrenNode(selector, options = {}) {
122
+ function applyNodeReplaceChildren(selector, options = {}) {
122
123
  return applyNode(selector, { ...options, position: "replaceChildren" });
123
124
  }
124
- function applyInnerHtmlNode(selector, options = {}) {
125
+ function applyNodeInnerHtml(selector, options = {}) {
125
126
  return applyNode(selector, { ...options, position: "innerHtml" });
126
127
  }
127
- function applyInnerTextNode(selector, options = {}) {
128
+ function applyNodeInnerText(selector, options = {}) {
128
129
  return applyNode(selector, { ...options, position: "innerText" });
129
130
  }
130
131
  export {
131
132
  APPLY_NODE_METADATA_KEY,
132
- applyInnerHtmlNode,
133
- applyInnerHtmlNodeThis,
134
- applyInnerTextNode,
135
133
  applyNode,
134
+ applyNodeInnerHtml,
135
+ applyNodeInnerText,
136
+ applyNodeReplaceChildren,
136
137
  applyNodeThis,
137
- applyReplaceChildrenNode,
138
- applyReplaceChildrenNodeThis,
138
+ applyNodeThisReplaceChildren,
139
+ applyThisInnerHtmlNode,
139
140
  findAllApplyNodeMetadata
140
141
  };
141
142
  //# sourceMappingURL=applyNode.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/decorators/applyNode.ts"],
4
- "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit, getElementConfig } from './elementDefine';\nimport { HelperHostSet, SwcRootType } from '../types';\nimport { SwcUtils } from \"../utils/Utils\";\n/*\n<!-- beforebegin -->\n<p>\n <!-- afterbegin -->\n foo\n <!-- beforeend -->\n</p>\n<!-- afterend -->\n */\nexport type ApplyNodePosition = 'beforeBegin' | 'afterBegin' | 'beforeEnd' | 'afterEnd' | 'replace' | 'replaceChildren' | 'innerHtml' | 'innerText' | 'remove';\n\nexport interface ApplyNodeOptions {\n position?: ApplyNodePosition;\n root?: SwcRootType;\n /**\n * Filter function to determine whether to perform DOM operation.\n * If it returns false, the operation is skipped.\n */\n filter?: (target: HTMLElement | ShadowRoot, newValue: any, meta:{currentThis: any,helper: HelperHostSet}) => boolean;\n /**\n * Optional loading content to display while an async method is executing.\n */\n loading?: (helper: HelperHostSet) => any;\n}\n\nexport interface ApplyNodeMetadata {\n propertyKey: string | symbol;\n selector: string;\n options: ApplyNodeOptions;\n}\n\nexport const APPLY_NODE_METADATA_KEY = Symbol.for('simple-web-component:apply-node');\n\nconst normalizeNodes = (res: any, doc: Document): Node[] => {\n const items = Array.isArray(res) ? res : [res];\n return items.map(it => {\n if (it instanceof Node) return it;\n return doc.createTextNode(it !== undefined && it !== null ? String(it) : '');\n });\n};\n\nconst applyToDom = (targetEl: any, res: any, pos: ApplyNodePosition, doc: Document) => {\n if (!targetEl) return;\n \n if (pos === 'innerHtml') {\n targetEl.innerHTML = res !== undefined && res !== null ? String(res) : '';\n return;\n }\n \n if (pos === 'innerText') {\n if (targetEl.innerText !== undefined) {\n targetEl.innerText = res !== undefined && res !== null ? String(res) : '';\n }\n return;\n }\n\n const isShadowRoot = targetEl instanceof ShadowRoot;\n const nodes = normalizeNodes(res, doc);\n if (pos === 'replace') {\n if (!isShadowRoot) targetEl.replaceWith(...nodes);\n } else if (pos === 'replaceChildren') {\n targetEl.replaceChildren(...nodes);\n } else {\n if (pos === 'beforeEnd') targetEl.append(...nodes);\n else if (pos === 'afterBegin') targetEl.prepend(...nodes);\n else if (pos === 'beforeBegin' && !isShadowRoot) targetEl.before(...nodes);\n else if (pos === 'afterEnd' && !isShadowRoot) targetEl.after(...nodes);\n }\n};\n\n/**\n * @applyNode decorator to surgically add/replace nodes to a target element.\n */\nexport function applyNode(selector: string, options: ApplyNodeOptions = { position: 'beforeEnd' }): MethodDecorator {\n return (targetObj: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = targetObj.constructor;\n let metaList = ReflectUtils.getOwnMetadata(APPLY_NODE_METADATA_KEY, constructor) as Map<string | symbol, ApplyNodeMetadata>;\n if (!metaList) {\n metaList = new Map<string | symbol, ApplyNodeMetadata>();\n ReflectUtils.defineMetadata(APPLY_NODE_METADATA_KEY, metaList, constructor);\n }\n metaList.set(propertyKey, { propertyKey, selector, options });\n\n const original = descriptor.value;\n descriptor.value = function (...args: any[]) {\n ensureInit(this);\n \n const conf = getElementConfig(this);\n const currentWin = (this as any)._resolveWindow?.(conf) || ((typeof window !== 'undefined' ? window : undefined) as Window);\n const currentDoc = currentWin.document;\n const hostSet = SwcUtils.getHelperAndHostSet(currentWin, this);\n \n const getTarget = () => {\n const r = options.root || 'auto';\n const applyRoot = (t: any) => {\n if (!t) return t;\n if (r === 'auto') return t.shadowRoot || t;\n if (r === 'shadow') return t.shadowRoot;\n if (r === 'light') return t;\n if (r === 'all') return t.shadowRoot || t;\n return t;\n };\n\n if (selector === '$this') return applyRoot(this);\n if (selector === '$host') return applyRoot(hostSet.$host);\n if (selector === '$parentHost') return applyRoot(hostSet.$parentHost);\n if (selector === '$appHost') return applyRoot(hostSet.$appHost);\n if (selector === '$firstHost') return applyRoot(hostSet.$firstHost);\n if (selector === '$lastHost') return applyRoot(hostSet.$lastHost);\n \n const targetRoot = applyRoot(this);\n return targetRoot ? targetRoot.querySelector(selector) : null;\n };\n\n const targetEl = getTarget();\n const res = original.apply(this, args);\n\n const runApply = (target: any, val: any) => {\n const pos = options.position || 'beforeEnd';\n \n // \uC0AC\uC6A9\uC790\uAC00 filter\uB97C \uBA85\uC2DC\uD558\uBA74 \uADF8 \uC870\uAC74\uC73C\uB85C, \uC544\uB2C8\uBA74 \uD56D\uC0C1 \uC801\uC6A9\n if (!options.filter || options.filter(target, val, {currentThis: this, helper: hostSet})) {\n applyToDom(target, val, pos, currentDoc);\n }\n };\n\n if (res instanceof Promise) {\n // \uBE44\uB3D9\uAE30\uC77C \uB54C\uB9CC \uB85C\uB529 \uD45C\uC2DC\n if (targetEl && options.loading) {\n const loadingRes = options.loading.call(this, hostSet);\n applyToDom(targetEl, loadingRes, options.position || 'beforeEnd', currentDoc);\n }\n\n return res.then(finalRes => {\n if (finalRes !== undefined && targetEl) runApply(targetEl, finalRes);\n return finalRes;\n });\n } else {\n if (res !== undefined && targetEl) runApply(targetEl, res);\n return res;\n }\n };\n };\n}\n\nexport const findAllApplyNodeMetadata = (target: any): Map<string | symbol, ApplyNodeMetadata> => {\n const result = new Map<string | symbol, ApplyNodeMetadata>();\n const maps = ReflectUtils.findAllMetadata<Map<string | symbol, ApplyNodeMetadata>>(APPLY_NODE_METADATA_KEY, target);\n maps.forEach(map => {\n if (map instanceof Map) {\n map.forEach((v, k) => result.set(k, v));\n }\n });\n return result;\n};\n\nexport function applyNodeThis(options: ApplyNodeOptions): MethodDecorator;\nexport function applyNodeThis(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function applyNodeThis(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n if (propertyKey !== undefined) return applyNode('$this', { position: 'beforeEnd' })(targetOrOptions, propertyKey, descriptor);\n const opt = targetOrOptions || {};\n return applyNode('$this', { position: 'beforeEnd', ...opt });\n}\n\nexport function applyReplaceChildrenNodeThis(options: ApplyNodeOptions): MethodDecorator;\nexport function applyReplaceChildrenNodeThis(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function applyReplaceChildrenNodeThis(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n if (propertyKey !== undefined) return applyNode('$this', { position: 'replaceChildren' })(targetOrOptions, propertyKey, descriptor);\n const opt = targetOrOptions || {};\n return applyNode('$this', { position: 'replaceChildren', ...opt });\n}\n\nexport function applyInnerHtmlNodeThis(options: ApplyNodeOptions): MethodDecorator;\nexport function applyInnerHtmlNodeThis(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function applyInnerHtmlNodeThis(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n if (propertyKey !== undefined) return applyNode('$this', { position: 'innerHtml' })(targetOrOptions, propertyKey, descriptor);\n const opt = targetOrOptions || {};\n return applyNode('$this', { position: 'innerHtml', ...opt });\n}\n\nexport function applyReplaceChildrenNode(selector: string, options: ApplyNodeOptions = {}): MethodDecorator {\n return applyNode(selector, { ...options, position: 'replaceChildren' });\n}\n\nexport function applyInnerHtmlNode(selector: string, options: ApplyNodeOptions = {}): MethodDecorator {\n return applyNode(selector, { ...options, position: 'innerHtml' });\n}\n\nexport function applyInnerTextNode(selector: string, options: ApplyNodeOptions = {}): MethodDecorator {\n return applyNode(selector, { ...options, position: 'innerText' });\n}\n"],
5
- "mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,YAAY,wBAAwB;AAE7C,SAAS,gBAAgB;AAgClB,MAAM,0BAA0B,OAAO,IAAI,iCAAiC;AAEnF,MAAM,iBAAiB,CAAC,KAAU,QAA0B;AAC1D,QAAM,QAAQ,MAAM,QAAQ,GAAG,IAAI,MAAM,CAAC,GAAG;AAC7C,SAAO,MAAM,IAAI,QAAM;AACrB,QAAI,cAAc,KAAM,QAAO;AAC/B,WAAO,IAAI,eAAe,OAAO,UAAa,OAAO,OAAO,OAAO,EAAE,IAAI,EAAE;AAAA,EAC7E,CAAC;AACH;AAEA,MAAM,aAAa,CAAC,UAAe,KAAU,KAAwB,QAAkB;AACnF,MAAI,CAAC,SAAU;AAEf,MAAI,QAAQ,aAAa;AACrB,aAAS,YAAY,QA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AG,SAAS,UAAU,kBAAkB,CAAC;AAC1E;AAEO,SAAS,mBAAmB,UAAkB,UAA4B,CAAC,GAAoB;AAClG,SAAO,UAAU,UAAU,EAAE,GAAG,SAAS,UAAU,YAAY,CAAC;AACpE;AAEO,SAAS,mBAAmB,UAAkB,UAA4B,CAAC,GAAoB;AAClG,SAAO,UAAU,UAAU,EAAE,GAAG,SAAS,UAAU,YAAY,CAAC;AACpE;",
4
+ "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit, getElementConfig } from './elementDefine';\nimport { HelperHostSet, SwcRootType } from '../types';\nimport { SwcUtils } from \"../utils/Utils\";\n/*\n<!-- beforebegin -->\n<p> <-- it's me\n <!-- afterbegin -->\n foo\n <!-- beforeend -->\n</p>\n<!-- afterend -->\n */\nexport type ApplyNodePosition = 'beforeBegin' | 'afterBegin' | 'beforeEnd' | 'afterEnd' | 'replace' | 'replaceChildren' | 'innerHtml' | 'innerText' | 'remove';\n\nexport interface ApplyNodeOptions {\n position?: ApplyNodePosition;\n root?: SwcRootType;\n /**\n * Filter function to determine whether to perform DOM operation.\n * If it returns false, the operation is skipped.\n */\n filter?: (target: HTMLElement | ShadowRoot, newValue: any, meta:{currentThis: any,helper: HelperHostSet}) => boolean;\n /**\n * Optional loading content to display while an async method is executing.\n */\n loading?: (helper: HelperHostSet) => any;\n}\n\nexport interface ApplyNodeMetadata {\n propertyKey: string | symbol;\n selector: string;\n options: ApplyNodeOptions;\n}\n\nexport const APPLY_NODE_METADATA_KEY = Symbol.for('simple-web-component:apply-node');\n\nconst normalizeNodes = (res: any, doc: Document): Node[] => {\n const items = Array.isArray(res) ? res : [res];\n return items.map(it => {\n if (it instanceof Node) return it;\n return doc.createTextNode(it !== undefined && it !== null ? String(it) : '');\n });\n};\n\nconst applyToDom = (targetEl: any, res: any, pos: ApplyNodePosition, win: Window) => {\n if (!targetEl) return;\n\n const doc = win.document;\n \n if (pos === 'innerHtml') {\n targetEl.innerHTML = res !== undefined && res !== null ? String(res) : '';\n return;\n }\n \n if (pos === 'innerText') {\n if (targetEl.innerText !== undefined) {\n targetEl.innerText = res !== undefined && res !== null ? String(res) : '';\n }\n return;\n }\n\n const isShadowRoot = targetEl instanceof win.ShadowRoot;\n const nodes = normalizeNodes(res, doc);\n if (pos === 'replace') {\n if (!isShadowRoot) targetEl.replaceWith(...nodes);\n } else if (pos === 'replaceChildren') {\n targetEl.replaceChildren(...nodes);\n } else {\n if (pos === 'beforeEnd') targetEl.append(...nodes);\n else if (pos === 'afterBegin') targetEl.prepend(...nodes);\n else if (pos === 'beforeBegin' && !isShadowRoot) targetEl.before(...nodes);\n else if (pos === 'afterEnd' && !isShadowRoot) targetEl.after(...nodes);\n }\n};\n\n/**\n * @applyNode decorator to surgically add/replace nodes to a target element.\n */\nexport function applyNode(selector: string, options: ApplyNodeOptions = { position: 'beforeEnd' }): MethodDecorator {\n return (targetObj: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = targetObj.constructor;\n let metaList = ReflectUtils.getOwnMetadata(APPLY_NODE_METADATA_KEY, constructor) as Map<string | symbol, ApplyNodeMetadata>;\n if (!metaList) {\n metaList = new Map<string | symbol, ApplyNodeMetadata>();\n ReflectUtils.defineMetadata(APPLY_NODE_METADATA_KEY, metaList, constructor);\n }\n metaList.set(propertyKey, { propertyKey, selector, options });\n\n const original = descriptor.value;\n descriptor.value = function (...args: any[]) {\n ensureInit(this);\n \n const conf = getElementConfig(this);\n const currentWin = (this as any)._resolveWindow?.(conf) || ((typeof window !== 'undefined' ? window : undefined) as Window);\n const currentDoc = currentWin.document;\n const hostSet = SwcUtils.getHelperAndHostSet(currentWin, this);\n \n const getTarget = () => {\n const r = options.root || 'auto';\n const applyRoot = (t: any) => {\n if (!t) return t;\n if (r === 'auto') return t.shadowRoot || t;\n if (r === 'shadow') return t.shadowRoot;\n if (r === 'light') return t;\n if (r === 'all') return t.shadowRoot || t;\n return t;\n };\n\n if (selector === '$this') return applyRoot(this);\n if (selector === '$host') return applyRoot(hostSet.$host);\n if (selector === '$parentHost') return applyRoot(hostSet.$parentHost);\n if (selector === '$appHost') return applyRoot(hostSet.$appHost);\n if (selector === '$firstHost') return applyRoot(hostSet.$firstHost);\n if (selector === '$lastHost') return applyRoot(hostSet.$lastHost);\n \n const targetRoot = applyRoot(this);\n return targetRoot ? targetRoot.querySelector(selector) : null;\n };\n\n const targetEl = getTarget();\n const res = original.apply(this, args);\n\n const runApply = (target: any, val: any) => {\n const pos = options.position || 'beforeEnd';\n \n // \uC0AC\uC6A9\uC790\uAC00 filter\uB97C \uBA85\uC2DC\uD558\uBA74 \uADF8 \uC870\uAC74\uC73C\uB85C, \uC544\uB2C8\uBA74 \uD56D\uC0C1 \uC801\uC6A9\n if (!options.filter || options.filter(target, val, {currentThis: this, helper: hostSet})) {\n applyToDom(target, val, pos, currentWin);\n }\n };\n\n if (res instanceof Promise) {\n // \uBE44\uB3D9\uAE30\uC77C \uB54C\uB9CC \uB85C\uB529 \uD45C\uC2DC\n if (targetEl && options.loading) {\n const loadingRes = options.loading.call(this, hostSet);\n applyToDom(targetEl, loadingRes, options.position || 'beforeEnd', currentDoc);\n }\n\n return res.then(finalRes => {\n if (finalRes !== undefined && targetEl) runApply(targetEl, finalRes);\n return finalRes;\n });\n } else {\n if (res !== undefined && targetEl) runApply(targetEl, res);\n return res;\n }\n };\n };\n}\n\nexport const findAllApplyNodeMetadata = (target: any): Map<string | symbol, ApplyNodeMetadata> => {\n const result = new Map<string | symbol, ApplyNodeMetadata>();\n const maps = ReflectUtils.findAllMetadata<Map<string | symbol, ApplyNodeMetadata>>(APPLY_NODE_METADATA_KEY, target);\n maps.forEach(map => {\n if (map instanceof Map) {\n map.forEach((v, k) => result.set(k, v));\n }\n });\n return result;\n};\n\nexport function applyNodeThis(options: ApplyNodeOptions): MethodDecorator;\nexport function applyNodeThis(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function applyNodeThis(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n if (propertyKey !== undefined) return applyNode('$this', { position: 'beforeEnd' })(targetOrOptions, propertyKey, descriptor);\n const opt = targetOrOptions || {};\n return applyNode('$this', { position: 'beforeEnd', ...opt });\n}\n\nexport function applyNodeThisReplaceChildren(options: ApplyNodeOptions): MethodDecorator;\nexport function applyNodeThisReplaceChildren(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function applyNodeThisReplaceChildren(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n if (propertyKey !== undefined) return applyNode('$this', { position: 'replaceChildren' })(targetOrOptions, propertyKey, descriptor);\n const opt = targetOrOptions || {};\n return applyNode('$this', { position: 'replaceChildren', ...opt });\n}\n\nexport function applyThisInnerHtmlNode(options: ApplyNodeOptions): MethodDecorator;\nexport function applyThisInnerHtmlNode(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function applyThisInnerHtmlNode(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n if (propertyKey !== undefined) return applyNode('$this', { position: 'innerHtml' })(targetOrOptions, propertyKey, descriptor);\n const opt = targetOrOptions || {};\n return applyNode('$this', { position: 'innerHtml', ...opt });\n}\n\nexport function applyNodeReplaceChildren(selector: string, options: ApplyNodeOptions = {}): MethodDecorator {\n return applyNode(selector, { ...options, position: 'replaceChildren' });\n}\n\nexport function applyNodeInnerHtml(selector: string, options: ApplyNodeOptions = {}): MethodDecorator {\n return applyNode(selector, { ...options, position: 'innerHtml' });\n}\n\nexport function applyNodeInnerText(selector: string, options: ApplyNodeOptions = {}): MethodDecorator {\n return applyNode(selector, { ...options, position: 'innerText' });\n}\n"],
5
+ "mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,YAAY,wBAAwB;AAE7C,SAAS,gBAAgB;AAgClB,MAAM,0BAA0B,OAAO,IAAI,iCAAiC;AAEnF,MAAM,iBAAiB,CAAC,KAAU,QAA0B;AAC1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SAAS,EAAE,UAAU,mBAAmB,GAAG,IAAI,CAAC;AACnE;AAIO,SAAS,uBAAuB,iBAAuB,aAA+B,YAAsC;AACjI,MAAI,gBAAgB,OAAW,QAAO,UAAU,SAAS,EAAE,UAAU,YAAY,CAAC,EAAE,iBAAiB,aAAa,UAAU;AAC5H,QAAM,MAAM,mBAAmB,CAAC;AAChC,SAAO,UAAU,SAAS,EAAE,UAAU,aAAa,GAAG,IAAI,CAAC;AAC7D;AAEO,SAAS,yBAAyB,UAAkB,UAA4B,CAAC,GAAoB;AACxG,SAAO,UAAU,UAAU,EAAE,GAAG,SAAS,UAAU,kBAAkB,CAAC;AAC1E;AAEO,SAAS,mBAAmB,UAAkB,UAA4B,CAAC,GAAoB;AAClG,SAAO,UAAU,UAAU,EAAE,GAAG,SAAS,UAAU,YAAY,CAAC;AACpE;AAEO,SAAS,mBAAmB,UAAkB,UAA4B,CAAC,GAAoB;AAClG,SAAO,UAAU,UAAU,EAAE,GAAG,SAAS,UAAU,YAAY,CAAC;AACpE;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,103 @@
1
+ import { ReflectUtils } from "@dooboostore/core";
2
+ import { ensureInit, getElementConfig } from "./elementDefine.js";
3
+ import { SwcUtils } from "../utils/Utils.js";
4
+ import { NodeSlot } from "@dooboostore/core-web";
5
+ const APPLY_SLOT_METADATA_KEY = Symbol.for("simple-web-component:apply-slot");
6
+ function applySlot(id, options = { position: "replaceChildrenHtml" }) {
7
+ return (targetObj, propertyKey, descriptor) => {
8
+ const type = descriptor === void 0 ? "property" : "method";
9
+ if (type === "property") {
10
+ Object.defineProperty(targetObj, propertyKey, {
11
+ get() {
12
+ const nodeSlot = new NodeSlot(this, `${this._swcId}-${id}`);
13
+ return nodeSlot;
14
+ },
15
+ configurable: true,
16
+ enumerable: true
17
+ });
18
+ }
19
+ const constructor = targetObj.constructor;
20
+ let metaList = ReflectUtils.getOwnMetadata(APPLY_SLOT_METADATA_KEY, constructor);
21
+ if (!metaList) {
22
+ metaList = [];
23
+ ReflectUtils.defineMetadata(APPLY_SLOT_METADATA_KEY, metaList, constructor);
24
+ }
25
+ metaList.push({ propertyKey, id, type, options });
26
+ if (type === "method") {
27
+ const original = descriptor.value;
28
+ descriptor.value = function(...args) {
29
+ ensureInit(this);
30
+ const conf = getElementConfig(this);
31
+ const currentWin = this._resolveWindow?.(conf) || (typeof window !== "undefined" ? window : void 0);
32
+ const currentDoc = currentWin.document;
33
+ const hostSet = SwcUtils.getHelperAndHostSet(currentWin, this);
34
+ const res = original.apply(this, args);
35
+ if (res) {
36
+ const nodeSlot = new NodeSlot(this, `${this._swcId}-${id}`);
37
+ const pos = options.position || "replaceChildrenHtml";
38
+ const doc = currentWin.document;
39
+ if (pos === "replaceChildrenHtml") {
40
+ nodeSlot.replaceChildrenHtml(res);
41
+ } else if (pos === "replaceChildrenText") {
42
+ nodeSlot.replaceChildrenText(res);
43
+ } else if (pos === "appendHtml") {
44
+ nodeSlot.appendHtml(res);
45
+ } else if (pos === "appendText") {
46
+ nodeSlot.appendText(res);
47
+ } else if (pos === "prependHtml") {
48
+ nodeSlot.prependHtml(res);
49
+ } else if (pos === "prependText") {
50
+ nodeSlot.prependText(res);
51
+ } else if (pos === "clear") {
52
+ nodeSlot.clear();
53
+ }
54
+ }
55
+ return res;
56
+ };
57
+ }
58
+ };
59
+ }
60
+ const findAllApplySlotMetadata = (target) => {
61
+ const constructor = target instanceof Function ? target : target.constructor;
62
+ return ReflectUtils.getMetadata(APPLY_SLOT_METADATA_KEY, constructor);
63
+ };
64
+ function applySlotClear(id) {
65
+ return applySlot(id, { position: "clear" });
66
+ }
67
+ function applySlotPrependHtml(id) {
68
+ return applySlot(id, { position: "prependHtml" });
69
+ }
70
+ const applySlotPrepend = applySlotPrependHtml;
71
+ function applySlotPrependText(id) {
72
+ return applySlot(id, { position: "prependText" });
73
+ }
74
+ function applySlotAppendHtml(id) {
75
+ return applySlot(id, { position: "appendHtml" });
76
+ }
77
+ function applySlotAppendText(id) {
78
+ return applySlot(id, { position: "appendText" });
79
+ }
80
+ const applySlotAppend = applySlotAppendHtml;
81
+ function applySlotReplaceChildrenHtml(id) {
82
+ return applySlot(id, { position: "replaceChildrenHtml" });
83
+ }
84
+ const applySlotReplaceChildren = applySlotReplaceChildrenHtml;
85
+ function applySlotReplaceChildrenText(id) {
86
+ return applySlot(id, { position: "replaceChildrenText" });
87
+ }
88
+ export {
89
+ APPLY_SLOT_METADATA_KEY,
90
+ applySlot,
91
+ applySlotAppend,
92
+ applySlotAppendHtml,
93
+ applySlotAppendText,
94
+ applySlotClear,
95
+ applySlotPrepend,
96
+ applySlotPrependHtml,
97
+ applySlotPrependText,
98
+ applySlotReplaceChildren,
99
+ applySlotReplaceChildrenHtml,
100
+ applySlotReplaceChildrenText,
101
+ findAllApplySlotMetadata
102
+ };
103
+ //# sourceMappingURL=applySlot.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/decorators/applySlot.ts"],
4
+ "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit, getElementConfig } from './elementDefine';\nimport { HelperHostSet, SwcRootType } from '../types';\nimport { SwcUtils } from \"../utils/Utils\";\nimport {NodeSlot} from \"@dooboostore/core-web\";\n/*\n<!-- beforebegin -->\n<p> <-- it's me\n <!-- afterbegin -->\n foo\n <!-- beforeend -->\n</p>\n<!-- afterend -->\n */\nexport type ApplySlotPosition = 'prependHtml' | 'prependText' | 'appendHtml' | 'appendText' | 'replaceChildrenHtml' | 'replaceChildrenText' | 'clear';\n\nexport interface ApplySlotOptions {\n position?: ApplySlotPosition;\n // root?: SwcRootType;\n /**\n * Filter function to determine whether to perform DOM operation.\n * If it returns false, the operation is skipped.\n */\n // filter?: (target: HTMLElement | ShadowRoot, newValue: any, meta:{currentThis: any,helper: HelperHostSet}) => boolean;\n /**\n * Optional loading content to display while an async method is executing.\n */\n // loading?: (helper: HelperHostSet) => any;\n}\n\nexport interface ApplySlotMetadata {\n propertyKey: string | symbol;\n id: string;\n type: 'method' | 'property';\n options: ApplySlotOptions;\n}\n\nexport const APPLY_SLOT_METADATA_KEY = Symbol.for('simple-web-component:apply-slot');\n\n// const normalizeNodes = (res: any, doc: Document): Node[] => {\n// const items = Array.isArray(res) ? res : [res];\n// return items.map(it => {\n// if (it instanceof Node) return it;\n// return doc.createTextNode(it !== undefined && it !== null ? String(it) : '');\n// });\n// };\n\n// const applyToDom = (targetEl: any, res: any, pos: ApplyNodePosition, win: Window) => {\n// if (!targetEl) return;\n//\n// const doc = win.document;\n//\n// if (pos === 'innerHtml') {\n// targetEl.innerHTML = res !== undefined && res !== null ? String(res) : '';\n// return;\n// }\n//\n// if (pos === 'innerText') {\n// if (targetEl.innerText !== undefined) {\n// targetEl.innerText = res !== undefined && res !== null ? String(res) : '';\n// }\n// return;\n// }\n//\n// const isShadowRoot = targetEl instanceof win.ShadowRoot;\n// const nodes = normalizeNodes(res, doc);\n// if (pos === 'replace') {\n// if (!isShadowRoot) targetEl.replaceWith(...nodes);\n// } else if (pos === 'replaceChildren') {\n// targetEl.replaceChildren(...nodes);\n// } else {\n// if (pos === 'beforeEnd') targetEl.append(...nodes);\n// else if (pos === 'afterBegin') targetEl.prepend(...nodes);\n// else if (pos === 'beforeBegin' && !isShadowRoot) targetEl.before(...nodes);\n// else if (pos === 'afterEnd' && !isShadowRoot) targetEl.after(...nodes);\n// }\n// };\n\n/**\n * @applyNode decorator to surgically add/replace nodes to a target element.\n */\nexport function applySlot(id: string, options: ApplySlotOptions = { position: 'replaceChildrenHtml' }): MethodDecorator & PropertyDecorator {\n return (targetObj: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => {\n const type = descriptor === undefined ? 'property' : 'method';\n\n if (type === 'property') {\n Object.defineProperty(targetObj, propertyKey, {\n get(this: any) {\n const nodeSlot = new NodeSlot(this, `${this._swcId}-${id}`);\n return nodeSlot;\n },\n configurable: true,\n enumerable: true,\n })\n // return nodeSlot;\n // return;\n }\n\n const constructor = targetObj.constructor;\n let metaList = ReflectUtils.getOwnMetadata(APPLY_SLOT_METADATA_KEY, constructor) as ApplySlotMetadata[];\n if (!metaList) {\n metaList = []\n ReflectUtils.defineMetadata(APPLY_SLOT_METADATA_KEY, metaList, constructor);\n }\n metaList.push({ propertyKey, id, type, options });\n\n\n\n if (type === 'method') {\n const original = descriptor.value;\n descriptor.value = function (...args: any[]) {\n ensureInit(this);\n\n const conf = getElementConfig(this);\n const currentWin = (this as any)._resolveWindow?.(conf) || ((typeof window !== 'undefined' ? window : undefined) as Window);\n const currentDoc = currentWin.document;\n const hostSet = SwcUtils.getHelperAndHostSet(currentWin, this);\n\n\n // const getTarget = () => {\n // const r = options.root || 'auto';\n // const applyRoot = (t: any) => {\n // if (!t) return t;\n // if (r === 'auto') return t.shadowRoot || t;\n // if (r === 'shadow') return t.shadowRoot;\n // if (r === 'light') return t;\n // if (r === 'all') return t.shadowRoot || t;\n // return t;\n // };\n //\n // if (selector === '$this') return applyRoot(this);\n // if (selector === '$host') return applyRoot(hostSet.$host);\n // if (selector === '$parentHost') return applyRoot(hostSet.$parentHost);\n // if (selector === '$appHost') return applyRoot(hostSet.$appHost);\n // if (selector === '$firstHost') return applyRoot(hostSet.$firstHost);\n // if (selector === '$lastHost') return applyRoot(hostSet.$lastHost);\n //\n // const targetRoot = applyRoot(this);\n // return targetRoot ? targetRoot.querySelector(selector) : null;\n // };\n\n // const targetEl = getTarget();\n const res = original.apply(this, args);\n\n // const runApply = (target: any, val: any) => {\n // const pos = options.position || 'beforeEnd';\n //\n // // \uC0AC\uC6A9\uC790\uAC00 filter\uB97C \uBA85\uC2DC\uD558\uBA74 \uADF8 \uC870\uAC74\uC73C\uB85C, \uC544\uB2C8\uBA74 \uD56D\uC0C1 \uC801\uC6A9\n // if (!options.filter || options.filter(target, val, {currentThis: this, helper: hostSet})) {\n // applyToDom(target, val, pos, currentWin);\n // }\n // };\n\n // if (res instanceof Promise) {\n // // \uBE44\uB3D9\uAE30\uC77C \uB54C\uB9CC \uB85C\uB529 \uD45C\uC2DC\n // if (targetEl && options.loading) {\n // const loadingRes = options.loading.call(this, hostSet);\n // applyToDom(targetEl, loadingRes, options.position || 'beforeEnd', currentDoc);\n // }\n //\n // return res.then(finalRes => {\n // if (finalRes !== undefined && targetEl) runApply(targetEl, finalRes);\n // return finalRes;\n // });\n // } else {\n // if (res !== undefined && targetEl) runApply(targetEl, res);\n // return res;\n // }\n if (res) {\n const nodeSlot = new NodeSlot(this, `${this._swcId}-${id}`);\n const pos = options.position || 'replaceChildrenHtml';\n const doc = currentWin.document;\n\n\n // const isShadowRoot = targetEl instanceof win.ShadowRoot;\n // const nodes = normalizeNodes(res, doc);\n if (pos === 'replaceChildrenHtml') {\n nodeSlot.replaceChildrenHtml(res);\n } else if (pos === 'replaceChildrenText') {\n nodeSlot.replaceChildrenText(res);\n } else if (pos === 'appendHtml') {\n nodeSlot.appendHtml(res);\n } else if (pos === 'appendText') {\n nodeSlot.appendText(res);\n } else if (pos === 'prependHtml') {\n nodeSlot.prependHtml(res);\n } else if (pos === 'prependText') {\n nodeSlot.prependText(res);\n } else if (pos === 'clear') {\n nodeSlot.clear();\n }\n }\n return res;\n };\n }\n };\n}\n\n// export const findAllApplySlotMetadata = (target: any): Map<string | symbol, ApplySlotMetadata> => {\nexport const findAllApplySlotMetadata = (target: any): ApplySlotMetadata[] => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(APPLY_SLOT_METADATA_KEY, constructor);\n};\n\nexport function applySlotClear(id: string): MethodDecorator {\n return applySlot(id, { position: 'clear' });\n}\nexport function applySlotPrependHtml(id: string): MethodDecorator {\n return applySlot(id, { position: 'prependHtml' });\n}\nexport const applySlotPrepend = applySlotPrependHtml;\nexport function applySlotPrependText(id: string): MethodDecorator {\n return applySlot(id, { position: 'prependText' });\n}\nexport function applySlotAppendHtml(id: string): MethodDecorator {\n return applySlot(id, { position: 'appendHtml' });\n}\nexport function applySlotAppendText(id: string): MethodDecorator {\n return applySlot(id, { position: 'appendText' });\n}\nexport const applySlotAppend = applySlotAppendHtml;\nexport function applySlotReplaceChildrenHtml(id: string): MethodDecorator {\n return applySlot(id, { position: 'replaceChildrenHtml' });\n}\nexport const applySlotReplaceChildren = applySlotReplaceChildrenHtml;\nexport function applySlotReplaceChildrenText(id: string): MethodDecorator {\n return applySlot(id, { position: 'replaceChildrenText' });\n}\n"],
5
+ "mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,YAAY,wBAAwB;AAE7C,SAAS,gBAAgB;AACzB,SAAQ,gBAAe;AAiChB,MAAM,0BAA0B,OAAO,IAAI,iCAAiC;AA4C5E,SAAS,UAAU,IAAY,UAA4B,EAAE,UAAU,sBAAsB,GAAwC;AAC1I,SAAO,CAAC,WAAmB,aAA8B,eAAoC;AAC3F,UAAM,OAAO,eAAe,SAAY,aAAa;AAErD,QAAI,SAAS,YAAY;AACjB,aAAO,eAAe,WAAW,aAAa;AAAA,QAC5C,MAAe;AACb,gBAAM,WAAW,IAAI,SAAS,MAAM,GAAG,KAAK,MAAM,IAAI,EAAE,EAAE;AAC1D,iBAAO;AAAA,QACT;AAAA,QACA,cAAc;AAAA,QACd,YAAY;AAAA,MACd,CAAC;AAAA,IAGT;AAEA,UAAM,cAAc,UAAU;AAC9B,QAAI,WAAW,aAAa,eAAe,yBAAyB,WAAW;AAC/E,QAAI,CAAC,UAAU;AACb,iBAAW,CAAC;AACZ,mBAAa,eAAe,yBAAyB,UAAU,WAAW;AAAA,IAC5E;AACA,aAAS,KAAK,EAAE,aAAa,IAAI,MAAM,QAAQ,CAAC;AAIhD,QAAI,SAAS,UAAU;AACrB,YAAM,WAAW,WAAW;AAC5B,iBAAW,QAAQ,YAAa,MAAa;AAC3C,mBAAW,IAAI;AAEf,cAAM,OAAO,iBAAiB,IAAI;AAClC,cAAM,aAAc,KAAa,iBAAiB,IAAI,MAAO,OAAO,WAAW,cAAc,SAAS;AACtG,cAAM,aAAa,WAAW;AAC9B,cAAM,UAAU,S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