@defold-typescript/types 0.19.4 → 0.20.1
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-availability.json +2755 -0
- package/api-migrations.json +31 -0
- package/api-signatures.json +2324 -0
- package/api-targets.json +493 -45
- package/generated/b2d.d.ts +6 -0
- package/generated/b2d_body.d.ts +329 -1
- package/generated/b2d_chain.d.ts +106 -0
- package/generated/b2d_fixture.d.ts +155 -0
- package/generated/b2d_joint.d.ts +823 -0
- package/generated/b2d_shape.d.ts +215 -0
- package/generated/b2d_world.d.ts +314 -0
- package/generated/buffer.d.ts +1 -1
- package/generated/builtin-messages.d.ts +18 -0
- package/generated/camera.d.ts +62 -5
- package/generated/compute.d.ts +306 -0
- package/generated/crash.d.ts +2 -2
- package/generated/go.d.ts +31 -6
- package/generated/graphics.d.ts +95 -0
- package/generated/gui.d.ts +4 -6
- package/generated/image.d.ts +3 -3
- package/generated/json.d.ts +2 -2
- package/generated/kinds/gui-script.d.ts +7 -0
- package/generated/kinds/render-script.d.ts +7 -0
- package/generated/kinds/script.d.ts +7 -0
- package/generated/label.d.ts +1 -1
- package/generated/liveupdate.d.ts +22 -4
- package/generated/material.d.ts +444 -0
- package/generated/model.d.ts +46 -5
- package/generated/physics.d.ts +2 -4
- package/generated/profiler.d.ts +2 -3
- package/generated/render.d.ts +25 -9
- package/generated/resource.d.ts +2 -2
- package/generated/socket.d.ts +35 -35
- package/generated/sprite.d.ts +15 -1
- package/generated/sys.d.ts +1 -1
- package/generated/tilemap.d.ts +14 -0
- package/generated/timer.d.ts +1 -1
- package/generated/versions/defold-1.12.4/b2d.d.ts +27 -0
- package/generated/versions/defold-1.12.4/b2d_body.d.ts +348 -0
- package/generated/versions/defold-1.12.4/buffer.d.ts +176 -0
- package/generated/versions/defold-1.12.4/camera.d.ts +245 -0
- package/generated/versions/defold-1.12.4/collectionfactory.d.ts +146 -0
- package/generated/versions/defold-1.12.4/collectionproxy.d.ts +71 -0
- package/generated/versions/defold-1.12.4/crash.d.ts +143 -0
- package/generated/versions/defold-1.12.4/factory.d.ts +123 -0
- package/generated/versions/defold-1.12.4/font.d.ts +81 -0
- package/generated/versions/defold-1.12.4/go.d.ts +1029 -0
- package/generated/versions/defold-1.12.4/graphics.d.ts +226 -0
- package/generated/versions/defold-1.12.4/gui.d.ts +2372 -0
- package/generated/versions/defold-1.12.4/html5.d.ts +53 -0
- package/generated/versions/defold-1.12.4/http.d.ts +84 -0
- package/generated/versions/defold-1.12.4/iac.d.ts +18 -0
- package/generated/versions/defold-1.12.4/iap.d.ts +60 -0
- package/generated/versions/defold-1.12.4/image.d.ts +139 -0
- package/generated/versions/defold-1.12.4/index.d.ts +41 -0
- package/generated/versions/defold-1.12.4/json.d.ts +76 -0
- package/generated/versions/defold-1.12.4/label.d.ts +94 -0
- package/generated/versions/defold-1.12.4/liveupdate.d.ts +122 -0
- package/generated/versions/defold-1.12.4/model.d.ts +205 -0
- package/generated/versions/defold-1.12.4/msg.d.ts +10 -0
- package/generated/versions/defold-1.12.4/particlefx.d.ts +166 -0
- package/generated/versions/defold-1.12.4/physics.d.ts +547 -0
- package/generated/versions/defold-1.12.4/profiler.d.ts +234 -0
- package/generated/versions/defold-1.12.4/push.d.ts +66 -0
- package/generated/versions/defold-1.12.4/render.d.ts +1149 -0
- package/generated/versions/defold-1.12.4/resource.d.ts +1518 -0
- package/generated/versions/defold-1.12.4/socket.d.ts +795 -0
- package/generated/versions/defold-1.12.4/sound.d.ts +291 -0
- package/generated/versions/defold-1.12.4/sprite.d.ts +143 -0
- package/generated/versions/defold-1.12.4/sys.d.ts +695 -0
- package/generated/versions/defold-1.12.4/tilemap.d.ts +181 -0
- package/generated/versions/defold-1.12.4/timer.d.ts +114 -0
- package/generated/versions/defold-1.12.4/types.d.ts +61 -0
- package/generated/versions/defold-1.12.4/vmath.d.ts +806 -0
- package/generated/versions/defold-1.12.4/webview.d.ts +68 -0
- package/generated/versions/defold-1.12.4/window.d.ts +198 -0
- package/generated/versions/defold-1.12.4/zlib.d.ts +40 -0
- package/index.d.ts +22 -0
- package/package.json +8 -1
- package/scripts/fidelity-audit.ts +69 -12
- package/scripts/fidelity-baseline.json +56 -0
- package/scripts/generate-api-availability.ts +139 -0
- package/scripts/generate-api-signatures.ts +66 -0
- package/scripts/import-defold-release.ts +480 -0
- package/scripts/materialize-version.ts +45 -20
- package/scripts/regen.ts +53 -6
- package/scripts/sync-api-docs.ts +89 -41
- package/src/api-availability.ts +0 -0
- package/src/core-types.ts +9 -0
- package/src/emit-dts.ts +685 -17
- package/src/emit-messages.ts +72 -2
- package/src/index.ts +26 -1
- package/src/lifecycle.ts +43 -2
|
@@ -31,8 +31,7 @@ export function renderMaterializedKindIndex(opts: RenderMaterializedKindIndexOpt
|
|
|
31
31
|
return `${LUA_STDLIB_REFERENCES}${lines.join("\n")}\n\nexport { ${entry.factory} } from "@defold-typescript/types/lifecycle";\nexport type { ScriptProperties, ScriptProperty } from "@defold-typescript/types/lifecycle";\n`;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
export interface
|
|
35
|
-
readonly destDir: string;
|
|
34
|
+
export interface BuildVersionedSurfaceOptions {
|
|
36
35
|
readonly resolveOpts?: ResolveTargetOptions;
|
|
37
36
|
// Bare module names (no `.d.ts`) to omit from the surface — both the emitted
|
|
38
37
|
// file and its aggregate-index import. Lets a caller narrow the surface to a
|
|
@@ -40,35 +39,61 @@ export interface MaterializeVersionedSurfaceOptions {
|
|
|
40
39
|
readonly excludeModules?: readonly string[];
|
|
41
40
|
}
|
|
42
41
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
42
|
+
export interface MaterializeVersionedSurfaceOptions extends BuildVersionedSurfaceOptions {
|
|
43
|
+
readonly destDir: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface VersionedSurfaceFile {
|
|
47
|
+
// Relative to the surface root, so a sink can write it to disk or key it in
|
|
48
|
+
// object storage without rewriting the path.
|
|
49
|
+
readonly path: string;
|
|
50
|
+
readonly contents: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Generate a versioned surface as an in-memory file map: resolve the target's
|
|
54
|
+
// module docs (ref-doc or committed fixture), emit each module declaration, then
|
|
55
|
+
// the aggregate side-effect entrypoint and a minimal package.json. Pure — no
|
|
56
|
+
// `node:fs` — so a Worker with no filesystem can serve a version generated at
|
|
57
|
+
// request time; `materializeVersionedSurface` is the disk sink over the same map.
|
|
58
|
+
export async function buildVersionedSurfaceFiles(
|
|
49
59
|
target: ApiTarget,
|
|
50
|
-
opts:
|
|
51
|
-
): Promise<
|
|
60
|
+
opts: BuildVersionedSurfaceOptions = {},
|
|
61
|
+
): Promise<VersionedSurfaceFile[]> {
|
|
52
62
|
const exclude = new Set(opts.excludeModules ?? []);
|
|
53
63
|
const modules = (await resolveTargetModules(target, opts.resolveOpts ?? {})).filter(
|
|
54
64
|
(entry) => !exclude.has(entry.outFile.replace(/\.d\.ts$/, "")),
|
|
55
65
|
);
|
|
56
|
-
mkdirSync(opts.destDir, { recursive: true });
|
|
57
66
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
67
|
+
const files: VersionedSurfaceFile[] = modules.map((entry) => ({
|
|
68
|
+
path: entry.outFile,
|
|
69
|
+
contents: generateModuleDeclaration(entry).contents,
|
|
70
|
+
}));
|
|
62
71
|
|
|
63
72
|
const versioned = modules.map((entry) => ({ ...entry, versionId: target.id }));
|
|
64
|
-
|
|
73
|
+
files.push({ path: "index.d.ts", contents: generateVersionIndex(target.id, versioned) });
|
|
65
74
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
`${JSON.stringify(
|
|
75
|
+
files.push({
|
|
76
|
+
path: "package.json",
|
|
77
|
+
contents: `${JSON.stringify(
|
|
69
78
|
{ name: `@defold-typescript/materialized-${target.id}`, types: "index.d.ts" },
|
|
70
79
|
null,
|
|
71
80
|
2,
|
|
72
81
|
)}\n`,
|
|
73
|
-
);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
return files;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Write the generated surface into a project-local faux `@types` package.
|
|
88
|
+
// ref-doc targets are never pre-baked, so this is the only path that turns a
|
|
89
|
+
// resolved version into a consumable on-disk type surface.
|
|
90
|
+
export async function materializeVersionedSurface(
|
|
91
|
+
target: ApiTarget,
|
|
92
|
+
opts: MaterializeVersionedSurfaceOptions,
|
|
93
|
+
): Promise<void> {
|
|
94
|
+
const files = await buildVersionedSurfaceFiles(target, opts);
|
|
95
|
+
mkdirSync(opts.destDir, { recursive: true });
|
|
96
|
+
for (const file of files) {
|
|
97
|
+
writeFileSync(resolve(opts.destDir, file.path), file.contents);
|
|
98
|
+
}
|
|
74
99
|
}
|
package/scripts/regen.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
2
|
import { resolve } from "node:path";
|
|
3
3
|
import messagesDoc from "../fixtures/messages_doc.json" with { type: "json" };
|
|
4
|
-
import { parseDefoldApiDoc } from "../src/api-doc";
|
|
5
|
-
import { emitDeclarations } from "../src/emit-dts";
|
|
6
|
-
import {
|
|
4
|
+
import { type ApiModule, parseDefoldApiDoc } from "../src/api-doc";
|
|
5
|
+
import { emitDeclarations, emitSymbolSignatures, type SymbolSignature } from "../src/emit-dts";
|
|
6
|
+
import {
|
|
7
|
+
applyMessageDeprecations,
|
|
8
|
+
emitBuiltinMessages,
|
|
9
|
+
parseMessagesDoc,
|
|
10
|
+
} from "../src/emit-messages";
|
|
7
11
|
import type { TranslationStore } from "../src/example-store";
|
|
8
12
|
import { wrapAsAmbientGlobal } from "../src/publish-dts";
|
|
9
13
|
import {
|
|
@@ -143,6 +147,15 @@ const DEFAULT_TARGET = API_TARGETS.find((t) => t.default === true) as ApiTarget;
|
|
|
143
147
|
|
|
144
148
|
export const MODULE_MANIFEST: readonly ModuleManifestEntry[] = loadTargetModules(DEFAULT_TARGET);
|
|
145
149
|
|
|
150
|
+
// The fidelity audit runs over the promoted default surface (the `default: true`
|
|
151
|
+
// target) so the 1.13-only modules (b2d.*, compute, material) and the 1.13 model
|
|
152
|
+
// additions are audited too — auditing the older 1.12.4 target left them unseen,
|
|
153
|
+
// which is how the promoted surface shipped opaque `Record` fallbacks while the
|
|
154
|
+
// gate read `recordTables: 0`.
|
|
155
|
+
const FIDELITY_BASELINE_TARGET = DEFAULT_TARGET;
|
|
156
|
+
export const FIDELITY_BASELINE_MANIFEST: readonly ModuleManifestEntry[] =
|
|
157
|
+
loadTargetModules(FIDELITY_BASELINE_TARGET);
|
|
158
|
+
|
|
146
159
|
export interface MessagesManifestEntry {
|
|
147
160
|
readonly doc: unknown;
|
|
148
161
|
readonly outFile: string;
|
|
@@ -158,7 +171,7 @@ export const MESSAGES_MANIFEST: MessagesManifestEntry = {
|
|
|
158
171
|
};
|
|
159
172
|
|
|
160
173
|
export function generateBuiltinMessagesDeclaration(entry: MessagesManifestEntry): string {
|
|
161
|
-
return emitBuiltinMessages(parseMessagesDoc(entry.doc));
|
|
174
|
+
return emitBuiltinMessages(applyMessageDeprecations(parseMessagesDoc(entry.doc)));
|
|
162
175
|
}
|
|
163
176
|
|
|
164
177
|
export interface GenerateResult {
|
|
@@ -185,10 +198,21 @@ export interface GenerateOptions {
|
|
|
185
198
|
translations?: TranslationStore;
|
|
186
199
|
}
|
|
187
200
|
|
|
188
|
-
|
|
201
|
+
interface PreparedGeneratedModule {
|
|
202
|
+
module: ApiModule;
|
|
203
|
+
knownConstantFqns: ReadonlySet<string>;
|
|
204
|
+
translations: TranslationStore;
|
|
205
|
+
dropped: string[];
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// Parse a manifest entry, apply its `skipFunctions` filter, and resolve the
|
|
209
|
+
// shared constant-brand universe and translations. Both the `.d.ts` emit and
|
|
210
|
+
// the authoritative-signature emit run off this identical prepared module, so a
|
|
211
|
+
// dropped member never appears in either surface.
|
|
212
|
+
function prepareGeneratedModule(
|
|
189
213
|
entry: ModuleManifestEntry,
|
|
190
214
|
options?: GenerateOptions,
|
|
191
|
-
):
|
|
215
|
+
): PreparedGeneratedModule {
|
|
192
216
|
const module = parseDefoldApiDoc(entry.doc);
|
|
193
217
|
const prefix = `${module.namespace}.`;
|
|
194
218
|
const dropped: string[] = [];
|
|
@@ -203,6 +227,17 @@ export function generateModuleDeclaration(
|
|
|
203
227
|
});
|
|
204
228
|
const knownConstantFqns = options?.knownConstantFqns ?? collectConstantFqns();
|
|
205
229
|
const translations = options?.translations ?? loadTranslations();
|
|
230
|
+
return { module, knownConstantFqns, translations, dropped };
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export function generateModuleDeclaration(
|
|
234
|
+
entry: ModuleManifestEntry,
|
|
235
|
+
options?: GenerateOptions,
|
|
236
|
+
): GenerateResult {
|
|
237
|
+
const { module, knownConstantFqns, translations, dropped } = prepareGeneratedModule(
|
|
238
|
+
entry,
|
|
239
|
+
options,
|
|
240
|
+
);
|
|
206
241
|
const emitted = emitDeclarations(module, { knownConstantFqns, translations });
|
|
207
242
|
const contents = wrapAsAmbientGlobal({
|
|
208
243
|
namespace: module.namespace,
|
|
@@ -212,6 +247,18 @@ export function generateModuleDeclaration(
|
|
|
212
247
|
return { contents, dropped };
|
|
213
248
|
}
|
|
214
249
|
|
|
250
|
+
// The authoritative per-symbol signatures for a manifest entry, rendered through
|
|
251
|
+
// the same prepared module (skip filter + constant branding) as
|
|
252
|
+
// `generateModuleDeclaration`, so every signature corresponds to the committed
|
|
253
|
+
// `.d.ts` byte-for-byte.
|
|
254
|
+
export function generateModuleSignatures(
|
|
255
|
+
entry: ModuleManifestEntry,
|
|
256
|
+
options?: GenerateOptions,
|
|
257
|
+
): SymbolSignature[] {
|
|
258
|
+
const { module, knownConstantFqns } = prepareGeneratedModule(entry, options);
|
|
259
|
+
return emitSymbolSignatures(module, { knownConstantFqns });
|
|
260
|
+
}
|
|
261
|
+
|
|
215
262
|
export interface VersionedModuleManifestEntry extends ModuleManifestEntry {
|
|
216
263
|
readonly versionId: string;
|
|
217
264
|
}
|
package/scripts/sync-api-docs.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { DEFOLD_TYPE_MAP } from "../src/core-types";
|
|
|
6
6
|
import { parseScriptApi } from "../src/script-api";
|
|
7
7
|
import { MODULE_MANIFEST } from "./regen";
|
|
8
8
|
|
|
9
|
-
export const DEFOLD_VERSION = "1.
|
|
9
|
+
export const DEFOLD_VERSION = "1.13.0";
|
|
10
10
|
export const refDocUrl = (version = DEFOLD_VERSION): string =>
|
|
11
11
|
`https://github.com/defold/defold/releases/download/${version}/ref-doc.zip`;
|
|
12
12
|
|
|
@@ -26,52 +26,71 @@ export interface SyncManifestEntry {
|
|
|
26
26
|
// so each path is confirmed against the pinned release artifact, not derived.
|
|
27
27
|
export const SYNC_MANIFEST: readonly SyncManifestEntry[] = [
|
|
28
28
|
entry("b2d", "doc/scripts-box2d-script_box2d.cpp_doc.json"),
|
|
29
|
-
//
|
|
30
|
-
//
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
29
|
+
// Box2D 1.13.0 documents the v2 and v3 backends separately. On-disk dotted
|
|
30
|
+
// namespaces use underscores while the namespace itself stays dotted.
|
|
31
|
+
entry("b2d.body", "doc/scripts-box2d-v2-script_box2d_body_v2.cpp_doc.json", undefined, [
|
|
32
|
+
"doc/scripts-box2d-v3-script_box2d_body_v3.cpp_doc.json",
|
|
33
|
+
]),
|
|
34
|
+
entry("b2d.chain", "doc/scripts-box2d-v3-script_box2d_chain_v3.cpp_doc.json"),
|
|
35
|
+
entry("b2d.fixture", "doc/scripts-box2d-v2-script_box2d_fixture_v2.cpp_doc.json"),
|
|
36
|
+
entry("b2d.joint", "doc/scripts-box2d-v2-script_box2d_joint_v2.cpp_doc.json", undefined, [
|
|
37
|
+
"doc/scripts-box2d-v3-script_box2d_joint_v3.cpp_doc.json",
|
|
38
|
+
]),
|
|
39
|
+
entry("b2d.shape", "doc/scripts-box2d-v2-script_box2d_shape_v2.cpp_doc.json", undefined, [
|
|
40
|
+
"doc/scripts-box2d-v3-script_box2d_shape_v3.cpp_doc.json",
|
|
41
|
+
]),
|
|
42
|
+
entry("b2d.world", "doc/scripts-box2d-v2-script_box2d_world_v2.cpp_doc.json", undefined, [
|
|
43
|
+
"doc/scripts-box2d-v3-script_box2d_world_v3.cpp_doc.json",
|
|
44
|
+
]),
|
|
38
45
|
entry("buffer", "doc/scripts-script_buffer.cpp_doc.json"),
|
|
39
|
-
//
|
|
40
|
-
//
|
|
41
|
-
entry("camera", "doc/
|
|
46
|
+
// Camera and component namespaces merge their DDF messages/properties into
|
|
47
|
+
// the callable script API so release snapshots retain every declared symbol.
|
|
48
|
+
entry("camera", "doc/gamesys-camera_ddf.proto_doc.json", undefined, [
|
|
49
|
+
"doc/render-render_script_camera.cpp_doc.json",
|
|
50
|
+
]),
|
|
42
51
|
entry("collectionfactory", "doc/scripts-script_collection_factory.cpp_doc.json"),
|
|
43
52
|
entry("collectionproxy", "doc/scripts-script_collectionproxy.cpp_doc.json"),
|
|
53
|
+
entry("compute", "doc/scripts-script_compute.cpp_doc.json"),
|
|
44
54
|
entry("crash", "doc/script_crash.cpp_doc.json"),
|
|
45
55
|
entry("factory", "doc/scripts-script_factory.cpp_doc.json"),
|
|
46
56
|
entry("font", "doc/scripts-script_font.cpp_doc.json"),
|
|
47
|
-
entry("go", "doc/
|
|
57
|
+
entry("go", "doc/gameobject-gameobject_ddf.proto_doc.json", undefined, [
|
|
58
|
+
"doc/gameobject_script.cpp_doc.json",
|
|
59
|
+
]),
|
|
48
60
|
entry("graphics", "doc/src-script_graphics.cpp_doc.json"),
|
|
49
|
-
entry("gui", "doc/gui_script.cpp_doc.json"),
|
|
61
|
+
entry("gui", "doc/gamesys-gui_ddf.proto_doc.json", undefined, ["doc/gui_script.cpp_doc.json"]),
|
|
50
62
|
entry("html5", "doc/src-script_html5_js.cpp_doc.json"),
|
|
51
63
|
entry("http", "doc/scripts-script_http.cpp_doc.json"),
|
|
52
64
|
entry("image", "doc/scripts-script_image.cpp_doc.json"),
|
|
53
65
|
entry("json", "doc/src-script_json.cpp_doc.json"),
|
|
54
|
-
entry("label", "doc/
|
|
66
|
+
entry("label", "doc/gamesys-label_ddf.proto_doc.json", undefined, [
|
|
67
|
+
"doc/scripts-script_label.cpp_doc.json",
|
|
68
|
+
]),
|
|
55
69
|
entry("liveupdate", "doc/src-script_liveupdate.h_doc.json"),
|
|
56
|
-
entry("
|
|
70
|
+
entry("material", "doc/scripts-script_material.cpp_doc.json"),
|
|
71
|
+
entry("model", "doc/gamesys-model_ddf.proto_doc.json", undefined, [
|
|
72
|
+
"doc/scripts-script_model.cpp_doc.json",
|
|
73
|
+
]),
|
|
57
74
|
entry("msg", "doc/src-script_msg.cpp_doc.json"),
|
|
58
75
|
entry("particlefx", "doc/scripts-script_particlefx.cpp_doc.json"),
|
|
59
|
-
entry("physics", "doc/
|
|
76
|
+
entry("physics", "doc/gamesys-physics_ddf.proto_doc.json", undefined, [
|
|
77
|
+
"doc/scripts-script_physics.cpp_doc.json",
|
|
78
|
+
]),
|
|
60
79
|
entry("profiler", "doc/profiler.cpp_doc.json"),
|
|
61
|
-
entry("render", "doc/render-
|
|
80
|
+
entry("render", "doc/render-render_ddf.proto_doc.json", undefined, [
|
|
81
|
+
"doc/render-render_script.cpp_doc.json",
|
|
82
|
+
]),
|
|
62
83
|
entry("resource", "doc/scripts-script_resource.cpp_doc.json"),
|
|
63
84
|
entry("socket", "doc/luasocket-luasocket.doc_h_doc.json"),
|
|
64
85
|
entry("sound", "doc/scripts-script_sound.cpp_doc.json"),
|
|
65
|
-
entry("sprite", "doc/
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
//
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
// and owned by the builtin-messages catalog.
|
|
72
|
-
entry("sys", "doc/src-script_sys.cpp_doc.json", "fixtures/sys_doc.json", [
|
|
86
|
+
entry("sprite", "doc/gamesys-sprite_ddf.proto_doc.json", undefined, [
|
|
87
|
+
"doc/scripts-script_sprite.cpp_doc.json",
|
|
88
|
+
]),
|
|
89
|
+
// The sys surface spans core, gamesys, engine, and DDF documents in 1.13.0.
|
|
90
|
+
entry("sys", "doc/script-script_engine.cpp_doc.json", undefined, [
|
|
91
|
+
"doc/script-sys_ddf.proto_doc.json",
|
|
73
92
|
"doc/scripts-script_sys_gamesys.cpp_doc.json",
|
|
74
|
-
"doc/
|
|
93
|
+
"doc/src-script_sys.cpp_doc.json",
|
|
75
94
|
]),
|
|
76
95
|
entry("tilemap", "doc/scripts-script_tilemap.cpp_doc.json"),
|
|
77
96
|
entry("timer", "doc/src-script_timer.cpp_doc.json"),
|
|
@@ -118,7 +137,7 @@ export const IGNORED_UPSTREAM: ReadonlyMap<string, string> = new Map([
|
|
|
118
137
|
export const LUA_STDLIB_MANIFEST: readonly SyncManifestEntry[] = [
|
|
119
138
|
entry("base", "doc/lua_base.doc_h_doc.json"),
|
|
120
139
|
entry("bit", "doc/src-script_bitop.cpp_doc.json"),
|
|
121
|
-
// Core Lua stdlib docs. The 1.
|
|
140
|
+
// Core Lua stdlib docs. The 1.13.0 release names these `doc/lua_<ns>.doc_h_doc.json`
|
|
122
141
|
// (confirmed against the pinned ref-doc.zip, not derived — the naming drifted from
|
|
123
142
|
// the 1.9.8 `doc/<ns>_doc.json` form). Typed by the lua-types dependency, so docs-only.
|
|
124
143
|
entry("math", "doc/lua_math.doc_h_doc.json"),
|
|
@@ -127,7 +146,7 @@ export const LUA_STDLIB_MANIFEST: readonly SyncManifestEntry[] = [
|
|
|
127
146
|
entry("table", "doc/lua_table.doc_h_doc.json"),
|
|
128
147
|
entry("coroutine", "doc/lua_coroutine.doc_h_doc.json"),
|
|
129
148
|
// Sandboxed-runtime stdlib surfaces. Defold sandboxes the Lua VM, but the pinned
|
|
130
|
-
// 1.
|
|
149
|
+
// 1.13.0 ref-doc.zip documents all three with real function elements; types stay
|
|
131
150
|
// owned by lua-types (core/{debug,io}.d.ts + core/modules.d.ts for `package`).
|
|
132
151
|
entry("debug", "doc/lua_debug.doc_h_doc.json"),
|
|
133
152
|
entry("io", "doc/lua_io.doc_h_doc.json"),
|
|
@@ -137,7 +156,7 @@ export const LUA_STDLIB_MANIFEST: readonly SyncManifestEntry[] = [
|
|
|
137
156
|
function entry(
|
|
138
157
|
namespace: string,
|
|
139
158
|
zipEntry: string,
|
|
140
|
-
fixture: string = `fixtures/${namespace}_doc.json`,
|
|
159
|
+
fixture: string = `fixtures/defold-1.13.0/${namespace.replace(/\./g, "_")}_doc.json`,
|
|
141
160
|
mergeEntries?: readonly string[],
|
|
142
161
|
): SyncManifestEntry {
|
|
143
162
|
return { namespace, zipEntry, fixture, ...(mergeEntries ? { mergeEntries } : {}) };
|
|
@@ -163,7 +182,13 @@ export const EXTENSION_MANIFEST: readonly ExtensionManifestEntry[] = [
|
|
|
163
182
|
];
|
|
164
183
|
|
|
165
184
|
function ext(namespace: string, repo: string, tag: string, path: string): ExtensionManifestEntry {
|
|
166
|
-
return {
|
|
185
|
+
return {
|
|
186
|
+
namespace,
|
|
187
|
+
repo,
|
|
188
|
+
tag,
|
|
189
|
+
path,
|
|
190
|
+
fixture: `fixtures/defold-1.13.0/${namespace}_doc.json`,
|
|
191
|
+
};
|
|
167
192
|
}
|
|
168
193
|
|
|
169
194
|
export const extensionRawUrl = (e: ExtensionManifestEntry): string =>
|
|
@@ -249,22 +274,20 @@ function isRecord(value: unknown): value is Record<string, unknown> {
|
|
|
249
274
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
250
275
|
}
|
|
251
276
|
|
|
252
|
-
// Concatenate the `elements` of every doc into the first doc, deduping
|
|
253
|
-
//
|
|
254
|
-
//
|
|
255
|
-
//
|
|
256
|
-
// result is still parseable by `parseDefoldApiDoc`.
|
|
277
|
+
// Concatenate the `elements` of every doc into the first doc, deduping exact
|
|
278
|
+
// API signatures with first occurrence winning, and keep the first doc's
|
|
279
|
+
// `info`. Function signatures include parameters and returns because the same
|
|
280
|
+
// namespace can expose backend-specific overloads under one function name.
|
|
257
281
|
export function mergeApiDocs(docs: readonly unknown[]): unknown {
|
|
258
282
|
const first = docs[0];
|
|
259
283
|
const seen = new Set<string>();
|
|
260
284
|
const elements: unknown[] = [];
|
|
261
285
|
for (const doc of docs) {
|
|
262
286
|
if (!isRecord(doc) || !Array.isArray(doc.elements)) continue;
|
|
287
|
+
const info = isRecord(doc.info) ? doc.info : null;
|
|
288
|
+
const namespace = info && typeof info.namespace === "string" ? info.namespace : "";
|
|
263
289
|
for (const element of doc.elements) {
|
|
264
|
-
const key =
|
|
265
|
-
isRecord(element) && typeof element.name === "string" && typeof element.type === "string"
|
|
266
|
-
? `${element.type}${element.name}`
|
|
267
|
-
: null;
|
|
290
|
+
const key = apiElementIdentity(namespace, element);
|
|
268
291
|
if (key !== null) {
|
|
269
292
|
if (seen.has(key)) continue;
|
|
270
293
|
seen.add(key);
|
|
@@ -275,6 +298,31 @@ export function mergeApiDocs(docs: readonly unknown[]): unknown {
|
|
|
275
298
|
return isRecord(first) ? { ...first, elements } : { elements };
|
|
276
299
|
}
|
|
277
300
|
|
|
301
|
+
export function apiElementIdentity(namespace: string, element: unknown): string | null {
|
|
302
|
+
if (!isRecord(element) || typeof element.name !== "string" || typeof element.type !== "string") {
|
|
303
|
+
return null;
|
|
304
|
+
}
|
|
305
|
+
const base = `${namespace}\0${element.type}\0${element.name}`;
|
|
306
|
+
if (element.type !== "FUNCTION") return base;
|
|
307
|
+
return `${base}\0${normalizedArguments(element.parameters)}\0${normalizedArguments(element.returnvalues)}`;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
function normalizedArguments(value: unknown): string {
|
|
311
|
+
if (!Array.isArray(value)) return "[]";
|
|
312
|
+
return JSON.stringify(
|
|
313
|
+
value.map((argument) => {
|
|
314
|
+
if (!isRecord(argument)) return argument;
|
|
315
|
+
const types = Array.isArray(argument.types)
|
|
316
|
+
? argument.types.filter((type): type is string => typeof type === "string").sort()
|
|
317
|
+
: [];
|
|
318
|
+
return {
|
|
319
|
+
types,
|
|
320
|
+
...(argument.is_optional === undefined ? {} : { is_optional: argument.is_optional }),
|
|
321
|
+
};
|
|
322
|
+
}),
|
|
323
|
+
);
|
|
324
|
+
}
|
|
325
|
+
|
|
278
326
|
export function extractFixtures(
|
|
279
327
|
zip: ZipAccessor,
|
|
280
328
|
manifest: readonly SyncManifestEntry[] = SYNC_MANIFEST,
|
|
Binary file
|
package/src/core-types.ts
CHANGED
|
@@ -188,6 +188,9 @@ export const DEFOLD_TYPE_MAP: Readonly<Record<string, string>> = {
|
|
|
188
188
|
vector4: "Vector4",
|
|
189
189
|
quaternion: "Quaternion",
|
|
190
190
|
matrix4: "Matrix4",
|
|
191
|
+
"vmath.vector3": "Vector3",
|
|
192
|
+
"vmath.vector4": "Vector4",
|
|
193
|
+
"vmath.matrix4": "Matrix4",
|
|
191
194
|
hash: "Hash",
|
|
192
195
|
url: "Url",
|
|
193
196
|
node: 'Opaque<"node">',
|
|
@@ -201,6 +204,12 @@ export const DEFOLD_TYPE_MAP: Readonly<Record<string, string>> = {
|
|
|
201
204
|
resource: 'Opaque<"resource">',
|
|
202
205
|
b2World: 'Opaque<"b2World">',
|
|
203
206
|
b2Body: 'Opaque<"b2Body">',
|
|
207
|
+
b2Chain: 'Opaque<"b2Chain">',
|
|
208
|
+
b2Shape: 'Opaque<"b2Shape">',
|
|
209
|
+
b2Joint: 'Opaque<"b2Joint">',
|
|
210
|
+
b2ContactEdge: 'Opaque<"b2ContactEdge">',
|
|
211
|
+
b2MassData: 'Opaque<"b2MassData">',
|
|
212
|
+
b2Transform: 'Opaque<"b2Transform">',
|
|
204
213
|
b2BodyType:
|
|
205
214
|
'(number & { readonly __brand: "b2d.body.B2_DYNAMIC_BODY" }) | (number & { readonly __brand: "b2d.body.B2_KINEMATIC_BODY" }) | (number & { readonly __brand: "b2d.body.B2_STATIC_BODY" })',
|
|
206
215
|
// socket handle types resolve to the method-bearing `interface <receiver>`
|