@defold-typescript/types 0.35.0 → 0.37.0
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/api-signatures.json +9406 -18
- package/examples/translations.json +11 -11
- package/generated/b2d.d.ts +1 -1
- package/generated/b2d_body.d.ts +6 -4
- package/generated/b2d_fixture.d.ts +6 -4
- package/generated/b2d_shape.d.ts +6 -4
- package/generated/factory.d.ts +11 -10
- package/generated/render.d.ts +5 -5
- package/generated/resource.d.ts +4 -4
- package/generated/sys.d.ts +2 -2
- package/generated/versions/defold-1.12.4/b2d.d.ts +1 -1
- package/generated/versions/defold-1.12.4/factory.d.ts +11 -10
- package/generated/versions/defold-1.12.4/render.d.ts +5 -5
- package/generated/versions/defold-1.12.4/resource.d.ts +4 -4
- package/generated/versions/defold-1.12.4/sys.d.ts +2 -2
- package/generated/versions/defold-1.12.4/window.d.ts +1 -1
- package/generated/versions/defold-1.12.4/zlib.d.ts +2 -1
- package/generated/versions/defold-1.13.0/b2d.d.ts +1 -1
- package/generated/versions/defold-1.13.0/b2d_body.d.ts +6 -4
- package/generated/versions/defold-1.13.0/b2d_fixture.d.ts +6 -4
- package/generated/versions/defold-1.13.0/b2d_shape.d.ts +6 -4
- package/generated/versions/defold-1.13.0/factory.d.ts +11 -10
- package/generated/versions/defold-1.13.0/render.d.ts +5 -5
- package/generated/versions/defold-1.13.0/resource.d.ts +4 -4
- package/generated/versions/defold-1.13.0/sys.d.ts +2 -2
- package/generated/versions/defold-1.13.0/window.d.ts +1 -1
- package/generated/versions/defold-1.13.0/zlib.d.ts +2 -1
- package/generated/window.d.ts +1 -1
- package/generated/zlib.d.ts +2 -1
- package/index.d.ts +1 -0
- package/package.json +5 -2
- package/scripts/generate-api-signatures.ts +33 -8
- package/src/emit-dts.ts +355 -71
- package/src/index.ts +1 -0
- package/src/render-overloads.d.ts +17 -0
- package/src/return-correction-provenance.ts +306 -0
|
@@ -28,7 +28,8 @@ declare global {
|
|
|
28
28
|
* @returns inflated buffer
|
|
29
29
|
* @example
|
|
30
30
|
* ```ts
|
|
31
|
-
* const data =
|
|
31
|
+
* const data =
|
|
32
|
+
* "\x78\x5e\x0b\xc9\xc8\x2c\x56\x00\xa2\x44\x85\xe2\x92\xa2\xcc\xbc\x74\x85\xf2\xcc\x92\x0c\x85\xd2\xbc\xe4\xfc\xdc\x82\xa2\xd4\xe2\xe2\xd4\x14\x85\x94\xc4\x92\x44\x3d\x00\x2c\x43\x0e\xc9";
|
|
32
33
|
* const uncompressed_data = zlib.inflate(data);
|
|
33
34
|
* print(uncompressed_data); //> This is a string with uncompressed data.
|
|
34
35
|
* ```
|
package/generated/window.d.ts
CHANGED
|
@@ -95,7 +95,7 @@ declare global {
|
|
|
95
95
|
*
|
|
96
96
|
* - number `inset_bottom`
|
|
97
97
|
*/
|
|
98
|
-
function get_safe_area(): {
|
|
98
|
+
function get_safe_area(): { x: number; y: number; width: number; height: number; inset_left: number; inset_top: number; inset_right: number; inset_bottom: number };
|
|
99
99
|
/**
|
|
100
100
|
* This returns the current window size (width and height).
|
|
101
101
|
*/
|
package/generated/zlib.d.ts
CHANGED
|
@@ -28,7 +28,8 @@ declare global {
|
|
|
28
28
|
* @returns inflated buffer
|
|
29
29
|
* @example
|
|
30
30
|
* ```ts
|
|
31
|
-
* const data =
|
|
31
|
+
* const data =
|
|
32
|
+
* "\x78\x5e\x0b\xc9\xc8\x2c\x56\x00\xa2\x44\x85\xe2\x92\xa2\xcc\xbc\x74\x85\xf2\xcc\x92\x0c\x85\xd2\xbc\xe4\xfc\xdc\x82\xa2\xd4\xe2\xe2\xd4\x14\x85\x94\xc4\x92\x44\x3d\x00\x2c\x43\x0e\xc9";
|
|
32
33
|
* const uncompressed_data = zlib.inflate(data);
|
|
33
34
|
* print(uncompressed_data); //> This is a string with uncompressed data.
|
|
34
35
|
* ```
|
package/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@defold-typescript/types",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.37.0",
|
|
4
4
|
"description": "TypeScript types for the Defold engine's Lua APIs.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -68,7 +68,10 @@
|
|
|
68
68
|
"!src/**/__snapshots__",
|
|
69
69
|
"!scripts/lua-types-signature-index.ts",
|
|
70
70
|
"!scripts/fidelity-audit.ts",
|
|
71
|
-
"!scripts/augmentation-namespaces.ts"
|
|
71
|
+
"!scripts/augmentation-namespaces.ts",
|
|
72
|
+
"!scripts/example-pins.ts",
|
|
73
|
+
"!scripts/example-surfaces.ts",
|
|
74
|
+
"!scripts/example-typecheck.ts"
|
|
72
75
|
],
|
|
73
76
|
"publishConfig": {
|
|
74
77
|
"access": "public"
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { resolve } from "node:path";
|
|
2
2
|
import { symbolIdentityKey } from "../src/api-availability";
|
|
3
|
+
import type { SlotTypes } from "../src/emit-dts";
|
|
3
4
|
import { selectCompleteVersionSurfaces, versionOf } from "./generate-api-availability";
|
|
4
5
|
import {
|
|
5
6
|
generateModuleSignatures,
|
|
@@ -15,6 +16,11 @@ const SIGNATURES_PATH = resolve(PACKAGE_ROOT, "api-signatures.json");
|
|
|
15
16
|
export interface SignaturesArtifact {
|
|
16
17
|
// version -> symbolIdentityKey -> authoritative TS signature text
|
|
17
18
|
readonly versions: Record<string, Record<string, string>>;
|
|
19
|
+
// The same axis and keys, carrying each documented slot's rendered type. Kept
|
|
20
|
+
// parallel rather than folded into `versions` because three consumers
|
|
21
|
+
// (`api-surface-loader`, `combined-surface`, `version-window`) type that map's
|
|
22
|
+
// value as a string; a symbol documenting no slot is absent here.
|
|
23
|
+
readonly slotTypes: Record<string, Record<string, SlotTypes>>;
|
|
18
24
|
}
|
|
19
25
|
|
|
20
26
|
export interface BuildSignaturesOptions {
|
|
@@ -51,9 +57,9 @@ export function withheldSymbols(entry: ModuleManifestEntry): { key: string; fqn:
|
|
|
51
57
|
return withheld;
|
|
52
58
|
}
|
|
53
59
|
|
|
54
|
-
function sortObjectKeys(record: Record<string,
|
|
55
|
-
const sorted: Record<string,
|
|
56
|
-
for (const key of Object.keys(record).sort()) sorted[key] = record[key] as
|
|
60
|
+
function sortObjectKeys<T>(record: Record<string, T>): Record<string, T> {
|
|
61
|
+
const sorted: Record<string, T> = {};
|
|
62
|
+
for (const key of Object.keys(record).sort()) sorted[key] = record[key] as T;
|
|
57
63
|
return sorted;
|
|
58
64
|
}
|
|
59
65
|
|
|
@@ -62,21 +68,33 @@ export function buildSignaturesArtifact(options: BuildSignaturesOptions = {}): S
|
|
|
62
68
|
const registryPath = options.registryPath ?? resolve(packageRoot, "api-targets.json");
|
|
63
69
|
const targets = selectCompleteVersionSurfaces(loadApiTargets(registryPath));
|
|
64
70
|
const versions: Record<string, Record<string, string>> = {};
|
|
71
|
+
const slotTypes: Record<string, Record<string, SlotTypes>> = {};
|
|
65
72
|
for (const target of targets) {
|
|
66
73
|
const version = versionOf(target);
|
|
67
74
|
const perSymbol: Record<string, string> = {};
|
|
75
|
+
const perSymbolSlots: Record<string, SlotTypes> = {};
|
|
68
76
|
for (const entry of loadTargetModules(target, packageRoot)) {
|
|
69
|
-
for (const
|
|
70
|
-
|
|
77
|
+
for (const signature of generateModuleSignatures(entry)) {
|
|
78
|
+
const key = symbolIdentityKey(signature.identity);
|
|
79
|
+
perSymbol[key] = signature.tsSignature;
|
|
80
|
+
if (Object.keys(signature.slotTypes).length > 0) {
|
|
81
|
+
perSymbolSlots[key] = sortObjectKeys({ ...signature.slotTypes });
|
|
82
|
+
}
|
|
71
83
|
}
|
|
84
|
+
// An authored fold replaces the declaration text wholesale, so whatever
|
|
85
|
+
// slots the generated emit had recorded no longer describe it.
|
|
72
86
|
for (const { key, fqn } of withheldSymbols(entry)) {
|
|
73
87
|
const authored = authoredSignature(packageRoot, entry.namespace, fqn);
|
|
74
|
-
if (authored !== null)
|
|
88
|
+
if (authored !== null) {
|
|
89
|
+
perSymbol[key] = authored;
|
|
90
|
+
delete perSymbolSlots[key];
|
|
91
|
+
}
|
|
75
92
|
}
|
|
76
93
|
}
|
|
77
94
|
versions[version] = sortObjectKeys(perSymbol);
|
|
95
|
+
slotTypes[version] = sortObjectKeys(perSymbolSlots);
|
|
78
96
|
}
|
|
79
|
-
return { versions };
|
|
97
|
+
return { versions, slotTypes };
|
|
80
98
|
}
|
|
81
99
|
|
|
82
100
|
function biomeFormatJson(raw: string): string {
|
|
@@ -86,7 +104,14 @@ function biomeFormatJson(raw: string): string {
|
|
|
86
104
|
if (out.exitCode !== 0) {
|
|
87
105
|
throw new Error(`biome format failed: ${out.stderr.toString()}`);
|
|
88
106
|
}
|
|
89
|
-
|
|
107
|
+
const formatted = out.stdout.toString();
|
|
108
|
+
// Biome exits 0 and emits nothing for input it declined to read (a payload over
|
|
109
|
+
// `files.maxSize` is reported only on stderr), which would otherwise serialize
|
|
110
|
+
// the artifact as an empty file.
|
|
111
|
+
if (formatted.length === 0) {
|
|
112
|
+
throw new Error(`biome format produced no output: ${out.stderr.toString()}`);
|
|
113
|
+
}
|
|
114
|
+
return formatted;
|
|
90
115
|
}
|
|
91
116
|
|
|
92
117
|
export function serializeSignaturesArtifact(artifact: SignaturesArtifact): string {
|