@dooboostore/simple-boot-http-server-ssr 1.0.14 → 1.0.15

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 (157) hide show
  1. package/README.MD +131 -0
  2. package/dist/cjs/SimpleBootHttpSSRFactory.js.map +1 -1
  3. package/dist/cjs/SimpleBootHttpSSRServer.js +1 -0
  4. package/dist/cjs/SimpleBootHttpSSRServer.js.map +2 -2
  5. package/dist/cjs/bundle-entry.js +0 -2
  6. package/dist/cjs/bundle-entry.js.map +2 -2
  7. package/dist/cjs/decorators/LoadAroundBefore.js +2 -2
  8. package/dist/cjs/decorators/LoadAroundBefore.js.map +2 -2
  9. package/dist/cjs/filters/SSRDomParserFilter.js +54 -89
  10. package/dist/cjs/filters/SSRDomParserFilter.js.map +2 -2
  11. package/dist/cjs/filters/SSRFilter.js +10 -14
  12. package/dist/cjs/filters/SSRFilter.js.map +2 -2
  13. package/dist/cjs/filters/SSRLinkDomDomFilter.js +10 -14
  14. package/dist/cjs/filters/SSRLinkDomDomFilter.js.map +2 -2
  15. package/dist/cjs/filters/SSRSimpleWebComponentFilter.js +93 -0
  16. package/dist/cjs/filters/SSRSimpleWebComponentFilter.js.map +7 -0
  17. package/dist/cjs/filters/SSRWorker.js +2 -2
  18. package/dist/cjs/filters/SSRWorker.js.map +2 -2
  19. package/dist/cjs/filters/index.js +2 -2
  20. package/dist/cjs/filters/index.js.map +2 -2
  21. package/dist/cjs/index.js +18 -8
  22. package/dist/cjs/index.js.map +2 -2
  23. package/dist/cjs/initializers/DomParserInitializer.js +5 -2
  24. package/dist/cjs/initializers/DomParserInitializer.js.map +2 -2
  25. package/dist/cjs/proxy/SSRDomParserFilterDataHydrationProxy.js +92 -0
  26. package/dist/cjs/proxy/SSRDomParserFilterDataHydrationProxy.js.map +7 -0
  27. package/dist/cjs/proxy/index.js +2 -8
  28. package/dist/cjs/proxy/index.js.map +2 -2
  29. package/dist/esm/SimpleBootHttpSSRFactory.js.map +1 -1
  30. package/dist/esm/SimpleBootHttpSSRServer.js +1 -0
  31. package/dist/esm/SimpleBootHttpSSRServer.js.map +2 -2
  32. package/dist/esm/bundle-entry.js +0 -1
  33. package/dist/esm/bundle-entry.js.map +2 -2
  34. package/dist/esm/decorators/LoadAroundBefore.js +1 -1
  35. package/dist/esm/decorators/LoadAroundBefore.js.map +1 -1
  36. package/dist/esm/filters/SSRDomParserFilter.js +52 -87
  37. package/dist/esm/filters/SSRDomParserFilter.js.map +2 -2
  38. package/dist/esm/filters/SSRFilter.js +7 -11
  39. package/dist/esm/filters/SSRFilter.js.map +2 -2
  40. package/dist/esm/filters/SSRLinkDomDomFilter.js +7 -11
  41. package/dist/esm/filters/SSRLinkDomDomFilter.js.map +2 -2
  42. package/dist/esm/filters/SSRSimpleWebComponentFilter.js +70 -0
  43. package/dist/esm/filters/SSRSimpleWebComponentFilter.js.map +7 -0
  44. package/dist/esm/filters/SSRWorker.js +1 -1
  45. package/dist/esm/filters/SSRWorker.js.map +2 -2
  46. package/dist/esm/filters/index.js +1 -1
  47. package/dist/esm/filters/index.js.map +1 -1
  48. package/dist/esm/index.js +7 -4
  49. package/dist/esm/index.js.map +2 -2
  50. package/dist/esm/initializers/DomParserInitializer.js +6 -3
  51. package/dist/esm/initializers/DomParserInitializer.js.map +2 -2
  52. package/dist/esm/proxy/SSRDomParserFilterDataHydrationProxy.js +69 -0
  53. package/dist/esm/proxy/SSRDomParserFilterDataHydrationProxy.js.map +7 -0
  54. package/dist/esm/proxy/index.js +1 -4
  55. package/dist/esm/proxy/index.js.map +2 -2
  56. package/dist/esm-bundle/dooboostore-simple-boot-http-server-ssr.esm.js +20723 -8294
  57. package/dist/esm-bundle/dooboostore-simple-boot-http-server-ssr.esm.js.map +4 -4
  58. package/dist/types/SimpleBootHttpSSRFactory.d.ts +1 -1
  59. package/dist/types/SimpleBootHttpSSRFactory.d.ts.map +1 -1
  60. package/dist/types/SimpleBootHttpSSRServer.d.ts +3 -2
  61. package/dist/types/SimpleBootHttpSSRServer.d.ts.map +1 -1
  62. package/dist/types/bundle-entry.d.ts +0 -1
  63. package/dist/types/bundle-entry.d.ts.map +1 -1
  64. package/dist/types/filters/SSRDomParserFilter.d.ts +10 -16
  65. package/dist/types/filters/SSRDomParserFilter.d.ts.map +1 -1
  66. package/dist/types/filters/SSRFilter.d.ts +1 -1
  67. package/dist/types/filters/SSRFilter.d.ts.map +1 -1
  68. package/dist/types/filters/SSRLinkDomDomFilter.d.ts +1 -1
  69. package/dist/types/filters/SSRLinkDomDomFilter.d.ts.map +1 -1
  70. package/dist/types/filters/SSRSimpleWebComponentFilter.d.ts +37 -0
  71. package/dist/types/filters/SSRSimpleWebComponentFilter.d.ts.map +1 -0
  72. package/dist/types/filters/SSRWorker.d.ts +1 -1
  73. package/dist/types/filters/SSRWorker.d.ts.map +1 -1
  74. package/dist/types/filters/index.d.ts +1 -1
  75. package/dist/types/filters/index.d.ts.map +1 -1
  76. package/dist/types/index.d.ts +7 -2
  77. package/dist/types/index.d.ts.map +1 -1
  78. package/dist/types/initializers/DomParserInitializer.d.ts +2 -0
  79. package/dist/types/initializers/DomParserInitializer.d.ts.map +1 -1
  80. package/dist/types/proxy/SSRDomParserFilterDataHydrationProxy.d.ts +7 -0
  81. package/dist/types/proxy/SSRDomParserFilterDataHydrationProxy.d.ts.map +1 -0
  82. package/dist/types/proxy/index.d.ts +1 -4
  83. package/dist/types/proxy/index.d.ts.map +1 -1
  84. package/dist/umd-bundle/dooboostore-simple-boot-http-server-ssr.umd.js +20726 -8301
  85. package/dist/umd-bundle/dooboostore-simple-boot-http-server-ssr.umd.js.map +4 -4
  86. package/package.json +16 -10
  87. package/src/SimpleBootHttpSSRFactory.ts +1 -1
  88. package/src/SimpleBootHttpSSRServer.ts +5 -3
  89. package/src/bundle-entry.ts +0 -1
  90. package/src/decorators/LoadAroundBefore.ts +1 -1
  91. package/src/filters/SSRDomParserFilter.ts +111 -124
  92. package/src/filters/SSRFilter.ts +7 -12
  93. package/src/filters/SSRLinkDomDomFilter.ts +7 -12
  94. package/src/filters/SSRSimpleWebComponentFilter.ts +103 -0
  95. package/src/filters/SSRWorker.ts +1 -2
  96. package/src/filters/index.ts +1 -1
  97. package/src/index.ts +7 -9
  98. package/src/initializers/DomParserInitializer.ts +9 -2
  99. package/src/proxy/SSRDomParserFilterDataHydrationProxy.ts +63 -0
  100. package/src/proxy/index.ts +1 -4
  101. package/tsconfig.json +1 -0
  102. package/dist/cjs/codes/HttpHeaders.js +0 -41
  103. package/dist/cjs/codes/HttpHeaders.js.map +0 -7
  104. package/dist/cjs/codes/Mimes.js +0 -33
  105. package/dist/cjs/codes/Mimes.js.map +0 -7
  106. package/dist/cjs/codes/index.js +0 -24
  107. package/dist/cjs/codes/index.js.map +0 -7
  108. package/dist/cjs/filters/IntentSchemeFilter.js +0 -92
  109. package/dist/cjs/filters/IntentSchemeFilter.js.map +0 -7
  110. package/dist/cjs/proxy/IntentSchemeFrontProxy.js +0 -87
  111. package/dist/cjs/proxy/IntentSchemeFrontProxy.js.map +0 -7
  112. package/dist/cjs/proxy/IntentSchemeServerProxy.js +0 -67
  113. package/dist/cjs/proxy/IntentSchemeServerProxy.js.map +0 -7
  114. package/dist/cjs/proxy/SymbolIntentApiServiceProxy.js +0 -138
  115. package/dist/cjs/proxy/SymbolIntentApiServiceProxy.js.map +0 -7
  116. package/dist/cjs/proxy/SymbolIntentApiServiceProxyBase.js +0 -35
  117. package/dist/cjs/proxy/SymbolIntentApiServiceProxyBase.js.map +0 -7
  118. package/dist/esm/codes/HttpHeaders.js +0 -17
  119. package/dist/esm/codes/HttpHeaders.js.map +0 -7
  120. package/dist/esm/codes/Mimes.js +0 -10
  121. package/dist/esm/codes/Mimes.js.map +0 -7
  122. package/dist/esm/codes/index.js +0 -3
  123. package/dist/esm/codes/index.js.map +0 -7
  124. package/dist/esm/filters/IntentSchemeFilter.js +0 -69
  125. package/dist/esm/filters/IntentSchemeFilter.js.map +0 -7
  126. package/dist/esm/proxy/IntentSchemeFrontProxy.js +0 -64
  127. package/dist/esm/proxy/IntentSchemeFrontProxy.js.map +0 -7
  128. package/dist/esm/proxy/IntentSchemeServerProxy.js +0 -44
  129. package/dist/esm/proxy/IntentSchemeServerProxy.js.map +0 -7
  130. package/dist/esm/proxy/SymbolIntentApiServiceProxy.js +0 -115
  131. package/dist/esm/proxy/SymbolIntentApiServiceProxy.js.map +0 -7
  132. package/dist/esm/proxy/SymbolIntentApiServiceProxyBase.js +0 -12
  133. package/dist/esm/proxy/SymbolIntentApiServiceProxyBase.js.map +0 -7
  134. package/dist/types/codes/HttpHeaders.d.ts +0 -45
  135. package/dist/types/codes/HttpHeaders.d.ts.map +0 -1
  136. package/dist/types/codes/Mimes.d.ts +0 -31
  137. package/dist/types/codes/Mimes.d.ts.map +0 -1
  138. package/dist/types/codes/index.d.ts +0 -3
  139. package/dist/types/codes/index.d.ts.map +0 -1
  140. package/dist/types/filters/IntentSchemeFilter.d.ts +0 -20
  141. package/dist/types/filters/IntentSchemeFilter.d.ts.map +0 -1
  142. package/dist/types/proxy/IntentSchemeFrontProxy.d.ts +0 -4
  143. package/dist/types/proxy/IntentSchemeFrontProxy.d.ts.map +0 -1
  144. package/dist/types/proxy/IntentSchemeServerProxy.d.ts +0 -4
  145. package/dist/types/proxy/IntentSchemeServerProxy.d.ts.map +0 -1
  146. package/dist/types/proxy/SymbolIntentApiServiceProxy.d.ts +0 -18
  147. package/dist/types/proxy/SymbolIntentApiServiceProxy.d.ts.map +0 -1
  148. package/dist/types/proxy/SymbolIntentApiServiceProxyBase.d.ts +0 -5
  149. package/dist/types/proxy/SymbolIntentApiServiceProxyBase.d.ts.map +0 -1
  150. package/src/codes/HttpHeaders.ts +0 -17
  151. package/src/codes/Mimes.ts +0 -6
  152. package/src/codes/index.ts +0 -2
  153. package/src/filters/IntentSchemeFilter.ts +0 -69
  154. package/src/proxy/IntentSchemeFrontProxy.ts +0 -67
  155. package/src/proxy/IntentSchemeServerProxy.ts +0 -35
  156. package/src/proxy/SymbolIntentApiServiceProxy.ts +0 -115
  157. package/src/proxy/SymbolIntentApiServiceProxyBase.ts +0 -19
package/README.MD CHANGED
@@ -18,6 +18,7 @@ A framework for building Server-Side Rendered (SSR) applications by seamlessly i
18
18
  - **Automatic Data Hydration**: Serializes data fetched on the server and hydrates it on the client to avoid redundant API calls.
19
19
  - **Unified Codebase**: Enables sharing of routing, services, and components between the server and the client.
20
20
  - **Intent-based Communication**: Provides a mechanism for client-server communication using custom HTTP headers.
21
+ - **SimpleWebComponent Integration**: Seamless SSR support for `@dooboostore/simple-web-component` with automatic component registration and hydration.
21
22
 
22
23
  ## Quick Start
23
24
 
@@ -27,10 +28,140 @@ cd my-ssr-app
27
28
  npm start
28
29
  ```
29
30
 
31
+ ---
32
+
33
+ ## SimpleWebComponent SSR Integration
34
+
35
+ This package enables seamless Server-Side Rendering (SSR) for `@dooboostore/simple-web-component` applications. Here's how it works:
36
+
37
+ ### Backend Setup
38
+
39
+ Configure the server with `SSRSimpleWebComponentFilter` to handle SWC component registration and rendering:
40
+
41
+ ```typescript
42
+ import { SimpleBootHttpSSRServer } from '@dooboostore/simple-boot-http-server-ssr/SimpleBootHttpSSRServer';
43
+ import { HttpSSRServerOption } from '@dooboostore/simple-boot-http-server-ssr/option';
44
+ import { SSRSimpleWebComponentFilter } from '@dooboostore/simple-boot-http-server-ssr/filters/SSRSimpleWebComponentFilter';
45
+ import { ResourceFilter } from '@dooboostore/simple-boot-http-server/filters';
46
+ import swcRegister from '@dooboostore/simple-web-component';
47
+ import bootfactory from './bootfactory';
48
+
49
+ const swcFilter = new SSRSimpleWebComponentFilter({
50
+ frontDistPath: './dist-front-end',
51
+ frontDistIndexFileName: 'index.html',
52
+ registerComponents: async (window: any) => {
53
+ // Register SWC components in the virtual DOM
54
+ swcRegister(window);
55
+ const urlPath = window.location.pathname;
56
+ // Initialize your app with bootfactory
57
+ bootfactory(window, urlPath);
58
+ }
59
+ });
60
+
61
+ const server = new SimpleBootHttpSSRServer(
62
+ new HttpSSRServerOption({
63
+ listen: { port: 8080 },
64
+ filters: [new ResourceFilter('./dist-front-end'), swcFilter]
65
+ })
66
+ );
67
+
68
+ server.run();
69
+ ```
70
+
71
+ ### Universal Bootfactory Pattern
72
+
73
+ Use a universal bootfactory that runs on both server and client, detecting the environment and choosing the appropriate connection mode:
74
+
75
+ ```typescript
76
+ // src/bootfactory.ts
77
+ import register from '@dooboostore/simple-web-component';
78
+ import { componentFactories } from './components';
79
+ import { pageFactories } from './pages';
80
+
81
+ export default (window: Window, urlPath?: string) => {
82
+ // Register all SWC components
83
+ register(window, [...componentFactories, ...pageFactories]);
84
+
85
+ const appElement = window.document.querySelector('#app');
86
+ if (appElement?.connect) {
87
+ const isClientWindow = typeof window !== 'undefined' && window === globalThis.window;
88
+
89
+ appElement.connect({
90
+ rootRouter: RootRouter.SYMBOL,
91
+ routeType: 'path',
92
+ path: urlPath ?? '/',
93
+ window,
94
+ // Server renders with direct mode, client hydrates with swap mode
95
+ connectMode: isClientWindow ? 'swap' : 'direct'
96
+ });
97
+ }
98
+
99
+ return appElement;
100
+ };
101
+ ```
102
+
103
+ ### Client Entry Point
104
+
105
+ The client-side entry point simply calls the same bootfactory to hydrate the server-rendered markup:
106
+
107
+ ```typescript
108
+ // front-end/index.ts
109
+ import bootfactory from './bootfactory';
110
+ import { UrlUtils } from '@dooboostore/core/url';
111
+
112
+ console.log('🚀 Hydrating with SwcApplication...');
113
+ const w = window;
114
+ bootfactory(w, UrlUtils.getUrlPath(w.location));
115
+ ```
116
+
117
+ ### How It Works
118
+
119
+ 1. **Server Request**: Client sends GET request to `/user/123`
120
+ 2. **Virtual DOM Rendering**: `SSRSimpleWebComponentFilter` creates a virtual DOM environment via JSDOM
121
+ 3. **Component Registration**: Your `registerComponents` callback registers all SWC components
122
+ 4. **Bootfactory Initialization**: Bootfactory connects the app to the root router in **direct mode**
123
+ 5. **HTML Serialization**: The rendered virtual DOM is serialized to HTML and sent to the client
124
+ 6. **Client Hydration**: Browser loads the JavaScript and calls bootfactory again in **swap mode**
125
+ 7. **Zero FOUC**: User sees the fully rendered page immediately; JavaScript takes over seamlessly
126
+
127
+ ### Key Benefits
128
+
129
+ | Benefit | Description |
130
+ |---------|-------------|
131
+ | **SEO-Friendly** | Full HTML sent to search engines; all content indexable |
132
+ | **Fast FCP** | No "loading..." spinner; page is immediately interactive |
133
+ | **Preserved Tags** | Server-rendered DOM tags (data attributes, ARIA labels) remain intact |
134
+ | **Code Sharing** | Same routing, services, and components on server and client |
135
+ | **Zero FOUC** | Flash of Unstyled Content eliminated; page renders on server first |
136
+ | **Progressive Enhancement** | Core content works without JavaScript |
137
+
138
+ ---
139
+
30
140
  ## Learn More
31
141
 
32
142
  The detailed API documentation is available on our documentation website.
33
143
 
144
+ ## Security Hardening
145
+
146
+ Use the following baseline controls before deploying SSR applications to production:
147
+
148
+ - Restrict trusted origins and set strict CORS policy.
149
+ - Sanitize any user-derived values injected into HTML templates.
150
+ - Set `Content-Security-Policy`, `X-Content-Type-Options`, and `X-Frame-Options` headers.
151
+ - Validate and bound request payload size, query parameters, and header length.
152
+ - Use secure cookies (`HttpOnly`, `Secure`, `SameSite`) for session-related data.
153
+ - Add SSR timeout and concurrency limits to prevent resource exhaustion.
154
+ - Keep dependency versions updated and run vulnerability scans in CI.
155
+
156
+ ### Minimal Production Checklist
157
+
158
+ - HTTPS enforced end-to-end.
159
+ - Origin/cookie policy reviewed.
160
+ - CSP configured and tested for hydration scripts.
161
+ - Error responses avoid leaking stack traces.
162
+ - Request logs redact secrets and personal data.
163
+ - SSR pool size and queue limits tuned for expected traffic.
164
+
34
165
  ## License
35
166
 
36
167
  This package is licensed under the [MIT License](https://opensource.org/licenses/MIT).
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/SimpleBootHttpSSRFactory.ts"],
4
- "sourcesContent": ["import { SimpleBootFront } from '@dooboostore/simple-boot-front/SimpleBootFront';\nimport { ConstructorType } from '@dooboostore/core/types';\nimport { SimFrontOption } from '@dooboostore/simple-boot-front/option/SimFrontOption';\nexport abstract class SimpleBootHttpSSRFactory {\n public abstract factory(simFrontOption: SimFrontOption, using: (ConstructorType<any> | Function)[], domExcludes: ConstructorType<any>[]): Promise<SimpleBootFront> ;\n\n public async create(simFrontOption: SimFrontOption, using: (ConstructorType<any> | Function)[] = [], domExcludes: ConstructorType<any>[] = []): Promise<SimpleBootFront> {\n const front = await this.factory(simFrontOption, using, domExcludes);\n return front;\n }\n}\n"],
4
+ "sourcesContent": ["import { SimpleBootFront } from '@dooboostore/simple-boot-front/SimpleBootFront';\nimport { ConstructorType } from '@dooboostore/core';\nimport { SimFrontOption } from '@dooboostore/simple-boot-front/option/SimFrontOption';\nexport abstract class SimpleBootHttpSSRFactory {\n public abstract factory(simFrontOption: SimFrontOption, using: (ConstructorType<any> | Function)[], domExcludes: ConstructorType<any>[]): Promise<SimpleBootFront> ;\n\n public async create(simFrontOption: SimFrontOption, using: (ConstructorType<any> | Function)[] = [], domExcludes: ConstructorType<any>[] = []): Promise<SimpleBootFront> {\n const front = await this.factory(simFrontOption, using, domExcludes);\n return front;\n }\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,MAAe,yBAAyB;AAAA,EAG3C,MAAa,OAAO,gBAAgC,QAA6C,CAAC,GAAG,cAAsC,CAAC,GAA6B;AACrK,UAAM,QAAQ,MAAM,KAAK,QAAQ,gBAAgB,OAAO,WAAW;AACnE,WAAO;AAAA,EACX;AACJ;",
6
6
  "names": []
7
7
  }
@@ -27,6 +27,7 @@ class SimpleBootHttpSSRServer extends import_SimpleBootHttpServer.SimpleBootHttp
27
27
  }
28
28
  run(otherInstanceSim) {
29
29
  const oi = /* @__PURE__ */ new Map();
30
+ oi.set(SimpleBootHttpSSRServer, this);
30
31
  otherInstanceSim?.forEach((value, key) => oi.set(key, value));
31
32
  return super.run(oi);
32
33
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/SimpleBootHttpSSRServer.ts"],
4
- "sourcesContent": ["import { SimpleBootHttpServer } from '@dooboostore/simple-boot-http-server/SimpleBootHttpServer';\n// import { SimstanceManager } from '@dooboostore/simple-boot/simstance/SimstanceManager';\nimport { HttpSSRServerOption } from './option/HttpSSRServerOption';\nimport { ConstructorType } from '@dooboostore/core/types';\n\nexport class SimpleBootHttpSSRServer extends SimpleBootHttpServer {\n constructor(option?: HttpSSRServerOption) {\n super(option)\n }\n\n run(otherInstanceSim?: Map<ConstructorType<any>, any>) {\n const oi = new Map<ConstructorType<any>, any>()\n otherInstanceSim?.forEach((value, key) => oi.set(key, value));\n return super.run(oi);\n }\n\n // TODO: \uB098\uC911\uC5D0 \uBB50\uB77C\uB3C4..\n stop(){\n\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kCAAqC;AAK9B,MAAM,gCAAgC,iDAAqB;AAAA,EAChE,YAAY,QAA8B;AACxC,UAAM,MAAM;AAAA,EACd;AAAA,EAEA,IAAI,kBAAmD;AACrD,UAAM,KAAK,oBAAI,IAA+B;AAC9C,sBAAkB,QAAQ,CAAC,OAAO,QAAQ,GAAG,IAAI,KAAK,KAAK,CAAC;AAC5D,WAAO,MAAM,IAAI,EAAE;AAAA,EACrB;AAAA;AAAA,EAGA,OAAM;AAAA,EAEN;AACF;",
4
+ "sourcesContent": ["import { SimpleBootHttpServer } from '@dooboostore/simple-boot-http-server/SimpleBootHttpServer';\n// import { SimstanceManager } from '@dooboostore/simple-boot/simstance/SimstanceManager';\nimport { HttpSSRServerOption } from './option/HttpSSRServerOption';\nimport { ConstructorType } from '@dooboostore/core';\nimport {SimConfig} from \"@dooboostore/simple-boot/decorators/SimDecorator\";\n\nexport class SimpleBootHttpSSRServer extends SimpleBootHttpServer {\n constructor(option?: HttpSSRServerOption) {\n super(option)\n }\n\n run(otherInstanceSim?: Map<ConstructorType<any> | Function | SimConfig | Symbol, any>) {\n const oi = new Map<ConstructorType<any> | Function | SimConfig | Symbol, any>();\n oi.set(SimpleBootHttpSSRServer, this);\n otherInstanceSim?.forEach((value, key) => oi.set(key, value));\n return super.run(oi);\n }\n\n // TODO: \uB098\uC911\uC5D0 \uBB50\uB77C\uB3C4..\n stop(){\n\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kCAAqC;AAM9B,MAAM,gCAAgC,iDAAqB;AAAA,EAChE,YAAY,QAA8B;AACxC,UAAM,MAAM;AAAA,EACd;AAAA,EAEA,IAAI,kBAAmF;AACrF,UAAM,KAAK,oBAAI,IAA+D;AAC9E,OAAG,IAAI,yBAAyB,IAAI;AACpC,sBAAkB,QAAQ,CAAC,OAAO,QAAQ,GAAG,IAAI,KAAK,KAAK,CAAC;AAC5D,WAAO,MAAM,IAAI,EAAE;AAAA,EACrB;AAAA;AAAA,EAGA,OAAM;AAAA,EAEN;AACF;",
6
6
  "names": []
7
7
  }
@@ -14,7 +14,6 @@ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "defau
14
14
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
15
  var bundle_entry_exports = {};
16
16
  module.exports = __toCommonJS(bundle_entry_exports);
17
- __reExport(bundle_entry_exports, require("./codes"), module.exports);
18
17
  __reExport(bundle_entry_exports, require("./decorators"), module.exports);
19
18
  __reExport(bundle_entry_exports, require("./filters"), module.exports);
20
19
  __reExport(bundle_entry_exports, require("./initializers"), module.exports);
@@ -24,7 +23,6 @@ __reExport(bundle_entry_exports, require("./SimpleBootHttpSSRFactory"), module.e
24
23
  __reExport(bundle_entry_exports, require("./SimpleBootHttpSSRServer"), module.exports);
25
24
  // Annotate the CommonJS export names for ESM import in node:
26
25
  0 && (module.exports = {
27
- ...require("./codes"),
28
26
  ...require("./decorators"),
29
27
  ...require("./filters"),
30
28
  ...require("./initializers"),
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/bundle-entry.ts"],
4
- "sourcesContent": ["export * from './codes';\nexport * from './decorators';\nexport * from './filters';\nexport * from './initializers';\nexport * from './option';\nexport * from './proxy';\nexport * from './SimpleBootHttpSSRFactory';\nexport * from './SimpleBootHttpSSRServer';"],
5
- "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA,iCAAc,oBAAd;AACA,iCAAc,yBADd;AAEA,iCAAc,sBAFd;AAGA,iCAAc,2BAHd;AAIA,iCAAc,qBAJd;AAKA,iCAAc,oBALd;AAMA,iCAAc,uCANd;AAOA,iCAAc,sCAPd;",
4
+ "sourcesContent": ["export * from './decorators';\nexport * from './filters';\nexport * from './initializers';\nexport * from './option';\nexport * from './proxy';\nexport * from './SimpleBootHttpSSRFactory';\nexport * from './SimpleBootHttpSSRServer';"],
5
+ "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA,iCAAc,yBAAd;AACA,iCAAc,sBADd;AAEA,iCAAc,2BAFd;AAGA,iCAAc,qBAHd;AAIA,iCAAc,oBAJd;AAKA,iCAAc,uCALd;AAMA,iCAAc,sCANd;",
6
6
  "names": []
7
7
  }
@@ -22,14 +22,14 @@ __export(LoadAroundBefore_exports, {
22
22
  module.exports = __toCommonJS(LoadAroundBefore_exports);
23
23
  var import_SimDecorator = require("@dooboostore/simple-boot/decorators/SimDecorator");
24
24
  var import_AOPDecorator = require("@dooboostore/simple-boot/decorators/aop/AOPDecorator");
25
- var import_ReflectUtils = require("@dooboostore/core/reflect/ReflectUtils");
25
+ var import_core = require("@dooboostore/core");
26
26
  const LoadAroundBefore = (obj, propertyKey, args) => {
27
27
  const simstanceManager = obj._SimpleBoot_simstanceManager;
28
28
  const simOption = obj._SimpleBoot_simOption;
29
29
  const config = (0, import_SimDecorator.getSim)(obj);
30
30
  if (simstanceManager && simOption && config?.scheme) {
31
31
  const key = config.scheme + "_" + propertyKey;
32
- const type = import_ReflectUtils.ReflectUtils.getReturnType(obj, propertyKey);
32
+ const type = import_core.ReflectUtils.getReturnType(obj, propertyKey);
33
33
  const isHas = key in (simOption.window.server_side_data ?? {});
34
34
  if (isHas) {
35
35
  const data = simOption.window.server_side_data?.[key];
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/decorators/LoadAroundBefore.ts"],
4
- "sourcesContent": ["import { getSim } from '@dooboostore/simple-boot/decorators/SimDecorator';\nimport { AroundForceReturn } from '@dooboostore/simple-boot/decorators/aop/AOPDecorator';\nimport { ReflectUtils } from '@dooboostore/core/reflect/ReflectUtils';\n\nexport const LoadAroundBefore = (obj: any, propertyKey: string, args: any[]) => {\n const simstanceManager = obj._SimpleBoot_simstanceManager;\n const simOption = obj._SimpleBoot_simOption;\n const config = getSim(obj);\n if (simstanceManager && simOption && config?.scheme) {\n const key = config.scheme + '_' + propertyKey;\n const type = ReflectUtils.getReturnType(obj, propertyKey);\n const isHas = (key in (simOption.window.server_side_data ?? {}))\n if (isHas) {\n const data = simOption.window.server_side_data?.[key];\n delete simOption.window.server_side_data?.[key];\n let rdata;\n if (type === Promise) {\n rdata = Promise.resolve(data);\n } else {\n rdata = data;\n }\n throw new AroundForceReturn(rdata);\n } else {\n return args;\n }\n }\n return args;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAuB;AACvB,0BAAkC;AAClC,0BAA6B;AAEtB,MAAM,mBAAmB,CAAC,KAAU,aAAqB,SAAgB;AAC5E,QAAM,mBAAmB,IAAI;AAC7B,QAAM,YAAY,IAAI;AACtB,QAAM,aAAS,4BAAO,GAAG;AACzB,MAAI,oBAAoB,aAAa,QAAQ,QAAQ;AACjD,UAAM,MAAM,OAAO,SAAS,MAAM;AAClC,UAAM,OAAO,iCAAa,cAAc,KAAK,WAAW;AACxD,UAAM,QAAS,QAAQ,UAAU,OAAO,oBAAoB,CAAC;AAC7D,QAAI,OAAO;AACP,YAAM,OAAO,UAAU,OAAO,mBAAmB,GAAG;AACpD,aAAO,UAAU,OAAO,mBAAmB,GAAG;AAC9C,UAAI;AACJ,UAAI,SAAS,SAAS;AAClB,gBAAQ,QAAQ,QAAQ,IAAI;AAAA,MAChC,OAAO;AACH,gBAAQ;AAAA,MACZ;AACA,YAAM,IAAI,sCAAkB,KAAK;AAAA,IACrC,OAAO;AACH,aAAO;AAAA,IACX;AAAA,EACJ;AACA,SAAO;AACX;",
4
+ "sourcesContent": ["import { getSim } from '@dooboostore/simple-boot/decorators/SimDecorator';\nimport { AroundForceReturn } from '@dooboostore/simple-boot/decorators/aop/AOPDecorator';\nimport { ReflectUtils } from '@dooboostore/core';\n\nexport const LoadAroundBefore = (obj: any, propertyKey: string, args: any[]) => {\n const simstanceManager = obj._SimpleBoot_simstanceManager;\n const simOption = obj._SimpleBoot_simOption;\n const config = getSim(obj);\n if (simstanceManager && simOption && config?.scheme) {\n const key = config.scheme + '_' + propertyKey;\n const type = ReflectUtils.getReturnType(obj, propertyKey);\n const isHas = (key in (simOption.window.server_side_data ?? {}))\n if (isHas) {\n const data = simOption.window.server_side_data?.[key];\n delete simOption.window.server_side_data?.[key];\n let rdata;\n if (type === Promise) {\n rdata = Promise.resolve(data);\n } else {\n rdata = data;\n }\n throw new AroundForceReturn(rdata);\n } else {\n return args;\n }\n }\n return args;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAuB;AACvB,0BAAkC;AAClC,kBAA6B;AAEtB,MAAM,mBAAmB,CAAC,KAAU,aAAqB,SAAgB;AAC5E,QAAM,mBAAmB,IAAI;AAC7B,QAAM,YAAY,IAAI;AACtB,QAAM,aAAS,4BAAO,GAAG;AACzB,MAAI,oBAAoB,aAAa,QAAQ,QAAQ;AACjD,UAAM,MAAM,OAAO,SAAS,MAAM;AAClC,UAAM,OAAO,yBAAa,cAAc,KAAK,WAAW;AACxD,UAAM,QAAS,QAAQ,UAAU,OAAO,oBAAoB,CAAC;AAC7D,QAAI,OAAO;AACP,YAAM,OAAO,UAAU,OAAO,mBAAmB,GAAG;AACpD,aAAO,UAAU,OAAO,mBAAmB,GAAG;AAC9C,UAAI;AACJ,UAAI,SAAS,SAAS;AAClB,gBAAQ,QAAQ,QAAQ,IAAI;AAAA,MAChC,OAAO;AACH,gBAAQ;AAAA,MACZ;AACA,YAAM,IAAI,sCAAkB,KAAK;AAAA,IACrC,OAAO;AACH,aAAO;AAAA,IACX;AAAA,EACJ;AACA,SAAO;AACX;",
6
6
  "names": []
7
7
  }
@@ -20,121 +20,99 @@ __export(SSRDomParserFilter_exports, {
20
20
  SSRDomParserFilter: () => SSRDomParserFilter
21
21
  });
22
22
  module.exports = __toCommonJS(SSRDomParserFilter_exports);
23
+ var import_RequestResponse = require("@dooboostore/simple-boot-http-server/models/RequestResponse");
23
24
  var import_HttpHeaders = require("@dooboostore/simple-boot-http-server/codes/HttpHeaders");
25
+ var import_core = require("@dooboostore/core");
24
26
  var import_Mimes = require("@dooboostore/simple-boot-http-server/codes/Mimes");
25
27
  var import_HttpStatus = require("@dooboostore/simple-boot-http-server/codes/HttpStatus");
26
- var import_AsyncBlockingQueue = require("@dooboostore/core/queues/AsyncBlockingQueue");
27
- var import_RandomUtils = require("@dooboostore/core/random/RandomUtils");
28
28
  var import_NotFoundError = require("@dooboostore/simple-boot-http-server/errors/NotFoundError");
29
- var import_DomRenderProxy = require("@dooboostore/dom-render/DomRenderProxy");
30
- var import_filter = require("@dooboostore/core/message/operators/filter");
31
- var import_first = require("@dooboostore/core/message/operators/first");
32
- var import_firstValueFrom = require("@dooboostore/core/message/internal/firstValueFrom");
33
- var import_Promises = require("@dooboostore/core/promise/Promises");
29
+ var import_dom_render = require("@dooboostore/dom-render");
34
30
  var import_DomParserInitializer = require("../initializers/DomParserInitializer");
35
31
  class SSRDomParserFilter {
32
+ // private poolGeneration = 0;
33
+ // private intervalId?: NodeJS.Timeout;
36
34
  constructor(config, otherInstanceSim) {
37
35
  this.config = config;
38
36
  this.otherInstanceSim = otherInstanceSim;
39
- this.simpleBootFrontPool = [];
40
- this.simpleBootFrontQueue = new import_AsyncBlockingQueue.AsyncBlockingQueue();
37
+ // private simpleBootFrontPool: SimpleBootFront[] = [];
38
+ // private simpleBootFrontQueue = new AsyncBlockingQueue<SimpleBootFront>();
41
39
  // private indexHTML: string;
42
40
  this.welcomUrl = "http://localhost";
43
- this.poolGeneration = 0;
44
41
  config.frontDistIndexFileName = config.frontDistIndexFileName || "index.html";
45
42
  }
46
43
  async onInit(app) {
47
- for (let i = 0; i < this.config.poolOption.min; i++) {
48
- await this.pushQueue();
49
- }
50
- if (this.config.poolOption.clearIntervalTime && this.config.poolOption.clearIntervalTime > 0) {
51
- this.intervalId = setInterval(() => {
52
- this.poolGeneration++;
53
- }, this.config.poolOption.clearIntervalTime);
54
- }
55
44
  }
56
45
  async onDestroy() {
57
- if (this.intervalId) {
58
- clearInterval(this.intervalId);
59
- }
60
- this.simpleBootFrontPool.forEach((front) => {
61
- front.jsdom?.window.close();
62
- });
63
- this.simpleBootFrontPool = [];
64
46
  }
65
- async makePage() {
66
- let windowPromise = await new import_DomParserInitializer.DomParserInitializer(
67
- this.config.frontDistPath,
68
- this.config.frontDistIndexFileName || "index.html",
69
- { url: this.welcomUrl }
70
- ).run();
71
- return windowPromise;
47
+ async makePage(url = this.welcomUrl) {
48
+ const domParserInitializer = new import_DomParserInitializer.DomParserInitializer(this.config.frontDistPath, this.config.frontDistIndexFileName || "index.html", { url });
49
+ const window = await domParserInitializer.run();
50
+ return { window, domParserInitializer };
72
51
  }
73
- async makeFront(window) {
74
- const name = import_RandomUtils.RandomUtils.uuid();
52
+ async makeFront(window, otherInstanceSim) {
53
+ const name = import_core.RandomUtils.uuid();
75
54
  window.ssrUse = false;
76
- const option = this.config.factorySimFrontOption(import_DomRenderProxy.DomRenderProxy.final(window));
77
- const simpleBootFront = await this.config.factory.create(option, this.config.using, this.config.domExcludes);
78
- simpleBootFront.run(this.otherInstanceSim);
79
- simpleBootFront.generation = this.poolGeneration;
55
+ const option = this.config.factorySimFrontOption(import_dom_render.DomRenderProxy.final(window));
56
+ const domExcludes = [import_RequestResponse.RequestResponse, ...this.config.domExcludes || []];
57
+ const simpleBootFront = await this.config.factory.create(option, this.config.using, domExcludes);
58
+ otherInstanceSim ??= /* @__PURE__ */ new Map();
59
+ this.otherInstanceSim?.forEach((v, k) => otherInstanceSim.set(k, v));
60
+ simpleBootFront.run(otherInstanceSim);
80
61
  return simpleBootFront;
81
62
  }
82
- enqueueFrontApp(simpleBootFront) {
83
- this.simpleBootFrontPool.push(simpleBootFront);
84
- this.simpleBootFrontQueue.enqueue(simpleBootFront);
85
- }
86
- async pushQueue() {
87
- if (this.simpleBootFrontPool.length < this.config.poolOption.max) {
88
- this.enqueueFrontApp(await this.makeFront(await this.makePage()));
89
- }
90
- }
63
+ // enqueueFrontApp(simpleBootFront: SimpleBootFront) {
64
+ // // this.simpleBootFrontPool.set(simpleBootFront.option.name!, simpleBootFront);
65
+ // this.simpleBootFrontPool.push(simpleBootFront);
66
+ // this.simpleBootFrontQueue.enqueue(simpleBootFront);
67
+ // }
68
+ //
69
+ // async pushQueue() {
70
+ // if (this.simpleBootFrontPool.length < this.config.poolOption.max) {
71
+ // this.enqueueFrontApp(await this.makeFront(await this.makePage()));
72
+ // }
73
+ // }
91
74
  async proceedBefore({ rr, app }) {
92
75
  if (this.config.ssrExcludeFilter?.(rr)) {
93
76
  return false;
94
77
  }
95
78
  if (rr.reqHasAcceptHeader(import_Mimes.Mimes.TextHtml) || rr.reqHasAcceptHeader(import_Mimes.Mimes.All)) {
96
- if (this.simpleBootFrontQueue.isEmpty()) {
97
- await this.pushQueue();
98
- }
99
- const simpleBootFront = await this.simpleBootFrontQueue.dequeue();
79
+ const url = rr.reqUrlObj({ host: "localhost" });
80
+ const targetUrl = url.toString() ?? this.welcomUrl;
81
+ const { window, domParserInitializer } = await this.makePage(targetUrl);
82
+ const otherSim = /* @__PURE__ */ new Map();
83
+ otherSim.set(import_RequestResponse.RequestResponse, rr);
84
+ const simpleBootFront = await this.makeFront(window, otherSim);
100
85
  try {
101
86
  simpleBootFront.option.window.ssrUse = true;
102
- delete simpleBootFront.option.window.server_side_data;
103
- const url = rr.reqUrlObj({ host: "localhost" });
104
87
  if (this.config.simpleBootFront?.notFoundError) {
105
- const intent = await simpleBootFront.getIntent(url.pathname);
88
+ const intent = await simpleBootFront.routingRouterModule(url.pathname);
106
89
  if (intent.module === void 0 && !intent.getRouterPathData(rr.reqUrlPathName)) {
107
90
  throw new import_NotFoundError.NotFoundError({ message: `Not Found: ${rr.reqUrlPathName}` });
108
91
  }
109
92
  }
110
- const targetUrl = url.toString();
111
- await simpleBootFront.goRouting(targetUrl);
112
- await import_Promises.Promises.sleep(0);
113
- const data = await (0, import_firstValueFrom.firstValueFrom)(
114
- simpleBootFront.routingSubjectObservable.pipe(
115
- (0, import_filter.filter)(
116
- (it) => it.triggerPoint === "end" && typeof it.routerModule.intent.uri === "string" && targetUrl.endsWith(it.routerModule.intent.uri)
117
- ),
93
+ const data = await import_core.MessageInternal.firstValueFrom(
94
+ simpleBootFront.routingObservable.pipe(
95
+ import_core.MessageOperator.filter((it) => {
96
+ const sw = it.triggerPoint === "end" && typeof it.routerModule.intent.uri === "string" && targetUrl.endsWith(it.routerModule.intent.uri);
97
+ return sw;
98
+ }),
118
99
  // delay(1000),
119
- (0, import_first.first)()
100
+ import_core.MessageOperator.first()
120
101
  )
121
102
  );
122
- await import_Promises.Promises.sleep(0);
103
+ simpleBootFront.writeDataHydration();
104
+ simpleBootFront.clearDataHydration();
123
105
  const html = this.makeHTML(simpleBootFront);
124
106
  await this.writeOkHtmlAndEnd({ rr }, html);
125
107
  } finally {
126
- simpleBootFront.option.window.ssrUse = false;
127
- delete simpleBootFront.option.window.server_side_data;
128
- if (simpleBootFront.generation < this.poolGeneration) {
129
- const jsdom = simpleBootFront.jsdom;
130
- jsdom?.window.close();
131
- const index = this.simpleBootFrontPool.indexOf(simpleBootFront);
132
- if (index > -1) {
133
- this.simpleBootFrontPool.splice(index, 1);
134
- }
135
- this.pushQueue();
136
- } else {
137
- this.simpleBootFrontQueue.enqueue(simpleBootFront);
108
+ try {
109
+ simpleBootFront.option.window.ssrUse = false;
110
+ window.close();
111
+ simpleBootFront.onDestroy();
112
+ simpleBootFront.option.window?.close?.();
113
+ domParserInitializer.destroy();
114
+ } catch (e) {
115
+ console.log("eeeeee", e);
138
116
  }
139
117
  }
140
118
  return false;
@@ -155,19 +133,6 @@ class SSRDomParserFilter {
155
133
  html = "<!DOCTYPE html>" + html;
156
134
  }
157
135
  html = html.replace(/\$\{[\s\S]*?\}\$/g, "");
158
- const serverSideData = simpleBootFront.option.window.server_side_data;
159
- if (serverSideData) {
160
- const data = Object.entries(serverSideData).map(([k, v]) => {
161
- if (typeof v === "string") {
162
- return `window.server_side_data.${k} = ${v}`;
163
- } else {
164
- return `window.server_side_data.${k} = ${JSON.stringify(v)}`;
165
- }
166
- }).join(";");
167
- if (data) {
168
- html = html.replace("</head>", `<script> window.server_side_data={}; ${data}; </script></head>`);
169
- }
170
- }
171
136
  return html;
172
137
  }
173
138
  async writeOkHtmlAndEnd({ rr, status = import_HttpStatus.HttpStatus.Ok }, html) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/filters/SSRDomParserFilter.ts"],
4
- "sourcesContent": ["import { RequestResponse } from '@dooboostore/simple-boot-http-server/models/RequestResponse';\nimport { HttpHeaders } from '@dooboostore/simple-boot-http-server/codes/HttpHeaders';\nimport { SimpleBootHttpSSRFactory } from '../SimpleBootHttpSSRFactory';\nimport { ConstructorType } from '@dooboostore/core/types';\nimport { Filter } from '@dooboostore/simple-boot-http-server/filters/Filter';\nimport { Mimes } from '@dooboostore/simple-boot-http-server/codes/Mimes';\nimport { HttpStatus } from '@dooboostore/simple-boot-http-server/codes/HttpStatus';\nimport { SimpleBootHttpServer } from '@dooboostore/simple-boot-http-server/SimpleBootHttpServer';\nimport { SimFrontOption } from '@dooboostore/simple-boot-front/option/SimFrontOption';\nimport { SimpleBootFront } from '@dooboostore/simple-boot-front/SimpleBootFront';\nimport { AsyncBlockingQueue } from '@dooboostore/core/queues/AsyncBlockingQueue';\nimport { RandomUtils } from '@dooboostore/core/random/RandomUtils';\nimport * as JSDOM from 'jsdom';\nimport { NotFoundError } from '@dooboostore/simple-boot-http-server/errors/NotFoundError';\nimport { DomRenderProxy } from '@dooboostore/dom-render/DomRenderProxy';\nimport { filter } from '@dooboostore/core/message/operators/filter';\nimport { first } from '@dooboostore/core/message/operators/first';\nimport { delay } from '@dooboostore/core/message/operators/delay';\nimport { firstValueFrom } from '@dooboostore/core/message/internal/firstValueFrom';\nimport { parseHTML } from 'linkedom';\nimport {Promises} from '@dooboostore/core/promise/Promises';\nimport { DomParserInitializer } from '../initializers/DomParserInitializer';\n\nexport type FactoryAndParams = {\n frontDistPath: string;\n frontDistIndexFileName?: string;\n factorySimFrontOption: (window: any) => SimFrontOption;\n factory: SimpleBootHttpSSRFactory;\n poolOption: {\n max: number;\n min: number;\n clearIntervalTime?: number;\n };\n using: ConstructorType<any>[];\n domExcludes?: ConstructorType<any>[];\n ssrExcludeFilter?: (rr: RequestResponse) => boolean;\n simpleBootFront?: {\n notFoundError?: boolean;\n };\n};\n\nexport class SSRDomParserFilter implements Filter {\n private simpleBootFrontPool: SimpleBootFront[] = [];\n private simpleBootFrontQueue = new AsyncBlockingQueue<SimpleBootFront>();\n // private indexHTML: string;\n private welcomUrl = 'http://localhost';\n private poolGeneration = 0;\n private intervalId?: NodeJS.Timeout;\n\n constructor(\n public config: FactoryAndParams,\n public otherInstanceSim?: Map<ConstructorType<any>, any>\n ) {\n config.frontDistIndexFileName = config.frontDistIndexFileName || 'index.html';\n // this.indexHTML = JsdomInitializer.loadFile(this.config.frontDistPath, config.frontDistIndexFileName);\n }\n\n async onInit(app: SimpleBootHttpServer) {\n for (let i = 0; i < this.config.poolOption.min; i++) {\n await this.pushQueue();\n }\n\n if (this.config.poolOption.clearIntervalTime && this.config.poolOption.clearIntervalTime > 0) {\n this.intervalId = setInterval(() => {\n this.poolGeneration++;\n }, this.config.poolOption.clearIntervalTime);\n }\n }\n\n async onDestroy() {\n if (this.intervalId) {\n clearInterval(this.intervalId);\n }\n // this.simpleBootFrontQueue.clear();\n this.simpleBootFrontPool.forEach(front => {\n (front as any).jsdom?.window.close();\n });\n this.simpleBootFrontPool = [];\n }\n\n async makePage() {\n let windowPromise = await new DomParserInitializer(\n this.config.frontDistPath,\n this.config.frontDistIndexFileName || 'index.html',\n { url: this.welcomUrl }\n ).run();\n return windowPromise;\n // const jsdom = await new JsdomInitializer(\n // this.config.frontDistPath,\n // this.config.frontDistIndexFileName || 'index.html',\n // { url: this.welcomUrl }\n // ).run();\n // return jsdom;\n }\n\n async makeFront(window: Window) {\n const name = RandomUtils.uuid();\n (window as any).ssrUse = false;\n const option = this.config.factorySimFrontOption(DomRenderProxy.final(window));\n const simpleBootFront = await this.config.factory.create(option, this.config.using, this.config.domExcludes);\n simpleBootFront.run(this.otherInstanceSim);\n (simpleBootFront as any).generation = this.poolGeneration;\n return simpleBootFront;\n }\n\n enqueueFrontApp(simpleBootFront: SimpleBootFront) {\n // this.simpleBootFrontPool.set(simpleBootFront.option.name!, simpleBootFront);\n this.simpleBootFrontPool.push(simpleBootFront);\n this.simpleBootFrontQueue.enqueue(simpleBootFront);\n }\n async pushQueue() {\n if (this.simpleBootFrontPool.length < this.config.poolOption.max) {\n this.enqueueFrontApp(await this.makeFront(await this.makePage()));\n }\n }\n\n async proceedBefore({ rr, app }: { rr: RequestResponse; app: SimpleBootHttpServer; carrier: Map<string, any> }) {\n if (this.config.ssrExcludeFilter?.(rr)) {\n return false;\n }\n if (rr.reqHasAcceptHeader(Mimes.TextHtml) || rr.reqHasAcceptHeader(Mimes.All)) {\n if (this.simpleBootFrontQueue.isEmpty()) {\n await this.pushQueue();\n }\n const simpleBootFront = await this.simpleBootFrontQueue.dequeue();\n try {\n (simpleBootFront.option.window as any).ssrUse = true;\n delete (simpleBootFront.option.window as any).server_side_data;\n const url = rr.reqUrlObj({ host: 'localhost' });\n if (this.config.simpleBootFront?.notFoundError) {\n // intent router check first\n const intent = await simpleBootFront.getIntent(url.pathname);\n // route\uB97C \uBABB\uCC3E\uC740\uC0C1\uD0DC\uC5D0\uC11C router path\uAE4C\uC9C0 \uC548\uB9DE\uC73C\uBA74 404 \uCC98\uB9AC\uD55C\uB2E4. route\uB791 router\uB791 \uB2E4\uB974\uB2C8\uAE50 \uD5DB\uAC08\uB9AC\uC9C0\uB9D0\uB3C4\uB85D\n if (intent.module === undefined && !intent.getRouterPathData(rr.reqUrlPathName)) {\n throw new NotFoundError({ message: `Not Found: ${rr.reqUrlPathName}` });\n }\n }\n\n // runRouting!!\n const targetUrl = url.toString();\n // console.log('runRoutingrunRouting', targetUrl);\n await simpleBootFront.goRouting(targetUrl);\n await Promises.sleep(0); // <--\uC911\uC694: \uC774\uAC70 \uB123\uC5B4\uC57C\uC9C0 \uB450\uBC88\uBD88\uB7EC\uC9C0\uB294\uAC8C \uC5C6\uC5B4\uC9C0\uB294\uB4EF? \uBB50\uC9C0 event loop \uBCC0\uACBD\uB41C\uAC74\uAC00?\n\n // console.log('runRout22222ingrunRouting', targetUrl);\n\n // simpleBootFront.routingSubjectObservable.subscribe(it=>{\n // console.log('zzzzzzzzzzzzzzzzzzz', it);\n // if (it.triggerPoint==='end') {\n // console.log('zzz@@', it.routerModule.intent);\n // }\n // })\n\n const data = await firstValueFrom(\n simpleBootFront.routingSubjectObservable.pipe(\n filter(\n (it) =>\n it.triggerPoint === 'end' &&\n typeof it.routerModule.intent.uri === 'string' &&\n targetUrl.endsWith(it.routerModule.intent.uri)\n ),\n // delay(1000),\n first()\n )\n );\n // console.log('???????done');\n await Promises.sleep(0)\n const html = this.makeHTML(simpleBootFront);\n // console.log('---------',html);\n await this.writeOkHtmlAndEnd({ rr }, html);\n } finally {\n (simpleBootFront.option.window as any).ssrUse = false;\n delete (simpleBootFront.option.window as any).server_side_data;\n if ((simpleBootFront as any).generation < this.poolGeneration) {\n // Stale instance, destroy it\n const jsdom = (simpleBootFront as any).jsdom as JSDOM.JSDOM | undefined;\n jsdom?.window.close();\n const index = this.simpleBootFrontPool.indexOf(simpleBootFront);\n if (index > -1) {\n this.simpleBootFrontPool.splice(index, 1);\n }\n this.pushQueue();\n } else {\n // Current instance, return to queue\n this.simpleBootFrontQueue.enqueue(simpleBootFront);\n }\n }\n return false;\n } else {\n return true;\n }\n }\n\n makeHTML(simpleBootFront: SimpleBootFront) {\n (simpleBootFront.option.window as any).document.querySelectorAll('*').forEach((el:HTMLElement )=> {\n Array.from(el.attributes).forEach(attr => {\n if (/^dr-/.test(attr.name) || /^domstyle/.test(attr.name) || /this-path/.test(attr.name)) {\n el.removeAttribute(attr.name);\n }\n });\n });\n let html = simpleBootFront.option.window.document.documentElement.outerHTML;\n if (!/^<!DOCTYPE html>/i.test(html)) {\n html = '<!DOCTYPE html>' + html;\n }\n html = html.replace(/\\$\\{[\\s\\S]*?\\}\\$/g, '');\n const serverSideData = (simpleBootFront.option.window as any).server_side_data;\n if (serverSideData) {\n const data = Object.entries(serverSideData)\n .map(([k, v]) => {\n if (typeof v === 'string') {\n return `window.server_side_data.${k} = ${v}`;\n } else {\n return `window.server_side_data.${k} = ${JSON.stringify(v)}`;\n }\n })\n .join(';');\n if (data) {\n html = html.replace('</head>', `<script> window.server_side_data={}; ${data}; </script></head>`);\n }\n }\n return html;\n }\n async writeOkHtmlAndEnd({ rr, status = HttpStatus.Ok }: { rr: RequestResponse; status?: HttpStatus }, html: string) {\n rr.resStatusCode(status);\n rr.resSetHeader(HttpHeaders.ContentType, Mimes.TextHtml);\n await rr.resEnd(html);\n }\n\n async proceedAfter({ rr, app }: { rr: RequestResponse; app: SimpleBootHttpServer; carrier: Map<string, any> }) {\n return true;\n }\n}\n"],
5
- "mappings": ";;;;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G,gBAAgB,KAAK,IAAI;AAAA,QAC9B;AAAA,MACF,CAAC;AAAA,IACH,CAAC;AACD,QAAI,OAAO,gBAAgB,OAAO,OAAO,SAAS,gBAAgB;AAChE,QAAI,CAAC,oBAAoB,KAAK,IAAI,GAAG;AACnC,aAAO,oBAAoB;AAAA,IAC7B;AACF,WAAO,KAAK,QAAQ,qBAAqB,EAAE;AAC3C,UAAM,iBAAkB,gBAAgB,OAAO,OAAe;AAC9D,QAAI,gBAAgB;AAClB,YAAM,OAAO,OAAO,QAAQ,cAAc,EACvC,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM;AACf,YAAI,OAAO,MAAM,UAAU;AACzB,iBAAO,2BAA2B,CAAC,MAAM,CAAC;AAAA,QAC5C,OAAO;AACL,iBAAO,2BAA2B,CAAC,MAAM,KAAK,UAAU,CAAC,CAAC;AAAA,QAC5D;AAAA,MACF,CAAC,EACA,KAAK,GAAG;AACX,UAAI,MAAM;AACR,eAAO,KAAK,QAAQ,WAAW,wCAAwC,IAAI,oBAAoB;AAAA,MACjG;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAAA,EACA,MAAM,kBAAkB,EAAE,IAAI,SAAS,6BAAW,GAAG,GAAiD,MAAc;AAClH,OAAG,cAAc,MAAM;AACvB,OAAG,aAAa,+BAAY,aAAa,mBAAM,QAAQ;AACvD,UAAM,GAAG,OAAO,IAAI;AAAA,EACtB;AAAA,EAEA,MAAM,aAAa,EAAE,IAAI,IAAI,GAAkF;AAC7G,WAAO;AAAA,EACT;AACF;",
4
+ "sourcesContent": ["import { RequestResponse } from '@dooboostore/simple-boot-http-server/models/RequestResponse';\nimport { HttpHeaders } from '@dooboostore/simple-boot-http-server/codes/HttpHeaders';\nimport { SimpleBootHttpSSRFactory } from '../SimpleBootHttpSSRFactory';\nimport { ConstructorType, AsyncBlockingQueue, RandomUtils, MessageOperator, MessageInternal, Promises } from '@dooboostore/core';\nimport { Filter } from '@dooboostore/simple-boot-http-server/filters/Filter';\nimport { Mimes } from '@dooboostore/simple-boot-http-server/codes/Mimes';\nimport { HttpStatus } from '@dooboostore/simple-boot-http-server/codes/HttpStatus';\nimport { SimpleBootHttpServer } from '@dooboostore/simple-boot-http-server/SimpleBootHttpServer';\nimport { SimFrontOption } from '@dooboostore/simple-boot-front/option/SimFrontOption';\nimport { SimpleBootFront } from '@dooboostore/simple-boot-front/SimpleBootFront';\nimport * as JSDOM from 'jsdom';\nimport { NotFoundError } from '@dooboostore/simple-boot-http-server/errors/NotFoundError';\nimport { DomRenderProxy } from '@dooboostore/dom-render';\nimport { parseHTML } from 'linkedom';\nimport { DomParserInitializer } from '../initializers/DomParserInitializer';\nimport { JsdomInitializer } from '../initializers';\nimport { SimConfig } from '@dooboostore/simple-boot/decorators/SimDecorator';\n\nexport type FactoryAndParams = {\n frontDistPath: string;\n frontDistIndexFileName?: string;\n factorySimFrontOption: (window: any) => SimFrontOption;\n factory: SimpleBootHttpSSRFactory;\n // poolOption: {\n // max: number;\n // min: number;\n // clearIntervalTime?: number;\n // };\n using: ConstructorType<any>[];\n domExcludes?: ConstructorType<any>[];\n ssrExcludeFilter?: (rr: RequestResponse) => boolean;\n simpleBootFront?: {\n notFoundError?: boolean;\n };\n};\n\nexport class SSRDomParserFilter implements Filter {\n // private simpleBootFrontPool: SimpleBootFront[] = [];\n // private simpleBootFrontQueue = new AsyncBlockingQueue<SimpleBootFront>();\n // private indexHTML: string;\n private welcomUrl = 'http://localhost';\n // private poolGeneration = 0;\n // private intervalId?: NodeJS.Timeout;\n\n constructor(\n public config: FactoryAndParams,\n public otherInstanceSim?: Map<ConstructorType<any> | Function | SimConfig | Symbol, any>\n ) {\n config.frontDistIndexFileName = config.frontDistIndexFileName || 'index.html';\n // this.indexHTML = JsdomInitializer.loadFile(this.config.frontDistPath, config.frontDistIndexFileName);\n }\n\n async onInit(app: SimpleBootHttpServer) {\n // for (let i = 0; i < this.config.poolOption.min; i++) {\n // await this.pushQueue();\n // }\n // if (this.config.poolOption.clearIntervalTime && this.config.poolOption.clearIntervalTime > 0) {\n // this.intervalId = setInterval(() => {\n // this.poolGeneration++;\n // }, this.config.poolOption.clearIntervalTime);\n // }\n }\n\n async onDestroy() {\n // if (this.intervalId) {\n // clearInterval(this.intervalId);\n // }\n // // this.simpleBootFrontQueue.clear();\n // this.simpleBootFrontPool.forEach(front => {\n // // JSDOM\uB3C4 \uC815\uB9AC (\uD558\uC704 \uD638\uD658\uC131)\n // (front as any).jsdom?.window.close();\n // // Window close - \uC774\uAC83\uB9CC\uC73C\uB85C WindowBase.close()\uAC00 \uD638\uCD9C\uB418\uC5B4 \uBA54\uBAA8\uB9AC \uC815\uB9AC\uB428\n // (front.option.window as any)?.close?.();\n // });\n // this.simpleBootFrontPool = [];\n }\n\n async makePage(url = this.welcomUrl) {\n const domParserInitializer = new DomParserInitializer(this.config.frontDistPath, this.config.frontDistIndexFileName || 'index.html', { url: url });\n const window = await domParserInitializer.run();\n // window.document.querySelector('#app').setAttribute(('vvv'),'zzz')\n // console.log('vvv', window.document.querySelector('#app'))\n // console.log('------', window.document.documentElement.outerHTML);\n return { window, domParserInitializer };\n // const jsdom = await new JsdomInitializer(\n // this.config.frontDistPath,\n // this.config.frontDistIndexFileName || 'index.html',\n // { url: this.welcomUrl }\n // ).run();\n // return { window: jsdom.window as any, domParserInitializer: {destroy: () => {jsdom.window.close()}} };\n // return jsdom;\n }\n\n async makeFront(window: Window, otherInstanceSim?: Map<Function | ConstructorType<any> | SimConfig | Symbol, any>) {\n const name = RandomUtils.uuid();\n (window as any).ssrUse = false;\n const option = this.config.factorySimFrontOption(DomRenderProxy.final(window));\n const domExcludes = [RequestResponse, ...(this.config.domExcludes || [])];\n const simpleBootFront = await this.config.factory.create(option, this.config.using, domExcludes);\n otherInstanceSim ??= new Map<Function | ConstructorType<any> | SimConfig | Symbol, any>();\n this.otherInstanceSim?.forEach((v, k) => otherInstanceSim!.set(k, v));\n\n simpleBootFront.run(otherInstanceSim);\n // (simpleBootFront as any).generation = this.poolGeneration;\n return simpleBootFront;\n }\n\n // enqueueFrontApp(simpleBootFront: SimpleBootFront) {\n // // this.simpleBootFrontPool.set(simpleBootFront.option.name!, simpleBootFront);\n // this.simpleBootFrontPool.push(simpleBootFront);\n // this.simpleBootFrontQueue.enqueue(simpleBootFront);\n // }\n //\n // async pushQueue() {\n // if (this.simpleBootFrontPool.length < this.config.poolOption.max) {\n // this.enqueueFrontApp(await this.makeFront(await this.makePage()));\n // }\n // }\n\n async proceedBefore({ rr, app }: { rr: RequestResponse; app: SimpleBootHttpServer; carrier: Map<string, any> }) {\n if (this.config.ssrExcludeFilter?.(rr)) {\n return false;\n }\n if (rr.reqHasAcceptHeader(Mimes.TextHtml) || rr.reqHasAcceptHeader(Mimes.All)) {\n // if (this.simpleBootFrontQueue.isEmpty()) {\n // await this.pushQueue();\n // }\n // const simpleBootFront = await this.simpleBootFrontQueue.dequeue();\n const url = rr.reqUrlObj({ host: 'localhost' });\n const targetUrl = url.toString() ?? this.welcomUrl;\n const { window, domParserInitializer } = await this.makePage(targetUrl);\n const otherSim = new Map<Function | ConstructorType<any> | SimConfig | Symbol, any>();\n otherSim.set(RequestResponse, rr);\n const simpleBootFront = await this.makeFront(window, otherSim);\n try {\n (simpleBootFront.option.window as any).ssrUse = true;\n // console.log(simpleBootFront.routing)\n if (this.config.simpleBootFront?.notFoundError) {\n // intent router check first\n const intent = await simpleBootFront.routingRouterModule(url.pathname);\n // route\uB97C \uBABB\uCC3E\uC740\uC0C1\uD0DC\uC5D0\uC11C router path\uAE4C\uC9C0 \uC548\uB9DE\uC73C\uBA74 404 \uCC98\uB9AC\uD55C\uB2E4. route\uB791 router\uB791 \uB2E4\uB974\uB2C8\uAE50 \uD5DB\uAC08\uB9AC\uC9C0\uB9D0\uB3C4\uB85D\n if (intent.module === undefined && !intent.getRouterPathData(rr.reqUrlPathName)) {\n throw new NotFoundError({ message: `Not Found: ${rr.reqUrlPathName}` });\n }\n }\n\n const data = await MessageInternal.firstValueFrom(\n simpleBootFront.routingObservable.pipe(\n MessageOperator.filter(it => {\n\n const sw = it.triggerPoint === 'end' && typeof it.routerModule.intent.uri === 'string' && targetUrl.endsWith(it.routerModule.intent.uri);\n return sw;\n }),\n // delay(1000),\n MessageOperator.first()\n )\n );\n\n // [\uC544\uD0A4\uD14D\uD2B8\uB2D8\uC758 \uC815\uC11D] \uD558\uC774\uB4DC\uB808\uC774\uC158 \uB370\uC774\uD130\uB97C \uAC00\uC0C1 \uC708\uB3C4\uC6B0\uC758 body\uC5D0 script \uD0DC\uADF8\uB85C \uBC15\uC81C\n // @ts-ignore: writeDataHydration is part of the \uC815\uC11D\n simpleBootFront.writeDataHydration();\n simpleBootFront.clearDataHydration();\n\n const html = this.makeHTML(simpleBootFront);\n await this.writeOkHtmlAndEnd({ rr }, html);\n } finally {\n try {\n (simpleBootFront.option.window as any).ssrUse = false;\n window.close();\n simpleBootFront.onDestroy();\n\n // window.close()\uB9CC \uD638\uCD9C\uD558\uBA74 WindowBase.close()\uAC00 \uC2E4\uD589\uB418\uC5B4 \uBA54\uBAA8\uB9AC \uC815\uB9AC\uB428\n (simpleBootFront.option.window as any)?.close?.();\n domParserInitializer.destroy();\n } catch (e) {\n console.log('eeeeee', e);\n }\n\n // const index = this.simpleBootPool.indexOf(simpleBootFront);\n // if (index > -1) {\n // this.simpleBootPool.splice(index, 1);\n // }\n // this.pushQueue();\n }\n return false;\n } else {\n return true;\n }\n }\n\n makeHTML(simpleBootFront: SimpleBootFront) {\n (simpleBootFront.option.window as any).document.querySelectorAll('*').forEach((el: HTMLElement) => {\n Array.from(el.attributes).forEach(attr => {\n if (/^dr-/.test(attr.name) || /^domstyle/.test(attr.name) || /this-path/.test(attr.name)) {\n el.removeAttribute(attr.name);\n }\n });\n });\n let html = simpleBootFront.option.window.document.documentElement.outerHTML;\n if (!/^<!DOCTYPE html>/i.test(html)) {\n html = '<!DOCTYPE html>' + html;\n }\n html = html.replace(/\\$\\{[\\s\\S]*?\\}\\$/g, '');\n\n // [\uC544\uD0A4\uD14D\uD2B8\uB2D8\uC758 \uC815\uC11D]\n // body\uC5D0 \uC9C1\uC811 append\uB41C script tag\uAC00 outerHTML\uC5D0 \uC774\uBBF8 \uD3EC\uD568\uB418\uC5B4 \uC788\uC73C\uBBC0\uB85C \uCD94\uAC00 \uC870\uC791\uC740 \uBD88\uD544\uC694\uD569\uB2C8\uB2E4.\n\n return html;\n }\n\n async writeOkHtmlAndEnd({ rr, status = HttpStatus.Ok }: { rr: RequestResponse; status?: HttpStatus }, html: string) {\n rr.resStatusCode(status);\n rr.resSetHeader(HttpHeaders.ContentType, Mimes.TextHtml);\n await rr.resEnd(html);\n }\n\n async proceedAfter({ rr, app }: { rr: RequestResponse; app: SimpleBootHttpServer; carrier: Map<string, any> }) {\n return true;\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,6BAAgC;AAChC,yBAA4B;AAE5B,kBAA6G;AAE7G,mBAAsB;AACtB,wBAA2B;AAK3B,2BAA8B;AAC9B,wBAA+B;AAE/B,kCAAqC;AAsB9B,MAAM,mBAAqC;AAAA;AAAA;AAAA,EAQhD,YACS,QACA,kBACP;AAFO;AACA;AANT;AAAA;AAAA;AAAA,SAAQ,YAAY;AAQlB,WAAO,yBAAyB,OAAO,0BAA0B;AAAA,EAEnE;AAAA,EAEA,MAAM,OAAO,KAA2B;AAAA,EASxC;AAAA,EAEA,MAAM,YAAY;AAAA,EAYlB;AAAA,EAEA,MAAM,SAAS,MAAM,KAAK,WAAW;AACnC,UAAM,uBAAuB,IAAI,iDAAqB,KAAK,OAAO,eAAe,KAAK,OAAO,0BAA0B,cAAc,EAAE,IAAS,CAAC;AACjJ,UAAM,SAAS,MAAM,qBAAqB,IAAI;AAI9C,WAAO,EAAE,QAAQ,qBAAqB;AAAA,EAQxC;AAAA,EAEA,MAAM,UAAU,QAAgB,kBAAmF;AACjH,UAAM,OAAO,wBAAY,KAAK;AAC9B,IAAC,OAAe,S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,qBAAqB,EAAE;AAK3C,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,kBAAkB,EAAE,IAAI,SAAS,6BAAW,GAAG,GAAiD,MAAc;AAClH,OAAG,cAAc,MAAM;AACvB,OAAG,aAAa,+BAAY,aAAa,mBAAM,QAAQ;AACvD,UAAM,GAAG,OAAO,IAAI;AAAA,EACtB;AAAA,EAEA,MAAM,aAAa,EAAE,IAAI,IAAI,GAAkF;AAC7G,WAAO;AAAA,EACT;AACF;",
6
6
  "names": []
7
7
  }
@@ -21,22 +21,18 @@ __export(SSRFilter_exports, {
21
21
  });
22
22
  module.exports = __toCommonJS(SSRFilter_exports);
23
23
  var import_HttpHeaders = require("@dooboostore/simple-boot-http-server/codes/HttpHeaders");
24
+ var import_core = require("@dooboostore/core");
24
25
  var import_JsdomInitializer = require("../initializers/JsdomInitializer");
25
26
  var import_Mimes = require("@dooboostore/simple-boot-http-server/codes/Mimes");
26
27
  var import_HttpStatus = require("@dooboostore/simple-boot-http-server/codes/HttpStatus");
27
- var import_AsyncBlockingQueue = require("@dooboostore/core/queues/AsyncBlockingQueue");
28
- var import_RandomUtils = require("@dooboostore/core/random/RandomUtils");
29
28
  var import_NotFoundError = require("@dooboostore/simple-boot-http-server/errors/NotFoundError");
30
- var import_DomRenderProxy = require("@dooboostore/dom-render/DomRenderProxy");
31
- var import_filter = require("@dooboostore/core/message/operators/filter");
32
- var import_first = require("@dooboostore/core/message/operators/first");
33
- var import_firstValueFrom = require("@dooboostore/core/message/internal/firstValueFrom");
29
+ var import_dom_render = require("@dooboostore/dom-render");
34
30
  class SSRFilter {
35
31
  constructor(config, otherInstanceSim) {
36
32
  this.config = config;
37
33
  this.otherInstanceSim = otherInstanceSim;
38
34
  this.simpleBootFrontPool = [];
39
- this.simpleBootFrontQueue = new import_AsyncBlockingQueue.AsyncBlockingQueue();
35
+ this.simpleBootFrontQueue = new import_core.AsyncBlockingQueue();
40
36
  this.welcomUrl = "http://localhost";
41
37
  this.poolGeneration = 0;
42
38
  config.frontDistIndexFileName = config.frontDistIndexFileName || "index.html";
@@ -78,10 +74,10 @@ class SSRFilter {
78
74
  return jsdom;
79
75
  }
80
76
  async makeFront(jsdom) {
81
- const name = import_RandomUtils.RandomUtils.uuid();
77
+ const name = import_core.RandomUtils.uuid();
82
78
  const window = jsdom.window;
83
79
  window.ssrUse = false;
84
- const option = this.config.factorySimFrontOption(import_DomRenderProxy.DomRenderProxy.final(window));
80
+ const option = this.config.factorySimFrontOption(import_dom_render.DomRenderProxy.final(window));
85
81
  const simpleBootFront = await this.config.factory.create(option, this.config.using, this.config.domExcludes);
86
82
  simpleBootFront.run(this.otherInstanceSim);
87
83
  simpleBootFront.jsdom = jsdom;
@@ -115,7 +111,7 @@ class SSRFilter {
115
111
  delete simpleBootFront.option.window.server_side_data;
116
112
  const url = rr.reqUrlObj({ host: "localhost" });
117
113
  if (this.config.simpleBootFront?.notFoundError) {
118
- const intent = await simpleBootFront.getIntent(url.pathname);
114
+ const intent = await simpleBootFront.routingRouterModule(url.pathname);
119
115
  if (intent.module === void 0 && !intent.getRouterPathData(rr.reqUrlPathName)) {
120
116
  throw new import_NotFoundError.NotFoundError({ message: `Not Found: ${rr.reqUrlPathName}` });
121
117
  }
@@ -123,15 +119,15 @@ class SSRFilter {
123
119
  const targetUrl = url.toString();
124
120
  await simpleBootFront.goRouting(targetUrl);
125
121
  await new Promise((r) => setTimeout(r, 0));
126
- const data = await (0, import_firstValueFrom.firstValueFrom)(
122
+ const data = await import_core.MessageInternal.firstValueFrom(
127
123
  // @ts-ignore
128
- simpleBootFront.routingSubjectObservable.pipe(
124
+ simpleBootFront.routingObservable.pipe(
129
125
  // @ts-ignore
130
- (0, import_filter.filter)(
126
+ import_core.MessageOperator.filter(
131
127
  (it) => it.triggerPoint === "end" && typeof it.routerModule.intent.uri === "string" && targetUrl.endsWith(it.routerModule.intent.uri)
132
128
  ),
133
129
  // delay(1000),
134
- (0, import_first.first)()
130
+ import_core.MessageOperator.first()
135
131
  )
136
132
  );
137
133
  const html = this.makeHTML(simpleBootFront);