@defold-typescript/types 0.39.0 → 0.41.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 (227) hide show
  1. package/api-availability.json +4024 -716
  2. package/api-migrations.json +27 -0
  3. package/api-signatures.json +18118 -10264
  4. package/api-targets.json +448 -11
  5. package/examples/translations.json +619 -148
  6. package/fixtures/messages_doc.json +96 -0
  7. package/generated/b2d.d.ts +680 -4
  8. package/generated/b2d_body.d.ts +29 -103
  9. package/generated/b2d_chain.d.ts +5 -6
  10. package/generated/b2d_fixture.d.ts +34 -38
  11. package/generated/b2d_joint.d.ts +503 -25
  12. package/generated/b2d_shape.d.ts +199 -14
  13. package/generated/b2d_world.d.ts +57 -63
  14. package/generated/buffer.d.ts +33 -29
  15. package/generated/builtin-messages.d.ts +7 -1
  16. package/generated/bullet3d.d.ts +91 -0
  17. package/generated/bullet3d_collision_object.d.ts +433 -0
  18. package/generated/bullet3d_constraint.d.ts +818 -0
  19. package/generated/bullet3d_rigid_body.d.ts +429 -0
  20. package/generated/bullet3d_shape.d.ts +123 -0
  21. package/generated/bullet3d_world.d.ts +492 -0
  22. package/generated/camera.d.ts +31 -34
  23. package/generated/collectionfactory.d.ts +26 -27
  24. package/generated/collectionproxy.d.ts +22 -6
  25. package/generated/compute.d.ts +12 -238
  26. package/generated/crash.d.ts +24 -10
  27. package/generated/editor-vm/http.d.ts +90 -7
  28. package/generated/editor-vm/image.d.ts +7 -7
  29. package/generated/editor-vm/json.d.ts +11 -0
  30. package/generated/editor-vm/localization.d.ts +7 -7
  31. package/generated/editor-vm/tilemap_tiles.d.ts +56 -10
  32. package/generated/editor-vm/zip.d.ts +28 -0
  33. package/generated/editor.d.ts +1496 -430
  34. package/generated/factory.d.ts +21 -25
  35. package/generated/font.d.ts +64 -22
  36. package/generated/go.d.ts +243 -186
  37. package/generated/graphics.d.ts +374 -84
  38. package/generated/gui.d.ts +282 -492
  39. package/generated/html5.d.ts +5 -3
  40. package/generated/http.d.ts +31 -36
  41. package/generated/image.d.ts +127 -85
  42. package/generated/json.d.ts +34 -16
  43. package/generated/kinds/gui-script.d.ts +8 -0
  44. package/generated/kinds/render-script.d.ts +8 -0
  45. package/generated/kinds/script.d.ts +8 -0
  46. package/generated/label.d.ts +77 -7
  47. package/generated/liveupdate.d.ts +13 -10
  48. package/generated/material.d.ts +312 -360
  49. package/generated/model.d.ts +72 -42
  50. package/generated/particlefx.d.ts +19 -28
  51. package/generated/physics.d.ts +378 -144
  52. package/generated/profiler.d.ts +14 -24
  53. package/generated/render.d.ts +294 -297
  54. package/generated/resource.d.ts +753 -641
  55. package/generated/socket.d.ts +131 -134
  56. package/generated/sound.d.ts +65 -34
  57. package/generated/sprite.d.ts +39 -17
  58. package/generated/sys.d.ts +237 -182
  59. package/generated/tilemap.d.ts +21 -16
  60. package/generated/timer.d.ts +34 -21
  61. package/generated/versions/defold-1.12.4/b2d_body.d.ts +0 -7
  62. package/generated/versions/defold-1.12.4/buffer.d.ts +18 -17
  63. package/generated/versions/defold-1.12.4/camera.d.ts +23 -23
  64. package/generated/versions/defold-1.12.4/collectionfactory.d.ts +21 -19
  65. package/generated/versions/defold-1.12.4/collectionproxy.d.ts +2 -2
  66. package/generated/versions/defold-1.12.4/crash.d.ts +2 -2
  67. package/generated/versions/defold-1.12.4/factory.d.ts +15 -16
  68. package/generated/versions/defold-1.12.4/go.d.ts +15 -17
  69. package/generated/versions/defold-1.12.4/gui.d.ts +111 -193
  70. package/generated/versions/defold-1.12.4/html5.d.ts +4 -2
  71. package/generated/versions/defold-1.12.4/http.d.ts +4 -15
  72. package/generated/versions/defold-1.12.4/image.d.ts +38 -46
  73. package/generated/versions/defold-1.12.4/index.d.ts +2 -0
  74. package/generated/versions/defold-1.12.4/json.d.ts +10 -6
  75. package/generated/versions/defold-1.12.4/label.d.ts +2 -3
  76. package/generated/versions/defold-1.12.4/liveupdate.d.ts +5 -3
  77. package/generated/versions/defold-1.12.4/model.d.ts +34 -13
  78. package/generated/versions/defold-1.12.4/particlefx.d.ts +2 -5
  79. package/generated/versions/defold-1.12.4/physics.d.ts +82 -78
  80. package/generated/versions/defold-1.12.4/profiler.d.ts +3 -6
  81. package/generated/versions/defold-1.12.4/render.d.ts +160 -132
  82. package/generated/versions/defold-1.12.4/resource.d.ts +212 -209
  83. package/generated/versions/defold-1.12.4/socket.d.ts +45 -61
  84. package/generated/versions/defold-1.12.4/sound.d.ts +11 -11
  85. package/generated/versions/defold-1.12.4/sprite.d.ts +24 -6
  86. package/generated/versions/defold-1.12.4/sys.d.ts +45 -68
  87. package/generated/versions/defold-1.12.4/tilemap.d.ts +18 -11
  88. package/generated/versions/defold-1.12.4/timer.d.ts +5 -3
  89. package/generated/versions/defold-1.12.4/vmath.d.ts +5 -26
  90. package/generated/versions/defold-1.12.4/window.d.ts +1 -16
  91. package/generated/versions/defold-1.13.0/b2d_body.d.ts +10 -55
  92. package/generated/versions/defold-1.13.0/b2d_fixture.d.ts +25 -25
  93. package/generated/versions/defold-1.13.0/b2d_shape.d.ts +188 -5
  94. package/generated/versions/defold-1.13.0/b2d_world.d.ts +16 -10
  95. package/generated/versions/defold-1.13.0/buffer.d.ts +18 -17
  96. package/generated/versions/defold-1.13.0/camera.d.ts +27 -27
  97. package/generated/versions/defold-1.13.0/collectionfactory.d.ts +21 -19
  98. package/generated/versions/defold-1.13.0/collectionproxy.d.ts +2 -2
  99. package/generated/versions/defold-1.13.0/compute.d.ts +1 -70
  100. package/generated/versions/defold-1.13.0/crash.d.ts +2 -2
  101. package/generated/versions/defold-1.13.0/editor-vm/tilemap_tiles.d.ts +3 -3
  102. package/generated/versions/defold-1.13.0/editor.d.ts +34 -24
  103. package/generated/versions/defold-1.13.0/factory.d.ts +15 -16
  104. package/generated/versions/defold-1.13.0/go.d.ts +15 -17
  105. package/generated/versions/defold-1.13.0/graphics.d.ts +121 -37
  106. package/generated/versions/defold-1.13.0/gui.d.ts +111 -193
  107. package/generated/versions/defold-1.13.0/html5.d.ts +4 -2
  108. package/generated/versions/defold-1.13.0/http.d.ts +4 -15
  109. package/generated/versions/defold-1.13.0/image.d.ts +38 -46
  110. package/generated/versions/defold-1.13.0/index.d.ts +2 -0
  111. package/generated/versions/defold-1.13.0/json.d.ts +10 -6
  112. package/generated/versions/defold-1.13.0/label.d.ts +2 -3
  113. package/generated/versions/defold-1.13.0/liveupdate.d.ts +7 -5
  114. package/generated/versions/defold-1.13.0/material.d.ts +69 -107
  115. package/generated/versions/defold-1.13.0/model.d.ts +34 -13
  116. package/generated/versions/defold-1.13.0/particlefx.d.ts +2 -5
  117. package/generated/versions/defold-1.13.0/physics.d.ts +82 -78
  118. package/generated/versions/defold-1.13.0/profiler.d.ts +3 -6
  119. package/generated/versions/defold-1.13.0/render.d.ts +160 -132
  120. package/generated/versions/defold-1.13.0/resource.d.ts +217 -210
  121. package/generated/versions/defold-1.13.0/socket.d.ts +45 -61
  122. package/generated/versions/defold-1.13.0/sound.d.ts +11 -11
  123. package/generated/versions/defold-1.13.0/sprite.d.ts +24 -6
  124. package/generated/versions/defold-1.13.0/sys.d.ts +45 -68
  125. package/generated/versions/defold-1.13.0/tilemap.d.ts +18 -11
  126. package/generated/versions/defold-1.13.0/timer.d.ts +5 -3
  127. package/generated/versions/defold-1.13.0/vmath.d.ts +5 -26
  128. package/generated/versions/defold-1.13.0/window.d.ts +1 -16
  129. package/generated/versions/defold-1.13.1/b2d.d.ts +33 -0
  130. package/generated/versions/defold-1.13.1/b2d_body.d.ts +636 -0
  131. package/generated/versions/defold-1.13.1/b2d_chain.d.ts +106 -0
  132. package/generated/versions/defold-1.13.1/b2d_fixture.d.ts +157 -0
  133. package/generated/versions/defold-1.13.1/b2d_joint.d.ts +823 -0
  134. package/generated/versions/defold-1.13.1/b2d_shape.d.ts +400 -0
  135. package/generated/versions/defold-1.13.1/b2d_world.d.ts +320 -0
  136. package/generated/versions/defold-1.13.1/buffer.d.ts +189 -0
  137. package/generated/versions/defold-1.13.1/camera.d.ts +303 -0
  138. package/generated/versions/defold-1.13.1/collectionfactory.d.ts +151 -0
  139. package/generated/versions/defold-1.13.1/collectionproxy.d.ts +93 -0
  140. package/generated/versions/defold-1.13.1/compute.d.ts +237 -0
  141. package/generated/versions/defold-1.13.1/crash.d.ts +143 -0
  142. package/generated/versions/defold-1.13.1/editor-vm/http.d.ts +56 -0
  143. package/generated/versions/defold-1.13.1/editor-vm/image.d.ts +48 -0
  144. package/generated/versions/defold-1.13.1/editor-vm/json.d.ts +10 -0
  145. package/generated/versions/defold-1.13.1/editor-vm/localization.d.ts +42 -0
  146. package/generated/versions/defold-1.13.1/editor-vm/tilemap_tiles.d.ts +80 -0
  147. package/generated/versions/defold-1.13.1/editor-vm/zip.d.ts +10 -0
  148. package/generated/versions/defold-1.13.1/editor-vm/zlib.d.ts +24 -0
  149. package/generated/versions/defold-1.13.1/editor.d.ts +1121 -0
  150. package/generated/versions/defold-1.13.1/factory.d.ts +124 -0
  151. package/generated/versions/defold-1.13.1/font.d.ts +81 -0
  152. package/generated/versions/defold-1.13.1/go.d.ts +1107 -0
  153. package/generated/versions/defold-1.13.1/graphics.d.ts +411 -0
  154. package/generated/versions/defold-1.13.1/gui.d.ts +2353 -0
  155. package/generated/versions/defold-1.13.1/html5.d.ts +55 -0
  156. package/generated/versions/defold-1.13.1/http.d.ts +77 -0
  157. package/generated/versions/defold-1.13.1/image.d.ts +131 -0
  158. package/generated/versions/defold-1.13.1/index.d.ts +57 -0
  159. package/generated/versions/defold-1.13.1/json.d.ts +80 -0
  160. package/generated/versions/defold-1.13.1/kinds/editor-script.d.ts +14 -0
  161. package/generated/versions/defold-1.13.1/label.d.ts +93 -0
  162. package/generated/versions/defold-1.13.1/liveupdate.d.ts +142 -0
  163. package/generated/versions/defold-1.13.1/material.d.ts +408 -0
  164. package/generated/versions/defold-1.13.1/model.d.ts +272 -0
  165. package/generated/versions/defold-1.13.1/msg.d.ts +10 -0
  166. package/generated/versions/defold-1.13.1/particlefx.d.ts +163 -0
  167. package/generated/versions/defold-1.13.1/physics.d.ts +559 -0
  168. package/generated/versions/defold-1.13.1/profiler.d.ts +235 -0
  169. package/generated/versions/defold-1.13.1/render.d.ts +1190 -0
  170. package/generated/versions/defold-1.13.1/resource.d.ts +1523 -0
  171. package/generated/versions/defold-1.13.1/socket.d.ts +784 -0
  172. package/generated/versions/defold-1.13.1/sound.d.ts +292 -0
  173. package/generated/versions/defold-1.13.1/sprite.d.ts +175 -0
  174. package/generated/versions/defold-1.13.1/sys.d.ts +678 -0
  175. package/generated/versions/defold-1.13.1/tilemap.d.ts +208 -0
  176. package/generated/versions/defold-1.13.1/timer.d.ts +125 -0
  177. package/generated/versions/defold-1.13.1/types.d.ts +61 -0
  178. package/generated/versions/defold-1.13.1/vmath.d.ts +774 -0
  179. package/generated/versions/defold-1.13.1/window.d.ts +183 -0
  180. package/generated/versions/defold-1.13.1/zlib.d.ts +41 -0
  181. package/generated/vmath.d.ts +6 -26
  182. package/generated/window.d.ts +71 -71
  183. package/identity-vocabulary.json +561 -0
  184. package/index.d.ts +8 -0
  185. package/package.json +13 -2
  186. package/scripts/example-store-io.ts +12 -1
  187. package/scripts/extension-goldens.ts +1 -0
  188. package/scripts/fidelity-baseline.json +146 -46
  189. package/scripts/generate-api-availability.ts +90 -12
  190. package/scripts/generate-api-signatures.ts +14 -3
  191. package/scripts/import-defold-release.ts +85 -24
  192. package/scripts/prose-constants.ts +157 -0
  193. package/scripts/regen.ts +396 -78
  194. package/scripts/shared-handle-methods.ts +53 -0
  195. package/scripts/signature-store-fs.ts +1 -0
  196. package/scripts/sync-api-docs.ts +16 -5
  197. package/src/api-availability.ts +0 -0
  198. package/src/api-doc.ts +201 -3
  199. package/src/api-identity.ts +252 -0
  200. package/src/component-properties.d.ts +33 -0
  201. package/src/core-types.ts +28 -3
  202. package/src/correction-pins.ts +49 -0
  203. package/src/custom-messages.d.ts +4 -3
  204. package/src/doc-comment.ts +139 -23
  205. package/src/doc-corrections.ts +108 -0
  206. package/src/editor-vm-globals.d.ts +5 -2
  207. package/src/emit-dts.ts +2474 -281
  208. package/src/emit-messages.ts +52 -0
  209. package/src/engine-globals.d.ts +2 -2
  210. package/src/example-store.ts +125 -14
  211. package/src/field-correction-coverage.ts +204 -0
  212. package/src/fnv1a.ts +16 -0
  213. package/src/go-overloads.d.ts +33 -13
  214. package/src/index-base-table.ts +145 -0
  215. package/src/index-slot-classifications.ts +588 -0
  216. package/src/index.ts +39 -2
  217. package/src/library-index-slot-classifications.ts +332 -0
  218. package/src/lifecycle.ts +61 -199
  219. package/src/luals-type-expr.ts +354 -0
  220. package/src/msg-overloads.d.ts +0 -1
  221. package/src/param-correction-provenance.ts +64 -0
  222. package/src/return-correction-provenance.ts +58 -16
  223. package/src/script-api.ts +3 -1
  224. package/src/sys-overloads.d.ts +48 -0
  225. package/src/vmath-overloads.d.ts +27 -1
  226. package/src/window-event-guard.d.ts +6 -9
  227. package/url-parameters.json +1 -2
@@ -1,5 +1,5 @@
1
1
  /** @noSelfInFile */
2
- import type { Hash, Opaque } from "../src/core-types";
2
+ import type { Opaque } from "../src/core-types";
3
3
 
4
4
  declare global {
5
5
  /**
@@ -7,29 +7,162 @@ declare global {
7
7
  * error handling and debugging.
8
8
  */
9
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
+ }
10
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;
11
144
  /**
12
- * network connected through other, non cellular, connection
145
+ * Connected through Wi-Fi or another non-cellular network.
13
146
  */
14
147
  const NETWORK_CONNECTED: number & { readonly __brand: "sys.NETWORK_CONNECTED" };
15
148
  /**
16
- * network connected through mobile cellular
149
+ * Connected through a cellular network.
17
150
  */
18
151
  const NETWORK_CONNECTED_CELLULAR: number & { readonly __brand: "sys.NETWORK_CONNECTED_CELLULAR" };
19
152
  /**
20
- * no network connection found
153
+ * No network connection was found.
21
154
  */
22
155
  const NETWORK_DISCONNECTED: number & { readonly __brand: "sys.NETWORK_DISCONNECTED" };
23
156
  /**
24
- * an asyncronous request is unable to read the resource
157
+ * An I/O error occurred.
25
158
  */
26
159
  const REQUEST_STATUS_ERROR_IO_ERROR: number & { readonly __brand: "sys.REQUEST_STATUS_ERROR_IO_ERROR" };
27
160
  /**
28
- * an asyncronous request is unable to locate the resource
161
+ * The requested resource was not found.
29
162
  */
30
163
  const REQUEST_STATUS_ERROR_NOT_FOUND: number & { readonly __brand: "sys.REQUEST_STATUS_ERROR_NOT_FOUND" };
31
164
  /**
32
- * an asyncronous request has finished successfully
165
+ * The request completed successfully.
33
166
  */
34
167
  const REQUEST_STATUS_FINISHED: number & { readonly __brand: "sys.REQUEST_STATUS_FINISHED" };
35
168
  /**
@@ -45,7 +178,7 @@ declare global {
45
178
  * const table = sys.deserialize(buffer);
46
179
  * ```
47
180
  */
48
- function deserialize(buffer: string): Record<string | number, unknown>;
181
+ function deserialize(buffer: string): LuaTable<AnyNotNil, unknown>;
49
182
  /**
50
183
  * Check if a path exists
51
184
  * Good for checking if a file exists before loading a large file
@@ -55,11 +188,12 @@ declare global {
55
188
  * @example
56
189
  * ```ts
57
190
  * // Load data but return nil if path didn't exist
58
- * const path = "/save/game.dat";
59
- * if (!sys.exists(path)) {
60
- * return undefined;
191
+ * function load_data(path: string) {
192
+ * if (!sys.exists(path)) {
193
+ * return undefined;
194
+ * }
195
+ * return sys.load(path); // returns {} if it failed
61
196
  * }
62
- * return sys.load(path); // returns {} if it failed
63
197
  * ```
64
198
  */
65
199
  function exists(path: string): boolean;
@@ -89,15 +223,12 @@ declare global {
89
223
  * On Android, the `app_string` is the package identifier for the app.
90
224
  *
91
225
  * @param app_string - platform specific string with application package or query, see above for details.
92
- * @returns table with application information in the following fields:
93
- *
94
- * `installed`
95
- * boolean `true` if the application is installed, `false` otherwise.
226
+ * @returns application information
96
227
  * @example
228
+ * Check if twitter is installed:
97
229
  * ```ts
98
- * // Check if twitter is installed:
99
230
  * const sysinfo = sys.get_sys_info();
100
- * let twitter = {};
231
+ * let twitter: { installed?: boolean } = {};
101
232
  *
102
233
  * if (sysinfo.system_name === "Android") {
103
234
  * twitter = sys.get_application_info("com.twitter.android");
@@ -108,8 +239,10 @@ declare global {
108
239
  * if (twitter.installed) {
109
240
  * // twitter is installed!
110
241
  * }
111
- *
112
- * // Info.plist for the iOS app needs to list the schemes that are queried:
242
+ * ```
243
+ * @example
244
+ * Info.plist for the iOS app needs to list the schemes that are queried:
245
+ * ```ts
113
246
  * // ...
114
247
  * // <key>LSApplicationQueriesSchemes</key>
115
248
  * // <array>
@@ -118,7 +251,7 @@ declare global {
118
251
  * // ...
119
252
  * ```
120
253
  */
121
- function get_application_info(app_string: string): { installed: boolean };
254
+ function get_application_info(app_string: string): sys.application_info;
122
255
  /**
123
256
  * The path from which the application is run.
124
257
  * This function will raise a Lua error if unable to get the application support path.
@@ -168,10 +301,12 @@ declare global {
168
301
  * @param default_value - (optional) default value to return if the value does not exist
169
302
  * @returns config value as an integer. default_value if the config key does not exist. 0 if no default value was supplied.
170
303
  * @example
304
+ * Get user config value
171
305
  * ```ts
172
- * // Get user config value
173
306
  * const speed = sys.get_config_int("my_game.speed", 20); // with default value
174
- *
307
+ * ```
308
+ * @example
309
+ * ```ts
175
310
  * const testmode = sys.get_config_int("my_game.testmode"); // without default value
176
311
  * if (testmode !== undefined) {
177
312
  * // do stuff
@@ -192,37 +327,12 @@ declare global {
192
327
  * ```
193
328
  */
194
329
  function get_config_number(key: string, default_value?: number): number;
195
- /**
196
- * Get string config value from the game.project configuration file with optional default value
197
- *
198
- * @param key - key to get value for. The syntax is SECTION.KEY
199
- * @param default_value - (optional) default value to return if the value does not exist
200
- * @returns config value as a string. default_value if the config key does not exist. nil if no default value was supplied.
201
- * @example
202
- * ```ts
203
- * // Get user config value
204
- * const text = sys.get_config_string("my_game.text", "default text");
205
- *
206
- * // Start the engine with a bootstrap config override and add a custom config value
207
- * // $ dmengine --config=bootstrap.main_collection=/mytest.collectionc --config=mygame.testmode=1
208
- *
209
- * // Read the custom config value from the command line
210
- * const testmode = sys.get_config_int("mygame.testmode");
211
- * ```
212
- */
213
- function get_config_string(key: string, default_value?: string): string;
214
330
  /**
215
331
  * Returns the current network connectivity status
216
332
  * on mobile platforms.
217
333
  * On desktop, this function always return `sys.NETWORK_CONNECTED`.
218
334
  *
219
- * @returns network connectivity status:
220
- *
221
- * - `sys.NETWORK_DISCONNECTED` (no network connection is found)
222
- *
223
- * - `sys.NETWORK_CONNECTED_CELLULAR` (connected through mobile cellular)
224
- *
225
- * - `sys.NETWORK_CONNECTED` (otherwise, Wifi)
335
+ * @returns network connectivity status
226
336
  * @example
227
337
  * ```ts
228
338
  * // Check if we are connected through a cellular connection
@@ -231,18 +341,11 @@ declare global {
231
341
  * }
232
342
  * ```
233
343
  */
234
- function get_connectivity(): sys.NetworkConnectivity;
344
+ function get_connectivity(): sys.NETWORK;
235
345
  /**
236
346
  * Returns a table with engine information.
237
347
  *
238
- * @returns table with engine information in the following fields:
239
- *
240
- * `version`
241
- * string The current Defold engine version, i.e. "1.2.96"
242
- * `version_sha1`
243
- * string The SHA1 for the current engine build, i.e. "0060183cce2e29dbd09c85ece83cbb72068ee050"
244
- * `is_debug`
245
- * boolean If the engine is a debug or release version
348
+ * @returns engine information
246
349
  * @example
247
350
  * ```ts
248
351
  * // How to retrieve engine information:
@@ -252,7 +355,7 @@ declare global {
252
355
  * gui.set_text(gui.get_node("version"), version_str);
253
356
  * ```
254
357
  */
255
- function get_engine_info(): { version: string; version_sha1: string; is_debug: boolean };
358
+ function get_engine_info(): sys.engine_info;
256
359
  /**
257
360
  * Create a path to the host device for unit testing
258
361
  * Useful for saving logs etc during development
@@ -260,13 +363,15 @@ declare global {
260
363
  * @param filename - file to read from
261
364
  * @returns the path prefixed with the proper host mount
262
365
  * @example
366
+ * Save data on the host
263
367
  * ```ts
264
- * // Save data on the host
265
368
  * const mytable = { score: 100, level: 3 };
266
369
  * const host_path = sys.get_host_path("logs/test.txt");
267
370
  * sys.save(host_path, mytable);
268
- *
269
- * // Load data from the host
371
+ * ```
372
+ * @example
373
+ * Load data from the host
374
+ * ```ts
270
375
  * const host_path = sys.get_host_path("logs/test.txt");
271
376
  * const table = sys.load(host_path);
272
377
  * ```
@@ -275,18 +380,7 @@ declare global {
275
380
  /**
276
381
  * Returns an array of tables with information on network interfaces.
277
382
  *
278
- * @returns an array of tables. Each table entry contain the following fields:
279
- *
280
- * `name`
281
- * string Interface name
282
- * `address`
283
- * string IP address. might be `nil` if not available.
284
- * `mac`
285
- * string Hardware MAC address. might be nil if not available.
286
- * `up`
287
- * boolean `true` if the interface is up (available to transmit and receive data), `false` otherwise.
288
- * `running`
289
- * boolean `true` if the interface is running, `false` otherwise.
383
+ * @returns network interfaces
290
384
  * @example
291
385
  * ```ts
292
386
  * // How to get the IP address of interface "en0":
@@ -298,7 +392,7 @@ declare global {
298
392
  * }
299
393
  * ```
300
394
  */
301
- function get_ifaddrs(): { name: string; address?: string; mac?: string; up: boolean; running: boolean }[];
395
+ function get_ifaddrs(): sys.interface_info[];
302
396
  /**
303
397
  * The save-file path is operating system specific and is typically located under the user's home directory.
304
398
  * This function will raise a Lua error if unable to get the save file path.
@@ -334,32 +428,8 @@ declare global {
334
428
  /**
335
429
  * Returns a table with system information.
336
430
  *
337
- * @param options - optional options table
338
- * - ignore_secure boolean this flag ignores values might be secured by OS e.g. `device_ident`
339
- * @returns table with system information in the following fields:
340
- *
341
- * `device_model`
342
- * string Only available on iOS and Android.
343
- * `manufacturer`
344
- * string Only available on iOS and Android.
345
- * `system_name`
346
- * string The system name: "Darwin", "Linux", "Windows", "HTML5", "Android" or "iPhone OS"
347
- * `system_version`
348
- * string The system OS version.
349
- * `api_version`
350
- * string The API version on the system.
351
- * `language`
352
- * string Two character ISO-639 format, i.e. "en".
353
- * `device_language`
354
- * 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.
355
- * `territory`
356
- * string Two character ISO-3166 format, i.e. "US".
357
- * `gmt_offset`
358
- * number The current offset from GMT (Greenwich Mean Time), in minutes.
359
- * `device_ident`
360
- * 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.
361
- * `user_agent`
362
- * 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"
431
+ * @param options - optional system-information options
432
+ * @returns system information
363
433
  * @example
364
434
  * ```ts
365
435
  * // How to get system information:
@@ -369,7 +439,7 @@ declare global {
369
439
  * }
370
440
  * ```
371
441
  */
372
- 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 };
442
+ function get_sys_info(options?: sys.sys_info_options): sys.sys_info;
373
443
  /**
374
444
  * If the file exists, it must have been created by `sys.save` to be loaded.
375
445
  * This function will raise a Lua error if an error occurs while loading the file.
@@ -386,7 +456,7 @@ declare global {
386
456
  * }
387
457
  * ```
388
458
  */
389
- function load(filename: string): Record<string | number, unknown>;
459
+ function load(filename: string): LuaTable<AnyNotNil, unknown>;
390
460
  /**
391
461
  * The sys.load_buffer function will first try to load the resource
392
462
  * from any of the mounted resource locations and return the data if
@@ -402,13 +472,15 @@ declare global {
402
472
  * @param path - the path to load the buffer from
403
473
  * @returns the buffer with data
404
474
  * @example
475
+ * Load binary data from a custom project resource:
405
476
  * ```ts
406
- * // Load binary data from a custom project resource:
407
477
  * const my_buffer = sys.load_buffer("/assets/my_level_data.bin");
408
478
  * const data_str = buffer.get_bytes(my_buffer, "data");
409
479
  * const has_my_header = data_str.slice(0, 6) === "D3F0LD";
410
- *
411
- * // Load binary data from non-custom resource files on disk:
480
+ * ```
481
+ * @example
482
+ * Load binary data from non-custom resource files on disk:
483
+ * ```ts
412
484
  * const asset_1 = sys.load_buffer("folder_next_to_binary/my_level_asset.txt");
413
485
  * const asset_2 = sys.load_buffer("/my/absolute/path");
414
486
  * ```
@@ -426,59 +498,51 @@ declare global {
426
498
  * included:
427
499
  * For example "main/data/,assets/level_data.json".
428
500
  * Note that issuing multiple requests of the same resource will yield
429
- * individual buffers per request. There is no implic caching of the buffers
501
+ * individual buffers per request. There is no implicit caching of the buffers
430
502
  * based on request path.
431
503
  *
432
504
  * @param path - the path to load the buffer from
433
- * @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:
434
- *
435
- * `status`
436
- * number The status of the request, supported values are:
437
- *
438
- * - `resource.REQUEST_STATUS_FINISHED`
439
- *
440
- * - `resource.REQUEST_STATUS_ERROR_IO_ERROR`
441
- *
442
- * - `resource.REQUEST_STATUS_ERROR_NOT_FOUND`
443
- *
444
- * `buffer`
445
- * 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!
505
+ * @param status_callback - callback invoked when the request completes or fails
446
506
  * @returns a handle to the request
447
507
  * @example
508
+ * Load binary data from a custom project resource and update a texture resource:
448
509
  * ```ts
449
510
  * // Load binary data from a custom project resource and update a texture resource:
450
- * function my_callback(self: unknown, request_id: unknown, result: unknown) {
451
- * const { status, buf } = result as { status: number; buf: Opaque<"buffer"> };
452
- * if (status === resource.REQUEST_STATUS_FINISHED) {
453
- * resource.set_texture("/my_texture", {}, buf); // texture args
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);
454
515
  * }
455
516
  * }
456
517
  *
457
518
  * const my_request = sys.load_buffer_async("/assets/my_level_data.bin", my_callback);
458
- *
519
+ * ```
520
+ * @example
521
+ * Load binary data from non-custom resource files on disk:
522
+ * ```ts
459
523
  * // Load binary data from non-custom resource files on disk:
460
- * function my_callback(self: unknown, request_id: unknown, result: unknown) {
461
- * const { first_asset, second_asset } = self as { first_asset: Hash; second_asset: Hash };
462
- * if ((result as { status: number }).status !== sys.REQUEST_STATUS_FINISHED) {
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) {
463
527
  * // uh oh! File could not be found, do something graceful
464
- * } else if (request_id === first_asset) {
528
+ * } else if (request_id === first_request) {
465
529
  * // result.buffer contains data from my_level_asset.bin
466
- * } else if (request_id === second_asset) {
530
+ * } else if (request_id === second_request) {
467
531
  * // result.buffer contains data from 'my_level.bin'
468
532
  * }
469
533
  * }
470
534
  *
471
535
  * export default defineScript({
472
- * init(self) {
473
- * self.first_asset = hash("folder_next_to_binary/my_level_asset.bin");
474
- * self.second_asset = hash("/some_absolute_path/my_level.bin");
475
- * self.first_request = sys.load_buffer_async(self.first_asset, my_callback);
476
- * self.second_request = sys.load_buffer_async(self.second_asset, my_callback);
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
+ * };
477
541
  * },
478
542
  * });
479
543
  * ```
480
544
  */
481
- function load_buffer_async(path: string, status_callback: (self: unknown, request_id: unknown, result: unknown) => void): number;
545
+ function load_buffer_async(path: string, status_callback: (self: unknown, request_id: number, result: sys.load_buffer_result) => void): number;
482
546
  /**
483
547
  * Loads a custom resource. Specify the full filename of the resource that you want
484
548
  * to load. When loaded, the file data is returned as a string.
@@ -509,14 +573,7 @@ declare global {
509
573
  * Open URL in default application, typically a browser
510
574
  *
511
575
  * @param url - url to open
512
- * @param attributes - table with attributes
513
- * `target`
514
- * - string : Optional. Specifies the target attribute or the name of the window. The following values are supported:
515
- * - `_self` - (default value) URL replaces the current page.
516
- * - `_blank` - URL is loaded into a new window, or tab.
517
- * - `_parent` - URL is loaded into the parent frame.
518
- * - `_top` - URL replaces any framesets that may be loaded.
519
- * - `name` - The name of the window (Note: the name does not specify the title of the new window).
576
+ * @param attributes - optional URL opening attributes
520
577
  * @returns a boolean indicating if the url could be opened or not
521
578
  * @example
522
579
  * ```ts
@@ -527,7 +584,7 @@ declare global {
527
584
  * }
528
585
  * ```
529
586
  */
530
- function open_url(url: string, attributes?: { target?: string }): boolean;
587
+ function open_url(url: string, attributes?: sys.open_url_attributes): boolean;
531
588
  /**
532
589
  * Reboots the game engine with a specified set of arguments.
533
590
  * Arguments will be translated into command line arguments. Calling reboot
@@ -572,7 +629,7 @@ declare global {
572
629
  * sys.save(my_file_path, my_table);
573
630
  * ```
574
631
  */
575
- function save(filename: string, table: Record<string | number, unknown>): void;
632
+ function save(filename: string, table: LuaMap<AnyNotNil, unknown> | Record<string, unknown> | readonly unknown[]): boolean;
576
633
  /**
577
634
  * The buffer can later deserialized by `sys.deserialize`.
578
635
  * This function has all the same limitations as `sys.save`.
@@ -588,7 +645,7 @@ declare global {
588
645
  * const buffer = sys.serialize(my_table);
589
646
  * ```
590
647
  */
591
- function serialize(table: Record<string | number, unknown>): string;
648
+ function serialize(table: LuaMap<AnyNotNil, unknown> | Record<string, unknown> | readonly unknown[]): string;
592
649
  /**
593
650
  * Sets the host that is used to check for network connectivity against.
594
651
  *
@@ -599,21 +656,6 @@ declare global {
599
656
  * ```
600
657
  */
601
658
  function set_connectivity_host(host: string): void;
602
- /**
603
- * Enables engine throttling.
604
- *
605
- * @param enable - true if throttling should be enabled
606
- * @param cooldown - the time period to do update + render for (seconds)
607
- * @example
608
- * ```ts
609
- * // Disable throttling
610
- * sys.set_engine_throttle(false);
611
- *
612
- * // Enable throttling
613
- * sys.set_engine_throttle(true, 1.5);
614
- * ```
615
- */
616
- function set_engine_throttle(enable: boolean, cooldown?: number): void;
617
659
  /**
618
660
  * Set the Lua error handler function.
619
661
  * The error handler is a function which is called whenever a lua runtime error occurs.
@@ -649,7 +691,7 @@ declare global {
649
691
  * });
650
692
  * ```
651
693
  */
652
- function set_error_handler(error_handler: (source: unknown, message: unknown, traceback: unknown) => void): void;
694
+ function set_error_handler(error_handler: (source: string, message: string, traceback: string) => void): void;
653
695
  /**
654
696
  * Disables rendering
655
697
  *
@@ -657,18 +699,29 @@ declare global {
657
699
  * @example
658
700
  * ```ts
659
701
  * // Disable rendering
660
- * sys.set_render_enable(false);
702
+ * sys.set_render_enabled(false);
661
703
  * ```
662
704
  */
663
- function set_render_enable(enable: boolean): void;
664
- /**
665
- * Set game update-frequency (frame cap). This option is equivalent to `display.update_frequency` in
666
- * the "game.project" settings but set in run-time. If `Vsync` checked in "game.project", the rate will
667
- * be clamped to a swap interval that matches any detected main monitor refresh rate. If `Vsync` is
668
- * unchecked the engine will try to respect the rate in software using timers. There is no
669
- * guarantee that the frame cap will be achieved depending on platform specifics and hardware settings.
670
- *
671
- * @param frequency - target frequency. 60 for 60 fps
705
+ function set_render_enabled(enable: boolean): void;
706
+ /**
707
+ * Set game update-frequency (frame cap). This option is equivalent to
708
+ * `display.update_frequency` in the "game.project" settings but set at run-time.
709
+ * On platforms where Defold owns the application loop, a positive value uses
710
+ * timer pacing and requests a swap interval of 0 to avoid an additional vsync
711
+ * wait where supported. Setting the frequency to 0 restores the requested swap
712
+ * interval and uses variable-rate updates. Platform-owned loops, such as HTML5
713
+ * and iOS, retain their platform scheduling and presentation behavior. There is
714
+ * no guarantee that the frame cap will be achieved depending on platform and
715
+ * hardware constraints.
716
+ * With engine-side timer pacing, the update dt can be shortened or enlarged to
717
+ * account for elapsed time; the frame cap does not guarantee a constant dt.
718
+ * Elapsed time beyond max(engine.max_time_step, 1 / frequency) is discarded,
719
+ * so accumulated dt can trail wall-clock time after hitches. An intentional
720
+ * fixed interval longer than engine.max_time_step is allowed. This setting
721
+ * is separate from the fixed_update() timestep.
722
+ *
723
+ * @param frequency - target frequency in hertz. 0 selects a variable
724
+ * frame rate; negative values are treated as 0.
672
725
  * @example
673
726
  * ```ts
674
727
  * // Setting the update frequency to 60 frames per second
@@ -677,20 +730,22 @@ declare global {
677
730
  */
678
731
  function set_update_frequency(frequency: number): void;
679
732
  /**
680
- * Set the vsync swap interval. The interval with which to swap the front and back buffers
681
- * in sync with vertical blanks (v-blank), the hardware event where the screen image is updated
682
- * with data from the front buffer. A value of 1 swaps the buffers at every v-blank, a value of
683
- * 2 swaps the buffers every other v-blank and so on. A value of 0 disables waiting for v-blank
684
- * before swapping the buffers. Default value is 1.
685
- * When setting the swap interval to 0 and having `vsync` disabled in
686
- * "game.project", the engine will try to respect the set frame cap value from
687
- * "game.project" in software instead.
733
+ * Request a presentation interval relative to vertical blanks (v-blank).
734
+ * 0 requests disabling vsync and 1 requests presenting every refresh (the default).
735
+ * OpenGL may support larger intervals, such as 2 for every other refresh.
736
+ * Vulkan and Metal treat any nonzero interval as enabling vsync; DX12 clamps
737
+ * intervals to the supported range 0 through 4. Actual behavior depends on
738
+ * the backend, platform, and driver.
739
+ * On platforms where Defold owns the application loop, a positive
740
+ * `display.update_frequency` or a positive value set by `sys.set_update_frequency()`
741
+ * uses timer pacing and requests a swap interval of 0. The requested
742
+ * swap interval is retained and applied again when the update frequency is set to 0.
688
743
  * This setting may be overridden by driver settings.
689
744
  *
690
745
  * @param swap_interval - target swap interval.
691
746
  * @example
692
747
  * ```ts
693
- * // Setting the swap intervall to swap every v-blank
748
+ * // Setting the swap interval to swap every v-blank
694
749
  * sys.set_vsync_swap_interval(1);
695
750
  * ```
696
751
  */