typed-factorio 2.14.0 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -8
- package/common/data-global.d.ts +8 -0
- package/common/types.d.ts +3 -1
- package/package.json +1 -2
- package/prototype/generated/prototypes.d.ts +6818 -4113
- package/prototype/generated/types.d.ts +10656 -6113
- package/runtime/generated/classes.d.ts +11574 -10762
- package/runtime/generated/concepts.d.ts +7516 -5096
- package/runtime/generated/defines.d.ts +832 -250
- package/runtime/generated/events.d.ts +712 -287
- package/runtime/generated/global-functions.d.ts +3 -3
- package/runtime/generated/global-objects.d.ts +23 -11
package/README.md
CHANGED
@@ -28,7 +28,7 @@ Example:
|
|
28
28
|
```
|
29
29
|
|
30
30
|
The stages used will select the global variables defined.
|
31
|
-
You can include multiple stages, but there are some caveats. See [Using multiple stages in the same project](#using-multiple-stages-in-the-same-project) for more info.
|
31
|
+
You can include multiple stages, but there are some caveats. See [Using multiple stages in the same project](#using-multiple-loading-stages-in-the-same-project) for more info.
|
32
32
|
|
33
33
|
## Usage notes
|
34
34
|
|
@@ -107,14 +107,15 @@ const foo = util.copy(bar)
|
|
107
107
|
|
108
108
|
If you wish to see types for more lualib modules, feel free to open an issue or pull request.
|
109
109
|
|
110
|
-
### The `
|
110
|
+
### The `storage` table
|
111
111
|
|
112
|
-
The `
|
112
|
+
The `storage` table (in the runtime stage) can have any shape, so it is not defined here. Instead, you can define it yourself:
|
113
113
|
|
114
|
-
- Add `declare const
|
115
|
-
- Add `declare
|
114
|
+
- Add `declare const storage: <Your type>` in a `.d.ts` file. Make sure this file is included by your tsconfig!
|
115
|
+
- Add `declare global { const storage: <Your type> }` in a `.ts` file included in your project.
|
116
|
+
- Add `declare const storage: {...}` to each file where needed. This way, you can define only properties that each file specifically uses.
|
116
117
|
|
117
|
-
## Using multiple stages in the same project
|
118
|
+
## Using multiple loading stages in the same project
|
118
119
|
|
119
120
|
Every Factorio loading stage declares different global variables.
|
120
121
|
To add types for multiple Factorio stages, you have a few options:
|
@@ -123,17 +124,19 @@ To add types for multiple Factorio stages, you have a few options:
|
|
123
124
|
2. Add _only_ the runtime stage, then manually declare other global variables in files that use them. There are types in `"factorio:common"` to allow this:
|
124
125
|
```ts
|
125
126
|
// -- For the prototype stage --
|
126
|
-
import { PrototypeData, ActiveMods } from "factorio:common"
|
127
|
+
import { PrototypeData, ActiveMods, FeatureFlags } from "factorio:common"
|
127
128
|
declare const data: PrototypeData
|
128
129
|
declare const mods: ActiveMods
|
130
|
+
declare const feature_flags: FeatureFlags
|
129
131
|
// The `settings` global variable is already declared in the runtime stage.
|
130
132
|
// However, in the prototype stage _only_ `settings.startup` are available.
|
131
133
|
```
|
132
134
|
```ts
|
133
135
|
// -- For the settings stage --
|
134
|
-
import { SettingsData, ActiveMods } from "factorio:common"
|
136
|
+
import { SettingsData, ActiveMods, FeatureFlags } from "factorio:common"
|
135
137
|
declare const data: SettingsData
|
136
138
|
declare const mods: ActiveMods
|
139
|
+
declare const feature_flags: FeatureFlags
|
137
140
|
```
|
138
141
|
3. Use a separate `tsconfig.json` for each stage. In each `tsconfig.json`, add only files in that stage to the `"include"` field, e.g. `include: ["src/control.ts"]` for the runtime stage. However, this means you need to run `tstl` separately for each stage, and files shared by multiple stages will be compiled multiple times.
|
139
142
|
|
package/common/data-global.d.ts
CHANGED
@@ -13,3 +13,11 @@ declare const data: import("factorio:common").DataGlobal
|
|
13
13
|
* In the runtime stage, use `script.active_mods`.
|
14
14
|
*/
|
15
15
|
declare const mods: import("factorio:common").ActiveMods
|
16
|
+
|
17
|
+
/**
|
18
|
+
* A dict of feature flags and their status.
|
19
|
+
*
|
20
|
+
* This global is only available in the settings or prototype stage.
|
21
|
+
* In the runtime stage, use `script.feature_flags`.
|
22
|
+
*/
|
23
|
+
declare const feature_flags: import("factorio:common").FeatureFlags
|
package/common/types.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/** @noResolution */
|
2
2
|
declare module "factorio:common" {
|
3
|
-
import { ModSetting } from "factorio:runtime"
|
3
|
+
import { ModSetting, LuaBootstrap } from "factorio:runtime"
|
4
4
|
import { Data } from "factorio:prototype"
|
5
5
|
import { SettingsPrototypeMap } from "factorio:settings"
|
6
6
|
/**
|
@@ -48,6 +48,8 @@ declare module "factorio:common" {
|
|
48
48
|
readonly [modName: string]: VersionString | undefined
|
49
49
|
}
|
50
50
|
|
51
|
+
export type FeatureFlags = LuaBootstrap["feature_flags"]
|
52
|
+
|
51
53
|
/**
|
52
54
|
* Represents the `data` global variable for the prototype stage.
|
53
55
|
*
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "typed-factorio",
|
3
|
-
"version": "
|
3
|
+
"version": "3.0.1",
|
4
4
|
"description": "Featureful typescript definitions for the Factorio modding api.",
|
5
5
|
"keywords": [
|
6
6
|
"factorio",
|
@@ -46,7 +46,6 @@
|
|
46
46
|
"@types/node": "^20.11.29",
|
47
47
|
"@typescript-eslint/eslint-plugin": "^7.3.0",
|
48
48
|
"@typescript-eslint/parser": "^7.3.0",
|
49
|
-
"chalk": "^5.3.0",
|
50
49
|
"download": "^8.0.0",
|
51
50
|
"eslint": "^8.57.0",
|
52
51
|
"eslint-config-prettier": "^9.1.0",
|