typed-factorio 1.7.3 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
package/Changelog.md
ADDED
@@ -0,0 +1,256 @@
|
|
1
|
+
# v1.8.0
|
2
|
+
|
3
|
+
- Updated to factorio version 1.1.69
|
4
|
+
|
5
|
+
# v1.7.4
|
6
|
+
|
7
|
+
- Fix advanced types of method returns (nullability, string unions, etc.)
|
8
|
+
|
9
|
+
# v1.7.3
|
10
|
+
|
11
|
+
- Improve types of "util" lualib module
|
12
|
+
- Made compatible with typescript v4.8
|
13
|
+
|
14
|
+
# v1.7.1
|
15
|
+
|
16
|
+
- Added proper nullablity to members with different read/write types
|
17
|
+
- Deduped union types
|
18
|
+
|
19
|
+
# v1.7.0
|
20
|
+
|
21
|
+
- Updated to factorio version 1.1.67
|
22
|
+
|
23
|
+
# v1.6.1
|
24
|
+
|
25
|
+
- Fixed write type for `BoundingBox`.
|
26
|
+
- Simplified types for BlueprintEntity.
|
27
|
+
|
28
|
+
# v1.6.0
|
29
|
+
|
30
|
+
- Updated to factorio version 1.1.64
|
31
|
+
|
32
|
+
# v1.5.1
|
33
|
+
|
34
|
+
- Added old `Read` types as deprecated type aliases of new types; to help with migration.
|
35
|
+
|
36
|
+
# v1.5.0
|
37
|
+
|
38
|
+
### BREAKING
|
39
|
+
|
40
|
+
- 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.
|
41
|
+
- Write forms are now specified as either a union of table and array forms, or with a `Write` suffix for concepts.
|
42
|
+
- For table-or-array concepts: `MapPositionRead` -> `MapPosition`, `MapPosition` -> `MapPosition | PositionArray`
|
43
|
+
- For table concepts: `ScriptAreaRead` -> `ScriptArea`, `ScriptArea` -> `ScriptAreaWrite`
|
44
|
+
- The minimum TSTL version has been increased to v1.6.1 (A bug with documentation comments was fixed in that version).
|
45
|
+
|
46
|
+
### Other
|
47
|
+
|
48
|
+
- Updated to factorio version 1.1.63.
|
49
|
+
- Upgraded to factorio api docs json version 3.
|
50
|
+
- The new type `nil` is used instead of `undefined` (they are equivalent).
|
51
|
+
- More complete type for `BlueprintEntity`.
|
52
|
+
- Fixed missing read-write forms for more concepts.
|
53
|
+
- Improved documentation comments (enabled by json docs version 3).
|
54
|
+
- Improved documentation comments for variant parameter groups.
|
55
|
+
|
56
|
+
# v1.4.0
|
57
|
+
|
58
|
+
- Improve doc comments for enum concepts
|
59
|
+
- Improve doc comment formatting
|
60
|
+
- Improve types of concepts with literal union types
|
61
|
+
- Add read-specific types to AutoplaceControl and ComparatorString
|
62
|
+
|
63
|
+
# v1.3.2
|
64
|
+
|
65
|
+
- Move "notes" comment into the main body of doc comment, instead of in @remarks. This works around #13.
|
66
|
+
- Add manually defined overload for LuaControl::teleport().
|
67
|
+
|
68
|
+
# v1.3.1
|
69
|
+
|
70
|
+
- Use @linkplain instead of @link for web links. This hopefully works around issue #13
|
71
|
+
|
72
|
+
# v1.3.0
|
73
|
+
|
74
|
+
- Updated to factorio version 1.1.61
|
75
|
+
|
76
|
+
# v1.2.0
|
77
|
+
|
78
|
+
- Updated to factorio version 1.1.60
|
79
|
+
|
80
|
+
# v1.1.0
|
81
|
+
|
82
|
+
- Updated to factorio version 1.1.59
|
83
|
+
|
84
|
+
# v1.0.0
|
85
|
+
|
86
|
+
- This project now has all the features that was originally planned, and can now guarantee reasonable backwards compatibility for future releases.
|
87
|
+
- Updated to factorio version 1.1.57
|
88
|
+
|
89
|
+
# v0.20.0
|
90
|
+
|
91
|
+
- Updated to factorio version 1.1.56
|
92
|
+
- 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.
|
93
|
+
- Added custom-index-template.d.ts to assist trying out custom changes to types in a project.
|
94
|
+
|
95
|
+
# v0.19.0
|
96
|
+
|
97
|
+
- Updated to factorio version 1.1.53
|
98
|
+
- Updated to json api version 2
|
99
|
+
- Improved documentation comments
|
100
|
+
|
101
|
+
## Changes
|
102
|
+
|
103
|
+
- `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.
|
104
|
+
|
105
|
+
# v0.18.1
|
106
|
+
|
107
|
+
- `TechnologyIdentification` now also has a more specific type when read.
|
108
|
+
|
109
|
+
# v0.18.0
|
110
|
+
|
111
|
+
- `ForceIdentification` and `ItemPrototypeIdentification` now have more specific types when read.
|
112
|
+
- Properties which represent a flag concept now have the correct specific type, instead of `string`.
|
113
|
+
|
114
|
+
# v0.17.1
|
115
|
+
|
116
|
+
- Fixed documentation links for events
|
117
|
+
|
118
|
+
# v0.17.0
|
119
|
+
|
120
|
+
- Updated to factorio version 1.1.52
|
121
|
+
|
122
|
+
# v0.16.0
|
123
|
+
|
124
|
+
- `LuaCustomTable` can be iterated on in a for-of loop directly (without using `pairs`). This requires TSTL v1.3.0 or later.
|
125
|
+
- TSTL dependency minimum version is now v1.3.0.
|
126
|
+
|
127
|
+
# v0.15.0
|
128
|
+
|
129
|
+
- Table or array concepts are now declared in table form wherever it is an "read" position.
|
130
|
+
- This works with setter overloading for applicable properties: `player.color.x; player.color = [1, 1, 1]` is now valid!
|
131
|
+
- This also applies to concepts/complex types which contain table_or_array properties.
|
132
|
+
- 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`.
|
133
|
+
- 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.
|
134
|
+
- `MapPosition` is now a table or array concept.
|
135
|
+
- Classes with subclasses are now declared with all properties, instead of an intersection of subclasses (reversion)
|
136
|
+
- Subclass specializations added for some missing classes
|
137
|
+
|
138
|
+
# v0.14.1
|
139
|
+
|
140
|
+
- LuaStyle: `extra_margin/padding_when_activated` is now for subclass scroll_pane
|
141
|
+
|
142
|
+
# v0.14.0
|
143
|
+
|
144
|
+
- LuaStyle size, margin/padding setters now have more specific array types. These array types are `SizeArray` and `StyleValuesArray` for size and margin/padding, respectively.
|
145
|
+
- `@noSelf` annotation is now only present when necessary.
|
146
|
+
- For classes with subclasses:
|
147
|
+
- The original class name (e.g. `LuaItemStack`) still contains attributes of all subclasses (same as before).
|
148
|
+
- There is now a `Base` type (e.g. `BaseItemStack`) which only includes attributes common to all subclasses.
|
149
|
+
- 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).
|
150
|
+
- The above two can be optionally used for stricter types.
|
151
|
+
|
152
|
+
# v0.13.2
|
153
|
+
|
154
|
+
- Fix: resize_to_sprite property should not be on subclass sprite-button
|
155
|
+
- Fix: ChooseElemButtonSpec filters should be named elem_filters
|
156
|
+
- Switch back to `/latest` api docs link
|
157
|
+
- New version of web api docs is now active
|
158
|
+
|
159
|
+
# v0.13.0
|
160
|
+
|
161
|
+
- Update to factorio version 1.1.49
|
162
|
+
|
163
|
+
# v0.12.0
|
164
|
+
|
165
|
+
- Update to factorio version 1.1.48
|
166
|
+
|
167
|
+
# v0.11.1
|
168
|
+
|
169
|
+
- Localised strings now accept boolean and undefined.
|
170
|
+
|
171
|
+
# v0.11.0
|
172
|
+
|
173
|
+
- Update to factorio version 1.1.46
|
174
|
+
|
175
|
+
# v0.10.0
|
176
|
+
|
177
|
+
- LuaGuiElement.style and LuaControl.opened now have different get/set types (more specific get type).
|
178
|
+
- The array form of LocalizedString is now readonly.
|
179
|
+
|
180
|
+
# v0.9.0
|
181
|
+
|
182
|
+
- Update to factorio version 1.1.43
|
183
|
+
- The `defines.events `_type_ was renamed to `defines.Events`, to reduce confusion between the namespace/type
|
184
|
+
|
185
|
+
# v0.8.0
|
186
|
+
|
187
|
+
- All event types now explicitly extend `EventData`
|
188
|
+
- Variant parameter groups without additional fields now have their own type, instead of all being grouped into `Other`
|
189
|
+
|
190
|
+
# v0.7.3
|
191
|
+
|
192
|
+
- Update to factorio version 1.1.42
|
193
|
+
- No api changes, but improvements to descriptions
|
194
|
+
|
195
|
+
# v0.7.2
|
196
|
+
|
197
|
+
- Fix minor issue for event types
|
198
|
+
|
199
|
+
# v0.7.0
|
200
|
+
|
201
|
+
- Updated to factorio version 1.1.41 (no changes to lua api)
|
202
|
+
- Improved smart types for events
|
203
|
+
|
204
|
+
# v0.6.1
|
205
|
+
|
206
|
+
- Added type for BlueprintControlBehavior
|
207
|
+
|
208
|
+
# v0.6.0
|
209
|
+
|
210
|
+
- Updated to factorio version 1.1.40
|
211
|
+
- Fixed regression with duplicate strings in string union types
|
212
|
+
|
213
|
+
# v0.5.0
|
214
|
+
|
215
|
+
- Updated to factorio version 1.1.39
|
216
|
+
- Documentation links now point to the new API docs website. More info here: https://forums.factorio.com/viewtopic.php?f=34&t=99797
|
217
|
+
|
218
|
+
# v0.4.1
|
219
|
+
|
220
|
+
### Changed
|
221
|
+
|
222
|
+
- LuaRemote.addInterface now lets remote functions take any arguments.
|
223
|
+
|
224
|
+
# v0.4.0
|
225
|
+
|
226
|
+
## **BREAKING**
|
227
|
+
|
228
|
+
- Only the latest version api is now provided.
|
229
|
+
- It is now accessed using `typed-factorio/runtime` instead of `typed-factorio/<version>`
|
230
|
+
|
231
|
+
### Added
|
232
|
+
|
233
|
+
- Basic types for settings and data stage. See README for more details.
|
234
|
+
- Types for "util" and "mod-gui" lualib modules
|
235
|
+
|
236
|
+
### Fixed
|
237
|
+
|
238
|
+
- LuaGuiElement::add with a literal now give diagnostic if you supply a field that shouldn't be there.
|
239
|
+
|
240
|
+
### Internal
|
241
|
+
|
242
|
+
- Split generated files into multiple files
|
243
|
+
- Improved compilation tests
|
244
|
+
|
245
|
+
# v0.3.0
|
246
|
+
|
247
|
+
- Added factorio version `1.1.38`
|
248
|
+
|
249
|
+
# v0.2.0
|
250
|
+
|
251
|
+
- `AnyBasic` now uses type `table` instead of type `Record<any, AnyBasic>`
|
252
|
+
- README changes
|
253
|
+
|
254
|
+
# v0.1.0
|
255
|
+
|
256
|
+
- Initial release
|
package/generated/classes.d.ts
CHANGED
@@ -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):
|
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.
|
@@ -1276,10 +1276,11 @@ interface LuaControl {
|
|
1276
1276
|
| LuaEquipmentGrid
|
1277
1277
|
| LuaPlayer
|
1278
1278
|
| LuaGuiElement
|
1279
|
+
| LuaInventory
|
1279
1280
|
| defines.gui_type
|
1280
1281
|
| nil
|
1281
1282
|
)
|
1282
|
-
get opened(): LuaEntity | LuaEquipment | LuaEquipmentGrid | LuaPlayer | LuaGuiElement | nil
|
1283
|
+
get opened(): LuaEntity | LuaEquipment | LuaEquipmentGrid | LuaPlayer | LuaGuiElement | LuaInventory | nil
|
1283
1284
|
/**
|
1284
1285
|
* Size of the crafting queue.
|
1285
1286
|
* @see {@link https://lua-api.factorio.com/latest/LuaControl.html#LuaControl.crafting_queue_size Online documentation}
|
@@ -1575,7 +1576,10 @@ interface LuaControlBehavior {
|
|
1575
1576
|
* @returns The circuit network or nil.
|
1576
1577
|
* @see {@link https://lua-api.factorio.com/latest/LuaControlBehavior.html#LuaControlBehavior.get_circuit_network Online documentation}
|
1577
1578
|
*/
|
1578
|
-
get_circuit_network(
|
1579
|
+
get_circuit_network(
|
1580
|
+
wire: defines.wire_type,
|
1581
|
+
circuit_connector?: defines.circuit_connector_id
|
1582
|
+
): LuaCircuitNetwork | nil
|
1579
1583
|
/**
|
1580
1584
|
* The concrete type of this control behavior.
|
1581
1585
|
* @see {@link https://lua-api.factorio.com/latest/LuaControlBehavior.html#LuaControlBehavior.type Online documentation}
|
@@ -7747,7 +7751,14 @@ interface LuaEntityPrototype {
|
|
7747
7751
|
*/
|
7748
7752
|
readonly torso_rotation_speed?: double
|
7749
7753
|
/**
|
7750
|
-
*
|
7754
|
+
* The torso bob speed of this spider vehicle prototype.
|
7755
|
+
*
|
7756
|
+
* _Can only be used if this is SpiderVehicle_
|
7757
|
+
* @see {@link https://lua-api.factorio.com/latest/LuaEntityPrototype.html#LuaEntityPrototype.torso_bob_speed Online documentation}
|
7758
|
+
*/
|
7759
|
+
readonly torso_bob_speed?: double
|
7760
|
+
/**
|
7761
|
+
* Whether this spider vehicle prototype automatically cycles weapons.
|
7751
7762
|
*
|
7752
7763
|
* _Can only be used if this is SpiderVehicle_
|
7753
7764
|
* @see {@link https://lua-api.factorio.com/latest/LuaEntityPrototype.html#LuaEntityPrototype.automatic_weapon_cycling Online documentation}
|
@@ -8974,7 +8985,14 @@ interface SpiderVehicleEntityPrototype extends BaseEntityPrototype {
|
|
8974
8985
|
*/
|
8975
8986
|
readonly torso_rotation_speed?: double
|
8976
8987
|
/**
|
8977
|
-
*
|
8988
|
+
* The torso bob speed of this spider vehicle prototype.
|
8989
|
+
*
|
8990
|
+
* _Can only be used if this is SpiderVehicle_
|
8991
|
+
* @see {@link https://lua-api.factorio.com/latest/LuaEntityPrototype.html#LuaEntityPrototype.torso_bob_speed Online documentation}
|
8992
|
+
*/
|
8993
|
+
readonly torso_bob_speed?: double
|
8994
|
+
/**
|
8995
|
+
* Whether this spider vehicle prototype automatically cycles weapons.
|
8978
8996
|
*
|
8979
8997
|
* _Can only be used if this is SpiderVehicle_
|
8980
8998
|
* @see {@link https://lua-api.factorio.com/latest/LuaEntityPrototype.html#LuaEntityPrototype.automatic_weapon_cycling Online documentation}
|
@@ -10506,7 +10524,7 @@ interface LuaFluidBox extends Array<Fluid | nil> {
|
|
10506
10524
|
* 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
10525
|
* @see {@link https://lua-api.factorio.com/latest/LuaFluidBox.html#LuaFluidBox.get_fluid_system_id Online documentation}
|
10508
10526
|
*/
|
10509
|
-
get_fluid_system_id(index: uint): uint
|
10527
|
+
get_fluid_system_id(index: uint): uint | nil
|
10510
10528
|
/**
|
10511
10529
|
* Flushes all fluid from this fluidbox and its fluid system.
|
10512
10530
|
* @param fluid If provided, only this fluid is flushed.
|
@@ -20081,7 +20099,7 @@ interface LuaRendering {
|
|
20081
20099
|
* Gets the type of the given object. The types are "text", "line", "circle", "rectangle", "arc", "polygon", "sprite", "light" and "animation".
|
20082
20100
|
* @see {@link https://lua-api.factorio.com/latest/LuaRendering.html#LuaRendering.get_type Online documentation}
|
20083
20101
|
*/
|
20084
|
-
get_type(id: uint64):
|
20102
|
+
get_type(id: uint64): "text" | "line" | "circle" | "rectangle" | "arc" | "polygon" | "sprite" | "light" | "animation"
|
20085
20103
|
/**
|
20086
20104
|
* Reorder this object so that it is drawn in front of the already existing objects.
|
20087
20105
|
* @see {@link https://lua-api.factorio.com/latest/LuaRendering.html#LuaRendering.bring_to_front Online documentation}
|
@@ -22429,7 +22447,7 @@ interface LuaSurface {
|
|
22429
22447
|
* The force the result will be an enemy of. Uses the player force if not specified.
|
22430
22448
|
*/
|
22431
22449
|
readonly force?: ForceIdentification
|
22432
|
-
}): LuaEntity
|
22450
|
+
}): LuaEntity | nil
|
22433
22451
|
/**
|
22434
22452
|
* Give a command to multiple units. This will automatically select suitable units for the task.
|
22435
22453
|
* @returns Number of units actually sent. May be less than `count` if not enough units were available.
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "typed-factorio",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.8.0",
|
4
4
|
"description": "Featureful typescript definitions for the the Factorio modding lua api.",
|
5
5
|
"keywords": [
|
6
6
|
"factorio",
|
@@ -26,20 +26,20 @@
|
|
26
26
|
"prepublishOnly": "yarn run check",
|
27
27
|
"download-latest-runtime-api": "ts-node --esm ./scripts/download-latest.ts",
|
28
28
|
"new-version-changelog": "ts-node --esm ./scripts/new-version-changelog.ts",
|
29
|
-
"next-version": "yarn run download-latest-runtime-api && yarn run clean && yarn run check && yarn run new-version-changelog &&
|
29
|
+
"next-factorio-version": "yarn run download-latest-runtime-api && yarn run clean && yarn run check && yarn run new-version-changelog && npm version minor"
|
30
30
|
},
|
31
31
|
"peerDependencies": {
|
32
32
|
"lua-types": "^2.13.0",
|
33
33
|
"typescript-to-lua": "^1.6.1"
|
34
34
|
},
|
35
35
|
"devDependencies": {
|
36
|
-
"@types/jest": "^
|
37
|
-
"@types/node": "^18.7.
|
36
|
+
"@types/jest": "^29.0.1",
|
37
|
+
"@types/node": "^18.7.16",
|
38
38
|
"@types/prettier": "^2.7.0",
|
39
39
|
"@typescript-eslint/eslint-plugin": "^5.36.2",
|
40
40
|
"@typescript-eslint/parser": "^5.36.2",
|
41
41
|
"chalk": "^5.0.1",
|
42
|
-
"eslint": "~8.23.
|
42
|
+
"eslint": "~8.23.1",
|
43
43
|
"eslint-config-prettier": "^8.5.0",
|
44
44
|
"eslint-config-standard": "^17.0.0",
|
45
45
|
"eslint-import-resolver-typescript": "^3.5.1",
|
@@ -48,13 +48,14 @@
|
|
48
48
|
"eslint-plugin-node": "^11.1.0",
|
49
49
|
"eslint-plugin-prettier": "^4.2.1",
|
50
50
|
"eslint-plugin-promise": "^6.0.1",
|
51
|
-
"jest": "^
|
51
|
+
"jest": "^29.0.3",
|
52
52
|
"lua-types": "^2.13.0",
|
53
53
|
"prettier": "^2.7.1",
|
54
|
-
"
|
54
|
+
"rimraf": "^3.0.2",
|
55
|
+
"ts-jest": "^29.0.0",
|
55
56
|
"ts-node": "^10.9.1",
|
56
|
-
"typescript": "~4.8.
|
57
|
+
"typescript": "~4.8.3",
|
57
58
|
"typescript-to-lua": "^1.10.0"
|
58
59
|
},
|
59
60
|
"packageManager": "yarn@3.2.3"
|
60
|
-
}
|
61
|
+
}
|
@@ -1,153 +0,0 @@
|
|
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;
|