@defold-typescript/types 0.49.0 → 0.50.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 (76) hide show
  1. package/api-availability.json +696 -624
  2. package/api-signatures.json +6799 -160
  3. package/api-targets.json +393 -2
  4. package/examples/translations.json +12 -0
  5. package/generated/b2d.d.ts +15 -0
  6. package/generated/bullet3d.d.ts +16 -0
  7. package/generated/font.d.ts +7 -3
  8. package/generated/graphics.d.ts +7 -0
  9. package/generated/gui.d.ts +5 -4
  10. package/generated/label.d.ts +3 -3
  11. package/generated/render.d.ts +16 -1
  12. package/generated/versions/defold-1.13.2/b2d.d.ts +709 -0
  13. package/generated/versions/defold-1.13.2/b2d_body.d.ts +593 -0
  14. package/generated/versions/defold-1.13.2/b2d_chain.d.ts +105 -0
  15. package/generated/versions/defold-1.13.2/b2d_fixture.d.ts +175 -0
  16. package/generated/versions/defold-1.13.2/b2d_joint.d.ts +1301 -0
  17. package/generated/versions/defold-1.13.2/b2d_shape.d.ts +423 -0
  18. package/generated/versions/defold-1.13.2/b2d_world.d.ts +308 -0
  19. package/generated/versions/defold-1.13.2/buffer.d.ts +192 -0
  20. package/generated/versions/defold-1.13.2/bullet3d.d.ts +91 -0
  21. package/generated/versions/defold-1.13.2/bullet3d_collision_object.d.ts +433 -0
  22. package/generated/versions/defold-1.13.2/bullet3d_constraint.d.ts +818 -0
  23. package/generated/versions/defold-1.13.2/bullet3d_rigid_body.d.ts +429 -0
  24. package/generated/versions/defold-1.13.2/bullet3d_shape.d.ts +123 -0
  25. package/generated/versions/defold-1.13.2/bullet3d_world.d.ts +492 -0
  26. package/generated/versions/defold-1.13.2/camera.d.ts +300 -0
  27. package/generated/versions/defold-1.13.2/collectionfactory.d.ts +148 -0
  28. package/generated/versions/defold-1.13.2/collectionproxy.d.ts +109 -0
  29. package/generated/versions/defold-1.13.2/compute.d.ts +107 -0
  30. package/generated/versions/defold-1.13.2/crash.d.ts +157 -0
  31. package/generated/versions/defold-1.13.2/editor-vm/http.d.ts +139 -0
  32. package/generated/versions/defold-1.13.2/editor-vm/image.d.ts +48 -0
  33. package/generated/versions/defold-1.13.2/editor-vm/json.d.ts +21 -0
  34. package/generated/versions/defold-1.13.2/editor-vm/localization.d.ts +42 -0
  35. package/generated/versions/defold-1.13.2/editor-vm/tilemap_tiles.d.ts +126 -0
  36. package/generated/versions/defold-1.13.2/editor-vm/zip.d.ts +38 -0
  37. package/generated/versions/defold-1.13.2/editor-vm/zlib.d.ts +24 -0
  38. package/generated/versions/defold-1.13.2/editor.d.ts +2177 -0
  39. package/generated/versions/defold-1.13.2/factory.d.ts +121 -0
  40. package/generated/versions/defold-1.13.2/font.d.ts +123 -0
  41. package/generated/versions/defold-1.13.2/go.d.ts +1166 -0
  42. package/generated/versions/defold-1.13.2/graphics.d.ts +613 -0
  43. package/generated/versions/defold-1.13.2/gui.d.ts +2212 -0
  44. package/generated/versions/defold-1.13.2/html5.d.ts +55 -0
  45. package/generated/versions/defold-1.13.2/http.d.ts +83 -0
  46. package/generated/versions/defold-1.13.2/image.d.ts +181 -0
  47. package/generated/versions/defold-1.13.2/index.d.ts +63 -0
  48. package/generated/versions/defold-1.13.2/json.d.ts +94 -0
  49. package/generated/versions/defold-1.13.2/kinds/editor-script.d.ts +14 -0
  50. package/generated/versions/defold-1.13.2/label.d.ts +164 -0
  51. package/generated/versions/defold-1.13.2/liveupdate.d.ts +143 -0
  52. package/generated/versions/defold-1.13.2/material.d.ts +490 -0
  53. package/generated/versions/defold-1.13.2/model.d.ts +287 -0
  54. package/generated/versions/defold-1.13.2/msg.d.ts +10 -0
  55. package/generated/versions/defold-1.13.2/particlefx.d.ts +155 -0
  56. package/generated/versions/defold-1.13.2/physics.d.ts +789 -0
  57. package/generated/versions/defold-1.13.2/profiler.d.ts +228 -0
  58. package/generated/versions/defold-1.13.2/render.d.ts +1153 -0
  59. package/generated/versions/defold-1.13.2/resource.d.ts +1628 -0
  60. package/generated/versions/defold-1.13.2/socket.d.ts +797 -0
  61. package/generated/versions/defold-1.13.2/sound.d.ts +323 -0
  62. package/generated/versions/defold-1.13.2/sprite.d.ts +179 -0
  63. package/generated/versions/defold-1.13.2/sys.d.ts +754 -0
  64. package/generated/versions/defold-1.13.2/tilemap.d.ts +206 -0
  65. package/generated/versions/defold-1.13.2/timer.d.ts +136 -0
  66. package/generated/versions/defold-1.13.2/types.d.ts +61 -0
  67. package/generated/versions/defold-1.13.2/vmath.d.ts +775 -0
  68. package/generated/versions/defold-1.13.2/window.d.ts +196 -0
  69. package/generated/versions/defold-1.13.2/zlib.d.ts +41 -0
  70. package/identity-vocabulary.json +1 -0
  71. package/package.json +2 -2
  72. package/scripts/import-defold-release.ts +3 -31
  73. package/scripts/materialize-version.ts +13 -7
  74. package/scripts/regen.ts +63 -29
  75. package/scripts/sync-api-docs.ts +31 -2
  76. package/src/emit-dts.ts +25 -3
@@ -0,0 +1,754 @@
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
+ * Application information
12
+ */
13
+ interface application_info {
14
+ /**
15
+ * Whether the queried application is installed.
16
+ */
17
+ installed: boolean;
18
+ }
19
+ /**
20
+ * Engine information
21
+ */
22
+ interface engine_info {
23
+ /**
24
+ * Defold engine version.
25
+ */
26
+ version: string;
27
+ /**
28
+ * Engine build SHA-1.
29
+ */
30
+ version_sha1: string;
31
+ /**
32
+ * Whether this is a debug engine build.
33
+ */
34
+ is_debug: boolean;
35
+ }
36
+ /**
37
+ * Network-interface information
38
+ */
39
+ interface interface_info {
40
+ /**
41
+ * Interface name.
42
+ */
43
+ name: string;
44
+ /**
45
+ * IP address, when available.
46
+ */
47
+ address?: string;
48
+ /**
49
+ * Hardware MAC address, when available.
50
+ */
51
+ mac?: string;
52
+ /**
53
+ * Whether the interface can transmit and receive data.
54
+ */
55
+ up: boolean;
56
+ /**
57
+ * Whether the interface is running.
58
+ */
59
+ running: boolean;
60
+ }
61
+ /**
62
+ * Asynchronous buffer-load result
63
+ */
64
+ interface load_buffer_result {
65
+ /**
66
+ * Request status.
67
+ */
68
+ status: sys.REQUEST_STATUS;
69
+ /**
70
+ * Loaded payload for a successful request.
71
+ */
72
+ buffer?: Opaque<"buffer">;
73
+ }
74
+ /**
75
+ * URL opening attributes
76
+ */
77
+ interface open_url_attributes {
78
+ /**
79
+ * HTML5 browsing context: `_self`, `_blank`, `_parent`, `_top`, or a named window.
80
+ */
81
+ target?: string;
82
+ }
83
+ /**
84
+ * System information
85
+ */
86
+ interface sys_info {
87
+ /**
88
+ * Device model on iOS and Android.
89
+ */
90
+ device_model?: string;
91
+ /**
92
+ * Device manufacturer on iOS and Android.
93
+ */
94
+ manufacturer?: string;
95
+ /**
96
+ * Operating-system name.
97
+ */
98
+ system_name: string;
99
+ /**
100
+ * Operating-system version.
101
+ */
102
+ system_version: string;
103
+ /**
104
+ * Platform API version.
105
+ */
106
+ api_version: string;
107
+ /**
108
+ * ISO 639 language code.
109
+ */
110
+ language: string;
111
+ /**
112
+ * Preferred device language, optionally followed by an ISO 15924 script code.
113
+ */
114
+ device_language: string;
115
+ /**
116
+ * ISO 3166-1 alpha-2 country code or UN M.49 numeric region code.
117
+ */
118
+ territory: string;
119
+ /**
120
+ * Current GMT offset in minutes.
121
+ */
122
+ gmt_offset: number;
123
+ /**
124
+ * Operating-system-protected device identifier.
125
+ */
126
+ device_ident?: string;
127
+ /**
128
+ * HTTP user agent on HTML5.
129
+ */
130
+ user_agent?: string;
131
+ }
132
+ /**
133
+ * System-information options
134
+ */
135
+ interface sys_info_options {
136
+ /**
137
+ * Omit operating-system-protected values such as `device_ident`.
138
+ */
139
+ ignore_secure?: boolean;
140
+ }
141
+ type NetworkConnectivity = typeof sys.NETWORK_DISCONNECTED | typeof sys.NETWORK_CONNECTED_CELLULAR | typeof sys.NETWORK_CONNECTED;
142
+ type NETWORK = typeof sys.NETWORK_CONNECTED | typeof sys.NETWORK_CONNECTED_CELLULAR | typeof sys.NETWORK_DISCONNECTED;
143
+ type REQUEST_STATUS = typeof sys.REQUEST_STATUS_ERROR_IO_ERROR | typeof sys.REQUEST_STATUS_ERROR_NOT_FOUND | typeof sys.REQUEST_STATUS_FINISHED;
144
+ /**
145
+ * Connected through Wi-Fi or another non-cellular network.
146
+ */
147
+ const NETWORK_CONNECTED: number & { readonly __brand: "sys.NETWORK_CONNECTED" };
148
+ /**
149
+ * Connected through a cellular network.
150
+ */
151
+ const NETWORK_CONNECTED_CELLULAR: number & { readonly __brand: "sys.NETWORK_CONNECTED_CELLULAR" };
152
+ /**
153
+ * No network connection was found.
154
+ */
155
+ const NETWORK_DISCONNECTED: number & { readonly __brand: "sys.NETWORK_DISCONNECTED" };
156
+ /**
157
+ * An I/O error occurred.
158
+ */
159
+ const REQUEST_STATUS_ERROR_IO_ERROR: number & { readonly __brand: "sys.REQUEST_STATUS_ERROR_IO_ERROR" };
160
+ /**
161
+ * The requested resource was not found.
162
+ */
163
+ const REQUEST_STATUS_ERROR_NOT_FOUND: number & { readonly __brand: "sys.REQUEST_STATUS_ERROR_NOT_FOUND" };
164
+ /**
165
+ * The request completed successfully.
166
+ */
167
+ const REQUEST_STATUS_FINISHED: number & { readonly __brand: "sys.REQUEST_STATUS_FINISHED" };
168
+ /**
169
+ * This function will raise a Lua error if an error occurs while deserializing the buffer.
170
+ *
171
+ * @param buffer - buffer to deserialize from
172
+ * @returns lua table with deserialized data
173
+ * @example
174
+ * ```ts
175
+ * // Deserialize a table that was previously serialized:
176
+ * const my_table = { score: 100, level: 3 };
177
+ * const buffer = sys.serialize(my_table);
178
+ * const table = sys.deserialize(buffer);
179
+ * ```
180
+ */
181
+ function deserialize(buffer: string): LuaTable<AnyNotNil, unknown>;
182
+ /**
183
+ * Check if a path exists
184
+ * Good for checking if a file exists before loading a large file
185
+ *
186
+ * @param path - path to check
187
+ * @returns `true` if the path exists, `false` otherwise
188
+ * @example
189
+ * ```ts
190
+ * // Load data but return nil if path didn't exist
191
+ * function load_data(path: string) {
192
+ * if (!sys.exists(path)) {
193
+ * return undefined;
194
+ * }
195
+ * return sys.load(path); // returns {} if it failed
196
+ * }
197
+ * ```
198
+ */
199
+ function exists(path: string): boolean;
200
+ /**
201
+ * Terminates the game application and reports the specified `code` to the OS.
202
+ *
203
+ * @param code - exit code to report to the OS, 0 means clean exit
204
+ * @example
205
+ * ```ts
206
+ * // This example demonstrates how to exit the application when some kind of quit
207
+ * // message is received (maybe from gui or similar):
208
+ * export default defineScript({
209
+ * on_message(self, message_id, message, sender) {
210
+ * if (message_id === hash("quit")) {
211
+ * sys.exit(0);
212
+ * }
213
+ * },
214
+ * });
215
+ * ```
216
+ */
217
+ function exit(code: number): void;
218
+ /**
219
+ * Returns a table with application information for the requested app.
220
+ * On iOS, the `app_string` is an url scheme for the app that is queried. Your
221
+ * game needs to list the schemes that are queried in an `LSApplicationQueriesSchemes` array
222
+ * in a custom "Info.plist".
223
+ * On Android, the `app_string` is the package identifier for the app.
224
+ *
225
+ * @param app_string - platform specific string with application package or query, see above for details.
226
+ * @returns application information
227
+ * @example
228
+ * Check if twitter is installed:
229
+ * ```ts
230
+ * const sysinfo = sys.get_sys_info();
231
+ * let twitter: { installed?: boolean } = {};
232
+ *
233
+ * if (sysinfo.system_name === "Android") {
234
+ * twitter = sys.get_application_info("com.twitter.android");
235
+ * } else if (sysinfo.system_name === "iPhone OS") {
236
+ * twitter = sys.get_application_info("twitter:");
237
+ * }
238
+ *
239
+ * if (twitter.installed) {
240
+ * // twitter is installed!
241
+ * }
242
+ * ```
243
+ * @example
244
+ * Info.plist for the iOS app needs to list the schemes that are queried:
245
+ * ```ts
246
+ * // ...
247
+ * // <key>LSApplicationQueriesSchemes</key>
248
+ * // <array>
249
+ * // <string>twitter</string>
250
+ * // </array>
251
+ * // ...
252
+ * ```
253
+ */
254
+ function get_application_info(app_string: string): sys.application_info;
255
+ /**
256
+ * The path from which the application is run.
257
+ * This function will raise a Lua error if unable to get the application support path.
258
+ *
259
+ * @returns path to application executable
260
+ * @example
261
+ * ```ts
262
+ * // Find a path where we can store data (the example path is on the macOS platform):
263
+ * // macOS: /Applications/my_game.app
264
+ * const application_path = sys.get_application_path();
265
+ * print(application_path); //> /Applications/my_game.app
266
+ *
267
+ * // Windows: C:\Program Files\my_game\my_game.exe
268
+ * print(application_path); //> C:\Program Files\my_game
269
+ *
270
+ * // Linux: /home/foobar/my_game/my_game
271
+ * print(application_path); //> /home/foobar/my_game
272
+ *
273
+ * // Android package name: com.foobar.my_game
274
+ * print(application_path); //> /data/user/0/com.foobar.my_game
275
+ *
276
+ * // iOS: my_game.app
277
+ * print(application_path); //> /var/containers/Bundle/Applications/123456AB-78CD-90DE-12345678ABCD/my_game.app
278
+ *
279
+ * // HTML5: http://www.foobar.com/my_game/
280
+ * print(application_path); //> http://www.foobar.com/my_game
281
+ * ```
282
+ */
283
+ function get_application_path(): string;
284
+ /**
285
+ * Get boolean config value from the game.project configuration file with optional default value
286
+ *
287
+ * @param key - key to get value for. The syntax is SECTION.KEY
288
+ * @param default_value - (optional) default value to return if the value does not exist
289
+ * @returns config value as a boolean. default_value if the config key does not exist. false if no default value was supplied.
290
+ * @example
291
+ * ```ts
292
+ * // Get user config value
293
+ * const vsync = sys.get_config_boolean("display.vsync", false);
294
+ * ```
295
+ */
296
+ function get_config_boolean(key: string, default_value?: boolean): boolean;
297
+ /**
298
+ * Get integer config value from the game.project configuration file with optional default value
299
+ *
300
+ * @param key - key to get value for. The syntax is SECTION.KEY
301
+ * @param default_value - (optional) default value to return if the value does not exist
302
+ * @returns config value as an integer. default_value if the config key does not exist. 0 if no default value was supplied.
303
+ * @example
304
+ * Get user config value
305
+ * ```ts
306
+ * const speed = sys.get_config_int("my_game.speed", 20); // with default value
307
+ * ```
308
+ * @example
309
+ * ```ts
310
+ * const testmode = sys.get_config_int("my_game.testmode"); // without default value
311
+ * if (testmode !== undefined) {
312
+ * // do stuff
313
+ * }
314
+ * ```
315
+ */
316
+ function get_config_int(key: string, default_value?: number): number;
317
+ /**
318
+ * Get number config value from the game.project configuration file with optional default value
319
+ *
320
+ * @param key - key to get value for. The syntax is SECTION.KEY
321
+ * @param default_value - (optional) default value to return if the value does not exist
322
+ * @returns config value as an number. default_value if the config key does not exist. 0 if no default value was supplied.
323
+ * @example
324
+ * ```ts
325
+ * // Get user config value
326
+ * const speed = sys.get_config_number("my_game.speed", 20.0);
327
+ * ```
328
+ */
329
+ function get_config_number(key: string, default_value?: number): number;
330
+ /**
331
+ * Returns the current network connectivity status
332
+ * on mobile platforms.
333
+ * On desktop, this function always return `sys.NETWORK_CONNECTED`.
334
+ *
335
+ * @returns network connectivity status
336
+ * @example
337
+ * ```ts
338
+ * // Check if we are connected through a cellular connection
339
+ * if (sys.NETWORK_CONNECTED_CELLULAR === sys.get_connectivity()) {
340
+ * print("Connected via cellular, avoid downloading big files!");
341
+ * }
342
+ * ```
343
+ */
344
+ function get_connectivity(): sys.NETWORK;
345
+ /**
346
+ * Returns a table with engine information.
347
+ *
348
+ * @returns engine information
349
+ * @example
350
+ * ```ts
351
+ * // How to retrieve engine information:
352
+ * // Update version text label so our testers know what version we're running
353
+ * const engine_info = sys.get_engine_info();
354
+ * const version_str = `Defold ${engine_info.version}\n${engine_info.version_sha1}`;
355
+ * gui.set_text(gui.get_node("version"), version_str);
356
+ * ```
357
+ */
358
+ function get_engine_info(): sys.engine_info;
359
+ /**
360
+ * Create a path to the host device for unit testing
361
+ * Useful for saving logs etc during development
362
+ *
363
+ * @param filename - file to read from
364
+ * @returns the path prefixed with the proper host mount
365
+ * @example
366
+ * Save data on the host
367
+ * ```ts
368
+ * const mytable = { score: 100, level: 3 };
369
+ * const host_path = sys.get_host_path("logs/test.txt");
370
+ * sys.save(host_path, mytable);
371
+ * ```
372
+ * @example
373
+ * Load data from the host
374
+ * ```ts
375
+ * const host_path = sys.get_host_path("logs/test.txt");
376
+ * const table = sys.load(host_path);
377
+ * ```
378
+ */
379
+ function get_host_path(filename: string): string;
380
+ /**
381
+ * Returns an array of tables with information on network interfaces.
382
+ *
383
+ * @returns network interfaces
384
+ * @example
385
+ * ```ts
386
+ * // How to get the IP address of interface "en0":
387
+ * const ifaddrs = sys.get_ifaddrs();
388
+ * for (const iface of ifaddrs) {
389
+ * if (iface.name === "en0") {
390
+ * const ip = iface.address;
391
+ * }
392
+ * }
393
+ * ```
394
+ */
395
+ function get_ifaddrs(): sys.interface_info[];
396
+ /**
397
+ * The save-file path is operating system specific and is typically located under the user's home directory.
398
+ * This function will raise a Lua error if unable to get the save file path.
399
+ *
400
+ * @param application_id - user defined id of the application, which helps define the location of the save-file
401
+ * @param file_name - file-name to get path for
402
+ * @returns path to save-file
403
+ * @example
404
+ * ```ts
405
+ * // Find a path where we can store data:
406
+ * const my_file_path = sys.get_save_file("my_game", "my_file");
407
+ * // macOS: /Users/foobar/Library/Application Support/my_game/my_file
408
+ * print(my_file_path); //> /Users/foobar/Library/Application Support/my_game/my_file
409
+ *
410
+ * // Windows: C:\Users\foobar\AppData\Roaming\my_game\my_file
411
+ * print(my_file_path); //> C:\Users\foobar\AppData\Roaming\my_game\my_file
412
+ *
413
+ * // Linux: $XDG_DATA_HOME/my_game/my_file or /home/foobar/.my_game/my_file
414
+ * // Linux: Defaults to /home/foobar/.local/share/my_game/my_file if neither exist.
415
+ * print(my_file_path); //> /home/foobar/.local/share/my_game/my_file
416
+ *
417
+ * // Android package name: com.foobar.packagename
418
+ * print(my_file_path); //> /data/data/0/com.foobar.packagename/files/my_file
419
+ *
420
+ * // iOS: my_game.app
421
+ * print(my_file_path); //> /var/mobile/Containers/Data/Application/123456AB-78CD-90DE-12345678ABCD/my_game/my_file
422
+ *
423
+ * // HTML5 path inside the IndexedDB: /data/.my_game/my_file or /.my_game/my_file
424
+ * print(my_file_path); //> /data/.my_game/my_file
425
+ * ```
426
+ */
427
+ function get_save_file(application_id: string, file_name: string): string;
428
+ /**
429
+ * Returns a table with system information.
430
+ *
431
+ * @param options - optional system-information options
432
+ * @returns system information
433
+ * @example
434
+ * ```ts
435
+ * // How to get system information:
436
+ * const info = sys.get_sys_info();
437
+ * if (info.system_name === "HTML5") {
438
+ * // We are running in a browser.
439
+ * }
440
+ * ```
441
+ */
442
+ function get_sys_info(options?: sys.sys_info_options): sys.sys_info;
443
+ /**
444
+ * If the file exists, it must have been created by `sys.save` to be loaded.
445
+ * This function will raise a Lua error if an error occurs while loading the file.
446
+ *
447
+ * @param filename - file to read from
448
+ * @returns lua table, which is empty if the file could not be found
449
+ * @example
450
+ * ```ts
451
+ * // Load data that was previously saved, e.g. an earlier game session:
452
+ * const my_file_path = sys.get_save_file("my_game", "my_file");
453
+ * const my_table = sys.load(my_file_path);
454
+ * if (!next(my_table)) {
455
+ * // empty table
456
+ * }
457
+ * ```
458
+ */
459
+ function load(filename: string): LuaTable<AnyNotNil, unknown>;
460
+ /**
461
+ * The sys.load_buffer function will first try to load the resource
462
+ * from any of the mounted resource locations and return the data if
463
+ * any matching entries found. If not, the path will be tried
464
+ * as is from the primary disk on the device.
465
+ * In order for the engine to include custom resources in the build process, you need
466
+ * to specify them in the "custom_resources" key in your "game.project" settings file.
467
+ * You can specify single resource files or directories. If a directory is included
468
+ * in the resource list, all files and directories in that directory is recursively
469
+ * included:
470
+ * For example "main/data/,assets/level_data.json".
471
+ *
472
+ * @param path - the path to load the buffer from
473
+ * @returns the buffer with data
474
+ * @example
475
+ * Load binary data from a custom project resource:
476
+ * ```ts
477
+ * const my_buffer = sys.load_buffer("/assets/my_level_data.bin");
478
+ * const data_str = buffer.get_bytes(my_buffer, "data");
479
+ * const has_my_header = data_str.slice(0, 6) === "D3F0LD";
480
+ * ```
481
+ * @example
482
+ * Load binary data from non-custom resource files on disk:
483
+ * ```ts
484
+ * const asset_1 = sys.load_buffer("folder_next_to_binary/my_level_asset.txt");
485
+ * const asset_2 = sys.load_buffer("/my/absolute/path");
486
+ * ```
487
+ */
488
+ function load_buffer(path: string): Opaque<"buffer">;
489
+ /**
490
+ * The sys.load_buffer function will first try to load the resource
491
+ * from any of the mounted resource locations and return the data if
492
+ * any matching entries found. If not, the path will be tried
493
+ * as is from the primary disk on the device.
494
+ * In order for the engine to include custom resources in the build process, you need
495
+ * to specify them in the "custom_resources" key in your "game.project" settings file.
496
+ * You can specify single resource files or directories. If a directory is included
497
+ * in the resource list, all files and directories in that directory is recursively
498
+ * included:
499
+ * For example "main/data/,assets/level_data.json".
500
+ * Note that issuing multiple requests of the same resource will yield
501
+ * individual buffers per request. There is no implicit caching of the buffers
502
+ * based on request path.
503
+ *
504
+ * @param path - the path to load the buffer from
505
+ * @param status_callback - callback invoked when the request completes or fails
506
+ * @returns a handle to the request
507
+ * @example
508
+ * Load binary data from a custom project resource and update a texture resource:
509
+ * ```ts
510
+ * // Load binary data from a custom project resource and update a texture resource:
511
+ * function my_callback(self: unknown, request_id: number, result: sys.load_buffer_result) {
512
+ * const format = graphics.TEXTURE_FORMAT_RGBA;
513
+ * if (result.status === sys.REQUEST_STATUS_FINISHED && result.buffer !== undefined && format !== undefined) {
514
+ * resource.set_texture("/my_texture", { type: graphics.TEXTURE_TYPE_2D, width: 128, height: 128, format }, result.buffer);
515
+ * }
516
+ * }
517
+ *
518
+ * const my_request = sys.load_buffer_async("/assets/my_level_data.bin", my_callback);
519
+ * ```
520
+ * @example
521
+ * Load binary data from non-custom resource files on disk:
522
+ * ```ts
523
+ * // Load binary data from non-custom resource files on disk:
524
+ * function my_callback(self: unknown, request_id: number, result: sys.load_buffer_result) {
525
+ * const { first_request, second_request } = self as { first_request: number; second_request: number };
526
+ * if (result.status !== sys.REQUEST_STATUS_FINISHED) {
527
+ * // uh oh! File could not be found, do something graceful
528
+ * } else if (request_id === first_request) {
529
+ * // result.buffer contains data from my_level_asset.bin
530
+ * } else if (request_id === second_request) {
531
+ * // result.buffer contains data from 'my_level.bin'
532
+ * }
533
+ * }
534
+ *
535
+ * export default defineScript({
536
+ * init() {
537
+ * return {
538
+ * first_request: sys.load_buffer_async("folder_next_to_binary/my_level_asset.bin", my_callback),
539
+ * second_request: sys.load_buffer_async("/some_absolute_path/my_level.bin", my_callback),
540
+ * };
541
+ * },
542
+ * });
543
+ * ```
544
+ */
545
+ function load_buffer_async(path: string, status_callback: (self: unknown, request_id: number, result: sys.load_buffer_result) => void): number;
546
+ /**
547
+ * Loads a custom resource. Specify the full filename of the resource that you want
548
+ * to load. When loaded, the file data is returned as a string.
549
+ * If loading fails, the function returns `nil` plus the error message.
550
+ * In order for the engine to include custom resources in the build process, you need
551
+ * to specify them in the "custom_resources" key in your "game.project" settings file.
552
+ * You can specify single resource files or directories. If a directory is included
553
+ * in the resource list, all files and directories in that directory is recursively
554
+ * included:
555
+ * For example "main/data/,assets/level_data.json".
556
+ *
557
+ * @param filename - resource to load, full path
558
+ * @example
559
+ * ```ts
560
+ * // Load level data into a string
561
+ * const [data, error] = sys.load_resource("/assets/level_data.json");
562
+ * // Decode json string to a table
563
+ * if (data) {
564
+ * const data_table = json.decode(data);
565
+ * pprint(data_table);
566
+ * } else {
567
+ * print(error);
568
+ * }
569
+ * ```
570
+ */
571
+ function load_resource(filename: string): LuaMultiReturn<[string | undefined, string | undefined]>;
572
+ /**
573
+ * Open URL in default application, typically a browser
574
+ *
575
+ * @param url - url to open
576
+ * @param attributes - optional URL opening attributes
577
+ * @returns a boolean indicating if the url could be opened or not
578
+ * @example
579
+ * ```ts
580
+ * // Open an URL:
581
+ * const success = sys.open_url("http://www.defold.com", { target: "_blank" });
582
+ * if (!success) {
583
+ * // could not open the url...
584
+ * }
585
+ * ```
586
+ */
587
+ function open_url(url: string, attributes?: sys.open_url_attributes): boolean;
588
+ /**
589
+ * Reboots the game engine with a specified set of arguments.
590
+ * Arguments will be translated into command line arguments. Calling reboot
591
+ * function is equivalent to starting the engine with the same arguments.
592
+ * On startup the engine reads configuration from "game.project" in the
593
+ * project root.
594
+ *
595
+ * @param arg1 - argument 1
596
+ * @param arg2 - argument 2
597
+ * @param arg3 - argument 3
598
+ * @param arg4 - argument 4
599
+ * @param arg5 - argument 5
600
+ * @param arg6 - argument 6
601
+ * @example
602
+ * ```ts
603
+ * // How to reboot engine with a specific bootstrap collection.
604
+ * const arg1 = "--config=bootstrap.main_collection=/my.collectionc";
605
+ * const arg2 = "build/game.projectc";
606
+ * sys.reboot(arg1, arg2);
607
+ * ```
608
+ */
609
+ function reboot(arg1?: string, arg2?: string, arg3?: string, arg4?: string, arg5?: string, arg6?: string): void;
610
+ /**
611
+ * The table can later be loaded by `sys.load`.
612
+ * Use `sys.get_save_file` to obtain a valid location for the file.
613
+ * Internally, this function uses a workspace buffer sized output file sized 512kb.
614
+ * This size reflects the output file size which must not exceed this limit.
615
+ * Additionally, the total number of rows that any one table may contain is limited to 65536
616
+ * (i.e. a 16 bit range). When tables are used to represent arrays, the values of
617
+ * keys are permitted to fall within a 32 bit range, supporting sparse arrays, however
618
+ * the limit on the total number of rows remains in effect.
619
+ * This function will raise a Lua error if an error occurs while saving the table.
620
+ *
621
+ * @param filename - file to write to
622
+ * @param table - lua table to save
623
+ * @example
624
+ * ```ts
625
+ * // Save data:
626
+ * const my_table = [];
627
+ * my_table.push("my_value");
628
+ * const my_file_path = sys.get_save_file("my_game", "my_file");
629
+ * sys.save(my_file_path, my_table);
630
+ * ```
631
+ */
632
+ function save(filename: string, table: LuaMap<AnyNotNil, unknown> | Record<string, unknown> | readonly unknown[]): boolean;
633
+ /**
634
+ * The buffer can later deserialized by `sys.deserialize`.
635
+ * This function has all the same limitations as `sys.save`.
636
+ * This function will raise a Lua error if an error occurs while serializing the table.
637
+ *
638
+ * @param table - lua table to serialize
639
+ * @returns serialized data buffer
640
+ * @example
641
+ * ```ts
642
+ * // Serialize table:
643
+ * const my_table = [];
644
+ * my_table.push("my_value");
645
+ * const buffer = sys.serialize(my_table);
646
+ * ```
647
+ */
648
+ function serialize(table: LuaMap<AnyNotNil, unknown> | Record<string, unknown> | readonly unknown[]): string;
649
+ /**
650
+ * Sets the host that is used to check for network connectivity against.
651
+ *
652
+ * @param host - hostname to check against
653
+ * @example
654
+ * ```ts
655
+ * sys.set_connectivity_host("www.google.com");
656
+ * ```
657
+ */
658
+ function set_connectivity_host(host: string): void;
659
+ /**
660
+ * Set the Lua error handler function.
661
+ * The error handler is a function which is called whenever a lua runtime error occurs.
662
+ *
663
+ * @param error_handler - the function to be called on error
664
+ *
665
+ * `source`
666
+ * string The runtime context of the error. Currently, this is always `"lua"`.
667
+ * `message`
668
+ * string The source file, line number and error message.
669
+ * `traceback`
670
+ * string The stack traceback.
671
+ * @example
672
+ * ```ts
673
+ * function boom() {
674
+ * return 10 + "string";
675
+ * }
676
+ *
677
+ * export default defineScript({
678
+ * init() {
679
+ * // Install error handler that just prints the errors
680
+ * sys.set_error_handler((source, message, traceback) => {
681
+ * print(source); //> lua
682
+ * print(message); //> main/my.script:10: attempt to perform arithmetic on a string value
683
+ * print(traceback); //> stack traceback:
684
+ * //> main/test.script:10: in function 'boom'
685
+ * //> main/test.script:15: in function <main/my.script:13>
686
+ * });
687
+ * boom();
688
+ * },
689
+ * });
690
+ * ```
691
+ */
692
+ function set_error_handler(error_handler: (source: string, message: string, traceback: string) => void): void;
693
+ /**
694
+ * Disables rendering
695
+ *
696
+ * @param enable - true if throttling should be enabled
697
+ * @example
698
+ * ```ts
699
+ * // Disable rendering
700
+ * sys.set_render_enabled(false);
701
+ * ```
702
+ */
703
+ function set_render_enabled(enable: boolean): void;
704
+ /**
705
+ * Set game update-frequency (frame cap). This option is equivalent to
706
+ * `display.update_frequency` in the "game.project" settings but set at run-time.
707
+ * On platforms where Defold owns the application loop, a positive value uses
708
+ * timer pacing and requests a swap interval of 0 to avoid an additional vsync
709
+ * wait where supported. Setting the frequency to 0 restores the requested swap
710
+ * interval and uses variable-rate updates. Platform-owned loops, such as HTML5
711
+ * and iOS, retain their platform scheduling and presentation behavior. There is
712
+ * no guarantee that the frame cap will be achieved depending on platform and
713
+ * hardware constraints.
714
+ * With engine-side timer pacing, the update dt can be shortened or enlarged to
715
+ * account for elapsed time; the frame cap does not guarantee a constant dt.
716
+ * Elapsed time beyond max(engine.max_time_step, 1 / frequency) is discarded,
717
+ * so accumulated dt can trail wall-clock time after hitches. An intentional
718
+ * fixed interval longer than engine.max_time_step is allowed. This setting
719
+ * is separate from the fixed_update() timestep.
720
+ *
721
+ * @param frequency - target frequency in hertz. 0 selects a variable
722
+ * frame rate; negative values are treated as 0.
723
+ * @example
724
+ * ```ts
725
+ * // Setting the update frequency to 60 frames per second
726
+ * sys.set_update_frequency(60);
727
+ * ```
728
+ */
729
+ function set_update_frequency(frequency: number): void;
730
+ /**
731
+ * Request a presentation interval relative to vertical blanks (v-blank).
732
+ * 0 requests disabling vsync and 1 requests presenting every refresh (the default).
733
+ * OpenGL may support larger intervals, such as 2 for every other refresh.
734
+ * Vulkan and Metal treat any nonzero interval as enabling vsync; DX12 clamps
735
+ * intervals to the supported range 0 through 4. Actual behavior depends on
736
+ * the backend, platform, and driver.
737
+ * On platforms where Defold owns the application loop, a positive
738
+ * `display.update_frequency` or a positive value set by `sys.set_update_frequency()`
739
+ * uses timer pacing and requests a swap interval of 0. The requested
740
+ * swap interval is retained and applied again when the update frequency is set to 0.
741
+ * This setting may be overridden by driver settings.
742
+ *
743
+ * @param swap_interval - target swap interval.
744
+ * @example
745
+ * ```ts
746
+ * // Setting the swap interval to swap every v-blank
747
+ * sys.set_vsync_swap_interval(1);
748
+ * ```
749
+ */
750
+ function set_vsync_swap_interval(swap_interval: number): void;
751
+ }
752
+ }
753
+
754
+ export {};