@defold-typescript/types 0.26.0 → 0.27.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-availability.json +307 -307
- package/api-signatures.json +1311 -0
- package/api-targets.json +342 -0
- package/examples/translations.json +1984 -0
- package/fixtures/messages_doc.json +880 -0
- package/generated/versions/defold-1.12.4/gui.d.ts +43 -43
- package/generated/versions/defold-1.12.4/liveupdate.d.ts +22 -22
- package/generated/versions/defold-1.12.4/physics.d.ts +78 -75
- package/generated/versions/defold-1.12.4/render.d.ts +75 -55
- package/generated/versions/defold-1.12.4/resource.d.ts +187 -175
- package/generated/versions/defold-1.13.0/b2d.d.ts +33 -0
- package/generated/versions/defold-1.13.0/b2d_body.d.ts +676 -0
- package/generated/versions/defold-1.13.0/b2d_chain.d.ts +106 -0
- package/generated/versions/defold-1.13.0/b2d_fixture.d.ts +155 -0
- package/generated/versions/defold-1.13.0/b2d_joint.d.ts +823 -0
- package/generated/versions/defold-1.13.0/b2d_shape.d.ts +215 -0
- package/generated/versions/defold-1.13.0/b2d_world.d.ts +314 -0
- package/generated/versions/defold-1.13.0/buffer.d.ts +176 -0
- package/generated/versions/defold-1.13.0/camera.d.ts +302 -0
- package/generated/versions/defold-1.13.0/collectionfactory.d.ts +146 -0
- package/generated/versions/defold-1.13.0/collectionproxy.d.ts +71 -0
- package/generated/versions/defold-1.13.0/compute.d.ts +306 -0
- package/generated/versions/defold-1.13.0/crash.d.ts +143 -0
- package/generated/versions/defold-1.13.0/editor-vm/http.d.ts +56 -0
- package/generated/versions/defold-1.13.0/editor-vm/json.d.ts +10 -0
- package/generated/versions/defold-1.13.0/editor-vm/localization.d.ts +42 -0
- package/generated/versions/defold-1.13.0/editor-vm/tilemap_tiles.d.ts +80 -0
- package/generated/versions/defold-1.13.0/editor-vm/zip.d.ts +10 -0
- package/generated/versions/defold-1.13.0/editor-vm/zlib.d.ts +24 -0
- package/generated/versions/defold-1.13.0/editor.d.ts +1092 -0
- package/generated/versions/defold-1.13.0/factory.d.ts +123 -0
- package/generated/versions/defold-1.13.0/font.d.ts +81 -0
- package/generated/versions/defold-1.13.0/go.d.ts +1054 -0
- package/generated/versions/defold-1.13.0/graphics.d.ts +321 -0
- package/generated/versions/defold-1.13.0/gui.d.ts +2370 -0
- package/generated/versions/defold-1.13.0/html5.d.ts +53 -0
- package/generated/versions/defold-1.13.0/http.d.ts +84 -0
- package/generated/versions/defold-1.13.0/iac.d.ts +18 -0
- package/generated/versions/defold-1.13.0/iap.d.ts +60 -0
- package/generated/versions/defold-1.13.0/image.d.ts +139 -0
- package/generated/versions/defold-1.13.0/index.d.ts +48 -0
- package/generated/versions/defold-1.13.0/json.d.ts +76 -0
- package/generated/versions/defold-1.13.0/kinds/editor-script.d.ts +13 -0
- package/generated/versions/defold-1.13.0/label.d.ts +94 -0
- package/generated/versions/defold-1.13.0/liveupdate.d.ts +140 -0
- package/generated/versions/defold-1.13.0/material.d.ts +444 -0
- package/generated/versions/defold-1.13.0/model.d.ts +246 -0
- package/generated/versions/defold-1.13.0/msg.d.ts +10 -0
- package/generated/versions/defold-1.13.0/particlefx.d.ts +166 -0
- package/generated/versions/defold-1.13.0/physics.d.ts +548 -0
- package/generated/versions/defold-1.13.0/profiler.d.ts +233 -0
- package/generated/versions/defold-1.13.0/push.d.ts +66 -0
- package/generated/versions/defold-1.13.0/render.d.ts +1185 -0
- package/generated/versions/defold-1.13.0/resource.d.ts +1530 -0
- package/generated/versions/defold-1.13.0/socket.d.ts +795 -0
- package/generated/versions/defold-1.13.0/sound.d.ts +291 -0
- package/generated/versions/defold-1.13.0/sprite.d.ts +157 -0
- package/generated/versions/defold-1.13.0/sys.d.ts +695 -0
- package/generated/versions/defold-1.13.0/tilemap.d.ts +195 -0
- package/generated/versions/defold-1.13.0/timer.d.ts +114 -0
- package/generated/versions/defold-1.13.0/types.d.ts +61 -0
- package/generated/versions/defold-1.13.0/vmath.d.ts +806 -0
- package/generated/versions/defold-1.13.0/webview.d.ts +68 -0
- package/generated/versions/defold-1.13.0/window.d.ts +198 -0
- package/generated/versions/defold-1.13.0/zlib.d.ts +40 -0
- package/index.d.ts +4 -84
- package/package.json +11 -3
- package/scripts/import-defold-release.ts +18 -1
- package/src/example-store.ts +5 -0
- package/scripts/lua-types-signature-index.ts +0 -151
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/** @noSelfInFile */
|
|
2
|
+
declare global {
|
|
3
|
+
/**
|
|
4
|
+
* Functions and constants for interacting with webview APIs
|
|
5
|
+
*/
|
|
6
|
+
namespace webview {
|
|
7
|
+
/**
|
|
8
|
+
* Creates a webview instance. It can show HTML pages as well as evaluate Javascript. The view remains hidden until the first call. There can exist a maximum of 4 webviews at the same time.
|
|
9
|
+
* On iOS, the callback will never get a `webview.CALLBACK_RESULT_EVAL_ERROR`, due to the iOS SDK implementation."
|
|
10
|
+
*
|
|
11
|
+
* @param callback - A callback which receives info about finished requests taking the following parameters:
|
|
12
|
+
*/
|
|
13
|
+
function create(callback: (...args: unknown[]) => unknown): void;
|
|
14
|
+
/**
|
|
15
|
+
* Destroys an instance of a webview.
|
|
16
|
+
*
|
|
17
|
+
* @param webview_id - The webview id (returned by the `webview.create()` call)
|
|
18
|
+
*/
|
|
19
|
+
function destroy(webview_id: number): void;
|
|
20
|
+
/**
|
|
21
|
+
* Evaluates JavaScript within the context of the currently loaded page (if any). Once the request is done, the callback (registered in `webview.create()`) is invoked. The callback will get the result in the `data["result"]` field.
|
|
22
|
+
*
|
|
23
|
+
* @param webview_id - The webview id
|
|
24
|
+
* @param code - The JavaScript code to evaluate
|
|
25
|
+
*/
|
|
26
|
+
function eval(webview_id: number, code: string): void;
|
|
27
|
+
/**
|
|
28
|
+
* Returns the visibility state of the webview.
|
|
29
|
+
*
|
|
30
|
+
* @param webview_id - The webview id
|
|
31
|
+
*/
|
|
32
|
+
function is_visible(webview_id: number): void;
|
|
33
|
+
/**
|
|
34
|
+
* Opens a web page in the webview, using HTML data. Once the request is done, the callback (registered in `webview.create()`) is invoked.
|
|
35
|
+
*
|
|
36
|
+
* @param webview_id - The webview id
|
|
37
|
+
* @param html - The HTML data to display
|
|
38
|
+
* @param options - A table of options for the request. See `webview.open()`
|
|
39
|
+
*/
|
|
40
|
+
function open_raw(webview_id: number, html: string, options: Record<string | number, unknown>): void;
|
|
41
|
+
/**
|
|
42
|
+
* Sets the position and size of the webview
|
|
43
|
+
*
|
|
44
|
+
* @param webview_id - The webview id
|
|
45
|
+
* @param x - The x position of the webview
|
|
46
|
+
* @param y - The y position of the webview
|
|
47
|
+
* @param width - The width of the webview (-1 to match screen width)
|
|
48
|
+
* @param height - The height of the webview (-1 to match screen height)
|
|
49
|
+
*/
|
|
50
|
+
function set_position(webview_id: number, x: number, y: number, width: number, height: number): void;
|
|
51
|
+
/**
|
|
52
|
+
* Set transparency of webview background
|
|
53
|
+
*
|
|
54
|
+
* @param webview_id - The webview id
|
|
55
|
+
* @param transparent - If `true`, the webview background becomes transparent, otherwise opaque.
|
|
56
|
+
*/
|
|
57
|
+
function set_transparent(webview_id: number, transparent: boolean): void;
|
|
58
|
+
/**
|
|
59
|
+
* Shows or hides a webview
|
|
60
|
+
*
|
|
61
|
+
* @param webview_id - The webview id
|
|
62
|
+
* @param visible - If `0`, hides the webview. If non zero, shows the view
|
|
63
|
+
*/
|
|
64
|
+
function set_visible(webview_id: number, visible: number): void;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export {};
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
/** @noSelfInFile */
|
|
2
|
+
import type { Opaque } from "../../../src/core-types";
|
|
3
|
+
|
|
4
|
+
declare global {
|
|
5
|
+
/**
|
|
6
|
+
* Functions and constants to access the window, window event listeners
|
|
7
|
+
* and screen dimming.
|
|
8
|
+
*/
|
|
9
|
+
namespace window {
|
|
10
|
+
/**
|
|
11
|
+
* Dimming mode is used to control whether or not a mobile device should dim the screen after a period without user interaction.
|
|
12
|
+
*/
|
|
13
|
+
const DIMMING_OFF: number & { readonly __brand: "window.DIMMING_OFF" };
|
|
14
|
+
/**
|
|
15
|
+
* Dimming mode is used to control whether or not a mobile device should dim the screen after a period without user interaction.
|
|
16
|
+
*/
|
|
17
|
+
const DIMMING_ON: number & { readonly __brand: "window.DIMMING_ON" };
|
|
18
|
+
/**
|
|
19
|
+
* Dimming mode is used to control whether or not a mobile device should dim the screen after a period without user interaction.
|
|
20
|
+
* This mode indicates that the dim mode can't be determined, or that the platform doesn't support dimming.
|
|
21
|
+
*/
|
|
22
|
+
const DIMMING_UNKNOWN: number & { readonly __brand: "window.DIMMING_UNKNOWN" };
|
|
23
|
+
/**
|
|
24
|
+
* This event is sent to a window event listener when the game window or app screen is
|
|
25
|
+
* restored after being iconified.
|
|
26
|
+
*/
|
|
27
|
+
const WINDOW_EVENT_DEICONIFIED: number & { readonly __brand: "window.WINDOW_EVENT_DEICONIFIED" };
|
|
28
|
+
/**
|
|
29
|
+
* This event is sent to a window event listener when the game window or app screen has
|
|
30
|
+
* gained focus.
|
|
31
|
+
* This event is also sent at game startup and the engine gives focus to the game.
|
|
32
|
+
*/
|
|
33
|
+
const WINDOW_EVENT_FOCUS_GAINED: number & { readonly __brand: "window.WINDOW_EVENT_FOCUS_GAINED" };
|
|
34
|
+
/**
|
|
35
|
+
* This event is sent to a window event listener when the game window or app screen has lost focus.
|
|
36
|
+
*/
|
|
37
|
+
const WINDOW_EVENT_FOCUS_LOST: number & { readonly __brand: "window.WINDOW_EVENT_FOCUS_LOST" };
|
|
38
|
+
/**
|
|
39
|
+
* This event is sent to a window event listener when the game window or app screen is
|
|
40
|
+
* iconified (reduced to an application icon in a toolbar, application tray or similar).
|
|
41
|
+
*/
|
|
42
|
+
const WINDOW_EVENT_ICONFIED: number & { readonly __brand: "window.WINDOW_EVENT_ICONFIED" };
|
|
43
|
+
/**
|
|
44
|
+
* This event is sent to a window event listener when the game window or app screen is resized.
|
|
45
|
+
* The new size is passed along in the data field to the event listener.
|
|
46
|
+
*/
|
|
47
|
+
const WINDOW_EVENT_RESIZED: number & { readonly __brand: "window.WINDOW_EVENT_RESIZED" };
|
|
48
|
+
/**
|
|
49
|
+
* Returns the current dimming mode set on a mobile device.
|
|
50
|
+
* The dimming mode specifies whether or not a mobile device should dim the screen after a period without user interaction.
|
|
51
|
+
* On platforms that does not support dimming, `window.DIMMING_UNKNOWN` is always returned.
|
|
52
|
+
*
|
|
53
|
+
* @returns The mode for screen dimming
|
|
54
|
+
*
|
|
55
|
+
* - `window.DIMMING_UNKNOWN`
|
|
56
|
+
*
|
|
57
|
+
* - `window.DIMMING_ON`
|
|
58
|
+
*
|
|
59
|
+
* - `window.DIMMING_OFF`
|
|
60
|
+
*/
|
|
61
|
+
function get_dim_mode(): Opaque<"constant">;
|
|
62
|
+
/**
|
|
63
|
+
* This returns the content scale of the current display.
|
|
64
|
+
*
|
|
65
|
+
* @returns The display scale
|
|
66
|
+
*/
|
|
67
|
+
function get_display_scale(): number;
|
|
68
|
+
/**
|
|
69
|
+
* This returns the current lock state of the mouse cursor
|
|
70
|
+
*
|
|
71
|
+
* @returns The lock state
|
|
72
|
+
*/
|
|
73
|
+
function get_mouse_lock(): boolean;
|
|
74
|
+
/**
|
|
75
|
+
* This returns the safe area rectangle (x, y, width, height) and the inset
|
|
76
|
+
* values relative to the window edges. On platforms without a safe area,
|
|
77
|
+
* this returns the full window size and zero insets.
|
|
78
|
+
*
|
|
79
|
+
* @returns safe area data
|
|
80
|
+
*
|
|
81
|
+
* `safe_area`
|
|
82
|
+
* table table containing these keys:
|
|
83
|
+
*
|
|
84
|
+
* - number `x`
|
|
85
|
+
*
|
|
86
|
+
* - number `y`
|
|
87
|
+
*
|
|
88
|
+
* - number `width`
|
|
89
|
+
*
|
|
90
|
+
* - number `height`
|
|
91
|
+
*
|
|
92
|
+
* - number `inset_left`
|
|
93
|
+
*
|
|
94
|
+
* - number `inset_top`
|
|
95
|
+
*
|
|
96
|
+
* - number `inset_right`
|
|
97
|
+
*
|
|
98
|
+
* - number `inset_bottom`
|
|
99
|
+
*/
|
|
100
|
+
function get_safe_area(): { safe_area: { x: number; y: number; width: number; height: number; inset_left: number; inset_top: number; inset_right: number; inset_bottom: number } };
|
|
101
|
+
/**
|
|
102
|
+
* This returns the current window size (width and height).
|
|
103
|
+
*/
|
|
104
|
+
function get_size(): LuaMultiReturn<[number, number]>;
|
|
105
|
+
/**
|
|
106
|
+
* Sets the dimming mode on a mobile device.
|
|
107
|
+
* The dimming mode specifies whether or not a mobile device should dim the screen after a period without user interaction. The dimming mode will only affect the mobile device while the game is in focus on the device, but not when the game is running in the background.
|
|
108
|
+
* This function has no effect on platforms that does not support dimming.
|
|
109
|
+
*
|
|
110
|
+
* @param mode - The mode for screen dimming
|
|
111
|
+
*
|
|
112
|
+
* - `window.DIMMING_ON`
|
|
113
|
+
*
|
|
114
|
+
* - `window.DIMMING_OFF`
|
|
115
|
+
*/
|
|
116
|
+
function set_dim_mode(mode: Opaque<"constant">): void;
|
|
117
|
+
/**
|
|
118
|
+
* Sets a window event listener. Only one window event listener can be set at a time.
|
|
119
|
+
*
|
|
120
|
+
* @param callback - A callback which receives info about window events. Pass an empty function or `nil` if you no longer wish to receive callbacks.
|
|
121
|
+
*
|
|
122
|
+
* `self`
|
|
123
|
+
* object The calling script
|
|
124
|
+
* `event`
|
|
125
|
+
* constant The type of event. Can be one of these:
|
|
126
|
+
*
|
|
127
|
+
* - `window.WINDOW_EVENT_FOCUS_LOST`
|
|
128
|
+
*
|
|
129
|
+
* - `window.WINDOW_EVENT_FOCUS_GAINED`
|
|
130
|
+
*
|
|
131
|
+
* - `window.WINDOW_EVENT_RESIZED`
|
|
132
|
+
*
|
|
133
|
+
* - `window.WINDOW_EVENT_ICONIFIED`
|
|
134
|
+
*
|
|
135
|
+
* - `window.WINDOW_EVENT_DEICONIFIED`
|
|
136
|
+
*
|
|
137
|
+
* `data`
|
|
138
|
+
* table The callback value `data` is a table which currently holds these values
|
|
139
|
+
*
|
|
140
|
+
* - number `width`: The width of a resize event. nil otherwise.
|
|
141
|
+
*
|
|
142
|
+
* - number `height`: The height of a resize event. nil otherwise.
|
|
143
|
+
* @example
|
|
144
|
+
* ```ts
|
|
145
|
+
* function window_callback(self, event, data) {
|
|
146
|
+
* if (event === window.WINDOW_EVENT_FOCUS_LOST) {
|
|
147
|
+
* print("window.WINDOW_EVENT_FOCUS_LOST");
|
|
148
|
+
* } else if (event === window.WINDOW_EVENT_FOCUS_GAINED) {
|
|
149
|
+
* print("window.WINDOW_EVENT_FOCUS_GAINED");
|
|
150
|
+
* } else if (event === window.WINDOW_EVENT_ICONFIED) {
|
|
151
|
+
* print("window.WINDOW_EVENT_ICONFIED");
|
|
152
|
+
* } else if (event === window.WINDOW_EVENT_DEICONIFIED) {
|
|
153
|
+
* print("window.WINDOW_EVENT_DEICONIFIED");
|
|
154
|
+
* } else if (event === window.WINDOW_EVENT_RESIZED) {
|
|
155
|
+
* print("Window resized: ", data.width, data.height);
|
|
156
|
+
* }
|
|
157
|
+
* }
|
|
158
|
+
*
|
|
159
|
+
* export default defineScript({
|
|
160
|
+
* init() {
|
|
161
|
+
* window.set_listener(window_callback);
|
|
162
|
+
* },
|
|
163
|
+
* });
|
|
164
|
+
* ```
|
|
165
|
+
*/
|
|
166
|
+
function set_listener(callback?: (self: unknown, event: typeof WINDOW_EVENT_FOCUS_LOST | typeof WINDOW_EVENT_FOCUS_GAINED | typeof WINDOW_EVENT_RESIZED | typeof WINDOW_EVENT_ICONFIED | typeof WINDOW_EVENT_DEICONIFIED, data: Record<string | number, unknown>) => void): void;
|
|
167
|
+
/**
|
|
168
|
+
* Set the locking state for current mouse cursor on a PC platform.
|
|
169
|
+
* This function locks or unlocks the mouse cursor to the center point of the window. While the cursor is locked,
|
|
170
|
+
* mouse position updates will still be sent to the scripts as usual.
|
|
171
|
+
*
|
|
172
|
+
* @param flag - The lock state for the mouse cursor
|
|
173
|
+
*/
|
|
174
|
+
function set_mouse_lock(flag: boolean): void;
|
|
175
|
+
/**
|
|
176
|
+
* Sets the window position.
|
|
177
|
+
*
|
|
178
|
+
* @param x - Horizontal position of window
|
|
179
|
+
* @param y - Vertical position of window
|
|
180
|
+
*/
|
|
181
|
+
function set_position(x: number, y: number): void;
|
|
182
|
+
/**
|
|
183
|
+
* Sets the window size. Works on desktop platforms only.
|
|
184
|
+
*
|
|
185
|
+
* @param width - Width of window
|
|
186
|
+
* @param height - Height of window
|
|
187
|
+
*/
|
|
188
|
+
function set_size(width: number, height: number): void;
|
|
189
|
+
/**
|
|
190
|
+
* Sets the window title. Works on desktop platforms.
|
|
191
|
+
*
|
|
192
|
+
* @param title - The title, encoded as UTF-8
|
|
193
|
+
*/
|
|
194
|
+
function set_title(title: string): void;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/** @noSelfInFile */
|
|
2
|
+
declare global {
|
|
3
|
+
/**
|
|
4
|
+
* Functions for compression and decompression of string buffers.
|
|
5
|
+
*/
|
|
6
|
+
namespace zlib {
|
|
7
|
+
/**
|
|
8
|
+
* A lua error is raised is on error
|
|
9
|
+
*
|
|
10
|
+
* @param buf - buffer to deflate
|
|
11
|
+
* @returns deflated buffer
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* const data = "This is a string with uncompressed data.";
|
|
15
|
+
* const compressed_data = zlib.deflate(data);
|
|
16
|
+
* let s = "";
|
|
17
|
+
* for (const c of compressed_data) {
|
|
18
|
+
* s = s + "\\" + c.charCodeAt(0);
|
|
19
|
+
* }
|
|
20
|
+
* print(s); //> \120\94\11\201\200\44\86\0\162\68\133\226\146\162 ...
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
function deflate(buf: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* A lua error is raised is on error
|
|
26
|
+
*
|
|
27
|
+
* @param buf - buffer to inflate
|
|
28
|
+
* @returns inflated buffer
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* const data = "\120\94\11\201\200\44\86\0\162\68\133\226\146\162\204\188\116\133\242\204\146\12\133\210\188\228\252\220\130\162\212\226\226\212\20\133\148\196\146\68\61\0\44\67\14\201";
|
|
32
|
+
* const uncompressed_data = zlib.inflate(data);
|
|
33
|
+
* print(uncompressed_data); //> This is a string with uncompressed data.
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
function inflate(buf: string): string;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export {};
|
package/index.d.ts
CHANGED
|
@@ -56,87 +56,7 @@ import "./generated/webview";
|
|
|
56
56
|
import "./generated/window";
|
|
57
57
|
import "./generated/zlib";
|
|
58
58
|
|
|
59
|
-
export
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
type AvailabilityLabelKind,
|
|
64
|
-
type AvailabilityLabelOptions,
|
|
65
|
-
availabilityLabel,
|
|
66
|
-
deriveAvailabilityMatrix,
|
|
67
|
-
groupByLogicalName,
|
|
68
|
-
isSignatureTransition,
|
|
69
|
-
type LogicalNameGroup,
|
|
70
|
-
normalizedFunctionSignature,
|
|
71
|
-
signatureTransitionNames,
|
|
72
|
-
symbolIdentityKey,
|
|
73
|
-
symbolNameKey,
|
|
74
|
-
type VersionSurface,
|
|
75
|
-
} from "./src/api-availability";
|
|
76
|
-
export type { ApiFunction, ApiModule, ApiParameter, ApiVariable } from "./src/api-doc";
|
|
77
|
-
export { parseDefoldApiDoc } from "./src/api-doc";
|
|
78
|
-
export {
|
|
79
|
-
DEFOLD_TYPE_MAP,
|
|
80
|
-
type Hash,
|
|
81
|
-
type Matrix4,
|
|
82
|
-
type Quaternion,
|
|
83
|
-
type Url,
|
|
84
|
-
type Vector,
|
|
85
|
-
type Vector3,
|
|
86
|
-
type Vector4,
|
|
87
|
-
} from "./src/core-types";
|
|
88
|
-
export {
|
|
89
|
-
examplesHtmlToMarkdown,
|
|
90
|
-
htmlToCodeText,
|
|
91
|
-
htmlToDocText,
|
|
92
|
-
renderDocComment,
|
|
93
|
-
} from "./src/doc-comment";
|
|
94
|
-
export {
|
|
95
|
-
defineEditorScript,
|
|
96
|
-
type EditorCommand,
|
|
97
|
-
type EditorScriptModule,
|
|
98
|
-
} from "./src/editor";
|
|
99
|
-
export {
|
|
100
|
-
type EmitOptions,
|
|
101
|
-
emitDeclarations,
|
|
102
|
-
TS_IDENTIFIER,
|
|
103
|
-
TS_RESERVED_NAMES,
|
|
104
|
-
} from "./src/emit-dts";
|
|
105
|
-
export {
|
|
106
|
-
hashExampleSource,
|
|
107
|
-
lookupTranslation,
|
|
108
|
-
type Translation,
|
|
109
|
-
type TranslationStore,
|
|
110
|
-
} from "./src/example-store";
|
|
111
|
-
export {
|
|
112
|
-
hasTopLevelUnion,
|
|
113
|
-
luaMultiReturn,
|
|
114
|
-
needsArrayParens,
|
|
115
|
-
varargElementType,
|
|
116
|
-
} from "./src/library-signature";
|
|
117
|
-
export {
|
|
118
|
-
defineGuiScript,
|
|
119
|
-
defineRenderScript,
|
|
120
|
-
defineScript,
|
|
121
|
-
type GuiScriptHooks,
|
|
122
|
-
type InputAction,
|
|
123
|
-
type InputTouch,
|
|
124
|
-
type RenderScriptHooks,
|
|
125
|
-
SCRIPT_HOOK_NAMES,
|
|
126
|
-
type ScriptHookName,
|
|
127
|
-
type ScriptHooks,
|
|
128
|
-
type ScriptProperties,
|
|
129
|
-
type ScriptPropertiesOf,
|
|
130
|
-
type ScriptProperty,
|
|
131
|
-
} from "./src/lifecycle";
|
|
132
|
-
export { type WrapOptions, wrapAsAmbientGlobal } from "./src/publish-dts";
|
|
133
|
-
export {
|
|
134
|
-
lookupSignature,
|
|
135
|
-
type SignatureOverride,
|
|
136
|
-
type SignatureStore,
|
|
137
|
-
} from "./src/signature-store";
|
|
138
|
-
export type {
|
|
139
|
-
UrlParameterClass,
|
|
140
|
-
UrlParameterEntry,
|
|
141
|
-
UrlParameterTable,
|
|
142
|
-
} from "./src/url-parameters";
|
|
59
|
+
// The root export set lives in `src/index.ts`, the runtime `default` condition.
|
|
60
|
+
// Re-exporting it keeps the `types` condition from drifting into a subset, and
|
|
61
|
+
// is what `@defold-typescript/types/api` publishes for a pinned entrypoint.
|
|
62
|
+
export * from "./src/index";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@defold-typescript/types",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.27.0",
|
|
4
4
|
"description": "TypeScript types for the Defold engine's Lua APIs.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -30,6 +30,9 @@
|
|
|
30
30
|
"./editor-script": {
|
|
31
31
|
"types": "./generated/kinds/editor-script.d.ts"
|
|
32
32
|
},
|
|
33
|
+
"./api": {
|
|
34
|
+
"types": "./src/index.ts"
|
|
35
|
+
},
|
|
33
36
|
"./core-types": {
|
|
34
37
|
"types": "./src/core-types.ts"
|
|
35
38
|
},
|
|
@@ -57,9 +60,13 @@
|
|
|
57
60
|
"api-signatures.json",
|
|
58
61
|
"url-parameters.json",
|
|
59
62
|
"index.d.ts",
|
|
63
|
+
"fixtures/messages_doc.json",
|
|
64
|
+
"fixtures/defold-*",
|
|
65
|
+
"examples/translations.json",
|
|
60
66
|
"!src/**/*.test.ts",
|
|
61
67
|
"!scripts/**/*.test.ts",
|
|
62
|
-
"!src/**/__snapshots__"
|
|
68
|
+
"!src/**/__snapshots__",
|
|
69
|
+
"!scripts/lua-types-signature-index.ts"
|
|
63
70
|
],
|
|
64
71
|
"publishConfig": {
|
|
65
72
|
"access": "public"
|
|
@@ -75,7 +82,8 @@
|
|
|
75
82
|
"ref-doc-delta": "bun scripts/ref-doc-delta.ts --target defold-1.9.8 --namespace label --present label.get_text --absent label.set_text"
|
|
76
83
|
},
|
|
77
84
|
"dependencies": {
|
|
78
|
-
"lua-types": "^2.13.1"
|
|
85
|
+
"lua-types": "^2.13.1",
|
|
86
|
+
"yaml": "^2.9.0"
|
|
79
87
|
},
|
|
80
88
|
"devDependencies": {
|
|
81
89
|
"@typescript-to-lua/language-extensions": "1.19.0",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
2
|
import { dirname, resolve } from "node:path";
|
|
3
3
|
import { isKnownDefoldTypeToken } from "../src/emit-dts";
|
|
4
4
|
import { refDocCacheDir, resolveRefDoc } from "./doc-source";
|
|
@@ -387,6 +387,23 @@ export function applyReleaseImport(plan: ReleaseImportPlan, packageRoot = PACKAG
|
|
|
387
387
|
writeFileSync(path, `${JSON.stringify(snapshot.doc, null, 2)}\n`);
|
|
388
388
|
written.push(relative);
|
|
389
389
|
}
|
|
390
|
+
// The prefixless builtins (`hash`, `pprint`, ...) are hand-vendored rather than
|
|
391
|
+
// generated, so no upstream snapshot carries them. Seeding the canonical copy
|
|
392
|
+
// here is what keeps a newly imported target from being born without a globals
|
|
393
|
+
// document — which the availability projection would read as a removal. The
|
|
394
|
+
// source is always the real package's canonical file, never `packageRoot`,
|
|
395
|
+
// which for a writer test is an empty temp tree.
|
|
396
|
+
const canonicalGlobals = resolve(PACKAGE_ROOT, "fixtures/globals_doc.json");
|
|
397
|
+
if (!existsSync(canonicalGlobals))
|
|
398
|
+
throw new Error(`missing canonical globals document at ${canonicalGlobals}`);
|
|
399
|
+
const globals = JSON.parse(readFileSync(canonicalGlobals, "utf8")) as {
|
|
400
|
+
info: Record<string, unknown>;
|
|
401
|
+
};
|
|
402
|
+
globals.info = { ...globals.info, version: plan.version };
|
|
403
|
+
const globalsPath = `${relativeRoot}/globals_doc.json`;
|
|
404
|
+
writeFileSync(resolve(packageRoot, globalsPath), `${JSON.stringify(globals, null, 2)}\n`);
|
|
405
|
+
written.push(globalsPath);
|
|
406
|
+
|
|
390
407
|
const manifestPath = `${relativeRoot}/import-manifest.json`;
|
|
391
408
|
writeFileSync(resolve(packageRoot, manifestPath), releaseImportReportJson(plan));
|
|
392
409
|
written.push(manifestPath);
|
package/src/example-store.ts
CHANGED
|
@@ -10,6 +10,11 @@ export interface Translation {
|
|
|
10
10
|
// An FQN maps to one translation per distinct example body it carries: an
|
|
11
11
|
// overloaded element (same name, differing `@example` source) contributes one
|
|
12
12
|
// array entry per body, each pinned by its own `sourceHash`.
|
|
13
|
+
//
|
|
14
|
+
// add-don't-swap: a ref-doc re-pin that rewrites an element's example must
|
|
15
|
+
// *append* the translation for the new source hash, never overwrite the entry
|
|
16
|
+
// for the old one. Older API targets keep shipping the previous body, so
|
|
17
|
+
// replacing the entry silently regresses every demoted surface to raw Lua.
|
|
13
18
|
export type TranslationStore = Record<string, Translation[]>;
|
|
14
19
|
|
|
15
20
|
const FNV_OFFSET_BASIS = 0xcbf29ce484222325n;
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
import { readFileSync } from "node:fs";
|
|
2
|
-
import { resolve } from "node:path";
|
|
3
|
-
import * as ts from "typescript";
|
|
4
|
-
|
|
5
|
-
// Build-time only: lives under `scripts/` (never reachable from the shipped
|
|
6
|
-
// `src/index.ts` graph) so its `typescript`/`node:fs` imports cannot leak into a
|
|
7
|
-
// consumer's typecheck, exactly like `signature-store-fs.ts`.
|
|
8
|
-
|
|
9
|
-
// One indexed declaration: how many overloads the source carries for the FQN
|
|
10
|
-
// and, per overload, the parameter names (so a future check can compare optional
|
|
11
|
-
// params). A `const`/`var`/property value is recorded as a single entry with an
|
|
12
|
-
// empty parameter list.
|
|
13
|
-
export interface SignatureIndexEntry {
|
|
14
|
-
overloadCount: number;
|
|
15
|
-
params: string[][];
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// FQN (`string.byte`, `file:read`, `socket.dns.toip`, bare `pcall`) -> entry.
|
|
19
|
-
export type SignatureIndex = Map<string, SignatureIndexEntry>;
|
|
20
|
-
|
|
21
|
-
export const LUA_TYPES_DIR = resolve(import.meta.dir, "..", "node_modules", "lua-types");
|
|
22
|
-
|
|
23
|
-
export function luaTypesFile(...segments: string[]): string {
|
|
24
|
-
return resolve(LUA_TYPES_DIR, ...segments);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function recordEntry(index: SignatureIndex, key: string, params: string[]): void {
|
|
28
|
-
const existing = index.get(key);
|
|
29
|
-
if (existing) {
|
|
30
|
-
existing.overloadCount += 1;
|
|
31
|
-
existing.params.push(params);
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
index.set(key, { overloadCount: 1, params: [params] });
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function parameterNames(parameters: ts.NodeArray<ts.ParameterDeclaration>): string[] {
|
|
38
|
-
return parameters.map((parameter) =>
|
|
39
|
-
ts.isIdentifier(parameter.name) ? parameter.name.text : parameter.name.getText(),
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// `declare global { ... }` is a transparent wrapper (the repo's `generated/*.d.ts`
|
|
44
|
-
// nest their namespace under it); its members keep the surrounding prefix.
|
|
45
|
-
function isGlobalAugmentation(node: ts.ModuleDeclaration): boolean {
|
|
46
|
-
if ((node.flags & ts.NodeFlags.GlobalAugmentation) !== 0) return true;
|
|
47
|
-
return ts.isIdentifier(node.name) && node.name.text === "global";
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function qualify(prefix: string, name: string): string {
|
|
51
|
-
return prefix ? `${prefix}.${name}` : name;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function visit(
|
|
55
|
-
node: ts.Node,
|
|
56
|
-
prefix: string,
|
|
57
|
-
handleByInterface: Map<string, string>,
|
|
58
|
-
index: SignatureIndex,
|
|
59
|
-
): void {
|
|
60
|
-
if (ts.isFunctionDeclaration(node) && node.name) {
|
|
61
|
-
recordEntry(index, qualify(prefix, node.name.text), parameterNames(node.parameters));
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (ts.isModuleDeclaration(node)) {
|
|
66
|
-
const childPrefix = isGlobalAugmentation(node)
|
|
67
|
-
? prefix
|
|
68
|
-
: ts.isIdentifier(node.name)
|
|
69
|
-
? qualify(prefix, node.name.text)
|
|
70
|
-
: prefix;
|
|
71
|
-
if (node.body) {
|
|
72
|
-
if (ts.isModuleBlock(node.body)) {
|
|
73
|
-
for (const statement of node.body.statements) {
|
|
74
|
-
visit(statement, childPrefix, handleByInterface, index);
|
|
75
|
-
}
|
|
76
|
-
} else if (ts.isModuleDeclaration(node.body)) {
|
|
77
|
-
visit(node.body, childPrefix, handleByInterface, index);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// Handle interfaces are re-keyed by their handle name (`LuaFile` -> `file:read`,
|
|
84
|
-
// socket's `client` -> `client:close`); non-handle interfaces are ignored. This
|
|
85
|
-
// fires for both top-level interfaces (io's `LuaFile`) and interfaces nested in
|
|
86
|
-
// a namespace (socket's handle interfaces), so the surrounding prefix is dropped.
|
|
87
|
-
if (ts.isInterfaceDeclaration(node)) {
|
|
88
|
-
const handle = handleByInterface.get(node.name.text);
|
|
89
|
-
if (!handle) return;
|
|
90
|
-
for (const member of node.members) {
|
|
91
|
-
if (!member.name || !ts.isIdentifier(member.name)) continue;
|
|
92
|
-
if (ts.isMethodSignature(member)) {
|
|
93
|
-
recordEntry(index, `${handle}:${member.name.text}`, parameterNames(member.parameters));
|
|
94
|
-
} else if (ts.isPropertySignature(member)) {
|
|
95
|
-
recordEntry(index, `${handle}:${member.name.text}`, []);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
if (ts.isVariableStatement(node)) {
|
|
102
|
-
for (const declaration of node.declarationList.declarations) {
|
|
103
|
-
if (ts.isIdentifier(declaration.name)) {
|
|
104
|
-
recordEntry(index, qualify(prefix, declaration.name.text), []);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function reverseHandles(handleInterfaces: Record<string, string>): Map<string, string> {
|
|
111
|
-
return new Map(Object.entries(handleInterfaces).map(([handle, iface]) => [iface, handle]));
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
function indexSourceFile(
|
|
115
|
-
index: SignatureIndex,
|
|
116
|
-
fileName: string,
|
|
117
|
-
source: string,
|
|
118
|
-
handleByInterface: Map<string, string>,
|
|
119
|
-
): void {
|
|
120
|
-
const sourceFile = ts.createSourceFile(fileName, source, ts.ScriptTarget.Latest, true);
|
|
121
|
-
for (const statement of sourceFile.statements) {
|
|
122
|
-
visit(statement, "", handleByInterface, index);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
// Parse one in-memory `.d.ts` source into an index (or fold into `into`). Used by
|
|
127
|
-
// the drift guard's synthetic-source cases; the file-reading path delegates here.
|
|
128
|
-
export function indexDeclarationSource(
|
|
129
|
-
fileName: string,
|
|
130
|
-
source: string,
|
|
131
|
-
handleInterfaces: Record<string, string> = {},
|
|
132
|
-
into?: SignatureIndex,
|
|
133
|
-
): SignatureIndex {
|
|
134
|
-
const index = into ?? new Map<string, SignatureIndexEntry>();
|
|
135
|
-
indexSourceFile(index, fileName, source, reverseHandles(handleInterfaces));
|
|
136
|
-
return index;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// Parse each `.d.ts` file and fold every declaration into one FQN -> entry index.
|
|
140
|
-
// When an FQN appears in more than one file its overloads accumulate.
|
|
141
|
-
export function buildSignatureIndex(
|
|
142
|
-
filePaths: string[],
|
|
143
|
-
handleInterfaces: Record<string, string> = {},
|
|
144
|
-
): SignatureIndex {
|
|
145
|
-
const index = new Map<string, SignatureIndexEntry>();
|
|
146
|
-
const handleByInterface = reverseHandles(handleInterfaces);
|
|
147
|
-
for (const filePath of filePaths) {
|
|
148
|
-
indexSourceFile(index, filePath, readFileSync(filePath, "utf8"), handleByInterface);
|
|
149
|
-
}
|
|
150
|
-
return index;
|
|
151
|
-
}
|