@defold-typescript/types 0.40.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 (224) hide show
  1. package/api-availability.json +3963 -772
  2. package/api-migrations.json +27 -0
  3. package/api-signatures.json +18069 -10240
  4. package/api-targets.json +448 -11
  5. package/examples/translations.json +560 -89
  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 +183 -20
  13. package/generated/b2d_world.d.ts +57 -63
  14. package/generated/buffer.d.ts +16 -15
  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 +29 -32
  23. package/generated/collectionfactory.d.ts +15 -18
  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 +235 -182
  37. package/generated/graphics.d.ts +335 -97
  38. package/generated/gui.d.ts +240 -471
  39. package/generated/html5.d.ts +2 -2
  40. package/generated/http.d.ts +28 -35
  41. package/generated/image.d.ts +105 -72
  42. package/generated/json.d.ts +34 -16
  43. package/generated/kinds/gui-script.d.ts +7 -0
  44. package/generated/kinds/render-script.d.ts +7 -0
  45. package/generated/kinds/script.d.ts +7 -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 +40 -39
  50. package/generated/particlefx.d.ts +19 -28
  51. package/generated/physics.d.ts +365 -133
  52. package/generated/profiler.d.ts +13 -23
  53. package/generated/render.d.ts +237 -297
  54. package/generated/resource.d.ts +664 -583
  55. package/generated/socket.d.ts +120 -133
  56. package/generated/sound.d.ts +62 -31
  57. package/generated/sprite.d.ts +31 -17
  58. package/generated/sys.d.ts +234 -190
  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 +1 -3
  63. package/generated/versions/defold-1.12.4/camera.d.ts +21 -21
  64. package/generated/versions/defold-1.12.4/collectionfactory.d.ts +9 -9
  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 +6 -12
  69. package/generated/versions/defold-1.12.4/gui.d.ts +77 -175
  70. package/generated/versions/defold-1.12.4/html5.d.ts +1 -1
  71. package/generated/versions/defold-1.12.4/http.d.ts +0 -13
  72. package/generated/versions/defold-1.12.4/image.d.ts +16 -33
  73. package/generated/versions/defold-1.12.4/index.d.ts +1 -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 +2 -10
  78. package/generated/versions/defold-1.12.4/particlefx.d.ts +2 -5
  79. package/generated/versions/defold-1.12.4/physics.d.ts +69 -67
  80. package/generated/versions/defold-1.12.4/profiler.d.ts +2 -5
  81. package/generated/versions/defold-1.12.4/render.d.ts +99 -128
  82. package/generated/versions/defold-1.12.4/resource.d.ts +120 -148
  83. package/generated/versions/defold-1.12.4/socket.d.ts +34 -60
  84. package/generated/versions/defold-1.12.4/sound.d.ts +8 -8
  85. package/generated/versions/defold-1.12.4/sprite.d.ts +15 -5
  86. package/generated/versions/defold-1.12.4/sys.d.ts +37 -71
  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 +0 -21
  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 +169 -8
  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 +1 -3
  96. package/generated/versions/defold-1.13.0/camera.d.ts +25 -25
  97. package/generated/versions/defold-1.13.0/collectionfactory.d.ts +9 -9
  98. package/generated/versions/defold-1.13.0/collectionproxy.d.ts +2 -2
  99. package/generated/versions/defold-1.13.0/compute.d.ts +0 -69
  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 +6 -12
  105. package/generated/versions/defold-1.13.0/graphics.d.ts +73 -37
  106. package/generated/versions/defold-1.13.0/gui.d.ts +77 -175
  107. package/generated/versions/defold-1.13.0/html5.d.ts +1 -1
  108. package/generated/versions/defold-1.13.0/http.d.ts +0 -13
  109. package/generated/versions/defold-1.13.0/image.d.ts +16 -33
  110. package/generated/versions/defold-1.13.0/index.d.ts +1 -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 +68 -106
  115. package/generated/versions/defold-1.13.0/model.d.ts +2 -10
  116. package/generated/versions/defold-1.13.0/particlefx.d.ts +2 -5
  117. package/generated/versions/defold-1.13.0/physics.d.ts +69 -67
  118. package/generated/versions/defold-1.13.0/profiler.d.ts +2 -5
  119. package/generated/versions/defold-1.13.0/render.d.ts +99 -128
  120. package/generated/versions/defold-1.13.0/resource.d.ts +126 -150
  121. package/generated/versions/defold-1.13.0/socket.d.ts +34 -60
  122. package/generated/versions/defold-1.13.0/sound.d.ts +8 -8
  123. package/generated/versions/defold-1.13.0/sprite.d.ts +15 -5
  124. package/generated/versions/defold-1.13.0/sys.d.ts +37 -71
  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 +0 -21
  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 +1 -21
  182. package/generated/window.d.ts +71 -71
  183. package/identity-vocabulary.json +561 -0
  184. package/index.d.ts +7 -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 +12 -2
  191. package/scripts/import-defold-release.ts +85 -24
  192. package/scripts/prose-constants.ts +77 -16
  193. package/scripts/regen.ts +391 -77
  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/core-types.ts +26 -3
  201. package/src/correction-pins.ts +49 -0
  202. package/src/doc-comment.ts +104 -11
  203. package/src/doc-corrections.ts +108 -0
  204. package/src/editor-vm-globals.d.ts +5 -2
  205. package/src/emit-dts.ts +2064 -281
  206. package/src/emit-messages.ts +52 -0
  207. package/src/example-store.ts +125 -14
  208. package/src/field-correction-coverage.ts +204 -0
  209. package/src/fnv1a.ts +16 -0
  210. package/src/go-overloads.d.ts +25 -6
  211. package/src/index-base-table.ts +145 -0
  212. package/src/index-slot-classifications.ts +588 -0
  213. package/src/index.ts +38 -5
  214. package/src/library-index-slot-classifications.ts +332 -0
  215. package/src/lifecycle.ts +61 -199
  216. package/src/luals-type-expr.ts +354 -0
  217. package/src/msg-overloads.d.ts +0 -1
  218. package/src/param-correction-provenance.ts +8 -11
  219. package/src/render-overloads.d.ts +0 -15
  220. package/src/return-correction-provenance.ts +58 -16
  221. package/src/sys-overloads.d.ts +48 -0
  222. package/src/vmath-overloads.d.ts +27 -1
  223. package/src/window-event-guard.d.ts +6 -9
  224. 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
@@ -90,13 +223,10 @@ declare global {
90
223
  * On Android, the `app_string` is the package identifier for the app.
91
224
  *
92
225
  * @param app_string - platform specific string with application package or query, see above for details.
93
- * @returns table with application information in the following fields:
94
- *
95
- * `installed`
96
- * boolean `true` if the application is installed, `false` otherwise.
226
+ * @returns application information
97
227
  * @example
228
+ * Check if twitter is installed:
98
229
  * ```ts
99
- * // Check if twitter is installed:
100
230
  * const sysinfo = sys.get_sys_info();
101
231
  * let twitter: { installed?: boolean } = {};
102
232
  *
@@ -109,8 +239,10 @@ declare global {
109
239
  * if (twitter.installed) {
110
240
  * // twitter is installed!
111
241
  * }
112
- *
113
- * // 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
114
246
  * // ...
115
247
  * // <key>LSApplicationQueriesSchemes</key>
116
248
  * // <array>
@@ -119,7 +251,7 @@ declare global {
119
251
  * // ...
120
252
  * ```
121
253
  */
122
- function get_application_info(app_string: string): { installed: boolean };
254
+ function get_application_info(app_string: string): sys.application_info;
123
255
  /**
124
256
  * The path from which the application is run.
125
257
  * This function will raise a Lua error if unable to get the application support path.
@@ -169,10 +301,12 @@ declare global {
169
301
  * @param default_value - (optional) default value to return if the value does not exist
170
302
  * @returns config value as an integer. default_value if the config key does not exist. 0 if no default value was supplied.
171
303
  * @example
304
+ * Get user config value
172
305
  * ```ts
173
- * // Get user config value
174
306
  * const speed = sys.get_config_int("my_game.speed", 20); // with default value
175
- *
307
+ * ```
308
+ * @example
309
+ * ```ts
176
310
  * const testmode = sys.get_config_int("my_game.testmode"); // without default value
177
311
  * if (testmode !== undefined) {
178
312
  * // do stuff
@@ -193,37 +327,12 @@ declare global {
193
327
  * ```
194
328
  */
195
329
  function get_config_number(key: string, default_value?: number): number;
196
- /**
197
- * Get string config value from the game.project configuration file with optional default value
198
- *
199
- * @param key - key to get value for. The syntax is SECTION.KEY
200
- * @param default_value - (optional) default value to return if the value does not exist
201
- * @returns config value as a string. default_value if the config key does not exist. nil if no default value was supplied.
202
- * @example
203
- * ```ts
204
- * // Get user config value
205
- * const text = sys.get_config_string("my_game.text", "default text");
206
- *
207
- * // Start the engine with a bootstrap config override and add a custom config value
208
- * // $ dmengine --config=bootstrap.main_collection=/mytest.collectionc --config=mygame.testmode=1
209
- *
210
- * // Read the custom config value from the command line
211
- * const testmode = sys.get_config_int("mygame.testmode");
212
- * ```
213
- */
214
- function get_config_string(key: string, default_value?: string): string;
215
330
  /**
216
331
  * Returns the current network connectivity status
217
332
  * on mobile platforms.
218
333
  * On desktop, this function always return `sys.NETWORK_CONNECTED`.
219
334
  *
220
- * @returns network connectivity status:
221
- *
222
- * - `sys.NETWORK_DISCONNECTED` (no network connection is found)
223
- *
224
- * - `sys.NETWORK_CONNECTED_CELLULAR` (connected through mobile cellular)
225
- *
226
- * - `sys.NETWORK_CONNECTED` (otherwise, Wifi)
335
+ * @returns network connectivity status
227
336
  * @example
228
337
  * ```ts
229
338
  * // Check if we are connected through a cellular connection
@@ -232,18 +341,11 @@ declare global {
232
341
  * }
233
342
  * ```
234
343
  */
235
- function get_connectivity(): sys.NetworkConnectivity;
344
+ function get_connectivity(): sys.NETWORK;
236
345
  /**
237
346
  * Returns a table with engine information.
238
347
  *
239
- * @returns table with engine information in the following fields:
240
- *
241
- * `version`
242
- * string The current Defold engine version, i.e. "1.2.96"
243
- * `version_sha1`
244
- * string The SHA1 for the current engine build, i.e. "0060183cce2e29dbd09c85ece83cbb72068ee050"
245
- * `is_debug`
246
- * boolean If the engine is a debug or release version
348
+ * @returns engine information
247
349
  * @example
248
350
  * ```ts
249
351
  * // How to retrieve engine information:
@@ -253,7 +355,7 @@ declare global {
253
355
  * gui.set_text(gui.get_node("version"), version_str);
254
356
  * ```
255
357
  */
256
- function get_engine_info(): { version: string; version_sha1: string; is_debug: boolean };
358
+ function get_engine_info(): sys.engine_info;
257
359
  /**
258
360
  * Create a path to the host device for unit testing
259
361
  * Useful for saving logs etc during development
@@ -261,37 +363,24 @@ declare global {
261
363
  * @param filename - file to read from
262
364
  * @returns the path prefixed with the proper host mount
263
365
  * @example
366
+ * Save data on the host
264
367
  * ```ts
265
- * // Save data on the host
266
- * {
267
- * const mytable = { score: 100, level: 3 };
268
- * const host_path = sys.get_host_path("logs/test.txt");
269
- * sys.save(host_path, mytable);
270
- * }
271
- *
272
- * // Load data from the host
273
- * {
274
- * const host_path = sys.get_host_path("logs/test.txt");
275
- * const table = sys.load(host_path);
276
- * }
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);
277
377
  * ```
278
378
  */
279
379
  function get_host_path(filename: string): string;
280
380
  /**
281
381
  * Returns an array of tables with information on network interfaces.
282
382
  *
283
- * @returns an array of tables. Each table entry contain the following fields:
284
- *
285
- * `name`
286
- * string Interface name
287
- * `address`
288
- * string IP address. might be `nil` if not available.
289
- * `mac`
290
- * string Hardware MAC address. might be nil if not available.
291
- * `up`
292
- * boolean `true` if the interface is up (available to transmit and receive data), `false` otherwise.
293
- * `running`
294
- * boolean `true` if the interface is running, `false` otherwise.
383
+ * @returns network interfaces
295
384
  * @example
296
385
  * ```ts
297
386
  * // How to get the IP address of interface "en0":
@@ -303,7 +392,7 @@ declare global {
303
392
  * }
304
393
  * ```
305
394
  */
306
- function get_ifaddrs(): { name: string; address?: string; mac?: string; up: boolean; running: boolean }[];
395
+ function get_ifaddrs(): sys.interface_info[];
307
396
  /**
308
397
  * The save-file path is operating system specific and is typically located under the user's home directory.
309
398
  * This function will raise a Lua error if unable to get the save file path.
@@ -339,32 +428,8 @@ declare global {
339
428
  /**
340
429
  * Returns a table with system information.
341
430
  *
342
- * @param options - optional options table
343
- * - ignore_secure boolean this flag ignores values might be secured by OS e.g. `device_ident`
344
- * @returns table with system information in the following fields:
345
- *
346
- * `device_model`
347
- * string Only available on iOS and Android.
348
- * `manufacturer`
349
- * string Only available on iOS and Android.
350
- * `system_name`
351
- * string The system name: "Darwin", "Linux", "Windows", "HTML5", "Android" or "iPhone OS"
352
- * `system_version`
353
- * string The system OS version.
354
- * `api_version`
355
- * string The API version on the system.
356
- * `language`
357
- * string Two character ISO-639 format, i.e. "en".
358
- * `device_language`
359
- * 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.
360
- * `territory`
361
- * string Two character ISO-3166 format, i.e. "US".
362
- * `gmt_offset`
363
- * number The current offset from GMT (Greenwich Mean Time), in minutes.
364
- * `device_ident`
365
- * 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.
366
- * `user_agent`
367
- * 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
368
433
  * @example
369
434
  * ```ts
370
435
  * // How to get system information:
@@ -374,7 +439,7 @@ declare global {
374
439
  * }
375
440
  * ```
376
441
  */
377
- 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;
378
443
  /**
379
444
  * If the file exists, it must have been created by `sys.save` to be loaded.
380
445
  * This function will raise a Lua error if an error occurs while loading the file.
@@ -391,7 +456,7 @@ declare global {
391
456
  * }
392
457
  * ```
393
458
  */
394
- function load(filename: string): Record<string | number, unknown>;
459
+ function load(filename: string): LuaTable<AnyNotNil, unknown>;
395
460
  /**
396
461
  * The sys.load_buffer function will first try to load the resource
397
462
  * from any of the mounted resource locations and return the data if
@@ -407,13 +472,15 @@ declare global {
407
472
  * @param path - the path to load the buffer from
408
473
  * @returns the buffer with data
409
474
  * @example
475
+ * Load binary data from a custom project resource:
410
476
  * ```ts
411
- * // Load binary data from a custom project resource:
412
477
  * const my_buffer = sys.load_buffer("/assets/my_level_data.bin");
413
478
  * const data_str = buffer.get_bytes(my_buffer, "data");
414
479
  * const has_my_header = data_str.slice(0, 6) === "D3F0LD";
415
- *
416
- * // 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
417
484
  * const asset_1 = sys.load_buffer("folder_next_to_binary/my_level_asset.txt");
418
485
  * const asset_2 = sys.load_buffer("/my/absolute/path");
419
486
  * ```
@@ -431,65 +498,51 @@ declare global {
431
498
  * included:
432
499
  * For example "main/data/,assets/level_data.json".
433
500
  * Note that issuing multiple requests of the same resource will yield
434
- * 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
435
502
  * based on request path.
436
503
  *
437
504
  * @param path - the path to load the buffer from
438
- * @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:
439
- *
440
- * `status`
441
- * number The status of the request, supported values are:
442
- *
443
- * - `resource.REQUEST_STATUS_FINISHED`
444
- *
445
- * - `resource.REQUEST_STATUS_ERROR_IO_ERROR`
446
- *
447
- * - `resource.REQUEST_STATUS_ERROR_NOT_FOUND`
448
- *
449
- * `buffer`
450
- * 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
451
506
  * @returns a handle to the request
452
507
  * @example
508
+ * Load binary data from a custom project resource and update a texture resource:
453
509
  * ```ts
454
510
  * // Load binary data from a custom project resource and update a texture resource:
455
- * {
456
- * function my_callback(self: unknown, request_id: unknown, result: unknown) {
457
- * const { status, buf } = result as { status: number; buf: Opaque<"buffer"> };
458
- * if (status === sys.REQUEST_STATUS_FINISHED) {
459
- * resource.set_texture("/my_texture", {}, buf); // texture args
460
- * }
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);
461
515
  * }
462
- *
463
- * const my_request = sys.load_buffer_async("/assets/my_level_data.bin", my_callback);
464
516
  * }
465
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
466
523
  * // Load binary data from non-custom resource files on disk:
467
- * function my_callback(self: unknown, request_id: unknown, result: unknown) {
468
- * const { first_asset, second_asset } = self as { first_asset: Hash; second_asset: Hash };
469
- * 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) {
470
527
  * // uh oh! File could not be found, do something graceful
471
- * } else if (request_id === first_asset) {
528
+ * } else if (request_id === first_request) {
472
529
  * // result.buffer contains data from my_level_asset.bin
473
- * } else if (request_id === second_asset) {
530
+ * } else if (request_id === second_request) {
474
531
  * // result.buffer contains data from 'my_level.bin'
475
532
  * }
476
533
  * }
477
534
  *
478
535
  * export default defineScript({
479
536
  * init() {
480
- * const first_path = "folder_next_to_binary/my_level_asset.bin";
481
- * const second_path = "/some_absolute_path/my_level.bin";
482
537
  * return {
483
- * first_asset: hash(first_path),
484
- * second_asset: hash(second_path),
485
- * first_request: sys.load_buffer_async(first_path, my_callback),
486
- * second_request: sys.load_buffer_async(second_path, my_callback),
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),
487
540
  * };
488
541
  * },
489
542
  * });
490
543
  * ```
491
544
  */
492
- 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;
493
546
  /**
494
547
  * Loads a custom resource. Specify the full filename of the resource that you want
495
548
  * to load. When loaded, the file data is returned as a string.
@@ -520,14 +573,7 @@ declare global {
520
573
  * Open URL in default application, typically a browser
521
574
  *
522
575
  * @param url - url to open
523
- * @param attributes - table with attributes
524
- * `target`
525
- * - string : Optional. Specifies the target attribute or the name of the window. The following values are supported:
526
- * - `_self` - (default value) URL replaces the current page.
527
- * - `_blank` - URL is loaded into a new window, or tab.
528
- * - `_parent` - URL is loaded into the parent frame.
529
- * - `_top` - URL replaces any framesets that may be loaded.
530
- * - `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
531
577
  * @returns a boolean indicating if the url could be opened or not
532
578
  * @example
533
579
  * ```ts
@@ -538,7 +584,7 @@ declare global {
538
584
  * }
539
585
  * ```
540
586
  */
541
- function open_url(url: string, attributes?: { target?: string }): boolean;
587
+ function open_url(url: string, attributes?: sys.open_url_attributes): boolean;
542
588
  /**
543
589
  * Reboots the game engine with a specified set of arguments.
544
590
  * Arguments will be translated into command line arguments. Calling reboot
@@ -583,7 +629,7 @@ declare global {
583
629
  * sys.save(my_file_path, my_table);
584
630
  * ```
585
631
  */
586
- function save(filename: string, table: Record<string | number, unknown> | readonly unknown[]): void;
632
+ function save(filename: string, table: LuaMap<AnyNotNil, unknown> | Record<string, unknown> | readonly unknown[]): boolean;
587
633
  /**
588
634
  * The buffer can later deserialized by `sys.deserialize`.
589
635
  * This function has all the same limitations as `sys.save`.
@@ -599,7 +645,7 @@ declare global {
599
645
  * const buffer = sys.serialize(my_table);
600
646
  * ```
601
647
  */
602
- function serialize(table: Record<string | number, unknown> | readonly unknown[]): string;
648
+ function serialize(table: LuaMap<AnyNotNil, unknown> | Record<string, unknown> | readonly unknown[]): string;
603
649
  /**
604
650
  * Sets the host that is used to check for network connectivity against.
605
651
  *
@@ -610,21 +656,6 @@ declare global {
610
656
  * ```
611
657
  */
612
658
  function set_connectivity_host(host: string): void;
613
- /**
614
- * Enables engine throttling.
615
- *
616
- * @param enable - true if throttling should be enabled
617
- * @param cooldown - the time period to do update + render for (seconds)
618
- * @example
619
- * ```ts
620
- * // Disable throttling
621
- * sys.set_engine_throttle(false);
622
- *
623
- * // Enable throttling
624
- * sys.set_engine_throttle(true, 1.5);
625
- * ```
626
- */
627
- function set_engine_throttle(enable: boolean, cooldown?: number): void;
628
659
  /**
629
660
  * Set the Lua error handler function.
630
661
  * The error handler is a function which is called whenever a lua runtime error occurs.
@@ -660,7 +691,7 @@ declare global {
660
691
  * });
661
692
  * ```
662
693
  */
663
- 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;
664
695
  /**
665
696
  * Disables rendering
666
697
  *
@@ -668,18 +699,29 @@ declare global {
668
699
  * @example
669
700
  * ```ts
670
701
  * // Disable rendering
671
- * sys.set_render_enable(false);
702
+ * sys.set_render_enabled(false);
672
703
  * ```
673
704
  */
674
- function set_render_enable(enable: boolean): void;
675
- /**
676
- * Set game update-frequency (frame cap). This option is equivalent to `display.update_frequency` in
677
- * the "game.project" settings but set in run-time. If `Vsync` checked in "game.project", the rate will
678
- * be clamped to a swap interval that matches any detected main monitor refresh rate. If `Vsync` is
679
- * unchecked the engine will try to respect the rate in software using timers. There is no
680
- * guarantee that the frame cap will be achieved depending on platform specifics and hardware settings.
681
- *
682
- * @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.
683
725
  * @example
684
726
  * ```ts
685
727
  * // Setting the update frequency to 60 frames per second
@@ -688,20 +730,22 @@ declare global {
688
730
  */
689
731
  function set_update_frequency(frequency: number): void;
690
732
  /**
691
- * Set the vsync swap interval. The interval with which to swap the front and back buffers
692
- * in sync with vertical blanks (v-blank), the hardware event where the screen image is updated
693
- * with data from the front buffer. A value of 1 swaps the buffers at every v-blank, a value of
694
- * 2 swaps the buffers every other v-blank and so on. A value of 0 disables waiting for v-blank
695
- * before swapping the buffers. Default value is 1.
696
- * When setting the swap interval to 0 and having `vsync` disabled in
697
- * "game.project", the engine will try to respect the set frame cap value from
698
- * "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.
699
743
  * This setting may be overridden by driver settings.
700
744
  *
701
745
  * @param swap_interval - target swap interval.
702
746
  * @example
703
747
  * ```ts
704
- * // Setting the swap intervall to swap every v-blank
748
+ * // Setting the swap interval to swap every v-blank
705
749
  * sys.set_vsync_swap_interval(1);
706
750
  * ```
707
751
  */