typed-factorio 1.6.1 → 1.7.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,153 @@
1
+ import {ChildProcess} from 'child_process';
2
+
3
+ declare namespace open {
4
+ interface Options {
5
+ /**
6
+ Wait for the opened app to exit before fulfilling the promise. If `false` it's fulfilled immediately when opening the app.
7
+
8
+ Note that it waits for the app to exit, not just for the window to close.
9
+
10
+ On Windows, you have to explicitly specify an app for it to be able to wait.
11
+
12
+ @default false
13
+ */
14
+ readonly wait?: boolean;
15
+
16
+ /**
17
+ __macOS only__
18
+
19
+ Do not bring the app to the foreground.
20
+
21
+ @default false
22
+ */
23
+ readonly background?: boolean;
24
+
25
+ /**
26
+ __macOS only__
27
+
28
+ Open a new instance of the app even it's already running.
29
+
30
+ A new instance is always opened on other platforms.
31
+
32
+ @default false
33
+ */
34
+ readonly newInstance?: boolean;
35
+
36
+ /**
37
+ Specify the `name` of the app to open the `target` with, and optionally, app `arguments`. `app` can be an array of apps to try to open and `name` can be an array of app names to try. If each app fails, the last error will be thrown.
38
+
39
+ The app name is platform dependent. Don't hard code it in reusable modules. For example, Chrome is `google chrome` on macOS, `google-chrome` on Linux and `chrome` on Windows. If possible, use [`open.apps`](#openapps) which auto-detects the correct binary to use.
40
+
41
+ You may also pass in the app's full path. For example on WSL, this can be `/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe` for the Windows installation of Chrome.
42
+
43
+ The app `arguments` are app dependent. Check the app's documentation for what arguments it accepts.
44
+ */
45
+ readonly app?: App | readonly App[];
46
+
47
+ /**
48
+ Allow the opened app to exit with nonzero exit code when the `wait` option is `true`.
49
+
50
+ We do not recommend setting this option. The convention for success is exit code zero.
51
+
52
+ @default false
53
+ */
54
+ readonly allowNonzeroExitCode?: boolean;
55
+ }
56
+
57
+ interface OpenAppOptions extends Omit<Options, 'app'> {
58
+ /**
59
+ Arguments passed to the app.
60
+
61
+ These arguments are app dependent. Check the app's documentation for what arguments it accepts.
62
+ */
63
+ readonly arguments?: readonly string[];
64
+ }
65
+
66
+ type AppName =
67
+ | 'chrome'
68
+ | 'firefox'
69
+ | 'edge';
70
+
71
+ type App = {
72
+ name: string | readonly string[];
73
+ arguments?: readonly string[];
74
+ };
75
+ }
76
+
77
+ // eslint-disable-next-line no-redeclare
78
+ declare const open: {
79
+ /**
80
+ Open stuff like URLs, files, executables. Cross-platform.
81
+
82
+ Uses the command `open` on macOS, `start` on Windows and `xdg-open` on other platforms.
83
+
84
+ There is a caveat for [double-quotes on Windows](https://github.com/sindresorhus/open#double-quotes-on-windows) where all double-quotes are stripped from the `target`.
85
+
86
+ @param target - The thing you want to open. Can be a URL, file, or executable. Opens in the default app for the file type. For example, URLs open in your default browser.
87
+ @returns The [spawned child process](https://nodejs.org/api/child_process.html#child_process_class_childprocess). You would normally not need to use this for anything, but it can be useful if you'd like to attach custom event listeners or perform other operations directly on the spawned process.
88
+
89
+ @example
90
+ ```
91
+ import open = require('open');
92
+
93
+ // Opens the image in the default image viewer
94
+ await open('unicorn.png', {wait: true});
95
+ console.log('The image viewer app closed');
96
+
97
+ // Opens the url in the default browser
98
+ await open('https://sindresorhus.com');
99
+
100
+ // Opens the URL in a specified browser.
101
+ await open('https://sindresorhus.com', {app: {name: 'firefox'}});
102
+
103
+ // Specify app arguments.
104
+ await open('https://sindresorhus.com', {app: {name: 'google chrome', arguments: ['--incognito']}});
105
+ ```
106
+ */
107
+ (
108
+ target: string,
109
+ options?: open.Options
110
+ ): Promise<ChildProcess>;
111
+
112
+ /**
113
+ An object containing auto-detected binary names for common apps. Useful to work around cross-platform differences.
114
+
115
+ @example
116
+ ```
117
+ import open = require('open');
118
+
119
+ await open('https://google.com', {
120
+ app: {
121
+ name: open.apps.chrome
122
+ }
123
+ });
124
+ ```
125
+ */
126
+ apps: Record<open.AppName, string | readonly string[]>;
127
+
128
+ /**
129
+ Open an app. Cross-platform.
130
+
131
+ Uses the command `open` on macOS, `start` on Windows and `xdg-open` on other platforms.
132
+
133
+ @param name - The app you want to open. Can be either builtin supported `open.apps` names or other name supported in platform.
134
+ @returns The [spawned child process](https://nodejs.org/api/child_process.html#child_process_class_childprocess). You would normally not need to use this for anything, but it can be useful if you'd like to attach custom event listeners or perform other operations directly on the spawned process.
135
+
136
+ @example
137
+ ```
138
+ const {apps, openApp} = require('open');
139
+
140
+ // Open Firefox
141
+ await openApp(apps.firefox);
142
+
143
+ // Open Chrome incognito mode
144
+ await openApp(apps.chrome, {arguments: ['--incognito']});
145
+
146
+ // Open Xcode
147
+ await openApp('xcode');
148
+ ```
149
+ */
150
+ openApp: (name: open.App['name'], options?: open.OpenAppOptions) => Promise<ChildProcess>;
151
+ };
152
+
153
+ export = open;
@@ -1407,8 +1407,8 @@ interface LuaControl {
1407
1407
  * @remarks Items in the cursor stack will take priority over the cursor ghost.
1408
1408
  * @see {@link https://lua-api.factorio.com/latest/LuaControl.html#LuaControl.cursor_ghost Online documentation}
1409
1409
  */
1410
- get cursor_ghost(): LuaItemPrototype
1411
- set cursor_ghost(value: ItemPrototypeIdentification)
1410
+ get cursor_ghost(): LuaItemPrototype | nil
1411
+ set cursor_ghost(value: ItemPrototypeIdentification | nil)
1412
1412
  /**
1413
1413
  * `true` if the player is in a vehicle. Writing to this attribute puts the player in or out of a vehicle.
1414
1414
  *
@@ -2941,6 +2941,13 @@ interface LuaEntity extends LuaControl {
2941
2941
  * @see {@link https://lua-api.factorio.com/latest/LuaEntity.html#LuaEntity.get_spider_legs Online documentation}
2942
2942
  */
2943
2943
  get_spider_legs(): LuaEntity[]
2944
+ /**
2945
+ * Stops the given SpiderVehicle.
2946
+ *
2947
+ * _Can only be used if this is SpiderVehicle_
2948
+ * @see {@link https://lua-api.factorio.com/latest/LuaEntity.html#LuaEntity.stop_spider Online documentation}
2949
+ */
2950
+ stop_spider(): void
2944
2951
  /**
2945
2952
  * Name of the entity prototype. E.g. "inserter" or "filter-inserter".
2946
2953
  * @see {@link https://lua-api.factorio.com/latest/LuaEntity.html#LuaEntity.name Online documentation}
@@ -3261,8 +3268,8 @@ interface LuaEntity extends LuaControl {
3261
3268
  * @remarks Car color is overridden by the color of the current driver/passenger, if there is one.
3262
3269
  * @see {@link https://lua-api.factorio.com/latest/LuaEntity.html#LuaEntity.color Online documentation}
3263
3270
  */
3264
- get color(): Color
3265
- set color(value: Color | ColorArray)
3271
+ get color(): Color | nil
3272
+ set color(value: Color | ColorArray | nil)
3266
3273
  /**
3267
3274
  * The text of this flying-text entity.
3268
3275
  *
@@ -3406,8 +3413,8 @@ interface LuaEntity extends LuaControl {
3406
3413
  * _Can only be used if this is EntityWithOwner_
3407
3414
  * @see {@link https://lua-api.factorio.com/latest/LuaEntity.html#LuaEntity.last_user Online documentation}
3408
3415
  */
3409
- get last_user(): LuaPlayer | LuaPlayer
3410
- set last_user(value: LuaPlayer | PlayerIdentification)
3416
+ get last_user(): LuaPlayer | nil
3417
+ set last_user(value: LuaPlayer | PlayerIdentification | nil)
3411
3418
  /**
3412
3419
  * The buffer size for the electric energy source. `nil` if the entity doesn't have an electric energy source.
3413
3420
  * @remarks Write access is limited to the ElectricEnergyInterface type
@@ -3695,8 +3702,8 @@ interface LuaEntity extends LuaControl {
3695
3702
  * @remarks A character associated with a player is not directly controlled by any player.
3696
3703
  * @see {@link https://lua-api.factorio.com/latest/LuaEntity.html#LuaEntity.associated_player Online documentation}
3697
3704
  */
3698
- get associated_player(): LuaPlayer | LuaPlayer
3699
- set associated_player(value: LuaPlayer | PlayerIdentification)
3705
+ get associated_player(): LuaPlayer | nil
3706
+ set associated_player(value: LuaPlayer | PlayerIdentification | nil)
3700
3707
  /**
3701
3708
  * The last tick this character entity was attacked.
3702
3709
  *
@@ -3827,15 +3834,15 @@ interface LuaEntity extends LuaControl {
3827
3834
  * Reading this property will return a {@link LuaPlayer}, while {@link PlayerIdentification} can be used when writing.
3828
3835
  * @see {@link https://lua-api.factorio.com/latest/LuaEntity.html#LuaEntity.render_player Online documentation}
3829
3836
  */
3830
- get render_player(): LuaPlayer | LuaPlayer
3831
- set render_player(value: LuaPlayer | PlayerIdentification)
3837
+ get render_player(): LuaPlayer | nil
3838
+ set render_player(value: LuaPlayer | PlayerIdentification | nil)
3832
3839
  /**
3833
3840
  * The forces that this `simple-entity-with-owner`, `simple-entity-with-force`, or `flying-text` is visible to. `nil` or an empty array when this entity is rendered for all forces.
3834
3841
  * @remarks Reading will always give an array of {@link LuaForce}
3835
3842
  * @see {@link https://lua-api.factorio.com/latest/LuaEntity.html#LuaEntity.render_to_forces Online documentation}
3836
3843
  */
3837
- get render_to_forces(): LuaForce[]
3838
- set render_to_forces(value: readonly ForceIdentification[])
3844
+ get render_to_forces(): LuaForce[] | nil
3845
+ set render_to_forces(value: readonly ForceIdentification[] | nil)
3839
3846
  /**
3840
3847
  * The rail target of this pump, if any.
3841
3848
  *
@@ -3931,8 +3938,8 @@ interface LuaEntity extends LuaControl {
3931
3938
  * _Can only be used if this is SpiderVehicle_
3932
3939
  * @see {@link https://lua-api.factorio.com/latest/LuaEntity.html#LuaEntity.autopilot_destination Online documentation}
3933
3940
  */
3934
- get autopilot_destination(): MapPosition
3935
- set autopilot_destination(value: MapPosition | MapPositionArray)
3941
+ get autopilot_destination(): MapPosition | nil
3942
+ set autopilot_destination(value: MapPosition | MapPositionArray | nil)
3936
3943
  /**
3937
3944
  * The queued destination positions of spidertron's autopilot.
3938
3945
  *
@@ -3941,21 +3948,21 @@ interface LuaEntity extends LuaControl {
3941
3948
  */
3942
3949
  readonly autopilot_destinations: MapPosition[]
3943
3950
  /**
3944
- * Amount of trains related to this particular train stop. Includes train stopped at this train stop (until it finds a path to next target) and trains having this train stop as goal or waypoint. Writing nil will disable the limit (will set a maximum possible value).
3951
+ * Amount of trains related to this particular train stop. Includes train stopped at this train stop (until it finds a path to next target) and trains having this train stop as goal or waypoint.
3945
3952
  *
3946
3953
  * _Can only be used if this is TrainStop_
3947
3954
  * @remarks Train may be included multiple times when braking distance covers this train stop multiple times<br>Value may be read even when train stop has no control behavior
3948
3955
  * @see {@link https://lua-api.factorio.com/latest/LuaEntity.html#LuaEntity.trains_count Online documentation}
3949
3956
  */
3950
- readonly trains_count: uint | nil
3957
+ readonly trains_count: uint
3951
3958
  /**
3952
- * Amount of trains above which no new trains will be sent to this train stop.
3959
+ * Amount of trains above which no new trains will be sent to this train stop. Writing nil will disable the limit (will set a maximum possible value).
3953
3960
  *
3954
3961
  * _Can only be used if this is TrainStop_
3955
3962
  * @remarks When a train stop has a control behavior with wire connected and set_trains_limit enabled, this value will be overwritten by it
3956
3963
  * @see {@link https://lua-api.factorio.com/latest/LuaEntity.html#LuaEntity.trains_limit Online documentation}
3957
3964
  */
3958
- trains_limit: uint
3965
+ trains_limit: uint | nil
3959
3966
  /**
3960
3967
  * (deprecated by 1.1.51) If this entity is a MilitaryTarget. Returns same value as LuaEntity::is_military_target
3961
3968
  * @see {@link https://lua-api.factorio.com/latest/LuaEntity.html#LuaEntity.is_entity_with_force Online documentation}
@@ -4760,8 +4767,8 @@ interface BaseEntity extends LuaControl {
4760
4767
  * @remarks Car color is overridden by the color of the current driver/passenger, if there is one.
4761
4768
  * @see {@link https://lua-api.factorio.com/latest/LuaEntity.html#LuaEntity.color Online documentation}
4762
4769
  */
4763
- get color(): Color
4764
- set color(value: Color | ColorArray)
4770
+ get color(): Color | nil
4771
+ set color(value: Color | ColorArray | nil)
4765
4772
  /**
4766
4773
  * The productivity bonus of this entity.
4767
4774
  * @remarks This includes force based bonuses as well as beacon/module bonuses.
@@ -4991,15 +4998,15 @@ interface BaseEntity extends LuaControl {
4991
4998
  * Reading this property will return a {@link LuaPlayer}, while {@link PlayerIdentification} can be used when writing.
4992
4999
  * @see {@link https://lua-api.factorio.com/latest/LuaEntity.html#LuaEntity.render_player Online documentation}
4993
5000
  */
4994
- get render_player(): LuaPlayer | LuaPlayer
4995
- set render_player(value: LuaPlayer | PlayerIdentification)
5001
+ get render_player(): LuaPlayer | nil
5002
+ set render_player(value: LuaPlayer | PlayerIdentification | nil)
4996
5003
  /**
4997
5004
  * The forces that this `simple-entity-with-owner`, `simple-entity-with-force`, or `flying-text` is visible to. `nil` or an empty array when this entity is rendered for all forces.
4998
5005
  * @remarks Reading will always give an array of {@link LuaForce}
4999
5006
  * @see {@link https://lua-api.factorio.com/latest/LuaEntity.html#LuaEntity.render_to_forces Online documentation}
5000
5007
  */
5001
- get render_to_forces(): LuaForce[]
5002
- set render_to_forces(value: readonly ForceIdentification[])
5008
+ get render_to_forces(): LuaForce[] | nil
5009
+ set render_to_forces(value: readonly ForceIdentification[] | nil)
5003
5010
  /**
5004
5011
  * Returns the id of the electric network that this entity is connected to, if any.
5005
5012
  * @see {@link https://lua-api.factorio.com/latest/LuaEntity.html#LuaEntity.electric_network_id Online documentation}
@@ -5784,21 +5791,21 @@ interface TrainStopEntity extends BaseEntity {
5784
5791
  */
5785
5792
  readonly connected_rail_direction: defines.rail_direction
5786
5793
  /**
5787
- * Amount of trains related to this particular train stop. Includes train stopped at this train stop (until it finds a path to next target) and trains having this train stop as goal or waypoint. Writing nil will disable the limit (will set a maximum possible value).
5794
+ * Amount of trains related to this particular train stop. Includes train stopped at this train stop (until it finds a path to next target) and trains having this train stop as goal or waypoint.
5788
5795
  *
5789
5796
  * _Can only be used if this is TrainStop_
5790
5797
  * @remarks Train may be included multiple times when braking distance covers this train stop multiple times<br>Value may be read even when train stop has no control behavior
5791
5798
  * @see {@link https://lua-api.factorio.com/latest/LuaEntity.html#LuaEntity.trains_count Online documentation}
5792
5799
  */
5793
- readonly trains_count: uint | nil
5800
+ readonly trains_count: uint
5794
5801
  /**
5795
- * Amount of trains above which no new trains will be sent to this train stop.
5802
+ * Amount of trains above which no new trains will be sent to this train stop. Writing nil will disable the limit (will set a maximum possible value).
5796
5803
  *
5797
5804
  * _Can only be used if this is TrainStop_
5798
5805
  * @remarks When a train stop has a control behavior with wire connected and set_trains_limit enabled, this value will be overwritten by it
5799
5806
  * @see {@link https://lua-api.factorio.com/latest/LuaEntity.html#LuaEntity.trains_limit Online documentation}
5800
5807
  */
5801
- trains_limit: uint
5808
+ trains_limit: uint | nil
5802
5809
  }
5803
5810
 
5804
5811
  /**
@@ -5885,6 +5892,13 @@ interface SpiderVehicleEntity extends BaseEntity {
5885
5892
  * @see {@link https://lua-api.factorio.com/latest/LuaEntity.html#LuaEntity.get_spider_legs Online documentation}
5886
5893
  */
5887
5894
  get_spider_legs(): LuaEntity[]
5895
+ /**
5896
+ * Stops the given SpiderVehicle.
5897
+ *
5898
+ * _Can only be used if this is SpiderVehicle_
5899
+ * @see {@link https://lua-api.factorio.com/latest/LuaEntity.html#LuaEntity.stop_spider Online documentation}
5900
+ */
5901
+ stop_spider(): void
5888
5902
  /**
5889
5903
  * The torso orientation of this spider vehicle.
5890
5904
  *
@@ -5905,8 +5919,8 @@ interface SpiderVehicleEntity extends BaseEntity {
5905
5919
  * _Can only be used if this is SpiderVehicle_
5906
5920
  * @see {@link https://lua-api.factorio.com/latest/LuaEntity.html#LuaEntity.autopilot_destination Online documentation}
5907
5921
  */
5908
- get autopilot_destination(): MapPosition
5909
- set autopilot_destination(value: MapPosition | MapPositionArray)
5922
+ get autopilot_destination(): MapPosition | nil
5923
+ set autopilot_destination(value: MapPosition | MapPositionArray | nil)
5910
5924
  /**
5911
5925
  * The queued destination positions of spidertron's autopilot.
5912
5926
  *
@@ -6124,8 +6138,8 @@ interface CharacterEntity extends BaseEntity {
6124
6138
  * @remarks A character associated with a player is not directly controlled by any player.
6125
6139
  * @see {@link https://lua-api.factorio.com/latest/LuaEntity.html#LuaEntity.associated_player Online documentation}
6126
6140
  */
6127
- get associated_player(): LuaPlayer | LuaPlayer
6128
- set associated_player(value: LuaPlayer | PlayerIdentification)
6141
+ get associated_player(): LuaPlayer | nil
6142
+ set associated_player(value: LuaPlayer | PlayerIdentification | nil)
6129
6143
  /**
6130
6144
  * The last tick this character entity was attacked.
6131
6145
  *
@@ -6222,8 +6236,8 @@ interface EntityWithOwnerEntity extends BaseEntity {
6222
6236
  * _Can only be used if this is EntityWithOwner_
6223
6237
  * @see {@link https://lua-api.factorio.com/latest/LuaEntity.html#LuaEntity.last_user Online documentation}
6224
6238
  */
6225
- get last_user(): LuaPlayer | LuaPlayer
6226
- set last_user(value: LuaPlayer | PlayerIdentification)
6239
+ get last_user(): LuaPlayer | nil
6240
+ set last_user(value: LuaPlayer | PlayerIdentification | nil)
6227
6241
  }
6228
6242
 
6229
6243
  interface ElectricEnergyInterfaceEntity extends BaseEntity {
@@ -11351,8 +11365,8 @@ interface LuaForce {
11351
11365
  * Custom color for this force. If specified, will take priority over other sources of the force color. Writing nil clears custom color. Will return nil if it was not specified or if was set to {0,0,0,0}
11352
11366
  * @see {@link https://lua-api.factorio.com/latest/LuaForce.html#LuaForce.custom_color Online documentation}
11353
11367
  */
11354
- get custom_color(): Color
11355
- set custom_color(value: Color | ColorArray)
11368
+ get custom_color(): Color | nil
11369
+ set custom_color(value: Color | ColorArray | nil)
11356
11370
  /**
11357
11371
  * Effective color of this force.
11358
11372
  * @see {@link https://lua-api.factorio.com/latest/LuaForce.html#LuaForce.color Online documentation}
@@ -13278,8 +13292,8 @@ interface BaseGuiElement {
13278
13292
  * The location of this widget when stored in {@link LuaGui#screen LuaGui::screen}. `nil` if not set or not in {@link LuaGui#screen LuaGui::screen}.
13279
13293
  * @see {@link https://lua-api.factorio.com/latest/LuaGuiElement.html#LuaGuiElement.location Online documentation}
13280
13294
  */
13281
- get location(): GuiLocation
13282
- set location(value: GuiLocation | GuiLocationArray)
13295
+ get location(): GuiLocation | nil
13296
+ set location(value: GuiLocation | GuiLocationArray | nil)
13283
13297
  /**
13284
13298
  * Whether this GUI element is enabled. Disabled GUI elements don't trigger events when clicked.
13285
13299
  * @see {@link https://lua-api.factorio.com/latest/LuaGuiElement.html#LuaGuiElement.enabled Online documentation}
@@ -16322,16 +16336,16 @@ interface LuaItemStack {
16322
16336
  * _Can only be used if this is BlueprintItem_
16323
16337
  * @see {@link https://lua-api.factorio.com/latest/LuaItemStack.html#LuaItemStack.blueprint_snap_to_grid Online documentation}
16324
16338
  */
16325
- get blueprint_snap_to_grid(): TilePosition
16326
- set blueprint_snap_to_grid(value: TilePosition | TilePositionArray)
16339
+ get blueprint_snap_to_grid(): TilePosition | nil
16340
+ set blueprint_snap_to_grid(value: TilePosition | TilePositionArray | nil)
16327
16341
  /**
16328
16342
  * The offset from the absolute grid. `nil` if absolute snapping is not enabled.
16329
16343
  *
16330
16344
  * _Can only be used if this is BlueprintItem_
16331
16345
  * @see {@link https://lua-api.factorio.com/latest/LuaItemStack.html#LuaItemStack.blueprint_position_relative_to_grid Online documentation}
16332
16346
  */
16333
- get blueprint_position_relative_to_grid(): TilePosition
16334
- set blueprint_position_relative_to_grid(value: TilePosition | TilePositionArray)
16347
+ get blueprint_position_relative_to_grid(): TilePosition | nil
16348
+ set blueprint_position_relative_to_grid(value: TilePosition | TilePositionArray | nil)
16335
16349
  /**
16336
16350
  * If absolute snapping is enabled on this blueprint item.
16337
16351
  *
@@ -16352,8 +16366,8 @@ interface LuaItemStack {
16352
16366
  * _Can only be used if this is ItemWithLabel_
16353
16367
  * @see {@link https://lua-api.factorio.com/latest/LuaItemStack.html#LuaItemStack.label_color Online documentation}
16354
16368
  */
16355
- get label_color(): Color
16356
- set label_color(value: Color | ColorArray)
16369
+ get label_color(): Color | nil
16370
+ set label_color(value: Color | ColorArray | nil)
16357
16371
  /**
16358
16372
  * Whether the label for this item can be manually changed. When false the label can only be changed through the API.
16359
16373
  *
@@ -17007,16 +17021,16 @@ interface BlueprintItemStack extends BaseItemStack {
17007
17021
  * _Can only be used if this is BlueprintItem_
17008
17022
  * @see {@link https://lua-api.factorio.com/latest/LuaItemStack.html#LuaItemStack.blueprint_snap_to_grid Online documentation}
17009
17023
  */
17010
- get blueprint_snap_to_grid(): TilePosition
17011
- set blueprint_snap_to_grid(value: TilePosition | TilePositionArray)
17024
+ get blueprint_snap_to_grid(): TilePosition | nil
17025
+ set blueprint_snap_to_grid(value: TilePosition | TilePositionArray | nil)
17012
17026
  /**
17013
17027
  * The offset from the absolute grid. `nil` if absolute snapping is not enabled.
17014
17028
  *
17015
17029
  * _Can only be used if this is BlueprintItem_
17016
17030
  * @see {@link https://lua-api.factorio.com/latest/LuaItemStack.html#LuaItemStack.blueprint_position_relative_to_grid Online documentation}
17017
17031
  */
17018
- get blueprint_position_relative_to_grid(): TilePosition
17019
- set blueprint_position_relative_to_grid(value: TilePosition | TilePositionArray)
17032
+ get blueprint_position_relative_to_grid(): TilePosition | nil
17033
+ set blueprint_position_relative_to_grid(value: TilePosition | TilePositionArray | nil)
17020
17034
  /**
17021
17035
  * If absolute snapping is enabled on this blueprint item.
17022
17036
  *
@@ -17277,8 +17291,8 @@ interface ItemWithLabelItemStack extends BaseItemStack {
17277
17291
  * _Can only be used if this is ItemWithLabel_
17278
17292
  * @see {@link https://lua-api.factorio.com/latest/LuaItemStack.html#LuaItemStack.label_color Online documentation}
17279
17293
  */
17280
- get label_color(): Color
17281
- set label_color(value: Color | ColorArray)
17294
+ get label_color(): Color | nil
17295
+ set label_color(value: Color | ColorArray | nil)
17282
17296
  /**
17283
17297
  * Whether the label for this item can be manually changed. When false the label can only be changed through the API.
17284
17298
  *
@@ -18340,7 +18354,7 @@ interface LuaPlayer extends LuaControl {
18340
18354
  */
18341
18355
  remove_alert(params: {
18342
18356
  readonly entity?: LuaEntity
18343
- readonly prototype?: LuaEntityPrototype
18357
+ readonly prototype?: LuaEntityPrototype | string
18344
18358
  readonly position?: MapPosition | MapPositionArray
18345
18359
  readonly type?: defines.alert_type
18346
18360
  readonly surface?: SurfaceIdentification
@@ -23084,7 +23098,7 @@ interface LuaSurface {
23084
23098
  */
23085
23099
  readonly can_open_gates?: boolean
23086
23100
  /**
23087
- * Defines how coarse the pathfinder's grid is. Smaller values mean a coarser grid (negative numbers allowed). Defaults to `0`.
23101
+ * Defines how coarse the pathfinder's grid is. Smaller values mean a coarser grid (negative numbers allowed). Allowed values are from -8 to 8. Defaults to `0`.
23088
23102
  */
23089
23103
  readonly path_resolution_modifier?: int
23090
23104
  /**
@@ -23887,8 +23901,8 @@ interface LuaTrain {
23887
23901
  * @remarks The schedule can't be changed by modifying the returned table. Instead, changes must be made by assigning a new table to this attribute.
23888
23902
  * @see {@link https://lua-api.factorio.com/latest/LuaTrain.html#LuaTrain.schedule Online documentation}
23889
23903
  */
23890
- get schedule(): TrainSchedule
23891
- set schedule(value: TrainScheduleWrite)
23904
+ get schedule(): TrainSchedule | nil
23905
+ set schedule(value: TrainScheduleWrite | nil)
23892
23906
  /**
23893
23907
  * This train's current state.
23894
23908
  * @see {@link https://lua-api.factorio.com/latest/LuaTrain.html#LuaTrain.state Online documentation}
@@ -3398,6 +3398,9 @@ interface AmmoType {
3398
3398
  * Energy consumption of a single shot, if applicable. Defaults to `0`.
3399
3399
  */
3400
3400
  readonly energy_consumption?: double
3401
+ readonly range_modifier?: double
3402
+ readonly cooldown_modifier?: double
3403
+ readonly consumption_modifier?: double
3401
3404
  }
3402
3405
 
3403
3406
  interface BeamTarget {
@@ -4119,9 +4122,9 @@ interface LogisticFilter {
4119
4122
  */
4120
4123
  interface ModSetting {
4121
4124
  /**
4122
- * The value of the mod setting. The type depends on the setting.
4125
+ * The value of the mod setting. The type depends on the kind of setting.
4123
4126
  */
4124
- readonly value: uint | double | boolean | string
4127
+ readonly value: int | double | boolean | string
4125
4128
  }
4126
4129
 
4127
4130
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "typed-factorio",
3
- "version": "1.6.1",
3
+ "version": "1.7.3",
4
4
  "description": "Featureful typescript definitions for the the Factorio modding lua api.",
5
5
  "keywords": [
6
6
  "factorio",
@@ -11,47 +11,50 @@
11
11
  "repository": "https://github.com/GlassBricks/typed-factorio",
12
12
  "license": "MIT",
13
13
  "files": [
14
- "**/*.d.ts"
14
+ "**/*.d.ts",
15
+ "*.d.ts",
16
+ "!generator/**/*"
15
17
  ],
18
+ "type": "module",
16
19
  "homepage": "https://github.com/GlassBricks/typed-factorio#readme",
17
20
  "scripts": {
18
- "generate": "ts-node -P generator/tsconfig.json generator/main.ts",
21
+ "generate": "ts-node --esm -P generator/tsconfig.json generator/main.ts",
19
22
  "clean": "rimraf generated",
20
- "pretest": "yarn run generate",
21
23
  "test": "jest",
22
24
  "lint": "eslint .",
23
- "check": "yarn run lint && yarn run test",
25
+ "check": "yarn run lint && yarn run generate && yarn run test",
24
26
  "prepublishOnly": "yarn run check",
25
- "download-latest-runtime-api": "ts-node ./scripts/download-latest.ts",
26
- "new-version-changelog": "ts-node ./scripts/new-version-changelog.ts",
27
+ "download-latest-runtime-api": "ts-node --esm ./scripts/download-latest.ts",
28
+ "new-version-changelog": "ts-node --esm ./scripts/new-version-changelog.ts",
27
29
  "next-version": "yarn run download-latest-runtime-api && yarn run clean && yarn run check && yarn run new-version-changelog && git add . && yarn version --minor"
28
30
  },
29
31
  "peerDependencies": {
30
- "lua-types": "^2.11.0",
32
+ "lua-types": "^2.13.0",
31
33
  "typescript-to-lua": "^1.6.1"
32
34
  },
33
35
  "devDependencies": {
34
- "@types/jest": "^28.1.6",
35
- "@types/node": "^18.6.2",
36
- "@types/prettier": "^2.6.4",
37
- "@typescript-eslint/eslint-plugin": "^5.31.0",
38
- "@typescript-eslint/parser": "^5.31.0",
39
- "chalk": "^4.1.2",
40
- "eslint": "^8.20.0",
36
+ "@types/jest": "^28.1.8",
37
+ "@types/node": "^18.7.15",
38
+ "@types/prettier": "^2.7.0",
39
+ "@typescript-eslint/eslint-plugin": "^5.36.2",
40
+ "@typescript-eslint/parser": "^5.36.2",
41
+ "chalk": "^5.0.1",
42
+ "eslint": "~8.23.0",
41
43
  "eslint-config-prettier": "^8.5.0",
42
44
  "eslint-config-standard": "^17.0.0",
43
- "eslint-import-resolver-typescript": "^3.3.0",
45
+ "eslint-import-resolver-typescript": "^3.5.1",
44
46
  "eslint-plugin-import": "^2.26.0",
45
- "eslint-plugin-n": "^15.2.4",
47
+ "eslint-plugin-n": "^15.2.5",
46
48
  "eslint-plugin-node": "^11.1.0",
47
49
  "eslint-plugin-prettier": "^4.2.1",
48
- "eslint-plugin-promise": "^6.0.0",
50
+ "eslint-plugin-promise": "^6.0.1",
49
51
  "jest": "^28.1.3",
50
- "lua-types": "^2.11.0",
52
+ "lua-types": "^2.13.0",
51
53
  "prettier": "^2.7.1",
52
- "ts-jest": "^28.0.7",
54
+ "ts-jest": "^28.0.8",
53
55
  "ts-node": "^10.9.1",
54
- "typescript": "^4.7.4",
55
- "typescript-to-lua": "^1.7.1"
56
- }
56
+ "typescript": "~4.8.2",
57
+ "typescript-to-lua": "^1.10.0"
58
+ },
59
+ "packageManager": "yarn@3.2.3"
57
60
  }
package/runtime/util.d.ts CHANGED
@@ -8,54 +8,58 @@ declare module "util" {
8
8
  namespace table {
9
9
  function deepcopy<T>(table: T): T
10
10
 
11
- function compare<T>(tb1: T, tb2: T): boolean
11
+ function compare<T extends table>(tb1: T, tb2: T): boolean
12
12
  }
13
13
 
14
14
  function copy<T>(table: T): T
15
15
 
16
- function distance(position1: MapPosition, position2: MapPosition): number
16
+ function distance(position1: MapPosition | MapPositionArray, position2: MapPosition | MapPositionArray): number
17
17
 
18
- function positiontostr(position: MapPosition): string
18
+ function positiontostr(position: MapPosition | MapPositionArray): string
19
19
 
20
20
  function formattime(ticks: number): string
21
21
 
22
22
  /** Supports 'rrggbb', 'rgb', 'rrggbbaa', 'rgba', 'ww', 'w' */
23
- function color(hex: string): ColorTable
23
+ function color(hex: string): Color
24
24
 
25
- function premul_color(color: Color): ColorTable
25
+ function premul_color(color: Color): Color
26
26
 
27
27
  function mix_color(c1: Color, c2: Color): ColorArray
28
28
 
29
29
  function multiply_color(c1: Color, n: number): ColorArray
30
30
 
31
31
  function moveposition(
32
- position: MapPosition,
32
+ position: MapPositionArray,
33
33
  direction: defines.direction.north | defines.direction.east | defines.direction.south | defines.direction.west,
34
34
  distance: number
35
- ): MapPosition
36
- function moveposition(position: MapPosition, direction: defines.direction, distance: number): MapPosition | undefined
35
+ ): MapPositionArray
36
+ function moveposition(
37
+ position: MapPositionArray,
38
+ direction: defines.direction,
39
+ distance: number
40
+ ): MapPositionArray | nil
37
41
 
38
42
  function oppositedirection(direction: defines.direction): defines.direction
39
43
 
40
44
  /** Creates a new array where each element in `stripes` is duplicated `count` times */
41
- function multiplystripes<T>(count: number, stripes: T[]): T[]
45
+ function multiplystripes<T>(count: number, stripes: readonly T[]): T[]
42
46
 
43
47
  /** Gets tile position by pixel */
44
- function by_pixel(x: number, y: number): MapPosition
48
+ function by_pixel(x: number, y: number): MapPositionArray
45
49
 
46
50
  /** Gets tile position by pixel, hr */
47
- function by_pixel_hr(x: number, y: number): MapPosition
51
+ function by_pixel_hr(x: number, y: number): MapPositionArray
48
52
 
49
53
  // omitted: foreach_sprite_definition
50
54
 
51
- function add_shift(a: MapPositionArray | undefined, b: MapPositionArray): MapPositionArray
52
- function add_shift(a: MapPositionArray, b: MapPositionArray | undefined): MapPositionArray
53
- function add_shift(a: MapPositionArray | undefined, b: MapPositionArray | undefined): MapPositionArray | undefined
55
+ function add_shift(a: MapPositionArray | nil, b: MapPositionArray): MapPositionArray
56
+ function add_shift(a: MapPositionArray, b: MapPositionArray | nil): MapPositionArray
57
+ function add_shift(a: MapPositionArray | nil, b: MapPositionArray | nil): MapPositionArray | nil
54
58
 
55
59
  // omitted: add_shift_offset
56
60
 
57
- function mul_shift(shift: MapPositionArray, scale: number | undefined): MapPositionArray
58
- function mul_shift(shift: MapPositionArray | undefined, scale: number | undefined): MapPositionArray | undefined
61
+ function mul_shift(shift: MapPositionArray, scale: number | nil): MapPositionArray
62
+ function mul_shift(shift: MapPositionArray | nil, scale: number | nil): MapPositionArray | nil
59
63
 
60
64
  function format_number(amount: number, append_suffix?: boolean): string
61
65
 
@@ -68,11 +72,11 @@ declare module "util" {
68
72
  * entries are themselves tables, in which case they are recursively merged. Non-merged tables are deep-copied, so
69
73
  * that the result is brand new.
70
74
  */
71
- function merge<T extends object>(tables: T[]): T
75
+ function merge<T extends object>(tables: readonly T[]): T
72
76
 
73
- function insert_safe(entity: LuaEntity | undefined, item_dict: Record<string, number> | undefined): void
77
+ function insert_safe(entity: LuaEntity | nil, item_dict: Record<string, number> | nil): void
74
78
 
75
- function remove_safe(entity: LuaEntity | undefined, item_dict: Record<string, number> | undefined): void
79
+ function remove_safe(entity: LuaEntity | nil, item_dict: Record<string, number> | nil): void
76
80
 
77
81
  function split_whitespace(string: string): string[]
78
82
 
@@ -82,7 +86,7 @@ declare module "util" {
82
86
 
83
87
  function clamp(x: number, lower: number, upper: number): number
84
88
 
85
- // omitted: get_walkable_tile
89
+ function get_walkable_tile(): string
86
90
 
87
91
  // omitted: combine_icons
88
92
  // omitted: technology_icons. Create an issue if you really want to see these
@@ -110,7 +114,7 @@ declare module "util" {
110
114
 
111
115
  function remove_from_list<T>(list: T[], value: T): boolean
112
116
 
113
- function list_to_map<T extends keyof any>(list: T[]): Record<T, true>
114
- function list_to_map<T>(list: T[]): LuaTable<T, true>
115
- function list_to_map<T>(list: T): LuaTable<T[keyof T], true>
117
+ function list_to_map<V>(list: LuaPairsIterable<any, V>): LuaSet<NonNullable<V>>
118
+ function list_to_map<T extends AnyNotNil>(list: T[]): LuaSet<T>
119
+ function list_to_map<T extends AnyNotNil>(list: T): LuaSet<NonNullable<T[keyof T]>>
116
120
  }
package/Changelog.md DELETED
@@ -1,234 +0,0 @@
1
- # v1.6.1
2
-
3
- - Fixed write type for `BoundingBox`.
4
- - Simplified types for BlueprintEntity.
5
-
6
- # v1.6.0
7
-
8
- - Updated to factorio version 1.1.64
9
-
10
- # v1.5.1
11
-
12
- - Added old `Read` types as deprecated type aliases of new types; to help with migration.
13
-
14
- # v1.5.0
15
-
16
- ### BREAKING
17
-
18
- - Read-only forms of concepts (the most common form used) is now specified with just the name; forms with a `Read` or `Table` suffix have been removed.
19
- - Write forms are now specified as either a union of table and array forms, or with a `Write` suffix for concepts.
20
- - For table-or-array concepts: `MapPositionRead` -> `MapPosition`, `MapPosition` -> `MapPosition | PositionArray`
21
- - For table concepts: `ScriptAreaRead` -> `ScriptArea`, `ScriptArea` -> `ScriptAreaWrite`
22
- - The minimum TSTL version has been increased to v1.6.1 (A bug with documentation comments was fixed in that version).
23
-
24
- ### Other
25
-
26
- - Updated to factorio version 1.1.63.
27
- - Upgraded to factorio api docs json version 3.
28
- - The new type `nil` is used instead of `undefined` (they are equivalent).
29
- - More complete type for `BlueprintEntity`.
30
- - Fixed missing read-write forms for more concepts.
31
- - Improved documentation comments (enabled by json docs version 3).
32
- - Improved documentation comments for variant parameter groups.
33
-
34
- # v1.4.0
35
-
36
- - Improve doc comments for enum concepts
37
- - Improve doc comment formatting
38
- - Improve types of concepts with literal union types
39
- - Add read-specific types to AutoplaceControl and ComparatorString
40
-
41
- # v1.3.2
42
-
43
- - Move "notes" comment into the main body of doc comment, instead of in @remarks. This works around #13.
44
- - Add manually defined overload for LuaControl::teleport().
45
-
46
- # v1.3.1
47
-
48
- - Use @linkplain instead of @link for web links. This hopefully works around issue #13
49
-
50
- # v1.3.0
51
-
52
- - Updated to factorio version 1.1.61
53
-
54
- # v1.2.0
55
-
56
- - Updated to factorio version 1.1.60
57
-
58
- # v1.1.0
59
-
60
- - Updated to factorio version 1.1.59
61
-
62
- # v1.0.0
63
-
64
- - This project now has all the features that was originally planned, and can now guarantee reasonable backwards compatibility for future releases.
65
- - Updated to factorio version 1.1.57
66
-
67
- # v0.20.0
68
-
69
- - Updated to factorio version 1.1.56
70
- - This is an **opt-in** feature: Some numeric types which represent indices/number,e.g. player_index, entity_number, are now branded numbers with their own type, e.g. `PlayerIndex` and `EntityNumber`. See the README for more info.
71
- - Added custom-index-template.d.ts to assist trying out custom changes to types in a project.
72
-
73
- # v0.19.0
74
-
75
- - Updated to factorio version 1.1.53
76
- - Updated to json api version 2
77
- - Improved documentation comments
78
-
79
- ## Changes
80
-
81
- - `Position`, `PositionArray`, and `PositionTable` have been replaced by `MapPosition`, `MapPositionArray`, and `MapPositionTable` respectively. These are now deprecated and may be removed in a future version.
82
-
83
- # v0.18.1
84
-
85
- - `TechnologyIdentification` now also has a more specific type when read.
86
-
87
- # v0.18.0
88
-
89
- - `ForceIdentification` and `ItemPrototypeIdentification` now have more specific types when read.
90
- - Properties which represent a flag concept now have the correct specific type, instead of `string`.
91
-
92
- # v0.17.1
93
-
94
- - Fixed documentation links for events
95
-
96
- # v0.17.0
97
-
98
- - Updated to factorio version 1.1.52
99
-
100
- # v0.16.0
101
-
102
- - `LuaCustomTable` can be iterated on in a for-of loop directly (without using `pairs`). This requires TSTL v1.3.0 or later.
103
- - TSTL dependency minimum version is now v1.3.0.
104
-
105
- # v0.15.0
106
-
107
- - Table or array concepts are now declared in table form wherever it is an "read" position.
108
- - This works with setter overloading for applicable properties: `player.color.x; player.color = [1, 1, 1]` is now valid!
109
- - This also applies to concepts/complex types which contain table_or_array properties.
110
- - Some concepts now also have a special form where it is known to be in a "read" position, where all table_or_array concepts are declared in table form. These concepts are suffixed with "Read", e.g. `ScriptAreaRead`.
111
- - Arrays which are known to be in a "write" only form (e.g. method parameters) now are marked readonly. This means you can now pass readonly arrays to these methods.
112
- - `MapPosition` is now a table or array concept.
113
- - Classes with subclasses are now declared with all properties, instead of an intersection of subclasses (reversion)
114
- - Subclass specializations added for some missing classes
115
-
116
- # v0.14.1
117
-
118
- - LuaStyle: `extra_margin/padding_when_activated` is now for subclass scroll_pane
119
-
120
- # v0.14.0
121
-
122
- - LuaStyle size, margin/padding setters now have more specific array types. These array types are `SizeArray` and `StyleValuesArray` for size and margin/padding, respectively.
123
- - `@noSelf` annotation is now only present when necessary.
124
- - For classes with subclasses:
125
- - The original class name (e.g. `LuaItemStack`) still contains attributes of all subclasses (same as before).
126
- - There is now a `Base` type (e.g. `BaseItemStack`) which only includes attributes common to all subclasses.
127
- - There is a separate type definition for each subclass, e.g. `BlueprintItem`. Note that one instance may still belong to multiple subclasses (the subclasses are not mutually exclusive).
128
- - The above two can be optionally used for stricter types.
129
-
130
- # v0.13.2
131
-
132
- - Fix: resize_to_sprite property should not be on subclass sprite-button
133
- - Fix: ChooseElemButtonSpec filters should be named elem_filters
134
- - Switch back to `/latest` api docs link
135
- - New version of web api docs is now active
136
-
137
- # v0.13.0
138
-
139
- - Update to factorio version 1.1.49
140
-
141
- # v0.12.0
142
-
143
- - Update to factorio version 1.1.48
144
-
145
- # v0.11.1
146
-
147
- - Localised strings now accept boolean and undefined.
148
-
149
- # v0.11.0
150
-
151
- - Update to factorio version 1.1.46
152
-
153
- # v0.10.0
154
-
155
- - LuaGuiElement.style and LuaControl.opened now have different get/set types (more specific get type).
156
- - The array form of LocalizedString is now readonly.
157
-
158
- # v0.9.0
159
-
160
- - Update to factorio version 1.1.43
161
- - The `defines.events `_type_ was renamed to `defines.Events`, to reduce confusion between the namespace/type
162
-
163
- # v0.8.0
164
-
165
- - All event types now explicitly extend `EventData`
166
- - Variant parameter groups without additional fields now have their own type, instead of all being grouped into `Other`
167
-
168
- # v0.7.3
169
-
170
- - Update to factorio version 1.1.42
171
- - No api changes, but improvements to descriptions
172
-
173
- # v0.7.2
174
-
175
- - Fix minor issue for event types
176
-
177
- # v0.7.0
178
-
179
- - Updated to factorio version 1.1.41 (no changes to lua api)
180
- - Improved smart types for events
181
-
182
- # v0.6.1
183
-
184
- - Added type for BlueprintControlBehavior
185
-
186
- # v0.6.0
187
-
188
- - Updated to factorio version 1.1.40
189
- - Fixed regression with duplicate strings in string union types
190
-
191
- # v0.5.0
192
-
193
- - Updated to factorio version 1.1.39
194
- - Documentation links now point to the new API docs website. More info here: https://forums.factorio.com/viewtopic.php?f=34&t=99797
195
-
196
- # v0.4.1
197
-
198
- ### Changed
199
-
200
- - LuaRemote.addInterface now lets remote functions take any arguments.
201
-
202
- # v0.4.0
203
-
204
- ## **BREAKING**
205
-
206
- - Only the latest version api is now provided.
207
- - It is now accessed using `typed-factorio/runtime` instead of `typed-factorio/<version>`
208
-
209
- ### Added
210
-
211
- - Basic types for settings and data stage. See README for more details.
212
- - Types for "util" and "mod-gui" lualib modules
213
-
214
- ### Fixed
215
-
216
- - LuaGuiElement::add with a literal now give diagnostic if you supply a field that shouldn't be there.
217
-
218
- ### Internal
219
-
220
- - Split generated files into multiple files
221
- - Improved compilation tests
222
-
223
- # v0.3.0
224
-
225
- - Added factorio version `1.1.38`
226
-
227
- # v0.2.0
228
-
229
- - `AnyBasic` now uses type `table` instead of type `Record<any, AnyBasic>`
230
- - README changes
231
-
232
- # v0.1.0
233
-
234
- - Initial release
@@ -1,9 +0,0 @@
1
- declare module "typescript" {
2
- interface JSDocContainer {
3
- jsDoc?: JSDoc[]
4
- }
5
- interface Node {
6
- emitNode?: unknown
7
- }
8
- }
9
- export {}