@dooboostore/simple-boot-http-server-ssr 1.0.8 → 1.0.9
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 +8 -0
- package/SimpleBootHttpSSRFactory.js +2 -2
- package/decorators/LoadAroundBefore.js +1 -1
- package/filters/IntentSchemeFilter.js +6 -6
- package/filters/SSRFilter.d.ts +1 -1
- package/filters/SSRFilter.js +20 -9
- package/package.json +9 -9
- package/proxy/IntentSchemeFrontProxy.js +1 -1
package/README.MD
CHANGED
|
@@ -16,6 +16,14 @@ This package seamlessly integrates `@dooboostore/simple-boot-front` and `@dooboo
|
|
|
16
16
|
- **@dooboostore/simple-boot-front**: The front-end framework for building components and managing UI state.
|
|
17
17
|
- **@dooboostore/simple-boot-http-server**: The underlying HTTP server for handling requests.
|
|
18
18
|
|
|
19
|
+
## 🚀 Quick Start
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
npm init @dooboostore/simple-boot-http-server-ssr projectname
|
|
23
|
+
cd projectname
|
|
24
|
+
npm start
|
|
25
|
+
```
|
|
26
|
+
|
|
19
27
|
## 🚀 How It Works
|
|
20
28
|
|
|
21
29
|
The core of this package is the `SSRFilter`. When a request for an HTML page comes in, the filter does the following:
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
2
|
export class SimpleBootHttpSSRFactory {
|
|
3
|
-
create(
|
|
4
|
-
return __awaiter(this,
|
|
3
|
+
create(simFrontOption_1) {
|
|
4
|
+
return __awaiter(this, arguments, void 0, function* (simFrontOption, using = [], domExcludes = []) {
|
|
5
5
|
const front = yield this.factory(simFrontOption, using, domExcludes);
|
|
6
6
|
return front;
|
|
7
7
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getSim } from '@dooboostore/simple-boot/decorators/SimDecorator';
|
|
2
2
|
import { AroundForceReturn } from '@dooboostore/simple-boot/decorators/aop/AOPDecorator';
|
|
3
|
-
import { ReflectUtils } from '@dooboostore/
|
|
3
|
+
import { ReflectUtils } from '@dooboostore/core/reflect/ReflectUtils';
|
|
4
4
|
export const LoadAroundBefore = (obj, propertyKey, args) => {
|
|
5
5
|
var _a, _b, _c;
|
|
6
6
|
const simstanceManager = obj._SimpleBoot_simstanceManager;
|
|
@@ -13,12 +13,12 @@ let IntentSchemeFilter = class IntentSchemeFilter {
|
|
|
13
13
|
return __awaiter(this, void 0, void 0, function* () {
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
|
-
proceedBefore(
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
proceedBefore(_a) {
|
|
17
|
+
return __awaiter(this, arguments, void 0, function* ({ rr, app }) {
|
|
18
|
+
var _b;
|
|
19
19
|
// const rr = rrr;
|
|
20
20
|
const url = rr.reqUrl;
|
|
21
|
-
const contentLength = Number(rr.reqHeader((
|
|
21
|
+
const contentLength = Number(rr.reqHeader((_b = HttpHeaders.ContentLength.toLowerCase()) !== null && _b !== void 0 ? _b : '0'));
|
|
22
22
|
const acceptType = rr.reqHeader(HttpHeaders.Accept);
|
|
23
23
|
const contentType = rr.reqHeader(HttpHeaders.ContentType);
|
|
24
24
|
const intentScheme = rr.reqHeader(HttpHeaders.XSimpleBootSsrIntentScheme);
|
|
@@ -58,8 +58,8 @@ let IntentSchemeFilter = class IntentSchemeFilter {
|
|
|
58
58
|
}
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
|
-
proceedAfter(
|
|
62
|
-
return __awaiter(this,
|
|
61
|
+
proceedAfter(_a) {
|
|
62
|
+
return __awaiter(this, arguments, void 0, function* ({ rr, app }) {
|
|
63
63
|
return true;
|
|
64
64
|
});
|
|
65
65
|
}
|
package/filters/SSRFilter.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export type FactoryAndParams = {
|
|
|
17
17
|
min: number;
|
|
18
18
|
};
|
|
19
19
|
using: ConstructorType<any>[];
|
|
20
|
-
domExcludes
|
|
20
|
+
domExcludes?: ConstructorType<any>[];
|
|
21
21
|
ssrExcludeFilter?: (rr: RequestResponse) => boolean;
|
|
22
22
|
simpleBootFront?: {
|
|
23
23
|
notFoundError?: boolean;
|
package/filters/SSRFilter.js
CHANGED
|
@@ -67,10 +67,10 @@ export class SSRFilter {
|
|
|
67
67
|
}
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
|
-
proceedBefore(
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
if ((
|
|
70
|
+
proceedBefore(_a) {
|
|
71
|
+
return __awaiter(this, arguments, void 0, function* ({ rr, app }) {
|
|
72
|
+
var _b, _c, _d;
|
|
73
|
+
if ((_c = (_b = this.config).ssrExcludeFilter) === null || _c === void 0 ? void 0 : _c.call(_b, rr)) {
|
|
74
74
|
return false;
|
|
75
75
|
}
|
|
76
76
|
if ((rr.reqHasAcceptHeader(Mimes.TextHtml) || rr.reqHasAcceptHeader(Mimes.All))) {
|
|
@@ -83,7 +83,7 @@ export class SSRFilter {
|
|
|
83
83
|
simpleBootFront.option.window.ssrUse = true;
|
|
84
84
|
delete simpleBootFront.option.window.server_side_data;
|
|
85
85
|
const url = rr.reqUrlObj({ host: 'localhost' });
|
|
86
|
-
if ((
|
|
86
|
+
if ((_d = this.config.simpleBootFront) === null || _d === void 0 ? void 0 : _d.notFoundError) {
|
|
87
87
|
// intent router check first
|
|
88
88
|
const intent = yield simpleBootFront.getIntent(url.pathname);
|
|
89
89
|
// route를 못찾은상태에서 router path까지 안맞으면 404 처리한다. route랑 router랑 다르니깐 헛갈리지말도록
|
|
@@ -97,7 +97,18 @@ export class SSRFilter {
|
|
|
97
97
|
yield new Promise((r) => setTimeout(r, 0)); // <--중요: 이거 넣어야지 두번불러지는게 없어지는듯? 뭐지 event loop 변경된건가?
|
|
98
98
|
// const e = Expression.Path.pathNameData(rr.reqUrlPathName, intent.getRouterPath())
|
|
99
99
|
// console.log('------intent', rr.reqUrl, rr.reqUrlPathName, intent.module, intent.getRouterPath(), e)
|
|
100
|
+
// simpleBootFront.option.window.document.documentElemenh
|
|
101
|
+
// "dr-"로 시작하는 모든 attribute를 가진 element에서 해당 attribute를 제거
|
|
102
|
+
simpleBootFront.option.window.document.querySelectorAll('*').forEach(el => {
|
|
103
|
+
Array.from(el.attributes).forEach(attr => {
|
|
104
|
+
if (/^dr-/.test(attr.name) || /^domstyle/.test(attr.name) || /this-path/.test(attr.name)) {
|
|
105
|
+
el.removeAttribute(attr.name);
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
});
|
|
100
109
|
let html = simpleBootFront.option.window.document.documentElement.outerHTML;
|
|
110
|
+
// html = '<!DOCTYPE html>'+html;
|
|
111
|
+
html = html.replace(/\$\{[\s\S]*?\}\$/g, '');
|
|
101
112
|
const serverSideData = simpleBootFront.option.window.server_side_data;
|
|
102
113
|
if (serverSideData) {
|
|
103
114
|
const data = Object.entries(serverSideData).map(([k, v]) => {
|
|
@@ -203,16 +214,16 @@ export class SSRFilter {
|
|
|
203
214
|
}
|
|
204
215
|
});
|
|
205
216
|
}
|
|
206
|
-
writeOkHtmlAndEnd(
|
|
207
|
-
return __awaiter(this,
|
|
217
|
+
writeOkHtmlAndEnd(_a, html_1) {
|
|
218
|
+
return __awaiter(this, arguments, void 0, function* ({ rr, status = HttpStatus.Ok }, html) {
|
|
208
219
|
// rr.res.writeHead(status, {[HttpHeaders.ContentType]: Mimes.TextHtml});
|
|
209
220
|
rr.resStatusCode(status);
|
|
210
221
|
rr.resSetHeader(HttpHeaders.ContentType, Mimes.TextHtml);
|
|
211
222
|
yield rr.resEnd(html);
|
|
212
223
|
});
|
|
213
224
|
}
|
|
214
|
-
proceedAfter(
|
|
215
|
-
return __awaiter(this,
|
|
225
|
+
proceedAfter(_a) {
|
|
226
|
+
return __awaiter(this, arguments, void 0, function* ({ rr, app }) {
|
|
216
227
|
// console.log('done--------', sw)
|
|
217
228
|
return true;
|
|
218
229
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dooboostore/simple-boot-http-server-ssr",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"license": "MIT",
|
|
@@ -55,23 +55,23 @@
|
|
|
55
55
|
"ts-jest": "^26.5.4",
|
|
56
56
|
"@types/node": "^20",
|
|
57
57
|
"tslib": "^2.8.1",
|
|
58
|
-
"typescript": "^
|
|
58
|
+
"typescript": "^5.9.2"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
61
|
"jsdom": "^26.0.0",
|
|
62
62
|
"reflect-metadata": "^0.2.2",
|
|
63
|
+
"@dooboostore/core": "1.0.8",
|
|
63
64
|
"@dooboostore/core-web": "1.0.1",
|
|
64
|
-
"@dooboostore/simple-boot": "1.0.
|
|
65
|
-
"@dooboostore/dom-render": "1.0.99",
|
|
66
|
-
"@dooboostore/simple-boot-front": "1.0.120",
|
|
65
|
+
"@dooboostore/simple-boot": "1.0.44",
|
|
67
66
|
"@dooboostore/core-node": "1.0.1",
|
|
68
|
-
"@dooboostore/
|
|
69
|
-
"@dooboostore/simple-boot-
|
|
67
|
+
"@dooboostore/dom-render": "1.0.102",
|
|
68
|
+
"@dooboostore/simple-boot-front": "1.0.121",
|
|
69
|
+
"@dooboostore/simple-boot-http-server": "1.0.16"
|
|
70
70
|
},
|
|
71
71
|
"scripts": {
|
|
72
|
-
"build": "rm -rf dist && tsc -p tsconfig.build.json",
|
|
72
|
+
"tsc:build": "rm -rf dist && tsc -p tsconfig.build.json",
|
|
73
73
|
"clean": "rm -rf dist",
|
|
74
|
-
"npm:build": "pnpm run build && cp README.MD dist/ && pnpm pack && TARBALL_NAME=$(ls dooboostore-simple-boot-http-server-ssr-*.tgz | head -n 1) && tar -xzf \"$TARBALL_NAME\" -C dist --strip-components=1 package/package.json && rm \"$TARBALL_NAME\"",
|
|
74
|
+
"npm:build": "pnpm run tsc:build && cp README.MD dist/ && pnpm pack && TARBALL_NAME=$(ls dooboostore-simple-boot-http-server-ssr-*.tgz | head -n 1) && tar -xzf \"$TARBALL_NAME\" -C dist --strip-components=1 package/package.json && rm \"$TARBALL_NAME\"",
|
|
75
75
|
"npm:clean": "rm -rf dist",
|
|
76
76
|
"npm:publish": "pnpm run npm:build && cd dist && pnpm publish --no-git-checks",
|
|
77
77
|
"npm:publish:clean": "pnpm run npm:publish && rm -rf dist",
|
|
@@ -3,7 +3,7 @@ import { getSim, Sim } from '@dooboostore/simple-boot/decorators/SimDecorator';
|
|
|
3
3
|
import { HttpHeaders } from '@dooboostore/simple-boot-http-server/codes/HttpHeaders';
|
|
4
4
|
import { HttpHeaders as SSRHttpHeaders } from '../codes/HttpHeaders';
|
|
5
5
|
import { Mimes as SSRMimes } from '../codes/Mimes';
|
|
6
|
-
import { ReflectUtils } from '@dooboostore/
|
|
6
|
+
import { ReflectUtils } from '@dooboostore/core/reflect/ReflectUtils';
|
|
7
7
|
import { ConvertUtils } from '@dooboostore/core/convert/ConvertUtils';
|
|
8
8
|
let IntentSchemeFrontProxy = class IntentSchemeFrontProxy {
|
|
9
9
|
get(target, prop) {
|