@nocobase/server 2.1.0-alpha.45 → 2.1.0-alpha.46
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/lib/gateway/index.js +7 -2
- package/lib/gateway/utils.d.ts +2 -0
- package/lib/gateway/utils.js +16 -3
- package/package.json +17 -17
package/lib/gateway/index.js
CHANGED
|
@@ -287,6 +287,7 @@ const _Gateway = class _Gateway extends import_events.EventEmitter {
|
|
|
287
287
|
getV2RuntimeConfig() {
|
|
288
288
|
return {
|
|
289
289
|
__nocobase_public_path__: this.getV2PublicPath(),
|
|
290
|
+
__nocobase_modern_client_prefix__: (0, import_utils3.normalizeModernClientPrefix)(import_node_process.default.env.APP_MODERN_CLIENT_PREFIX),
|
|
290
291
|
__webpack_public_path__: import_node_process.default.env.CDN_BASE_URL ? `${import_node_process.default.env.CDN_BASE_URL.replace(/\/+$/, "")}/` : "",
|
|
291
292
|
__nocobase_api_base_url__: import_node_process.default.env.API_BASE_URL || import_node_process.default.env.API_BASE_PATH,
|
|
292
293
|
__nocobase_api_client_storage_prefix__: import_node_process.default.env.API_CLIENT_STORAGE_PREFIX,
|
|
@@ -306,12 +307,12 @@ const _Gateway = class _Gateway extends import_events.EventEmitter {
|
|
|
306
307
|
}
|
|
307
308
|
getV2AssetPublicPath() {
|
|
308
309
|
if (import_node_process.default.env.CDN_BASE_URL) {
|
|
309
|
-
return `${import_node_process.default.env.CDN_BASE_URL.replace(/\/+$/, "")}
|
|
310
|
+
return `${import_node_process.default.env.CDN_BASE_URL.replace(/\/+$/, "")}/${import_utils3.MODERN_CLIENT_DIST_DIR}/`;
|
|
310
311
|
}
|
|
311
312
|
return this.getV2PublicPath();
|
|
312
313
|
}
|
|
313
314
|
getV2IndexTemplate() {
|
|
314
|
-
const file = `${import_node_process.default.env.APP_PACKAGE_ROOT}/dist/client/
|
|
315
|
+
const file = `${import_node_process.default.env.APP_PACKAGE_ROOT}/dist/client/${import_utils3.MODERN_CLIENT_DIST_DIR}/index.html`;
|
|
315
316
|
if (!import_fs.default.existsSync(file)) {
|
|
316
317
|
return null;
|
|
317
318
|
}
|
|
@@ -409,6 +410,10 @@ const _Gateway = class _Gateway extends import_events.EventEmitter {
|
|
|
409
410
|
}
|
|
410
411
|
}
|
|
411
412
|
req.url = req.url.substring(APP_PUBLIC_PATH.length - 1);
|
|
413
|
+
const modernPrefix = (0, import_utils3.normalizeModernClientPrefix)(import_node_process.default.env.APP_MODERN_CLIENT_PREFIX);
|
|
414
|
+
if (modernPrefix !== import_utils3.MODERN_CLIENT_DIST_DIR && req.url.startsWith(`/${modernPrefix}/`)) {
|
|
415
|
+
req.url = `/${import_utils3.MODERN_CLIENT_DIST_DIR}/${req.url.slice(modernPrefix.length + 2)}`;
|
|
416
|
+
}
|
|
412
417
|
await compress(req, res);
|
|
413
418
|
return (0, import_serve_handler.default)(req, res, {
|
|
414
419
|
public: `${import_node_process.default.env.APP_PACKAGE_ROOT}/dist/client`
|
package/lib/gateway/utils.d.ts
CHANGED
|
@@ -9,7 +9,9 @@
|
|
|
9
9
|
/// <reference types="node" />
|
|
10
10
|
import { IncomingMessage } from 'http';
|
|
11
11
|
import { IncomingRequest } from '.';
|
|
12
|
+
export declare const MODERN_CLIENT_DIST_DIR = "v";
|
|
12
13
|
export declare function resolvePublicPath(appPublicPath?: string): string;
|
|
14
|
+
export declare function normalizeModernClientPrefix(value?: string): string;
|
|
13
15
|
export declare function resolveV2PublicPath(appPublicPath?: string): string;
|
|
14
16
|
export declare function rewriteV2AssetPublicPath(html: string, assetPublicPath: string): string;
|
|
15
17
|
export declare function injectRuntimeScript(html: string, runtimeScript: string): string;
|
package/lib/gateway/utils.js
CHANGED
|
@@ -27,23 +27,32 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
27
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
28
|
var utils_exports = {};
|
|
29
29
|
__export(utils_exports, {
|
|
30
|
+
MODERN_CLIENT_DIST_DIR: () => MODERN_CLIENT_DIST_DIR,
|
|
30
31
|
getHost: () => getHost,
|
|
31
32
|
getHostname: () => getHostname,
|
|
32
33
|
injectRuntimeScript: () => injectRuntimeScript,
|
|
34
|
+
normalizeModernClientPrefix: () => normalizeModernClientPrefix,
|
|
33
35
|
resolvePublicPath: () => resolvePublicPath,
|
|
34
36
|
resolveV2PublicPath: () => resolveV2PublicPath,
|
|
35
37
|
rewriteV2AssetPublicPath: () => rewriteV2AssetPublicPath
|
|
36
38
|
});
|
|
37
39
|
module.exports = __toCommonJS(utils_exports);
|
|
40
|
+
const MODERN_CLIENT_DIST_DIR = "v";
|
|
38
41
|
function resolvePublicPath(appPublicPath = "/") {
|
|
39
42
|
const normalized = String(appPublicPath || "/").trim() || "/";
|
|
40
43
|
const withLeadingSlash = normalized.startsWith("/") ? normalized : `/${normalized}`;
|
|
41
44
|
return withLeadingSlash.endsWith("/") ? withLeadingSlash : `${withLeadingSlash}/`;
|
|
42
45
|
}
|
|
43
46
|
__name(resolvePublicPath, "resolvePublicPath");
|
|
47
|
+
function normalizeModernClientPrefix(value) {
|
|
48
|
+
const segment = String(value || "").trim().replace(/^\/+|\/+$/g, "");
|
|
49
|
+
return segment || MODERN_CLIENT_DIST_DIR;
|
|
50
|
+
}
|
|
51
|
+
__name(normalizeModernClientPrefix, "normalizeModernClientPrefix");
|
|
44
52
|
function resolveV2PublicPath(appPublicPath = "/") {
|
|
45
53
|
const publicPath = resolvePublicPath(appPublicPath);
|
|
46
|
-
|
|
54
|
+
const prefix = normalizeModernClientPrefix(process.env.APP_MODERN_CLIENT_PREFIX);
|
|
55
|
+
return `${publicPath.replace(/\/$/, "")}/${prefix}/`;
|
|
47
56
|
}
|
|
48
57
|
__name(resolveV2PublicPath, "resolveV2PublicPath");
|
|
49
58
|
function ensureTrailingSlash(value) {
|
|
@@ -52,10 +61,12 @@ function ensureTrailingSlash(value) {
|
|
|
52
61
|
__name(ensureTrailingSlash, "ensureTrailingSlash");
|
|
53
62
|
function rewriteV2AssetPublicPath(html, assetPublicPath) {
|
|
54
63
|
const normalizedAssetPublicPath = ensureTrailingSlash(assetPublicPath);
|
|
55
|
-
|
|
64
|
+
const sentinel = `/${MODERN_CLIENT_DIST_DIR}/`;
|
|
65
|
+
if (normalizedAssetPublicPath === sentinel) {
|
|
56
66
|
return html;
|
|
57
67
|
}
|
|
58
|
-
|
|
68
|
+
const sentinelPattern = new RegExp(`((?:src|href)=["'])${sentinel.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}`, "g");
|
|
69
|
+
return html.replace(sentinelPattern, `$1${normalizedAssetPublicPath}`);
|
|
59
70
|
}
|
|
60
71
|
__name(rewriteV2AssetPublicPath, "rewriteV2AssetPublicPath");
|
|
61
72
|
function injectRuntimeScript(html, runtimeScript) {
|
|
@@ -106,9 +117,11 @@ function getHostname(req) {
|
|
|
106
117
|
__name(getHostname, "getHostname");
|
|
107
118
|
// Annotate the CommonJS export names for ESM import in node:
|
|
108
119
|
0 && (module.exports = {
|
|
120
|
+
MODERN_CLIENT_DIST_DIR,
|
|
109
121
|
getHost,
|
|
110
122
|
getHostname,
|
|
111
123
|
injectRuntimeScript,
|
|
124
|
+
normalizeModernClientPrefix,
|
|
112
125
|
resolvePublicPath,
|
|
113
126
|
resolveV2PublicPath,
|
|
114
127
|
rewriteV2AssetPublicPath
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/server",
|
|
3
|
-
"version": "2.1.0-alpha.
|
|
3
|
+
"version": "2.1.0-alpha.46",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"types": "./lib/index.d.ts",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -10,21 +10,21 @@
|
|
|
10
10
|
"@koa/cors": "^5.0.0",
|
|
11
11
|
"@koa/multer": "^3.1.0",
|
|
12
12
|
"@koa/router": "^13.1.0",
|
|
13
|
-
"@nocobase/acl": "2.1.0-alpha.
|
|
14
|
-
"@nocobase/actions": "2.1.0-alpha.
|
|
15
|
-
"@nocobase/ai": "2.1.0-alpha.
|
|
16
|
-
"@nocobase/auth": "2.1.0-alpha.
|
|
17
|
-
"@nocobase/cache": "2.1.0-alpha.
|
|
18
|
-
"@nocobase/data-source-manager": "2.1.0-alpha.
|
|
19
|
-
"@nocobase/database": "2.1.0-alpha.
|
|
20
|
-
"@nocobase/evaluators": "2.1.0-alpha.
|
|
21
|
-
"@nocobase/lock-manager": "2.1.0-alpha.
|
|
22
|
-
"@nocobase/logger": "2.1.0-alpha.
|
|
23
|
-
"@nocobase/resourcer": "2.1.0-alpha.
|
|
24
|
-
"@nocobase/sdk": "2.1.0-alpha.
|
|
25
|
-
"@nocobase/snowflake-id": "2.1.0-alpha.
|
|
26
|
-
"@nocobase/telemetry": "2.1.0-alpha.
|
|
27
|
-
"@nocobase/utils": "2.1.0-alpha.
|
|
13
|
+
"@nocobase/acl": "2.1.0-alpha.46",
|
|
14
|
+
"@nocobase/actions": "2.1.0-alpha.46",
|
|
15
|
+
"@nocobase/ai": "2.1.0-alpha.46",
|
|
16
|
+
"@nocobase/auth": "2.1.0-alpha.46",
|
|
17
|
+
"@nocobase/cache": "2.1.0-alpha.46",
|
|
18
|
+
"@nocobase/data-source-manager": "2.1.0-alpha.46",
|
|
19
|
+
"@nocobase/database": "2.1.0-alpha.46",
|
|
20
|
+
"@nocobase/evaluators": "2.1.0-alpha.46",
|
|
21
|
+
"@nocobase/lock-manager": "2.1.0-alpha.46",
|
|
22
|
+
"@nocobase/logger": "2.1.0-alpha.46",
|
|
23
|
+
"@nocobase/resourcer": "2.1.0-alpha.46",
|
|
24
|
+
"@nocobase/sdk": "2.1.0-alpha.46",
|
|
25
|
+
"@nocobase/snowflake-id": "2.1.0-alpha.46",
|
|
26
|
+
"@nocobase/telemetry": "2.1.0-alpha.46",
|
|
27
|
+
"@nocobase/utils": "2.1.0-alpha.46",
|
|
28
28
|
"@types/decompress": "4.2.7",
|
|
29
29
|
"@types/ini": "^1.3.31",
|
|
30
30
|
"@types/koa-send": "^4.1.3",
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"@types/serve-handler": "^6.1.1",
|
|
62
62
|
"@types/ws": "^8.5.5"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "42b269944cdd1908d7a848c0af4936fe94c03bb7"
|
|
65
65
|
}
|