@module-federation/dts-plugin 0.2.8 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CHANGELOG.md +23 -0
- package/dist/{DTSManagerOptions-c0728719.d.ts → DTSManagerOptions-7109e8ac.d.ts} +1 -0
- package/dist/{DtsWorker-90454949.d.ts → DtsWorker-17de6ba4.d.ts} +2 -5
- package/dist/core.d.mts +8 -4
- package/dist/core.d.ts +8 -4
- package/dist/core.js +73 -43
- package/dist/dynamic-remote-type-hints-plugin.js +5 -7
- package/dist/esm/{chunk-MQRIERJP.js → chunk-6DND574L.js} +7 -15
- package/dist/esm/{chunk-2RCHPGBO.js → chunk-7AXI7WOP.js} +286 -1390
- package/dist/esm/chunk-HKRTV6ZH.js +900 -0
- package/dist/esm/chunk-VFGWGY54.js +283 -0
- package/dist/esm/{chunk-G7ONFBMA.js → chunk-XKCIYRDL.js} +1 -1
- package/dist/esm/core.js +11 -11
- package/dist/esm/dynamic-remote-type-hints-plugin.js +2 -2
- package/dist/esm/fork-dev-worker.js +11 -7
- package/dist/esm/fork-generate-dts.js +3 -2
- package/dist/esm/index.js +21 -18
- package/dist/esm/start-broker.js +2 -2
- package/dist/fork-dev-worker.d.mts +1 -1
- package/dist/fork-dev-worker.d.ts +1 -1
- package/dist/fork-dev-worker.js +69 -41
- package/dist/fork-generate-dts.d.mts +2 -2
- package/dist/fork-generate-dts.d.ts +2 -2
- package/dist/fork-generate-dts.js +141 -292
- package/dist/iife/launch-web-client.js +5 -7
- package/dist/index.js +84 -54
- package/dist/package.json +1 -1
- package/dist/start-broker.js +28 -344
- package/package.json +5 -5
|
@@ -1,62 +1,36 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
APIKind,
|
|
3
|
+
Broker,
|
|
4
|
+
LogKind,
|
|
5
|
+
fib,
|
|
6
|
+
fileLog,
|
|
7
|
+
getFreePort,
|
|
8
|
+
getIPV4,
|
|
9
|
+
getIdentifier
|
|
10
|
+
} from "./chunk-HKRTV6ZH.js";
|
|
11
|
+
import {
|
|
3
12
|
AddPublisherAction,
|
|
4
13
|
AddSubscriberAction,
|
|
5
14
|
DEFAULT_TAR_NAME,
|
|
6
|
-
DEFAULT_WEB_SOCKET_PORT,
|
|
7
15
|
ExitPublisherAction,
|
|
8
16
|
ExitSubscriberAction,
|
|
9
|
-
HOST_API_TYPES_FILE_NAME,
|
|
10
17
|
MF_SERVER_IDENTIFIER,
|
|
11
|
-
Message,
|
|
12
18
|
NotifyWebClientAction,
|
|
13
|
-
REMOTE_ALIAS_IDENTIFIER,
|
|
14
|
-
REMOTE_API_TYPES_FILE_NAME,
|
|
15
19
|
UpdateKind,
|
|
16
20
|
UpdateMode,
|
|
17
21
|
UpdatePublisherAction,
|
|
18
|
-
WEB_SOCKET_CONNECT_MAGIC_ID,
|
|
19
22
|
__async,
|
|
20
|
-
__export,
|
|
21
23
|
__name,
|
|
22
24
|
__publicField,
|
|
23
25
|
__require,
|
|
24
26
|
__spreadProps,
|
|
25
27
|
__spreadValues
|
|
26
|
-
} from "./chunk-
|
|
27
|
-
|
|
28
|
-
// packages/dts-plugin/src/core/configurations/remotePlugin.ts
|
|
29
|
-
import { existsSync as existsSync2 } from "fs";
|
|
30
|
-
import { dirname as dirname2, join as join3, resolve as resolve3, extname as extname2 } from "path";
|
|
31
|
-
import { utils as utils2 } from "@module-federation/managers";
|
|
32
|
-
import typescript from "typescript";
|
|
33
|
-
|
|
34
|
-
// packages/dts-plugin/src/core/lib/utils.ts
|
|
35
|
-
import fs3 from "fs";
|
|
36
|
-
import path3 from "path";
|
|
37
|
-
import axios from "axios";
|
|
38
|
-
import http from "http";
|
|
39
|
-
import https from "https";
|
|
40
|
-
import ansiColors2 from "ansi-colors";
|
|
41
|
-
|
|
42
|
-
// packages/dts-plugin/src/core/lib/DTSManager.ts
|
|
43
|
-
import ansiColors from "ansi-colors";
|
|
44
|
-
import path2 from "path";
|
|
45
|
-
import { rm as rm3 } from "fs/promises";
|
|
46
|
-
import fs2 from "fs";
|
|
47
|
-
import { MANIFEST_EXT, inferAutoPublicPath } from "@module-federation/sdk";
|
|
48
|
-
import cloneDeepWith from "lodash.clonedeepwith";
|
|
49
|
-
import { ThirdPartyExtractor as ThirdPartyExtractor2 } from "@module-federation/third-party-dts-extractor";
|
|
50
|
-
|
|
51
|
-
// packages/dts-plugin/src/core/lib/archiveHandler.ts
|
|
52
|
-
import AdmZip from "adm-zip";
|
|
53
|
-
import { resolve as resolve2, join as join2 } from "path";
|
|
54
|
-
import { rm as rm2 } from "fs/promises";
|
|
28
|
+
} from "./chunk-6DND574L.js";
|
|
55
29
|
|
|
56
30
|
// packages/dts-plugin/src/core/lib/typeScriptCompiler.ts
|
|
57
31
|
import { ensureDirSync, writeFileSync, existsSync } from "fs-extra";
|
|
32
|
+
import crypto from "crypto";
|
|
58
33
|
import { stat, readdir, writeFile, rm, readFile } from "fs/promises";
|
|
59
|
-
import { randomUUID } from "crypto";
|
|
60
34
|
import { dirname, join, normalize, relative, resolve, sep, extname, isAbsolute } from "path";
|
|
61
35
|
import { ThirdPartyExtractor } from "@module-federation/third-party-dts-extractor";
|
|
62
36
|
import { exec } from "child_process";
|
|
@@ -67,8 +41,12 @@ var DEFINITION_FILE_EXTENSION = ".d.ts";
|
|
|
67
41
|
var retrieveMfTypesPath = /* @__PURE__ */ __name((tsConfig, remoteOptions) => normalize(tsConfig.compilerOptions.outDir.replace(remoteOptions.compiledTypesFolder, "")), "retrieveMfTypesPath");
|
|
68
42
|
var retrieveOriginalOutDir = /* @__PURE__ */ __name((tsConfig, remoteOptions) => normalize(tsConfig.compilerOptions.outDir.replace(remoteOptions.compiledTypesFolder, "").replace(remoteOptions.typesFolder, "")), "retrieveOriginalOutDir");
|
|
69
43
|
var retrieveMfAPITypesPath = /* @__PURE__ */ __name((tsConfig, remoteOptions) => join(retrieveOriginalOutDir(tsConfig, remoteOptions), `${remoteOptions.typesFolder}.d.ts`), "retrieveMfAPITypesPath");
|
|
70
|
-
function writeTempTsConfig(tsConfig, context) {
|
|
71
|
-
const
|
|
44
|
+
function writeTempTsConfig(tsConfig, context, name) {
|
|
45
|
+
const createHash = /* @__PURE__ */ __name((contents) => {
|
|
46
|
+
return crypto.createHash("md5").update(contents).digest("hex");
|
|
47
|
+
}, "createHash");
|
|
48
|
+
const hash = createHash(`${JSON.stringify(tsConfig)}${name}`);
|
|
49
|
+
const tempTsConfigJsonPath = resolve(context, "node_modules", TEMP_DIR, `tsconfig.${hash}.json`);
|
|
72
50
|
ensureDirSync(dirname(tempTsConfigJsonPath));
|
|
73
51
|
writeFileSync(tempTsConfigJsonPath, JSON.stringify(tsConfig, null, 2));
|
|
74
52
|
return tempTsConfigJsonPath;
|
|
@@ -121,7 +99,7 @@ var compileTs = /* @__PURE__ */ __name((mapComponentsToExpose, tsConfig, remoteO
|
|
|
121
99
|
return;
|
|
122
100
|
}
|
|
123
101
|
const { compilerOptions } = tsConfig;
|
|
124
|
-
const tempTsConfigJsonPath = writeTempTsConfig(tsConfig, remoteOptions.context);
|
|
102
|
+
const tempTsConfigJsonPath = writeTempTsConfig(tsConfig, remoteOptions.context, remoteOptions.moduleFederationConfig.name || "mf");
|
|
125
103
|
try {
|
|
126
104
|
const mfTypePath = retrieveMfTypesPath(tsConfig, remoteOptions);
|
|
127
105
|
const thirdPartyExtractor = new ThirdPartyExtractor(resolve(mfTypePath, "node_modules"), remoteOptions.context);
|
|
@@ -159,891 +137,12 @@ var compileTs = /* @__PURE__ */ __name((mapComponentsToExpose, tsConfig, remoteO
|
|
|
159
137
|
}
|
|
160
138
|
yield rm(tempTsConfigJsonPath);
|
|
161
139
|
} catch (err) {
|
|
162
|
-
if (isDebugMode()) {
|
|
163
|
-
console.log("tsconfig: ", JSON.stringify(tsConfig, null, 2));
|
|
164
|
-
}
|
|
165
140
|
throw err;
|
|
166
141
|
}
|
|
167
142
|
}), "compileTs");
|
|
168
143
|
|
|
169
|
-
// packages/dts-plugin/src/server/message/API/API.ts
|
|
170
|
-
var APIKind;
|
|
171
|
-
(function(APIKind2) {
|
|
172
|
-
APIKind2["UPDATE_SUBSCRIBER"] = "UPDATE_SUBSCRIBER";
|
|
173
|
-
APIKind2["RELOAD_WEB_CLIENT"] = "RELOAD_WEB_CLIENT";
|
|
174
|
-
APIKind2["FETCH_TYPES"] = "FETCH_TYPES";
|
|
175
|
-
})(APIKind || (APIKind = {}));
|
|
176
|
-
var _API = class _API extends Message {
|
|
177
|
-
constructor(content, kind) {
|
|
178
|
-
super("API", kind);
|
|
179
|
-
__publicField(this, "code");
|
|
180
|
-
__publicField(this, "payload");
|
|
181
|
-
const { code, payload } = content;
|
|
182
|
-
this.code = code;
|
|
183
|
-
this.payload = payload;
|
|
184
|
-
}
|
|
185
|
-
};
|
|
186
|
-
__name(_API, "API");
|
|
187
|
-
var API = _API;
|
|
188
|
-
|
|
189
|
-
// packages/dts-plugin/src/server/message/API/UpdateSubscriber.ts
|
|
190
|
-
var _UpdateSubscriberAPI = class _UpdateSubscriberAPI extends API {
|
|
191
|
-
constructor(payload) {
|
|
192
|
-
super({
|
|
193
|
-
code: 0,
|
|
194
|
-
payload
|
|
195
|
-
}, APIKind.UPDATE_SUBSCRIBER);
|
|
196
|
-
}
|
|
197
|
-
};
|
|
198
|
-
__name(_UpdateSubscriberAPI, "UpdateSubscriberAPI");
|
|
199
|
-
var UpdateSubscriberAPI = _UpdateSubscriberAPI;
|
|
200
|
-
|
|
201
|
-
// packages/dts-plugin/src/server/message/API/ReloadWebClient.ts
|
|
202
|
-
var _ReloadWebClientAPI = class _ReloadWebClientAPI extends API {
|
|
203
|
-
constructor(payload) {
|
|
204
|
-
super({
|
|
205
|
-
code: 0,
|
|
206
|
-
payload
|
|
207
|
-
}, APIKind.RELOAD_WEB_CLIENT);
|
|
208
|
-
}
|
|
209
|
-
};
|
|
210
|
-
__name(_ReloadWebClientAPI, "ReloadWebClientAPI");
|
|
211
|
-
var ReloadWebClientAPI = _ReloadWebClientAPI;
|
|
212
|
-
|
|
213
|
-
// packages/dts-plugin/src/server/message/API/FetchTypes.ts
|
|
214
|
-
var _FetchTypesAPI = class _FetchTypesAPI extends API {
|
|
215
|
-
constructor(payload) {
|
|
216
|
-
super({
|
|
217
|
-
code: 0,
|
|
218
|
-
payload
|
|
219
|
-
}, APIKind.FETCH_TYPES);
|
|
220
|
-
}
|
|
221
|
-
};
|
|
222
|
-
__name(_FetchTypesAPI, "FetchTypesAPI");
|
|
223
|
-
var FetchTypesAPI = _FetchTypesAPI;
|
|
224
|
-
|
|
225
|
-
// packages/dts-plugin/src/server/utils/index.ts
|
|
226
|
-
import net from "net";
|
|
227
|
-
import { SEPARATOR } from "@module-federation/sdk";
|
|
228
|
-
|
|
229
|
-
// packages/dts-plugin/src/server/utils/logTransform.ts
|
|
230
|
-
import chalk from "chalk";
|
|
231
|
-
|
|
232
|
-
// packages/dts-plugin/src/server/message/Log/Log.ts
|
|
233
|
-
var LogLevel;
|
|
234
|
-
(function(LogLevel2) {
|
|
235
|
-
LogLevel2["LOG"] = "LOG";
|
|
236
|
-
LogLevel2["WARN"] = "WARN";
|
|
237
|
-
LogLevel2["ERROR"] = "ERROR";
|
|
238
|
-
})(LogLevel || (LogLevel = {}));
|
|
239
|
-
var LogKind;
|
|
240
|
-
(function(LogKind2) {
|
|
241
|
-
LogKind2["BrokerExitLog"] = "BrokerExitLog";
|
|
242
|
-
LogKind2["PublisherRegisteredLog"] = "PublisherRegisteredLog";
|
|
243
|
-
})(LogKind || (LogKind = {}));
|
|
244
|
-
var _Log = class _Log extends Message {
|
|
245
|
-
constructor(level, kind, ignoreVerbose = false) {
|
|
246
|
-
super("Log", kind);
|
|
247
|
-
__publicField(this, "level");
|
|
248
|
-
__publicField(this, "ignoreVerbose", false);
|
|
249
|
-
this.level = level;
|
|
250
|
-
this.ignoreVerbose = ignoreVerbose;
|
|
251
|
-
}
|
|
252
|
-
};
|
|
253
|
-
__name(_Log, "Log");
|
|
254
|
-
var Log = _Log;
|
|
255
|
-
|
|
256
|
-
// packages/dts-plugin/src/server/message/Log/BrokerExitLog.ts
|
|
257
|
-
var _BrokerExitLog = class _BrokerExitLog extends Log {
|
|
258
|
-
constructor() {
|
|
259
|
-
super(LogLevel.LOG, LogKind.BrokerExitLog);
|
|
260
|
-
}
|
|
261
|
-
};
|
|
262
|
-
__name(_BrokerExitLog, "BrokerExitLog");
|
|
263
|
-
var BrokerExitLog = _BrokerExitLog;
|
|
264
|
-
|
|
265
|
-
// packages/dts-plugin/src/server/utils/log.ts
|
|
266
|
-
import { logger } from "@module-federation/sdk";
|
|
267
|
-
import * as log4js from "log4js";
|
|
268
|
-
import chalk2 from "chalk";
|
|
269
|
-
function fileLog(msg, module, level) {
|
|
270
|
-
var _a3, _b;
|
|
271
|
-
if (!((_a3 = process == null ? void 0 : process.env) == null ? void 0 : _a3["FEDERATION_DEBUG"])) {
|
|
272
|
-
return;
|
|
273
|
-
}
|
|
274
|
-
log4js.configure({
|
|
275
|
-
appenders: {
|
|
276
|
-
[module]: {
|
|
277
|
-
type: "file",
|
|
278
|
-
filename: ".mf/typesGenerate.log"
|
|
279
|
-
},
|
|
280
|
-
default: {
|
|
281
|
-
type: "file",
|
|
282
|
-
filename: ".mf/typesGenerate.log"
|
|
283
|
-
}
|
|
284
|
-
},
|
|
285
|
-
categories: {
|
|
286
|
-
[module]: {
|
|
287
|
-
appenders: [
|
|
288
|
-
module
|
|
289
|
-
],
|
|
290
|
-
level: "error"
|
|
291
|
-
},
|
|
292
|
-
default: {
|
|
293
|
-
appenders: [
|
|
294
|
-
"default"
|
|
295
|
-
],
|
|
296
|
-
level: "trace"
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
});
|
|
300
|
-
const logger4 = log4js.getLogger(module);
|
|
301
|
-
logger4.level = "debug";
|
|
302
|
-
(_b = logger4[level]) == null ? void 0 : _b.call(logger4, msg);
|
|
303
|
-
}
|
|
304
|
-
__name(fileLog, "fileLog");
|
|
305
|
-
function error(error2, action, from) {
|
|
306
|
-
const err = error2 instanceof Error ? error2 : new Error(`${action} error`);
|
|
307
|
-
fileLog(`[${action}] error: ${err}`, from, "fatal");
|
|
308
|
-
return err.toString();
|
|
309
|
-
}
|
|
310
|
-
__name(error, "error");
|
|
311
|
-
|
|
312
|
-
// packages/dts-plugin/src/server/utils/getIPV4.ts
|
|
313
|
-
import os from "os";
|
|
314
|
-
var localIpv4 = "127.0.0.1";
|
|
315
|
-
var getIpv4Interfaces = /* @__PURE__ */ __name(() => {
|
|
316
|
-
try {
|
|
317
|
-
const interfaces = os.networkInterfaces();
|
|
318
|
-
const ipv4Interfaces = [];
|
|
319
|
-
Object.values(interfaces).forEach((detail) => {
|
|
320
|
-
detail == null ? void 0 : detail.forEach((detail2) => {
|
|
321
|
-
const familyV4Value = typeof detail2.family === "string" ? "IPv4" : 4;
|
|
322
|
-
if (detail2.family === familyV4Value && detail2.address !== localIpv4) {
|
|
323
|
-
ipv4Interfaces.push(detail2);
|
|
324
|
-
}
|
|
325
|
-
});
|
|
326
|
-
});
|
|
327
|
-
return ipv4Interfaces;
|
|
328
|
-
} catch (_err) {
|
|
329
|
-
return [];
|
|
330
|
-
}
|
|
331
|
-
}, "getIpv4Interfaces");
|
|
332
|
-
var getIPV4 = /* @__PURE__ */ __name(() => {
|
|
333
|
-
const ipv4Interfaces = getIpv4Interfaces();
|
|
334
|
-
const ipv4Interface = ipv4Interfaces[0] || {
|
|
335
|
-
address: localIpv4
|
|
336
|
-
};
|
|
337
|
-
return ipv4Interface.address;
|
|
338
|
-
}, "getIPV4");
|
|
339
|
-
|
|
340
|
-
// packages/dts-plugin/src/server/utils/index.ts
|
|
341
|
-
function getIdentifier(options) {
|
|
342
|
-
const { ip, name } = options;
|
|
343
|
-
return `mf ${SEPARATOR}${name}${ip ? `${SEPARATOR}${ip}` : ""}`;
|
|
344
|
-
}
|
|
345
|
-
__name(getIdentifier, "getIdentifier");
|
|
346
|
-
function fib(n) {
|
|
347
|
-
let i = 2;
|
|
348
|
-
const res = [
|
|
349
|
-
0,
|
|
350
|
-
1,
|
|
351
|
-
1
|
|
352
|
-
];
|
|
353
|
-
while (i <= n) {
|
|
354
|
-
res[i] = res[i - 1] + res[i - 2];
|
|
355
|
-
i++;
|
|
356
|
-
}
|
|
357
|
-
return res[n];
|
|
358
|
-
}
|
|
359
|
-
__name(fib, "fib");
|
|
360
|
-
function getFreePort() {
|
|
361
|
-
return new Promise((resolve4, reject) => {
|
|
362
|
-
const server = net.createServer();
|
|
363
|
-
server.unref();
|
|
364
|
-
server.on("error", reject);
|
|
365
|
-
server.listen(0, () => {
|
|
366
|
-
const { port } = server.address();
|
|
367
|
-
server.close(() => {
|
|
368
|
-
resolve4(port);
|
|
369
|
-
});
|
|
370
|
-
});
|
|
371
|
-
});
|
|
372
|
-
}
|
|
373
|
-
__name(getFreePort, "getFreePort");
|
|
374
|
-
|
|
375
|
-
// packages/dts-plugin/src/server/Publisher.ts
|
|
376
|
-
var _Publisher = class _Publisher {
|
|
377
|
-
constructor(ctx) {
|
|
378
|
-
__publicField(this, "_ip");
|
|
379
|
-
__publicField(this, "_name");
|
|
380
|
-
__publicField(this, "_remoteTypeTarPath");
|
|
381
|
-
__publicField(this, "_subscribers");
|
|
382
|
-
__publicField(this, "_ws");
|
|
383
|
-
__publicField(this, "dynamicRemoteMap");
|
|
384
|
-
this._name = ctx.name;
|
|
385
|
-
this._ip = ctx.ip;
|
|
386
|
-
this._remoteTypeTarPath = ctx.remoteTypeTarPath;
|
|
387
|
-
this._subscribers = /* @__PURE__ */ new Map();
|
|
388
|
-
this._ws = ctx.ws;
|
|
389
|
-
this.dynamicRemoteMap = /* @__PURE__ */ new Map();
|
|
390
|
-
}
|
|
391
|
-
get identifier() {
|
|
392
|
-
return getIdentifier({
|
|
393
|
-
name: this._name,
|
|
394
|
-
ip: this._ip
|
|
395
|
-
});
|
|
396
|
-
}
|
|
397
|
-
get name() {
|
|
398
|
-
return this._name;
|
|
399
|
-
}
|
|
400
|
-
get ip() {
|
|
401
|
-
return this._ip;
|
|
402
|
-
}
|
|
403
|
-
get remoteTypeTarPath() {
|
|
404
|
-
return this._remoteTypeTarPath;
|
|
405
|
-
}
|
|
406
|
-
get hasSubscribes() {
|
|
407
|
-
return Boolean(this._subscribers.size);
|
|
408
|
-
}
|
|
409
|
-
get subscribers() {
|
|
410
|
-
return this._subscribers;
|
|
411
|
-
}
|
|
412
|
-
addSubscriber(identifier, subscriber) {
|
|
413
|
-
fileLog(`${this.name} set subscriber: ${identifier}`, "Publisher", "info");
|
|
414
|
-
this._subscribers.set(identifier, subscriber);
|
|
415
|
-
}
|
|
416
|
-
removeSubscriber(identifier) {
|
|
417
|
-
if (this._subscribers.has(identifier)) {
|
|
418
|
-
fileLog(`${this.name} removeSubscriber: ${identifier}`, "Publisher", "warn");
|
|
419
|
-
this._subscribers.delete(identifier);
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
notifySubscriber(subscriberIdentifier, options) {
|
|
423
|
-
const subscriber = this._subscribers.get(subscriberIdentifier);
|
|
424
|
-
if (!subscriber) {
|
|
425
|
-
fileLog(`[notifySubscriber] ${this.name} notifySubscriber: ${subscriberIdentifier}, does not exits`, "Publisher", "error");
|
|
426
|
-
return;
|
|
427
|
-
}
|
|
428
|
-
const api = new UpdateSubscriberAPI(options);
|
|
429
|
-
subscriber.send(JSON.stringify(api));
|
|
430
|
-
fileLog(`[notifySubscriber] ${this.name} notifySubscriber: ${JSON.stringify(subscriberIdentifier)}, message: ${JSON.stringify(api)}`, "Publisher", "info");
|
|
431
|
-
}
|
|
432
|
-
fetchRemoteTypes(options) {
|
|
433
|
-
fileLog(`[fetchRemoteTypes] ${this.name} fetchRemoteTypes, options: ${JSON.stringify(options)}, ws: ${Boolean(this._ws)}`, "Publisher", "info");
|
|
434
|
-
if (!this._ws) {
|
|
435
|
-
return;
|
|
436
|
-
}
|
|
437
|
-
const api = new FetchTypesAPI(options);
|
|
438
|
-
this._ws.send(JSON.stringify(api));
|
|
439
|
-
}
|
|
440
|
-
notifySubscribers(options) {
|
|
441
|
-
const api = new UpdateSubscriberAPI(options);
|
|
442
|
-
this.broadcast(api);
|
|
443
|
-
}
|
|
444
|
-
broadcast(message) {
|
|
445
|
-
if (this.hasSubscribes) {
|
|
446
|
-
this._subscribers.forEach((subscriber, key) => {
|
|
447
|
-
fileLog(`[BroadCast] ${this.name} notifySubscriber: ${key}, PID: ${process.pid}, message: ${JSON.stringify(message)}`, "Publisher", "info");
|
|
448
|
-
subscriber.send(JSON.stringify(message));
|
|
449
|
-
});
|
|
450
|
-
} else {
|
|
451
|
-
fileLog(`[BroadCast] ${this.name}'s subscribe is empty`, "Publisher", "warn");
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
close() {
|
|
455
|
-
this._ws = void 0;
|
|
456
|
-
this._subscribers.forEach((_subscriber, identifier) => {
|
|
457
|
-
fileLog(`[BroadCast] close ${this.name} remove: ${identifier}`, "Publisher", "warn");
|
|
458
|
-
this.removeSubscriber(identifier);
|
|
459
|
-
});
|
|
460
|
-
}
|
|
461
|
-
};
|
|
462
|
-
__name(_Publisher, "Publisher");
|
|
463
|
-
var Publisher = _Publisher;
|
|
464
|
-
|
|
465
144
|
// packages/dts-plugin/src/server/DevServer.ts
|
|
466
|
-
import WebSocket2 from "isomorphic-ws";
|
|
467
|
-
|
|
468
|
-
// packages/dts-plugin/src/server/broker/Broker.ts
|
|
469
|
-
import { createServer } from "http";
|
|
470
145
|
import WebSocket from "isomorphic-ws";
|
|
471
|
-
import schedule from "node-schedule";
|
|
472
|
-
import { parse } from "url";
|
|
473
|
-
var _Broker = class _Broker {
|
|
474
|
-
constructor() {
|
|
475
|
-
__publicField(this, "_publisherMap", /* @__PURE__ */ new Map());
|
|
476
|
-
__publicField(this, "_webClientMap", /* @__PURE__ */ new Map());
|
|
477
|
-
__publicField(this, "_webSocketServer");
|
|
478
|
-
__publicField(this, "_secureWebSocketServer");
|
|
479
|
-
__publicField(this, "_tmpSubscriberShelter", /* @__PURE__ */ new Map());
|
|
480
|
-
__publicField(this, "_scheduleJob", null);
|
|
481
|
-
this._setSchedule();
|
|
482
|
-
this._startWsServer();
|
|
483
|
-
this._stopWhenSIGTERMOrSIGINT();
|
|
484
|
-
this._handleUnexpectedExit();
|
|
485
|
-
}
|
|
486
|
-
get hasPublishers() {
|
|
487
|
-
return Boolean(this._publisherMap.size);
|
|
488
|
-
}
|
|
489
|
-
_startWsServer() {
|
|
490
|
-
return __async(this, null, function* () {
|
|
491
|
-
const wsHandler = /* @__PURE__ */ __name((ws, req) => {
|
|
492
|
-
const { url: reqUrl = "" } = req;
|
|
493
|
-
const { query } = parse(reqUrl, true);
|
|
494
|
-
const { WEB_SOCKET_CONNECT_MAGIC_ID: WEB_SOCKET_CONNECT_MAGIC_ID2 } = query;
|
|
495
|
-
if (WEB_SOCKET_CONNECT_MAGIC_ID2 === _Broker.WEB_SOCKET_CONNECT_MAGIC_ID) {
|
|
496
|
-
ws.on("message", (message) => {
|
|
497
|
-
try {
|
|
498
|
-
const text = message.toString();
|
|
499
|
-
const action = JSON.parse(text);
|
|
500
|
-
fileLog(`${action == null ? void 0 : action.kind} action received `, "Broker", "info");
|
|
501
|
-
this._takeAction(action, ws);
|
|
502
|
-
} catch (error2) {
|
|
503
|
-
fileLog(`parse action message error: ${error2}`, "Broker", "error");
|
|
504
|
-
}
|
|
505
|
-
});
|
|
506
|
-
ws.on("error", (e) => {
|
|
507
|
-
fileLog(`parse action message error: ${e}`, "Broker", "error");
|
|
508
|
-
});
|
|
509
|
-
} else {
|
|
510
|
-
ws.send("Invalid CONNECT ID.");
|
|
511
|
-
fileLog("Invalid CONNECT ID.", "Broker", "warn");
|
|
512
|
-
ws.close();
|
|
513
|
-
}
|
|
514
|
-
}, "wsHandler");
|
|
515
|
-
const server = createServer();
|
|
516
|
-
this._webSocketServer = new WebSocket.Server({
|
|
517
|
-
noServer: true
|
|
518
|
-
});
|
|
519
|
-
this._webSocketServer.on("error", (err) => {
|
|
520
|
-
fileLog(`ws error:
|
|
521
|
-
${err.message}
|
|
522
|
-
${err.stack}`, "Broker", "error");
|
|
523
|
-
});
|
|
524
|
-
this._webSocketServer.on("listening", () => {
|
|
525
|
-
fileLog(`WebSocket server is listening on port ${_Broker.DEFAULT_WEB_SOCKET_PORT}`, "Broker", "info");
|
|
526
|
-
});
|
|
527
|
-
this._webSocketServer.on("connection", wsHandler);
|
|
528
|
-
this._webSocketServer.on("close", (code) => {
|
|
529
|
-
fileLog(`WebSocket Server Close with Code ${code}`, "Broker", "warn");
|
|
530
|
-
this._webSocketServer && this._webSocketServer.close();
|
|
531
|
-
this._webSocketServer = void 0;
|
|
532
|
-
});
|
|
533
|
-
server.on("upgrade", (req, socket, head) => {
|
|
534
|
-
var _a3;
|
|
535
|
-
if (req.url) {
|
|
536
|
-
const { pathname } = parse(req.url);
|
|
537
|
-
if (pathname === "/") {
|
|
538
|
-
(_a3 = this._webSocketServer) == null ? void 0 : _a3.handleUpgrade(req, socket, head, (ws) => {
|
|
539
|
-
var _a4;
|
|
540
|
-
(_a4 = this._webSocketServer) == null ? void 0 : _a4.emit("connection", ws, req);
|
|
541
|
-
});
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
});
|
|
545
|
-
server.listen(_Broker.DEFAULT_WEB_SOCKET_PORT);
|
|
546
|
-
});
|
|
547
|
-
}
|
|
548
|
-
_takeAction(action, client) {
|
|
549
|
-
return __async(this, null, function* () {
|
|
550
|
-
const { kind, payload } = action;
|
|
551
|
-
if (kind === ActionKind.ADD_PUBLISHER) {
|
|
552
|
-
yield this._addPublisher(payload, client);
|
|
553
|
-
}
|
|
554
|
-
if (kind === ActionKind.UPDATE_PUBLISHER) {
|
|
555
|
-
yield this._updatePublisher(payload, client);
|
|
556
|
-
}
|
|
557
|
-
if (kind === ActionKind.ADD_SUBSCRIBER) {
|
|
558
|
-
yield this._addSubscriber(payload, client);
|
|
559
|
-
}
|
|
560
|
-
if (kind === ActionKind.EXIT_SUBSCRIBER) {
|
|
561
|
-
yield this._removeSubscriber(payload, client);
|
|
562
|
-
}
|
|
563
|
-
if (kind === ActionKind.EXIT_PUBLISHER) {
|
|
564
|
-
yield this._removePublisher(payload, client);
|
|
565
|
-
}
|
|
566
|
-
if (kind === ActionKind.ADD_WEB_CLIENT) {
|
|
567
|
-
yield this._addWebClient(payload, client);
|
|
568
|
-
}
|
|
569
|
-
if (kind === ActionKind.NOTIFY_WEB_CLIENT) {
|
|
570
|
-
yield this._notifyWebClient(payload, client);
|
|
571
|
-
}
|
|
572
|
-
if (kind === ActionKind.FETCH_TYPES) {
|
|
573
|
-
yield this._fetchTypes(payload, client);
|
|
574
|
-
}
|
|
575
|
-
if (kind === ActionKind.ADD_DYNAMIC_REMOTE) {
|
|
576
|
-
this._addDynamicRemote(payload);
|
|
577
|
-
}
|
|
578
|
-
});
|
|
579
|
-
}
|
|
580
|
-
_addPublisher(context, client) {
|
|
581
|
-
return __async(this, null, function* () {
|
|
582
|
-
const { name, ip, remoteTypeTarPath } = context != null ? context : {};
|
|
583
|
-
const identifier = getIdentifier({
|
|
584
|
-
name,
|
|
585
|
-
ip
|
|
586
|
-
});
|
|
587
|
-
if (this._publisherMap.has(identifier)) {
|
|
588
|
-
fileLog(`[${ActionKind.ADD_PUBLISHER}] ${identifier} has been added, this action will be ignored`, "Broker", "warn");
|
|
589
|
-
return;
|
|
590
|
-
}
|
|
591
|
-
try {
|
|
592
|
-
const publisher = new Publisher({
|
|
593
|
-
name,
|
|
594
|
-
ip,
|
|
595
|
-
remoteTypeTarPath,
|
|
596
|
-
ws: client
|
|
597
|
-
});
|
|
598
|
-
this._publisherMap.set(identifier, publisher);
|
|
599
|
-
fileLog(`[${ActionKind.ADD_PUBLISHER}] ${identifier} Adding Publisher Succeed`, "Broker", "info");
|
|
600
|
-
const tmpSubScribers = this._getTmpSubScribers(identifier);
|
|
601
|
-
if (tmpSubScribers) {
|
|
602
|
-
fileLog(`[${ActionKind.ADD_PUBLISHER}] consumeTmpSubscriber set ${publisher.name}\u2019s subscribers `, "Broker", "info");
|
|
603
|
-
this._consumeTmpSubScribers(publisher, tmpSubScribers);
|
|
604
|
-
this._clearTmpSubScriberRelation(identifier);
|
|
605
|
-
}
|
|
606
|
-
} catch (err) {
|
|
607
|
-
const msg = error(err, ActionKind.ADD_PUBLISHER, "Broker");
|
|
608
|
-
client.send(msg);
|
|
609
|
-
client.close();
|
|
610
|
-
}
|
|
611
|
-
});
|
|
612
|
-
}
|
|
613
|
-
_updatePublisher(context, client) {
|
|
614
|
-
return __async(this, null, function* () {
|
|
615
|
-
const { name, updateMode, updateKind, updateSourcePaths, remoteTypeTarPath, ip } = context != null ? context : {};
|
|
616
|
-
const identifier = getIdentifier({
|
|
617
|
-
name,
|
|
618
|
-
ip
|
|
619
|
-
});
|
|
620
|
-
if (!this._publisherMap.has(identifier)) {
|
|
621
|
-
fileLog(`[${ActionKind.UPDATE_PUBLISHER}] ${identifier} has not been started, this action will be ignored
|
|
622
|
-
this._publisherMap: ${JSON.stringify(this._publisherMap.entries())}
|
|
623
|
-
`, "Broker", "warn");
|
|
624
|
-
return;
|
|
625
|
-
}
|
|
626
|
-
try {
|
|
627
|
-
const publisher = this._publisherMap.get(identifier);
|
|
628
|
-
fileLog(
|
|
629
|
-
// eslint-disable-next-line max-len
|
|
630
|
-
`[${ActionKind.UPDATE_PUBLISHER}] ${identifier} update, and notify subscribers to update`,
|
|
631
|
-
"Broker",
|
|
632
|
-
"info"
|
|
633
|
-
);
|
|
634
|
-
if (publisher) {
|
|
635
|
-
publisher.notifySubscribers({
|
|
636
|
-
remoteTypeTarPath,
|
|
637
|
-
name,
|
|
638
|
-
updateMode,
|
|
639
|
-
updateKind,
|
|
640
|
-
updateSourcePaths: updateSourcePaths || []
|
|
641
|
-
});
|
|
642
|
-
this._publisherMap.forEach((p) => {
|
|
643
|
-
if (p.name === publisher.name) {
|
|
644
|
-
return;
|
|
645
|
-
}
|
|
646
|
-
const dynamicRemoteInfo = p.dynamicRemoteMap.get(identifier);
|
|
647
|
-
if (dynamicRemoteInfo) {
|
|
648
|
-
fileLog(
|
|
649
|
-
// eslint-disable-next-line max-len
|
|
650
|
-
`dynamicRemoteInfo: ${JSON.stringify(dynamicRemoteInfo)}, identifier:${identifier} publish: ${p.name}`,
|
|
651
|
-
"Broker",
|
|
652
|
-
"info"
|
|
653
|
-
);
|
|
654
|
-
p.fetchRemoteTypes({
|
|
655
|
-
remoteInfo: dynamicRemoteInfo,
|
|
656
|
-
once: false
|
|
657
|
-
});
|
|
658
|
-
}
|
|
659
|
-
});
|
|
660
|
-
}
|
|
661
|
-
} catch (err) {
|
|
662
|
-
const msg = error(err, ActionKind.UPDATE_PUBLISHER, "Broker");
|
|
663
|
-
client.send(msg);
|
|
664
|
-
client.close();
|
|
665
|
-
}
|
|
666
|
-
});
|
|
667
|
-
}
|
|
668
|
-
_fetchTypes(context, _client) {
|
|
669
|
-
return __async(this, null, function* () {
|
|
670
|
-
const { name, ip, remoteInfo } = context != null ? context : {};
|
|
671
|
-
const identifier = getIdentifier({
|
|
672
|
-
name,
|
|
673
|
-
ip
|
|
674
|
-
});
|
|
675
|
-
try {
|
|
676
|
-
const publisher = this._publisherMap.get(identifier);
|
|
677
|
-
fileLog(`[${ActionKind.FETCH_TYPES}] ${identifier} fetch types`, "Broker", "info");
|
|
678
|
-
if (publisher) {
|
|
679
|
-
publisher.fetchRemoteTypes({
|
|
680
|
-
remoteInfo,
|
|
681
|
-
once: true
|
|
682
|
-
});
|
|
683
|
-
}
|
|
684
|
-
} catch (err) {
|
|
685
|
-
fileLog(`[${ActionKind.FETCH_TYPES}] ${identifier} fetch types fail , error info: ${err}`, "Broker", "error");
|
|
686
|
-
}
|
|
687
|
-
});
|
|
688
|
-
}
|
|
689
|
-
_addDynamicRemote(context) {
|
|
690
|
-
const { name, ip, remoteInfo, remoteIp } = context != null ? context : {};
|
|
691
|
-
const identifier = getIdentifier({
|
|
692
|
-
name,
|
|
693
|
-
ip
|
|
694
|
-
});
|
|
695
|
-
const publisher = this._publisherMap.get(identifier);
|
|
696
|
-
const remoteId = getIdentifier({
|
|
697
|
-
name: remoteInfo.name,
|
|
698
|
-
ip: remoteIp
|
|
699
|
-
});
|
|
700
|
-
fileLog(`[${ActionKind.ADD_DYNAMIC_REMOTE}] identifier:${identifier},publisher: ${publisher.name}, remoteId:${remoteId}`, "Broker", "error");
|
|
701
|
-
if (!publisher || publisher.dynamicRemoteMap.has(remoteId)) {
|
|
702
|
-
return;
|
|
703
|
-
}
|
|
704
|
-
publisher.dynamicRemoteMap.set(remoteId, remoteInfo);
|
|
705
|
-
}
|
|
706
|
-
// app1 consumes provider1,provider2. Dependencies at this time: publishers: [provider1, provider2], subscriberName: app1
|
|
707
|
-
// provider1 is app1's remote
|
|
708
|
-
_addSubscriber(context, client) {
|
|
709
|
-
return __async(this, null, function* () {
|
|
710
|
-
const { publishers, name: subscriberName } = context != null ? context : {};
|
|
711
|
-
publishers.forEach((publisher) => {
|
|
712
|
-
const { name, ip } = publisher;
|
|
713
|
-
const identifier = getIdentifier({
|
|
714
|
-
name,
|
|
715
|
-
ip
|
|
716
|
-
});
|
|
717
|
-
if (!this._publisherMap.has(identifier)) {
|
|
718
|
-
fileLog(`[${ActionKind.ADD_SUBSCRIBER}]: ${identifier} has not been started, ${subscriberName} will add the relation to tmp shelter`, "Broker", "warn");
|
|
719
|
-
this._addTmpSubScriberRelation({
|
|
720
|
-
name: getIdentifier({
|
|
721
|
-
name: context.name,
|
|
722
|
-
ip: context.ip
|
|
723
|
-
}),
|
|
724
|
-
client
|
|
725
|
-
}, publisher);
|
|
726
|
-
return;
|
|
727
|
-
}
|
|
728
|
-
try {
|
|
729
|
-
const registeredPublisher = this._publisherMap.get(identifier);
|
|
730
|
-
if (registeredPublisher) {
|
|
731
|
-
registeredPublisher.addSubscriber(getIdentifier({
|
|
732
|
-
name: subscriberName,
|
|
733
|
-
ip: context.ip
|
|
734
|
-
}), client);
|
|
735
|
-
fileLog(
|
|
736
|
-
// eslint-disable-next-line @ies/eden/max-calls-in-template
|
|
737
|
-
`[${ActionKind.ADD_SUBSCRIBER}]: ${identifier} has been started, Adding Subscriber ${subscriberName} Succeed, this.__publisherMap are: ${JSON.stringify(Array.from(this._publisherMap.entries()))}`,
|
|
738
|
-
"Broker",
|
|
739
|
-
"info"
|
|
740
|
-
);
|
|
741
|
-
registeredPublisher.notifySubscriber(getIdentifier({
|
|
742
|
-
name: subscriberName,
|
|
743
|
-
ip: context.ip
|
|
744
|
-
}), {
|
|
745
|
-
updateKind: UpdateKind.UPDATE_TYPE,
|
|
746
|
-
updateMode: UpdateMode.PASSIVE,
|
|
747
|
-
updateSourcePaths: [
|
|
748
|
-
registeredPublisher.name
|
|
749
|
-
],
|
|
750
|
-
remoteTypeTarPath: registeredPublisher.remoteTypeTarPath,
|
|
751
|
-
name: registeredPublisher.name
|
|
752
|
-
});
|
|
753
|
-
fileLog(
|
|
754
|
-
// eslint-disable-next-line @ies/eden/max-calls-in-template
|
|
755
|
-
`[${ActionKind.ADD_SUBSCRIBER}]: notifySubscriber Subscriber ${subscriberName}, updateMode: "PASSIVE", updateSourcePaths: ${registeredPublisher.name}`,
|
|
756
|
-
"Broker",
|
|
757
|
-
"info"
|
|
758
|
-
);
|
|
759
|
-
}
|
|
760
|
-
} catch (err) {
|
|
761
|
-
const msg = error(err, ActionKind.ADD_SUBSCRIBER, "Broker");
|
|
762
|
-
client.send(msg);
|
|
763
|
-
client.close();
|
|
764
|
-
}
|
|
765
|
-
});
|
|
766
|
-
});
|
|
767
|
-
}
|
|
768
|
-
// Trigger while consumer exit
|
|
769
|
-
_removeSubscriber(context, client) {
|
|
770
|
-
return __async(this, null, function* () {
|
|
771
|
-
const { publishers } = context != null ? context : {};
|
|
772
|
-
const subscriberIdentifier = getIdentifier({
|
|
773
|
-
name: context == null ? void 0 : context.name,
|
|
774
|
-
ip: context == null ? void 0 : context.ip
|
|
775
|
-
});
|
|
776
|
-
publishers.forEach((publisher) => {
|
|
777
|
-
const { name, ip } = publisher;
|
|
778
|
-
const identifier = getIdentifier({
|
|
779
|
-
name,
|
|
780
|
-
ip
|
|
781
|
-
});
|
|
782
|
-
const registeredPublisher = this._publisherMap.get(identifier);
|
|
783
|
-
if (!registeredPublisher) {
|
|
784
|
-
fileLog(`[${ActionKind.EXIT_SUBSCRIBER}], ${identifier} does not exit `, "Broker", "warn");
|
|
785
|
-
return;
|
|
786
|
-
}
|
|
787
|
-
try {
|
|
788
|
-
fileLog(`[${ActionKind.EXIT_SUBSCRIBER}], ${identifier} will exit `, "Broker", "INFO");
|
|
789
|
-
registeredPublisher.removeSubscriber(subscriberIdentifier);
|
|
790
|
-
this._clearTmpSubScriberRelation(identifier);
|
|
791
|
-
if (!registeredPublisher.hasSubscribes) {
|
|
792
|
-
this._publisherMap.delete(identifier);
|
|
793
|
-
}
|
|
794
|
-
if (!this.hasPublishers) {
|
|
795
|
-
this.exit();
|
|
796
|
-
}
|
|
797
|
-
} catch (err) {
|
|
798
|
-
const msg = error(err, ActionKind.EXIT_SUBSCRIBER, "Broker");
|
|
799
|
-
client.send(msg);
|
|
800
|
-
client.close();
|
|
801
|
-
}
|
|
802
|
-
});
|
|
803
|
-
});
|
|
804
|
-
}
|
|
805
|
-
_removePublisher(context, client) {
|
|
806
|
-
return __async(this, null, function* () {
|
|
807
|
-
const { name, ip } = context != null ? context : {};
|
|
808
|
-
const identifier = getIdentifier({
|
|
809
|
-
name,
|
|
810
|
-
ip
|
|
811
|
-
});
|
|
812
|
-
const publisher = this._publisherMap.get(identifier);
|
|
813
|
-
if (!publisher) {
|
|
814
|
-
fileLog(`[${ActionKind.EXIT_PUBLISHER}]: ${identifier}} has not been added, this action will be ingored`, "Broker", "warn");
|
|
815
|
-
return;
|
|
816
|
-
}
|
|
817
|
-
try {
|
|
818
|
-
const { subscribers } = publisher;
|
|
819
|
-
subscribers.forEach((subscriber, subscriberIdentifier) => {
|
|
820
|
-
this._addTmpSubScriberRelation({
|
|
821
|
-
name: subscriberIdentifier,
|
|
822
|
-
client: subscriber
|
|
823
|
-
}, {
|
|
824
|
-
name: publisher.name,
|
|
825
|
-
ip: publisher.ip
|
|
826
|
-
});
|
|
827
|
-
fileLog(
|
|
828
|
-
// eslint-disable-next-line max-len
|
|
829
|
-
`[${ActionKind.EXIT_PUBLISHER}]: ${identifier} is removing , subscriber: ${subscriberIdentifier} will be add tmpSubScriberRelation`,
|
|
830
|
-
"Broker",
|
|
831
|
-
"info"
|
|
832
|
-
);
|
|
833
|
-
});
|
|
834
|
-
this._publisherMap.delete(identifier);
|
|
835
|
-
fileLog(`[${ActionKind.EXIT_PUBLISHER}]: ${identifier} is removed `, "Broker", "info");
|
|
836
|
-
if (!this.hasPublishers) {
|
|
837
|
-
fileLog(`[${ActionKind.EXIT_PUBLISHER}]: _publisherMap is empty, all server will exit `, "Broker", "warn");
|
|
838
|
-
this.exit();
|
|
839
|
-
}
|
|
840
|
-
} catch (err) {
|
|
841
|
-
const msg = error(err, ActionKind.EXIT_PUBLISHER, "Broker");
|
|
842
|
-
client.send(msg);
|
|
843
|
-
client.close();
|
|
844
|
-
}
|
|
845
|
-
});
|
|
846
|
-
}
|
|
847
|
-
_addWebClient(context, client) {
|
|
848
|
-
return __async(this, null, function* () {
|
|
849
|
-
const { name } = context != null ? context : {};
|
|
850
|
-
const identifier = getIdentifier({
|
|
851
|
-
name
|
|
852
|
-
});
|
|
853
|
-
if (this._webClientMap.has(identifier)) {
|
|
854
|
-
fileLog(`${identifier}} has been added, this action will override prev WebClient`, "Broker", "warn");
|
|
855
|
-
}
|
|
856
|
-
try {
|
|
857
|
-
this._webClientMap.set(identifier, client);
|
|
858
|
-
fileLog(`${identifier} adding WebClient Succeed`, "Broker", "info");
|
|
859
|
-
} catch (err) {
|
|
860
|
-
const msg = error(err, ActionKind.ADD_WEB_CLIENT, "Broker");
|
|
861
|
-
client.send(msg);
|
|
862
|
-
client.close();
|
|
863
|
-
}
|
|
864
|
-
});
|
|
865
|
-
}
|
|
866
|
-
_notifyWebClient(context, client) {
|
|
867
|
-
return __async(this, null, function* () {
|
|
868
|
-
const { name, updateMode } = context != null ? context : {};
|
|
869
|
-
const identifier = getIdentifier({
|
|
870
|
-
name
|
|
871
|
-
});
|
|
872
|
-
const webClient = this._webClientMap.get(identifier);
|
|
873
|
-
if (!webClient) {
|
|
874
|
-
fileLog(`[${ActionKind.NOTIFY_WEB_CLIENT}] ${identifier} has not been added, this action will be ignored`, "Broker", "warn");
|
|
875
|
-
return;
|
|
876
|
-
}
|
|
877
|
-
try {
|
|
878
|
-
const api = new ReloadWebClientAPI({
|
|
879
|
-
name,
|
|
880
|
-
updateMode
|
|
881
|
-
});
|
|
882
|
-
webClient.send(JSON.stringify(api));
|
|
883
|
-
fileLog(`[${ActionKind.NOTIFY_WEB_CLIENT}] Notify ${name} WebClient Succeed`, "Broker", "info");
|
|
884
|
-
} catch (err) {
|
|
885
|
-
const msg = error(err, ActionKind.NOTIFY_WEB_CLIENT, "Broker");
|
|
886
|
-
client.send(msg);
|
|
887
|
-
client.close();
|
|
888
|
-
}
|
|
889
|
-
});
|
|
890
|
-
}
|
|
891
|
-
// app1 consumes provider1, and provider1 not launch. this._tmpSubscriberShelter at this time: {provider1: Map{subscribers: Map{app1: app1+ip+client'}, timestamp: 'xx'} }
|
|
892
|
-
_addTmpSubScriberRelation(subscriber, publisher) {
|
|
893
|
-
const publisherIdentifier = getIdentifier({
|
|
894
|
-
name: publisher.name,
|
|
895
|
-
ip: publisher.ip
|
|
896
|
-
});
|
|
897
|
-
const subscriberIdentifier = subscriber.name;
|
|
898
|
-
const shelter = this._tmpSubscriberShelter.get(publisherIdentifier);
|
|
899
|
-
if (!shelter) {
|
|
900
|
-
const map = /* @__PURE__ */ new Map();
|
|
901
|
-
map.set(subscriberIdentifier, subscriber);
|
|
902
|
-
this._tmpSubscriberShelter.set(publisherIdentifier, {
|
|
903
|
-
subscribers: map,
|
|
904
|
-
timestamp: Date.now()
|
|
905
|
-
});
|
|
906
|
-
fileLog(`[AddTmpSubscriberRelation] ${publisherIdentifier}'s subscriber has ${subscriberIdentifier} `, "Broker", "info");
|
|
907
|
-
return;
|
|
908
|
-
}
|
|
909
|
-
const tmpSubScriberShelterSubscriber = shelter.subscribers.get(subscriberIdentifier);
|
|
910
|
-
if (tmpSubScriberShelterSubscriber) {
|
|
911
|
-
fileLog(`[AddTmpSubscriberRelation] ${publisherIdentifier} and ${subscriberIdentifier} relation has been added`, "Broker", "warn");
|
|
912
|
-
shelter.subscribers.set(subscriberIdentifier, subscriber);
|
|
913
|
-
shelter.timestamp = Date.now();
|
|
914
|
-
} else {
|
|
915
|
-
fileLog(
|
|
916
|
-
// eslint-disable-next-line max-len
|
|
917
|
-
`AddTmpSubscriberLog ${publisherIdentifier}'s shelter has been added, update shelter.subscribers ${subscriberIdentifier}`,
|
|
918
|
-
"Broker",
|
|
919
|
-
"warn"
|
|
920
|
-
);
|
|
921
|
-
shelter.subscribers.set(subscriberIdentifier, subscriber);
|
|
922
|
-
}
|
|
923
|
-
}
|
|
924
|
-
_getTmpSubScribers(publisherIdentifier) {
|
|
925
|
-
var _a3;
|
|
926
|
-
return (_a3 = this._tmpSubscriberShelter.get(publisherIdentifier)) == null ? void 0 : _a3.subscribers;
|
|
927
|
-
}
|
|
928
|
-
// after adding publisher, it will change the temp subscriber to regular subscriber
|
|
929
|
-
_consumeTmpSubScribers(publisher, tmpSubScribers) {
|
|
930
|
-
tmpSubScribers.forEach((tmpSubScriber, identifier) => {
|
|
931
|
-
fileLog(`notifyTmpSubScribers ${publisher.name} will be add a subscriber: ${identifier} `, "Broker", "warn");
|
|
932
|
-
publisher.addSubscriber(identifier, tmpSubScriber.client);
|
|
933
|
-
publisher.notifySubscriber(identifier, {
|
|
934
|
-
updateKind: UpdateKind.UPDATE_TYPE,
|
|
935
|
-
updateMode: UpdateMode.PASSIVE,
|
|
936
|
-
updateSourcePaths: [
|
|
937
|
-
publisher.name
|
|
938
|
-
],
|
|
939
|
-
remoteTypeTarPath: publisher.remoteTypeTarPath,
|
|
940
|
-
name: publisher.name
|
|
941
|
-
});
|
|
942
|
-
});
|
|
943
|
-
}
|
|
944
|
-
_clearTmpSubScriberRelation(identifier) {
|
|
945
|
-
this._tmpSubscriberShelter.delete(identifier);
|
|
946
|
-
}
|
|
947
|
-
_clearTmpSubScriberRelations() {
|
|
948
|
-
this._tmpSubscriberShelter.clear();
|
|
949
|
-
}
|
|
950
|
-
_disconnect() {
|
|
951
|
-
this._publisherMap.forEach((publisher) => {
|
|
952
|
-
publisher.close();
|
|
953
|
-
});
|
|
954
|
-
}
|
|
955
|
-
// Every day on 0/6/9/12/15//18, Publishers that have not been connected within 1.5 hours will be cleared regularly.
|
|
956
|
-
// If process.env.FEDERATION_SERVER_TEST is set, it will be read at a specified time.
|
|
957
|
-
_setSchedule() {
|
|
958
|
-
const rule = new schedule.RecurrenceRule();
|
|
959
|
-
if (Number(process.env["FEDERATION_SERVER_TEST"])) {
|
|
960
|
-
const interval = Number(process.env["FEDERATION_SERVER_TEST"]) / 1e3;
|
|
961
|
-
const second = [];
|
|
962
|
-
for (let i = 0; i < 60; i = i + interval) {
|
|
963
|
-
second.push(i);
|
|
964
|
-
}
|
|
965
|
-
rule.second = second;
|
|
966
|
-
} else {
|
|
967
|
-
rule.second = 0;
|
|
968
|
-
rule.hour = [
|
|
969
|
-
0,
|
|
970
|
-
3,
|
|
971
|
-
6,
|
|
972
|
-
9,
|
|
973
|
-
12,
|
|
974
|
-
15,
|
|
975
|
-
18
|
|
976
|
-
];
|
|
977
|
-
rule.minute = 0;
|
|
978
|
-
}
|
|
979
|
-
const serverTest = Number(process.env["FEDERATION_SERVER_TEST"]);
|
|
980
|
-
this._scheduleJob = schedule.scheduleJob(rule, () => {
|
|
981
|
-
this._tmpSubscriberShelter.forEach((tmpSubscriber, identifier) => {
|
|
982
|
-
fileLog(` _clearTmpSubScriberRelation ${identifier}, ${Date.now() - tmpSubscriber.timestamp >= (process.env["GARFISH_MODULE_SERVER_TEST"] ? serverTest : _Broker.DEFAULT_WAITING_TIME)}`, "Broker", "info");
|
|
983
|
-
if (Date.now() - tmpSubscriber.timestamp >= (process.env["FEDERATION_SERVER_TEST"] ? serverTest : _Broker.DEFAULT_WAITING_TIME)) {
|
|
984
|
-
this._clearTmpSubScriberRelation(identifier);
|
|
985
|
-
}
|
|
986
|
-
});
|
|
987
|
-
});
|
|
988
|
-
}
|
|
989
|
-
_clearSchedule() {
|
|
990
|
-
if (!this._scheduleJob) {
|
|
991
|
-
return;
|
|
992
|
-
}
|
|
993
|
-
this._scheduleJob.cancel();
|
|
994
|
-
this._scheduleJob = null;
|
|
995
|
-
}
|
|
996
|
-
_stopWhenSIGTERMOrSIGINT() {
|
|
997
|
-
process.on("SIGTERM", () => {
|
|
998
|
-
this.exit();
|
|
999
|
-
});
|
|
1000
|
-
process.on("SIGINT", () => {
|
|
1001
|
-
this.exit();
|
|
1002
|
-
});
|
|
1003
|
-
}
|
|
1004
|
-
_handleUnexpectedExit() {
|
|
1005
|
-
process.on("unhandledRejection", (error2) => {
|
|
1006
|
-
console.error("Unhandled Rejection Error: ", error2);
|
|
1007
|
-
fileLog(`Unhandled Rejection Error: ${error2}`, "Broker", "fatal");
|
|
1008
|
-
process.exit(1);
|
|
1009
|
-
});
|
|
1010
|
-
process.on("uncaughtException", (error2) => {
|
|
1011
|
-
console.error("Unhandled Exception Error: ", error2);
|
|
1012
|
-
fileLog(`Unhandled Rejection Error: ${error2}`, "Broker", "fatal");
|
|
1013
|
-
process.exit(1);
|
|
1014
|
-
});
|
|
1015
|
-
}
|
|
1016
|
-
start() {
|
|
1017
|
-
return __async(this, null, function* () {
|
|
1018
|
-
});
|
|
1019
|
-
}
|
|
1020
|
-
exit() {
|
|
1021
|
-
const brokerExitLog = new BrokerExitLog();
|
|
1022
|
-
this.broadcast(JSON.stringify(brokerExitLog));
|
|
1023
|
-
this._disconnect();
|
|
1024
|
-
this._clearSchedule();
|
|
1025
|
-
this._clearTmpSubScriberRelations();
|
|
1026
|
-
this._webSocketServer && this._webSocketServer.close();
|
|
1027
|
-
this._secureWebSocketServer && this._secureWebSocketServer.close();
|
|
1028
|
-
process.exit(0);
|
|
1029
|
-
}
|
|
1030
|
-
broadcast(message) {
|
|
1031
|
-
var _a3, _b;
|
|
1032
|
-
fileLog(`[broadcast] exit info : ${JSON.stringify(message)}`, "Broker", "warn");
|
|
1033
|
-
(_a3 = this._webSocketServer) == null ? void 0 : _a3.clients.forEach((client) => {
|
|
1034
|
-
client.send(JSON.stringify(message));
|
|
1035
|
-
});
|
|
1036
|
-
(_b = this._secureWebSocketServer) == null ? void 0 : _b.clients.forEach((client) => {
|
|
1037
|
-
client.send(JSON.stringify(message));
|
|
1038
|
-
});
|
|
1039
|
-
}
|
|
1040
|
-
};
|
|
1041
|
-
__name(_Broker, "Broker");
|
|
1042
|
-
__publicField(_Broker, "WEB_SOCKET_CONNECT_MAGIC_ID", WEB_SOCKET_CONNECT_MAGIC_ID);
|
|
1043
|
-
__publicField(_Broker, "DEFAULT_WEB_SOCKET_PORT", DEFAULT_WEB_SOCKET_PORT);
|
|
1044
|
-
__publicField(_Broker, "DEFAULT_SECURE_WEB_SOCKET_PORT", 16324);
|
|
1045
|
-
__publicField(_Broker, "DEFAULT_WAITING_TIME", 1.5 * 60 * 60 * 1e3);
|
|
1046
|
-
var Broker = _Broker;
|
|
1047
146
|
|
|
1048
147
|
// packages/dts-plugin/src/server/broker/createBroker.ts
|
|
1049
148
|
import { fork } from "child_process";
|
|
@@ -1090,21 +189,21 @@ var _ModuleFederationDevServer = class _ModuleFederationDevServer {
|
|
|
1090
189
|
return;
|
|
1091
190
|
}
|
|
1092
191
|
fileLog(`Publisher:${this._name} Trying to connect to ws://${this._ip}:${Broker.DEFAULT_WEB_SOCKET_PORT}...`, MF_SERVER_IDENTIFIER, "info");
|
|
1093
|
-
this._publishWebSocket = new
|
|
192
|
+
this._publishWebSocket = new WebSocket(`ws://${this._ip}:${Broker.DEFAULT_WEB_SOCKET_PORT}?WEB_SOCKET_CONNECT_MAGIC_ID=${Broker.WEB_SOCKET_CONNECT_MAGIC_ID}`);
|
|
1094
193
|
this._publishWebSocket.on("open", () => {
|
|
1095
|
-
var
|
|
194
|
+
var _a2;
|
|
1096
195
|
fileLog(`Current pid: ${process.pid}, publisher:${this._name} connected to ws://${this._ip}:${Broker.DEFAULT_WEB_SOCKET_PORT}, starting service...`, MF_SERVER_IDENTIFIER, "info");
|
|
1097
196
|
this._isConnected = true;
|
|
1098
|
-
const
|
|
197
|
+
const addPublisherAction = new AddPublisherAction({
|
|
1099
198
|
name: this._name,
|
|
1100
199
|
ip: this._ip,
|
|
1101
200
|
remoteTypeTarPath: this._remoteTypeTarPath
|
|
1102
201
|
});
|
|
1103
|
-
(
|
|
202
|
+
(_a2 = this._publishWebSocket) == null ? void 0 : _a2.send(JSON.stringify(addPublisherAction));
|
|
1104
203
|
this._connectSubscribers();
|
|
1105
204
|
});
|
|
1106
205
|
this._publishWebSocket.on("message", (message) => __async(this, null, function* () {
|
|
1107
|
-
var
|
|
206
|
+
var _a2, _b;
|
|
1108
207
|
try {
|
|
1109
208
|
const parsedMessage = JSON.parse(message.toString());
|
|
1110
209
|
if (parsedMessage.type === "Log") {
|
|
@@ -1136,7 +235,7 @@ var _ModuleFederationDevServer = class _ModuleFederationDevServer {
|
|
|
1136
235
|
ip: remote.ip
|
|
1137
236
|
}))
|
|
1138
237
|
});
|
|
1139
|
-
(
|
|
238
|
+
(_a2 = this._publishWebSocket) == null ? void 0 : _a2.send(JSON.stringify(exitPublisher));
|
|
1140
239
|
(_b = this._publishWebSocket) == null ? void 0 : _b.send(JSON.stringify(exitSubscriber));
|
|
1141
240
|
fileLog("Parse messages error, ModuleFederationDevServer will exit...", MF_SERVER_IDENTIFIER, "fatal");
|
|
1142
241
|
this._exit();
|
|
@@ -1163,7 +262,7 @@ var _ModuleFederationDevServer = class _ModuleFederationDevServer {
|
|
|
1163
262
|
name,
|
|
1164
263
|
ip
|
|
1165
264
|
});
|
|
1166
|
-
this._subscriberWebsocketMap[identifier] = new
|
|
265
|
+
this._subscriberWebsocketMap[identifier] = new WebSocket(`ws://${ip}:${Broker.DEFAULT_WEB_SOCKET_PORT}?WEB_SOCKET_CONNECT_MAGIC_ID=${Broker.WEB_SOCKET_CONNECT_MAGIC_ID}`);
|
|
1167
266
|
this._subscriberWebsocketMap[identifier].on("open", () => {
|
|
1168
267
|
fileLog(`Current pid: ${process.pid} remote module: ${name} connected to ws://${ip}:${Broker.DEFAULT_WEB_SOCKET_PORT}, starting service...`, MF_SERVER_IDENTIFIER, "info");
|
|
1169
268
|
const addSubscriber = new AddSubscriberAction({
|
|
@@ -1231,7 +330,7 @@ var _ModuleFederationDevServer = class _ModuleFederationDevServer {
|
|
|
1231
330
|
// app1 consumes provider1. And the function will be triggered when provider1 code change.
|
|
1232
331
|
_updateSubscriber(options) {
|
|
1233
332
|
return __async(this, null, function* () {
|
|
1234
|
-
var
|
|
333
|
+
var _a2;
|
|
1235
334
|
const { updateMode, updateKind, updateSourcePaths, name, remoteTypeTarPath, remoteInfo } = options;
|
|
1236
335
|
fileLog(
|
|
1237
336
|
// eslint-disable-next-line max-len
|
|
@@ -1281,7 +380,7 @@ var _ModuleFederationDevServer = class _ModuleFederationDevServer {
|
|
|
1281
380
|
MF_SERVER_IDENTIFIER,
|
|
1282
381
|
"info"
|
|
1283
382
|
);
|
|
1284
|
-
(
|
|
383
|
+
(_a2 = this._publishWebSocket) == null ? void 0 : _a2.send(JSON.stringify(updatePublisher));
|
|
1285
384
|
});
|
|
1286
385
|
}
|
|
1287
386
|
_tryCreateBackgroundBroker(err) {
|
|
@@ -1320,19 +419,19 @@ var _ModuleFederationDevServer = class _ModuleFederationDevServer {
|
|
|
1320
419
|
});
|
|
1321
420
|
}
|
|
1322
421
|
_handleUnexpectedExit() {
|
|
1323
|
-
process.on("unhandledRejection", (
|
|
422
|
+
process.on("unhandledRejection", (error) => {
|
|
1324
423
|
if (this._isReconnecting) {
|
|
1325
424
|
return;
|
|
1326
425
|
}
|
|
1327
|
-
console.error("Unhandled Rejection Error: ",
|
|
426
|
+
console.error("Unhandled Rejection Error: ", error);
|
|
1328
427
|
fileLog(`Process(${process.pid}) unhandledRejection, garfishModuleServer will exit...`, MF_SERVER_IDENTIFIER, "error");
|
|
1329
428
|
this._exit();
|
|
1330
429
|
});
|
|
1331
|
-
process.on("uncaughtException", (
|
|
430
|
+
process.on("uncaughtException", (error) => {
|
|
1332
431
|
if (this._isReconnecting) {
|
|
1333
432
|
return;
|
|
1334
433
|
}
|
|
1335
|
-
console.error("Unhandled Exception Error: ",
|
|
434
|
+
console.error("Unhandled Exception Error: ", error);
|
|
1336
435
|
fileLog(`Process(${process.pid}) uncaughtException, garfishModuleServer will exit...`, MF_SERVER_IDENTIFIER, "error");
|
|
1337
436
|
this._exit();
|
|
1338
437
|
});
|
|
@@ -1363,11 +462,11 @@ var _ModuleFederationDevServer = class _ModuleFederationDevServer {
|
|
|
1363
462
|
if (!this._publishWebSocket || !this._isConnected) {
|
|
1364
463
|
return;
|
|
1365
464
|
}
|
|
1366
|
-
const { updateKind, updateMode, updateSourcePaths } = options;
|
|
465
|
+
const { updateKind, updateMode, updateSourcePaths, clientName } = options;
|
|
1367
466
|
fileLog(`update run, ${this._name} module update, updateKind: ${updateKind}, updateMode: ${updateMode}, updateSourcePaths: ${updateSourcePaths}`, MF_SERVER_IDENTIFIER, "info");
|
|
1368
467
|
if (updateKind === UpdateKind.RELOAD_PAGE) {
|
|
1369
468
|
const notifyWebClient = new NotifyWebClientAction({
|
|
1370
|
-
name: this._name,
|
|
469
|
+
name: clientName || this._name,
|
|
1371
470
|
updateMode
|
|
1372
471
|
});
|
|
1373
472
|
this._publishWebSocket.send(JSON.stringify(notifyWebClient));
|
|
@@ -1444,64 +543,145 @@ function createKoaServer(options) {
|
|
|
1444
543
|
__name(createKoaServer, "createKoaServer");
|
|
1445
544
|
|
|
1446
545
|
// packages/dts-plugin/src/core/lib/archiveHandler.ts
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
if (retries >= hostOptions.maxRetries) {
|
|
1491
|
-
if (hostOptions.abortOnError !== false) {
|
|
1492
|
-
throw error2;
|
|
1493
|
-
}
|
|
1494
|
-
return void 0;
|
|
1495
|
-
}
|
|
546
|
+
import AdmZip from "adm-zip";
|
|
547
|
+
import { resolve as resolve3, join as join3 } from "path";
|
|
548
|
+
import { rm as rm3 } from "fs/promises";
|
|
549
|
+
|
|
550
|
+
// packages/dts-plugin/src/core/lib/utils.ts
|
|
551
|
+
import fs3 from "fs";
|
|
552
|
+
import path3 from "path";
|
|
553
|
+
import axios from "axios";
|
|
554
|
+
import http from "http";
|
|
555
|
+
import https from "https";
|
|
556
|
+
import ansiColors2 from "ansi-colors";
|
|
557
|
+
|
|
558
|
+
// packages/dts-plugin/src/core/configurations/remotePlugin.ts
|
|
559
|
+
import { existsSync as existsSync2 } from "fs";
|
|
560
|
+
import { dirname as dirname2, join as join2, resolve as resolve2, extname as extname2 } from "path";
|
|
561
|
+
import { utils } from "@module-federation/managers";
|
|
562
|
+
import typescript from "typescript";
|
|
563
|
+
var defaultOptions = {
|
|
564
|
+
tsConfigPath: "./tsconfig.json",
|
|
565
|
+
typesFolder: "@mf-types",
|
|
566
|
+
compiledTypesFolder: "compiled-types",
|
|
567
|
+
hostRemoteTypesFolder: "@mf-types",
|
|
568
|
+
deleteTypesFolder: true,
|
|
569
|
+
additionalFilesToCompile: [],
|
|
570
|
+
compilerInstance: "tsc",
|
|
571
|
+
compileInChildProcess: false,
|
|
572
|
+
implementation: "",
|
|
573
|
+
generateAPITypes: false,
|
|
574
|
+
context: process.cwd(),
|
|
575
|
+
abortOnError: true,
|
|
576
|
+
extractRemoteTypes: false,
|
|
577
|
+
extractThirdParty: false
|
|
578
|
+
};
|
|
579
|
+
function getEffectiveRootDir(parsedCommandLine) {
|
|
580
|
+
const compilerOptions = parsedCommandLine.options;
|
|
581
|
+
if (compilerOptions.rootDir) {
|
|
582
|
+
return compilerOptions.rootDir;
|
|
583
|
+
}
|
|
584
|
+
const files = parsedCommandLine.fileNames;
|
|
585
|
+
if (files.length > 0) {
|
|
586
|
+
const commonRoot = files.map((file) => dirname2(file)).reduce((commonPath, fileDir) => {
|
|
587
|
+
while (!fileDir.startsWith(commonPath)) {
|
|
588
|
+
commonPath = dirname2(commonPath);
|
|
1496
589
|
}
|
|
590
|
+
return commonPath;
|
|
591
|
+
}, files[0]);
|
|
592
|
+
return commonRoot;
|
|
593
|
+
}
|
|
594
|
+
throw new Error("Can not get effective rootDir, please set compilerOptions.rootDir !");
|
|
595
|
+
}
|
|
596
|
+
__name(getEffectiveRootDir, "getEffectiveRootDir");
|
|
597
|
+
var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiledTypesFolder, context, additionalFilesToCompile }, mapComponentsToExpose) => {
|
|
598
|
+
var _a2;
|
|
599
|
+
const resolvedTsConfigPath = resolve2(context, tsConfigPath);
|
|
600
|
+
const readResult = typescript.readConfigFile(resolvedTsConfigPath, typescript.sys.readFile);
|
|
601
|
+
if (readResult.error) {
|
|
602
|
+
throw new Error(readResult.error.messageText.toString());
|
|
603
|
+
}
|
|
604
|
+
const rawTsConfigJson = readResult.config;
|
|
605
|
+
const configContent = typescript.parseJsonConfigFileContent(rawTsConfigJson, typescript.sys, dirname2(resolvedTsConfigPath));
|
|
606
|
+
const rootDir = getEffectiveRootDir(configContent);
|
|
607
|
+
const outDir = resolve2(context, configContent.options.outDir || "dist", typesFolder, compiledTypesFolder);
|
|
608
|
+
const defaultCompilerOptions = {
|
|
609
|
+
rootDir,
|
|
610
|
+
emitDeclarationOnly: true,
|
|
611
|
+
noEmit: false,
|
|
612
|
+
declaration: true,
|
|
613
|
+
outDir
|
|
614
|
+
};
|
|
615
|
+
rawTsConfigJson.compilerOptions = rawTsConfigJson.compilerOptions || {};
|
|
616
|
+
rawTsConfigJson.compilerOptions = __spreadValues(__spreadValues({}, rawTsConfigJson.compilerOptions), defaultCompilerOptions);
|
|
617
|
+
(_a2 = rawTsConfigJson.compilerOptions) == null ? true : delete _a2.paths;
|
|
618
|
+
const filesToCompile = [
|
|
619
|
+
...Object.values(mapComponentsToExpose),
|
|
620
|
+
...additionalFilesToCompile
|
|
621
|
+
];
|
|
622
|
+
rawTsConfigJson.include = [];
|
|
623
|
+
rawTsConfigJson.files = filesToCompile;
|
|
624
|
+
rawTsConfigJson.exclude = [];
|
|
625
|
+
"references" in rawTsConfigJson && delete rawTsConfigJson.references;
|
|
626
|
+
rawTsConfigJson.extends = resolvedTsConfigPath;
|
|
627
|
+
return rawTsConfigJson;
|
|
628
|
+
}, "readTsConfig");
|
|
629
|
+
var TS_EXTENSIONS = [
|
|
630
|
+
"ts",
|
|
631
|
+
"tsx",
|
|
632
|
+
"vue",
|
|
633
|
+
"svelte"
|
|
634
|
+
];
|
|
635
|
+
var resolveWithExtension = /* @__PURE__ */ __name((exposedPath, context) => {
|
|
636
|
+
if (extname2(exposedPath)) {
|
|
637
|
+
return resolve2(context, exposedPath);
|
|
638
|
+
}
|
|
639
|
+
for (const extension of TS_EXTENSIONS) {
|
|
640
|
+
const exposedPathWithExtension = resolve2(context, `${exposedPath}.${extension}`);
|
|
641
|
+
if (existsSync2(exposedPathWithExtension)) {
|
|
642
|
+
return exposedPathWithExtension;
|
|
1497
643
|
}
|
|
1498
|
-
}
|
|
1499
|
-
|
|
644
|
+
}
|
|
645
|
+
return void 0;
|
|
646
|
+
}, "resolveWithExtension");
|
|
647
|
+
var resolveExposes = /* @__PURE__ */ __name((remoteOptions) => {
|
|
648
|
+
const parsedOptions = utils.parseOptions(remoteOptions.moduleFederationConfig.exposes || {}, (item, key) => ({
|
|
649
|
+
exposePath: Array.isArray(item) ? item[0] : item,
|
|
650
|
+
key
|
|
651
|
+
}), (item, key) => ({
|
|
652
|
+
exposePath: Array.isArray(item.import) ? item.import[0] : item.import[0],
|
|
653
|
+
key
|
|
654
|
+
}));
|
|
655
|
+
return parsedOptions.reduce((accumulator, item) => {
|
|
656
|
+
const { exposePath, key } = item[1];
|
|
657
|
+
accumulator[key] = resolveWithExtension(exposePath, remoteOptions.context) || resolveWithExtension(join2(exposePath, "index"), remoteOptions.context) || exposePath;
|
|
658
|
+
return accumulator;
|
|
659
|
+
}, {});
|
|
660
|
+
}, "resolveExposes");
|
|
661
|
+
var retrieveRemoteConfig = /* @__PURE__ */ __name((options) => {
|
|
662
|
+
validateOptions(options);
|
|
663
|
+
const remoteOptions = __spreadValues(__spreadValues({}, defaultOptions), options);
|
|
664
|
+
const mapComponentsToExpose = resolveExposes(remoteOptions);
|
|
665
|
+
const tsConfig = readTsConfig(remoteOptions, mapComponentsToExpose);
|
|
666
|
+
return {
|
|
667
|
+
tsConfig,
|
|
668
|
+
mapComponentsToExpose,
|
|
669
|
+
remoteOptions
|
|
670
|
+
};
|
|
671
|
+
}, "retrieveRemoteConfig");
|
|
672
|
+
|
|
673
|
+
// packages/dts-plugin/src/core/lib/DTSManager.ts
|
|
674
|
+
import ansiColors from "ansi-colors";
|
|
675
|
+
import path2 from "path";
|
|
676
|
+
import { rm as rm2 } from "fs/promises";
|
|
677
|
+
import fs2 from "fs";
|
|
678
|
+
import { MANIFEST_EXT, inferAutoPublicPath } from "@module-federation/sdk";
|
|
679
|
+
import { ThirdPartyExtractor as ThirdPartyExtractor2 } from "@module-federation/third-party-dts-extractor";
|
|
1500
680
|
|
|
1501
681
|
// packages/dts-plugin/src/core/configurations/hostPlugin.ts
|
|
1502
682
|
import { parseEntry, ENCODE_NAME_PREFIX, decodeName } from "@module-federation/sdk";
|
|
1503
|
-
import { utils } from "@module-federation/managers";
|
|
1504
|
-
var
|
|
683
|
+
import { utils as utils2 } from "@module-federation/managers";
|
|
684
|
+
var defaultOptions2 = {
|
|
1505
685
|
typesFolder: "@mf-types",
|
|
1506
686
|
remoteTypesFolder: "@mf-types",
|
|
1507
687
|
deleteTypesFolder: true,
|
|
@@ -1509,7 +689,8 @@ var defaultOptions = {
|
|
|
1509
689
|
implementation: "",
|
|
1510
690
|
context: process.cwd(),
|
|
1511
691
|
abortOnError: true,
|
|
1512
|
-
consumeAPITypes: false
|
|
692
|
+
consumeAPITypes: false,
|
|
693
|
+
runtimePkgs: []
|
|
1513
694
|
};
|
|
1514
695
|
var buildZipUrl = /* @__PURE__ */ __name((hostOptions, url) => {
|
|
1515
696
|
const remoteUrl = new URL(url, "file:");
|
|
@@ -1541,7 +722,7 @@ var retrieveRemoteInfo = /* @__PURE__ */ __name((options) => {
|
|
|
1541
722
|
};
|
|
1542
723
|
}, "retrieveRemoteInfo");
|
|
1543
724
|
var resolveRemotes = /* @__PURE__ */ __name((hostOptions) => {
|
|
1544
|
-
const parsedOptions =
|
|
725
|
+
const parsedOptions = utils2.parseOptions(hostOptions.moduleFederationConfig.remotes || {}, (item, key) => ({
|
|
1545
726
|
remote: Array.isArray(item) ? item[0] : item,
|
|
1546
727
|
key
|
|
1547
728
|
}), (item, key) => ({
|
|
@@ -1560,7 +741,7 @@ var resolveRemotes = /* @__PURE__ */ __name((hostOptions) => {
|
|
|
1560
741
|
}, "resolveRemotes");
|
|
1561
742
|
var retrieveHostConfig = /* @__PURE__ */ __name((options) => {
|
|
1562
743
|
validateOptions(options);
|
|
1563
|
-
const hostOptions = __spreadValues(__spreadValues({},
|
|
744
|
+
const hostOptions = __spreadValues(__spreadValues({}, defaultOptions2), options);
|
|
1564
745
|
const mapRemotesToDownload = resolveRemotes(hostOptions);
|
|
1565
746
|
return {
|
|
1566
747
|
hostOptions,
|
|
@@ -1568,6 +749,11 @@ var retrieveHostConfig = /* @__PURE__ */ __name((options) => {
|
|
|
1568
749
|
};
|
|
1569
750
|
}, "retrieveHostConfig");
|
|
1570
751
|
|
|
752
|
+
// packages/dts-plugin/src/core/constant.ts
|
|
753
|
+
var REMOTE_ALIAS_IDENTIFIER = "REMOTE_ALIAS_IDENTIFIER";
|
|
754
|
+
var REMOTE_API_TYPES_FILE_NAME = "apis.d.ts";
|
|
755
|
+
var HOST_API_TYPES_FILE_NAME = "index.d.ts";
|
|
756
|
+
|
|
1571
757
|
// packages/dts-plugin/src/core/lib/DTSManager.ts
|
|
1572
758
|
var _a;
|
|
1573
759
|
var DTSManager = (_a = class {
|
|
@@ -1578,11 +764,7 @@ var DTSManager = (_a = class {
|
|
|
1578
764
|
__publicField(this, "loadedRemoteAPIAlias");
|
|
1579
765
|
__publicField(this, "extraOptions");
|
|
1580
766
|
__publicField(this, "updatedRemoteInfos");
|
|
1581
|
-
this.options =
|
|
1582
|
-
if (key === "manifest") {
|
|
1583
|
-
return false;
|
|
1584
|
-
}
|
|
1585
|
-
});
|
|
767
|
+
this.options = cloneDeepOptions(options);
|
|
1586
768
|
this.runtimePkgs = [
|
|
1587
769
|
"@module-federation/runtime",
|
|
1588
770
|
"@module-federation/enhanced/runtime",
|
|
@@ -1641,7 +823,7 @@ var DTSManager = (_a = class {
|
|
|
1641
823
|
}
|
|
1642
824
|
generateTypes() {
|
|
1643
825
|
return __async(this, null, function* () {
|
|
1644
|
-
var
|
|
826
|
+
var _a2;
|
|
1645
827
|
try {
|
|
1646
828
|
const { options } = this;
|
|
1647
829
|
if (!options.remote) {
|
|
@@ -1666,7 +848,7 @@ var DTSManager = (_a = class {
|
|
|
1666
848
|
}
|
|
1667
849
|
try {
|
|
1668
850
|
if (remoteOptions.deleteTypesFolder) {
|
|
1669
|
-
yield
|
|
851
|
+
yield rm2(retrieveMfTypesPath(tsConfig, remoteOptions), {
|
|
1670
852
|
recursive: true,
|
|
1671
853
|
force: true
|
|
1672
854
|
});
|
|
@@ -1677,11 +859,11 @@ var DTSManager = (_a = class {
|
|
|
1677
859
|
}
|
|
1678
860
|
}
|
|
1679
861
|
console.log(ansiColors.green("Federated types created correctly"));
|
|
1680
|
-
} catch (
|
|
1681
|
-
if (((
|
|
1682
|
-
console.error(ansiColors.red(`Unable to compile federated types, ${
|
|
862
|
+
} catch (error) {
|
|
863
|
+
if (((_a2 = this.options.remote) == null ? void 0 : _a2.abortOnError) === false) {
|
|
864
|
+
console.error(ansiColors.red(`Unable to compile federated types, ${error}`));
|
|
1683
865
|
} else {
|
|
1684
|
-
throw
|
|
866
|
+
throw error;
|
|
1685
867
|
}
|
|
1686
868
|
}
|
|
1687
869
|
});
|
|
@@ -1793,7 +975,16 @@ var DTSManager = (_a = class {
|
|
|
1793
975
|
...packageTypes,
|
|
1794
976
|
"Y"
|
|
1795
977
|
].join(" :\n")} ;`;
|
|
1796
|
-
const
|
|
978
|
+
const runtimePkgs = /* @__PURE__ */ new Set();
|
|
979
|
+
[
|
|
980
|
+
...this.runtimePkgs,
|
|
981
|
+
...hostOptions.runtimePkgs
|
|
982
|
+
].forEach((pkg) => {
|
|
983
|
+
runtimePkgs.add(pkg);
|
|
984
|
+
});
|
|
985
|
+
const pkgsDeclareStr = [
|
|
986
|
+
...runtimePkgs
|
|
987
|
+
].map((pkg) => {
|
|
1797
988
|
return `declare module "${pkg}" {
|
|
1798
989
|
${remoteKeysStr}
|
|
1799
990
|
${packageTypesStr}
|
|
@@ -1826,7 +1017,7 @@ var DTSManager = (_a = class {
|
|
|
1826
1017
|
}
|
|
1827
1018
|
consumeTypes() {
|
|
1828
1019
|
return __async(this, null, function* () {
|
|
1829
|
-
var
|
|
1020
|
+
var _a2;
|
|
1830
1021
|
try {
|
|
1831
1022
|
const { options } = this;
|
|
1832
1023
|
if (!options.host) {
|
|
@@ -1853,7 +1044,7 @@ var DTSManager = (_a = class {
|
|
|
1853
1044
|
}
|
|
1854
1045
|
console.log(ansiColors.green("Federated types extraction completed"));
|
|
1855
1046
|
} catch (err) {
|
|
1856
|
-
if (((
|
|
1047
|
+
if (((_a2 = this.options.host) == null ? void 0 : _a2.abortOnError) === false) {
|
|
1857
1048
|
fileLog(`Unable to consume federated types, ${err}`, "consumeTypes", "error");
|
|
1858
1049
|
} else {
|
|
1859
1050
|
throw err;
|
|
@@ -1863,10 +1054,10 @@ var DTSManager = (_a = class {
|
|
|
1863
1054
|
}
|
|
1864
1055
|
updateTypes(options) {
|
|
1865
1056
|
return __async(this, null, function* () {
|
|
1866
|
-
var
|
|
1057
|
+
var _a2, _b, _c;
|
|
1867
1058
|
try {
|
|
1868
1059
|
const { remoteName, updateMode, remoteInfo: updatedRemoteInfo, once } = options;
|
|
1869
|
-
const hostName = (_c = (_b = (
|
|
1060
|
+
const hostName = (_c = (_b = (_a2 = this.options) == null ? void 0 : _a2.host) == null ? void 0 : _b.moduleFederationConfig) == null ? void 0 : _c.name;
|
|
1870
1061
|
fileLog(`updateTypes options:, ${JSON.stringify(options, null, 2)}`, "consumeTypes", "info");
|
|
1871
1062
|
if (updateMode === UpdateMode.POSITIVE && remoteName === hostName) {
|
|
1872
1063
|
if (!this.options.remote) {
|
|
@@ -1880,7 +1071,7 @@ var DTSManager = (_a = class {
|
|
|
1880
1071
|
}
|
|
1881
1072
|
const { hostOptions, mapRemotesToDownload } = retrieveHostConfig(this.options.host);
|
|
1882
1073
|
const loadedRemoteInfo = Object.values(remoteAliasMap).find((i) => i.name === remoteName);
|
|
1883
|
-
const
|
|
1074
|
+
const consumeTypes = /* @__PURE__ */ __name((requiredRemoteInfo) => __async(this, null, function* () {
|
|
1884
1075
|
const [_alias, destinationPath] = yield this.consumeTargetRemotes(hostOptions, requiredRemoteInfo);
|
|
1885
1076
|
yield this.downloadAPITypes(requiredRemoteInfo, destinationPath);
|
|
1886
1077
|
}), "consumeTypes");
|
|
@@ -1893,10 +1084,10 @@ var DTSManager = (_a = class {
|
|
|
1893
1084
|
const requiredRemoteInfo = yield this.requestRemoteManifest(remoteInfo);
|
|
1894
1085
|
this.remoteAliasMap[remoteInfo.alias] = requiredRemoteInfo;
|
|
1895
1086
|
}
|
|
1896
|
-
yield
|
|
1087
|
+
yield consumeTypes(this.remoteAliasMap[remoteInfo.alias]);
|
|
1897
1088
|
} else if (updatedRemoteInfo) {
|
|
1898
1089
|
const consumeDynamicRemoteTypes = /* @__PURE__ */ __name(() => __async(this, null, function* () {
|
|
1899
|
-
yield
|
|
1090
|
+
yield consumeTypes(this.updatedRemoteInfos[updatedRemoteInfo.name]);
|
|
1900
1091
|
this.consumeAPITypes(hostOptions);
|
|
1901
1092
|
}), "consumeDynamicRemoteTypes");
|
|
1902
1093
|
if (!this.updatedRemoteInfos[updatedRemoteInfo.name]) {
|
|
@@ -1915,7 +1106,7 @@ var DTSManager = (_a = class {
|
|
|
1915
1106
|
}
|
|
1916
1107
|
}
|
|
1917
1108
|
} else {
|
|
1918
|
-
yield
|
|
1109
|
+
yield consumeTypes(loadedRemoteInfo);
|
|
1919
1110
|
}
|
|
1920
1111
|
}
|
|
1921
1112
|
} catch (err) {
|
|
@@ -1926,6 +1117,7 @@ var DTSManager = (_a = class {
|
|
|
1926
1117
|
}, __name(_a, "DTSManager"), _a);
|
|
1927
1118
|
|
|
1928
1119
|
// packages/dts-plugin/src/core/lib/utils.ts
|
|
1120
|
+
import cloneDeepWith from "lodash.clonedeepwith";
|
|
1929
1121
|
function getDTSManagerConstructor(implementation) {
|
|
1930
1122
|
if (implementation) {
|
|
1931
1123
|
const NewConstructor = __require(implementation);
|
|
@@ -1997,6 +1189,18 @@ var isTSProject = /* @__PURE__ */ __name((dtsOptions, context = process.cwd()) =
|
|
|
1997
1189
|
return false;
|
|
1998
1190
|
}
|
|
1999
1191
|
}, "isTSProject");
|
|
1192
|
+
function cloneDeepOptions(options) {
|
|
1193
|
+
const excludeKeys = [
|
|
1194
|
+
"manifest",
|
|
1195
|
+
"async"
|
|
1196
|
+
];
|
|
1197
|
+
return cloneDeepWith(options, (_value, key) => {
|
|
1198
|
+
if (typeof key === "string" && excludeKeys.includes(key)) {
|
|
1199
|
+
return false;
|
|
1200
|
+
}
|
|
1201
|
+
});
|
|
1202
|
+
}
|
|
1203
|
+
__name(cloneDeepOptions, "cloneDeepOptions");
|
|
2000
1204
|
function axiosGet(url, config) {
|
|
2001
1205
|
return __async(this, null, function* () {
|
|
2002
1206
|
const httpAgent = new http.Agent({
|
|
@@ -2013,147 +1217,72 @@ function axiosGet(url, config) {
|
|
|
2013
1217
|
}
|
|
2014
1218
|
__name(axiosGet, "axiosGet");
|
|
2015
1219
|
|
|
2016
|
-
// packages/dts-plugin/src/core/
|
|
2017
|
-
var
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
1220
|
+
// packages/dts-plugin/src/core/lib/archiveHandler.ts
|
|
1221
|
+
var retrieveTypesZipPath = /* @__PURE__ */ __name((mfTypesPath, remoteOptions) => join3(mfTypesPath.replace(remoteOptions.typesFolder, ""), `${remoteOptions.typesFolder}.zip`), "retrieveTypesZipPath");
|
|
1222
|
+
var createTypesArchive = /* @__PURE__ */ __name((tsConfig, remoteOptions) => __async(void 0, null, function* () {
|
|
1223
|
+
const mfTypesPath = retrieveMfTypesPath(tsConfig, remoteOptions);
|
|
1224
|
+
const zip = new AdmZip();
|
|
1225
|
+
zip.addLocalFolder(mfTypesPath);
|
|
1226
|
+
return zip.writeZipPromise(retrieveTypesZipPath(mfTypesPath, remoteOptions));
|
|
1227
|
+
}), "createTypesArchive");
|
|
1228
|
+
var downloadErrorLogger = /* @__PURE__ */ __name((destinationFolder, fileToDownload) => (reason) => {
|
|
1229
|
+
throw __spreadProps(__spreadValues({}, reason), {
|
|
1230
|
+
message: `Network error: Unable to download federated mocks for '${destinationFolder}' from '${fileToDownload}' because '${reason.message}'`
|
|
1231
|
+
});
|
|
1232
|
+
}, "downloadErrorLogger");
|
|
1233
|
+
var retrieveTypesArchiveDestinationPath = /* @__PURE__ */ __name((hostOptions, destinationFolder) => {
|
|
1234
|
+
return resolve3(hostOptions.context, hostOptions.typesFolder, destinationFolder);
|
|
1235
|
+
}, "retrieveTypesArchiveDestinationPath");
|
|
1236
|
+
var downloadTypesArchive = /* @__PURE__ */ __name((hostOptions) => {
|
|
1237
|
+
let retries = 0;
|
|
1238
|
+
return (_0) => __async(void 0, [_0], function* ([destinationFolder, fileToDownload]) {
|
|
1239
|
+
const destinationPath = retrieveTypesArchiveDestinationPath(hostOptions, destinationFolder);
|
|
1240
|
+
while (retries++ < hostOptions.maxRetries) {
|
|
1241
|
+
try {
|
|
1242
|
+
const url = fileToDownload;
|
|
1243
|
+
const response = yield axiosGet(url, {
|
|
1244
|
+
responseType: "arraybuffer"
|
|
1245
|
+
}).catch(downloadErrorLogger(destinationFolder, url));
|
|
1246
|
+
try {
|
|
1247
|
+
if (hostOptions.deleteTypesFolder) {
|
|
1248
|
+
yield rm3(destinationPath, {
|
|
1249
|
+
recursive: true,
|
|
1250
|
+
force: true
|
|
1251
|
+
});
|
|
1252
|
+
}
|
|
1253
|
+
} catch (error) {
|
|
1254
|
+
fileLog(`Unable to remove types folder, ${error}`, "downloadTypesArchive", "error");
|
|
1255
|
+
}
|
|
1256
|
+
const zip = new AdmZip(Buffer.from(response.data));
|
|
1257
|
+
zip.extractAllTo(destinationPath, true);
|
|
1258
|
+
return [
|
|
1259
|
+
destinationFolder,
|
|
1260
|
+
destinationPath
|
|
1261
|
+
];
|
|
1262
|
+
} catch (error) {
|
|
1263
|
+
fileLog(`Error during types archive download: ${(error == null ? void 0 : error.message) || "unknown error"}`, "downloadTypesArchive", "error");
|
|
1264
|
+
if (retries >= hostOptions.maxRetries) {
|
|
1265
|
+
if (hostOptions.abortOnError !== false) {
|
|
1266
|
+
throw error;
|
|
1267
|
+
}
|
|
1268
|
+
return void 0;
|
|
1269
|
+
}
|
|
2043
1270
|
}
|
|
2044
|
-
return commonPath;
|
|
2045
|
-
}, files[0]);
|
|
2046
|
-
return commonRoot;
|
|
2047
|
-
}
|
|
2048
|
-
throw new Error("Can not get effective rootDir, please set compilerOptions.rootDir !");
|
|
2049
|
-
}
|
|
2050
|
-
__name(getEffectiveRootDir, "getEffectiveRootDir");
|
|
2051
|
-
var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiledTypesFolder, context, additionalFilesToCompile }, mapComponentsToExpose) => {
|
|
2052
|
-
const resolvedTsConfigPath = resolve3(context, tsConfigPath);
|
|
2053
|
-
const readResult = typescript.readConfigFile(resolvedTsConfigPath, typescript.sys.readFile);
|
|
2054
|
-
if (readResult.error) {
|
|
2055
|
-
throw new Error(readResult.error.messageText.toString());
|
|
2056
|
-
}
|
|
2057
|
-
const rawTsConfigJson = readResult.config;
|
|
2058
|
-
const configContent = typescript.parseJsonConfigFileContent(rawTsConfigJson, typescript.sys, dirname2(resolvedTsConfigPath));
|
|
2059
|
-
const rootDir = getEffectiveRootDir(configContent);
|
|
2060
|
-
const outDir = resolve3(context, configContent.options.outDir || "dist", typesFolder, compiledTypesFolder);
|
|
2061
|
-
const defaultCompilerOptions = {
|
|
2062
|
-
rootDir,
|
|
2063
|
-
emitDeclarationOnly: true,
|
|
2064
|
-
noEmit: false,
|
|
2065
|
-
declaration: true,
|
|
2066
|
-
outDir
|
|
2067
|
-
};
|
|
2068
|
-
rawTsConfigJson.compilerOptions = rawTsConfigJson.compilerOptions || {};
|
|
2069
|
-
rawTsConfigJson.compilerOptions = __spreadValues(__spreadValues({}, rawTsConfigJson.compilerOptions), defaultCompilerOptions);
|
|
2070
|
-
const filesToCompile = [
|
|
2071
|
-
...Object.values(mapComponentsToExpose),
|
|
2072
|
-
...additionalFilesToCompile
|
|
2073
|
-
];
|
|
2074
|
-
rawTsConfigJson.include = [];
|
|
2075
|
-
rawTsConfigJson.files = filesToCompile;
|
|
2076
|
-
rawTsConfigJson.exclude = [];
|
|
2077
|
-
"references" in rawTsConfigJson && delete rawTsConfigJson.references;
|
|
2078
|
-
const extendsPath = rawTsConfigJson.extends;
|
|
2079
|
-
if (extendsPath && extendsPath.startsWith(".")) {
|
|
2080
|
-
rawTsConfigJson.extends = resolve3(context, extendsPath);
|
|
2081
|
-
}
|
|
2082
|
-
return rawTsConfigJson;
|
|
2083
|
-
}, "readTsConfig");
|
|
2084
|
-
var TS_EXTENSIONS = [
|
|
2085
|
-
"ts",
|
|
2086
|
-
"tsx",
|
|
2087
|
-
"vue",
|
|
2088
|
-
"svelte"
|
|
2089
|
-
];
|
|
2090
|
-
var resolveWithExtension = /* @__PURE__ */ __name((exposedPath, context) => {
|
|
2091
|
-
if (extname2(exposedPath)) {
|
|
2092
|
-
return resolve3(context, exposedPath);
|
|
2093
|
-
}
|
|
2094
|
-
for (const extension of TS_EXTENSIONS) {
|
|
2095
|
-
const exposedPathWithExtension = resolve3(context, `${exposedPath}.${extension}`);
|
|
2096
|
-
if (existsSync2(exposedPathWithExtension)) {
|
|
2097
|
-
return exposedPathWithExtension;
|
|
2098
1271
|
}
|
|
2099
|
-
}
|
|
2100
|
-
|
|
2101
|
-
}, "resolveWithExtension");
|
|
2102
|
-
var resolveExposes = /* @__PURE__ */ __name((remoteOptions) => {
|
|
2103
|
-
const parsedOptions = utils2.parseOptions(remoteOptions.moduleFederationConfig.exposes || {}, (item, key) => ({
|
|
2104
|
-
exposePath: Array.isArray(item) ? item[0] : item,
|
|
2105
|
-
key
|
|
2106
|
-
}), (item, key) => ({
|
|
2107
|
-
exposePath: Array.isArray(item.import) ? item.import[0] : item.import[0],
|
|
2108
|
-
key
|
|
2109
|
-
}));
|
|
2110
|
-
return parsedOptions.reduce((accumulator, item) => {
|
|
2111
|
-
const { exposePath, key } = item[1];
|
|
2112
|
-
accumulator[key] = resolveWithExtension(exposePath, remoteOptions.context) || resolveWithExtension(join3(exposePath, "index"), remoteOptions.context) || exposePath;
|
|
2113
|
-
return accumulator;
|
|
2114
|
-
}, {});
|
|
2115
|
-
}, "resolveExposes");
|
|
2116
|
-
var retrieveRemoteConfig = /* @__PURE__ */ __name((options) => {
|
|
2117
|
-
validateOptions(options);
|
|
2118
|
-
const remoteOptions = __spreadValues(__spreadValues({}, defaultOptions2), options);
|
|
2119
|
-
const mapComponentsToExpose = resolveExposes(remoteOptions);
|
|
2120
|
-
const tsConfig = readTsConfig(remoteOptions, mapComponentsToExpose);
|
|
2121
|
-
return {
|
|
2122
|
-
tsConfig,
|
|
2123
|
-
mapComponentsToExpose,
|
|
2124
|
-
remoteOptions
|
|
2125
|
-
};
|
|
2126
|
-
}, "retrieveRemoteConfig");
|
|
1272
|
+
});
|
|
1273
|
+
}, "downloadTypesArchive");
|
|
2127
1274
|
|
|
2128
1275
|
// packages/dts-plugin/src/core/lib/generateTypes.ts
|
|
2129
1276
|
function generateTypes(options) {
|
|
2130
1277
|
return __async(this, null, function* () {
|
|
2131
|
-
var
|
|
2132
|
-
const DTSManagerConstructor = getDTSManagerConstructor((
|
|
1278
|
+
var _a2;
|
|
1279
|
+
const DTSManagerConstructor = getDTSManagerConstructor((_a2 = options.remote) == null ? void 0 : _a2.implementation);
|
|
2133
1280
|
const dtsManager = new DTSManagerConstructor(options);
|
|
2134
1281
|
return dtsManager.generateTypes();
|
|
2135
1282
|
});
|
|
2136
1283
|
}
|
|
2137
1284
|
__name(generateTypes, "generateTypes");
|
|
2138
1285
|
|
|
2139
|
-
// packages/dts-plugin/src/core/lib/DtsWorker.ts
|
|
2140
|
-
import path4 from "path";
|
|
2141
|
-
import cloneDeepWith2 from "lodash.clonedeepwith";
|
|
2142
|
-
|
|
2143
|
-
// packages/dts-plugin/src/core/rpc/index.ts
|
|
2144
|
-
var rpc_exports = {};
|
|
2145
|
-
__export(rpc_exports, {
|
|
2146
|
-
RpcExitError: () => RpcExitError,
|
|
2147
|
-
RpcGMCallTypes: () => RpcGMCallTypes,
|
|
2148
|
-
createRpcWorker: () => createRpcWorker,
|
|
2149
|
-
exposeRpc: () => exposeRpc,
|
|
2150
|
-
getRpcWorkerData: () => getRpcWorkerData,
|
|
2151
|
-
wrapRpc: () => wrapRpc
|
|
2152
|
-
});
|
|
2153
|
-
|
|
2154
|
-
// packages/dts-plugin/src/core/rpc/expose-rpc.ts
|
|
2155
|
-
import process2 from "process";
|
|
2156
|
-
|
|
2157
1286
|
// packages/dts-plugin/src/core/rpc/types.ts
|
|
2158
1287
|
var RpcGMCallTypes;
|
|
2159
1288
|
(function(RpcGMCallTypes2) {
|
|
@@ -2164,6 +1293,7 @@ var RpcGMCallTypes;
|
|
|
2164
1293
|
})(RpcGMCallTypes || (RpcGMCallTypes = {}));
|
|
2165
1294
|
|
|
2166
1295
|
// packages/dts-plugin/src/core/rpc/expose-rpc.ts
|
|
1296
|
+
import process2 from "process";
|
|
2167
1297
|
function exposeRpc(fn) {
|
|
2168
1298
|
const sendMessage = /* @__PURE__ */ __name((message) => new Promise((resolve4, reject) => {
|
|
2169
1299
|
if (!process2.send) {
|
|
@@ -2171,9 +1301,9 @@ function exposeRpc(fn) {
|
|
|
2171
1301
|
} else if (!process2.connected) {
|
|
2172
1302
|
reject(new Error(`Process ${process2.pid} doesn't have open IPC channels`));
|
|
2173
1303
|
} else {
|
|
2174
|
-
process2.send(message, void 0, void 0, (
|
|
2175
|
-
if (
|
|
2176
|
-
reject(
|
|
1304
|
+
process2.send(message, void 0, void 0, (error) => {
|
|
1305
|
+
if (error) {
|
|
1306
|
+
reject(error);
|
|
2177
1307
|
} else {
|
|
2178
1308
|
resolve4(void 0);
|
|
2179
1309
|
}
|
|
@@ -2185,18 +1315,18 @@ function exposeRpc(fn) {
|
|
|
2185
1315
|
if (!process2.send) {
|
|
2186
1316
|
return;
|
|
2187
1317
|
}
|
|
2188
|
-
let value,
|
|
1318
|
+
let value, error;
|
|
2189
1319
|
try {
|
|
2190
1320
|
value = yield fn(...message.args);
|
|
2191
1321
|
} catch (fnError) {
|
|
2192
|
-
|
|
1322
|
+
error = fnError;
|
|
2193
1323
|
}
|
|
2194
1324
|
try {
|
|
2195
|
-
if (
|
|
1325
|
+
if (error) {
|
|
2196
1326
|
yield sendMessage({
|
|
2197
1327
|
type: RpcGMCallTypes.REJECT,
|
|
2198
1328
|
id: message.id,
|
|
2199
|
-
error
|
|
1329
|
+
error
|
|
2200
1330
|
});
|
|
2201
1331
|
} else {
|
|
2202
1332
|
yield sendMessage({
|
|
@@ -2206,9 +1336,9 @@ function exposeRpc(fn) {
|
|
|
2206
1336
|
});
|
|
2207
1337
|
}
|
|
2208
1338
|
} catch (sendError) {
|
|
2209
|
-
if (
|
|
2210
|
-
if (
|
|
2211
|
-
console.error(
|
|
1339
|
+
if (error) {
|
|
1340
|
+
if (error instanceof Error) {
|
|
1341
|
+
console.error(error);
|
|
2212
1342
|
}
|
|
2213
1343
|
}
|
|
2214
1344
|
console.error(sendError);
|
|
@@ -2219,259 +1349,25 @@ function exposeRpc(fn) {
|
|
|
2219
1349
|
}
|
|
2220
1350
|
__name(exposeRpc, "exposeRpc");
|
|
2221
1351
|
|
|
2222
|
-
// packages/dts-plugin/src/core/rpc/rpc-error.ts
|
|
2223
|
-
var _a2;
|
|
2224
|
-
var RpcExitError = (_a2 = class extends Error {
|
|
2225
|
-
constructor(message, code, signal) {
|
|
2226
|
-
super(message);
|
|
2227
|
-
__publicField(this, "code");
|
|
2228
|
-
__publicField(this, "signal");
|
|
2229
|
-
this.code = code;
|
|
2230
|
-
this.signal = signal;
|
|
2231
|
-
this.name = "RpcExitError";
|
|
2232
|
-
}
|
|
2233
|
-
}, __name(_a2, "RpcExitError"), _a2);
|
|
2234
|
-
|
|
2235
|
-
// packages/dts-plugin/src/core/rpc/wrap-rpc.ts
|
|
2236
|
-
function createControlledPromise() {
|
|
2237
|
-
let resolve4 = /* @__PURE__ */ __name(() => void 0, "resolve");
|
|
2238
|
-
let reject = /* @__PURE__ */ __name(() => void 0, "reject");
|
|
2239
|
-
const promise = new Promise((aResolve, aReject) => {
|
|
2240
|
-
resolve4 = aResolve;
|
|
2241
|
-
reject = aReject;
|
|
2242
|
-
});
|
|
2243
|
-
return {
|
|
2244
|
-
promise,
|
|
2245
|
-
resolve: resolve4,
|
|
2246
|
-
reject
|
|
2247
|
-
};
|
|
2248
|
-
}
|
|
2249
|
-
__name(createControlledPromise, "createControlledPromise");
|
|
2250
|
-
function wrapRpc(childProcess, options) {
|
|
2251
|
-
return (...args) => __async(this, null, function* () {
|
|
2252
|
-
if (!childProcess.send) {
|
|
2253
|
-
throw new Error(`Process ${childProcess.pid} doesn't have IPC channels`);
|
|
2254
|
-
} else if (!childProcess.connected) {
|
|
2255
|
-
throw new Error(`Process ${childProcess.pid} doesn't have open IPC channels`);
|
|
2256
|
-
}
|
|
2257
|
-
const { id, once } = options;
|
|
2258
|
-
const { promise: resultPromise, resolve: resolveResult, reject: rejectResult } = createControlledPromise();
|
|
2259
|
-
const { promise: sendPromise, resolve: resolveSend, reject: rejectSend } = createControlledPromise();
|
|
2260
|
-
const handleMessage = /* @__PURE__ */ __name((message) => {
|
|
2261
|
-
if ((message == null ? void 0 : message.id) === id) {
|
|
2262
|
-
if (message.type === RpcGMCallTypes.RESOLVE) {
|
|
2263
|
-
resolveResult(message.value);
|
|
2264
|
-
} else if (message.type === RpcGMCallTypes.REJECT) {
|
|
2265
|
-
rejectResult(message.error);
|
|
2266
|
-
}
|
|
2267
|
-
}
|
|
2268
|
-
if (once && (childProcess == null ? void 0 : childProcess.kill)) {
|
|
2269
|
-
childProcess.kill("SIGTERM");
|
|
2270
|
-
}
|
|
2271
|
-
}, "handleMessage");
|
|
2272
|
-
const handleClose = /* @__PURE__ */ __name((code, signal) => {
|
|
2273
|
-
rejectResult(new RpcExitError(code ? `Process ${childProcess.pid} exited with code ${code}${signal ? ` [${signal}]` : ""}` : `Process ${childProcess.pid} exited${signal ? ` [${signal}]` : ""}`, code, signal));
|
|
2274
|
-
removeHandlers();
|
|
2275
|
-
}, "handleClose");
|
|
2276
|
-
const removeHandlers = /* @__PURE__ */ __name(() => {
|
|
2277
|
-
childProcess.off("message", handleMessage);
|
|
2278
|
-
childProcess.off("close", handleClose);
|
|
2279
|
-
}, "removeHandlers");
|
|
2280
|
-
if (once) {
|
|
2281
|
-
childProcess.once("message", handleMessage);
|
|
2282
|
-
} else {
|
|
2283
|
-
childProcess.on("message", handleMessage);
|
|
2284
|
-
}
|
|
2285
|
-
childProcess.on("close", handleClose);
|
|
2286
|
-
childProcess.send({
|
|
2287
|
-
type: RpcGMCallTypes.CALL,
|
|
2288
|
-
id,
|
|
2289
|
-
args
|
|
2290
|
-
}, (error2) => {
|
|
2291
|
-
if (error2) {
|
|
2292
|
-
rejectSend(error2);
|
|
2293
|
-
removeHandlers();
|
|
2294
|
-
} else {
|
|
2295
|
-
resolveSend(void 0);
|
|
2296
|
-
}
|
|
2297
|
-
});
|
|
2298
|
-
return sendPromise.then(() => resultPromise);
|
|
2299
|
-
});
|
|
2300
|
-
}
|
|
2301
|
-
__name(wrapRpc, "wrapRpc");
|
|
2302
|
-
|
|
2303
|
-
// packages/dts-plugin/src/core/rpc/rpc-worker.ts
|
|
2304
|
-
import * as child_process from "child_process";
|
|
2305
|
-
import * as process3 from "process";
|
|
2306
|
-
import { randomUUID as randomUUID2 } from "crypto";
|
|
2307
|
-
var FEDERATION_WORKER_DATA_ENV_KEY = "VMOK_WORKER_DATA_ENV";
|
|
2308
|
-
function createRpcWorker(modulePath, data, memoryLimit, once) {
|
|
2309
|
-
const options = {
|
|
2310
|
-
env: __spreadProps(__spreadValues({}, process3.env), {
|
|
2311
|
-
[FEDERATION_WORKER_DATA_ENV_KEY]: JSON.stringify(data || {})
|
|
2312
|
-
}),
|
|
2313
|
-
stdio: [
|
|
2314
|
-
"inherit",
|
|
2315
|
-
"inherit",
|
|
2316
|
-
"inherit",
|
|
2317
|
-
"ipc"
|
|
2318
|
-
],
|
|
2319
|
-
serialization: "advanced"
|
|
2320
|
-
};
|
|
2321
|
-
if (memoryLimit) {
|
|
2322
|
-
options.execArgv = [
|
|
2323
|
-
`--max-old-space-size=${memoryLimit}`
|
|
2324
|
-
];
|
|
2325
|
-
}
|
|
2326
|
-
let childProcess, remoteMethod;
|
|
2327
|
-
const id = randomUUID2();
|
|
2328
|
-
const worker = {
|
|
2329
|
-
connect(...args) {
|
|
2330
|
-
if (childProcess && !childProcess.connected) {
|
|
2331
|
-
childProcess.send({
|
|
2332
|
-
type: RpcGMCallTypes.EXIT,
|
|
2333
|
-
id
|
|
2334
|
-
});
|
|
2335
|
-
childProcess = void 0;
|
|
2336
|
-
remoteMethod = void 0;
|
|
2337
|
-
}
|
|
2338
|
-
if (!(childProcess == null ? void 0 : childProcess.connected)) {
|
|
2339
|
-
childProcess = child_process.fork(modulePath, options);
|
|
2340
|
-
remoteMethod = wrapRpc(childProcess, {
|
|
2341
|
-
id,
|
|
2342
|
-
once
|
|
2343
|
-
});
|
|
2344
|
-
}
|
|
2345
|
-
if (!remoteMethod) {
|
|
2346
|
-
return Promise.reject(new Error("Worker is not connected - cannot perform RPC."));
|
|
2347
|
-
}
|
|
2348
|
-
return remoteMethod(...args);
|
|
2349
|
-
},
|
|
2350
|
-
terminate() {
|
|
2351
|
-
var _a3;
|
|
2352
|
-
(_a3 = childProcess == null ? void 0 : childProcess.send) == null ? void 0 : _a3.call(childProcess, {
|
|
2353
|
-
type: RpcGMCallTypes.EXIT,
|
|
2354
|
-
id
|
|
2355
|
-
});
|
|
2356
|
-
childProcess = void 0;
|
|
2357
|
-
remoteMethod = void 0;
|
|
2358
|
-
},
|
|
2359
|
-
get connected() {
|
|
2360
|
-
return Boolean(childProcess == null ? void 0 : childProcess.connected);
|
|
2361
|
-
},
|
|
2362
|
-
get process() {
|
|
2363
|
-
return childProcess;
|
|
2364
|
-
},
|
|
2365
|
-
get id() {
|
|
2366
|
-
return id;
|
|
2367
|
-
}
|
|
2368
|
-
};
|
|
2369
|
-
return worker;
|
|
2370
|
-
}
|
|
2371
|
-
__name(createRpcWorker, "createRpcWorker");
|
|
2372
|
-
function getRpcWorkerData() {
|
|
2373
|
-
return JSON.parse(process3.env[FEDERATION_WORKER_DATA_ENV_KEY] || "{}");
|
|
2374
|
-
}
|
|
2375
|
-
__name(getRpcWorkerData, "getRpcWorkerData");
|
|
2376
|
-
|
|
2377
|
-
// packages/dts-plugin/src/core/lib/DtsWorker.ts
|
|
2378
|
-
var _DtsWorker = class _DtsWorker {
|
|
2379
|
-
constructor(options) {
|
|
2380
|
-
__publicField(this, "rpcWorker");
|
|
2381
|
-
__publicField(this, "_options");
|
|
2382
|
-
__publicField(this, "_res");
|
|
2383
|
-
this._options = cloneDeepWith2(options, (_value, key) => {
|
|
2384
|
-
if (key === "manifest") {
|
|
2385
|
-
return false;
|
|
2386
|
-
}
|
|
2387
|
-
});
|
|
2388
|
-
this.removeUnSerializationOptions();
|
|
2389
|
-
this.rpcWorker = createRpcWorker(path4.resolve(__dirname, "./fork-generate-dts.js"), {}, void 0, true);
|
|
2390
|
-
this._res = this.rpcWorker.connect(this._options);
|
|
2391
|
-
}
|
|
2392
|
-
removeUnSerializationOptions() {
|
|
2393
|
-
var _a3, _b, _c, _d, _e, _f, _g, _h;
|
|
2394
|
-
if ((_b = (_a3 = this._options.remote) == null ? void 0 : _a3.moduleFederationConfig) == null ? void 0 : _b.manifest) {
|
|
2395
|
-
(_d = (_c = this._options.remote) == null ? void 0 : _c.moduleFederationConfig) == null ? true : delete _d.manifest;
|
|
2396
|
-
}
|
|
2397
|
-
if ((_f = (_e = this._options.host) == null ? void 0 : _e.moduleFederationConfig) == null ? void 0 : _f.manifest) {
|
|
2398
|
-
(_h = (_g = this._options.host) == null ? void 0 : _g.moduleFederationConfig) == null ? true : delete _h.manifest;
|
|
2399
|
-
}
|
|
2400
|
-
}
|
|
2401
|
-
get controlledPromise() {
|
|
2402
|
-
const ensureChildProcessExit = /* @__PURE__ */ __name(() => {
|
|
2403
|
-
var _a3;
|
|
2404
|
-
try {
|
|
2405
|
-
const pid = (_a3 = this.rpcWorker.process) == null ? void 0 : _a3.pid;
|
|
2406
|
-
const rootPid = process.pid;
|
|
2407
|
-
if (pid && rootPid !== pid) {
|
|
2408
|
-
process.kill(pid, 0);
|
|
2409
|
-
}
|
|
2410
|
-
} catch (error2) {
|
|
2411
|
-
if (isDebugMode()) {
|
|
2412
|
-
console.error(error2);
|
|
2413
|
-
}
|
|
2414
|
-
}
|
|
2415
|
-
}, "ensureChildProcessExit");
|
|
2416
|
-
return Promise.resolve(this._res).then(() => {
|
|
2417
|
-
this.exit();
|
|
2418
|
-
ensureChildProcessExit();
|
|
2419
|
-
}).catch((err) => {
|
|
2420
|
-
if (isDebugMode()) {
|
|
2421
|
-
console.error(err);
|
|
2422
|
-
}
|
|
2423
|
-
ensureChildProcessExit();
|
|
2424
|
-
});
|
|
2425
|
-
}
|
|
2426
|
-
exit() {
|
|
2427
|
-
var _a3;
|
|
2428
|
-
(_a3 = this.rpcWorker) == null ? void 0 : _a3.terminate();
|
|
2429
|
-
}
|
|
2430
|
-
};
|
|
2431
|
-
__name(_DtsWorker, "DtsWorker");
|
|
2432
|
-
var DtsWorker = _DtsWorker;
|
|
2433
|
-
|
|
2434
|
-
// packages/dts-plugin/src/core/lib/generateTypesInChildProcess.ts
|
|
2435
|
-
function generateTypesInChildProcess(options) {
|
|
2436
|
-
return __async(this, null, function* () {
|
|
2437
|
-
const dtsWorker = new DtsWorker(options);
|
|
2438
|
-
return dtsWorker.controlledPromise;
|
|
2439
|
-
});
|
|
2440
|
-
}
|
|
2441
|
-
__name(generateTypesInChildProcess, "generateTypesInChildProcess");
|
|
2442
|
-
|
|
2443
|
-
// packages/dts-plugin/src/core/lib/consumeTypes.ts
|
|
2444
|
-
function consumeTypes(options) {
|
|
2445
|
-
return __async(this, null, function* () {
|
|
2446
|
-
var _a3;
|
|
2447
|
-
const DTSManagerConstructor = getDTSManagerConstructor((_a3 = options.host) == null ? void 0 : _a3.implementation);
|
|
2448
|
-
const dtsManager = new DTSManagerConstructor(options);
|
|
2449
|
-
yield dtsManager.consumeTypes();
|
|
2450
|
-
});
|
|
2451
|
-
}
|
|
2452
|
-
__name(consumeTypes, "consumeTypes");
|
|
2453
|
-
|
|
2454
1352
|
export {
|
|
2455
1353
|
retrieveMfTypesPath,
|
|
2456
1354
|
retrieveOriginalOutDir,
|
|
2457
|
-
fileLog,
|
|
2458
|
-
getIPV4,
|
|
2459
|
-
Broker,
|
|
2460
1355
|
ModuleFederationDevServer,
|
|
2461
1356
|
createKoaServer,
|
|
2462
1357
|
retrieveTypesZipPath,
|
|
2463
1358
|
retrieveHostConfig,
|
|
1359
|
+
REMOTE_ALIAS_IDENTIFIER,
|
|
1360
|
+
REMOTE_API_TYPES_FILE_NAME,
|
|
1361
|
+
HOST_API_TYPES_FILE_NAME,
|
|
2464
1362
|
DTSManager,
|
|
2465
1363
|
getDTSManagerConstructor,
|
|
2466
1364
|
validateOptions,
|
|
2467
1365
|
retrieveTypesAssetsInfo,
|
|
1366
|
+
isDebugMode,
|
|
2468
1367
|
isTSProject,
|
|
1368
|
+
cloneDeepOptions,
|
|
2469
1369
|
retrieveRemoteConfig,
|
|
2470
1370
|
generateTypes,
|
|
2471
1371
|
RpcGMCallTypes,
|
|
2472
|
-
exposeRpc
|
|
2473
|
-
rpc_exports,
|
|
2474
|
-
DtsWorker,
|
|
2475
|
-
generateTypesInChildProcess,
|
|
2476
|
-
consumeTypes
|
|
1372
|
+
exposeRpc
|
|
2477
1373
|
};
|