@module-federation/native-federation-typescript 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +82 -34
- package/dist/CHANGELOG.md +336 -0
- package/dist/DTSManagerOptions-3369791f.d.ts +9 -0
- package/dist/HostOptions-cf22e0ab.d.ts +23 -0
- package/dist/README.md +214 -0
- package/dist/chunk-2NC7LVYZ.js +864 -0
- package/dist/chunk-CF5CH54A.mjs +864 -0
- package/dist/chunk-JLWFNRJL.js +179 -0
- package/dist/chunk-QYHGZU7D.mjs +244 -0
- package/dist/chunk-VHQW5BQS.js +244 -0
- package/dist/chunk-VKKLMSMI.mjs +179 -0
- package/dist/esbuild.d.mts +9 -0
- package/dist/esbuild.d.ts +6 -3
- package/dist/esbuild.js +14 -1
- package/dist/esbuild.mjs +14 -1
- package/dist/helpers.d.mts +160 -0
- package/dist/helpers.d.ts +160 -0
- package/dist/helpers.js +40 -0
- package/dist/helpers.mjs +40 -0
- package/dist/index.d.mts +16 -0
- package/dist/index.d.ts +13 -4
- package/dist/index.js +10 -1
- package/dist/index.mjs +10 -1
- package/dist/lib/forkGenerateDts.d.mts +9 -0
- package/dist/lib/forkGenerateDts.d.ts +9 -0
- package/dist/lib/forkGenerateDts.js +18 -0
- package/dist/lib/forkGenerateDts.mjs +18 -0
- package/dist/package.json +103 -0
- package/dist/rolldown.d.mts +9 -0
- package/dist/rolldown.d.ts +9 -0
- package/dist/rolldown.js +14 -0
- package/dist/rolldown.mjs +14 -0
- package/dist/rollup.d.mts +9 -0
- package/dist/rollup.d.ts +6 -3
- package/dist/rollup.js +14 -1
- package/dist/rollup.mjs +14 -1
- package/dist/rspack.d.mts +9 -0
- package/dist/rspack.d.ts +6 -3
- package/dist/rspack.js +14 -1
- package/dist/rspack.mjs +14 -1
- package/dist/vite.d.mts +9 -0
- package/dist/vite.d.ts +6 -3
- package/dist/vite.js +14 -1
- package/dist/vite.mjs +14 -1
- package/dist/webpack.d.mts +9 -0
- package/dist/webpack.d.ts +6 -3
- package/dist/webpack.js +14 -1
- package/dist/webpack.mjs +14 -1
- package/package.json +50 -5
- package/CHANGELOG.md +0 -28
- package/dist/RemoteOptions-ce85caac.d.ts +0 -17
- package/dist/chunk-HJB2AKNY.mjs +0 -682
- package/dist/chunk-WNKHVVXS.js +0 -682
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import {
|
|
2
|
+
consumeTypes,
|
|
3
|
+
generateTypesInChildProcess
|
|
4
|
+
} from "./chunk-QYHGZU7D.mjs";
|
|
5
|
+
import {
|
|
6
|
+
generateTypes,
|
|
7
|
+
retrieveTypesAssetsInfo,
|
|
8
|
+
validateOptions
|
|
9
|
+
} from "./chunk-CF5CH54A.mjs";
|
|
10
|
+
|
|
11
|
+
// packages/native-federation-typescript/src/index.ts
|
|
12
|
+
import { createUnplugin } from "unplugin";
|
|
13
|
+
import fs from "fs";
|
|
14
|
+
var NativeFederationTypeScriptRemote = createUnplugin(
|
|
15
|
+
(enhancedOptions) => {
|
|
16
|
+
const options = "extraOptions" in enhancedOptions ? enhancedOptions.remote : enhancedOptions;
|
|
17
|
+
const extraOptions = "extraOptions" in enhancedOptions ? enhancedOptions.extraOptions : void 0;
|
|
18
|
+
validateOptions(options);
|
|
19
|
+
const isProd = process.env.NODE_ENV === "production";
|
|
20
|
+
const generateTypesOptions = {
|
|
21
|
+
remote: options,
|
|
22
|
+
extraOptions
|
|
23
|
+
};
|
|
24
|
+
const getGenerateTypesFn = () => {
|
|
25
|
+
let fn = generateTypes;
|
|
26
|
+
let res;
|
|
27
|
+
if (options.compileInChildProcess) {
|
|
28
|
+
fn = generateTypesInChildProcess;
|
|
29
|
+
}
|
|
30
|
+
if (isProd) {
|
|
31
|
+
res = fn(generateTypesOptions);
|
|
32
|
+
return () => res;
|
|
33
|
+
}
|
|
34
|
+
return fn;
|
|
35
|
+
};
|
|
36
|
+
const generateTypesFn = getGenerateTypesFn();
|
|
37
|
+
return {
|
|
38
|
+
name: "native-federation-typescript/remote",
|
|
39
|
+
rollup: {
|
|
40
|
+
writeBundle: async () => {
|
|
41
|
+
await generateTypesFn(generateTypesOptions);
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
vite: {
|
|
45
|
+
buildStart: async () => {
|
|
46
|
+
if (isProd) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
await generateTypesFn(generateTypesOptions);
|
|
50
|
+
},
|
|
51
|
+
watchChange: async () => {
|
|
52
|
+
if (isProd) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
await generateTypesFn(generateTypesOptions);
|
|
56
|
+
},
|
|
57
|
+
writeBundle: async () => {
|
|
58
|
+
await generateTypesFn(generateTypesOptions);
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
webpack: (compiler) => {
|
|
62
|
+
compiler.hooks.thisCompilation.tap("generateTypes", (compilation) => {
|
|
63
|
+
const hookName = "mf:generateTypes";
|
|
64
|
+
compilation.hooks.processAssets.tapPromise(
|
|
65
|
+
{
|
|
66
|
+
name: hookName,
|
|
67
|
+
stage: (
|
|
68
|
+
// @ts-expect-error use runtime variable in case peer dep not installed
|
|
69
|
+
compilation.constructor.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER
|
|
70
|
+
)
|
|
71
|
+
},
|
|
72
|
+
async () => {
|
|
73
|
+
try {
|
|
74
|
+
const { zipTypesPath, apiTypesPath, zipName, apiFileName } = retrieveTypesAssetsInfo(options);
|
|
75
|
+
if (zipName && compilation.getAsset(zipName)) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
await generateTypesFn(generateTypesOptions);
|
|
79
|
+
if (zipTypesPath) {
|
|
80
|
+
compilation.emitAsset(
|
|
81
|
+
zipName,
|
|
82
|
+
new compiler.webpack.sources.RawSource(
|
|
83
|
+
fs.readFileSync(zipTypesPath),
|
|
84
|
+
false
|
|
85
|
+
)
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
if (apiTypesPath) {
|
|
89
|
+
compilation.emitAsset(
|
|
90
|
+
apiFileName,
|
|
91
|
+
new compiler.webpack.sources.RawSource(
|
|
92
|
+
fs.readFileSync(apiTypesPath),
|
|
93
|
+
false
|
|
94
|
+
)
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
} catch (err) {
|
|
98
|
+
console.error(err);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
);
|
|
102
|
+
});
|
|
103
|
+
},
|
|
104
|
+
rspack: (compiler) => {
|
|
105
|
+
compiler.hooks.thisCompilation.tap("generateTypes", (compilation) => {
|
|
106
|
+
const hookName = "mf:generateTypes";
|
|
107
|
+
compilation.hooks.processAssets.tapPromise(
|
|
108
|
+
{
|
|
109
|
+
name: hookName,
|
|
110
|
+
stage: (
|
|
111
|
+
// @ts-expect-error use runtime variable in case peer dep not installed
|
|
112
|
+
compilation.constructor.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER
|
|
113
|
+
)
|
|
114
|
+
},
|
|
115
|
+
async () => {
|
|
116
|
+
try {
|
|
117
|
+
const { zipTypesPath, apiTypesPath, zipName, apiFileName } = retrieveTypesAssetsInfo(options);
|
|
118
|
+
if (zipName && compilation.getAsset(zipName)) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
await generateTypesFn(generateTypesOptions);
|
|
122
|
+
if (zipTypesPath) {
|
|
123
|
+
compilation.emitAsset(
|
|
124
|
+
zipName,
|
|
125
|
+
new compiler.webpack.sources.RawSource(
|
|
126
|
+
fs.readFileSync(zipTypesPath),
|
|
127
|
+
false
|
|
128
|
+
)
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
if (apiTypesPath) {
|
|
132
|
+
compilation.emitAsset(
|
|
133
|
+
apiFileName,
|
|
134
|
+
new compiler.webpack.sources.RawSource(
|
|
135
|
+
fs.readFileSync(apiTypesPath),
|
|
136
|
+
false
|
|
137
|
+
)
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
} catch (err) {
|
|
141
|
+
console.error(err);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
);
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
);
|
|
150
|
+
var NativeFederationTypeScriptHost = createUnplugin(
|
|
151
|
+
(enhancedOptions) => {
|
|
152
|
+
const options = "extraOptions" in enhancedOptions ? enhancedOptions.host : enhancedOptions;
|
|
153
|
+
const extraOptions = "extraOptions" in enhancedOptions ? enhancedOptions.extraOptions : void 0;
|
|
154
|
+
validateOptions(options);
|
|
155
|
+
const consumeTypesOptions = {
|
|
156
|
+
host: options,
|
|
157
|
+
extraOptions
|
|
158
|
+
};
|
|
159
|
+
const consumeTypesPromise = consumeTypes(consumeTypesOptions);
|
|
160
|
+
return {
|
|
161
|
+
name: "native-federation-typescript/host",
|
|
162
|
+
async writeBundle() {
|
|
163
|
+
await consumeTypesPromise;
|
|
164
|
+
},
|
|
165
|
+
get vite() {
|
|
166
|
+
return process.env.NODE_ENV === "production" ? void 0 : {
|
|
167
|
+
buildStart: async () => {
|
|
168
|
+
await consumeTypesPromise;
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
);
|
|
175
|
+
|
|
176
|
+
export {
|
|
177
|
+
NativeFederationTypeScriptRemote,
|
|
178
|
+
NativeFederationTypeScriptHost
|
|
179
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { EnhancedRemoteOptions, EnhancedHostOptions } from './index.mjs';
|
|
2
|
+
import 'unplugin';
|
|
3
|
+
import './HostOptions-cf22e0ab.js';
|
|
4
|
+
import '@module-federation/sdk';
|
|
5
|
+
|
|
6
|
+
declare const NativeFederationTypeScriptRemote: (options: EnhancedRemoteOptions) => undefined;
|
|
7
|
+
declare const NativeFederationTypeScriptHost: (options: EnhancedHostOptions) => undefined;
|
|
8
|
+
|
|
9
|
+
export { NativeFederationTypeScriptHost, NativeFederationTypeScriptRemote };
|
package/dist/esbuild.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EnhancedRemoteOptions, EnhancedHostOptions } from './index.js';
|
|
2
|
+
import 'unplugin';
|
|
3
|
+
import './HostOptions-cf22e0ab.js';
|
|
4
|
+
import '@module-federation/sdk';
|
|
2
5
|
|
|
3
|
-
declare const NativeFederationTypeScriptRemote: (options:
|
|
4
|
-
declare const NativeFederationTypeScriptHost: (options:
|
|
6
|
+
declare const NativeFederationTypeScriptRemote: (options: EnhancedRemoteOptions) => undefined;
|
|
7
|
+
declare const NativeFederationTypeScriptHost: (options: EnhancedHostOptions) => undefined;
|
|
5
8
|
|
|
6
9
|
export { NativeFederationTypeScriptHost, NativeFederationTypeScriptRemote };
|
package/dist/esbuild.js
CHANGED
|
@@ -1 +1,14 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var _chunkJLWFNRJLjs = require('./chunk-JLWFNRJL.js');
|
|
5
|
+
require('./chunk-VHQW5BQS.js');
|
|
6
|
+
require('./chunk-2NC7LVYZ.js');
|
|
7
|
+
|
|
8
|
+
// packages/native-federation-typescript/src/esbuild.ts
|
|
9
|
+
var NativeFederationTypeScriptRemote2 = _chunkJLWFNRJLjs.NativeFederationTypeScriptRemote.esbuild;
|
|
10
|
+
var NativeFederationTypeScriptHost2 = _chunkJLWFNRJLjs.NativeFederationTypeScriptHost.esbuild;
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
exports.NativeFederationTypeScriptHost = NativeFederationTypeScriptHost2; exports.NativeFederationTypeScriptRemote = NativeFederationTypeScriptRemote2;
|
package/dist/esbuild.mjs
CHANGED
|
@@ -1 +1,14 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {
|
|
2
|
+
NativeFederationTypeScriptHost,
|
|
3
|
+
NativeFederationTypeScriptRemote
|
|
4
|
+
} from "./chunk-VKKLMSMI.mjs";
|
|
5
|
+
import "./chunk-QYHGZU7D.mjs";
|
|
6
|
+
import "./chunk-CF5CH54A.mjs";
|
|
7
|
+
|
|
8
|
+
// packages/native-federation-typescript/src/esbuild.ts
|
|
9
|
+
var NativeFederationTypeScriptRemote2 = NativeFederationTypeScriptRemote.esbuild;
|
|
10
|
+
var NativeFederationTypeScriptHost2 = NativeFederationTypeScriptHost.esbuild;
|
|
11
|
+
export {
|
|
12
|
+
NativeFederationTypeScriptHost2 as NativeFederationTypeScriptHost,
|
|
13
|
+
NativeFederationTypeScriptRemote2 as NativeFederationTypeScriptRemote
|
|
14
|
+
};
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import typescript from 'typescript';
|
|
2
|
+
import { R as RemoteOptions, H as HostOptions, a as RemoteInfo } from './HostOptions-cf22e0ab.js';
|
|
3
|
+
import { D as DTSManagerOptions } from './DTSManagerOptions-3369791f.js';
|
|
4
|
+
import { ChildProcess } from 'child_process';
|
|
5
|
+
import '@module-federation/sdk';
|
|
6
|
+
|
|
7
|
+
declare const retrieveRemoteConfig: (options: RemoteOptions) => {
|
|
8
|
+
tsConfig: typescript.CompilerOptions;
|
|
9
|
+
mapComponentsToExpose: Record<string, string>;
|
|
10
|
+
remoteOptions: Required<RemoteOptions>;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
declare const retrieveHostConfig: (options: HostOptions) => {
|
|
14
|
+
hostOptions: Required<HostOptions>;
|
|
15
|
+
mapRemotesToDownload: Record<string, RemoteInfo>;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
declare const REMOTE_ALIAS_IDENTIFIER = "REMOTE_ALIAS_IDENTIFIER";
|
|
19
|
+
declare const REMOTE_API_TYPES_FILE_NAME = "apis.d.ts";
|
|
20
|
+
declare const HOST_API_TYPES_FILE_NAME = "index.d.ts";
|
|
21
|
+
declare const enum UpdateMode {
|
|
22
|
+
POSITIVE = "POSITIVE",
|
|
23
|
+
PASSIVE = "PASSIVE"
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
interface UpdateTypesOptions {
|
|
27
|
+
updateMode: UpdateMode;
|
|
28
|
+
remoteName?: string;
|
|
29
|
+
remoteTarPath?: string;
|
|
30
|
+
}
|
|
31
|
+
declare class DTSManager {
|
|
32
|
+
options: DTSManagerOptions;
|
|
33
|
+
runtimePkgs: string[];
|
|
34
|
+
remoteAliasMap: Record<string, Required<RemoteInfo>>;
|
|
35
|
+
loadedRemoteAPIAlias: string[];
|
|
36
|
+
extraOptions: Record<string, any>;
|
|
37
|
+
constructor(options: DTSManagerOptions);
|
|
38
|
+
generateAPITypes(mapComponentsToExpose: Record<string, string>): string;
|
|
39
|
+
extractRemoteTypes(options: ReturnType<typeof retrieveRemoteConfig>): Promise<void>;
|
|
40
|
+
generateTypes(): Promise<void>;
|
|
41
|
+
requestRemoteManifest(remoteInfo: RemoteInfo): Promise<Required<RemoteInfo>>;
|
|
42
|
+
consumeTargetRemotes(hostOptions: Required<HostOptions>, remoteInfo: Required<RemoteInfo>): Promise<[string, string] | undefined>;
|
|
43
|
+
downloadAPITypes(remoteInfo: Required<RemoteInfo>, destinationPath: string): Promise<void>;
|
|
44
|
+
consumeAPITypes(hostOptions: Required<HostOptions>): void;
|
|
45
|
+
consumeArchiveTypes(options: HostOptions): Promise<{
|
|
46
|
+
hostOptions: Required<HostOptions>;
|
|
47
|
+
downloadPromisesResult: PromiseSettledResult<[string, string] | undefined>[];
|
|
48
|
+
}>;
|
|
49
|
+
consumeTypes(): Promise<void>;
|
|
50
|
+
updateTypes(options: UpdateTypesOptions): Promise<void>;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
declare function getDTSManagerConstructor(implementation?: string): typeof DTSManager;
|
|
54
|
+
declare const validateOptions: (options: HostOptions) => void;
|
|
55
|
+
declare function retrieveTypesAssetsInfo(options: RemoteOptions): {
|
|
56
|
+
apiTypesPath: string;
|
|
57
|
+
zipTypesPath: string;
|
|
58
|
+
zipName: string;
|
|
59
|
+
apiFileName: string;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
declare const retrieveMfTypesPath: (tsConfig: typescript.CompilerOptions, remoteOptions: Required<RemoteOptions>) => string;
|
|
63
|
+
declare const retrieveOriginalOutDir: (tsConfig: typescript.CompilerOptions, remoteOptions: Required<RemoteOptions>) => string;
|
|
64
|
+
|
|
65
|
+
declare const retrieveTypesZipPath: (mfTypesPath: string, remoteOptions: Required<RemoteOptions>) => string;
|
|
66
|
+
|
|
67
|
+
declare function generateTypes(options: DTSManagerOptions): Promise<void>;
|
|
68
|
+
|
|
69
|
+
declare function generateTypesInChildProcess(options: DTSManagerOptions): Promise<void>;
|
|
70
|
+
|
|
71
|
+
declare function consumeTypes(options: DTSManagerOptions): Promise<void>;
|
|
72
|
+
|
|
73
|
+
declare function exposeRpc(fn: (...args: any[]) => any): void;
|
|
74
|
+
|
|
75
|
+
declare enum RpcGMCallTypes {
|
|
76
|
+
CALL = "mf_call",
|
|
77
|
+
RESOLVE = "mf_resolve",
|
|
78
|
+
REJECT = "mf_reject",
|
|
79
|
+
EXIT = "mf_exit"
|
|
80
|
+
}
|
|
81
|
+
interface RpcCallMessage {
|
|
82
|
+
type: RpcGMCallTypes.CALL;
|
|
83
|
+
id: string;
|
|
84
|
+
args: unknown[];
|
|
85
|
+
}
|
|
86
|
+
interface RpcResolveMessage {
|
|
87
|
+
type: RpcGMCallTypes.RESOLVE;
|
|
88
|
+
id: string;
|
|
89
|
+
value: unknown;
|
|
90
|
+
}
|
|
91
|
+
interface RpcRejectMessage {
|
|
92
|
+
type: RpcGMCallTypes.REJECT;
|
|
93
|
+
id: string;
|
|
94
|
+
error: unknown;
|
|
95
|
+
}
|
|
96
|
+
interface RpcExitMessage {
|
|
97
|
+
type: RpcGMCallTypes.EXIT;
|
|
98
|
+
id: string;
|
|
99
|
+
}
|
|
100
|
+
type RpcMessage = RpcCallMessage | RpcResolveMessage | RpcRejectMessage | RpcExitMessage;
|
|
101
|
+
type RpcMethod = (...args: any[]) => any;
|
|
102
|
+
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>;
|
|
103
|
+
|
|
104
|
+
interface WrapRpcOptions {
|
|
105
|
+
id: string;
|
|
106
|
+
once?: boolean;
|
|
107
|
+
}
|
|
108
|
+
declare function wrapRpc<T extends (...args: any[]) => any>(childProcess: ChildProcess, options: WrapRpcOptions): RpcRemoteMethod<T>;
|
|
109
|
+
|
|
110
|
+
interface RpcWorkerBase {
|
|
111
|
+
connect(...args: unknown[]): any;
|
|
112
|
+
terminate(): void;
|
|
113
|
+
readonly connected: boolean;
|
|
114
|
+
readonly id: string;
|
|
115
|
+
readonly process: ChildProcess | undefined;
|
|
116
|
+
}
|
|
117
|
+
type RpcWorker<T extends RpcMethod = RpcMethod> = RpcWorkerBase & RpcRemoteMethod<T>;
|
|
118
|
+
declare function createRpcWorker<T extends RpcMethod>(modulePath: string, data: unknown, memoryLimit?: number, once?: boolean): RpcWorker<T>;
|
|
119
|
+
declare function getRpcWorkerData(): unknown;
|
|
120
|
+
|
|
121
|
+
declare class RpcExitError extends Error {
|
|
122
|
+
readonly code?: string | number | null | undefined;
|
|
123
|
+
readonly signal?: string | null | undefined;
|
|
124
|
+
constructor(message: string, code?: string | number | null | undefined, signal?: string | null | undefined);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
type index_RpcCallMessage = RpcCallMessage;
|
|
128
|
+
type index_RpcExitError = RpcExitError;
|
|
129
|
+
declare const index_RpcExitError: typeof RpcExitError;
|
|
130
|
+
type index_RpcGMCallTypes = RpcGMCallTypes;
|
|
131
|
+
declare const index_RpcGMCallTypes: typeof RpcGMCallTypes;
|
|
132
|
+
type index_RpcMessage = RpcMessage;
|
|
133
|
+
type index_RpcMethod = RpcMethod;
|
|
134
|
+
type index_RpcRejectMessage = RpcRejectMessage;
|
|
135
|
+
type index_RpcRemoteMethod<T extends RpcMethod> = RpcRemoteMethod<T>;
|
|
136
|
+
type index_RpcResolveMessage = RpcResolveMessage;
|
|
137
|
+
type index_RpcWorker<T extends RpcMethod = RpcMethod> = RpcWorker<T>;
|
|
138
|
+
declare const index_createRpcWorker: typeof createRpcWorker;
|
|
139
|
+
declare const index_exposeRpc: typeof exposeRpc;
|
|
140
|
+
declare const index_getRpcWorkerData: typeof getRpcWorkerData;
|
|
141
|
+
declare const index_wrapRpc: typeof wrapRpc;
|
|
142
|
+
declare namespace index {
|
|
143
|
+
export {
|
|
144
|
+
index_RpcCallMessage as RpcCallMessage,
|
|
145
|
+
index_RpcExitError as RpcExitError,
|
|
146
|
+
index_RpcGMCallTypes as RpcGMCallTypes,
|
|
147
|
+
index_RpcMessage as RpcMessage,
|
|
148
|
+
index_RpcMethod as RpcMethod,
|
|
149
|
+
index_RpcRejectMessage as RpcRejectMessage,
|
|
150
|
+
index_RpcRemoteMethod as RpcRemoteMethod,
|
|
151
|
+
index_RpcResolveMessage as RpcResolveMessage,
|
|
152
|
+
index_RpcWorker as RpcWorker,
|
|
153
|
+
index_createRpcWorker as createRpcWorker,
|
|
154
|
+
index_exposeRpc as exposeRpc,
|
|
155
|
+
index_getRpcWorkerData as getRpcWorkerData,
|
|
156
|
+
index_wrapRpc as wrapRpc,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export { DTSManager, DTSManagerOptions, HOST_API_TYPES_FILE_NAME, HostOptions, REMOTE_ALIAS_IDENTIFIER, REMOTE_API_TYPES_FILE_NAME, RemoteOptions, UpdateMode, consumeTypes, generateTypes, generateTypesInChildProcess, getDTSManagerConstructor, retrieveHostConfig, retrieveMfTypesPath, retrieveOriginalOutDir, retrieveRemoteConfig, retrieveTypesAssetsInfo, retrieveTypesZipPath, index as rpc, validateOptions };
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import typescript from 'typescript';
|
|
2
|
+
import { R as RemoteOptions, H as HostOptions, a as RemoteInfo } from './HostOptions-cf22e0ab.js';
|
|
3
|
+
import { D as DTSManagerOptions } from './DTSManagerOptions-3369791f.js';
|
|
4
|
+
import { ChildProcess } from 'child_process';
|
|
5
|
+
import '@module-federation/sdk';
|
|
6
|
+
|
|
7
|
+
declare const retrieveRemoteConfig: (options: RemoteOptions) => {
|
|
8
|
+
tsConfig: typescript.CompilerOptions;
|
|
9
|
+
mapComponentsToExpose: Record<string, string>;
|
|
10
|
+
remoteOptions: Required<RemoteOptions>;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
declare const retrieveHostConfig: (options: HostOptions) => {
|
|
14
|
+
hostOptions: Required<HostOptions>;
|
|
15
|
+
mapRemotesToDownload: Record<string, RemoteInfo>;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
declare const REMOTE_ALIAS_IDENTIFIER = "REMOTE_ALIAS_IDENTIFIER";
|
|
19
|
+
declare const REMOTE_API_TYPES_FILE_NAME = "apis.d.ts";
|
|
20
|
+
declare const HOST_API_TYPES_FILE_NAME = "index.d.ts";
|
|
21
|
+
declare const enum UpdateMode {
|
|
22
|
+
POSITIVE = "POSITIVE",
|
|
23
|
+
PASSIVE = "PASSIVE"
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
interface UpdateTypesOptions {
|
|
27
|
+
updateMode: UpdateMode;
|
|
28
|
+
remoteName?: string;
|
|
29
|
+
remoteTarPath?: string;
|
|
30
|
+
}
|
|
31
|
+
declare class DTSManager {
|
|
32
|
+
options: DTSManagerOptions;
|
|
33
|
+
runtimePkgs: string[];
|
|
34
|
+
remoteAliasMap: Record<string, Required<RemoteInfo>>;
|
|
35
|
+
loadedRemoteAPIAlias: string[];
|
|
36
|
+
extraOptions: Record<string, any>;
|
|
37
|
+
constructor(options: DTSManagerOptions);
|
|
38
|
+
generateAPITypes(mapComponentsToExpose: Record<string, string>): string;
|
|
39
|
+
extractRemoteTypes(options: ReturnType<typeof retrieveRemoteConfig>): Promise<void>;
|
|
40
|
+
generateTypes(): Promise<void>;
|
|
41
|
+
requestRemoteManifest(remoteInfo: RemoteInfo): Promise<Required<RemoteInfo>>;
|
|
42
|
+
consumeTargetRemotes(hostOptions: Required<HostOptions>, remoteInfo: Required<RemoteInfo>): Promise<[string, string] | undefined>;
|
|
43
|
+
downloadAPITypes(remoteInfo: Required<RemoteInfo>, destinationPath: string): Promise<void>;
|
|
44
|
+
consumeAPITypes(hostOptions: Required<HostOptions>): void;
|
|
45
|
+
consumeArchiveTypes(options: HostOptions): Promise<{
|
|
46
|
+
hostOptions: Required<HostOptions>;
|
|
47
|
+
downloadPromisesResult: PromiseSettledResult<[string, string] | undefined>[];
|
|
48
|
+
}>;
|
|
49
|
+
consumeTypes(): Promise<void>;
|
|
50
|
+
updateTypes(options: UpdateTypesOptions): Promise<void>;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
declare function getDTSManagerConstructor(implementation?: string): typeof DTSManager;
|
|
54
|
+
declare const validateOptions: (options: HostOptions) => void;
|
|
55
|
+
declare function retrieveTypesAssetsInfo(options: RemoteOptions): {
|
|
56
|
+
apiTypesPath: string;
|
|
57
|
+
zipTypesPath: string;
|
|
58
|
+
zipName: string;
|
|
59
|
+
apiFileName: string;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
declare const retrieveMfTypesPath: (tsConfig: typescript.CompilerOptions, remoteOptions: Required<RemoteOptions>) => string;
|
|
63
|
+
declare const retrieveOriginalOutDir: (tsConfig: typescript.CompilerOptions, remoteOptions: Required<RemoteOptions>) => string;
|
|
64
|
+
|
|
65
|
+
declare const retrieveTypesZipPath: (mfTypesPath: string, remoteOptions: Required<RemoteOptions>) => string;
|
|
66
|
+
|
|
67
|
+
declare function generateTypes(options: DTSManagerOptions): Promise<void>;
|
|
68
|
+
|
|
69
|
+
declare function generateTypesInChildProcess(options: DTSManagerOptions): Promise<void>;
|
|
70
|
+
|
|
71
|
+
declare function consumeTypes(options: DTSManagerOptions): Promise<void>;
|
|
72
|
+
|
|
73
|
+
declare function exposeRpc(fn: (...args: any[]) => any): void;
|
|
74
|
+
|
|
75
|
+
declare enum RpcGMCallTypes {
|
|
76
|
+
CALL = "mf_call",
|
|
77
|
+
RESOLVE = "mf_resolve",
|
|
78
|
+
REJECT = "mf_reject",
|
|
79
|
+
EXIT = "mf_exit"
|
|
80
|
+
}
|
|
81
|
+
interface RpcCallMessage {
|
|
82
|
+
type: RpcGMCallTypes.CALL;
|
|
83
|
+
id: string;
|
|
84
|
+
args: unknown[];
|
|
85
|
+
}
|
|
86
|
+
interface RpcResolveMessage {
|
|
87
|
+
type: RpcGMCallTypes.RESOLVE;
|
|
88
|
+
id: string;
|
|
89
|
+
value: unknown;
|
|
90
|
+
}
|
|
91
|
+
interface RpcRejectMessage {
|
|
92
|
+
type: RpcGMCallTypes.REJECT;
|
|
93
|
+
id: string;
|
|
94
|
+
error: unknown;
|
|
95
|
+
}
|
|
96
|
+
interface RpcExitMessage {
|
|
97
|
+
type: RpcGMCallTypes.EXIT;
|
|
98
|
+
id: string;
|
|
99
|
+
}
|
|
100
|
+
type RpcMessage = RpcCallMessage | RpcResolveMessage | RpcRejectMessage | RpcExitMessage;
|
|
101
|
+
type RpcMethod = (...args: any[]) => any;
|
|
102
|
+
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>;
|
|
103
|
+
|
|
104
|
+
interface WrapRpcOptions {
|
|
105
|
+
id: string;
|
|
106
|
+
once?: boolean;
|
|
107
|
+
}
|
|
108
|
+
declare function wrapRpc<T extends (...args: any[]) => any>(childProcess: ChildProcess, options: WrapRpcOptions): RpcRemoteMethod<T>;
|
|
109
|
+
|
|
110
|
+
interface RpcWorkerBase {
|
|
111
|
+
connect(...args: unknown[]): any;
|
|
112
|
+
terminate(): void;
|
|
113
|
+
readonly connected: boolean;
|
|
114
|
+
readonly id: string;
|
|
115
|
+
readonly process: ChildProcess | undefined;
|
|
116
|
+
}
|
|
117
|
+
type RpcWorker<T extends RpcMethod = RpcMethod> = RpcWorkerBase & RpcRemoteMethod<T>;
|
|
118
|
+
declare function createRpcWorker<T extends RpcMethod>(modulePath: string, data: unknown, memoryLimit?: number, once?: boolean): RpcWorker<T>;
|
|
119
|
+
declare function getRpcWorkerData(): unknown;
|
|
120
|
+
|
|
121
|
+
declare class RpcExitError extends Error {
|
|
122
|
+
readonly code?: string | number | null | undefined;
|
|
123
|
+
readonly signal?: string | null | undefined;
|
|
124
|
+
constructor(message: string, code?: string | number | null | undefined, signal?: string | null | undefined);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
type index_RpcCallMessage = RpcCallMessage;
|
|
128
|
+
type index_RpcExitError = RpcExitError;
|
|
129
|
+
declare const index_RpcExitError: typeof RpcExitError;
|
|
130
|
+
type index_RpcGMCallTypes = RpcGMCallTypes;
|
|
131
|
+
declare const index_RpcGMCallTypes: typeof RpcGMCallTypes;
|
|
132
|
+
type index_RpcMessage = RpcMessage;
|
|
133
|
+
type index_RpcMethod = RpcMethod;
|
|
134
|
+
type index_RpcRejectMessage = RpcRejectMessage;
|
|
135
|
+
type index_RpcRemoteMethod<T extends RpcMethod> = RpcRemoteMethod<T>;
|
|
136
|
+
type index_RpcResolveMessage = RpcResolveMessage;
|
|
137
|
+
type index_RpcWorker<T extends RpcMethod = RpcMethod> = RpcWorker<T>;
|
|
138
|
+
declare const index_createRpcWorker: typeof createRpcWorker;
|
|
139
|
+
declare const index_exposeRpc: typeof exposeRpc;
|
|
140
|
+
declare const index_getRpcWorkerData: typeof getRpcWorkerData;
|
|
141
|
+
declare const index_wrapRpc: typeof wrapRpc;
|
|
142
|
+
declare namespace index {
|
|
143
|
+
export {
|
|
144
|
+
index_RpcCallMessage as RpcCallMessage,
|
|
145
|
+
index_RpcExitError as RpcExitError,
|
|
146
|
+
index_RpcGMCallTypes as RpcGMCallTypes,
|
|
147
|
+
index_RpcMessage as RpcMessage,
|
|
148
|
+
index_RpcMethod as RpcMethod,
|
|
149
|
+
index_RpcRejectMessage as RpcRejectMessage,
|
|
150
|
+
index_RpcRemoteMethod as RpcRemoteMethod,
|
|
151
|
+
index_RpcResolveMessage as RpcResolveMessage,
|
|
152
|
+
index_RpcWorker as RpcWorker,
|
|
153
|
+
index_createRpcWorker as createRpcWorker,
|
|
154
|
+
index_exposeRpc as exposeRpc,
|
|
155
|
+
index_getRpcWorkerData as getRpcWorkerData,
|
|
156
|
+
index_wrapRpc as wrapRpc,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export { DTSManager, DTSManagerOptions, HOST_API_TYPES_FILE_NAME, HostOptions, REMOTE_ALIAS_IDENTIFIER, REMOTE_API_TYPES_FILE_NAME, RemoteOptions, UpdateMode, consumeTypes, generateTypes, generateTypesInChildProcess, getDTSManagerConstructor, retrieveHostConfig, retrieveMfTypesPath, retrieveOriginalOutDir, retrieveRemoteConfig, retrieveTypesAssetsInfo, retrieveTypesZipPath, index as rpc, validateOptions };
|
package/dist/helpers.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
var _chunkVHQW5BQSjs = require('./chunk-VHQW5BQS.js');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
var _chunk2NC7LVYZjs = require('./chunk-2NC7LVYZ.js');
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
exports.DTSManager = _chunk2NC7LVYZjs.DTSManager; exports.HOST_API_TYPES_FILE_NAME = _chunk2NC7LVYZjs.HOST_API_TYPES_FILE_NAME; exports.REMOTE_ALIAS_IDENTIFIER = _chunk2NC7LVYZjs.REMOTE_ALIAS_IDENTIFIER; exports.REMOTE_API_TYPES_FILE_NAME = _chunk2NC7LVYZjs.REMOTE_API_TYPES_FILE_NAME; exports.UpdateMode = _chunk2NC7LVYZjs.UpdateMode; exports.consumeTypes = _chunkVHQW5BQSjs.consumeTypes; exports.generateTypes = _chunk2NC7LVYZjs.generateTypes; exports.generateTypesInChildProcess = _chunkVHQW5BQSjs.generateTypesInChildProcess; exports.getDTSManagerConstructor = _chunk2NC7LVYZjs.getDTSManagerConstructor; exports.retrieveHostConfig = _chunk2NC7LVYZjs.retrieveHostConfig; exports.retrieveMfTypesPath = _chunk2NC7LVYZjs.retrieveMfTypesPath; exports.retrieveOriginalOutDir = _chunk2NC7LVYZjs.retrieveOriginalOutDir; exports.retrieveRemoteConfig = _chunk2NC7LVYZjs.retrieveRemoteConfig; exports.retrieveTypesAssetsInfo = _chunk2NC7LVYZjs.retrieveTypesAssetsInfo; exports.retrieveTypesZipPath = _chunk2NC7LVYZjs.retrieveTypesZipPath; exports.rpc = _chunkVHQW5BQSjs.rpc_exports; exports.validateOptions = _chunk2NC7LVYZjs.validateOptions;
|
package/dist/helpers.mjs
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {
|
|
2
|
+
consumeTypes,
|
|
3
|
+
generateTypesInChildProcess,
|
|
4
|
+
rpc_exports
|
|
5
|
+
} from "./chunk-QYHGZU7D.mjs";
|
|
6
|
+
import {
|
|
7
|
+
DTSManager,
|
|
8
|
+
HOST_API_TYPES_FILE_NAME,
|
|
9
|
+
REMOTE_ALIAS_IDENTIFIER,
|
|
10
|
+
REMOTE_API_TYPES_FILE_NAME,
|
|
11
|
+
UpdateMode,
|
|
12
|
+
generateTypes,
|
|
13
|
+
getDTSManagerConstructor,
|
|
14
|
+
retrieveHostConfig,
|
|
15
|
+
retrieveMfTypesPath,
|
|
16
|
+
retrieveOriginalOutDir,
|
|
17
|
+
retrieveRemoteConfig,
|
|
18
|
+
retrieveTypesAssetsInfo,
|
|
19
|
+
retrieveTypesZipPath,
|
|
20
|
+
validateOptions
|
|
21
|
+
} from "./chunk-CF5CH54A.mjs";
|
|
22
|
+
export {
|
|
23
|
+
DTSManager,
|
|
24
|
+
HOST_API_TYPES_FILE_NAME,
|
|
25
|
+
REMOTE_ALIAS_IDENTIFIER,
|
|
26
|
+
REMOTE_API_TYPES_FILE_NAME,
|
|
27
|
+
UpdateMode,
|
|
28
|
+
consumeTypes,
|
|
29
|
+
generateTypes,
|
|
30
|
+
generateTypesInChildProcess,
|
|
31
|
+
getDTSManagerConstructor,
|
|
32
|
+
retrieveHostConfig,
|
|
33
|
+
retrieveMfTypesPath,
|
|
34
|
+
retrieveOriginalOutDir,
|
|
35
|
+
retrieveRemoteConfig,
|
|
36
|
+
retrieveTypesAssetsInfo,
|
|
37
|
+
retrieveTypesZipPath,
|
|
38
|
+
rpc_exports as rpc,
|
|
39
|
+
validateOptions
|
|
40
|
+
};
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as unplugin from 'unplugin';
|
|
2
|
+
import { R as RemoteOptions, H as HostOptions } from './HostOptions-cf22e0ab.js';
|
|
3
|
+
import '@module-federation/sdk';
|
|
4
|
+
|
|
5
|
+
type EnhancedRemoteOptions = {
|
|
6
|
+
remote: RemoteOptions;
|
|
7
|
+
extraOptions: Record<string, any>;
|
|
8
|
+
} | RemoteOptions;
|
|
9
|
+
type EnhancedHostOptions = {
|
|
10
|
+
host: HostOptions;
|
|
11
|
+
extraOptions: Record<string, any>;
|
|
12
|
+
} | HostOptions;
|
|
13
|
+
declare const NativeFederationTypeScriptRemote: unplugin.UnpluginInstance<EnhancedRemoteOptions, boolean>;
|
|
14
|
+
declare const NativeFederationTypeScriptHost: unplugin.UnpluginInstance<EnhancedHostOptions, boolean>;
|
|
15
|
+
|
|
16
|
+
export { EnhancedHostOptions, EnhancedRemoteOptions, NativeFederationTypeScriptHost, NativeFederationTypeScriptRemote };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import * as unplugin from 'unplugin';
|
|
2
|
-
import { R as RemoteOptions, H as HostOptions } from './
|
|
2
|
+
import { R as RemoteOptions, H as HostOptions } from './HostOptions-cf22e0ab.js';
|
|
3
|
+
import '@module-federation/sdk';
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
type EnhancedRemoteOptions = {
|
|
6
|
+
remote: RemoteOptions;
|
|
7
|
+
extraOptions: Record<string, any>;
|
|
8
|
+
} | RemoteOptions;
|
|
9
|
+
type EnhancedHostOptions = {
|
|
10
|
+
host: HostOptions;
|
|
11
|
+
extraOptions: Record<string, any>;
|
|
12
|
+
} | HostOptions;
|
|
13
|
+
declare const NativeFederationTypeScriptRemote: unplugin.UnpluginInstance<EnhancedRemoteOptions, boolean>;
|
|
14
|
+
declare const NativeFederationTypeScriptHost: unplugin.UnpluginInstance<EnhancedHostOptions, boolean>;
|
|
6
15
|
|
|
7
|
-
export { NativeFederationTypeScriptHost, NativeFederationTypeScriptRemote };
|
|
16
|
+
export { EnhancedHostOptions, EnhancedRemoteOptions, NativeFederationTypeScriptHost, NativeFederationTypeScriptRemote };
|