@defold-typescript/types 0.19.3 → 0.20.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.
Files changed (86) hide show
  1. package/api-availability.json +2755 -0
  2. package/api-migrations.json +31 -0
  3. package/api-signatures.json +2324 -0
  4. package/api-targets.json +493 -45
  5. package/generated/b2d.d.ts +6 -0
  6. package/generated/b2d_body.d.ts +329 -1
  7. package/generated/b2d_chain.d.ts +106 -0
  8. package/generated/b2d_fixture.d.ts +155 -0
  9. package/generated/b2d_joint.d.ts +823 -0
  10. package/generated/b2d_shape.d.ts +215 -0
  11. package/generated/b2d_world.d.ts +314 -0
  12. package/generated/builtin-messages.d.ts +18 -0
  13. package/generated/camera.d.ts +62 -5
  14. package/generated/compute.d.ts +306 -0
  15. package/generated/go.d.ts +29 -4
  16. package/generated/graphics.d.ts +95 -0
  17. package/generated/gui.d.ts +1 -3
  18. package/generated/json.d.ts +2 -2
  19. package/generated/kinds/gui-script.d.ts +7 -0
  20. package/generated/kinds/render-script.d.ts +7 -0
  21. package/generated/kinds/script.d.ts +7 -0
  22. package/generated/label.d.ts +1 -1
  23. package/generated/liveupdate.d.ts +22 -4
  24. package/generated/material.d.ts +444 -0
  25. package/generated/model.d.ts +46 -5
  26. package/generated/physics.d.ts +1 -3
  27. package/generated/profiler.d.ts +2 -3
  28. package/generated/render.d.ts +25 -9
  29. package/generated/resource.d.ts +2 -2
  30. package/generated/sprite.d.ts +15 -1
  31. package/generated/tilemap.d.ts +14 -0
  32. package/generated/versions/defold-1.12.4/b2d.d.ts +27 -0
  33. package/generated/versions/defold-1.12.4/b2d_body.d.ts +348 -0
  34. package/generated/versions/defold-1.12.4/buffer.d.ts +176 -0
  35. package/generated/versions/defold-1.12.4/camera.d.ts +245 -0
  36. package/generated/versions/defold-1.12.4/collectionfactory.d.ts +146 -0
  37. package/generated/versions/defold-1.12.4/collectionproxy.d.ts +71 -0
  38. package/generated/versions/defold-1.12.4/crash.d.ts +143 -0
  39. package/generated/versions/defold-1.12.4/factory.d.ts +123 -0
  40. package/generated/versions/defold-1.12.4/font.d.ts +81 -0
  41. package/generated/versions/defold-1.12.4/go.d.ts +1029 -0
  42. package/generated/versions/defold-1.12.4/graphics.d.ts +226 -0
  43. package/generated/versions/defold-1.12.4/gui.d.ts +2372 -0
  44. package/generated/versions/defold-1.12.4/html5.d.ts +53 -0
  45. package/generated/versions/defold-1.12.4/http.d.ts +84 -0
  46. package/generated/versions/defold-1.12.4/iac.d.ts +18 -0
  47. package/generated/versions/defold-1.12.4/iap.d.ts +60 -0
  48. package/generated/versions/defold-1.12.4/image.d.ts +139 -0
  49. package/generated/versions/defold-1.12.4/index.d.ts +41 -0
  50. package/generated/versions/defold-1.12.4/json.d.ts +76 -0
  51. package/generated/versions/defold-1.12.4/label.d.ts +94 -0
  52. package/generated/versions/defold-1.12.4/liveupdate.d.ts +122 -0
  53. package/generated/versions/defold-1.12.4/model.d.ts +205 -0
  54. package/generated/versions/defold-1.12.4/msg.d.ts +10 -0
  55. package/generated/versions/defold-1.12.4/particlefx.d.ts +166 -0
  56. package/generated/versions/defold-1.12.4/physics.d.ts +547 -0
  57. package/generated/versions/defold-1.12.4/profiler.d.ts +234 -0
  58. package/generated/versions/defold-1.12.4/push.d.ts +66 -0
  59. package/generated/versions/defold-1.12.4/render.d.ts +1149 -0
  60. package/generated/versions/defold-1.12.4/resource.d.ts +1518 -0
  61. package/generated/versions/defold-1.12.4/socket.d.ts +795 -0
  62. package/generated/versions/defold-1.12.4/sound.d.ts +291 -0
  63. package/generated/versions/defold-1.12.4/sprite.d.ts +143 -0
  64. package/generated/versions/defold-1.12.4/sys.d.ts +695 -0
  65. package/generated/versions/defold-1.12.4/tilemap.d.ts +181 -0
  66. package/generated/versions/defold-1.12.4/timer.d.ts +114 -0
  67. package/generated/versions/defold-1.12.4/types.d.ts +61 -0
  68. package/generated/versions/defold-1.12.4/vmath.d.ts +806 -0
  69. package/generated/versions/defold-1.12.4/webview.d.ts +68 -0
  70. package/generated/versions/defold-1.12.4/window.d.ts +198 -0
  71. package/generated/versions/defold-1.12.4/zlib.d.ts +40 -0
  72. package/index.d.ts +22 -0
  73. package/package.json +8 -1
  74. package/scripts/fidelity-audit.ts +69 -12
  75. package/scripts/fidelity-baseline.json +56 -0
  76. package/scripts/generate-api-availability.ts +139 -0
  77. package/scripts/generate-api-signatures.ts +66 -0
  78. package/scripts/import-defold-release.ts +480 -0
  79. package/scripts/regen.ts +53 -6
  80. package/scripts/sync-api-docs.ts +89 -41
  81. package/src/api-availability.ts +0 -0
  82. package/src/core-types.ts +9 -0
  83. package/src/emit-dts.ts +674 -17
  84. package/src/emit-messages.ts +72 -2
  85. package/src/index.ts +26 -1
  86. package/src/lifecycle.ts +43 -2
@@ -0,0 +1,695 @@
1
+ /** @noSelfInFile */
2
+ import type { Opaque } from "../../../src/core-types";
3
+
4
+ declare global {
5
+ /**
6
+ * Functions and messages for using system resources, controlling the engine,
7
+ * error handling and debugging.
8
+ */
9
+ namespace sys {
10
+ /**
11
+ * network connected through other, non cellular, connection
12
+ */
13
+ const NETWORK_CONNECTED: number & { readonly __brand: "sys.NETWORK_CONNECTED" };
14
+ /**
15
+ * network connected through mobile cellular
16
+ */
17
+ const NETWORK_CONNECTED_CELLULAR: number & { readonly __brand: "sys.NETWORK_CONNECTED_CELLULAR" };
18
+ /**
19
+ * no network connection found
20
+ */
21
+ const NETWORK_DISCONNECTED: number & { readonly __brand: "sys.NETWORK_DISCONNECTED" };
22
+ /**
23
+ * an asyncronous request is unable to read the resource
24
+ */
25
+ const REQUEST_STATUS_ERROR_IO_ERROR: number & { readonly __brand: "sys.REQUEST_STATUS_ERROR_IO_ERROR" };
26
+ /**
27
+ * an asyncronous request is unable to locate the resource
28
+ */
29
+ const REQUEST_STATUS_ERROR_NOT_FOUND: number & { readonly __brand: "sys.REQUEST_STATUS_ERROR_NOT_FOUND" };
30
+ /**
31
+ * an asyncronous request has finished successfully
32
+ */
33
+ const REQUEST_STATUS_FINISHED: number & { readonly __brand: "sys.REQUEST_STATUS_FINISHED" };
34
+ /**
35
+ * This function will raise a Lua error if an error occurs while deserializing the buffer.
36
+ *
37
+ * @param buffer - buffer to deserialize from
38
+ * @returns lua table with deserialized data
39
+ * @example
40
+ * ```ts
41
+ * // Deserialize a table that was previously serialized:
42
+ * const buffer = sys.serialize(my_table);
43
+ * const table = sys.deserialize(buffer);
44
+ * ```
45
+ */
46
+ function deserialize(buffer: string): Record<string | number, unknown>;
47
+ /**
48
+ * Check if a path exists
49
+ * Good for checking if a file exists before loading a large file
50
+ *
51
+ * @param path - path to check
52
+ * @returns `true` if the path exists, `false` otherwise
53
+ * @example
54
+ * ```ts
55
+ * // Load data but return nil if path didn't exist
56
+ * if (!sys.exists(path)) {
57
+ * return undefined;
58
+ * }
59
+ * return sys.load(path); // returns {} if it failed
60
+ * ```
61
+ */
62
+ function exists(path: string): boolean;
63
+ /**
64
+ * Terminates the game application and reports the specified `code` to the OS.
65
+ *
66
+ * @param code - exit code to report to the OS, 0 means clean exit
67
+ * @example
68
+ * ```ts
69
+ * // This example demonstrates how to exit the application when some kind of quit
70
+ * // message is received (maybe from gui or similar):
71
+ * export default defineScript({
72
+ * on_message(self, message_id, message, sender) {
73
+ * if (message_id === hash("quit")) {
74
+ * sys.exit(0);
75
+ * }
76
+ * },
77
+ * });
78
+ * ```
79
+ */
80
+ function exit(code: number): void;
81
+ /**
82
+ * Returns a table with application information for the requested app.
83
+ * On iOS, the `app_string` is an url scheme for the app that is queried. Your
84
+ * game needs to list the schemes that are queried in an `LSApplicationQueriesSchemes` array
85
+ * in a custom "Info.plist".
86
+ * On Android, the `app_string` is the package identifier for the app.
87
+ *
88
+ * @param app_string - platform specific string with application package or query, see above for details.
89
+ * @returns table with application information in the following fields:
90
+ *
91
+ * `installed`
92
+ * boolean `true` if the application is installed, `false` otherwise.
93
+ * @example
94
+ * ```ts
95
+ * // Check if twitter is installed:
96
+ * const sysinfo = sys.get_sys_info();
97
+ * let twitter = {};
98
+ *
99
+ * if (sysinfo.system_name === "Android") {
100
+ * twitter = sys.get_application_info("com.twitter.android");
101
+ * } else if (sysinfo.system_name === "iPhone OS") {
102
+ * twitter = sys.get_application_info("twitter:");
103
+ * }
104
+ *
105
+ * if (twitter.installed) {
106
+ * // twitter is installed!
107
+ * }
108
+ *
109
+ * // Info.plist for the iOS app needs to list the schemes that are queried:
110
+ * // ...
111
+ * // <key>LSApplicationQueriesSchemes</key>
112
+ * // <array>
113
+ * // <string>twitter</string>
114
+ * // </array>
115
+ * // ...
116
+ * ```
117
+ */
118
+ function get_application_info(app_string: string): { installed: boolean };
119
+ /**
120
+ * The path from which the application is run.
121
+ * This function will raise a Lua error if unable to get the application support path.
122
+ *
123
+ * @returns path to application executable
124
+ * @example
125
+ * ```ts
126
+ * // Find a path where we can store data (the example path is on the macOS platform):
127
+ * // macOS: /Applications/my_game.app
128
+ * const application_path = sys.get_application_path();
129
+ * print(application_path); //> /Applications/my_game.app
130
+ *
131
+ * // Windows: C:\Program Files\my_game\my_game.exe
132
+ * print(application_path); //> C:\Program Files\my_game
133
+ *
134
+ * // Linux: /home/foobar/my_game/my_game
135
+ * print(application_path); //> /home/foobar/my_game
136
+ *
137
+ * // Android package name: com.foobar.my_game
138
+ * print(application_path); //> /data/user/0/com.foobar.my_game
139
+ *
140
+ * // iOS: my_game.app
141
+ * print(application_path); //> /var/containers/Bundle/Applications/123456AB-78CD-90DE-12345678ABCD/my_game.app
142
+ *
143
+ * // HTML5: http://www.foobar.com/my_game/
144
+ * print(application_path); //> http://www.foobar.com/my_game
145
+ * ```
146
+ */
147
+ function get_application_path(): string;
148
+ /**
149
+ * Get boolean config value from the game.project configuration file with optional default value
150
+ *
151
+ * @param key - key to get value for. The syntax is SECTION.KEY
152
+ * @param default_value - (optional) default value to return if the value does not exist
153
+ * @returns config value as a boolean. default_value if the config key does not exist. false if no default value was supplied.
154
+ * @example
155
+ * ```ts
156
+ * // Get user config value
157
+ * const vsync = sys.get_config_boolean("display.vsync", false);
158
+ * ```
159
+ */
160
+ function get_config_boolean(key: string, default_value?: boolean): boolean;
161
+ /**
162
+ * Get integer config value from the game.project configuration file with optional default value
163
+ *
164
+ * @param key - key to get value for. The syntax is SECTION.KEY
165
+ * @param default_value - (optional) default value to return if the value does not exist
166
+ * @returns config value as an integer. default_value if the config key does not exist. 0 if no default value was supplied.
167
+ * @example
168
+ * ```ts
169
+ * // Get user config value
170
+ * const speed = sys.get_config_int("my_game.speed", 20); // with default value
171
+ *
172
+ * const testmode = sys.get_config_int("my_game.testmode"); // without default value
173
+ * if (testmode !== undefined) {
174
+ * // do stuff
175
+ * }
176
+ * ```
177
+ */
178
+ function get_config_int(key: string, default_value?: number): number;
179
+ /**
180
+ * Get number config value from the game.project configuration file with optional default value
181
+ *
182
+ * @param key - key to get value for. The syntax is SECTION.KEY
183
+ * @param default_value - (optional) default value to return if the value does not exist
184
+ * @returns config value as an number. default_value if the config key does not exist. 0 if no default value was supplied.
185
+ * @example
186
+ * ```ts
187
+ * // Get user config value
188
+ * const speed = sys.get_config_number("my_game.speed", 20.0);
189
+ * ```
190
+ */
191
+ function get_config_number(key: string, default_value?: number): number;
192
+ /**
193
+ * Get string config value from the game.project configuration file with optional default value
194
+ *
195
+ * @param key - key to get value for. The syntax is SECTION.KEY
196
+ * @param default_value - (optional) default value to return if the value does not exist
197
+ * @returns config value as a string. default_value if the config key does not exist. nil if no default value was supplied.
198
+ * @example
199
+ * ```ts
200
+ * // Get user config value
201
+ * const text = sys.get_config_string("my_game.text", "default text");
202
+ *
203
+ * // Start the engine with a bootstrap config override and add a custom config value
204
+ * // $ dmengine --config=bootstrap.main_collection=/mytest.collectionc --config=mygame.testmode=1
205
+ *
206
+ * // Read the custom config value from the command line
207
+ * const testmode = sys.get_config_int("mygame.testmode");
208
+ * ```
209
+ */
210
+ function get_config_string(key: string, default_value?: string): string;
211
+ /**
212
+ * Returns the current network connectivity status
213
+ * on mobile platforms.
214
+ * On desktop, this function always return `sys.NETWORK_CONNECTED`.
215
+ *
216
+ * @returns network connectivity status:
217
+ *
218
+ * - `sys.NETWORK_DISCONNECTED` (no network connection is found)
219
+ *
220
+ * - `sys.NETWORK_CONNECTED_CELLULAR` (connected through mobile cellular)
221
+ *
222
+ * - `sys.NETWORK_CONNECTED` (otherwise, Wifi)
223
+ * @example
224
+ * ```ts
225
+ * // Check if we are connected through a cellular connection
226
+ * if (sys.NETWORK_CONNECTED_CELLULAR === sys.get_connectivity()) {
227
+ * print("Connected via cellular, avoid downloading big files!");
228
+ * }
229
+ * ```
230
+ */
231
+ function get_connectivity(): Opaque<"constant">;
232
+ /**
233
+ * Returns a table with engine information.
234
+ *
235
+ * @returns table with engine information in the following fields:
236
+ *
237
+ * `version`
238
+ * string The current Defold engine version, i.e. "1.2.96"
239
+ * `version_sha1`
240
+ * string The SHA1 for the current engine build, i.e. "0060183cce2e29dbd09c85ece83cbb72068ee050"
241
+ * `is_debug`
242
+ * boolean If the engine is a debug or release version
243
+ * @example
244
+ * ```ts
245
+ * // How to retrieve engine information:
246
+ * // Update version text label so our testers know what version we're running
247
+ * const engine_info = sys.get_engine_info();
248
+ * const version_str = `Defold ${engine_info.version}\n${engine_info.version_sha1}`;
249
+ * gui.set_text(gui.get_node("version"), version_str);
250
+ * ```
251
+ */
252
+ function get_engine_info(): { version: string; version_sha1: string; is_debug: boolean };
253
+ /**
254
+ * Create a path to the host device for unit testing
255
+ * Useful for saving logs etc during development
256
+ *
257
+ * @param filename - file to read from
258
+ * @returns the path prefixed with the proper host mount
259
+ * @example
260
+ * ```ts
261
+ * // Save data on the host
262
+ * const host_path = sys.get_host_path("logs/test.txt");
263
+ * sys.save(host_path, mytable);
264
+ *
265
+ * // Load data from the host
266
+ * const host_path = sys.get_host_path("logs/test.txt");
267
+ * const table = sys.load(host_path);
268
+ * ```
269
+ */
270
+ function get_host_path(filename: string): string;
271
+ /**
272
+ * Returns an array of tables with information on network interfaces.
273
+ *
274
+ * @returns an array of tables. Each table entry contain the following fields:
275
+ *
276
+ * `name`
277
+ * string Interface name
278
+ * `address`
279
+ * string IP address. might be `nil` if not available.
280
+ * `mac`
281
+ * string Hardware MAC address. might be nil if not available.
282
+ * `up`
283
+ * boolean `true` if the interface is up (available to transmit and receive data), `false` otherwise.
284
+ * `running`
285
+ * boolean `true` if the interface is running, `false` otherwise.
286
+ * @example
287
+ * ```ts
288
+ * // How to get the IP address of interface "en0":
289
+ * const ifaddrs = sys.get_ifaddrs();
290
+ * for (const iface of ifaddrs) {
291
+ * if (iface.name === "en0") {
292
+ * const ip = iface.address;
293
+ * }
294
+ * }
295
+ * ```
296
+ */
297
+ function get_ifaddrs(): { name: string; address: string; mac: string; up: boolean; running: boolean }[];
298
+ /**
299
+ * The save-file path is operating system specific and is typically located under the user's home directory.
300
+ * This function will raise a Lua error if unable to get the save file path.
301
+ *
302
+ * @param application_id - user defined id of the application, which helps define the location of the save-file
303
+ * @param file_name - file-name to get path for
304
+ * @returns path to save-file
305
+ * @example
306
+ * ```ts
307
+ * // Find a path where we can store data:
308
+ * const my_file_path = sys.get_save_file("my_game", "my_file");
309
+ * // macOS: /Users/foobar/Library/Application Support/my_game/my_file
310
+ * print(my_file_path); //> /Users/foobar/Library/Application Support/my_game/my_file
311
+ *
312
+ * // Windows: C:\Users\foobar\AppData\Roaming\my_game\my_file
313
+ * print(my_file_path); //> C:\Users\foobar\AppData\Roaming\my_game\my_file
314
+ *
315
+ * // Linux: $XDG_DATA_HOME/my_game/my_file or /home/foobar/.my_game/my_file
316
+ * // Linux: Defaults to /home/foobar/.local/share/my_game/my_file if neither exist.
317
+ * print(my_file_path); //> /home/foobar/.local/share/my_game/my_file
318
+ *
319
+ * // Android package name: com.foobar.packagename
320
+ * print(my_file_path); //> /data/data/0/com.foobar.packagename/files/my_file
321
+ *
322
+ * // iOS: my_game.app
323
+ * print(my_file_path); //> /var/mobile/Containers/Data/Application/123456AB-78CD-90DE-12345678ABCD/my_game/my_file
324
+ *
325
+ * // HTML5 path inside the IndexedDB: /data/.my_game/my_file or /.my_game/my_file
326
+ * print(my_file_path); //> /data/.my_game/my_file
327
+ * ```
328
+ */
329
+ function get_save_file(application_id: string, file_name: string): string;
330
+ /**
331
+ * Returns a table with system information.
332
+ *
333
+ * @param options - optional options table
334
+ * - ignore_secure boolean this flag ignores values might be secured by OS e.g. `device_ident`
335
+ * @returns table with system information in the following fields:
336
+ *
337
+ * `device_model`
338
+ * string Only available on iOS and Android.
339
+ * `manufacturer`
340
+ * string Only available on iOS and Android.
341
+ * `system_name`
342
+ * string The system name: "Darwin", "Linux", "Windows", "HTML5", "Android" or "iPhone OS"
343
+ * `system_version`
344
+ * string The system OS version.
345
+ * `api_version`
346
+ * string The API version on the system.
347
+ * `language`
348
+ * string Two character ISO-639 format, i.e. "en".
349
+ * `device_language`
350
+ * string Two character ISO-639 format (i.e. "sr") and, if applicable, followed by a dash (-) and an ISO 15924 script code (i.e. "sr-Cyrl" or "sr-Latn"). Reflects the device preferred language.
351
+ * `territory`
352
+ * string Two character ISO-3166 format, i.e. "US".
353
+ * `gmt_offset`
354
+ * number The current offset from GMT (Greenwich Mean Time), in minutes.
355
+ * `device_ident`
356
+ * string This value secured by OS. "identifierForVendor" on iOS. "android_id" on Android. On Android, you need to add `READ_PHONE_STATE` permission to be able to get this data. We don't use this permission in Defold.
357
+ * `user_agent`
358
+ * string The HTTP user agent, i.e. "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/602.4.8 (KHTML, like Gecko) Version/10.0.3 Safari/602.4.8"
359
+ * @example
360
+ * ```ts
361
+ * // How to get system information:
362
+ * const info = sys.get_sys_info();
363
+ * if (info.system_name === "HTML5") {
364
+ * // We are running in a browser.
365
+ * }
366
+ * ```
367
+ */
368
+ function get_sys_info(options?: { ignore_secure?: boolean }): { device_model: string; manufacturer: string; system_name: string; system_version: string; api_version: string; language: string; device_language: string; territory: string; gmt_offset: number; device_ident: string; user_agent: string };
369
+ /**
370
+ * If the file exists, it must have been created by `sys.save` to be loaded.
371
+ * This function will raise a Lua error if an error occurs while loading the file.
372
+ *
373
+ * @param filename - file to read from
374
+ * @returns lua table, which is empty if the file could not be found
375
+ * @example
376
+ * ```ts
377
+ * // Load data that was previously saved, e.g. an earlier game session:
378
+ * const my_file_path = sys.get_save_file("my_game", "my_file");
379
+ * const my_table = sys.load(my_file_path);
380
+ * if (!next(my_table)) {
381
+ * // empty table
382
+ * }
383
+ * ```
384
+ */
385
+ function load(filename: string): Record<string | number, unknown>;
386
+ /**
387
+ * The sys.load_buffer function will first try to load the resource
388
+ * from any of the mounted resource locations and return the data if
389
+ * any matching entries found. If not, the path will be tried
390
+ * as is from the primary disk on the device.
391
+ * In order for the engine to include custom resources in the build process, you need
392
+ * to specify them in the "custom_resources" key in your "game.project" settings file.
393
+ * You can specify single resource files or directories. If a directory is included
394
+ * in the resource list, all files and directories in that directory is recursively
395
+ * included:
396
+ * For example "main/data/,assets/level_data.json".
397
+ *
398
+ * @param path - the path to load the buffer from
399
+ * @returns the buffer with data
400
+ * @example
401
+ * ```ts
402
+ * // Load binary data from a custom project resource:
403
+ * const my_buffer = sys.load_buffer("/assets/my_level_data.bin");
404
+ * const data_str = buffer.get_bytes(my_buffer, "data");
405
+ * const has_my_header = data_str.slice(0, 6) === "D3F0LD";
406
+ *
407
+ * // Load binary data from non-custom resource files on disk:
408
+ * const asset_1 = sys.load_buffer("folder_next_to_binary/my_level_asset.txt");
409
+ * const asset_2 = sys.load_buffer("/my/absolute/path");
410
+ * ```
411
+ */
412
+ function load_buffer(path: string): Opaque<"buffer">;
413
+ /**
414
+ * The sys.load_buffer function will first try to load the resource
415
+ * from any of the mounted resource locations and return the data if
416
+ * any matching entries found. If not, the path will be tried
417
+ * as is from the primary disk on the device.
418
+ * In order for the engine to include custom resources in the build process, you need
419
+ * to specify them in the "custom_resources" key in your "game.project" settings file.
420
+ * You can specify single resource files or directories. If a directory is included
421
+ * in the resource list, all files and directories in that directory is recursively
422
+ * included:
423
+ * For example "main/data/,assets/level_data.json".
424
+ * Note that issuing multiple requests of the same resource will yield
425
+ * individual buffers per request. There is no implic caching of the buffers
426
+ * based on request path.
427
+ *
428
+ * @param path - the path to load the buffer from
429
+ * @param status_callback - A status callback that will be invoked when a request has been handled, or an error occured. The result is a table containing:
430
+ *
431
+ * `status`
432
+ * number The status of the request, supported values are:
433
+ *
434
+ * - `resource.REQUEST_STATUS_FINISHED`
435
+ *
436
+ * - `resource.REQUEST_STATUS_ERROR_IO_ERROR`
437
+ *
438
+ * - `resource.REQUEST_STATUS_ERROR_NOT_FOUND`
439
+ *
440
+ * `buffer`
441
+ * buffer If the request was successfull, this will contain the request payload in a buffer object, and nil otherwise. Make sure to check the status before doing anything with the buffer value!
442
+ * @returns a handle to the request
443
+ * @example
444
+ * ```ts
445
+ * // Load binary data from a custom project resource and update a texture resource:
446
+ * function my_callback(self, request_id, result) {
447
+ * if (result.status === resource.REQUEST_STATUS_FINISHED) {
448
+ * resource.set_texture("/my_texture", {}, result.buf); // texture args
449
+ * }
450
+ * }
451
+ *
452
+ * const my_request = sys.load_buffer_async("/assets/my_level_data.bin", my_callback);
453
+ *
454
+ * // Load binary data from non-custom resource files on disk:
455
+ * function my_callback(self, request_id, result) {
456
+ * if (result.status !== sys.REQUEST_STATUS_FINISHED) {
457
+ * // uh oh! File could not be found, do something graceful
458
+ * } else if (request_id === self.first_asset) {
459
+ * // result.buffer contains data from my_level_asset.bin
460
+ * } else if (request_id === self.second_asset) {
461
+ * // result.buffer contains data from 'my_level.bin'
462
+ * }
463
+ * }
464
+ *
465
+ * export default defineScript({
466
+ * init(self) {
467
+ * self.first_asset = hash("folder_next_to_binary/my_level_asset.bin");
468
+ * self.second_asset = hash("/some_absolute_path/my_level.bin");
469
+ * self.first_request = sys.load_buffer_async(self.first_asset, my_callback);
470
+ * self.second_request = sys.load_buffer_async(self.second_asset, my_callback);
471
+ * },
472
+ * });
473
+ * ```
474
+ */
475
+ function load_buffer_async(path: string, status_callback: (self: unknown, request_id: unknown, result: unknown) => void): number;
476
+ /**
477
+ * Loads a custom resource. Specify the full filename of the resource that you want
478
+ * to load. When loaded, the file data is returned as a string.
479
+ * If loading fails, the function returns `nil` plus the error message.
480
+ * In order for the engine to include custom resources in the build process, you need
481
+ * to specify them in the "custom_resources" key in your "game.project" settings file.
482
+ * You can specify single resource files or directories. If a directory is included
483
+ * in the resource list, all files and directories in that directory is recursively
484
+ * included:
485
+ * For example "main/data/,assets/level_data.json".
486
+ *
487
+ * @param filename - resource to load, full path
488
+ * @example
489
+ * ```ts
490
+ * // Load level data into a string
491
+ * const [data, error] = sys.load_resource("/assets/level_data.json");
492
+ * // Decode json string to a table
493
+ * if (data) {
494
+ * const data_table = json.decode(data);
495
+ * pprint(data_table);
496
+ * } else {
497
+ * print(error);
498
+ * }
499
+ * ```
500
+ */
501
+ function load_resource(filename: string): LuaMultiReturn<[string | unknown, string | unknown]>;
502
+ /**
503
+ * Open URL in default application, typically a browser
504
+ *
505
+ * @param url - url to open
506
+ * @param attributes - table with attributes
507
+ * `target`
508
+ * - string : Optional. Specifies the target attribute or the name of the window. The following values are supported:
509
+ * - `_self` - (default value) URL replaces the current page.
510
+ * - `_blank` - URL is loaded into a new window, or tab.
511
+ * - `_parent` - URL is loaded into the parent frame.
512
+ * - `_top` - URL replaces any framesets that may be loaded.
513
+ * - `name` - The name of the window (Note: the name does not specify the title of the new window).
514
+ * @returns a boolean indicating if the url could be opened or not
515
+ * @example
516
+ * ```ts
517
+ * // Open an URL:
518
+ * const success = sys.open_url("http://www.defold.com", { target: "_blank" });
519
+ * if (!success) {
520
+ * // could not open the url...
521
+ * }
522
+ * ```
523
+ */
524
+ function open_url(url: string, attributes?: { target?: string }): boolean;
525
+ /**
526
+ * Reboots the game engine with a specified set of arguments.
527
+ * Arguments will be translated into command line arguments. Calling reboot
528
+ * function is equivalent to starting the engine with the same arguments.
529
+ * On startup the engine reads configuration from "game.project" in the
530
+ * project root.
531
+ *
532
+ * @param arg1 - argument 1
533
+ * @param arg2 - argument 2
534
+ * @param arg3 - argument 3
535
+ * @param arg4 - argument 4
536
+ * @param arg5 - argument 5
537
+ * @param arg6 - argument 6
538
+ * @example
539
+ * ```ts
540
+ * // How to reboot engine with a specific bootstrap collection.
541
+ * const arg1 = "--config=bootstrap.main_collection=/my.collectionc";
542
+ * const arg2 = "build/game.projectc";
543
+ * sys.reboot(arg1, arg2);
544
+ * ```
545
+ */
546
+ function reboot(arg1?: string, arg2?: string, arg3?: string, arg4?: string, arg5?: string, arg6?: string): void;
547
+ /**
548
+ * The table can later be loaded by `sys.load`.
549
+ * Use `sys.get_save_file` to obtain a valid location for the file.
550
+ * Internally, this function uses a workspace buffer sized output file sized 512kb.
551
+ * This size reflects the output file size which must not exceed this limit.
552
+ * Additionally, the total number of rows that any one table may contain is limited to 65536
553
+ * (i.e. a 16 bit range). When tables are used to represent arrays, the values of
554
+ * keys are permitted to fall within a 32 bit range, supporting sparse arrays, however
555
+ * the limit on the total number of rows remains in effect.
556
+ * This function will raise a Lua error if an error occurs while saving the table.
557
+ *
558
+ * @param filename - file to write to
559
+ * @param table - lua table to save
560
+ * @example
561
+ * ```ts
562
+ * // Save data:
563
+ * const my_table = [];
564
+ * my_table.push("my_value");
565
+ * const my_file_path = sys.get_save_file("my_game", "my_file");
566
+ * sys.save(my_file_path, my_table);
567
+ * ```
568
+ */
569
+ function save(filename: string, table: Record<string | number, unknown>): void;
570
+ /**
571
+ * The buffer can later deserialized by `sys.deserialize`.
572
+ * This function has all the same limitations as `sys.save`.
573
+ * This function will raise a Lua error if an error occurs while serializing the table.
574
+ *
575
+ * @param table - lua table to serialize
576
+ * @returns serialized data buffer
577
+ * @example
578
+ * ```ts
579
+ * // Serialize table:
580
+ * const my_table = [];
581
+ * my_table.push("my_value");
582
+ * const buffer = sys.serialize(my_table);
583
+ * ```
584
+ */
585
+ function serialize(table: Record<string | number, unknown>): string;
586
+ /**
587
+ * Sets the host that is used to check for network connectivity against.
588
+ *
589
+ * @param host - hostname to check against
590
+ * @example
591
+ * ```ts
592
+ * sys.set_connectivity_host("www.google.com");
593
+ * ```
594
+ */
595
+ function set_connectivity_host(host: string): void;
596
+ /**
597
+ * Enables engine throttling.
598
+ *
599
+ * @param enable - true if throttling should be enabled
600
+ * @param cooldown - the time period to do update + render for (seconds)
601
+ * @example
602
+ * ```ts
603
+ * // Disable throttling
604
+ * sys.set_engine_throttle(false);
605
+ *
606
+ * // Enable throttling
607
+ * sys.set_engine_throttle(true, 1.5);
608
+ * ```
609
+ */
610
+ function set_engine_throttle(enable: boolean, cooldown: number): void;
611
+ /**
612
+ * Set the Lua error handler function.
613
+ * The error handler is a function which is called whenever a lua runtime error occurs.
614
+ *
615
+ * @param error_handler - the function to be called on error
616
+ *
617
+ * `source`
618
+ * string The runtime context of the error. Currently, this is always `"lua"`.
619
+ * `message`
620
+ * string The source file, line number and error message.
621
+ * `traceback`
622
+ * string The stack traceback.
623
+ * @example
624
+ * ```ts
625
+ * // Install error handler that just prints the errors
626
+ * function my_error_handler(source, message, traceback) {
627
+ * print(source); //> lua
628
+ * print(message); //> main/my.script:10: attempt to perform arithmetic on a string value
629
+ * print(traceback); //> stack traceback:
630
+ * //> main/test.script:10: in function 'boom'
631
+ * //> main/test.script:15: in function <main/my.script:13>
632
+ * }
633
+ *
634
+ * function boom() {
635
+ * return 10 + "string";
636
+ * }
637
+ *
638
+ * export default defineScript({
639
+ * init() {
640
+ * sys.set_error_handler(my_error_handler);
641
+ * boom();
642
+ * },
643
+ * });
644
+ * ```
645
+ */
646
+ function set_error_handler(error_handler: (source: unknown, message: unknown, traceback: unknown) => void): void;
647
+ /**
648
+ * Disables rendering
649
+ *
650
+ * @param enable - true if throttling should be enabled
651
+ * @example
652
+ * ```ts
653
+ * // Disable rendering
654
+ * sys.set_render_enable(false);
655
+ * ```
656
+ */
657
+ function set_render_enable(enable: boolean): void;
658
+ /**
659
+ * Set game update-frequency (frame cap). This option is equivalent to `display.update_frequency` in
660
+ * the "game.project" settings but set in run-time. If `Vsync` checked in "game.project", the rate will
661
+ * be clamped to a swap interval that matches any detected main monitor refresh rate. If `Vsync` is
662
+ * unchecked the engine will try to respect the rate in software using timers. There is no
663
+ * guarantee that the frame cap will be achieved depending on platform specifics and hardware settings.
664
+ *
665
+ * @param frequency - target frequency. 60 for 60 fps
666
+ * @example
667
+ * ```ts
668
+ * // Setting the update frequency to 60 frames per second
669
+ * sys.set_update_frequency(60);
670
+ * ```
671
+ */
672
+ function set_update_frequency(frequency: number): void;
673
+ /**
674
+ * Set the vsync swap interval. The interval with which to swap the front and back buffers
675
+ * in sync with vertical blanks (v-blank), the hardware event where the screen image is updated
676
+ * with data from the front buffer. A value of 1 swaps the buffers at every v-blank, a value of
677
+ * 2 swaps the buffers every other v-blank and so on. A value of 0 disables waiting for v-blank
678
+ * before swapping the buffers. Default value is 1.
679
+ * When setting the swap interval to 0 and having `vsync` disabled in
680
+ * "game.project", the engine will try to respect the set frame cap value from
681
+ * "game.project" in software instead.
682
+ * This setting may be overridden by driver settings.
683
+ *
684
+ * @param swap_interval - target swap interval.
685
+ * @example
686
+ * ```ts
687
+ * // Setting the swap intervall to swap every v-blank
688
+ * sys.set_vsync_swap_interval(1);
689
+ * ```
690
+ */
691
+ function set_vsync_swap_interval(swap_interval: number): void;
692
+ }
693
+ }
694
+
695
+ export {};