@defold-typescript/types 0.12.1 → 0.14.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-targets.json +1 -1
- package/generated/camera.d.ts +8 -8
- package/generated/font.d.ts +1 -1
- package/generated/go.d.ts +2 -2
- package/generated/msg.d.ts +0 -67
- package/package.json +1 -1
- package/scripts/fidelity-audit.ts +7 -21
- package/scripts/fidelity-baseline.json +3 -3
- package/src/emit-dts.ts +36 -1
- package/src/msg-overloads.d.ts +38 -0
package/api-targets.json
CHANGED
package/generated/camera.d.ts
CHANGED
|
@@ -52,7 +52,7 @@ declare global {
|
|
|
52
52
|
* }
|
|
53
53
|
* ```
|
|
54
54
|
*/
|
|
55
|
-
function get_cameras():
|
|
55
|
+
function get_cameras(): Url[];
|
|
56
56
|
/**
|
|
57
57
|
* get enabled
|
|
58
58
|
*
|
|
@@ -175,7 +175,7 @@ declare global {
|
|
|
175
175
|
* @param camera - camera id
|
|
176
176
|
* @param aspect_ratio - the manual aspect ratio value.
|
|
177
177
|
*/
|
|
178
|
-
function set_aspect_ratio(camera: Url | number, aspect_ratio: number): void;
|
|
178
|
+
function set_aspect_ratio(camera: Url | number | undefined, aspect_ratio: number): void;
|
|
179
179
|
/**
|
|
180
180
|
* Enables or disables automatic aspect ratio calculation. When enabled (true),
|
|
181
181
|
* the camera automatically calculates aspect ratio from render target dimensions.
|
|
@@ -184,42 +184,42 @@ declare global {
|
|
|
184
184
|
* @param camera - camera id
|
|
185
185
|
* @param auto_aspect_ratio - true to enable auto aspect ratio
|
|
186
186
|
*/
|
|
187
|
-
function set_auto_aspect_ratio(camera: Url | number, auto_aspect_ratio: boolean): void;
|
|
187
|
+
function set_auto_aspect_ratio(camera: Url | number | undefined, auto_aspect_ratio: boolean): void;
|
|
188
188
|
/**
|
|
189
189
|
* set far z
|
|
190
190
|
*
|
|
191
191
|
* @param camera - camera id
|
|
192
192
|
* @param far_z - the far z.
|
|
193
193
|
*/
|
|
194
|
-
function set_far_z(camera: Url | number, far_z: number): void;
|
|
194
|
+
function set_far_z(camera: Url | number | undefined, far_z: number): void;
|
|
195
195
|
/**
|
|
196
196
|
* set field of view
|
|
197
197
|
*
|
|
198
198
|
* @param camera - camera id
|
|
199
199
|
* @param fov - the field of view.
|
|
200
200
|
*/
|
|
201
|
-
function set_fov(camera: Url | number, fov: number): void;
|
|
201
|
+
function set_fov(camera: Url | number | undefined, fov: number): void;
|
|
202
202
|
/**
|
|
203
203
|
* set near z
|
|
204
204
|
*
|
|
205
205
|
* @param camera - camera id
|
|
206
206
|
* @param near_z - the near z.
|
|
207
207
|
*/
|
|
208
|
-
function set_near_z(camera: Url | number, near_z: number): void;
|
|
208
|
+
function set_near_z(camera: Url | number | undefined, near_z: number): void;
|
|
209
209
|
/**
|
|
210
210
|
* set orthographic zoom mode
|
|
211
211
|
*
|
|
212
212
|
* @param camera - camera id
|
|
213
213
|
* @param mode - camera.ORTHO_MODE_FIXED, camera.ORTHO_MODE_AUTO_FIT or camera.ORTHO_MODE_AUTO_COVER
|
|
214
214
|
*/
|
|
215
|
-
function set_orthographic_mode(camera: Url | number, mode: number): void;
|
|
215
|
+
function set_orthographic_mode(camera: Url | number | undefined, mode: number): void;
|
|
216
216
|
/**
|
|
217
217
|
* set orthographic zoom
|
|
218
218
|
*
|
|
219
219
|
* @param camera - camera id
|
|
220
220
|
* @param orthographic_zoom - the zoom level when the camera uses orthographic projection.
|
|
221
221
|
*/
|
|
222
|
-
function set_orthographic_zoom(camera: Url | number, orthographic_zoom: number): void;
|
|
222
|
+
function set_orthographic_zoom(camera: Url | number | undefined, orthographic_zoom: number): void;
|
|
223
223
|
/**
|
|
224
224
|
* Converts a 3D world position to screen-space coordinates with view depth.
|
|
225
225
|
* Returns a vector3 where x and y are in screen pixels and z is the view depth in world units
|
package/generated/font.d.ts
CHANGED
|
@@ -36,7 +36,7 @@ declare global {
|
|
|
36
36
|
* `path_hash`
|
|
37
37
|
* hash The path of the font file
|
|
38
38
|
*/
|
|
39
|
-
function get_info(fontc: string | Hash): { path: Hash; fonts:
|
|
39
|
+
function get_info(fontc: string | Hash): { path: Hash; fonts: { path: string; path_hash: Hash }[] };
|
|
40
40
|
/**
|
|
41
41
|
* prepopulates the font glyph cache with rasterised glyphs
|
|
42
42
|
*
|
package/generated/go.d.ts
CHANGED
|
@@ -471,7 +471,7 @@ declare global {
|
|
|
471
471
|
* // Get the world position of the game object the script is attached to:
|
|
472
472
|
* const p = go.get_world_position();
|
|
473
473
|
*
|
|
474
|
-
* //
|
|
474
|
+
* // Reach a sibling game object by its id — relative addressing, no socket prefix:
|
|
475
475
|
* const p2 = go.get_world_position("x");
|
|
476
476
|
* ```
|
|
477
477
|
*/
|
|
@@ -868,7 +868,7 @@ declare global {
|
|
|
868
868
|
* // Set the position of the game object the script is attached to:
|
|
869
869
|
* go.set_position(p);
|
|
870
870
|
*
|
|
871
|
-
* //
|
|
871
|
+
* // Reach a sibling game object by its id — relative addressing, no socket prefix:
|
|
872
872
|
* go.set_position(p, "x");
|
|
873
873
|
* ```
|
|
874
874
|
*/
|
package/generated/msg.d.ts
CHANGED
|
@@ -1,76 +1,9 @@
|
|
|
1
1
|
/** @noSelfInFile */
|
|
2
|
-
import type { Hash, Url } from "../src/core-types";
|
|
3
|
-
|
|
4
2
|
declare global {
|
|
5
3
|
/**
|
|
6
4
|
* Functions for passing messages and constructing URL objects.
|
|
7
5
|
*/
|
|
8
6
|
namespace msg {
|
|
9
|
-
/**
|
|
10
|
-
* This is equivalent to `msg.url(nil)` or `msg.url("#")`, which creates an url to the current
|
|
11
|
-
* script component.
|
|
12
|
-
*
|
|
13
|
-
* @returns a new URL
|
|
14
|
-
* @example
|
|
15
|
-
* ```ts
|
|
16
|
-
* // Create a new URL which will address the current script:
|
|
17
|
-
* const my_url = msg.url();
|
|
18
|
-
* print(my_url); // => url: [current_collection:/my_instance#my_component]
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
|
-
function url(): Url;
|
|
22
|
-
/**
|
|
23
|
-
* The format of the string must be `[socket:][path][#fragment]`, which is similar to a HTTP URL.
|
|
24
|
-
* When addressing instances:
|
|
25
|
-
*
|
|
26
|
-
* - `socket` is the name of a valid world (a collection)
|
|
27
|
-
*
|
|
28
|
-
* - `path` is the id of the instance, which can either be relative the instance of the calling script or global
|
|
29
|
-
*
|
|
30
|
-
* - `fragment` would be the id of the desired component
|
|
31
|
-
*
|
|
32
|
-
* In addition, the following shorthands are available:
|
|
33
|
-
*
|
|
34
|
-
* - `"."` the current game object
|
|
35
|
-
*
|
|
36
|
-
* - `"#"` the current component
|
|
37
|
-
*
|
|
38
|
-
* @param urlstring - string to create the url from
|
|
39
|
-
* @returns a new URL
|
|
40
|
-
* @example
|
|
41
|
-
* ```ts
|
|
42
|
-
* const my_url = msg.url("#my_component");
|
|
43
|
-
* print(my_url); // => url: [current_collection:/my_instance#my_component]
|
|
44
|
-
*
|
|
45
|
-
* const my_collection_url = msg.url("my_collection:/my_sub_collection/my_instance#my_component");
|
|
46
|
-
* print(my_collection_url); // => url: [my_collection:/my_sub_collection/my_instance#my_component]
|
|
47
|
-
*
|
|
48
|
-
* const my_socket_url = msg.url("my_socket:");
|
|
49
|
-
* print(my_socket_url); // => url: [my_collection:]
|
|
50
|
-
* ```
|
|
51
|
-
*/
|
|
52
|
-
function url(urlstring: string): Url;
|
|
53
|
-
/**
|
|
54
|
-
* creates a new URL from separate arguments
|
|
55
|
-
*
|
|
56
|
-
* @param socket - socket of the URL
|
|
57
|
-
* @param path - path of the URL
|
|
58
|
-
* @param fragment - fragment of the URL
|
|
59
|
-
* @returns a new URL
|
|
60
|
-
* @example
|
|
61
|
-
* ```ts
|
|
62
|
-
* const my_socket = "main"; // specify by valid name
|
|
63
|
-
* const my_path = hash("/my_collection/my_gameobject"); // specify as string or hash
|
|
64
|
-
* const my_fragment = "component"; // specify as string or hash
|
|
65
|
-
* const my_url = msg.url(my_socket, my_path, my_fragment);
|
|
66
|
-
*
|
|
67
|
-
* print(my_url); // => url: [main:/my_collection/my_gameobject#component]
|
|
68
|
-
* print(my_url.socket); // => 786443 (internal numeric value)
|
|
69
|
-
* print(my_url.path); // => hash: [/my_collection/my_gameobject]
|
|
70
|
-
* print(my_url.fragment); // => hash: [component]
|
|
71
|
-
* ```
|
|
72
|
-
*/
|
|
73
|
-
function url(socket?: string | Hash, path?: string | Hash, fragment?: string | Hash): Url;
|
|
74
7
|
}
|
|
75
8
|
}
|
|
76
9
|
|
package/package.json
CHANGED
|
@@ -63,20 +63,6 @@ function docString(raw: unknown): string | undefined {
|
|
|
63
63
|
return typeof raw === "string" ? raw : undefined;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
function isDocOptional(param: Record<string, unknown>): boolean {
|
|
67
|
-
return param.is_optional === "True" || stringArray(param.types).includes("nil");
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function trailingOptionalCutoff(params: readonly Record<string, unknown>[]): number {
|
|
71
|
-
let cutoff = params.length;
|
|
72
|
-
for (let i = params.length - 1; i >= 0; i -= 1) {
|
|
73
|
-
const p = params[i];
|
|
74
|
-
if (p && isDocOptional(p)) cutoff = i;
|
|
75
|
-
else break;
|
|
76
|
-
}
|
|
77
|
-
return cutoff;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
66
|
// Colon `<receiver>:<method>` FUNCTION elements are emitted as method-bearing
|
|
81
67
|
// interfaces (see emit-dts collectHandleMethodGroups). Before that recovery they
|
|
82
68
|
// emitted nothing yet were never counted as a droppedMembers loss — a blind spot
|
|
@@ -109,7 +95,9 @@ function auditEntry(
|
|
|
109
95
|
// multiReturn is fully recovered: emitReturn emits LuaMultiReturn<[...]> for
|
|
110
96
|
// every >1-return function, so no documented multi-return is a loss anymore.
|
|
111
97
|
const multiReturn = 0;
|
|
112
|
-
|
|
98
|
+
// optionalAsRequired is fully recovered: emitParameter expresses an interior
|
|
99
|
+
// doc-optional param as `| undefined`, so no doc-optional param is a loss.
|
|
100
|
+
const optionalAsRequired = 0;
|
|
113
101
|
const unknown = new Set<string>();
|
|
114
102
|
|
|
115
103
|
const constantFqns = new Set<string>();
|
|
@@ -325,14 +313,13 @@ function auditEntry(
|
|
|
325
313
|
}
|
|
326
314
|
const params = paramList(element.parameters);
|
|
327
315
|
const returns = paramList(element.returnvalues);
|
|
328
|
-
const cutoff = trailingOptionalCutoff(params);
|
|
329
316
|
const arbitraryTable =
|
|
330
317
|
typeof element.name === "string" && ARBITRARY_TABLE_SLOTS.has(element.name);
|
|
331
318
|
const mappingSlot =
|
|
332
319
|
typeof element.name === "string" ? MAPPING_TABLE_SLOTS.get(element.name) : undefined;
|
|
333
320
|
const homogeneousElement =
|
|
334
321
|
typeof element.name === "string" ? HOMOGENEOUS_ARRAY_SLOTS.get(element.name) : undefined;
|
|
335
|
-
params.forEach((param
|
|
322
|
+
params.forEach((param) => {
|
|
336
323
|
const tableSlotCuration =
|
|
337
324
|
typeof element.name === "string" && typeof param.name === "string"
|
|
338
325
|
? TABLE_SLOT_CURATIONS.get(tableSlotKey(element.name, "param", param.name))
|
|
@@ -348,10 +335,9 @@ function auditEntry(
|
|
|
348
335
|
? { element: element.name, kind: "param", name: param.name }
|
|
349
336
|
: undefined,
|
|
350
337
|
);
|
|
351
|
-
//
|
|
352
|
-
//
|
|
353
|
-
//
|
|
354
|
-
if (isDocOptional(param) && index < cutoff) optionalAsRequired += 1;
|
|
338
|
+
// Interior doc-optional params (a required param follows) are no longer a
|
|
339
|
+
// loss: emitParameter expresses them as `| undefined`, mirroring the
|
|
340
|
+
// emitted surface. optionalAsRequired stays in the report shape reading 0.
|
|
355
341
|
});
|
|
356
342
|
for (const ret of returns) {
|
|
357
343
|
const tableSlotCuration =
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
"camera": {
|
|
27
27
|
"droppedElements": 0,
|
|
28
28
|
"unknownTokens": [],
|
|
29
|
-
"recordTables":
|
|
29
|
+
"recordTables": 0,
|
|
30
30
|
"multiReturn": 0,
|
|
31
31
|
"droppedMembers": 0,
|
|
32
|
-
"optionalAsRequired":
|
|
32
|
+
"optionalAsRequired": 0
|
|
33
33
|
},
|
|
34
34
|
"collectionfactory": {
|
|
35
35
|
"droppedElements": 0,
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"font": {
|
|
67
67
|
"droppedElements": 0,
|
|
68
68
|
"unknownTokens": [],
|
|
69
|
-
"recordTables":
|
|
69
|
+
"recordTables": 0,
|
|
70
70
|
"multiReturn": 0,
|
|
71
71
|
"droppedMembers": 0,
|
|
72
72
|
"optionalAsRequired": 0
|
package/src/emit-dts.ts
CHANGED
|
@@ -164,6 +164,9 @@ export const OVERLOAD_COVERED_SKIPS = new Set([
|
|
|
164
164
|
"go.property",
|
|
165
165
|
// msg-overloads.d.ts supplies the typed msg.post shape.
|
|
166
166
|
"msg.post",
|
|
167
|
+
// msg-overloads.d.ts supplies the typed msg.url shape (0 / 1-string / 3-arg
|
|
168
|
+
// arities; the runtime-invalid two-arg form is intentionally omitted).
|
|
169
|
+
"msg.url",
|
|
167
170
|
]);
|
|
168
171
|
|
|
169
172
|
// Element names whose `table` slot is a prose-only `a table mapping X to Y`
|
|
@@ -214,6 +217,9 @@ export const HOMOGENEOUS_ARRAY_SLOTS: ReadonlyMap<string, string | readonly stri
|
|
|
214
217
|
// no brand exists to reference; `number` is the faithful element token for these
|
|
215
218
|
// numeric constants, mirroring the vmath.vector/buffer.* number entries.
|
|
216
219
|
["push.register", "number"],
|
|
220
|
+
// camera.get_cameras returns "a table with all camera URLs" (the ref example
|
|
221
|
+
// iterates it with `pairs`) — a homogeneous list of `url`, emitted `Url[]`.
|
|
222
|
+
["camera.get_cameras", "url"],
|
|
217
223
|
]);
|
|
218
224
|
|
|
219
225
|
// A `mapping` curation whose value is itself a single-level mapping, emitted
|
|
@@ -231,6 +237,30 @@ export const SOCKET_HANDLE_TOKENS = ["client", "master", "unconnected"] as const
|
|
|
231
237
|
|
|
232
238
|
export const TABLE_SLOT_CURATIONS: ReadonlyMap<string, TableSlotCuration> = new Map([
|
|
233
239
|
["collectionfactory.create:return:ids", { kind: "mapping", key: "hash", value: "hash" }],
|
|
240
|
+
// font.get_info's `info` return is a `<dl>` with `path: hash` and a nested
|
|
241
|
+
// `fonts` field whose `<dd>` is itself a `<dl>` (`path: string`, `path_hash:
|
|
242
|
+
// hash`). parseTableFields flattens the inner `<dl>` to the top level, which
|
|
243
|
+
// duplicates the `path` key and bares `fonts` to Record; this curation replaces
|
|
244
|
+
// the whole mis-parsed field list with the faithful shape (a nested isList
|
|
245
|
+
// object), recovering the array and removing the duplicate key.
|
|
246
|
+
[
|
|
247
|
+
"font.get_info:return:info",
|
|
248
|
+
{
|
|
249
|
+
kind: "object",
|
|
250
|
+
fields: [
|
|
251
|
+
{ name: "path", types: ["hash"] },
|
|
252
|
+
{
|
|
253
|
+
name: "fonts",
|
|
254
|
+
types: ["table"],
|
|
255
|
+
isList: true,
|
|
256
|
+
fields: [
|
|
257
|
+
{ name: "path", types: ["string"] },
|
|
258
|
+
{ name: "path_hash", types: ["hash"] },
|
|
259
|
+
],
|
|
260
|
+
},
|
|
261
|
+
],
|
|
262
|
+
},
|
|
263
|
+
],
|
|
234
264
|
// iap.finish and iap.acknowledge take the same Defold IAP transaction object —
|
|
235
265
|
// the table handed to the iap.set_listener callback. The ref-doc fixture
|
|
236
266
|
// describes it in prose only (no field list), so the shape is curated from the
|
|
@@ -1234,7 +1264,12 @@ function emitParameter(
|
|
|
1234
1264
|
concrete.length > 0
|
|
1235
1265
|
? mapSlotUnion(concrete, p.doc, mapType, true, resolver, elementName, "param", p.name)
|
|
1236
1266
|
: "unknown";
|
|
1237
|
-
|
|
1267
|
+
// An interior doc-optional param (a required param follows, so the trailing-`?`
|
|
1268
|
+
// projection cannot mark it) keeps its optionality as `| undefined` — TSTL
|
|
1269
|
+
// lowers `undefined` to `nil`, the faithful call. Trailing optionals keep the
|
|
1270
|
+
// `?` form; required params are untouched.
|
|
1271
|
+
const interiorOptional = !optional && isDocOptional(p) ? " | undefined" : "";
|
|
1272
|
+
return `${name}${optional ? "?" : ""}: ${ts}${interiorOptional}`;
|
|
1238
1273
|
}
|
|
1239
1274
|
|
|
1240
1275
|
function emitReturn(
|
package/src/msg-overloads.d.ts
CHANGED
|
@@ -40,5 +40,43 @@ declare global {
|
|
|
40
40
|
message_id: Hash,
|
|
41
41
|
message?: Record<string | number, unknown>,
|
|
42
42
|
): void;
|
|
43
|
+
/**
|
|
44
|
+
* Construct a URL. A URL is `[socket:][path][#fragment]`.
|
|
45
|
+
*
|
|
46
|
+
* @remarks
|
|
47
|
+
* Only the following arities are supported at runtime:
|
|
48
|
+
*
|
|
49
|
+
* - `msg.url()` — no-arg.
|
|
50
|
+
* - `msg.url("[socket:][path][#fragment]")` — one string, the full URL.
|
|
51
|
+
* - `msg.url(socket, path, fragment)` — three required args.
|
|
52
|
+
*
|
|
53
|
+
* The two-arg form `msg.url(socket, path)` is a runtime error.
|
|
54
|
+
*
|
|
55
|
+
* In the same world, address a sibling **relatively** — by bare id
|
|
56
|
+
* (`msg.url("camera")`), absolute path (`msg.url("/camera")`), or
|
|
57
|
+
* component (`msg.url("#main")`). The `socket:` prefix only crosses
|
|
58
|
+
* into a collection-proxy-loaded world.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```ts
|
|
62
|
+
* // No-arg, then take the current game object's URL.
|
|
63
|
+
* const self: Url = msg.url();
|
|
64
|
+
*
|
|
65
|
+
* // A sibling in the same world — bare id, no socket prefix.
|
|
66
|
+
* const sibling: Url = msg.url("camera");
|
|
67
|
+
*
|
|
68
|
+
* // An absolute path in the same world.
|
|
69
|
+
* const absSibling: Url = msg.url("/camera");
|
|
70
|
+
*
|
|
71
|
+
* // A component on a sibling.
|
|
72
|
+
* const comp: Url = msg.url("camera#script");
|
|
73
|
+
*
|
|
74
|
+
* // Crossing into a proxy-loaded world — `socket` is the world name.
|
|
75
|
+
* const proxied: Url = msg.url(hash("level1"), hash("/door"), hash("script"));
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
function url(): Url;
|
|
79
|
+
function url(urlstring: string): Url;
|
|
80
|
+
function url(socket: string | Hash, path: string | Hash, fragment: string | Hash): Url;
|
|
43
81
|
}
|
|
44
82
|
}
|