@formspec/build 0.1.0-alpha.53 → 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/build-alpha.d.ts +40 -0
- package/dist/build-beta.d.ts +40 -0
- package/dist/build-internal.d.ts +40 -0
- package/dist/build.d.ts +40 -0
- package/dist/cli.cjs +14 -2
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +14 -2
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +14 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +14 -2
- package/dist/index.js.map +1 -1
- package/dist/internals.cjs +14 -2
- package/dist/internals.cjs.map +1 -1
- package/dist/internals.js +14 -2
- package/dist/internals.js.map +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"class-analyzer.d.ts","sourceRoot":"","sources":["../../src/analyzer/class-analyzer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAGL,KAAK,4BAA4B,EAElC,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EACV,SAAS,EACT,QAAQ,EAIR,cAAc,EAId,cAAc,EACd,SAAS,EACT,gBAAgB,EAEjB,MAAM,0BAA0B,CAAC;AAQlC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAUhE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAgC,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAkB7F,wBAAgB,mCAAmC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,GAAG,OAAO,CAclF;AA0ED;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,qEAAqE;IACrE,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAA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AAQ,CA2LV;AAinCD;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,kBAAkB;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,wBAAwB;IACxB,UAAU,EAAE,aAAa,EAAE,CAAC;IAC5B,uBAAuB;IACvB,cAAc,EAAE,EAAE,CAAC,QAAQ,GAAG,SAAS,CAAC;IACxC,2BAA2B;IAC3B,UAAU,EAAE,EAAE,CAAC,IAAI,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,qBAAqB;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,2BAA2B;IAC3B,QAAQ,EAAE,EAAE,CAAC,QAAQ,GAAG,SAAS,CAAC;IAClC,oBAAoB;IACpB,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC;IACd,0DAA0D;IAC1D,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,iEAAiE;IACjE,QAAQ,EAAE,OAAO,CAAC;CACnB"}
|
package/dist/build-alpha.d.ts
CHANGED
|
@@ -469,6 +469,46 @@ declare interface CustomTypeRegistration_2 {
|
|
|
469
469
|
* Note: `"__integerBrand"` is reserved for the builtin Integer type.
|
|
470
470
|
*/
|
|
471
471
|
readonly brand?: string;
|
|
472
|
+
/**
|
|
473
|
+
* Optional callback to extract a payload from the TypeScript type at
|
|
474
|
+
* analysis time. The returned value is stored on the custom type node
|
|
475
|
+
* and later passed to `toJsonSchema`.
|
|
476
|
+
*
|
|
477
|
+
* Use this to carry type-level information (e.g., a generic argument's
|
|
478
|
+
* resolved literal value) through the IR into schema generation.
|
|
479
|
+
*
|
|
480
|
+
* **Parameters:** typed as `unknown` because `@formspec/core` does not
|
|
481
|
+
* depend on the TypeScript compiler API. Implementations should cast to
|
|
482
|
+
* `ts.Type` and `ts.TypeChecker`. Both parameters originate from the
|
|
483
|
+
* host program's type checker — extensions may rely on host-program
|
|
484
|
+
* symbol identity.
|
|
485
|
+
*
|
|
486
|
+
* **Contract:**
|
|
487
|
+
* - Must be a pure function of `(type, checker)` — no I/O or shared state.
|
|
488
|
+
* - May be invoked multiple times for the same type (no memoization is provided).
|
|
489
|
+
* - Must return a JSON-serializable `ExtensionPayloadValue`. Returning live
|
|
490
|
+
* compiler objects (e.g., `ts.Type`) will corrupt any IR caching.
|
|
491
|
+
* - Errors thrown by the callback are attributed to the extension and
|
|
492
|
+
* reported as build diagnostics.
|
|
493
|
+
* - Returning `undefined` is coerced to `null` at the call site.
|
|
494
|
+
*
|
|
495
|
+
* @param type - The resolved TypeScript type (cast to `ts.Type`).
|
|
496
|
+
* @param checker - The TypeScript type checker (cast to `ts.TypeChecker`).
|
|
497
|
+
* @returns A JSON-serializable payload, or `null` if no payload can be extracted.
|
|
498
|
+
*
|
|
499
|
+
* @example
|
|
500
|
+
* ```typescript
|
|
501
|
+
* extractPayload: (type: unknown, checker: unknown) => {
|
|
502
|
+
* const tsType = type as ts.Type;
|
|
503
|
+
* const tsChecker = checker as ts.TypeChecker;
|
|
504
|
+
* const prop = tsType.getProperty('target');
|
|
505
|
+
* if (!prop) return null;
|
|
506
|
+
* const propType = tsChecker.getTypeOfSymbol(prop);
|
|
507
|
+
* return propType.isStringLiteral() ? propType.value : null;
|
|
508
|
+
* }
|
|
509
|
+
* ```
|
|
510
|
+
*/
|
|
511
|
+
readonly extractPayload?: (type: unknown, checker: unknown) => ExtensionPayloadValue;
|
|
472
512
|
/**
|
|
473
513
|
* Converts the custom type's payload into a JSON Schema fragment.
|
|
474
514
|
*
|
package/dist/build-beta.d.ts
CHANGED
|
@@ -469,6 +469,46 @@ declare interface CustomTypeRegistration_2 {
|
|
|
469
469
|
* Note: `"__integerBrand"` is reserved for the builtin Integer type.
|
|
470
470
|
*/
|
|
471
471
|
readonly brand?: string;
|
|
472
|
+
/**
|
|
473
|
+
* Optional callback to extract a payload from the TypeScript type at
|
|
474
|
+
* analysis time. The returned value is stored on the custom type node
|
|
475
|
+
* and later passed to `toJsonSchema`.
|
|
476
|
+
*
|
|
477
|
+
* Use this to carry type-level information (e.g., a generic argument's
|
|
478
|
+
* resolved literal value) through the IR into schema generation.
|
|
479
|
+
*
|
|
480
|
+
* **Parameters:** typed as `unknown` because `@formspec/core` does not
|
|
481
|
+
* depend on the TypeScript compiler API. Implementations should cast to
|
|
482
|
+
* `ts.Type` and `ts.TypeChecker`. Both parameters originate from the
|
|
483
|
+
* host program's type checker — extensions may rely on host-program
|
|
484
|
+
* symbol identity.
|
|
485
|
+
*
|
|
486
|
+
* **Contract:**
|
|
487
|
+
* - Must be a pure function of `(type, checker)` — no I/O or shared state.
|
|
488
|
+
* - May be invoked multiple times for the same type (no memoization is provided).
|
|
489
|
+
* - Must return a JSON-serializable `ExtensionPayloadValue`. Returning live
|
|
490
|
+
* compiler objects (e.g., `ts.Type`) will corrupt any IR caching.
|
|
491
|
+
* - Errors thrown by the callback are attributed to the extension and
|
|
492
|
+
* reported as build diagnostics.
|
|
493
|
+
* - Returning `undefined` is coerced to `null` at the call site.
|
|
494
|
+
*
|
|
495
|
+
* @param type - The resolved TypeScript type (cast to `ts.Type`).
|
|
496
|
+
* @param checker - The TypeScript type checker (cast to `ts.TypeChecker`).
|
|
497
|
+
* @returns A JSON-serializable payload, or `null` if no payload can be extracted.
|
|
498
|
+
*
|
|
499
|
+
* @example
|
|
500
|
+
* ```typescript
|
|
501
|
+
* extractPayload: (type: unknown, checker: unknown) => {
|
|
502
|
+
* const tsType = type as ts.Type;
|
|
503
|
+
* const tsChecker = checker as ts.TypeChecker;
|
|
504
|
+
* const prop = tsType.getProperty('target');
|
|
505
|
+
* if (!prop) return null;
|
|
506
|
+
* const propType = tsChecker.getTypeOfSymbol(prop);
|
|
507
|
+
* return propType.isStringLiteral() ? propType.value : null;
|
|
508
|
+
* }
|
|
509
|
+
* ```
|
|
510
|
+
*/
|
|
511
|
+
readonly extractPayload?: (type: unknown, checker: unknown) => ExtensionPayloadValue;
|
|
472
512
|
/**
|
|
473
513
|
* Converts the custom type's payload into a JSON Schema fragment.
|
|
474
514
|
*
|
package/dist/build-internal.d.ts
CHANGED
|
@@ -469,6 +469,46 @@ declare interface CustomTypeRegistration_2 {
|
|
|
469
469
|
* Note: `"__integerBrand"` is reserved for the builtin Integer type.
|
|
470
470
|
*/
|
|
471
471
|
readonly brand?: string;
|
|
472
|
+
/**
|
|
473
|
+
* Optional callback to extract a payload from the TypeScript type at
|
|
474
|
+
* analysis time. The returned value is stored on the custom type node
|
|
475
|
+
* and later passed to `toJsonSchema`.
|
|
476
|
+
*
|
|
477
|
+
* Use this to carry type-level information (e.g., a generic argument's
|
|
478
|
+
* resolved literal value) through the IR into schema generation.
|
|
479
|
+
*
|
|
480
|
+
* **Parameters:** typed as `unknown` because `@formspec/core` does not
|
|
481
|
+
* depend on the TypeScript compiler API. Implementations should cast to
|
|
482
|
+
* `ts.Type` and `ts.TypeChecker`. Both parameters originate from the
|
|
483
|
+
* host program's type checker — extensions may rely on host-program
|
|
484
|
+
* symbol identity.
|
|
485
|
+
*
|
|
486
|
+
* **Contract:**
|
|
487
|
+
* - Must be a pure function of `(type, checker)` — no I/O or shared state.
|
|
488
|
+
* - May be invoked multiple times for the same type (no memoization is provided).
|
|
489
|
+
* - Must return a JSON-serializable `ExtensionPayloadValue`. Returning live
|
|
490
|
+
* compiler objects (e.g., `ts.Type`) will corrupt any IR caching.
|
|
491
|
+
* - Errors thrown by the callback are attributed to the extension and
|
|
492
|
+
* reported as build diagnostics.
|
|
493
|
+
* - Returning `undefined` is coerced to `null` at the call site.
|
|
494
|
+
*
|
|
495
|
+
* @param type - The resolved TypeScript type (cast to `ts.Type`).
|
|
496
|
+
* @param checker - The TypeScript type checker (cast to `ts.TypeChecker`).
|
|
497
|
+
* @returns A JSON-serializable payload, or `null` if no payload can be extracted.
|
|
498
|
+
*
|
|
499
|
+
* @example
|
|
500
|
+
* ```typescript
|
|
501
|
+
* extractPayload: (type: unknown, checker: unknown) => {
|
|
502
|
+
* const tsType = type as ts.Type;
|
|
503
|
+
* const tsChecker = checker as ts.TypeChecker;
|
|
504
|
+
* const prop = tsType.getProperty('target');
|
|
505
|
+
* if (!prop) return null;
|
|
506
|
+
* const propType = tsChecker.getTypeOfSymbol(prop);
|
|
507
|
+
* return propType.isStringLiteral() ? propType.value : null;
|
|
508
|
+
* }
|
|
509
|
+
* ```
|
|
510
|
+
*/
|
|
511
|
+
readonly extractPayload?: (type: unknown, checker: unknown) => ExtensionPayloadValue;
|
|
472
512
|
/**
|
|
473
513
|
* Converts the custom type's payload into a JSON Schema fragment.
|
|
474
514
|
*
|
package/dist/build.d.ts
CHANGED
|
@@ -469,6 +469,46 @@ declare interface CustomTypeRegistration_2 {
|
|
|
469
469
|
* Note: `"__integerBrand"` is reserved for the builtin Integer type.
|
|
470
470
|
*/
|
|
471
471
|
readonly brand?: string;
|
|
472
|
+
/**
|
|
473
|
+
* Optional callback to extract a payload from the TypeScript type at
|
|
474
|
+
* analysis time. The returned value is stored on the custom type node
|
|
475
|
+
* and later passed to `toJsonSchema`.
|
|
476
|
+
*
|
|
477
|
+
* Use this to carry type-level information (e.g., a generic argument's
|
|
478
|
+
* resolved literal value) through the IR into schema generation.
|
|
479
|
+
*
|
|
480
|
+
* **Parameters:** typed as `unknown` because `@formspec/core` does not
|
|
481
|
+
* depend on the TypeScript compiler API. Implementations should cast to
|
|
482
|
+
* `ts.Type` and `ts.TypeChecker`. Both parameters originate from the
|
|
483
|
+
* host program's type checker — extensions may rely on host-program
|
|
484
|
+
* symbol identity.
|
|
485
|
+
*
|
|
486
|
+
* **Contract:**
|
|
487
|
+
* - Must be a pure function of `(type, checker)` — no I/O or shared state.
|
|
488
|
+
* - May be invoked multiple times for the same type (no memoization is provided).
|
|
489
|
+
* - Must return a JSON-serializable `ExtensionPayloadValue`. Returning live
|
|
490
|
+
* compiler objects (e.g., `ts.Type`) will corrupt any IR caching.
|
|
491
|
+
* - Errors thrown by the callback are attributed to the extension and
|
|
492
|
+
* reported as build diagnostics.
|
|
493
|
+
* - Returning `undefined` is coerced to `null` at the call site.
|
|
494
|
+
*
|
|
495
|
+
* @param type - The resolved TypeScript type (cast to `ts.Type`).
|
|
496
|
+
* @param checker - The TypeScript type checker (cast to `ts.TypeChecker`).
|
|
497
|
+
* @returns A JSON-serializable payload, or `null` if no payload can be extracted.
|
|
498
|
+
*
|
|
499
|
+
* @example
|
|
500
|
+
* ```typescript
|
|
501
|
+
* extractPayload: (type: unknown, checker: unknown) => {
|
|
502
|
+
* const tsType = type as ts.Type;
|
|
503
|
+
* const tsChecker = checker as ts.TypeChecker;
|
|
504
|
+
* const prop = tsType.getProperty('target');
|
|
505
|
+
* if (!prop) return null;
|
|
506
|
+
* const propType = tsChecker.getTypeOfSymbol(prop);
|
|
507
|
+
* return propType.isStringLiteral() ? propType.value : null;
|
|
508
|
+
* }
|
|
509
|
+
* ```
|
|
510
|
+
*/
|
|
511
|
+
readonly extractPayload?: (type: unknown, checker: unknown) => ExtensionPayloadValue;
|
|
472
512
|
/**
|
|
473
513
|
* Converts the custom type's payload into a JSON Schema fragment.
|
|
474
514
|
*
|
package/dist/cli.cjs
CHANGED
|
@@ -4440,10 +4440,22 @@ function resolveTypeNode(type, checker, file, typeRegistry, visiting, sourceNode
|
|
|
4440
4440
|
sourceNode
|
|
4441
4441
|
);
|
|
4442
4442
|
if (customTypeLookup !== null) {
|
|
4443
|
+
const typeId = customTypeIdFromLookup(customTypeLookup);
|
|
4444
|
+
let payload = null;
|
|
4445
|
+
if (customTypeLookup.registration.extractPayload !== void 0) {
|
|
4446
|
+
try {
|
|
4447
|
+
payload = customTypeLookup.registration.extractPayload(type, checker) ?? null;
|
|
4448
|
+
} catch (cause) {
|
|
4449
|
+
throw new Error(
|
|
4450
|
+
`extractPayload for custom type "${customTypeLookup.registration.typeName}" in extension "${customTypeLookup.extensionId}" threw`,
|
|
4451
|
+
{ cause }
|
|
4452
|
+
);
|
|
4453
|
+
}
|
|
4454
|
+
}
|
|
4443
4455
|
return {
|
|
4444
4456
|
kind: "custom",
|
|
4445
|
-
typeId
|
|
4446
|
-
payload
|
|
4457
|
+
typeId,
|
|
4458
|
+
payload
|
|
4447
4459
|
};
|
|
4448
4460
|
}
|
|
4449
4461
|
const primitiveAlias = tryResolveNamedPrimitiveAlias(
|