@module-federation/dts-plugin 0.1.2 → 0.1.4

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 CHANGED
@@ -1,5 +1,23 @@
1
1
  # @module-federation/dts-plugin
2
2
 
3
+ ## 0.1.4
4
+
5
+ ### Patch Changes
6
+
7
+ - 8f3a440: fix: detect whether the project is ts
8
+ - Updated dependencies [8f3a440]
9
+ - Updated dependencies [2f697b9]
10
+ - @module-federation/sdk@0.1.4
11
+ - @module-federation/managers@0.1.4
12
+
13
+ ## 0.1.3
14
+
15
+ ### Patch Changes
16
+
17
+ - f926b6c: chore: split types plugins implementation
18
+ - @module-federation/sdk@0.1.3
19
+ - @module-federation/managers@0.1.3
20
+
3
21
  ## 0.1.2
4
22
 
5
23
  ### Patch Changes
@@ -0,0 +1,29 @@
1
+ import { moduleFederationPlugin } from '@module-federation/sdk';
2
+
3
+ interface RemoteOptions extends moduleFederationPlugin.DtsRemoteOptions {
4
+ moduleFederationConfig: moduleFederationPlugin.ModuleFederationPluginOptions;
5
+ context?: string;
6
+ implementation?: string;
7
+ hostRemoteTypesFolder?: string;
8
+ }
9
+
10
+ interface HostOptions extends moduleFederationPlugin.DtsHostOptions {
11
+ moduleFederationConfig: moduleFederationPlugin.ModuleFederationPluginOptions;
12
+ context?: string;
13
+ implementation?: string;
14
+ }
15
+ interface RemoteInfo {
16
+ name: string;
17
+ url: string;
18
+ alias: string;
19
+ zipUrl?: string;
20
+ apiTypeUrl?: string;
21
+ }
22
+
23
+ interface DTSManagerOptions {
24
+ remote?: RemoteOptions;
25
+ host?: HostOptions;
26
+ extraOptions?: Record<string, any>;
27
+ }
28
+
29
+ export { DTSManagerOptions as D, HostOptions as H, RemoteInfo as R, RemoteOptions as a };
@@ -0,0 +1,97 @@
1
+ import { ChildProcess } from 'child_process';
2
+ import { a as RemoteOptions, D as DTSManagerOptions, R as RemoteInfo, H as HostOptions } from './DTSManagerOptions-c0728719.js';
3
+ import typescript from 'typescript';
4
+
5
+ declare const retrieveRemoteConfig: (options: RemoteOptions) => {
6
+ tsConfig: typescript.CompilerOptions;
7
+ mapComponentsToExpose: Record<string, string>;
8
+ remoteOptions: Required<RemoteOptions>;
9
+ };
10
+
11
+ declare const REMOTE_ALIAS_IDENTIFIER = "REMOTE_ALIAS_IDENTIFIER";
12
+ declare const REMOTE_API_TYPES_FILE_NAME = "apis.d.ts";
13
+ declare const HOST_API_TYPES_FILE_NAME = "index.d.ts";
14
+ declare const enum UpdateMode {
15
+ POSITIVE = "POSITIVE",
16
+ PASSIVE = "PASSIVE"
17
+ }
18
+
19
+ interface UpdateTypesOptions {
20
+ updateMode: UpdateMode;
21
+ remoteName?: string;
22
+ remoteTarPath?: string;
23
+ }
24
+ declare class DTSManager {
25
+ options: DTSManagerOptions;
26
+ runtimePkgs: string[];
27
+ remoteAliasMap: Record<string, Required<RemoteInfo>>;
28
+ loadedRemoteAPIAlias: string[];
29
+ extraOptions: Record<string, any>;
30
+ constructor(options: DTSManagerOptions);
31
+ generateAPITypes(mapComponentsToExpose: Record<string, string>): string;
32
+ extractRemoteTypes(options: ReturnType<typeof retrieveRemoteConfig>): Promise<void>;
33
+ generateTypes(): Promise<void>;
34
+ requestRemoteManifest(remoteInfo: RemoteInfo): Promise<Required<RemoteInfo>>;
35
+ consumeTargetRemotes(hostOptions: Required<HostOptions>, remoteInfo: Required<RemoteInfo>): Promise<[string, string] | undefined>;
36
+ downloadAPITypes(remoteInfo: Required<RemoteInfo>, destinationPath: string): Promise<void>;
37
+ consumeAPITypes(hostOptions: Required<HostOptions>): void;
38
+ consumeArchiveTypes(options: HostOptions): Promise<{
39
+ hostOptions: Required<HostOptions>;
40
+ downloadPromisesResult: PromiseSettledResult<[string, string] | undefined>[];
41
+ }>;
42
+ consumeTypes(): Promise<void>;
43
+ updateTypes(options: UpdateTypesOptions): Promise<void>;
44
+ }
45
+
46
+ declare enum RpcGMCallTypes {
47
+ CALL = "mf_call",
48
+ RESOLVE = "mf_resolve",
49
+ REJECT = "mf_reject",
50
+ EXIT = "mf_exit"
51
+ }
52
+ interface RpcCallMessage {
53
+ type: RpcGMCallTypes.CALL;
54
+ id: string;
55
+ args: unknown[];
56
+ }
57
+ interface RpcResolveMessage {
58
+ type: RpcGMCallTypes.RESOLVE;
59
+ id: string;
60
+ value: unknown;
61
+ }
62
+ interface RpcRejectMessage {
63
+ type: RpcGMCallTypes.REJECT;
64
+ id: string;
65
+ error: unknown;
66
+ }
67
+ interface RpcExitMessage {
68
+ type: RpcGMCallTypes.EXIT;
69
+ id: string;
70
+ }
71
+ type RpcMessage = RpcCallMessage | RpcResolveMessage | RpcRejectMessage | RpcExitMessage;
72
+ type RpcMethod = (...args: any[]) => any;
73
+ 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>;
74
+
75
+ interface RpcWorkerBase {
76
+ connect(...args: unknown[]): any;
77
+ terminate(): void;
78
+ readonly connected: boolean;
79
+ readonly id: string;
80
+ readonly process: ChildProcess | undefined;
81
+ }
82
+ type RpcWorker<T extends RpcMethod = RpcMethod> = RpcWorkerBase & RpcRemoteMethod<T>;
83
+ declare function createRpcWorker<T extends RpcMethod>(modulePath: string, data: unknown, memoryLimit?: number, once?: boolean): RpcWorker<T>;
84
+ declare function getRpcWorkerData(): unknown;
85
+
86
+ type DtsWorkerOptions = DTSManagerOptions;
87
+ declare class DtsWorker {
88
+ rpcWorker: RpcWorker<RpcMethod>;
89
+ private _options;
90
+ private _res;
91
+ constructor(options: DtsWorkerOptions);
92
+ removeUnSerializationOptions(): void;
93
+ get controlledPromise(): ReturnType<DTSManager['generateTypes']>;
94
+ exit(): void;
95
+ }
96
+
97
+ export { DTSManager as D, HOST_API_TYPES_FILE_NAME as H, RpcRemoteMethod as R, UpdateMode as U, RpcCallMessage as a, RpcGMCallTypes as b, RpcMessage as c, RpcMethod as d, RpcRejectMessage as e, RpcResolveMessage as f, RpcWorker as g, createRpcWorker as h, getRpcWorkerData as i, DtsWorker as j, REMOTE_ALIAS_IDENTIFIER as k, REMOTE_API_TYPES_FILE_NAME as l, DtsWorkerOptions as m, retrieveRemoteConfig as r };
package/dist/core.d.ts ADDED
@@ -0,0 +1,84 @@
1
+ import { D as DTSManager, R as RpcRemoteMethod, a as RpcCallMessage, b as RpcGMCallTypes, c as RpcMessage, d as RpcMethod, e as RpcRejectMessage, f as RpcResolveMessage, g as RpcWorker, h as createRpcWorker, i as getRpcWorkerData } from './DtsWorker-d731dc2b.js';
2
+ export { j as DtsWorker, H as HOST_API_TYPES_FILE_NAME, k as REMOTE_ALIAS_IDENTIFIER, l as REMOTE_API_TYPES_FILE_NAME, U as UpdateMode, r as retrieveRemoteConfig } from './DtsWorker-d731dc2b.js';
3
+ import { H as HostOptions, R as RemoteInfo, a as RemoteOptions, D as DTSManagerOptions } from './DTSManagerOptions-c0728719.js';
4
+ import typescript from 'typescript';
5
+ import { ChildProcess } from 'child_process';
6
+ import '@module-federation/sdk';
7
+
8
+ declare const retrieveHostConfig: (options: HostOptions) => {
9
+ hostOptions: Required<HostOptions>;
10
+ mapRemotesToDownload: Record<string, RemoteInfo>;
11
+ };
12
+
13
+ declare function getDTSManagerConstructor(implementation?: string): typeof DTSManager;
14
+ declare const validateOptions: (options: HostOptions) => void;
15
+ declare function retrieveTypesAssetsInfo(options: RemoteOptions): {
16
+ apiTypesPath: string;
17
+ zipTypesPath: string;
18
+ zipName: string;
19
+ apiFileName: string;
20
+ };
21
+
22
+ declare const retrieveMfTypesPath: (tsConfig: typescript.CompilerOptions, remoteOptions: Required<RemoteOptions>) => string;
23
+ declare const retrieveOriginalOutDir: (tsConfig: typescript.CompilerOptions, remoteOptions: Required<RemoteOptions>) => string;
24
+
25
+ declare const retrieveTypesZipPath: (mfTypesPath: string, remoteOptions: Required<RemoteOptions>) => string;
26
+
27
+ declare function generateTypes(options: DTSManagerOptions): Promise<void>;
28
+
29
+ declare function generateTypesInChildProcess(options: DTSManagerOptions): Promise<void>;
30
+
31
+ declare function exposeRpc(fn: (...args: any[]) => any): void;
32
+
33
+ interface WrapRpcOptions {
34
+ id: string;
35
+ once?: boolean;
36
+ }
37
+ declare function wrapRpc<T extends (...args: any[]) => any>(childProcess: ChildProcess, options: WrapRpcOptions): RpcRemoteMethod<T>;
38
+
39
+ declare class RpcExitError extends Error {
40
+ readonly code?: string | number | null | undefined;
41
+ readonly signal?: string | null | undefined;
42
+ constructor(message: string, code?: string | number | null | undefined, signal?: string | null | undefined);
43
+ }
44
+
45
+ /**
46
+ * forked from https://github.com/TypeStrong/fork-ts-checker-webpack-plugin
47
+ * license at https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/blob/main/LICENSE
48
+ */
49
+
50
+ declare const index_RpcCallMessage: typeof RpcCallMessage;
51
+ type index_RpcExitError = RpcExitError;
52
+ declare const index_RpcExitError: typeof RpcExitError;
53
+ declare const index_RpcGMCallTypes: typeof RpcGMCallTypes;
54
+ declare const index_RpcMessage: typeof RpcMessage;
55
+ declare const index_RpcMethod: typeof RpcMethod;
56
+ declare const index_RpcRejectMessage: typeof RpcRejectMessage;
57
+ declare const index_RpcRemoteMethod: typeof RpcRemoteMethod;
58
+ declare const index_RpcResolveMessage: typeof RpcResolveMessage;
59
+ declare const index_RpcWorker: typeof RpcWorker;
60
+ declare const index_createRpcWorker: typeof createRpcWorker;
61
+ declare const index_exposeRpc: typeof exposeRpc;
62
+ declare const index_getRpcWorkerData: typeof getRpcWorkerData;
63
+ declare const index_wrapRpc: typeof wrapRpc;
64
+ declare namespace index {
65
+ export {
66
+ index_RpcCallMessage as RpcCallMessage,
67
+ index_RpcExitError as RpcExitError,
68
+ index_RpcGMCallTypes as RpcGMCallTypes,
69
+ index_RpcMessage as RpcMessage,
70
+ index_RpcMethod as RpcMethod,
71
+ index_RpcRejectMessage as RpcRejectMessage,
72
+ index_RpcRemoteMethod as RpcRemoteMethod,
73
+ index_RpcResolveMessage as RpcResolveMessage,
74
+ index_RpcWorker as RpcWorker,
75
+ index_createRpcWorker as createRpcWorker,
76
+ index_exposeRpc as exposeRpc,
77
+ index_getRpcWorkerData as getRpcWorkerData,
78
+ index_wrapRpc as wrapRpc,
79
+ };
80
+ }
81
+
82
+ declare function consumeTypes(options: DTSManagerOptions): Promise<void>;
83
+
84
+ export { DTSManager, DTSManagerOptions, HostOptions, RemoteOptions, consumeTypes, generateTypes, generateTypesInChildProcess, getDTSManagerConstructor, retrieveHostConfig, retrieveMfTypesPath, retrieveOriginalOutDir, retrieveTypesAssetsInfo, retrieveTypesZipPath, index as rpc, validateOptions };