forked from microsoft/FluidFramework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrollup-api-data.js
More file actions
99 lines (92 loc) · 3.41 KB
/
rollup-api-data.js
File metadata and controls
99 lines (92 loc) · 3.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/*!
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
* Licensed under the MIT License.
*/
/**
* Our public API is exposed by re-exporting things from 'internal' packages in 'external' packages, like
* fluid-framework. API Extractor does not extract re-exported APIs, so we need to merge and rewrite the API JSON. This
* file contains the input data to the re-writing process. The processing script itself is in the rollup-api-json.js
* file.
*/
/** An array of all packages whose TSDocs should be published to website. */
const websitePackages = [
"fluid-framework",
"tinylicious",
"@fluidframework/azure-client",
"@fluidframework/azure-service-utils",
"@fluidframework/test-client-utils",
"@fluidframework/tinylicious-client",
];
/** An array of objects describing how members should be combined. */
const memberCombineInstructions = [
{
package: "@fluidframework/test-client-utils",
sourceImports: new Map([
["@fluidframework/test-runtime-utils", ["InsecureTokenProvider"]],
])
},
{
package: "@fluidframework/azure-client",
sourceImports: new Map([
["@fluidframework/routerlicious-driver", ["ITokenProvider", "ITokenResponse"]],
["@fluidframework/protocol-definitions", ["ScopeType", "ITokenClaims", "IUser"]],
])
},
{
package: "@fluidframework/fluid-static",
sourceImports: new Map([
["@fluidframework/container-definitions", ["IAudience"]],
])
},
{
package: "fluid-framework",
sourceImports: new Map([
["@fluidframework/container-definitions", ["AttachState"]],
["@fluidframework/fluid-static", ["*"]],
["@fluidframework/map", ["*"]],
["@fluidframework/sequence", ["*"]],
])
},
];
/**
* An array of tuples containing a member reference to search for and a replacement member reference string.
*/
const stringReplacements = memberCombineInstructions.flatMap((instruction) => {
const returnValue = [];
const { package, sourceImports } = instruction;
for (const [sourcePackage, imports] of sourceImports) {
for (const importName of imports) {
if (importName !== "*") {
const searchString = `${sourcePackage}!${importName}`;
const replacementString = `${package}!${importName}`;
returnValue.push([searchString, replacementString]);
} else {
const searchString = `${sourcePackage}!`;
const replacementString = `${package}!`;
returnValue.push([searchString, replacementString]);
}
}
}
return returnValue;
});
/**
* Adds an array of strings to a set individually.
*
* @param {Set<string>} set
* @param {string[]} add
*/
const addToSet = (set, add) => {
for (item of add) {
set.add(item);
}
}
/** A Set containing all the packages that are needed to do the API rollup. */
const allStagingPackages = new Set(websitePackages);
for (const { package, sourceImports } of memberCombineInstructions) {
allStagingPackages.add(package);
addToSet(allStagingPackages, Array.from(sourceImports.keys()));
}
exports.allStagingPackages = Array.from(allStagingPackages);
exports.memberCombineInstructions = memberCombineInstructions;
exports.stringReplacements = stringReplacements;
exports.websitePackages = websitePackages;