@rsdoctor/sdk 0.1.0 → 0.1.2
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/README.md +10 -3
- package/dist/cjs/sdk/server/index.js +19 -10
- package/dist/cjs/sdk/utils/openBrowser.js +92 -0
- package/dist/esm/sdk/server/index.js +19 -10
- package/dist/esm/sdk/utils/openBrowser.js +58 -0
- package/dist/type/index.d.ts +1 -1
- package/dist/type/sdk/index.d.ts +1 -1
- package/dist/type/sdk/multiple/controller.d.ts +9 -13
- package/dist/type/sdk/multiple/index.d.ts +1 -1
- package/dist/type/sdk/multiple/server.d.ts +4 -4
- package/dist/type/sdk/multiple/slave.d.ts +23 -28
- package/dist/type/sdk/sdk/core.d.ts +29 -32
- package/dist/type/sdk/sdk/index.d.ts +1 -1
- package/dist/type/sdk/sdk/types.d.ts +19 -17
- package/dist/type/sdk/sdk/webpack.d.ts +42 -42
- package/dist/type/sdk/server/apis/alerts.d.ts +2 -2
- package/dist/type/sdk/server/apis/base.d.ts +8 -8
- package/dist/type/sdk/server/apis/bundle-diff.d.ts +3 -3
- package/dist/type/sdk/server/apis/data.d.ts +3 -3
- package/dist/type/sdk/server/apis/fs.d.ts +2 -2
- package/dist/type/sdk/server/apis/graph.d.ts +9 -9
- package/dist/type/sdk/server/apis/index.d.ts +1 -1
- package/dist/type/sdk/server/apis/loader.d.ts +13 -13
- package/dist/type/sdk/server/apis/plugin.d.ts +3 -3
- package/dist/type/sdk/server/apis/project.d.ts +5 -5
- package/dist/type/sdk/server/apis/renderer.d.ts +4 -4
- package/dist/type/sdk/server/apis/resolver.d.ts +3 -3
- package/dist/type/sdk/server/fakeServer.d.ts +4 -4
- package/dist/type/sdk/server/index.d.ts +24 -23
- package/dist/type/sdk/server/router.d.ts +17 -17
- package/dist/type/sdk/server/socket/api.d.ts +9 -9
- package/dist/type/sdk/server/socket/index.d.ts +18 -18
- package/dist/type/sdk/server/utils.d.ts +3 -3
- package/dist/type/sdk/utils/constant.d.ts +1 -1
- package/dist/type/sdk/utils/index.d.ts +1 -1
- package/dist/type/sdk/utils/openBrowser.d.ts +4 -0
- package/dist/type/sdk/utils/upload.d.ts +1 -1
- package/package.json +7 -6
- package/static/openChrome.applescript +95 -0
package/README.md
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
|
-
# Rsdoctor
|
|
1
|
+
# Rsdoctor SDK
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This package is the intermediate data layer of Rsdoctor.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## features
|
|
6
|
+
|
|
7
|
+
- Rsdoctor is a one-stop tool for diagnosing and analyzing the build process and build artifacts.
|
|
8
|
+
- Rsdoctor is a tool that supports Webpack and Rspack build analysis.
|
|
9
|
+
- Rsdoctor is an analysis tool that can display the time-consuming and behavioral details of the compilation.
|
|
10
|
+
- Rsdoctor is a tool that provides bundle Diff and other anti-degradation capabilities simultaneously.
|
|
6
11
|
|
|
7
12
|
## Documentation
|
|
8
13
|
|
|
14
|
+
https://rsdoctor.dev/
|
|
15
|
+
|
|
9
16
|
## Contributing
|
|
10
17
|
|
|
11
18
|
Please read the [Contributing Guide](https://github.com/web-infra-dev/rsdoctor/blob/main/CONTRIBUTING.md).
|
|
@@ -37,13 +37,14 @@ var import_build = require("@rsdoctor/utils/build");
|
|
|
37
37
|
var import_common = require("@rsdoctor/utils/common");
|
|
38
38
|
var import_assert = __toESM(require("assert"));
|
|
39
39
|
var import_body_parser = __toESM(require("body-parser"));
|
|
40
|
-
var import_open = __toESM(require("open"));
|
|
41
40
|
var import_ip = __toESM(require("ip"));
|
|
42
41
|
var import_cors = __toESM(require("cors"));
|
|
43
42
|
var import_stream = require("stream");
|
|
44
43
|
var import_socket = require("./socket");
|
|
45
44
|
var import_router = require("./router");
|
|
46
45
|
var APIs = __toESM(require("./apis"));
|
|
46
|
+
var import_logger = require("@rsdoctor/utils/logger");
|
|
47
|
+
var import_openBrowser = require("../utils/openBrowser");
|
|
47
48
|
__reExport(server_exports, require("./utils"), module.exports);
|
|
48
49
|
class RsdoctorServer {
|
|
49
50
|
constructor(sdk, port = import_build.Server.defaultPort) {
|
|
@@ -77,12 +78,15 @@ class RsdoctorServer {
|
|
|
77
78
|
get app() {
|
|
78
79
|
return this._server.app;
|
|
79
80
|
}
|
|
80
|
-
get
|
|
81
|
+
get host() {
|
|
81
82
|
const host = import_ip.default.address();
|
|
82
|
-
return
|
|
83
|
+
return host;
|
|
84
|
+
}
|
|
85
|
+
get origin() {
|
|
86
|
+
return `http://${this.host}:${this.port}`;
|
|
83
87
|
}
|
|
84
88
|
get socketUrl() {
|
|
85
|
-
return `ws
|
|
89
|
+
return `ws://localhost:${this.port}`;
|
|
86
90
|
}
|
|
87
91
|
async bootstrap() {
|
|
88
92
|
if (!this.disposed) {
|
|
@@ -152,23 +156,28 @@ class RsdoctorServer {
|
|
|
152
156
|
});
|
|
153
157
|
}
|
|
154
158
|
getClientUrl(route = "homepage", ...args) {
|
|
155
|
-
const
|
|
159
|
+
const relativeUrl = import_types.SDK.ServerAPI.API.EntryHtml;
|
|
156
160
|
switch (route) {
|
|
157
161
|
case import_types.Client.RsdoctorClientRoutes.BundleDiff: {
|
|
158
162
|
const [baseline, current] = args;
|
|
159
163
|
const qs = import_common.Bundle.getBundleDiffPageQueryString([baseline, current]);
|
|
160
|
-
return `${
|
|
164
|
+
return `${relativeUrl}${qs}#${import_types.Client.RsdoctorClientRoutes.BundleDiff}`;
|
|
161
165
|
}
|
|
162
166
|
default:
|
|
163
|
-
return
|
|
167
|
+
return relativeUrl;
|
|
164
168
|
}
|
|
165
169
|
}
|
|
166
170
|
async openClientPage(...args) {
|
|
167
|
-
const
|
|
171
|
+
const relativeUrl = this.getClientUrl(
|
|
168
172
|
...args
|
|
169
173
|
);
|
|
170
|
-
|
|
171
|
-
|
|
174
|
+
const url = `http://${this.host}:${this.port}${relativeUrl}`;
|
|
175
|
+
const localhostUrl = `http://localhost:${this.port}${relativeUrl}`;
|
|
176
|
+
await (0, import_openBrowser.openBrowser)(url);
|
|
177
|
+
import_logger.logger.info(`Rsdoctor analyze server running on: ${import_logger.chalk.cyan(url)}`);
|
|
178
|
+
import_logger.logger.info(
|
|
179
|
+
`Rsdoctor analyze server running on: ${import_logger.chalk.cyan(localhostUrl)}`
|
|
180
|
+
);
|
|
172
181
|
}
|
|
173
182
|
sendAPIDataToClient(api, msg) {
|
|
174
183
|
this._socket?.sendAPIData(api, msg);
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var openBrowser_exports = {};
|
|
30
|
+
__export(openBrowser_exports, {
|
|
31
|
+
openBrowser: () => openBrowser
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(openBrowser_exports);
|
|
34
|
+
var import_node_child_process = require("node:child_process");
|
|
35
|
+
var import_node_util = require("node:util");
|
|
36
|
+
var import_logger = require("@rsdoctor/utils/logger");
|
|
37
|
+
var import_open = __toESM(require("open"));
|
|
38
|
+
var import_node_path = require("node:path");
|
|
39
|
+
const execAsync = (0, import_node_util.promisify)(import_node_child_process.exec);
|
|
40
|
+
const supportedChromiumBrowsers = [
|
|
41
|
+
"Google Chrome Canary",
|
|
42
|
+
"Google Chrome Dev",
|
|
43
|
+
"Google Chrome Beta",
|
|
44
|
+
"Google Chrome",
|
|
45
|
+
"Microsoft Edge",
|
|
46
|
+
"Brave Browser",
|
|
47
|
+
"Vivaldi",
|
|
48
|
+
"Chromium"
|
|
49
|
+
];
|
|
50
|
+
const getTargetBrowser = async () => {
|
|
51
|
+
let targetBrowser = process.env.BROWSER;
|
|
52
|
+
if (!targetBrowser || !supportedChromiumBrowsers.includes(targetBrowser)) {
|
|
53
|
+
const { stdout: ps } = await execAsync("ps cax");
|
|
54
|
+
targetBrowser = supportedChromiumBrowsers.find((b) => ps.includes(b));
|
|
55
|
+
}
|
|
56
|
+
return targetBrowser;
|
|
57
|
+
};
|
|
58
|
+
async function openBrowser(url) {
|
|
59
|
+
const shouldTryOpenChromeWithAppleScript = process.platform === "darwin";
|
|
60
|
+
if (shouldTryOpenChromeWithAppleScript) {
|
|
61
|
+
try {
|
|
62
|
+
const targetBrowser = await getTargetBrowser();
|
|
63
|
+
if (targetBrowser) {
|
|
64
|
+
await execAsync(
|
|
65
|
+
`osascript openChrome.applescript "${encodeURI(
|
|
66
|
+
url
|
|
67
|
+
)}" "${targetBrowser}"`,
|
|
68
|
+
{
|
|
69
|
+
cwd: (0, import_node_path.join)(__dirname, "../../../../static")
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
import_logger.logger.debug("Failed to find the target browser.");
|
|
75
|
+
} catch (err) {
|
|
76
|
+
import_logger.logger.debug("Failed to open Rsdoctor URL with apple script.");
|
|
77
|
+
import_logger.logger.debug(err);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
try {
|
|
81
|
+
await (0, import_open.default)(url);
|
|
82
|
+
return true;
|
|
83
|
+
} catch (err) {
|
|
84
|
+
import_logger.logger.error("Failed to open Rsdoctor URL.");
|
|
85
|
+
import_logger.logger.error(err);
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
90
|
+
0 && (module.exports = {
|
|
91
|
+
openBrowser
|
|
92
|
+
});
|
|
@@ -3,13 +3,14 @@ import { Server } from "@rsdoctor/utils/build";
|
|
|
3
3
|
import { Bundle } from "@rsdoctor/utils/common";
|
|
4
4
|
import assert from "assert";
|
|
5
5
|
import bodyParser from "body-parser";
|
|
6
|
-
import open from "open";
|
|
7
6
|
import ip from "ip";
|
|
8
7
|
import cors from "cors";
|
|
9
8
|
import { PassThrough } from "stream";
|
|
10
9
|
import { Socket } from "./socket";
|
|
11
10
|
import { Router } from "./router";
|
|
12
11
|
import * as APIs from "./apis";
|
|
12
|
+
import { chalk, logger } from "@rsdoctor/utils/logger";
|
|
13
|
+
import { openBrowser } from "../utils/openBrowser";
|
|
13
14
|
export * from "./utils";
|
|
14
15
|
class RsdoctorServer {
|
|
15
16
|
constructor(sdk, port = Server.defaultPort) {
|
|
@@ -43,12 +44,15 @@ class RsdoctorServer {
|
|
|
43
44
|
get app() {
|
|
44
45
|
return this._server.app;
|
|
45
46
|
}
|
|
46
|
-
get
|
|
47
|
+
get host() {
|
|
47
48
|
const host = ip.address();
|
|
48
|
-
return
|
|
49
|
+
return host;
|
|
50
|
+
}
|
|
51
|
+
get origin() {
|
|
52
|
+
return `http://${this.host}:${this.port}`;
|
|
49
53
|
}
|
|
50
54
|
get socketUrl() {
|
|
51
|
-
return `ws
|
|
55
|
+
return `ws://localhost:${this.port}`;
|
|
52
56
|
}
|
|
53
57
|
async bootstrap() {
|
|
54
58
|
if (!this.disposed) {
|
|
@@ -118,23 +122,28 @@ class RsdoctorServer {
|
|
|
118
122
|
});
|
|
119
123
|
}
|
|
120
124
|
getClientUrl(route = "homepage", ...args) {
|
|
121
|
-
const
|
|
125
|
+
const relativeUrl = SDK.ServerAPI.API.EntryHtml;
|
|
122
126
|
switch (route) {
|
|
123
127
|
case Client.RsdoctorClientRoutes.BundleDiff: {
|
|
124
128
|
const [baseline, current] = args;
|
|
125
129
|
const qs = Bundle.getBundleDiffPageQueryString([baseline, current]);
|
|
126
|
-
return `${
|
|
130
|
+
return `${relativeUrl}${qs}#${Client.RsdoctorClientRoutes.BundleDiff}`;
|
|
127
131
|
}
|
|
128
132
|
default:
|
|
129
|
-
return
|
|
133
|
+
return relativeUrl;
|
|
130
134
|
}
|
|
131
135
|
}
|
|
132
136
|
async openClientPage(...args) {
|
|
133
|
-
const
|
|
137
|
+
const relativeUrl = this.getClientUrl(
|
|
134
138
|
...args
|
|
135
139
|
);
|
|
136
|
-
|
|
137
|
-
|
|
140
|
+
const url = `http://${this.host}:${this.port}${relativeUrl}`;
|
|
141
|
+
const localhostUrl = `http://localhost:${this.port}${relativeUrl}`;
|
|
142
|
+
await openBrowser(url);
|
|
143
|
+
logger.info(`Rsdoctor analyze server running on: ${chalk.cyan(url)}`);
|
|
144
|
+
logger.info(
|
|
145
|
+
`Rsdoctor analyze server running on: ${chalk.cyan(localhostUrl)}`
|
|
146
|
+
);
|
|
138
147
|
}
|
|
139
148
|
sendAPIDataToClient(api, msg) {
|
|
140
149
|
this._socket?.sendAPIData(api, msg);
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { exec } from "node:child_process";
|
|
2
|
+
import { promisify } from "node:util";
|
|
3
|
+
import { logger } from "@rsdoctor/utils/logger";
|
|
4
|
+
import open from "open";
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
const execAsync = promisify(exec);
|
|
7
|
+
const supportedChromiumBrowsers = [
|
|
8
|
+
"Google Chrome Canary",
|
|
9
|
+
"Google Chrome Dev",
|
|
10
|
+
"Google Chrome Beta",
|
|
11
|
+
"Google Chrome",
|
|
12
|
+
"Microsoft Edge",
|
|
13
|
+
"Brave Browser",
|
|
14
|
+
"Vivaldi",
|
|
15
|
+
"Chromium"
|
|
16
|
+
];
|
|
17
|
+
const getTargetBrowser = async () => {
|
|
18
|
+
let targetBrowser = process.env.BROWSER;
|
|
19
|
+
if (!targetBrowser || !supportedChromiumBrowsers.includes(targetBrowser)) {
|
|
20
|
+
const { stdout: ps } = await execAsync("ps cax");
|
|
21
|
+
targetBrowser = supportedChromiumBrowsers.find((b) => ps.includes(b));
|
|
22
|
+
}
|
|
23
|
+
return targetBrowser;
|
|
24
|
+
};
|
|
25
|
+
async function openBrowser(url) {
|
|
26
|
+
const shouldTryOpenChromeWithAppleScript = process.platform === "darwin";
|
|
27
|
+
if (shouldTryOpenChromeWithAppleScript) {
|
|
28
|
+
try {
|
|
29
|
+
const targetBrowser = await getTargetBrowser();
|
|
30
|
+
if (targetBrowser) {
|
|
31
|
+
await execAsync(
|
|
32
|
+
`osascript openChrome.applescript "${encodeURI(
|
|
33
|
+
url
|
|
34
|
+
)}" "${targetBrowser}"`,
|
|
35
|
+
{
|
|
36
|
+
cwd: join(__dirname, "../../../../static")
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
logger.debug("Failed to find the target browser.");
|
|
42
|
+
} catch (err) {
|
|
43
|
+
logger.debug("Failed to open Rsdoctor URL with apple script.");
|
|
44
|
+
logger.debug(err);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
try {
|
|
48
|
+
await open(url);
|
|
49
|
+
return true;
|
|
50
|
+
} catch (err) {
|
|
51
|
+
logger.error("Failed to open Rsdoctor URL.");
|
|
52
|
+
logger.error(err);
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
export {
|
|
57
|
+
openBrowser
|
|
58
|
+
};
|
package/dist/type/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './sdk';
|
|
1
|
+
export * from './sdk';
|
package/dist/type/sdk/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from './sdk';
|
|
2
|
-
export * from './multiple';
|
|
2
|
+
export * from './multiple';
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
import { Manifest } from '@rsdoctor/types';
|
|
2
2
|
import { RsdoctorSlaveSDK } from './slave';
|
|
3
3
|
export declare class RsdoctorSDKController {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
stage,
|
|
14
|
-
extraConfig
|
|
15
|
-
}: Omit<ConstructorParameters<typeof RsdoctorSlaveSDK>[0], 'controller'>): RsdoctorSlaveSDK;
|
|
16
|
-
}
|
|
4
|
+
readonly slaves: RsdoctorSlaveSDK[];
|
|
5
|
+
root: string;
|
|
6
|
+
constructor(root?: string);
|
|
7
|
+
get master(): RsdoctorSlaveSDK;
|
|
8
|
+
getLastSdk(): RsdoctorSlaveSDK;
|
|
9
|
+
hasName(name: string): boolean;
|
|
10
|
+
getSeriesData(serverUrl?: boolean): Manifest.RsdoctorManifestSeriesData[];
|
|
11
|
+
createSlave({ name, stage, extraConfig, }: Omit<ConstructorParameters<typeof RsdoctorSlaveSDK>[0], 'controller'>): RsdoctorSlaveSDK;
|
|
12
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from './controller';
|
|
2
|
-
export * from './slave';
|
|
2
|
+
export * from './slave';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RsdoctorServer } from '../server';
|
|
2
2
|
import type { RsdoctorSlaveSDK } from './slave';
|
|
3
3
|
export declare class RsdoctorSlaveServer extends RsdoctorServer {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
4
|
+
protected sdk: RsdoctorSlaveSDK;
|
|
5
|
+
constructor(sdk: RsdoctorSlaveSDK, port?: number);
|
|
6
|
+
openClientPage(...args: unknown[]): Promise<void>;
|
|
7
|
+
}
|
|
@@ -2,34 +2,29 @@ import { SDK } from '@rsdoctor/types';
|
|
|
2
2
|
import { RsdoctorWebpackSDK } from '../sdk';
|
|
3
3
|
import type { RsdoctorSDKController } from './controller';
|
|
4
4
|
interface RsdoctorSlaveSDKOptions {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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: RsdoctorSDKController;
|
|
14
14
|
}
|
|
15
15
|
export declare class RsdoctorSlaveSDK extends RsdoctorWebpackSDK {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
protected writePieces(): Promise<void>;
|
|
30
|
-
protected writeManifest(): Promise<string>;
|
|
31
|
-
getSeriesData(serverUrl?: boolean): import("@rsdoctor/types/dist/manifest").RsdoctorManifestSeriesData[];
|
|
32
|
-
setName(name: string): void;
|
|
33
|
-
getManifestData(): import("@rsdoctor/types/dist/manifest").RsdoctorManifestWithShardingFiles;
|
|
16
|
+
id: number;
|
|
17
|
+
readonly stage: number;
|
|
18
|
+
private parent;
|
|
19
|
+
private uploadPieces;
|
|
20
|
+
private finishUploadPieceSwitch;
|
|
21
|
+
constructor({ name, stage, controller, extraConfig }: RsdoctorSlaveSDKOptions);
|
|
22
|
+
private clearSwitch;
|
|
23
|
+
get isMaster(): boolean;
|
|
24
|
+
protected writePieces(): Promise<void>;
|
|
25
|
+
protected writeManifest(): Promise<string>;
|
|
26
|
+
getSeriesData(serverUrl?: boolean): import("@rsdoctor/types/dist/manifest").RsdoctorManifestSeriesData[];
|
|
27
|
+
setName(name: string): void;
|
|
28
|
+
getManifestData(): import("@rsdoctor/types/dist/manifest").RsdoctorManifestWithShardingFiles;
|
|
34
29
|
}
|
|
35
|
-
export {};
|
|
30
|
+
export {};
|
|
@@ -1,35 +1,32 @@
|
|
|
1
1
|
import { Common, Manifest, SDK } from '@rsdoctor/types';
|
|
2
2
|
import { RsdoctorSDKOptions, DataWithUrl } from './types';
|
|
3
3
|
export declare abstract class SDKCore<T extends RsdoctorSDKOptions> implements SDK.RsdoctorSDKInstance {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
protected writeToFolder(jsonstr: string, dir: string, key: string): Promise<DataWithUrl>;
|
|
34
|
-
abstract onDataReport(): void | Promise<void>;
|
|
35
|
-
}
|
|
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.RsdoctorManifestWithShardingFiles;
|
|
15
|
+
constructor({ name, root }: T);
|
|
16
|
+
get outputDir(): string;
|
|
17
|
+
get name(): string;
|
|
18
|
+
bootstrap(): Promise<void>;
|
|
19
|
+
dispose(): Promise<void>;
|
|
20
|
+
setOutputDir(outputDir: string): void;
|
|
21
|
+
setName(name: string): void;
|
|
22
|
+
setHash(hash: string): void;
|
|
23
|
+
getClientRoutes(): Manifest.RsdoctorManifestClientRoutes[];
|
|
24
|
+
addClientRoutes(routes: Manifest.RsdoctorManifestClientRoutes[]): void;
|
|
25
|
+
/** Upload analysis data pieces */
|
|
26
|
+
protected writePieces(storeData: Common.PlainObject, _options?: SDK.WriteStoreOptionsType): Promise<void>;
|
|
27
|
+
/** Upload manifest file */
|
|
28
|
+
protected writeManifest(): Promise<string>;
|
|
29
|
+
saveManifest(data: Common.PlainObject, options: SDK.WriteStoreOptionsType): Promise<string>;
|
|
30
|
+
protected writeToFolder(jsonstr: string, dir: string, key: string): Promise<DataWithUrl>;
|
|
31
|
+
abstract onDataReport(): void | Promise<void>;
|
|
32
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from './webpack';
|
|
2
|
-
export { RsdoctorWebpackSDK as RsdoctorSDK } from './webpack';
|
|
2
|
+
export { RsdoctorWebpackSDK as RsdoctorSDK } from './webpack';
|
|
@@ -1,28 +1,30 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { SDK } from '@rsdoctor/types';
|
|
3
3
|
export interface DataWithUrl {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
name: string;
|
|
5
|
+
files: {
|
|
6
|
+
path: string;
|
|
7
|
+
basename: string;
|
|
8
|
+
content: Buffer;
|
|
9
|
+
}[] | string;
|
|
10
10
|
}
|
|
11
11
|
export interface RsdoctorSDKOptions {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
name: string;
|
|
13
|
+
root: string;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* sdk options for builder.
|
|
17
17
|
*/
|
|
18
18
|
export interface RsdoctorBuilderSDK extends RsdoctorSDKOptions {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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 RsdoctorWebpackSDKOptions extends RsdoctorBuilderSDK {
|
|
28
|
+
}
|
|
29
|
+
export interface RsdoctorEMOSDKOptions extends RsdoctorSDKOptions {
|
|
26
30
|
}
|
|
27
|
-
export interface RsdoctorWebpackSDKOptions extends RsdoctorBuilderSDK {}
|
|
28
|
-
export interface RsdoctorEMOSDKOptions extends RsdoctorSDKOptions {}
|
|
@@ -6,45 +6,45 @@ import { RsdoctorWebpackSDKOptions } from './types';
|
|
|
6
6
|
import { SDKCore } from './core';
|
|
7
7
|
import { ResourceLoaderData } from '@rsdoctor/types/dist/sdk';
|
|
8
8
|
export declare class RsdoctorWebpackSDK<T extends RsdoctorWebpackSDKOptions = RsdoctorWebpackSDKOptions> extends SDKCore<T> implements SDK.RsdoctorBuilderSDKInstance {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
9
|
+
server: RsdoctorServer;
|
|
10
|
+
extraConfig: SDK.SDKOptionsType | undefined;
|
|
11
|
+
private type;
|
|
12
|
+
private _summary;
|
|
13
|
+
private _configs;
|
|
14
|
+
private _errors;
|
|
15
|
+
private _loader;
|
|
16
|
+
private _loaderStart;
|
|
17
|
+
private _resolver;
|
|
18
|
+
private _plugin;
|
|
19
|
+
private _moduleGraph;
|
|
20
|
+
private _chunkGraph;
|
|
21
|
+
private _rawSourceMapCache;
|
|
22
|
+
private _sourceMap;
|
|
23
|
+
private _packageGraph;
|
|
24
|
+
private _tileReportHtml;
|
|
25
|
+
constructor(options: T);
|
|
26
|
+
bootstrap(): Promise<void>;
|
|
27
|
+
dispose(): Promise<void>;
|
|
28
|
+
applyErrorFix(id: number): Promise<void>;
|
|
29
|
+
clear(): void;
|
|
30
|
+
clearSourceMapCache(): void;
|
|
31
|
+
getSourceMap(file: string): Promise<SourceMapConsumer | undefined>;
|
|
32
|
+
reportSourceMap(data: RawSourceMap): void;
|
|
33
|
+
reportConfiguration(config: SDK.ConfigData[0]): void;
|
|
34
|
+
reportError(errors: Error[]): void;
|
|
35
|
+
reportLoader(data: SDK.LoaderData): void;
|
|
36
|
+
reportLoaderStartOrEnd(data: ResourceLoaderData): void;
|
|
37
|
+
reportResolver(data: SDK.ResolverData): void;
|
|
38
|
+
reportPlugin(data: SDK.PluginData): void;
|
|
39
|
+
reportModuleGraph(data: ModuleGraph): void;
|
|
40
|
+
reportPackageGraph(data: PackageGraph): void;
|
|
41
|
+
reportChunkGraph(data: ChunkGraph): void;
|
|
42
|
+
reportSummaryData(part: Partial<SDK.SummaryData>): void;
|
|
43
|
+
reportTileHtml(tileReportHtml: string): void;
|
|
44
|
+
createPackageGraph(): void;
|
|
45
|
+
writeStore(options?: SDK.WriteStoreOptionsType): Promise<string>;
|
|
46
|
+
getStoreData(): SDK.BuilderStoreData;
|
|
47
|
+
getManifestData(): Manifest.RsdoctorManifestWithShardingFiles;
|
|
48
|
+
getRuleContext(_options: SDK.RuntimeContextOptions): SDK.RuntimeContext;
|
|
49
|
+
onDataReport(): void | Promise<void>;
|
|
50
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SDK } from '@rsdoctor/types';
|
|
2
2
|
import { BaseAPI } from './base';
|
|
3
3
|
export declare class AlertsAPI extends BaseAPI {
|
|
4
|
-
|
|
5
|
-
}
|
|
4
|
+
getPackageRelationAlertDetails(): Promise<SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetPackageRelationAlertDetails>>;
|
|
5
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Data } from '@rsdoctor/utils/common';
|
|
2
2
|
import { Manifest, SDK } from '@rsdoctor/types';
|
|
3
3
|
export declare class BaseAPI implements Manifest.ManifestDataLoader {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
4
|
+
[key: string | symbol]: any;
|
|
5
|
+
readonly ctx: SDK.ServerAPI.APIContext;
|
|
6
|
+
protected dataLoader: Data.APIDataLoader;
|
|
7
|
+
constructor(sdk: SDK.RsdoctorSDKInstance, server: SDK.RsdoctorServerInstance);
|
|
8
|
+
loadManifest(): Promise<Manifest.RsdoctorManifestWithShardingFiles>;
|
|
9
|
+
loadData<T extends Manifest.RsdoctorManifestMappingKeys>(key: T): Promise<Manifest.InferManifestDataValue<T>>;
|
|
10
|
+
loadData(key: string): Promise<void>;
|
|
11
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SDK } from '@rsdoctor/types';
|
|
2
2
|
import { BaseAPI } from './base';
|
|
3
3
|
export declare class BundleDiffAPI extends BaseAPI {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
4
|
+
getBundleDiffSummary(): Promise<SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetBundleDiffSummary>>;
|
|
5
|
+
bundleDiffManifest(): Promise<SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.BundleDiffManifest>>;
|
|
6
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SDK } from '@rsdoctor/types';
|
|
2
2
|
import { BaseAPI } from './base';
|
|
3
3
|
export declare class DataAPI extends BaseAPI {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
4
|
+
loadDataByKey(): Promise<SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.LoadDataByKey>>;
|
|
5
|
+
sendMessageToClient(): Promise<SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.SendAPIDataToClient>>;
|
|
6
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SDK } from '@rsdoctor/types';
|
|
2
2
|
import { BaseAPI } from './base';
|
|
3
3
|
export declare class FileSystemAPI extends BaseAPI {
|
|
4
|
-
|
|
5
|
-
}
|
|
4
|
+
applyErrorFix(): Promise<SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.ApplyErrorFix>>;
|
|
5
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { SDK } from '@rsdoctor/types';
|
|
2
2
|
import { BaseAPI } from './base';
|
|
3
3
|
export declare class GraphAPI extends BaseAPI {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
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
|
+
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { SDK } from '@rsdoctor/types';
|
|
2
2
|
import { BaseAPI } from './base';
|
|
3
3
|
export declare class LoaderAPI extends BaseAPI {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
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
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SDK } from '@rsdoctor/types';
|
|
2
2
|
import { BaseAPI } from './base';
|
|
3
3
|
export declare class PluginAPI extends BaseAPI {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
4
|
+
getPluginSummary(): Promise<SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetPluginSummary>>;
|
|
5
|
+
getPluginData(): Promise<SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetPluginData>>;
|
|
6
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { SDK } from '@rsdoctor/types';
|
|
2
2
|
import { BaseAPI } from './base';
|
|
3
3
|
export declare class ProjectAPI extends BaseAPI {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
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
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SDK } from '@rsdoctor/types';
|
|
2
2
|
import { BaseAPI } from './base';
|
|
3
3
|
export declare class RendererAPI extends BaseAPI {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
4
|
+
private isClientServed;
|
|
5
|
+
/** sdk manifest api */
|
|
6
|
+
entryHtml(): Promise<SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.EntryHtml>>;
|
|
7
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SDK } from '@rsdoctor/types';
|
|
2
2
|
import { BaseAPI } from './base';
|
|
3
3
|
export declare class ResolverAPI extends BaseAPI {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
4
|
+
getResolverFileTree(): Promise<SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetResolverFileTree>>;
|
|
5
|
+
getResolverFileDetails(): Promise<SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetResolverFileDetails>>;
|
|
6
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SDK } from '@rsdoctor/types';
|
|
2
2
|
import { RsdoctorServer } from '.';
|
|
3
3
|
export declare class RsdoctorFakeServer extends RsdoctorServer {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
4
|
+
protected sdk: SDK.RsdoctorBuilderSDKInstance;
|
|
5
|
+
constructor(sdk: SDK.RsdoctorBuilderSDKInstance, port?: number);
|
|
6
|
+
openClientPage(): Promise<void>;
|
|
7
|
+
}
|
|
@@ -2,26 +2,27 @@
|
|
|
2
2
|
import { Common, SDK, Thirdparty, Client } from '@rsdoctor/types';
|
|
3
3
|
export * from './utils';
|
|
4
4
|
export declare class RsdoctorServer implements SDK.RsdoctorServerInstance {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
5
|
+
protected sdk: SDK.RsdoctorBuilderSDKInstance;
|
|
6
|
+
private _server;
|
|
7
|
+
port: number;
|
|
8
|
+
private _socket?;
|
|
9
|
+
private disposed;
|
|
10
|
+
private _router;
|
|
11
|
+
constructor(sdk: SDK.RsdoctorBuilderSDKInstance, port?: number);
|
|
12
|
+
get app(): SDK.RsdoctorServerInstance['app'];
|
|
13
|
+
get host(): string;
|
|
14
|
+
get origin(): string;
|
|
15
|
+
get socketUrl(): string;
|
|
16
|
+
bootstrap(): Promise<void>;
|
|
17
|
+
protected wrapNextHandleFunction(method: 'GET' | 'POST', cb: (...args: Parameters<Thirdparty.connect.NextHandleFunction>) => Common.PlainObject | string): Thirdparty.connect.NextHandleFunction;
|
|
18
|
+
proxy(api: SDK.ServerAPI.API, method: 'GET' | 'POST', cb: (...args: Parameters<Thirdparty.connect.NextHandleFunction>) => Common.PlainObject | string): void;
|
|
19
|
+
get: SDK.RsdoctorServerInstance['get'];
|
|
20
|
+
post: SDK.RsdoctorServerInstance['post'];
|
|
21
|
+
getClientUrl(route: Client.RsdoctorClientRoutes, baselineUrl: string, currentUrl: string): string;
|
|
22
|
+
getClientUrl(route?: 'homepage'): string;
|
|
23
|
+
openClientPage(route: Client.RsdoctorClientRoutes, baselineUrl: string, currentUrl: string): Promise<void>;
|
|
24
|
+
openClientPage(route?: 'homepage'): Promise<void>;
|
|
25
|
+
sendAPIDataToClient<T extends SDK.ServerAPI.API | SDK.ServerAPI.APIExtends>(api: T, msg: SDK.ServerAPI.SocketResponseType<T>): void;
|
|
26
|
+
broadcast(): Promise<void>;
|
|
27
|
+
dispose: () => Promise<void>;
|
|
28
|
+
}
|
|
@@ -3,23 +3,23 @@ import type { ServerResponse } from 'http';
|
|
|
3
3
|
import { Common, SDK, Thirdparty } from '@rsdoctor/types';
|
|
4
4
|
import { BaseAPI } from './apis/base';
|
|
5
5
|
interface RouterOptions {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
apis: Common.Constructor<typeof BaseAPI>[];
|
|
7
|
+
sdk: SDK.RsdoctorBuilderSDKInstance;
|
|
8
|
+
server: SDK.RsdoctorServerInstance;
|
|
9
9
|
}
|
|
10
10
|
export declare class Router {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
24
|
}
|
|
25
|
-
export {};
|
|
25
|
+
export {};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { Data } from '@rsdoctor/utils/common';
|
|
2
2
|
import { Manifest, SDK } from '@rsdoctor/types';
|
|
3
3
|
interface SocketAPILoaderOptions {
|
|
4
|
-
|
|
4
|
+
sdk: SDK.RsdoctorBuilderSDKInstance;
|
|
5
5
|
}
|
|
6
6
|
export declare class SocketAPILoader implements Manifest.ManifestDataLoader {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
protected options: SocketAPILoaderOptions;
|
|
8
|
+
protected dataLoader: Data.APIDataLoader;
|
|
9
|
+
constructor(options: SocketAPILoaderOptions);
|
|
10
|
+
loadManifest(): Promise<Manifest.RsdoctorManifestWithShardingFiles>;
|
|
11
|
+
loadData<T extends Manifest.RsdoctorManifestMappingKeys>(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
14
|
}
|
|
15
|
-
export {};
|
|
15
|
+
export {};
|
|
@@ -5,24 +5,24 @@ import type { Server } from 'http';
|
|
|
5
5
|
import { Server as SocketServer, ServerOptions as SocketServerOptions, Socket as SocketType } from 'socket.io';
|
|
6
6
|
import { SocketAPILoader } from './api';
|
|
7
7
|
interface SocketOptions {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
sdk: SDK.RsdoctorBuilderSDKInstance;
|
|
9
|
+
server: Server;
|
|
10
|
+
port: number;
|
|
11
|
+
socketOptions?: SocketServerOptions;
|
|
12
12
|
}
|
|
13
13
|
export declare class Socket {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
27
|
}
|
|
28
|
-
export {};
|
|
28
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SDK } from '@rsdoctor/types';
|
|
2
2
|
export declare function getDataByPagination<T>(data: T[], pagination: SDK.ServerAPI.PaginationRequest): {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
};
|
|
3
|
+
data: T[];
|
|
4
|
+
pagination: SDK.ServerAPI.PaginationResponse;
|
|
5
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const CLOUD_DIR: string;
|
|
1
|
+
export declare const CLOUD_DIR: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from './constant';
|
|
2
|
-
export * from './upload';
|
|
2
|
+
export * from './upload';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { DataWithUrl } from '../sdk/types';
|
|
2
|
-
export declare const transformDataUrls: (d: DataWithUrl[]) => Record<string, string[] | string>;
|
|
2
|
+
export declare const transformDataUrls: (d: DataWithUrl[]) => Record<string, string[] | string>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsdoctor/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/web-infra-dev/rsdoctor",
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
"module": "dist/esm/index.js",
|
|
12
12
|
"types": "dist/type/index.d.ts",
|
|
13
13
|
"files": [
|
|
14
|
-
"dist"
|
|
14
|
+
"dist",
|
|
15
|
+
"static"
|
|
15
16
|
],
|
|
16
17
|
"dependencies": {
|
|
17
18
|
"body-parser": "1.20.1",
|
|
@@ -24,10 +25,10 @@
|
|
|
24
25
|
"socket.io": "4.7.2",
|
|
25
26
|
"source-map": "^0.7.4",
|
|
26
27
|
"tapable": "2.2.1",
|
|
27
|
-
"@rsdoctor/client": "0.1.
|
|
28
|
-
"@rsdoctor/graph": "0.1.
|
|
29
|
-
"@rsdoctor/
|
|
30
|
-
"@rsdoctor/
|
|
28
|
+
"@rsdoctor/client": "0.1.2",
|
|
29
|
+
"@rsdoctor/graph": "0.1.2",
|
|
30
|
+
"@rsdoctor/types": "0.1.2",
|
|
31
|
+
"@rsdoctor/utils": "0.1.2"
|
|
31
32
|
},
|
|
32
33
|
"devDependencies": {
|
|
33
34
|
"@types/body-parser": "1.19.2",
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
(*
|
|
2
|
+
Copyright (c) 2015-present, Facebook, Inc.
|
|
3
|
+
|
|
4
|
+
This source code is licensed under the MIT license found in the
|
|
5
|
+
LICENSE file at
|
|
6
|
+
https://github.com/facebookincubator/create-react-app/blob/master/LICENSE
|
|
7
|
+
*)
|
|
8
|
+
|
|
9
|
+
property targetTab: null
|
|
10
|
+
property targetTabIndex: -1
|
|
11
|
+
property targetWindow: null
|
|
12
|
+
property theProgram: "Google Chrome"
|
|
13
|
+
|
|
14
|
+
on run argv
|
|
15
|
+
set theURL to item 1 of argv
|
|
16
|
+
|
|
17
|
+
-- Allow requested program to be optional,
|
|
18
|
+
-- default to Google Chrome
|
|
19
|
+
if (count of argv) > 1 then
|
|
20
|
+
set theProgram to item 2 of argv
|
|
21
|
+
end if
|
|
22
|
+
|
|
23
|
+
using terms from application "Google Chrome"
|
|
24
|
+
tell application theProgram
|
|
25
|
+
|
|
26
|
+
if (count every window) = 0 then
|
|
27
|
+
make new window
|
|
28
|
+
end if
|
|
29
|
+
|
|
30
|
+
-- 1: Looking for tab running debugger
|
|
31
|
+
-- then, Reload debugging tab if found
|
|
32
|
+
-- then return
|
|
33
|
+
set found to my lookupTabWithUrl(theURL)
|
|
34
|
+
if found then
|
|
35
|
+
set targetWindow's active tab index to targetTabIndex
|
|
36
|
+
tell targetTab to reload
|
|
37
|
+
tell targetWindow to activate
|
|
38
|
+
set index of targetWindow to 1
|
|
39
|
+
return
|
|
40
|
+
end if
|
|
41
|
+
|
|
42
|
+
-- 2: Looking for Empty tab
|
|
43
|
+
-- In case debugging tab was not found
|
|
44
|
+
-- We try to find an empty tab instead
|
|
45
|
+
set found to my lookupTabWithUrl("chrome://newtab/")
|
|
46
|
+
if found then
|
|
47
|
+
set targetWindow's active tab index to targetTabIndex
|
|
48
|
+
set URL of targetTab to theURL
|
|
49
|
+
tell targetWindow to activate
|
|
50
|
+
return
|
|
51
|
+
end if
|
|
52
|
+
|
|
53
|
+
-- 3: Create new tab
|
|
54
|
+
-- both debugging and empty tab were not found
|
|
55
|
+
-- make a new tab with url
|
|
56
|
+
tell window 1
|
|
57
|
+
activate
|
|
58
|
+
make new tab with properties {URL:theURL}
|
|
59
|
+
end tell
|
|
60
|
+
end tell
|
|
61
|
+
end using terms from
|
|
62
|
+
end run
|
|
63
|
+
|
|
64
|
+
-- Function:
|
|
65
|
+
-- Lookup tab with given url
|
|
66
|
+
-- if found, store tab, index, and window in properties
|
|
67
|
+
-- (properties were declared on top of file)
|
|
68
|
+
on lookupTabWithUrl(lookupUrl)
|
|
69
|
+
using terms from application "Google Chrome"
|
|
70
|
+
tell application theProgram
|
|
71
|
+
-- Find a tab with the given url
|
|
72
|
+
set found to false
|
|
73
|
+
set theTabIndex to -1
|
|
74
|
+
repeat with theWindow in every window
|
|
75
|
+
set theTabIndex to 0
|
|
76
|
+
repeat with theTab in every tab of theWindow
|
|
77
|
+
set theTabIndex to theTabIndex + 1
|
|
78
|
+
if (theTab's URL as string) contains lookupUrl then
|
|
79
|
+
-- assign tab, tab index, and window to properties
|
|
80
|
+
set targetTab to theTab
|
|
81
|
+
set targetTabIndex to theTabIndex
|
|
82
|
+
set targetWindow to theWindow
|
|
83
|
+
set found to true
|
|
84
|
+
exit repeat
|
|
85
|
+
end if
|
|
86
|
+
end repeat
|
|
87
|
+
|
|
88
|
+
if found then
|
|
89
|
+
exit repeat
|
|
90
|
+
end if
|
|
91
|
+
end repeat
|
|
92
|
+
end tell
|
|
93
|
+
end using terms from
|
|
94
|
+
return found
|
|
95
|
+
end lookupTabWithUrl
|