@defold-typescript/types 0.19.4 → 0.20.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.
Files changed (93) hide show
  1. package/api-availability.json +2755 -0
  2. package/api-migrations.json +31 -0
  3. package/api-signatures.json +2324 -0
  4. package/api-targets.json +493 -45
  5. package/generated/b2d.d.ts +6 -0
  6. package/generated/b2d_body.d.ts +329 -1
  7. package/generated/b2d_chain.d.ts +106 -0
  8. package/generated/b2d_fixture.d.ts +155 -0
  9. package/generated/b2d_joint.d.ts +823 -0
  10. package/generated/b2d_shape.d.ts +215 -0
  11. package/generated/b2d_world.d.ts +314 -0
  12. package/generated/buffer.d.ts +1 -1
  13. package/generated/builtin-messages.d.ts +18 -0
  14. package/generated/camera.d.ts +62 -5
  15. package/generated/compute.d.ts +306 -0
  16. package/generated/crash.d.ts +2 -2
  17. package/generated/go.d.ts +31 -6
  18. package/generated/graphics.d.ts +95 -0
  19. package/generated/gui.d.ts +4 -6
  20. package/generated/image.d.ts +3 -3
  21. package/generated/json.d.ts +2 -2
  22. package/generated/kinds/gui-script.d.ts +7 -0
  23. package/generated/kinds/render-script.d.ts +7 -0
  24. package/generated/kinds/script.d.ts +7 -0
  25. package/generated/label.d.ts +1 -1
  26. package/generated/liveupdate.d.ts +22 -4
  27. package/generated/material.d.ts +444 -0
  28. package/generated/model.d.ts +46 -5
  29. package/generated/physics.d.ts +2 -4
  30. package/generated/profiler.d.ts +2 -3
  31. package/generated/render.d.ts +25 -9
  32. package/generated/resource.d.ts +2 -2
  33. package/generated/socket.d.ts +35 -35
  34. package/generated/sprite.d.ts +15 -1
  35. package/generated/sys.d.ts +1 -1
  36. package/generated/tilemap.d.ts +14 -0
  37. package/generated/timer.d.ts +1 -1
  38. package/generated/versions/defold-1.12.4/b2d.d.ts +27 -0
  39. package/generated/versions/defold-1.12.4/b2d_body.d.ts +348 -0
  40. package/generated/versions/defold-1.12.4/buffer.d.ts +176 -0
  41. package/generated/versions/defold-1.12.4/camera.d.ts +245 -0
  42. package/generated/versions/defold-1.12.4/collectionfactory.d.ts +146 -0
  43. package/generated/versions/defold-1.12.4/collectionproxy.d.ts +71 -0
  44. package/generated/versions/defold-1.12.4/crash.d.ts +143 -0
  45. package/generated/versions/defold-1.12.4/factory.d.ts +123 -0
  46. package/generated/versions/defold-1.12.4/font.d.ts +81 -0
  47. package/generated/versions/defold-1.12.4/go.d.ts +1029 -0
  48. package/generated/versions/defold-1.12.4/graphics.d.ts +226 -0
  49. package/generated/versions/defold-1.12.4/gui.d.ts +2372 -0
  50. package/generated/versions/defold-1.12.4/html5.d.ts +53 -0
  51. package/generated/versions/defold-1.12.4/http.d.ts +84 -0
  52. package/generated/versions/defold-1.12.4/iac.d.ts +18 -0
  53. package/generated/versions/defold-1.12.4/iap.d.ts +60 -0
  54. package/generated/versions/defold-1.12.4/image.d.ts +139 -0
  55. package/generated/versions/defold-1.12.4/index.d.ts +41 -0
  56. package/generated/versions/defold-1.12.4/json.d.ts +76 -0
  57. package/generated/versions/defold-1.12.4/label.d.ts +94 -0
  58. package/generated/versions/defold-1.12.4/liveupdate.d.ts +122 -0
  59. package/generated/versions/defold-1.12.4/model.d.ts +205 -0
  60. package/generated/versions/defold-1.12.4/msg.d.ts +10 -0
  61. package/generated/versions/defold-1.12.4/particlefx.d.ts +166 -0
  62. package/generated/versions/defold-1.12.4/physics.d.ts +547 -0
  63. package/generated/versions/defold-1.12.4/profiler.d.ts +234 -0
  64. package/generated/versions/defold-1.12.4/push.d.ts +66 -0
  65. package/generated/versions/defold-1.12.4/render.d.ts +1149 -0
  66. package/generated/versions/defold-1.12.4/resource.d.ts +1518 -0
  67. package/generated/versions/defold-1.12.4/socket.d.ts +795 -0
  68. package/generated/versions/defold-1.12.4/sound.d.ts +291 -0
  69. package/generated/versions/defold-1.12.4/sprite.d.ts +143 -0
  70. package/generated/versions/defold-1.12.4/sys.d.ts +695 -0
  71. package/generated/versions/defold-1.12.4/tilemap.d.ts +181 -0
  72. package/generated/versions/defold-1.12.4/timer.d.ts +114 -0
  73. package/generated/versions/defold-1.12.4/types.d.ts +61 -0
  74. package/generated/versions/defold-1.12.4/vmath.d.ts +806 -0
  75. package/generated/versions/defold-1.12.4/webview.d.ts +68 -0
  76. package/generated/versions/defold-1.12.4/window.d.ts +198 -0
  77. package/generated/versions/defold-1.12.4/zlib.d.ts +40 -0
  78. package/index.d.ts +22 -0
  79. package/package.json +8 -1
  80. package/scripts/fidelity-audit.ts +69 -12
  81. package/scripts/fidelity-baseline.json +56 -0
  82. package/scripts/generate-api-availability.ts +139 -0
  83. package/scripts/generate-api-signatures.ts +66 -0
  84. package/scripts/import-defold-release.ts +480 -0
  85. package/scripts/materialize-version.ts +45 -20
  86. package/scripts/regen.ts +53 -6
  87. package/scripts/sync-api-docs.ts +89 -41
  88. package/src/api-availability.ts +0 -0
  89. package/src/core-types.ts +9 -0
  90. package/src/emit-dts.ts +685 -17
  91. package/src/emit-messages.ts +72 -2
  92. package/src/index.ts +26 -1
  93. package/src/lifecycle.ts +43 -2
@@ -0,0 +1,348 @@
1
+ /** @noSelfInFile */
2
+ import type { Opaque, Vector3 } from "../../../src/core-types";
3
+
4
+ declare global {
5
+ /**
6
+ * Functions for interacting with Box2D bodies.
7
+ */
8
+ namespace b2d.body {
9
+ type b2Body = Opaque<"b2Body">;
10
+ type b2World = Opaque<"b2World">;
11
+ /**
12
+ * Dynamic body
13
+ */
14
+ const B2_DYNAMIC_BODY: number & { readonly __brand: "b2d.body.B2_DYNAMIC_BODY" };
15
+ /**
16
+ * Kinematic body
17
+ */
18
+ const B2_KINEMATIC_BODY: number & { readonly __brand: "b2d.body.B2_KINEMATIC_BODY" };
19
+ /**
20
+ * Static (immovable) body
21
+ */
22
+ const B2_STATIC_BODY: number & { readonly __brand: "b2d.body.B2_STATIC_BODY" };
23
+ /**
24
+ * Apply an angular impulse.
25
+ *
26
+ * @param body - body
27
+ * @param impulse - impulse the angular impulse in units of kg*m*m/s
28
+ */
29
+ function apply_angular_impulse(body: Opaque<"b2Body">, impulse: number): void;
30
+ /**
31
+ * Apply a force at a world point. If the force is not
32
+ * applied at the center of mass, it will generate a torque and
33
+ * affect the angular velocity. This wakes up the body.
34
+ *
35
+ * @param body - body
36
+ * @param force - the world force vector, usually in Newtons (N).
37
+ * @param point - the world position of the point of application.
38
+ */
39
+ function apply_force(body: Opaque<"b2Body">, force: Vector3, point: Vector3): void;
40
+ /**
41
+ * Apply a force to the center of mass. This wakes up the body.
42
+ *
43
+ * @param body - body
44
+ * @param force - the world force vector, usually in Newtons (N).
45
+ */
46
+ function apply_force_to_center(body: Opaque<"b2Body">, force: Vector3): void;
47
+ /**
48
+ * Apply an impulse at a point. This immediately modifies the velocity.
49
+ * It also modifies the angular velocity if the point of application
50
+ * is not at the center of mass. This wakes up the body.
51
+ *
52
+ * @param body - body
53
+ * @param impulse - the world impulse vector, usually in N-seconds or kg-m/s.
54
+ * @param point - the world position of the point of application.
55
+ */
56
+ function apply_linear_impulse(body: Opaque<"b2Body">, impulse: Vector3, point: Vector3): void;
57
+ /**
58
+ * Apply a torque. This affects the angular velocity
59
+ * without affecting the linear velocity of the center of mass.
60
+ * This wakes up the body.
61
+ *
62
+ * @param body - body
63
+ * @param torque - torque about the z-axis (out of the screen), usually in N-m.
64
+ */
65
+ function apply_torque(body: Opaque<"b2Body">, torque: number): void;
66
+ /**
67
+ * You can disable sleeping on this body. If you disable sleeping, the body will be woken.
68
+ *
69
+ * @param body - body
70
+ * @param enable - if false, the body will never sleep, and consume more CPU
71
+ */
72
+ function enable_sleep(body: Opaque<"b2Body">, enable: boolean): void;
73
+ /**
74
+ * Get the angle in radians.
75
+ *
76
+ * @param body - body
77
+ * @returns the current world rotation angle in radians.
78
+ */
79
+ function get_angle(body: Opaque<"b2Body">): number;
80
+ /**
81
+ * Get the angular damping of the body.
82
+ *
83
+ * @param body - body
84
+ * @returns the damping
85
+ */
86
+ function get_angular_damping(body: Opaque<"b2Body">): number;
87
+ /**
88
+ * Get the angular velocity.
89
+ *
90
+ * @param body - body
91
+ * @returns the angular velocity in radians/second.
92
+ */
93
+ function get_angular_velocity(body: Opaque<"b2Body">): number;
94
+ /**
95
+ * Get the gravity scale of the body.
96
+ *
97
+ * @param body - body
98
+ * @returns the scale
99
+ */
100
+ function get_gravity_scale(body: Opaque<"b2Body">): number;
101
+ /**
102
+ * Get the linear damping of the body.
103
+ *
104
+ * @param body - body
105
+ * @returns the damping
106
+ */
107
+ function get_linear_damping(body: Opaque<"b2Body">): number;
108
+ /**
109
+ * Get the linear velocity of the center of mass.
110
+ *
111
+ * @param body - body
112
+ * @returns the linear velocity of the center of mass.
113
+ */
114
+ function get_linear_velocity(body: Opaque<"b2Body">): Vector3;
115
+ /**
116
+ * Get the world velocity of a local point.
117
+ *
118
+ * @param body - body
119
+ * @param local_point - a point in local coordinates.
120
+ * @returns the world velocity of a point.
121
+ */
122
+ function get_linear_velocity_from_local_point(body: Opaque<"b2Body">, local_point: Vector3): Vector3;
123
+ /**
124
+ * Get the world linear velocity of a world point attached to this body.
125
+ *
126
+ * @param body - body
127
+ * @param world_point - a point in world coordinates.
128
+ * @returns the world velocity of a point.
129
+ */
130
+ function get_linear_velocity_from_world_point(body: Opaque<"b2Body">, world_point: Vector3): Vector3;
131
+ /**
132
+ * Get the local position of the center of mass.
133
+ *
134
+ * @param body - body
135
+ * @returns Get the local position of the center of mass.
136
+ */
137
+ function get_local_center_of_mass(body: Opaque<"b2Body">): Vector3;
138
+ /**
139
+ * Gets a local point relative to the body's origin given a world point.
140
+ *
141
+ * @param body - body
142
+ * @param world_point - a point in world coordinates.
143
+ * @returns the corresponding local point relative to the body's origin.
144
+ */
145
+ function get_local_point(body: Opaque<"b2Body">, world_point: Vector3): Vector3;
146
+ /**
147
+ * Gets a local vector given a world vector.
148
+ *
149
+ * @param body - body
150
+ * @param world_vector - a vector in world coordinates.
151
+ * @returns the corresponding local vector.
152
+ */
153
+ function get_local_vector(body: Opaque<"b2Body">, world_vector: Vector3): Vector3;
154
+ /**
155
+ * Get the total mass of the body.
156
+ *
157
+ * @param body - body
158
+ * @returns the mass, usually in kilograms (kg).
159
+ */
160
+ function get_mass(body: Opaque<"b2Body">): number;
161
+ /**
162
+ * Get the world body origin position.
163
+ *
164
+ * @param body - body
165
+ * @returns the world position of the body's origin.
166
+ */
167
+ function get_position(body: Opaque<"b2Body">): Vector3;
168
+ /**
169
+ * Get the rotational inertia of the body about the local origin.
170
+ *
171
+ * @param body - body
172
+ * @returns the rotational inertia, usually in kg-m^2.
173
+ */
174
+ function get_rotational_inertia(body: Opaque<"b2Body">): number;
175
+ /**
176
+ * Get the type of this body.
177
+ *
178
+ * @param body - body
179
+ * @returns the body type
180
+ */
181
+ function get_type(body: Opaque<"b2Body">): (number & { readonly __brand: "b2d.body.B2_DYNAMIC_BODY" }) | (number & { readonly __brand: "b2d.body.B2_KINEMATIC_BODY" }) | (number & { readonly __brand: "b2d.body.B2_STATIC_BODY" });
182
+ /**
183
+ * Get the parent world of this body.
184
+ *
185
+ * @param body - body
186
+ */
187
+ function get_world(body: Opaque<"b2Body">): Opaque<"b2World">;
188
+ /**
189
+ * Get the world position of the center of mass.
190
+ *
191
+ * @param body - body
192
+ * @returns Get the world position of the center of mass.
193
+ */
194
+ function get_world_center_of_mass(body: Opaque<"b2Body">): Vector3;
195
+ /**
196
+ * Get the world coordinates of a point given the local coordinates.
197
+ *
198
+ * @param body - body
199
+ * @param local_vector - localPoint a point on the body measured relative the the body's origin.
200
+ * @returns the same point expressed in world coordinates.
201
+ */
202
+ function get_world_point(body: Opaque<"b2Body">, local_vector: Vector3): Vector3;
203
+ /**
204
+ * Get the world coordinates of a vector given the local coordinates.
205
+ *
206
+ * @param body - body
207
+ * @param local_vector - a vector fixed in the body.
208
+ * @returns the same vector expressed in world coordinates.
209
+ */
210
+ function get_world_vector(body: Opaque<"b2Body">, local_vector: Vector3): Vector3;
211
+ /**
212
+ * Get the active state of the body.
213
+ *
214
+ * @param body - body
215
+ * @returns is the body active
216
+ */
217
+ function is_active(body: Opaque<"b2Body">): boolean;
218
+ /**
219
+ * Get the sleeping state of this body.
220
+ *
221
+ * @param body - body
222
+ * @returns true if the body is awake, false if it's sleeping.
223
+ */
224
+ function is_awake(body: Opaque<"b2Body">): boolean;
225
+ /**
226
+ * Is this body in bullet mode
227
+ *
228
+ * @param body - body
229
+ * @returns true if the body is in bullet mode
230
+ */
231
+ function is_bullet(body: Opaque<"b2Body">): boolean;
232
+ /**
233
+ * Does this body have fixed rotation?
234
+ *
235
+ * @param body - body
236
+ * @returns is the rotation fixed
237
+ */
238
+ function is_fixed_rotation(body: Opaque<"b2Body">): boolean;
239
+ /**
240
+ * Is this body allowed to sleep
241
+ *
242
+ * @param body - body
243
+ * @returns true if the body is allowed to sleep
244
+ */
245
+ function is_sleeping_enabled(body: Opaque<"b2Body">): boolean;
246
+ /**
247
+ * This resets the mass properties to the sum of the mass properties of the fixtures.
248
+ * This normally does not need to be called unless you called SetMassData to override
249
+ *
250
+ * @param body - body
251
+ */
252
+ function reset_mass_data(body: Opaque<"b2Body">): void;
253
+ /**
254
+ * Set the active state of the body. An inactive body is not
255
+ * simulated and cannot be collided with or woken up.
256
+ * If you pass a flag of true, all fixtures will be added to the
257
+ * broad-phase.
258
+ * If you pass a flag of false, all fixtures will be removed from
259
+ * the broad-phase and all contacts will be destroyed.
260
+ * Fixtures and joints are otherwise unaffected. You may continue
261
+ * to create/destroy fixtures and joints on inactive bodies.
262
+ * Fixtures on an inactive body are implicitly inactive and will
263
+ * not participate in collisions, ray-casts, or queries.
264
+ * Joints connected to an inactive body are implicitly inactive.
265
+ * An inactive body is still owned by a b2World object and remains
266
+ * in the body list.
267
+ *
268
+ * @param body - body
269
+ * @param enable - true if the body should be active
270
+ */
271
+ function set_active(body: Opaque<"b2Body">, enable: boolean): void;
272
+ /**
273
+ * Set the angular damping of the body.
274
+ *
275
+ * @param body - body
276
+ * @param damping - the damping
277
+ */
278
+ function set_angular_damping(body: Opaque<"b2Body">, damping: number): void;
279
+ /**
280
+ * Set the angular velocity.
281
+ *
282
+ * @param body - body
283
+ * @param omega - the new angular velocity in radians/second.
284
+ */
285
+ function set_angular_velocity(body: Opaque<"b2Body">, omega: number): void;
286
+ /**
287
+ * Set the sleep state of the body. A sleeping body has very low CPU cost.
288
+ *
289
+ * @param body - body
290
+ * @param enable - flag set to false to put body to sleep, true to wake it.
291
+ */
292
+ function set_awake(body: Opaque<"b2Body">, enable: boolean): void;
293
+ /**
294
+ * Should this body be treated like a bullet for continuous collision detection?
295
+ *
296
+ * @param body - body
297
+ * @param enable - if true, the body will be in bullet mode
298
+ */
299
+ function set_bullet(body: Opaque<"b2Body">, enable: boolean): void;
300
+ /**
301
+ * Set this body to have fixed rotation. This causes the mass to be reset.
302
+ *
303
+ * @param body - body
304
+ * @param enable - true if the rotation should be fixed
305
+ */
306
+ function set_fixed_rotation(body: Opaque<"b2Body">, enable: boolean): void;
307
+ /**
308
+ * Set the gravity scale of the body.
309
+ *
310
+ * @param body - body
311
+ * @param scale - the scale
312
+ */
313
+ function set_gravity_scale(body: Opaque<"b2Body">, scale: number): void;
314
+ /**
315
+ * Set the linear damping of the body.
316
+ *
317
+ * @param body - body
318
+ * @param damping - the damping
319
+ */
320
+ function set_linear_damping(body: Opaque<"b2Body">, damping: number): void;
321
+ /**
322
+ * Set the linear velocity of the center of mass.
323
+ *
324
+ * @param body - body
325
+ * @param velocity - the new linear velocity of the center of mass.
326
+ */
327
+ function set_linear_velocity(body: Opaque<"b2Body">, velocity: Vector3): void;
328
+ /**
329
+ * Set the position of the body's origin and rotation.
330
+ * This breaks any contacts and wakes the other bodies.
331
+ * Manipulating a body's transform may cause non-physical behavior.
332
+ *
333
+ * @param body - body
334
+ * @param position - the world position of the body's local origin.
335
+ * @param angle - the world position of the body's local origin.
336
+ */
337
+ function set_transform(body: Opaque<"b2Body">, position: Vector3, angle: number): void;
338
+ /**
339
+ * Set the type of this body. This may alter the mass and velocity.
340
+ *
341
+ * @param body - body
342
+ * @param type - the body type
343
+ */
344
+ function set_type(body: Opaque<"b2Body">, type: (number & { readonly __brand: "b2d.body.B2_DYNAMIC_BODY" }) | (number & { readonly __brand: "b2d.body.B2_KINEMATIC_BODY" }) | (number & { readonly __brand: "b2d.body.B2_STATIC_BODY" })): void;
345
+ }
346
+ }
347
+
348
+ export {};
@@ -0,0 +1,176 @@
1
+ /** @noSelfInFile */
2
+ import type { Hash, Opaque } from "../../../src/core-types";
3
+
4
+ declare global {
5
+ /**
6
+ * Functions for manipulating buffers and streams
7
+ */
8
+ namespace buffer {
9
+ /**
10
+ * Float, single precision, 4 bytes
11
+ */
12
+ const VALUE_TYPE_FLOAT32: number & { readonly __brand: "buffer.VALUE_TYPE_FLOAT32" };
13
+ /**
14
+ * Signed integer, 2 bytes
15
+ */
16
+ const VALUE_TYPE_INT16: number & { readonly __brand: "buffer.VALUE_TYPE_INT16" };
17
+ /**
18
+ * Signed integer, 4 bytes
19
+ */
20
+ const VALUE_TYPE_INT32: number & { readonly __brand: "buffer.VALUE_TYPE_INT32" };
21
+ /**
22
+ * Signed integer, 8 bytes
23
+ */
24
+ const VALUE_TYPE_INT64: number & { readonly __brand: "buffer.VALUE_TYPE_INT64" };
25
+ /**
26
+ * Signed integer, 1 byte
27
+ */
28
+ const VALUE_TYPE_INT8: number & { readonly __brand: "buffer.VALUE_TYPE_INT8" };
29
+ /**
30
+ * Unsigned integer, 2 bytes
31
+ */
32
+ const VALUE_TYPE_UINT16: number & { readonly __brand: "buffer.VALUE_TYPE_UINT16" };
33
+ /**
34
+ * Unsigned integer, 4 bytes
35
+ */
36
+ const VALUE_TYPE_UINT32: number & { readonly __brand: "buffer.VALUE_TYPE_UINT32" };
37
+ /**
38
+ * Unsigned integer, 8 bytes
39
+ */
40
+ const VALUE_TYPE_UINT64: number & { readonly __brand: "buffer.VALUE_TYPE_UINT64" };
41
+ /**
42
+ * Unsigned integer, 1 byte
43
+ */
44
+ const VALUE_TYPE_UINT8: number & { readonly __brand: "buffer.VALUE_TYPE_UINT8" };
45
+ /**
46
+ * Copy all data streams from one buffer to another, element wise.
47
+ * Each of the source streams must have a matching stream in the
48
+ * destination buffer. The streams must match in both type and size.
49
+ * The source and destination buffer can be the same.
50
+ *
51
+ * @param dst - the destination buffer
52
+ * @param dstoffset - the offset to start copying data to
53
+ * @param src - the source data buffer
54
+ * @param srcoffset - the offset to start copying data from
55
+ * @param count - the number of elements to copy
56
+ * @example
57
+ * ```ts
58
+ * // How to copy elements (e.g. vertices) from one buffer to another
59
+ * // copy entire buffer
60
+ * buffer.copy_buffer(dstbuffer, 0, srcbuffer, 0, srcbuffer.length);
61
+ *
62
+ * // copy last 10 elements to the front of another buffer
63
+ * buffer.copy_buffer(dstbuffer, 0, srcbuffer, srcbuffer.length - 10, 10);
64
+ * ```
65
+ */
66
+ function copy_buffer(dst: Opaque<"buffer">, dstoffset: number, src: Opaque<"buffer">, srcoffset: number, count: number): void;
67
+ /**
68
+ * Copy a specified amount of data from one stream to another.
69
+ * The value type and size must match between source and destination streams.
70
+ * The source and destination streams can be the same.
71
+ *
72
+ * @param dst - the destination stream
73
+ * @param dstoffset - the offset to start copying data to (measured in value type)
74
+ * @param src - the source data stream
75
+ * @param srcoffset - the offset to start copying data from (measured in value type)
76
+ * @param count - the number of values to copy (measured in value type)
77
+ * @example
78
+ * ```ts
79
+ * // How to update a texture of a sprite:
80
+ * // copy entire stream
81
+ * const srcstream = buffer.get_stream(srcbuffer, hash("xyz"));
82
+ * const dststream = buffer.get_stream(dstbuffer, hash("xyz"));
83
+ * buffer.copy_stream(dststream, 0, srcstream, 0, srcstream.length);
84
+ * ```
85
+ */
86
+ function copy_stream(dst: Opaque<"bufferstream"> & { [index: number]: number }, dstoffset: number, src: Opaque<"bufferstream"> & { [index: number]: number }, srcoffset: number, count: number): void;
87
+ /**
88
+ * Create a new data buffer containing a specified set of streams. A data buffer
89
+ * can contain one or more streams with typed data. This is useful for managing
90
+ * compound data, for instance a vertex buffer could contain separate streams for
91
+ * vertex position, color, normal etc.
92
+ *
93
+ * @param element_count - The number of elements the buffer should hold
94
+ * @param declaration - A table where each entry (table) describes a stream
95
+ *
96
+ * - hash | string `name`: The name of the stream
97
+ *
98
+ * - constant `type`: The data type of the stream
99
+ *
100
+ * - number `count`: The number of values each element should hold
101
+ * @returns the new buffer
102
+ * @example
103
+ * ```ts
104
+ * // How to create and initialize a buffer
105
+ * export default defineScript({
106
+ * init(self) {
107
+ * const size = 128;
108
+ * self.image = buffer.create(size * size, [{ name: hash("rgb"), type: buffer.VALUE_TYPE_UINT8, count: 3 }]);
109
+ * self.imagestream = buffer.get_stream(self.image, hash("rgb"));
110
+ *
111
+ * for (let y = 0; y < self.height; y++) {
112
+ * for (let x = 0; x < self.width; x++) {
113
+ * const index = y * self.width * 3 + x * 3;
114
+ * self.imagestream[index + 0] = self.r;
115
+ * self.imagestream[index + 1] = self.g;
116
+ * self.imagestream[index + 2] = self.b;
117
+ * }
118
+ * }
119
+ * },
120
+ * });
121
+ * ```
122
+ */
123
+ function create(element_count: number, declaration: { name?: Hash | string; type?: Opaque<"constant">; count?: number }): Opaque<"buffer">;
124
+ /**
125
+ * Get a copy of all the bytes from a specified stream as a Lua string.
126
+ *
127
+ * @param buffer - the source buffer
128
+ * @param stream_name - the name of the stream
129
+ * @returns the buffer data as a Lua string
130
+ */
131
+ function get_bytes(buffer: Opaque<"buffer">, stream_name: Hash): string;
132
+ /**
133
+ * Get a named metadata entry from a buffer along with its type.
134
+ *
135
+ * @param buf - the buffer to get the metadata from
136
+ * @param metadata_name - name of the metadata entry
137
+ * @example
138
+ * ```ts
139
+ * // How to get a metadata entry from a buffer
140
+ * // retrieve a metadata entry named "somefloats" and its numeric type
141
+ * const [values, type] = buffer.get_metadata(buf, hash("somefloats"));
142
+ * if (values) print(`${values.length} values in 'somefloats'`);
143
+ * ```
144
+ */
145
+ function get_metadata(buf: Opaque<"buffer">, metadata_name: Hash | string): LuaMultiReturn<[number[] | undefined, Opaque<"constant"> | undefined]>;
146
+ /**
147
+ * Get a specified stream from a buffer.
148
+ *
149
+ * @param buffer - the buffer to get the stream from
150
+ * @param stream_name - the stream name
151
+ * @returns the data stream
152
+ */
153
+ function get_stream(buffer: Opaque<"buffer">, stream_name: Hash | string): Opaque<"bufferstream"> & { [index: number]: number };
154
+ /**
155
+ * Creates or updates a metadata array entry on a buffer.
156
+ * The value type and count given when updating the entry should match those used when first creating it.
157
+ *
158
+ * @param buf - the buffer to set the metadata on
159
+ * @param metadata_name - name of the metadata entry
160
+ * @param values - actual metadata, an array of numeric values
161
+ * @param value_type - type of values when stored
162
+ * @example
163
+ * ```ts
164
+ * // How to set a metadata entry on a buffer
165
+ * // create a new metadata entry with three floats
166
+ * buffer.set_metadata(buf, hash("somefloats"), [1.5, 3.2, 7.9], buffer.VALUE_TYPE_FLOAT32);
167
+ * // ...
168
+ * // update to a new set of values
169
+ * buffer.set_metadata(buf, hash("somefloats"), [-2.5, 10.0, 32.2], buffer.VALUE_TYPE_FLOAT32);
170
+ * ```
171
+ */
172
+ function set_metadata(buf: Opaque<"buffer">, metadata_name: Hash | string, values: number[], value_type: Opaque<"constant">): void;
173
+ }
174
+ }
175
+
176
+ export {};