@module-federation/dts-plugin 0.0.0-chore-bump-node-22-20260710161714
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +1 -0
- package/dist/Action-CzhPMw2i.js +153 -0
- package/dist/Broker-CaenCqdn.js +783 -0
- package/dist/CHANGELOG.md +1390 -0
- package/dist/DtsWorker-Bt7-_SGH.d.ts +166 -0
- package/dist/README.md +1 -0
- package/dist/constant-YOdZl7sj.d.ts +42 -0
- package/dist/consumeTypes-Dle9g2SZ.js +241 -0
- package/dist/core.d.ts +3 -0
- package/dist/core.js +28 -0
- package/dist/dynamic-remote-type-hints-plugin.d.ts +766 -0
- package/dist/dynamic-remote-type-hints-plugin.js +74 -0
- package/dist/esm/Action-DNNg2YDh.mjs +47 -0
- package/dist/esm/Broker-Cmbh_XVO.mjs +718 -0
- package/dist/esm/consumeTypes-3S4eCiRK.mjs +208 -0
- package/dist/esm/core.mjs +5 -0
- package/dist/esm/dynamic-remote-type-hints-plugin.mjs +73 -0
- package/dist/esm/expose-rpc-CDdqA9PX.mjs +1380 -0
- package/dist/esm/fork-dev-worker.mjs +113 -0
- package/dist/esm/fork-generate-dts.mjs +14 -0
- package/dist/esm/index.mjs +509 -0
- package/dist/esm/start-broker.mjs +22 -0
- package/dist/esm/utils-CkPvDGOy.mjs +13 -0
- package/dist/expose-rpc-BpRiu3VK.js +1489 -0
- package/dist/fork-dev-worker.d.ts +16 -0
- package/dist/fork-dev-worker.js +114 -0
- package/dist/fork-generate-dts.d.ts +6 -0
- package/dist/fork-generate-dts.js +15 -0
- package/dist/iife/launch-web-client.iife.js +117 -0
- package/dist/index.d.ts +67 -0
- package/dist/index.js +517 -0
- package/dist/start-broker.d.ts +44 -0
- package/dist/start-broker.js +23 -0
- package/dist/utils-7KqCZHbb.js +19 -0
- package/package.json +108 -0
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { moduleFederationPlugin } from "@module-federation/sdk";
|
|
2
|
+
import ts from "typescript";
|
|
3
|
+
import { ChildProcess } from "child_process";
|
|
4
|
+
|
|
5
|
+
//#region \0rolldown/runtime.js
|
|
6
|
+
//#endregion
|
|
7
|
+
//#region src/core/interfaces/RemoteOptions.d.ts
|
|
8
|
+
interface RemoteOptions extends moduleFederationPlugin.DtsRemoteOptions {
|
|
9
|
+
moduleFederationConfig: moduleFederationPlugin.ModuleFederationPluginOptions;
|
|
10
|
+
context?: string;
|
|
11
|
+
implementation?: string;
|
|
12
|
+
hostRemoteTypesFolder?: string;
|
|
13
|
+
outputDir?: string;
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/core/interfaces/TsConfigJson.d.ts
|
|
17
|
+
interface TsConfigJson {
|
|
18
|
+
extends?: string;
|
|
19
|
+
compilerOptions?: ts.CompilerOptions;
|
|
20
|
+
exclude?: string[];
|
|
21
|
+
include?: string[];
|
|
22
|
+
files?: string[];
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/core/configurations/remotePlugin.d.ts
|
|
26
|
+
declare const retrieveRemoteConfig: (options: RemoteOptions) => {
|
|
27
|
+
tsConfig: TsConfigJson;
|
|
28
|
+
mapComponentsToExpose: Record<string, string>;
|
|
29
|
+
remoteOptions: Required<RemoteOptions>;
|
|
30
|
+
};
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/core/interfaces/HostOptions.d.ts
|
|
33
|
+
interface HostOptions extends moduleFederationPlugin.DtsHostOptions {
|
|
34
|
+
moduleFederationConfig: moduleFederationPlugin.ModuleFederationPluginOptions;
|
|
35
|
+
context?: string;
|
|
36
|
+
implementation?: string;
|
|
37
|
+
runtimePkgs?: string[];
|
|
38
|
+
}
|
|
39
|
+
interface RemoteInfo {
|
|
40
|
+
name: string;
|
|
41
|
+
url: string;
|
|
42
|
+
alias: string;
|
|
43
|
+
zipUrl?: string;
|
|
44
|
+
apiTypeUrl?: string;
|
|
45
|
+
}
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/core/interfaces/DTSManagerOptions.d.ts
|
|
48
|
+
interface DTSManagerOptions {
|
|
49
|
+
remote?: RemoteOptions;
|
|
50
|
+
host?: HostOptions;
|
|
51
|
+
extraOptions?: Record<string, any>;
|
|
52
|
+
displayErrorInTerminal?: moduleFederationPlugin.PluginDtsOptions['displayErrorInTerminal'];
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region src/server/constant.d.ts
|
|
56
|
+
declare const enum UpdateMode {
|
|
57
|
+
POSITIVE = "POSITIVE",
|
|
58
|
+
PASSIVE = "PASSIVE"
|
|
59
|
+
}
|
|
60
|
+
//#endregion
|
|
61
|
+
//#region src/core/lib/DTSManager.d.ts
|
|
62
|
+
interface UpdateTypesOptions {
|
|
63
|
+
updateMode: UpdateMode;
|
|
64
|
+
remoteName?: string;
|
|
65
|
+
remoteTarPath?: string;
|
|
66
|
+
remoteInfo?: RemoteInfo;
|
|
67
|
+
once?: boolean;
|
|
68
|
+
}
|
|
69
|
+
declare class DTSManager {
|
|
70
|
+
options: DTSManagerOptions;
|
|
71
|
+
runtimePkgs: string[];
|
|
72
|
+
remoteAliasMap: Record<string, Required<RemoteInfo>>;
|
|
73
|
+
loadedRemoteAPIAlias: Set<string>;
|
|
74
|
+
extraOptions: Record<string, any>;
|
|
75
|
+
updatedRemoteInfos: Record<string, Required<RemoteInfo>>;
|
|
76
|
+
constructor(options: DTSManagerOptions);
|
|
77
|
+
generateAPITypes(mapComponentsToExpose: Record<string, string>): string;
|
|
78
|
+
extractRemoteTypes(options: ReturnType<typeof retrieveRemoteConfig>): Promise<void>;
|
|
79
|
+
generateTypes(): Promise<void>;
|
|
80
|
+
requestRemoteManifest(remoteInfo: RemoteInfo, hostOptions: Required<HostOptions>): Promise<Required<RemoteInfo>>;
|
|
81
|
+
consumeTargetRemotes(hostOptions: Required<HostOptions>, remoteInfo: Required<RemoteInfo>): Promise<[string, string] | undefined>;
|
|
82
|
+
downloadAPITypes(remoteInfo: Required<RemoteInfo>, destinationPath: string, hostOptions: Required<HostOptions>): Promise<boolean | undefined>;
|
|
83
|
+
consumeAPITypes(hostOptions: Required<HostOptions>): void;
|
|
84
|
+
consumeArchiveTypes(options: HostOptions): Promise<{
|
|
85
|
+
hostOptions: Required<HostOptions>;
|
|
86
|
+
downloadPromisesResult: PromiseSettledResult<[string, string] | undefined>[];
|
|
87
|
+
}>;
|
|
88
|
+
consumeTypes(): Promise<void>;
|
|
89
|
+
updateTypes(options: UpdateTypesOptions): Promise<void>;
|
|
90
|
+
}
|
|
91
|
+
//#endregion
|
|
92
|
+
//#region src/core/rpc/expose-rpc.d.ts
|
|
93
|
+
declare function exposeRpc(fn: (...args: any[]) => any): void;
|
|
94
|
+
//#endregion
|
|
95
|
+
//#region src/core/rpc/types.d.ts
|
|
96
|
+
declare enum RpcGMCallTypes {
|
|
97
|
+
CALL = "mf_call",
|
|
98
|
+
RESOLVE = "mf_resolve",
|
|
99
|
+
REJECT = "mf_reject",
|
|
100
|
+
EXIT = "mf_exit"
|
|
101
|
+
}
|
|
102
|
+
interface RpcCallMessage {
|
|
103
|
+
type: RpcGMCallTypes.CALL;
|
|
104
|
+
id: string;
|
|
105
|
+
args: unknown[];
|
|
106
|
+
}
|
|
107
|
+
interface RpcResolveMessage {
|
|
108
|
+
type: RpcGMCallTypes.RESOLVE;
|
|
109
|
+
id: string;
|
|
110
|
+
value: unknown;
|
|
111
|
+
}
|
|
112
|
+
interface RpcRejectMessage {
|
|
113
|
+
type: RpcGMCallTypes.REJECT;
|
|
114
|
+
id: string;
|
|
115
|
+
error: unknown;
|
|
116
|
+
}
|
|
117
|
+
interface RpcExitMessage {
|
|
118
|
+
type: RpcGMCallTypes.EXIT;
|
|
119
|
+
id: string;
|
|
120
|
+
}
|
|
121
|
+
type RpcMessage = RpcCallMessage | RpcResolveMessage | RpcRejectMessage | RpcExitMessage;
|
|
122
|
+
type RpcMethod = (...args: any[]) => any;
|
|
123
|
+
type RpcRemoteMethod<T extends RpcMethod> = T extends ((...args: infer A) => infer R) ? R extends Promise<any> ? (...args: A) => R : (...args: A) => Promise<R> : (...args: unknown[]) => Promise<unknown>;
|
|
124
|
+
//#endregion
|
|
125
|
+
//#region src/core/rpc/wrap-rpc.d.ts
|
|
126
|
+
interface WrapRpcOptions {
|
|
127
|
+
id: string;
|
|
128
|
+
once?: boolean;
|
|
129
|
+
}
|
|
130
|
+
declare function wrapRpc<T extends (...args: any[]) => any>(childProcess: ChildProcess, options: WrapRpcOptions): RpcRemoteMethod<T>;
|
|
131
|
+
//#endregion
|
|
132
|
+
//#region src/core/rpc/rpc-worker.d.ts
|
|
133
|
+
interface RpcWorkerBase {
|
|
134
|
+
connect(...args: unknown[]): any;
|
|
135
|
+
terminate(): void;
|
|
136
|
+
readonly connected: boolean;
|
|
137
|
+
readonly id: string;
|
|
138
|
+
readonly process: ChildProcess | undefined;
|
|
139
|
+
}
|
|
140
|
+
type RpcWorker<T extends RpcMethod = RpcMethod> = RpcWorkerBase & RpcRemoteMethod<T>;
|
|
141
|
+
declare function createRpcWorker<T extends RpcMethod>(modulePath: string, data: unknown, memoryLimit?: number, once?: boolean): RpcWorker<T>;
|
|
142
|
+
declare function getRpcWorkerData(): unknown;
|
|
143
|
+
//#endregion
|
|
144
|
+
//#region src/core/rpc/rpc-error.d.ts
|
|
145
|
+
declare class RpcExitError extends Error {
|
|
146
|
+
readonly code?: string | number | null | undefined;
|
|
147
|
+
readonly signal?: string | null | undefined;
|
|
148
|
+
constructor(message: string, code?: string | number | null | undefined, signal?: string | null | undefined);
|
|
149
|
+
}
|
|
150
|
+
declare namespace index_d_exports {
|
|
151
|
+
export { RpcCallMessage, RpcExitError, RpcGMCallTypes, RpcMessage, RpcMethod, RpcRejectMessage, RpcRemoteMethod, RpcResolveMessage, RpcWorker, createRpcWorker, exposeRpc, getRpcWorkerData, wrapRpc };
|
|
152
|
+
}
|
|
153
|
+
//#endregion
|
|
154
|
+
//#region src/core/lib/DtsWorker.d.ts
|
|
155
|
+
type DtsWorkerOptions = DTSManagerOptions;
|
|
156
|
+
declare class DtsWorker {
|
|
157
|
+
rpcWorker: RpcWorker<RpcMethod>;
|
|
158
|
+
private _options;
|
|
159
|
+
private _res;
|
|
160
|
+
constructor(options: DtsWorkerOptions);
|
|
161
|
+
removeUnSerializationOptions(): void;
|
|
162
|
+
get controlledPromise(): ReturnType<DTSManager['generateTypes']>;
|
|
163
|
+
exit(): void;
|
|
164
|
+
}
|
|
165
|
+
//#endregion
|
|
166
|
+
export { DTSManagerOptions as a, retrieveRemoteConfig as c, DTSManager as i, TsConfigJson as l, DtsWorkerOptions as n, HostOptions as o, index_d_exports as r, RemoteInfo as s, DtsWorker as t, RemoteOptions as u };
|
package/dist/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# @module-federation/dts-plugin
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { a as DTSManagerOptions, i as DTSManager, l as TsConfigJson, o as HostOptions, s as RemoteInfo, u as RemoteOptions } from "./DtsWorker-Bt7-_SGH.js";
|
|
2
|
+
import { moduleFederationPlugin } from "@module-federation/sdk";
|
|
3
|
+
|
|
4
|
+
//#region src/core/configurations/hostPlugin.d.ts
|
|
5
|
+
declare const retrieveHostConfig: (options: HostOptions) => {
|
|
6
|
+
hostOptions: Required<HostOptions>;
|
|
7
|
+
mapRemotesToDownload: Record<string, RemoteInfo>;
|
|
8
|
+
};
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/core/lib/utils.d.ts
|
|
11
|
+
declare function getDTSManagerConstructor(implementation?: string): typeof DTSManager;
|
|
12
|
+
declare const validateOptions: (options: HostOptions) => void;
|
|
13
|
+
declare function retrieveTypesAssetsInfo(options: RemoteOptions): {
|
|
14
|
+
apiTypesPath: string;
|
|
15
|
+
zipTypesPath: string;
|
|
16
|
+
zipName: string;
|
|
17
|
+
apiFileName: string;
|
|
18
|
+
};
|
|
19
|
+
declare const isTSProject: (dtsOptions: moduleFederationPlugin.ModuleFederationPluginOptions["dts"], context?: string) => boolean;
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/core/lib/typeScriptCompiler.d.ts
|
|
22
|
+
declare const retrieveMfTypesPath: (tsConfig: TsConfigJson, remoteOptions: Required<RemoteOptions>) => string;
|
|
23
|
+
declare const retrieveOriginalOutDir: (tsConfig: TsConfigJson, remoteOptions: Required<RemoteOptions>) => string;
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/core/lib/archiveHandler.d.ts
|
|
26
|
+
declare const retrieveTypesZipPath: (mfTypesPath: string, remoteOptions: Required<RemoteOptions>) => string;
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/core/lib/generateTypes.d.ts
|
|
29
|
+
declare function generateTypes(options: DTSManagerOptions): Promise<void>;
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region src/core/lib/generateTypesInChildProcess.d.ts
|
|
32
|
+
declare function generateTypesInChildProcess(options: DTSManagerOptions): Promise<void>;
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region src/core/lib/consumeTypes.d.ts
|
|
35
|
+
declare function consumeTypes(options: DTSManagerOptions): Promise<void>;
|
|
36
|
+
//#endregion
|
|
37
|
+
//#region src/core/constant.d.ts
|
|
38
|
+
declare const REMOTE_ALIAS_IDENTIFIER = "REMOTE_ALIAS_IDENTIFIER";
|
|
39
|
+
declare const REMOTE_API_TYPES_FILE_NAME = "apis.d.ts";
|
|
40
|
+
declare const HOST_API_TYPES_FILE_NAME = "index.d.ts";
|
|
41
|
+
//#endregion
|
|
42
|
+
export { generateTypesInChildProcess as a, retrieveMfTypesPath as c, isTSProject as d, retrieveTypesAssetsInfo as f, consumeTypes as i, retrieveOriginalOutDir as l, retrieveHostConfig as m, REMOTE_ALIAS_IDENTIFIER as n, generateTypes as o, validateOptions as p, REMOTE_API_TYPES_FILE_NAME as r, retrieveTypesZipPath as s, HOST_API_TYPES_FILE_NAME as t, getDTSManagerConstructor as u };
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
const require_Action = require('./Action-CzhPMw2i.js');
|
|
2
|
+
const require_expose_rpc = require('./expose-rpc-BpRiu3VK.js');
|
|
3
|
+
let url = require("url");
|
|
4
|
+
let path = require("path");
|
|
5
|
+
path = require_Action.__toESM(path);
|
|
6
|
+
let crypto = require("crypto");
|
|
7
|
+
let child_process = require("child_process");
|
|
8
|
+
child_process = require_Action.__toESM(child_process);
|
|
9
|
+
let process$1 = require("process");
|
|
10
|
+
process$1 = require_Action.__toESM(process$1);
|
|
11
|
+
|
|
12
|
+
//#region src/core/rpc/rpc-error.ts
|
|
13
|
+
var RpcExitError = class extends Error {
|
|
14
|
+
constructor(message, code, signal) {
|
|
15
|
+
super(message);
|
|
16
|
+
this.code = code;
|
|
17
|
+
this.signal = signal;
|
|
18
|
+
this.name = "RpcExitError";
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/core/rpc/wrap-rpc.ts
|
|
24
|
+
function createControlledPromise() {
|
|
25
|
+
let resolve = () => void 0;
|
|
26
|
+
let reject = () => void 0;
|
|
27
|
+
return {
|
|
28
|
+
promise: new Promise((aResolve, aReject) => {
|
|
29
|
+
resolve = aResolve;
|
|
30
|
+
reject = aReject;
|
|
31
|
+
}),
|
|
32
|
+
resolve,
|
|
33
|
+
reject
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function wrapRpc(childProcess, options) {
|
|
37
|
+
return (async (...args) => {
|
|
38
|
+
if (!childProcess.send) throw new Error(`Process ${childProcess.pid} doesn't have IPC channels`);
|
|
39
|
+
else if (!childProcess.connected) throw new Error(`Process ${childProcess.pid} doesn't have open IPC channels`);
|
|
40
|
+
const { id, once } = options;
|
|
41
|
+
const { promise: resultPromise, resolve: resolveResult, reject: rejectResult } = createControlledPromise();
|
|
42
|
+
const { promise: sendPromise, resolve: resolveSend, reject: rejectSend } = createControlledPromise();
|
|
43
|
+
const handleMessage = (message) => {
|
|
44
|
+
if (message?.id === id) {
|
|
45
|
+
if (message.type === require_expose_rpc.RpcGMCallTypes.RESOLVE) resolveResult(message.value);
|
|
46
|
+
else if (message.type === require_expose_rpc.RpcGMCallTypes.REJECT) rejectResult(message.error);
|
|
47
|
+
}
|
|
48
|
+
if (once && childProcess?.kill) childProcess.kill("SIGTERM");
|
|
49
|
+
};
|
|
50
|
+
const handleClose = (code, signal) => {
|
|
51
|
+
rejectResult(new RpcExitError(code ? `Process ${childProcess.pid} exited with code ${code}${signal ? ` [${signal}]` : ""}` : `Process ${childProcess.pid} exited${signal ? ` [${signal}]` : ""}`, code, signal));
|
|
52
|
+
removeHandlers();
|
|
53
|
+
};
|
|
54
|
+
const removeHandlers = () => {
|
|
55
|
+
childProcess.off("message", handleMessage);
|
|
56
|
+
childProcess.off("close", handleClose);
|
|
57
|
+
};
|
|
58
|
+
if (once) childProcess.once("message", handleMessage);
|
|
59
|
+
else childProcess.on("message", handleMessage);
|
|
60
|
+
childProcess.on("close", handleClose);
|
|
61
|
+
childProcess.send({
|
|
62
|
+
type: require_expose_rpc.RpcGMCallTypes.CALL,
|
|
63
|
+
id,
|
|
64
|
+
args
|
|
65
|
+
}, (error) => {
|
|
66
|
+
if (error) {
|
|
67
|
+
rejectSend(error);
|
|
68
|
+
removeHandlers();
|
|
69
|
+
} else resolveSend(void 0);
|
|
70
|
+
});
|
|
71
|
+
return sendPromise.then(() => resultPromise);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
//#endregion
|
|
76
|
+
//#region src/core/rpc/rpc-worker.ts
|
|
77
|
+
const FEDERATION_WORKER_DATA_ENV_KEY = "VMOK_WORKER_DATA_ENV";
|
|
78
|
+
function createRpcWorker(modulePath, data, memoryLimit, once) {
|
|
79
|
+
const options = {
|
|
80
|
+
env: {
|
|
81
|
+
...process$1.env,
|
|
82
|
+
[FEDERATION_WORKER_DATA_ENV_KEY]: JSON.stringify(data || {})
|
|
83
|
+
},
|
|
84
|
+
stdio: [
|
|
85
|
+
"inherit",
|
|
86
|
+
"inherit",
|
|
87
|
+
"inherit",
|
|
88
|
+
"ipc"
|
|
89
|
+
],
|
|
90
|
+
serialization: "advanced"
|
|
91
|
+
};
|
|
92
|
+
if (memoryLimit) options.execArgv = [`--max-old-space-size=${memoryLimit}`];
|
|
93
|
+
let childProcess, remoteMethod;
|
|
94
|
+
const id = (0, crypto.randomUUID)();
|
|
95
|
+
return {
|
|
96
|
+
connect(...args) {
|
|
97
|
+
if (childProcess && !childProcess.connected) {
|
|
98
|
+
childProcess.send({
|
|
99
|
+
type: require_expose_rpc.RpcGMCallTypes.EXIT,
|
|
100
|
+
id
|
|
101
|
+
});
|
|
102
|
+
childProcess = void 0;
|
|
103
|
+
remoteMethod = void 0;
|
|
104
|
+
}
|
|
105
|
+
if (!childProcess?.connected) {
|
|
106
|
+
childProcess = child_process.fork(modulePath, options);
|
|
107
|
+
remoteMethod = wrapRpc(childProcess, {
|
|
108
|
+
id,
|
|
109
|
+
once
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
if (!remoteMethod) return Promise.reject(/* @__PURE__ */ new Error("Worker is not connected - cannot perform RPC."));
|
|
113
|
+
return remoteMethod(...args);
|
|
114
|
+
},
|
|
115
|
+
terminate() {
|
|
116
|
+
try {
|
|
117
|
+
if (childProcess.connected) childProcess.send({
|
|
118
|
+
type: require_expose_rpc.RpcGMCallTypes.EXIT,
|
|
119
|
+
id
|
|
120
|
+
}, (err) => {
|
|
121
|
+
if (err) console.error("Error sending message:", err);
|
|
122
|
+
});
|
|
123
|
+
} catch (error) {
|
|
124
|
+
if (error.code === "EPIPE") console.error("Pipe closed before message could be sent:", error);
|
|
125
|
+
else console.error("Unexpected error:", error);
|
|
126
|
+
}
|
|
127
|
+
childProcess = void 0;
|
|
128
|
+
remoteMethod = void 0;
|
|
129
|
+
},
|
|
130
|
+
get connected() {
|
|
131
|
+
return Boolean(childProcess?.connected);
|
|
132
|
+
},
|
|
133
|
+
get process() {
|
|
134
|
+
return childProcess;
|
|
135
|
+
},
|
|
136
|
+
get id() {
|
|
137
|
+
return id;
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
function getRpcWorkerData() {
|
|
142
|
+
return JSON.parse(process$1.env[FEDERATION_WORKER_DATA_ENV_KEY] || "{}");
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
//#endregion
|
|
146
|
+
//#region src/core/rpc/index.ts
|
|
147
|
+
var rpc_exports = /* @__PURE__ */ require_Action.__exportAll({
|
|
148
|
+
RpcExitError: () => RpcExitError,
|
|
149
|
+
RpcGMCallTypes: () => require_expose_rpc.RpcGMCallTypes,
|
|
150
|
+
createRpcWorker: () => createRpcWorker,
|
|
151
|
+
exposeRpc: () => require_expose_rpc.exposeRpc,
|
|
152
|
+
getRpcWorkerData: () => getRpcWorkerData,
|
|
153
|
+
wrapRpc: () => wrapRpc
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
//#endregion
|
|
157
|
+
//#region src/core/lib/DtsWorker.ts
|
|
158
|
+
const __filename$1 = (0, url.fileURLToPath)(require("url").pathToFileURL(__filename).href);
|
|
159
|
+
const __dirname$1 = path.default.dirname(__filename$1);
|
|
160
|
+
const __extname = path.default.extname(__filename$1);
|
|
161
|
+
var DtsWorker = class {
|
|
162
|
+
constructor(options) {
|
|
163
|
+
this._options = require_expose_rpc.cloneDeepOptions(options);
|
|
164
|
+
this.removeUnSerializationOptions();
|
|
165
|
+
this.rpcWorker = createRpcWorker(path.default.resolve(__dirname$1, `./fork-generate-dts${__extname}`), {}, void 0, true);
|
|
166
|
+
this._res = this.rpcWorker.connect(this._options);
|
|
167
|
+
}
|
|
168
|
+
removeUnSerializationOptions() {
|
|
169
|
+
if (this._options.remote?.moduleFederationConfig?.manifest) delete this._options.remote?.moduleFederationConfig?.manifest;
|
|
170
|
+
if (this._options.host?.moduleFederationConfig?.manifest) delete this._options.host?.moduleFederationConfig?.manifest;
|
|
171
|
+
}
|
|
172
|
+
get controlledPromise() {
|
|
173
|
+
const ensureChildProcessExit = () => {
|
|
174
|
+
try {
|
|
175
|
+
const pid = this.rpcWorker.process?.pid;
|
|
176
|
+
const rootPid = process.pid;
|
|
177
|
+
if (pid && rootPid !== pid) process.kill(pid, 0);
|
|
178
|
+
} catch (error) {
|
|
179
|
+
if (require_expose_rpc.isDebugMode()) console.error(error);
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
return Promise.resolve(this._res).then(() => {
|
|
183
|
+
this.exit();
|
|
184
|
+
ensureChildProcessExit();
|
|
185
|
+
}).catch((err) => {
|
|
186
|
+
if (require_expose_rpc.isDebugMode()) console.error(err);
|
|
187
|
+
ensureChildProcessExit();
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
exit() {
|
|
191
|
+
try {
|
|
192
|
+
this.rpcWorker?.terminate();
|
|
193
|
+
} catch (err) {
|
|
194
|
+
if (require_expose_rpc.isDebugMode()) console.error(err);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
//#endregion
|
|
200
|
+
//#region src/core/lib/generateTypesInChildProcess.ts
|
|
201
|
+
async function generateTypesInChildProcess(options) {
|
|
202
|
+
return new DtsWorker(options).controlledPromise;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
//#endregion
|
|
206
|
+
//#region src/core/lib/consumeTypes.ts
|
|
207
|
+
async function consumeTypes(options) {
|
|
208
|
+
await new (require_expose_rpc.getDTSManagerConstructor(options.host?.implementation))(options).consumeTypes();
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
//#endregion
|
|
212
|
+
Object.defineProperty(exports, 'DtsWorker', {
|
|
213
|
+
enumerable: true,
|
|
214
|
+
get: function () {
|
|
215
|
+
return DtsWorker;
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
Object.defineProperty(exports, 'consumeTypes', {
|
|
219
|
+
enumerable: true,
|
|
220
|
+
get: function () {
|
|
221
|
+
return consumeTypes;
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
Object.defineProperty(exports, 'createRpcWorker', {
|
|
225
|
+
enumerable: true,
|
|
226
|
+
get: function () {
|
|
227
|
+
return createRpcWorker;
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
Object.defineProperty(exports, 'generateTypesInChildProcess', {
|
|
231
|
+
enumerable: true,
|
|
232
|
+
get: function () {
|
|
233
|
+
return generateTypesInChildProcess;
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
Object.defineProperty(exports, 'rpc_exports', {
|
|
237
|
+
enumerable: true,
|
|
238
|
+
get: function () {
|
|
239
|
+
return rpc_exports;
|
|
240
|
+
}
|
|
241
|
+
});
|
package/dist/core.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { a as DTSManagerOptions, c as retrieveRemoteConfig, i as DTSManager, o as HostOptions, r as index_d_exports, t as DtsWorker, u as RemoteOptions } from "./DtsWorker-Bt7-_SGH.js";
|
|
2
|
+
import { a as generateTypesInChildProcess, c as retrieveMfTypesPath, d as isTSProject, f as retrieveTypesAssetsInfo, i as consumeTypes, l as retrieveOriginalOutDir, m as retrieveHostConfig, n as REMOTE_ALIAS_IDENTIFIER, o as generateTypes, p as validateOptions, r as REMOTE_API_TYPES_FILE_NAME, s as retrieveTypesZipPath, t as HOST_API_TYPES_FILE_NAME, u as getDTSManagerConstructor } from "./constant-YOdZl7sj.js";
|
|
3
|
+
export { DTSManager, type DTSManagerOptions, DtsWorker, HOST_API_TYPES_FILE_NAME, type HostOptions, REMOTE_ALIAS_IDENTIFIER, REMOTE_API_TYPES_FILE_NAME, type RemoteOptions, consumeTypes, generateTypes, generateTypesInChildProcess, getDTSManagerConstructor, isTSProject, retrieveHostConfig, retrieveMfTypesPath, retrieveOriginalOutDir, retrieveRemoteConfig, retrieveTypesAssetsInfo, retrieveTypesZipPath, index_d_exports as rpc, validateOptions };
|
package/dist/core.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
require('./Broker-CaenCqdn.js');
|
|
3
|
+
const require_expose_rpc = require('./expose-rpc-BpRiu3VK.js');
|
|
4
|
+
const require_consumeTypes = require('./consumeTypes-Dle9g2SZ.js');
|
|
5
|
+
|
|
6
|
+
exports.DTSManager = require_expose_rpc.DTSManager;
|
|
7
|
+
exports.DtsWorker = require_consumeTypes.DtsWorker;
|
|
8
|
+
exports.HOST_API_TYPES_FILE_NAME = require_expose_rpc.HOST_API_TYPES_FILE_NAME;
|
|
9
|
+
exports.REMOTE_ALIAS_IDENTIFIER = require_expose_rpc.REMOTE_ALIAS_IDENTIFIER;
|
|
10
|
+
exports.REMOTE_API_TYPES_FILE_NAME = require_expose_rpc.REMOTE_API_TYPES_FILE_NAME;
|
|
11
|
+
exports.consumeTypes = require_consumeTypes.consumeTypes;
|
|
12
|
+
exports.generateTypes = require_expose_rpc.generateTypes;
|
|
13
|
+
exports.generateTypesInChildProcess = require_consumeTypes.generateTypesInChildProcess;
|
|
14
|
+
exports.getDTSManagerConstructor = require_expose_rpc.getDTSManagerConstructor;
|
|
15
|
+
exports.isTSProject = require_expose_rpc.isTSProject;
|
|
16
|
+
exports.retrieveHostConfig = require_expose_rpc.retrieveHostConfig;
|
|
17
|
+
exports.retrieveMfTypesPath = require_expose_rpc.retrieveMfTypesPath;
|
|
18
|
+
exports.retrieveOriginalOutDir = require_expose_rpc.retrieveOriginalOutDir;
|
|
19
|
+
exports.retrieveRemoteConfig = require_expose_rpc.retrieveRemoteConfig;
|
|
20
|
+
exports.retrieveTypesAssetsInfo = require_expose_rpc.retrieveTypesAssetsInfo;
|
|
21
|
+
exports.retrieveTypesZipPath = require_expose_rpc.retrieveTypesZipPath;
|
|
22
|
+
Object.defineProperty(exports, 'rpc', {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
get: function () {
|
|
25
|
+
return require_consumeTypes.rpc_exports;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
exports.validateOptions = require_expose_rpc.validateOptions;
|