@formspec/build 0.1.0-alpha.49 → 0.1.0-alpha.50
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/cli.cjs +381 -374
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +339 -334
- package/dist/cli.js.map +1 -1
- package/dist/extensions/resolve-custom-type.d.ts +37 -0
- package/dist/extensions/resolve-custom-type.d.ts.map +1 -0
- package/dist/extensions/symbol-registry.d.ts.map +1 -1
- package/dist/extensions/ts-type-utils.d.ts +40 -0
- package/dist/extensions/ts-type-utils.d.ts.map +1 -0
- package/dist/index.cjs +359 -365
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +328 -334
- package/dist/index.js.map +1 -1
- package/dist/internals.cjs +332 -333
- package/dist/internals.cjs.map +1 -1
- package/dist/internals.js +297 -298
- package/dist/internals.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as ts from "typescript";
|
|
2
|
+
import type { ExtensionRegistry, ExtensionTypeLookupResult } from "./registry.js";
|
|
3
|
+
/**
|
|
4
|
+
* Resolves a TypeScript type to an extension-registered custom type, trying
|
|
5
|
+
* all three registration mechanisms in order of precision:
|
|
6
|
+
*
|
|
7
|
+
* 1. **Name-based** (via `sourceNode` AST walk) — matches the user-written
|
|
8
|
+
* alias identifier (e.g. `amount: Decimal` → `"Decimal"`). Requires a
|
|
9
|
+
* source node to walk; used by the direct-field code path.
|
|
10
|
+
* 2. **Symbol-based** — matches `ts.Symbol` identity via
|
|
11
|
+
* `ExtensionRegistry.findTypeBySymbol`, populated from
|
|
12
|
+
* `defineCustomType<T>()` type parameter extraction. Works for any type
|
|
13
|
+
* regardless of import aliases or name collisions.
|
|
14
|
+
* 3. **Brand-based** — matches the `brand` identifier encoded into
|
|
15
|
+
* intersection types as computed-property keys (e.g.
|
|
16
|
+
* `string & { [__decimalBrand]: true }`). Structural; independent of
|
|
17
|
+
* declaration names.
|
|
18
|
+
*
|
|
19
|
+
* Name-based resolution also has a symbol-fallback path that uses
|
|
20
|
+
* `type.aliasSymbol?.getName()` when no `sourceNode` is provided, so
|
|
21
|
+
* path-resolved types can still match name-registered custom types.
|
|
22
|
+
*
|
|
23
|
+
* Nullable unions (`T | null`, `T | undefined`, `T | null | undefined`) are
|
|
24
|
+
* stripped before every detection attempt, so registrations apply through
|
|
25
|
+
* nullable wrappers transparently.
|
|
26
|
+
*
|
|
27
|
+
* Returns `null` when no registered custom type matches.
|
|
28
|
+
*/
|
|
29
|
+
export declare function resolveCustomTypeFromTsType(type: ts.Type, checker: ts.TypeChecker, registry: ExtensionRegistry | undefined, sourceNode?: ts.Node): ExtensionTypeLookupResult | null;
|
|
30
|
+
/**
|
|
31
|
+
* Returns the fully-qualified type ID for a resolved custom-type lookup.
|
|
32
|
+
*
|
|
33
|
+
* Type IDs have the form `${extensionId}/${typeName}`, matching the format
|
|
34
|
+
* produced elsewhere in the build pipeline.
|
|
35
|
+
*/
|
|
36
|
+
export declare function customTypeIdFromLookup(result: ExtensionTypeLookupResult): string;
|
|
37
|
+
//# sourceMappingURL=resolve-custom-type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-custom-type.d.ts","sourceRoot":"","sources":["../../src/extensions/resolve-custom-type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAIjC,OAAO,KAAK,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAoDlF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,EAAE,CAAC,IAAI,EACb,OAAO,EAAE,EAAE,CAAC,WAAW,EACvB,QAAQ,EAAE,iBAAiB,GAAG,SAAS,EACvC,UAAU,CAAC,EAAE,EAAE,CAAC,IAAI,GACnB,yBAAyB,GAAG,IAAI,CA8ClC;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,yBAAyB,GAAG,MAAM,CAEhF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"symbol-registry.d.ts","sourceRoot":"","sources":["../../src/extensions/symbol-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjC,OAAO,KAAK,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"symbol-registry.d.ts","sourceRoot":"","sources":["../../src/extensions/symbol-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjC,OAAO,KAAK,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAOlF;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,EAAE,CAAC,OAAO,EACnB,OAAO,EAAE,EAAE,CAAC,WAAW,EACvB,iBAAiB,EAAE,iBAAiB,GACnC,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,yBAAyB,CAAC,CA+D3C"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as ts from "typescript";
|
|
2
|
+
/**
|
|
3
|
+
* Collects all brand identifier texts from an intersection type's computed
|
|
4
|
+
* property names.
|
|
5
|
+
*
|
|
6
|
+
* Walks `type.getProperties()` looking for computed property names backed
|
|
7
|
+
* by plain identifiers — the standard `unique symbol` brand pattern. Returns
|
|
8
|
+
* all matching identifiers so that types with multiple brands (e.g.,
|
|
9
|
+
* `number & { [__integerBrand]: true } & { [__otherBrand]: true }`) are
|
|
10
|
+
* fully inspected regardless of property order.
|
|
11
|
+
*/
|
|
12
|
+
export declare function collectBrandIdentifiers(type: ts.Type): readonly string[];
|
|
13
|
+
/**
|
|
14
|
+
* Resolves a TypeScript type to its canonical `ts.Symbol`, following alias chains.
|
|
15
|
+
*
|
|
16
|
+
* `aliasSymbol` tracks type aliases (e.g. `type Foo = Bar`); `getSymbol()` tracks
|
|
17
|
+
* the structural symbol. We prefer `aliasSymbol` when present so that aliased
|
|
18
|
+
* types resolve to the declaration site rather than the structural shape.
|
|
19
|
+
*
|
|
20
|
+
* Returns `undefined` for bare primitives and anonymous types, which have no
|
|
21
|
+
* symbol.
|
|
22
|
+
*/
|
|
23
|
+
export declare function resolveCanonicalSymbol(type: ts.Type, checker: ts.TypeChecker): ts.Symbol | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Extracts the `ts.TypeNode` backing a property / parameter / type-alias
|
|
26
|
+
* declaration. Returns the node itself when `sourceNode` is already a type
|
|
27
|
+
* node, or `undefined` otherwise.
|
|
28
|
+
*/
|
|
29
|
+
export declare function extractTypeNodeFromSource(sourceNode: ts.Node): ts.TypeNode | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* Resolves a `ts.TypeReferenceNode` to its declaring `ts.TypeAliasDeclaration`,
|
|
32
|
+
* if the reference names a type alias — following import aliases so that
|
|
33
|
+
* `import { Foo } from "./types"; field: Foo` resolves through to the
|
|
34
|
+
* original `type Foo = ...` declaration.
|
|
35
|
+
*
|
|
36
|
+
* Returns `undefined` for references to non-alias declarations (interfaces,
|
|
37
|
+
* classes, modules, etc.).
|
|
38
|
+
*/
|
|
39
|
+
export declare function getTypeAliasDeclarationFromTypeReference(typeNode: ts.TypeReferenceNode, checker: ts.TypeChecker): ts.TypeAliasDeclaration | undefined;
|
|
40
|
+
//# sourceMappingURL=ts-type-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ts-type-utils.d.ts","sourceRoot":"","sources":["../../src/extensions/ts-type-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjC;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,SAAS,MAAM,EAAE,CAcxE;AAED;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,EAAE,CAAC,IAAI,EACb,OAAO,EAAE,EAAE,CAAC,WAAW,GACtB,EAAE,CAAC,MAAM,GAAG,SAAS,CAIvB;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,UAAU,EAAE,EAAE,CAAC,IAAI,GAAG,EAAE,CAAC,QAAQ,GAAG,SAAS,CAatF;AAUD;;;;;;;;GAQG;AACH,wBAAgB,wCAAwC,CACtD,QAAQ,EAAE,EAAE,CAAC,iBAAiB,EAC9B,OAAO,EAAE,EAAE,CAAC,WAAW,GACtB,EAAE,CAAC,oBAAoB,GAAG,SAAS,CAGrC"}
|