@dooboostore/simple-web-component 1.0.33 → 1.0.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. package/README.md +23 -30
  2. package/dist/cjs/decorators/addEventListener.js.map +1 -1
  3. package/dist/cjs/decorators/applyAttribute.js +67 -57
  4. package/dist/cjs/decorators/applyAttribute.js.map +2 -2
  5. package/dist/cjs/decorators/applyClass.js +80 -70
  6. package/dist/cjs/decorators/applyClass.js.map +2 -2
  7. package/dist/cjs/decorators/applyNode.js +5 -8
  8. package/dist/cjs/decorators/applyNode.js.map +2 -2
  9. package/dist/cjs/decorators/applyStyle.js +66 -56
  10. package/dist/cjs/decorators/applyStyle.js.map +2 -2
  11. package/dist/cjs/decorators/attribute.js +35 -29
  12. package/dist/cjs/decorators/attribute.js.map +2 -2
  13. package/dist/cjs/decorators/changedAttributeHost.js +32 -12
  14. package/dist/cjs/decorators/changedAttributeHost.js.map +2 -2
  15. package/dist/cjs/decorators/elementDefine.js +238 -180
  16. package/dist/cjs/decorators/elementDefine.js.map +2 -2
  17. package/dist/cjs/decorators/emitCustomEvent.js +67 -48
  18. package/dist/cjs/decorators/emitCustomEvent.js.map +2 -2
  19. package/dist/cjs/decorators/lifecycles.js +15 -17
  20. package/dist/cjs/decorators/lifecycles.js.map +2 -2
  21. package/dist/cjs/decorators/setProperty.js +50 -39
  22. package/dist/cjs/decorators/setProperty.js.map +2 -2
  23. package/dist/cjs/decorators/subscribeSwcAppMessageWhileConnected.js.map +1 -1
  24. package/dist/cjs/decorators/subscribeSwcAppRouteChangeWhileConnected.js +2 -2
  25. package/dist/cjs/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +2 -2
  26. package/dist/cjs/elements/SwcAppEngine.js +14 -8
  27. package/dist/cjs/elements/SwcAppEngine.js.map +3 -3
  28. package/dist/cjs/elements/SwcAppMixin.js +154 -81
  29. package/dist/cjs/elements/SwcAppMixin.js.map +2 -2
  30. package/dist/cjs/elements/SwcAsync.js +28 -18
  31. package/dist/cjs/elements/SwcAsync.js.map +2 -2
  32. package/dist/cjs/elements/SwcChoose.js +68 -45
  33. package/dist/cjs/elements/SwcChoose.js.map +2 -2
  34. package/dist/cjs/elements/SwcIf.js +52 -30
  35. package/dist/cjs/elements/SwcIf.js.map +2 -2
  36. package/dist/cjs/elements/SwcLoop.js +109 -35
  37. package/dist/cjs/elements/SwcLoop.js.map +2 -2
  38. package/dist/cjs/elements/register.js +263 -131
  39. package/dist/cjs/elements/register.js.map +2 -2
  40. package/dist/cjs/router/ElementRouter.js +4 -2
  41. package/dist/cjs/router/ElementRouter.js.map +1 -1
  42. package/dist/cjs/types.js.map +1 -1
  43. package/dist/cjs/utils/Utils.js +25 -7
  44. package/dist/cjs/utils/Utils.js.map +2 -2
  45. package/dist/esm/decorators/addEventListener.js.map +1 -1
  46. package/dist/esm/decorators/applyAttribute.js +67 -57
  47. package/dist/esm/decorators/applyAttribute.js.map +2 -2
  48. package/dist/esm/decorators/applyClass.js +80 -70
  49. package/dist/esm/decorators/applyClass.js.map +2 -2
  50. package/dist/esm/decorators/applyNode.js +5 -8
  51. package/dist/esm/decorators/applyNode.js.map +2 -2
  52. package/dist/esm/decorators/applyStyle.js +66 -56
  53. package/dist/esm/decorators/applyStyle.js.map +2 -2
  54. package/dist/esm/decorators/attribute.js +35 -29
  55. package/dist/esm/decorators/attribute.js.map +2 -2
  56. package/dist/esm/decorators/changedAttributeHost.js +32 -12
  57. package/dist/esm/decorators/changedAttributeHost.js.map +2 -2
  58. package/dist/esm/decorators/elementDefine.js +240 -182
  59. package/dist/esm/decorators/elementDefine.js.map +2 -2
  60. package/dist/esm/decorators/emitCustomEvent.js +67 -48
  61. package/dist/esm/decorators/emitCustomEvent.js.map +2 -2
  62. package/dist/esm/decorators/lifecycles.js +15 -17
  63. package/dist/esm/decorators/lifecycles.js.map +2 -2
  64. package/dist/esm/decorators/setProperty.js +50 -39
  65. package/dist/esm/decorators/setProperty.js.map +2 -2
  66. package/dist/esm/decorators/subscribeSwcAppMessageWhileConnected.js.map +1 -1
  67. package/dist/esm/decorators/subscribeSwcAppRouteChangeWhileConnected.js +2 -2
  68. package/dist/esm/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +2 -2
  69. package/dist/esm/elements/SwcAppEngine.js +14 -7
  70. package/dist/esm/elements/SwcAppEngine.js.map +2 -2
  71. package/dist/esm/elements/SwcAppMixin.js +156 -82
  72. package/dist/esm/elements/SwcAppMixin.js.map +2 -2
  73. package/dist/esm/elements/SwcAsync.js +28 -18
  74. package/dist/esm/elements/SwcAsync.js.map +2 -2
  75. package/dist/esm/elements/SwcChoose.js +69 -46
  76. package/dist/esm/elements/SwcChoose.js.map +2 -2
  77. package/dist/esm/elements/SwcIf.js +53 -31
  78. package/dist/esm/elements/SwcIf.js.map +2 -2
  79. package/dist/esm/elements/SwcLoop.js +110 -36
  80. package/dist/esm/elements/SwcLoop.js.map +2 -2
  81. package/dist/esm/elements/register.js +264 -132
  82. package/dist/esm/elements/register.js.map +2 -2
  83. package/dist/esm/router/ElementRouter.js +5 -2
  84. package/dist/esm/router/ElementRouter.js.map +1 -1
  85. package/dist/esm/types.js.map +1 -1
  86. package/dist/esm/utils/Utils.js +25 -7
  87. package/dist/esm/utils/Utils.js.map +2 -2
  88. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +728 -595
  89. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
  90. package/dist/types/decorators/addEventListener.d.ts +4 -1
  91. package/dist/types/decorators/addEventListener.d.ts.map +1 -1
  92. package/dist/types/decorators/applyAttribute.d.ts +5 -1
  93. package/dist/types/decorators/applyAttribute.d.ts.map +1 -1
  94. package/dist/types/decorators/applyClass.d.ts +4 -0
  95. package/dist/types/decorators/applyClass.d.ts.map +1 -1
  96. package/dist/types/decorators/applyNode.d.ts +5 -1
  97. package/dist/types/decorators/applyNode.d.ts.map +1 -1
  98. package/dist/types/decorators/applyStyle.d.ts +5 -1
  99. package/dist/types/decorators/applyStyle.d.ts.map +1 -1
  100. package/dist/types/decorators/attribute.d.ts +5 -0
  101. package/dist/types/decorators/attribute.d.ts.map +1 -1
  102. package/dist/types/decorators/changedAttributeHost.d.ts +14 -3
  103. package/dist/types/decorators/changedAttributeHost.d.ts.map +1 -1
  104. package/dist/types/decorators/elementDefine.d.ts +1 -1
  105. package/dist/types/decorators/elementDefine.d.ts.map +1 -1
  106. package/dist/types/decorators/emitCustomEvent.d.ts +15 -7
  107. package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
  108. package/dist/types/decorators/lifecycles.d.ts +10 -7
  109. package/dist/types/decorators/lifecycles.d.ts.map +1 -1
  110. package/dist/types/decorators/setProperty.d.ts +5 -1
  111. package/dist/types/decorators/setProperty.d.ts.map +1 -1
  112. package/dist/types/decorators/subscribeSwcAppMessageWhileConnected.d.ts +2 -2
  113. package/dist/types/decorators/subscribeSwcAppMessageWhileConnected.d.ts.map +1 -1
  114. package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts +5 -6
  115. package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts.map +1 -1
  116. package/dist/types/elements/SwcAppEngine.d.ts +9 -3
  117. package/dist/types/elements/SwcAppEngine.d.ts.map +1 -1
  118. package/dist/types/elements/SwcAppMixin.d.ts +12 -7
  119. package/dist/types/elements/SwcAppMixin.d.ts.map +1 -1
  120. package/dist/types/elements/register.d.ts.map +1 -1
  121. package/dist/types/types.d.ts +1 -0
  122. package/dist/types/types.d.ts.map +1 -1
  123. package/dist/types/utils/Utils.d.ts +4 -1
  124. package/dist/types/utils/Utils.d.ts.map +1 -1
  125. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +728 -595
  126. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
  127. package/package.json +5 -5
  128. package/src/decorators/addEventListener.ts +1 -1
  129. package/src/decorators/applyAttribute.ts +74 -61
  130. package/src/decorators/applyClass.ts +91 -77
  131. package/src/decorators/applyNode.ts +16 -13
  132. package/src/decorators/applyStyle.ts +75 -61
  133. package/src/decorators/attribute.ts +55 -43
  134. package/src/decorators/changedAttributeHost.ts +49 -15
  135. package/src/decorators/elementDefine.ts +401 -340
  136. package/src/decorators/emitCustomEvent.ts +92 -62
  137. package/src/decorators/lifecycles.ts +11 -10
  138. package/src/decorators/setProperty.ts +58 -44
  139. package/src/decorators/subscribeSwcAppMessageWhileConnected.ts +2 -2
  140. package/src/decorators/subscribeSwcAppRouteChangeWhileConnected.ts +11 -11
  141. package/src/elements/SwcAppEngine.ts +19 -13
  142. package/src/elements/SwcAppMixin.ts +214 -102
  143. package/src/elements/SwcAsync.ts +28 -17
  144. package/src/elements/SwcChoose.ts +94 -36
  145. package/src/elements/SwcIf.ts +59 -22
  146. package/src/elements/SwcLoop.ts +140 -27
  147. package/src/elements/register.ts +319 -100
  148. package/src/types.ts +1 -0
  149. package/src/utils/Utils.ts +38 -10
  150. package/tsconfig.json +2 -2
@@ -1,6 +1,7 @@
1
1
  import { SwcAppInterface, HostSet, HelperSet, HelperHostSet } from '../types';
2
2
  import {getElementConfig} from "../decorators";
3
3
  import { getExpression, ExpressionResult, GetExpressionConfig, GetExpressionResult } from '@dooboostore/core';
4
+ import {Router} from "@dooboostore/core-web";
4
5
 
5
6
  export const SWC_NOT_FOUND = Symbol.for('simple-web-component:not-found');
6
7
 
@@ -151,14 +152,30 @@ export const htmlArticleElement = (options?: { doc?: Document; attrs?: Record<st
151
152
  export namespace SwcUtils {
152
153
 
153
154
 
155
+ export const getParentContainer = (e: Node) => {
156
+ return e.parentElement ?? e.getRootNode() as any;
157
+ }
158
+
154
159
  export const parsePathPatternsSetAttributeString = (pathPattern: string[], path: string) => {
155
160
  return JSON.stringify(SwcUtils.parsePathPatternsSet(pathPattern, path)).replace(/"/g, "'");
156
161
  }
157
162
 
158
- export const parsePathPatternsSet = (pathPattern: string[], path: string) => {
163
+ export const parsePathPatternsSet = (pathPattern: string[], urlAndRouter?: string | Router) => {
164
+ // if (!path) {
165
+ // return;
166
+ // }
167
+ urlAndRouter ??= '/'
168
+ const p = typeof urlAndRouter === 'string' ? urlAndRouter : urlAndRouter.value.url;
169
+ const searchParams = new URLSearchParams();
170
+ const qs = p.split('?')[1];
171
+ qs?.split('&').forEach(it => {
172
+ const [k, v] = it.split('=');
173
+ searchParams.set(k,v);
174
+ })
159
175
  return {
160
- path: path,
161
- pathData: SwcUtils.parsePathPatterns(pathPattern, path)
176
+ path: p,
177
+ searchParams,
178
+ pathData: SwcUtils.parsePathPatterns(pathPattern, p)
162
179
  };
163
180
  };
164
181
  export const parsePathPatterns = (pathPattern: string[], path: string) => {
@@ -209,8 +226,8 @@ export namespace SwcUtils {
209
226
  * Checks __swc_host property first, then climbs the DOM tree.
210
227
  */
211
228
  export const findNearestSwcHost = (el: HTMLElement | Node): HTMLElement | undefined => {
212
- if ((el as any).__swc_host) return (el as any).__swc_host;
213
- // if ((el as any).__swc_proto_setup) return (el as any).__swc_proto_setup;
229
+ const el1 = el as any;
230
+ if (el1.__swc_host) return el1.__swc_host;
214
231
 
215
232
  let current: any = el.parentElement || (el.getRootNode?.() as any)?.host;
216
233
  const doc = el.ownerDocument;
@@ -249,8 +266,10 @@ export namespace SwcUtils {
249
266
  };
250
267
 
251
268
  export const getAppHosts = (el: HTMLElement): SwcAppInterface[] => {
252
- const hosts = getHosts(el);
253
- return hosts.filter(host => host.tagName.toLowerCase() === 'swc-app' || host.getAttribute('is')?.startsWith('swc-app-')) as SwcAppInterface[];
269
+ // const hosts = getHosts(el);
270
+ // return hosts.filter(host => host.tagName.toLowerCase() === 'swc-app' || host.getAttribute('is')?.startsWith('swc-app-')) as SwcAppInterface[];
271
+ const hosts = SwcUtils.findAllParentAppHostsDirect(el);
272
+ return hosts;
254
273
  };
255
274
 
256
275
  export const getAppHost = (el: HTMLElement): SwcAppInterface | undefined => {
@@ -277,7 +296,15 @@ export namespace SwcUtils {
277
296
  */
278
297
  export const findAllParentAppHostsDirect = (el: HTMLElement): SwcAppInterface[] => {
279
298
  const appHosts: SwcAppInterface[] = [];
280
-
299
+
300
+ const w = el.ownerDocument?.defaultView || ((typeof window !== 'undefined' ? window : undefined) as any);
301
+
302
+ // Guard against SSR environment where window might be undefined
303
+ if (!w) {
304
+ return appHosts;
305
+ }
306
+
307
+ // console.log('------?',w.ShadowRoot);
281
308
  // el 자체부터 시작 (el이 app host일 수도 있음)
282
309
  let current: HTMLElement | null = el;
283
310
 
@@ -296,9 +323,9 @@ export namespace SwcUtils {
296
323
  } else {
297
324
  // parentElement가 없음 = Shadow root의 직접 자식일 수 있음
298
325
  const root = current.getRootNode();
299
- if (root instanceof ShadowRoot) {
326
+ if (w.ShadowRoot && root instanceof w.ShadowRoot) {
300
327
  // Shadow host로 올라가기
301
- current = root.host as HTMLElement;
328
+ current = (root as ShadowRoot).host as HTMLElement;
302
329
  } else {
303
330
  // Document root 도달
304
331
  break;
@@ -338,6 +365,7 @@ export namespace SwcUtils {
338
365
  $hosts,
339
366
  $firstHost,
340
367
  $lastHost: $parentHost,
368
+ $templateHost: (el as any).__swc_template_host,
341
369
  $appHost,
342
370
  $appHosts,
343
371
  $firstAppHost,
package/tsconfig.json CHANGED
@@ -6,9 +6,9 @@
6
6
  "declaration": true,
7
7
  "declarationMap": true,
8
8
  "stripInternal": true,
9
- "target": "es2020",
9
+ "target": "es2022",
10
10
  "noEmit": true,
11
- "lib": ["dom", "dom.iterable", "esnext"],
11
+ "lib": ["dom", "dom.iterable", "es2024", "esnext"],
12
12
  "experimentalDecorators": true,
13
13
  "emitDecoratorMetadata": true,
14
14
  "esModuleInterop": true,