@dooboostore/simple-web-component 1.0.39 → 1.0.41

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 (98) hide show
  1. package/LICENSE.md +7 -0
  2. package/README.md +235 -47
  3. package/dist/cjs/SwcAppEngine.js.map +2 -2
  4. package/dist/cjs/decorators/applyAttribute.js +194 -111
  5. package/dist/cjs/decorators/applyAttribute.js.map +2 -2
  6. package/dist/cjs/decorators/applyNode.js +58 -43
  7. package/dist/cjs/decorators/applyNode.js.map +2 -2
  8. package/dist/cjs/decorators/applyProperty.js +213 -0
  9. package/dist/cjs/decorators/applyProperty.js.map +7 -0
  10. package/dist/cjs/decorators/applySlot.js +32 -26
  11. package/dist/cjs/decorators/applySlot.js.map +2 -2
  12. package/dist/cjs/decorators/changedAttributeThis.js.map +1 -1
  13. package/dist/cjs/decorators/elementDefine.js +17 -30
  14. package/dist/cjs/decorators/elementDefine.js.map +2 -2
  15. package/dist/cjs/decorators/index.js +2 -2
  16. package/dist/cjs/decorators/index.js.map +2 -2
  17. package/dist/cjs/decorators/lifecycles.js +4 -4
  18. package/dist/cjs/decorators/lifecycles.js.map +2 -2
  19. package/dist/cjs/decorators/subscribeSwcAppRouteChangeWhileConnected.js +9 -3
  20. package/dist/cjs/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +2 -2
  21. package/dist/cjs/elements/SwcApp.js.map +2 -2
  22. package/dist/cjs/elements/SwcAppMixin.js +11 -4
  23. package/dist/cjs/elements/SwcAppMixin.js.map +2 -2
  24. package/dist/cjs/types/index.js.map +1 -1
  25. package/dist/esm/SwcAppEngine.js.map +2 -2
  26. package/dist/esm/decorators/applyAttribute.js +196 -113
  27. package/dist/esm/decorators/applyAttribute.js.map +2 -2
  28. package/dist/esm/decorators/applyNode.js +58 -43
  29. package/dist/esm/decorators/applyNode.js.map +2 -2
  30. package/dist/esm/decorators/applyProperty.js +194 -0
  31. package/dist/esm/decorators/applyProperty.js.map +7 -0
  32. package/dist/esm/decorators/applySlot.js +32 -26
  33. package/dist/esm/decorators/applySlot.js.map +2 -2
  34. package/dist/esm/decorators/changedAttributeThis.js.map +1 -1
  35. package/dist/esm/decorators/elementDefine.js +17 -30
  36. package/dist/esm/decorators/elementDefine.js.map +2 -2
  37. package/dist/esm/decorators/index.js +2 -2
  38. package/dist/esm/decorators/index.js.map +1 -1
  39. package/dist/esm/decorators/lifecycles.js +4 -4
  40. package/dist/esm/decorators/lifecycles.js.map +2 -2
  41. package/dist/esm/decorators/subscribeSwcAppRouteChangeWhileConnected.js +9 -3
  42. package/dist/esm/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +2 -2
  43. package/dist/esm/elements/SwcApp.js.map +2 -2
  44. package/dist/esm/elements/SwcAppMixin.js +11 -4
  45. package/dist/esm/elements/SwcAppMixin.js.map +2 -2
  46. package/dist/esm/types/index.js.map +1 -1
  47. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +441 -401
  48. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
  49. package/dist/types/SwcAppEngine.d.ts.map +1 -1
  50. package/dist/types/decorators/applyAttribute.d.ts +56 -15
  51. package/dist/types/decorators/applyAttribute.d.ts.map +1 -1
  52. package/dist/types/decorators/applyNode.d.ts +28 -24
  53. package/dist/types/decorators/applyNode.d.ts.map +1 -1
  54. package/dist/types/decorators/applyProperty.d.ts +61 -0
  55. package/dist/types/decorators/applyProperty.d.ts.map +1 -0
  56. package/dist/types/decorators/applySlot.d.ts +10 -10
  57. package/dist/types/decorators/applySlot.d.ts.map +1 -1
  58. package/dist/types/decorators/elementDefine.d.ts.map +1 -1
  59. package/dist/types/decorators/index.d.ts +2 -2
  60. package/dist/types/decorators/index.d.ts.map +1 -1
  61. package/dist/types/decorators/lifecycles.d.ts +4 -4
  62. package/dist/types/decorators/lifecycles.d.ts.map +1 -1
  63. package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts +2 -0
  64. package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts.map +1 -1
  65. package/dist/types/elements/SwcApp.d.ts.map +1 -1
  66. package/dist/types/elements/SwcAppMixin.d.ts.map +1 -1
  67. package/dist/types/types/index.d.ts +1 -6
  68. package/dist/types/types/index.d.ts.map +1 -1
  69. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +441 -401
  70. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
  71. package/package.json +3 -3
  72. package/src/SwcAppEngine.ts +1 -0
  73. package/src/decorators/applyAttribute.ts +311 -126
  74. package/src/decorators/applyNode.ts +68 -57
  75. package/src/decorators/applyProperty.ts +302 -0
  76. package/src/decorators/applySlot.ts +25 -18
  77. package/src/decorators/changedAttributeThis.ts +1 -1
  78. package/src/decorators/elementDefine.ts +41 -30
  79. package/src/decorators/index.ts +2 -3
  80. package/src/decorators/lifecycles.ts +6 -6
  81. package/src/decorators/subscribeSwcAppRouteChangeWhileConnected.ts +14 -4
  82. package/src/elements/SwcApp.ts +0 -1
  83. package/src/elements/SwcAppMixin.ts +16 -4
  84. package/src/types/index.ts +7 -7
  85. package/dist/cjs/decorators/attribute.js +0 -187
  86. package/dist/cjs/decorators/attribute.js.map +0 -7
  87. package/dist/cjs/decorators/setProperty.js +0 -109
  88. package/dist/cjs/decorators/setProperty.js.map +0 -7
  89. package/dist/esm/decorators/attribute.js +0 -168
  90. package/dist/esm/decorators/attribute.js.map +0 -7
  91. package/dist/esm/decorators/setProperty.js +0 -90
  92. package/dist/esm/decorators/setProperty.js.map +0 -7
  93. package/dist/types/decorators/attribute.d.ts +0 -31
  94. package/dist/types/decorators/attribute.d.ts.map +0 -1
  95. package/dist/types/decorators/setProperty.d.ts +0 -17
  96. package/dist/types/decorators/setProperty.d.ts.map +0 -1
  97. package/src/decorators/attribute.ts +0 -223
  98. package/src/decorators/setProperty.ts +0 -112
package/LICENSE.md ADDED
@@ -0,0 +1,7 @@
1
+ Copyright (c) 2016-21 these people
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -39,31 +39,31 @@ class Dashboard extends HTMLElement {
39
39
 
40
40
  ### 3. **Declarative DOM Updates**
41
41
 
42
- #### @onConnectedInnerHtml
42
+ #### @onConnectedShadow
43
43
  Render HTML automatically when component connects to DOM.
44
44
 
45
45
  ```typescript
46
- @onConnectedShadowDom
46
+ @onConnectedShadow
47
47
  render() {
48
48
  return `<div>Hello, <span>${this.name}</span>!</div>`;
49
49
  }
50
50
  ```
51
51
 
52
- #### @applyNodeThisInnerHtml
52
+ #### @innerHtmlLightNodeThis
53
53
  Apply HTML to specific host element.
54
54
 
55
55
  ```typescript
56
- @applyThisInnerHtmlNodeLightDom
56
+ @innerHtmlLightNodeThis
57
57
  updateContent() {
58
58
  return `<p>Updated content</p>`;
59
59
  }
60
60
  ```
61
61
 
62
- #### @applyNodeThisReplaceChildren
62
+ #### @replaceChildrenLightNodeThis
63
63
  Replace child nodes with new content.
64
64
 
65
65
  ```typescript
66
- @applyNodeThisReplaceChildrenLightDom
66
+ @replaceChildrenLightNodeThis
67
67
  replaceChildren(node: Node) {
68
68
  return node;
69
69
  }
@@ -73,39 +73,40 @@ replaceChildren(node: Node) {
73
73
  Manage dynamic content insertion into named slots using the `@applySlot` decorator. Slots are placeholders in templates that can be updated dynamically.
74
74
 
75
75
  ```typescript
76
+ import {clearSlot} from "./applySlot";
77
+
76
78
  @elementDefine('content-manager')
77
79
  class ContentManager extends HTMLElement {
78
-
80
+
79
81
 
80
82
  // Method: Replace children in slot with HTML
81
83
  @addEventListener('.update-btn', 'click')
82
- @applySlotReplaceChildren('main-content')
84
+ @replaceChildrenSlot('main-content')
83
85
  updateContent() {
84
86
  return '<div>Updated content here</div>';
85
87
  }
86
88
 
87
89
  // Method: Append HTML to slot
88
- @applySlotAppendHtml('main-content')
90
+ @appendHtmlSlot('main-content')
89
91
  addMoreContent() {
90
92
  return '<p>Additional content</p>';
91
93
  }
92
94
 
93
95
  // Method: Append text to slot
94
- @applySlotAppendText('sidebar')
96
+ @appendTextSlot('sidebar')
95
97
  addSidebarText() {
96
98
  return 'Sidebar text: ' + new Date().toISOString();
97
99
  }
98
100
 
99
101
  // Method: Clear slot content
100
102
  @addEventListener('.clear-btn', 'click')
101
- @applySlotClear('main-content')
103
+ @clearSlot('main-content')
102
104
  clearContent() {
103
105
  return true;
104
106
  }
105
107
 
106
-
107
108
 
108
- @onConnectedInnerHtml
109
+ @onConnectedLight
109
110
  render() {
110
111
  return `
111
112
  <div>
@@ -129,22 +130,28 @@ class ContentManager extends HTMLElement {
129
130
  - `<!--[[ slot-id ]]-->` - Named slot placeholder (HTML comment syntax)
130
131
 
131
132
  **@applySlot Decorator Variants:**
132
- - `@applySlot(id, options)` - Generic slot operation with position option
133
- - `@applySlotReplaceChildren(id)` - Replace all children with HTML
134
- - `@applySlotReplaceChildrenText(id)` - Replace all children with text
135
- - `@applySlotAppendHtml(id)` - Append HTML to slot
136
- - `@applySlotAppendText(id)` - Append text to slot
137
- - `@applySlotPrependHtml(id)` - Prepend HTML to slot
138
- - `@applySlotPrependText(id)` - Prepend text to slot
139
- - `@applySlotClear(id)` - Clear slot content
133
+ - clearSlot
134
+ - prependHtmlSlot
135
+ - prependSlot
136
+ - prependTextSlot
137
+ - appendHtmlSlot
138
+ - appendTextSlot
139
+ - appendSlot
140
+ - replaceChildrenHtmlSlot
141
+ - replaceChildrenSlot
142
+ - replaceChildrenTextSlot
143
+
140
144
 
141
145
  **Position Options:**
142
146
  ```typescript
143
147
  export type ApplySlotPosition =
148
+ | 'prepend'
144
149
  | 'prependHtml' // Add HTML at beginning
145
150
  | 'prependText' // Add text at beginning
151
+ | 'append'
146
152
  | 'appendHtml' // Add HTML at end
147
153
  | 'appendText' // Add text at end
154
+ | 'replaceChildren'
148
155
  | 'replaceChildrenHtml' // Replace all with HTML
149
156
  | 'replaceChildrenText' // Replace all with text
150
157
  | 'clear'; // Clear all content
@@ -184,14 +191,13 @@ class CounterApp extends HTMLElement {
184
191
  <!--[text Count: @count@ ]-->
185
192
 
186
193
  <!-- Attribute binding with a: prefix -->
187
- <div a:title="Count is @count@"></div>
194
+ <div a:title="'Count is'+@count@"></div>
188
195
 
189
196
  <!-- Event binding with e: prefix -->
190
197
  <button e:click="@increment@()">Increment (@count@)</button>
191
198
 
192
199
  <!-- Conditional rendering -->
193
200
  <div a:style="@isActive@ ? 'color: green' : 'color: red'">
194
- Status: @isActive@
195
201
  </div>
196
202
  </div>
197
203
  `;
@@ -240,7 +246,7 @@ class UserProfile extends HTMLElement {
240
246
  this.isEditing = !this.isEditing;
241
247
  }
242
248
 
243
- @onConnectedShadowDom
249
+ @onConnectedShadow
244
250
  render() {
245
251
  return `
246
252
  <div>
@@ -253,9 +259,7 @@ class UserProfile extends HTMLElement {
253
259
  <!--[html @isEditing@ ? '<input type="text" />' : '<span>View Mode</span>' ]-->
254
260
  </div>
255
261
 
256
- <button e:click="toggleEdit">
257
- @isEditing@ ? 'Save' : 'Edit'
258
- </button>
262
+ <button e:click="toggleEdit"> toggleEdit </button>
259
263
  </div>
260
264
  `;
261
265
  }
@@ -284,6 +288,17 @@ onCriticalClick(event: Event) {
284
288
  }
285
289
  ```
286
290
 
291
+ **other Event decorators**
292
+ - addEventListenerDelegateLightDom
293
+ - addEventListenerDelegateShadowDom
294
+ - addEventListenerDelegateAllDom
295
+ - addEventListenerDelegate
296
+ - addEventListenerThis
297
+ - addEventListenerAppHost
298
+ - addEventListenerWindow
299
+ - addEventListenerDocument
300
+
301
+
287
302
  #### @emitCustomEvent
288
303
  Emit custom events with data.
289
304
 
@@ -384,11 +399,11 @@ printTag() {
384
399
  Bind HTML attributes to properties (automatic sync).
385
400
 
386
401
  ```typescript
387
- @attribute
388
- width: string = '100px';
402
+ @attributeThis
403
+ width: string = '100px'; // Bind to this.width
389
404
 
390
405
  @attribute('data-id')
391
- resourceId: string = '';
406
+ resourceId: string; // element attribute first
392
407
  ```
393
408
 
394
409
  #### @attributeThis
@@ -396,7 +411,7 @@ Bind attributes on host element itself.
396
411
 
397
412
  ```typescript
398
413
  @attributeThis('product-id')
399
- productId: string = '';
414
+ productId?: string;
400
415
 
401
416
  @onInitialize
402
417
  onconstructor() {
@@ -632,41 +647,213 @@ w.document.addEventListener('DOMContentLoaded', async () => {
632
647
 
633
648
  ```typescript
634
649
  // Component factory
650
+ import {defineSwcApp} from "./SwcApp";
651
+
635
652
  export default (w: Window) => {
636
653
  const tagName = 'my-component';
637
654
  const existing = w.customElements.get(tagName);
638
655
  if (existing) return tagName;
639
656
 
640
- @elementDefine(tagName, { window: w })
657
+ @elementDefine(tagName, {window: w})
641
658
  class MyComponent extends w.HTMLElement {
642
659
  @onInitialize
643
660
  onconstructor(service: MyService) {
644
661
  this.service = service;
645
662
  }
646
663
  }
647
-
664
+
648
665
  return tagName;
649
666
  };
650
667
 
651
668
  // Boot factory
652
669
  export default (w: Window, container: symbol) => {
653
670
  serviceFactories.forEach(s => s(container));
654
- register(w, [...pageFactories, ...componentFactories]);
655
671
  };
656
672
 
657
673
  // Entry point
658
674
  const container = Symbol('app');
659
- bootFactory(w, container);
675
+ await defineSwcAppBody(w)
676
+ const appElement = w.document.querySelector('#app') as SwcAppInterface;
660
677
  appElement.connect({
661
678
  container,
662
679
  window: w,
680
+ onStartedLazyDefineComponent: [...pageFactories, ...componentFactories],
663
681
  onEngineStarted: () => {
664
682
  appElement.innerHTML = '<root-router></root-router>';
665
683
  }
666
684
  });
667
685
  ```
668
686
 
669
- ### 11. **Accommodation Pattern**
687
+ ### 11. **Routing with @subscribeSwcAppRouteChangeWhileConnected**
688
+
689
+ SWC provides declarative routing with automatic path matching, order-based execution, and optional propagation control.
690
+
691
+ #### Basic Routing Setup
692
+
693
+ ```typescript
694
+ @elementDefine('root-router')
695
+ class RootRouter extends HTMLElement {
696
+ @subscribeSwcAppRouteChangeWhileConnected(['', '/'], { order: 0 })
697
+ @innerHtmlLightNodeThis
698
+ handleHome(routerPathSet: RouterEventType) {
699
+ return `<landing-page/>`;
700
+ }
701
+
702
+ @subscribeSwcAppRouteChangeWhileConnected(['/products'], { order: 1 })
703
+ @innerHtmlLightNodeThis
704
+ handleProducts(routerPathSet: RouterEventType) {
705
+ return `<products-list/>`;
706
+ }
707
+
708
+ @subscribeSwcAppRouteChangeWhileConnected(['/product/{id}'], { order: 2 })
709
+ @innerHtmlLightNodeThis
710
+ handleProductDetail(routerPathSet: RouterEventType) {
711
+ const { id } = routerPathSet.pathData;
712
+ return `<product-detail product-id="${id}"/>`;
713
+ }
714
+
715
+ @subscribeSwcAppRouteChangeWhileConnected(['/{tail:.*}'], { order: 999 })
716
+ @innerHtmlLightNodeThis
717
+ handle404(routerPathSet: RouterEventType) {
718
+ return `<not-found-page/>`;
719
+ }
720
+ }
721
+ ```
722
+
723
+ #### Route Handler Features
724
+
725
+ **1. Path Matching**
726
+ - Exact match: `['', '/']` - matches home route
727
+ - Prefix match: `['/products']` - matches `/products` and `/products/...`
728
+ - Dynamic segments: `['/product/{id}']` - captures `id` parameter
729
+ - Wildcard: `['/{tail:.*}']` - matches any remaining path (use for 404)
730
+
731
+ **2. Order-Based Execution**
732
+ Routes are executed in order of `order` value (lowest first). First matching route with a return value stops propagation:
733
+
734
+ ```typescript
735
+ @subscribeSwcAppRouteChangeWhileConnected(['', '/'], { order: 0 }) // Checked first
736
+ @subscribeSwcAppRouteChangeWhileConnected(['/admin'], { order: 1 }) // Checked second
737
+ @subscribeSwcAppRouteChangeWhileConnected(['/{tail:.*}'], { order: 999 }) // Checked last (404)
738
+ ```
739
+
740
+ **3. Propagation Control**
741
+ - **Return a value** (HTML string) → Stops propagation to next handlers
742
+ - **Return undefined/null** → Continues to next handler
743
+
744
+ ```typescript
745
+ // This handler stops propagation (returns HTML)
746
+ @subscribeSwcAppRouteChangeWhileConnected(['/admin'], { order: 1 })
747
+ @innerHtmlLightNodeThis
748
+ handleAdmin(routerPathSet: RouterEventType) {
749
+ return `<admin-panel/>`; // ✅ Stops here
750
+ }
751
+
752
+ // This handler continues propagation (no return value)
753
+ @subscribeSwcAppRouteChangeWhileConnected(['*'], { order: -1 })
754
+ onRouteChange(routerPathSet: RouterEventType) {
755
+ console.log('Route changed:', routerPathSet.path);
756
+ // No return value → continues to next handler
757
+ }
758
+ ```
759
+
760
+ #### Advanced Example with Logging
761
+
762
+ ```typescript
763
+ @elementDefine('accommodation-router')
764
+ class AccommodationRouter extends HTMLElement {
765
+ // Global route logger (order: -1 runs first, no return value)
766
+ @subscribeSwcAppRouteChangeWhileConnected(['*'], { order: -1 })
767
+ onRouteChange(routerPathSet: RouterEventType) {
768
+ console.log('[Route Change]', {
769
+ path: routerPathSet.path,
770
+ pathData: routerPathSet.pathData,
771
+ timestamp: new Date().toISOString()
772
+ });
773
+ // No return → continues to route handlers
774
+ }
775
+
776
+ // Home route
777
+ @subscribeSwcAppRouteChangeWhileConnected(['', '/'], { order: 0 })
778
+ @innerHtmlLightNodeThis
779
+ handleHome(routerPathSet: RouterEventType) {
780
+ console.log('[Route Handler] Home');
781
+ return `<landing-page/>`;
782
+ }
783
+
784
+ // List route
785
+ @subscribeSwcAppRouteChangeWhileConnected(['/list'], { order: 1 })
786
+ @innerHtmlLightNodeThis
787
+ handleList(routerPathSet: RouterEventType) {
788
+ console.log('[Route Handler] List');
789
+ return `<list-page/>`;
790
+ }
791
+
792
+ // Detail route with dynamic parameter
793
+ @subscribeSwcAppRouteChangeWhileConnected(['/detail/{productId}'], { order: 2 })
794
+ @innerHtmlLightNodeThis
795
+ handleDetail(routerPathSet: RouterEventType) {
796
+ const { productId } = routerPathSet.pathData;
797
+ console.log('[Route Handler] Detail', { productId });
798
+ return `<detail-page product-id="${productId}"/>`;
799
+ }
800
+
801
+ // 404 fallback (order: 999 runs last)
802
+ @subscribeSwcAppRouteChangeWhileConnected(['/{tail:.*}'], { order: 999 })
803
+ @innerHtmlLightNodeThis
804
+ handle404(routerPathSet: RouterEventType) {
805
+ console.log('[Route Handler] 404 Not Found', routerPathSet.path);
806
+ return `<not-found-page/>`;
807
+ }
808
+ }
809
+ ```
810
+
811
+ #### Router Configuration Options
812
+
813
+ ```typescript
814
+ interface SwcAppRouteChangeOptions {
815
+ path?: RoutePathType; // Route path pattern(s)
816
+ order?: number; // Execution order (default: 0)
817
+ filter?: (router: Router, meta: {currentThis: any, helper: HelperHostSet}) => boolean;
818
+ }
819
+ ```
820
+
821
+ **Usage:**
822
+ ```typescript
823
+ @subscribeSwcAppRouteChangeWhileConnected(
824
+ ['/admin/{section}'],
825
+ {
826
+ order: 5,
827
+ filter: (router, meta) => meta.currentThis.isAdmin === true
828
+ }
829
+ )
830
+ @innerHtmlLightNodeThis
831
+ handleAdminSection(routerPathSet: RouterEventType) {
832
+ const { section } = routerPathSet.pathData;
833
+ return `<admin-${section}/>`;
834
+ }
835
+ ```
836
+
837
+ #### RouterEventType Structure
838
+
839
+ ```typescript
840
+ type RouterEventType = {
841
+ path: string; // Current route path
842
+ pathData: Record<string, any>; // Extracted path parameters
843
+ triggerPoint: 'start' | 'end'; // Route change phase
844
+ };
845
+ ```
846
+
847
+ **Example with path parameters:**
848
+ ```
849
+ Route: /product/{id}
850
+ URL: /product/123
851
+ pathData: { id: '123' }
852
+ ```
853
+
854
+ ---
855
+
856
+ ### 12. **Accommodation Pattern**
670
857
  Factory-based component registration with explicit DI.
671
858
 
672
859
  ```typescript
@@ -700,18 +887,18 @@ export default (w: Window) => {
700
887
  ## ⚠️ Critical Rules
701
888
 
702
889
  ### DO NOT Use @Sim on Web Components
703
- `@Sim` is for **Services only**. Web Components should use `@elementDefine`.
890
+ `@sim` is for **Services only**. Web Components should use `@elementDefine`.
704
891
 
705
892
  ```typescript
706
893
  // ✅ CORRECT
707
- @Sim
894
+ @sim
708
895
  export class UserService { }
709
896
 
710
897
  @elementDefine(tagName, { window: w })
711
898
  class UserWidget extends w.HTMLElement { }
712
899
 
713
900
  // ❌ WRONG
714
- @Sim
901
+ @sim
715
902
  @elementDefine(tagName, { window: w })
716
903
  class UserWidget extends w.HTMLElement { }
717
904
  ```
@@ -734,7 +921,7 @@ export default (w: Window) => {
734
921
  ```typescript
735
922
  // ✅ CORRECT
736
923
  @onInitialize
737
- onconstructor(@Inject(symbol: Service.SYMBOL) service: Service) {
924
+ onconstructor(@inject(Service.SYMBOL) service: Service) {
738
925
  this.service = service;
739
926
  }
740
927
 
@@ -746,19 +933,20 @@ constructor(private service: Service) { super(); } // Web Components can't have
746
933
 
747
934
  ## 📚 Examples
748
935
 
749
- - **[Commerce (E-Commerce SPA)](./examples/commerce)** - Full shopping cart example
750
- - **[Stock (Market Dashboard)](./examples/stock)** - Real-time data with routing
751
- - **[Accommodation (Reference Pattern)](./examples/accommodation)** - Standard setup pattern
936
+ - **[Commerce (E-Commerce SPA)](https://github.com/dooboostore-develop/packages/tree/main/%40dooboostore/simple-web-component/examples/commerce)** - Full shopping cart example
937
+ - **[Stock (Market Dashboard)](https://github.com/dooboostore-develop/packages/tree/main/%40dooboostore/simple-web-component/examples/stock)** - Real-time data with routing
938
+ - **[Accommodation (Reference Pattern)](https://github.com/dooboostore-develop/packages/tree/main/%40dooboostore/simple-web-component/examples/accommodation)** - Standard setup pattern
752
939
 
753
940
  ---
754
941
 
755
942
  ## 🔗 Related Packages
756
943
 
757
- - **[@dooboostore/simple-boot](../simple-boot)** - DI & AOP Container
758
- - **[@dooboostore/core-web](../core-web)** - Web Utilities & Router
759
- - **[@dooboostore/dom-parser](../dom-parser)** - HTML Parsing & AST
944
+ - **[@dooboostore/simple-boot](https://github.com/dooboostore-develop/packages/tree/main/%40dooboostore/simple-boot)** - DI & AOP Container
945
+ - **[@dooboostore/core-web](https://github.com/dooboostore-develop/packages/tree/main/%40dooboostore/core-web)** - Web Utilities & Router
946
+ - **[@dooboostore/dom-parser](https://github.com/dooboostore-develop/packages/tree/main/%40dooboostore/dom-parser)** - HTML Parsing & AST
760
947
 
761
948
  ---
762
949
 
763
950
  ## 📄 License
764
- MIT © 2024 dooboostore-develop
951
+ [MIT License](https://github.com/dooboostore-develop/packages/tree/main/%40dooboostore/simple-web-component/LICENSE.md)
952
+
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
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';\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 \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 onStartedLazyDefineComponent?: ((w: Window)=> Promise<CustomElementConstructor> | void | string | any | CustomElementConstructor)[];\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\n if (this._config.onStartedLazyDefineComponent) {\n await Promise.all(this._config.onStartedLazyDefineComponent.map(it => it(this._config.window)))\n }\n if (this._config.onEngineStarted) {\n await this._config.onEngineStarted(this.simpleApplication, this.host as unknown as SwcAppInterface);\n }\n } catch (e) {\n console.error('[SWC-APP-ENGINE] Init failed:', e, this._config);\n }\n }\n\n disconnect() {\n this.routerSubscription?.unsubscribe();\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAAkC;AAClC,sBAAgE;AAChE,2BAA8B;AAC9B,IAAAA,sBAA0B;AAgCnB,MAAM,aAAa;AAAA,EAMxB,YAAoB,MAAmB;AAAnB;AALpB,wBAAO;AACP,wBAAO;AACP,wBAAQ;AACR,wBAAQ;AAAA,EAEgC;AAAA,EAExC,IAAI,SAAS;AACX,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAM,QAAQ,QAAuB;AACnC,QAAI;AACF,WAAK,UAAU;AAGf,UAAI,KAAK,QAAQ,cAAc,QAAQ;AACrC,aAAK,SAAS,IAAI,2BAAW,EAAE,QAAQ,KAAK,QAAQ,QAAQ,UAAU,KAAK,QAAQ,KAAK,CAAC;AAAA,MAC3F,WAAW,KAAK,QAAQ,cAAc,QAAQ;AAC5C,aAAK,SAAS,IAAI,2BAAW,EAAE,QAAQ,KAAK,QAAQ,QAAQ,UAAU,KAAK,QAAQ,KAAK,CAAC;AAAA,MAC3F,WAAW,KAAK,QAAQ,cAAc,WAAW;AAC/C,aAAK,SAAS,IAAI,mCAAc,EAAE,QAAQ,KAAK,QAAQ,QAAQ,UAAU,KAAK,QAAQ,KAAK,CAAC;AAAA,MAC9F;AAKA,WAAK,oBAAoB,IAAI;AAAA,QAC3B,IAAI,8BAAU;AAAA,UACZ,eAAe,CAAE,KAAK,QAAQ,OAAe,IAAI;AAAA,UACjD,WAAW,KAAK,QAAQ;AAAA,QAC1B,CAAC;AAAA,MACH;AAEA,YAAM,mBAAmB,oBAAI,IAAc;AAC3C,WAAK,QAAQ,kBAAkB,QAAQ,CAAC,GAAG,MAAM;AAC/C,yBAAiB,IAAI,GAAG,CAAC;AAAA,MAC3B,CAAC;AACD,UAAI,KAAK,OAAQ,kBAAiB,IAAI,wBAAQ,KAAK,MAAM;AACzD,WAAK,kBAAkB,IAAI,gBAAgB;AAG3C,UAAI,KAAK,QAAQ,8BAA8B;AAC7C,cAAM,QAAQ,IAAI,KAAK,QAAQ,6BAA6B,IAAI,QAAM,GAAG,KAAK,QAAQ,MAAM,CAAC,CAAC;AAAA,MAChG;AACA,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;",
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';\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 \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 onStartedLazyDefineComponent?: ((w: Window)=> Promise<CustomElementConstructor> | void | string | any | CustomElementConstructor)[];\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\n if (this._config.onStartedLazyDefineComponent) {\n // console.log('-------->', this._config.onStartedLazyDefineComponent)\n await Promise.all(this._config.onStartedLazyDefineComponent.map(it => it(this._config.window)))\n }\n if (this._config.onEngineStarted) {\n await this._config.onEngineStarted(this.simpleApplication, this.host as unknown as SwcAppInterface);\n }\n } catch (e) {\n console.error('[SWC-APP-ENGINE] Init failed:', e, this._config);\n }\n }\n\n disconnect() {\n this.routerSubscription?.unsubscribe();\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAAkC;AAClC,sBAAgE;AAChE,2BAA8B;AAC9B,IAAAA,sBAA0B;AAgCnB,MAAM,aAAa;AAAA,EAMxB,YAAoB,MAAmB;AAAnB;AALpB,wBAAO;AACP,wBAAO;AACP,wBAAQ;AACR,wBAAQ;AAAA,EAEgC;AAAA,EAExC,IAAI,SAAS;AACX,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAM,QAAQ,QAAuB;AACnC,QAAI;AACF,WAAK,UAAU;AAGf,UAAI,KAAK,QAAQ,cAAc,QAAQ;AACrC,aAAK,SAAS,IAAI,2BAAW,EAAE,QAAQ,KAAK,QAAQ,QAAQ,UAAU,KAAK,QAAQ,KAAK,CAAC;AAAA,MAC3F,WAAW,KAAK,QAAQ,cAAc,QAAQ;AAC5C,aAAK,SAAS,IAAI,2BAAW,EAAE,QAAQ,KAAK,QAAQ,QAAQ,UAAU,KAAK,QAAQ,KAAK,CAAC;AAAA,MAC3F,WAAW,KAAK,QAAQ,cAAc,WAAW;AAC/C,aAAK,SAAS,IAAI,mCAAc,EAAE,QAAQ,KAAK,QAAQ,QAAQ,UAAU,KAAK,QAAQ,KAAK,CAAC;AAAA,MAC9F;AAKA,WAAK,oBAAoB,IAAI;AAAA,QAC3B,IAAI,8BAAU;AAAA,UACZ,eAAe,CAAE,KAAK,QAAQ,OAAe,IAAI;AAAA,UACjD,WAAW,KAAK,QAAQ;AAAA,QAC1B,CAAC;AAAA,MACH;AAEA,YAAM,mBAAmB,oBAAI,IAAc;AAC3C,WAAK,QAAQ,kBAAkB,QAAQ,CAAC,GAAG,MAAM;AAC/C,yBAAiB,IAAI,GAAG,CAAC;AAAA,MAC3B,CAAC;AACD,UAAI,KAAK,OAAQ,kBAAiB,IAAI,wBAAQ,KAAK,MAAM;AACzD,WAAK,kBAAkB,IAAI,gBAAgB;AAG3C,UAAI,KAAK,QAAQ,8BAA8B;AAE7C,cAAM,QAAQ,IAAI,KAAK,QAAQ,6BAA6B,IAAI,QAAM,GAAG,KAAK,QAAQ,MAAM,CAAC,CAAC;AAAA,MAChG;AACA,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
6
  "names": ["import_simple_boot"]
7
7
  }