@opensumi/ide-express-file-server 3.7.1-next-1739774311.0 → 3.7.1
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"express-file-server.contribution.d.ts","sourceRoot":"","sources":["../../src/node/express-file-server.contribution.ts"],"names":[],"mappings":"AAMA,OAAO,EAAqB,UAAU,EAAE,qBAAqB,EAAO,MAAM,yBAAyB,CAAC;AAIpG,qBACa,6BAA8B,YAAW,qBAAqB;IAEzE,OAAO,CAAC,SAAS,CAAY;IAE7B,YAAY;IAQZ,UAAU,CAAC,GAAG,EAAE,UAAU;
|
|
1
|
+
{"version":3,"file":"express-file-server.contribution.d.ts","sourceRoot":"","sources":["../../src/node/express-file-server.contribution.ts"],"names":[],"mappings":"AAMA,OAAO,EAAqB,UAAU,EAAE,qBAAqB,EAAO,MAAM,yBAAyB,CAAC;AAIpG,qBACa,6BAA8B,YAAW,qBAAqB;IAEzE,OAAO,CAAC,SAAS,CAAY;IAE7B,YAAY;IAQZ,UAAU,CAAC,GAAG,EAAE,UAAU;CA+C3B"}
|
|
@@ -23,9 +23,20 @@ let ExpressFileServerContribution = class ExpressFileServerContribution {
|
|
|
23
23
|
ctx.status = 404;
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
26
|
+
if (process.env.NODE_ENV === 'development' && uriPath.startsWith('/monaco/worker')) {
|
|
27
|
+
const filePath = path_1.default.resolve(__dirname, `../../../${uriPath}`);
|
|
28
|
+
const contentType = common_1.ALLOW_MIME[path_1.default.extname(filePath).slice(1)];
|
|
29
|
+
if (!contentType) {
|
|
30
|
+
ctx.status = 404;
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
ctx.set('Content-Type', contentType);
|
|
34
|
+
ctx.body = fs_1.default.createReadStream(filePath);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
26
37
|
const filePath = ide_core_node_1.URI.parse(`file://${uriPath}`).codeUri.fsPath;
|
|
27
38
|
const whitelist = this.getWhiteList();
|
|
28
|
-
const contentType = common_1.ALLOW_MIME[path_1.default.extname(filePath).slice(1)
|
|
39
|
+
const contentType = common_1.ALLOW_MIME[path_1.default.extname(filePath).slice(1)];
|
|
29
40
|
if (
|
|
30
41
|
/**
|
|
31
42
|
* 地址在白名单内
|
|
@@ -34,39 +45,11 @@ let ExpressFileServerContribution = class ExpressFileServerContribution {
|
|
|
34
45
|
whitelist.some((whitelistPath) => whitelistPath && filePath.toLowerCase().startsWith(whitelistPath.toLowerCase())) &&
|
|
35
46
|
// 在允许的 contentType
|
|
36
47
|
contentType) {
|
|
37
|
-
|
|
38
|
-
if (!fs_1.default.existsSync(filePath)) {
|
|
39
|
-
ctx.status = 404;
|
|
40
|
-
ctx.body = '文件未找到';
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
48
|
+
ctx.set('Content-Type', contentType);
|
|
43
49
|
if (this.appConfig.staticAllowOrigin) {
|
|
44
50
|
ctx.set('Access-Control-Allow-Origin', this.appConfig.staticAllowOrigin);
|
|
45
51
|
}
|
|
46
|
-
|
|
47
|
-
const total = stats.size;
|
|
48
|
-
if (!range) {
|
|
49
|
-
ctx.status = 200;
|
|
50
|
-
ctx.set('Content-Type', contentType);
|
|
51
|
-
ctx.set('Content-Length', String(total));
|
|
52
|
-
ctx.body = fs_1.default.createReadStream(filePath);
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
const parts = range.replace(/bytes=/, '').split('-');
|
|
56
|
-
const start = parseInt(parts[0], 10);
|
|
57
|
-
const end = parts[1] ? parseInt(parts[1], 10) : total - 1;
|
|
58
|
-
if (start >= total || end >= total || start > end) {
|
|
59
|
-
ctx.status = 416; // Range Not Satisfiable
|
|
60
|
-
ctx.set('Content-Range', `bytes */${total}`);
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
ctx.status = 206;
|
|
64
|
-
ctx.set('Content-Range', `bytes ${start}-${end}/${total}`);
|
|
65
|
-
ctx.set('Accept-Ranges', 'bytes');
|
|
66
|
-
ctx.set('Content-Length', String(end - start + 1));
|
|
67
|
-
ctx.set('Content-Type', contentType);
|
|
68
|
-
const stream = fs_1.default.createReadStream(filePath, { start, end });
|
|
69
|
-
ctx.body = stream;
|
|
52
|
+
ctx.body = fs_1.default.createReadStream(filePath);
|
|
70
53
|
}
|
|
71
54
|
else {
|
|
72
55
|
ctx.status = 403;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"express-file-server.contribution.js","sourceRoot":"","sources":["../../src/node/express-file-server.contribution.ts"],"names":[],"mappings":";;;;AAAA,oDAAoB;AACpB,wDAAwB;AAExB,kEAA8B;AAE9B,qCAAyC;AACzC,2DAAoG;AAEpG,sCAAuC;AAGhC,IAAM,6BAA6B,GAAnC,MAAM,6BAA6B;IAIxC,YAAY;QACV,OAAO;YACL,WAAW;YACX,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,YAAY;YACvC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,eAAe,IAAI,EAAE,CAAC;SAC1C,CAAC;IACJ,CAAC;IAED,UAAU,CAAC,GAAe;QACxB,GAAG,CAAC,GAAG,CACL,IAAA,mBAAK,EAAC,SAAS,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE;YAC7B,MAAM,OAAO,GAAG,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,CAAC;YAC7D,IAAI,CAAC,OAAO,EAAE,CAAC;gBACb,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC;gBACjB,OAAO;YACT,CAAC;YAED,
|
|
1
|
+
{"version":3,"file":"express-file-server.contribution.js","sourceRoot":"","sources":["../../src/node/express-file-server.contribution.ts"],"names":[],"mappings":";;;;AAAA,oDAAoB;AACpB,wDAAwB;AAExB,kEAA8B;AAE9B,qCAAyC;AACzC,2DAAoG;AAEpG,sCAAuC;AAGhC,IAAM,6BAA6B,GAAnC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IAAI,CAAC,YAAY,EAAE,CAAC;YACtC,MAAM,WAAW,GAAG,mBAAU,CAAC,cAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;YAChE;YACE;;;eAGG;YACH,SAAS,CAAC,IAAI,CACZ,CAAC,aAAa,EAAE,EAAE,CAAC,aAAa,IAAI,QAAQ,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC,CACnG;gBACD,mBAAmB;gBACnB,WAAW,EACX,CAAC;gBACD,GAAG,CAAC,GAAG,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC;gBACrC,IAAI,IAAI,CAAC,SAAS,CAAC,iBAAiB,EAAE,CAAC;oBACrC,GAAG,CAAC,GAAG,CAAC,6BAA6B,EAAE,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC;gBAC3E,CAAC;gBAED,GAAG,CAAC,IAAI,GAAG,YAAE,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;YAC3C,CAAC;iBAAM,CAAC;gBACN,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC;YACnB,CAAC;QACH,CAAC,CAAC,CACH,CAAC;IACJ,CAAC;CACF,CAAA;AA3DY,sEAA6B;AAEhC;IADP,IAAA,cAAS,EAAC,yBAAS,CAAC;;gEACQ;wCAFlB,6BAA6B;IADzC,IAAA,sBAAM,EAAC,qCAAqB,CAAC;GACjB,6BAA6B,CA2DzC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opensumi/ide-express-file-server",
|
|
3
|
-
"version": "3.7.1
|
|
3
|
+
"version": "3.7.1",
|
|
4
4
|
"files": [
|
|
5
5
|
"lib",
|
|
6
6
|
"src"
|
|
@@ -17,15 +17,15 @@
|
|
|
17
17
|
"url": "git@github.com:opensumi/core.git"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@opensumi/ide-core-browser": "3.7.1
|
|
21
|
-
"@opensumi/ide-core-common": "3.7.1
|
|
22
|
-
"@opensumi/ide-core-node": "3.7.1
|
|
20
|
+
"@opensumi/ide-core-browser": "3.7.1",
|
|
21
|
+
"@opensumi/ide-core-common": "3.7.1",
|
|
22
|
+
"@opensumi/ide-core-node": "3.7.1",
|
|
23
23
|
"koa-mount": "^4.0.0"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@opensumi/ide-core-browser": "workspace:*",
|
|
27
|
-
"@opensumi/ide-dev-tool": "3.7.1
|
|
27
|
+
"@opensumi/ide-dev-tool": "3.7.1",
|
|
28
28
|
"@types/koa-mount": "^4.0.0"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "222d1329fb66dfc168696348c2512e1c3bbaf622"
|
|
31
31
|
}
|
|
@@ -30,9 +30,21 @@ export class ExpressFileServerContribution implements ServerAppContribution {
|
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
if (process.env.NODE_ENV === 'development' && uriPath.startsWith('/monaco/worker')) {
|
|
34
|
+
const filePath = path.resolve(__dirname, `../../../${uriPath}`);
|
|
35
|
+
const contentType = ALLOW_MIME[path.extname(filePath).slice(1)];
|
|
36
|
+
if (!contentType) {
|
|
37
|
+
ctx.status = 404;
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
ctx.set('Content-Type', contentType);
|
|
41
|
+
ctx.body = fs.createReadStream(filePath);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
33
45
|
const filePath = URI.parse(`file://${uriPath}`).codeUri.fsPath;
|
|
34
46
|
const whitelist = this.getWhiteList();
|
|
35
|
-
const contentType = ALLOW_MIME[path.extname(filePath).slice(1)
|
|
47
|
+
const contentType = ALLOW_MIME[path.extname(filePath).slice(1)];
|
|
36
48
|
if (
|
|
37
49
|
/**
|
|
38
50
|
* 地址在白名单内
|
|
@@ -44,47 +56,12 @@ export class ExpressFileServerContribution implements ServerAppContribution {
|
|
|
44
56
|
// 在允许的 contentType
|
|
45
57
|
contentType
|
|
46
58
|
) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (!fs.existsSync(filePath)) {
|
|
50
|
-
ctx.status = 404;
|
|
51
|
-
ctx.body = '文件未找到';
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
|
|
59
|
+
ctx.set('Content-Type', contentType);
|
|
55
60
|
if (this.appConfig.staticAllowOrigin) {
|
|
56
61
|
ctx.set('Access-Control-Allow-Origin', this.appConfig.staticAllowOrigin);
|
|
57
62
|
}
|
|
58
63
|
|
|
59
|
-
|
|
60
|
-
const total = stats.size;
|
|
61
|
-
|
|
62
|
-
if (!range) {
|
|
63
|
-
ctx.status = 200;
|
|
64
|
-
ctx.set('Content-Type', contentType);
|
|
65
|
-
ctx.set('Content-Length', String(total));
|
|
66
|
-
ctx.body = fs.createReadStream(filePath);
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const parts = range.replace(/bytes=/, '').split('-');
|
|
71
|
-
const start = parseInt(parts[0], 10);
|
|
72
|
-
const end = parts[1] ? parseInt(parts[1], 10) : total - 1;
|
|
73
|
-
|
|
74
|
-
if (start >= total || end >= total || start > end) {
|
|
75
|
-
ctx.status = 416; // Range Not Satisfiable
|
|
76
|
-
ctx.set('Content-Range', `bytes */${total}`);
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
ctx.status = 206;
|
|
81
|
-
ctx.set('Content-Range', `bytes ${start}-${end}/${total}`);
|
|
82
|
-
ctx.set('Accept-Ranges', 'bytes');
|
|
83
|
-
ctx.set('Content-Length', String(end - start + 1));
|
|
84
|
-
ctx.set('Content-Type', contentType);
|
|
85
|
-
|
|
86
|
-
const stream = fs.createReadStream(filePath, { start, end });
|
|
87
|
-
ctx.body = stream;
|
|
64
|
+
ctx.body = fs.createReadStream(filePath);
|
|
88
65
|
} else {
|
|
89
66
|
ctx.status = 403;
|
|
90
67
|
}
|