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

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 (184) hide show
  1. package/README.md +98 -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 -4
  6. package/dist/cjs/bundle-entry.js.map +2 -2
  7. package/dist/cjs/filters/SSRDomParserFilter.js +54 -89
  8. package/dist/cjs/filters/SSRDomParserFilter.js.map +2 -2
  9. package/dist/cjs/filters/SSRFilter.js +10 -14
  10. package/dist/cjs/filters/SSRFilter.js.map +2 -2
  11. package/dist/cjs/filters/{SSRLinkDomDomFilter.js → SSRLinkDomFilter.js} +17 -21
  12. package/dist/cjs/filters/SSRLinkDomFilter.js.map +7 -0
  13. package/dist/cjs/filters/SSRSimpleWebComponentDomParserFilter.js +81 -0
  14. package/dist/cjs/filters/SSRSimpleWebComponentDomParserFilter.js.map +7 -0
  15. package/dist/cjs/filters/SSRSimpleWebComponentFilter.js +223 -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 +9 -3
  20. package/dist/cjs/filters/index.js.map +2 -2
  21. package/dist/cjs/index.js +16 -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 -2
  33. package/dist/esm/bundle-entry.js.map +2 -2
  34. package/dist/esm/filters/SSRDomParserFilter.js +52 -87
  35. package/dist/esm/filters/SSRDomParserFilter.js.map +2 -2
  36. package/dist/esm/filters/SSRFilter.js +7 -11
  37. package/dist/esm/filters/SSRFilter.js.map +2 -2
  38. package/dist/esm/filters/{SSRLinkDomDomFilter.js → SSRLinkDomFilter.js} +10 -14
  39. package/dist/esm/filters/SSRLinkDomFilter.js.map +7 -0
  40. package/dist/esm/filters/SSRSimpleWebComponentDomParserFilter.js +58 -0
  41. package/dist/esm/filters/SSRSimpleWebComponentDomParserFilter.js.map +7 -0
  42. package/dist/esm/filters/SSRSimpleWebComponentFilter.js +190 -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 +4 -1
  47. package/dist/esm/filters/index.js.map +2 -2
  48. package/dist/esm/index.js +6 -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 +56266 -10404
  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 -2
  63. package/dist/types/bundle-entry.d.ts.map +1 -1
  64. package/dist/types/filters/SSRDomParserFilter.d.ts +12 -18
  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 → SSRLinkDomFilter.d.ts} +6 -6
  69. package/dist/types/filters/SSRLinkDomFilter.d.ts.map +1 -0
  70. package/dist/types/filters/SSRSimpleWebComponentDomParserFilter.d.ts +37 -0
  71. package/dist/types/filters/SSRSimpleWebComponentDomParserFilter.d.ts.map +1 -0
  72. package/dist/types/filters/SSRSimpleWebComponentFilter.d.ts +57 -0
  73. package/dist/types/filters/SSRSimpleWebComponentFilter.d.ts.map +1 -0
  74. package/dist/types/filters/SSRWorker.d.ts +1 -1
  75. package/dist/types/filters/SSRWorker.d.ts.map +1 -1
  76. package/dist/types/filters/index.d.ts +4 -1
  77. package/dist/types/filters/index.d.ts.map +1 -1
  78. package/dist/types/index.d.ts +6 -2
  79. package/dist/types/index.d.ts.map +1 -1
  80. package/dist/types/initializers/DomParserInitializer.d.ts +2 -0
  81. package/dist/types/initializers/DomParserInitializer.d.ts.map +1 -1
  82. package/dist/types/proxy/SSRDomParserFilterDataHydrationProxy.d.ts +7 -0
  83. package/dist/types/proxy/SSRDomParserFilterDataHydrationProxy.d.ts.map +1 -0
  84. package/dist/types/proxy/index.d.ts +1 -4
  85. package/dist/types/proxy/index.d.ts.map +1 -1
  86. package/dist/umd-bundle/dooboostore-simple-boot-http-server-ssr.umd.js +56265 -10408
  87. package/dist/umd-bundle/dooboostore-simple-boot-http-server-ssr.umd.js.map +4 -4
  88. package/package.json +22 -15
  89. package/src/SimpleBootHttpSSRFactory.ts +1 -1
  90. package/src/SimpleBootHttpSSRServer.ts +5 -4
  91. package/src/bundle-entry.ts +0 -2
  92. package/src/filters/SSRDomParserFilter.ts +113 -126
  93. package/src/filters/SSRFilter.ts +7 -12
  94. package/src/filters/{SSRLinkDomDomFilter.ts → SSRLinkDomFilter.ts} +10 -15
  95. package/src/filters/SSRSimpleWebComponentDomParserFilter.ts +106 -0
  96. package/src/filters/SSRSimpleWebComponentFilter.ts +306 -0
  97. package/src/filters/SSRWorker.ts +1 -2
  98. package/src/filters/index.ts +5 -2
  99. package/src/index.ts +6 -9
  100. package/src/initializers/DomParserInitializer.ts +9 -2
  101. package/src/proxy/SSRDomParserFilterDataHydrationProxy.ts +63 -0
  102. package/src/proxy/index.ts +1 -4
  103. package/tsconfig.json +1 -0
  104. package/README.MD +0 -36
  105. package/dist/cjs/codes/HttpHeaders.js +0 -41
  106. package/dist/cjs/codes/HttpHeaders.js.map +0 -7
  107. package/dist/cjs/codes/Mimes.js +0 -33
  108. package/dist/cjs/codes/Mimes.js.map +0 -7
  109. package/dist/cjs/codes/index.js +0 -24
  110. package/dist/cjs/codes/index.js.map +0 -7
  111. package/dist/cjs/decorators/LoadAroundBefore.js +0 -54
  112. package/dist/cjs/decorators/LoadAroundBefore.js.map +0 -7
  113. package/dist/cjs/decorators/SaveAroundAfter.js +0 -53
  114. package/dist/cjs/decorators/SaveAroundAfter.js.map +0 -7
  115. package/dist/cjs/decorators/index.js +0 -24
  116. package/dist/cjs/decorators/index.js.map +0 -7
  117. package/dist/cjs/filters/IntentSchemeFilter.js +0 -92
  118. package/dist/cjs/filters/IntentSchemeFilter.js.map +0 -7
  119. package/dist/cjs/filters/SSRLinkDomDomFilter.js.map +0 -7
  120. package/dist/cjs/proxy/IntentSchemeFrontProxy.js +0 -87
  121. package/dist/cjs/proxy/IntentSchemeFrontProxy.js.map +0 -7
  122. package/dist/cjs/proxy/IntentSchemeServerProxy.js +0 -67
  123. package/dist/cjs/proxy/IntentSchemeServerProxy.js.map +0 -7
  124. package/dist/cjs/proxy/SymbolIntentApiServiceProxy.js +0 -138
  125. package/dist/cjs/proxy/SymbolIntentApiServiceProxy.js.map +0 -7
  126. package/dist/cjs/proxy/SymbolIntentApiServiceProxyBase.js +0 -35
  127. package/dist/cjs/proxy/SymbolIntentApiServiceProxyBase.js.map +0 -7
  128. package/dist/esm/codes/HttpHeaders.js +0 -17
  129. package/dist/esm/codes/HttpHeaders.js.map +0 -7
  130. package/dist/esm/codes/Mimes.js +0 -10
  131. package/dist/esm/codes/Mimes.js.map +0 -7
  132. package/dist/esm/codes/index.js +0 -3
  133. package/dist/esm/codes/index.js.map +0 -7
  134. package/dist/esm/decorators/LoadAroundBefore.js +0 -31
  135. package/dist/esm/decorators/LoadAroundBefore.js.map +0 -7
  136. package/dist/esm/decorators/SaveAroundAfter.js +0 -29
  137. package/dist/esm/decorators/SaveAroundAfter.js.map +0 -7
  138. package/dist/esm/decorators/index.js +0 -3
  139. package/dist/esm/decorators/index.js.map +0 -7
  140. package/dist/esm/filters/IntentSchemeFilter.js +0 -69
  141. package/dist/esm/filters/IntentSchemeFilter.js.map +0 -7
  142. package/dist/esm/filters/SSRLinkDomDomFilter.js.map +0 -7
  143. package/dist/esm/proxy/IntentSchemeFrontProxy.js +0 -64
  144. package/dist/esm/proxy/IntentSchemeFrontProxy.js.map +0 -7
  145. package/dist/esm/proxy/IntentSchemeServerProxy.js +0 -44
  146. package/dist/esm/proxy/IntentSchemeServerProxy.js.map +0 -7
  147. package/dist/esm/proxy/SymbolIntentApiServiceProxy.js +0 -115
  148. package/dist/esm/proxy/SymbolIntentApiServiceProxy.js.map +0 -7
  149. package/dist/esm/proxy/SymbolIntentApiServiceProxyBase.js +0 -12
  150. package/dist/esm/proxy/SymbolIntentApiServiceProxyBase.js.map +0 -7
  151. package/dist/types/codes/HttpHeaders.d.ts +0 -45
  152. package/dist/types/codes/HttpHeaders.d.ts.map +0 -1
  153. package/dist/types/codes/Mimes.d.ts +0 -31
  154. package/dist/types/codes/Mimes.d.ts.map +0 -1
  155. package/dist/types/codes/index.d.ts +0 -3
  156. package/dist/types/codes/index.d.ts.map +0 -1
  157. package/dist/types/decorators/LoadAroundBefore.d.ts +0 -2
  158. package/dist/types/decorators/LoadAroundBefore.d.ts.map +0 -1
  159. package/dist/types/decorators/SaveAroundAfter.d.ts +0 -3
  160. package/dist/types/decorators/SaveAroundAfter.d.ts.map +0 -1
  161. package/dist/types/decorators/index.d.ts +0 -3
  162. package/dist/types/decorators/index.d.ts.map +0 -1
  163. package/dist/types/filters/IntentSchemeFilter.d.ts +0 -20
  164. package/dist/types/filters/IntentSchemeFilter.d.ts.map +0 -1
  165. package/dist/types/filters/SSRLinkDomDomFilter.d.ts.map +0 -1
  166. package/dist/types/proxy/IntentSchemeFrontProxy.d.ts +0 -4
  167. package/dist/types/proxy/IntentSchemeFrontProxy.d.ts.map +0 -1
  168. package/dist/types/proxy/IntentSchemeServerProxy.d.ts +0 -4
  169. package/dist/types/proxy/IntentSchemeServerProxy.d.ts.map +0 -1
  170. package/dist/types/proxy/SymbolIntentApiServiceProxy.d.ts +0 -18
  171. package/dist/types/proxy/SymbolIntentApiServiceProxy.d.ts.map +0 -1
  172. package/dist/types/proxy/SymbolIntentApiServiceProxyBase.d.ts +0 -5
  173. package/dist/types/proxy/SymbolIntentApiServiceProxyBase.d.ts.map +0 -1
  174. package/src/codes/HttpHeaders.ts +0 -17
  175. package/src/codes/Mimes.ts +0 -6
  176. package/src/codes/index.ts +0 -2
  177. package/src/decorators/LoadAroundBefore.ts +0 -28
  178. package/src/decorators/SaveAroundAfter.ts +0 -27
  179. package/src/decorators/index.ts +0 -2
  180. package/src/filters/IntentSchemeFilter.ts +0 -69
  181. package/src/proxy/IntentSchemeFrontProxy.ts +0 -67
  182. package/src/proxy/IntentSchemeServerProxy.ts +0 -35
  183. package/src/proxy/SymbolIntentApiServiceProxy.ts +0 -115
  184. package/src/proxy/SymbolIntentApiServiceProxyBase.ts +0 -19
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dooboostore/simple-boot-http-server-ssr",
3
- "version": "1.0.14",
3
+ "version": "1.0.16",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/cjs/index.js",
@@ -38,6 +38,11 @@
38
38
  "import": "./dist/esm/index.js",
39
39
  "require": "./dist/cjs/index.js"
40
40
  },
41
+ "./bundle-entry": {
42
+ "types": "./dist/types/bundle-entry.d.ts",
43
+ "import": "./dist/esm/bundle-entry.js",
44
+ "require": "./dist/cjs/bundle-entry.js"
45
+ },
41
46
  "./*": {
42
47
  "types": "./dist/types/*.d.ts",
43
48
  "import": "./dist/esm/*.js",
@@ -65,7 +70,6 @@
65
70
  "reflect-metadata": "^0.2.2"
66
71
  },
67
72
  "devDependencies": {
68
- "@types/jsdom": "^21.1.7",
69
73
  "@babel/core": "^7.24.0",
70
74
  "@babel/plugin-proposal-class-properties": "^7.18.6",
71
75
  "@babel/plugin-proposal-decorators": "^7.24.0",
@@ -73,27 +77,30 @@
73
77
  "@babel/preset-env": "^7.24.0",
74
78
  "@babel/preset-typescript": "^7.24.0",
75
79
  "@types/jest": "^26.0.22",
76
- "raw-loader": "^4.0.2",
80
+ "@types/jsdom": "^21.1.7",
81
+ "@types/node": "^20",
82
+ "@types/node-gzip": "^1.1.0",
77
83
  "@typescript-eslint/eslint-plugin": "^4.16.1",
78
84
  "@typescript-eslint/parser": "^4.16.1",
85
+ "esbuild": "^0.23.0",
86
+ "esbuild-plugin-tsc": "^0.5.0",
87
+ "raw-loader": "^4.0.2",
79
88
  "tslib": "^2.8.1",
80
- "@types/node": "^20",
81
89
  "typescript": "^5.9.2",
82
- "@types/node-gzip": "^1.1.0",
83
- "esbuild-plugin-tsc": "^0.5.0",
84
- "esbuild": "^0.23.0",
85
- "@dooboostore/core-node": "1.0.10",
86
- "@dooboostore/core-web": "1.0.9",
87
- "@dooboostore/dom-render": "1.0.112",
88
- "@dooboostore/simple-boot": "1.0.53",
89
- "@dooboostore/core": "1.0.28",
90
- "@dooboostore/simple-boot-front": "1.0.130",
91
- "@dooboostore/simple-boot-http-server": "1.0.23"
90
+ "@dooboostore/core": "1.0.32",
91
+ "@dooboostore/core-web": "1.0.12",
92
+ "@dooboostore/simple-boot": "1.0.56",
93
+ "@dooboostore/dom-render": "1.0.113",
94
+ "@dooboostore/dom-parser": "1.0.7",
95
+ "@dooboostore/simple-boot-front": "1.0.131",
96
+ "@dooboostore/simple-boot-http-server": "1.0.25",
97
+ "@dooboostore/simple-web-component": "1.0.37",
98
+ "@dooboostore/core-node": "1.0.12"
92
99
  },
93
100
  "dependencies": {
94
101
  "jsdom": "^26.0.0",
95
102
  "linkedom": "0.18.12",
96
- "@dooboostore/dom-parser": "1.0.1"
103
+ "playwright": "^1.59.1"
97
104
  },
98
105
  "scripts": {
99
106
  "clean": "rm -rf dist",
@@ -1,5 +1,5 @@
1
1
  import { SimpleBootFront } from '@dooboostore/simple-boot-front/SimpleBootFront';
2
- import { ConstructorType } from '@dooboostore/core/types';
2
+ import { ConstructorType } from '@dooboostore/core';
3
3
  import { SimFrontOption } from '@dooboostore/simple-boot-front/option/SimFrontOption';
4
4
  export abstract class SimpleBootHttpSSRFactory {
5
5
  public abstract factory(simFrontOption: SimFrontOption, using: (ConstructorType<any> | Function)[], domExcludes: ConstructorType<any>[]): Promise<SimpleBootFront> ;
@@ -1,15 +1,16 @@
1
1
  import { SimpleBootHttpServer } from '@dooboostore/simple-boot-http-server/SimpleBootHttpServer';
2
- // import { SimstanceManager } from '@dooboostore/simple-boot/simstance/SimstanceManager';
3
2
  import { HttpSSRServerOption } from './option/HttpSSRServerOption';
4
- import { ConstructorType } from '@dooboostore/core/types';
3
+ import { ConstructorType } from '@dooboostore/core';
4
+ import {SimConfig} from "@dooboostore/simple-boot/decorators/SimDecorator";
5
5
 
6
6
  export class SimpleBootHttpSSRServer extends SimpleBootHttpServer {
7
7
  constructor(option?: HttpSSRServerOption) {
8
8
  super(option)
9
9
  }
10
10
 
11
- run(otherInstanceSim?: Map<ConstructorType<any>, any>) {
12
- const oi = new Map<ConstructorType<any>, any>()
11
+ run(otherInstanceSim?: Map<ConstructorType<any> | Function | SimConfig | symbol, any>) {
12
+ const oi = new Map<ConstructorType<any> | Function | SimConfig | symbol, any>();
13
+ oi.set(SimpleBootHttpSSRServer, this);
13
14
  otherInstanceSim?.forEach((value, key) => oi.set(key, value));
14
15
  return super.run(oi);
15
16
  }
@@ -1,5 +1,3 @@
1
- export * from './codes';
2
- export * from './decorators';
3
1
  export * from './filters';
4
2
  export * from './initializers';
5
3
  export * from './option';
@@ -1,36 +1,31 @@
1
1
  import { RequestResponse } from '@dooboostore/simple-boot-http-server/models/RequestResponse';
2
2
  import { HttpHeaders } from '@dooboostore/simple-boot-http-server/codes/HttpHeaders';
3
3
  import { SimpleBootHttpSSRFactory } from '../SimpleBootHttpSSRFactory';
4
- import { ConstructorType } from '@dooboostore/core/types';
4
+ import { ConstructorType, AsyncBlockingQueue, RandomUtils, MessageOperator, MessageInternal, Promises } from '@dooboostore/core';
5
5
  import { Filter } from '@dooboostore/simple-boot-http-server/filters/Filter';
6
6
  import { Mimes } from '@dooboostore/simple-boot-http-server/codes/Mimes';
7
7
  import { HttpStatus } from '@dooboostore/simple-boot-http-server/codes/HttpStatus';
8
8
  import { SimpleBootHttpServer } from '@dooboostore/simple-boot-http-server/SimpleBootHttpServer';
9
9
  import { SimFrontOption } from '@dooboostore/simple-boot-front/option/SimFrontOption';
10
10
  import { SimpleBootFront } from '@dooboostore/simple-boot-front/SimpleBootFront';
11
- import { AsyncBlockingQueue } from '@dooboostore/core/queues/AsyncBlockingQueue';
12
- import { RandomUtils } from '@dooboostore/core/random/RandomUtils';
13
11
  import * as JSDOM from 'jsdom';
14
12
  import { NotFoundError } from '@dooboostore/simple-boot-http-server/errors/NotFoundError';
15
- import { DomRenderProxy } from '@dooboostore/dom-render/DomRenderProxy';
16
- import { filter } from '@dooboostore/core/message/operators/filter';
17
- import { first } from '@dooboostore/core/message/operators/first';
18
- import { delay } from '@dooboostore/core/message/operators/delay';
19
- import { firstValueFrom } from '@dooboostore/core/message/internal/firstValueFrom';
13
+ import { DomRenderProxy } from '@dooboostore/dom-render';
20
14
  import { parseHTML } from 'linkedom';
21
- import {Promises} from '@dooboostore/core/promise/Promises';
22
15
  import { DomParserInitializer } from '../initializers/DomParserInitializer';
16
+ import { JsdomInitializer } from '../initializers';
17
+ import { SimConfig } from '@dooboostore/simple-boot/decorators/SimDecorator';
23
18
 
24
- export type FactoryAndParams = {
19
+ export type DomParserFactoryAndParams = {
25
20
  frontDistPath: string;
26
21
  frontDistIndexFileName?: string;
27
22
  factorySimFrontOption: (window: any) => SimFrontOption;
28
23
  factory: SimpleBootHttpSSRFactory;
29
- poolOption: {
30
- max: number;
31
- min: number;
32
- clearIntervalTime?: number;
33
- };
24
+ // poolOption: {
25
+ // max: number;
26
+ // min: number;
27
+ // clearIntervalTime?: number;
28
+ // };
34
29
  using: ConstructorType<any>[];
35
30
  domExcludes?: ConstructorType<any>[];
36
31
  ssrExcludeFilter?: (rr: RequestResponse) => boolean;
@@ -40,150 +35,152 @@ export type FactoryAndParams = {
40
35
  };
41
36
 
42
37
  export class SSRDomParserFilter implements Filter {
43
- private simpleBootFrontPool: SimpleBootFront[] = [];
44
- private simpleBootFrontQueue = new AsyncBlockingQueue<SimpleBootFront>();
38
+ // private simpleBootFrontPool: SimpleBootFront[] = [];
39
+ // private simpleBootFrontQueue = new AsyncBlockingQueue<SimpleBootFront>();
45
40
  // private indexHTML: string;
46
41
  private welcomUrl = 'http://localhost';
47
- private poolGeneration = 0;
48
- private intervalId?: NodeJS.Timeout;
42
+ // private poolGeneration = 0;
43
+ // private intervalId?: NodeJS.Timeout;
49
44
 
50
45
  constructor(
51
- public config: FactoryAndParams,
52
- public otherInstanceSim?: Map<ConstructorType<any>, any>
46
+ public config: DomParserFactoryAndParams,
47
+ public otherInstanceSim?: Map<ConstructorType<any> | Function | SimConfig | Symbol, any>
53
48
  ) {
54
49
  config.frontDistIndexFileName = config.frontDistIndexFileName || 'index.html';
55
50
  // this.indexHTML = JsdomInitializer.loadFile(this.config.frontDistPath, config.frontDistIndexFileName);
56
51
  }
57
52
 
58
53
  async onInit(app: SimpleBootHttpServer) {
59
- for (let i = 0; i < this.config.poolOption.min; i++) {
60
- await this.pushQueue();
61
- }
62
-
63
- if (this.config.poolOption.clearIntervalTime && this.config.poolOption.clearIntervalTime > 0) {
64
- this.intervalId = setInterval(() => {
65
- this.poolGeneration++;
66
- }, this.config.poolOption.clearIntervalTime);
67
- }
54
+ // for (let i = 0; i < this.config.poolOption.min; i++) {
55
+ // await this.pushQueue();
56
+ // }
57
+ // if (this.config.poolOption.clearIntervalTime && this.config.poolOption.clearIntervalTime > 0) {
58
+ // this.intervalId = setInterval(() => {
59
+ // this.poolGeneration++;
60
+ // }, this.config.poolOption.clearIntervalTime);
61
+ // }
68
62
  }
69
63
 
70
64
  async onDestroy() {
71
- if (this.intervalId) {
72
- clearInterval(this.intervalId);
73
- }
74
- // this.simpleBootFrontQueue.clear();
75
- this.simpleBootFrontPool.forEach(front => {
76
- (front as any).jsdom?.window.close();
77
- });
78
- this.simpleBootFrontPool = [];
65
+ // if (this.intervalId) {
66
+ // clearInterval(this.intervalId);
67
+ // }
68
+ // // this.simpleBootFrontQueue.clear();
69
+ // this.simpleBootFrontPool.forEach(front => {
70
+ // // JSDOM도 정리 (하위 호환성)
71
+ // (front as any).jsdom?.window.close();
72
+ // // Window close - 이것만으로 WindowBase.close()가 호출되어 메모리 정리됨
73
+ // (front.option.window as any)?.close?.();
74
+ // });
75
+ // this.simpleBootFrontPool = [];
79
76
  }
80
77
 
81
- async makePage() {
82
- let windowPromise = await new DomParserInitializer(
83
- this.config.frontDistPath,
84
- this.config.frontDistIndexFileName || 'index.html',
85
- { url: this.welcomUrl }
86
- ).run();
87
- return windowPromise;
78
+ async makePage(url = this.welcomUrl) {
79
+ const domParserInitializer = new DomParserInitializer(this.config.frontDistPath, this.config.frontDistIndexFileName || 'index.html', { url: url });
80
+ const window = await domParserInitializer.run();
81
+ // window.document.querySelector('#app').setAttribute(('vvv'),'zzz')
82
+ // console.log('vvv', window.document.querySelector('#app'))
83
+ // console.log('------', window.document.documentElement.outerHTML);
84
+ return { window, domParserInitializer };
88
85
  // const jsdom = await new JsdomInitializer(
89
86
  // this.config.frontDistPath,
90
87
  // this.config.frontDistIndexFileName || 'index.html',
91
88
  // { url: this.welcomUrl }
92
89
  // ).run();
90
+ // return { window: jsdom.window as any, domParserInitializer: {destroy: () => {jsdom.window.close()}} };
93
91
  // return jsdom;
94
92
  }
95
93
 
96
- async makeFront(window: Window) {
94
+ async makeFront(window: Window, otherInstanceSim?: Map<Function | ConstructorType<any> | SimConfig | Symbol, any>) {
97
95
  const name = RandomUtils.uuid();
98
96
  (window as any).ssrUse = false;
99
97
  const option = this.config.factorySimFrontOption(DomRenderProxy.final(window));
100
- const simpleBootFront = await this.config.factory.create(option, this.config.using, this.config.domExcludes);
101
- simpleBootFront.run(this.otherInstanceSim);
102
- (simpleBootFront as any).generation = this.poolGeneration;
98
+ const domExcludes = [RequestResponse, ...(this.config.domExcludes || [])];
99
+ const simpleBootFront = await this.config.factory.create(option, this.config.using, domExcludes);
100
+ otherInstanceSim ??= new Map<Function | ConstructorType<any> | SimConfig | symbol, any>();
101
+ this.otherInstanceSim?.forEach((v, k) => otherInstanceSim!.set(k, v));
102
+
103
+ simpleBootFront.run(otherInstanceSim as any);
104
+ // (simpleBootFront as any).generation = this.poolGeneration;
103
105
  return simpleBootFront;
104
106
  }
105
107
 
106
- enqueueFrontApp(simpleBootFront: SimpleBootFront) {
107
- // this.simpleBootFrontPool.set(simpleBootFront.option.name!, simpleBootFront);
108
- this.simpleBootFrontPool.push(simpleBootFront);
109
- this.simpleBootFrontQueue.enqueue(simpleBootFront);
110
- }
111
- async pushQueue() {
112
- if (this.simpleBootFrontPool.length < this.config.poolOption.max) {
113
- this.enqueueFrontApp(await this.makeFront(await this.makePage()));
114
- }
115
- }
108
+ // enqueueFrontApp(simpleBootFront: SimpleBootFront) {
109
+ // // this.simpleBootFrontPool.set(simpleBootFront.option.name!, simpleBootFront);
110
+ // this.simpleBootFrontPool.push(simpleBootFront);
111
+ // this.simpleBootFrontQueue.enqueue(simpleBootFront);
112
+ // }
113
+ //
114
+ // async pushQueue() {
115
+ // if (this.simpleBootFrontPool.length < this.config.poolOption.max) {
116
+ // this.enqueueFrontApp(await this.makeFront(await this.makePage()));
117
+ // }
118
+ // }
116
119
 
117
120
  async proceedBefore({ rr, app }: { rr: RequestResponse; app: SimpleBootHttpServer; carrier: Map<string, any> }) {
118
121
  if (this.config.ssrExcludeFilter?.(rr)) {
119
122
  return false;
120
123
  }
121
124
  if (rr.reqHasAcceptHeader(Mimes.TextHtml) || rr.reqHasAcceptHeader(Mimes.All)) {
122
- if (this.simpleBootFrontQueue.isEmpty()) {
123
- await this.pushQueue();
124
- }
125
- const simpleBootFront = await this.simpleBootFrontQueue.dequeue();
125
+ // if (this.simpleBootFrontQueue.isEmpty()) {
126
+ // await this.pushQueue();
127
+ // }
128
+ // const simpleBootFront = await this.simpleBootFrontQueue.dequeue();
129
+ const url = rr.reqUrlObj({ host: 'localhost' });
130
+ const targetUrl = url.toString() ?? this.welcomUrl;
131
+ const { window, domParserInitializer } = await this.makePage(targetUrl);
132
+ const otherSim = new Map<Function | ConstructorType<any> | SimConfig | Symbol, any>();
133
+ otherSim.set(RequestResponse, rr);
134
+ const simpleBootFront = await this.makeFront(window, otherSim);
126
135
  try {
127
136
  (simpleBootFront.option.window as any).ssrUse = true;
128
- delete (simpleBootFront.option.window as any).server_side_data;
129
- const url = rr.reqUrlObj({ host: 'localhost' });
137
+ // console.log(simpleBootFront.routing)
130
138
  if (this.config.simpleBootFront?.notFoundError) {
131
139
  // intent router check first
132
- const intent = await simpleBootFront.getIntent(url.pathname);
140
+ const intent = await simpleBootFront.routingRouterModule(url.pathname);
133
141
  // route를 못찾은상태에서 router path까지 안맞으면 404 처리한다. route랑 router랑 다르니깐 헛갈리지말도록
134
142
  if (intent.module === undefined && !intent.getRouterPathData(rr.reqUrlPathName)) {
135
143
  throw new NotFoundError({ message: `Not Found: ${rr.reqUrlPathName}` });
136
144
  }
137
145
  }
138
146
 
139
- // runRouting!!
140
- const targetUrl = url.toString();
141
- // console.log('runRoutingrunRouting', targetUrl);
142
- await simpleBootFront.goRouting(targetUrl);
143
- await Promises.sleep(0); // <--중요: 이거 넣어야지 두번불러지는게 없어지는듯? 뭐지 event loop 변경된건가?
144
-
145
- // console.log('runRout22222ingrunRouting', targetUrl);
146
-
147
- // simpleBootFront.routingSubjectObservable.subscribe(it=>{
148
- // console.log('zzzzzzzzzzzzzzzzzzz', it);
149
- // if (it.triggerPoint==='end') {
150
- // console.log('zzz@@', it.routerModule.intent);
151
- // }
152
- // })
153
-
154
- const data = await firstValueFrom(
155
- simpleBootFront.routingSubjectObservable.pipe(
156
- filter(
157
- (it) =>
158
- it.triggerPoint === 'end' &&
159
- typeof it.routerModule.intent.uri === 'string' &&
160
- targetUrl.endsWith(it.routerModule.intent.uri)
161
- ),
147
+ const data = await MessageInternal.firstValueFrom(
148
+ simpleBootFront.routingObservable.pipe(
149
+ MessageOperator.filter(it => {
150
+
151
+ const sw = it.triggerPoint === 'end' && typeof it.routerModule.intent.uri === 'string' && targetUrl.endsWith(it.routerModule.intent.uri);
152
+ return sw;
153
+ }),
162
154
  // delay(1000),
163
- first()
155
+ MessageOperator.first()
164
156
  )
165
157
  );
166
- // console.log('???????done');
167
- await Promises.sleep(0)
158
+
159
+ // [아키텍트님의 정석] 하이드레이션 데이터를 가상 윈도우의 body에 script 태그로 박제
160
+ // @ts-ignore: writeDataHydration is part of the 정석
161
+ simpleBootFront.writeDataHydration();
162
+ simpleBootFront.clearDataHydration();
163
+
168
164
  const html = this.makeHTML(simpleBootFront);
169
- // console.log('---------',html);
170
165
  await this.writeOkHtmlAndEnd({ rr }, html);
171
166
  } finally {
172
- (simpleBootFront.option.window as any).ssrUse = false;
173
- delete (simpleBootFront.option.window as any).server_side_data;
174
- if ((simpleBootFront as any).generation < this.poolGeneration) {
175
- // Stale instance, destroy it
176
- const jsdom = (simpleBootFront as any).jsdom as JSDOM.JSDOM | undefined;
177
- jsdom?.window.close();
178
- const index = this.simpleBootFrontPool.indexOf(simpleBootFront);
179
- if (index > -1) {
180
- this.simpleBootFrontPool.splice(index, 1);
181
- }
182
- this.pushQueue();
183
- } else {
184
- // Current instance, return to queue
185
- this.simpleBootFrontQueue.enqueue(simpleBootFront);
167
+ try {
168
+ (simpleBootFront.option.window as any).ssrUse = false;
169
+ window.close();
170
+ simpleBootFront.onDestroy();
171
+
172
+ // window.close()만 호출하면 WindowBase.close()가 실행되어 메모리 정리됨
173
+ (simpleBootFront.option.window as any)?.close?.();
174
+ domParserInitializer.destroy();
175
+ } catch (e) {
176
+ console.log('eeeeee', e);
186
177
  }
178
+
179
+ // const index = this.simpleBootPool.indexOf(simpleBootFront);
180
+ // if (index > -1) {
181
+ // this.simpleBootPool.splice(index, 1);
182
+ // }
183
+ // this.pushQueue();
187
184
  }
188
185
  return false;
189
186
  } else {
@@ -192,7 +189,7 @@ export class SSRDomParserFilter implements Filter {
192
189
  }
193
190
 
194
191
  makeHTML(simpleBootFront: SimpleBootFront) {
195
- (simpleBootFront.option.window as any).document.querySelectorAll('*').forEach((el:HTMLElement )=> {
192
+ (simpleBootFront.option.window as any).document.querySelectorAll('*').forEach((el: HTMLElement) => {
196
193
  Array.from(el.attributes).forEach(attr => {
197
194
  if (/^dr-/.test(attr.name) || /^domstyle/.test(attr.name) || /this-path/.test(attr.name)) {
198
195
  el.removeAttribute(attr.name);
@@ -200,27 +197,17 @@ export class SSRDomParserFilter implements Filter {
200
197
  });
201
198
  });
202
199
  let html = simpleBootFront.option.window.document.documentElement.outerHTML;
203
- if (!/^<!DOCTYPE html>/i.test(html)) {
204
- html = '<!DOCTYPE html>' + html;
205
- }
206
- html = html.replace(/\$\{[\s\S]*?\}\$/g, '');
207
- const serverSideData = (simpleBootFront.option.window as any).server_side_data;
208
- if (serverSideData) {
209
- const data = Object.entries(serverSideData)
210
- .map(([k, v]) => {
211
- if (typeof v === 'string') {
212
- return `window.server_side_data.${k} = ${v}`;
213
- } else {
214
- return `window.server_side_data.${k} = ${JSON.stringify(v)}`;
215
- }
216
- })
217
- .join(';');
218
- if (data) {
219
- html = html.replace('</head>', `<script> window.server_side_data={}; ${data}; </script></head>`);
220
- }
200
+ if (!/^<!DOCTYPE html>/i.test(html)) {
201
+ html = '<!DOCTYPE html>' + html;
221
202
  }
203
+ html = html.replace(/\$\{[\s\S]*?\}\$/g, '');
204
+
205
+ // [아키텍트님의 정석]
206
+ // body에 직접 append된 script tag가 outerHTML에 이미 포함되어 있으므로 추가 조작은 불필요합니다.
207
+
222
208
  return html;
223
209
  }
210
+
224
211
  async writeOkHtmlAndEnd({ rr, status = HttpStatus.Ok }: { rr: RequestResponse; status?: HttpStatus }, html: string) {
225
212
  rr.resStatusCode(status);
226
213
  rr.resSetHeader(HttpHeaders.ContentType, Mimes.TextHtml);
@@ -1,7 +1,7 @@
1
1
  import { RequestResponse } from '@dooboostore/simple-boot-http-server/models/RequestResponse';
2
2
  import { HttpHeaders } from '@dooboostore/simple-boot-http-server/codes/HttpHeaders';
3
3
  import { SimpleBootHttpSSRFactory } from '../SimpleBootHttpSSRFactory';
4
- import { ConstructorType } from '@dooboostore/core/types';
4
+ import { ConstructorType, AsyncBlockingQueue, RandomUtils, MessageOperator, MessageInternal } from '@dooboostore/core';
5
5
  import { JsdomInitializer } from '../initializers/JsdomInitializer';
6
6
  import { Filter } from '@dooboostore/simple-boot-http-server/filters/Filter';
7
7
  import { Mimes } from '@dooboostore/simple-boot-http-server/codes/Mimes';
@@ -9,14 +9,9 @@ import { HttpStatus } from '@dooboostore/simple-boot-http-server/codes/HttpStatu
9
9
  import { SimpleBootHttpServer } from '@dooboostore/simple-boot-http-server/SimpleBootHttpServer';
10
10
  import { SimFrontOption } from '@dooboostore/simple-boot-front/option/SimFrontOption';
11
11
  import { SimpleBootFront } from '@dooboostore/simple-boot-front/SimpleBootFront';
12
- import { AsyncBlockingQueue } from '@dooboostore/core/queues/AsyncBlockingQueue';
13
- import { RandomUtils } from '@dooboostore/core/random/RandomUtils';
14
12
  import * as JSDOM from 'jsdom';
15
13
  import { NotFoundError } from '@dooboostore/simple-boot-http-server/errors/NotFoundError';
16
- import { DomRenderProxy } from '@dooboostore/dom-render/DomRenderProxy';
17
- import { filter } from '@dooboostore/core/message/operators/filter';
18
- import { first } from '@dooboostore/core/message/operators/first';
19
- import { firstValueFrom } from '@dooboostore/core/message/internal/firstValueFrom';
14
+ import { DomRenderProxy } from '@dooboostore/dom-render';
20
15
 
21
16
  export type FactoryAndParams = {
22
17
  frontDistPath: string;
@@ -140,7 +135,7 @@ export class SSRFilter implements Filter {
140
135
  const url = rr.reqUrlObj({ host: 'localhost' });
141
136
  if (this.config.simpleBootFront?.notFoundError) {
142
137
  // intent router check first
143
- const intent = await simpleBootFront.getIntent(url.pathname);
138
+ const intent = await simpleBootFront.routingRouterModule(url.pathname);
144
139
  // route를 못찾은상태에서 router path까지 안맞으면 404 처리한다. route랑 router랑 다르니깐 헛갈리지말도록
145
140
  if (intent.module === undefined && !intent.getRouterPathData(rr.reqUrlPathName)) {
146
141
  throw new NotFoundError({ message: `Not Found: ${rr.reqUrlPathName}` });
@@ -167,18 +162,18 @@ export class SSRFilter implements Filter {
167
162
  // // delay(1000),
168
163
  // first()
169
164
  // );
170
- const data = await firstValueFrom(
165
+ const data = await MessageInternal.firstValueFrom(
171
166
  // @ts-ignore
172
- simpleBootFront.routingSubjectObservable.pipe(
167
+ simpleBootFront.routingObservable.pipe(
173
168
  // @ts-ignore
174
- filter(
169
+ MessageOperator.filter(
175
170
  (it) =>
176
171
  it.triggerPoint === 'end' &&
177
172
  typeof it.routerModule.intent.uri === 'string' &&
178
173
  targetUrl.endsWith(it.routerModule.intent.uri)
179
174
  ),
180
175
  // delay(1000),
181
- first()
176
+ MessageOperator.first()
182
177
  )
183
178
  );
184
179
  // console.log('rrrrrssss');
@@ -1,7 +1,7 @@
1
1
  import { RequestResponse } from '@dooboostore/simple-boot-http-server/models/RequestResponse';
2
2
  import { HttpHeaders } from '@dooboostore/simple-boot-http-server/codes/HttpHeaders';
3
3
  import { SimpleBootHttpSSRFactory } from '../SimpleBootHttpSSRFactory';
4
- import { ConstructorType } from '@dooboostore/core/types';
4
+ import { ConstructorType, AsyncBlockingQueue, RandomUtils, MessageOperator, MessageInternal } from '@dooboostore/core';
5
5
  import { JsdomInitializer } from '../initializers/JsdomInitializer';
6
6
  import { Filter } from '@dooboostore/simple-boot-http-server/filters/Filter';
7
7
  import { Mimes } from '@dooboostore/simple-boot-http-server/codes/Mimes';
@@ -9,18 +9,13 @@ import { HttpStatus } from '@dooboostore/simple-boot-http-server/codes/HttpStatu
9
9
  import { SimpleBootHttpServer } from '@dooboostore/simple-boot-http-server/SimpleBootHttpServer';
10
10
  import { SimFrontOption } from '@dooboostore/simple-boot-front/option/SimFrontOption';
11
11
  import { SimpleBootFront } from '@dooboostore/simple-boot-front/SimpleBootFront';
12
- import { AsyncBlockingQueue } from '@dooboostore/core/queues/AsyncBlockingQueue';
13
- import { RandomUtils } from '@dooboostore/core/random/RandomUtils';
14
12
  import * as JSDOM from 'jsdom';
15
13
  import { NotFoundError } from '@dooboostore/simple-boot-http-server/errors/NotFoundError';
16
- import { DomRenderProxy } from '@dooboostore/dom-render/DomRenderProxy';
17
- import { filter } from '@dooboostore/core/message/operators/filter';
18
- import { first } from '@dooboostore/core/message/operators/first';
19
- import { firstValueFrom } from '@dooboostore/core/message/internal/firstValueFrom';
14
+ import { DomRenderProxy } from '@dooboostore/dom-render';
20
15
  import { parseHTML } from 'linkedom';
21
16
  import { LinkedomInitializer } from '../initializers/LinkedomInitializer';
22
17
 
23
- export type FactoryAndParams = {
18
+ export type LinkDomFactoryAndParams = {
24
19
  frontDistPath: string;
25
20
  frontDistIndexFileName?: string;
26
21
  factorySimFrontOption: (window: any) => SimFrontOption;
@@ -38,7 +33,7 @@ export type FactoryAndParams = {
38
33
  };
39
34
  };
40
35
 
41
- export class SSRLinkDomDomFilter implements Filter {
36
+ export class SSRLinkDomFilter implements Filter {
42
37
  private simpleBootFrontPool: SimpleBootFront[] = [];
43
38
  private simpleBootFrontQueue = new AsyncBlockingQueue<SimpleBootFront>();
44
39
  // private indexHTML: string;
@@ -47,7 +42,7 @@ export class SSRLinkDomDomFilter implements Filter {
47
42
  private intervalId?: NodeJS.Timeout;
48
43
 
49
44
  constructor(
50
- public config: FactoryAndParams,
45
+ public config: LinkDomFactoryAndParams,
51
46
  public otherInstanceSim?: Map<ConstructorType<any>, any>
52
47
  ) {
53
48
  config.frontDistIndexFileName = config.frontDistIndexFileName || 'index.html';
@@ -127,7 +122,7 @@ export class SSRLinkDomDomFilter implements Filter {
127
122
  const url = rr.reqUrlObj({ host: 'localhost' });
128
123
  if (this.config.simpleBootFront?.notFoundError) {
129
124
  // intent router check first
130
- const intent = await simpleBootFront.getIntent(url.pathname);
125
+ const intent = await simpleBootFront.routingRouterModule(url.pathname);
131
126
  // route를 못찾은상태에서 router path까지 안맞으면 404 처리한다. route랑 router랑 다르니깐 헛갈리지말도록
132
127
  if (intent.module === undefined && !intent.getRouterPathData(rr.reqUrlPathName)) {
133
128
  throw new NotFoundError({ message: `Not Found: ${rr.reqUrlPathName}` });
@@ -147,18 +142,18 @@ export class SSRLinkDomDomFilter implements Filter {
147
142
  // }
148
143
  // })
149
144
 
150
- const data = await firstValueFrom(
145
+ const data = await MessageInternal.firstValueFrom(
151
146
  // @ts-ignore
152
- simpleBootFront.routingSubjectObservable.pipe(
147
+ simpleBootFront.routingObservable.pipe(
153
148
  // @ts-ignore
154
- filter(
149
+ MessageOperator.filter(
155
150
  (it) =>
156
151
  it.triggerPoint === 'end' &&
157
152
  typeof it.routerModule.intent.uri === 'string' &&
158
153
  targetUrl.endsWith(it.routerModule.intent.uri)
159
154
  ),
160
155
  // delay(1000),
161
- first()
156
+ MessageOperator.first()
162
157
  )
163
158
  );
164
159
  // console.log('???????done');