@defold-typescript/types 0.25.0 → 0.27.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.
- package/api-availability.json +333 -306
- package/api-signatures.json +1312 -0
- package/api-targets.json +351 -2
- package/examples/translations.json +1984 -0
- package/fixtures/messages_doc.json +880 -0
- package/generated/collectionproxy.d.ts +22 -0
- package/generated/editor-vm/http.d.ts +2 -2
- package/generated/editor-vm/image.d.ts +48 -0
- package/generated/editor.d.ts +27 -8
- package/generated/gui.d.ts +35 -6
- package/generated/kinds/editor-script.d.ts +1 -0
- package/generated/material.d.ts +4 -0
- package/generated/versions/defold-1.12.4/liveupdate.d.ts +22 -22
- package/generated/versions/defold-1.12.4/physics.d.ts +78 -75
- package/generated/versions/defold-1.12.4/render.d.ts +75 -55
- package/generated/versions/defold-1.12.4/resource.d.ts +187 -175
- package/generated/versions/defold-1.13.0/b2d.d.ts +33 -0
- package/generated/versions/defold-1.13.0/b2d_body.d.ts +676 -0
- package/generated/versions/defold-1.13.0/b2d_chain.d.ts +106 -0
- package/generated/versions/defold-1.13.0/b2d_fixture.d.ts +155 -0
- package/generated/versions/defold-1.13.0/b2d_joint.d.ts +823 -0
- package/generated/versions/defold-1.13.0/b2d_shape.d.ts +215 -0
- package/generated/versions/defold-1.13.0/b2d_world.d.ts +314 -0
- package/generated/versions/defold-1.13.0/buffer.d.ts +176 -0
- package/generated/versions/defold-1.13.0/camera.d.ts +302 -0
- package/generated/versions/defold-1.13.0/collectionfactory.d.ts +146 -0
- package/generated/versions/defold-1.13.0/collectionproxy.d.ts +71 -0
- package/generated/versions/defold-1.13.0/compute.d.ts +306 -0
- package/generated/versions/defold-1.13.0/crash.d.ts +143 -0
- package/generated/versions/defold-1.13.0/editor-vm/http.d.ts +56 -0
- package/generated/versions/defold-1.13.0/editor-vm/json.d.ts +10 -0
- package/generated/versions/defold-1.13.0/editor-vm/localization.d.ts +42 -0
- package/generated/versions/defold-1.13.0/editor-vm/tilemap_tiles.d.ts +80 -0
- package/generated/versions/defold-1.13.0/editor-vm/zip.d.ts +10 -0
- package/generated/versions/defold-1.13.0/editor-vm/zlib.d.ts +24 -0
- package/generated/versions/defold-1.13.0/editor.d.ts +1092 -0
- package/generated/versions/defold-1.13.0/factory.d.ts +123 -0
- package/generated/versions/defold-1.13.0/font.d.ts +81 -0
- package/generated/versions/defold-1.13.0/go.d.ts +1054 -0
- package/generated/versions/defold-1.13.0/graphics.d.ts +321 -0
- package/generated/versions/defold-1.13.0/gui.d.ts +2370 -0
- package/generated/versions/defold-1.13.0/html5.d.ts +53 -0
- package/generated/versions/defold-1.13.0/http.d.ts +84 -0
- package/generated/versions/defold-1.13.0/iac.d.ts +18 -0
- package/generated/versions/defold-1.13.0/iap.d.ts +60 -0
- package/generated/versions/defold-1.13.0/image.d.ts +139 -0
- package/generated/versions/defold-1.13.0/index.d.ts +48 -0
- package/generated/versions/defold-1.13.0/json.d.ts +76 -0
- package/generated/versions/defold-1.13.0/kinds/editor-script.d.ts +13 -0
- package/generated/versions/defold-1.13.0/label.d.ts +94 -0
- package/generated/versions/defold-1.13.0/liveupdate.d.ts +140 -0
- package/generated/versions/defold-1.13.0/material.d.ts +444 -0
- package/generated/versions/defold-1.13.0/model.d.ts +246 -0
- package/generated/versions/defold-1.13.0/msg.d.ts +10 -0
- package/generated/versions/defold-1.13.0/particlefx.d.ts +166 -0
- package/generated/versions/defold-1.13.0/physics.d.ts +548 -0
- package/generated/versions/defold-1.13.0/profiler.d.ts +233 -0
- package/generated/versions/defold-1.13.0/push.d.ts +66 -0
- package/generated/versions/defold-1.13.0/render.d.ts +1185 -0
- package/generated/versions/defold-1.13.0/resource.d.ts +1530 -0
- package/generated/versions/defold-1.13.0/socket.d.ts +795 -0
- package/generated/versions/defold-1.13.0/sound.d.ts +291 -0
- package/generated/versions/defold-1.13.0/sprite.d.ts +157 -0
- package/generated/versions/defold-1.13.0/sys.d.ts +695 -0
- package/generated/versions/defold-1.13.0/tilemap.d.ts +195 -0
- package/generated/versions/defold-1.13.0/timer.d.ts +114 -0
- package/generated/versions/defold-1.13.0/types.d.ts +61 -0
- package/generated/versions/defold-1.13.0/vmath.d.ts +806 -0
- package/generated/versions/defold-1.13.0/webview.d.ts +68 -0
- package/generated/versions/defold-1.13.0/window.d.ts +198 -0
- package/generated/versions/defold-1.13.0/zlib.d.ts +40 -0
- package/index.d.ts +4 -81
- package/package.json +11 -3
- package/scripts/import-defold-release.ts +28 -1
- package/scripts/sync-api-docs.ts +4 -3
- package/src/api-availability.ts +0 -0
- package/src/emit-dts.ts +6 -0
- package/src/example-store.ts +5 -0
- package/src/index.ts +3 -0
- package/scripts/lua-types-signature-index.ts +0 -151
|
@@ -0,0 +1,53 @@
|
|
|
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
|
+
* print(res_num - 20); // prints 10
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
function run(code: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* Set a JavaScript interaction listener callaback from lua that will be
|
|
27
|
+
* invoked when a user interacts with the web page by clicking, touching or typing.
|
|
28
|
+
* The callback can then call DOM restricted actions like requesting a pointer lock,
|
|
29
|
+
* or start playing sounds the first time the callback is invoked.
|
|
30
|
+
*
|
|
31
|
+
* @param callback - The interaction callback. Pass an empty function or `nil` if you no longer wish to receive callbacks.
|
|
32
|
+
*
|
|
33
|
+
* `self`
|
|
34
|
+
* object The calling script
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* function on_interaction(self) {
|
|
38
|
+
* print("on_interaction called");
|
|
39
|
+
* html5.set_interaction_listener(undefined);
|
|
40
|
+
* }
|
|
41
|
+
*
|
|
42
|
+
* export default defineScript({
|
|
43
|
+
* init() {
|
|
44
|
+
* html5.set_interaction_listener(on_interaction);
|
|
45
|
+
* },
|
|
46
|
+
* });
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
function set_interaction_listener(callback?: (self: unknown) => void): void;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export {};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/** @noSelfInFile */
|
|
2
|
+
declare global {
|
|
3
|
+
/**
|
|
4
|
+
* Functions for performing HTTP and HTTPS requests.
|
|
5
|
+
*/
|
|
6
|
+
namespace http {
|
|
7
|
+
/**
|
|
8
|
+
* Perform a HTTP/HTTPS request.
|
|
9
|
+
* 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).
|
|
10
|
+
*
|
|
11
|
+
* @param url - target url
|
|
12
|
+
* @param method - HTTP/HTTPS method, e.g. "GET", "PUT", "POST" etc.
|
|
13
|
+
* @param callback - response callback function
|
|
14
|
+
*
|
|
15
|
+
* `self`
|
|
16
|
+
* object The script instance
|
|
17
|
+
* `id`
|
|
18
|
+
* hash Internal message identifier. Do not use!
|
|
19
|
+
* `response`
|
|
20
|
+
* table The response data. Contains the fields:
|
|
21
|
+
*
|
|
22
|
+
* - number `status`: the status of the response
|
|
23
|
+
*
|
|
24
|
+
* - string `response`: the response data (if not saved on disc)
|
|
25
|
+
*
|
|
26
|
+
* - table `headers`: all the returned headers (if status is 200 or 206)
|
|
27
|
+
*
|
|
28
|
+
* - string `path`: the stored path (if saved to disc)
|
|
29
|
+
*
|
|
30
|
+
* - string `error`: if any unforeseen errors occurred (e.g. file I/O)
|
|
31
|
+
*
|
|
32
|
+
* - number `bytes_received`: the amount of bytes received/sent for a request, only if option `report_progress` is true
|
|
33
|
+
*
|
|
34
|
+
* - number `bytes_total`: the total amount of bytes for a request, only if option `report_progress` is true
|
|
35
|
+
*
|
|
36
|
+
* - number `range_start`: the start offset into the requested file
|
|
37
|
+
*
|
|
38
|
+
* - number `range_end`: the end offset into the requested file (inclusive)
|
|
39
|
+
*
|
|
40
|
+
* - number `document_size`: the full size of the requested file
|
|
41
|
+
* @param headers - optional table with custom headers
|
|
42
|
+
* @param post_data - optional data to send
|
|
43
|
+
* @param options - optional table with request parameters. Supported entries:
|
|
44
|
+
*
|
|
45
|
+
* - number `timeout`: timeout in seconds
|
|
46
|
+
*
|
|
47
|
+
* - string `path`: path on disc where to download the file. Only overwrites the path if status is 200. Path should be absolute
|
|
48
|
+
*
|
|
49
|
+
* - boolean `ignore_cache`: don't return cached data if we get a 304. Not available in HTML5 build
|
|
50
|
+
*
|
|
51
|
+
* - boolean `chunked_transfer`: use chunked transfer encoding for https requests larger than 16kb. Defaults to true. Not available in HTML5 build
|
|
52
|
+
*
|
|
53
|
+
* - 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
|
|
54
|
+
* @example
|
|
55
|
+
* ```ts
|
|
56
|
+
* // Basic HTTP-GET request. The callback receives a table with the response
|
|
57
|
+
* // in the fields status, the response (the data) and headers (a table).
|
|
58
|
+
* export default defineScript({
|
|
59
|
+
* init() {
|
|
60
|
+
* http.request(
|
|
61
|
+
* "http://www.google.com",
|
|
62
|
+
* "GET",
|
|
63
|
+
* (self, _id, response) => {
|
|
64
|
+
* if (response.bytes_total !== undefined) {
|
|
65
|
+
* update_my_progress_bar(self, response.bytes_received / response.bytes_total);
|
|
66
|
+
* } else {
|
|
67
|
+
* print(response.status);
|
|
68
|
+
* print(response.response);
|
|
69
|
+
* pprint(response.headers);
|
|
70
|
+
* }
|
|
71
|
+
* },
|
|
72
|
+
* undefined,
|
|
73
|
+
* undefined,
|
|
74
|
+
* { report_progress: true },
|
|
75
|
+
* );
|
|
76
|
+
* },
|
|
77
|
+
* });
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
function request(url: string, method: string, callback: (self: unknown, id: unknown, response: unknown) => void, headers?: LuaMap<string, string>, post_data?: string, options?: { timeout?: number; path?: string; ignore_cache?: boolean; chunked_transfer?: boolean; report_progress?: boolean }): void;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** @noSelfInFile */
|
|
2
|
+
declare global {
|
|
3
|
+
/**
|
|
4
|
+
* Functions and constants for doing inter-app communication. Supported on iOS and Android. [icon:ios] [icon:android]
|
|
5
|
+
*/
|
|
6
|
+
namespace iac {
|
|
7
|
+
/**
|
|
8
|
+
* Sets the listener function for inter-app communication events.
|
|
9
|
+
*
|
|
10
|
+
* @param payload - The iac payload.
|
|
11
|
+
* @param type - The type of iac, an iac.TYPE_ enumeration. It can be one of the predefined constants below
|
|
12
|
+
* - `iac.TYPE_INVOCATION`
|
|
13
|
+
*/
|
|
14
|
+
function set_listener(payload: Record<string | number, unknown>, type: number): void;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/** @noSelfInFile */
|
|
2
|
+
import type { Opaque } from "../../../src/core-types";
|
|
3
|
+
|
|
4
|
+
declare global {
|
|
5
|
+
/**
|
|
6
|
+
* Functions and constants for doing in-app purchases. Supported on iOS, Android (Google Play and Amazon) and Facebook Canvas platforms. [icon:ios] [icon:googleplay] [icon:amazon] [icon:facebook]
|
|
7
|
+
*/
|
|
8
|
+
namespace iap {
|
|
9
|
+
/**
|
|
10
|
+
* Acknowledge a transaction. [icon:attention] Calling iap.acknowledge is required on a successful transaction on Google Play unless iap.finish is called. The transaction.state field must equal iap.TRANS_STATE_PURCHASED.
|
|
11
|
+
*
|
|
12
|
+
* @param transaction - transaction table parameter as supplied in listener callback
|
|
13
|
+
*/
|
|
14
|
+
function acknowledge(transaction: { ident?: string; state?: number; trans_ident?: string; date?: string; original_trans?: string; receipt?: string; signature?: string; user_id?: string }): void;
|
|
15
|
+
/**
|
|
16
|
+
* Purchase a product.
|
|
17
|
+
*
|
|
18
|
+
* @param id - product to buy
|
|
19
|
+
* @param options - optional parameters as properties. The following parameters can be set
|
|
20
|
+
*/
|
|
21
|
+
function buy(id: string, options: { request_id?: string; token?: string }): void;
|
|
22
|
+
/**
|
|
23
|
+
* Explicitly finish a product transaction. [icon:attention] Calling iap.finish is required on a successful transaction if `auto_finish_transactions` is disabled in project settings. Calling this function with `auto_finish_transactions` set will be ignored and a warning is printed. The `transaction.state` field must equal `iap.TRANS_STATE_PURCHASED`.
|
|
24
|
+
*
|
|
25
|
+
* @param transaction - transaction table parameter as supplied in listener callback
|
|
26
|
+
*/
|
|
27
|
+
function finish(transaction: { ident?: string; state?: number; trans_ident?: string; date?: string; original_trans?: string; receipt?: string; signature?: string; user_id?: string }): void;
|
|
28
|
+
/**
|
|
29
|
+
* Get current iap provider
|
|
30
|
+
*
|
|
31
|
+
* @returns one of the following values
|
|
32
|
+
* - `iap.PROVIDER_ID_GOOGLE`
|
|
33
|
+
* - `iap.PROVIDER_ID_AMAZON`
|
|
34
|
+
* - `iap.PROVIDER_ID_APPLE`
|
|
35
|
+
* - `iap.PROVIDER_ID_FACEBOOK`
|
|
36
|
+
*/
|
|
37
|
+
function get_provider_id(): Opaque<"constant">;
|
|
38
|
+
/**
|
|
39
|
+
* Get a list of all avaliable iap products.
|
|
40
|
+
*
|
|
41
|
+
* @param ids - table (array) of identifiers to get products from
|
|
42
|
+
* @param callback - result callback taking the following parameters
|
|
43
|
+
*/
|
|
44
|
+
function list(ids: string[], callback: (...args: unknown[]) => unknown): void;
|
|
45
|
+
/**
|
|
46
|
+
* Restore previously purchased products.
|
|
47
|
+
*
|
|
48
|
+
* @returns value is `true` if current store supports handling restored transactions, otherwise `false`.
|
|
49
|
+
*/
|
|
50
|
+
function restore(): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Set the callback function to receive purchase transaction events.
|
|
53
|
+
*
|
|
54
|
+
* @param listener - listener callback function. Pass an empty function if you no longer wish to receive callbacks.
|
|
55
|
+
*/
|
|
56
|
+
function set_listener(listener: (...args: unknown[]) => unknown): void;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export {};
|
|
@@ -0,0 +1,139 @@
|
|
|
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: number & { readonly __brand: "image.TYPE_LUMINANCE" };
|
|
13
|
+
/**
|
|
14
|
+
* luminance image type
|
|
15
|
+
*/
|
|
16
|
+
const TYPE_LUMINANCE_ALPHA: number & { readonly __brand: "image.TYPE_LUMINANCE_ALPHA" };
|
|
17
|
+
/**
|
|
18
|
+
* RGB image type
|
|
19
|
+
*/
|
|
20
|
+
const TYPE_RGB: number & { readonly __brand: "image.TYPE_RGB" };
|
|
21
|
+
/**
|
|
22
|
+
* RGBA image type
|
|
23
|
+
*/
|
|
24
|
+
const TYPE_RGBA: number & { 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
|
+
*
|
|
33
|
+
* - number `height`: image height
|
|
34
|
+
*
|
|
35
|
+
* - number `depth`: image depth
|
|
36
|
+
*
|
|
37
|
+
* - number `block_size_x`: block size x
|
|
38
|
+
*
|
|
39
|
+
* - number `block_size_y`: block size y
|
|
40
|
+
*
|
|
41
|
+
* - number `block_size_z`: block size z
|
|
42
|
+
* @example
|
|
43
|
+
* ```ts
|
|
44
|
+
* // How to get the block size and dimensions from a .astc file
|
|
45
|
+
* const [s] = sys.load_resource("/assets/cat.astc");
|
|
46
|
+
* const header = image.get_astc_header(s);
|
|
47
|
+
* pprint(s);
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
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;
|
|
51
|
+
/**
|
|
52
|
+
* Load image (PNG or JPEG) from buffer.
|
|
53
|
+
*
|
|
54
|
+
* @param buffer - image data buffer
|
|
55
|
+
* @param options - An optional table containing parameters for loading the image. Supported entries:
|
|
56
|
+
*
|
|
57
|
+
* `premultiply_alpha`
|
|
58
|
+
* boolean True if alpha should be premultiplied into the color components. Defaults to `false`.
|
|
59
|
+
* `flip_vertically`
|
|
60
|
+
* boolean True if the image contents should be flipped vertically. Defaults to `false`.
|
|
61
|
+
* @returns object or `nil` if loading fails. The object is a table with the following fields:
|
|
62
|
+
*
|
|
63
|
+
* - number `width`: image width
|
|
64
|
+
*
|
|
65
|
+
* - number `height`: image height
|
|
66
|
+
*
|
|
67
|
+
* - constant `type`: image type
|
|
68
|
+
*
|
|
69
|
+
* - `image.TYPE_RGB`
|
|
70
|
+
*
|
|
71
|
+
* - `image.TYPE_RGBA`
|
|
72
|
+
*
|
|
73
|
+
* - `image.TYPE_LUMINANCE`
|
|
74
|
+
*
|
|
75
|
+
* - `image.TYPE_LUMINANCE_ALPHA`
|
|
76
|
+
*
|
|
77
|
+
* - string `buffer`: the raw image data
|
|
78
|
+
* @example
|
|
79
|
+
* ```ts
|
|
80
|
+
* // How to load an image from an URL and create a GUI texture from it:
|
|
81
|
+
* const imgurl = "http://www.site.com/image.png";
|
|
82
|
+
* http.request(imgurl, "GET", (self, id, response) => {
|
|
83
|
+
* const img = image.load(response.response);
|
|
84
|
+
* const tx = gui.new_texture("image_node", img.width, img.height, img.type, img.buffer);
|
|
85
|
+
* });
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
function load(buffer: string, options?: { premultiply_alpha?: boolean; flip_vertically?: boolean }): { width: number; height: number; type: Opaque<"constant">; buffer: string } | undefined;
|
|
89
|
+
/**
|
|
90
|
+
* Load image (PNG or JPEG) from a string buffer.
|
|
91
|
+
*
|
|
92
|
+
* @param buffer - image data buffer
|
|
93
|
+
* @param options - An optional table containing parameters for loading the image. Supported entries:
|
|
94
|
+
*
|
|
95
|
+
* `premultiply_alpha`
|
|
96
|
+
* boolean True if alpha should be premultiplied into the color components. Defaults to `false`.
|
|
97
|
+
* `flip_vertically`
|
|
98
|
+
* boolean True if the image contents should be flipped vertically. Defaults to `false`.
|
|
99
|
+
* @returns object or `nil` if loading fails. The object is a table with the following fields:
|
|
100
|
+
*
|
|
101
|
+
* - number `width`: image width
|
|
102
|
+
*
|
|
103
|
+
* - number `height`: image height
|
|
104
|
+
*
|
|
105
|
+
* - constant `type`: image type
|
|
106
|
+
*
|
|
107
|
+
* - `image.TYPE_RGB`
|
|
108
|
+
*
|
|
109
|
+
* - `image.TYPE_RGBA`
|
|
110
|
+
*
|
|
111
|
+
* - `image.TYPE_LUMINANCE`
|
|
112
|
+
*
|
|
113
|
+
* - `image.TYPE_LUMINANCE_ALPHA`
|
|
114
|
+
*
|
|
115
|
+
* - buffer `buffer`: the script buffer that holds the decompressed image data. See buffer.create how to use the buffer.
|
|
116
|
+
* @example
|
|
117
|
+
* ```ts
|
|
118
|
+
* // Load an image from an URL as a buffer and create a texture resource from it:
|
|
119
|
+
* const imgurl = "http://www.site.com/image.png";
|
|
120
|
+
* http.request(imgurl, "GET", (self, id, response) => {
|
|
121
|
+
* const img = image.load_buffer(response.response, { flip_vertically: true });
|
|
122
|
+
* const tparams = {
|
|
123
|
+
* width: img.width,
|
|
124
|
+
* height: img.height,
|
|
125
|
+
* type: graphics.TEXTURE_TYPE_2D,
|
|
126
|
+
* format: graphics.TEXTURE_FORMAT_RGBA,
|
|
127
|
+
* };
|
|
128
|
+
*
|
|
129
|
+
* const my_texture_id = resource.create_texture("/my_custom_texture.texturec", tparams, img.buffer);
|
|
130
|
+
* // Apply the texture to a model
|
|
131
|
+
* go.set("/go1#model", "texture0", my_texture_id);
|
|
132
|
+
* });
|
|
133
|
+
* ```
|
|
134
|
+
*/
|
|
135
|
+
function load_buffer(buffer: string, options?: { premultiply_alpha?: boolean; flip_vertically?: boolean }): { width: number; height: number; type: Opaque<"constant">; buffer: Opaque<"buffer"> } | undefined;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import "./b2d";
|
|
2
|
+
import "./b2d_body";
|
|
3
|
+
import "./b2d_chain";
|
|
4
|
+
import "./b2d_fixture";
|
|
5
|
+
import "./b2d_joint";
|
|
6
|
+
import "./b2d_shape";
|
|
7
|
+
import "./b2d_world";
|
|
8
|
+
import "./buffer";
|
|
9
|
+
import "./camera";
|
|
10
|
+
import "./collectionfactory";
|
|
11
|
+
import "./collectionproxy";
|
|
12
|
+
import "./compute";
|
|
13
|
+
import "./crash";
|
|
14
|
+
import "./factory";
|
|
15
|
+
import "./font";
|
|
16
|
+
import "./go";
|
|
17
|
+
import "./graphics";
|
|
18
|
+
import "./gui";
|
|
19
|
+
import "./html5";
|
|
20
|
+
import "./http";
|
|
21
|
+
import "./iac";
|
|
22
|
+
import "./iap";
|
|
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 "./push";
|
|
34
|
+
import "./render";
|
|
35
|
+
import "./resource";
|
|
36
|
+
import "./socket";
|
|
37
|
+
import "./sound";
|
|
38
|
+
import "./sprite";
|
|
39
|
+
import "./sys";
|
|
40
|
+
import "./tilemap";
|
|
41
|
+
import "./timer";
|
|
42
|
+
import "./types";
|
|
43
|
+
import "./vmath";
|
|
44
|
+
import "./webview";
|
|
45
|
+
import "./window";
|
|
46
|
+
import "./zlib";
|
|
47
|
+
|
|
48
|
+
export {};
|
|
@@ -0,0 +1,76 @@
|
|
|
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
|
+
* ```ts
|
|
22
|
+
* // Converting a string containing JSON data into a table:
|
|
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
|
+
* // Results in the following printout:
|
|
32
|
+
* // {
|
|
33
|
+
* // persons = {
|
|
34
|
+
* // 1 = {
|
|
35
|
+
* // name = John Doe,
|
|
36
|
+
* // }
|
|
37
|
+
* // 2 = {
|
|
38
|
+
* // name = Darth Vader,
|
|
39
|
+
* // }
|
|
40
|
+
* // }
|
|
41
|
+
* // }
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export function decode(json: string, options?: { decode_null_as_userdata?: boolean }): Record<string | number, unknown>;
|
|
45
|
+
/**
|
|
46
|
+
* Encode a lua table to a JSON string.
|
|
47
|
+
* A Lua error is raised for syntax errors.
|
|
48
|
+
*
|
|
49
|
+
* @param tbl - lua table to encode
|
|
50
|
+
* @param options - table with encode options
|
|
51
|
+
*
|
|
52
|
+
* - string `encode_empty_table_as_object`: whether to encode an empty table as an JSON object or array (default is object)
|
|
53
|
+
* @returns encoded json
|
|
54
|
+
* @example
|
|
55
|
+
* ```ts
|
|
56
|
+
* // Convert a table to a JSON string:
|
|
57
|
+
* export default defineScript({
|
|
58
|
+
* init() {
|
|
59
|
+
* const tbl = {
|
|
60
|
+
* persons: [{ name: "John Doe" }, { name: "Darth Vader" }],
|
|
61
|
+
* };
|
|
62
|
+
* const jsonstring = json.encode(tbl);
|
|
63
|
+
* pprint(jsonstring);
|
|
64
|
+
* },
|
|
65
|
+
* });
|
|
66
|
+
*
|
|
67
|
+
* // Results in the following printout:
|
|
68
|
+
* // {"persons":[{"name":"John Doe"},{"name":"Darth Vader"}]}
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
export function encode(tbl: Record<string | number, unknown>, options?: { encode_empty_table_as_object?: string }): string;
|
|
72
|
+
export { _null as null };
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="lua-types/5.1" />
|
|
2
|
+
import "../editor";
|
|
3
|
+
import "../editor-vm/http";
|
|
4
|
+
import "../editor-vm/json";
|
|
5
|
+
import "../editor-vm/localization";
|
|
6
|
+
import "../editor-vm/zip";
|
|
7
|
+
import "../editor-vm/zlib";
|
|
8
|
+
import "../editor-vm/tilemap_tiles";
|
|
9
|
+
import "../../../../src/editor-overloads";
|
|
10
|
+
import "../../../../src/editor-vm-globals";
|
|
11
|
+
|
|
12
|
+
export { defineEditorScript, defineEditorCommand } from "../../../../src/editor";
|
|
13
|
+
export type { EditorCommandQuery, EditorNode } from "../../../../src/editor";
|
|
@@ -0,0 +1,94 @@
|
|
|
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. The type of the property is number (uniform)
|
|
72
|
+
* or vector3 (non uniform).
|
|
73
|
+
*/
|
|
74
|
+
scale: number | Vector3;
|
|
75
|
+
/**
|
|
76
|
+
* The shadow color of the label. The type of the property is vector4.
|
|
77
|
+
*/
|
|
78
|
+
shadow: Vector4;
|
|
79
|
+
/**
|
|
80
|
+
* Returns the size of the label. The size will constrain the text if line break is enabled.
|
|
81
|
+
* The type of the property is vector3.
|
|
82
|
+
*/
|
|
83
|
+
size: Vector3;
|
|
84
|
+
/**
|
|
85
|
+
* The tracking of the label.
|
|
86
|
+
* This value is used to adjust the vertical spacing of characters in the text.
|
|
87
|
+
* The type of the property is number.
|
|
88
|
+
*/
|
|
89
|
+
tracking: number;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export {};
|