typed-factorio 1.7.0 → 1.7.4

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;
@@ -286,7 +286,7 @@ interface LuaBootstrap {
286
286
  * @remarks Depending on when a given entity is destroyed, {@link OnEntityDestroyedEvent on_entity_destroyed} will either be fired at the end of the current tick or at the end of the next tick.
287
287
  * @see {@link https://lua-api.factorio.com/latest/LuaBootstrap.html#LuaBootstrap.register_on_entity_destroyed Online documentation}
288
288
  */
289
- register_on_entity_destroyed(entity: LuaEntity): uint64
289
+ register_on_entity_destroyed(entity: LuaEntity): RegistrationNumber
290
290
  /**
291
291
  * Generate a new, unique event ID that can be used to raise custom events with {@link LuaBootstrap#raise_event LuaBootstrap::raise_event}.
292
292
  * @returns The newly generated event ID.
@@ -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
  *
@@ -1575,7 +1575,10 @@ interface LuaControlBehavior {
1575
1575
  * @returns The circuit network or nil.
1576
1576
  * @see {@link https://lua-api.factorio.com/latest/LuaControlBehavior.html#LuaControlBehavior.get_circuit_network Online documentation}
1577
1577
  */
1578
- get_circuit_network(wire: defines.wire_type, circuit_connector?: defines.circuit_connector_id): LuaCircuitNetwork
1578
+ get_circuit_network(
1579
+ wire: defines.wire_type,
1580
+ circuit_connector?: defines.circuit_connector_id
1581
+ ): LuaCircuitNetwork | nil
1579
1582
  /**
1580
1583
  * The concrete type of this control behavior.
1581
1584
  * @see {@link https://lua-api.factorio.com/latest/LuaControlBehavior.html#LuaControlBehavior.type Online documentation}
@@ -3268,8 +3271,8 @@ interface LuaEntity extends LuaControl {
3268
3271
  * @remarks Car color is overridden by the color of the current driver/passenger, if there is one.
3269
3272
  * @see {@link https://lua-api.factorio.com/latest/LuaEntity.html#LuaEntity.color Online documentation}
3270
3273
  */
3271
- get color(): Color
3272
- set color(value: Color | ColorArray)
3274
+ get color(): Color | nil
3275
+ set color(value: Color | ColorArray | nil)
3273
3276
  /**
3274
3277
  * The text of this flying-text entity.
3275
3278
  *
@@ -3413,8 +3416,8 @@ interface LuaEntity extends LuaControl {
3413
3416
  * _Can only be used if this is EntityWithOwner_
3414
3417
  * @see {@link https://lua-api.factorio.com/latest/LuaEntity.html#LuaEntity.last_user Online documentation}
3415
3418
  */
3416
- get last_user(): LuaPlayer | LuaPlayer
3417
- set last_user(value: LuaPlayer | PlayerIdentification)
3419
+ get last_user(): LuaPlayer | nil
3420
+ set last_user(value: LuaPlayer | PlayerIdentification | nil)
3418
3421
  /**
3419
3422
  * The buffer size for the electric energy source. `nil` if the entity doesn't have an electric energy source.
3420
3423
  * @remarks Write access is limited to the ElectricEnergyInterface type
@@ -3702,8 +3705,8 @@ interface LuaEntity extends LuaControl {
3702
3705
  * @remarks A character associated with a player is not directly controlled by any player.
3703
3706
  * @see {@link https://lua-api.factorio.com/latest/LuaEntity.html#LuaEntity.associated_player Online documentation}
3704
3707
  */
3705
- get associated_player(): LuaPlayer | LuaPlayer
3706
- set associated_player(value: LuaPlayer | PlayerIdentification)
3708
+ get associated_player(): LuaPlayer | nil
3709
+ set associated_player(value: LuaPlayer | PlayerIdentification | nil)
3707
3710
  /**
3708
3711
  * The last tick this character entity was attacked.
3709
3712
  *
@@ -3834,15 +3837,15 @@ interface LuaEntity extends LuaControl {
3834
3837
  * Reading this property will return a {@link LuaPlayer}, while {@link PlayerIdentification} can be used when writing.
3835
3838
  * @see {@link https://lua-api.factorio.com/latest/LuaEntity.html#LuaEntity.render_player Online documentation}
3836
3839
  */
3837
- get render_player(): LuaPlayer | LuaPlayer
3838
- set render_player(value: LuaPlayer | PlayerIdentification)
3840
+ get render_player(): LuaPlayer | nil
3841
+ set render_player(value: LuaPlayer | PlayerIdentification | nil)
3839
3842
  /**
3840
3843
  * 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.
3841
3844
  * @remarks Reading will always give an array of {@link LuaForce}
3842
3845
  * @see {@link https://lua-api.factorio.com/latest/LuaEntity.html#LuaEntity.render_to_forces Online documentation}
3843
3846
  */
3844
- get render_to_forces(): LuaForce[]
3845
- set render_to_forces(value: readonly ForceIdentification[])
3847
+ get render_to_forces(): LuaForce[] | nil
3848
+ set render_to_forces(value: readonly ForceIdentification[] | nil)
3846
3849
  /**
3847
3850
  * The rail target of this pump, if any.
3848
3851
  *
@@ -3938,8 +3941,8 @@ interface LuaEntity extends LuaControl {
3938
3941
  * _Can only be used if this is SpiderVehicle_
3939
3942
  * @see {@link https://lua-api.factorio.com/latest/LuaEntity.html#LuaEntity.autopilot_destination Online documentation}
3940
3943
  */
3941
- get autopilot_destination(): MapPosition
3942
- set autopilot_destination(value: MapPosition | MapPositionArray)
3944
+ get autopilot_destination(): MapPosition | nil
3945
+ set autopilot_destination(value: MapPosition | MapPositionArray | nil)
3943
3946
  /**
3944
3947
  * The queued destination positions of spidertron's autopilot.
3945
3948
  *
@@ -4767,8 +4770,8 @@ interface BaseEntity extends LuaControl {
4767
4770
  * @remarks Car color is overridden by the color of the current driver/passenger, if there is one.
4768
4771
  * @see {@link https://lua-api.factorio.com/latest/LuaEntity.html#LuaEntity.color Online documentation}
4769
4772
  */
4770
- get color(): Color
4771
- set color(value: Color | ColorArray)
4773
+ get color(): Color | nil
4774
+ set color(value: Color | ColorArray | nil)
4772
4775
  /**
4773
4776
  * The productivity bonus of this entity.
4774
4777
  * @remarks This includes force based bonuses as well as beacon/module bonuses.
@@ -4998,15 +5001,15 @@ interface BaseEntity extends LuaControl {
4998
5001
  * Reading this property will return a {@link LuaPlayer}, while {@link PlayerIdentification} can be used when writing.
4999
5002
  * @see {@link https://lua-api.factorio.com/latest/LuaEntity.html#LuaEntity.render_player Online documentation}
5000
5003
  */
5001
- get render_player(): LuaPlayer | LuaPlayer
5002
- set render_player(value: LuaPlayer | PlayerIdentification)
5004
+ get render_player(): LuaPlayer | nil
5005
+ set render_player(value: LuaPlayer | PlayerIdentification | nil)
5003
5006
  /**
5004
5007
  * 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.
5005
5008
  * @remarks Reading will always give an array of {@link LuaForce}
5006
5009
  * @see {@link https://lua-api.factorio.com/latest/LuaEntity.html#LuaEntity.render_to_forces Online documentation}
5007
5010
  */
5008
- get render_to_forces(): LuaForce[]
5009
- set render_to_forces(value: readonly ForceIdentification[])
5011
+ get render_to_forces(): LuaForce[] | nil
5012
+ set render_to_forces(value: readonly ForceIdentification[] | nil)
5010
5013
  /**
5011
5014
  * Returns the id of the electric network that this entity is connected to, if any.
5012
5015
  * @see {@link https://lua-api.factorio.com/latest/LuaEntity.html#LuaEntity.electric_network_id Online documentation}
@@ -5919,8 +5922,8 @@ interface SpiderVehicleEntity extends BaseEntity {
5919
5922
  * _Can only be used if this is SpiderVehicle_
5920
5923
  * @see {@link https://lua-api.factorio.com/latest/LuaEntity.html#LuaEntity.autopilot_destination Online documentation}
5921
5924
  */
5922
- get autopilot_destination(): MapPosition
5923
- set autopilot_destination(value: MapPosition | MapPositionArray)
5925
+ get autopilot_destination(): MapPosition | nil
5926
+ set autopilot_destination(value: MapPosition | MapPositionArray | nil)
5924
5927
  /**
5925
5928
  * The queued destination positions of spidertron's autopilot.
5926
5929
  *
@@ -6138,8 +6141,8 @@ interface CharacterEntity extends BaseEntity {
6138
6141
  * @remarks A character associated with a player is not directly controlled by any player.
6139
6142
  * @see {@link https://lua-api.factorio.com/latest/LuaEntity.html#LuaEntity.associated_player Online documentation}
6140
6143
  */
6141
- get associated_player(): LuaPlayer | LuaPlayer
6142
- set associated_player(value: LuaPlayer | PlayerIdentification)
6144
+ get associated_player(): LuaPlayer | nil
6145
+ set associated_player(value: LuaPlayer | PlayerIdentification | nil)
6143
6146
  /**
6144
6147
  * The last tick this character entity was attacked.
6145
6148
  *
@@ -6236,8 +6239,8 @@ interface EntityWithOwnerEntity extends BaseEntity {
6236
6239
  * _Can only be used if this is EntityWithOwner_
6237
6240
  * @see {@link https://lua-api.factorio.com/latest/LuaEntity.html#LuaEntity.last_user Online documentation}
6238
6241
  */
6239
- get last_user(): LuaPlayer | LuaPlayer
6240
- set last_user(value: LuaPlayer | PlayerIdentification)
6242
+ get last_user(): LuaPlayer | nil
6243
+ set last_user(value: LuaPlayer | PlayerIdentification | nil)
6241
6244
  }
6242
6245
 
6243
6246
  interface ElectricEnergyInterfaceEntity extends BaseEntity {
@@ -10506,7 +10509,7 @@ interface LuaFluidBox extends Array<Fluid | nil> {
10506
10509
  * Gets unique fluid system identifier of selected fluid box. May return nil for fluid wagon, fluid turret's internal buffer or a fluidbox which does not belong to a fluid system
10507
10510
  * @see {@link https://lua-api.factorio.com/latest/LuaFluidBox.html#LuaFluidBox.get_fluid_system_id Online documentation}
10508
10511
  */
10509
- get_fluid_system_id(index: uint): uint
10512
+ get_fluid_system_id(index: uint): uint | nil
10510
10513
  /**
10511
10514
  * Flushes all fluid from this fluidbox and its fluid system.
10512
10515
  * @param fluid If provided, only this fluid is flushed.
@@ -11365,8 +11368,8 @@ interface LuaForce {
11365
11368
  * 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}
11366
11369
  * @see {@link https://lua-api.factorio.com/latest/LuaForce.html#LuaForce.custom_color Online documentation}
11367
11370
  */
11368
- get custom_color(): Color
11369
- set custom_color(value: Color | ColorArray)
11371
+ get custom_color(): Color | nil
11372
+ set custom_color(value: Color | ColorArray | nil)
11370
11373
  /**
11371
11374
  * Effective color of this force.
11372
11375
  * @see {@link https://lua-api.factorio.com/latest/LuaForce.html#LuaForce.color Online documentation}
@@ -13292,8 +13295,8 @@ interface BaseGuiElement {
13292
13295
  * 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}.
13293
13296
  * @see {@link https://lua-api.factorio.com/latest/LuaGuiElement.html#LuaGuiElement.location Online documentation}
13294
13297
  */
13295
- get location(): GuiLocation
13296
- set location(value: GuiLocation | GuiLocationArray)
13298
+ get location(): GuiLocation | nil
13299
+ set location(value: GuiLocation | GuiLocationArray | nil)
13297
13300
  /**
13298
13301
  * Whether this GUI element is enabled. Disabled GUI elements don't trigger events when clicked.
13299
13302
  * @see {@link https://lua-api.factorio.com/latest/LuaGuiElement.html#LuaGuiElement.enabled Online documentation}
@@ -16336,16 +16339,16 @@ interface LuaItemStack {
16336
16339
  * _Can only be used if this is BlueprintItem_
16337
16340
  * @see {@link https://lua-api.factorio.com/latest/LuaItemStack.html#LuaItemStack.blueprint_snap_to_grid Online documentation}
16338
16341
  */
16339
- get blueprint_snap_to_grid(): TilePosition
16340
- set blueprint_snap_to_grid(value: TilePosition | TilePositionArray)
16342
+ get blueprint_snap_to_grid(): TilePosition | nil
16343
+ set blueprint_snap_to_grid(value: TilePosition | TilePositionArray | nil)
16341
16344
  /**
16342
16345
  * The offset from the absolute grid. `nil` if absolute snapping is not enabled.
16343
16346
  *
16344
16347
  * _Can only be used if this is BlueprintItem_
16345
16348
  * @see {@link https://lua-api.factorio.com/latest/LuaItemStack.html#LuaItemStack.blueprint_position_relative_to_grid Online documentation}
16346
16349
  */
16347
- get blueprint_position_relative_to_grid(): TilePosition
16348
- set blueprint_position_relative_to_grid(value: TilePosition | TilePositionArray)
16350
+ get blueprint_position_relative_to_grid(): TilePosition | nil
16351
+ set blueprint_position_relative_to_grid(value: TilePosition | TilePositionArray | nil)
16349
16352
  /**
16350
16353
  * If absolute snapping is enabled on this blueprint item.
16351
16354
  *
@@ -16366,8 +16369,8 @@ interface LuaItemStack {
16366
16369
  * _Can only be used if this is ItemWithLabel_
16367
16370
  * @see {@link https://lua-api.factorio.com/latest/LuaItemStack.html#LuaItemStack.label_color Online documentation}
16368
16371
  */
16369
- get label_color(): Color
16370
- set label_color(value: Color | ColorArray)
16372
+ get label_color(): Color | nil
16373
+ set label_color(value: Color | ColorArray | nil)
16371
16374
  /**
16372
16375
  * Whether the label for this item can be manually changed. When false the label can only be changed through the API.
16373
16376
  *
@@ -17021,16 +17024,16 @@ interface BlueprintItemStack extends BaseItemStack {
17021
17024
  * _Can only be used if this is BlueprintItem_
17022
17025
  * @see {@link https://lua-api.factorio.com/latest/LuaItemStack.html#LuaItemStack.blueprint_snap_to_grid Online documentation}
17023
17026
  */
17024
- get blueprint_snap_to_grid(): TilePosition
17025
- set blueprint_snap_to_grid(value: TilePosition | TilePositionArray)
17027
+ get blueprint_snap_to_grid(): TilePosition | nil
17028
+ set blueprint_snap_to_grid(value: TilePosition | TilePositionArray | nil)
17026
17029
  /**
17027
17030
  * The offset from the absolute grid. `nil` if absolute snapping is not enabled.
17028
17031
  *
17029
17032
  * _Can only be used if this is BlueprintItem_
17030
17033
  * @see {@link https://lua-api.factorio.com/latest/LuaItemStack.html#LuaItemStack.blueprint_position_relative_to_grid Online documentation}
17031
17034
  */
17032
- get blueprint_position_relative_to_grid(): TilePosition
17033
- set blueprint_position_relative_to_grid(value: TilePosition | TilePositionArray)
17035
+ get blueprint_position_relative_to_grid(): TilePosition | nil
17036
+ set blueprint_position_relative_to_grid(value: TilePosition | TilePositionArray | nil)
17034
17037
  /**
17035
17038
  * If absolute snapping is enabled on this blueprint item.
17036
17039
  *
@@ -17291,8 +17294,8 @@ interface ItemWithLabelItemStack extends BaseItemStack {
17291
17294
  * _Can only be used if this is ItemWithLabel_
17292
17295
  * @see {@link https://lua-api.factorio.com/latest/LuaItemStack.html#LuaItemStack.label_color Online documentation}
17293
17296
  */
17294
- get label_color(): Color
17295
- set label_color(value: Color | ColorArray)
17297
+ get label_color(): Color | nil
17298
+ set label_color(value: Color | ColorArray | nil)
17296
17299
  /**
17297
17300
  * Whether the label for this item can be manually changed. When false the label can only be changed through the API.
17298
17301
  *
@@ -20081,7 +20084,7 @@ interface LuaRendering {
20081
20084
  * Gets the type of the given object. The types are "text", "line", "circle", "rectangle", "arc", "polygon", "sprite", "light" and "animation".
20082
20085
  * @see {@link https://lua-api.factorio.com/latest/LuaRendering.html#LuaRendering.get_type Online documentation}
20083
20086
  */
20084
- get_type(id: uint64): string
20087
+ get_type(id: uint64): "text" | "line" | "circle" | "rectangle" | "arc" | "polygon" | "sprite" | "light" | "animation"
20085
20088
  /**
20086
20089
  * Reorder this object so that it is drawn in front of the already existing objects.
20087
20090
  * @see {@link https://lua-api.factorio.com/latest/LuaRendering.html#LuaRendering.bring_to_front Online documentation}
@@ -22429,7 +22432,7 @@ interface LuaSurface {
22429
22432
  * The force the result will be an enemy of. Uses the player force if not specified.
22430
22433
  */
22431
22434
  readonly force?: ForceIdentification
22432
- }): LuaEntity
22435
+ }): LuaEntity | nil
22433
22436
  /**
22434
22437
  * Give a command to multiple units. This will automatically select suitable units for the task.
22435
22438
  * @returns Number of units actually sent. May be less than `count` if not enough units were available.
@@ -23901,8 +23904,8 @@ interface LuaTrain {
23901
23904
  * @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.
23902
23905
  * @see {@link https://lua-api.factorio.com/latest/LuaTrain.html#LuaTrain.schedule Online documentation}
23903
23906
  */
23904
- get schedule(): TrainSchedule
23905
- set schedule(value: TrainScheduleWrite)
23907
+ get schedule(): TrainSchedule | nil
23908
+ set schedule(value: TrainScheduleWrite | nil)
23906
23909
  /**
23907
23910
  * This train's current state.
23908
23911
  * @see {@link https://lua-api.factorio.com/latest/LuaTrain.html#LuaTrain.state Online documentation}
package/package.json CHANGED
@@ -1,57 +1,57 @@
1
1
  {
2
2
  "name": "typed-factorio",
3
- "version": "1.7.0",
3
+ "version": "1.7.4",
4
4
  "description": "Featureful typescript definitions for the the Factorio modding lua api.",
5
5
  "keywords": [
6
- "factorio",
7
- "types",
8
- "typescript-to-lua",
9
- "tstl"
6
+ "factorio", "types", "typescript-to-lua", "tstl"
10
7
  ],
11
8
  "repository": "https://github.com/GlassBricks/typed-factorio",
12
9
  "license": "MIT",
13
10
  "files": [
14
- "**/*.d.ts"
11
+ "**/*.d.ts",
12
+ "*.d.ts",
13
+ "!generator/**/*"
15
14
  ],
15
+ "type": "module",
16
16
  "homepage": "https://github.com/GlassBricks/typed-factorio#readme",
17
17
  "scripts": {
18
- "generate": "ts-node -P generator/tsconfig.json generator/main.ts",
18
+ "generate": "ts-node --esm -P generator/tsconfig.json generator/main.ts",
19
19
  "clean": "rimraf generated",
20
- "pretest": "yarn run generate",
21
20
  "test": "jest",
22
21
  "lint": "eslint .",
23
- "check": "yarn run lint && yarn run test",
22
+ "check": "yarn run lint && yarn run generate && yarn run test",
24
23
  "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",
24
+ "download-latest-runtime-api": "ts-node --esm ./scripts/download-latest.ts",
25
+ "new-version-changelog": "ts-node --esm ./scripts/new-version-changelog.ts",
27
26
  "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
27
  },
29
28
  "peerDependencies": {
30
- "lua-types": "^2.11.0",
29
+ "lua-types": "^2.13.0",
31
30
  "typescript-to-lua": "^1.6.1"
32
31
  },
33
32
  "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",
33
+ "@types/jest": "^28.1.8",
34
+ "@types/node": "^18.7.15",
35
+ "@types/prettier": "^2.7.0",
36
+ "@typescript-eslint/eslint-plugin": "^5.36.2",
37
+ "@typescript-eslint/parser": "^5.36.2",
38
+ "chalk": "^5.0.1",
39
+ "eslint": "~8.23.0",
41
40
  "eslint-config-prettier": "^8.5.0",
42
41
  "eslint-config-standard": "^17.0.0",
43
- "eslint-import-resolver-typescript": "^3.3.0",
42
+ "eslint-import-resolver-typescript": "^3.5.1",
44
43
  "eslint-plugin-import": "^2.26.0",
45
- "eslint-plugin-n": "^15.2.4",
44
+ "eslint-plugin-n": "^15.2.5",
46
45
  "eslint-plugin-node": "^11.1.0",
47
46
  "eslint-plugin-prettier": "^4.2.1",
48
- "eslint-plugin-promise": "^6.0.0",
47
+ "eslint-plugin-promise": "^6.0.1",
49
48
  "jest": "^28.1.3",
50
- "lua-types": "^2.11.0",
49
+ "lua-types": "^2.13.0",
51
50
  "prettier": "^2.7.1",
52
- "ts-jest": "^28.0.7",
51
+ "ts-jest": "^28.0.8",
53
52
  "ts-node": "^10.9.1",
54
- "typescript": "^4.7.4",
55
- "typescript-to-lua": "^1.7.1"
56
- }
53
+ "typescript": "~4.8.2",
54
+ "typescript-to-lua": "^1.10.0"
55
+ },
56
+ "packageManager": "yarn@3.2.3"
57
57
  }
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,238 +0,0 @@
1
- # v1.7.0
2
-
3
- - Updated to factorio version 1.1.67
4
-
5
- # v1.6.1
6
-
7
- - Fixed write type for `BoundingBox`.
8
- - Simplified types for BlueprintEntity.
9
-
10
- # v1.6.0
11
-
12
- - Updated to factorio version 1.1.64
13
-
14
- # v1.5.1
15
-
16
- - Added old `Read` types as deprecated type aliases of new types; to help with migration.
17
-
18
- # v1.5.0
19
-
20
- ### BREAKING
21
-
22
- - 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.
23
- - Write forms are now specified as either a union of table and array forms, or with a `Write` suffix for concepts.
24
- - For table-or-array concepts: `MapPositionRead` -> `MapPosition`, `MapPosition` -> `MapPosition | PositionArray`
25
- - For table concepts: `ScriptAreaRead` -> `ScriptArea`, `ScriptArea` -> `ScriptAreaWrite`
26
- - The minimum TSTL version has been increased to v1.6.1 (A bug with documentation comments was fixed in that version).
27
-
28
- ### Other
29
-
30
- - Updated to factorio version 1.1.63.
31
- - Upgraded to factorio api docs json version 3.
32
- - The new type `nil` is used instead of `undefined` (they are equivalent).
33
- - More complete type for `BlueprintEntity`.
34
- - Fixed missing read-write forms for more concepts.
35
- - Improved documentation comments (enabled by json docs version 3).
36
- - Improved documentation comments for variant parameter groups.
37
-
38
- # v1.4.0
39
-
40
- - Improve doc comments for enum concepts
41
- - Improve doc comment formatting
42
- - Improve types of concepts with literal union types
43
- - Add read-specific types to AutoplaceControl and ComparatorString
44
-
45
- # v1.3.2
46
-
47
- - Move "notes" comment into the main body of doc comment, instead of in @remarks. This works around #13.
48
- - Add manually defined overload for LuaControl::teleport().
49
-
50
- # v1.3.1
51
-
52
- - Use @linkplain instead of @link for web links. This hopefully works around issue #13
53
-
54
- # v1.3.0
55
-
56
- - Updated to factorio version 1.1.61
57
-
58
- # v1.2.0
59
-
60
- - Updated to factorio version 1.1.60
61
-
62
- # v1.1.0
63
-
64
- - Updated to factorio version 1.1.59
65
-
66
- # v1.0.0
67
-
68
- - This project now has all the features that was originally planned, and can now guarantee reasonable backwards compatibility for future releases.
69
- - Updated to factorio version 1.1.57
70
-
71
- # v0.20.0
72
-
73
- - Updated to factorio version 1.1.56
74
- - 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.
75
- - Added custom-index-template.d.ts to assist trying out custom changes to types in a project.
76
-
77
- # v0.19.0
78
-
79
- - Updated to factorio version 1.1.53
80
- - Updated to json api version 2
81
- - Improved documentation comments
82
-
83
- ## Changes
84
-
85
- - `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.
86
-
87
- # v0.18.1
88
-
89
- - `TechnologyIdentification` now also has a more specific type when read.
90
-
91
- # v0.18.0
92
-
93
- - `ForceIdentification` and `ItemPrototypeIdentification` now have more specific types when read.
94
- - Properties which represent a flag concept now have the correct specific type, instead of `string`.
95
-
96
- # v0.17.1
97
-
98
- - Fixed documentation links for events
99
-
100
- # v0.17.0
101
-
102
- - Updated to factorio version 1.1.52
103
-
104
- # v0.16.0
105
-
106
- - `LuaCustomTable` can be iterated on in a for-of loop directly (without using `pairs`). This requires TSTL v1.3.0 or later.
107
- - TSTL dependency minimum version is now v1.3.0.
108
-
109
- # v0.15.0
110
-
111
- - Table or array concepts are now declared in table form wherever it is an "read" position.
112
- - This works with setter overloading for applicable properties: `player.color.x; player.color = [1, 1, 1]` is now valid!
113
- - This also applies to concepts/complex types which contain table_or_array properties.
114
- - 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`.
115
- - 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.
116
- - `MapPosition` is now a table or array concept.
117
- - Classes with subclasses are now declared with all properties, instead of an intersection of subclasses (reversion)
118
- - Subclass specializations added for some missing classes
119
-
120
- # v0.14.1
121
-
122
- - LuaStyle: `extra_margin/padding_when_activated` is now for subclass scroll_pane
123
-
124
- # v0.14.0
125
-
126
- - LuaStyle size, margin/padding setters now have more specific array types. These array types are `SizeArray` and `StyleValuesArray` for size and margin/padding, respectively.
127
- - `@noSelf` annotation is now only present when necessary.
128
- - For classes with subclasses:
129
- - The original class name (e.g. `LuaItemStack`) still contains attributes of all subclasses (same as before).
130
- - There is now a `Base` type (e.g. `BaseItemStack`) which only includes attributes common to all subclasses.
131
- - 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).
132
- - The above two can be optionally used for stricter types.
133
-
134
- # v0.13.2
135
-
136
- - Fix: resize_to_sprite property should not be on subclass sprite-button
137
- - Fix: ChooseElemButtonSpec filters should be named elem_filters
138
- - Switch back to `/latest` api docs link
139
- - New version of web api docs is now active
140
-
141
- # v0.13.0
142
-
143
- - Update to factorio version 1.1.49
144
-
145
- # v0.12.0
146
-
147
- - Update to factorio version 1.1.48
148
-
149
- # v0.11.1
150
-
151
- - Localised strings now accept boolean and undefined.
152
-
153
- # v0.11.0
154
-
155
- - Update to factorio version 1.1.46
156
-
157
- # v0.10.0
158
-
159
- - LuaGuiElement.style and LuaControl.opened now have different get/set types (more specific get type).
160
- - The array form of LocalizedString is now readonly.
161
-
162
- # v0.9.0
163
-
164
- - Update to factorio version 1.1.43
165
- - The `defines.events `_type_ was renamed to `defines.Events`, to reduce confusion between the namespace/type
166
-
167
- # v0.8.0
168
-
169
- - All event types now explicitly extend `EventData`
170
- - Variant parameter groups without additional fields now have their own type, instead of all being grouped into `Other`
171
-
172
- # v0.7.3
173
-
174
- - Update to factorio version 1.1.42
175
- - No api changes, but improvements to descriptions
176
-
177
- # v0.7.2
178
-
179
- - Fix minor issue for event types
180
-
181
- # v0.7.0
182
-
183
- - Updated to factorio version 1.1.41 (no changes to lua api)
184
- - Improved smart types for events
185
-
186
- # v0.6.1
187
-
188
- - Added type for BlueprintControlBehavior
189
-
190
- # v0.6.0
191
-
192
- - Updated to factorio version 1.1.40
193
- - Fixed regression with duplicate strings in string union types
194
-
195
- # v0.5.0
196
-
197
- - Updated to factorio version 1.1.39
198
- - Documentation links now point to the new API docs website. More info here: https://forums.factorio.com/viewtopic.php?f=34&t=99797
199
-
200
- # v0.4.1
201
-
202
- ### Changed
203
-
204
- - LuaRemote.addInterface now lets remote functions take any arguments.
205
-
206
- # v0.4.0
207
-
208
- ## **BREAKING**
209
-
210
- - Only the latest version api is now provided.
211
- - It is now accessed using `typed-factorio/runtime` instead of `typed-factorio/<version>`
212
-
213
- ### Added
214
-
215
- - Basic types for settings and data stage. See README for more details.
216
- - Types for "util" and "mod-gui" lualib modules
217
-
218
- ### Fixed
219
-
220
- - LuaGuiElement::add with a literal now give diagnostic if you supply a field that shouldn't be there.
221
-
222
- ### Internal
223
-
224
- - Split generated files into multiple files
225
- - Improved compilation tests
226
-
227
- # v0.3.0
228
-
229
- - Added factorio version `1.1.38`
230
-
231
- # v0.2.0
232
-
233
- - `AnyBasic` now uses type `table` instead of type `Record<any, AnyBasic>`
234
- - README changes
235
-
236
- # v0.1.0
237
-
238
- - 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 {}