@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.cjs
CHANGED
|
@@ -1044,39 +1044,85 @@ function isNonReferenceIdentifier(node) {
|
|
|
1044
1044
|
}
|
|
1045
1045
|
return false;
|
|
1046
1046
|
}
|
|
1047
|
-
function
|
|
1047
|
+
function astReferencesImportedName(root, importedNames) {
|
|
1048
1048
|
if (importedNames.size === 0) {
|
|
1049
1049
|
return false;
|
|
1050
1050
|
}
|
|
1051
|
-
let
|
|
1051
|
+
let found = false;
|
|
1052
1052
|
const visit = (node) => {
|
|
1053
|
-
if (
|
|
1054
|
-
return;
|
|
1055
|
-
}
|
|
1053
|
+
if (found) return;
|
|
1056
1054
|
if (ts4.isIdentifier(node) && importedNames.has(node.text) && !isNonReferenceIdentifier(node)) {
|
|
1057
|
-
|
|
1055
|
+
found = true;
|
|
1058
1056
|
return;
|
|
1059
1057
|
}
|
|
1060
1058
|
ts4.forEachChild(node, visit);
|
|
1061
1059
|
};
|
|
1062
|
-
visit(
|
|
1063
|
-
return
|
|
1060
|
+
visit(root);
|
|
1061
|
+
return found;
|
|
1062
|
+
}
|
|
1063
|
+
function getObjectMembers(statement) {
|
|
1064
|
+
if (ts4.isInterfaceDeclaration(statement)) {
|
|
1065
|
+
return statement.members;
|
|
1066
|
+
}
|
|
1067
|
+
if (ts4.isTypeLiteralNode(statement.type)) {
|
|
1068
|
+
return statement.type.members;
|
|
1069
|
+
}
|
|
1070
|
+
return void 0;
|
|
1071
|
+
}
|
|
1072
|
+
function rewriteImportedMemberTypes(statement, sourceFile, importedNames) {
|
|
1073
|
+
const members = getObjectMembers(statement);
|
|
1074
|
+
if (members === void 0) {
|
|
1075
|
+
return null;
|
|
1076
|
+
}
|
|
1077
|
+
const replacements = [];
|
|
1078
|
+
for (const member of members) {
|
|
1079
|
+
if (!ts4.isPropertySignature(member)) {
|
|
1080
|
+
if (astReferencesImportedName(member, importedNames)) {
|
|
1081
|
+
return null;
|
|
1082
|
+
}
|
|
1083
|
+
continue;
|
|
1084
|
+
}
|
|
1085
|
+
const typeAnnotation = member.type;
|
|
1086
|
+
if (typeAnnotation === void 0) continue;
|
|
1087
|
+
if (astReferencesImportedName(typeAnnotation, importedNames)) {
|
|
1088
|
+
replacements.push({
|
|
1089
|
+
start: typeAnnotation.getStart(sourceFile),
|
|
1090
|
+
end: typeAnnotation.getEnd()
|
|
1091
|
+
});
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
if (replacements.length === 0) {
|
|
1095
|
+
return statement.getText(sourceFile);
|
|
1096
|
+
}
|
|
1097
|
+
const stmtStart = statement.getStart(sourceFile);
|
|
1098
|
+
let result = statement.getText(sourceFile);
|
|
1099
|
+
for (const { start, end } of [...replacements].reverse()) {
|
|
1100
|
+
result = result.slice(0, start - stmtStart) + "unknown" + result.slice(end - stmtStart);
|
|
1101
|
+
}
|
|
1102
|
+
return result;
|
|
1064
1103
|
}
|
|
1065
1104
|
function buildSupportingDeclarations(sourceFile, extensionTypeNames) {
|
|
1066
1105
|
const importedNames = collectImportedNames(sourceFile);
|
|
1067
1106
|
const importedNamesToSkip = new Set(
|
|
1068
1107
|
[...importedNames].filter((name) => !extensionTypeNames.has(name))
|
|
1069
1108
|
);
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
if (ts4.
|
|
1073
|
-
if (ts4.
|
|
1074
|
-
|
|
1075
|
-
if (
|
|
1076
|
-
|
|
1109
|
+
const result = [];
|
|
1110
|
+
for (const statement of sourceFile.statements) {
|
|
1111
|
+
if (ts4.isImportDeclaration(statement)) continue;
|
|
1112
|
+
if (ts4.isImportEqualsDeclaration(statement)) continue;
|
|
1113
|
+
if (ts4.isExportDeclaration(statement) && statement.moduleSpecifier !== void 0) continue;
|
|
1114
|
+
if (!astReferencesImportedName(statement, importedNamesToSkip)) {
|
|
1115
|
+
result.push(statement.getText(sourceFile));
|
|
1116
|
+
continue;
|
|
1077
1117
|
}
|
|
1078
|
-
|
|
1079
|
-
|
|
1118
|
+
if (ts4.isInterfaceDeclaration(statement) || ts4.isTypeAliasDeclaration(statement)) {
|
|
1119
|
+
const rewritten = rewriteImportedMemberTypes(statement, sourceFile, importedNamesToSkip);
|
|
1120
|
+
if (rewritten !== null) {
|
|
1121
|
+
result.push(rewritten);
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
return result;
|
|
1080
1126
|
}
|
|
1081
1127
|
function pushUniqueCompilerDiagnostics(target, additions) {
|
|
1082
1128
|
for (const diagnostic of additions) {
|
|
@@ -2920,10 +2966,22 @@ function resolveTypeNode(type, checker, file, typeRegistry, visiting, sourceNode
|
|
|
2920
2966
|
sourceNode
|
|
2921
2967
|
);
|
|
2922
2968
|
if (customTypeLookup !== null) {
|
|
2969
|
+
const typeId = customTypeIdFromLookup(customTypeLookup);
|
|
2970
|
+
let payload = null;
|
|
2971
|
+
if (customTypeLookup.registration.extractPayload !== void 0) {
|
|
2972
|
+
try {
|
|
2973
|
+
payload = customTypeLookup.registration.extractPayload(type, checker) ?? null;
|
|
2974
|
+
} catch (cause) {
|
|
2975
|
+
throw new Error(
|
|
2976
|
+
`extractPayload for custom type "${customTypeLookup.registration.typeName}" in extension "${customTypeLookup.extensionId}" threw`,
|
|
2977
|
+
{ cause }
|
|
2978
|
+
);
|
|
2979
|
+
}
|
|
2980
|
+
}
|
|
2923
2981
|
return {
|
|
2924
2982
|
kind: "custom",
|
|
2925
|
-
typeId
|
|
2926
|
-
payload
|
|
2983
|
+
typeId,
|
|
2984
|
+
payload
|
|
2927
2985
|
};
|
|
2928
2986
|
}
|
|
2929
2987
|
const primitiveAlias = tryResolveNamedPrimitiveAlias(
|