@opensumi/ide-express-file-server 2.12.1-next-079c1930

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.
@@ -0,0 +1,7 @@
1
+ import { AppConfig } from '@opensumi/ide-core-browser';
2
+ import { StaticResourceContribution, StaticResourceService } from '@opensumi/ide-static-resource/lib/browser/static.definition';
3
+ export declare class ExpressFileServerContribution implements StaticResourceContribution {
4
+ appConfig: AppConfig;
5
+ registerStaticResolver(service: StaticResourceService): void;
6
+ }
7
+ //# sourceMappingURL=file-server.contribution.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-server.contribution.d.ts","sourceRoot":"","sources":["../../src/browser/file-server.contribution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAEpE,OAAO,EAAE,0BAA0B,EAAE,qBAAqB,EAAE,MAAM,6DAA6D,CAAC;AAGhI,qBACa,6BAA8B,YAAW,0BAA0B;IAG9E,SAAS,EAAE,SAAS,CAAC;IAErB,sBAAsB,CAAC,OAAO,EAAE,qBAAqB,GAAG,IAAI;CAiB7D"}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ExpressFileServerContribution = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const ide_core_browser_1 = require("@opensumi/ide-core-browser");
6
+ const di_1 = require("@opensumi/di");
7
+ const static_definition_1 = require("@opensumi/ide-static-resource/lib/browser/static.definition");
8
+ const common_1 = require("../common");
9
+ let ExpressFileServerContribution = class ExpressFileServerContribution {
10
+ registerStaticResolver(service) {
11
+ service.registerStaticResourceProvider({
12
+ scheme: 'file',
13
+ resolveStaticResource: (uri) => {
14
+ // file 协议统一走静态服务
15
+ // http://127.0.0.1:8000/assets/${path}
16
+ const assetsUri = new ide_core_browser_1.URI(this.appConfig.staticServicePath || common_1.EXPRESS_SERVER_PATH);
17
+ /**
18
+ * uri.path 在 Windows 下会被解析为 \c:\\Path\\to\file
19
+ * fsPath C:\\Path\\to\\file
20
+ */
21
+ return assetsUri.withPath(`assets${decodeURIComponent(uri.codeUri.fsPath)}`);
22
+ },
23
+ roots: [this.appConfig.staticServicePath || common_1.EXPRESS_SERVER_PATH],
24
+ });
25
+ }
26
+ };
27
+ (0, tslib_1.__decorate)([
28
+ (0, di_1.Autowired)(ide_core_browser_1.AppConfig),
29
+ (0, tslib_1.__metadata)("design:type", Object)
30
+ ], ExpressFileServerContribution.prototype, "appConfig", void 0);
31
+ ExpressFileServerContribution = (0, tslib_1.__decorate)([
32
+ (0, ide_core_browser_1.Domain)(static_definition_1.StaticResourceContribution)
33
+ ], ExpressFileServerContribution);
34
+ exports.ExpressFileServerContribution = ExpressFileServerContribution;
35
+ //# sourceMappingURL=file-server.contribution.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-server.contribution.js","sourceRoot":"","sources":["../../src/browser/file-server.contribution.ts"],"names":[],"mappings":";;;;AAAA,iEAAoE;AACpE,qCAAyC;AACzC,mGAAgI;AAChI,sCAAgD;AAGhD,IAAa,6BAA6B,GAA1C,MAAa,6BAA6B;IAKxC,sBAAsB,CAAC,OAA8B;QACnD,OAAO,CAAC,8BAA8B,CAAC;YACrC,MAAM,EAAE,MAAM;YACd,qBAAqB,EAAE,CAAC,GAAQ,EAAE,EAAE;gBAClC,iBAAiB;gBACjB,uCAAuC;gBACvC,MAAM,SAAS,GAAG,IAAI,sBAAG,CAAC,IAAI,CAAC,SAAS,CAAC,iBAAiB,IAAI,4BAAmB,CAAC,CAAC;gBACnF;;;mBAGG;gBACH,OAAO,SAAS,CAAC,QAAQ,CAAC,SAAS,kBAAkB,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YAC/E,CAAC;YACD,KAAK,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,iBAAiB,IAAI,4BAAmB,CAAC;SACjE,CAAC,CAAC;IACL,CAAC;CAEF,CAAA;AAnBC;IADC,IAAA,cAAS,EAAC,4BAAS,CAAC;;gEACA;AAHV,6BAA6B;IADzC,IAAA,yBAAM,EAAC,8CAA0B,CAAC;GACtB,6BAA6B,CAsBzC;AAtBY,sEAA6B"}
@@ -0,0 +1,6 @@
1
+ import { Provider } from '@opensumi/di';
2
+ import { BrowserModule } from '@opensumi/ide-core-browser';
3
+ export declare class ExpressFileServerModule extends BrowserModule {
4
+ providers: Provider[];
5
+ }
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/browser/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAc,MAAM,cAAc,CAAC;AAEpD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,qBACa,uBAAwB,SAAQ,aAAa;IACxD,SAAS,EAAE,QAAQ,EAAE,CAEnB;CACH"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ExpressFileServerModule = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const di_1 = require("@opensumi/di");
6
+ const file_server_contribution_1 = require("./file-server.contribution");
7
+ const ide_core_browser_1 = require("@opensumi/ide-core-browser");
8
+ let ExpressFileServerModule = class ExpressFileServerModule extends ide_core_browser_1.BrowserModule {
9
+ constructor() {
10
+ super(...arguments);
11
+ this.providers = [
12
+ file_server_contribution_1.ExpressFileServerContribution,
13
+ ];
14
+ }
15
+ };
16
+ ExpressFileServerModule = (0, tslib_1.__decorate)([
17
+ (0, di_1.Injectable)()
18
+ ], ExpressFileServerModule);
19
+ exports.ExpressFileServerModule = ExpressFileServerModule;
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/browser/index.ts"],"names":[],"mappings":";;;;AAAA,qCAAoD;AACpD,yEAA2E;AAC3E,iEAA2D;AAG3D,IAAa,uBAAuB,GAApC,MAAa,uBAAwB,SAAQ,gCAAa;IAA1D;;QACE,cAAS,GAAe;YACtB,wDAA6B;SAC9B,CAAC;IACJ,CAAC;CAAA,CAAA;AAJY,uBAAuB;IADnC,IAAA,eAAU,GAAE;GACA,uBAAuB,CAInC;AAJY,0DAAuB"}
@@ -0,0 +1,19 @@
1
+ export declare const EXPRESS_SERVER_PORT = 8000;
2
+ export declare const EXPRESS_SERVER_PATH: string;
3
+ export declare const ALLOW_MIME: {
4
+ gif: string;
5
+ jpg: string;
6
+ png: string;
7
+ svg: string;
8
+ ttf: string;
9
+ eot: string;
10
+ otf: string;
11
+ woff: string;
12
+ woff2: string;
13
+ js: string;
14
+ css: string;
15
+ mp4: string;
16
+ ogg: string;
17
+ webm: string;
18
+ };
19
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB,OAAO,CAAC;AACxC,eAAO,MAAM,mBAAmB,QAAsF,CAAC;AAEvH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;CAetB,CAAC"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ALLOW_MIME = exports.EXPRESS_SERVER_PATH = exports.EXPRESS_SERVER_PORT = void 0;
4
+ exports.EXPRESS_SERVER_PORT = 8000;
5
+ exports.EXPRESS_SERVER_PATH = process.env.STATIC_SERVER_PATH || ('http://127.0.0.1:' + exports.EXPRESS_SERVER_PORT + '/');
6
+ // 静态服务资源白名单
7
+ exports.ALLOW_MIME = {
8
+ gif: 'image/gif',
9
+ jpg: 'image/jpeg',
10
+ png: 'image/png',
11
+ svg: 'image/svg+xml',
12
+ ttf: 'font/ttf',
13
+ eot: 'font/eot',
14
+ otf: 'font/otf',
15
+ woff: 'font/woff',
16
+ woff2: 'font/woff2',
17
+ js: 'application/javascript',
18
+ css: 'text/css',
19
+ mp4: 'video/mp4',
20
+ ogg: 'video/ogg',
21
+ webm: 'video/webm',
22
+ };
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":";;;AAAa,QAAA,mBAAmB,GAAG,IAAI,CAAC;AAC3B,QAAA,mBAAmB,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,CAAC,mBAAmB,GAAG,2BAAmB,GAAG,GAAG,CAAC,CAAC;AACvH,YAAY;AACC,QAAA,UAAU,GAAG;IACxB,GAAG,EAAE,WAAW;IAChB,GAAG,EAAE,YAAY;IACjB,GAAG,EAAE,WAAW;IAChB,GAAG,EAAE,eAAe;IACpB,GAAG,EAAE,UAAU;IACf,GAAG,EAAE,UAAU;IACf,GAAG,EAAE,UAAU;IACf,IAAI,EAAE,WAAW;IACjB,KAAK,EAAG,YAAY;IACpB,EAAE,EAAE,wBAAwB;IAC5B,GAAG,EAAE,UAAU;IACf,GAAG,EAAE,WAAW;IAChB,GAAG,EAAE,WAAW;IAChB,IAAI,EAAE,YAAY;CACnB,CAAC"}
package/lib/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * from './common';
2
+ export * from './node';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC"}
package/lib/index.js ADDED
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ (0, tslib_1.__exportStar)(require("./common"), exports);
5
+ (0, tslib_1.__exportStar)(require("./node"), exports);
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,wDAAyB;AACzB,sDAAuB"}
@@ -0,0 +1,7 @@
1
+ import { ServerAppContribution, IServerApp } from '@opensumi/ide-core-node';
2
+ export declare class ExpressFileServerContribution implements ServerAppContribution {
3
+ private appConfig;
4
+ getWhiteList(): string[];
5
+ initialize(app: IServerApp): void;
6
+ }
7
+ //# sourceMappingURL=express-file-server.contribution.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"express-file-server.contribution.d.ts","sourceRoot":"","sources":["../../src/node/express-file-server.contribution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAU,UAAU,EAAa,MAAM,yBAAyB,CAAC;AAO/F,qBACa,6BAA8B,YAAW,qBAAqB;IAGzE,OAAO,CAAC,SAAS,CAAY;IAE7B,YAAY;IAQZ,UAAU,CAAC,GAAG,EAAE,UAAU;CA8B3B"}
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ExpressFileServerContribution = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const ide_core_node_1 = require("@opensumi/ide-core-node");
6
+ const di_1 = require("@opensumi/di");
7
+ const common_1 = require("../common");
8
+ const koa_mount_1 = (0, tslib_1.__importDefault)(require("koa-mount"));
9
+ const fs_1 = (0, tslib_1.__importDefault)(require("fs"));
10
+ const path_1 = (0, tslib_1.__importDefault)(require("path"));
11
+ let ExpressFileServerContribution = class ExpressFileServerContribution {
12
+ getWhiteList() {
13
+ return [
14
+ // 插件市场安装目录
15
+ this.appConfig.marketplace.extensionDir,
16
+ ...(this.appConfig.staticAllowPath || []),
17
+ ];
18
+ }
19
+ initialize(app) {
20
+ app.use((0, koa_mount_1.default)('/assets', async (ctx) => {
21
+ const filePath = ctx.path.replace(/^\/assets/, '');
22
+ if (!filePath) {
23
+ ctx.status = 404;
24
+ return;
25
+ }
26
+ const whitelist = this.getWhiteList();
27
+ const contentType = common_1.ALLOW_MIME[path_1.default.extname(filePath).slice(1)];
28
+ if (
29
+ /**
30
+ * 地址在白名单内
31
+ * Windows 下 C:\\Path\\to\\file 会被转换成 c:\\Path\\to\\file
32
+ */
33
+ whitelist.some((whitelistPath) => whitelistPath && filePath.toLowerCase().startsWith(whitelistPath.toLowerCase()))
34
+ // 在允许的 contentType
35
+ && contentType) {
36
+ ctx.set('Content-Type', contentType);
37
+ if (this.appConfig.staticAllowOrigin) {
38
+ ctx.set('Access-Control-Allow-Origin', this.appConfig.staticAllowOrigin);
39
+ }
40
+ ctx.body = fs_1.default.createReadStream(filePath);
41
+ }
42
+ else {
43
+ ctx.status = 403;
44
+ }
45
+ }));
46
+ }
47
+ };
48
+ (0, tslib_1.__decorate)([
49
+ (0, di_1.Autowired)(ide_core_node_1.AppConfig),
50
+ (0, tslib_1.__metadata)("design:type", Object)
51
+ ], ExpressFileServerContribution.prototype, "appConfig", void 0);
52
+ ExpressFileServerContribution = (0, tslib_1.__decorate)([
53
+ (0, ide_core_node_1.Domain)(ide_core_node_1.ServerAppContribution)
54
+ ], ExpressFileServerContribution);
55
+ exports.ExpressFileServerContribution = ExpressFileServerContribution;
56
+ //# sourceMappingURL=express-file-server.contribution.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"express-file-server.contribution.js","sourceRoot":"","sources":["../../src/node/express-file-server.contribution.ts"],"names":[],"mappings":";;;;AAAA,2DAA+F;AAC/F,qCAAyC;AACzC,sCAAuC;AACvC,uEAA8B;AAC9B,yDAAoB;AACpB,6DAAwB;AAGxB,IAAa,6BAA6B,GAA1C,MAAa,6BAA6B;IAKxC,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,CAAC,IAAA,mBAAK,EAAC,SAAS,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE;YACrC,MAAM,QAAQ,GAAG,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;YACnD,IAAI,CAAC,QAAQ,EAAE;gBACb,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC;gBACjB,OAAO;aACR;YAED,MAAM,SAAS,GAAG,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,CAAC,CAAC,aAAa,EAAE,EAAE,CAAC,aAAa,IAAI,QAAQ,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC,CAAC;gBAClH,mBAAmB;mBAChB,WAAW,EACd;gBACA,GAAG,CAAC,GAAG,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC;gBACrC,IAAI,IAAI,CAAC,SAAS,CAAC,iBAAiB,EAAE;oBACpC,GAAG,CAAC,GAAG,CAAC,6BAA6B,EAAE,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC;iBAC1E;gBACD,GAAG,CAAC,IAAI,GAAG,YAAE,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;aAC1C;iBAAM;gBACL,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC;aAClB;QACH,CAAC,CAAC,CAAC,CAAC;IAEN,CAAC;CACF,CAAA;AAxCC;IADC,IAAA,cAAS,EAAC,yBAAS,CAAC;;gEACQ;AAHlB,6BAA6B;IADzC,IAAA,sBAAM,EAAC,qCAAqB,CAAC;GACjB,6BAA6B,CA2CzC;AA3CY,sEAA6B"}
@@ -0,0 +1,6 @@
1
+ import { Provider } from '@opensumi/di';
2
+ import { NodeModule } from '@opensumi/ide-core-node';
3
+ export declare class ExpressFileServerModule extends NodeModule {
4
+ providers: Provider[];
5
+ }
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAc,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAGrD,qBACa,uBAAwB,SAAQ,UAAU;IACrD,SAAS,EAAE,QAAQ,EAAE,CAEnB;CACH"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ExpressFileServerModule = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const di_1 = require("@opensumi/di");
6
+ const ide_core_node_1 = require("@opensumi/ide-core-node");
7
+ const express_file_server_contribution_1 = require("./express-file-server.contribution");
8
+ let ExpressFileServerModule = class ExpressFileServerModule extends ide_core_node_1.NodeModule {
9
+ constructor() {
10
+ super(...arguments);
11
+ this.providers = [
12
+ express_file_server_contribution_1.ExpressFileServerContribution,
13
+ ];
14
+ }
15
+ };
16
+ ExpressFileServerModule = (0, tslib_1.__decorate)([
17
+ (0, di_1.Injectable)()
18
+ ], ExpressFileServerModule);
19
+ exports.ExpressFileServerModule = ExpressFileServerModule;
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":";;;;AAAA,qCAAoD;AACpD,2DAAqD;AACrD,yFAAmF;AAGnF,IAAa,uBAAuB,GAApC,MAAa,uBAAwB,SAAQ,0BAAU;IAAvD;;QACE,cAAS,GAAe;YACtB,gEAA6B;SAC9B,CAAC;IACJ,CAAC;CAAA,CAAA;AAJY,uBAAuB;IADnC,IAAA,eAAU,GAAE;GACA,uBAAuB,CAInC;AAJY,0DAAuB"}
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@opensumi/ide-express-file-server",
3
+ "version": "2.12.1-next-079c1930",
4
+ "files": [
5
+ "lib"
6
+ ],
7
+ "license": "MIT",
8
+ "main": "lib/index.js",
9
+ "typings": "lib/index.d.ts",
10
+ "scripts": {
11
+ "prepublishOnly": "npm run build",
12
+ "build": "tsc --build ../../configs/ts/references/tsconfig.express-file-server.json"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git@github.com:opensumi/core.git"
17
+ },
18
+ "dependencies": {
19
+ "@opensumi/ide-core-common": "2.12.1-next-079c1930",
20
+ "@opensumi/ide-core-node": "2.12.1-next-079c1930",
21
+ "@opensumi/ide-static-resource": "2.12.1-next-079c1930",
22
+ "koa-mount": "^4.0.0"
23
+ },
24
+ "devDependencies": {
25
+ "@opensumi/ide-core-browser": "2.12.1-next-079c1930",
26
+ "@opensumi/ide-dev-tool": "^1.3.1",
27
+ "superagent": "^5.1.0"
28
+ }
29
+ }