@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
@@ -0,0 +1,55 @@
1
+ /** @noSelfInFile */
2
+ declare global {
3
+ /**
4
+ * HTML5 platform specific functions.
5
+ *
6
+ * [icon:html5] The following functions are only available on HTML5 builds, the `html5.*` Lua namespace will not be available on other platforms.
7
+ */
8
+ namespace html5 {
9
+ /**
10
+ * Executes the supplied string as JavaScript inside the browser.
11
+ * A call to this function is blocking, the result is returned as-is, as a string.
12
+ * (Internally this will execute the string using the `eval()` JavaScript function.)
13
+ *
14
+ * @param code - Javascript code to run
15
+ * @returns result as string
16
+ * @example
17
+ * ```ts
18
+ * const res = html5.run("10 + 20"); // returns the string "30"
19
+ * print(res);
20
+ * const res_num = tonumber(res); // convert to number
21
+ * if (res_num !== undefined) {
22
+ * print(res_num - 20); // prints 10
23
+ * }
24
+ * ```
25
+ */
26
+ function run(code: string): string;
27
+ /**
28
+ * Set a JavaScript interaction listener callaback from lua that will be
29
+ * invoked when a user interacts with the web page by clicking, touching or typing.
30
+ * The callback can then call DOM restricted actions like requesting a pointer lock,
31
+ * or start playing sounds the first time the callback is invoked.
32
+ *
33
+ * @param callback - The interaction callback. Pass an empty function or `nil` if you no longer wish to receive callbacks.
34
+ *
35
+ * `self`
36
+ * object The calling script
37
+ * @example
38
+ * ```ts
39
+ * function on_interaction(self: unknown) {
40
+ * print("on_interaction called");
41
+ * html5.set_interaction_listener(undefined);
42
+ * }
43
+ *
44
+ * export default defineScript({
45
+ * init() {
46
+ * html5.set_interaction_listener(on_interaction);
47
+ * },
48
+ * });
49
+ * ```
50
+ */
51
+ function set_interaction_listener(callback: ((self: unknown) => void) | undefined): void;
52
+ }
53
+ }
54
+
55
+ export {};
@@ -0,0 +1,77 @@
1
+ /** @noSelfInFile */
2
+ import type { Hash } from "../../../src/core-types";
3
+
4
+ declare global {
5
+ /**
6
+ * Functions for performing HTTP and HTTPS requests.
7
+ */
8
+ namespace http {
9
+ /**
10
+ * Perform a HTTP/HTTPS request.
11
+ * If no timeout value is passed, the configuration value "network.http_timeout" is used. If that is not set, the timeout value is `0` (which blocks indefinitely).
12
+ *
13
+ * @param url - target url
14
+ * @param method - HTTP/HTTPS method, e.g. "GET", "PUT", "POST" etc.
15
+ * @param callback - response callback function
16
+ *
17
+ * `self`
18
+ * object The script instance
19
+ * `id`
20
+ * hash Internal message identifier. Do not use!
21
+ * `response`
22
+ * table The response data. Contains the fields:
23
+ *
24
+ * - number `status`: the status of the response
25
+ * - string `response`: the response data (if not saved on disc)
26
+ * - table `headers`: all the returned headers (if status is 200 or 206)
27
+ * - string `path`: the stored path (if saved to disc)
28
+ * - string `error`: if any unforeseen errors occurred (e.g. file I/O)
29
+ * - number `bytes_received`: the amount of bytes received/sent for a request, only if option `report_progress` is true
30
+ * - number `bytes_total`: the total amount of bytes for a request, only if option `report_progress` is true
31
+ * - number `range_start`: the start offset into the requested file
32
+ * - number `range_end`: the end offset into the requested file (inclusive)
33
+ * - number `document_size`: the full size of the requested file
34
+ * @param headers - optional table with custom headers
35
+ * @param post_data - optional data to send
36
+ * @param options - optional table with request parameters. Supported entries:
37
+ *
38
+ * - number `timeout`: timeout in seconds
39
+ * - string `path`: path on disc where to download the file. Only overwrites the path if status is 200. Path should be absolute
40
+ * - boolean `ignore_cache`: don't return cached data if we get a 304. Not available in HTML5 build
41
+ * - boolean `chunked_transfer`: use chunked transfer encoding for https requests larger than 16kb. Defaults to true. Not available in HTML5 build
42
+ * - boolean `report_progress`: when it is true, the amount of bytes sent and/or received for a request will be passed into the callback function
43
+ * @example
44
+ * ```ts
45
+ * function update_my_progress_bar(self: unknown, fraction: number) {
46
+ * // draw the progress bar at the given fraction
47
+ * }
48
+ *
49
+ * // Basic HTTP-GET request. The callback receives a table with the response
50
+ * // in the fields status, the response (the data) and headers (a table).
51
+ * export default defineScript({
52
+ * init() {
53
+ * http.request(
54
+ * "http://www.google.com",
55
+ * "GET",
56
+ * (self, _id, response) => {
57
+ * if (response.bytes_received !== undefined && response.bytes_total !== undefined) {
58
+ * update_my_progress_bar(self, response.bytes_received / response.bytes_total);
59
+ * } else {
60
+ * print(response.status);
61
+ * print(response.response);
62
+ * pprint(response.headers);
63
+ * }
64
+ * },
65
+ * undefined,
66
+ * undefined,
67
+ * { report_progress: true },
68
+ * );
69
+ * },
70
+ * });
71
+ * ```
72
+ */
73
+ function request(url: string, method: string, callback: (self: unknown, id: Hash, response: { status: number; response?: string; headers?: LuaMap<string, string>; path?: string; error?: string; bytes_received?: number; bytes_total?: number; range_start?: number; range_end?: number; document_size?: number }) => void, headers?: LuaMap<string, string> | Record<string, string>, post_data?: string, options?: { timeout?: number; path?: string; ignore_cache?: boolean; chunked_transfer?: boolean; report_progress?: boolean }): void;
74
+ }
75
+ }
76
+
77
+ export {};
@@ -0,0 +1,131 @@
1
+ /** @noSelfInFile */
2
+ import type { Opaque } from "../../../src/core-types";
3
+
4
+ declare global {
5
+ /**
6
+ * Functions for creating image objects.
7
+ */
8
+ namespace image {
9
+ /**
10
+ * luminance image type
11
+ */
12
+ const TYPE_LUMINANCE: string & { readonly __brand: "image.TYPE_LUMINANCE" };
13
+ /**
14
+ * luminance image type
15
+ */
16
+ const TYPE_LUMINANCE_ALPHA: string & { readonly __brand: "image.TYPE_LUMINANCE_ALPHA" };
17
+ /**
18
+ * RGB image type
19
+ */
20
+ const TYPE_RGB: string & { readonly __brand: "image.TYPE_RGB" };
21
+ /**
22
+ * RGBA image type
23
+ */
24
+ const TYPE_RGBA: string & { readonly __brand: "image.TYPE_RGBA" };
25
+ /**
26
+ * get the header of an .astc buffer
27
+ *
28
+ * @param buffer - .astc file data buffer
29
+ * @returns header or `nil` if buffer is not a valid .astc. The header has these fields:
30
+ *
31
+ * - number `width`: image width
32
+ * - number `height`: image height
33
+ * - number `depth`: image depth
34
+ * - number `block_size_x`: block size x
35
+ * - number `block_size_y`: block size y
36
+ * - number `block_size_z`: block size z
37
+ * @example
38
+ * ```ts
39
+ * // How to get the block size and dimensions from a .astc file
40
+ * const [s] = sys.load_resource("/assets/cat.astc");
41
+ * if (s !== undefined) {
42
+ * const header = image.get_astc_header(s);
43
+ * pprint(s);
44
+ * }
45
+ * ```
46
+ */
47
+ function get_astc_header(buffer: string): { width: number; height: number; depth: number; block_size_x: number; block_size_y: number; block_size_z: number } | undefined;
48
+ /**
49
+ * Load image (PNG or JPEG) from buffer.
50
+ *
51
+ * @param buffer - image data buffer
52
+ * @param options - An optional table containing parameters for loading the image. Supported entries:
53
+ *
54
+ * `premultiply_alpha`
55
+ * boolean True if alpha should be premultiplied into the color components. Defaults to `false`.
56
+ * `flip_vertically`
57
+ * boolean True if the image contents should be flipped vertically. Defaults to `false`.
58
+ * @returns object or `nil` if loading fails. The object is a table with the following fields:
59
+ *
60
+ * - number `width`: image width
61
+ * - number `height`: image height
62
+ * - constant `type`: image type
63
+ * - `image.TYPE_RGB`
64
+ * - `image.TYPE_RGBA`
65
+ * - `image.TYPE_LUMINANCE`
66
+ * - `image.TYPE_LUMINANCE_ALPHA`
67
+ * - string `buffer`: the raw image data
68
+ * @example
69
+ * ```ts
70
+ * // How to load an image from an URL and create a GUI texture from it:
71
+ * const imgurl = "http://www.site.com/image.png";
72
+ * http.request(imgurl, "GET", (self, id, response) => {
73
+ * const img = response.response !== undefined ? image.load(response.response) : undefined;
74
+ * if (img !== undefined) {
75
+ * const tx = gui.new_texture("image_node", img.width, img.height, img.type, img.buffer);
76
+ * }
77
+ * });
78
+ * ```
79
+ */
80
+ function load(buffer: string, options?: { premultiply_alpha?: boolean; flip_vertically?: boolean }): { width: number; height: number; type: Opaque<"constant">; buffer: string } | undefined;
81
+ /**
82
+ * Load image (PNG or JPEG) from a string buffer.
83
+ *
84
+ * @param buffer - image data buffer
85
+ * @param options - An optional table containing parameters for loading the image. Supported entries:
86
+ *
87
+ * `premultiply_alpha`
88
+ * boolean True if alpha should be premultiplied into the color components. Defaults to `false`.
89
+ * `flip_vertically`
90
+ * boolean True if the image contents should be flipped vertically. Defaults to `false`.
91
+ * @returns object or `nil` if loading fails. The object is a table with the following fields:
92
+ *
93
+ * - number `width`: image width
94
+ * - number `height`: image height
95
+ * - constant `type`: image type
96
+ * - `image.TYPE_RGB`
97
+ * - `image.TYPE_RGBA`
98
+ * - `image.TYPE_LUMINANCE`
99
+ * - `image.TYPE_LUMINANCE_ALPHA`
100
+ * - buffer `buffer`: the script buffer that holds the decompressed image data. See buffer.create how to use the buffer.
101
+ * @example
102
+ * ```ts
103
+ * // Load an image from an URL as a buffer and create a texture resource from it:
104
+ * const imgurl = "http://www.site.com/image.png";
105
+ * http.request(imgurl, "GET", (self, id, response) => {
106
+ * const img =
107
+ * response.response !== undefined
108
+ * ? image.load_buffer(response.response, { flip_vertically: true })
109
+ * : undefined;
110
+ * // the engine registers a texture format only when the driver supports it
111
+ * const format = graphics.TEXTURE_FORMAT_RGBA;
112
+ * if (img !== undefined && format !== undefined) {
113
+ * const tparams = {
114
+ * width: img.width,
115
+ * height: img.height,
116
+ * type: graphics.TEXTURE_TYPE_2D,
117
+ * format,
118
+ * };
119
+ *
120
+ * const my_texture_id = resource.create_texture("/my_custom_texture.texturec", tparams, img.buffer);
121
+ * // Apply the texture to a model
122
+ * go.set("/go1#model", "texture0", my_texture_id);
123
+ * }
124
+ * });
125
+ * ```
126
+ */
127
+ function load_buffer(buffer: string, options?: { premultiply_alpha?: boolean; flip_vertically?: boolean }): { width: number; height: number; type: Opaque<"constant">; buffer: Opaque<"buffer"> } | undefined;
128
+ }
129
+ }
130
+
131
+ export {};
@@ -0,0 +1,57 @@
1
+ /// <reference types="lua-types/5.1" />
2
+ /// <reference types="lua-types/special/jit-only" />
3
+ import "./b2d";
4
+ import "./b2d_body";
5
+ import "./b2d_chain";
6
+ import "./b2d_fixture";
7
+ import "./b2d_joint";
8
+ import "./b2d_shape";
9
+ import "./b2d_world";
10
+ import "./buffer";
11
+ import "./camera";
12
+ import "./collectionfactory";
13
+ import "./collectionproxy";
14
+ import "./compute";
15
+ import "./crash";
16
+ import "./factory";
17
+ import "./font";
18
+ import "./go";
19
+ import "./graphics";
20
+ import "./gui";
21
+ import "./html5";
22
+ import "./http";
23
+ import "./image";
24
+ import "./json";
25
+ import "./label";
26
+ import "./liveupdate";
27
+ import "./material";
28
+ import "./model";
29
+ import "./msg";
30
+ import "./particlefx";
31
+ import "./physics";
32
+ import "./profiler";
33
+ import "./render";
34
+ import "./resource";
35
+ import "./socket";
36
+ import "./sound";
37
+ import "./sprite";
38
+ import "./sys";
39
+ import "./tilemap";
40
+ import "./timer";
41
+ import "./types";
42
+ import "./vmath";
43
+ import "./window";
44
+ import "./zlib";
45
+ import "../../../src/custom-messages";
46
+ import "../../../src/engine-globals";
47
+ import "../../../src/msg-overloads";
48
+ import "../../../src/message-guard";
49
+ import "../../../src/window-event-guard";
50
+ import "../../../src/scene-addresses";
51
+ import "../../../src/go-overloads";
52
+ import "../../../src/component-properties";
53
+ import "../../../src/render-overloads";
54
+ import "../../../src/vmath-overloads";
55
+ import "../../../src/sys-overloads";
56
+
57
+ export {};
@@ -0,0 +1,80 @@
1
+ /** @noSelfInFile */
2
+ declare global {
3
+ /**
4
+ * Manipulation of JSON data strings.
5
+ */
6
+ namespace json {
7
+ /**
8
+ * Represents the null primitive from a json file
9
+ */
10
+ const _null: unknown;
11
+ /**
12
+ * Decode a string of JSON data into a Lua table.
13
+ * A Lua error is raised for syntax errors.
14
+ *
15
+ * @param json - json data
16
+ * @param options - table with decode options
17
+ *
18
+ * - boolean `decode_null_as_userdata`: whether to decode a JSON null value as json.null or nil (default is nil)
19
+ * @returns decoded json
20
+ * @example
21
+ * Converting a string containing JSON data into a Lua table:
22
+ * ```ts
23
+ * export default defineScript({
24
+ * init() {
25
+ * const jsonstring = '{"persons":[{"name":"John Doe"},{"name":"Darth Vader"}]}';
26
+ * const data = json.decode(jsonstring);
27
+ * pprint(data);
28
+ * },
29
+ * });
30
+ * ```
31
+ * @example
32
+ * Results in the following printout:
33
+ * ```ts
34
+ * // {
35
+ * // persons = {
36
+ * // 1 = {
37
+ * // name = John Doe,
38
+ * // }
39
+ * // 2 = {
40
+ * // name = Darth Vader,
41
+ * // }
42
+ * // }
43
+ * // }
44
+ * ```
45
+ */
46
+ export function decode(json: string, options?: { decode_null_as_userdata?: boolean }): Record<string | number, unknown>;
47
+ /**
48
+ * Encode a lua table to a JSON string.
49
+ * A Lua error is raised for syntax errors.
50
+ *
51
+ * @param tbl - lua table to encode
52
+ * @param options - table with encode options
53
+ *
54
+ * - string `encode_empty_table_as_object`: whether to encode an empty table as an JSON object or array (default is object)
55
+ * @returns encoded json
56
+ * @example
57
+ * Convert a lua table to a JSON string:
58
+ * ```ts
59
+ * export default defineScript({
60
+ * init() {
61
+ * const tbl = {
62
+ * persons: [{ name: "John Doe" }, { name: "Darth Vader" }],
63
+ * };
64
+ * const jsonstring = json.encode(tbl);
65
+ * pprint(jsonstring);
66
+ * },
67
+ * });
68
+ * ```
69
+ * @example
70
+ * Results in the following printout:
71
+ * ```ts
72
+ * // {"persons":[{"name":"John Doe"},{"name":"Darth Vader"}]}
73
+ * ```
74
+ */
75
+ export function encode(tbl: Record<string | number, unknown>, options?: { encode_empty_table_as_object?: string }): string;
76
+ export { _null as null };
77
+ }
78
+ }
79
+
80
+ export {};
@@ -0,0 +1,14 @@
1
+ /// <reference types="lua-types/5.1" />
2
+ import "../editor";
3
+ import "../editor-vm/http";
4
+ import "../editor-vm/image";
5
+ import "../editor-vm/json";
6
+ import "../editor-vm/localization";
7
+ import "../editor-vm/zip";
8
+ import "../editor-vm/zlib";
9
+ import "../editor-vm/tilemap_tiles";
10
+ import "../../../../src/editor-overloads";
11
+ import "../../../../src/editor-vm-globals";
12
+
13
+ export { defineEditorScript, defineEditorCommand } from "../../../../src/editor";
14
+ export type { EditorCommandQuery, EditorNode } from "../../../../src/editor";
@@ -0,0 +1,93 @@
1
+ /** @noSelfInFile */
2
+ import type { Hash, Url, Vector3, Vector4 } from "../../../src/core-types";
3
+
4
+ declare global {
5
+ /**
6
+ * Label API documentation
7
+ */
8
+ namespace label {
9
+ /**
10
+ * Gets the text from a label component
11
+ *
12
+ * @param url - the label to get the text from
13
+ * @returns the label text
14
+ * @example
15
+ * ```ts
16
+ * export default defineScript({
17
+ * init(self) {
18
+ * const text = label.get_text("#label");
19
+ * print(text);
20
+ * },
21
+ * });
22
+ * ```
23
+ */
24
+ function get_text(url: string | Hash | Url): string;
25
+ /**
26
+ * Sets the text of a label component
27
+ * This method uses the message passing that means the value will be set after `dispatch messages` step.
28
+ * More information is available in the Application Lifecycle manual.
29
+ *
30
+ * @param url - the label that should have a constant set
31
+ * @param text - the text
32
+ * @example
33
+ * ```ts
34
+ * export default defineScript({
35
+ * init(self) {
36
+ * label.set_text("#label", "Hello World!");
37
+ * },
38
+ * });
39
+ * ```
40
+ */
41
+ function set_text(url: string | Hash | Url, text: string | number): void;
42
+ interface properties {
43
+ /**
44
+ * The color of the label. The type of the property is vector4.
45
+ */
46
+ color: Vector4;
47
+ /**
48
+ * The font used when rendering the label. The type of the property is hash.
49
+ */
50
+ font: Hash;
51
+ /**
52
+ * The leading of the label. This value is used to scale the line spacing of text.
53
+ * The type of the property is number.
54
+ */
55
+ leading: number;
56
+ /**
57
+ * The line break of the label.
58
+ * This value is used to adjust the vertical spacing of characters in the text.
59
+ * The type of the property is boolean.
60
+ */
61
+ line_break: boolean;
62
+ /**
63
+ * The material used when rendering the label. The type of the property is hash.
64
+ */
65
+ material: Hash;
66
+ /**
67
+ * The outline color of the label. The type of the property is vector4.
68
+ */
69
+ outline: Vector4;
70
+ /**
71
+ * The scale of the label. `go.get` returns and `go.set` takes a vector3; `go.animate` also takes a number, which sets a uniform scale.
72
+ */
73
+ scale: Vector3;
74
+ /**
75
+ * The shadow color of the label. The type of the property is vector4.
76
+ */
77
+ shadow: Vector4;
78
+ /**
79
+ * Returns the size of the label. The size will constrain the text if line break is enabled.
80
+ * The type of the property is vector3.
81
+ */
82
+ size: Vector3;
83
+ /**
84
+ * The tracking of the label.
85
+ * This value is used to adjust the vertical spacing of characters in the text.
86
+ * The type of the property is number.
87
+ */
88
+ tracking: number;
89
+ }
90
+ }
91
+ }
92
+
93
+ export {};
@@ -0,0 +1,142 @@
1
+ /** @noSelfInFile */
2
+ import type { Hash } from "../../../src/core-types";
3
+
4
+ declare global {
5
+ /**
6
+ * Functions and constants to access resources.
7
+ */
8
+ namespace liveupdate {
9
+ /**
10
+ * Mismatch between between expected bundled resources and actual bundled resources. The manifest expects a resource to be in the bundle, but it was not found in the bundle. This is typically the case when a non-excluded resource was modified between publishing the bundle and publishing the manifest.
11
+ */
12
+ const LIVEUPDATE_BUNDLED_RESOURCE_MISMATCH: number & { readonly __brand: "liveupdate.LIVEUPDATE_BUNDLED_RESOURCE_MISMATCH" };
13
+ /**
14
+ * Mismatch between running engine version and engine versions supported by manifest.
15
+ */
16
+ const LIVEUPDATE_ENGINE_VERSION_MISMATCH: number & { readonly __brand: "liveupdate.LIVEUPDATE_ENGINE_VERSION_MISMATCH" };
17
+ /**
18
+ * Failed to parse manifest data buffer. The manifest was probably produced by a different engine version.
19
+ */
20
+ const LIVEUPDATE_FORMAT_ERROR: number & { readonly __brand: "liveupdate.LIVEUPDATE_FORMAT_ERROR" };
21
+ /**
22
+ * Argument was invalid
23
+ */
24
+ const LIVEUPDATE_INVAL: number & { readonly __brand: "liveupdate.LIVEUPDATE_INVAL" };
25
+ /**
26
+ * The handled resource is invalid.
27
+ */
28
+ const LIVEUPDATE_INVALID_HEADER: number & { readonly __brand: "liveupdate.LIVEUPDATE_INVALID_HEADER" };
29
+ /**
30
+ * The header of the resource is invalid.
31
+ */
32
+ const LIVEUPDATE_INVALID_RESOURCE: number & { readonly __brand: "liveupdate.LIVEUPDATE_INVALID_RESOURCE" };
33
+ /**
34
+ * I/O operation failed
35
+ */
36
+ const LIVEUPDATE_IO_ERROR: number & { readonly __brand: "liveupdate.LIVEUPDATE_IO_ERROR" };
37
+ /**
38
+ * Memory wasn't allocated
39
+ */
40
+ const LIVEUPDATE_MEM_ERROR: number & { readonly __brand: "liveupdate.LIVEUPDATE_MEM_ERROR" };
41
+ /**
42
+ * LIVEUPDATE_OK
43
+ */
44
+ const LIVEUPDATE_OK: number & { readonly __brand: "liveupdate.LIVEUPDATE_OK" };
45
+ /**
46
+ * Mismatch between scheme used to load resources. Resources are loaded with a different scheme than from manifest, for example over HTTP or directly from file. This is typically the case when running the game directly from the editor instead of from a bundle.
47
+ */
48
+ const LIVEUPDATE_SCHEME_MISMATCH: number & { readonly __brand: "liveupdate.LIVEUPDATE_SCHEME_MISMATCH" };
49
+ /**
50
+ * Mismatch between expected and actual integrity data for legacy liveupdate verification.
51
+ */
52
+ const LIVEUPDATE_SIGNATURE_MISMATCH: number & { readonly __brand: "liveupdate.LIVEUPDATE_SIGNATURE_MISMATCH" };
53
+ /**
54
+ * Unspecified error
55
+ */
56
+ const LIVEUPDATE_UNKNOWN: number & { readonly __brand: "liveupdate.LIVEUPDATE_UNKNOWN" };
57
+ /**
58
+ * Mismatch between manifest expected version and actual version.
59
+ */
60
+ const LIVEUPDATE_VERSION_MISMATCH: number & { readonly __brand: "liveupdate.LIVEUPDATE_VERSION_MISMATCH" };
61
+ /**
62
+ * Adds a resource mount to the resource system.
63
+ * After the mount succeeded, the resources are available to load. (i.e. no reboot required)
64
+ *
65
+ * @param name - Unique name of the mount
66
+ * @param uri - The uri of the mount, including the scheme. Currently supported schemes are 'zip' and 'archive'.
67
+ * @param priority - Priority of mount. Larger priority takes prescedence
68
+ * @param callback - Callback after the asynchronous request completed
69
+ * - `name` hash Unique name of the mount
70
+ * - `uri` string The uri of the mount
71
+ * - `result` number The result of the request
72
+ * @returns The result of the request
73
+ * @example
74
+ * ```ts
75
+ * // Add multiple mounts. Higher priority takes precedence.
76
+ * liveupdate.add_mount("common", "zip:/path/to/common_stuff.zip", 10, (result) => {}); // base pack
77
+ * liveupdate.add_mount("levelpack_1", "zip:/path/to/levels_1_to_20.zip", 20, (result) => {}); // level pack
78
+ * liveupdate.add_mount("season_pack_1", "zip:/path/to/easter_pack_1.zip", 30, (result) => {}); // season pack, overriding content in the other packs
79
+ * ```
80
+ */
81
+ function add_mount(name: string | Hash, uri: string, priority: number, callback: (self: unknown, name: unknown, uri: unknown, result: unknown) => void): number;
82
+ /**
83
+ * Get an array of the current mounts
84
+ * This can be used to determine if a new mount is needed or not
85
+ *
86
+ * @returns Array of mounts
87
+ * @example
88
+ * Output the current resource mounts
89
+ * ```ts
90
+ * pprint("MOUNTS", liveupdate.get_mounts());
91
+ * ```
92
+ * @example
93
+ * Give an output like:
94
+ * ```ts
95
+ * // DEBUG:SCRIPT: MOUNTS,
96
+ * // {
97
+ * // 1 = {
98
+ * // name = hash: [liveupdate],
99
+ * // uri = "zip:/device/path/to/acchives/liveupdate.zip",
100
+ * // priority = 5
101
+ * // },
102
+ * // 2 = {
103
+ * // name = hash: [_base],
104
+ * // uri = "archive:build/default/game.dmanifest",
105
+ * // priority = -10
106
+ * // }
107
+ * // }
108
+ * ```
109
+ */
110
+ function get_mounts(): { name: string; uri: string; priority: number }[];
111
+ /**
112
+ * Checks if the bundled application was built with one or more resources
113
+ * excluded from the main bundle, through a collection proxy with
114
+ * `Exclude` enabled.
115
+ * This value is based on metadata in the bundled manifest. It does not check
116
+ * whether any live update archive has been mounted or whether the excluded
117
+ * resources are currently available on device.
118
+ *
119
+ * @returns true if the bundled application was built with excluded files
120
+ * @example
121
+ * ```ts
122
+ * if (liveupdate.is_built_with_excluded_files()) print("The bundle expects live update content.");
123
+ * ```
124
+ */
125
+ function is_built_with_excluded_files(): boolean;
126
+ /**
127
+ * Remove a mount the resource system.
128
+ * Removing a mount does not affect any loaded resources.
129
+ *
130
+ * @param name - Unique name of the mount
131
+ * @returns The result of the call
132
+ * @example
133
+ * ```ts
134
+ * // Add multiple mounts. Higher priority takes precedence.
135
+ * liveupdate.remove_mount("season_pack_1");
136
+ * ```
137
+ */
138
+ function remove_mount(name: string | Hash): number;
139
+ }
140
+ }
141
+
142
+ export {};