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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (170) hide show
  1. package/README.MD +131 -2
  2. package/dist/cjs/SimpleBootHttpSSRFactory.js.map +1 -1
  3. package/dist/cjs/SimpleBootHttpSSRServer.js +1 -0
  4. package/dist/cjs/SimpleBootHttpSSRServer.js.map +2 -2
  5. package/dist/cjs/bundle-entry.js +0 -2
  6. package/dist/cjs/bundle-entry.js.map +2 -2
  7. package/dist/cjs/decorators/LoadAroundBefore.js +2 -2
  8. package/dist/cjs/decorators/LoadAroundBefore.js.map +2 -2
  9. package/dist/cjs/filters/SSRDomParserFilter.js +151 -0
  10. package/dist/cjs/filters/SSRDomParserFilter.js.map +7 -0
  11. package/dist/cjs/filters/SSRFilter.js +10 -14
  12. package/dist/cjs/filters/SSRFilter.js.map +2 -2
  13. package/dist/cjs/filters/SSRLinkDomDomFilter.js +10 -14
  14. package/dist/cjs/filters/SSRLinkDomDomFilter.js.map +2 -2
  15. package/dist/cjs/filters/SSRSimpleWebComponentFilter.js +93 -0
  16. package/dist/cjs/filters/SSRSimpleWebComponentFilter.js.map +7 -0
  17. package/dist/cjs/filters/SSRWorker.js +2 -2
  18. package/dist/cjs/filters/SSRWorker.js.map +2 -2
  19. package/dist/cjs/filters/index.js +2 -2
  20. package/dist/cjs/filters/index.js.map +2 -2
  21. package/dist/cjs/index.js +18 -8
  22. package/dist/cjs/index.js.map +2 -2
  23. package/dist/cjs/initializers/DomParserInitializer.js +82 -0
  24. package/dist/cjs/initializers/DomParserInitializer.js.map +7 -0
  25. package/dist/cjs/proxy/SSRDomParserFilterDataHydrationProxy.js +92 -0
  26. package/dist/cjs/proxy/SSRDomParserFilterDataHydrationProxy.js.map +7 -0
  27. package/dist/cjs/proxy/index.js +2 -8
  28. package/dist/cjs/proxy/index.js.map +2 -2
  29. package/dist/esm/SimpleBootHttpSSRFactory.js.map +1 -1
  30. package/dist/esm/SimpleBootHttpSSRServer.js +1 -0
  31. package/dist/esm/SimpleBootHttpSSRServer.js.map +2 -2
  32. package/dist/esm/bundle-entry.js +0 -1
  33. package/dist/esm/bundle-entry.js.map +2 -2
  34. package/dist/esm/decorators/LoadAroundBefore.js +1 -1
  35. package/dist/esm/decorators/LoadAroundBefore.js.map +1 -1
  36. package/dist/esm/filters/SSRDomParserFilter.js +128 -0
  37. package/dist/esm/filters/SSRDomParserFilter.js.map +7 -0
  38. package/dist/esm/filters/SSRFilter.js +7 -11
  39. package/dist/esm/filters/SSRFilter.js.map +2 -2
  40. package/dist/esm/filters/SSRLinkDomDomFilter.js +7 -11
  41. package/dist/esm/filters/SSRLinkDomDomFilter.js.map +2 -2
  42. package/dist/esm/filters/SSRSimpleWebComponentFilter.js +70 -0
  43. package/dist/esm/filters/SSRSimpleWebComponentFilter.js.map +7 -0
  44. package/dist/esm/filters/SSRWorker.js +1 -1
  45. package/dist/esm/filters/SSRWorker.js.map +2 -2
  46. package/dist/esm/filters/index.js +1 -1
  47. package/dist/esm/filters/index.js.map +1 -1
  48. package/dist/esm/index.js +7 -4
  49. package/dist/esm/index.js.map +2 -2
  50. package/dist/esm/initializers/DomParserInitializer.js +49 -0
  51. package/dist/esm/initializers/DomParserInitializer.js.map +7 -0
  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 +21225 -8576
  57. package/dist/esm-bundle/dooboostore-simple-boot-http-server-ssr.esm.js.map +4 -4
  58. package/dist/types/SimpleBootHttpSSRFactory.d.ts +1 -1
  59. package/dist/types/SimpleBootHttpSSRFactory.d.ts.map +1 -1
  60. package/dist/types/SimpleBootHttpSSRServer.d.ts +3 -2
  61. package/dist/types/SimpleBootHttpSSRServer.d.ts.map +1 -1
  62. package/dist/types/bundle-entry.d.ts +0 -1
  63. package/dist/types/bundle-entry.d.ts.map +1 -1
  64. package/dist/types/filters/SSRDomParserFilter.d.ts +51 -0
  65. package/dist/types/filters/SSRDomParserFilter.d.ts.map +1 -0
  66. package/dist/types/filters/SSRFilter.d.ts +1 -1
  67. package/dist/types/filters/SSRFilter.d.ts.map +1 -1
  68. package/dist/types/filters/SSRLinkDomDomFilter.d.ts +1 -1
  69. package/dist/types/filters/SSRLinkDomDomFilter.d.ts.map +1 -1
  70. package/dist/types/filters/SSRSimpleWebComponentFilter.d.ts +37 -0
  71. package/dist/types/filters/SSRSimpleWebComponentFilter.d.ts.map +1 -0
  72. package/dist/types/filters/SSRWorker.d.ts +1 -1
  73. package/dist/types/filters/SSRWorker.d.ts.map +1 -1
  74. package/dist/types/filters/index.d.ts +1 -1
  75. package/dist/types/filters/index.d.ts.map +1 -1
  76. package/dist/types/index.d.ts +7 -2
  77. package/dist/types/index.d.ts.map +1 -1
  78. package/dist/types/initializers/DomParserInitializer.d.ts +13 -0
  79. package/dist/types/initializers/DomParserInitializer.d.ts.map +1 -0
  80. package/dist/types/proxy/SSRDomParserFilterDataHydrationProxy.d.ts +7 -0
  81. package/dist/types/proxy/SSRDomParserFilterDataHydrationProxy.d.ts.map +1 -0
  82. package/dist/types/proxy/index.d.ts +1 -4
  83. package/dist/types/proxy/index.d.ts.map +1 -1
  84. package/dist/umd-bundle/dooboostore-simple-boot-http-server-ssr.umd.js +22093 -9448
  85. package/dist/umd-bundle/dooboostore-simple-boot-http-server-ssr.umd.js.map +4 -4
  86. package/package.json +15 -8
  87. package/src/SimpleBootHttpSSRFactory.ts +1 -1
  88. package/src/SimpleBootHttpSSRServer.ts +5 -3
  89. package/src/bundle-entry.ts +0 -1
  90. package/src/decorators/LoadAroundBefore.ts +1 -1
  91. package/src/filters/SSRDomParserFilter.ts +220 -0
  92. package/src/filters/SSRFilter.ts +7 -12
  93. package/src/filters/SSRLinkDomDomFilter.ts +7 -12
  94. package/src/filters/SSRSimpleWebComponentFilter.ts +103 -0
  95. package/src/filters/SSRWorker.ts +1 -2
  96. package/src/filters/index.ts +1 -1
  97. package/src/index.ts +7 -9
  98. package/src/initializers/DomParserInitializer.ts +77 -0
  99. package/src/proxy/SSRDomParserFilterDataHydrationProxy.ts +63 -0
  100. package/src/proxy/index.ts +1 -4
  101. package/tsconfig.json +3 -1
  102. package/dist/cjs/codes/HttpHeaders.js +0 -41
  103. package/dist/cjs/codes/HttpHeaders.js.map +0 -7
  104. package/dist/cjs/codes/Mimes.js +0 -33
  105. package/dist/cjs/codes/Mimes.js.map +0 -7
  106. package/dist/cjs/codes/index.js +0 -24
  107. package/dist/cjs/codes/index.js.map +0 -7
  108. package/dist/cjs/filters/IntentSchemeFilter.js +0 -92
  109. package/dist/cjs/filters/IntentSchemeFilter.js.map +0 -7
  110. package/dist/cjs/proxy/IntentSchemeFrontProxy.js +0 -87
  111. package/dist/cjs/proxy/IntentSchemeFrontProxy.js.map +0 -7
  112. package/dist/cjs/proxy/IntentSchemeServerProxy.js +0 -67
  113. package/dist/cjs/proxy/IntentSchemeServerProxy.js.map +0 -7
  114. package/dist/cjs/proxy/SymbolIntentApiServiceProxy.js +0 -126
  115. package/dist/cjs/proxy/SymbolIntentApiServiceProxy.js.map +0 -7
  116. package/dist/cjs/proxy/SymbolIntentApiServiceProxyBase.js +0 -110
  117. package/dist/cjs/proxy/SymbolIntentApiServiceProxyBase.js.map +0 -7
  118. package/dist/esm/codes/HttpHeaders.js +0 -17
  119. package/dist/esm/codes/HttpHeaders.js.map +0 -7
  120. package/dist/esm/codes/Mimes.js +0 -10
  121. package/dist/esm/codes/Mimes.js.map +0 -7
  122. package/dist/esm/codes/index.js +0 -3
  123. package/dist/esm/codes/index.js.map +0 -7
  124. package/dist/esm/filters/IntentSchemeFilter.js +0 -69
  125. package/dist/esm/filters/IntentSchemeFilter.js.map +0 -7
  126. package/dist/esm/proxy/IntentSchemeFrontProxy.js +0 -64
  127. package/dist/esm/proxy/IntentSchemeFrontProxy.js.map +0 -7
  128. package/dist/esm/proxy/IntentSchemeServerProxy.js +0 -44
  129. package/dist/esm/proxy/IntentSchemeServerProxy.js.map +0 -7
  130. package/dist/esm/proxy/SymbolIntentApiServiceProxy.js +0 -103
  131. package/dist/esm/proxy/SymbolIntentApiServiceProxy.js.map +0 -7
  132. package/dist/esm/proxy/SymbolIntentApiServiceProxyBase.js +0 -87
  133. package/dist/esm/proxy/SymbolIntentApiServiceProxyBase.js.map +0 -7
  134. package/dist/types/codes/HttpHeaders.d.ts +0 -45
  135. package/dist/types/codes/HttpHeaders.d.ts.map +0 -1
  136. package/dist/types/codes/Mimes.d.ts +0 -31
  137. package/dist/types/codes/Mimes.d.ts.map +0 -1
  138. package/dist/types/codes/index.d.ts +0 -3
  139. package/dist/types/codes/index.d.ts.map +0 -1
  140. package/dist/types/filters/IntentSchemeFilter.d.ts +0 -20
  141. package/dist/types/filters/IntentSchemeFilter.d.ts.map +0 -1
  142. package/dist/types/proxy/IntentSchemeFrontProxy.d.ts +0 -4
  143. package/dist/types/proxy/IntentSchemeFrontProxy.d.ts.map +0 -1
  144. package/dist/types/proxy/IntentSchemeServerProxy.d.ts +0 -4
  145. package/dist/types/proxy/IntentSchemeServerProxy.d.ts.map +0 -1
  146. package/dist/types/proxy/SymbolIntentApiServiceProxy.d.ts +0 -16
  147. package/dist/types/proxy/SymbolIntentApiServiceProxy.d.ts.map +0 -1
  148. package/dist/types/proxy/SymbolIntentApiServiceProxyBase.d.ts +0 -13
  149. package/dist/types/proxy/SymbolIntentApiServiceProxyBase.d.ts.map +0 -1
  150. package/src/codes/HttpHeaders.ts +0 -17
  151. package/src/codes/Mimes.ts +0 -6
  152. package/src/codes/index.ts +0 -2
  153. package/src/filters/IntentSchemeFilter.ts +0 -66
  154. package/src/node_modules/.bin/acorn +0 -17
  155. package/src/node_modules/.bin/browserslist +0 -17
  156. package/src/node_modules/.bin/eslint +0 -17
  157. package/src/node_modules/.bin/jest +0 -17
  158. package/src/node_modules/.bin/ts-jest +0 -17
  159. package/src/node_modules/.bin/ts-node +0 -17
  160. package/src/node_modules/.bin/ts-node-cwd +0 -17
  161. package/src/node_modules/.bin/ts-node-esm +0 -17
  162. package/src/node_modules/.bin/ts-node-script +0 -17
  163. package/src/node_modules/.bin/ts-node-transpile-only +0 -17
  164. package/src/node_modules/.bin/ts-script +0 -17
  165. package/src/node_modules/.bin/tsc +0 -17
  166. package/src/node_modules/.bin/tsserver +0 -17
  167. package/src/proxy/IntentSchemeFrontProxy.ts +0 -67
  168. package/src/proxy/IntentSchemeServerProxy.ts +0 -35
  169. package/src/proxy/SymbolIntentApiServiceProxy.ts +0 -131
  170. package/src/proxy/SymbolIntentApiServiceProxyBase.ts +0 -97
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dooboostore/simple-boot-http-server-ssr",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
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",
@@ -82,13 +87,15 @@
82
87
  "@types/node-gzip": "^1.1.0",
83
88
  "esbuild-plugin-tsc": "^0.5.0",
84
89
  "esbuild": "^0.23.0",
85
- "@dooboostore/core": "1.0.26",
86
- "@dooboostore/core-web": "1.0.8",
87
- "@dooboostore/core-node": "1.0.9",
88
- "@dooboostore/simple-boot": "1.0.52",
89
- "@dooboostore/dom-render": "1.0.110",
90
- "@dooboostore/simple-boot-front": "1.0.129",
91
- "@dooboostore/simple-boot-http-server": "1.0.22"
90
+ "@dooboostore/core-node": "1.0.12",
91
+ "@dooboostore/core": "1.0.30",
92
+ "@dooboostore/core-web": "1.0.10",
93
+ "@dooboostore/simple-web-component": "1.0.20",
94
+ "@dooboostore/simple-boot-front": "1.0.131",
95
+ "@dooboostore/simple-boot-http-server": "1.0.24",
96
+ "@dooboostore/dom-parser": "1.0.5",
97
+ "@dooboostore/simple-boot": "1.0.54",
98
+ "@dooboostore/dom-render": "1.0.113"
92
99
  },
93
100
  "dependencies": {
94
101
  "jsdom": "^26.0.0",
@@ -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,17 @@
1
1
  import { SimpleBootHttpServer } from '@dooboostore/simple-boot-http-server/SimpleBootHttpServer';
2
2
  // import { SimstanceManager } from '@dooboostore/simple-boot/simstance/SimstanceManager';
3
3
  import { HttpSSRServerOption } from './option/HttpSSRServerOption';
4
- import { ConstructorType } from '@dooboostore/core/types';
4
+ import { ConstructorType } from '@dooboostore/core';
5
+ import {SimConfig} from "@dooboostore/simple-boot/decorators/SimDecorator";
5
6
 
6
7
  export class SimpleBootHttpSSRServer extends SimpleBootHttpServer {
7
8
  constructor(option?: HttpSSRServerOption) {
8
9
  super(option)
9
10
  }
10
11
 
11
- run(otherInstanceSim?: Map<ConstructorType<any>, any>) {
12
- const oi = new Map<ConstructorType<any>, any>()
12
+ run(otherInstanceSim?: Map<ConstructorType<any> | Function | SimConfig | Symbol, any>) {
13
+ const oi = new Map<ConstructorType<any> | Function | SimConfig | Symbol, any>();
14
+ oi.set(SimpleBootHttpSSRServer, this);
13
15
  otherInstanceSim?.forEach((value, key) => oi.set(key, value));
14
16
  return super.run(oi);
15
17
  }
@@ -1,4 +1,3 @@
1
- export * from './codes';
2
1
  export * from './decorators';
3
2
  export * from './filters';
4
3
  export * from './initializers';
@@ -1,6 +1,6 @@
1
1
  import { getSim } from '@dooboostore/simple-boot/decorators/SimDecorator';
2
2
  import { AroundForceReturn } from '@dooboostore/simple-boot/decorators/aop/AOPDecorator';
3
- import { ReflectUtils } from '@dooboostore/core/reflect/ReflectUtils';
3
+ import { ReflectUtils } from '@dooboostore/core';
4
4
 
5
5
  export const LoadAroundBefore = (obj: any, propertyKey: string, args: any[]) => {
6
6
  const simstanceManager = obj._SimpleBoot_simstanceManager;
@@ -0,0 +1,220 @@
1
+ import { RequestResponse } from '@dooboostore/simple-boot-http-server/models/RequestResponse';
2
+ import { HttpHeaders } from '@dooboostore/simple-boot-http-server/codes/HttpHeaders';
3
+ import { SimpleBootHttpSSRFactory } from '../SimpleBootHttpSSRFactory';
4
+ import { ConstructorType, AsyncBlockingQueue, RandomUtils, MessageOperator, MessageInternal, Promises } from '@dooboostore/core';
5
+ import { Filter } from '@dooboostore/simple-boot-http-server/filters/Filter';
6
+ import { Mimes } from '@dooboostore/simple-boot-http-server/codes/Mimes';
7
+ import { HttpStatus } from '@dooboostore/simple-boot-http-server/codes/HttpStatus';
8
+ import { SimpleBootHttpServer } from '@dooboostore/simple-boot-http-server/SimpleBootHttpServer';
9
+ import { SimFrontOption } from '@dooboostore/simple-boot-front/option/SimFrontOption';
10
+ import { SimpleBootFront } from '@dooboostore/simple-boot-front/SimpleBootFront';
11
+ import * as JSDOM from 'jsdom';
12
+ import { NotFoundError } from '@dooboostore/simple-boot-http-server/errors/NotFoundError';
13
+ import { DomRenderProxy } from '@dooboostore/dom-render';
14
+ import { parseHTML } from 'linkedom';
15
+ import { DomParserInitializer } from '../initializers/DomParserInitializer';
16
+ import { JsdomInitializer } from '../initializers';
17
+ import { SimConfig } from '@dooboostore/simple-boot/decorators/SimDecorator';
18
+
19
+ export type FactoryAndParams = {
20
+ frontDistPath: string;
21
+ frontDistIndexFileName?: string;
22
+ factorySimFrontOption: (window: any) => SimFrontOption;
23
+ factory: SimpleBootHttpSSRFactory;
24
+ // poolOption: {
25
+ // max: number;
26
+ // min: number;
27
+ // clearIntervalTime?: number;
28
+ // };
29
+ using: ConstructorType<any>[];
30
+ domExcludes?: ConstructorType<any>[];
31
+ ssrExcludeFilter?: (rr: RequestResponse) => boolean;
32
+ simpleBootFront?: {
33
+ notFoundError?: boolean;
34
+ };
35
+ };
36
+
37
+ export class SSRDomParserFilter implements Filter {
38
+ // private simpleBootFrontPool: SimpleBootFront[] = [];
39
+ // private simpleBootFrontQueue = new AsyncBlockingQueue<SimpleBootFront>();
40
+ // private indexHTML: string;
41
+ private welcomUrl = 'http://localhost';
42
+ // private poolGeneration = 0;
43
+ // private intervalId?: NodeJS.Timeout;
44
+
45
+ constructor(
46
+ public config: FactoryAndParams,
47
+ public otherInstanceSim?: Map<ConstructorType<any> | Function | SimConfig | Symbol, any>
48
+ ) {
49
+ config.frontDistIndexFileName = config.frontDistIndexFileName || 'index.html';
50
+ // this.indexHTML = JsdomInitializer.loadFile(this.config.frontDistPath, config.frontDistIndexFileName);
51
+ }
52
+
53
+ async onInit(app: SimpleBootHttpServer) {
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
+ // }
62
+ }
63
+
64
+ async onDestroy() {
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 = [];
76
+ }
77
+
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 };
85
+ // const jsdom = await new JsdomInitializer(
86
+ // this.config.frontDistPath,
87
+ // this.config.frontDistIndexFileName || 'index.html',
88
+ // { url: this.welcomUrl }
89
+ // ).run();
90
+ // return { window: jsdom.window as any, domParserInitializer: {destroy: () => {jsdom.window.close()}} };
91
+ // return jsdom;
92
+ }
93
+
94
+ async makeFront(window: Window, otherInstanceSim?: Map<Function | ConstructorType<any> | SimConfig | Symbol, any>) {
95
+ const name = RandomUtils.uuid();
96
+ (window as any).ssrUse = false;
97
+ const option = this.config.factorySimFrontOption(DomRenderProxy.final(window));
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);
104
+ // (simpleBootFront as any).generation = this.poolGeneration;
105
+ return simpleBootFront;
106
+ }
107
+
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
+ // }
119
+
120
+ async proceedBefore({ rr, app }: { rr: RequestResponse; app: SimpleBootHttpServer; carrier: Map<string, any> }) {
121
+ if (this.config.ssrExcludeFilter?.(rr)) {
122
+ return false;
123
+ }
124
+ if (rr.reqHasAcceptHeader(Mimes.TextHtml) || rr.reqHasAcceptHeader(Mimes.All)) {
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);
135
+ try {
136
+ (simpleBootFront.option.window as any).ssrUse = true;
137
+ // console.log(simpleBootFront.routing)
138
+ if (this.config.simpleBootFront?.notFoundError) {
139
+ // intent router check first
140
+ const intent = await simpleBootFront.routingRouterModule(url.pathname);
141
+ // route를 못찾은상태에서 router path까지 안맞으면 404 처리한다. route랑 router랑 다르니깐 헛갈리지말도록
142
+ if (intent.module === undefined && !intent.getRouterPathData(rr.reqUrlPathName)) {
143
+ throw new NotFoundError({ message: `Not Found: ${rr.reqUrlPathName}` });
144
+ }
145
+ }
146
+
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
+ }),
154
+ // delay(1000),
155
+ MessageOperator.first()
156
+ )
157
+ );
158
+
159
+ // [아키텍트님의 정석] 하이드레이션 데이터를 가상 윈도우의 body에 script 태그로 박제
160
+ // @ts-ignore: writeDataHydration is part of the 정석
161
+ simpleBootFront.writeDataHydration();
162
+ simpleBootFront.clearDataHydration();
163
+
164
+ const html = this.makeHTML(simpleBootFront);
165
+ await this.writeOkHtmlAndEnd({ rr }, html);
166
+ } finally {
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);
177
+ }
178
+
179
+ // const index = this.simpleBootPool.indexOf(simpleBootFront);
180
+ // if (index > -1) {
181
+ // this.simpleBootPool.splice(index, 1);
182
+ // }
183
+ // this.pushQueue();
184
+ }
185
+ return false;
186
+ } else {
187
+ return true;
188
+ }
189
+ }
190
+
191
+ makeHTML(simpleBootFront: SimpleBootFront) {
192
+ (simpleBootFront.option.window as any).document.querySelectorAll('*').forEach((el: HTMLElement) => {
193
+ Array.from(el.attributes).forEach(attr => {
194
+ if (/^dr-/.test(attr.name) || /^domstyle/.test(attr.name) || /this-path/.test(attr.name)) {
195
+ el.removeAttribute(attr.name);
196
+ }
197
+ });
198
+ });
199
+ let html = simpleBootFront.option.window.document.documentElement.outerHTML;
200
+ if (!/^<!DOCTYPE html>/i.test(html)) {
201
+ html = '<!DOCTYPE html>' + html;
202
+ }
203
+ html = html.replace(/\$\{[\s\S]*?\}\$/g, '');
204
+
205
+ // [아키텍트님의 정석]
206
+ // body에 직접 append된 script tag가 outerHTML에 이미 포함되어 있으므로 추가 조작은 불필요합니다.
207
+
208
+ return html;
209
+ }
210
+
211
+ async writeOkHtmlAndEnd({ rr, status = HttpStatus.Ok }: { rr: RequestResponse; status?: HttpStatus }, html: string) {
212
+ rr.resStatusCode(status);
213
+ rr.resSetHeader(HttpHeaders.ContentType, Mimes.TextHtml);
214
+ await rr.resEnd(html);
215
+ }
216
+
217
+ async proceedAfter({ rr, app }: { rr: RequestResponse; app: SimpleBootHttpServer; carrier: Map<string, any> }) {
218
+ return true;
219
+ }
220
+ }
@@ -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,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
  import { parseHTML } from 'linkedom';
21
16
  import { LinkedomInitializer } from '../initializers/LinkedomInitializer';
22
17
 
@@ -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');
@@ -0,0 +1,103 @@
1
+ import { RequestResponse } from '@dooboostore/simple-boot-http-server/models/RequestResponse';
2
+ import { HttpHeaders } from '@dooboostore/simple-boot-http-server/codes/HttpHeaders';
3
+ import { Filter } from '@dooboostore/simple-boot-http-server/filters/Filter';
4
+ import { Mimes } from '@dooboostore/simple-boot-http-server/codes/Mimes';
5
+ import { HttpStatus } from '@dooboostore/simple-boot-http-server/codes/HttpStatus';
6
+ import { SimpleBootHttpServer } from '@dooboostore/simple-boot-http-server/SimpleBootHttpServer';
7
+ import { DomParserInitializer } from '../initializers/DomParserInitializer';
8
+ import { HTMLElementBase } from '@dooboostore/dom-parser';
9
+ import { ConstructorType } from '@dooboostore/core';
10
+ import {getElementConfig} from "@dooboostore/simple-web-component";
11
+
12
+ export type SWCSSRConfig = {
13
+ frontDistPath: string;
14
+ frontDistIndexFileName?: string;
15
+ welcomUrl?: string;
16
+ ssrExcludeFilter?: (rr: RequestResponse) => boolean;
17
+ /**
18
+ * Function to register components for each request.
19
+ */
20
+ registerComponents?: (window: any) => Promise<void> | void;
21
+ };
22
+
23
+ /**
24
+ * SSR Filter specifically for Simple Web Component (SWC).
25
+ * It utilizes @dooboostore/dom-parser for rendering and DSD support.
26
+ */
27
+ export class SSRSimpleWebComponentFilter implements Filter {
28
+ private welcomUrl = 'http://localhost';
29
+
30
+ constructor(public config: SWCSSRConfig) {
31
+ this.welcomUrl = config.welcomUrl || this.welcomUrl;
32
+ }
33
+
34
+ async onInit(app: SimpleBootHttpServer) {}
35
+
36
+ async onDestroy() {}
37
+
38
+ async proceedBefore({ rr }: { rr: RequestResponse; app: SimpleBootHttpServer; carrier: Map<string, any> }) {
39
+ if (this.config.ssrExcludeFilter?.(rr)) {
40
+ return false;
41
+ }
42
+
43
+ if (rr.reqHasAcceptHeader(Mimes.TextHtml) || rr.reqHasAcceptHeader(Mimes.All)) {
44
+ const url = rr.reqUrlObj({ host: 'localhost' });
45
+ const targetUrl = url.toString() ?? this.welcomUrl;
46
+
47
+ // 1. Initialize Virtual DOM Environment
48
+ const domParserInitializer = new DomParserInitializer(this.config.frontDistPath, this.config.frontDistIndexFileName || 'index.html', { url: targetUrl });
49
+ const window = await domParserInitializer.run();
50
+
51
+ // web component 경우 자기 tagName을 생성자 에게 HTMLElementBase에넘겨줘야되기떄문에
52
+ const getTagName = (type: ConstructorType<any>) => {
53
+ const zz = getElementConfig(type);
54
+ return zz.name;
55
+ };
56
+ (window as any).HTMLElement = class extends HTMLElementBase {
57
+ constructor(...args: any[]) {
58
+ const ctor = new.target as any; // 이런 슈가 기능이...
59
+ const resolvedTagName = getTagName(ctor);
60
+ super(resolvedTagName, args[0]);
61
+ }
62
+ }
63
+
64
+
65
+ try {
66
+ // 2. Register Components if provided
67
+ // We use SwcApplication inside the callback or directly here.
68
+ if (this.config.registerComponents) {
69
+ await this.config.registerComponents(window);
70
+ }
71
+
72
+ // 3. Generate Final HTML
73
+ const html = this.makeHTML(window);
74
+
75
+ await this.writeOkHtmlAndEnd({ rr }, html);
76
+ } finally {
77
+ // 4. Cleanup
78
+ (window as any).close?.();
79
+ domParserInitializer.destroy();
80
+ }
81
+ return false;
82
+ }
83
+ return true;
84
+ }
85
+
86
+ makeHTML(window: any) {
87
+ let html = window.document.documentElement.outerHTML;
88
+ if (!/^<!DOCTYPE html>/i.test(html)) {
89
+ html = '<!DOCTYPE html>\n' + html;
90
+ }
91
+ return html;
92
+ }
93
+
94
+ async writeOkHtmlAndEnd({ rr, status = HttpStatus.Ok }: { rr: RequestResponse; status?: HttpStatus }, html: string) {
95
+ rr.resStatusCode(status);
96
+ rr.resSetHeader(HttpHeaders.ContentType, Mimes.TextHtml);
97
+ await rr.resEnd(html);
98
+ }
99
+
100
+ async proceedAfter() {
101
+ return true;
102
+ }
103
+ }
@@ -1,8 +1,7 @@
1
- import { ConstructorType } from '@dooboostore/core/types';
1
+ import { ConstructorType, RandomUtils } from '@dooboostore/core';
2
2
  import {FactoryAndParams} from './SSRFilter';
3
3
  import {JsdomInitializer} from '../initializers/JsdomInitializer';
4
4
  import JSDOM from 'jsdom';
5
- import {RandomUtils} from '@dooboostore/core/random/RandomUtils';
6
5
  import {SimpleBootFront} from '@dooboostore/simple-boot-front/SimpleBootFront';
7
6
 
8
7
  export class SSRWorker {
@@ -1,3 +1,3 @@
1
- export * from './IntentSchemeFilter';
1
+ export * from '@dooboostore/simple-boot-http-server/filters/IntentSchemeFilter';
2
2
  export * from './SSRFilter';
3
3
  export * from './SSRWorker';
package/src/index.ts CHANGED
@@ -1,9 +1,7 @@
1
- // export * from './codes';
2
- // export * from './decorators';
3
- // export * from './filters';
4
- // export * from './initializers';
5
- // export * from './option';
6
- // export * from './proxy';
7
- // export * from './SimpleBootHttpSSRFactory';
8
- // export * from './SimpleBootHttpSSRServer';
9
- export default {}
1
+ export * from './decorators';
2
+ export * from './filters';
3
+ export * from './initializers';
4
+ export * from './option';
5
+ export * from './proxy';
6
+ export * from './SimpleBootHttpSSRFactory';
7
+ export * from './SimpleBootHttpSSRServer';
@@ -0,0 +1,77 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import { DomParser } from '@dooboostore/dom-parser';
4
+
5
+ export class DomParserInitializer {
6
+ private domParser: DomParser;
7
+ constructor(
8
+ private frontDistPath: string,
9
+ private frontDistIndexFileName: string,
10
+ private reconfigureSettings?: {url: string}
11
+ ) {}
12
+
13
+ public static loadFile(distPath: string, filePath: string): string {
14
+ return fs.readFileSync(path.join(distPath, filePath), 'utf8');
15
+ }
16
+
17
+ async run(): Promise<Window> {
18
+ // const indexHTML = fs.readFileSync(path.join(this.frontDistPath, 'index.html'), 'utf8');
19
+ // const indexHTML = JsdomInitializer.loadFile(this.frontDistPath, this.frontDistIndexFileName);
20
+ const pathStr = path.join(this.frontDistPath, this.frontDistIndexFileName);
21
+
22
+ const html = fs.readFileSync(pathStr,'utf8');
23
+
24
+ this.domParser = new DomParser(html, {href: this.reconfigureSettings?.url});
25
+ const w = this.domParser.window as unknown as Window & typeof globalThis;
26
+
27
+ // @ts-ignore
28
+ w.location ??= { href: 'about:blank'};
29
+ if(this.reconfigureSettings?.url){
30
+ // console.log('--',w,w.location);
31
+ // @ts-ignore
32
+ w.location.href = this.reconfigureSettings.url;
33
+ }
34
+ // console.log('!!!!!!!!!!!', html, w.document);
35
+ // @ts-ignore
36
+ // global.document = w.document;
37
+ // @ts-ignore
38
+ // global.window = w as unknown as Window & typeof globalThis;
39
+ // @ts-ignore
40
+ // global.window.requestAnimationFrame = () => {};
41
+ // global.window.scrollTo = () => {};
42
+ // @ts-ignore
43
+ // global.history = w.history;
44
+ global.Event = w.Event;
45
+ // @ts-ignore
46
+ global.PopStateEvent = w.Event;
47
+ global.IntersectionObserver = w.IntersectionObserver;
48
+ // @ts-ignore
49
+ // global.Error = ErrorBase;
50
+ // @ts-ignore
51
+ // global.navigator = w.navigator;
52
+ global.NodeFilter = w.NodeFilter;
53
+ global.Node = w.Node;
54
+ global.DocumentFragment = w.DocumentFragment;
55
+ global.HTMLElement = w.HTMLElement;
56
+ global.HTMLMetaElement = w.HTMLMetaElement;
57
+ global.Element = w.Element;
58
+ global.HTMLCanvasElement = w.HTMLCanvasElement;
59
+ global.HTMLCanvasElement.prototype.getContext = () => {
60
+ return null;
61
+ };
62
+ global.CanvasRenderingContext2D = w.CanvasRenderingContext2D;
63
+ global.CanvasPattern = w.CanvasPattern;
64
+ global.CanvasGradient = w.CanvasGradient;
65
+ global.Path2D = w.Path2D;
66
+ global.ImageData = w.ImageData;
67
+ // console.log('cvvvvvvvvvvvvvv', w.Node.DOCUMENT_FRAGMENT_NODE);
68
+ return w;
69
+ }
70
+
71
+ destroy(): void {
72
+ this.domParser?.destroy();
73
+ }
74
+
75
+ }
76
+ //
77
+ // export default new JsdomInitializer();