@defold-typescript/types 0.5.5 → 0.7.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 (54) hide show
  1. package/README.md +2 -2
  2. package/api-targets.json +1 -1
  3. package/generated/b2d.d.ts +3 -0
  4. package/generated/buffer.d.ts +44 -38
  5. package/generated/builtin-messages.d.ts +1 -1
  6. package/generated/camera.d.ts +3 -0
  7. package/generated/collectionfactory.d.ts +47 -40
  8. package/generated/collectionproxy.d.ts +23 -18
  9. package/generated/crash.d.ts +3 -0
  10. package/generated/factory.d.ts +32 -24
  11. package/generated/go.d.ts +123 -124
  12. package/generated/graphics.d.ts +3 -0
  13. package/generated/gui.d.ts +303 -283
  14. package/generated/http.d.ts +26 -16
  15. package/generated/iac.d.ts +3 -0
  16. package/generated/iap.d.ts +6 -3
  17. package/generated/image.d.ts +30 -26
  18. package/generated/json.d.ts +36 -32
  19. package/generated/kinds/gui-script.d.ts +7 -5
  20. package/generated/kinds/render-script.d.ts +7 -5
  21. package/generated/kinds/script.d.ts +7 -5
  22. package/generated/label.d.ts +16 -9
  23. package/generated/liveupdate.d.ts +29 -26
  24. package/generated/model.d.ts +57 -45
  25. package/generated/msg.d.ts +3 -0
  26. package/generated/particlefx.d.ts +50 -34
  27. package/generated/physics.d.ts +153 -133
  28. package/generated/profiler.d.ts +45 -41
  29. package/generated/push.d.ts +5 -2
  30. package/generated/render.d.ts +410 -349
  31. package/generated/resource.d.ts +619 -572
  32. package/generated/socket.d.ts +49 -33
  33. package/generated/sound.d.ts +83 -72
  34. package/generated/sprite.d.ts +3 -0
  35. package/generated/sys.d.ts +198 -189
  36. package/generated/tilemap.d.ts +43 -39
  37. package/generated/timer.d.ts +42 -36
  38. package/generated/vmath.d.ts +22 -0
  39. package/generated/webview.d.ts +3 -0
  40. package/generated/window.d.ts +23 -17
  41. package/generated/zlib.d.ts +15 -12
  42. package/index.d.ts +3 -1
  43. package/package.json +13 -2
  44. package/scripts/fidelity-audit.ts +61 -1
  45. package/scripts/fidelity-baseline.json +10 -10
  46. package/scripts/ref-doc-delta.ts +143 -0
  47. package/scripts/regen.ts +18 -9
  48. package/src/core-types.ts +14 -0
  49. package/src/emit-dts.ts +219 -13
  50. package/src/engine-globals.d.ts +2 -0
  51. package/src/go-overloads.d.ts +43 -0
  52. package/src/index.ts +5 -0
  53. package/src/lifecycle.ts +157 -16
  54. package/src/publish-dts.ts +1 -1
package/generated/go.d.ts CHANGED
@@ -2,6 +2,11 @@
2
2
  import type { Hash, Matrix4, Opaque, Quaternion, Url, Vector, Vector3, Vector4 } from "../src/core-types";
3
3
 
4
4
  declare global {
5
+ /**
6
+ * Functions, core hooks, messages and constants for manipulation of
7
+ * game objects. The "go" namespace is accessible from game object script
8
+ * files.
9
+ */
5
10
  namespace go {
6
11
  /**
7
12
  * in-back
@@ -322,11 +327,13 @@ declare global {
322
327
  *
323
328
  * @param self - reference to the script state to be used for storing data
324
329
  * @example
325
- * ```lua
326
- * function final(self)
327
- * -- report finalization
328
- * msg.post("my_friend_instance", "im_dead", {my_stats = self.some_value})
329
- * end
330
+ * ```ts
331
+ * export default defineScript({
332
+ * final(self) {
333
+ * // report finalization
334
+ * msg.post("my_friend_instance", "im_dead", { my_stats: self.some_value });
335
+ * },
336
+ * });
330
337
  * ```
331
338
  */
332
339
  export function final(self: Opaque<"userdata">): void;
@@ -530,11 +537,13 @@ declare global {
530
537
  *
531
538
  * @param self - reference to the script state to be used for storing data
532
539
  * @example
533
- * ```lua
534
- * function init(self)
535
- * -- set up useful data
536
- * self.my_value = 1
537
- * end
540
+ * ```ts
541
+ * export default defineScript({
542
+ * init() {
543
+ * // set up useful data
544
+ * return { my_value: 1 };
545
+ * },
546
+ * });
538
547
  * ```
539
548
  */
540
549
  export function init(self: Opaque<"userdata">): void;
@@ -646,32 +655,38 @@ declare global {
646
655
  * @param action - a table containing the input data, see above for a description
647
656
  * @returns optional boolean to signal if the input should be consumed (not passed on to others) or not, default is false
648
657
  * @example
649
- * ```lua
650
- * This example demonstrates how a game object instance can be moved as a response to user input.
651
- * function init(self)
652
- * -- acquire input focus
653
- * msg.post(".", "acquire_input_focus")
654
- * -- maximum speed the instance can be moved
655
- * self.max_speed = 2
656
- * -- velocity of the instance, initially zero
657
- * self.velocity = vmath.vector3()
658
- * end
659
- *
660
- * function update(self, dt)
661
- * -- move the instance
662
- * go.set_position(go.get_position() + dt * self.velocity)
663
- * end
664
- *
665
- * function on_input(self, action_id, action)
666
- * -- check for movement input
667
- * if action_id == hash("right") then
668
- * if action.released then -- reset velocity if input was released
669
- * self.velocity = vmath.vector3()
670
- * else -- update velocity
671
- * self.velocity = vmath.vector3(action.value * self.max_speed, 0, 0)
672
- * end
673
- * end
674
- * end
658
+ * ```ts
659
+ * // This example demonstrates how a game object instance can be moved as a response to user input.
660
+ * export default defineScript({
661
+ * init() {
662
+ * // acquire input focus
663
+ * msg.post(".", "acquire_input_focus");
664
+ * return {
665
+ * // maximum speed the instance can be moved
666
+ * max_speed: 2,
667
+ * // velocity of the instance, initially zero
668
+ * velocity: vmath.vector3(),
669
+ * };
670
+ * },
671
+ *
672
+ * update(self, dt) {
673
+ * // move the instance
674
+ * go.set_position(go.get_position().add(self.velocity.mul(dt)));
675
+ * },
676
+ *
677
+ * on_input(self, action_id, action) {
678
+ * // check for movement input
679
+ * if (action_id === hash("right")) {
680
+ * if (action.released) {
681
+ * // reset velocity if input was released
682
+ * self.velocity = vmath.vector3();
683
+ * } else {
684
+ * // update velocity
685
+ * self.velocity = vmath.vector3(action.value * self.max_speed, 0, 0);
686
+ * }
687
+ * }
688
+ * },
689
+ * });
675
690
  * ```
676
691
  */
677
692
  export function on_input(self: Opaque<"userdata">, action_id: Hash, action: Record<string | number, unknown>): boolean | unknown;
@@ -686,29 +701,34 @@ declare global {
686
701
  * @param message - a table containing the message data
687
702
  * @param sender - address of the sender
688
703
  * @example
689
- * ```lua
690
- * This example demonstrates how a game object instance, called "a", can communicate with another instance, called "b". It
691
- * is assumed that both script components of the instances has id "script".
692
- * Script of instance "a":
693
- * function init(self)
694
- * -- let b know about some important data
695
- * msg.post("b#script", "my_data", {important_value = 1})
696
- * end
697
- *
698
- * Script of instance "b":
699
- * function init(self)
700
- * -- store the url of instance "a" for later use, by specifying nil as socket we
701
- * -- automatically use our own socket
702
- * self.a_url = msg.url(nil, go.get_id("a"), "script")
703
- * end
704
- *
705
- * function on_message(self, message_id, message, sender)
706
- * -- check message and sender
707
- * if message_id == hash("my_data") and sender == self.a_url then
708
- * -- use the data in some way
709
- * self.important_value = message.important_value
710
- * end
711
- * end
704
+ * ```ts
705
+ * // This example demonstrates how a game object instance, called "a", can communicate with another instance, called "b". It
706
+ * // is assumed that both script components of the instances has id "script".
707
+ *
708
+ * // a.script — Script of instance "a":
709
+ * export default defineScript({
710
+ * init() {
711
+ * // let b know about some important data
712
+ * msg.post("b#script", "my_data", { important_value: 1 });
713
+ * },
714
+ * });
715
+ *
716
+ * // b.script Script of instance "b":
717
+ * export default defineScript({
718
+ * init() {
719
+ * // store the url of instance "a" for later use, by specifying undefined as socket we
720
+ * // automatically use our own socket
721
+ * return { a_url: msg.url(undefined, go.get_id("a"), "script") };
722
+ * },
723
+ *
724
+ * on_message(self, message_id, message, sender) {
725
+ * // check message and sender
726
+ * if (message_id === hash("my_data") && sender === self.a_url) {
727
+ * // use the data in some way
728
+ * self.important_value = message.important_value;
729
+ * }
730
+ * },
731
+ * });
712
732
  * ```
713
733
  */
714
734
  export function on_message(self: Opaque<"userdata">, message_id: Hash, message: Record<string | number, unknown>, sender: Url): void;
@@ -718,69 +738,46 @@ declare global {
718
738
  *
719
739
  * @param self - reference to the script state to be used for storing data
720
740
  * @example
721
- * ```lua
722
- * This example demonstrates how to tweak the speed of a game object instance that is moved on user input.
723
- * function init(self)
724
- * -- acquire input focus
725
- * msg.post(".", "acquire_input_focus")
726
- * -- maximum speed the instance can be moved, this value is tweaked in the on_reload function below
727
- * self.max_speed = 2
728
- * -- velocity of the instance, initially zero
729
- * self.velocity = vmath.vector3()
730
- * end
731
- *
732
- * function update(self, dt)
733
- * -- move the instance
734
- * go.set_position(go.get_position() + dt * self.velocity)
735
- * end
736
- *
737
- * function on_input(self, action_id, action)
738
- * -- check for movement input
739
- * if action_id == hash("right") then
740
- * if action.released then -- reset velocity if input was released
741
- * self.velocity = vmath.vector3()
742
- * else -- update velocity
743
- * self.velocity = vmath.vector3(action.value * self.max_speed, 0, 0)
744
- * end
745
- * end
746
- * end
747
- *
748
- * function on_reload(self)
749
- * -- edit this value and reload the script component
750
- * self.max_speed = 100
751
- * end
752
- * ```
753
- */
754
- export function on_reload(self: Opaque<"userdata">): void;
755
- /**
756
- * This function defines a property which can then be used in the script through the self-reference.
757
- * The properties defined this way are automatically exposed in the editor in game objects and collections which use the script.
758
- * Note that you can only use this function outside any callback-functions like init and update.
759
- *
760
- * @param name - the id of the property
761
- * @param value - default value of the property. In the case of a url, only the empty constructor msg.url() is allowed. In the case of a resource one of the resource constructors (eg resource.atlas(), resource.font() etc) is expected.
762
- * @example
763
741
  * ```ts
764
- * // This example defines a property "health" in a script. The health is decreased
765
- * // whenever someone sends a "take_damage" message to the script.
766
- * go.property("health", 100);
767
- *
742
+ * // This example demonstrates how to tweak the speed of a game object instance that is moved on user input.
768
743
  * export default defineScript({
769
- * init(self) {
770
- * // prints 100 to the output
771
- * print(self.health);
744
+ * init() {
745
+ * // acquire input focus
746
+ * msg.post(".", "acquire_input_focus");
747
+ * return {
748
+ * // maximum speed the instance can be moved, this value is tweaked in the on_reload function below
749
+ * max_speed: 2,
750
+ * // velocity of the instance, initially zero
751
+ * velocity: vmath.vector3(),
752
+ * };
772
753
  * },
773
754
  *
774
- * on_message(self, message_id, message) {
775
- * if (message_id === hash("take_damage")) {
776
- * self.health = self.health - message.damage;
777
- * print(`Ouch! My health is now: ${self.health}`);
755
+ * update(self, dt) {
756
+ * // move the instance
757
+ * go.set_position(go.get_position().add(self.velocity.mul(dt)));
758
+ * },
759
+ *
760
+ * on_input(self, action_id, action) {
761
+ * // check for movement input
762
+ * if (action_id === hash("right")) {
763
+ * if (action.released) {
764
+ * // reset velocity if input was released
765
+ * self.velocity = vmath.vector3();
766
+ * } else {
767
+ * // update velocity
768
+ * self.velocity = vmath.vector3(action.value * self.max_speed, 0, 0);
769
+ * }
778
770
  * }
779
771
  * },
772
+ *
773
+ * on_reload(self) {
774
+ * // edit this value and reload the script component
775
+ * self.max_speed = 100;
776
+ * },
780
777
  * });
781
778
  * ```
782
779
  */
783
- export function property(name: string, value: number | Hash | Url | Vector3 | Vector4 | Quaternion | Opaque<"resource"> | boolean): void;
780
+ export function on_reload(self: Opaque<"userdata">): void;
784
781
  /**
785
782
  * Sets the parent for a game object instance. This means that the instance will exist in the geometrical space of its parent,
786
783
  * like a basic transformation hierarchy or scene graph. If no parent is specified, the instance will be detached from any parent and exist in world
@@ -884,17 +881,19 @@ declare global {
884
881
  * @param self - reference to the script state to be used for storing data
885
882
  * @param dt - the time-step of the frame update
886
883
  * @example
887
- * ```lua
888
- * This example demonstrates how to move a game object instance through the script component:
889
- * function init(self)
890
- * -- set initial velocity to be 1 along world x-axis
891
- * self.my_velocity = vmath.vector3(1, 0, 0)
892
- * end
893
- *
894
- * function update(self, dt)
895
- * -- move the game object instance
896
- * go.set_position(go.get_position() + dt * self.my_velocity)
897
- * end
884
+ * ```ts
885
+ * // This example demonstrates how to move a game object instance through the script component:
886
+ * export default defineScript({
887
+ * init() {
888
+ * // set initial velocity to be 1 along world x-axis
889
+ * return { my_velocity: vmath.vector3(1, 0, 0) };
890
+ * },
891
+ *
892
+ * update(self, dt) {
893
+ * // move the game object instance
894
+ * go.set_position(go.get_position().add(self.my_velocity.mul(dt)));
895
+ * },
896
+ * });
898
897
  * ```
899
898
  */
900
899
  export function update(self: Opaque<"userdata">, dt: number): void;
@@ -1,5 +1,8 @@
1
1
  /** @noSelfInFile */
2
2
  declare global {
3
+ /**
4
+ * Graphics functions and constants.
5
+ */
3
6
  namespace graphics {
4
7
  const BLEND_FACTOR_CONSTANT_ALPHA: number & { readonly __brand: "graphics.BLEND_FACTOR_CONSTANT_ALPHA" };
5
8
  const BLEND_FACTOR_CONSTANT_COLOR: number & { readonly __brand: "graphics.BLEND_FACTOR_CONSTANT_COLOR" };