@defold-typescript/types 0.34.0 → 0.36.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 (67) hide show
  1. package/api-signatures.json +9547 -186
  2. package/api-targets.json +9 -66
  3. package/examples/translations.json +6 -6
  4. package/generated/buffer.d.ts +2 -2
  5. package/generated/collectionfactory.d.ts +2 -2
  6. package/generated/factory.d.ts +13 -12
  7. package/generated/gui.d.ts +23 -23
  8. package/generated/kinds/gui-script.d.ts +0 -4
  9. package/generated/kinds/render-script.d.ts +1 -4
  10. package/generated/kinds/script.d.ts +0 -4
  11. package/generated/model.d.ts +2 -2
  12. package/generated/profiler.d.ts +2 -4
  13. package/generated/render.d.ts +7 -155
  14. package/generated/sys.d.ts +1 -1
  15. package/generated/versions/defold-1.12.4/buffer.d.ts +2 -2
  16. package/generated/versions/defold-1.12.4/collectionfactory.d.ts +2 -2
  17. package/generated/versions/defold-1.12.4/factory.d.ts +13 -12
  18. package/generated/versions/defold-1.12.4/gui.d.ts +23 -23
  19. package/generated/versions/defold-1.12.4/index.d.ts +9 -4
  20. package/generated/versions/defold-1.12.4/model.d.ts +2 -2
  21. package/generated/versions/defold-1.12.4/profiler.d.ts +2 -4
  22. package/generated/versions/defold-1.12.4/render.d.ts +7 -155
  23. package/generated/versions/defold-1.12.4/sys.d.ts +1 -1
  24. package/generated/versions/defold-1.12.4/vmath.d.ts +0 -19
  25. package/generated/versions/defold-1.12.4/window.d.ts +2 -4
  26. package/generated/versions/defold-1.12.4/zlib.d.ts +2 -1
  27. package/generated/versions/defold-1.13.0/buffer.d.ts +2 -2
  28. package/generated/versions/defold-1.13.0/collectionfactory.d.ts +2 -2
  29. package/generated/versions/defold-1.13.0/factory.d.ts +13 -12
  30. package/generated/versions/defold-1.13.0/gui.d.ts +23 -23
  31. package/generated/versions/defold-1.13.0/index.d.ts +9 -4
  32. package/generated/versions/defold-1.13.0/model.d.ts +2 -2
  33. package/generated/versions/defold-1.13.0/profiler.d.ts +2 -4
  34. package/generated/versions/defold-1.13.0/render.d.ts +7 -155
  35. package/generated/versions/defold-1.13.0/sys.d.ts +1 -1
  36. package/generated/versions/defold-1.13.0/vmath.d.ts +0 -19
  37. package/generated/versions/defold-1.13.0/window.d.ts +2 -4
  38. package/generated/versions/defold-1.13.0/zlib.d.ts +2 -1
  39. package/generated/vmath.d.ts +0 -19
  40. package/generated/window.d.ts +2 -4
  41. package/generated/zlib.d.ts +2 -1
  42. package/index.d.ts +2 -4
  43. package/package.json +7 -2
  44. package/scripts/extension-goldens.ts +23 -0
  45. package/scripts/generate-api-signatures.ts +72 -8
  46. package/scripts/materialize-version.ts +15 -1
  47. package/scripts/regen.ts +109 -27
  48. package/scripts/signature-store-fs.ts +1 -0
  49. package/scripts/sync-api-docs.ts +5 -61
  50. package/src/emit-dts.ts +359 -58
  51. package/src/index.ts +1 -0
  52. package/src/optional-correction-provenance.ts +13 -2
  53. package/src/render-overloads.d.ts +46 -0
  54. package/src/vmath-overloads.d.ts +19 -0
  55. package/generated/iac.d.ts +0 -18
  56. package/generated/iap.d.ts +0 -60
  57. package/generated/push.d.ts +0 -66
  58. package/generated/versions/defold-1.12.4/iac.d.ts +0 -18
  59. package/generated/versions/defold-1.12.4/iap.d.ts +0 -60
  60. package/generated/versions/defold-1.12.4/push.d.ts +0 -66
  61. package/generated/versions/defold-1.12.4/webview.d.ts +0 -71
  62. package/generated/versions/defold-1.13.0/iac.d.ts +0 -18
  63. package/generated/versions/defold-1.13.0/iap.d.ts +0 -60
  64. package/generated/versions/defold-1.13.0/push.d.ts +0 -66
  65. package/generated/versions/defold-1.13.0/webview.d.ts +0 -71
  66. package/generated/webview.d.ts +0 -71
  67. package/scripts/fidelity-audit.ts +0 -684
@@ -38,13 +38,13 @@ declare global {
38
38
  * @example
39
39
  * ```ts
40
40
  * // Clear the color buffer and the depth buffer.
41
- * render.clear({
42
- * [graphics.BUFFER_TYPE_COLOR0_BIT]: vmath.vector4(0, 0, 0, 0),
43
- * [graphics.BUFFER_TYPE_DEPTH_BIT]: 1,
44
- * });
41
+ * const buffers = new LuaMap<render.ClearBufferKey, number | Vector4>();
42
+ * buffers.set(graphics.BUFFER_TYPE_COLOR0_BIT, vmath.vector4(0, 0, 0, 0));
43
+ * buffers.set(graphics.BUFFER_TYPE_DEPTH_BIT, 1);
44
+ * render.clear(buffers);
45
45
  * ```
46
46
  */
47
- function clear(buffers: LuaMap<number, number | Vector4>): void;
47
+ function clear(buffers: LuaMap<number & { readonly __brand: "graphics.BUFFER_TYPE_COLOR0_BIT" } | number & { readonly __brand: "graphics.BUFFER_TYPE_DEPTH_BIT" } | number & { readonly __brand: "graphics.BUFFER_TYPE_STENCIL_BIT" }, number | Vector4>): void;
48
48
  /**
49
49
  * Constant buffers are used to set shader program variables and are optionally passed to the `render.draw()` function.
50
50
  * The buffer's constant elements can be indexed like an ordinary Lua table, but you can't iterate over them with pairs() or ipairs().
@@ -128,7 +128,7 @@ declare global {
128
128
  * render.draw(self.tile_pred);
129
129
  * ```
130
130
  */
131
- function disable_state(state: Opaque<"constant">): void;
131
+ function disable_state(state: number & { readonly __brand: "graphics.STATE_DEPTH_TEST" } | number & { readonly __brand: "graphics.STATE_STENCIL_TEST" } | number & { readonly __brand: "graphics.STATE_BLEND" } | number & { readonly __brand: "graphics.STATE_ALPHA_TEST" } | number & { readonly __brand: "graphics.STATE_CULL_FACE" } | number & { readonly __brand: "graphics.STATE_POLYGON_OFFSET_FILL" }): void;
132
132
  /**
133
133
  * Disables a texture that has previourly been enabled.
134
134
  *
@@ -307,7 +307,7 @@ declare global {
307
307
  * render.disable_state(graphics.STATE_STENCIL_TEST);
308
308
  * ```
309
309
  */
310
- function enable_state(state: Opaque<"constant">): void;
310
+ function enable_state(state: number & { readonly __brand: "graphics.STATE_DEPTH_TEST" } | number & { readonly __brand: "graphics.STATE_STENCIL_TEST" } | number & { readonly __brand: "graphics.STATE_BLEND" } | number & { readonly __brand: "graphics.STATE_ALPHA_TEST" } | number & { readonly __brand: "graphics.STATE_CULL_FACE" } | number & { readonly __brand: "graphics.STATE_POLYGON_OFFSET_FILL" }): void;
311
311
  /**
312
312
  * Sets the specified texture handle for a render target attachment or a regular texture
313
313
  * that should be used for rendering. The texture can be bound to either a texture unit
@@ -502,154 +502,6 @@ declare global {
502
502
  * ```
503
503
  */
504
504
  function predicate(tags: (string | Hash)[]): number;
505
- /**
506
- * Creates a new render target according to the supplied
507
- * specification table.
508
- * The table should contain keys specifying which buffers should be created
509
- * with what parameters. Each buffer key should have a table value consisting
510
- * of parameters. The following parameter keys are available:
511
- *
512
- * Key
513
- * Values
514
- *
515
- * `format`
516
- * `graphics.TEXTURE_FORMAT_LUMINANCE`
517
- * `graphics.TEXTURE_FORMAT_RGB`
518
- * `graphics.TEXTURE_FORMAT_RGBA`
519
- * `graphics.TEXTURE_FORMAT_DEPTH`
520
- * `graphics.TEXTURE_FORMAT_STENCIL`
521
- * `graphics.TEXTURE_FORMAT_RGBA32F`
522
- * `graphics.TEXTURE_FORMAT_RGBA16F`
523
- *
524
- * `width`
525
- * number
526
- *
527
- * `height`
528
- * number
529
- *
530
- * `min_filter` (optional)
531
- * `graphics.TEXTURE_FILTER_LINEAR`
532
- * `graphics.TEXTURE_FILTER_NEAREST`
533
- *
534
- * `mag_filter` (optional)
535
- * `graphics.TEXTURE_FILTER_LINEAR`
536
- * `graphics.TEXTURE_FILTER_NEAREST`
537
- *
538
- * `u_wrap` (optional)
539
- * `graphics.TEXTURE_WRAP_CLAMP_TO_BORDER`
540
- * `graphics.TEXTURE_WRAP_CLAMP_TO_EDGE`
541
- * `graphics.TEXTURE_WRAP_MIRRORED_REPEAT`
542
- * `graphics.TEXTURE_WRAP_REPEAT`
543
- *
544
- * `v_wrap` (optional)
545
- * `graphics.TEXTURE_WRAP_CLAMP_TO_BORDER`
546
- * `graphics.TEXTURE_WRAP_CLAMP_TO_EDGE`
547
- * `graphics.TEXTURE_WRAP_MIRRORED_REPEAT`
548
- * `graphics.TEXTURE_WRAP_REPEAT`
549
- *
550
- * `flags` (optional)
551
- * `render.TEXTURE_BIT` (only applicable to depth and stencil buffers)
552
- *
553
- * The render target can be created to support multiple color attachments. Each attachment can have different format settings and texture filters,
554
- * but attachments must be added in sequence, meaning you cannot create a render target at slot 0 and 3.
555
- * Instead it has to be created with all four buffer types ranging from [0..3] (as denoted by graphics.BUFFER_TYPE_COLORX_BIT where 'X' is the attachment you want to create).
556
- * It is not guaranteed that the device running the script can support creating render targets with multiple color attachments. To check if the device can support multiple attachments,
557
- * you can check if the `render` table contains any of the `BUFFER_TYPE_COLOR1_BIT`, `BUFFER_TYPE_COLOR2_BIT` or `BUFFER_TYPE_COLOR3_BIT` constants:
558
- *
559
- * `function init(self)
560
- * if graphics.BUFFER_TYPE_COLOR1_BIT == nil then
561
- * -- this devices does not support multiple color attachments
562
- * end
563
- * end
564
- * `
565
- *
566
- * @param name - render target name
567
- * @param parameters - table of buffer parameters, see the description for available keys and values
568
- * @returns new render target
569
- * @example
570
- * ```ts
571
- * // How to create a new render target and draw to it:
572
- * export default defineScript({
573
- * init() {
574
- * // render target buffer parameters
575
- * const color_params = {
576
- * format: graphics.TEXTURE_FORMAT_RGBA,
577
- * width: render.get_window_width(),
578
- * height: render.get_window_height(),
579
- * min_filter: graphics.TEXTURE_FILTER_LINEAR,
580
- * mag_filter: graphics.TEXTURE_FILTER_LINEAR,
581
- * u_wrap: graphics.TEXTURE_WRAP_CLAMP_TO_EDGE,
582
- * v_wrap: graphics.TEXTURE_WRAP_CLAMP_TO_EDGE,
583
- * };
584
- * const depth_params = {
585
- * format: graphics.TEXTURE_FORMAT_DEPTH,
586
- * width: render.get_window_width(),
587
- * height: render.get_window_height(),
588
- * u_wrap: graphics.TEXTURE_WRAP_CLAMP_TO_EDGE,
589
- * v_wrap: graphics.TEXTURE_WRAP_CLAMP_TO_EDGE,
590
- * };
591
- * return {
592
- * my_render_target: render.render_target({
593
- * [graphics.BUFFER_TYPE_COLOR0_BIT]: color_params,
594
- * [graphics.BUFFER_TYPE_DEPTH_BIT]: depth_params,
595
- * }),
596
- * };
597
- * },
598
- *
599
- * update(self, dt) {
600
- * // enable target so all drawing is done to it
601
- * render.set_render_target(self.my_render_target);
602
- *
603
- * // draw a predicate to the render target
604
- * render.draw(self.my_pred);
605
- * },
606
- * });
607
- *
608
- * // How to create a render target with multiple outputs:
609
- * export default defineScript({
610
- * init() {
611
- * // render target buffer parameters
612
- * const color_params_rgba = {
613
- * format: graphics.TEXTURE_FORMAT_RGBA,
614
- * width: render.get_window_width(),
615
- * height: render.get_window_height(),
616
- * min_filter: graphics.TEXTURE_FILTER_LINEAR,
617
- * mag_filter: graphics.TEXTURE_FILTER_LINEAR,
618
- * u_wrap: graphics.TEXTURE_WRAP_CLAMP_TO_EDGE,
619
- * v_wrap: graphics.TEXTURE_WRAP_CLAMP_TO_EDGE,
620
- * };
621
- * const color_params_float = {
622
- * format: graphics.TEXTURE_FORMAT_RG32F,
623
- * width: render.get_window_width(),
624
- * height: render.get_window_height(),
625
- * min_filter: graphics.TEXTURE_FILTER_LINEAR,
626
- * mag_filter: graphics.TEXTURE_FILTER_LINEAR,
627
- * u_wrap: graphics.TEXTURE_WRAP_CLAMP_TO_EDGE,
628
- * v_wrap: graphics.TEXTURE_WRAP_CLAMP_TO_EDGE,
629
- * };
630
- *
631
- * // Create a render target with three color attachments
632
- * // Note: No depth buffer is attached here
633
- * return {
634
- * my_render_target: render.render_target({
635
- * [graphics.BUFFER_TYPE_COLOR0_BIT]: color_params_rgba,
636
- * [graphics.BUFFER_TYPE_COLOR1_BIT]: color_params_rgba,
637
- * [graphics.BUFFER_TYPE_COLOR2_BIT]: color_params_float,
638
- * }),
639
- * };
640
- * },
641
- *
642
- * update(self, dt) {
643
- * // enable target so all drawing is done to it
644
- * render.enable_render_target(self.my_render_target);
645
- *
646
- * // draw a predicate to the render target
647
- * render.draw(self.my_pred);
648
- * },
649
- * });
650
- * ```
651
- */
652
- function render_target(name: string, parameters: Record<string | number, unknown>): Opaque<"render_target">;
653
505
  /**
654
506
  * Sets the blend equation with separate equations for the color and alpha channels.
655
507
  *
@@ -228,7 +228,7 @@ declare global {
228
228
  * }
229
229
  * ```
230
230
  */
231
- function get_connectivity(): Opaque<"constant">;
231
+ function get_connectivity(): number & { readonly __brand: "sys.NETWORK_DISCONNECTED" } | number & { readonly __brand: "sys.NETWORK_CONNECTED_CELLULAR" } | number & { readonly __brand: "sys.NETWORK_CONNECTED" };
232
232
  /**
233
233
  * Returns a table with engine information.
234
234
  *
@@ -91,25 +91,6 @@ declare global {
91
91
  * ```
92
92
  */
93
93
  function dot(v1: Vector3 | Vector4, v2: Vector3 | Vector4): number;
94
- /**
95
- * Converts euler angles (x, y, z) in degrees into a quaternion
96
- * The error is guaranteed to be less than 0.001.
97
- * If the first argument is vector3, its values are used as x, y, z angles.
98
- *
99
- * @param x - rotation around x-axis in degrees or vector3 with euler angles in degrees
100
- * @param y - rotation around y-axis in degrees
101
- * @param z - rotation around z-axis in degrees
102
- * @returns quaternion describing an equivalent rotation (231 (YZX) rotation sequence)
103
- * @example
104
- * ```ts
105
- * const q = vmath.euler_to_quat(0, 45, 90);
106
- * print(q); // => vmath.quat(0.27059805393219, 0.27059805393219, 0.65328145027161, 0.65328145027161)
107
- *
108
- * const v = vmath.vector3(0, 0, 90);
109
- * print(vmath.euler_to_quat(v)); // => vmath.quat(0, 0, 0.70710676908493, 0.70710676908493)
110
- * ```
111
- */
112
- function euler_to_quat(x: number | Vector3, y: number, z: number): Quaternion;
113
94
  /**
114
95
  * The resulting matrix is the inverse of the supplied matrix.
115
96
  * For ortho-normal matrices, e.g. regular object transformation,
@@ -1,6 +1,4 @@
1
1
  /** @noSelfInFile */
2
- import type { Opaque } from "../../../src/core-types";
3
-
4
2
  declare global {
5
3
  /**
6
4
  * Functions and constants to access the window, window event listeners
@@ -58,7 +56,7 @@ declare global {
58
56
  *
59
57
  * - `window.DIMMING_OFF`
60
58
  */
61
- function get_dim_mode(): Opaque<"constant">;
59
+ function get_dim_mode(): number & { readonly __brand: "window.DIMMING_UNKNOWN" } | number & { readonly __brand: "window.DIMMING_ON" } | number & { readonly __brand: "window.DIMMING_OFF" };
62
60
  /**
63
61
  * This returns the content scale of the current display.
64
62
  *
@@ -113,7 +111,7 @@ declare global {
113
111
  *
114
112
  * - `window.DIMMING_OFF`
115
113
  */
116
- function set_dim_mode(mode: Opaque<"constant">): void;
114
+ function set_dim_mode(mode: number & { readonly __brand: "window.DIMMING_ON" } | number & { readonly __brand: "window.DIMMING_OFF" }): void;
117
115
  /**
118
116
  * Sets a window event listener. Only one window event listener can be set at a time.
119
117
  *
@@ -28,7 +28,8 @@ declare global {
28
28
  * @returns inflated buffer
29
29
  * @example
30
30
  * ```ts
31
- * const data = "\120\94\11\201\200\44\86\0\162\68\133\226\146\162\204\188\116\133\242\204\146\12\133\210\188\228\252\220\130\162\212\226\226\212\20\133\148\196\146\68\61\0\44\67\14\201";
31
+ * const data =
32
+ * "\x78\x5e\x0b\xc9\xc8\x2c\x56\x00\xa2\x44\x85\xe2\x92\xa2\xcc\xbc\x74\x85\xf2\xcc\x92\x0c\x85\xd2\xbc\xe4\xfc\xdc\x82\xa2\xd4\xe2\xe2\xd4\x14\x85\x94\xc4\x92\x44\x3d\x00\x2c\x43\x0e\xc9";
32
33
  * const uncompressed_data = zlib.inflate(data);
33
34
  * print(uncompressed_data); //> This is a string with uncompressed data.
34
35
  * ```
@@ -91,25 +91,6 @@ declare global {
91
91
  * ```
92
92
  */
93
93
  function dot(v1: Vector3 | Vector4, v2: Vector3 | Vector4): number;
94
- /**
95
- * Converts euler angles (x, y, z) in degrees into a quaternion
96
- * The error is guaranteed to be less than 0.001.
97
- * If the first argument is vector3, its values are used as x, y, z angles.
98
- *
99
- * @param x - rotation around x-axis in degrees or vector3 with euler angles in degrees
100
- * @param y - rotation around y-axis in degrees
101
- * @param z - rotation around z-axis in degrees
102
- * @returns quaternion describing an equivalent rotation (231 (YZX) rotation sequence)
103
- * @example
104
- * ```ts
105
- * const q = vmath.euler_to_quat(0, 45, 90);
106
- * print(q); // => vmath.quat(0.27059805393219, 0.27059805393219, 0.65328145027161, 0.65328145027161)
107
- *
108
- * const v = vmath.vector3(0, 0, 90);
109
- * print(vmath.euler_to_quat(v)); // => vmath.quat(0, 0, 0.70710676908493, 0.70710676908493)
110
- * ```
111
- */
112
- function euler_to_quat(x: number | Vector3, y: number, z: number): Quaternion;
113
94
  /**
114
95
  * The resulting matrix is the inverse of the supplied matrix.
115
96
  * For ortho-normal matrices, e.g. regular object transformation,
@@ -1,6 +1,4 @@
1
1
  /** @noSelfInFile */
2
- import type { Opaque } from "../src/core-types";
3
-
4
2
  declare global {
5
3
  /**
6
4
  * Functions and constants to access the window, window event listeners
@@ -58,7 +56,7 @@ declare global {
58
56
  *
59
57
  * - `window.DIMMING_OFF`
60
58
  */
61
- function get_dim_mode(): Opaque<"constant">;
59
+ function get_dim_mode(): number & { readonly __brand: "window.DIMMING_UNKNOWN" } | number & { readonly __brand: "window.DIMMING_ON" } | number & { readonly __brand: "window.DIMMING_OFF" };
62
60
  /**
63
61
  * This returns the content scale of the current display.
64
62
  *
@@ -113,7 +111,7 @@ declare global {
113
111
  *
114
112
  * - `window.DIMMING_OFF`
115
113
  */
116
- function set_dim_mode(mode: Opaque<"constant">): void;
114
+ function set_dim_mode(mode: number & { readonly __brand: "window.DIMMING_ON" } | number & { readonly __brand: "window.DIMMING_OFF" }): void;
117
115
  /**
118
116
  * Sets a window event listener. Only one window event listener can be set at a time.
119
117
  *
@@ -28,7 +28,8 @@ declare global {
28
28
  * @returns inflated buffer
29
29
  * @example
30
30
  * ```ts
31
- * const data = "\120\94\11\201\200\44\86\0\162\68\133\226\146\162\204\188\116\133\242\204\146\12\133\210\188\228\252\220\130\162\212\226\226\212\20\133\148\196\146\68\61\0\44\67\14\201";
31
+ * const data =
32
+ * "\x78\x5e\x0b\xc9\xc8\x2c\x56\x00\xa2\x44\x85\xe2\x92\xa2\xcc\xbc\x74\x85\xf2\xcc\x92\x0c\x85\xd2\xbc\xe4\xfc\xdc\x82\xa2\xd4\xe2\xe2\xd4\x14\x85\x94\xc4\x92\x44\x3d\x00\x2c\x43\x0e\xc9";
32
33
  * const uncompressed_data = zlib.inflate(data);
33
34
  * print(uncompressed_data); //> This is a string with uncompressed data.
34
35
  * ```
package/index.d.ts CHANGED
@@ -22,14 +22,13 @@ import "./generated/collectionproxy";
22
22
  import "./generated/compute";
23
23
  import "./generated/crash";
24
24
  import "./generated/factory";
25
+ import "./generated/font";
25
26
  import "./generated/go";
26
27
  import "./src/go-overloads";
27
28
  import "./generated/graphics";
28
29
  import "./generated/gui";
29
30
  import "./generated/html5";
30
31
  import "./generated/http";
31
- import "./generated/iac";
32
- import "./generated/iap";
33
32
  import "./generated/image";
34
33
  import "./generated/json";
35
34
  import "./generated/label";
@@ -40,8 +39,8 @@ import "./generated/msg";
40
39
  import "./generated/particlefx";
41
40
  import "./generated/physics";
42
41
  import "./generated/profiler";
43
- import "./generated/push";
44
42
  import "./generated/render";
43
+ import "./src/render-overloads";
45
44
  import "./generated/resource";
46
45
  import "./generated/socket";
47
46
  import "./src/socket-types";
@@ -53,7 +52,6 @@ import "./generated/timer";
53
52
  import "./generated/types";
54
53
  import "./generated/vmath";
55
54
  import "./src/vmath-overloads";
56
- import "./generated/webview";
57
55
  import "./generated/window";
58
56
  import "./generated/zlib";
59
57
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defold-typescript/types",
3
- "version": "0.34.0",
3
+ "version": "0.36.0",
4
4
  "description": "TypeScript types for the Defold engine's Lua APIs.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -66,7 +66,12 @@
66
66
  "!src/**/*.test.ts",
67
67
  "!scripts/**/*.test.ts",
68
68
  "!src/**/__snapshots__",
69
- "!scripts/lua-types-signature-index.ts"
69
+ "!scripts/lua-types-signature-index.ts",
70
+ "!scripts/fidelity-audit.ts",
71
+ "!scripts/augmentation-namespaces.ts",
72
+ "!scripts/example-pins.ts",
73
+ "!scripts/example-surfaces.ts",
74
+ "!scripts/example-typecheck.ts"
70
75
  ],
71
76
  "publishConfig": {
72
77
  "access": "public"
@@ -0,0 +1,23 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { resolve } from "node:path";
3
+ import type { ModuleManifestEntry } from "./regen";
4
+
5
+ // Committed declarations the `resolve` emitter must reproduce for the extensions
6
+ // whose ref-docs this repo carries. They are a golden lane, not a surface: no
7
+ // entrypoint, kind index or pinned version imports them. They live in their own
8
+ // module because `resolve` imports `regen.ts` from the published package, which
9
+ // does not ship these root fixtures, so reading them at `regen.ts` load time would
10
+ // break every installed `resolve`.
11
+ export const EXTENSION_GOLDENS_DIR = "extension-goldens";
12
+
13
+ const PACKAGE_ROOT = resolve(import.meta.dir, "..");
14
+ const EXTENSION_GOLDEN_NAMESPACES = ["iac", "iap", "push", "webview"] as const;
15
+
16
+ export const EXTENSION_GOLDEN_MANIFEST: readonly ModuleManifestEntry[] =
17
+ EXTENSION_GOLDEN_NAMESPACES.map((namespace) => ({
18
+ namespace,
19
+ doc: JSON.parse(
20
+ readFileSync(resolve(PACKAGE_ROOT, "fixtures", `${namespace}_doc.json`), "utf8"),
21
+ ),
22
+ outFile: `${namespace}.d.ts`,
23
+ }));
@@ -1,7 +1,14 @@
1
1
  import { resolve } from "node:path";
2
2
  import { symbolIdentityKey } from "../src/api-availability";
3
+ import type { SlotTypes } from "../src/emit-dts";
3
4
  import { selectCompleteVersionSurfaces, versionOf } from "./generate-api-availability";
4
- import { generateModuleSignatures, loadApiTargets, loadTargetModules } from "./regen";
5
+ import {
6
+ generateModuleSignatures,
7
+ loadApiTargets,
8
+ loadTargetModules,
9
+ type ModuleManifestEntry,
10
+ } from "./regen";
11
+ import { loadSignatureFile } from "./signature-store-fs";
5
12
 
6
13
  const PACKAGE_ROOT = resolve(import.meta.dir, "..");
7
14
  const SIGNATURES_PATH = resolve(PACKAGE_ROOT, "api-signatures.json");
@@ -9,6 +16,11 @@ const SIGNATURES_PATH = resolve(PACKAGE_ROOT, "api-signatures.json");
9
16
  export interface SignaturesArtifact {
10
17
  // version -> symbolIdentityKey -> authoritative TS signature text
11
18
  readonly versions: Record<string, Record<string, string>>;
19
+ // The same axis and keys, carrying each documented slot's rendered type. Kept
20
+ // parallel rather than folded into `versions` because three consumers
21
+ // (`api-surface-loader`, `combined-surface`, `version-window`) type that map's
22
+ // value as a string; a symbol documenting no slot is absent here.
23
+ readonly slotTypes: Record<string, Record<string, SlotTypes>>;
12
24
  }
13
25
 
14
26
  export interface BuildSignaturesOptions {
@@ -16,9 +28,38 @@ export interface BuildSignaturesOptions {
16
28
  readonly registryPath?: string;
17
29
  }
18
30
 
19
- function sortObjectKeys(record: Record<string, string>): Record<string, string> {
20
- const sorted: Record<string, string> = {};
21
- for (const key of Object.keys(record).sort()) sorted[key] = record[key] as string;
31
+ // The authored replacement for a symbol the skip filter withheld, read from the
32
+ // same `signatures/<ns>.json` store the version-prefixed API pages render from.
33
+ // One seam keeps all three artifacts consistent: `overloads-signature-parity`
34
+ // pins the store to the `src/*-overloads.d.ts` declarations, so folding the
35
+ // store in cannot drift from the surface a consumer actually compiles against.
36
+ function authoredSignature(packageRoot: string, namespace: string, fqn: string): string | null {
37
+ const store = loadSignatureFile(resolve(packageRoot, "signatures", `${namespace}.json`));
38
+ const forms = store[fqn]?.signatures ?? [];
39
+ return forms.length > 0 ? forms.join("\n") : null;
40
+ }
41
+
42
+ // The symbols `skipFunctions` removed from this module, as the difference
43
+ // between the unfiltered and filtered signature emits. Derived rather than
44
+ // re-matched so the withholding rules stay owned by `prepareGeneratedModule`.
45
+ export function withheldSymbols(entry: ModuleManifestEntry): { key: string; fqn: string }[] {
46
+ if ((entry.skipFunctions ?? []).length === 0) return [];
47
+ const kept = new Set(
48
+ generateModuleSignatures(entry).map(({ identity }) => symbolIdentityKey(identity)),
49
+ );
50
+ const withheld: { key: string; fqn: string }[] = [];
51
+ for (const { identity } of generateModuleSignatures({ ...entry, skipFunctions: [] })) {
52
+ const key = symbolIdentityKey(identity);
53
+ if (kept.has(key)) continue;
54
+ const fqn = key.split("\0")[2] as string;
55
+ withheld.push({ key, fqn });
56
+ }
57
+ return withheld;
58
+ }
59
+
60
+ function sortObjectKeys<T>(record: Record<string, T>): Record<string, T> {
61
+ const sorted: Record<string, T> = {};
62
+ for (const key of Object.keys(record).sort()) sorted[key] = record[key] as T;
22
63
  return sorted;
23
64
  }
24
65
 
@@ -27,17 +68,33 @@ export function buildSignaturesArtifact(options: BuildSignaturesOptions = {}): S
27
68
  const registryPath = options.registryPath ?? resolve(packageRoot, "api-targets.json");
28
69
  const targets = selectCompleteVersionSurfaces(loadApiTargets(registryPath));
29
70
  const versions: Record<string, Record<string, string>> = {};
71
+ const slotTypes: Record<string, Record<string, SlotTypes>> = {};
30
72
  for (const target of targets) {
31
73
  const version = versionOf(target);
32
74
  const perSymbol: Record<string, string> = {};
75
+ const perSymbolSlots: Record<string, SlotTypes> = {};
33
76
  for (const entry of loadTargetModules(target, packageRoot)) {
34
- for (const { identity, tsSignature } of generateModuleSignatures(entry)) {
35
- perSymbol[symbolIdentityKey(identity)] = tsSignature;
77
+ for (const signature of generateModuleSignatures(entry)) {
78
+ const key = symbolIdentityKey(signature.identity);
79
+ perSymbol[key] = signature.tsSignature;
80
+ if (Object.keys(signature.slotTypes).length > 0) {
81
+ perSymbolSlots[key] = sortObjectKeys({ ...signature.slotTypes });
82
+ }
83
+ }
84
+ // An authored fold replaces the declaration text wholesale, so whatever
85
+ // slots the generated emit had recorded no longer describe it.
86
+ for (const { key, fqn } of withheldSymbols(entry)) {
87
+ const authored = authoredSignature(packageRoot, entry.namespace, fqn);
88
+ if (authored !== null) {
89
+ perSymbol[key] = authored;
90
+ delete perSymbolSlots[key];
91
+ }
36
92
  }
37
93
  }
38
94
  versions[version] = sortObjectKeys(perSymbol);
95
+ slotTypes[version] = sortObjectKeys(perSymbolSlots);
39
96
  }
40
- return { versions };
97
+ return { versions, slotTypes };
41
98
  }
42
99
 
43
100
  function biomeFormatJson(raw: string): string {
@@ -47,7 +104,14 @@ function biomeFormatJson(raw: string): string {
47
104
  if (out.exitCode !== 0) {
48
105
  throw new Error(`biome format failed: ${out.stderr.toString()}`);
49
106
  }
50
- return out.stdout.toString();
107
+ const formatted = out.stdout.toString();
108
+ // Biome exits 0 and emits nothing for input it declined to read (a payload over
109
+ // `files.maxSize` is reported only on stderr), which would otherwise serialize
110
+ // the artifact as an empty file.
111
+ if (formatted.length === 0) {
112
+ throw new Error(`biome format produced no output: ${out.stderr.toString()}`);
113
+ }
114
+ return formatted;
51
115
  }
52
116
 
53
117
  export function serializeSignaturesArtifact(artifact: SignaturesArtifact): string {
@@ -15,7 +15,12 @@ import {
15
15
  resolveTargetModules,
16
16
  } from "./regen";
17
17
 
18
- export { RUNTIME_KIND_MANIFEST, SRC_AUGMENTATION_MODULES, targetKindManifest } from "./regen";
18
+ export {
19
+ RESTRICTED_SRC_AUGMENTATIONS,
20
+ RUNTIME_KIND_MANIFEST,
21
+ SRC_AUGMENTATION_MODULES,
22
+ targetKindManifest,
23
+ } from "./regen";
19
24
 
20
25
  // The surface's own `core-types` module: a re-export of the installed package's,
21
26
  // so every declaration in the surface reaches the brand types through a
@@ -26,6 +31,10 @@ export interface RenderMaterializedKindIndexOptions {
26
31
  readonly kind: string;
27
32
  readonly universalModules: readonly string[];
28
33
  readonly restrictedModule: string | null;
34
+ // The `src/*` augmentations this kind earns because they re-open the very
35
+ // namespace the kind is restricted to. They sit outside `universalModules`
36
+ // precisely so no other kind imports them.
37
+ readonly restrictedAugmentations?: readonly string[];
29
38
  // Set for a kind built from the target's own editor documents. It replaces
30
39
  // the universal set outright — an editor kind is disjoint from the runtime
31
40
  // surface, not a narrowing of it.
@@ -54,6 +63,11 @@ export function renderMaterializedKindIndex(opts: RenderMaterializedKindIndexOpt
54
63
  if (entry.only === undefined && opts.restrictedModule) {
55
64
  lines.push(`import "../${opts.restrictedModule}";`);
56
65
  }
66
+ if (entry.only === undefined) {
67
+ for (const augmentation of opts.restrictedAugmentations ?? []) {
68
+ lines.push(`import "../${augmentation}";`);
69
+ }
70
+ }
57
71
  const from = installedFactoryModule(entry);
58
72
  const values = [entry.factory, ...(entry.extraExports ?? [])].join(", ");
59
73
  const typeExports = entry.extraTypeExports?.length