@formspec/build 0.1.0-alpha.52 → 0.1.0-alpha.53
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/analyzer/tsdoc-parser.d.ts.map +1 -1
- package/dist/browser.cjs +17 -0
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.ts +8 -2
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +19 -0
- package/dist/browser.js.map +1 -1
- package/dist/build-alpha.d.ts +21 -0
- package/dist/build-beta.d.ts +21 -0
- package/dist/build-internal.d.ts +21 -0
- package/dist/build.d.ts +21 -0
- package/dist/cli/logger.d.ts +22 -0
- package/dist/cli/logger.d.ts.map +1 -0
- package/dist/cli.cjs +123 -21
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +119 -20
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +88 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +90 -20
- package/dist/index.js.map +1 -1
- package/dist/internals.cjs +63 -17
- package/dist/internals.cjs.map +1 -1
- package/dist/internals.js +63 -17
- package/dist/internals.js.map +1 -1
- package/dist/json-schema/generator.d.ts +6 -1
- package/dist/json-schema/generator.d.ts.map +1 -1
- package/dist/ui-schema/generator.d.ts +6 -1
- package/dist/ui-schema/generator.d.ts.map +1 -1
- package/package.json +11 -5
package/dist/internals.js
CHANGED
|
@@ -1010,39 +1010,85 @@ function isNonReferenceIdentifier(node) {
|
|
|
1010
1010
|
}
|
|
1011
1011
|
return false;
|
|
1012
1012
|
}
|
|
1013
|
-
function
|
|
1013
|
+
function astReferencesImportedName(root, importedNames) {
|
|
1014
1014
|
if (importedNames.size === 0) {
|
|
1015
1015
|
return false;
|
|
1016
1016
|
}
|
|
1017
|
-
let
|
|
1017
|
+
let found = false;
|
|
1018
1018
|
const visit = (node) => {
|
|
1019
|
-
if (
|
|
1020
|
-
return;
|
|
1021
|
-
}
|
|
1019
|
+
if (found) return;
|
|
1022
1020
|
if (ts4.isIdentifier(node) && importedNames.has(node.text) && !isNonReferenceIdentifier(node)) {
|
|
1023
|
-
|
|
1021
|
+
found = true;
|
|
1024
1022
|
return;
|
|
1025
1023
|
}
|
|
1026
1024
|
ts4.forEachChild(node, visit);
|
|
1027
1025
|
};
|
|
1028
|
-
visit(
|
|
1029
|
-
return
|
|
1026
|
+
visit(root);
|
|
1027
|
+
return found;
|
|
1028
|
+
}
|
|
1029
|
+
function getObjectMembers(statement) {
|
|
1030
|
+
if (ts4.isInterfaceDeclaration(statement)) {
|
|
1031
|
+
return statement.members;
|
|
1032
|
+
}
|
|
1033
|
+
if (ts4.isTypeLiteralNode(statement.type)) {
|
|
1034
|
+
return statement.type.members;
|
|
1035
|
+
}
|
|
1036
|
+
return void 0;
|
|
1037
|
+
}
|
|
1038
|
+
function rewriteImportedMemberTypes(statement, sourceFile, importedNames) {
|
|
1039
|
+
const members = getObjectMembers(statement);
|
|
1040
|
+
if (members === void 0) {
|
|
1041
|
+
return null;
|
|
1042
|
+
}
|
|
1043
|
+
const replacements = [];
|
|
1044
|
+
for (const member of members) {
|
|
1045
|
+
if (!ts4.isPropertySignature(member)) {
|
|
1046
|
+
if (astReferencesImportedName(member, importedNames)) {
|
|
1047
|
+
return null;
|
|
1048
|
+
}
|
|
1049
|
+
continue;
|
|
1050
|
+
}
|
|
1051
|
+
const typeAnnotation = member.type;
|
|
1052
|
+
if (typeAnnotation === void 0) continue;
|
|
1053
|
+
if (astReferencesImportedName(typeAnnotation, importedNames)) {
|
|
1054
|
+
replacements.push({
|
|
1055
|
+
start: typeAnnotation.getStart(sourceFile),
|
|
1056
|
+
end: typeAnnotation.getEnd()
|
|
1057
|
+
});
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1060
|
+
if (replacements.length === 0) {
|
|
1061
|
+
return statement.getText(sourceFile);
|
|
1062
|
+
}
|
|
1063
|
+
const stmtStart = statement.getStart(sourceFile);
|
|
1064
|
+
let result = statement.getText(sourceFile);
|
|
1065
|
+
for (const { start, end } of [...replacements].reverse()) {
|
|
1066
|
+
result = result.slice(0, start - stmtStart) + "unknown" + result.slice(end - stmtStart);
|
|
1067
|
+
}
|
|
1068
|
+
return result;
|
|
1030
1069
|
}
|
|
1031
1070
|
function buildSupportingDeclarations(sourceFile, extensionTypeNames) {
|
|
1032
1071
|
const importedNames = collectImportedNames(sourceFile);
|
|
1033
1072
|
const importedNamesToSkip = new Set(
|
|
1034
1073
|
[...importedNames].filter((name) => !extensionTypeNames.has(name))
|
|
1035
1074
|
);
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
if (ts4.
|
|
1039
|
-
if (ts4.
|
|
1040
|
-
|
|
1041
|
-
if (
|
|
1042
|
-
|
|
1075
|
+
const result = [];
|
|
1076
|
+
for (const statement of sourceFile.statements) {
|
|
1077
|
+
if (ts4.isImportDeclaration(statement)) continue;
|
|
1078
|
+
if (ts4.isImportEqualsDeclaration(statement)) continue;
|
|
1079
|
+
if (ts4.isExportDeclaration(statement) && statement.moduleSpecifier !== void 0) continue;
|
|
1080
|
+
if (!astReferencesImportedName(statement, importedNamesToSkip)) {
|
|
1081
|
+
result.push(statement.getText(sourceFile));
|
|
1082
|
+
continue;
|
|
1043
1083
|
}
|
|
1044
|
-
|
|
1045
|
-
|
|
1084
|
+
if (ts4.isInterfaceDeclaration(statement) || ts4.isTypeAliasDeclaration(statement)) {
|
|
1085
|
+
const rewritten = rewriteImportedMemberTypes(statement, sourceFile, importedNamesToSkip);
|
|
1086
|
+
if (rewritten !== null) {
|
|
1087
|
+
result.push(rewritten);
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
return result;
|
|
1046
1092
|
}
|
|
1047
1093
|
function pushUniqueCompilerDiagnostics(target, additions) {
|
|
1048
1094
|
for (const diagnostic of additions) {
|