@dooboostore/simple-boot-http-server-ssr 1.0.11 → 1.0.13

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 (171) hide show
  1. package/README.MD +24 -209
  2. package/dist/cjs/bundle-entry.js +36 -0
  3. package/dist/cjs/bundle-entry.js.map +7 -0
  4. package/dist/cjs/codes/HttpHeaders.js.map +2 -2
  5. package/dist/cjs/filters/SSRFilter.js +5 -7
  6. package/dist/cjs/filters/SSRFilter.js.map +2 -2
  7. package/dist/cjs/filters/SSRLinkDomDomFilter.js +183 -0
  8. package/dist/cjs/filters/SSRLinkDomDomFilter.js.map +7 -0
  9. package/dist/cjs/filters/SSRWorker.js +1 -2
  10. package/dist/cjs/filters/SSRWorker.js.map +1 -1
  11. package/dist/cjs/index.js.map +2 -2
  12. package/dist/cjs/initializers/JsdomInitializer.js +1 -0
  13. package/dist/cjs/initializers/JsdomInitializer.js.map +2 -2
  14. package/dist/cjs/initializers/LinkedomInitializer.js +81 -0
  15. package/dist/cjs/initializers/LinkedomInitializer.js.map +7 -0
  16. package/dist/cjs/package.json +2 -0
  17. package/dist/cjs/proxy/SymbolIntentApiServiceProxy.js +17 -2
  18. package/dist/cjs/proxy/SymbolIntentApiServiceProxy.js.map +3 -3
  19. package/dist/esm/bundle-entry.js +9 -0
  20. package/dist/esm/bundle-entry.js.map +7 -0
  21. package/dist/esm/codes/HttpHeaders.js.map +2 -2
  22. package/dist/esm/filters/SSRFilter.js +5 -7
  23. package/dist/esm/filters/SSRFilter.js.map +2 -2
  24. package/dist/esm/filters/SSRLinkDomDomFilter.js +160 -0
  25. package/dist/esm/filters/SSRLinkDomDomFilter.js.map +7 -0
  26. package/dist/esm/filters/SSRWorker.js +1 -2
  27. package/dist/esm/filters/SSRWorker.js.map +1 -1
  28. package/dist/esm/index.js.map +2 -2
  29. package/dist/esm/initializers/JsdomInitializer.js +1 -0
  30. package/dist/esm/initializers/JsdomInitializer.js.map +2 -2
  31. package/dist/esm/initializers/LinkedomInitializer.js +48 -0
  32. package/dist/esm/initializers/LinkedomInitializer.js.map +7 -0
  33. package/dist/esm/proxy/SymbolIntentApiServiceProxy.js +18 -3
  34. package/dist/esm/proxy/SymbolIntentApiServiceProxy.js.map +3 -3
  35. package/dist/esm-bundle/dooboostore-simple-boot-http-server-ssr.esm.js +11811 -3
  36. package/dist/esm-bundle/dooboostore-simple-boot-http-server-ssr.esm.js.map +4 -4
  37. package/dist/{esm → types}/SimpleBootHttpSSRServer.d.ts +1 -1
  38. package/dist/types/bundle-entry.d.ts +9 -0
  39. package/dist/types/bundle-entry.d.ts.map +1 -0
  40. package/dist/types/codes/HttpHeaders.d.ts +45 -0
  41. package/dist/types/codes/HttpHeaders.d.ts.map +1 -0
  42. package/dist/{cjs → types}/filters/SSRFilter.d.ts.map +1 -1
  43. package/dist/{esm/filters/SSRFilter.d.ts → types/filters/SSRLinkDomDomFilter.d.ts} +4 -6
  44. package/dist/types/filters/SSRLinkDomDomFilter.d.ts.map +1 -0
  45. package/dist/{esm → types}/index.d.ts.map +1 -1
  46. package/dist/{cjs → types}/initializers/JsdomInitializer.d.ts.map +1 -1
  47. package/dist/types/initializers/LinkedomInitializer.d.ts +11 -0
  48. package/dist/types/initializers/LinkedomInitializer.d.ts.map +1 -0
  49. package/dist/{cjs → types}/proxy/SymbolIntentApiServiceProxy.d.ts.map +1 -1
  50. package/dist/umd-bundle/dooboostore-simple-boot-http-server-ssr.umd.js +11803 -6
  51. package/dist/umd-bundle/dooboostore-simple-boot-http-server-ssr.umd.js.map +4 -4
  52. package/package.json +36 -23
  53. package/src/SimpleBootHttpSSRFactory.ts +11 -0
  54. package/src/SimpleBootHttpSSRServer.ts +21 -0
  55. package/src/bundle-entry.ts +8 -0
  56. package/src/codes/HttpHeaders.ts +17 -0
  57. package/src/codes/Mimes.ts +6 -0
  58. package/src/codes/index.ts +2 -0
  59. package/src/decorators/LoadAroundBefore.ts +28 -0
  60. package/src/decorators/SaveAroundAfter.ts +27 -0
  61. package/src/decorators/index.ts +2 -0
  62. package/src/filters/IntentSchemeFilter.ts +66 -0
  63. package/src/filters/SSRFilter.ts +339 -0
  64. package/src/filters/SSRLinkDomDomFilter.ts +227 -0
  65. package/src/filters/SSRWorker.ts +76 -0
  66. package/{dist/esm/filters/index.d.ts → src/filters/index.ts} +1 -2
  67. package/src/index.ts +9 -0
  68. package/src/initializers/JsdomInitializer.ts +85 -0
  69. package/src/initializers/LinkedomInitializer.ts +69 -0
  70. package/src/initializers/index.ts +1 -0
  71. package/src/node_modules/.bin/acorn +17 -0
  72. package/src/node_modules/.bin/browserslist +17 -0
  73. package/src/node_modules/.bin/eslint +17 -0
  74. package/src/node_modules/.bin/jest +17 -0
  75. package/src/node_modules/.bin/ts-jest +17 -0
  76. package/src/node_modules/.bin/ts-node +17 -0
  77. package/src/node_modules/.bin/ts-node-cwd +17 -0
  78. package/src/node_modules/.bin/ts-node-esm +17 -0
  79. package/src/node_modules/.bin/ts-node-script +17 -0
  80. package/src/node_modules/.bin/ts-node-transpile-only +17 -0
  81. package/src/node_modules/.bin/ts-script +17 -0
  82. package/src/node_modules/.bin/tsc +17 -0
  83. package/src/node_modules/.bin/tsserver +17 -0
  84. package/src/option/HttpSSRServerOption.ts +4 -0
  85. package/src/option/index.ts +1 -0
  86. package/src/proxy/IntentSchemeFrontProxy.ts +67 -0
  87. package/src/proxy/IntentSchemeServerProxy.ts +35 -0
  88. package/src/proxy/SymbolIntentApiServiceProxy.ts +131 -0
  89. package/src/proxy/SymbolIntentApiServiceProxyBase.ts +97 -0
  90. package/{dist/esm/proxy/index.d.ts → src/proxy/index.ts} +1 -2
  91. package/tsconfig.json +24 -0
  92. package/dist/cjs/SimpleBootHttpSSRServer.d.ts +0 -9
  93. package/dist/cjs/codes/HttpHeaders.d.ts +0 -45
  94. package/dist/cjs/codes/HttpHeaders.d.ts.map +0 -1
  95. package/dist/cjs/index.d.ts.map +0 -1
  96. package/dist/esm/SimpleBootHttpSSRFactory.d.ts +0 -8
  97. package/dist/esm/SimpleBootHttpSSRFactory.d.ts.map +0 -1
  98. package/dist/esm/SimpleBootHttpSSRServer.d.ts.map +0 -1
  99. package/dist/esm/codes/HttpHeaders.d.ts +0 -45
  100. package/dist/esm/codes/HttpHeaders.d.ts.map +0 -1
  101. package/dist/esm/codes/Mimes.d.ts +0 -31
  102. package/dist/esm/codes/Mimes.d.ts.map +0 -1
  103. package/dist/esm/codes/index.d.ts +0 -3
  104. package/dist/esm/codes/index.d.ts.map +0 -1
  105. package/dist/esm/decorators/LoadAroundBefore.d.ts +0 -2
  106. package/dist/esm/decorators/LoadAroundBefore.d.ts.map +0 -1
  107. package/dist/esm/decorators/SaveAroundAfter.d.ts +0 -3
  108. package/dist/esm/decorators/SaveAroundAfter.d.ts.map +0 -1
  109. package/dist/esm/decorators/index.d.ts +0 -3
  110. package/dist/esm/decorators/index.d.ts.map +0 -1
  111. package/dist/esm/filters/IntentSchemeFilter.d.ts +0 -20
  112. package/dist/esm/filters/IntentSchemeFilter.d.ts.map +0 -1
  113. package/dist/esm/filters/SSRFilter.d.ts.map +0 -1
  114. package/dist/esm/filters/SSRWorker.d.ts +0 -16
  115. package/dist/esm/filters/SSRWorker.d.ts.map +0 -1
  116. package/dist/esm/filters/index.d.ts.map +0 -1
  117. package/dist/esm/index.d.ts +0 -3
  118. package/dist/esm/initializers/JsdomInitializer.d.ts +0 -11
  119. package/dist/esm/initializers/JsdomInitializer.d.ts.map +0 -1
  120. package/dist/esm/initializers/index.d.ts +0 -2
  121. package/dist/esm/initializers/index.d.ts.map +0 -1
  122. package/dist/esm/option/HttpSSRServerOption.d.ts +0 -4
  123. package/dist/esm/option/HttpSSRServerOption.d.ts.map +0 -1
  124. package/dist/esm/option/index.d.ts +0 -2
  125. package/dist/esm/option/index.d.ts.map +0 -1
  126. package/dist/esm/proxy/IntentSchemeFrontProxy.d.ts +0 -4
  127. package/dist/esm/proxy/IntentSchemeFrontProxy.d.ts.map +0 -1
  128. package/dist/esm/proxy/IntentSchemeServerProxy.d.ts +0 -4
  129. package/dist/esm/proxy/IntentSchemeServerProxy.d.ts.map +0 -1
  130. package/dist/esm/proxy/SymbolIntentApiServiceProxy.d.ts +0 -16
  131. package/dist/esm/proxy/SymbolIntentApiServiceProxy.d.ts.map +0 -1
  132. package/dist/esm/proxy/SymbolIntentApiServiceProxyBase.d.ts +0 -13
  133. package/dist/esm/proxy/SymbolIntentApiServiceProxyBase.d.ts.map +0 -1
  134. package/dist/esm/proxy/index.d.ts.map +0 -1
  135. /package/dist/{cjs → types}/SimpleBootHttpSSRFactory.d.ts +0 -0
  136. /package/dist/{cjs → types}/SimpleBootHttpSSRFactory.d.ts.map +0 -0
  137. /package/dist/{cjs → types}/SimpleBootHttpSSRServer.d.ts.map +0 -0
  138. /package/dist/{cjs → types}/codes/Mimes.d.ts +0 -0
  139. /package/dist/{cjs → types}/codes/Mimes.d.ts.map +0 -0
  140. /package/dist/{cjs → types}/codes/index.d.ts +0 -0
  141. /package/dist/{cjs → types}/codes/index.d.ts.map +0 -0
  142. /package/dist/{cjs → types}/decorators/LoadAroundBefore.d.ts +0 -0
  143. /package/dist/{cjs → types}/decorators/LoadAroundBefore.d.ts.map +0 -0
  144. /package/dist/{cjs → types}/decorators/SaveAroundAfter.d.ts +0 -0
  145. /package/dist/{cjs → types}/decorators/SaveAroundAfter.d.ts.map +0 -0
  146. /package/dist/{cjs → types}/decorators/index.d.ts +0 -0
  147. /package/dist/{cjs → types}/decorators/index.d.ts.map +0 -0
  148. /package/dist/{cjs → types}/filters/IntentSchemeFilter.d.ts +0 -0
  149. /package/dist/{cjs → types}/filters/IntentSchemeFilter.d.ts.map +0 -0
  150. /package/dist/{cjs → types}/filters/SSRFilter.d.ts +0 -0
  151. /package/dist/{cjs → types}/filters/SSRWorker.d.ts +0 -0
  152. /package/dist/{cjs → types}/filters/SSRWorker.d.ts.map +0 -0
  153. /package/dist/{cjs → types}/filters/index.d.ts +0 -0
  154. /package/dist/{cjs → types}/filters/index.d.ts.map +0 -0
  155. /package/dist/{cjs → types}/index.d.ts +0 -0
  156. /package/dist/{cjs → types}/initializers/JsdomInitializer.d.ts +0 -0
  157. /package/dist/{cjs → types}/initializers/index.d.ts +0 -0
  158. /package/dist/{cjs → types}/initializers/index.d.ts.map +0 -0
  159. /package/dist/{cjs → types}/option/HttpSSRServerOption.d.ts +0 -0
  160. /package/dist/{cjs → types}/option/HttpSSRServerOption.d.ts.map +0 -0
  161. /package/dist/{cjs → types}/option/index.d.ts +0 -0
  162. /package/dist/{cjs → types}/option/index.d.ts.map +0 -0
  163. /package/dist/{cjs → types}/proxy/IntentSchemeFrontProxy.d.ts +0 -0
  164. /package/dist/{cjs → types}/proxy/IntentSchemeFrontProxy.d.ts.map +0 -0
  165. /package/dist/{cjs → types}/proxy/IntentSchemeServerProxy.d.ts +0 -0
  166. /package/dist/{cjs → types}/proxy/IntentSchemeServerProxy.d.ts.map +0 -0
  167. /package/dist/{cjs → types}/proxy/SymbolIntentApiServiceProxy.d.ts +0 -0
  168. /package/dist/{cjs → types}/proxy/SymbolIntentApiServiceProxyBase.d.ts +0 -0
  169. /package/dist/{cjs → types}/proxy/SymbolIntentApiServiceProxyBase.d.ts.map +0 -0
  170. /package/dist/{cjs → types}/proxy/index.d.ts +0 -0
  171. /package/dist/{cjs → types}/proxy/index.d.ts.map +0 -0
package/README.MD CHANGED
@@ -1,223 +1,38 @@
1
- # SIMPLE-BOOT-HTTP-SSR
1
+ # @dooboostore/simple-boot-http-server-ssr
2
2
 
3
- ### A framework for building Server-Side Rendered (SSR) applications.
3
+ [![NPM version](https://img.shields.io/npm/v/@dooboostore/simple-boot-http-server-ssr.svg?style=flat-square)](https://www.npmjs.com/package/@dooboostore/simple-boot-http-server-ssr)
4
+ [![Build and Test](https://github.com/dooboostore-develop/packages/actions/workflows/main.yaml/badge.svg?branch=main)](https://github.com/dooboostore-develop/packages/actions/workflows/main.yaml)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](https://opensource.org/licenses/MIT)
4
6
 
5
- This package seamlessly integrates `@dooboostore/simple-boot-front` and `@dooboostore/simple-boot-http-server` to provide a powerful solution for building fast, SEO-friendly, and dynamic web applications.
7
+ **Full Documentation:** [https://dooboostore-develop.github.io/packages/simple-boot-http-server-ssr](https://dooboostore-develop.github.io/packages/simple-boot-http-server-ssr)
6
8
 
7
- - **Server-Side Rendering**: Renders your single-page application on the server before sending it to the client.
8
- - **JSDOM Integration**: Uses `jsdom` to create a virtual DOM environment on the server, allowing front-end code to run.
9
- - **Component Pooling**: Manages a pool of `SimpleBootFront` instances to handle concurrent SSR requests efficiently.
10
- - **Data Hydration**: Automatically serializes data fetched on the server and hydrates it on the client, avoiding redundant API calls. The `SaveAroundAfter` and `LoadAroundBefore` decorators facilitate this by saving data to `window.server_side_data` on the server and retrieving it on the client.
11
- - **Unified Codebase**: Enables sharing of routing, services, and components between the server and the client.
12
- - **Intent-based Communication**: Provides a mechanism for client-server communication using custom HTTP headers and intent publishing, allowing for flexible data fetching and action triggering.
9
+ A framework for building Server-Side Rendered (SSR) applications by seamlessly integrating `@dooboostore/simple-boot-front` and `@dooboostore/simple-boot-http-server`.
13
10
 
14
- ### Dependencies
11
+ ---
15
12
 
16
- - **@dooboostore/simple-boot-front**: The front-end framework for building components and managing UI state.
17
- - **@dooboostore/simple-boot-http-server**: The underlying HTTP server for handling requests.
13
+ ## Features
18
14
 
19
- ## 🚀 Quick Start
15
+ - **Server-Side Rendering**: Renders your single-page application on the server for fast, SEO-friendly websites.
16
+ - **JSDOM Integration**: Uses `jsdom` to create a virtual DOM environment on the server, allowing front-end code to run.
17
+ - **Component Pooling**: Manages a pool of `SimpleBootFront` instances to handle concurrent SSR requests efficiently.
18
+ - **Automatic Data Hydration**: Serializes data fetched on the server and hydrates it on the client to avoid redundant API calls.
19
+ - **Unified Codebase**: Enables sharing of routing, services, and components between the server and the client.
20
+ - **Intent-based Communication**: Provides a mechanism for client-server communication using custom HTTP headers.
20
21
 
21
- ```
22
- npm init @dooboostore/simple-boot-http-server-ssr projectname
23
- cd projectname
24
- npm start
25
- ```
26
-
27
- ## 🚀 How It Works
28
-
29
- The core of this package is the `SSRFilter`. When a request for an HTML page comes in, the filter does the following:
30
-
31
- 1. **Intercepts the Request**: It captures the request before it would normally serve a static `index.html` file.
32
- 2. **Acquires a Browser Environment**: It takes a pre-initialized `jsdom` instance from a pool. This instance acts as a virtual browser on the server.
33
- 3. **Initializes a Front-End App**: It uses a `SimpleBootFront` application instance (also from a pool) and sets its context to the `jsdom` window.
34
- 4. **Executes Routing**: It triggers the front-end router within the `jsdom` environment, using the path from the incoming request.
35
- 5. **Renders Components**: The front-end components render into the virtual DOM.
36
- 6. **Handles Data Fetching**: If components fetch data during their lifecycle, this happens on the server. The `SaveAroundAfter` and `LoadAroundBefore` decorators automatically handle the serialization of this data into `window.server_side_data`.
37
- 7. **Serializes the DOM**: Once rendering is complete, it captures the `outerHTML` of the `jsdom` document.
38
- 8. **Injects Hydration Data**: The serialized data from step 6 is injected into the HTML inside a `<script>` tag.
39
- 9. **Sends Response**: The fully rendered HTML is sent to the client.
40
-
41
- The client-side application then boots up, sees the pre-rendered HTML and the hydration data, and takes over without needing to re-render the initial view or re-fetch the initial data.
42
-
43
- Additionally, the `IntentSchemeFilter` handles specific client-server communication. When a request with `Accept: application/json-post+simple-boot-ssr-intent-scheme` and `X-Simple-Boot-Ssr-Intent-Scheme` headers is received, this filter intercepts it, publishes an intent, and returns the result, enabling a robust intent-based API.
44
-
45
- # 😃 Example Setup
46
-
47
- ### Common Factory (`factory.ts`)
48
-
49
- This factory is used by both the server (for SSR) and the client (for browser rendering).
50
-
51
- ```typescript
52
- import { SimpleBootHttpSSRFactory, SimFrontOption, SimpleBootFront } from '@dooboostore/simple-boot-http-server-ssr';
53
- import { ConstructorType } from '@dooboostore/core';
54
- import { IndexRouterComponent } from './components/index.router.component';
55
-
56
- // Function to create a standard front-end option object
57
- export const MakeSimFrontOption = (window: any): SimFrontOption => {
58
- return new SimFrontOption(window).setUrlType('path');
59
- }
60
-
61
- // The factory class that creates instances of the front-end application
62
- class Factory extends SimpleBootHttpSSRFactory {
63
- factory(simFrontOption: SimFrontOption, using: ConstructorType<any>[] = [], domExcludes: ConstructorType<any>[] = []): Promise<SimpleBootFront> {
64
- const simpleBootFront = new SimpleBootFront(IndexRouterComponent, simFrontOption);
65
- // Exclude certain types from being proxied by the DOM renderer
66
- simpleBootFront.domRendoerExcludeProxy.push(...domExcludes);
67
- return Promise.resolve(simpleBootFront);
68
- }
69
- }
22
+ ## Quick Start
70
23
 
71
- export default new Factory();
24
+ ```bash
25
+ npx @dooboostore/create-simple-boot-http-server-ssr my-ssr-app
26
+ cd my-ssr-app
27
+ npm start
72
28
  ```
73
29
 
74
- ### Server Entry Point (`server.ts`)
75
-
76
- This sets up the HTTP server with the `SSRFilter` and `IntentSchemeFilter`.
77
-
78
- ```typescript
79
- import 'reflect-metadata';
80
- import { ConstructorType } from '@dooboostore/core/types';
81
- import { SimpleBootHttpSSRServer } from '@dooboostore/simple-boot-http-server-ssr/SimpleBootHttpSSRServer';
82
- import { HttpSSRServerOption } from '@dooboostore/simple-boot-http-server-ssr/option/HttpSSRServerOption';
83
- import { environment } from './environments/environment';
84
- import { NotFoundError } from '@dooboostore/simple-boot-http-server/errors/NotFoundError';
85
- import { SimpleBootHttpServer } from '@dooboostore/simple-boot-http-server/SimpleBootHttpServer';
86
- import Factory, { MakeSimFrontOption } from '@src/bootfactory';
87
- import { FactoryAndParams, SSRFilter } from '@dooboostore/simple-boot-http-server-ssr/filters/SSRFilter';
88
- import { ResourceFilter } from '@dooboostore/simple-boot-http-server/filters/ResourceFilter';
89
- import { RootRouter } from '@backend/root.router';
90
- import { RequestResponse } from '@dooboostore/simple-boot-http-server/models/RequestResponse';
91
- import { DataSource } from 'typeorm';
92
- import { DatabaseService } from '@backend/service/database/DatabaseService';
93
- import { services } from '@backend/service';
94
- import { IntentSchemeFilter } from '@dooboostore/simple-boot-http-server-ssr/filters/IntentSchemeFilter';
95
- import { ErrorLogEndPoint } from '@backend/endpoints/ErrorLogEndPoint';
96
- import { CloseLogEndPoint } from '@backend/endpoints/CloseLogEndPoint';
97
- import { RequestLogEndPoint } from '@backend/endpoints/RequestLogEndPoint';
98
- import { GlobalAdvice } from '@backend/advices/GlobalAdvice';
99
- import { SimpleBootHttpSSRFactory } from '@dooboostore/simple-boot-http-server-ssr/SimpleBootHttpSSRFactory';
100
- import { Runnable } from '@dooboostore/core/runs/Runnable';
101
- import { CrossDomainHeaderEndPoint } from '@dooboostore/simple-boot-http-server/endpoints/CrossDomainHeaderEndPoint';
102
- import { SyncManager } from '@backend/manager';
103
- import { SecurityService } from '@backend/service/SecurityService';
104
-
105
- type ENV_MODE = 'ONLY_SYNC' | 'NO_SYNC' | undefined;
106
- type WORLD = undefined | string;
107
-
108
- type RunParams = { mode: ENV_MODE, world: WORLD };
109
-
110
- class Server implements Runnable<void, RunParams> {
111
- async run(config?: RunParams) {
112
- const securityService = new SecurityService();
113
- const databaseService = new DatabaseService(securityService);
114
- await databaseService.run();
115
- if (mode !== 'NO_SYNC') {
116
- const syncManager = new SyncManager(databaseService);
117
- await syncManager.run(config?.world ? Number(config.world) : undefined);
118
- }
119
-
120
- if (mode === 'ONLY_SYNC') {
121
- return;
122
- }
123
-
124
-
125
- // const cacheManager = new CacheManager(databaseService);
126
- // await cacheManager.run();
127
-
128
- const otherInstanceSim = new Map<ConstructorType<any>, any>();
129
- otherInstanceSim.set(SecurityService, securityService);
130
- otherInstanceSim.set(DatabaseService, databaseService);
131
- // otherInstanceSim.set(CacheManager, cacheManager);
132
-
133
- const ssrOption: FactoryAndParams = {
134
- frontDistPath: environment.frontDistPath,
135
- frontDistIndexFileName: environment.frontDistIndexFileName,
136
- factorySimFrontOption: (window: any) => MakeSimFrontOption(window),
137
- factory: Factory as SimpleBootHttpSSRFactory,
138
- poolOption: {
139
- max: 50,
140
- min: 5
141
- },
142
- using: [...services],
143
- domExcludes: [DataSource] as ConstructorType<any>[],
144
- ssrExcludeFilter: (rr: RequestResponse) => {
145
- const firstExcludeFilter = [
146
- /^\/signs\/confirm-email.*/,
147
- /^\/assets\/.*/,
148
- /^\/api\/.*/
149
- ];
150
- for (const excludeRegExp of firstExcludeFilter) {
151
- if (excludeRegExp.test(rr.reqUrl)) {
152
- return true;
153
- }
154
- }
155
- return false;
156
- },
157
- simpleBootFront: {
158
- notFoundError: true
159
- }
160
- };
161
- // const ssrFilter = new SSRFilter(ssrOption, otherInstanceSim);
162
-
163
- const resourceFilter = new ResourceFilter(environment.frontDistPath,
164
- [
165
- 'assets/privacy.html', 'assets/.*', '\.js$', '\.map$', '\.ico$', '\.png$', '\.jpg$', '\.jpeg$', '\.gif$', 'offline\.html$', 'webmanifest$', 'manifest\.json', 'service-worker\.js$', 'googlebe4b1abe81ab7cf3\.html$',
166
- {
167
- request: (rr) => {
168
- return RegExp('/.*').test(rr.reqUrlPathName) && rr.reqMethod()?.toUpperCase() === 'GET';
169
- },
170
- dist: 'index.html'
171
- }
172
- ]
173
- );
174
- const uploadResourceFilter = new ResourceFilter(environment.uploadTempPath,
175
- ['public/.*']
176
- );
177
-
178
- const option = new HttpSSRServerOption();
179
- option.cache = {
180
- enable: true
181
- }
182
- option.rootRouter = RootRouter;
183
- option.listen = environment.httpServerConfig.listen;
184
- option.globalAdvice = new GlobalAdvice();
185
- option.requestEndPoints = [
186
- new RequestLogEndPoint(),
187
- new CrossDomainHeaderEndPoint({accessControlExposeHeaders: 'Set-Cookie', accessControlAllowHeaders: '*', accessControlAllowMethods: '*', accessControlAllowOrigin: '*'}),
188
- ];
189
- option.closeEndPoints = [new CloseLogEndPoint()];
190
- option.errorEndPoints = [new ErrorLogEndPoint()];
191
- option.noSuchRouteEndPointMappingThrow = () => new NotFoundError();
192
- option.fileUploadTempPath = environment.uploadTempPath;
193
- option.filters = [
194
- resourceFilter,
195
- uploadResourceFilter,
196
- // ssrFilter,
197
- // SecurityFilter,
198
- IntentSchemeFilter
199
- ];
200
- // option.serverOption = {
201
- // key: fs.readFileSync(path.resolve(__dirname, '../data/certificates/localhost-key.pem')),
202
- // cert: fs.readFileSync(path.resolve(__dirname, '../data/certificates/localhost.pem')),
203
- // }
204
- option.listen.listeningListener = (server: SimpleBootHttpServer) => {
205
- console.log(`http server startUP! listening on ${server.option.listen.port}`);
206
- };
207
-
208
- const ssr = new SimpleBootHttpSSRServer(option);
209
- await ssr.run(otherInstanceSim);
210
- return ssr;
211
- }
212
- }
30
+ ## Learn More
213
31
 
214
- const mode = process.env.MODE as ENV_MODE;
215
- const world = process.env.WORLD as ENV_MODE;
216
- new Server().run({mode, world}).then(ssr => {
217
- console.log(`server started!! (mode:${mode})`);
218
- });
219
- console.log(`server wait... (mode:${mode})`);
32
+ The detailed API documentation is available on our documentation website.
220
33
 
34
+ **[Explore the full documentation &raquo;](https://dooboostore-develop.github.io/packages/simple-boot-http-server-ssr)**
221
35
 
36
+ ## License
222
37
 
223
- ```
38
+ This package is licensed under the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,36 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var bundle_entry_exports = {};
16
+ module.exports = __toCommonJS(bundle_entry_exports);
17
+ __reExport(bundle_entry_exports, require("./codes"), module.exports);
18
+ __reExport(bundle_entry_exports, require("./decorators"), module.exports);
19
+ __reExport(bundle_entry_exports, require("./filters"), module.exports);
20
+ __reExport(bundle_entry_exports, require("./initializers"), module.exports);
21
+ __reExport(bundle_entry_exports, require("./option"), module.exports);
22
+ __reExport(bundle_entry_exports, require("./proxy"), module.exports);
23
+ __reExport(bundle_entry_exports, require("./SimpleBootHttpSSRFactory"), module.exports);
24
+ __reExport(bundle_entry_exports, require("./SimpleBootHttpSSRServer"), module.exports);
25
+ // Annotate the CommonJS export names for ESM import in node:
26
+ 0 && (module.exports = {
27
+ ...require("./codes"),
28
+ ...require("./decorators"),
29
+ ...require("./filters"),
30
+ ...require("./initializers"),
31
+ ...require("./option"),
32
+ ...require("./proxy"),
33
+ ...require("./SimpleBootHttpSSRFactory"),
34
+ ...require("./SimpleBootHttpSSRServer")
35
+ });
36
+ //# sourceMappingURL=bundle-entry.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 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;",
6
+ "names": []
7
+ }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/codes/HttpHeaders.ts"],
4
- "sourcesContent": ["import { HttpHeaders as AHttpHeaders } from '@dooboostore/simple-boot-http-server/codes/HttpHeaders';\nimport { Mimes } from './Mimes';\n\nexport const HttpHeaders = {\n ...AHttpHeaders,\n XSimpleBootSsrIntentScheme: 'x-simple-boot-ssr-intent-scheme'\n};\n\nexport const makeIntentHeaderBySymbol = (symbol: Symbol): HeadersInit => {\n return {\n [HttpHeaders.Accept]: Mimes.ApplicationJsonPostSimpleBootSsrIntentScheme,\n [HttpHeaders.XSimpleBootSsrIntentScheme]: `Symbol.for(${symbol.description})`\n }\n};\n\n\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAA4C;AAC5C,mBAAsB;AAEf,MAAM,cAAc;AAAA,EACzB,GAAG,mBAAAA;AAAA,EACH,4BAA4B;AAC9B;AAEO,MAAM,2BAA2B,CAAC,WAAgC;AACvE,SAAO;AAAA,IACL,CAAC,YAAY,MAAM,GAAG,mBAAM;AAAA,IAC5B,CAAC,YAAY,0BAA0B,GAAG,cAAc,OAAO,WAAW;AAAA,EAC5E;AACF;",
4
+ "sourcesContent": ["import { HttpHeaders as AHttpHeaders } from '@dooboostore/simple-boot-http-server/codes/HttpHeaders';\nimport { Mimes } from './Mimes';\n\nexport const HttpHeaders = {\n ...AHttpHeaders,\n XSimpleBootSsrIntentScheme: 'x-simple-boot-ssr-intent-scheme'\n};\nexport type HttpHeadersType = typeof HttpHeaders;\n\nexport const makeIntentHeaderBySymbol = (symbol: Symbol): HeadersInit => {\n return {\n [HttpHeaders.Accept]: Mimes.ApplicationJsonPostSimpleBootSsrIntentScheme,\n [HttpHeaders.XSimpleBootSsrIntentScheme]: `Symbol.for(${symbol.description})`\n }\n};\n\n\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAA4C;AAC5C,mBAAsB;AAEf,MAAM,cAAc;AAAA,EACzB,GAAG,mBAAAA;AAAA,EACH,4BAA4B;AAC9B;AAGO,MAAM,2BAA2B,CAAC,WAAgC;AACvE,SAAO;AAAA,IACL,CAAC,YAAY,MAAM,GAAG,mBAAM;AAAA,IAC5B,CAAC,YAAY,0BAA0B,GAAG,cAAc,OAAO,WAAW;AAAA,EAC5E;AACF;",
6
6
  "names": ["AHttpHeaders"]
7
7
  }
@@ -35,15 +35,13 @@ class SSRFilter {
35
35
  constructor(config, otherInstanceSim) {
36
36
  this.config = config;
37
37
  this.otherInstanceSim = otherInstanceSim;
38
+ this.simpleBootFrontPool = [];
39
+ this.simpleBootFrontQueue = new import_AsyncBlockingQueue.AsyncBlockingQueue();
40
+ this.welcomUrl = "http://localhost";
41
+ this.poolGeneration = 0;
38
42
  config.frontDistIndexFileName = config.frontDistIndexFileName || "index.html";
39
43
  this.indexHTML = import_JsdomInitializer.JsdomInitializer.loadFile(this.config.frontDistPath, config.frontDistIndexFileName);
40
44
  }
41
- simpleBootFrontPool = [];
42
- simpleBootFrontQueue = new import_AsyncBlockingQueue.AsyncBlockingQueue();
43
- indexHTML;
44
- welcomUrl = "http://localhost";
45
- poolGeneration = 0;
46
- intervalId;
47
45
  async onInit(app) {
48
46
  for (let i = 0; i < this.config.poolOption.min; i++) {
49
47
  await this.pushQueue();
@@ -130,7 +128,7 @@ class SSRFilter {
130
128
  simpleBootFront.routingSubjectObservable.pipe(
131
129
  // @ts-ignore
132
130
  (0, import_filter.filter)(
133
- (it) => it.state === "end" && typeof it.routerModule.intent.uri === "string" && targetUrl.endsWith(it.routerModule.intent.uri)
131
+ (it) => it.triggerPoint === "end" && typeof it.routerModule.intent.uri === "string" && targetUrl.endsWith(it.routerModule.intent.uri)
134
132
  ),
135
133
  // delay(1000),
136
134
  (0, import_first.first)()
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/filters/SSRFilter.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 { JsdomInitializer } from '../initializers/JsdomInitializer';\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 { firstValueFrom } from '@dooboostore/core/message/internal/firstValueFrom';\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 SSRFilter 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 // console.log('SimpleBootHttpSSRFactory init success ', + this.simpleBootFrontPool.length)\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 // workerTs(workerOptions: WorkerOptions) {\n // workerOptions.eval = true;\n // if (!workerOptions.workerData) {\n // workerOptions.workerData = {};\n // }\n // workerOptions.workerData.__filename = '/Users/hyunhakim/source/visualkhh/pet-space/libs/simple-boot-http-ssr/dist/filters/SSRCreatorWorker.js';\n // return new Worker(` const wk = require('worker_threads'); require('ts-node').register(); let file = wk.workerData.__filename; require(file); `, workerOptions,);\n // }\n\n async makeJsdom() {\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(jsdom: JSDOM.JSDOM) {\n const name = RandomUtils.uuid();\n // const jsdom = await this.makeJsdom();\n const window = jsdom.window as unknown as Window & typeof globalThis;\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).jsdom = jsdom;\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(destorFront?: SimpleBootFront) {\n // if (destorFront) {\n // this.simpleBootFrontPool.delete(destorFront.option.name!);\n // }\n async pushQueue() {\n if (this.simpleBootFrontPool.length < this.config.poolOption.max) {\n this.enqueueFrontApp(await this.makeFront(await this.makeJsdom()));\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 // console.log('SSRFilter before-->' , simpleBootFront.option.name, 'poolLength:',this.simpleBootFrontPool.size);\n (simpleBootFront.option.window as any).ssrUse = true;\n delete (simpleBootFront.option.window as any).server_side_data;\n\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('rrrrr');\n // simpleBootFront.routingSubjectObservable.subscribe(it => {\n // if (it.state === 'end' && it.routerModule.intent.uri === targetUrl) {\n // console.log('vvvvvvvvvvvv', it.state, it.routerModule.intent.uri);\n // }\n // });\n await simpleBootFront.goRouting(targetUrl);\n await new Promise(r => setTimeout(r, 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 // TODO: \uC635\uC158\uC73C\uB85C \uC774\uAC70 \uD0A4\uACE0 \uB044\uACE0\uD560\uC218\uC788\uAC8C \uD574\uC57C\uB420\uAE4C..?\n // simpleBootFront.routingSubjectObservable.pipe(\n // filter((it) =>\n // it.state === 'end' &&\n // typeof it.routerModule.intent.uri === 'string' &&\n // targetUrl.endsWith(it.routerModule.intent.uri)\n // ),\n // // delay(1000),\n // first()\n // );\n const data = await firstValueFrom(\n // @ts-ignore\n simpleBootFront.routingSubjectObservable.pipe(\n // @ts-ignore\n filter(\n (it: any) =>\n it.state === '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('rrrrrssss');\n // console.log('rrrrrssss122');\n const html = this.makeHTML(simpleBootFront);\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 // console.log('--------->', simpleBootFront.option.window)\n // simpleBootFront.ninitWriteRootRouter();\n // ((simpleBootFront as any).jsdom as JSDOM.JSDOM)?.reconfigure({url: '/' });\n // simpleBootFront.option.window.location.href = 'about:blank';\n // console.log('ddddddddd', (simpleBootFront as any).generation, this.poolGeneration)\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 // Create a new one to maintain pool size\n this.pushQueue();\n } else {\n // Current instance, return to queue\n this.simpleBootFrontQueue.enqueue(simpleBootFront);\n }\n // simpleBootFront.option.window.document.body.innerHTML = this.rootJSDOM.window.document.body.innerHTML;\n // simpleBootFront.writeRootRouter()\n // await simpleBootFront.goRouting('/');\n\n // ((simpleBootFront as any).jsdom as JSDOM.JSDOM)?.reconfigure({url: this.welcomUrl });\n\n // simpleBootFront.option.window.location.href = this.welcomUrl;\n // simpleBootFront.option.window.document.documentElement.outerHTML = this.indexHTML;\n // this.simpleBootFrontQueue.enqueue(simpleBootFront);\n // await new Promise((re, r) => setTimeout(() => re(true), 10000));\n // new Promise((re, r) => setTimeout(() => re(true), 10000)).then(it => {\n // console.log('ddddddddddd')\n // });\n // this.simpleBootFrontPool.delete(simpleBootFront.option.name!);\n // if (isMainThread) { // \uBA54\uC778 \uC2A4\uB808\uB4DC\n // console.log('file-->', __filename)\n // const worker = new Worker(__filename);\n // worker.on('message', (value: any) => {\n // console.log('\uC6CC\uCEE4\uB85C\uBD80\uD130', value)\n // })\n // worker.on('exit', (value: any) => { // parentPort.close()\uAC00 \uC77C\uC5B4\uB098\uBA74 \uC774\uBCA4\uD2B8 \uBC1C\uC0DD\n // console.log('\uC6CC\uCEE4 \uB05D~');\n // })\n // worker.postMessage('ping'); // \uC6CC\uCEE4\uC2A4\uB808\uB4DC\uC5D0\uAC8C \uBA54\uC138\uC9C0\uB97C \uBCF4\uB0B8\uB2E4.\n // } else { // \uC6CC\uCEE4\uC2A4\uB808\uB4DC\n // parentPort.on('message', (value: any) => {\n // console.log(\"\uBD80\uBAA8\uB85C\uBD80\uD130\", value);\n // parentPort.postMessage('pong');\n // parentPort.close(); // \uC6CC\uCEE4\uC2A4\uB808\uB4DC \uC885\uB8CC\uB77C\uACE0 \uBA54\uC778\uC2A4\uB808\uB4DC\uC5D0 \uC54C\uB824\uC918\uC57C exit\uC774\uBCA4\uD2B8 \uBC1C\uC0DD\n // })\n // }\n\n //worker thrad\n // const workerPath = path.join(__dirname, 'SSRWorker.js');\n // const worker = new Worker(workerPath);\n // worker.once('message', (value: any) => {\n // console.log('\uC6CC\uCEE4\uB85C\uBD80\uD130', value)\n // });\n // const receiveWorker = new Worker('/Users/hyunhakim/source/visualkhh/pet-space/libs/simple-boot-http-ssr/dist/filters/SSRCreatorWorker.js');\n // receiveWorker.on('message', (msg: JSDOM.JSDOM)=>{\n // console.log('\uC6CC\uCEE4\uB85C\uBD80\uD130', msg, msg.window.document.body.innerHTML)\n // console.log('a message is sent! : ', msg)\n //\n // });\n //\n // receiveWorker.on('error', err=>{\n // console.error(err);\n // })\n //\n // receiveWorker.on('exit', ()=>console.log('exited!'));\n // receiveWorker.postMessage(\n // {\n // frontDistPath: this.factory.frontDistPath,\n // frontDistIndexFileName: this.factory.frontDistIndexFileName,\n // }\n // );\n\n // const myWorkers = this.workerTs({});\n // myWorkers.postMessage(this);\n // myWorkers.on('message', (value: SimpleBootFront) => {\n // this.pushQueue(value);\n // })\n // this\n // this.pushQueue(simpleBootFront).then(it => {\n // console.log('deee')\n // });\n // console.log('-1->', simpleBootFront.option.window.location.href);\n // simpleBootFront.option.window.location.href = this.welcomUrl;\n // simpleBootFront.option.window.location.reload();\n // console.log('-2->', simpleBootFront.option.window.location.href);\n // simpleBootFront.option.window.location.reload();\n // console.log('-3->', simpleBootFront.option.window.location.href);\n // this.simpleBootFrontQueue.enqueue(simpleBootFront);\n // await this.makeJsdom();\n // simpleBootFront.option.window.location.href = this.welcomUrl;\n }\n // console.log('----doen')\n return false;\n } else {\n // console.log('----doen2')\n return true;\n }\n }\n\n // const e = Expression.Path.pathNameData(rr.reqUrlPathName, intent.getRouterPath())\n // console.log('------intent', rr.reqUrl, rr.reqUrlPathName, intent.module, intent.getRouterPath(), e)\n // simpleBootFront.option.window.document.documentElemenh\n // \"dr-\"\uB85C \uC2DC\uC791\uD558\uB294 \uBAA8\uB4E0 attribute\uB97C \uAC00\uC9C4 element\uC5D0\uC11C \uD574\uB2F9 attribute\uB97C \uC81C\uAC70\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 html = '<!DOCTYPE html>' + html;\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.res.writeHead(status, {[HttpHeaders.ContentType]: Mimes.TextHtml});\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 // console.log('done--------', sw)\n return true;\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,yBAA4B;AAG5B,8BAAiC;AAEjC,mBAAsB;AACtB,wBAA2B;AAI3B,gCAAmC;AACnC,yBAA4B;AAE5B,2BAA8B;AAC9B,4BAA+B;AAC/B,oBAAuB;AACvB,mBAAsB;AACtB,4BAA+B;AAoBxB,MAAM,UAA4B;AAAA,EAQvC,YACS,QACA,kBACP;AAFO;AACA;AAEP,WAAO,yBAAyB,OAAO,0BAA0B;AACjE,SAAK,YAAY,yCAAiB,SAAS,KAAK,OAA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O,oBAAoB;AAC3B,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;AAElH,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;AAE7G,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 } from '@dooboostore/core/types';\nimport { JsdomInitializer } from '../initializers/JsdomInitializer';\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 { firstValueFrom } from '@dooboostore/core/message/internal/firstValueFrom';\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 SSRFilter 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 // console.log('SimpleBootHttpSSRFactory init success ', + this.simpleBootFrontPool.length)\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 // workerTs(workerOptions: WorkerOptions) {\n // workerOptions.eval = true;\n // if (!workerOptions.workerData) {\n // workerOptions.workerData = {};\n // }\n // workerOptions.workerData.__filename = '/Users/hyunhakim/source/visualkhh/pet-space/libs/simple-boot-http-ssr/dist/filters/SSRCreatorWorker.js';\n // return new Worker(` const wk = require('worker_threads'); require('ts-node').register(); let file = wk.workerData.__filename; require(file); `, workerOptions,);\n // }\n\n async makeJsdom() {\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(jsdom: JSDOM.JSDOM) {\n const name = RandomUtils.uuid();\n // const jsdom = await this.makeJsdom();\n const window = jsdom.window as unknown as Window & typeof globalThis;\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).jsdom = jsdom;\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(destorFront?: SimpleBootFront) {\n // if (destorFront) {\n // this.simpleBootFrontPool.delete(destorFront.option.name!);\n // }\n async pushQueue() {\n if (this.simpleBootFrontPool.length < this.config.poolOption.max) {\n this.enqueueFrontApp(await this.makeFront(await this.makeJsdom()));\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 // console.log('SSRFilter before-->' , simpleBootFront.option.name, 'poolLength:',this.simpleBootFrontPool.size);\n (simpleBootFront.option.window as any).ssrUse = true;\n delete (simpleBootFront.option.window as any).server_side_data;\n\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('rrrrr');\n // simpleBootFront.routingSubjectObservable.subscribe(it => {\n // if (it.state === 'end' && it.routerModule.intent.uri === targetUrl) {\n // console.log('vvvvvvvvvvvv', it.state, it.routerModule.intent.uri);\n // }\n // });\n await simpleBootFront.goRouting(targetUrl);\n await new Promise(r => setTimeout(r, 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 // TODO: \uC635\uC158\uC73C\uB85C \uC774\uAC70 \uD0A4\uACE0 \uB044\uACE0\uD560\uC218\uC788\uAC8C \uD574\uC57C\uB420\uAE4C..?\n // simpleBootFront.routingSubjectObservable.pipe(\n // filter((it) =>\n // it.state === 'end' &&\n // typeof it.routerModule.intent.uri === 'string' &&\n // targetUrl.endsWith(it.routerModule.intent.uri)\n // ),\n // // delay(1000),\n // first()\n // );\n const data = await firstValueFrom(\n // @ts-ignore\n simpleBootFront.routingSubjectObservable.pipe(\n // @ts-ignore\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('rrrrrssss');\n // console.log('rrrrrssss122');\n // await new Promise(r => setTimeout(r, 5000)); // <--\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 const html = this.makeHTML(simpleBootFront);\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 // console.log('--------->', simpleBootFront.option.window)\n // simpleBootFront.ninitWriteRootRouter();\n // ((simpleBootFront as any).jsdom as JSDOM.JSDOM)?.reconfigure({url: '/' });\n // simpleBootFront.option.window.location.href = 'about:blank';\n // console.log('ddddddddd', (simpleBootFront as any).generation, this.poolGeneration)\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 // Create a new one to maintain pool size\n this.pushQueue();\n } else {\n // Current instance, return to queue\n this.simpleBootFrontQueue.enqueue(simpleBootFront);\n }\n // simpleBootFront.option.window.document.body.innerHTML = this.rootJSDOM.window.document.body.innerHTML;\n // simpleBootFront.writeRootRouter()\n // await simpleBootFront.goRouting('/');\n\n // ((simpleBootFront as any).jsdom as JSDOM.JSDOM)?.reconfigure({url: this.welcomUrl });\n\n // simpleBootFront.option.window.location.href = this.welcomUrl;\n // simpleBootFront.option.window.document.documentElement.outerHTML = this.indexHTML;\n // this.simpleBootFrontQueue.enqueue(simpleBootFront);\n // await new Promise((re, r) => setTimeout(() => re(true), 10000));\n // new Promise((re, r) => setTimeout(() => re(true), 10000)).then(it => {\n // console.log('ddddddddddd')\n // });\n // this.simpleBootFrontPool.delete(simpleBootFront.option.name!);\n // if (isMainThread) { // \uBA54\uC778 \uC2A4\uB808\uB4DC\n // console.log('file-->', __filename)\n // const worker = new Worker(__filename);\n // worker.on('message', (value: any) => {\n // console.log('\uC6CC\uCEE4\uB85C\uBD80\uD130', value)\n // })\n // worker.on('exit', (value: any) => { // parentPort.close()\uAC00 \uC77C\uC5B4\uB098\uBA74 \uC774\uBCA4\uD2B8 \uBC1C\uC0DD\n // console.log('\uC6CC\uCEE4 \uB05D~');\n // })\n // worker.postMessage('ping'); // \uC6CC\uCEE4\uC2A4\uB808\uB4DC\uC5D0\uAC8C \uBA54\uC138\uC9C0\uB97C \uBCF4\uB0B8\uB2E4.\n // } else { // \uC6CC\uCEE4\uC2A4\uB808\uB4DC\n // parentPort.on('message', (value: any) => {\n // console.log(\"\uBD80\uBAA8\uB85C\uBD80\uD130\", value);\n // parentPort.postMessage('pong');\n // parentPort.close(); // \uC6CC\uCEE4\uC2A4\uB808\uB4DC \uC885\uB8CC\uB77C\uACE0 \uBA54\uC778\uC2A4\uB808\uB4DC\uC5D0 \uC54C\uB824\uC918\uC57C exit\uC774\uBCA4\uD2B8 \uBC1C\uC0DD\n // })\n // }\n\n //worker thrad\n // const workerPath = path.join(__dirname, 'SSRWorker.js');\n // const worker = new Worker(workerPath);\n // worker.once('message', (value: any) => {\n // console.log('\uC6CC\uCEE4\uB85C\uBD80\uD130', value)\n // });\n // const receiveWorker = new Worker('/Users/hyunhakim/source/visualkhh/pet-space/libs/simple-boot-http-ssr/dist/filters/SSRCreatorWorker.js');\n // receiveWorker.on('message', (msg: JSDOM.JSDOM)=>{\n // console.log('\uC6CC\uCEE4\uB85C\uBD80\uD130', msg, msg.window.document.body.innerHTML)\n // console.log('a message is sent! : ', msg)\n //\n // });\n //\n // receiveWorker.on('error', err=>{\n // console.error(err);\n // })\n //\n // receiveWorker.on('exit', ()=>console.log('exited!'));\n // receiveWorker.postMessage(\n // {\n // frontDistPath: this.factory.frontDistPath,\n // frontDistIndexFileName: this.factory.frontDistIndexFileName,\n // }\n // );\n\n // const myWorkers = this.workerTs({});\n // myWorkers.postMessage(this);\n // myWorkers.on('message', (value: SimpleBootFront) => {\n // this.pushQueue(value);\n // })\n // this\n // this.pushQueue(simpleBootFront).then(it => {\n // console.log('deee')\n // });\n // console.log('-1->', simpleBootFront.option.window.location.href);\n // simpleBootFront.option.window.location.href = this.welcomUrl;\n // simpleBootFront.option.window.location.reload();\n // console.log('-2->', simpleBootFront.option.window.location.href);\n // simpleBootFront.option.window.location.reload();\n // console.log('-3->', simpleBootFront.option.window.location.href);\n // this.simpleBootFrontQueue.enqueue(simpleBootFront);\n // await this.makeJsdom();\n // simpleBootFront.option.window.location.href = this.welcomUrl;\n }\n // console.log('----doen')\n return false;\n } else {\n // console.log('----doen2')\n return true;\n }\n }\n\n // const e = Expression.Path.pathNameData(rr.reqUrlPathName, intent.getRouterPath())\n // console.log('------intent', rr.reqUrl, rr.reqUrlPathName, intent.module, intent.getRouterPath(), e)\n // simpleBootFront.option.window.document.documentElemenh\n // \"dr-\"\uB85C \uC2DC\uC791\uD558\uB294 \uBAA8\uB4E0 attribute\uB97C \uAC00\uC9C4 element\uC5D0\uC11C \uD574\uB2F9 attribute\uB97C \uC81C\uAC70\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 html = '<!DOCTYPE html>' + html;\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.res.writeHead(status, {[HttpHeaders.ContentType]: Mimes.TextHtml});\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 // console.log('done--------', sw)\n return true;\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,yBAA4B;AAG5B,8BAAiC;AAEjC,mBAAsB;AACtB,wBAA2B;AAI3B,gCAAmC;AACnC,yBAA4B;AAE5B,2BAA8B;AAC9B,4BAA+B;AAC/B,oBAAuB;AACvB,mBAAsB;AACtB,4BAA+B;AAoBxB,MAAM,UAA4B;AAAA,EAQvC,YACS,QACA,kBACP;AAFO;AACA;AATT,SAAQ,sBAAyC,CAAC;AAClD,SAAQ,uBAAuB,IAAI,6CAAoC;AAEvE,SAAQ,YAAY;AACpB,SAAQ,iBAAiB;AAOvB,WAAO,yBAAyB,OA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AkB,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;AAElH,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;AAE7G,WAAO;AAAA,EACT;AACF;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,183 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var SSRLinkDomDomFilter_exports = {};
19
+ __export(SSRLinkDomDomFilter_exports, {
20
+ SSRLinkDomDomFilter: () => SSRLinkDomDomFilter
21
+ });
22
+ module.exports = __toCommonJS(SSRLinkDomDomFilter_exports);
23
+ var import_HttpHeaders = require("@dooboostore/simple-boot-http-server/codes/HttpHeaders");
24
+ var import_Mimes = require("@dooboostore/simple-boot-http-server/codes/Mimes");
25
+ 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
+ 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_LinkedomInitializer = require("../initializers/LinkedomInitializer");
34
+ class SSRLinkDomDomFilter {
35
+ constructor(config, otherInstanceSim) {
36
+ this.config = config;
37
+ this.otherInstanceSim = otherInstanceSim;
38
+ this.simpleBootFrontPool = [];
39
+ this.simpleBootFrontQueue = new import_AsyncBlockingQueue.AsyncBlockingQueue();
40
+ // private indexHTML: string;
41
+ this.welcomUrl = "http://localhost";
42
+ this.poolGeneration = 0;
43
+ config.frontDistIndexFileName = config.frontDistIndexFileName || "index.html";
44
+ }
45
+ async onInit(app) {
46
+ for (let i = 0; i < this.config.poolOption.min; i++) {
47
+ await this.pushQueue();
48
+ }
49
+ if (this.config.poolOption.clearIntervalTime && this.config.poolOption.clearIntervalTime > 0) {
50
+ this.intervalId = setInterval(() => {
51
+ this.poolGeneration++;
52
+ }, this.config.poolOption.clearIntervalTime);
53
+ }
54
+ }
55
+ async onDestroy() {
56
+ if (this.intervalId) {
57
+ clearInterval(this.intervalId);
58
+ }
59
+ this.simpleBootFrontPool.forEach((front) => {
60
+ front.jsdom?.window.close();
61
+ });
62
+ this.simpleBootFrontPool = [];
63
+ }
64
+ async makePage() {
65
+ return new import_LinkedomInitializer.LinkedomInitializer(
66
+ this.config.frontDistPath,
67
+ this.config.frontDistIndexFileName || "index.html",
68
+ { url: this.welcomUrl }
69
+ ).run();
70
+ }
71
+ async makeFront(window) {
72
+ const name = import_RandomUtils.RandomUtils.uuid();
73
+ window.ssrUse = false;
74
+ const option = this.config.factorySimFrontOption(import_DomRenderProxy.DomRenderProxy.final(window));
75
+ const simpleBootFront = await this.config.factory.create(option, this.config.using, this.config.domExcludes);
76
+ simpleBootFront.run(this.otherInstanceSim);
77
+ simpleBootFront.generation = this.poolGeneration;
78
+ return simpleBootFront;
79
+ }
80
+ enqueueFrontApp(simpleBootFront) {
81
+ this.simpleBootFrontPool.push(simpleBootFront);
82
+ this.simpleBootFrontQueue.enqueue(simpleBootFront);
83
+ }
84
+ async pushQueue() {
85
+ if (this.simpleBootFrontPool.length < this.config.poolOption.max) {
86
+ this.enqueueFrontApp(await this.makeFront(await this.makePage()));
87
+ }
88
+ }
89
+ async proceedBefore({ rr, app }) {
90
+ if (this.config.ssrExcludeFilter?.(rr)) {
91
+ return false;
92
+ }
93
+ if (rr.reqHasAcceptHeader(import_Mimes.Mimes.TextHtml) || rr.reqHasAcceptHeader(import_Mimes.Mimes.All)) {
94
+ if (this.simpleBootFrontQueue.isEmpty()) {
95
+ await this.pushQueue();
96
+ }
97
+ const simpleBootFront = await this.simpleBootFrontQueue.dequeue();
98
+ try {
99
+ simpleBootFront.option.window.ssrUse = true;
100
+ delete simpleBootFront.option.window.server_side_data;
101
+ const url = rr.reqUrlObj({ host: "localhost" });
102
+ if (this.config.simpleBootFront?.notFoundError) {
103
+ const intent = await simpleBootFront.getIntent(url.pathname);
104
+ if (intent.module === void 0 && !intent.getRouterPathData(rr.reqUrlPathName)) {
105
+ throw new import_NotFoundError.NotFoundError({ message: `Not Found: ${rr.reqUrlPathName}` });
106
+ }
107
+ }
108
+ const targetUrl = url.toString();
109
+ await simpleBootFront.goRouting(targetUrl);
110
+ await new Promise((r) => setTimeout(r, 0));
111
+ const data = await (0, import_firstValueFrom.firstValueFrom)(
112
+ // @ts-ignore
113
+ simpleBootFront.routingSubjectObservable.pipe(
114
+ // @ts-ignore
115
+ (0, import_filter.filter)(
116
+ (it) => it.triggerPoint === "end" && typeof it.routerModule.intent.uri === "string" && targetUrl.endsWith(it.routerModule.intent.uri)
117
+ ),
118
+ // delay(1000),
119
+ (0, import_first.first)()
120
+ )
121
+ );
122
+ const html = this.makeHTML(simpleBootFront);
123
+ await this.writeOkHtmlAndEnd({ rr }, html);
124
+ } finally {
125
+ simpleBootFront.option.window.ssrUse = false;
126
+ delete simpleBootFront.option.window.server_side_data;
127
+ if (simpleBootFront.generation < this.poolGeneration) {
128
+ const jsdom = simpleBootFront.jsdom;
129
+ jsdom?.window.close();
130
+ const index = this.simpleBootFrontPool.indexOf(simpleBootFront);
131
+ if (index > -1) {
132
+ this.simpleBootFrontPool.splice(index, 1);
133
+ }
134
+ this.pushQueue();
135
+ } else {
136
+ this.simpleBootFrontQueue.enqueue(simpleBootFront);
137
+ }
138
+ }
139
+ return false;
140
+ } else {
141
+ return true;
142
+ }
143
+ }
144
+ makeHTML(simpleBootFront) {
145
+ simpleBootFront.option.window.document.querySelectorAll("*").forEach((el) => {
146
+ Array.from(el.attributes).forEach((attr) => {
147
+ if (/^dr-/.test(attr.name) || /^domstyle/.test(attr.name) || /this-path/.test(attr.name)) {
148
+ el.removeAttribute(attr.name);
149
+ }
150
+ });
151
+ });
152
+ let html = simpleBootFront.option.window.document.documentElement.outerHTML;
153
+ html = "<!DOCTYPE html>" + html;
154
+ html = html.replace(/\$\{[\s\S]*?\}\$/g, "");
155
+ const serverSideData = simpleBootFront.option.window.server_side_data;
156
+ if (serverSideData) {
157
+ const data = Object.entries(serverSideData).map(([k, v]) => {
158
+ if (typeof v === "string") {
159
+ return `window.server_side_data.${k} = ${v}`;
160
+ } else {
161
+ return `window.server_side_data.${k} = ${JSON.stringify(v)}`;
162
+ }
163
+ }).join(";");
164
+ if (data) {
165
+ html = html.replace("</head>", `<script> window.server_side_data={}; ${data}; </script></head>`);
166
+ }
167
+ }
168
+ return html;
169
+ }
170
+ async writeOkHtmlAndEnd({ rr, status = import_HttpStatus.HttpStatus.Ok }, html) {
171
+ rr.resStatusCode(status);
172
+ rr.resSetHeader(import_HttpHeaders.HttpHeaders.ContentType, import_Mimes.Mimes.TextHtml);
173
+ await rr.resEnd(html);
174
+ }
175
+ async proceedAfter({ rr, app }) {
176
+ return true;
177
+ }
178
+ }
179
+ // Annotate the CommonJS export names for ESM import in node:
180
+ 0 && (module.exports = {
181
+ SSRLinkDomDomFilter
182
+ });
183
+ //# sourceMappingURL=SSRLinkDomDomFilter.js.map