@defold-typescript/library-types 0.23.0 → 0.25.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/NOTICE +2 -3
- package/api-doc/boom.json +3872 -0
- package/api-doc/bridge.json +10 -5
- package/api-doc/bzAnim.json +338 -0
- package/api-doc/checkpoint.json +127 -0
- package/api-doc/decore.json +1 -1
- package/api-doc/defcon.json +150 -0
- package/api-doc/{defmath.defmath.json → defmath.json} +6 -46
- package/api-doc/defsave.json +518 -0
- package/api-doc/deftest.json +745 -0
- package/api-doc/{dicebag.dicebag.json → dicebag.json} +19 -1
- package/api-doc/druid.json +90 -92
- package/api-doc/event.json +16 -16
- package/api-doc/gooey.json +2050 -0
- package/api-doc/in.accelerometer.json +75 -1
- package/api-doc/in.button.json +17 -10
- package/api-doc/in.cursor.json +26 -0
- package/api-doc/in.gesture.json +401 -6
- package/api-doc/in.keyboard.json +2 -0
- package/api-doc/in.mapper.json +12 -8
- package/api-doc/in.onscreen.json +61 -5
- package/api-doc/in.state.json +61 -13
- package/api-doc/in.textbox.json +23 -12
- package/api-doc/in.triggers.json +336 -0
- package/api-doc/lang.json +5 -5
- package/api-doc/log.json +1 -1
- package/api-doc/metrics.fps.json +61 -2
- package/api-doc/metrics.mem.json +61 -2
- package/api-doc/monarch.monarch.json +249 -7
- package/api-doc/monarch.transitions.easings.json +19 -26
- package/api-doc/monarch.transitions.gui.json +782 -79
- package/api-doc/nakama.engine.defold.json +31 -18
- package/api-doc/{nakama.nakama.json → nakama.json} +4752 -2554
- package/api-doc/nakama.session.json +315 -0
- package/api-doc/nakama.socket.json +3356 -0
- package/api-doc/nakama.util.log.json +32 -4
- package/api-doc/narrator.json +1 -1
- package/api-doc/openapi/nakama.nakama.json +7680 -0
- package/api-doc/orthographic.camera.json +96 -98
- package/api-doc/orthographic.json +602 -0
- package/api-doc/panthera.json +1183 -0
- package/api-doc/{persist.persist.json → persist.json} +26 -1
- package/api-doc/{platypus.platypus.json → platypus.json} +68 -14
- package/api-doc/{rendy.rendy.json → rendy.json} +46 -99
- package/api-doc/richtext.color.json +77 -0
- package/api-doc/richtext.richtext.json +375 -5
- package/api-doc/saver.saver.json +2 -1
- package/api-doc/saver.storage.json +2 -1
- package/api-doc/shutter.json +551 -0
- package/api-doc/{yagames.yagames.json → yagames.json} +784 -189
- package/api-doc/{zzfx.api.json → zzfx.json} +9 -9
- package/authored-targets.json +433 -0
- package/generated/{boom.boom.d.ts → boom.d.ts} +14 -0
- package/generated/bridge.d.ts +5 -5
- package/generated/{bzAnim.bzLibrary.d.ts → bzAnim.d.ts} +6 -0
- package/generated/checkpoint.d.ts +62 -0
- package/generated/decore.d.ts +1 -1
- package/generated/defcon.d.ts +43 -0
- package/generated/{defmath.defmath.d.ts → defmath.d.ts} +3 -2
- package/generated/defsave.d.ts +144 -0
- package/generated/{dicebag.dicebag.d.ts → dicebag.d.ts} +25 -0
- package/generated/druid.d.ts +81 -79
- package/generated/event.d.ts +15 -15
- package/generated/{gooey.gooey.d.ts → gooey.d.ts} +61 -6
- package/generated/in.onscreen.d.ts +5 -0
- package/generated/in.textbox.d.ts +4 -0
- package/generated/lang.d.ts +5 -5
- package/generated/log.d.ts +1 -1
- package/generated/metrics.fps.d.ts +19 -1
- package/generated/metrics.mem.d.ts +19 -1
- package/generated/monarch.monarch.d.ts +44 -1
- package/generated/monarch.transitions.easings.d.ts +0 -1
- package/generated/monarch.transitions.gui.d.ts +96 -12
- package/generated/nakama.d.ts +1158 -0
- package/generated/nakama.engine.defold.d.ts +3 -1
- package/generated/nakama.session.d.ts +95 -0
- package/generated/nakama.socket.d.ts +706 -0
- package/generated/nakama.util.log.d.ts +6 -0
- package/generated/narrator.d.ts +1 -1
- package/generated/openapi/nakama.nakama.d.ts +884 -0
- package/generated/orthographic.camera.d.ts +24 -38
- package/generated/orthographic.d.ts +155 -0
- package/generated/panthera.d.ts +170 -0
- package/generated/{persist.persist.d.ts → persist.d.ts} +3 -0
- package/generated/{platypus.platypus.d.ts → platypus.d.ts} +9 -0
- package/generated/proto.d.ts +4 -4
- package/generated/{rendy.rendy.d.ts → rendy.d.ts} +33 -80
- package/generated/richtext.color.d.ts +15 -0
- package/generated/saver.saver.d.ts +2 -0
- package/generated/saver.storage.d.ts +2 -0
- package/generated/shutter.d.ts +183 -0
- package/generated/{yagames.yagames.d.ts → yagames.d.ts} +151 -29
- package/generated/{zzfx.api.d.ts → zzfx.d.ts} +7 -0
- package/library-classification.json +0 -156
- package/library-targets.json +1 -218
- package/luals-targets.json +56 -3
- package/openapi-targets.json +17 -0
- package/package.json +7 -57
- package/scripts/__snapshots__/parse-luals.test.ts.snap +164 -10
- package/scripts/apply-luals-overrides.ts +39 -7
- package/scripts/authored-parity.ts +718 -0
- package/scripts/emit-library-dts.ts +94 -17
- package/scripts/extract-api-doc.ts +214 -42
- package/scripts/fidelity-floor.ts +178 -0
- package/scripts/import-upstream-docs.ts +125 -0
- package/scripts/lower-api-doc.ts +21 -3
- package/scripts/luals-fidelity.ts +16 -11
- package/scripts/map-luals-types.ts +52 -21
- package/scripts/parse-lua-surface.ts +187 -0
- package/scripts/parse-luals.ts +50 -4
- package/scripts/parse-markdown-api.ts +247 -0
- package/scripts/parse-openapi-api.ts +313 -0
- package/scripts/sync-authored-types.ts +249 -0
- package/scripts/sync-library-types.ts +99 -3
- package/scripts/sync-luals-types.ts +14 -1
- package/scripts/sync-markdown-types.ts +761 -0
- package/scripts/sync-openapi-types.ts +308 -0
- package/scripts/sync-script-api-types.ts +16 -17
- package/api-doc/boom.boom.json +0 -26
- package/api-doc/bzAnim.bzLibrary.json +0 -156
- package/api-doc/defcon.console.json +0 -109
- package/api-doc/defsave.defsave.json +0 -175
- package/api-doc/deftest.deftest.json +0 -71
- package/api-doc/gooey.gooey.json +0 -963
- package/api-doc/starly.starly.json +0 -488
- package/generated/defcon.console.d.ts +0 -24
- package/generated/defsave.defsave.d.ts +0 -31
- package/generated/nakama.nakama.d.ts +0 -594
- package/generated/starly.starly.d.ts +0 -148
- /package/generated/{deftest.deftest.d.ts → deftest.d.ts} +0 -0
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import type { FidelityReport } from "./luals-fidelity";
|
|
4
|
+
import { type OpenApiDoc, parseOpenApi } from "./parse-openapi-api";
|
|
5
|
+
import {
|
|
6
|
+
computeScriptApiFidelity,
|
|
7
|
+
type FetchText,
|
|
8
|
+
loadTypeResolver,
|
|
9
|
+
type ScriptApiDoc,
|
|
10
|
+
type TypeResolver,
|
|
11
|
+
} from "./sync-script-api-types";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The OpenAPI/proto ingestion front-end: a fifth `library-types` corpus mode
|
|
15
|
+
* beside the LuaLS front-end (`sync-luals-types.ts`), the `.script_api` front-end
|
|
16
|
+
* (`sync-script-api-types.ts`), the markdown front-end (`sync-markdown-types.ts`),
|
|
17
|
+
* and the authored `.d.ts` lane. It reads a library's pinned REST swagger + realtime
|
|
18
|
+
* `.proto` snapshot (`parseOpenApi`) into the shared ref-doc `doc` shape and routes
|
|
19
|
+
* it through the same emitter (`generateModuleDeclaration`) and fidelity machinery.
|
|
20
|
+
*
|
|
21
|
+
* The swagger/proto name no publish alias, so the parsed doc carries bare element
|
|
22
|
+
* names; each target pins the `namespace` this repo publishes under, and the doc is
|
|
23
|
+
* *retargeted* — the bare names are prefixed onto that namespace — before emitting.
|
|
24
|
+
*
|
|
25
|
+
* A structured-source parse is likely **lower coverage** than the hand-written
|
|
26
|
+
* ts-defold `.d.ts` it would replace (a REST swagger cannot describe a Lua client's
|
|
27
|
+
* hand-written helpers or its realtime socket wrappers), so each cutover is gated:
|
|
28
|
+
* `compareFidelityToTsDefold` reports the member surface lost versus the retired
|
|
29
|
+
* ts-defold declaration, and the target's recorded `decision` (`go` / `no-go`) must
|
|
30
|
+
* match. The parser + front-end land as the reusable foundation either way; only
|
|
31
|
+
* the per-library cutover is gated. The gate helpers are shared verbatim with the
|
|
32
|
+
* markdown lane rather than re-implemented.
|
|
33
|
+
*/
|
|
34
|
+
export {
|
|
35
|
+
compareFidelityToTsDefold,
|
|
36
|
+
type FidelityComparison,
|
|
37
|
+
tsDefoldMembers,
|
|
38
|
+
tsDefoldSurface,
|
|
39
|
+
} from "./sync-markdown-types";
|
|
40
|
+
|
|
41
|
+
export interface OpenApiTarget {
|
|
42
|
+
repo: string;
|
|
43
|
+
ref: string;
|
|
44
|
+
swagger: string;
|
|
45
|
+
proto: string;
|
|
46
|
+
moduleId: string;
|
|
47
|
+
namespace: string;
|
|
48
|
+
generated: string;
|
|
49
|
+
apiDoc: string;
|
|
50
|
+
// Defaults to `fidelity/<namespace>.json` when omitted.
|
|
51
|
+
fidelity: string;
|
|
52
|
+
// SPDX-style license id, surfaced by the docs-site provenance block. Optional
|
|
53
|
+
// in the config; defaults to "".
|
|
54
|
+
license: string;
|
|
55
|
+
// The recorded fidelity go/no-go decision for this target. `no-go` keeps the
|
|
56
|
+
// library ts-defold-sourced; `go` cuts it over. Optional until the gate runs.
|
|
57
|
+
decision?: "go" | "no-go";
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface OpenApiTargets {
|
|
61
|
+
targets: OpenApiTarget[];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const REQUIRED_FIELDS = [
|
|
65
|
+
"repo",
|
|
66
|
+
"ref",
|
|
67
|
+
"swagger",
|
|
68
|
+
"proto",
|
|
69
|
+
"moduleId",
|
|
70
|
+
"namespace",
|
|
71
|
+
"generated",
|
|
72
|
+
"apiDoc",
|
|
73
|
+
] as const;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Read `openapi-targets.json` (or an in-memory override), validate every required
|
|
77
|
+
* field per entry, and fill optional defaults (`fidelity` → `fidelity/<namespace>.json`,
|
|
78
|
+
* `license` → ""). Throws on the first missing field naming both the field and the
|
|
79
|
+
* offending entry (its `moduleId`, or its index when `moduleId` itself is absent) —
|
|
80
|
+
* the loud-fail discipline `readMarkdownTargets`/`readLualsTargets` use. No network.
|
|
81
|
+
*/
|
|
82
|
+
export function readOpenApiTargets(packageRoot: string, rawOverride?: string): OpenApiTarget[] {
|
|
83
|
+
const raw = rawOverride ?? readFileSync(join(packageRoot, "openapi-targets.json"), "utf8");
|
|
84
|
+
const parsed = JSON.parse(raw) as { targets: Partial<OpenApiTarget>[] };
|
|
85
|
+
return parsed.targets.map((entry, index) => {
|
|
86
|
+
const label = typeof entry.moduleId === "string" ? entry.moduleId : `index ${index}`;
|
|
87
|
+
for (const field of REQUIRED_FIELDS) {
|
|
88
|
+
if (entry[field] === undefined) {
|
|
89
|
+
throw new Error(
|
|
90
|
+
`openapi-targets.json: entry ${label} is missing required field "${field}".`,
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
repo: entry.repo as string,
|
|
96
|
+
ref: entry.ref as string,
|
|
97
|
+
swagger: entry.swagger as string,
|
|
98
|
+
proto: entry.proto as string,
|
|
99
|
+
moduleId: entry.moduleId as string,
|
|
100
|
+
namespace: entry.namespace as string,
|
|
101
|
+
generated: entry.generated as string,
|
|
102
|
+
apiDoc: entry.apiDoc as string,
|
|
103
|
+
fidelity: entry.fidelity ?? `fidelity/${entry.namespace as string}.json`,
|
|
104
|
+
license: entry.license ?? "",
|
|
105
|
+
...(entry.decision !== undefined ? { decision: entry.decision } : {}),
|
|
106
|
+
};
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** A GitHub repo URL reduced to the bare `<owner>/<repo>` slug. */
|
|
111
|
+
function repoSlug(repo: string): string {
|
|
112
|
+
return repo
|
|
113
|
+
.replace(/^https:\/\/github\.com\//, "")
|
|
114
|
+
.replace(/\.git$/, "")
|
|
115
|
+
.replace(/\/$/, "");
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function rawUrl(target: OpenApiTarget, path: string): string {
|
|
119
|
+
return `https://raw.githubusercontent.com/${repoSlug(target.repo)}/${target.ref}/${path}`;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function swaggerFixturePath(packageRoot: string, target: OpenApiTarget): string {
|
|
123
|
+
return join(packageRoot, "fixtures/openapi", `${target.moduleId}.swagger.json`);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function protoFixturePath(packageRoot: string, target: OpenApiTarget): string {
|
|
127
|
+
return join(packageRoot, "fixtures/openapi", `${target.moduleId}.api.proto`);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Snapshot the pinned swagger + realtime `.proto` into `fixtures/openapi/` via the
|
|
132
|
+
* raw-content URL. Snapshot only — no parse. The `fetchText` seam keeps the pass
|
|
133
|
+
* offline-testable; only the CLI `--fetch` arm wires the real network.
|
|
134
|
+
*/
|
|
135
|
+
export async function fetchOpenApiFixtures(
|
|
136
|
+
packageRoot: string,
|
|
137
|
+
target: OpenApiTarget,
|
|
138
|
+
seams: { fetchText: FetchText },
|
|
139
|
+
): Promise<void> {
|
|
140
|
+
for (const [path, dest] of [
|
|
141
|
+
[target.swagger, swaggerFixturePath(packageRoot, target)],
|
|
142
|
+
[target.proto, protoFixturePath(packageRoot, target)],
|
|
143
|
+
] as const) {
|
|
144
|
+
const text = await seams.fetchText(rawUrl(target, path));
|
|
145
|
+
mkdirSync(dirname(dest), { recursive: true });
|
|
146
|
+
writeFileSync(dest, text);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
interface RegenModule {
|
|
151
|
+
generateModuleDeclaration: (entry: {
|
|
152
|
+
namespace: string;
|
|
153
|
+
doc: unknown;
|
|
154
|
+
outFile: string;
|
|
155
|
+
importsFrom?: string;
|
|
156
|
+
moduleId?: string;
|
|
157
|
+
}) => { contents: string; dropped: string[] };
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// nakama's structured surface resolves to `string`/`number`/`boolean`/`table`
|
|
161
|
+
// only, so the module-wrapped form never emits a core-types handle and this import
|
|
162
|
+
// never reaches the golden; it mirrors the sibling front-ends for the day an
|
|
163
|
+
// openapi target references a branded engine handle.
|
|
164
|
+
const OPENAPI_CORE_TYPES_IMPORT = "../src/core-types";
|
|
165
|
+
|
|
166
|
+
async function loadGenerate(
|
|
167
|
+
packageRoot: string,
|
|
168
|
+
): Promise<RegenModule["generateModuleDeclaration"]> {
|
|
169
|
+
const typesRoot = join(packageRoot, "..", "types");
|
|
170
|
+
const regen = (await import(join(typesRoot, "scripts", "regen.ts"))) as RegenModule;
|
|
171
|
+
return regen.generateModuleDeclaration;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function parseFixtureDoc(packageRoot: string, target: OpenApiTarget): OpenApiDoc {
|
|
175
|
+
const swagger = readFileSync(swaggerFixturePath(packageRoot, target), "utf8");
|
|
176
|
+
const proto = readFileSync(protoFixturePath(packageRoot, target), "utf8");
|
|
177
|
+
return parseOpenApi(swagger, proto);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Retarget the parsed doc onto the pinned publish namespace: prefix each bare
|
|
182
|
+
* element name with `<namespace>.` and set `info.namespace`. Unlike the markdown
|
|
183
|
+
* lane (which replaces the README's own alias), the swagger/proto names carry no
|
|
184
|
+
* prefix, so retargeting *prepends* rather than rewrites.
|
|
185
|
+
*/
|
|
186
|
+
export function retargetDoc(doc: OpenApiDoc, namespace: string): OpenApiDoc {
|
|
187
|
+
return {
|
|
188
|
+
info: { ...doc.info, namespace },
|
|
189
|
+
elements: doc.elements.map((element) => ({
|
|
190
|
+
...element,
|
|
191
|
+
name: element.name.includes(".") ? element.name : `${namespace}.${element.name}`,
|
|
192
|
+
})),
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function retargetedFixtureDoc(packageRoot: string, target: OpenApiTarget): OpenApiDoc {
|
|
197
|
+
return retargetDoc(parseFixtureDoc(packageRoot, target), target.namespace);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* `parseOpenApi` -> retarget -> `generateModuleDeclaration`. Returns an importable
|
|
202
|
+
* module keyed by `moduleId` (`declare module '<moduleId>'`).
|
|
203
|
+
*/
|
|
204
|
+
export async function emitOpenApiDeclaration(
|
|
205
|
+
packageRoot: string,
|
|
206
|
+
target: OpenApiTarget,
|
|
207
|
+
): Promise<string> {
|
|
208
|
+
const generate = await loadGenerate(packageRoot);
|
|
209
|
+
const doc = retargetedFixtureDoc(packageRoot, target);
|
|
210
|
+
const { contents } = generate({
|
|
211
|
+
namespace: target.namespace,
|
|
212
|
+
doc,
|
|
213
|
+
outFile: `${target.moduleId}.d.ts`,
|
|
214
|
+
importsFrom: OPENAPI_CORE_TYPES_IMPORT,
|
|
215
|
+
moduleId: target.moduleId,
|
|
216
|
+
});
|
|
217
|
+
return contents;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/** The api-doc golden is the retargeted ref-doc `doc` itself, pretty-printed. */
|
|
221
|
+
export function lowerOpenApiApiDoc(packageRoot: string, target: OpenApiTarget): string {
|
|
222
|
+
const doc = retargetedFixtureDoc(packageRoot, target);
|
|
223
|
+
return `${JSON.stringify(doc, null, 2)}\n`;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// The OpenAPI parser maps every swagger/proto type onto a resolvable token, so no
|
|
227
|
+
// token is expected to be lossy. The set stays empty and any unresolved token
|
|
228
|
+
// loud-fails — a brand-new source's unclassified token must not be swallowed as
|
|
229
|
+
// `unknown` at regen time. Mirror of the markdown lane's `KNOWN_LOSSY_TOKENS`.
|
|
230
|
+
const KNOWN_LOSSY_TOKENS = new Set<string>();
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* openapi-scoped wrapper over the shared `computeScriptApiFidelity`. After the
|
|
234
|
+
* report is built, any `unknownToken` outside `KNOWN_LOSSY_TOKENS` loud-fails. The
|
|
235
|
+
* shared `computeScriptApiFidelity` is left untouched so the script_api/luals/markdown
|
|
236
|
+
* goldens stay green.
|
|
237
|
+
*/
|
|
238
|
+
export function computeOpenApiFidelity(
|
|
239
|
+
namespace: string,
|
|
240
|
+
doc: OpenApiDoc,
|
|
241
|
+
resolver: TypeResolver,
|
|
242
|
+
): FidelityReport {
|
|
243
|
+
const report = computeScriptApiFidelity(namespace, doc as unknown as ScriptApiDoc, resolver);
|
|
244
|
+
const unmappable = report.unknownTokens.filter((token) => !KNOWN_LOSSY_TOKENS.has(token));
|
|
245
|
+
if (unmappable.length > 0) {
|
|
246
|
+
throw new Error(
|
|
247
|
+
`openapi fidelity [${namespace}]: unmappable type token(s) ${JSON.stringify(unmappable)} — resolve them or add to KNOWN_LOSSY_TOKENS`,
|
|
248
|
+
);
|
|
249
|
+
}
|
|
250
|
+
return report;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
export async function buildOpenApiFidelity(
|
|
254
|
+
packageRoot: string,
|
|
255
|
+
target: OpenApiTarget,
|
|
256
|
+
): Promise<FidelityReport> {
|
|
257
|
+
const resolver = await loadTypeResolver(packageRoot);
|
|
258
|
+
const doc = retargetedFixtureDoc(packageRoot, target);
|
|
259
|
+
return computeOpenApiFidelity(target.namespace, doc, resolver);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
const defaultFetchText: FetchText = async (url) => {
|
|
263
|
+
const res = await fetch(url);
|
|
264
|
+
if (!res.ok) {
|
|
265
|
+
throw new Error(`fetch failed: ${url} -> ${res.status} ${res.statusText}`);
|
|
266
|
+
}
|
|
267
|
+
return res.text();
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
if (import.meta.main) {
|
|
271
|
+
const root = join(import.meta.dir, "..");
|
|
272
|
+
const argv = process.argv.slice(2);
|
|
273
|
+
if (argv.includes("--fetch")) {
|
|
274
|
+
for (const target of readOpenApiTargets(root)) {
|
|
275
|
+
await fetchOpenApiFixtures(root, target, { fetchText: defaultFetchText });
|
|
276
|
+
console.log(`snapshotted ${target.moduleId} from ${repoSlug(target.repo)}@${target.ref}`);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
if (argv.includes("--emit")) {
|
|
280
|
+
for (const target of readOpenApiTargets(root)) {
|
|
281
|
+
const contents = await emitOpenApiDeclaration(root, target);
|
|
282
|
+
const dest = join(root, target.generated);
|
|
283
|
+
mkdirSync(dirname(dest), { recursive: true });
|
|
284
|
+
writeFileSync(dest, contents);
|
|
285
|
+
console.log(`emitted ${target.moduleId} -> ${target.generated}`);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
if (argv.includes("--api-doc")) {
|
|
289
|
+
for (const target of readOpenApiTargets(root)) {
|
|
290
|
+
const json = lowerOpenApiApiDoc(root, target);
|
|
291
|
+
const dest = join(root, target.apiDoc);
|
|
292
|
+
mkdirSync(dirname(dest), { recursive: true });
|
|
293
|
+
writeFileSync(dest, json);
|
|
294
|
+
console.log(`lowered ${target.moduleId} -> ${target.apiDoc}`);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
if (argv.includes("--fidelity")) {
|
|
298
|
+
for (const target of readOpenApiTargets(root)) {
|
|
299
|
+
const report = await buildOpenApiFidelity(root, target);
|
|
300
|
+
const dest = join(root, target.fidelity);
|
|
301
|
+
mkdirSync(dirname(dest), { recursive: true });
|
|
302
|
+
writeFileSync(dest, `${JSON.stringify(report, null, 2)}\n`);
|
|
303
|
+
console.log(
|
|
304
|
+
`${target.moduleId}: coverage ${(report.coverage * 100).toFixed(1)}% (${report.unknownFallbacks} unknown, ${report.undocumentedMembers} undocumented)`,
|
|
305
|
+
);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
@@ -12,9 +12,11 @@ import type { FidelityReport } from "./luals-fidelity";
|
|
|
12
12
|
*
|
|
13
13
|
* Each target pins its exact output paths. Like the LuaLS libraries, a migrated
|
|
14
14
|
* script_api library is the sole maintainer of its namespace, so its goldens are
|
|
15
|
-
* named for the
|
|
16
|
-
* `api-doc
|
|
17
|
-
*
|
|
15
|
+
* named for the target's `namespace` verbatim (`generated/<namespace>.d.ts`,
|
|
16
|
+
* `api-doc/<namespace>.json`, `fidelity/<namespace>.json` — so `bridge` lands at
|
|
17
|
+
* `generated/bridge.d.ts` and `api-doc/bridge.json`) at the canonical roots,
|
|
18
|
+
* rather than the require `moduleId`, keeping the docs tree and file layout
|
|
19
|
+
* uniform with druid.
|
|
18
20
|
*/
|
|
19
21
|
export interface ScriptApiTarget {
|
|
20
22
|
repo: string;
|
|
@@ -158,10 +160,7 @@ interface RegenModule {
|
|
|
158
160
|
|
|
159
161
|
interface EmitDtsModule {
|
|
160
162
|
recoverCallbackSignature: (token: string) => string | null;
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
interface CoreTypesModule {
|
|
164
|
-
DEFOLD_TYPE_MAP: Readonly<Record<string, string>>;
|
|
163
|
+
isKnownDefoldTypeToken: (token: string) => boolean;
|
|
165
164
|
}
|
|
166
165
|
|
|
167
166
|
interface TypesModules {
|
|
@@ -181,24 +180,24 @@ const SCRIPT_API_CORE_TYPES_IMPORT = "../src/core-types";
|
|
|
181
180
|
* the sibling `@defold-typescript/types` package by resolved path, mirroring
|
|
182
181
|
* `extension-emit.ts`'s `loadEmitter`: `scriptApiToFixtureJson` (YAML -> ref-doc
|
|
183
182
|
* JSON) and `generateModuleDeclaration` live in the types package's `scripts/`,
|
|
184
|
-
* `recoverCallbackSignature`/`
|
|
185
|
-
* build script (never shipped), so the sibling `../types` path is
|
|
183
|
+
* `recoverCallbackSignature`/`isKnownDefoldTypeToken` in its `src/`. This is a
|
|
184
|
+
* repo-only build script (never shipped), so the sibling `../types` path is
|
|
185
|
+
* sufficient.
|
|
186
186
|
*
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
* so fidelity mirrors the emitter's real output
|
|
190
|
-
*
|
|
187
|
+
* Resolution delegates to the emitter's own exported `isKnownDefoldTypeToken` —
|
|
188
|
+
* the predicate the engine-release importer already trusts — rather than
|
|
189
|
+
* re-deriving it here, so fidelity mirrors the emitter's real output. That
|
|
190
|
+
* includes `nil`, which is absent from `DEFOLD_TYPE_MAP` because the emitter
|
|
191
|
+
* lowers it structurally (parameter-side optionality, return-side `undefined`)
|
|
192
|
+
* rather than by lookup.
|
|
191
193
|
*/
|
|
192
194
|
async function loadTypesModules(packageRoot: string): Promise<TypesModules> {
|
|
193
195
|
const typesRoot = join(packageRoot, "..", "types");
|
|
194
196
|
const sync = (await import(join(typesRoot, "scripts", "sync-api-docs.ts"))) as SyncApiDocsModule;
|
|
195
197
|
const regen = (await import(join(typesRoot, "scripts", "regen.ts"))) as RegenModule;
|
|
196
198
|
const emitDts = (await import(join(typesRoot, "src", "emit-dts.ts"))) as EmitDtsModule;
|
|
197
|
-
const core = (await import(join(typesRoot, "src", "core-types.ts"))) as CoreTypesModule;
|
|
198
199
|
const resolver: TypeResolver = {
|
|
199
|
-
resolves: (token) =>
|
|
200
|
-
Object.hasOwn(core.DEFOLD_TYPE_MAP, token) ||
|
|
201
|
-
emitDts.recoverCallbackSignature(token) !== null,
|
|
200
|
+
resolves: (token) => emitDts.isKnownDefoldTypeToken(token),
|
|
202
201
|
};
|
|
203
202
|
return {
|
|
204
203
|
scriptApiToFixtureJson: sync.scriptApiToFixtureJson,
|
package/api-doc/boom.boom.json
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"info": {
|
|
3
|
-
"namespace": "boom.boom",
|
|
4
|
-
"brief": "Boom is a game framework built on top of Defold.",
|
|
5
|
-
"description": "Boom is a game framework built on top of Defold."
|
|
6
|
-
},
|
|
7
|
-
"elements": [
|
|
8
|
-
{
|
|
9
|
-
"type": "FUNCTION",
|
|
10
|
-
"name": "boom",
|
|
11
|
-
"brief": "Start a boom game. Call this from your own game script",
|
|
12
|
-
"description": "Start a boom game. Call this from your own game script",
|
|
13
|
-
"parameters": [
|
|
14
|
-
{
|
|
15
|
-
"name": "game",
|
|
16
|
-
"doc": "Game loop function",
|
|
17
|
-
"types": [
|
|
18
|
-
"() => void"
|
|
19
|
-
],
|
|
20
|
-
"is_optional": "False"
|
|
21
|
-
}
|
|
22
|
-
],
|
|
23
|
-
"returnvalues": []
|
|
24
|
-
}
|
|
25
|
-
]
|
|
26
|
-
}
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"info": {
|
|
3
|
-
"namespace": "bzAnim.bzLibrary",
|
|
4
|
-
"brief": "",
|
|
5
|
-
"description": ""
|
|
6
|
-
},
|
|
7
|
-
"elements": [
|
|
8
|
-
{
|
|
9
|
-
"type": "VARIABLE",
|
|
10
|
-
"name": "INFO_LEVEL",
|
|
11
|
-
"types": []
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
"type": "VARIABLE",
|
|
15
|
-
"name": "DEBUG_LEVEL",
|
|
16
|
-
"types": []
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
"type": "VARIABLE",
|
|
20
|
-
"name": "TRACE_LEVEL",
|
|
21
|
-
"types": []
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
"type": "TYPEDEF",
|
|
25
|
-
"name": "Path"
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
"type": "TYPEDEF",
|
|
29
|
-
"name": "Segment"
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
"type": "TYPEDEF",
|
|
33
|
-
"name": "AnimateArgs"
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
"type": "TYPEDEF",
|
|
37
|
-
"name": "AnimateSequenceArgs"
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
"type": "FUNCTION",
|
|
41
|
-
"name": "animate",
|
|
42
|
-
"brief": "",
|
|
43
|
-
"description": "",
|
|
44
|
-
"parameters": [
|
|
45
|
-
{
|
|
46
|
-
"name": "args",
|
|
47
|
-
"doc": "",
|
|
48
|
-
"types": [
|
|
49
|
-
"AnimateArgs"
|
|
50
|
-
],
|
|
51
|
-
"is_optional": "False"
|
|
52
|
-
}
|
|
53
|
-
],
|
|
54
|
-
"returnvalues": [
|
|
55
|
-
{
|
|
56
|
-
"name": "",
|
|
57
|
-
"doc": "",
|
|
58
|
-
"types": [
|
|
59
|
-
"string"
|
|
60
|
-
]
|
|
61
|
-
}
|
|
62
|
-
]
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
"type": "FUNCTION",
|
|
66
|
-
"name": "animateSequence",
|
|
67
|
-
"brief": "",
|
|
68
|
-
"description": "",
|
|
69
|
-
"parameters": [
|
|
70
|
-
{
|
|
71
|
-
"name": "args",
|
|
72
|
-
"doc": "",
|
|
73
|
-
"types": [
|
|
74
|
-
"AnimateSequenceArgs"
|
|
75
|
-
],
|
|
76
|
-
"is_optional": "False"
|
|
77
|
-
}
|
|
78
|
-
],
|
|
79
|
-
"returnvalues": [
|
|
80
|
-
{
|
|
81
|
-
"name": "",
|
|
82
|
-
"doc": "",
|
|
83
|
-
"types": [
|
|
84
|
-
"string"
|
|
85
|
-
]
|
|
86
|
-
}
|
|
87
|
-
]
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
"type": "FUNCTION",
|
|
91
|
-
"name": "cancel",
|
|
92
|
-
"brief": "",
|
|
93
|
-
"description": "",
|
|
94
|
-
"parameters": [
|
|
95
|
-
{
|
|
96
|
-
"name": "id",
|
|
97
|
-
"doc": "",
|
|
98
|
-
"types": [
|
|
99
|
-
"string"
|
|
100
|
-
],
|
|
101
|
-
"is_optional": "False"
|
|
102
|
-
}
|
|
103
|
-
],
|
|
104
|
-
"returnvalues": []
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
"type": "FUNCTION",
|
|
108
|
-
"name": "info",
|
|
109
|
-
"brief": "",
|
|
110
|
-
"description": "",
|
|
111
|
-
"parameters": [],
|
|
112
|
-
"returnvalues": [
|
|
113
|
-
{
|
|
114
|
-
"name": "",
|
|
115
|
-
"doc": "",
|
|
116
|
-
"types": [
|
|
117
|
-
"string"
|
|
118
|
-
]
|
|
119
|
-
}
|
|
120
|
-
]
|
|
121
|
-
},
|
|
122
|
-
{
|
|
123
|
-
"type": "FUNCTION",
|
|
124
|
-
"name": "isReady",
|
|
125
|
-
"brief": "",
|
|
126
|
-
"description": "",
|
|
127
|
-
"parameters": [],
|
|
128
|
-
"returnvalues": [
|
|
129
|
-
{
|
|
130
|
-
"name": "",
|
|
131
|
-
"doc": "",
|
|
132
|
-
"types": [
|
|
133
|
-
"boolean"
|
|
134
|
-
]
|
|
135
|
-
}
|
|
136
|
-
]
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
"type": "FUNCTION",
|
|
140
|
-
"name": "setDebugLevel",
|
|
141
|
-
"brief": "",
|
|
142
|
-
"description": "",
|
|
143
|
-
"parameters": [
|
|
144
|
-
{
|
|
145
|
-
"name": "level",
|
|
146
|
-
"doc": "",
|
|
147
|
-
"types": [
|
|
148
|
-
"number"
|
|
149
|
-
],
|
|
150
|
-
"is_optional": "False"
|
|
151
|
-
}
|
|
152
|
-
],
|
|
153
|
-
"returnvalues": []
|
|
154
|
-
}
|
|
155
|
-
]
|
|
156
|
-
}
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"info": {
|
|
3
|
-
"namespace": "defcon.console",
|
|
4
|
-
"brief": "",
|
|
5
|
-
"description": ""
|
|
6
|
-
},
|
|
7
|
-
"elements": [
|
|
8
|
-
{
|
|
9
|
-
"type": "FUNCTION",
|
|
10
|
-
"name": "start",
|
|
11
|
-
"brief": "",
|
|
12
|
-
"description": "",
|
|
13
|
-
"parameters": [
|
|
14
|
-
{
|
|
15
|
-
"name": "port",
|
|
16
|
-
"doc": "",
|
|
17
|
-
"types": [
|
|
18
|
-
"number"
|
|
19
|
-
],
|
|
20
|
-
"is_optional": "False"
|
|
21
|
-
}
|
|
22
|
-
],
|
|
23
|
-
"returnvalues": []
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
"type": "FUNCTION",
|
|
27
|
-
"name": "stop",
|
|
28
|
-
"brief": "",
|
|
29
|
-
"description": "",
|
|
30
|
-
"parameters": [],
|
|
31
|
-
"returnvalues": []
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
"type": "FUNCTION",
|
|
35
|
-
"name": "update",
|
|
36
|
-
"brief": "",
|
|
37
|
-
"description": "",
|
|
38
|
-
"parameters": [],
|
|
39
|
-
"returnvalues": []
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
"type": "FUNCTION",
|
|
43
|
-
"name": "register_module",
|
|
44
|
-
"brief": "",
|
|
45
|
-
"description": "",
|
|
46
|
-
"parameters": [
|
|
47
|
-
{
|
|
48
|
-
"name": "module",
|
|
49
|
-
"doc": "",
|
|
50
|
-
"types": [
|
|
51
|
-
"unknown"
|
|
52
|
-
],
|
|
53
|
-
"is_optional": "False"
|
|
54
|
-
}
|
|
55
|
-
],
|
|
56
|
-
"returnvalues": []
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
"type": "FUNCTION",
|
|
60
|
-
"name": "register_command",
|
|
61
|
-
"brief": "",
|
|
62
|
-
"description": "",
|
|
63
|
-
"parameters": [
|
|
64
|
-
{
|
|
65
|
-
"name": "command",
|
|
66
|
-
"doc": "",
|
|
67
|
-
"types": [
|
|
68
|
-
"string"
|
|
69
|
-
],
|
|
70
|
-
"is_optional": "False"
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
"name": "description",
|
|
74
|
-
"doc": "",
|
|
75
|
-
"types": [
|
|
76
|
-
"string"
|
|
77
|
-
],
|
|
78
|
-
"is_optional": "False"
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
"name": "callback",
|
|
82
|
-
"doc": "",
|
|
83
|
-
"types": [
|
|
84
|
-
"CommandCallback"
|
|
85
|
-
],
|
|
86
|
-
"is_optional": "False"
|
|
87
|
-
}
|
|
88
|
-
],
|
|
89
|
-
"returnvalues": []
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
"type": "FUNCTION",
|
|
93
|
-
"name": "set_environment",
|
|
94
|
-
"brief": "",
|
|
95
|
-
"description": "",
|
|
96
|
-
"parameters": [
|
|
97
|
-
{
|
|
98
|
-
"name": "env",
|
|
99
|
-
"doc": "",
|
|
100
|
-
"types": [
|
|
101
|
-
"unknown"
|
|
102
|
-
],
|
|
103
|
-
"is_optional": "False"
|
|
104
|
-
}
|
|
105
|
-
],
|
|
106
|
-
"returnvalues": []
|
|
107
|
-
}
|
|
108
|
-
]
|
|
109
|
-
}
|