@module-federation/dts-plugin 0.2.7 → 0.3.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/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 +78 -41
- 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-DEW2PNCR.js +283 -0
- package/dist/esm/chunk-HKRTV6ZH.js +900 -0
- package/dist/esm/{chunk-ZLQBXHXA.js → chunk-SFEGBRA3.js} +331 -1426
- 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 +74 -39
- package/dist/fork-generate-dts.d.mts +2 -2
- package/dist/fork-generate-dts.d.ts +2 -2
- package/dist/fork-generate-dts.js +146 -290
- package/dist/iife/launch-web-client.js +5 -7
- package/dist/index.js +89 -52
- package/dist/package.json +1 -1
- package/dist/start-broker.js +28 -344
- package/package.json +5 -5
package/dist/start-broker.js
CHANGED
|
@@ -1,26 +1,10 @@
|
|
|
1
1
|
var __create = Object.create;
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
-
var __defProps = Object.defineProperties;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
9
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
7
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
-
var __spreadValues = (a, b) => {
|
|
13
|
-
for (var prop in b || (b = {}))
|
|
14
|
-
if (__hasOwnProp.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
if (__getOwnPropSymbols)
|
|
17
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
-
if (__propIsEnum.call(b, prop))
|
|
19
|
-
__defNormalProp(a, prop, b[prop]);
|
|
20
|
-
}
|
|
21
|
-
return a;
|
|
22
|
-
};
|
|
23
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
8
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
25
9
|
var __export = (target, all) => {
|
|
26
10
|
for (var name in all)
|
|
@@ -78,27 +62,19 @@ module.exports = __toCommonJS(startBroker_exports);
|
|
|
78
62
|
// packages/dts-plugin/src/server/broker/Broker.ts
|
|
79
63
|
var import_http = require("http");
|
|
80
64
|
|
|
81
|
-
// packages/dts-plugin/src/
|
|
82
|
-
var
|
|
83
|
-
var
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
// packages/dts-plugin/src/core/lib/DTSManager.ts
|
|
90
|
-
var import_ansi_colors = __toESM(require("ansi-colors"));
|
|
91
|
-
var import_sdk5 = require("@module-federation/sdk");
|
|
92
|
-
var import_lodash = __toESM(require("lodash.clonedeepwith"));
|
|
93
|
-
var import_third_party_dts_extractor2 = require("@module-federation/third-party-dts-extractor");
|
|
94
|
-
|
|
95
|
-
// packages/dts-plugin/src/core/lib/archiveHandler.ts
|
|
96
|
-
var import_adm_zip = __toESM(require("adm-zip"));
|
|
65
|
+
// packages/dts-plugin/src/server/constant.ts
|
|
66
|
+
var DEFAULT_WEB_SOCKET_PORT = 16322;
|
|
67
|
+
var WEB_SOCKET_CONNECT_MAGIC_ID = "1hpzW-zo2z-o8io-gfmV1-2cb1d82";
|
|
68
|
+
var UpdateMode;
|
|
69
|
+
(function(UpdateMode2) {
|
|
70
|
+
UpdateMode2["POSITIVE"] = "POSITIVE";
|
|
71
|
+
UpdateMode2["PASSIVE"] = "PASSIVE";
|
|
72
|
+
})(UpdateMode || (UpdateMode = {}));
|
|
97
73
|
|
|
98
|
-
// packages/dts-plugin/src/
|
|
99
|
-
var
|
|
100
|
-
var
|
|
101
|
-
var
|
|
74
|
+
// packages/dts-plugin/src/server/broker/Broker.ts
|
|
75
|
+
var import_isomorphic_ws = __toESM(require("isomorphic-ws"));
|
|
76
|
+
var import_node_schedule = __toESM(require("node-schedule"));
|
|
77
|
+
var import_url = require("url");
|
|
102
78
|
|
|
103
79
|
// packages/dts-plugin/src/server/message/Message.ts
|
|
104
80
|
var _Message = class _Message {
|
|
@@ -171,7 +147,7 @@ __name(_FetchTypesAPI, "FetchTypesAPI");
|
|
|
171
147
|
var FetchTypesAPI = _FetchTypesAPI;
|
|
172
148
|
|
|
173
149
|
// packages/dts-plugin/src/server/utils/index.ts
|
|
174
|
-
var
|
|
150
|
+
var import_sdk2 = require("@module-federation/sdk");
|
|
175
151
|
|
|
176
152
|
// packages/dts-plugin/src/server/utils/logTransform.ts
|
|
177
153
|
var import_chalk = __toESM(require("chalk"));
|
|
@@ -210,18 +186,12 @@ __name(_BrokerExitLog, "BrokerExitLog");
|
|
|
210
186
|
var BrokerExitLog = _BrokerExitLog;
|
|
211
187
|
|
|
212
188
|
// packages/dts-plugin/src/server/utils/log.ts
|
|
213
|
-
var
|
|
189
|
+
var import_sdk = require("@module-federation/sdk");
|
|
214
190
|
var log4js = __toESM(require("log4js"));
|
|
215
191
|
var import_chalk2 = __toESM(require("chalk"));
|
|
216
|
-
|
|
217
|
-
// packages/dts-plugin/src/server/constant.ts
|
|
218
|
-
var DEFAULT_WEB_SOCKET_PORT = 16322;
|
|
219
|
-
var WEB_SOCKET_CONNECT_MAGIC_ID = "1hpzW-zo2z-o8io-gfmV1-2cb1d82";
|
|
220
|
-
|
|
221
|
-
// packages/dts-plugin/src/server/utils/log.ts
|
|
222
192
|
function fileLog(msg, module2, level) {
|
|
223
|
-
var
|
|
224
|
-
if (!((
|
|
193
|
+
var _a, _b;
|
|
194
|
+
if (!((_a = process == null ? void 0 : process.env) == null ? void 0 : _a["FEDERATION_DEBUG"])) {
|
|
225
195
|
return;
|
|
226
196
|
}
|
|
227
197
|
log4js.configure({
|
|
@@ -265,7 +235,7 @@ __name(error, "error");
|
|
|
265
235
|
// packages/dts-plugin/src/server/utils/index.ts
|
|
266
236
|
function getIdentifier(options) {
|
|
267
237
|
const { ip, name } = options;
|
|
268
|
-
return `mf ${
|
|
238
|
+
return `mf ${import_sdk2.SEPARATOR}${name}${ip ? `${import_sdk2.SEPARATOR}${ip}` : ""}`;
|
|
269
239
|
}
|
|
270
240
|
__name(getIdentifier, "getIdentifier");
|
|
271
241
|
|
|
@@ -359,9 +329,6 @@ var _Publisher = class _Publisher {
|
|
|
359
329
|
__name(_Publisher, "Publisher");
|
|
360
330
|
var Publisher = _Publisher;
|
|
361
331
|
|
|
362
|
-
// packages/dts-plugin/src/server/DevServer.ts
|
|
363
|
-
var import_isomorphic_ws = __toESM(require("isomorphic-ws"));
|
|
364
|
-
|
|
365
332
|
// packages/dts-plugin/src/server/message/Action/Action.ts
|
|
366
333
|
var ActionKind;
|
|
367
334
|
(function(ActionKind2) {
|
|
@@ -384,290 +351,7 @@ var UpdateKind;
|
|
|
384
351
|
UpdateKind2["RELOAD_PAGE"] = "RELOAD_PAGE";
|
|
385
352
|
})(UpdateKind || (UpdateKind = {}));
|
|
386
353
|
|
|
387
|
-
// packages/dts-plugin/src/core/constant.ts
|
|
388
|
-
var UpdateMode;
|
|
389
|
-
(function(UpdateMode2) {
|
|
390
|
-
UpdateMode2["POSITIVE"] = "POSITIVE";
|
|
391
|
-
UpdateMode2["PASSIVE"] = "PASSIVE";
|
|
392
|
-
})(UpdateMode || (UpdateMode = {}));
|
|
393
|
-
|
|
394
|
-
// packages/dts-plugin/src/server/createKoaServer.ts
|
|
395
|
-
var import_fs_extra2 = __toESM(require("fs-extra"));
|
|
396
|
-
var import_koa = __toESM(require("koa"));
|
|
397
|
-
|
|
398
|
-
// packages/dts-plugin/src/core/configurations/hostPlugin.ts
|
|
399
|
-
var import_sdk4 = require("@module-federation/sdk");
|
|
400
|
-
var import_managers = require("@module-federation/managers");
|
|
401
|
-
var defaultOptions = {
|
|
402
|
-
typesFolder: "@mf-types",
|
|
403
|
-
remoteTypesFolder: "@mf-types",
|
|
404
|
-
deleteTypesFolder: true,
|
|
405
|
-
maxRetries: 3,
|
|
406
|
-
implementation: "",
|
|
407
|
-
context: process.cwd(),
|
|
408
|
-
abortOnError: true,
|
|
409
|
-
consumeAPITypes: false
|
|
410
|
-
};
|
|
411
|
-
|
|
412
|
-
// packages/dts-plugin/src/core/configurations/remotePlugin.ts
|
|
413
|
-
var defaultOptions2 = {
|
|
414
|
-
tsConfigPath: "./tsconfig.json",
|
|
415
|
-
typesFolder: "@mf-types",
|
|
416
|
-
compiledTypesFolder: "compiled-types",
|
|
417
|
-
hostRemoteTypesFolder: "@mf-types",
|
|
418
|
-
deleteTypesFolder: true,
|
|
419
|
-
additionalFilesToCompile: [],
|
|
420
|
-
compilerInstance: "tsc",
|
|
421
|
-
compileInChildProcess: false,
|
|
422
|
-
implementation: "",
|
|
423
|
-
generateAPITypes: false,
|
|
424
|
-
context: process.cwd(),
|
|
425
|
-
abortOnError: true,
|
|
426
|
-
extractRemoteTypes: false,
|
|
427
|
-
extractThirdParty: false
|
|
428
|
-
};
|
|
429
|
-
|
|
430
|
-
// packages/dts-plugin/src/core/lib/DtsWorker.ts
|
|
431
|
-
var import_lodash2 = __toESM(require("lodash.clonedeepwith"));
|
|
432
|
-
|
|
433
|
-
// packages/dts-plugin/src/core/rpc/index.ts
|
|
434
|
-
var rpc_exports = {};
|
|
435
|
-
__export(rpc_exports, {
|
|
436
|
-
RpcExitError: () => RpcExitError,
|
|
437
|
-
RpcGMCallTypes: () => RpcGMCallTypes,
|
|
438
|
-
createRpcWorker: () => createRpcWorker,
|
|
439
|
-
exposeRpc: () => exposeRpc,
|
|
440
|
-
getRpcWorkerData: () => getRpcWorkerData,
|
|
441
|
-
wrapRpc: () => wrapRpc
|
|
442
|
-
});
|
|
443
|
-
|
|
444
|
-
// packages/dts-plugin/src/core/rpc/expose-rpc.ts
|
|
445
|
-
var import_process = __toESM(require("process"));
|
|
446
|
-
|
|
447
|
-
// packages/dts-plugin/src/core/rpc/types.ts
|
|
448
|
-
var RpcGMCallTypes;
|
|
449
|
-
(function(RpcGMCallTypes2) {
|
|
450
|
-
RpcGMCallTypes2["CALL"] = "mf_call";
|
|
451
|
-
RpcGMCallTypes2["RESOLVE"] = "mf_resolve";
|
|
452
|
-
RpcGMCallTypes2["REJECT"] = "mf_reject";
|
|
453
|
-
RpcGMCallTypes2["EXIT"] = "mf_exit";
|
|
454
|
-
})(RpcGMCallTypes || (RpcGMCallTypes = {}));
|
|
455
|
-
|
|
456
|
-
// packages/dts-plugin/src/core/rpc/expose-rpc.ts
|
|
457
|
-
function exposeRpc(fn) {
|
|
458
|
-
const sendMessage = /* @__PURE__ */ __name((message) => new Promise((resolve, reject) => {
|
|
459
|
-
if (!import_process.default.send) {
|
|
460
|
-
reject(new Error(`Process ${import_process.default.pid} doesn't have IPC channels`));
|
|
461
|
-
} else if (!import_process.default.connected) {
|
|
462
|
-
reject(new Error(`Process ${import_process.default.pid} doesn't have open IPC channels`));
|
|
463
|
-
} else {
|
|
464
|
-
import_process.default.send(message, void 0, void 0, (error2) => {
|
|
465
|
-
if (error2) {
|
|
466
|
-
reject(error2);
|
|
467
|
-
} else {
|
|
468
|
-
resolve(void 0);
|
|
469
|
-
}
|
|
470
|
-
});
|
|
471
|
-
}
|
|
472
|
-
}), "sendMessage");
|
|
473
|
-
const handleMessage = /* @__PURE__ */ __name((message) => __async(this, null, function* () {
|
|
474
|
-
if (message.type === RpcGMCallTypes.CALL) {
|
|
475
|
-
if (!import_process.default.send) {
|
|
476
|
-
return;
|
|
477
|
-
}
|
|
478
|
-
let value, error2;
|
|
479
|
-
try {
|
|
480
|
-
value = yield fn(...message.args);
|
|
481
|
-
} catch (fnError) {
|
|
482
|
-
error2 = fnError;
|
|
483
|
-
}
|
|
484
|
-
try {
|
|
485
|
-
if (error2) {
|
|
486
|
-
yield sendMessage({
|
|
487
|
-
type: RpcGMCallTypes.REJECT,
|
|
488
|
-
id: message.id,
|
|
489
|
-
error: error2
|
|
490
|
-
});
|
|
491
|
-
} else {
|
|
492
|
-
yield sendMessage({
|
|
493
|
-
type: RpcGMCallTypes.RESOLVE,
|
|
494
|
-
id: message.id,
|
|
495
|
-
value
|
|
496
|
-
});
|
|
497
|
-
}
|
|
498
|
-
} catch (sendError) {
|
|
499
|
-
if (error2) {
|
|
500
|
-
if (error2 instanceof Error) {
|
|
501
|
-
console.error(error2);
|
|
502
|
-
}
|
|
503
|
-
}
|
|
504
|
-
console.error(sendError);
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
}), "handleMessage");
|
|
508
|
-
import_process.default.on("message", handleMessage);
|
|
509
|
-
}
|
|
510
|
-
__name(exposeRpc, "exposeRpc");
|
|
511
|
-
|
|
512
|
-
// packages/dts-plugin/src/core/rpc/rpc-error.ts
|
|
513
|
-
var _a;
|
|
514
|
-
var RpcExitError = (_a = class extends Error {
|
|
515
|
-
constructor(message, code, signal) {
|
|
516
|
-
super(message);
|
|
517
|
-
__publicField(this, "code");
|
|
518
|
-
__publicField(this, "signal");
|
|
519
|
-
this.code = code;
|
|
520
|
-
this.signal = signal;
|
|
521
|
-
this.name = "RpcExitError";
|
|
522
|
-
}
|
|
523
|
-
}, __name(_a, "RpcExitError"), _a);
|
|
524
|
-
|
|
525
|
-
// packages/dts-plugin/src/core/rpc/wrap-rpc.ts
|
|
526
|
-
function createControlledPromise() {
|
|
527
|
-
let resolve = /* @__PURE__ */ __name(() => void 0, "resolve");
|
|
528
|
-
let reject = /* @__PURE__ */ __name(() => void 0, "reject");
|
|
529
|
-
const promise = new Promise((aResolve, aReject) => {
|
|
530
|
-
resolve = aResolve;
|
|
531
|
-
reject = aReject;
|
|
532
|
-
});
|
|
533
|
-
return {
|
|
534
|
-
promise,
|
|
535
|
-
resolve,
|
|
536
|
-
reject
|
|
537
|
-
};
|
|
538
|
-
}
|
|
539
|
-
__name(createControlledPromise, "createControlledPromise");
|
|
540
|
-
function wrapRpc(childProcess, options) {
|
|
541
|
-
return (...args) => __async(this, null, function* () {
|
|
542
|
-
if (!childProcess.send) {
|
|
543
|
-
throw new Error(`Process ${childProcess.pid} doesn't have IPC channels`);
|
|
544
|
-
} else if (!childProcess.connected) {
|
|
545
|
-
throw new Error(`Process ${childProcess.pid} doesn't have open IPC channels`);
|
|
546
|
-
}
|
|
547
|
-
const { id, once } = options;
|
|
548
|
-
const { promise: resultPromise, resolve: resolveResult, reject: rejectResult } = createControlledPromise();
|
|
549
|
-
const { promise: sendPromise, resolve: resolveSend, reject: rejectSend } = createControlledPromise();
|
|
550
|
-
const handleMessage = /* @__PURE__ */ __name((message) => {
|
|
551
|
-
if ((message == null ? void 0 : message.id) === id) {
|
|
552
|
-
if (message.type === RpcGMCallTypes.RESOLVE) {
|
|
553
|
-
resolveResult(message.value);
|
|
554
|
-
} else if (message.type === RpcGMCallTypes.REJECT) {
|
|
555
|
-
rejectResult(message.error);
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
if (once && (childProcess == null ? void 0 : childProcess.kill)) {
|
|
559
|
-
childProcess.kill("SIGTERM");
|
|
560
|
-
}
|
|
561
|
-
}, "handleMessage");
|
|
562
|
-
const handleClose = /* @__PURE__ */ __name((code, signal) => {
|
|
563
|
-
rejectResult(new RpcExitError(code ? `Process ${childProcess.pid} exited with code ${code}${signal ? ` [${signal}]` : ""}` : `Process ${childProcess.pid} exited${signal ? ` [${signal}]` : ""}`, code, signal));
|
|
564
|
-
removeHandlers();
|
|
565
|
-
}, "handleClose");
|
|
566
|
-
const removeHandlers = /* @__PURE__ */ __name(() => {
|
|
567
|
-
childProcess.off("message", handleMessage);
|
|
568
|
-
childProcess.off("close", handleClose);
|
|
569
|
-
}, "removeHandlers");
|
|
570
|
-
if (once) {
|
|
571
|
-
childProcess.once("message", handleMessage);
|
|
572
|
-
} else {
|
|
573
|
-
childProcess.on("message", handleMessage);
|
|
574
|
-
}
|
|
575
|
-
childProcess.on("close", handleClose);
|
|
576
|
-
childProcess.send({
|
|
577
|
-
type: RpcGMCallTypes.CALL,
|
|
578
|
-
id,
|
|
579
|
-
args
|
|
580
|
-
}, (error2) => {
|
|
581
|
-
if (error2) {
|
|
582
|
-
rejectSend(error2);
|
|
583
|
-
removeHandlers();
|
|
584
|
-
} else {
|
|
585
|
-
resolveSend(void 0);
|
|
586
|
-
}
|
|
587
|
-
});
|
|
588
|
-
return sendPromise.then(() => resultPromise);
|
|
589
|
-
});
|
|
590
|
-
}
|
|
591
|
-
__name(wrapRpc, "wrapRpc");
|
|
592
|
-
|
|
593
|
-
// packages/dts-plugin/src/core/rpc/rpc-worker.ts
|
|
594
|
-
var child_process = __toESM(require("child_process"));
|
|
595
|
-
var process3 = __toESM(require("process"));
|
|
596
|
-
var import_crypto = require("crypto");
|
|
597
|
-
var FEDERATION_WORKER_DATA_ENV_KEY = "VMOK_WORKER_DATA_ENV";
|
|
598
|
-
function createRpcWorker(modulePath, data, memoryLimit, once) {
|
|
599
|
-
const options = {
|
|
600
|
-
env: __spreadProps(__spreadValues({}, process3.env), {
|
|
601
|
-
[FEDERATION_WORKER_DATA_ENV_KEY]: JSON.stringify(data || {})
|
|
602
|
-
}),
|
|
603
|
-
stdio: [
|
|
604
|
-
"inherit",
|
|
605
|
-
"inherit",
|
|
606
|
-
"inherit",
|
|
607
|
-
"ipc"
|
|
608
|
-
],
|
|
609
|
-
serialization: "advanced"
|
|
610
|
-
};
|
|
611
|
-
if (memoryLimit) {
|
|
612
|
-
options.execArgv = [
|
|
613
|
-
`--max-old-space-size=${memoryLimit}`
|
|
614
|
-
];
|
|
615
|
-
}
|
|
616
|
-
let childProcess, remoteMethod;
|
|
617
|
-
const id = (0, import_crypto.randomUUID)();
|
|
618
|
-
const worker = {
|
|
619
|
-
connect(...args) {
|
|
620
|
-
if (childProcess && !childProcess.connected) {
|
|
621
|
-
childProcess.send({
|
|
622
|
-
type: RpcGMCallTypes.EXIT,
|
|
623
|
-
id
|
|
624
|
-
});
|
|
625
|
-
childProcess = void 0;
|
|
626
|
-
remoteMethod = void 0;
|
|
627
|
-
}
|
|
628
|
-
if (!(childProcess == null ? void 0 : childProcess.connected)) {
|
|
629
|
-
childProcess = child_process.fork(modulePath, options);
|
|
630
|
-
remoteMethod = wrapRpc(childProcess, {
|
|
631
|
-
id,
|
|
632
|
-
once
|
|
633
|
-
});
|
|
634
|
-
}
|
|
635
|
-
if (!remoteMethod) {
|
|
636
|
-
return Promise.reject(new Error("Worker is not connected - cannot perform RPC."));
|
|
637
|
-
}
|
|
638
|
-
return remoteMethod(...args);
|
|
639
|
-
},
|
|
640
|
-
terminate() {
|
|
641
|
-
var _a2;
|
|
642
|
-
(_a2 = childProcess == null ? void 0 : childProcess.send) == null ? void 0 : _a2.call(childProcess, {
|
|
643
|
-
type: RpcGMCallTypes.EXIT,
|
|
644
|
-
id
|
|
645
|
-
});
|
|
646
|
-
childProcess = void 0;
|
|
647
|
-
remoteMethod = void 0;
|
|
648
|
-
},
|
|
649
|
-
get connected() {
|
|
650
|
-
return Boolean(childProcess == null ? void 0 : childProcess.connected);
|
|
651
|
-
},
|
|
652
|
-
get process() {
|
|
653
|
-
return childProcess;
|
|
654
|
-
},
|
|
655
|
-
get id() {
|
|
656
|
-
return id;
|
|
657
|
-
}
|
|
658
|
-
};
|
|
659
|
-
return worker;
|
|
660
|
-
}
|
|
661
|
-
__name(createRpcWorker, "createRpcWorker");
|
|
662
|
-
function getRpcWorkerData() {
|
|
663
|
-
return JSON.parse(process3.env[FEDERATION_WORKER_DATA_ENV_KEY] || "{}");
|
|
664
|
-
}
|
|
665
|
-
__name(getRpcWorkerData, "getRpcWorkerData");
|
|
666
|
-
|
|
667
354
|
// packages/dts-plugin/src/server/broker/Broker.ts
|
|
668
|
-
var import_isomorphic_ws2 = __toESM(require("isomorphic-ws"));
|
|
669
|
-
var import_node_schedule = __toESM(require("node-schedule"));
|
|
670
|
-
var import_url = require("url");
|
|
671
355
|
var _Broker = class _Broker {
|
|
672
356
|
constructor() {
|
|
673
357
|
__publicField(this, "_publisherMap", /* @__PURE__ */ new Map());
|
|
@@ -711,7 +395,7 @@ var _Broker = class _Broker {
|
|
|
711
395
|
}
|
|
712
396
|
}, "wsHandler");
|
|
713
397
|
const server = (0, import_http.createServer)();
|
|
714
|
-
this._webSocketServer = new
|
|
398
|
+
this._webSocketServer = new import_isomorphic_ws.default.Server({
|
|
715
399
|
noServer: true
|
|
716
400
|
});
|
|
717
401
|
this._webSocketServer.on("error", (err) => {
|
|
@@ -729,13 +413,13 @@ ${err.message}
|
|
|
729
413
|
this._webSocketServer = void 0;
|
|
730
414
|
});
|
|
731
415
|
server.on("upgrade", (req, socket, head) => {
|
|
732
|
-
var
|
|
416
|
+
var _a;
|
|
733
417
|
if (req.url) {
|
|
734
418
|
const { pathname } = (0, import_url.parse)(req.url);
|
|
735
419
|
if (pathname === "/") {
|
|
736
|
-
(
|
|
737
|
-
var
|
|
738
|
-
(
|
|
420
|
+
(_a = this._webSocketServer) == null ? void 0 : _a.handleUpgrade(req, socket, head, (ws) => {
|
|
421
|
+
var _a2;
|
|
422
|
+
(_a2 = this._webSocketServer) == null ? void 0 : _a2.emit("connection", ws, req);
|
|
739
423
|
});
|
|
740
424
|
}
|
|
741
425
|
}
|
|
@@ -1120,8 +804,8 @@ ${err.message}
|
|
|
1120
804
|
}
|
|
1121
805
|
}
|
|
1122
806
|
_getTmpSubScribers(publisherIdentifier) {
|
|
1123
|
-
var
|
|
1124
|
-
return (
|
|
807
|
+
var _a;
|
|
808
|
+
return (_a = this._tmpSubscriberShelter.get(publisherIdentifier)) == null ? void 0 : _a.subscribers;
|
|
1125
809
|
}
|
|
1126
810
|
// after adding publisher, it will change the temp subscriber to regular subscriber
|
|
1127
811
|
_consumeTmpSubScribers(publisher, tmpSubScribers) {
|
|
@@ -1226,9 +910,9 @@ ${err.message}
|
|
|
1226
910
|
process.exit(0);
|
|
1227
911
|
}
|
|
1228
912
|
broadcast(message) {
|
|
1229
|
-
var
|
|
913
|
+
var _a, _b;
|
|
1230
914
|
fileLog(`[broadcast] exit info : ${JSON.stringify(message)}`, "Broker", "warn");
|
|
1231
|
-
(
|
|
915
|
+
(_a = this._webSocketServer) == null ? void 0 : _a.clients.forEach((client) => {
|
|
1232
916
|
client.send(JSON.stringify(message));
|
|
1233
917
|
});
|
|
1234
918
|
(_b = this._secureWebSocketServer) == null ? void 0 : _b.clients.forEach((client) => {
|
|
@@ -1251,13 +935,13 @@ function getBroker() {
|
|
|
1251
935
|
__name(getBroker, "getBroker");
|
|
1252
936
|
function startBroker() {
|
|
1253
937
|
return __async(this, null, function* () {
|
|
1254
|
-
var
|
|
938
|
+
var _a;
|
|
1255
939
|
if (getBroker()) {
|
|
1256
940
|
return;
|
|
1257
941
|
}
|
|
1258
942
|
broker = new Broker();
|
|
1259
943
|
yield broker.start();
|
|
1260
|
-
(
|
|
944
|
+
(_a = process.send) == null ? void 0 : _a.call(process, "ready");
|
|
1261
945
|
});
|
|
1262
946
|
}
|
|
1263
947
|
__name(startBroker, "startBroker");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/dts-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"author": "hanric <hanric.zhang@gmail.com>",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -55,9 +55,9 @@
|
|
|
55
55
|
"log4js": "6.9.1",
|
|
56
56
|
"node-schedule": "2.1.1",
|
|
57
57
|
"ws": "8.17.1",
|
|
58
|
-
"@module-federation/sdk": "0.
|
|
59
|
-
"@module-federation/managers": "0.
|
|
60
|
-
"@module-federation/third-party-dts-extractor": "0.
|
|
58
|
+
"@module-federation/sdk": "0.3.0",
|
|
59
|
+
"@module-federation/managers": "0.3.0",
|
|
60
|
+
"@module-federation/third-party-dts-extractor": "0.3.0"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@types/ws": "8.5.10",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"vue": "^3.4.29",
|
|
67
67
|
"@vue/tsconfig": "^0.5.1",
|
|
68
68
|
"vue-tsc": "^2.0.26",
|
|
69
|
-
"@module-federation/runtime": "0.
|
|
69
|
+
"@module-federation/runtime": "0.3.0"
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
72
|
"typescript": "^4.9.0 || ^5.0.0",
|