@rsdoctor/sdk 0.0.2-beta.0
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/LICENSE +21 -0
- package/README.md +15 -0
- package/dist/cjs/index.js +22 -0
- package/dist/cjs/sdk/index.js +24 -0
- package/dist/cjs/sdk/multiple/controller.js +72 -0
- package/dist/cjs/sdk/multiple/index.js +24 -0
- package/dist/cjs/sdk/multiple/server.js +41 -0
- package/dist/cjs/sdk/multiple/slave.js +98 -0
- package/dist/cjs/sdk/sdk/core.js +185 -0
- package/dist/cjs/sdk/sdk/index.js +31 -0
- package/dist/cjs/sdk/sdk/types.js +16 -0
- package/dist/cjs/sdk/sdk/webpack.js +373 -0
- package/dist/cjs/sdk/server/apis/alerts.js +52 -0
- package/dist/cjs/sdk/server/apis/base.js +46 -0
- package/dist/cjs/sdk/server/apis/bundle-diff.js +79 -0
- package/dist/cjs/sdk/server/apis/data.js +66 -0
- package/dist/cjs/sdk/server/apis/fs.js +50 -0
- package/dist/cjs/sdk/server/apis/graph.js +117 -0
- package/dist/cjs/sdk/server/apis/index.js +38 -0
- package/dist/cjs/sdk/server/apis/loader.js +127 -0
- package/dist/cjs/sdk/server/apis/plugin.js +58 -0
- package/dist/cjs/sdk/server/apis/project.js +82 -0
- package/dist/cjs/sdk/server/apis/renderer.js +74 -0
- package/dist/cjs/sdk/server/apis/resolver.js +57 -0
- package/dist/cjs/sdk/server/fakeServer.js +38 -0
- package/dist/cjs/sdk/server/index.js +184 -0
- package/dist/cjs/sdk/server/router.js +116 -0
- package/dist/cjs/sdk/server/socket/api.js +49 -0
- package/dist/cjs/sdk/server/socket/index.js +104 -0
- package/dist/cjs/sdk/server/utils.js +38 -0
- package/dist/cjs/sdk/utils/constant.js +41 -0
- package/dist/cjs/sdk/utils/index.js +24 -0
- package/dist/cjs/sdk/utils/upload.js +33 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/sdk/index.js +2 -0
- package/dist/esm/sdk/multiple/controller.js +48 -0
- package/dist/esm/sdk/multiple/index.js +2 -0
- package/dist/esm/sdk/multiple/server.js +17 -0
- package/dist/esm/sdk/multiple/slave.js +64 -0
- package/dist/esm/sdk/sdk/core.js +151 -0
- package/dist/esm/sdk/sdk/index.js +5 -0
- package/dist/esm/sdk/sdk/types.js +0 -0
- package/dist/esm/sdk/sdk/webpack.js +349 -0
- package/dist/esm/sdk/server/apis/alerts.js +30 -0
- package/dist/esm/sdk/server/apis/base.js +22 -0
- package/dist/esm/sdk/server/apis/bundle-diff.js +57 -0
- package/dist/esm/sdk/server/apis/data.js +44 -0
- package/dist/esm/sdk/server/apis/fs.js +28 -0
- package/dist/esm/sdk/server/apis/graph.js +95 -0
- package/dist/esm/sdk/server/apis/index.js +9 -0
- package/dist/esm/sdk/server/apis/loader.js +105 -0
- package/dist/esm/sdk/server/apis/plugin.js +36 -0
- package/dist/esm/sdk/server/apis/project.js +50 -0
- package/dist/esm/sdk/server/apis/renderer.js +42 -0
- package/dist/esm/sdk/server/apis/resolver.js +35 -0
- package/dist/esm/sdk/server/fakeServer.js +14 -0
- package/dist/esm/sdk/server/index.js +148 -0
- package/dist/esm/sdk/server/router.js +92 -0
- package/dist/esm/sdk/server/socket/api.js +25 -0
- package/dist/esm/sdk/server/socket/index.js +82 -0
- package/dist/esm/sdk/server/utils.js +14 -0
- package/dist/esm/sdk/utils/constant.js +7 -0
- package/dist/esm/sdk/utils/index.js +2 -0
- package/dist/esm/sdk/utils/upload.js +9 -0
- package/dist/type/index.d.ts +1 -0
- package/dist/type/sdk/index.d.ts +2 -0
- package/dist/type/sdk/multiple/controller.d.ts +16 -0
- package/dist/type/sdk/multiple/index.d.ts +2 -0
- package/dist/type/sdk/multiple/server.d.ts +7 -0
- package/dist/type/sdk/multiple/slave.d.ts +35 -0
- package/dist/type/sdk/sdk/core.d.ts +35 -0
- package/dist/type/sdk/sdk/index.d.ts +2 -0
- package/dist/type/sdk/sdk/types.d.ts +28 -0
- package/dist/type/sdk/sdk/webpack.d.ts +47 -0
- package/dist/type/sdk/server/apis/alerts.d.ts +5 -0
- package/dist/type/sdk/server/apis/base.d.ts +11 -0
- package/dist/type/sdk/server/apis/bundle-diff.d.ts +6 -0
- package/dist/type/sdk/server/apis/data.d.ts +6 -0
- package/dist/type/sdk/server/apis/fs.d.ts +5 -0
- package/dist/type/sdk/server/apis/graph.d.ts +12 -0
- package/dist/type/sdk/server/apis/index.d.ts +9 -0
- package/dist/type/sdk/server/apis/loader.d.ts +16 -0
- package/dist/type/sdk/server/apis/plugin.d.ts +6 -0
- package/dist/type/sdk/server/apis/project.d.ts +8 -0
- package/dist/type/sdk/server/apis/renderer.d.ts +7 -0
- package/dist/type/sdk/server/apis/resolver.d.ts +6 -0
- package/dist/type/sdk/server/fakeServer.d.ts +7 -0
- package/dist/type/sdk/server/index.d.ts +27 -0
- package/dist/type/sdk/server/router.d.ts +25 -0
- package/dist/type/sdk/server/socket/api.d.ts +15 -0
- package/dist/type/sdk/server/socket/index.d.ts +28 -0
- package/dist/type/sdk/server/utils.d.ts +5 -0
- package/dist/type/sdk/utils/constant.d.ts +1 -0
- package/dist/type/sdk/utils/index.d.ts +2 -0
- package/dist/type/sdk/utils/upload.d.ts +2 -0
- package/package.json +51 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
const _Router = class _Router {
|
|
2
|
+
constructor(options) {
|
|
3
|
+
this.options = options;
|
|
4
|
+
}
|
|
5
|
+
static get(pathname) {
|
|
6
|
+
return (target, propertyKey, descriptor) => {
|
|
7
|
+
const routes = _Router.routes.get;
|
|
8
|
+
if (!routes.has(target.constructor)) {
|
|
9
|
+
routes.set(target.constructor, []);
|
|
10
|
+
}
|
|
11
|
+
routes.get(target.constructor).push([propertyKey, pathname]);
|
|
12
|
+
return descriptor;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
static post(pathname) {
|
|
16
|
+
return (target, propertyKey, descriptor) => {
|
|
17
|
+
const routes = _Router.routes.post;
|
|
18
|
+
if (!routes.has(target.constructor)) {
|
|
19
|
+
routes.set(target.constructor, []);
|
|
20
|
+
}
|
|
21
|
+
routes.get(target.constructor).push([propertyKey, pathname]);
|
|
22
|
+
return descriptor;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
async setup() {
|
|
26
|
+
const { apis, sdk, server } = this.options;
|
|
27
|
+
apis.forEach((API) => {
|
|
28
|
+
const obj = new API(sdk, server);
|
|
29
|
+
_Router.routes.get.forEach((v, cons) => {
|
|
30
|
+
v.forEach(([key, pathname]) => {
|
|
31
|
+
if (cons === API) {
|
|
32
|
+
server.get(pathname, this.wrapAPIFunction(obj, key));
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
_Router.routes.post.forEach((v, cons) => {
|
|
37
|
+
v.forEach(([key, pathname]) => {
|
|
38
|
+
if (cons === API) {
|
|
39
|
+
server.post(pathname, this.wrapAPIFunction(obj, key));
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
wrapAPIFunction(api, key) {
|
|
46
|
+
const { sdk, server } = this.options;
|
|
47
|
+
return async (req, res) => {
|
|
48
|
+
const ctx = {
|
|
49
|
+
req,
|
|
50
|
+
res,
|
|
51
|
+
sdk,
|
|
52
|
+
server
|
|
53
|
+
};
|
|
54
|
+
const trap = new Proxy(api, {
|
|
55
|
+
get(target, key2, receiver) {
|
|
56
|
+
switch (key2) {
|
|
57
|
+
case "ctx":
|
|
58
|
+
return ctx;
|
|
59
|
+
default:
|
|
60
|
+
return Reflect.get(target, key2, receiver);
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
set(target, key2, value, receiver) {
|
|
64
|
+
return Reflect.set(target, key2, value, receiver);
|
|
65
|
+
},
|
|
66
|
+
defineProperty(target, p, attrs) {
|
|
67
|
+
return Reflect.defineProperty(target, p, attrs);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
const fn = api[key];
|
|
71
|
+
const result = await fn.call(trap, trap);
|
|
72
|
+
if (typeof result === "string") {
|
|
73
|
+
return Buffer.from(result, "utf-8");
|
|
74
|
+
}
|
|
75
|
+
if (result && typeof result === "object") {
|
|
76
|
+
return Buffer.from(JSON.stringify(result), "utf-8");
|
|
77
|
+
}
|
|
78
|
+
return result;
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
_Router.routes = {
|
|
83
|
+
/**
|
|
84
|
+
* - `key` is the constuctor of object which used to match the API class
|
|
85
|
+
*/
|
|
86
|
+
get: /* @__PURE__ */ new Map(),
|
|
87
|
+
post: /* @__PURE__ */ new Map()
|
|
88
|
+
};
|
|
89
|
+
let Router = _Router;
|
|
90
|
+
export {
|
|
91
|
+
Router
|
|
92
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Data } from "@rsdoctor/utils/common";
|
|
2
|
+
class SocketAPILoader {
|
|
3
|
+
constructor(options) {
|
|
4
|
+
this.options = options;
|
|
5
|
+
this.dataLoader = new Data.APIDataLoader(this);
|
|
6
|
+
}
|
|
7
|
+
async loadManifest() {
|
|
8
|
+
return this.options.sdk.getManifestData();
|
|
9
|
+
}
|
|
10
|
+
async loadData(key) {
|
|
11
|
+
const data = this.options.sdk.getStoreData();
|
|
12
|
+
const sep = ".";
|
|
13
|
+
let res = data[key];
|
|
14
|
+
if (key.includes(sep)) {
|
|
15
|
+
res = key.split(sep).reduce((t, k) => t[k], data);
|
|
16
|
+
}
|
|
17
|
+
return res;
|
|
18
|
+
}
|
|
19
|
+
get loadAPIData() {
|
|
20
|
+
return this.dataLoader.loadAPI;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export {
|
|
24
|
+
SocketAPILoader
|
|
25
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { SDK } from "@rsdoctor/types";
|
|
2
|
+
import {
|
|
3
|
+
Server as SocketServer
|
|
4
|
+
} from "socket.io";
|
|
5
|
+
import { isDeepStrictEqual } from "util";
|
|
6
|
+
import { SocketAPILoader } from "./api";
|
|
7
|
+
class Socket {
|
|
8
|
+
constructor(options) {
|
|
9
|
+
this.options = options;
|
|
10
|
+
this.map = /* @__PURE__ */ new Map();
|
|
11
|
+
this.loader = new SocketAPILoader({ sdk: options.sdk });
|
|
12
|
+
}
|
|
13
|
+
bootstrap() {
|
|
14
|
+
this.io = new SocketServer(this.options.server, {
|
|
15
|
+
cors: {
|
|
16
|
+
origin: "*"
|
|
17
|
+
},
|
|
18
|
+
...this.options.socketOptions
|
|
19
|
+
});
|
|
20
|
+
this.io.on("connection", (socket) => {
|
|
21
|
+
this.setupSocket(socket);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
setupSocket(socket) {
|
|
25
|
+
Object.values(SDK.ServerAPI.API).forEach((api) => {
|
|
26
|
+
socket.on(api, async (body, callback) => {
|
|
27
|
+
this.saveRequestToMap(api, body);
|
|
28
|
+
callback(await this.getAPIResponse(api, body));
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
saveRequestToMap(api, body = null) {
|
|
33
|
+
if (!this.map.has(api)) {
|
|
34
|
+
this.map.set(api, []);
|
|
35
|
+
}
|
|
36
|
+
const list = this.map.get(api);
|
|
37
|
+
if (!list.some((e) => e === body || isDeepStrictEqual(e, body))) {
|
|
38
|
+
list.push(body);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
async getAPIResponse(api, body) {
|
|
42
|
+
const data = await this.loader.loadAPIData(
|
|
43
|
+
api,
|
|
44
|
+
body
|
|
45
|
+
);
|
|
46
|
+
const response = {
|
|
47
|
+
req: {
|
|
48
|
+
api,
|
|
49
|
+
body
|
|
50
|
+
},
|
|
51
|
+
res: data
|
|
52
|
+
};
|
|
53
|
+
return response;
|
|
54
|
+
}
|
|
55
|
+
async broadcast() {
|
|
56
|
+
clearImmediate(this.timer);
|
|
57
|
+
this.timer = setImmediate(async () => {
|
|
58
|
+
const promises = [];
|
|
59
|
+
this.map.forEach((bodies, api) => {
|
|
60
|
+
bodies.forEach((body) => {
|
|
61
|
+
promises.push(
|
|
62
|
+
(async () => {
|
|
63
|
+
const res = await this.getAPIResponse(api, body);
|
|
64
|
+
this.io.emit(api, res);
|
|
65
|
+
})()
|
|
66
|
+
);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
await Promise.all(promises);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
sendAPIData(api, msg) {
|
|
73
|
+
this.io.sockets.emit(api, msg);
|
|
74
|
+
}
|
|
75
|
+
dispose() {
|
|
76
|
+
this.io.disconnectSockets();
|
|
77
|
+
this.io.close();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
export {
|
|
81
|
+
Socket
|
|
82
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
function getDataByPagination(data, pagination) {
|
|
2
|
+
const { page = 1, pageSize = 1e3 } = pagination;
|
|
3
|
+
return {
|
|
4
|
+
data: data.slice((page - 1) * pageSize, page * pageSize),
|
|
5
|
+
pagination: {
|
|
6
|
+
page,
|
|
7
|
+
pageSize,
|
|
8
|
+
hasNextPage: page <= 0 ? false : page * pageSize < data.length
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
getDataByPagination
|
|
14
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './sdk';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Manifest } from '@rsdoctor/types';
|
|
2
|
+
import { DoctorSlaveSDK } from './slave';
|
|
3
|
+
export declare class DoctorSDKController {
|
|
4
|
+
readonly slaves: DoctorSlaveSDK[];
|
|
5
|
+
root: string;
|
|
6
|
+
constructor(root?: string);
|
|
7
|
+
get master(): DoctorSlaveSDK;
|
|
8
|
+
getLastSdk(): DoctorSlaveSDK;
|
|
9
|
+
hasName(name: string): boolean;
|
|
10
|
+
getSeriesData(serverUrl?: boolean): Manifest.DoctorManifestSeriesData[];
|
|
11
|
+
createSlave({
|
|
12
|
+
name,
|
|
13
|
+
stage,
|
|
14
|
+
extraConfig
|
|
15
|
+
}: Omit<ConstructorParameters<typeof DoctorSlaveSDK>[0], 'controller'>): DoctorSlaveSDK;
|
|
16
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DoctorServer } from '../server';
|
|
2
|
+
import type { DoctorSlaveSDK } from './slave';
|
|
3
|
+
export declare class DoctorSlaveServer extends DoctorServer {
|
|
4
|
+
protected sdk: DoctorSlaveSDK;
|
|
5
|
+
constructor(sdk: DoctorSlaveSDK, port?: number);
|
|
6
|
+
openClientPage(...args: unknown[]): Promise<void>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { SDK } from '@rsdoctor/types';
|
|
2
|
+
import { DoctorWebpackSDK } from '../sdk';
|
|
3
|
+
import type { DoctorSDKController } from './controller';
|
|
4
|
+
interface DoctorSlaveSDKOptions {
|
|
5
|
+
name: string;
|
|
6
|
+
/**
|
|
7
|
+
* use to sort for display in the client page.
|
|
8
|
+
* the smaller the front.
|
|
9
|
+
* @default 1
|
|
10
|
+
*/
|
|
11
|
+
stage?: number;
|
|
12
|
+
extraConfig?: SDK.SDKOptionsType;
|
|
13
|
+
controller: DoctorSDKController;
|
|
14
|
+
}
|
|
15
|
+
export declare class DoctorSlaveSDK extends DoctorWebpackSDK {
|
|
16
|
+
id: number;
|
|
17
|
+
readonly stage: number;
|
|
18
|
+
private parent;
|
|
19
|
+
private uploadPieces;
|
|
20
|
+
private finishUploadPieceSwitch;
|
|
21
|
+
constructor({
|
|
22
|
+
name,
|
|
23
|
+
stage,
|
|
24
|
+
controller,
|
|
25
|
+
extraConfig
|
|
26
|
+
}: DoctorSlaveSDKOptions);
|
|
27
|
+
private clearSwitch;
|
|
28
|
+
get isMaster(): boolean;
|
|
29
|
+
protected writePieces(): Promise<void>;
|
|
30
|
+
protected writeManifest(): Promise<string>;
|
|
31
|
+
getSeriesData(serverUrl?: boolean): import("@rsdoctor/types/dist/manifest").DoctorManifestSeriesData[];
|
|
32
|
+
setName(name: string): void;
|
|
33
|
+
getManifestData(): import("@rsdoctor/types/dist/manifest").DoctorManifestWithShardingFiles;
|
|
34
|
+
}
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Common, Manifest, SDK } from '@rsdoctor/types';
|
|
2
|
+
import { DoctorSDKOptions, DataWithUrl } from './types';
|
|
3
|
+
export declare abstract class SDKCore<T extends DoctorSDKOptions> implements SDK.DoctorSDKInstance {
|
|
4
|
+
protected _name: string;
|
|
5
|
+
protected hash: string;
|
|
6
|
+
extraConfig: SDK.SDKOptionsType | undefined;
|
|
7
|
+
readonly root: string;
|
|
8
|
+
readonly pid: number;
|
|
9
|
+
readonly hooks: SDK.Hooks;
|
|
10
|
+
protected _envinfo: SDK.EnvInfo;
|
|
11
|
+
private _clientRoutes;
|
|
12
|
+
private _outputDir;
|
|
13
|
+
diskManifestPath: string;
|
|
14
|
+
cloudData?: Manifest.DoctorManifestWithShardingFiles;
|
|
15
|
+
constructor({
|
|
16
|
+
name,
|
|
17
|
+
root
|
|
18
|
+
}: T);
|
|
19
|
+
get outputDir(): string;
|
|
20
|
+
get name(): string;
|
|
21
|
+
bootstrap(): Promise<void>;
|
|
22
|
+
dispose(): Promise<void>;
|
|
23
|
+
setOutputDir(outputDir: string): void;
|
|
24
|
+
setName(name: string): void;
|
|
25
|
+
setHash(hash: string): void;
|
|
26
|
+
getClientRoutes(): Manifest.DoctorManifestClientRoutes[];
|
|
27
|
+
addClientRoutes(routes: Manifest.DoctorManifestClientRoutes[]): void;
|
|
28
|
+
/** Upload analysis data pieces */
|
|
29
|
+
protected writePieces(storeData: Common.PlainObject, _options?: SDK.WriteStoreOptionsType): Promise<void>;
|
|
30
|
+
/** Upload manifest file */
|
|
31
|
+
protected writeManifest(): Promise<string>;
|
|
32
|
+
saveManifest(data: Common.PlainObject, options: SDK.WriteStoreOptionsType): Promise<string>;
|
|
33
|
+
protected writeToFolder(jsonstr: string, dir: string, key: string): Promise<DataWithUrl>;
|
|
34
|
+
abstract onDataReport(): void | Promise<void>;
|
|
35
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { SDK } from '@rsdoctor/types';
|
|
3
|
+
export interface DataWithUrl {
|
|
4
|
+
name: string;
|
|
5
|
+
files: {
|
|
6
|
+
path: string;
|
|
7
|
+
basename: string;
|
|
8
|
+
content: Buffer;
|
|
9
|
+
}[] | string;
|
|
10
|
+
}
|
|
11
|
+
export interface DoctorSDKOptions {
|
|
12
|
+
name: string;
|
|
13
|
+
root: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* sdk options for builder.
|
|
17
|
+
*/
|
|
18
|
+
export interface DoctorBuilderSDK extends DoctorSDKOptions {
|
|
19
|
+
type?: SDK.ToDataType;
|
|
20
|
+
/**
|
|
21
|
+
* port for client server
|
|
22
|
+
*/
|
|
23
|
+
port?: number;
|
|
24
|
+
noServer?: boolean;
|
|
25
|
+
config?: SDK.SDKOptionsType;
|
|
26
|
+
}
|
|
27
|
+
export interface DoctorWebpackSDKOptions extends DoctorBuilderSDK {}
|
|
28
|
+
export interface DoctorEMOSDKOptions extends DoctorSDKOptions {}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Manifest, SDK } from '@rsdoctor/types';
|
|
2
|
+
import { RawSourceMap, SourceMapConsumer } from 'source-map';
|
|
3
|
+
import { ModuleGraph, ChunkGraph, PackageGraph } from '@rsdoctor/graph';
|
|
4
|
+
import { DoctorServer } from '../server';
|
|
5
|
+
import { DoctorWebpackSDKOptions } from './types';
|
|
6
|
+
import { SDKCore } from './core';
|
|
7
|
+
export declare class DoctorWebpackSDK<T extends DoctorWebpackSDKOptions = DoctorWebpackSDKOptions> extends SDKCore<T> implements SDK.DoctorBuilderSDKInstance {
|
|
8
|
+
server: DoctorServer;
|
|
9
|
+
extraConfig: SDK.SDKOptionsType | undefined;
|
|
10
|
+
private type;
|
|
11
|
+
private _summary;
|
|
12
|
+
private _configs;
|
|
13
|
+
private _errors;
|
|
14
|
+
private _loader;
|
|
15
|
+
private _resolver;
|
|
16
|
+
private _plugin;
|
|
17
|
+
private _moduleGraph;
|
|
18
|
+
private _chunkGraph;
|
|
19
|
+
private _rawSourceMapCache;
|
|
20
|
+
private _sourceMap;
|
|
21
|
+
private _packageGraph;
|
|
22
|
+
private _tileReportHtml;
|
|
23
|
+
constructor(options: T);
|
|
24
|
+
bootstrap(): Promise<void>;
|
|
25
|
+
dispose(): Promise<void>;
|
|
26
|
+
applyErrorFix(id: number): Promise<void>;
|
|
27
|
+
clear(): void;
|
|
28
|
+
clearSourceMapCache(): void;
|
|
29
|
+
getSourceMap(file: string): Promise<SourceMapConsumer | undefined>;
|
|
30
|
+
reportSourceMap(data: RawSourceMap): void;
|
|
31
|
+
reportConfiguration(config: SDK.ConfigData[0]): void;
|
|
32
|
+
reportError(errors: Error[]): void;
|
|
33
|
+
reportLoader(data: SDK.LoaderData): void;
|
|
34
|
+
reportResolver(data: SDK.ResolverData): void;
|
|
35
|
+
reportPlugin(data: SDK.PluginData): void;
|
|
36
|
+
reportModuleGraph(data: ModuleGraph): void;
|
|
37
|
+
reportPackageGraph(data: PackageGraph): void;
|
|
38
|
+
reportChunkGraph(data: ChunkGraph): void;
|
|
39
|
+
reportSummaryData(part: Partial<SDK.SummaryData>): void;
|
|
40
|
+
reportTileHtml(tileReportHtml: string): void;
|
|
41
|
+
createPackageGraph(): void;
|
|
42
|
+
writeStore(options?: SDK.WriteStoreOptionsType): Promise<string>;
|
|
43
|
+
getStoreData(): SDK.BuilderStoreData;
|
|
44
|
+
getManifestData(): Manifest.DoctorManifestWithShardingFiles;
|
|
45
|
+
getRuleContext(_options: SDK.RuntimeContextOptions): SDK.RuntimeContext;
|
|
46
|
+
onDataReport(): void | Promise<void>;
|
|
47
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Data } from '@rsdoctor/utils/common';
|
|
2
|
+
import { Manifest, SDK } from '@rsdoctor/types';
|
|
3
|
+
export declare class BaseAPI implements Manifest.ManifestDataLoader {
|
|
4
|
+
[key: string | symbol]: any;
|
|
5
|
+
readonly ctx: SDK.ServerAPI.APIContext;
|
|
6
|
+
protected dataLoader: Data.APIDataLoader;
|
|
7
|
+
constructor(sdk: SDK.DoctorSDKInstance, server: SDK.DoctorServerInstance);
|
|
8
|
+
loadManifest(): Promise<Manifest.DoctorManifestWithShardingFiles>;
|
|
9
|
+
loadData<T extends Manifest.DoctorManifestMappingKeys>(key: T): Promise<Manifest.InferManifestDataValue<T>>;
|
|
10
|
+
loadData(key: string): Promise<void>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { SDK } from '@rsdoctor/types';
|
|
2
|
+
import { BaseAPI } from './base';
|
|
3
|
+
export declare class BundleDiffAPI extends BaseAPI {
|
|
4
|
+
getBundleDiffSummary(): Promise<SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetBundleDiffSummary>>;
|
|
5
|
+
bundleDiffManifest(): Promise<SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.BundleDiffManifest>>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { SDK } from '@rsdoctor/types';
|
|
2
|
+
import { BaseAPI } from './base';
|
|
3
|
+
export declare class DataAPI extends BaseAPI {
|
|
4
|
+
loadDataByKey(): Promise<SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.LoadDataByKey>>;
|
|
5
|
+
sendMessageToClient(): Promise<SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.SendAPIDataToClient>>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { SDK } from '@rsdoctor/types';
|
|
2
|
+
import { BaseAPI } from './base';
|
|
3
|
+
export declare class GraphAPI extends BaseAPI {
|
|
4
|
+
getAssetsSummary(): Promise<SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetAssetsSummary>>;
|
|
5
|
+
getModuleGraphForAsset(): Promise<SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetAssetDetails>>;
|
|
6
|
+
getChunksByModuleId(): Promise<SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetChunksByModuleId>>;
|
|
7
|
+
getModuleDetails(): Promise<SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetModuleDetails>>;
|
|
8
|
+
getDependencyByResolvedRequest(): Promise<SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetModulesByModuleIds>>;
|
|
9
|
+
getModuleCodeByModuleId(): Promise<SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetModuleCodeByModuleId>>;
|
|
10
|
+
getModuleCodeByModuleIds(): Promise<SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetModuleCodeByModuleIds>>;
|
|
11
|
+
getEntryModulesSummary(): Promise<SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetEntryPoints>>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SDK } from '@rsdoctor/types';
|
|
2
|
+
import { BaseAPI } from './base';
|
|
3
|
+
export declare class LoaderAPI extends BaseAPI {
|
|
4
|
+
/** report loader data api */
|
|
5
|
+
reportLoader(): Promise<SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.ReportLoader>>;
|
|
6
|
+
/** report sourcemap data api */
|
|
7
|
+
reportSourceMap(): Promise<SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.ReportLoader>>;
|
|
8
|
+
getLoaderNames(): Promise<SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetLoaderNames>>;
|
|
9
|
+
getLoaderChartData(): Promise<SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetLoaderChartData>>;
|
|
10
|
+
getLoaderFileTree(): Promise<SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetLoaderFileTree>>;
|
|
11
|
+
getLoaderFileDetails(): Promise<SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetLoaderFileDetails>>;
|
|
12
|
+
getLoaderFolderStatistics(): Promise<SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetLoaderFolderStatistics>>;
|
|
13
|
+
getLoaderFileFirstInput(): Promise<SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetLoaderFileFirstInput>>;
|
|
14
|
+
getLoaderFileInputAndOutput(): Promise<SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetLoaderFileInputAndOutput>>;
|
|
15
|
+
getTileReportHtml(): Promise<SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetTileReportHtml>>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { SDK } from '@rsdoctor/types';
|
|
2
|
+
import { BaseAPI } from './base';
|
|
3
|
+
export declare class PluginAPI extends BaseAPI {
|
|
4
|
+
getPluginSummary(): Promise<SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetPluginSummary>>;
|
|
5
|
+
getPluginData(): Promise<SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetPluginData>>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SDK } from '@rsdoctor/types';
|
|
2
|
+
import { BaseAPI } from './base';
|
|
3
|
+
export declare class ProjectAPI extends BaseAPI {
|
|
4
|
+
env(): Promise<SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.Env>>;
|
|
5
|
+
manifest(): Promise<SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.Manifest>>;
|
|
6
|
+
getProjectInfo(): Promise<SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetProjectInfo>>;
|
|
7
|
+
getClientRoutes(): Promise<SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetClientRoutes>>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { SDK } from '@rsdoctor/types';
|
|
2
|
+
import { BaseAPI } from './base';
|
|
3
|
+
export declare class RendererAPI extends BaseAPI {
|
|
4
|
+
private isClientServed;
|
|
5
|
+
/** sdk manifest api */
|
|
6
|
+
entryHtml(): Promise<SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.EntryHtml>>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { SDK } from '@rsdoctor/types';
|
|
2
|
+
import { BaseAPI } from './base';
|
|
3
|
+
export declare class ResolverAPI extends BaseAPI {
|
|
4
|
+
getResolverFileTree(): Promise<SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetResolverFileTree>>;
|
|
5
|
+
getResolverFileDetails(): Promise<SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetResolverFileDetails>>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { SDK } from '@rsdoctor/types';
|
|
2
|
+
import { DoctorServer } from '.';
|
|
3
|
+
export declare class DoctorFakeServer extends DoctorServer {
|
|
4
|
+
protected sdk: SDK.DoctorBuilderSDKInstance;
|
|
5
|
+
constructor(sdk: SDK.DoctorBuilderSDKInstance, port?: number);
|
|
6
|
+
openClientPage(): Promise<void>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/// <reference types="connect" />
|
|
2
|
+
import { Common, SDK, Thirdparty, Client } from '@rsdoctor/types';
|
|
3
|
+
export * from './utils';
|
|
4
|
+
export declare class DoctorServer implements SDK.DoctorServerInstance {
|
|
5
|
+
protected sdk: SDK.DoctorBuilderSDKInstance;
|
|
6
|
+
private _server;
|
|
7
|
+
port: number;
|
|
8
|
+
private _socket?;
|
|
9
|
+
private disposed;
|
|
10
|
+
private _router;
|
|
11
|
+
constructor(sdk: SDK.DoctorBuilderSDKInstance, port?: number);
|
|
12
|
+
get app(): SDK.DoctorServerInstance['app'];
|
|
13
|
+
get origin(): string;
|
|
14
|
+
get socketUrl(): string;
|
|
15
|
+
bootstrap(): Promise<void>;
|
|
16
|
+
protected wrapNextHandleFunction(method: 'GET' | 'POST', cb: (...args: Parameters<Thirdparty.connect.NextHandleFunction>) => Common.PlainObject | string): Thirdparty.connect.NextHandleFunction;
|
|
17
|
+
proxy(api: SDK.ServerAPI.API, method: 'GET' | 'POST', cb: (...args: Parameters<Thirdparty.connect.NextHandleFunction>) => Common.PlainObject | string): void;
|
|
18
|
+
get: SDK.DoctorServerInstance['get'];
|
|
19
|
+
post: SDK.DoctorServerInstance['post'];
|
|
20
|
+
getClientUrl(route: Client.DoctorClientRoutes, baselineUrl: string, currentUrl: string): string;
|
|
21
|
+
getClientUrl(route?: 'homepage'): string;
|
|
22
|
+
openClientPage(route: Client.DoctorClientRoutes, baselineUrl: string, currentUrl: string): Promise<void>;
|
|
23
|
+
openClientPage(route?: 'homepage'): Promise<void>;
|
|
24
|
+
sendAPIDataToClient<T extends SDK.ServerAPI.API | SDK.ServerAPI.APIExtends>(api: T, msg: SDK.ServerAPI.SocketResponseType<T>): void;
|
|
25
|
+
broadcast(): Promise<void>;
|
|
26
|
+
dispose: () => Promise<void>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { ServerResponse } from 'http';
|
|
3
|
+
import { Common, SDK, Thirdparty } from '@rsdoctor/types';
|
|
4
|
+
import { BaseAPI } from './apis/base';
|
|
5
|
+
interface RouterOptions {
|
|
6
|
+
apis: Common.Constructor<typeof BaseAPI>[];
|
|
7
|
+
sdk: SDK.DoctorBuilderSDKInstance;
|
|
8
|
+
server: SDK.DoctorServerInstance;
|
|
9
|
+
}
|
|
10
|
+
export declare class Router {
|
|
11
|
+
protected options: RouterOptions;
|
|
12
|
+
static routes: {
|
|
13
|
+
/**
|
|
14
|
+
* - `key` is the constuctor of object which used to match the API class
|
|
15
|
+
*/
|
|
16
|
+
get: Map<Function, [apiKey: PropertyKey, pathname: string][]>;
|
|
17
|
+
post: Map<Function, [apiKey: PropertyKey, pathname: string][]>;
|
|
18
|
+
};
|
|
19
|
+
static get(pathname: string): MethodDecorator;
|
|
20
|
+
static post(pathname: string): MethodDecorator;
|
|
21
|
+
constructor(options: RouterOptions);
|
|
22
|
+
setup(): Promise<void>;
|
|
23
|
+
wrapAPIFunction<T extends BaseAPI>(api: T, key: PropertyKey): (req: Thirdparty.connect.IncomingMessage, res: ServerResponse) => Promise<any>;
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Data } from '@rsdoctor/utils/common';
|
|
2
|
+
import { Manifest, SDK } from '@rsdoctor/types';
|
|
3
|
+
interface SocketAPILoaderOptions {
|
|
4
|
+
sdk: SDK.DoctorBuilderSDKInstance;
|
|
5
|
+
}
|
|
6
|
+
export declare class SocketAPILoader implements Manifest.ManifestDataLoader {
|
|
7
|
+
protected options: SocketAPILoaderOptions;
|
|
8
|
+
protected dataLoader: Data.APIDataLoader;
|
|
9
|
+
constructor(options: SocketAPILoaderOptions);
|
|
10
|
+
loadManifest(): Promise<Manifest.DoctorManifestWithShardingFiles>;
|
|
11
|
+
loadData<T extends Manifest.DoctorManifestMappingKeys>(key: T): Promise<Manifest.InferManifestDataValue<T>>;
|
|
12
|
+
loadData(key: string): Promise<void>;
|
|
13
|
+
get loadAPIData(): <T extends SDK.ServerAPI.API, B extends import("@rsdoctor/types/dist/common").Get<SDK.ServerAPI.ResquestBodyTypes, T, void> = import("@rsdoctor/types/dist/common").Get<SDK.ServerAPI.ResquestBodyTypes, T, void>, R extends import("@rsdoctor/types/dist/common").Get<SDK.ServerAPI.ResponseTypes, T, void> = import("@rsdoctor/types/dist/common").Get<SDK.ServerAPI.ResponseTypes, T, void>>(...args: B extends void ? [api: T] : [api: T, body: B]) => Promise<import("@rsdoctor/types/dist/common").Get<SDK.ServerAPI.ResponseTypes, T, void>>;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { Common, SDK } from '@rsdoctor/types';
|
|
4
|
+
import type { Server } from 'http';
|
|
5
|
+
import { Server as SocketServer, ServerOptions as SocketServerOptions, Socket as SocketType } from 'socket.io';
|
|
6
|
+
import { SocketAPILoader } from './api';
|
|
7
|
+
interface SocketOptions {
|
|
8
|
+
sdk: SDK.DoctorBuilderSDKInstance;
|
|
9
|
+
server: Server;
|
|
10
|
+
port: number;
|
|
11
|
+
socketOptions?: SocketServerOptions;
|
|
12
|
+
}
|
|
13
|
+
export declare class Socket {
|
|
14
|
+
protected options: SocketOptions;
|
|
15
|
+
protected io: SocketServer;
|
|
16
|
+
protected loader: SocketAPILoader;
|
|
17
|
+
protected map: Map<SDK.ServerAPI.API, (Common.PlainObject | null)[]>;
|
|
18
|
+
constructor(options: SocketOptions);
|
|
19
|
+
bootstrap(): void;
|
|
20
|
+
protected setupSocket(socket: SocketType): void;
|
|
21
|
+
protected saveRequestToMap<T extends SDK.ServerAPI.API>(api: T, body?: SDK.ServerAPI.InferRequestBodyType<T, null> | null): void;
|
|
22
|
+
protected getAPIResponse<T extends SDK.ServerAPI.API>(api: T, body: SDK.ServerAPI.InferRequestBodyType<T>): Promise<SDK.ServerAPI.SocketResponseType<SDK.ServerAPI.API>>;
|
|
23
|
+
protected timer: NodeJS.Immediate | undefined;
|
|
24
|
+
broadcast(): Promise<void>;
|
|
25
|
+
sendAPIData<T extends SDK.ServerAPI.API | SDK.ServerAPI.APIExtends>(api: T, msg: SDK.ServerAPI.SocketResponseType<T>): void;
|
|
26
|
+
dispose(): void;
|
|
27
|
+
}
|
|
28
|
+
export {};
|