@module-federation/dts-plugin 0.1.2 → 0.1.3

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/core.js ADDED
@@ -0,0 +1,1137 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // packages/dts-plugin/src/core/index.ts
31
+ var core_exports = {};
32
+ __export(core_exports, {
33
+ DTSManager: () => DTSManager,
34
+ DtsWorker: () => DtsWorker,
35
+ HOST_API_TYPES_FILE_NAME: () => HOST_API_TYPES_FILE_NAME,
36
+ REMOTE_ALIAS_IDENTIFIER: () => REMOTE_ALIAS_IDENTIFIER,
37
+ REMOTE_API_TYPES_FILE_NAME: () => REMOTE_API_TYPES_FILE_NAME,
38
+ UpdateMode: () => UpdateMode,
39
+ consumeTypes: () => consumeTypes,
40
+ generateTypes: () => generateTypes,
41
+ generateTypesInChildProcess: () => generateTypesInChildProcess,
42
+ getDTSManagerConstructor: () => getDTSManagerConstructor,
43
+ retrieveHostConfig: () => retrieveHostConfig,
44
+ retrieveMfTypesPath: () => retrieveMfTypesPath,
45
+ retrieveOriginalOutDir: () => retrieveOriginalOutDir,
46
+ retrieveRemoteConfig: () => retrieveRemoteConfig,
47
+ retrieveTypesAssetsInfo: () => retrieveTypesAssetsInfo,
48
+ retrieveTypesZipPath: () => retrieveTypesZipPath,
49
+ rpc: () => rpc_exports,
50
+ validateOptions: () => validateOptions
51
+ });
52
+ module.exports = __toCommonJS(core_exports);
53
+
54
+ // packages/dts-plugin/src/core/configurations/remotePlugin.ts
55
+ var import_fs2 = require("fs");
56
+ var import_path5 = require("path");
57
+ var import_managers2 = require("@module-federation/managers");
58
+ var import_typescript2 = __toESM(require("typescript"));
59
+
60
+ // packages/dts-plugin/src/core/lib/utils.ts
61
+ var import_path4 = __toESM(require("path"));
62
+
63
+ // packages/dts-plugin/src/core/lib/DTSManager.ts
64
+ var import_ansi_colors3 = __toESM(require("ansi-colors"));
65
+ var import_path3 = __toESM(require("path"));
66
+ var import_promises = require("fs/promises");
67
+ var import_fs = __toESM(require("fs"));
68
+ var import_sdk2 = require("@module-federation/sdk");
69
+ var import_lodash = __toESM(require("lodash.clonedeepwith"));
70
+
71
+ // packages/dts-plugin/src/core/lib/archiveHandler.ts
72
+ var import_adm_zip = __toESM(require("adm-zip"));
73
+ var import_ansi_colors2 = __toESM(require("ansi-colors"));
74
+ var import_axios = __toESM(require("axios"));
75
+ var import_path2 = require("path");
76
+
77
+ // packages/dts-plugin/src/core/lib/typeScriptCompiler.ts
78
+ var import_ansi_colors = __toESM(require("ansi-colors"));
79
+ var import_path = require("path");
80
+ var import_typescript = __toESM(require("typescript"));
81
+ var import_third_party_dts_extractor = require("@module-federation/third-party-dts-extractor");
82
+ var STARTS_WITH_SLASH = /^\//;
83
+ var DEFINITION_FILE_EXTENSION = ".d.ts";
84
+ var reportCompileDiagnostic = (diagnostic) => {
85
+ const { line } = diagnostic.file.getLineAndCharacterOfPosition(
86
+ diagnostic.start
87
+ );
88
+ console.error(
89
+ import_ansi_colors.default.red(
90
+ `TS Error ${diagnostic.code}':' ${import_typescript.default.flattenDiagnosticMessageText(
91
+ diagnostic.messageText,
92
+ import_typescript.default.sys.newLine
93
+ )}`
94
+ )
95
+ );
96
+ console.error(
97
+ import_ansi_colors.default.red(
98
+ ` at ${diagnostic.file.fileName}:${line + 1} typescript.sys.newLine`
99
+ )
100
+ );
101
+ };
102
+ var retrieveMfTypesPath = (tsConfig, remoteOptions) => (0, import_path.normalize)(tsConfig.outDir.replace(remoteOptions.compiledTypesFolder, ""));
103
+ var retrieveOriginalOutDir = (tsConfig, remoteOptions) => (0, import_path.normalize)(
104
+ tsConfig.outDir.replace(remoteOptions.compiledTypesFolder, "").replace(remoteOptions.typesFolder, "")
105
+ );
106
+ var retrieveMfAPITypesPath = (tsConfig, remoteOptions) => (0, import_path.join)(
107
+ retrieveOriginalOutDir(tsConfig, remoteOptions),
108
+ `${remoteOptions.typesFolder}.d.ts`
109
+ );
110
+ var createHost = (mapComponentsToExpose, tsConfig, remoteOptions, cb) => {
111
+ const host = import_typescript.default.createCompilerHost(tsConfig);
112
+ const originalWriteFile = host.writeFile;
113
+ const mapExposeToEntry = Object.fromEntries(
114
+ Object.entries(mapComponentsToExpose).map((entry) => entry.reverse())
115
+ );
116
+ const mfTypePath = retrieveMfTypesPath(tsConfig, remoteOptions);
117
+ host.writeFile = (filepath, text, writeOrderByteMark, onError, sourceFiles, data) => {
118
+ originalWriteFile(
119
+ filepath,
120
+ text,
121
+ writeOrderByteMark,
122
+ onError,
123
+ sourceFiles,
124
+ data
125
+ );
126
+ for (const sourceFile of sourceFiles || []) {
127
+ const sourceEntry = mapExposeToEntry[sourceFile.fileName];
128
+ if (sourceEntry) {
129
+ const mfeTypeEntry = (0, import_path.join)(
130
+ mfTypePath,
131
+ `${sourceEntry}${DEFINITION_FILE_EXTENSION}`
132
+ );
133
+ const mfeTypeEntryDirectory = (0, import_path.dirname)(mfeTypeEntry);
134
+ const relativePathToOutput = (0, import_path.relative)(mfeTypeEntryDirectory, filepath).replace(DEFINITION_FILE_EXTENSION, "").replace(STARTS_WITH_SLASH, "");
135
+ originalWriteFile(
136
+ mfeTypeEntry,
137
+ `export * from './${relativePathToOutput}';
138
+ export { default } from './${relativePathToOutput}';`,
139
+ writeOrderByteMark
140
+ );
141
+ }
142
+ }
143
+ cb(text);
144
+ };
145
+ return host;
146
+ };
147
+ var createVueTscProgram = (programOptions) => {
148
+ const vueTypescript = require("vue-tsc");
149
+ return vueTypescript.createProgram(programOptions);
150
+ };
151
+ var createProgram = (remoteOptions, programOptions) => {
152
+ switch (remoteOptions.compilerInstance) {
153
+ case "vue-tsc":
154
+ return createVueTscProgram(programOptions);
155
+ case "tsc":
156
+ default:
157
+ return import_typescript.default.createProgram(programOptions);
158
+ }
159
+ };
160
+ var compileTs = (mapComponentsToExpose, tsConfig, remoteOptions) => {
161
+ const mfTypePath = retrieveMfTypesPath(tsConfig, remoteOptions);
162
+ const thirdPartyExtractor = new import_third_party_dts_extractor.ThirdPartyExtractor(
163
+ (0, import_path.resolve)(mfTypePath, "node_modules"),
164
+ remoteOptions.context
165
+ );
166
+ const cb = remoteOptions.extractThirdParty ? thirdPartyExtractor.collectPkgs.bind(thirdPartyExtractor) : () => void 0;
167
+ const tsHost = createHost(mapComponentsToExpose, tsConfig, remoteOptions, cb);
168
+ const filesToCompile = [
169
+ ...Object.values(mapComponentsToExpose),
170
+ ...remoteOptions.additionalFilesToCompile
171
+ ];
172
+ const programOptions = {
173
+ rootNames: filesToCompile,
174
+ host: tsHost,
175
+ options: tsConfig
176
+ };
177
+ const tsProgram = createProgram(remoteOptions, programOptions);
178
+ const { diagnostics = [] } = tsProgram.emit();
179
+ diagnostics.forEach(reportCompileDiagnostic);
180
+ if (remoteOptions.extractThirdParty) {
181
+ thirdPartyExtractor.copyDts();
182
+ }
183
+ };
184
+
185
+ // packages/dts-plugin/src/core/lib/archiveHandler.ts
186
+ var retrieveTypesZipPath = (mfTypesPath, remoteOptions) => (0, import_path2.join)(
187
+ mfTypesPath.replace(remoteOptions.typesFolder, ""),
188
+ `${remoteOptions.typesFolder}.zip`
189
+ );
190
+ var createTypesArchive = async (tsConfig, remoteOptions) => {
191
+ const mfTypesPath = retrieveMfTypesPath(tsConfig, remoteOptions);
192
+ const zip = new import_adm_zip.default();
193
+ zip.addLocalFolder(mfTypesPath);
194
+ return zip.writeZipPromise(retrieveTypesZipPath(mfTypesPath, remoteOptions));
195
+ };
196
+ var downloadErrorLogger = (destinationFolder, fileToDownload) => (reason) => {
197
+ throw {
198
+ ...reason,
199
+ message: `Network error: Unable to download federated mocks for '${destinationFolder}' from '${fileToDownload}' because '${reason.message}'`
200
+ };
201
+ };
202
+ var retrieveTypesArchiveDestinationPath = (hostOptions, destinationFolder) => {
203
+ return (0, import_path2.resolve)(
204
+ hostOptions.context,
205
+ hostOptions.typesFolder,
206
+ destinationFolder
207
+ );
208
+ };
209
+ var downloadTypesArchive = (hostOptions) => {
210
+ let retries = 0;
211
+ return async ([destinationFolder, fileToDownload]) => {
212
+ const destinationPath = retrieveTypesArchiveDestinationPath(
213
+ hostOptions,
214
+ destinationFolder
215
+ );
216
+ while (retries++ < hostOptions.maxRetries) {
217
+ try {
218
+ const url = replaceLocalhost(fileToDownload);
219
+ const response = await import_axios.default.get(url, { responseType: "arraybuffer" }).catch(downloadErrorLogger(destinationFolder, url));
220
+ const zip = new import_adm_zip.default(Buffer.from(response.data));
221
+ zip.extractAllTo(destinationPath, true);
222
+ return [destinationFolder, destinationPath];
223
+ } catch (error) {
224
+ if (isDebugMode()) {
225
+ console.error(
226
+ import_ansi_colors2.default.red(
227
+ `Error during types archive download: ${(error == null ? void 0 : error.message) || "unknown error"}`
228
+ )
229
+ );
230
+ }
231
+ if (retries >= hostOptions.maxRetries) {
232
+ if (hostOptions.abortOnError !== false) {
233
+ throw error;
234
+ }
235
+ return void 0;
236
+ }
237
+ }
238
+ }
239
+ };
240
+ };
241
+
242
+ // packages/dts-plugin/src/core/configurations/hostPlugin.ts
243
+ var import_sdk = require("@module-federation/sdk");
244
+ var import_managers = require("@module-federation/managers");
245
+ var defaultOptions = {
246
+ typesFolder: "@mf-types",
247
+ remoteTypesFolder: "@mf-types",
248
+ deleteTypesFolder: true,
249
+ maxRetries: 3,
250
+ implementation: "",
251
+ context: process.cwd(),
252
+ abortOnError: true,
253
+ consumeAPITypes: false
254
+ };
255
+ var buildZipUrl = (hostOptions, url) => {
256
+ const remoteUrl = new URL(url);
257
+ if (remoteUrl.href.includes(import_sdk.MANIFEST_EXT)) {
258
+ return void 0;
259
+ }
260
+ const pathnameWithoutEntry = remoteUrl.pathname.split("/").slice(0, -1).join("/");
261
+ remoteUrl.pathname = `${pathnameWithoutEntry}/${hostOptions.remoteTypesFolder}.zip`;
262
+ return remoteUrl.href;
263
+ };
264
+ var buildApiTypeUrl = (zipUrl) => {
265
+ if (!zipUrl) {
266
+ return void 0;
267
+ }
268
+ return zipUrl.replace(".zip", ".d.ts");
269
+ };
270
+ var retrieveRemoteInfo = (options) => {
271
+ const { hostOptions, remoteAlias, remote } = options;
272
+ const parsedInfo = (0, import_sdk.parseEntry)(remote, void 0, "@");
273
+ const url = "entry" in parsedInfo ? parsedInfo.entry : parsedInfo.name === remote ? remote : "";
274
+ const zipUrl = url ? buildZipUrl(hostOptions, url) : "";
275
+ return {
276
+ name: parsedInfo.name || remoteAlias,
277
+ url,
278
+ zipUrl,
279
+ apiTypeUrl: buildApiTypeUrl(zipUrl),
280
+ alias: remoteAlias
281
+ };
282
+ };
283
+ var resolveRemotes = (hostOptions) => {
284
+ const parsedOptions = import_managers.utils.parseOptions(
285
+ hostOptions.moduleFederationConfig.remotes || {},
286
+ (item, key) => ({
287
+ remote: Array.isArray(item) ? item[0] : item,
288
+ key
289
+ }),
290
+ (item, key) => ({
291
+ remote: Array.isArray(item.external) ? item.external[0] : item.external,
292
+ key
293
+ })
294
+ );
295
+ return parsedOptions.reduce(
296
+ (accumulator, item) => {
297
+ const { key, remote } = item[1];
298
+ accumulator[key] = retrieveRemoteInfo({
299
+ hostOptions,
300
+ remoteAlias: key,
301
+ remote
302
+ });
303
+ return accumulator;
304
+ },
305
+ {}
306
+ );
307
+ };
308
+ var retrieveHostConfig = (options) => {
309
+ validateOptions(options);
310
+ const hostOptions = { ...defaultOptions, ...options };
311
+ const mapRemotesToDownload = resolveRemotes(hostOptions);
312
+ return {
313
+ hostOptions,
314
+ mapRemotesToDownload
315
+ };
316
+ };
317
+
318
+ // packages/dts-plugin/src/core/constant.ts
319
+ var REMOTE_ALIAS_IDENTIFIER = "REMOTE_ALIAS_IDENTIFIER";
320
+ var REMOTE_API_TYPES_FILE_NAME = "apis.d.ts";
321
+ var HOST_API_TYPES_FILE_NAME = "index.d.ts";
322
+ var UpdateMode = /* @__PURE__ */ ((UpdateMode2) => {
323
+ UpdateMode2["POSITIVE"] = "POSITIVE";
324
+ UpdateMode2["PASSIVE"] = "PASSIVE";
325
+ return UpdateMode2;
326
+ })(UpdateMode || {});
327
+
328
+ // packages/dts-plugin/src/core/lib/DTSManager.ts
329
+ var import_axios2 = __toESM(require("axios"));
330
+ var DTSManager = class {
331
+ constructor(options) {
332
+ this.options = (0, import_lodash.default)(options, (_value, key) => {
333
+ if (key === "manifest") {
334
+ return false;
335
+ }
336
+ });
337
+ this.runtimePkgs = [
338
+ "@module-federation/runtime",
339
+ "@module-federation/runtime-tools"
340
+ ];
341
+ this.loadedRemoteAPIAlias = [];
342
+ this.remoteAliasMap = {};
343
+ this.extraOptions = (options == null ? void 0 : options.extraOptions) || {};
344
+ }
345
+ generateAPITypes(mapComponentsToExpose) {
346
+ const exposePaths = /* @__PURE__ */ new Set();
347
+ const packageType = Object.keys(mapComponentsToExpose).reduce(
348
+ (sum, exposeKey) => {
349
+ const exposePath = import_path3.default.join(REMOTE_ALIAS_IDENTIFIER, exposeKey);
350
+ exposePaths.add(`'${exposePath}'`);
351
+ const curType = `T extends '${exposePath}' ? typeof import('${exposePath}') :`;
352
+ sum = curType + sum;
353
+ return sum;
354
+ },
355
+ "any;"
356
+ );
357
+ const exposePathKeys = [...exposePaths].join(" | ");
358
+ return `
359
+ export type RemoteKeys = ${exposePathKeys};
360
+ type PackageType<T> = ${packageType}`;
361
+ }
362
+ async extractRemoteTypes(options) {
363
+ const { remoteOptions, tsConfig } = options;
364
+ if (!remoteOptions.extractRemoteTypes) {
365
+ return;
366
+ }
367
+ let hasRemotes = false;
368
+ const remotes = remoteOptions.moduleFederationConfig.remotes;
369
+ if (remotes) {
370
+ if (Array.isArray(remotes)) {
371
+ hasRemotes = Boolean(remotes.length);
372
+ } else if (typeof remotes === "object") {
373
+ hasRemotes = Boolean(Object.keys(remotes).length);
374
+ }
375
+ }
376
+ const mfTypesPath = retrieveMfTypesPath(tsConfig, remoteOptions);
377
+ if (hasRemotes) {
378
+ const tempHostOptions = {
379
+ moduleFederationConfig: remoteOptions.moduleFederationConfig,
380
+ typesFolder: import_path3.default.join(mfTypesPath, "node_modules"),
381
+ remoteTypesFolder: (remoteOptions == null ? void 0 : remoteOptions.hostRemoteTypesFolder) || remoteOptions.typesFolder,
382
+ deleteTypesFolder: true,
383
+ context: remoteOptions.context,
384
+ implementation: remoteOptions.implementation,
385
+ abortOnError: false
386
+ };
387
+ await this.consumeArchiveTypes(tempHostOptions);
388
+ }
389
+ }
390
+ async generateTypes() {
391
+ var _a;
392
+ try {
393
+ const { options } = this;
394
+ if (!options.remote) {
395
+ throw new Error(
396
+ "options.remote is required if you want to generateTypes"
397
+ );
398
+ }
399
+ const { remoteOptions, tsConfig, mapComponentsToExpose } = retrieveRemoteConfig(options.remote);
400
+ if (!Object.keys(mapComponentsToExpose).length) {
401
+ return;
402
+ }
403
+ this.extractRemoteTypes({
404
+ remoteOptions,
405
+ tsConfig,
406
+ mapComponentsToExpose
407
+ });
408
+ compileTs(mapComponentsToExpose, tsConfig, remoteOptions);
409
+ await createTypesArchive(tsConfig, remoteOptions);
410
+ let apiTypesPath = "";
411
+ if (remoteOptions.generateAPITypes) {
412
+ const apiTypes = this.generateAPITypes(mapComponentsToExpose);
413
+ apiTypesPath = retrieveMfAPITypesPath(tsConfig, remoteOptions);
414
+ import_fs.default.writeFileSync(apiTypesPath, apiTypes);
415
+ }
416
+ if (remoteOptions.deleteTypesFolder) {
417
+ await (0, import_promises.rm)(retrieveMfTypesPath(tsConfig, remoteOptions), {
418
+ recursive: true,
419
+ force: true
420
+ });
421
+ }
422
+ console.log(import_ansi_colors3.default.green("Federated types created correctly"));
423
+ } catch (error) {
424
+ if (((_a = this.options.remote) == null ? void 0 : _a.abortOnError) === false) {
425
+ console.error(
426
+ import_ansi_colors3.default.red(`Unable to compile federated types, ${error}`)
427
+ );
428
+ } else {
429
+ throw error;
430
+ }
431
+ }
432
+ }
433
+ async requestRemoteManifest(remoteInfo) {
434
+ try {
435
+ if (!remoteInfo.url.includes(import_sdk2.MANIFEST_EXT)) {
436
+ return remoteInfo;
437
+ }
438
+ const url = replaceLocalhost(remoteInfo.url);
439
+ const res = await (0, import_axios2.default)({
440
+ method: "get",
441
+ url
442
+ });
443
+ const manifestJson = res.data;
444
+ if (!manifestJson.metaData.types.zip) {
445
+ throw new Error(`Can not get ${remoteInfo.name}'s types archive url!`);
446
+ }
447
+ const addProtocol = (u) => {
448
+ if (u.startsWith("//")) {
449
+ return `https:${u}`;
450
+ }
451
+ return u;
452
+ };
453
+ const publicPath = "publicPath" in manifestJson.metaData ? manifestJson.metaData.publicPath : new Function(manifestJson.metaData.getPublicPath)();
454
+ remoteInfo.zipUrl = new URL(
455
+ import_path3.default.join(addProtocol(publicPath), manifestJson.metaData.types.zip)
456
+ ).href;
457
+ if (!manifestJson.metaData.types.api) {
458
+ console.warn(`Can not get ${remoteInfo.name}'s api types url!`);
459
+ remoteInfo.apiTypeUrl = "";
460
+ return remoteInfo;
461
+ }
462
+ remoteInfo.apiTypeUrl = new URL(
463
+ import_path3.default.join(addProtocol(publicPath), manifestJson.metaData.types.api)
464
+ ).href;
465
+ return remoteInfo;
466
+ } catch (_err) {
467
+ console.error(_err);
468
+ return remoteInfo;
469
+ }
470
+ }
471
+ async consumeTargetRemotes(hostOptions, remoteInfo) {
472
+ if (!remoteInfo.zipUrl) {
473
+ throw new Error(`Can not get ${remoteInfo.name}'s types archive url!`);
474
+ }
475
+ const typesDownloader = downloadTypesArchive(hostOptions);
476
+ return typesDownloader([remoteInfo.alias, remoteInfo.zipUrl]);
477
+ }
478
+ async downloadAPITypes(remoteInfo, destinationPath) {
479
+ const { apiTypeUrl } = remoteInfo;
480
+ if (!apiTypeUrl) {
481
+ return;
482
+ }
483
+ try {
484
+ const url = replaceLocalhost(apiTypeUrl);
485
+ const res = await import_axios2.default.get(url);
486
+ let apiTypeFile = res.data;
487
+ apiTypeFile = apiTypeFile.replaceAll(
488
+ REMOTE_ALIAS_IDENTIFIER,
489
+ remoteInfo.alias
490
+ );
491
+ const filePath = import_path3.default.join(destinationPath, REMOTE_API_TYPES_FILE_NAME);
492
+ import_fs.default.writeFileSync(filePath, apiTypeFile);
493
+ this.loadedRemoteAPIAlias.push(remoteInfo.alias);
494
+ } catch (err) {
495
+ console.error(
496
+ import_ansi_colors3.default.red(
497
+ `Unable to download "${remoteInfo.name}" api types, ${err}`
498
+ )
499
+ );
500
+ }
501
+ }
502
+ consumeAPITypes(hostOptions) {
503
+ if (!this.loadedRemoteAPIAlias.length) {
504
+ return;
505
+ }
506
+ const packageTypes = [];
507
+ const remoteKeys = [];
508
+ const importTypeStr = this.loadedRemoteAPIAlias.map((alias, index) => {
509
+ const remoteKey = `RemoteKeys_${index}`;
510
+ const packageType = `PackageType_${index}`;
511
+ packageTypes.push(`T extends ${remoteKey} ? ${packageType}<T>`);
512
+ remoteKeys.push(remoteKey);
513
+ return `import type { PackageType as ${packageType},RemoteKeys as ${remoteKey} } from './${alias}/apis.d.ts';`;
514
+ }).join("\n");
515
+ const remoteKeysStr = `type RemoteKeys = ${remoteKeys.join(" | ")};`;
516
+ const packageTypesStr = `type PackageType<T, Y=any> = ${[
517
+ ...packageTypes,
518
+ "Y"
519
+ ].join(" :\n")} ;`;
520
+ const pkgsDeclareStr = this.runtimePkgs.map((pkg) => {
521
+ return `declare module "${pkg}" {
522
+ ${remoteKeysStr}
523
+ ${packageTypesStr}
524
+ export function loadRemote<T extends RemoteKeys,Y>(packageName: T): Promise<PackageType<T, Y>>;
525
+ export function loadRemote<T extends string,Y>(packageName: T): Promise<PackageType<T, Y>>;
526
+ }`;
527
+ }).join("\n");
528
+ const fileStr = `${importTypeStr}
529
+ ${pkgsDeclareStr}
530
+ `;
531
+ import_fs.default.writeFileSync(
532
+ import_path3.default.join(
533
+ hostOptions.context,
534
+ hostOptions.typesFolder,
535
+ HOST_API_TYPES_FILE_NAME
536
+ ),
537
+ fileStr
538
+ );
539
+ }
540
+ async consumeArchiveTypes(options) {
541
+ const { hostOptions, mapRemotesToDownload } = retrieveHostConfig(options);
542
+ if (hostOptions.deleteTypesFolder) {
543
+ await (0, import_promises.rm)(hostOptions.typesFolder, {
544
+ recursive: true,
545
+ force: true
546
+ }).catch(
547
+ (error) => console.error(
548
+ import_ansi_colors3.default.red(`Unable to remove types folder, ${error}`)
549
+ )
550
+ );
551
+ }
552
+ const downloadPromises = Object.entries(mapRemotesToDownload).map(
553
+ async (item) => {
554
+ const remoteInfo = item[1];
555
+ if (!this.remoteAliasMap[remoteInfo.alias]) {
556
+ const requiredRemoteInfo = await this.requestRemoteManifest(remoteInfo);
557
+ this.remoteAliasMap[remoteInfo.alias] = requiredRemoteInfo;
558
+ }
559
+ return this.consumeTargetRemotes(
560
+ hostOptions,
561
+ this.remoteAliasMap[remoteInfo.alias]
562
+ );
563
+ }
564
+ );
565
+ const downloadPromisesResult = await Promise.allSettled(downloadPromises);
566
+ return {
567
+ hostOptions,
568
+ downloadPromisesResult
569
+ };
570
+ }
571
+ async consumeTypes() {
572
+ var _a;
573
+ try {
574
+ const { options } = this;
575
+ if (!options.host) {
576
+ throw new Error("options.host is required if you want to consumeTypes");
577
+ }
578
+ const { mapRemotesToDownload } = retrieveHostConfig(options.host);
579
+ if (!Object.keys(mapRemotesToDownload).length) {
580
+ return;
581
+ }
582
+ const { downloadPromisesResult, hostOptions } = await this.consumeArchiveTypes(options.host);
583
+ if (hostOptions.consumeAPITypes) {
584
+ await Promise.all(
585
+ downloadPromisesResult.map(async (item) => {
586
+ if (item.status === "rejected" || !item.value) {
587
+ return;
588
+ }
589
+ const [alias, destinationPath] = item.value;
590
+ const remoteInfo = this.remoteAliasMap[alias];
591
+ if (!remoteInfo) {
592
+ return;
593
+ }
594
+ await this.downloadAPITypes(remoteInfo, destinationPath);
595
+ })
596
+ );
597
+ this.consumeAPITypes(hostOptions);
598
+ }
599
+ console.log(import_ansi_colors3.default.green("Federated types extraction completed"));
600
+ } catch (err) {
601
+ if (((_a = this.options.host) == null ? void 0 : _a.abortOnError) === false) {
602
+ console.error(
603
+ import_ansi_colors3.default.red(`Unable to consume federated types, ${err}`)
604
+ );
605
+ } else {
606
+ throw err;
607
+ }
608
+ }
609
+ }
610
+ async updateTypes(options) {
611
+ var _a, _b, _c;
612
+ const { remoteName, updateMode } = options;
613
+ const hostName = (_c = (_b = (_a = this.options) == null ? void 0 : _a.host) == null ? void 0 : _b.moduleFederationConfig) == null ? void 0 : _c.name;
614
+ if (updateMode === "POSITIVE" /* POSITIVE */ && remoteName === hostName) {
615
+ if (!this.options.remote) {
616
+ return;
617
+ }
618
+ this.generateTypes();
619
+ } else {
620
+ const { remoteAliasMap } = this;
621
+ if (!this.options.host) {
622
+ return;
623
+ }
624
+ const { hostOptions, mapRemotesToDownload } = retrieveHostConfig(
625
+ this.options.host
626
+ );
627
+ const loadedRemoteInfo = Object.values(remoteAliasMap).find(
628
+ (i) => i.name === remoteName
629
+ );
630
+ if (!loadedRemoteInfo) {
631
+ const remoteInfo = Object.values(mapRemotesToDownload).find((item) => {
632
+ return item.name === remoteName;
633
+ });
634
+ if (remoteInfo) {
635
+ if (!this.remoteAliasMap[remoteInfo.alias]) {
636
+ const requiredRemoteInfo = await this.requestRemoteManifest(remoteInfo);
637
+ this.remoteAliasMap[remoteInfo.alias] = requiredRemoteInfo;
638
+ }
639
+ await this.consumeTargetRemotes(
640
+ hostOptions,
641
+ this.remoteAliasMap[remoteInfo.alias]
642
+ );
643
+ }
644
+ } else {
645
+ await this.consumeTargetRemotes(hostOptions, loadedRemoteInfo);
646
+ }
647
+ }
648
+ }
649
+ };
650
+
651
+ // packages/dts-plugin/src/core/lib/utils.ts
652
+ var import_ansi_colors4 = __toESM(require("ansi-colors"));
653
+ function getDTSManagerConstructor(implementation) {
654
+ if (implementation) {
655
+ const NewConstructor = require(implementation);
656
+ return NewConstructor.default ? NewConstructor.default : NewConstructor;
657
+ }
658
+ return DTSManager;
659
+ }
660
+ var validateOptions = (options) => {
661
+ if (!options.moduleFederationConfig) {
662
+ throw new Error("moduleFederationConfig is required");
663
+ }
664
+ };
665
+ function retrieveTypesAssetsInfo(options) {
666
+ let apiTypesPath = "";
667
+ let zipTypesPath = "";
668
+ try {
669
+ const { tsConfig, remoteOptions, mapComponentsToExpose } = retrieveRemoteConfig(options);
670
+ if (!Object.keys(mapComponentsToExpose).length) {
671
+ return {
672
+ apiTypesPath,
673
+ zipTypesPath,
674
+ zipName: "",
675
+ apiFileName: ""
676
+ };
677
+ }
678
+ const mfTypesPath = retrieveMfTypesPath(tsConfig, remoteOptions);
679
+ zipTypesPath = retrieveTypesZipPath(mfTypesPath, remoteOptions);
680
+ if (remoteOptions.generateAPITypes) {
681
+ apiTypesPath = retrieveMfAPITypesPath(tsConfig, remoteOptions);
682
+ }
683
+ return {
684
+ apiTypesPath,
685
+ zipTypesPath,
686
+ zipName: import_path4.default.basename(zipTypesPath),
687
+ apiFileName: import_path4.default.basename(apiTypesPath)
688
+ };
689
+ } catch (err) {
690
+ console.error(import_ansi_colors4.default.red(`Unable to compile federated types, ${err}`));
691
+ return {
692
+ apiTypesPath: "",
693
+ zipTypesPath: "",
694
+ zipName: "",
695
+ apiFileName: ""
696
+ };
697
+ }
698
+ }
699
+ function replaceLocalhost(url) {
700
+ return url.replace("localhost", "127.0.0.1");
701
+ }
702
+ function isDebugMode() {
703
+ return Boolean(process.env["FEDERATION_DEBUG"]);
704
+ }
705
+
706
+ // packages/dts-plugin/src/core/configurations/remotePlugin.ts
707
+ var defaultOptions2 = {
708
+ tsConfigPath: "./tsconfig.json",
709
+ typesFolder: "@mf-types",
710
+ compiledTypesFolder: "compiled-types",
711
+ hostRemoteTypesFolder: "@mf-types",
712
+ deleteTypesFolder: true,
713
+ additionalFilesToCompile: [],
714
+ compilerInstance: "tsc",
715
+ compileInChildProcess: false,
716
+ implementation: "",
717
+ generateAPITypes: false,
718
+ context: process.cwd(),
719
+ abortOnError: true,
720
+ extractRemoteTypes: false,
721
+ extractThirdParty: false
722
+ };
723
+ var readTsConfig = ({
724
+ tsConfigPath,
725
+ typesFolder,
726
+ compiledTypesFolder,
727
+ context
728
+ }) => {
729
+ const resolvedTsConfigPath = (0, import_path5.resolve)(context, tsConfigPath);
730
+ const readResult = import_typescript2.default.readConfigFile(
731
+ resolvedTsConfigPath,
732
+ import_typescript2.default.sys.readFile
733
+ );
734
+ if (readResult.error) {
735
+ throw new Error(readResult.error.messageText.toString());
736
+ }
737
+ const configContent = import_typescript2.default.parseJsonConfigFileContent(
738
+ readResult.config,
739
+ import_typescript2.default.sys,
740
+ (0, import_path5.dirname)(resolvedTsConfigPath)
741
+ );
742
+ const outDir = (0, import_path5.resolve)(
743
+ context,
744
+ configContent.options.outDir || "dist",
745
+ typesFolder,
746
+ compiledTypesFolder
747
+ );
748
+ return {
749
+ ...configContent.options,
750
+ emitDeclarationOnly: true,
751
+ noEmit: false,
752
+ declaration: true,
753
+ outDir
754
+ };
755
+ };
756
+ var TS_EXTENSIONS = ["ts", "tsx", "vue", "svelte"];
757
+ var resolveWithExtension = (exposedPath, context) => {
758
+ if ((0, import_path5.extname)(exposedPath)) {
759
+ return (0, import_path5.resolve)(context, exposedPath);
760
+ }
761
+ for (const extension of TS_EXTENSIONS) {
762
+ const exposedPathWithExtension = (0, import_path5.resolve)(
763
+ context,
764
+ `${exposedPath}.${extension}`
765
+ );
766
+ if ((0, import_fs2.existsSync)(exposedPathWithExtension)) {
767
+ return exposedPathWithExtension;
768
+ }
769
+ }
770
+ return void 0;
771
+ };
772
+ var resolveExposes = (remoteOptions) => {
773
+ const parsedOptions = import_managers2.utils.parseOptions(
774
+ remoteOptions.moduleFederationConfig.exposes || {},
775
+ (item, key) => ({
776
+ exposePath: Array.isArray(item) ? item[0] : item,
777
+ key
778
+ }),
779
+ (item, key) => ({
780
+ exposePath: Array.isArray(item.import) ? item.import[0] : item.import[0],
781
+ key
782
+ })
783
+ );
784
+ return parsedOptions.reduce(
785
+ (accumulator, item) => {
786
+ const { exposePath, key } = item[1];
787
+ accumulator[key] = resolveWithExtension(exposePath, remoteOptions.context) || resolveWithExtension(
788
+ (0, import_path5.join)(exposePath, "index"),
789
+ remoteOptions.context
790
+ ) || exposePath;
791
+ return accumulator;
792
+ },
793
+ {}
794
+ );
795
+ };
796
+ var retrieveRemoteConfig = (options) => {
797
+ validateOptions(options);
798
+ const remoteOptions = {
799
+ ...defaultOptions2,
800
+ ...options
801
+ };
802
+ const mapComponentsToExpose = resolveExposes(remoteOptions);
803
+ const tsConfig = readTsConfig(remoteOptions);
804
+ return {
805
+ tsConfig,
806
+ mapComponentsToExpose,
807
+ remoteOptions
808
+ };
809
+ };
810
+
811
+ // packages/dts-plugin/src/core/lib/generateTypes.ts
812
+ async function generateTypes(options) {
813
+ var _a;
814
+ const DTSManagerConstructor = getDTSManagerConstructor(
815
+ (_a = options.remote) == null ? void 0 : _a.implementation
816
+ );
817
+ const dtsManager = new DTSManagerConstructor(options);
818
+ return dtsManager.generateTypes();
819
+ }
820
+
821
+ // packages/dts-plugin/src/core/lib/DtsWorker.ts
822
+ var import_path6 = __toESM(require("path"));
823
+ var import_lodash2 = __toESM(require("lodash.clonedeepwith"));
824
+
825
+ // packages/dts-plugin/src/core/rpc/index.ts
826
+ var rpc_exports = {};
827
+ __export(rpc_exports, {
828
+ RpcExitError: () => RpcExitError,
829
+ RpcGMCallTypes: () => RpcGMCallTypes,
830
+ createRpcWorker: () => createRpcWorker,
831
+ exposeRpc: () => exposeRpc,
832
+ getRpcWorkerData: () => getRpcWorkerData,
833
+ wrapRpc: () => wrapRpc
834
+ });
835
+
836
+ // packages/dts-plugin/src/core/rpc/expose-rpc.ts
837
+ var import_process = __toESM(require("process"));
838
+
839
+ // packages/dts-plugin/src/core/rpc/types.ts
840
+ var RpcGMCallTypes = /* @__PURE__ */ ((RpcGMCallTypes2) => {
841
+ RpcGMCallTypes2["CALL"] = "mf_call";
842
+ RpcGMCallTypes2["RESOLVE"] = "mf_resolve";
843
+ RpcGMCallTypes2["REJECT"] = "mf_reject";
844
+ RpcGMCallTypes2["EXIT"] = "mf_exit";
845
+ return RpcGMCallTypes2;
846
+ })(RpcGMCallTypes || {});
847
+
848
+ // packages/dts-plugin/src/core/rpc/expose-rpc.ts
849
+ function exposeRpc(fn) {
850
+ const sendMessage = (message) => new Promise((resolve4, reject) => {
851
+ if (!import_process.default.send) {
852
+ reject(new Error(`Process ${import_process.default.pid} doesn't have IPC channels`));
853
+ } else if (!import_process.default.connected) {
854
+ reject(
855
+ new Error(`Process ${import_process.default.pid} doesn't have open IPC channels`)
856
+ );
857
+ } else {
858
+ import_process.default.send(message, void 0, void 0, (error) => {
859
+ if (error) {
860
+ reject(error);
861
+ } else {
862
+ resolve4(void 0);
863
+ }
864
+ });
865
+ }
866
+ });
867
+ const handleMessage = async (message) => {
868
+ if (message.type === "mf_call" /* CALL */) {
869
+ if (!import_process.default.send) {
870
+ return;
871
+ }
872
+ let value, error;
873
+ try {
874
+ value = await fn(...message.args);
875
+ } catch (fnError) {
876
+ error = fnError;
877
+ }
878
+ try {
879
+ if (error) {
880
+ await sendMessage({
881
+ type: "mf_reject" /* REJECT */,
882
+ id: message.id,
883
+ error
884
+ });
885
+ } else {
886
+ await sendMessage({
887
+ type: "mf_resolve" /* RESOLVE */,
888
+ id: message.id,
889
+ value
890
+ });
891
+ }
892
+ } catch (sendError) {
893
+ if (error) {
894
+ if (error instanceof Error) {
895
+ console.error(error);
896
+ }
897
+ }
898
+ console.error(sendError);
899
+ }
900
+ }
901
+ };
902
+ import_process.default.on("message", handleMessage);
903
+ }
904
+
905
+ // packages/dts-plugin/src/core/rpc/rpc-error.ts
906
+ var RpcExitError = class extends Error {
907
+ constructor(message, code, signal) {
908
+ super(message);
909
+ this.code = code;
910
+ this.signal = signal;
911
+ this.name = "RpcExitError";
912
+ }
913
+ };
914
+
915
+ // packages/dts-plugin/src/core/rpc/wrap-rpc.ts
916
+ function createControlledPromise() {
917
+ let resolve4 = () => void 0;
918
+ let reject = () => void 0;
919
+ const promise = new Promise((aResolve, aReject) => {
920
+ resolve4 = aResolve;
921
+ reject = aReject;
922
+ });
923
+ return {
924
+ promise,
925
+ resolve: resolve4,
926
+ reject
927
+ };
928
+ }
929
+ function wrapRpc(childProcess, options) {
930
+ return async (...args) => {
931
+ if (!childProcess.send) {
932
+ throw new Error(`Process ${childProcess.pid} doesn't have IPC channels`);
933
+ } else if (!childProcess.connected) {
934
+ throw new Error(
935
+ `Process ${childProcess.pid} doesn't have open IPC channels`
936
+ );
937
+ }
938
+ const { id, once } = options;
939
+ const {
940
+ promise: resultPromise,
941
+ resolve: resolveResult,
942
+ reject: rejectResult
943
+ } = createControlledPromise();
944
+ const {
945
+ promise: sendPromise,
946
+ resolve: resolveSend,
947
+ reject: rejectSend
948
+ } = createControlledPromise();
949
+ const handleMessage = (message) => {
950
+ if ((message == null ? void 0 : message.id) === id) {
951
+ if (message.type === "mf_resolve" /* RESOLVE */) {
952
+ resolveResult(message.value);
953
+ } else if (message.type === "mf_reject" /* REJECT */) {
954
+ rejectResult(message.error);
955
+ }
956
+ }
957
+ if (once && (childProcess == null ? void 0 : childProcess.kill)) {
958
+ childProcess.kill("SIGTERM");
959
+ }
960
+ };
961
+ const handleClose = (code, signal) => {
962
+ rejectResult(
963
+ new RpcExitError(
964
+ code ? `Process ${childProcess.pid} exited with code ${code}${signal ? ` [${signal}]` : ""}` : `Process ${childProcess.pid} exited${signal ? ` [${signal}]` : ""}`,
965
+ code,
966
+ signal
967
+ )
968
+ );
969
+ removeHandlers();
970
+ };
971
+ const removeHandlers = () => {
972
+ childProcess.off("message", handleMessage);
973
+ childProcess.off("close", handleClose);
974
+ };
975
+ if (once) {
976
+ childProcess.once("message", handleMessage);
977
+ } else {
978
+ childProcess.on("message", handleMessage);
979
+ }
980
+ childProcess.on("close", handleClose);
981
+ childProcess.send(
982
+ {
983
+ type: "mf_call" /* CALL */,
984
+ id,
985
+ args
986
+ },
987
+ (error) => {
988
+ if (error) {
989
+ rejectSend(error);
990
+ removeHandlers();
991
+ } else {
992
+ resolveSend(void 0);
993
+ }
994
+ }
995
+ );
996
+ return sendPromise.then(() => resultPromise);
997
+ };
998
+ }
999
+
1000
+ // packages/dts-plugin/src/core/rpc/rpc-worker.ts
1001
+ var child_process = __toESM(require("child_process"));
1002
+ var process3 = __toESM(require("process"));
1003
+ var import_crypto = require("crypto");
1004
+ var FEDERATION_WORKER_DATA_ENV_KEY = "VMOK_WORKER_DATA_ENV";
1005
+ function createRpcWorker(modulePath, data, memoryLimit, once) {
1006
+ const options = {
1007
+ env: {
1008
+ ...process3.env,
1009
+ [FEDERATION_WORKER_DATA_ENV_KEY]: JSON.stringify(data || {})
1010
+ },
1011
+ stdio: ["inherit", "inherit", "inherit", "ipc"],
1012
+ serialization: "advanced"
1013
+ };
1014
+ if (memoryLimit) {
1015
+ options.execArgv = [`--max-old-space-size=${memoryLimit}`];
1016
+ }
1017
+ let childProcess, remoteMethod;
1018
+ const id = (0, import_crypto.randomUUID)();
1019
+ const worker = {
1020
+ connect(...args) {
1021
+ if (childProcess && !childProcess.connected) {
1022
+ childProcess.send({
1023
+ type: "mf_exit" /* EXIT */,
1024
+ id
1025
+ });
1026
+ childProcess = void 0;
1027
+ remoteMethod = void 0;
1028
+ }
1029
+ if (!(childProcess == null ? void 0 : childProcess.connected)) {
1030
+ childProcess = child_process.fork(modulePath, options);
1031
+ remoteMethod = wrapRpc(childProcess, { id, once });
1032
+ }
1033
+ if (!remoteMethod) {
1034
+ return Promise.reject(
1035
+ new Error("Worker is not connected - cannot perform RPC.")
1036
+ );
1037
+ }
1038
+ return remoteMethod(...args);
1039
+ },
1040
+ terminate() {
1041
+ var _a;
1042
+ (_a = childProcess == null ? void 0 : childProcess.send) == null ? void 0 : _a.call(childProcess, {
1043
+ type: "mf_exit" /* EXIT */,
1044
+ id
1045
+ });
1046
+ childProcess = void 0;
1047
+ remoteMethod = void 0;
1048
+ },
1049
+ get connected() {
1050
+ return Boolean(childProcess == null ? void 0 : childProcess.connected);
1051
+ },
1052
+ get process() {
1053
+ return childProcess;
1054
+ },
1055
+ get id() {
1056
+ return id;
1057
+ }
1058
+ };
1059
+ return worker;
1060
+ }
1061
+ function getRpcWorkerData() {
1062
+ return JSON.parse(process3.env[FEDERATION_WORKER_DATA_ENV_KEY] || "{}");
1063
+ }
1064
+
1065
+ // packages/dts-plugin/src/core/lib/DtsWorker.ts
1066
+ var DtsWorker = class {
1067
+ constructor(options) {
1068
+ this._options = (0, import_lodash2.default)(options, (_value, key) => {
1069
+ if (key === "manifest") {
1070
+ return false;
1071
+ }
1072
+ });
1073
+ this.removeUnSerializationOptions();
1074
+ this.rpcWorker = createRpcWorker(
1075
+ import_path6.default.resolve(__dirname, "./forkGenerateDts.js"),
1076
+ {},
1077
+ void 0,
1078
+ true
1079
+ );
1080
+ this._res = this.rpcWorker.connect(this._options);
1081
+ }
1082
+ removeUnSerializationOptions() {
1083
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1084
+ if ((_b = (_a = this._options.remote) == null ? void 0 : _a.moduleFederationConfig) == null ? void 0 : _b.manifest) {
1085
+ (_d = (_c = this._options.remote) == null ? void 0 : _c.moduleFederationConfig) == null ? true : delete _d.manifest;
1086
+ }
1087
+ if ((_f = (_e = this._options.host) == null ? void 0 : _e.moduleFederationConfig) == null ? void 0 : _f.manifest) {
1088
+ (_h = (_g = this._options.host) == null ? void 0 : _g.moduleFederationConfig) == null ? true : delete _h.manifest;
1089
+ }
1090
+ }
1091
+ get controlledPromise() {
1092
+ return Promise.resolve(this._res).then(() => {
1093
+ this.exit();
1094
+ });
1095
+ }
1096
+ exit() {
1097
+ var _a;
1098
+ (_a = this.rpcWorker) == null ? void 0 : _a.terminate();
1099
+ }
1100
+ };
1101
+
1102
+ // packages/dts-plugin/src/core/lib/generateTypesInChildProcess.ts
1103
+ async function generateTypesInChildProcess(options) {
1104
+ const dtsWorker = new DtsWorker(options);
1105
+ return dtsWorker.controlledPromise;
1106
+ }
1107
+
1108
+ // packages/dts-plugin/src/core/lib/consumeTypes.ts
1109
+ async function consumeTypes(options) {
1110
+ var _a;
1111
+ const DTSManagerConstructor = getDTSManagerConstructor(
1112
+ (_a = options.host) == null ? void 0 : _a.implementation
1113
+ );
1114
+ const dtsManager = new DTSManagerConstructor(options);
1115
+ await dtsManager.consumeTypes();
1116
+ }
1117
+ // Annotate the CommonJS export names for ESM import in node:
1118
+ 0 && (module.exports = {
1119
+ DTSManager,
1120
+ DtsWorker,
1121
+ HOST_API_TYPES_FILE_NAME,
1122
+ REMOTE_ALIAS_IDENTIFIER,
1123
+ REMOTE_API_TYPES_FILE_NAME,
1124
+ UpdateMode,
1125
+ consumeTypes,
1126
+ generateTypes,
1127
+ generateTypesInChildProcess,
1128
+ getDTSManagerConstructor,
1129
+ retrieveHostConfig,
1130
+ retrieveMfTypesPath,
1131
+ retrieveOriginalOutDir,
1132
+ retrieveRemoteConfig,
1133
+ retrieveTypesAssetsInfo,
1134
+ retrieveTypesZipPath,
1135
+ rpc,
1136
+ validateOptions
1137
+ });