@blocklet/pages-kit-block-studio 0.4.22 → 0.4.24
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/cjs/constants/new-block-template/@metadata.json +17 -0
- package/lib/cjs/middlewares/init-uploader-router.js +21 -8
- package/lib/cjs/plugins/vite-plugin-block-studio.js +5 -3
- package/lib/cjs/tsconfig.tsbuildinfo +1 -1
- package/lib/esm/constants/new-block-template/@metadata.json +17 -0
- package/lib/esm/middlewares/init-uploader-router.js +21 -8
- package/lib/esm/plugins/vite-plugin-block-studio.js +5 -3
- package/lib/esm/tsconfig.tsbuildinfo +1 -1
- package/lib/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -6
|
@@ -7,6 +7,9 @@
|
|
|
7
7
|
"key": "title",
|
|
8
8
|
"locales": {
|
|
9
9
|
"zh": {
|
|
10
|
+
"name": "标题"
|
|
11
|
+
},
|
|
12
|
+
"en": {
|
|
10
13
|
"name": "Title"
|
|
11
14
|
}
|
|
12
15
|
}
|
|
@@ -19,6 +22,10 @@
|
|
|
19
22
|
"key": "description",
|
|
20
23
|
"locales": {
|
|
21
24
|
"zh": {
|
|
25
|
+
"name": "描述",
|
|
26
|
+
"defaultValue": "欢迎来到 Pages Kit Block Studio"
|
|
27
|
+
},
|
|
28
|
+
"en": {
|
|
22
29
|
"name": "Description",
|
|
23
30
|
"defaultValue": "Welcome to Pages Kit Block Studio"
|
|
24
31
|
}
|
|
@@ -38,6 +45,13 @@
|
|
|
38
45
|
"mediaKitUrl": "/.well-known/service/blocklet/logo?imageFilter=convert&f=png&h=80"
|
|
39
46
|
},
|
|
40
47
|
"name": "Logo"
|
|
48
|
+
},
|
|
49
|
+
"en": {
|
|
50
|
+
"defaultValue": {
|
|
51
|
+
"url": "/.well-known/service/blocklet/logo?imageFilter=convert&f=png&h=80",
|
|
52
|
+
"mediaKitUrl": "/.well-known/service/blocklet/logo?imageFilter=convert&f=png&h=80"
|
|
53
|
+
},
|
|
54
|
+
"name": "Logo"
|
|
41
55
|
}
|
|
42
56
|
}
|
|
43
57
|
}
|
|
@@ -49,6 +63,9 @@
|
|
|
49
63
|
"key": "copyright",
|
|
50
64
|
"locales": {
|
|
51
65
|
"zh": {
|
|
66
|
+
"defaultValue": "由 Pages Kit Block Studio 提供支持"
|
|
67
|
+
},
|
|
68
|
+
"en": {
|
|
52
69
|
"defaultValue": "Powered by Pages Kit Block Studio"
|
|
53
70
|
}
|
|
54
71
|
},
|
|
@@ -40,21 +40,32 @@ exports.initUploaderRouter = void 0;
|
|
|
40
40
|
const uploader_server_1 = require("@blocklet/uploader-server");
|
|
41
41
|
const compression_1 = __importDefault(require("compression"));
|
|
42
42
|
const express_1 = __importStar(require("express"));
|
|
43
|
+
const zlib_1 = __importDefault(require("zlib"));
|
|
43
44
|
const constants_1 = require("../constants");
|
|
44
45
|
// compression options
|
|
45
46
|
const compressionOptions = {
|
|
46
|
-
level:
|
|
47
|
-
threshold:
|
|
47
|
+
level: 4, // 降低到 4,在性能和压缩率之间取得平衡
|
|
48
|
+
threshold: 2048, // 提高到 2KB,避免对小文件进行压缩
|
|
48
49
|
filter: (req) => {
|
|
49
50
|
var _a;
|
|
50
51
|
const path = req.path || '';
|
|
51
52
|
const extension = (_a = path.split('.').pop()) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
52
|
-
//
|
|
53
|
-
const compressibleExtensions = ['json', 'js', 'css', 'html', 'txt', 'svg', 'xml'];
|
|
53
|
+
// 更新可压缩的文件类型
|
|
54
|
+
const compressibleExtensions = ['json', 'js', 'css', 'html', 'txt', 'svg', 'xml', 'md', 'map'];
|
|
54
55
|
return extension ? compressibleExtensions.includes(extension) : false;
|
|
55
56
|
},
|
|
56
|
-
//
|
|
57
|
-
|
|
57
|
+
chunkSize: 16 * 1024, // 16KB 的块大小,减少内存使用
|
|
58
|
+
memLevel: 5, // 较低的内存级别(范围 1-9)
|
|
59
|
+
windowBits: 15, // 标准窗口大小
|
|
60
|
+
strategy: 0, // 默认策略
|
|
61
|
+
// brotli 配置更新
|
|
62
|
+
brotli: {
|
|
63
|
+
params: {
|
|
64
|
+
[zlib_1.default.constants.BROTLI_PARAM_QUALITY]: 4, // 较低的 brotli 质量,默认是 11
|
|
65
|
+
[zlib_1.default.constants.BROTLI_PARAM_SIZE_HINT]: 0, // 默认大小提示
|
|
66
|
+
[zlib_1.default.constants.BROTLI_PARAM_MODE]: 0, // 通用模式
|
|
67
|
+
},
|
|
68
|
+
},
|
|
58
69
|
};
|
|
59
70
|
// init uploader router
|
|
60
71
|
exports.initUploaderRouter = (0, express_1.Router)();
|
|
@@ -82,12 +93,14 @@ const staticResourceMiddleware = (0, uploader_server_1.initStaticResourceMiddlew
|
|
|
82
93
|
},
|
|
83
94
|
],
|
|
84
95
|
});
|
|
85
|
-
|
|
96
|
+
// init compression middleware
|
|
97
|
+
const compressionMiddleware = (0, compression_1.default)(compressionOptions);
|
|
98
|
+
exports.initUploaderRouter.use('/uploads', compressionMiddleware, (0, uploader_server_1.initProxyToMediaKitUploadsMiddleware)({
|
|
86
99
|
express: express_1.default,
|
|
87
100
|
}), staticResourceMiddleware, (_req, res) => {
|
|
88
101
|
res.status(404).send('404 NOT FOUND').end();
|
|
89
102
|
});
|
|
90
|
-
exports.initUploaderRouter.use('/chunks',
|
|
103
|
+
exports.initUploaderRouter.use('/chunks', compressionMiddleware, staticResourceMiddleware, (_req, res) => {
|
|
91
104
|
res.status(404).send('CHUNK NOT FOUND').end();
|
|
92
105
|
});
|
|
93
106
|
exports.default = exports.initUploaderRouter;
|
|
@@ -57,6 +57,7 @@ const rollup_plugin_external_globals_1 = __importDefault(require("rollup-plugin-
|
|
|
57
57
|
// import { visualizer } from 'rollup-plugin-visualizer';
|
|
58
58
|
const typescript_1 = __importDefault(require("typescript"));
|
|
59
59
|
const ufo_1 = require("ufo");
|
|
60
|
+
const vite_plugin_css_injected_by_js_1 = __importDefault(require("vite-plugin-css-injected-by-js"));
|
|
60
61
|
const vite_plugin_node_polyfills_1 = require("vite-plugin-node-polyfills");
|
|
61
62
|
const vite_plugin_react_pages_1 = __importStar(require("vite-plugin-react-pages"));
|
|
62
63
|
const helper_1 = require("../utils/helper");
|
|
@@ -190,7 +191,7 @@ function initBlockStudioPlugins(options) {
|
|
|
190
191
|
},
|
|
191
192
|
build: Object.assign(Object.assign({}, _config === null || _config === void 0 ? void 0 : _config.build), {
|
|
192
193
|
// sourcemap: true,
|
|
193
|
-
cssCodeSplit:
|
|
194
|
+
cssCodeSplit: true, lib: {
|
|
194
195
|
name,
|
|
195
196
|
entry: Object.assign({}, Object.fromEntries(entryList)),
|
|
196
197
|
formats,
|
|
@@ -260,6 +261,8 @@ function initBlockStudioPlugins(options) {
|
|
|
260
261
|
}),
|
|
261
262
|
}),
|
|
262
263
|
}),
|
|
264
|
+
(0, vite_plugin_html_transform_1.initHtmlPreviewTransformPlugin)(),
|
|
265
|
+
(0, vite_plugin_css_injected_by_js_1.default)(),
|
|
263
266
|
// https://github.com/rollup/plugins/tree/master/packages/typescript#noforceemit
|
|
264
267
|
// typescript({
|
|
265
268
|
// declaration: true,
|
|
@@ -268,14 +271,13 @@ function initBlockStudioPlugins(options) {
|
|
|
268
271
|
// declarationDir: path.resolve(workingDir, 'lib/types'),
|
|
269
272
|
// rootDir: path.resolve(workingDir),
|
|
270
273
|
// }),
|
|
271
|
-
(0, vite_plugin_html_transform_1.initHtmlPreviewTransformPlugin)(),
|
|
272
274
|
// initRemoteScriptLocalizerPlugin({
|
|
273
275
|
// tempDir: 'temp/remote-scripts', // 可选,默认值
|
|
274
276
|
// maxConcurrent: 5, // 可选,默认值
|
|
275
277
|
// timeout: 30 * 1000, // 可选,默认值 30 秒
|
|
276
278
|
// }),
|
|
277
279
|
{
|
|
278
|
-
name: 'build-
|
|
280
|
+
name: 'post-build-file-transpiler',
|
|
279
281
|
apply: 'build',
|
|
280
282
|
enforce: 'post',
|
|
281
283
|
writeBundle(options) {
|