@defold-typescript/types 0.38.0 → 0.40.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 (109) hide show
  1. package/api-availability.json +117 -0
  2. package/api-signatures.json +586 -480
  3. package/examples/translations.json +356 -180
  4. package/generated/b2d_body.d.ts +7 -4
  5. package/generated/b2d_shape.d.ts +23 -1
  6. package/generated/buffer.d.ts +34 -19
  7. package/generated/camera.d.ts +3 -2
  8. package/generated/collectionfactory.d.ts +17 -12
  9. package/generated/collectionproxy.d.ts +2 -2
  10. package/generated/compute.d.ts +1 -1
  11. package/generated/factory.d.ts +2 -1
  12. package/generated/go.d.ts +150 -91
  13. package/generated/graphics.d.ts +54 -0
  14. package/generated/gui.d.ts +117 -71
  15. package/generated/html5.d.ts +4 -2
  16. package/generated/http.d.ts +8 -2
  17. package/generated/image.d.ts +24 -15
  18. package/generated/kinds/gui-script.d.ts +1 -0
  19. package/generated/kinds/render-script.d.ts +1 -0
  20. package/generated/kinds/script.d.ts +1 -0
  21. package/generated/material.d.ts +1 -1
  22. package/generated/model.d.ts +41 -7
  23. package/generated/particlefx.d.ts +1 -1
  24. package/generated/physics.d.ts +29 -20
  25. package/generated/profiler.d.ts +10 -3
  26. package/generated/render.d.ts +293 -111
  27. package/generated/resource.d.ts +243 -226
  28. package/generated/socket.d.ts +33 -18
  29. package/generated/sound.d.ts +6 -5
  30. package/generated/sprite.d.ts +9 -1
  31. package/generated/sys.d.ts +44 -27
  32. package/generated/tilemap.d.ts +25 -19
  33. package/generated/timer.d.ts +33 -24
  34. package/generated/versions/defold-1.12.4/buffer.d.ts +34 -19
  35. package/generated/versions/defold-1.12.4/camera.d.ts +3 -2
  36. package/generated/versions/defold-1.12.4/collectionfactory.d.ts +17 -12
  37. package/generated/versions/defold-1.12.4/collectionproxy.d.ts +1 -1
  38. package/generated/versions/defold-1.12.4/factory.d.ts +2 -1
  39. package/generated/versions/defold-1.12.4/go.d.ts +150 -91
  40. package/generated/versions/defold-1.12.4/graphics.d.ts +2 -0
  41. package/generated/versions/defold-1.12.4/gui.d.ts +109 -69
  42. package/generated/versions/defold-1.12.4/html5.d.ts +4 -2
  43. package/generated/versions/defold-1.12.4/http.d.ts +8 -2
  44. package/generated/versions/defold-1.12.4/image.d.ts +24 -15
  45. package/generated/versions/defold-1.12.4/index.d.ts +1 -0
  46. package/generated/versions/defold-1.12.4/model.d.ts +41 -7
  47. package/generated/versions/defold-1.12.4/particlefx.d.ts +1 -1
  48. package/generated/versions/defold-1.12.4/physics.d.ts +29 -20
  49. package/generated/versions/defold-1.12.4/profiler.d.ts +10 -3
  50. package/generated/versions/defold-1.12.4/render.d.ts +292 -110
  51. package/generated/versions/defold-1.12.4/resource.d.ts +243 -226
  52. package/generated/versions/defold-1.12.4/socket.d.ts +33 -18
  53. package/generated/versions/defold-1.12.4/sound.d.ts +6 -5
  54. package/generated/versions/defold-1.12.4/sprite.d.ts +9 -1
  55. package/generated/versions/defold-1.12.4/sys.d.ts +44 -27
  56. package/generated/versions/defold-1.12.4/tilemap.d.ts +25 -19
  57. package/generated/versions/defold-1.12.4/timer.d.ts +33 -24
  58. package/generated/versions/defold-1.12.4/vmath.d.ts +18 -10
  59. package/generated/versions/defold-1.12.4/window.d.ts +5 -3
  60. package/generated/versions/defold-1.13.0/b2d_body.d.ts +7 -4
  61. package/generated/versions/defold-1.13.0/b2d_shape.d.ts +23 -1
  62. package/generated/versions/defold-1.13.0/buffer.d.ts +34 -19
  63. package/generated/versions/defold-1.13.0/camera.d.ts +3 -2
  64. package/generated/versions/defold-1.13.0/collectionfactory.d.ts +17 -12
  65. package/generated/versions/defold-1.13.0/collectionproxy.d.ts +1 -1
  66. package/generated/versions/defold-1.13.0/compute.d.ts +1 -1
  67. package/generated/versions/defold-1.13.0/factory.d.ts +2 -1
  68. package/generated/versions/defold-1.13.0/go.d.ts +150 -91
  69. package/generated/versions/defold-1.13.0/graphics.d.ts +50 -0
  70. package/generated/versions/defold-1.13.0/gui.d.ts +109 -69
  71. package/generated/versions/defold-1.13.0/html5.d.ts +4 -2
  72. package/generated/versions/defold-1.13.0/http.d.ts +8 -2
  73. package/generated/versions/defold-1.13.0/image.d.ts +24 -15
  74. package/generated/versions/defold-1.13.0/index.d.ts +1 -0
  75. package/generated/versions/defold-1.13.0/material.d.ts +1 -1
  76. package/generated/versions/defold-1.13.0/model.d.ts +41 -7
  77. package/generated/versions/defold-1.13.0/particlefx.d.ts +1 -1
  78. package/generated/versions/defold-1.13.0/physics.d.ts +29 -20
  79. package/generated/versions/defold-1.13.0/profiler.d.ts +10 -3
  80. package/generated/versions/defold-1.13.0/render.d.ts +293 -111
  81. package/generated/versions/defold-1.13.0/resource.d.ts +243 -226
  82. package/generated/versions/defold-1.13.0/socket.d.ts +33 -18
  83. package/generated/versions/defold-1.13.0/sound.d.ts +6 -5
  84. package/generated/versions/defold-1.13.0/sprite.d.ts +9 -1
  85. package/generated/versions/defold-1.13.0/sys.d.ts +44 -27
  86. package/generated/versions/defold-1.13.0/tilemap.d.ts +25 -19
  87. package/generated/versions/defold-1.13.0/timer.d.ts +33 -24
  88. package/generated/versions/defold-1.13.0/vmath.d.ts +18 -10
  89. package/generated/versions/defold-1.13.0/window.d.ts +5 -3
  90. package/generated/vmath.d.ts +18 -10
  91. package/generated/window.d.ts +5 -3
  92. package/index.d.ts +1 -0
  93. package/package.json +2 -1
  94. package/scripts/generate-api-signatures.ts +2 -1
  95. package/scripts/prose-constants.ts +96 -0
  96. package/scripts/regen.ts +6 -2
  97. package/src/api-doc.ts +8 -0
  98. package/src/component-properties.d.ts +33 -0
  99. package/src/core-types.ts +4 -2
  100. package/src/custom-messages.d.ts +4 -3
  101. package/src/doc-comment.ts +247 -43
  102. package/src/emit-dts.ts +958 -57
  103. package/src/engine-globals.d.ts +2 -2
  104. package/src/example-store.ts +26 -0
  105. package/src/go-overloads.d.ts +11 -10
  106. package/src/index.ts +9 -0
  107. package/src/param-correction-provenance.ts +67 -0
  108. package/src/render-overloads.d.ts +15 -17
  109. package/src/script-api.ts +3 -1
@@ -1,11 +1,25 @@
1
1
  /** @noSelfInFile */
2
- import type { Hash, Opaque, Quaternion, Url, Vector, Vector3, Vector4 } from "../src/core-types";
2
+ import type { Hash, Matrix4, Opaque, Quaternion, Url, Vector, Vector3, Vector4 } from "../src/core-types";
3
3
 
4
4
  declare global {
5
5
  /**
6
6
  * GUI API documentation
7
7
  */
8
8
  namespace gui {
9
+ type AdjustMode = typeof gui.ADJUST_FIT | typeof gui.ADJUST_ZOOM | typeof gui.ADJUST_STRETCH;
10
+ type BlendMode = typeof gui.BLEND_ALPHA | typeof gui.BLEND_ADD | typeof gui.BLEND_ADD_ALPHA | typeof gui.BLEND_MULT | typeof gui.BLEND_SCREEN;
11
+ type ClippingMode = typeof gui.CLIPPING_MODE_NONE | typeof gui.CLIPPING_MODE_STENCIL;
12
+ type Easing = typeof gui.EASING_INBACK | typeof gui.EASING_INBOUNCE | typeof gui.EASING_INCIRC | typeof gui.EASING_INCUBIC | typeof gui.EASING_INELASTIC | typeof gui.EASING_INEXPO | typeof gui.EASING_INOUTBACK | typeof gui.EASING_INOUTBOUNCE | typeof gui.EASING_INOUTCIRC | typeof gui.EASING_INOUTCUBIC | typeof gui.EASING_INOUTELASTIC | typeof gui.EASING_INOUTEXPO | typeof gui.EASING_INOUTQUAD | typeof gui.EASING_INOUTQUART | typeof gui.EASING_INOUTQUINT | typeof gui.EASING_INOUTSINE | typeof gui.EASING_INQUAD | typeof gui.EASING_INQUART | typeof gui.EASING_INQUINT | typeof gui.EASING_INSINE | typeof gui.EASING_LINEAR | typeof gui.EASING_OUTBACK | typeof gui.EASING_OUTBOUNCE | typeof gui.EASING_OUTCIRC | typeof gui.EASING_OUTCUBIC | typeof gui.EASING_OUTELASTIC | typeof gui.EASING_OUTEXPO | typeof gui.EASING_OUTINBACK | typeof gui.EASING_OUTINBOUNCE | typeof gui.EASING_OUTINCIRC | typeof gui.EASING_OUTINCUBIC | typeof gui.EASING_OUTINELASTIC | typeof gui.EASING_OUTINEXPO | typeof gui.EASING_OUTINQUAD | typeof gui.EASING_OUTINQUART | typeof gui.EASING_OUTINQUINT | typeof gui.EASING_OUTINSINE | typeof gui.EASING_OUTQUAD | typeof gui.EASING_OUTQUART | typeof gui.EASING_OUTQUINT | typeof gui.EASING_OUTSINE;
13
+ type KeyboardType = typeof gui.KEYBOARD_TYPE_DEFAULT | typeof gui.KEYBOARD_TYPE_EMAIL | typeof gui.KEYBOARD_TYPE_NUMBER_PAD | typeof gui.KEYBOARD_TYPE_PASSWORD;
14
+ type NodeType = typeof gui.TYPE_BOX | typeof gui.TYPE_TEXT | typeof gui.TYPE_PIE | typeof gui.TYPE_PARTICLEFX | typeof gui.TYPE_CUSTOM;
15
+ type PieBounds = typeof gui.PIEBOUNDS_RECTANGLE | typeof gui.PIEBOUNDS_ELLIPSE;
16
+ type Pivot = typeof gui.PIVOT_CENTER | typeof gui.PIVOT_N | typeof gui.PIVOT_NE | typeof gui.PIVOT_E | typeof gui.PIVOT_SE | typeof gui.PIVOT_S | typeof gui.PIVOT_SW | typeof gui.PIVOT_W | typeof gui.PIVOT_NW;
17
+ type Playback = typeof gui.PLAYBACK_ONCE_FORWARD | typeof gui.PLAYBACK_ONCE_BACKWARD | typeof gui.PLAYBACK_ONCE_PINGPONG | typeof gui.PLAYBACK_LOOP_FORWARD | typeof gui.PLAYBACK_LOOP_BACKWARD | typeof gui.PLAYBACK_LOOP_PINGPONG;
18
+ type Property = typeof gui.PROP_POSITION | typeof gui.PROP_ROTATION | typeof gui.PROP_EULER | typeof gui.PROP_SCALE | typeof gui.PROP_COLOR | typeof gui.PROP_OUTLINE | typeof gui.PROP_SHADOW | typeof gui.PROP_SIZE | typeof gui.PROP_FILL_ANGLE | typeof gui.PROP_INNER_RADIUS | typeof gui.PROP_LEADING | typeof gui.PROP_TRACKING | typeof gui.PROP_SLICE9;
19
+ type SafeAreaMode = typeof gui.SAFE_AREA_NONE | typeof gui.SAFE_AREA_LONG | typeof gui.SAFE_AREA_SHORT | typeof gui.SAFE_AREA_BOTH;
20
+ type SizeMode = typeof gui.SIZE_MODE_MANUAL | typeof gui.SIZE_MODE_AUTO;
21
+ type XAnchor = typeof gui.ANCHOR_NONE | typeof gui.ANCHOR_LEFT | typeof gui.ANCHOR_RIGHT;
22
+ type YAnchor = typeof gui.ANCHOR_NONE | typeof gui.ANCHOR_TOP | typeof gui.ANCHOR_BOTTOM;
9
23
  /**
10
24
  * Adjust mode is used when the screen resolution differs from the project settings.
11
25
  * The fit mode ensures that the entire node is visible in the adjusted gui scene.
@@ -522,19 +536,24 @@ declare global {
522
536
  *
523
537
  * - `gui.PLAYBACK_LOOP_PINGPONG`
524
538
  * @example
539
+ * How to start a simple color animation, where the node fades in to white during 0.5 seconds:
525
540
  * ```ts
526
541
  * // How to start a simple color animation, where the node fades in to white during 0.5 seconds:
542
+ * const node = gui.get_node("my_node");
527
543
  * gui.set_color(node, vmath.vector4(0, 0, 0, 0)); // node is fully transparent
528
544
  * gui.animate(node, gui.PROP_COLOR, vmath.vector4(1, 1, 1, 1), gui.EASING_INOUTQUAD, 0.5); // start animation
529
- *
545
+ * ```
546
+ * @example
547
+ * How to start a sequenced animation where the node fades in to white during 0.5 seconds, stays visible for 2 seconds and then fades out:
548
+ * ```ts
530
549
  * // How to start a sequenced animation where the node fades in to white during 0.5
531
550
  * // seconds, stays visible for 2 seconds and then fades out:
532
- * function on_animation_done(self, node) {
551
+ * function on_animation_done(self: unknown, node: unknown) {
533
552
  * // fade out node, but wait 2 seconds before the animation starts
534
- * gui.animate(node, gui.PROP_COLOR, vmath.vector4(0, 0, 0, 0), gui.EASING_OUTQUAD, 0.5, 2.0);
553
+ * gui.animate(node as Opaque<"node">, gui.PROP_COLOR, vmath.vector4(0, 0, 0, 0), gui.EASING_OUTQUAD, 0.5, 2.0);
535
554
  * }
536
555
  *
537
- * export default defineScript({
556
+ * export default defineGuiScript({
538
557
  * init(self) {
539
558
  * // fetch the node we want to animate
540
559
  * const my_node = gui.get_node("my_node");
@@ -544,9 +563,12 @@ declare global {
544
563
  * gui.animate(my_node, gui.PROP_COLOR, vmath.vector4(1, 1, 1, 1), gui.EASING_INOUTQUAD, 0.5, 0.0, on_animation_done);
545
564
  * },
546
565
  * });
547
- *
566
+ * ```
567
+ * @example
568
+ * How to animate a node's y position using a crazy custom easing curve:
569
+ * ```ts
548
570
  * // How to animate a node's y position using a crazy custom easing curve:
549
- * export default defineScript({
571
+ * export default defineGuiScript({
550
572
  * init(self) {
551
573
  * const values = [
552
574
  * 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
@@ -561,7 +583,7 @@ declare global {
561
583
  * });
562
584
  * ```
563
585
  */
564
- function animate(node: Opaque<"node">, property: string | number & { readonly __brand: "gui.PROP_POSITION" } | number & { readonly __brand: "gui.PROP_ROTATION" } | number & { readonly __brand: "gui.PROP_EULER" } | number & { readonly __brand: "gui.PROP_SCALE" } | number & { readonly __brand: "gui.PROP_COLOR" } | number & { readonly __brand: "gui.PROP_OUTLINE" } | number & { readonly __brand: "gui.PROP_SHADOW" } | number & { readonly __brand: "gui.PROP_SIZE" } | number & { readonly __brand: "gui.PROP_FILL_ANGLE" } | number & { readonly __brand: "gui.PROP_INNER_RADIUS" } | number & { readonly __brand: "gui.PROP_LEADING" } | number & { readonly __brand: "gui.PROP_TRACKING" } | number & { readonly __brand: "gui.PROP_SLICE9" }, to: number | Vector3 | Vector4 | Quaternion, easing: number & { readonly __brand: "gui.EASING_INBACK" } | number & { readonly __brand: "gui.EASING_INBOUNCE" } | number & { readonly __brand: "gui.EASING_INCIRC" } | number & { readonly __brand: "gui.EASING_INCUBIC" } | number & { readonly __brand: "gui.EASING_INELASTIC" } | number & { readonly __brand: "gui.EASING_INEXPO" } | number & { readonly __brand: "gui.EASING_INOUTBACK" } | number & { readonly __brand: "gui.EASING_INOUTBOUNCE" } | number & { readonly __brand: "gui.EASING_INOUTCIRC" } | number & { readonly __brand: "gui.EASING_INOUTCUBIC" } | number & { readonly __brand: "gui.EASING_INOUTELASTIC" } | number & { readonly __brand: "gui.EASING_INOUTEXPO" } | number & { readonly __brand: "gui.EASING_INOUTQUAD" } | number & { readonly __brand: "gui.EASING_INOUTQUART" } | number & { readonly __brand: "gui.EASING_INOUTQUINT" } | number & { readonly __brand: "gui.EASING_INOUTSINE" } | number & { readonly __brand: "gui.EASING_INQUAD" } | number & { readonly __brand: "gui.EASING_INQUART" } | number & { readonly __brand: "gui.EASING_INQUINT" } | number & { readonly __brand: "gui.EASING_INSINE" } | number & { readonly __brand: "gui.EASING_LINEAR" } | number & { readonly __brand: "gui.EASING_OUTBACK" } | number & { readonly __brand: "gui.EASING_OUTBOUNCE" } | number & { readonly __brand: "gui.EASING_OUTCIRC" } | number & { readonly __brand: "gui.EASING_OUTCUBIC" } | number & { readonly __brand: "gui.EASING_OUTELASTIC" } | number & { readonly __brand: "gui.EASING_OUTEXPO" } | number & { readonly __brand: "gui.EASING_OUTINBACK" } | number & { readonly __brand: "gui.EASING_OUTINBOUNCE" } | number & { readonly __brand: "gui.EASING_OUTINCIRC" } | number & { readonly __brand: "gui.EASING_OUTINCUBIC" } | number & { readonly __brand: "gui.EASING_OUTINELASTIC" } | number & { readonly __brand: "gui.EASING_OUTINEXPO" } | number & { readonly __brand: "gui.EASING_OUTINQUAD" } | number & { readonly __brand: "gui.EASING_OUTINQUART" } | number & { readonly __brand: "gui.EASING_OUTINQUINT" } | number & { readonly __brand: "gui.EASING_OUTINSINE" } | number & { readonly __brand: "gui.EASING_OUTQUAD" } | number & { readonly __brand: "gui.EASING_OUTQUART" } | number & { readonly __brand: "gui.EASING_OUTQUINT" } | number & { readonly __brand: "gui.EASING_OUTSINE" } | Vector, duration: number, delay?: number, complete_function?: (self: unknown, node: unknown) => void, playback?: number & { readonly __brand: "gui.PLAYBACK_ONCE_FORWARD" } | number & { readonly __brand: "gui.PLAYBACK_ONCE_BACKWARD" } | number & { readonly __brand: "gui.PLAYBACK_ONCE_PINGPONG" } | number & { readonly __brand: "gui.PLAYBACK_LOOP_FORWARD" } | number & { readonly __brand: "gui.PLAYBACK_LOOP_BACKWARD" } | number & { readonly __brand: "gui.PLAYBACK_LOOP_PINGPONG" }): void;
586
+ function animate(node: Opaque<"node">, property: string | gui.Property, to: number | Vector3 | Vector4 | Quaternion, easing: gui.Easing | Vector, duration: number, delay?: number, complete_function?: (self: unknown, node: unknown) => void, playback?: gui.Playback): void;
565
587
  /**
566
588
  * If one or more animations of the specified node is currently running (started by `gui.animate`), they will immediately be canceled.
567
589
  *
@@ -600,21 +622,21 @@ declare global {
600
622
  * const node = gui.get_node("my_node");
601
623
  * // animate to new position
602
624
  * const pos = vmath.vector3(100, 100, 0);
603
- * gui.animate(node, "position", pos, go.EASING_LINEAR, 2);
625
+ * gui.animate(node, "position", pos, gui.EASING_LINEAR, 2);
604
626
  * // ...
605
627
  * // cancel animation of the x component.
606
628
  * gui.cancel_animations(node, "position.x");
607
629
  *
608
630
  * // Cancels all property animations on a node in a single call:
609
631
  * // animate to new position and scale
610
- * gui.animate(node, "position", vmath.vector3(100, 100, 0), go.EASING_LINEAR, 5);
611
- * gui.animate(node, "scale", vmath.vector3(0.5), go.EASING_LINEAR, 5);
632
+ * gui.animate(node, "position", vmath.vector3(100, 100, 0), gui.EASING_LINEAR, 5);
633
+ * gui.animate(node, "scale", vmath.vector3(0.5), gui.EASING_LINEAR, 5);
612
634
  * // ...
613
635
  * // cancel positioning and scaling at once
614
636
  * gui.cancel_animations(node);
615
637
  * ```
616
638
  */
617
- function cancel_animations(node: Opaque<"node">, property?: string | number & { readonly __brand: "gui.PROP_POSITION" } | number & { readonly __brand: "gui.PROP_ROTATION" } | number & { readonly __brand: "gui.PROP_EULER" } | number & { readonly __brand: "gui.PROP_SCALE" } | number & { readonly __brand: "gui.PROP_COLOR" } | number & { readonly __brand: "gui.PROP_OUTLINE" } | number & { readonly __brand: "gui.PROP_SHADOW" } | number & { readonly __brand: "gui.PROP_SIZE" } | number & { readonly __brand: "gui.PROP_FILL_ANGLE" } | number & { readonly __brand: "gui.PROP_INNER_RADIUS" } | number & { readonly __brand: "gui.PROP_LEADING" } | number & { readonly __brand: "gui.PROP_TRACKING" } | number & { readonly __brand: "gui.PROP_SLICE9" }): void;
639
+ function cancel_animations(node: Opaque<"node">, property?: string | gui.Property): void;
618
640
  /**
619
641
  * Cancels any running flipbook animation on the specified node.
620
642
  *
@@ -664,7 +686,7 @@ declare global {
664
686
  * @param texture - texture id
665
687
  * @example
666
688
  * ```ts
667
- * export default defineScript({
689
+ * export default defineGuiScript({
668
690
  * init(self) {
669
691
  * // Create a texture.
670
692
  * if (gui.new_texture("temp_tx", 10, 10, "rgb", "\0".repeat(10 * 10 * 3))) {
@@ -689,6 +711,10 @@ declare global {
689
711
  * @example
690
712
  * ```ts
691
713
  * export default defineScript({
714
+ * init() {
715
+ * return { some_value: 0 };
716
+ * },
717
+ *
692
718
  * final(self) {
693
719
  * // report finalization
694
720
  * msg.post("my_friend_instance", "im_dead", { my_stats: self.some_value });
@@ -736,7 +762,7 @@ declare global {
736
762
  * @param node - node to get the property for
737
763
  * @param property - the property to retrieve
738
764
  * @param options - optional options table (only applicable for material constants)
739
- * - `index` number index into array property (1 based)
765
+ * - `index` number zero-based index into array property; the transpiler emits Defold's 1-based index
740
766
  * @example
741
767
  * ```ts
742
768
  * // Get properties on existing nodes:
@@ -744,7 +770,7 @@ declare global {
744
770
  * const node_position = gui.get(node, "position");
745
771
  * ```
746
772
  */
747
- function get(node: Opaque<"node">, property: string | Hash | number & { readonly __brand: "gui.PROP_POSITION" } | number & { readonly __brand: "gui.PROP_ROTATION" } | number & { readonly __brand: "gui.PROP_EULER" } | number & { readonly __brand: "gui.PROP_SCALE" } | number & { readonly __brand: "gui.PROP_COLOR" } | number & { readonly __brand: "gui.PROP_OUTLINE" } | number & { readonly __brand: "gui.PROP_SHADOW" } | number & { readonly __brand: "gui.PROP_SIZE" } | number & { readonly __brand: "gui.PROP_FILL_ANGLE" } | number & { readonly __brand: "gui.PROP_INNER_RADIUS" } | number & { readonly __brand: "gui.PROP_LEADING" } | number & { readonly __brand: "gui.PROP_TRACKING" } | number & { readonly __brand: "gui.PROP_SLICE9" }, options?: { index?: number }): unknown;
773
+ function get(node: Opaque<"node">, property: string | Hash | gui.Property, options?: { index?: number }): unknown;
748
774
  /**
749
775
  * Returns the adjust mode of a node.
750
776
  * The adjust mode defines how the node will adjust itself to screen
@@ -759,7 +785,7 @@ declare global {
759
785
  *
760
786
  * - `gui.ADJUST_STRETCH`
761
787
  */
762
- function get_adjust_mode(node: Opaque<"node">): number & { readonly __brand: "gui.ADJUST_FIT" } | number & { readonly __brand: "gui.ADJUST_ZOOM" } | number & { readonly __brand: "gui.ADJUST_STRETCH" };
788
+ function get_adjust_mode(node: Opaque<"node">): gui.AdjustMode;
763
789
  /**
764
790
  * gets the node alpha
765
791
  *
@@ -784,7 +810,7 @@ declare global {
784
810
  *
785
811
  * - `gui.BLEND_SCREEN`
786
812
  */
787
- function get_blend_mode(node: Opaque<"node">): number & { readonly __brand: "gui.BLEND_ALPHA" } | number & { readonly __brand: "gui.BLEND_ADD" } | number & { readonly __brand: "gui.BLEND_ADD_ALPHA" } | number & { readonly __brand: "gui.BLEND_MULT" } | number & { readonly __brand: "gui.BLEND_SCREEN" };
813
+ function get_blend_mode(node: Opaque<"node">): gui.BlendMode;
788
814
  /**
789
815
  * If node is set as an inverted clipping node, it will clip anything inside as opposed to outside.
790
816
  *
@@ -802,7 +828,7 @@ declare global {
802
828
  *
803
829
  * - `gui.CLIPPING_MODE_STENCIL`
804
830
  */
805
- function get_clipping_mode(node: Opaque<"node">): number & { readonly __brand: "gui.CLIPPING_MODE_NONE" } | number & { readonly __brand: "gui.CLIPPING_MODE_STENCIL" };
831
+ function get_clipping_mode(node: Opaque<"node">): gui.ClippingMode;
806
832
  /**
807
833
  * If node is set as visible clipping node, it will be shown as well as clipping. Otherwise, it will only clip but not show visually.
808
834
  *
@@ -884,7 +910,7 @@ declare global {
884
910
  * @example
885
911
  * ```ts
886
912
  * // Get the text metrics for a text
887
- * export default defineScript({
913
+ * export default defineGuiScript({
888
914
  * init(self) {
889
915
  * const node = gui.get_node("name");
890
916
  * const font_name = gui.get_font(node);
@@ -1028,7 +1054,7 @@ declare global {
1028
1054
  *
1029
1055
  * - `gui.PIEBOUNDS_ELLIPSE`
1030
1056
  */
1031
- function get_outer_bounds(node: Opaque<"node">): number & { readonly __brand: "gui.PIEBOUNDS_RECTANGLE" } | number & { readonly __brand: "gui.PIEBOUNDS_ELLIPSE" };
1057
+ function get_outer_bounds(node: Opaque<"node">): gui.PieBounds;
1032
1058
  /**
1033
1059
  * Returns the outline color of the supplied node.
1034
1060
  * See gui.get_color for info how vectors encode color values.
@@ -1084,7 +1110,7 @@ declare global {
1084
1110
  *
1085
1111
  * - `gui.PIVOT_NW`
1086
1112
  */
1087
- function get_pivot(node: Opaque<"node">): number & { readonly __brand: "gui.PIVOT_CENTER" } | number & { readonly __brand: "gui.PIVOT_N" } | number & { readonly __brand: "gui.PIVOT_NE" } | number & { readonly __brand: "gui.PIVOT_E" } | number & { readonly __brand: "gui.PIVOT_SE" } | number & { readonly __brand: "gui.PIVOT_S" } | number & { readonly __brand: "gui.PIVOT_SW" } | number & { readonly __brand: "gui.PIVOT_W" } | number & { readonly __brand: "gui.PIVOT_NW" };
1113
+ function get_pivot(node: Opaque<"node">): gui.Pivot;
1088
1114
  /**
1089
1115
  * Returns the position of the supplied node.
1090
1116
  *
@@ -1146,7 +1172,7 @@ declare global {
1146
1172
  *
1147
1173
  * - `gui.SIZE_MODE_AUTO`
1148
1174
  */
1149
- function get_size_mode(node: Opaque<"node">): number & { readonly __brand: "gui.SIZE_MODE_MANUAL" } | number & { readonly __brand: "gui.SIZE_MODE_AUTO" };
1175
+ function get_size_mode(node: Opaque<"node">): gui.SizeMode;
1150
1176
  /**
1151
1177
  * Returns the slice9 configuration values for the node.
1152
1178
  *
@@ -1189,7 +1215,7 @@ declare global {
1189
1215
  *
1190
1216
  * @param node - node from which to get the type
1191
1217
  */
1192
- function get_type(node: Opaque<"node">): LuaMultiReturn<[number & { readonly __brand: "gui.TYPE_BOX" } | number & { readonly __brand: "gui.TYPE_TEXT" } | number & { readonly __brand: "gui.TYPE_PIE" } | number & { readonly __brand: "gui.TYPE_PARTICLEFX" } | number & { readonly __brand: "gui.TYPE_CUSTOM" }, number | undefined]>;
1218
+ function get_type(node: Opaque<"node">): LuaMultiReturn<[gui.NodeType, number | undefined]>;
1193
1219
  /**
1194
1220
  * Returns `true` if a node is visible and `false` if it's not.
1195
1221
  * Invisible nodes are not rendered.
@@ -1216,7 +1242,7 @@ declare global {
1216
1242
  *
1217
1243
  * - `gui.ANCHOR_RIGHT`
1218
1244
  */
1219
- function get_xanchor(node: Opaque<"node">): number & { readonly __brand: "gui.ANCHOR_NONE" } | number & { readonly __brand: "gui.ANCHOR_LEFT" } | number & { readonly __brand: "gui.ANCHOR_RIGHT" };
1245
+ function get_xanchor(node: Opaque<"node">): gui.XAnchor;
1220
1246
  /**
1221
1247
  * The y-anchor specifies how the node is moved when the game is run in a different resolution.
1222
1248
  *
@@ -1229,7 +1255,7 @@ declare global {
1229
1255
  *
1230
1256
  * - `gui.ANCHOR_BOTTOM`
1231
1257
  */
1232
- function get_yanchor(node: Opaque<"node">): number & { readonly __brand: "gui.ANCHOR_NONE" } | number & { readonly __brand: "gui.ANCHOR_TOP" } | number & { readonly __brand: "gui.ANCHOR_BOTTOM" };
1258
+ function get_yanchor(node: Opaque<"node">): gui.YAnchor;
1233
1259
  /**
1234
1260
  * Hides the on-display touch keyboard on the device.
1235
1261
  */
@@ -1329,7 +1355,7 @@ declare global {
1329
1355
  * @example
1330
1356
  * ```ts
1331
1357
  * // How to create a texture and apply it to a new box node:
1332
- * export default defineScript({
1358
+ * export default defineGuiScript({
1333
1359
  * init(self) {
1334
1360
  * const w = 200;
1335
1361
  * const h = 300;
@@ -1355,13 +1381,17 @@ declare global {
1355
1381
  * });
1356
1382
  *
1357
1383
  * // How to create a texture using .astc format
1384
+ * const size = 4;
1385
+ * const pos = vmath.vector3(200, 200, 0);
1358
1386
  * const path = "/assets/images/logo_4x4.astc";
1359
- * const buffer = sys.load_resource(path);
1360
- * const n = gui.new_box_node(pos, vmath.vector3(size, size, 0));
1361
- * // size is read from the .astc buffer
1362
- * // flip is not supported
1363
- * gui.new_texture(path, 0, 0, "astc", buffer, false);
1364
- * gui.set_texture(n, path);
1387
+ * const [data] = sys.load_resource(path);
1388
+ * if (data !== undefined) {
1389
+ * const n = gui.new_box_node(pos, vmath.vector3(size, size, 0));
1390
+ * // size is read from the .astc buffer
1391
+ * // flip is not supported
1392
+ * gui.new_texture(path, 0, 0, "astc", data, false);
1393
+ * gui.set_texture(n, path);
1394
+ * }
1365
1395
  * ```
1366
1396
  */
1367
1397
  function new_texture(texture_id: string | Hash, width: number, height: number, type: string | Opaque<"constant">, buffer: string, flip?: boolean): LuaMultiReturn<[boolean, number]>;
@@ -1505,7 +1535,11 @@ declare global {
1505
1535
  * @returns optional boolean to signal if the input should be consumed (not passed on to others) or not, default is false
1506
1536
  * @example
1507
1537
  * ```ts
1508
- * export default defineScript({
1538
+ * export default defineGuiScript({
1539
+ * init(): { my_value: number | undefined } {
1540
+ * return { my_value: undefined };
1541
+ * },
1542
+ *
1509
1543
  * on_input(self, action_id, action) {
1510
1544
  * // check for input
1511
1545
  * if (action_id === hash("my_action")) {
@@ -1539,6 +1573,10 @@ declare global {
1539
1573
  * @example
1540
1574
  * ```ts
1541
1575
  * export default defineGuiScript({
1576
+ * init() {
1577
+ * return { my_original_color: gui.get_color(gui.get_node("my_node")) };
1578
+ * },
1579
+ *
1542
1580
  * on_reload(self) {
1543
1581
  * // restore some color (or similar)
1544
1582
  * gui.set_color(gui.get_node("my_node"), self.my_original_color);
@@ -1582,11 +1620,11 @@ declare global {
1582
1620
  * @example
1583
1621
  * ```ts
1584
1622
  * // Set the texture of a node to a flipbook animation from an atlas:
1585
- * function anim_callback(self, node) {
1623
+ * function anim_callback(self: unknown, node: unknown) {
1586
1624
  * // Take action after animation has played.
1587
1625
  * }
1588
1626
  *
1589
- * export default defineScript({
1627
+ * export default defineGuiScript({
1590
1628
  * init(self) {
1591
1629
  * // Create a new node and set the texture to a flipbook animation
1592
1630
  * const node = gui.get_node("button_node");
@@ -1630,13 +1668,13 @@ declare global {
1630
1668
  * // How to play a particle fx when a gui node is created.
1631
1669
  * // The callback receives the gui node, the hash of the id
1632
1670
  * // of the emitter, and the new state of the emitter as particlefx.EMITTER_STATE_.
1633
- * function emitter_state_change(self, node, emitter, state) {
1671
+ * function emitter_state_change(self: unknown, node: unknown, emitter: unknown, state: unknown) {
1634
1672
  * if (emitter === hash("exhaust") && state === particlefx.EMITTER_STATE_POSTSPAWN) {
1635
1673
  * // exhaust is done spawning particles...
1636
1674
  * }
1637
1675
  * }
1638
1676
  *
1639
- * export default defineScript({
1677
+ * export default defineGuiScript({
1640
1678
  * init(self) {
1641
1679
  * gui.play_particlefx(gui.get_node("particlefx"), emitter_state_change);
1642
1680
  * },
@@ -1676,14 +1714,19 @@ declare global {
1676
1714
  * @example
1677
1715
  * ```ts
1678
1716
  * // Animate a node to the pressed pointer position:
1679
- * export default defineScript({
1717
+ * export default defineGuiScript({
1680
1718
  * init() {
1681
1719
  * msg.post(".", "acquire_input_focus");
1682
1720
  * return { marker: gui.get_node("marker") };
1683
1721
  * },
1684
1722
  *
1685
1723
  * on_input(self, action_id, action) {
1686
- * if (action_id === hash("touch") && action.pressed) {
1724
+ * if (
1725
+ * action_id === hash("touch") &&
1726
+ * action.pressed &&
1727
+ * action.screen_x !== undefined &&
1728
+ * action.screen_y !== undefined
1729
+ * ) {
1687
1730
  * const screen_position = vmath.vector3(action.screen_x, action.screen_y, 0);
1688
1731
  * const target_position = gui.screen_to_local(self.marker, screen_position);
1689
1732
  * gui.animate(self.marker, gui.PROP_POSITION, target_position, gui.EASING_OUTQUAD, 0.2);
@@ -1741,13 +1784,13 @@ declare global {
1741
1784
  * @param property - the property to set
1742
1785
  * @param value - the property to set. `nil` is only supported for removing runtime texture mappings with `gui.set(msg.url(), "textures", nil, {key = ...})`.
1743
1786
  * @param options - optional options table (only applicable for material constants)
1744
- * - `index` number index into array property (1 based)
1787
+ * - `index` number zero-based index into array property; the transpiler emits Defold's 1-based index
1745
1788
  * - `key` hash name of internal property
1746
1789
  * @example
1747
1790
  * ```ts
1748
1791
  * // Updates the position property on an existing node:
1749
1792
  * const node = gui.get_node("my_box_node");
1750
- * const node_position = gui.get(node, "position");
1793
+ * const node_position = gui.get(node, "position") as Vector3;
1751
1794
  * gui.set(node, "position.x", node_position.x + 128);
1752
1795
  *
1753
1796
  * // Updates the rotation property on an existing node:
@@ -1764,23 +1807,23 @@ declare global {
1764
1807
  * // matrix4 is also supported
1765
1808
  * gui.set(node, "light_matrix", vmath.matrix4());
1766
1809
  * // update a constant in an array at position 4. the array is specified in the shader as:
1767
- * // uniform vec4 tint_array[4]; // lua is 1 based, shader is 0 based
1768
- * gui.set(node, "tint_array", vmath.vector4(1, 0, 0, 1), { index: 4 });
1810
+ * // uniform vec4 tint_array[4]; // TypeScript and the shader are both 0 based
1811
+ * gui.set(node, "tint_array", vmath.vector4(1, 0, 0, 1), { index: 3 });
1769
1812
  * // update a matrix constant in an array at position 4. the array is specified in the shader as:
1770
1813
  * // uniform mat4 light_matrix_array[4];
1771
- * gui.set(node, "light_matrix_array", vmath.matrix4(), { index: 4 });
1814
+ * gui.set(node, "light_matrix_array", vmath.matrix4(), { index: 3 });
1772
1815
  * // update a sub-element in a constant
1773
1816
  * gui.set(node, "tint.x", 1);
1774
1817
  * // update a sub-element in an array constant at position 4
1775
- * gui.set(node, "tint_array.x", 1, { index: 4 });
1818
+ * gui.set(node, "tint_array.x", 1, { index: 3 });
1776
1819
  *
1777
1820
  * // Set a named property
1778
- * export default defineScript({
1821
+ * export default defineGuiScript({
1779
1822
  * on_message(self, message_id, message) {
1780
- * if (message_id === hash("set_font")) {
1823
+ * if (message_id === hash("set_font") && types.is_hash(message.font)) {
1781
1824
  * gui.set(msg.url(), "fonts", message.font, { key: "my_font_name" });
1782
1825
  * gui.set_font(gui.get_node("text"), "my_font_name");
1783
- * } else if (message_id === hash("set_texture")) {
1826
+ * } else if (message_id === hash("set_texture") && types.is_hash(message.texture)) {
1784
1827
  * gui.set(msg.url(), "textures", message.texture, { key: "my_texture" });
1785
1828
  * gui.set_texture(gui.get_node("box"), "my_texture");
1786
1829
  * gui.play_flipbook(gui.get_node("box"), "logo_256");
@@ -1789,6 +1832,7 @@ declare global {
1789
1832
  * });
1790
1833
  *
1791
1834
  * // Remove a named runtime texture resource mapping:
1835
+ * const atlas_params = { texture: "/runtime.texturec", animations: [], geometries: [] };
1792
1836
  * const atlas_id = resource.create_atlas("/runtime.texturesetc", atlas_params);
1793
1837
  * gui.set(msg.url(), "textures", atlas_id, { key: "runtime_texture" });
1794
1838
  * gui.set_texture(gui.get_node("box"), "runtime_texture");
@@ -1798,7 +1842,7 @@ declare global {
1798
1842
  * resource.release(atlas_id);
1799
1843
  * ```
1800
1844
  */
1801
- function set(node: Opaque<"node"> | Url, property: string | Hash | number & { readonly __brand: "gui.PROP_POSITION" } | number & { readonly __brand: "gui.PROP_ROTATION" } | number & { readonly __brand: "gui.PROP_EULER" } | number & { readonly __brand: "gui.PROP_SCALE" } | number & { readonly __brand: "gui.PROP_COLOR" } | number & { readonly __brand: "gui.PROP_OUTLINE" } | number & { readonly __brand: "gui.PROP_SHADOW" } | number & { readonly __brand: "gui.PROP_SIZE" } | number & { readonly __brand: "gui.PROP_FILL_ANGLE" } | number & { readonly __brand: "gui.PROP_INNER_RADIUS" } | number & { readonly __brand: "gui.PROP_LEADING" } | number & { readonly __brand: "gui.PROP_TRACKING" } | number & { readonly __brand: "gui.PROP_SLICE9" }, value?: number | Vector4 | Vector3 | Quaternion, options?: { index?: number; key?: Hash }): void;
1845
+ function set(node: Opaque<"node"> | Url, property: string | Hash | gui.Property, value?: number | Vector4 | Vector3 | Quaternion | Matrix4 | Hash, options?: { index?: number; key?: string | Hash }): void;
1802
1846
  /**
1803
1847
  * Sets the adjust mode on a node.
1804
1848
  * The adjust mode defines how the node will adjust itself to screen
@@ -1813,7 +1857,7 @@ declare global {
1813
1857
  *
1814
1858
  * - `gui.ADJUST_STRETCH`
1815
1859
  */
1816
- function set_adjust_mode(node: Opaque<"node">, adjust_mode: number & { readonly __brand: "gui.ADJUST_FIT" } | number & { readonly __brand: "gui.ADJUST_ZOOM" } | number & { readonly __brand: "gui.ADJUST_STRETCH" }): void;
1860
+ function set_adjust_mode(node: Opaque<"node">, adjust_mode: gui.AdjustMode): void;
1817
1861
  /**
1818
1862
  * sets the node alpha
1819
1863
  *
@@ -1838,7 +1882,7 @@ declare global {
1838
1882
  *
1839
1883
  * - `gui.BLEND_SCREEN`
1840
1884
  */
1841
- function set_blend_mode(node: Opaque<"node">, blend_mode: number & { readonly __brand: "gui.BLEND_ALPHA" } | number & { readonly __brand: "gui.BLEND_ADD" } | number & { readonly __brand: "gui.BLEND_ADD_ALPHA" } | number & { readonly __brand: "gui.BLEND_MULT" } | number & { readonly __brand: "gui.BLEND_SCREEN" }): void;
1885
+ function set_blend_mode(node: Opaque<"node">, blend_mode: gui.BlendMode): void;
1842
1886
  /**
1843
1887
  * If node is set as an inverted clipping node, it will clip anything inside as opposed to outside.
1844
1888
  *
@@ -1856,7 +1900,7 @@ declare global {
1856
1900
  *
1857
1901
  * - `gui.CLIPPING_MODE_STENCIL`
1858
1902
  */
1859
- function set_clipping_mode(node: Opaque<"node">, clipping_mode: number & { readonly __brand: "gui.CLIPPING_MODE_NONE" } | number & { readonly __brand: "gui.CLIPPING_MODE_STENCIL" }): void;
1903
+ function set_clipping_mode(node: Opaque<"node">, clipping_mode: gui.ClippingMode): void;
1860
1904
  /**
1861
1905
  * If node is set as an visible clipping node, it will be shown as well as clipping. Otherwise, it will only clip but not show visually.
1862
1906
  *
@@ -2024,7 +2068,7 @@ declare global {
2024
2068
  *
2025
2069
  * - `gui.PIEBOUNDS_ELLIPSE`
2026
2070
  */
2027
- function set_outer_bounds(node: Opaque<"node">, bounds_mode: number & { readonly __brand: "gui.PIEBOUNDS_RECTANGLE" } | number & { readonly __brand: "gui.PIEBOUNDS_ELLIPSE" }): void;
2071
+ function set_outer_bounds(node: Opaque<"node">, bounds_mode: gui.PieBounds): void;
2028
2072
  /**
2029
2073
  * Sets the outline color of the supplied node.
2030
2074
  * See gui.set_color for info how vectors encode color values.
@@ -2079,7 +2123,7 @@ declare global {
2079
2123
  *
2080
2124
  * - `gui.PIVOT_NW`
2081
2125
  */
2082
- function set_pivot(node: Opaque<"node">, pivot: number & { readonly __brand: "gui.PIVOT_CENTER" } | number & { readonly __brand: "gui.PIVOT_N" } | number & { readonly __brand: "gui.PIVOT_NE" } | number & { readonly __brand: "gui.PIVOT_E" } | number & { readonly __brand: "gui.PIVOT_SE" } | number & { readonly __brand: "gui.PIVOT_S" } | number & { readonly __brand: "gui.PIVOT_SW" } | number & { readonly __brand: "gui.PIVOT_W" } | number & { readonly __brand: "gui.PIVOT_NW" }): void;
2126
+ function set_pivot(node: Opaque<"node">, pivot: gui.Pivot): void;
2083
2127
  /**
2084
2128
  * Sets the position of the supplied node.
2085
2129
  *
@@ -2104,7 +2148,7 @@ declare global {
2104
2148
  * @param node - node to set the rotation for
2105
2149
  * @param rotation - new rotation
2106
2150
  */
2107
- function set_rotation(node: Opaque<"node">, rotation: Quaternion | Vector4): void;
2151
+ function set_rotation(node: Opaque<"node">, rotation: Quaternion | Vector4 | Vector3): void;
2108
2152
  /**
2109
2153
  * Sets how the safe area is applied to this gui scene.
2110
2154
  *
@@ -2118,7 +2162,7 @@ declare global {
2118
2162
  *
2119
2163
  * - `gui.SAFE_AREA_BOTH`
2120
2164
  */
2121
- function set_safe_area_mode(mode: number & { readonly __brand: "gui.SAFE_AREA_NONE" } | number & { readonly __brand: "gui.SAFE_AREA_LONG" } | number & { readonly __brand: "gui.SAFE_AREA_SHORT" } | number & { readonly __brand: "gui.SAFE_AREA_BOTH" }): void;
2165
+ function set_safe_area_mode(mode: gui.SafeAreaMode): void;
2122
2166
  /**
2123
2167
  * Sets the scaling of the supplied node.
2124
2168
  *
@@ -2164,7 +2208,7 @@ declare global {
2164
2208
  *
2165
2209
  * - `gui.SIZE_MODE_AUTO`
2166
2210
  */
2167
- function set_size_mode(node: Opaque<"node">, size_mode: number & { readonly __brand: "gui.SIZE_MODE_MANUAL" } | number & { readonly __brand: "gui.SIZE_MODE_AUTO" }): void;
2211
+ function set_size_mode(node: Opaque<"node">, size_mode: gui.SizeMode): void;
2168
2212
  /**
2169
2213
  * Set the slice9 configuration values for the node.
2170
2214
  *
@@ -2229,7 +2273,7 @@ declare global {
2229
2273
  * @returns setting the data was successful
2230
2274
  * @example
2231
2275
  * ```ts
2232
- * export default defineScript({
2276
+ * export default defineGuiScript({
2233
2277
  * init(self) {
2234
2278
  * const w = 200;
2235
2279
  * const h = 300;
@@ -2284,7 +2328,7 @@ declare global {
2284
2328
  *
2285
2329
  * - `gui.ANCHOR_RIGHT`
2286
2330
  */
2287
- function set_xanchor(node: Opaque<"node">, anchor: number & { readonly __brand: "gui.ANCHOR_NONE" } | number & { readonly __brand: "gui.ANCHOR_LEFT" } | number & { readonly __brand: "gui.ANCHOR_RIGHT" }): void;
2331
+ function set_xanchor(node: Opaque<"node">, anchor: gui.XAnchor): void;
2288
2332
  /**
2289
2333
  * The y-anchor specifies how the node is moved when the game is run in a different resolution.
2290
2334
  *
@@ -2297,7 +2341,7 @@ declare global {
2297
2341
  *
2298
2342
  * - `gui.ANCHOR_BOTTOM`
2299
2343
  */
2300
- function set_yanchor(node: Opaque<"node">, anchor: number & { readonly __brand: "gui.ANCHOR_NONE" } | number & { readonly __brand: "gui.ANCHOR_TOP" } | number & { readonly __brand: "gui.ANCHOR_BOTTOM" }): void;
2344
+ function set_yanchor(node: Opaque<"node">, anchor: gui.YAnchor): void;
2301
2345
  /**
2302
2346
  * Shows the on-display touch keyboard.
2303
2347
  * The specified type of keyboard is displayed if it is available on
@@ -2315,7 +2359,7 @@ declare global {
2315
2359
  * - `gui.KEYBOARD_TYPE_PASSWORD`
2316
2360
  * @param autoclose - if the keyboard should automatically close when clicking outside
2317
2361
  */
2318
- function show_keyboard(type: number & { readonly __brand: "gui.KEYBOARD_TYPE_DEFAULT" } | number & { readonly __brand: "gui.KEYBOARD_TYPE_EMAIL" } | number & { readonly __brand: "gui.KEYBOARD_TYPE_NUMBER_PAD" } | number & { readonly __brand: "gui.KEYBOARD_TYPE_PASSWORD" }, autoclose: boolean): void;
2362
+ function show_keyboard(type: gui.KeyboardType, autoclose: boolean): void;
2319
2363
  /**
2320
2364
  * Stops the particle fx for a gui node
2321
2365
  *
@@ -2337,15 +2381,17 @@ declare global {
2337
2381
  * // in a counting fashion. It is assumed that the gui component receives messages
2338
2382
  * // from the game when a new score is to be shown.
2339
2383
  * export default defineGuiScript({
2340
- * init(self) {
2341
- * // fetch the score text node for later use (assumes it is called "score")
2342
- * self.score_node = gui.get_node("score");
2343
- * // keep track of the current score counted up so far
2344
- * self.current_score = 0;
2345
- * // keep track of the target score we should count up to
2346
- * self.target_score = 0;
2347
- * // how fast we will update the score, in score/second
2348
- * self.score_update_speed = 1;
2384
+ * init() {
2385
+ * return {
2386
+ * // fetch the score text node for later use (assumes it is called "score")
2387
+ * score_node: gui.get_node("score"),
2388
+ * // keep track of the current score counted up so far
2389
+ * current_score: 0,
2390
+ * // keep track of the target score we should count up to
2391
+ * target_score: 0,
2392
+ * // how fast we will update the score, in score/second
2393
+ * score_update_speed: 1,
2394
+ * };
2349
2395
  * },
2350
2396
  *
2351
2397
  * update(self, dt) {
@@ -2364,7 +2410,7 @@ declare global {
2364
2410
  *
2365
2411
  * on_message(self, message_id, message) {
2366
2412
  * // check the message
2367
- * if (message_id === hash("set_score")) {
2413
+ * if (message_id === hash("set_score") && typeof message.score === "number") {
2368
2414
  * self.target_score = message.score;
2369
2415
  * }
2370
2416
  * },
@@ -18,7 +18,9 @@ declare global {
18
18
  * const res = html5.run("10 + 20"); // returns the string "30"
19
19
  * print(res);
20
20
  * const res_num = tonumber(res); // convert to number
21
- * print(res_num - 20); // prints 10
21
+ * if (res_num !== undefined) {
22
+ * print(res_num - 20); // prints 10
23
+ * }
22
24
  * ```
23
25
  */
24
26
  function run(code: string): string;
@@ -34,7 +36,7 @@ declare global {
34
36
  * object The calling script
35
37
  * @example
36
38
  * ```ts
37
- * function on_interaction(self) {
39
+ * function on_interaction(self: unknown) {
38
40
  * print("on_interaction called");
39
41
  * html5.set_interaction_listener(undefined);
40
42
  * }
@@ -1,4 +1,6 @@
1
1
  /** @noSelfInFile */
2
+ import type { Hash } from "../src/core-types";
3
+
2
4
  declare global {
3
5
  /**
4
6
  * Functions for performing HTTP and HTTPS requests.
@@ -53,6 +55,10 @@ declare global {
53
55
  * - 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
56
  * @example
55
57
  * ```ts
58
+ * function update_my_progress_bar(self: unknown, fraction: number) {
59
+ * // draw the progress bar at the given fraction
60
+ * }
61
+ *
56
62
  * // Basic HTTP-GET request. The callback receives a table with the response
57
63
  * // in the fields status, the response (the data) and headers (a table).
58
64
  * export default defineScript({
@@ -61,7 +67,7 @@ declare global {
61
67
  * "http://www.google.com",
62
68
  * "GET",
63
69
  * (self, _id, response) => {
64
- * if (response.bytes_total !== undefined) {
70
+ * if (response.bytes_received !== undefined && response.bytes_total !== undefined) {
65
71
  * update_my_progress_bar(self, response.bytes_received / response.bytes_total);
66
72
  * } else {
67
73
  * print(response.status);
@@ -77,7 +83,7 @@ declare global {
77
83
  * });
78
84
  * ```
79
85
  */
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;
86
+ function request(url: string, method: string, callback: (self: unknown, id: Hash, response: { status: number; response?: string; headers?: LuaMap<string, string>; path?: string; error?: string; bytes_received?: number; bytes_total?: number; range_start?: number; range_end?: number; document_size?: number }) => void, headers?: LuaMap<string, string> | Record<string, string>, post_data?: string, options?: { timeout?: number; path?: string; ignore_cache?: boolean; chunked_transfer?: boolean; report_progress?: boolean }): void;
81
87
  }
82
88
  }
83
89