@formspec/build 0.1.0-alpha.24 → 0.1.0-alpha.27
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/program.d.ts +12 -0
- package/dist/analyzer/program.d.ts.map +1 -1
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.ts +1 -0
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js.map +1 -1
- package/dist/build-alpha.d.ts +167 -22
- package/dist/build-beta.d.ts +167 -22
- package/dist/build-internal.d.ts +167 -22
- package/dist/build.d.ts +239 -21
- package/dist/cli.cjs +118 -6
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +117 -6
- package/dist/cli.js.map +1 -1
- package/dist/generators/class-schema.d.ts +27 -0
- package/dist/generators/class-schema.d.ts.map +1 -1
- package/dist/generators/mixed-authoring.d.ts.map +1 -1
- package/dist/index.cjs +114 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +111 -6
- package/dist/index.js.map +1 -1
- package/dist/internals.cjs +46 -0
- package/dist/internals.cjs.map +1 -1
- package/dist/internals.d.ts +1 -1
- package/dist/internals.d.ts.map +1 -1
- package/dist/internals.js +44 -0
- package/dist/internals.js.map +1 -1
- package/dist/json-schema/ir-generator.d.ts +30 -0
- package/dist/json-schema/ir-generator.d.ts.map +1 -1
- package/dist/json-schema/schema.d.ts +2 -2
- package/dist/json-schema/types.d.ts +35 -4
- package/dist/json-schema/types.d.ts.map +1 -1
- package/dist/ui-schema/schema.d.ts +2 -7
- package/dist/ui-schema/schema.d.ts.map +1 -1
- package/dist/ui-schema/types.d.ts +58 -0
- package/dist/ui-schema/types.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/internals.cjs
CHANGED
|
@@ -32,12 +32,14 @@ var internals_exports = {};
|
|
|
32
32
|
__export(internals_exports, {
|
|
33
33
|
analyzeClassToIR: () => analyzeClassToIR,
|
|
34
34
|
analyzeInterfaceToIR: () => analyzeInterfaceToIR,
|
|
35
|
+
analyzeNamedTypeToIRFromProgramContext: () => analyzeNamedTypeToIRFromProgramContext,
|
|
35
36
|
analyzeTypeAliasToIR: () => analyzeTypeAliasToIR,
|
|
36
37
|
canonicalizeChainDSL: () => canonicalizeChainDSL,
|
|
37
38
|
canonicalizeTSDoc: () => canonicalizeTSDoc,
|
|
38
39
|
collectFormSpecReferences: () => collectFormSpecReferences,
|
|
39
40
|
createExtensionRegistry: () => createExtensionRegistry,
|
|
40
41
|
createProgramContext: () => createProgramContext,
|
|
42
|
+
createProgramContextFromProgram: () => createProgramContextFromProgram,
|
|
41
43
|
findClassByName: () => findClassByName,
|
|
42
44
|
findInterfaceByName: () => findInterfaceByName,
|
|
43
45
|
findTypeAliasByName: () => findTypeAliasByName,
|
|
@@ -2393,6 +2395,18 @@ function detectFormSpecReference(typeNode) {
|
|
|
2393
2395
|
}
|
|
2394
2396
|
|
|
2395
2397
|
// src/analyzer/program.ts
|
|
2398
|
+
function createProgramContextFromProgram(program, filePath) {
|
|
2399
|
+
const absolutePath = path.resolve(filePath);
|
|
2400
|
+
const sourceFile = program.getSourceFile(absolutePath) ?? program.getSourceFile(filePath);
|
|
2401
|
+
if (!sourceFile) {
|
|
2402
|
+
throw new Error(`Could not find source file in provided program: ${absolutePath}`);
|
|
2403
|
+
}
|
|
2404
|
+
return {
|
|
2405
|
+
program,
|
|
2406
|
+
checker: program.getTypeChecker(),
|
|
2407
|
+
sourceFile
|
|
2408
|
+
};
|
|
2409
|
+
}
|
|
2396
2410
|
function createProgramContext(filePath) {
|
|
2397
2411
|
const absolutePath = path.resolve(filePath);
|
|
2398
2412
|
const fileDir = path.dirname(absolutePath);
|
|
@@ -2461,6 +2475,36 @@ function findInterfaceByName(sourceFile, interfaceName) {
|
|
|
2461
2475
|
function findTypeAliasByName(sourceFile, aliasName) {
|
|
2462
2476
|
return findNodeByName(sourceFile, aliasName, ts4.isTypeAliasDeclaration, (n) => n.name.text);
|
|
2463
2477
|
}
|
|
2478
|
+
function analyzeNamedTypeToIRFromProgramContext(ctx, filePath, typeName, extensionRegistry) {
|
|
2479
|
+
const analysisFilePath = path.resolve(filePath);
|
|
2480
|
+
const classDecl = findClassByName(ctx.sourceFile, typeName);
|
|
2481
|
+
if (classDecl !== null) {
|
|
2482
|
+
return analyzeClassToIR(classDecl, ctx.checker, analysisFilePath, extensionRegistry);
|
|
2483
|
+
}
|
|
2484
|
+
const interfaceDecl = findInterfaceByName(ctx.sourceFile, typeName);
|
|
2485
|
+
if (interfaceDecl !== null) {
|
|
2486
|
+
return analyzeInterfaceToIR(interfaceDecl, ctx.checker, analysisFilePath, extensionRegistry);
|
|
2487
|
+
}
|
|
2488
|
+
const typeAlias = findTypeAliasByName(ctx.sourceFile, typeName);
|
|
2489
|
+
if (typeAlias !== null) {
|
|
2490
|
+
const result = analyzeTypeAliasToIR(
|
|
2491
|
+
typeAlias,
|
|
2492
|
+
ctx.checker,
|
|
2493
|
+
analysisFilePath,
|
|
2494
|
+
extensionRegistry
|
|
2495
|
+
);
|
|
2496
|
+
if (result.ok) {
|
|
2497
|
+
return result.analysis;
|
|
2498
|
+
}
|
|
2499
|
+
throw new Error(result.error);
|
|
2500
|
+
}
|
|
2501
|
+
throw new Error(
|
|
2502
|
+
`Type "${typeName}" not found as a class, interface, or type alias in ${analysisFilePath}`
|
|
2503
|
+
);
|
|
2504
|
+
}
|
|
2505
|
+
|
|
2506
|
+
// src/generators/class-schema.ts
|
|
2507
|
+
var ts5 = require("typescript");
|
|
2464
2508
|
|
|
2465
2509
|
// src/json-schema/ir-generator.ts
|
|
2466
2510
|
function makeContext(options) {
|
|
@@ -3415,12 +3459,14 @@ function collectFormSpecReferences(methods) {
|
|
|
3415
3459
|
0 && (module.exports = {
|
|
3416
3460
|
analyzeClassToIR,
|
|
3417
3461
|
analyzeInterfaceToIR,
|
|
3462
|
+
analyzeNamedTypeToIRFromProgramContext,
|
|
3418
3463
|
analyzeTypeAliasToIR,
|
|
3419
3464
|
canonicalizeChainDSL,
|
|
3420
3465
|
canonicalizeTSDoc,
|
|
3421
3466
|
collectFormSpecReferences,
|
|
3422
3467
|
createExtensionRegistry,
|
|
3423
3468
|
createProgramContext,
|
|
3469
|
+
createProgramContextFromProgram,
|
|
3424
3470
|
findClassByName,
|
|
3425
3471
|
findInterfaceByName,
|
|
3426
3472
|
findTypeAliasByName,
|