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