@defold-typescript/types 0.49.0 → 0.50.1
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 +696 -624
- package/api-signatures.json +6799 -160
- package/api-targets.json +393 -2
- package/examples/translations.json +12 -0
- package/generated/b2d.d.ts +15 -0
- package/generated/bullet3d.d.ts +16 -0
- package/generated/font.d.ts +7 -3
- package/generated/graphics.d.ts +7 -0
- package/generated/gui.d.ts +5 -4
- package/generated/label.d.ts +3 -3
- package/generated/render.d.ts +16 -1
- package/generated/versions/defold-1.13.2/b2d.d.ts +709 -0
- package/generated/versions/defold-1.13.2/b2d_body.d.ts +593 -0
- package/generated/versions/defold-1.13.2/b2d_chain.d.ts +105 -0
- package/generated/versions/defold-1.13.2/b2d_fixture.d.ts +175 -0
- package/generated/versions/defold-1.13.2/b2d_joint.d.ts +1301 -0
- package/generated/versions/defold-1.13.2/b2d_shape.d.ts +423 -0
- package/generated/versions/defold-1.13.2/b2d_world.d.ts +308 -0
- package/generated/versions/defold-1.13.2/buffer.d.ts +192 -0
- package/generated/versions/defold-1.13.2/bullet3d.d.ts +91 -0
- package/generated/versions/defold-1.13.2/bullet3d_collision_object.d.ts +433 -0
- package/generated/versions/defold-1.13.2/bullet3d_constraint.d.ts +818 -0
- package/generated/versions/defold-1.13.2/bullet3d_rigid_body.d.ts +429 -0
- package/generated/versions/defold-1.13.2/bullet3d_shape.d.ts +123 -0
- package/generated/versions/defold-1.13.2/bullet3d_world.d.ts +492 -0
- package/generated/versions/defold-1.13.2/camera.d.ts +300 -0
- package/generated/versions/defold-1.13.2/collectionfactory.d.ts +148 -0
- package/generated/versions/defold-1.13.2/collectionproxy.d.ts +109 -0
- package/generated/versions/defold-1.13.2/compute.d.ts +107 -0
- package/generated/versions/defold-1.13.2/crash.d.ts +157 -0
- package/generated/versions/defold-1.13.2/editor-vm/http.d.ts +139 -0
- package/generated/versions/defold-1.13.2/editor-vm/image.d.ts +48 -0
- package/generated/versions/defold-1.13.2/editor-vm/json.d.ts +21 -0
- package/generated/versions/defold-1.13.2/editor-vm/localization.d.ts +42 -0
- package/generated/versions/defold-1.13.2/editor-vm/tilemap_tiles.d.ts +126 -0
- package/generated/versions/defold-1.13.2/editor-vm/zip.d.ts +38 -0
- package/generated/versions/defold-1.13.2/editor-vm/zlib.d.ts +24 -0
- package/generated/versions/defold-1.13.2/editor.d.ts +2177 -0
- package/generated/versions/defold-1.13.2/factory.d.ts +121 -0
- package/generated/versions/defold-1.13.2/font.d.ts +123 -0
- package/generated/versions/defold-1.13.2/go.d.ts +1166 -0
- package/generated/versions/defold-1.13.2/graphics.d.ts +613 -0
- package/generated/versions/defold-1.13.2/gui.d.ts +2212 -0
- package/generated/versions/defold-1.13.2/html5.d.ts +55 -0
- package/generated/versions/defold-1.13.2/http.d.ts +83 -0
- package/generated/versions/defold-1.13.2/image.d.ts +181 -0
- package/generated/versions/defold-1.13.2/index.d.ts +63 -0
- package/generated/versions/defold-1.13.2/json.d.ts +94 -0
- package/generated/versions/defold-1.13.2/kinds/editor-script.d.ts +14 -0
- package/generated/versions/defold-1.13.2/label.d.ts +164 -0
- package/generated/versions/defold-1.13.2/liveupdate.d.ts +143 -0
- package/generated/versions/defold-1.13.2/material.d.ts +490 -0
- package/generated/versions/defold-1.13.2/model.d.ts +287 -0
- package/generated/versions/defold-1.13.2/msg.d.ts +10 -0
- package/generated/versions/defold-1.13.2/particlefx.d.ts +155 -0
- package/generated/versions/defold-1.13.2/physics.d.ts +789 -0
- package/generated/versions/defold-1.13.2/profiler.d.ts +228 -0
- package/generated/versions/defold-1.13.2/render.d.ts +1153 -0
- package/generated/versions/defold-1.13.2/resource.d.ts +1628 -0
- package/generated/versions/defold-1.13.2/socket.d.ts +797 -0
- package/generated/versions/defold-1.13.2/sound.d.ts +323 -0
- package/generated/versions/defold-1.13.2/sprite.d.ts +179 -0
- package/generated/versions/defold-1.13.2/sys.d.ts +754 -0
- package/generated/versions/defold-1.13.2/tilemap.d.ts +206 -0
- package/generated/versions/defold-1.13.2/timer.d.ts +136 -0
- package/generated/versions/defold-1.13.2/types.d.ts +61 -0
- package/generated/versions/defold-1.13.2/vmath.d.ts +775 -0
- package/generated/versions/defold-1.13.2/window.d.ts +196 -0
- package/generated/versions/defold-1.13.2/zlib.d.ts +41 -0
- package/identity-vocabulary.json +1 -0
- package/package.json +2 -2
- package/scripts/import-defold-release.ts +3 -31
- package/scripts/materialize-version.ts +13 -7
- package/scripts/regen.ts +63 -29
- package/scripts/sync-api-docs.ts +31 -2
- package/src/emit-dts.ts +25 -3
|
@@ -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
|
+
* script_instance The calling script instance
|
|
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,83 @@
|
|
|
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
|
+
* HTTP request options
|
|
11
|
+
*/
|
|
12
|
+
interface request_options {
|
|
13
|
+
/**
|
|
14
|
+
* timeout in seconds
|
|
15
|
+
*/
|
|
16
|
+
timeout?: number;
|
|
17
|
+
/**
|
|
18
|
+
* absolute destination path; overwritten only for status 200
|
|
19
|
+
*/
|
|
20
|
+
path?: string;
|
|
21
|
+
/**
|
|
22
|
+
* do not return cached data for status 304; unavailable on HTML5
|
|
23
|
+
*/
|
|
24
|
+
ignore_cache?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* use chunked transfer encoding for HTTPS requests larger than 16 KB; defaults to true and is unavailable on HTML5
|
|
27
|
+
*/
|
|
28
|
+
chunked_transfer?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* report transferred and total byte counts to the callback
|
|
31
|
+
*/
|
|
32
|
+
report_progress?: boolean;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Perform a HTTP/HTTPS request.
|
|
36
|
+
* 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).
|
|
37
|
+
*
|
|
38
|
+
* @param url - target url
|
|
39
|
+
* @param method - HTTP/HTTPS method, e.g. "GET", "PUT", "POST" etc.
|
|
40
|
+
* @param callback - response callback function
|
|
41
|
+
*
|
|
42
|
+
* `self`
|
|
43
|
+
* script_instance The current script instance
|
|
44
|
+
* `id`
|
|
45
|
+
* hash Internal message identifier. Do not use!
|
|
46
|
+
* @param headers - optional table with custom headers
|
|
47
|
+
* @param post_data - optional data to send
|
|
48
|
+
* @param options - optional request options
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* function update_my_progress_bar(self: unknown, fraction: number) {
|
|
52
|
+
* // draw the progress bar at the given fraction
|
|
53
|
+
* }
|
|
54
|
+
*
|
|
55
|
+
* // Basic HTTP-GET request. The callback receives a table with the response
|
|
56
|
+
* // in the fields status, the response (the data) and headers (a table).
|
|
57
|
+
* export default defineScript({
|
|
58
|
+
* init() {
|
|
59
|
+
* http.request(
|
|
60
|
+
* "http://www.google.com",
|
|
61
|
+
* "GET",
|
|
62
|
+
* (self, _id, response) => {
|
|
63
|
+
* if (response.bytes_received !== undefined && response.bytes_total !== undefined) {
|
|
64
|
+
* update_my_progress_bar(self, response.bytes_received / response.bytes_total);
|
|
65
|
+
* } else {
|
|
66
|
+
* print(response.status);
|
|
67
|
+
* print(response.response);
|
|
68
|
+
* pprint(response.headers);
|
|
69
|
+
* }
|
|
70
|
+
* },
|
|
71
|
+
* undefined,
|
|
72
|
+
* undefined,
|
|
73
|
+
* { report_progress: true },
|
|
74
|
+
* );
|
|
75
|
+
* },
|
|
76
|
+
* });
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
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?: http.request_options): void;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export {};
|
|
@@ -0,0 +1,181 @@
|
|
|
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
|
+
* ASTC image header
|
|
11
|
+
*/
|
|
12
|
+
interface astc_header {
|
|
13
|
+
/**
|
|
14
|
+
* Image width.
|
|
15
|
+
*/
|
|
16
|
+
width: number;
|
|
17
|
+
/**
|
|
18
|
+
* Image height.
|
|
19
|
+
*/
|
|
20
|
+
height: number;
|
|
21
|
+
/**
|
|
22
|
+
* Image depth.
|
|
23
|
+
*/
|
|
24
|
+
depth: number;
|
|
25
|
+
/**
|
|
26
|
+
* Block size on the x-axis.
|
|
27
|
+
*/
|
|
28
|
+
block_size_x: number;
|
|
29
|
+
/**
|
|
30
|
+
* Block size on the y-axis.
|
|
31
|
+
*/
|
|
32
|
+
block_size_y: number;
|
|
33
|
+
/**
|
|
34
|
+
* Block size on the z-axis.
|
|
35
|
+
*/
|
|
36
|
+
block_size_z: number;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Loaded buffer image data
|
|
40
|
+
*/
|
|
41
|
+
interface load_buffer_result {
|
|
42
|
+
/**
|
|
43
|
+
* Image width.
|
|
44
|
+
*/
|
|
45
|
+
width: number;
|
|
46
|
+
/**
|
|
47
|
+
* Image height.
|
|
48
|
+
*/
|
|
49
|
+
height: number;
|
|
50
|
+
/**
|
|
51
|
+
* Image type.
|
|
52
|
+
*/
|
|
53
|
+
type: image.TYPE;
|
|
54
|
+
/**
|
|
55
|
+
* Script buffer containing the decompressed image data.
|
|
56
|
+
*/
|
|
57
|
+
buffer: Opaque<"buffer">;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Image loading options
|
|
61
|
+
*/
|
|
62
|
+
interface load_options {
|
|
63
|
+
/**
|
|
64
|
+
* Whether to premultiply alpha into the color components. Defaults to `false`.
|
|
65
|
+
*/
|
|
66
|
+
premultiply_alpha?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Whether to flip the image contents vertically. Defaults to `false`.
|
|
69
|
+
*/
|
|
70
|
+
flip_vertically?: boolean;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Loaded string image data
|
|
74
|
+
*/
|
|
75
|
+
interface load_result {
|
|
76
|
+
/**
|
|
77
|
+
* Image width.
|
|
78
|
+
*/
|
|
79
|
+
width: number;
|
|
80
|
+
/**
|
|
81
|
+
* Image height.
|
|
82
|
+
*/
|
|
83
|
+
height: number;
|
|
84
|
+
/**
|
|
85
|
+
* Image type.
|
|
86
|
+
*/
|
|
87
|
+
type: image.TYPE;
|
|
88
|
+
/**
|
|
89
|
+
* Raw image data.
|
|
90
|
+
*/
|
|
91
|
+
buffer: string;
|
|
92
|
+
}
|
|
93
|
+
type TYPE = typeof image.TYPE_RGB | typeof image.TYPE_RGBA | typeof image.TYPE_LUMINANCE | typeof image.TYPE_LUMINANCE_ALPHA;
|
|
94
|
+
/**
|
|
95
|
+
* Luminance image type.
|
|
96
|
+
*/
|
|
97
|
+
const TYPE_LUMINANCE: string & { readonly __brand: "image.TYPE_LUMINANCE" };
|
|
98
|
+
/**
|
|
99
|
+
* Luminance-alpha image type.
|
|
100
|
+
*/
|
|
101
|
+
const TYPE_LUMINANCE_ALPHA: string & { readonly __brand: "image.TYPE_LUMINANCE_ALPHA" };
|
|
102
|
+
/**
|
|
103
|
+
* RGB image type.
|
|
104
|
+
*/
|
|
105
|
+
const TYPE_RGB: string & { readonly __brand: "image.TYPE_RGB" };
|
|
106
|
+
/**
|
|
107
|
+
* RGBA image type.
|
|
108
|
+
*/
|
|
109
|
+
const TYPE_RGBA: string & { readonly __brand: "image.TYPE_RGBA" };
|
|
110
|
+
/**
|
|
111
|
+
* get the header of an .astc buffer
|
|
112
|
+
*
|
|
113
|
+
* @param buffer - .astc file data buffer
|
|
114
|
+
* @returns header, or `nil` if the buffer is not a valid ASTC image
|
|
115
|
+
* @example
|
|
116
|
+
* ```ts
|
|
117
|
+
* // How to get the block size and dimensions from a .astc file
|
|
118
|
+
* const [s] = sys.load_resource("/assets/cat.astc");
|
|
119
|
+
* if (s !== undefined) {
|
|
120
|
+
* const header = image.get_astc_header(s);
|
|
121
|
+
* pprint(s);
|
|
122
|
+
* }
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
function get_astc_header(buffer: string): image.astc_header | undefined;
|
|
126
|
+
/**
|
|
127
|
+
* Load image (PNG or JPEG) from buffer.
|
|
128
|
+
*
|
|
129
|
+
* @param buffer - image data buffer
|
|
130
|
+
* @param options - Optional loading parameters. A boolean is accepted for backwards compatibility and controls `premultiply_alpha`.
|
|
131
|
+
* @returns loaded image, or `nil` if loading fails
|
|
132
|
+
* @example
|
|
133
|
+
* ```ts
|
|
134
|
+
* // How to load an image from an URL and create a GUI texture from it:
|
|
135
|
+
* const imgurl = "http://www.site.com/image.png";
|
|
136
|
+
* http.request(imgurl, "GET", (self, id, response) => {
|
|
137
|
+
* const img = response.response !== undefined ? image.load(response.response) : undefined;
|
|
138
|
+
* if (img !== undefined) {
|
|
139
|
+
* const tx = gui.new_texture("image_node", img.width, img.height, img.type, img.buffer);
|
|
140
|
+
* }
|
|
141
|
+
* });
|
|
142
|
+
* ```
|
|
143
|
+
*/
|
|
144
|
+
function load(buffer: string, options?: boolean | image.load_options): image.load_result | undefined;
|
|
145
|
+
/**
|
|
146
|
+
* Load image (PNG or JPEG) from a string buffer.
|
|
147
|
+
*
|
|
148
|
+
* @param buffer - image data buffer
|
|
149
|
+
* @param options - Optional loading parameters. A boolean is accepted for backwards compatibility and controls `premultiply_alpha`.
|
|
150
|
+
* @returns loaded image, or `nil` if loading fails
|
|
151
|
+
* @example
|
|
152
|
+
* ```ts
|
|
153
|
+
* // Load an image from an URL as a buffer and create a texture resource from it:
|
|
154
|
+
* const imgurl = "http://www.site.com/image.png";
|
|
155
|
+
* http.request(imgurl, "GET", (self, id, response) => {
|
|
156
|
+
* const img =
|
|
157
|
+
* response.response !== undefined
|
|
158
|
+
* ? image.load_buffer(response.response, { flip_vertically: true })
|
|
159
|
+
* : undefined;
|
|
160
|
+
* // the engine registers a texture format only when the driver supports it
|
|
161
|
+
* const format = graphics.TEXTURE_FORMAT_RGBA;
|
|
162
|
+
* if (img !== undefined && format !== undefined) {
|
|
163
|
+
* const tparams = {
|
|
164
|
+
* width: img.width,
|
|
165
|
+
* height: img.height,
|
|
166
|
+
* type: graphics.TEXTURE_TYPE_2D,
|
|
167
|
+
* format,
|
|
168
|
+
* };
|
|
169
|
+
*
|
|
170
|
+
* const my_texture_id = resource.create_texture("/my_custom_texture.texturec", tparams, img.buffer);
|
|
171
|
+
* // Apply the texture to a model
|
|
172
|
+
* go.set("/go1#model", "texture0", my_texture_id);
|
|
173
|
+
* }
|
|
174
|
+
* });
|
|
175
|
+
* ```
|
|
176
|
+
*/
|
|
177
|
+
function load_buffer(buffer: string, options?: boolean | image.load_options): image.load_buffer_result | undefined;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export {};
|
|
@@ -0,0 +1,63 @@
|
|
|
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 "./bullet3d";
|
|
12
|
+
import "./bullet3d_collision_object";
|
|
13
|
+
import "./bullet3d_constraint";
|
|
14
|
+
import "./bullet3d_rigid_body";
|
|
15
|
+
import "./bullet3d_shape";
|
|
16
|
+
import "./bullet3d_world";
|
|
17
|
+
import "./camera";
|
|
18
|
+
import "./collectionfactory";
|
|
19
|
+
import "./collectionproxy";
|
|
20
|
+
import "./compute";
|
|
21
|
+
import "./crash";
|
|
22
|
+
import "./factory";
|
|
23
|
+
import "./font";
|
|
24
|
+
import "./go";
|
|
25
|
+
import "./graphics";
|
|
26
|
+
import "./gui";
|
|
27
|
+
import "./html5";
|
|
28
|
+
import "./http";
|
|
29
|
+
import "./image";
|
|
30
|
+
import "./json";
|
|
31
|
+
import "./label";
|
|
32
|
+
import "./liveupdate";
|
|
33
|
+
import "./material";
|
|
34
|
+
import "./model";
|
|
35
|
+
import "./msg";
|
|
36
|
+
import "./particlefx";
|
|
37
|
+
import "./physics";
|
|
38
|
+
import "./profiler";
|
|
39
|
+
import "./render";
|
|
40
|
+
import "./resource";
|
|
41
|
+
import "./socket";
|
|
42
|
+
import "./sound";
|
|
43
|
+
import "./sprite";
|
|
44
|
+
import "./sys";
|
|
45
|
+
import "./tilemap";
|
|
46
|
+
import "./timer";
|
|
47
|
+
import "./types";
|
|
48
|
+
import "./vmath";
|
|
49
|
+
import "./window";
|
|
50
|
+
import "./zlib";
|
|
51
|
+
import "../../../src/custom-messages";
|
|
52
|
+
import "../../../src/engine-globals";
|
|
53
|
+
import "../../../src/msg-overloads";
|
|
54
|
+
import "../../../src/message-guard";
|
|
55
|
+
import "../../../src/window-event-guard";
|
|
56
|
+
import "../../../src/scene-addresses";
|
|
57
|
+
import "../../../src/go-overloads";
|
|
58
|
+
import "../../../src/component-properties";
|
|
59
|
+
import "../../../src/render-overloads";
|
|
60
|
+
import "../../../src/vmath-overloads";
|
|
61
|
+
import "../../../src/sys-overloads";
|
|
62
|
+
|
|
63
|
+
export {};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/** @noSelfInFile */
|
|
2
|
+
declare global {
|
|
3
|
+
/**
|
|
4
|
+
* Manipulation of JSON data strings.
|
|
5
|
+
*/
|
|
6
|
+
namespace json {
|
|
7
|
+
/**
|
|
8
|
+
* JSON decoding options
|
|
9
|
+
*/
|
|
10
|
+
export interface decode_options {
|
|
11
|
+
/**
|
|
12
|
+
* Decode JSON `null` as json.null instead of `nil`.
|
|
13
|
+
*/
|
|
14
|
+
decode_null_as_userdata?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* JSON encoding options
|
|
18
|
+
*/
|
|
19
|
+
export interface encode_options {
|
|
20
|
+
/**
|
|
21
|
+
* Encode an empty table as an object instead of an array. The default is true.
|
|
22
|
+
*/
|
|
23
|
+
encode_empty_table_as_object?: boolean;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Represents the null primitive from a json file
|
|
27
|
+
*/
|
|
28
|
+
const _null: unknown;
|
|
29
|
+
/**
|
|
30
|
+
* Decode a string of JSON data into a Lua table.
|
|
31
|
+
* A Lua error is raised for syntax errors.
|
|
32
|
+
*
|
|
33
|
+
* @param json - json data
|
|
34
|
+
* @param options - optional decoding options
|
|
35
|
+
* @returns decoded JSON value
|
|
36
|
+
* @example
|
|
37
|
+
* Converting a string containing JSON data into a Lua table:
|
|
38
|
+
* ```ts
|
|
39
|
+
* export default defineScript({
|
|
40
|
+
* init() {
|
|
41
|
+
* const jsonstring = '{"persons":[{"name":"John Doe"},{"name":"Darth Vader"}]}';
|
|
42
|
+
* const data = json.decode(jsonstring);
|
|
43
|
+
* pprint(data);
|
|
44
|
+
* },
|
|
45
|
+
* });
|
|
46
|
+
* ```
|
|
47
|
+
* @example
|
|
48
|
+
* Results in the following printout:
|
|
49
|
+
* ```ts
|
|
50
|
+
* // {
|
|
51
|
+
* // persons = {
|
|
52
|
+
* // 1 = {
|
|
53
|
+
* // name = John Doe,
|
|
54
|
+
* // }
|
|
55
|
+
* // 2 = {
|
|
56
|
+
* // name = Darth Vader,
|
|
57
|
+
* // }
|
|
58
|
+
* // }
|
|
59
|
+
* // }
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export function decode(json: string, options?: json.decode_options): unknown;
|
|
63
|
+
/**
|
|
64
|
+
* Encode a lua table to a JSON string.
|
|
65
|
+
* A Lua error is raised for syntax errors.
|
|
66
|
+
*
|
|
67
|
+
* @param tbl - Lua value to encode
|
|
68
|
+
* @param options - optional encoding options
|
|
69
|
+
* @returns encoded json
|
|
70
|
+
* @example
|
|
71
|
+
* Convert a lua table to a JSON string:
|
|
72
|
+
* ```ts
|
|
73
|
+
* export default defineScript({
|
|
74
|
+
* init() {
|
|
75
|
+
* const tbl = {
|
|
76
|
+
* persons: [{ name: "John Doe" }, { name: "Darth Vader" }],
|
|
77
|
+
* };
|
|
78
|
+
* const jsonstring = json.encode(tbl);
|
|
79
|
+
* pprint(jsonstring);
|
|
80
|
+
* },
|
|
81
|
+
* });
|
|
82
|
+
* ```
|
|
83
|
+
* @example
|
|
84
|
+
* Results in the following printout:
|
|
85
|
+
* ```ts
|
|
86
|
+
* // {"persons":[{"name":"John Doe"},{"name":"Darth Vader"}]}
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
export function encode(tbl: unknown, options?: json.encode_options): string;
|
|
90
|
+
export { _null as null };
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
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,164 @@
|
|
|
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
|
+
* Rich-text layout object
|
|
11
|
+
*/
|
|
12
|
+
interface layout_object {
|
|
13
|
+
/**
|
|
14
|
+
* object type, currently `link` or `sprite`
|
|
15
|
+
*/
|
|
16
|
+
type: string;
|
|
17
|
+
/**
|
|
18
|
+
* the object's `id` attribute, or its generated layout object id
|
|
19
|
+
*/
|
|
20
|
+
id: Hash;
|
|
21
|
+
/**
|
|
22
|
+
* zero-based UTF-32 offset in the visible text
|
|
23
|
+
*/
|
|
24
|
+
text_offset: number;
|
|
25
|
+
/**
|
|
26
|
+
* visible UTF-32 text length covered by the object
|
|
27
|
+
*/
|
|
28
|
+
text_length: number;
|
|
29
|
+
/**
|
|
30
|
+
* lower-left x-coordinate relative to the label's upper-left layout origin
|
|
31
|
+
*/
|
|
32
|
+
x: number;
|
|
33
|
+
/**
|
|
34
|
+
* lower-left y-coordinate relative to the label's upper-left layout origin
|
|
35
|
+
*/
|
|
36
|
+
y: number;
|
|
37
|
+
/**
|
|
38
|
+
* resolved object width
|
|
39
|
+
*/
|
|
40
|
+
width: number;
|
|
41
|
+
/**
|
|
42
|
+
* resolved object height
|
|
43
|
+
*/
|
|
44
|
+
height: number;
|
|
45
|
+
/**
|
|
46
|
+
* markup attributes keyed by name
|
|
47
|
+
*/
|
|
48
|
+
attributes: LuaTable<string, string>;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Returns the sprites and links found in the label's current layout.
|
|
52
|
+
* Each entry contains `type`, `id`, the zero-based UTF-32 `text_offset`,
|
|
53
|
+
* `text_length`, resolved `x`, `y`, `width`
|
|
54
|
+
* and `height`, and an `attributes` table. The position is the lower-left
|
|
55
|
+
* object corner relative to the label's upper-left layout origin.
|
|
56
|
+
* Inline resource rendering is not part of this MVP; sprites use their explicit
|
|
57
|
+
* dimensions or a one-em square fallback.
|
|
58
|
+
*
|
|
59
|
+
* @param url - the label to inspect
|
|
60
|
+
* @returns layout objects in source order. **0️⃣ `text_offset` is 0-based; passed to Defold unchanged.**
|
|
61
|
+
* @example
|
|
62
|
+
* ```ts
|
|
63
|
+
* const objects = label.get_layout_objects("#label");
|
|
64
|
+
* for (const object of objects) {
|
|
65
|
+
* if (object.type === "link") {
|
|
66
|
+
* print(object.attributes.get("src"), object.text_offset, object.text_length);
|
|
67
|
+
* } else if (object.type === "sprite") {
|
|
68
|
+
* print(object.attributes.get("src"), object.x, object.y, object.width, object.height);
|
|
69
|
+
* }
|
|
70
|
+
* }
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
function get_layout_objects(url: string | Hash | Url): label.layout_object[];
|
|
74
|
+
/**
|
|
75
|
+
* Gets the text from a label component
|
|
76
|
+
* This function is deprecated. Use `go.get("#label", "text")` instead.
|
|
77
|
+
*
|
|
78
|
+
* @param url - the label to get the text from
|
|
79
|
+
* @returns the label text
|
|
80
|
+
* @example
|
|
81
|
+
* ```ts
|
|
82
|
+
* export default defineScript({
|
|
83
|
+
* init() {
|
|
84
|
+
* const text = go.get<label.properties>()("#label", "text");
|
|
85
|
+
* print(text);
|
|
86
|
+
* },
|
|
87
|
+
* });
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
function get_text(url: string | Hash | Url): string;
|
|
91
|
+
/**
|
|
92
|
+
* Sets the text of a label component
|
|
93
|
+
* This function is deprecated. Use `go.set("#label", "text", value)` instead.
|
|
94
|
+
* This method uses the message passing that means the value will be set after `dispatch messages` step.
|
|
95
|
+
* More information is available in the Application Lifecycle manual.
|
|
96
|
+
*
|
|
97
|
+
* @param url - the label that should have a constant set
|
|
98
|
+
* @param text - the text
|
|
99
|
+
* @example
|
|
100
|
+
* ```ts
|
|
101
|
+
* export default defineScript({
|
|
102
|
+
* init() {
|
|
103
|
+
* go.set<label.properties>()("#label", "text", "Hello World!");
|
|
104
|
+
* },
|
|
105
|
+
* });
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
function set_text(url: string | Hash | Url, text: string | number): void;
|
|
109
|
+
interface properties {
|
|
110
|
+
/**
|
|
111
|
+
* The color of the label. The type of the property is vector4.
|
|
112
|
+
*/
|
|
113
|
+
color: Vector4;
|
|
114
|
+
/**
|
|
115
|
+
* The font used when rendering the label. The type of the property is hash.
|
|
116
|
+
*/
|
|
117
|
+
font: Hash;
|
|
118
|
+
/**
|
|
119
|
+
* The leading of the label. This value is used to scale the line spacing of text.
|
|
120
|
+
* The type of the property is number.
|
|
121
|
+
*/
|
|
122
|
+
leading: number;
|
|
123
|
+
/**
|
|
124
|
+
* The line break of the label.
|
|
125
|
+
* This value is used to adjust the vertical spacing of characters in the text.
|
|
126
|
+
* The type of the property is boolean.
|
|
127
|
+
*/
|
|
128
|
+
line_break: boolean;
|
|
129
|
+
/**
|
|
130
|
+
* The material used when rendering the label. The type of the property is hash.
|
|
131
|
+
*/
|
|
132
|
+
material: Hash;
|
|
133
|
+
/**
|
|
134
|
+
* The outline color of the label. The type of the property is vector4.
|
|
135
|
+
*/
|
|
136
|
+
outline: Vector4;
|
|
137
|
+
/**
|
|
138
|
+
* 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.
|
|
139
|
+
*/
|
|
140
|
+
scale: Vector3;
|
|
141
|
+
/**
|
|
142
|
+
* The shadow color of the label. The type of the property is vector4.
|
|
143
|
+
*/
|
|
144
|
+
shadow: Vector4;
|
|
145
|
+
/**
|
|
146
|
+
* Returns the size of the label. The size will constrain the text if line break is enabled.
|
|
147
|
+
* The type of the property is vector3.
|
|
148
|
+
*/
|
|
149
|
+
size: Vector3;
|
|
150
|
+
/**
|
|
151
|
+
* The text of the label.
|
|
152
|
+
*/
|
|
153
|
+
text: string;
|
|
154
|
+
/**
|
|
155
|
+
* The tracking of the label.
|
|
156
|
+
* This value is used to adjust the vertical spacing of characters in the text.
|
|
157
|
+
* The type of the property is number.
|
|
158
|
+
*/
|
|
159
|
+
tracking: number;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export {};
|