@dooboostore/simple-boot-http-server-ssr 1.0.16 → 1.0.18
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 +87 -38
- package/dist/cjs/bundle-entry.js +46 -12
- package/dist/cjs/bundle-entry.js.map +2 -2
- package/dist/cjs/filters/SSRDomParserFilter.js +4 -3
- package/dist/cjs/filters/SSRDomParserFilter.js.map +2 -2
- package/dist/cjs/filters/SSRFilter.js +4 -3
- package/dist/cjs/filters/SSRFilter.js.map +2 -2
- package/dist/cjs/filters/SSRLinkDomFilter.js +4 -3
- package/dist/cjs/filters/SSRLinkDomFilter.js.map +2 -2
- package/dist/cjs/filters/SSRSimpleWebComponentDomParserFilter.js +50 -2
- package/dist/cjs/filters/SSRSimpleWebComponentDomParserFilter.js.map +2 -2
- package/dist/cjs/filters/SSRSimpleWebComponentFilter.js.map +1 -1
- package/dist/esm/bundle-entry.js +22 -6
- package/dist/esm/bundle-entry.js.map +2 -2
- package/dist/esm/filters/SSRDomParserFilter.js +5 -4
- package/dist/esm/filters/SSRDomParserFilter.js.map +2 -2
- package/dist/esm/filters/SSRFilter.js +4 -3
- package/dist/esm/filters/SSRFilter.js.map +2 -2
- package/dist/esm/filters/SSRLinkDomFilter.js +4 -3
- package/dist/esm/filters/SSRLinkDomFilter.js.map +2 -2
- package/dist/esm/filters/SSRSimpleWebComponentDomParserFilter.js +50 -2
- package/dist/esm/filters/SSRSimpleWebComponentDomParserFilter.js.map +2 -2
- package/dist/esm/filters/SSRSimpleWebComponentFilter.js.map +1 -1
- package/dist/esm-bundle/dooboostore-simple-boot-http-server-ssr.esm.js +33495 -24465
- package/dist/esm-bundle/dooboostore-simple-boot-http-server-ssr.esm.js.map +4 -4
- package/dist/types/bundle-entry.d.ts +11 -6
- package/dist/types/bundle-entry.d.ts.map +1 -1
- package/dist/types/filters/SSRDomParserFilter.d.ts.map +1 -1
- package/dist/types/filters/SSRFilter.d.ts.map +1 -1
- package/dist/types/filters/SSRLinkDomFilter.d.ts.map +1 -1
- package/dist/types/filters/SSRSimpleWebComponentDomParserFilter.d.ts +14 -2
- package/dist/types/filters/SSRSimpleWebComponentDomParserFilter.d.ts.map +1 -1
- package/dist/types/filters/SSRSimpleWebComponentFilter.d.ts +1 -1
- package/dist/types/filters/SSRSimpleWebComponentFilter.d.ts.map +1 -1
- package/dist/umd-bundle/dooboostore-simple-boot-http-server-ssr.umd.js +32485 -23456
- package/dist/umd-bundle/dooboostore-simple-boot-http-server-ssr.umd.js.map +4 -4
- package/package.json +12 -12
- package/src/bundle-entry.ts +16 -6
- package/src/filters/SSRDomParserFilter.ts +5 -4
- package/src/filters/SSRFilter.ts +4 -3
- package/src/filters/SSRLinkDomFilter.ts +4 -3
- package/src/filters/SSRSimpleWebComponentDomParserFilter.ts +81 -5
- package/src/filters/SSRSimpleWebComponentFilter.ts +1 -1
package/README.md
CHANGED
|
@@ -4,27 +4,39 @@
|
|
|
4
4
|
[](https://github.com/dooboostore-develop/packages/actions/workflows/main.yaml)
|
|
5
5
|
[](https://opensource.org/licenses/MIT)
|
|
6
6
|
|
|
7
|
-
`@dooboostore/simple-boot-http-server-ssr` provides a powerful **Server-Side Rendering (SSR)** environment by seamlessly integrating `@dooboostore/simple-boot-front` and `@dooboostore/simple-boot-http-server`.
|
|
7
|
+
`@dooboostore/simple-boot-http-server-ssr` provides a powerful **Server-Side Rendering (SSR)** environment by seamlessly integrating `@dooboostore/simple-boot-front` and `@dooboostore/simple-boot-http-server`.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
It ships **five interchangeable rendering strategies** as separate `Filter`s, so you pick the one that fits your app instead of being locked into one DOM backend:
|
|
10
|
+
|
|
11
|
+
| Filter | DOM backend | Instance reuse | Best for |
|
|
12
|
+
| --- | --- | --- | --- |
|
|
13
|
+
| `SSRFilter` | `jsdom` | Pooled (`min`/`max`, generation-based eviction) | High-traffic apps that want warm instances ready to render |
|
|
14
|
+
| `SSRDomParserFilter` | `@dooboostore/dom-parser` (this monorepo's own lightweight, dependency-free DOM) | Fresh window per request | Lower memory footprint, no jsdom dependency; pairs with the AOP-based data-hydration proxy below |
|
|
15
|
+
| `SSRLinkDomFilter` | `linkedom` | Pooled (`poolOption` `min`/`max`, generation-based eviction) | Alternative lightweight DOM backend |
|
|
16
|
+
| `SSRSimpleWebComponentDomParserFilter` | `@dooboostore/dom-parser` | Fresh window per request | `@dooboostore/simple-web-component` apps without a browser; `intentServices` injection and SWC `@property` hydration (below) |
|
|
17
|
+
| `SSRSimpleWebComponentFilter` | Real headless **Chromium via Playwright** | New browser context per request (browser instance itself is reused) | Pixel/spec-perfect rendering (declarative Shadow DOM, real browser APIs) for `@dooboostore/simple-web-component` apps, at the cost of spinning up a real browser |
|
|
18
|
+
|
|
19
|
+
All of them execute your existing frontend code (routing, components, services) on the server and return fully rendered HTML — no separate server-only rendering path to maintain.
|
|
10
20
|
|
|
11
21
|
---
|
|
12
22
|
|
|
13
23
|
## 🚀 Key Features
|
|
14
24
|
|
|
15
25
|
- **Seamless SSR**: Render your SPA on the server without code modifications to maximize SEO and First Contentful Paint (FCP).
|
|
16
|
-
- **
|
|
17
|
-
- **Component Pooling
|
|
18
|
-
- **Automatic Data Hydration**:
|
|
26
|
+
- **Pluggable DOM backend**: Choose `jsdom`, this monorepo's own `@dooboostore/dom-parser`, `linkedom`, or a real headless Chromium (Playwright) — swap the `Filter` without touching your app code.
|
|
27
|
+
- **Component/Instance Pooling** (`SSRFilter`): Optimize resource management by pooling `jsdom`-backed SSR instances (with `min`/`max` pool size and generation-based stale eviction) to handle concurrent requests efficiently.
|
|
28
|
+
- **Automatic Data Hydration**: `SSRDomParserFilterDataHydrationProxy` transparently wraps `@Sim`-registered service methods — on the server it caches the method's result keyed by `symbol.method(args)`, embeds it in the HTML, and on the client it's read back instead of re-fetching, so hydration requires no manual wiring in your services.
|
|
19
29
|
- **Isomorphic Architecture**: Maintain a single codebase for routing, services, and components shared between server and client.
|
|
20
|
-
- **SWC
|
|
30
|
+
- **SWC-native rendering**: `SSRSimpleWebComponentFilter` drives a real Chromium instance via Playwright so `@dooboostore/simple-web-component` apps (declarative Shadow DOM, native Custom Elements) render exactly as they would in a real browser.
|
|
21
31
|
|
|
22
32
|
---
|
|
23
33
|
|
|
24
34
|
## 📦 Installation
|
|
25
35
|
|
|
26
36
|
```bash
|
|
27
|
-
pnpm add @dooboostore/simple-boot-http-server-ssr
|
|
37
|
+
pnpm add @dooboostore/simple-boot-http-server-ssr reflect-metadata
|
|
38
|
+
# jsdom, linkedom, and playwright are regular dependencies; for SSRSimpleWebComponentFilter also run:
|
|
39
|
+
npx playwright install chromium
|
|
28
40
|
```
|
|
29
41
|
|
|
30
42
|
---
|
|
@@ -32,45 +44,68 @@ pnpm add @dooboostore/simple-boot-http-server-ssr @dooboostore/simple-web-compon
|
|
|
32
44
|
## 💻 Core Usage
|
|
33
45
|
|
|
34
46
|
### 1. Universal Bootfactory (bootfactory.ts)
|
|
35
|
-
Define a shared function to initialize the
|
|
47
|
+
Define a shared function to initialize the SWC app on both server and client.
|
|
36
48
|
|
|
37
49
|
```typescript
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
return appElement;
|
|
50
|
+
import swcRegister, { type SwcAppInterface } from '@dooboostore/simple-web-component';
|
|
51
|
+
|
|
52
|
+
export default async (window: Window, otherInstanceSim?: Map<symbol, any>, urlPath?: string) => {
|
|
53
|
+
// Register the built-in SWC elements (swc-app, ...) on this window
|
|
54
|
+
await swcRegister(window);
|
|
55
|
+
|
|
56
|
+
const app = window.document.querySelector('#app') as SwcAppInterface;
|
|
57
|
+
await app.connect({
|
|
58
|
+
window,
|
|
59
|
+
path: urlPath ?? '/',
|
|
60
|
+
routeType: 'path',
|
|
61
|
+
otherInstanceSim, // e.g. the `sim` Map from registerComponents
|
|
62
|
+
onStartedLazyDefineComponent: [/* component/page factories */]
|
|
63
|
+
});
|
|
64
|
+
return { app };
|
|
55
65
|
};
|
|
56
66
|
```
|
|
57
67
|
|
|
58
68
|
### 2. Backend Configuration (SSR Filter)
|
|
59
|
-
Add
|
|
69
|
+
Add one of the SSR filters to your server configuration. Example using `SSRSimpleWebComponentDomParserFilter`:
|
|
60
70
|
|
|
61
71
|
```typescript
|
|
62
|
-
const
|
|
72
|
+
const ssrFilter = new SSRSimpleWebComponentDomParserFilter({
|
|
63
73
|
frontDistPath: './dist-client',
|
|
64
74
|
frontDistIndexFileName: 'index.html',
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
75
|
+
// Services exposed to SSR: each request gets them with its own `rr` injected, passed as `sim`
|
|
76
|
+
intentServices: [/* SimConfig items with a symbol */],
|
|
77
|
+
registerComponents: async (window: any, rr: RequestResponse, sim: Map<symbol, any>) => {
|
|
78
|
+
const { app } = await bootfactory(window, sim, UrlUtils.getUrlPath(window.location));
|
|
79
|
+
return app; // returning the SwcAppInterface enables @property hydration
|
|
80
|
+
},
|
|
81
|
+
ssrExcludeFilter: rr => /\.(js|css|map|ico|png|json)$/.test(rr.reqUrlPathName)
|
|
69
82
|
});
|
|
70
83
|
|
|
71
84
|
const server = new SimpleBootHttpSSRServer(
|
|
72
85
|
new HttpSSRServerOption({
|
|
73
|
-
|
|
86
|
+
listen: { port: 8080 },
|
|
87
|
+
filters: [new ResourceFilter('./dist-client', ['/bundle.js', /\.map$/]), ssrFilter]
|
|
88
|
+
})
|
|
89
|
+
);
|
|
90
|
+
server.run();
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
`SSRSimpleWebComponentFilter` (real Chromium via Playwright) takes the same `frontDistPath` / `frontDistIndexFileName` / `ssrExcludeFilter` plus `playwright: { waitUntil, waitForSelector, waitForTimeout, timeout, ignoreTags }`. Playwright loads your real bundle, so Custom Elements register themselves and `registerComponents` is usually unnecessary.
|
|
94
|
+
|
|
95
|
+
For `@dooboostore/simple-boot-front` apps, use `SSRDomParserFilter` (or `SSRFilter` for `jsdom` / `SSRLinkDomFilter` for `linkedom`, both pooled via `poolOption: { min, max, clearIntervalTime? }`) — same `Filter` interface:
|
|
96
|
+
|
|
97
|
+
```typescript
|
|
98
|
+
const domParserFilter = new SSRDomParserFilter({
|
|
99
|
+
frontDistPath: './dist-client',
|
|
100
|
+
frontDistIndexFileName: 'index.html',
|
|
101
|
+
factorySimFrontOption: (window) => new SimFrontOption({ window /* ... */ }),
|
|
102
|
+
factory: mySimpleBootHttpSSRFactory,
|
|
103
|
+
using: [/* components/pages to register */]
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
const server = new SimpleBootHttpSSRServer(
|
|
107
|
+
new HttpSSRServerOption({
|
|
108
|
+
filters: [new ResourceFilter('./dist-client'), domParserFilter]
|
|
74
109
|
})
|
|
75
110
|
);
|
|
76
111
|
server.run();
|
|
@@ -79,18 +114,32 @@ server.run();
|
|
|
79
114
|
---
|
|
80
115
|
|
|
81
116
|
## 🌊 Data Hydration
|
|
82
|
-
|
|
117
|
+
`SSRDomParserFilter` pairs with `SSRDomParserFilterDataHydrationProxy` (`@Sim`-injected, wraps `@Sim`-registered service methods) to automate transferring async data from server to client with no manual wiring in your services:
|
|
118
|
+
|
|
119
|
+
1. **Server Side**: The first call to a wrapped service method runs normally, then its result is cached via `simpleBootFront.saveDataHydration(key, data)` (`key` = `<service symbol>.<method>(<args>)`) and serialized into the HTML.
|
|
120
|
+
2. **Client Side**: On hydration, the same call is intercepted and `simpleBootFront.cutDataHydration(key)` returns the cached value instead of re-running the (async) call.
|
|
121
|
+
3. **Result**: The client shows the exact data the server already rendered, with no redundant fetch.
|
|
122
|
+
|
|
123
|
+
`SSRFilter`/`SSRWorker` (the `jsdom`-based filters) use a simpler, manual mechanism instead: whatever you assign onto `window.server_side_data` on the server is serialized as an inline `<script>` and available on `window.server_side_data` on the client.
|
|
124
|
+
|
|
125
|
+
### SWC `@property` hydration (`SSRSimpleWebComponentDomParserFilter`)
|
|
83
126
|
|
|
84
|
-
1.
|
|
85
|
-
2.
|
|
86
|
-
|
|
127
|
+
1. `registerComponents` returns the `SwcAppInterface` (host + `connectedElements()`).
|
|
128
|
+
2. `@property` metadata is collected from the host and connected elements into
|
|
129
|
+
`{ sel, prop, value }` items (`sel` = `[swc-use-ssr="<id>"]`, JSON-serializable values only).
|
|
130
|
+
3. Embedded as a `<script>` that runs before the bundle: finds each node with
|
|
131
|
+
`querySelector` and sets `el[prop] = value`.
|
|
132
|
+
4. The JSON is escaped for inline scripts (`<` → `\u003c`, U+2028/U+2029), so a value
|
|
133
|
+
containing `</script>` can't break out of the tag. `JSON.parse` restores it exactly.
|
|
134
|
+
5. Works because a custom element keeps own properties set **before** `customElements.define` —
|
|
135
|
+
the upgrade doesn't reset them. Declare hydrated fields with `declare` (see the SWC README).
|
|
87
136
|
|
|
88
137
|
---
|
|
89
138
|
|
|
90
139
|
## 📖 Learn More
|
|
91
140
|
Check out the detailed guides and tutorials in the `document` folder.
|
|
92
|
-
- [SSR Basics & JSDOM Usage](https://github.com/dooboostore-develop/packages/tree/main/simple-boot-http-server-ssr/document/Create%20a%20SSR%20Server%20Application%20Framework/02_chapter1_ssr_basics_jsdom.md)
|
|
93
|
-
- [Data Hydration Guide](https://github.com/dooboostore-develop/packages/tree/main/simple-boot-http-server-ssr/document/Create%20a%20SSR%20Server%20Application%20Framework/04_chapter3_data_hydration.md)
|
|
141
|
+
- [SSR Basics & JSDOM Usage](https://github.com/dooboostore-develop/packages/tree/main/@dooboostore/simple-boot-http-server-ssr/document/Create%20a%20SSR%20Server%20Application%20Framework/02_chapter1_ssr_basics_jsdom.md)
|
|
142
|
+
- [Data Hydration Guide](https://github.com/dooboostore-develop/packages/tree/main/@dooboostore/simple-boot-http-server-ssr/document/Create%20a%20SSR%20Server%20Application%20Framework/04_chapter3_data_hydration.md)
|
|
94
143
|
|
|
95
144
|
---
|
|
96
145
|
|
package/dist/cjs/bundle-entry.js
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
5
11
|
var __copyProps = (to, from, except, desc) => {
|
|
6
12
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
13
|
for (let key of __getOwnPropNames(from))
|
|
@@ -11,22 +17,50 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
11
17
|
return to;
|
|
12
18
|
};
|
|
13
19
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
14
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
29
|
var bundle_entry_exports = {};
|
|
30
|
+
__export(bundle_entry_exports, {
|
|
31
|
+
Core: () => Core,
|
|
32
|
+
CoreNode: () => CoreNode,
|
|
33
|
+
CoreWeb: () => CoreWeb,
|
|
34
|
+
DomParser: () => DomParser,
|
|
35
|
+
DomRender: () => DomRender,
|
|
36
|
+
SimpleBoot: () => SimpleBoot,
|
|
37
|
+
SimpleBootFront: () => SimpleBootFront,
|
|
38
|
+
SimpleBootHttpServer: () => SimpleBootHttpServer,
|
|
39
|
+
SimpleWebComponent: () => SimpleWebComponent
|
|
40
|
+
});
|
|
16
41
|
module.exports = __toCommonJS(bundle_entry_exports);
|
|
17
|
-
|
|
18
|
-
__reExport(bundle_entry_exports, require("./
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
42
|
+
var import_reflect_metadata = require("reflect-metadata");
|
|
43
|
+
__reExport(bundle_entry_exports, require("./index"), module.exports);
|
|
44
|
+
var Core = __toESM(require("@dooboostore/core"), 1);
|
|
45
|
+
var CoreNode = __toESM(require("@dooboostore/core-node"), 1);
|
|
46
|
+
var CoreWeb = __toESM(require("@dooboostore/core-web"), 1);
|
|
47
|
+
var DomParser = __toESM(require("@dooboostore/dom-parser"), 1);
|
|
48
|
+
var DomRender = __toESM(require("@dooboostore/dom-render"), 1);
|
|
49
|
+
var SimpleBoot = __toESM(require("@dooboostore/simple-boot"), 1);
|
|
50
|
+
var SimpleBootFront = __toESM(require("@dooboostore/simple-boot-front"), 1);
|
|
51
|
+
var SimpleBootHttpServer = __toESM(require("@dooboostore/simple-boot-http-server"), 1);
|
|
52
|
+
var SimpleWebComponent = __toESM(require("@dooboostore/simple-web-component"), 1);
|
|
23
53
|
// Annotate the CommonJS export names for ESM import in node:
|
|
24
54
|
0 && (module.exports = {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
55
|
+
Core,
|
|
56
|
+
CoreNode,
|
|
57
|
+
CoreWeb,
|
|
58
|
+
DomParser,
|
|
59
|
+
DomRender,
|
|
60
|
+
SimpleBoot,
|
|
61
|
+
SimpleBootFront,
|
|
62
|
+
SimpleBootHttpServer,
|
|
63
|
+
SimpleWebComponent,
|
|
64
|
+
...require("./index")
|
|
31
65
|
});
|
|
32
66
|
//# sourceMappingURL=bundle-entry.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/bundle-entry.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import 'reflect-metadata';\n\n// simple-boot-http-server-ssr itself\nexport * from './index';\n\n// Re-export peer dependencies so bundle consumers can access them\n// without separately importing each package\nexport * as Core from '@dooboostore/core';\nexport * as CoreNode from '@dooboostore/core-node';\nexport * as CoreWeb from '@dooboostore/core-web';\nexport * as DomParser from '@dooboostore/dom-parser';\nexport * as DomRender from '@dooboostore/dom-render';\nexport * as SimpleBoot from '@dooboostore/simple-boot';\nexport * as SimpleBootFront from '@dooboostore/simple-boot-front';\nexport * as SimpleBootHttpServer from '@dooboostore/simple-boot-http-server';\nexport * as SimpleWebComponent from '@dooboostore/simple-web-component';\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAAO;AAGP,iCAAc,oBAHd;AAOA,WAAsB;AACtB,eAA0B;AAC1B,cAAyB;AACzB,gBAA2B;AAC3B,gBAA2B;AAC3B,iBAA4B;AAC5B,sBAAiC;AACjC,2BAAsC;AACtC,yBAAoC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -23,6 +23,7 @@ module.exports = __toCommonJS(SSRDomParserFilter_exports);
|
|
|
23
23
|
var import_RequestResponse = require("@dooboostore/simple-boot-http-server/models/RequestResponse");
|
|
24
24
|
var import_HttpHeaders = require("@dooboostore/simple-boot-http-server/codes/HttpHeaders");
|
|
25
25
|
var import_core = require("@dooboostore/core");
|
|
26
|
+
var import_operators = require("@dooboostore/core/message/operators");
|
|
26
27
|
var import_Mimes = require("@dooboostore/simple-boot-http-server/codes/Mimes");
|
|
27
28
|
var import_HttpStatus = require("@dooboostore/simple-boot-http-server/codes/HttpStatus");
|
|
28
29
|
var import_NotFoundError = require("@dooboostore/simple-boot-http-server/errors/NotFoundError");
|
|
@@ -90,14 +91,14 @@ class SSRDomParserFilter {
|
|
|
90
91
|
throw new import_NotFoundError.NotFoundError({ message: `Not Found: ${rr.reqUrlPathName}` });
|
|
91
92
|
}
|
|
92
93
|
}
|
|
93
|
-
const data = await import_core.
|
|
94
|
+
const data = await (0, import_core.firstValueFrom)(
|
|
94
95
|
simpleBootFront.routingObservable.pipe(
|
|
95
|
-
|
|
96
|
+
(0, import_operators.filter)((it) => {
|
|
96
97
|
const sw = it.triggerPoint === "end" && typeof it.routerModule.intent.uri === "string" && targetUrl.endsWith(it.routerModule.intent.uri);
|
|
97
98
|
return sw;
|
|
98
99
|
}),
|
|
99
100
|
// delay(1000),
|
|
100
|
-
|
|
101
|
+
(0, import_operators.first)()
|
|
101
102
|
)
|
|
102
103
|
);
|
|
103
104
|
simpleBootFront.writeDataHydration();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/filters/SSRDomParserFilter.ts"],
|
|
4
|
-
"sourcesContent": ["import { RequestResponse } from '@dooboostore/simple-boot-http-server/models/RequestResponse';\nimport { HttpHeaders } from '@dooboostore/simple-boot-http-server/codes/HttpHeaders';\nimport { SimpleBootHttpSSRFactory } from '../SimpleBootHttpSSRFactory';\nimport { ConstructorType, 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 DomParserFactoryAndParams = {\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: DomParserFactoryAndParams,\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 as any);\n // (simpleBootFront as any).generation = this.poolGeneration;\n return simpleBootFront;\n }\n\n // enqueueFrontApp(simpleBootFront: SimpleBootFront) {\n // // this.simpleBootFrontPool.set(simpleBootFront.option.name!, simpleBootFront);\n // this.simpleBootFrontPool.push(simpleBootFront);\n // this.simpleBootFrontQueue.enqueue(simpleBootFront);\n // }\n //\n // async pushQueue() {\n // if (this.simpleBootFrontPool.length < this.config.poolOption.max) {\n // this.enqueueFrontApp(await this.makeFront(await this.makePage()));\n // }\n // }\n\n async proceedBefore({ rr, app }: { rr: RequestResponse; app: SimpleBootHttpServer; carrier: Map<string, any> }) {\n if (this.config.ssrExcludeFilter?.(rr)) {\n return false;\n }\n if (rr.reqHasAcceptHeader(Mimes.TextHtml) || rr.reqHasAcceptHeader(Mimes.All)) {\n // if (this.simpleBootFrontQueue.isEmpty()) {\n // await this.pushQueue();\n // }\n // const simpleBootFront = await this.simpleBootFrontQueue.dequeue();\n const url = rr.reqUrlObj({ host: 'localhost' });\n const targetUrl = url.toString() ?? this.welcomUrl;\n const { window, domParserInitializer } = await this.makePage(targetUrl);\n const otherSim = new Map<Function | ConstructorType<any> | SimConfig | Symbol, any>();\n otherSim.set(RequestResponse, rr);\n const simpleBootFront = await this.makeFront(window, otherSim);\n try {\n (simpleBootFront.option.window as any).ssrUse = true;\n // console.log(simpleBootFront.routing)\n if (this.config.simpleBootFront?.notFoundError) {\n // intent router check first\n const intent = await simpleBootFront.routingRouterModule(url.pathname);\n // route\uB97C \uBABB\uCC3E\uC740\uC0C1\uD0DC\uC5D0\uC11C router path\uAE4C\uC9C0 \uC548\uB9DE\uC73C\uBA74 404 \uCC98\uB9AC\uD55C\uB2E4. route\uB791 router\uB791 \uB2E4\uB974\uB2C8\uAE50 \uD5DB\uAC08\uB9AC\uC9C0\uB9D0\uB3C4\uB85D\n if (intent.module === undefined && !intent.getRouterPathData(rr.reqUrlPathName)) {\n throw new NotFoundError({ message: `Not Found: ${rr.reqUrlPathName}` });\n }\n }\n\n const data = await MessageInternal.firstValueFrom(\n simpleBootFront.routingObservable.pipe(\n MessageOperator.filter(it => {\n\n const sw = it.triggerPoint === 'end' && typeof it.routerModule.intent.uri === 'string' && targetUrl.endsWith(it.routerModule.intent.uri);\n return sw;\n }),\n // delay(1000),\n MessageOperator.first()\n )\n );\n\n // [\uC544\uD0A4\uD14D\uD2B8\uB2D8\uC758 \uC815\uC11D] \uD558\uC774\uB4DC\uB808\uC774\uC158 \uB370\uC774\uD130\uB97C \uAC00\uC0C1 \uC708\uB3C4\uC6B0\uC758 body\uC5D0 script \uD0DC\uADF8\uB85C \uBC15\uC81C\n // @ts-ignore: writeDataHydration is part of the \uC815\uC11D\n simpleBootFront.writeDataHydration();\n simpleBootFront.clearDataHydration();\n\n const html = this.makeHTML(simpleBootFront);\n await this.writeOkHtmlAndEnd({ rr }, html);\n } finally {\n try {\n (simpleBootFront.option.window as any).ssrUse = false;\n window.close();\n simpleBootFront.onDestroy();\n\n // window.close()\uB9CC \uD638\uCD9C\uD558\uBA74 WindowBase.close()\uAC00 \uC2E4\uD589\uB418\uC5B4 \uBA54\uBAA8\uB9AC \uC815\uB9AC\uB428\n (simpleBootFront.option.window as any)?.close?.();\n domParserInitializer.destroy();\n } catch (e) {\n console.log('eeeeee', e);\n }\n\n // const index = this.simpleBootPool.indexOf(simpleBootFront);\n // if (index > -1) {\n // this.simpleBootPool.splice(index, 1);\n // }\n // this.pushQueue();\n }\n return false;\n } else {\n return true;\n }\n }\n\n makeHTML(simpleBootFront: SimpleBootFront) {\n (simpleBootFront.option.window as any).document.querySelectorAll('*').forEach((el: HTMLElement) => {\n Array.from(el.attributes).forEach(attr => {\n if (/^dr-/.test(attr.name) || /^domstyle/.test(attr.name) || /this-path/.test(attr.name)) {\n el.removeAttribute(attr.name);\n }\n });\n });\n let html = simpleBootFront.option.window.document.documentElement.outerHTML;\n if (!/^<!DOCTYPE html>/i.test(html)) {\n html = '<!DOCTYPE html>' + html;\n }\n html = html.replace(/\\$\\{[\\s\\S]*?\\}\\$/g, '');\n\n // [\uC544\uD0A4\uD14D\uD2B8\uB2D8\uC758 \uC815\uC11D]\n // body\uC5D0 \uC9C1\uC811 append\uB41C script tag\uAC00 outerHTML\uC5D0 \uC774\uBBF8 \uD3EC\uD568\uB418\uC5B4 \uC788\uC73C\uBBC0\uB85C \uCD94\uAC00 \uC870\uC791\uC740 \uBD88\uD544\uC694\uD569\uB2C8\uB2E4.\n\n return html;\n }\n\n async writeOkHtmlAndEnd({ rr, status = HttpStatus.Ok }: { rr: RequestResponse; status?: HttpStatus }, html: string) {\n rr.resStatusCode(status);\n rr.resSetHeader(HttpHeaders.ContentType, Mimes.TextHtml);\n await rr.resEnd(html);\n }\n\n async proceedAfter({ rr, app }: { rr: RequestResponse; app: SimpleBootHttpServer; carrier: Map<string, any> }) {\n return true;\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,6BAAgC;AAChC,yBAA4B;AAE5B,
|
|
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, firstValueFrom } from '@dooboostore/core';\nimport { filter, first } from '@dooboostore/core/message/operators';\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 DomParserFactoryAndParams = {\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: DomParserFactoryAndParams,\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 as any);\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 firstValueFrom(\n simpleBootFront.routingObservable.pipe(\n 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 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: SimpleBoot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require("@dooboostore/simple-boot-http-server/codes/HttpHeaders");
|
|
24
24
|
var import_core = require("@dooboostore/core");
|
|
25
|
+
var import_operators = require("@dooboostore/core/message/operators");
|
|
25
26
|
var import_JsdomInitializer = require("../initializers/JsdomInitializer");
|
|
26
27
|
var import_Mimes = require("@dooboostore/simple-boot-http-server/codes/Mimes");
|
|
27
28
|
var import_HttpStatus = require("@dooboostore/simple-boot-http-server/codes/HttpStatus");
|
|
@@ -119,15 +120,15 @@ class SSRFilter {
|
|
|
119
120
|
const targetUrl = url.toString();
|
|
120
121
|
await simpleBootFront.goRouting(targetUrl);
|
|
121
122
|
await new Promise((r) => setTimeout(r, 0));
|
|
122
|
-
const data = await import_core.
|
|
123
|
+
const data = await (0, import_core.firstValueFrom)(
|
|
123
124
|
// @ts-ignore
|
|
124
125
|
simpleBootFront.routingObservable.pipe(
|
|
125
126
|
// @ts-ignore
|
|
126
|
-
|
|
127
|
+
MessageOperator.filter(
|
|
127
128
|
(it) => it.triggerPoint === "end" && typeof it.routerModule.intent.uri === "string" && targetUrl.endsWith(it.routerModule.intent.uri)
|
|
128
129
|
),
|
|
129
130
|
// delay(1000),
|
|
130
|
-
|
|
131
|
+
(0, import_operators.first)()
|
|
131
132
|
)
|
|
132
133
|
);
|
|
133
134
|
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, 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,
|
|
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, firstValueFrom } from '@dooboostore/core';\nimport { first } from '@dooboostore/core/message/operators';\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 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 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,kBAAiF;AACjF,uBAAsB;AACtB,8BAAiC;AAEjC,mBAAsB;AACtB,wBAA2B;AAK3B,2BAA8B;AAC9B,wBAA+B;AAoBxB,MAAM,UAA4B;AAAA,EAQvC,YACS,QACA,kBACP;AAFO;AACA;AATT,SAAQ,sBAAyC,CAAC;AAClD,SAAQ,uBAAuB,IAAI,+BAAoC;AAEvE,SAAQ,YAAY;AACpB,SAAQ,iBAAiB;AAOvB,WAAO,yBAAyB,OAAO,0BAA0B;A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gBAAgB,OAAO,OAAe;AAC9D,QAAI,gBAAgB;AAClB,YAAM,OAAO,OAAO,QAAQ,cAAc,EACvC,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM;AACf,YAAI,OAAO,MAAM,UAAU;AACzB,iBAAO,2BAA2B,CAAC,MAAM,CAAC;AAAA,QAC5C,OAAO;AACL,iBAAO,2BAA2B,CAAC,MAAM,KAAK,UAAU,CAAC,CAAC;AAAA,QAC5D;AAAA,MACF,CAAC,EACA,KAAK,GAAG;AACX,UAAI,MAAM;AACR,eAAO,KAAK,QAAQ,WAAW,wCAAwC,IAAI,oBAAoB;AAAA,MACjG;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAAA,EACA,MAAM,kBAAkB,EAAE,IAAI,SAAS,6BAAW,GAAG,GAAiD,MAAc;AAElH,OAAG,cAAc,MAAM;AACvB,OAAG,aAAa,+BAAY,aAAa,mBAAM,QAAQ;AACvD,UAAM,GAAG,OAAO,IAAI;AAAA,EACtB;AAAA,EAEA,MAAM,aAAa,EAAE,IAAI,IAAI,GAAkF;AAE7G,WAAO;AAAA,EACT;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -22,6 +22,7 @@ __export(SSRLinkDomFilter_exports, {
|
|
|
22
22
|
module.exports = __toCommonJS(SSRLinkDomFilter_exports);
|
|
23
23
|
var import_HttpHeaders = require("@dooboostore/simple-boot-http-server/codes/HttpHeaders");
|
|
24
24
|
var import_core = require("@dooboostore/core");
|
|
25
|
+
var import_operators = require("@dooboostore/core/message/operators");
|
|
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
28
|
var import_NotFoundError = require("@dooboostore/simple-boot-http-server/errors/NotFoundError");
|
|
@@ -104,15 +105,15 @@ class SSRLinkDomFilter {
|
|
|
104
105
|
const targetUrl = url.toString();
|
|
105
106
|
await simpleBootFront.goRouting(targetUrl);
|
|
106
107
|
await new Promise((r) => setTimeout(r, 0));
|
|
107
|
-
const data = await import_core.
|
|
108
|
+
const data = await (0, import_core.firstValueFrom)(
|
|
108
109
|
// @ts-ignore
|
|
109
110
|
simpleBootFront.routingObservable.pipe(
|
|
110
111
|
// @ts-ignore
|
|
111
|
-
|
|
112
|
+
MessageOperator.filter(
|
|
112
113
|
(it) => it.triggerPoint === "end" && typeof it.routerModule.intent.uri === "string" && targetUrl.endsWith(it.routerModule.intent.uri)
|
|
113
114
|
),
|
|
114
115
|
// delay(1000),
|
|
115
|
-
|
|
116
|
+
(0, import_operators.first)()
|
|
116
117
|
)
|
|
117
118
|
);
|
|
118
119
|
const html = this.makeHTML(simpleBootFront);
|