@formspec/build 0.1.0-alpha.52 → 0.1.0-alpha.54
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/class-analyzer.d.ts.map +1 -1
- 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 +61 -0
- package/dist/build-beta.d.ts +61 -0
- package/dist/build-internal.d.ts +61 -0
- package/dist/build.d.ts +61 -0
- package/dist/cli/logger.d.ts +22 -0
- package/dist/cli/logger.d.ts.map +1 -0
- package/dist/cli.cjs +137 -23
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +133 -22
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +102 -22
- 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 +104 -22
- package/dist/index.js.map +1 -1
- package/dist/internals.cjs +77 -19
- package/dist/internals.cjs.map +1 -1
- package/dist/internals.js +77 -19
- 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) {
|
|
@@ -2886,10 +2932,22 @@ function resolveTypeNode(type, checker, file, typeRegistry, visiting, sourceNode
|
|
|
2886
2932
|
sourceNode
|
|
2887
2933
|
);
|
|
2888
2934
|
if (customTypeLookup !== null) {
|
|
2935
|
+
const typeId = customTypeIdFromLookup(customTypeLookup);
|
|
2936
|
+
let payload = null;
|
|
2937
|
+
if (customTypeLookup.registration.extractPayload !== void 0) {
|
|
2938
|
+
try {
|
|
2939
|
+
payload = customTypeLookup.registration.extractPayload(type, checker) ?? null;
|
|
2940
|
+
} catch (cause) {
|
|
2941
|
+
throw new Error(
|
|
2942
|
+
`extractPayload for custom type "${customTypeLookup.registration.typeName}" in extension "${customTypeLookup.extensionId}" threw`,
|
|
2943
|
+
{ cause }
|
|
2944
|
+
);
|
|
2945
|
+
}
|
|
2946
|
+
}
|
|
2889
2947
|
return {
|
|
2890
2948
|
kind: "custom",
|
|
2891
|
-
typeId
|
|
2892
|
-
payload
|
|
2949
|
+
typeId,
|
|
2950
|
+
payload
|
|
2893
2951
|
};
|
|
2894
2952
|
}
|
|
2895
2953
|
const primitiveAlias = tryResolveNamedPrimitiveAlias(
|