@rsdoctor/sdk 1.5.12 → 2.0.0-alpha.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/dist/index.cjs +151 -35
- package/dist/index.js +150 -35
- package/dist/sdk/sdk/index.d.cts +2 -2
- package/dist/sdk/sdk/index.d.ts +2 -2
- package/dist/sdk/sdk/types.d.cts +1 -1
- package/dist/sdk/sdk/types.d.ts +1 -1
- package/dist/sdk/server/apis/index.d.cts +1 -0
- package/dist/sdk/server/apis/index.d.ts +1 -0
- package/dist/sdk/server/socket/index.d.cts +28 -7
- package/dist/sdk/server/socket/index.d.ts +28 -7
- package/package.json +7 -6
package/dist/index.cjs
CHANGED
|
@@ -921,7 +921,7 @@ var __webpack_modules__ = {
|
|
|
921
921
|
"use strict";
|
|
922
922
|
module.exports = URIError;
|
|
923
923
|
},
|
|
924
|
-
"../../node_modules/.pnpm/es-object-atoms@1.1.
|
|
924
|
+
"../../node_modules/.pnpm/es-object-atoms@1.1.2/node_modules/es-object-atoms/index.js" (module) {
|
|
925
925
|
"use strict";
|
|
926
926
|
module.exports = Object;
|
|
927
927
|
},
|
|
@@ -962,7 +962,7 @@ var __webpack_modules__ = {
|
|
|
962
962
|
},
|
|
963
963
|
"../../node_modules/.pnpm/get-intrinsic@1.3.0/node_modules/get-intrinsic/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
964
964
|
"use strict";
|
|
965
|
-
var undefined, $Object = __webpack_require__("../../node_modules/.pnpm/es-object-atoms@1.1.
|
|
965
|
+
var undefined, $Object = __webpack_require__("../../node_modules/.pnpm/es-object-atoms@1.1.2/node_modules/es-object-atoms/index.js"), $Error = __webpack_require__("../../node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/index.js"), $EvalError = __webpack_require__("../../node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/eval.js"), $RangeError = __webpack_require__("../../node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/range.js"), $ReferenceError = __webpack_require__("../../node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/ref.js"), $SyntaxError = __webpack_require__("../../node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/syntax.js"), $TypeError = __webpack_require__("../../node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/type.js"), $URIError = __webpack_require__("../../node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/uri.js"), abs = __webpack_require__("../../node_modules/.pnpm/math-intrinsics@1.1.0/node_modules/math-intrinsics/abs.js"), floor = __webpack_require__("../../node_modules/.pnpm/math-intrinsics@1.1.0/node_modules/math-intrinsics/floor.js"), max = __webpack_require__("../../node_modules/.pnpm/math-intrinsics@1.1.0/node_modules/math-intrinsics/max.js"), min = __webpack_require__("../../node_modules/.pnpm/math-intrinsics@1.1.0/node_modules/math-intrinsics/min.js"), pow = __webpack_require__("../../node_modules/.pnpm/math-intrinsics@1.1.0/node_modules/math-intrinsics/pow.js"), round = __webpack_require__("../../node_modules/.pnpm/math-intrinsics@1.1.0/node_modules/math-intrinsics/round.js"), sign = __webpack_require__("../../node_modules/.pnpm/math-intrinsics@1.1.0/node_modules/math-intrinsics/sign.js"), $Function = Function, getEvalledConstructor = function(expressionSyntax) {
|
|
966
966
|
try {
|
|
967
967
|
return $Function('"use strict"; return (' + expressionSyntax + ').constructor;')();
|
|
968
968
|
} catch (e) {}
|
|
@@ -1346,7 +1346,7 @@ var __webpack_modules__ = {
|
|
|
1346
1346
|
},
|
|
1347
1347
|
"../../node_modules/.pnpm/get-proto@1.0.1/node_modules/get-proto/Object.getPrototypeOf.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
1348
1348
|
"use strict";
|
|
1349
|
-
module.exports = __webpack_require__("../../node_modules/.pnpm/es-object-atoms@1.1.
|
|
1349
|
+
module.exports = __webpack_require__("../../node_modules/.pnpm/es-object-atoms@1.1.2/node_modules/es-object-atoms/index.js").getPrototypeOf || null;
|
|
1350
1350
|
},
|
|
1351
1351
|
"../../node_modules/.pnpm/get-proto@1.0.1/node_modules/get-proto/Reflect.getPrototypeOf.js" (module) {
|
|
1352
1352
|
"use strict";
|
|
@@ -5183,6 +5183,7 @@ var __webpack_modules__ = {
|
|
|
5183
5183
|
var apis_namespaceObject = {};
|
|
5184
5184
|
__webpack_require__.r(apis_namespaceObject), __webpack_require__.d(apis_namespaceObject, {
|
|
5185
5185
|
AlertsAPI: ()=>AlertsAPI,
|
|
5186
|
+
BundleDiffAPI: ()=>BundleDiffAPI,
|
|
5186
5187
|
DataAPI: ()=>DataAPI,
|
|
5187
5188
|
FileSystemAPI: ()=>FileSystemAPI,
|
|
5188
5189
|
GraphAPI: ()=>GraphAPI,
|
|
@@ -5678,8 +5679,8 @@ var __webpack_modules__ = {
|
|
|
5678
5679
|
var external_assert_default = __webpack_require__.n(external_assert_namespaceObject), body_parser = __webpack_require__("../../node_modules/.pnpm/body-parser@2.2.2/node_modules/body-parser/index.js"), body_parser_default = __webpack_require__.n(body_parser);
|
|
5679
5680
|
let cors_index_js_namespaceObject = require("../compiled/cors/index.js");
|
|
5680
5681
|
var cors_index_js_default = __webpack_require__.n(cors_index_js_namespaceObject), external_stream_ = __webpack_require__("stream");
|
|
5681
|
-
let
|
|
5682
|
-
var
|
|
5682
|
+
let external_ws_namespaceObject = require("ws");
|
|
5683
|
+
var external_ws_default = __webpack_require__.n(external_ws_namespaceObject);
|
|
5683
5684
|
class SocketAPILoader {
|
|
5684
5685
|
constructor(options){
|
|
5685
5686
|
this.options = options, this.dataLoader = new common_namespaceObject.Data.APIDataLoader(this);
|
|
@@ -5697,31 +5698,99 @@ var __webpack_modules__ = {
|
|
|
5697
5698
|
}
|
|
5698
5699
|
class Socket {
|
|
5699
5700
|
constructor(options){
|
|
5700
|
-
this.options = options, this.map = new Map(), this.loader = new SocketAPILoader({
|
|
5701
|
+
this.options = options, this.clients = new Set(), this.map = new Map(), this.clientSubscriptions = new Map(), this.loader = new SocketAPILoader({
|
|
5701
5702
|
sdk: options.sdk
|
|
5702
5703
|
});
|
|
5703
5704
|
}
|
|
5704
5705
|
bootstrap() {
|
|
5705
|
-
this.
|
|
5706
|
-
|
|
5707
|
-
|
|
5708
|
-
|
|
5709
|
-
...this.options.socketOptions
|
|
5710
|
-
}), this.io.on('connection', (socket)=>{
|
|
5711
|
-
this.setupSocket(socket);
|
|
5706
|
+
this.server = new external_ws_namespaceObject.WebSocketServer({
|
|
5707
|
+
server: this.options.server
|
|
5708
|
+
}), this.server.on('connection', (client)=>{
|
|
5709
|
+
this.attachClient(client);
|
|
5712
5710
|
});
|
|
5713
5711
|
}
|
|
5714
|
-
|
|
5715
|
-
|
|
5716
|
-
|
|
5717
|
-
|
|
5718
|
-
|
|
5712
|
+
attachClient(client) {
|
|
5713
|
+
this.clients.add(client), 'function' == typeof client.on && (client.on('message', (message)=>{
|
|
5714
|
+
this.handleClientMessage(message.toString(), client);
|
|
5715
|
+
}), client.on('close', ()=>{
|
|
5716
|
+
this.clients.delete(client), this.removeClientSubscriptions(client);
|
|
5717
|
+
}));
|
|
5718
|
+
}
|
|
5719
|
+
async handleClientMessage(raw, client) {
|
|
5720
|
+
let message;
|
|
5721
|
+
try {
|
|
5722
|
+
message = JSON.parse(raw);
|
|
5723
|
+
} catch {
|
|
5724
|
+
return;
|
|
5725
|
+
}
|
|
5726
|
+
if (message.api && Object.values(types_namespaceObject.SDK.ServerAPI.API).includes(message.api)) {
|
|
5727
|
+
if ('request' === message.type) return void await this.handleAPIRequestMessage(message, client);
|
|
5728
|
+
if ('subscribe' === message.type) return void this.saveRequestToMap(message.api, message.body ?? null, client);
|
|
5729
|
+
'unsubscribe' === message.type && this.removeRequestFromMap(message.api, message.body ?? null, client);
|
|
5730
|
+
}
|
|
5731
|
+
}
|
|
5732
|
+
async handleAPIRequestMessage(message, client) {
|
|
5733
|
+
if (message.id && client && client.readyState === external_ws_default().OPEN) try {
|
|
5734
|
+
let response = await this.getAPIResponse(message.api, message.body);
|
|
5735
|
+
client.send(JSON.stringify({
|
|
5736
|
+
type: 'response',
|
|
5737
|
+
id: message.id,
|
|
5738
|
+
payload: response.res
|
|
5739
|
+
}));
|
|
5740
|
+
} catch (err) {
|
|
5741
|
+
client.send(JSON.stringify({
|
|
5742
|
+
type: 'response',
|
|
5743
|
+
id: message.id,
|
|
5744
|
+
error: err instanceof Error ? err.message : String(err)
|
|
5745
|
+
}));
|
|
5746
|
+
}
|
|
5747
|
+
}
|
|
5748
|
+
getSubscriptions() {
|
|
5749
|
+
return [
|
|
5750
|
+
...this.map.values()
|
|
5751
|
+
].map(({ api, body })=>({
|
|
5752
|
+
api,
|
|
5753
|
+
body
|
|
5754
|
+
}));
|
|
5755
|
+
}
|
|
5756
|
+
saveRequestToMap(api, body = null, client) {
|
|
5757
|
+
let key = this.getSubscriptionKey(api, body);
|
|
5758
|
+
if (client) {
|
|
5759
|
+
this.clientSubscriptions.has(client) || this.clientSubscriptions.set(client, new Set());
|
|
5760
|
+
let subscriptions = this.clientSubscriptions.get(client);
|
|
5761
|
+
if (subscriptions.has(key)) return;
|
|
5762
|
+
subscriptions.add(key);
|
|
5763
|
+
}
|
|
5764
|
+
let record = this.map.get(key);
|
|
5765
|
+
if (record) {
|
|
5766
|
+
record.count += 1;
|
|
5767
|
+
return;
|
|
5768
|
+
}
|
|
5769
|
+
this.map.set(key, {
|
|
5770
|
+
api,
|
|
5771
|
+
body,
|
|
5772
|
+
count: 1
|
|
5719
5773
|
});
|
|
5720
5774
|
}
|
|
5721
|
-
|
|
5722
|
-
|
|
5723
|
-
|
|
5724
|
-
|
|
5775
|
+
removeRequestFromMap(api, body = null, client) {
|
|
5776
|
+
let key = this.getSubscriptionKey(api, body);
|
|
5777
|
+
if (client) {
|
|
5778
|
+
let subscriptions = this.clientSubscriptions.get(client);
|
|
5779
|
+
if (!subscriptions?.has(key)) return;
|
|
5780
|
+
subscriptions.delete(key), 0 === subscriptions.size && this.clientSubscriptions.delete(client);
|
|
5781
|
+
}
|
|
5782
|
+
this.removeSubscriptionKey(key);
|
|
5783
|
+
}
|
|
5784
|
+
removeClientSubscriptions(client) {
|
|
5785
|
+
let subscriptions = this.clientSubscriptions.get(client);
|
|
5786
|
+
subscriptions && (subscriptions.forEach((key)=>this.removeSubscriptionKey(key)), this.clientSubscriptions.delete(client));
|
|
5787
|
+
}
|
|
5788
|
+
removeSubscriptionKey(key) {
|
|
5789
|
+
let record = this.map.get(key);
|
|
5790
|
+
record && (record.count -= 1, record.count <= 0 && this.map.delete(key));
|
|
5791
|
+
}
|
|
5792
|
+
getSubscriptionKey(api, body) {
|
|
5793
|
+
return `${api}:${JSON.stringify(body ?? null)}`;
|
|
5725
5794
|
}
|
|
5726
5795
|
async getAPIResponse(api, body) {
|
|
5727
5796
|
let data = await this.loader.loadAPIData(api, body);
|
|
@@ -5736,21 +5805,27 @@ var __webpack_modules__ = {
|
|
|
5736
5805
|
async broadcast() {
|
|
5737
5806
|
clearImmediate(this.timer), this.timer = setImmediate(async ()=>{
|
|
5738
5807
|
let promises = [];
|
|
5739
|
-
this.map.forEach((
|
|
5740
|
-
|
|
5741
|
-
|
|
5742
|
-
|
|
5743
|
-
|
|
5744
|
-
})());
|
|
5745
|
-
});
|
|
5808
|
+
this.map.forEach(({ api, body })=>{
|
|
5809
|
+
promises.push((async ()=>{
|
|
5810
|
+
let res = await this.getAPIResponse(api, body);
|
|
5811
|
+
this.sendAPIData(api, res);
|
|
5812
|
+
})());
|
|
5746
5813
|
}), await Promise.all(promises);
|
|
5747
5814
|
});
|
|
5748
5815
|
}
|
|
5749
|
-
sendAPIData(api,
|
|
5750
|
-
|
|
5816
|
+
sendAPIData(api, payload) {
|
|
5817
|
+
let message = JSON.stringify({
|
|
5818
|
+
api,
|
|
5819
|
+
payload
|
|
5820
|
+
});
|
|
5821
|
+
this.clients.forEach((client)=>{
|
|
5822
|
+
client.readyState === external_ws_default().OPEN && client.send(message);
|
|
5823
|
+
});
|
|
5751
5824
|
}
|
|
5752
5825
|
dispose() {
|
|
5753
|
-
this.
|
|
5826
|
+
this.clients.forEach((client)=>{
|
|
5827
|
+
client.close();
|
|
5828
|
+
}), this.clients.clear(), this.server?.close();
|
|
5754
5829
|
}
|
|
5755
5830
|
}
|
|
5756
5831
|
class Router {
|
|
@@ -5840,13 +5915,13 @@ var __webpack_modules__ = {
|
|
|
5840
5915
|
});
|
|
5841
5916
|
}
|
|
5842
5917
|
}
|
|
5843
|
-
function
|
|
5918
|
+
function bundle_diff_ts_decorate(decorators, target, key, desc) {
|
|
5844
5919
|
var d, c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc;
|
|
5845
5920
|
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
|
|
5846
5921
|
else for(var i = decorators.length - 1; i >= 0; i--)(d = decorators[i]) && (r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r);
|
|
5847
5922
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5848
5923
|
}
|
|
5849
|
-
function
|
|
5924
|
+
function bundle_diff_ts_metadata(k, v) {
|
|
5850
5925
|
if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
|
|
5851
5926
|
}
|
|
5852
5927
|
!function(decorators, target, key, desc) {
|
|
@@ -5860,6 +5935,47 @@ var __webpack_modules__ = {
|
|
|
5860
5935
|
_ts_metadata("design:paramtypes", []),
|
|
5861
5936
|
_ts_metadata("design:returntype", Promise)
|
|
5862
5937
|
], AlertsAPI.prototype, "getPackageRelationAlertDetails", null);
|
|
5938
|
+
class BundleDiffAPI extends BaseAPI {
|
|
5939
|
+
async getBundleDiffSummary() {
|
|
5940
|
+
let { sdk } = this.ctx, { root, hash, errors, chunkGraph, moduleGraph, packageGraph, configs, moduleCodeMap, cloudManifestUrl } = sdk.getStoreData(), outputFilename = '';
|
|
5941
|
+
return 'string' == typeof configs?.[0]?.config?.output?.filename && (outputFilename = configs?.[0]?.config?.output?.filename), {
|
|
5942
|
+
root,
|
|
5943
|
+
hash,
|
|
5944
|
+
errors,
|
|
5945
|
+
chunkGraph,
|
|
5946
|
+
moduleGraph,
|
|
5947
|
+
packageGraph,
|
|
5948
|
+
outputFilename,
|
|
5949
|
+
moduleCodeMap,
|
|
5950
|
+
cloudManifestUrl
|
|
5951
|
+
};
|
|
5952
|
+
}
|
|
5953
|
+
async bundleDiffManifest() {
|
|
5954
|
+
let { sdk } = this.ctx;
|
|
5955
|
+
return sdk.getStoreData();
|
|
5956
|
+
}
|
|
5957
|
+
}
|
|
5958
|
+
function data_ts_decorate(decorators, target, key, desc) {
|
|
5959
|
+
var d, c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc;
|
|
5960
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
|
|
5961
|
+
else for(var i = decorators.length - 1; i >= 0; i--)(d = decorators[i]) && (r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r);
|
|
5962
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5963
|
+
}
|
|
5964
|
+
function data_ts_metadata(k, v) {
|
|
5965
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
|
|
5966
|
+
}
|
|
5967
|
+
bundle_diff_ts_decorate([
|
|
5968
|
+
Router.get(types_namespaceObject.SDK.ServerAPI.API.GetBundleDiffSummary),
|
|
5969
|
+
Router.post(types_namespaceObject.SDK.ServerAPI.API.GetBundleDiffSummary),
|
|
5970
|
+
bundle_diff_ts_metadata("design:type", Function),
|
|
5971
|
+
bundle_diff_ts_metadata("design:paramtypes", []),
|
|
5972
|
+
bundle_diff_ts_metadata("design:returntype", Promise)
|
|
5973
|
+
], BundleDiffAPI.prototype, "getBundleDiffSummary", null), bundle_diff_ts_decorate([
|
|
5974
|
+
Router.get(types_namespaceObject.SDK.ServerAPI.API.BundleDiffManifest),
|
|
5975
|
+
bundle_diff_ts_metadata("design:type", Function),
|
|
5976
|
+
bundle_diff_ts_metadata("design:paramtypes", []),
|
|
5977
|
+
bundle_diff_ts_metadata("design:returntype", Promise)
|
|
5978
|
+
], BundleDiffAPI.prototype, "bundleDiffManifest", null);
|
|
5863
5979
|
class DataAPI extends BaseAPI {
|
|
5864
5980
|
async loadDataByKey() {
|
|
5865
5981
|
let { req } = this.ctx, { url } = req, { key } = req.body;
|
|
@@ -6287,7 +6403,7 @@ var __webpack_modules__ = {
|
|
|
6287
6403
|
void 0 !== exitCode && process.exit(exitCode);
|
|
6288
6404
|
return;
|
|
6289
6405
|
}
|
|
6290
|
-
this.disposed = !0, this.
|
|
6406
|
+
this.disposed = !0, this._socket && this._socket.dispose(), this._server && await this._server.close(), void 0 !== exitCode && process.exit(exitCode);
|
|
6291
6407
|
}, external_assert_default()('number' == typeof port), this.port = port, this._router = new Router({
|
|
6292
6408
|
sdk,
|
|
6293
6409
|
server: this,
|
package/dist/index.js
CHANGED
|
@@ -16,8 +16,7 @@ import { Algorithm, Bundle, Data, GlobalConfig, Lodash, decycle } from "@rsdocto
|
|
|
16
16
|
import assert from "assert";
|
|
17
17
|
import cors from "../compiled/cors/index.js";
|
|
18
18
|
import { PassThrough } from "stream";
|
|
19
|
-
import {
|
|
20
|
-
import { isDeepStrictEqual } from "util";
|
|
19
|
+
import ws, { WebSocketServer } from "ws";
|
|
21
20
|
import os from "os";
|
|
22
21
|
import { exec } from "node:child_process";
|
|
23
22
|
import { promisify } from "node:util";
|
|
@@ -952,7 +951,7 @@ __webpack_require__.m = __webpack_modules__, __webpack_require__.n = (module)=>{
|
|
|
952
951
|
"../../node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/uri.js" (module) {
|
|
953
952
|
module.exports = URIError;
|
|
954
953
|
},
|
|
955
|
-
"../../node_modules/.pnpm/es-object-atoms@1.1.
|
|
954
|
+
"../../node_modules/.pnpm/es-object-atoms@1.1.2/node_modules/es-object-atoms/index.js" (module) {
|
|
956
955
|
module.exports = Object;
|
|
957
956
|
},
|
|
958
957
|
"../../node_modules/.pnpm/function-bind@1.1.2/node_modules/function-bind/implementation.js" (module) {
|
|
@@ -989,7 +988,7 @@ __webpack_require__.m = __webpack_modules__, __webpack_require__.n = (module)=>{
|
|
|
989
988
|
module.exports = Function.prototype.bind || implementation;
|
|
990
989
|
},
|
|
991
990
|
"../../node_modules/.pnpm/get-intrinsic@1.3.0/node_modules/get-intrinsic/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
992
|
-
var undefined, $Object = __webpack_require__("../../node_modules/.pnpm/es-object-atoms@1.1.
|
|
991
|
+
var undefined, $Object = __webpack_require__("../../node_modules/.pnpm/es-object-atoms@1.1.2/node_modules/es-object-atoms/index.js"), $Error = __webpack_require__("../../node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/index.js"), $EvalError = __webpack_require__("../../node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/eval.js"), $RangeError = __webpack_require__("../../node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/range.js"), $ReferenceError = __webpack_require__("../../node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/ref.js"), $SyntaxError = __webpack_require__("../../node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/syntax.js"), $TypeError = __webpack_require__("../../node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/type.js"), $URIError = __webpack_require__("../../node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/uri.js"), abs = __webpack_require__("../../node_modules/.pnpm/math-intrinsics@1.1.0/node_modules/math-intrinsics/abs.js"), floor = __webpack_require__("../../node_modules/.pnpm/math-intrinsics@1.1.0/node_modules/math-intrinsics/floor.js"), max = __webpack_require__("../../node_modules/.pnpm/math-intrinsics@1.1.0/node_modules/math-intrinsics/max.js"), min = __webpack_require__("../../node_modules/.pnpm/math-intrinsics@1.1.0/node_modules/math-intrinsics/min.js"), pow = __webpack_require__("../../node_modules/.pnpm/math-intrinsics@1.1.0/node_modules/math-intrinsics/pow.js"), round = __webpack_require__("../../node_modules/.pnpm/math-intrinsics@1.1.0/node_modules/math-intrinsics/round.js"), sign = __webpack_require__("../../node_modules/.pnpm/math-intrinsics@1.1.0/node_modules/math-intrinsics/sign.js"), $Function = Function, getEvalledConstructor = function(expressionSyntax) {
|
|
993
992
|
try {
|
|
994
993
|
return $Function('"use strict"; return (' + expressionSyntax + ').constructor;')();
|
|
995
994
|
} catch (e) {}
|
|
@@ -1372,7 +1371,7 @@ __webpack_require__.m = __webpack_modules__, __webpack_require__.n = (module)=>{
|
|
|
1372
1371
|
};
|
|
1373
1372
|
},
|
|
1374
1373
|
"../../node_modules/.pnpm/get-proto@1.0.1/node_modules/get-proto/Object.getPrototypeOf.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
1375
|
-
module.exports = __webpack_require__("../../node_modules/.pnpm/es-object-atoms@1.1.
|
|
1374
|
+
module.exports = __webpack_require__("../../node_modules/.pnpm/es-object-atoms@1.1.2/node_modules/es-object-atoms/index.js").getPrototypeOf || null;
|
|
1376
1375
|
},
|
|
1377
1376
|
"../../node_modules/.pnpm/get-proto@1.0.1/node_modules/get-proto/Reflect.getPrototypeOf.js" (module) {
|
|
1378
1377
|
module.exports = "u" > typeof Reflect && Reflect.getPrototypeOf || null;
|
|
@@ -5215,6 +5214,7 @@ __webpack_require__.m = __webpack_modules__, __webpack_require__.n = (module)=>{
|
|
|
5215
5214
|
var apis_namespaceObject = {};
|
|
5216
5215
|
__webpack_require__.r(apis_namespaceObject), __webpack_require__.d(apis_namespaceObject, {
|
|
5217
5216
|
AlertsAPI: ()=>AlertsAPI,
|
|
5217
|
+
BundleDiffAPI: ()=>BundleDiffAPI,
|
|
5218
5218
|
DataAPI: ()=>DataAPI,
|
|
5219
5219
|
FileSystemAPI: ()=>FileSystemAPI,
|
|
5220
5220
|
GraphAPI: ()=>GraphAPI,
|
|
@@ -5716,31 +5716,99 @@ class SocketAPILoader {
|
|
|
5716
5716
|
}
|
|
5717
5717
|
class Socket {
|
|
5718
5718
|
constructor(options){
|
|
5719
|
-
this.options = options, this.map = new Map(), this.loader = new SocketAPILoader({
|
|
5719
|
+
this.options = options, this.clients = new Set(), this.map = new Map(), this.clientSubscriptions = new Map(), this.loader = new SocketAPILoader({
|
|
5720
5720
|
sdk: options.sdk
|
|
5721
5721
|
});
|
|
5722
5722
|
}
|
|
5723
5723
|
bootstrap() {
|
|
5724
|
-
this.
|
|
5725
|
-
|
|
5726
|
-
|
|
5727
|
-
|
|
5728
|
-
...this.options.socketOptions
|
|
5729
|
-
}), this.io.on('connection', (socket)=>{
|
|
5730
|
-
this.setupSocket(socket);
|
|
5724
|
+
this.server = new WebSocketServer({
|
|
5725
|
+
server: this.options.server
|
|
5726
|
+
}), this.server.on('connection', (client)=>{
|
|
5727
|
+
this.attachClient(client);
|
|
5731
5728
|
});
|
|
5732
5729
|
}
|
|
5733
|
-
|
|
5734
|
-
|
|
5735
|
-
|
|
5736
|
-
|
|
5737
|
-
|
|
5730
|
+
attachClient(client) {
|
|
5731
|
+
this.clients.add(client), 'function' == typeof client.on && (client.on('message', (message)=>{
|
|
5732
|
+
this.handleClientMessage(message.toString(), client);
|
|
5733
|
+
}), client.on('close', ()=>{
|
|
5734
|
+
this.clients.delete(client), this.removeClientSubscriptions(client);
|
|
5735
|
+
}));
|
|
5736
|
+
}
|
|
5737
|
+
async handleClientMessage(raw, client) {
|
|
5738
|
+
let message;
|
|
5739
|
+
try {
|
|
5740
|
+
message = JSON.parse(raw);
|
|
5741
|
+
} catch {
|
|
5742
|
+
return;
|
|
5743
|
+
}
|
|
5744
|
+
if (message.api && Object.values(SDK.ServerAPI.API).includes(message.api)) {
|
|
5745
|
+
if ('request' === message.type) return void await this.handleAPIRequestMessage(message, client);
|
|
5746
|
+
if ('subscribe' === message.type) return void this.saveRequestToMap(message.api, message.body ?? null, client);
|
|
5747
|
+
'unsubscribe' === message.type && this.removeRequestFromMap(message.api, message.body ?? null, client);
|
|
5748
|
+
}
|
|
5749
|
+
}
|
|
5750
|
+
async handleAPIRequestMessage(message, client) {
|
|
5751
|
+
if (message.id && client && client.readyState === ws.OPEN) try {
|
|
5752
|
+
let response = await this.getAPIResponse(message.api, message.body);
|
|
5753
|
+
client.send(JSON.stringify({
|
|
5754
|
+
type: 'response',
|
|
5755
|
+
id: message.id,
|
|
5756
|
+
payload: response.res
|
|
5757
|
+
}));
|
|
5758
|
+
} catch (err) {
|
|
5759
|
+
client.send(JSON.stringify({
|
|
5760
|
+
type: 'response',
|
|
5761
|
+
id: message.id,
|
|
5762
|
+
error: err instanceof Error ? err.message : String(err)
|
|
5763
|
+
}));
|
|
5764
|
+
}
|
|
5765
|
+
}
|
|
5766
|
+
getSubscriptions() {
|
|
5767
|
+
return [
|
|
5768
|
+
...this.map.values()
|
|
5769
|
+
].map(({ api, body })=>({
|
|
5770
|
+
api,
|
|
5771
|
+
body
|
|
5772
|
+
}));
|
|
5773
|
+
}
|
|
5774
|
+
saveRequestToMap(api, body = null, client) {
|
|
5775
|
+
let key = this.getSubscriptionKey(api, body);
|
|
5776
|
+
if (client) {
|
|
5777
|
+
this.clientSubscriptions.has(client) || this.clientSubscriptions.set(client, new Set());
|
|
5778
|
+
let subscriptions = this.clientSubscriptions.get(client);
|
|
5779
|
+
if (subscriptions.has(key)) return;
|
|
5780
|
+
subscriptions.add(key);
|
|
5781
|
+
}
|
|
5782
|
+
let record = this.map.get(key);
|
|
5783
|
+
if (record) {
|
|
5784
|
+
record.count += 1;
|
|
5785
|
+
return;
|
|
5786
|
+
}
|
|
5787
|
+
this.map.set(key, {
|
|
5788
|
+
api,
|
|
5789
|
+
body,
|
|
5790
|
+
count: 1
|
|
5738
5791
|
});
|
|
5739
5792
|
}
|
|
5740
|
-
|
|
5741
|
-
|
|
5742
|
-
|
|
5743
|
-
|
|
5793
|
+
removeRequestFromMap(api, body = null, client) {
|
|
5794
|
+
let key = this.getSubscriptionKey(api, body);
|
|
5795
|
+
if (client) {
|
|
5796
|
+
let subscriptions = this.clientSubscriptions.get(client);
|
|
5797
|
+
if (!subscriptions?.has(key)) return;
|
|
5798
|
+
subscriptions.delete(key), 0 === subscriptions.size && this.clientSubscriptions.delete(client);
|
|
5799
|
+
}
|
|
5800
|
+
this.removeSubscriptionKey(key);
|
|
5801
|
+
}
|
|
5802
|
+
removeClientSubscriptions(client) {
|
|
5803
|
+
let subscriptions = this.clientSubscriptions.get(client);
|
|
5804
|
+
subscriptions && (subscriptions.forEach((key)=>this.removeSubscriptionKey(key)), this.clientSubscriptions.delete(client));
|
|
5805
|
+
}
|
|
5806
|
+
removeSubscriptionKey(key) {
|
|
5807
|
+
let record = this.map.get(key);
|
|
5808
|
+
record && (record.count -= 1, record.count <= 0 && this.map.delete(key));
|
|
5809
|
+
}
|
|
5810
|
+
getSubscriptionKey(api, body) {
|
|
5811
|
+
return `${api}:${JSON.stringify(body ?? null)}`;
|
|
5744
5812
|
}
|
|
5745
5813
|
async getAPIResponse(api, body) {
|
|
5746
5814
|
let data = await this.loader.loadAPIData(api, body);
|
|
@@ -5755,21 +5823,27 @@ class Socket {
|
|
|
5755
5823
|
async broadcast() {
|
|
5756
5824
|
clearImmediate(this.timer), this.timer = setImmediate(async ()=>{
|
|
5757
5825
|
let promises = [];
|
|
5758
|
-
this.map.forEach((
|
|
5759
|
-
|
|
5760
|
-
|
|
5761
|
-
|
|
5762
|
-
|
|
5763
|
-
})());
|
|
5764
|
-
});
|
|
5826
|
+
this.map.forEach(({ api, body })=>{
|
|
5827
|
+
promises.push((async ()=>{
|
|
5828
|
+
let res = await this.getAPIResponse(api, body);
|
|
5829
|
+
this.sendAPIData(api, res);
|
|
5830
|
+
})());
|
|
5765
5831
|
}), await Promise.all(promises);
|
|
5766
5832
|
});
|
|
5767
5833
|
}
|
|
5768
|
-
sendAPIData(api,
|
|
5769
|
-
|
|
5834
|
+
sendAPIData(api, payload) {
|
|
5835
|
+
let message = JSON.stringify({
|
|
5836
|
+
api,
|
|
5837
|
+
payload
|
|
5838
|
+
});
|
|
5839
|
+
this.clients.forEach((client)=>{
|
|
5840
|
+
client.readyState === ws.OPEN && client.send(message);
|
|
5841
|
+
});
|
|
5770
5842
|
}
|
|
5771
5843
|
dispose() {
|
|
5772
|
-
this.
|
|
5844
|
+
this.clients.forEach((client)=>{
|
|
5845
|
+
client.close();
|
|
5846
|
+
}), this.clients.clear(), this.server?.close();
|
|
5773
5847
|
}
|
|
5774
5848
|
}
|
|
5775
5849
|
class Router {
|
|
@@ -5859,13 +5933,13 @@ class AlertsAPI extends BaseAPI {
|
|
|
5859
5933
|
});
|
|
5860
5934
|
}
|
|
5861
5935
|
}
|
|
5862
|
-
function
|
|
5936
|
+
function bundle_diff_ts_decorate(decorators, target, key, desc) {
|
|
5863
5937
|
var d, c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc;
|
|
5864
5938
|
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
|
|
5865
5939
|
else for(var i = decorators.length - 1; i >= 0; i--)(d = decorators[i]) && (r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r);
|
|
5866
5940
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5867
5941
|
}
|
|
5868
|
-
function
|
|
5942
|
+
function bundle_diff_ts_metadata(k, v) {
|
|
5869
5943
|
if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
|
|
5870
5944
|
}
|
|
5871
5945
|
!function(decorators, target, key, desc) {
|
|
@@ -5879,6 +5953,47 @@ function data_ts_metadata(k, v) {
|
|
|
5879
5953
|
_ts_metadata("design:paramtypes", []),
|
|
5880
5954
|
_ts_metadata("design:returntype", Promise)
|
|
5881
5955
|
], AlertsAPI.prototype, "getPackageRelationAlertDetails", null);
|
|
5956
|
+
class BundleDiffAPI extends BaseAPI {
|
|
5957
|
+
async getBundleDiffSummary() {
|
|
5958
|
+
let { sdk } = this.ctx, { root, hash, errors, chunkGraph, moduleGraph, packageGraph, configs, moduleCodeMap, cloudManifestUrl } = sdk.getStoreData(), outputFilename = '';
|
|
5959
|
+
return 'string' == typeof configs?.[0]?.config?.output?.filename && (outputFilename = configs?.[0]?.config?.output?.filename), {
|
|
5960
|
+
root,
|
|
5961
|
+
hash,
|
|
5962
|
+
errors,
|
|
5963
|
+
chunkGraph,
|
|
5964
|
+
moduleGraph,
|
|
5965
|
+
packageGraph,
|
|
5966
|
+
outputFilename,
|
|
5967
|
+
moduleCodeMap,
|
|
5968
|
+
cloudManifestUrl
|
|
5969
|
+
};
|
|
5970
|
+
}
|
|
5971
|
+
async bundleDiffManifest() {
|
|
5972
|
+
let { sdk } = this.ctx;
|
|
5973
|
+
return sdk.getStoreData();
|
|
5974
|
+
}
|
|
5975
|
+
}
|
|
5976
|
+
function data_ts_decorate(decorators, target, key, desc) {
|
|
5977
|
+
var d, c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc;
|
|
5978
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
|
|
5979
|
+
else for(var i = decorators.length - 1; i >= 0; i--)(d = decorators[i]) && (r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r);
|
|
5980
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5981
|
+
}
|
|
5982
|
+
function data_ts_metadata(k, v) {
|
|
5983
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
|
|
5984
|
+
}
|
|
5985
|
+
bundle_diff_ts_decorate([
|
|
5986
|
+
Router.get(SDK.ServerAPI.API.GetBundleDiffSummary),
|
|
5987
|
+
Router.post(SDK.ServerAPI.API.GetBundleDiffSummary),
|
|
5988
|
+
bundle_diff_ts_metadata("design:type", Function),
|
|
5989
|
+
bundle_diff_ts_metadata("design:paramtypes", []),
|
|
5990
|
+
bundle_diff_ts_metadata("design:returntype", Promise)
|
|
5991
|
+
], BundleDiffAPI.prototype, "getBundleDiffSummary", null), bundle_diff_ts_decorate([
|
|
5992
|
+
Router.get(SDK.ServerAPI.API.BundleDiffManifest),
|
|
5993
|
+
bundle_diff_ts_metadata("design:type", Function),
|
|
5994
|
+
bundle_diff_ts_metadata("design:paramtypes", []),
|
|
5995
|
+
bundle_diff_ts_metadata("design:returntype", Promise)
|
|
5996
|
+
], BundleDiffAPI.prototype, "bundleDiffManifest", null);
|
|
5882
5997
|
class DataAPI extends BaseAPI {
|
|
5883
5998
|
async loadDataByKey() {
|
|
5884
5999
|
let { req } = this.ctx, { url } = req, { key } = req.body;
|
|
@@ -6307,7 +6422,7 @@ class RsdoctorServer {
|
|
|
6307
6422
|
void 0 !== exitCode && process.exit(exitCode);
|
|
6308
6423
|
return;
|
|
6309
6424
|
}
|
|
6310
|
-
this.disposed = !0, this.
|
|
6425
|
+
this.disposed = !0, this._socket && this._socket.dispose(), this._server && await this._server.close(), void 0 !== exitCode && process.exit(exitCode);
|
|
6311
6426
|
}, assert('number' == typeof port), this.port = port, this._router = new Router({
|
|
6312
6427
|
sdk,
|
|
6313
6428
|
server: this,
|
package/dist/sdk/sdk/index.d.cts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Manifest, SDK } from '@rsdoctor/types';
|
|
2
2
|
import { RawSourceMap, SourceMapConsumer } from 'source-map';
|
|
3
3
|
import { RsdoctorServer } from '../server';
|
|
4
|
-
import {
|
|
4
|
+
import { RsdoctorRspackSDKOptions } from './types';
|
|
5
5
|
import { SDKCore } from './core';
|
|
6
6
|
export * from '../utils/openBrowser';
|
|
7
7
|
export * from '../utils/base';
|
|
8
|
-
export declare class RsdoctorSDK<T extends
|
|
8
|
+
export declare class RsdoctorSDK<T extends RsdoctorRspackSDKOptions = RsdoctorRspackSDKOptions> extends SDKCore<T> implements SDK.RsdoctorBuilderSDKInstance {
|
|
9
9
|
server: RsdoctorServer;
|
|
10
10
|
extraConfig: SDK.SDKOptionsType | undefined;
|
|
11
11
|
type: SDK.ToDataType;
|
package/dist/sdk/sdk/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Manifest, SDK } from '@rsdoctor/types';
|
|
2
2
|
import { RawSourceMap, SourceMapConsumer } from 'source-map';
|
|
3
3
|
import { RsdoctorServer } from '../server/index.js';
|
|
4
|
-
import {
|
|
4
|
+
import { RsdoctorRspackSDKOptions } from './types.js';
|
|
5
5
|
import { SDKCore } from './core.js';
|
|
6
6
|
export * from '../utils/openBrowser.js';
|
|
7
7
|
export * from '../utils/base.js';
|
|
8
|
-
export declare class RsdoctorSDK<T extends
|
|
8
|
+
export declare class RsdoctorSDK<T extends RsdoctorRspackSDKOptions = RsdoctorRspackSDKOptions> extends SDKCore<T> implements SDK.RsdoctorBuilderSDKInstance {
|
|
9
9
|
server: RsdoctorServer;
|
|
10
10
|
extraConfig: SDK.SDKOptionsType | undefined;
|
|
11
11
|
type: SDK.ToDataType;
|
package/dist/sdk/sdk/types.d.cts
CHANGED
|
@@ -22,7 +22,7 @@ export interface RsdoctorBuilderSDK extends RsdoctorSDKOptions {
|
|
|
22
22
|
port?: number;
|
|
23
23
|
config?: SDK.SDKOptionsType;
|
|
24
24
|
}
|
|
25
|
-
export interface
|
|
25
|
+
export interface RsdoctorRspackSDKOptions extends RsdoctorBuilderSDK {
|
|
26
26
|
}
|
|
27
27
|
export interface RsdoctorEMOSDKOptions extends RsdoctorSDKOptions {
|
|
28
28
|
}
|
package/dist/sdk/sdk/types.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export interface RsdoctorBuilderSDK extends RsdoctorSDKOptions {
|
|
|
22
22
|
port?: number;
|
|
23
23
|
config?: SDK.SDKOptionsType;
|
|
24
24
|
}
|
|
25
|
-
export interface
|
|
25
|
+
export interface RsdoctorRspackSDKOptions extends RsdoctorBuilderSDK {
|
|
26
26
|
}
|
|
27
27
|
export interface RsdoctorEMOSDKOptions extends RsdoctorSDKOptions {
|
|
28
28
|
}
|
|
@@ -1,26 +1,47 @@
|
|
|
1
1
|
import { Common, SDK } from '@rsdoctor/types';
|
|
2
2
|
import type { Server } from 'http';
|
|
3
|
-
import
|
|
3
|
+
import WebSocket, { WebSocketServer } from 'ws';
|
|
4
4
|
import { SocketAPILoader } from './api';
|
|
5
5
|
interface SocketOptions {
|
|
6
6
|
sdk: SDK.RsdoctorBuilderSDKInstance;
|
|
7
7
|
server: Server;
|
|
8
8
|
port: number;
|
|
9
|
-
socketOptions?: SocketServerOptions;
|
|
10
9
|
}
|
|
10
|
+
type Subscription = {
|
|
11
|
+
api: SDK.ServerAPI.API;
|
|
12
|
+
body: Common.PlainObject | null;
|
|
13
|
+
};
|
|
14
|
+
type SubscriptionRecord = Subscription & {
|
|
15
|
+
count: number;
|
|
16
|
+
};
|
|
17
|
+
type ClientMessage = {
|
|
18
|
+
type?: string;
|
|
19
|
+
id?: string;
|
|
20
|
+
api?: SDK.ServerAPI.API;
|
|
21
|
+
body?: Common.PlainObject | null;
|
|
22
|
+
};
|
|
11
23
|
export declare class Socket {
|
|
12
24
|
protected options: SocketOptions;
|
|
13
|
-
protected
|
|
25
|
+
protected server?: WebSocketServer;
|
|
26
|
+
protected clients: Set<WebSocket>;
|
|
14
27
|
protected loader: SocketAPILoader;
|
|
15
|
-
protected map: Map<
|
|
28
|
+
protected map: Map<string, SubscriptionRecord>;
|
|
29
|
+
protected clientSubscriptions: Map<WebSocket, Set<string>>;
|
|
16
30
|
constructor(options: SocketOptions);
|
|
17
31
|
bootstrap(): void;
|
|
18
|
-
|
|
19
|
-
|
|
32
|
+
attachClient(client: WebSocket): void;
|
|
33
|
+
handleClientMessage(raw: string, client?: WebSocket): Promise<void>;
|
|
34
|
+
protected handleAPIRequestMessage(message: ClientMessage, client?: WebSocket): Promise<void>;
|
|
35
|
+
getSubscriptions(): Subscription[];
|
|
36
|
+
protected saveRequestToMap<T extends SDK.ServerAPI.API>(api: T, body?: SDK.ServerAPI.InferRequestBodyType<T, null> | null, client?: WebSocket): void;
|
|
37
|
+
protected removeRequestFromMap<T extends SDK.ServerAPI.API>(api: T, body?: SDK.ServerAPI.InferRequestBodyType<T, null> | null, client?: WebSocket): void;
|
|
38
|
+
protected removeClientSubscriptions(client: WebSocket): void;
|
|
39
|
+
protected removeSubscriptionKey(key: string): void;
|
|
40
|
+
protected getSubscriptionKey(api: SDK.ServerAPI.API, body: Common.PlainObject | null): string;
|
|
20
41
|
protected getAPIResponse<T extends SDK.ServerAPI.API>(api: T, body: SDK.ServerAPI.InferRequestBodyType<T>): Promise<SDK.ServerAPI.SocketResponseType<SDK.ServerAPI.API>>;
|
|
21
42
|
protected timer: NodeJS.Immediate | undefined;
|
|
22
43
|
broadcast(): Promise<void>;
|
|
23
|
-
sendAPIData<T extends SDK.ServerAPI.API | SDK.ServerAPI.APIExtends>(api: T,
|
|
44
|
+
sendAPIData<T extends SDK.ServerAPI.API | SDK.ServerAPI.APIExtends>(api: T, payload: SDK.ServerAPI.SocketResponseType<T>): void;
|
|
24
45
|
dispose(): void;
|
|
25
46
|
}
|
|
26
47
|
export {};
|
|
@@ -1,26 +1,47 @@
|
|
|
1
1
|
import { Common, SDK } from '@rsdoctor/types';
|
|
2
2
|
import type { Server } from 'http';
|
|
3
|
-
import
|
|
3
|
+
import WebSocket, { WebSocketServer } from 'ws';
|
|
4
4
|
import { SocketAPILoader } from './api.js';
|
|
5
5
|
interface SocketOptions {
|
|
6
6
|
sdk: SDK.RsdoctorBuilderSDKInstance;
|
|
7
7
|
server: Server;
|
|
8
8
|
port: number;
|
|
9
|
-
socketOptions?: SocketServerOptions;
|
|
10
9
|
}
|
|
10
|
+
type Subscription = {
|
|
11
|
+
api: SDK.ServerAPI.API;
|
|
12
|
+
body: Common.PlainObject | null;
|
|
13
|
+
};
|
|
14
|
+
type SubscriptionRecord = Subscription & {
|
|
15
|
+
count: number;
|
|
16
|
+
};
|
|
17
|
+
type ClientMessage = {
|
|
18
|
+
type?: string;
|
|
19
|
+
id?: string;
|
|
20
|
+
api?: SDK.ServerAPI.API;
|
|
21
|
+
body?: Common.PlainObject | null;
|
|
22
|
+
};
|
|
11
23
|
export declare class Socket {
|
|
12
24
|
protected options: SocketOptions;
|
|
13
|
-
protected
|
|
25
|
+
protected server?: WebSocketServer;
|
|
26
|
+
protected clients: Set<WebSocket>;
|
|
14
27
|
protected loader: SocketAPILoader;
|
|
15
|
-
protected map: Map<
|
|
28
|
+
protected map: Map<string, SubscriptionRecord>;
|
|
29
|
+
protected clientSubscriptions: Map<WebSocket, Set<string>>;
|
|
16
30
|
constructor(options: SocketOptions);
|
|
17
31
|
bootstrap(): void;
|
|
18
|
-
|
|
19
|
-
|
|
32
|
+
attachClient(client: WebSocket): void;
|
|
33
|
+
handleClientMessage(raw: string, client?: WebSocket): Promise<void>;
|
|
34
|
+
protected handleAPIRequestMessage(message: ClientMessage, client?: WebSocket): Promise<void>;
|
|
35
|
+
getSubscriptions(): Subscription[];
|
|
36
|
+
protected saveRequestToMap<T extends SDK.ServerAPI.API>(api: T, body?: SDK.ServerAPI.InferRequestBodyType<T, null> | null, client?: WebSocket): void;
|
|
37
|
+
protected removeRequestFromMap<T extends SDK.ServerAPI.API>(api: T, body?: SDK.ServerAPI.InferRequestBodyType<T, null> | null, client?: WebSocket): void;
|
|
38
|
+
protected removeClientSubscriptions(client: WebSocket): void;
|
|
39
|
+
protected removeSubscriptionKey(key: string): void;
|
|
40
|
+
protected getSubscriptionKey(api: SDK.ServerAPI.API, body: Common.PlainObject | null): string;
|
|
20
41
|
protected getAPIResponse<T extends SDK.ServerAPI.API>(api: T, body: SDK.ServerAPI.InferRequestBodyType<T>): Promise<SDK.ServerAPI.SocketResponseType<SDK.ServerAPI.API>>;
|
|
21
42
|
protected timer: NodeJS.Immediate | undefined;
|
|
22
43
|
broadcast(): Promise<void>;
|
|
23
|
-
sendAPIData<T extends SDK.ServerAPI.API | SDK.ServerAPI.APIExtends>(api: T,
|
|
44
|
+
sendAPIData<T extends SDK.ServerAPI.API | SDK.ServerAPI.APIExtends>(api: T, payload: SDK.ServerAPI.SocketResponseType<T>): void;
|
|
24
45
|
dispose(): void;
|
|
25
46
|
}
|
|
26
47
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsdoctor/sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-alpha.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/web-infra-dev/rsdoctor",
|
|
@@ -30,12 +30,12 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"launch-editor": "^2.13.2",
|
|
32
32
|
"safer-buffer": "2.1.2",
|
|
33
|
-
"socket.io": "4.8.1",
|
|
34
33
|
"tapable": "2.3.3",
|
|
35
|
-
"
|
|
36
|
-
"@rsdoctor/
|
|
37
|
-
"@rsdoctor/
|
|
38
|
-
"@rsdoctor/utils": "
|
|
34
|
+
"ws": "8.20.1",
|
|
35
|
+
"@rsdoctor/graph": "2.0.0-alpha.0",
|
|
36
|
+
"@rsdoctor/types": "2.0.0-alpha.0",
|
|
37
|
+
"@rsdoctor/utils": "2.0.0-alpha.0",
|
|
38
|
+
"@rsdoctor/client": "2.0.0-alpha.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/body-parser": "1.19.6",
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
"@types/cors": "2.8.19",
|
|
44
44
|
"@types/fs-extra": "^11.0.4",
|
|
45
45
|
"@types/node": "^24.12.3",
|
|
46
|
+
"@types/ws": "^8.18.1",
|
|
46
47
|
"body-parser": "2.2.2",
|
|
47
48
|
"cors": "2.8.6",
|
|
48
49
|
"dayjs": "1.11.20",
|