typed-factorio 0.15.0 → 0.18.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,9 +1,9 @@
1
- declare module "typescript" {
2
- interface JSDocContainer {
3
- jsDoc?: JSDoc[]
4
- }
5
- interface Node {
6
- emitNode?: unknown
7
- }
8
- }
9
- export {}
1
+ declare module "typescript" {
2
+ interface JSDocContainer {
3
+ jsDoc?: JSDoc[]
4
+ }
5
+ interface Node {
6
+ emitNode?: unknown
7
+ }
8
+ }
9
+ export {}
package/package.json CHANGED
@@ -1,55 +1,58 @@
1
- {
2
- "name": "typed-factorio",
3
- "version": "0.15.0",
4
- "description": "Featureful typescript definitions for the the Factorio modding lua api.",
5
- "keywords": [
6
- "factorio", "types", "typescript-to-lua", "tstl"
7
- ],
8
- "repository": "https://github.com/GlassBricks/typed-factorio",
9
- "license": "MIT",
10
- "files": [
11
- "**/*.d.ts"
12
- ],
13
- "homepage": "https://github.com/GlassBricks/typed-factorio#readme",
14
- "scripts": {
15
- "gen": "ts-node -P generator/tsconfig.json generator/main.ts",
16
- "generate": "yarn run gen --in ./generatorSrc --out ./generated --warn-as-error",
17
- "generate:dev": "yarn run gen --in ./generatorSrc --out ./generated --no-format",
18
- "clean": "rimraf generated",
19
- "pretest": "yarn run generate",
20
- "test": "jest",
21
- "lint": "eslint .",
22
- "check": "yarn run lint && yarn run test",
23
- "prepublishOnly": "yarn run check",
24
- "download-latest-runtime-api": "ts-node ./scripts/downloadLatest.ts"
25
- },
26
- "peerDependencies": {
27
- "lua-types": "^2.11.0",
28
- "typescript-to-lua": "^1.0.0"
29
- },
30
- "devDependencies": {
31
- "@types/jest": "^27.0.3",
32
- "@types/node": "^16.11.12",
33
- "@types/prettier": "^2.4.2",
34
- "@typescript-eslint/eslint-plugin": "^5.6.0",
35
- "@typescript-eslint/parser": "^5.6.0",
36
- "chalk": "^3.0.0",
37
- "commander": "^8.3.0",
38
- "eslint": "^8.4.1",
39
- "eslint-config-prettier": "^8.3.0",
40
- "eslint-config-standard": "^16.0.3",
41
- "eslint-import-resolver-typescript": "^2.5.0",
42
- "eslint-plugin-import": "^2.25.3",
43
- "eslint-plugin-node": "^11.1.0",
44
- "eslint-plugin-prettier": "^4.0.0",
45
- "eslint-plugin-promise": "^5.2.0",
46
- "jest": "^27.4.3",
47
- "lua-types": "^2.11.0",
48
- "prettier": "^2.5.1",
49
- "prettier-plugin-jsdoc": "^0.3.30",
50
- "ts-jest": "^27.1.0",
51
- "ts-node": "^10.4.0",
52
- "typescript": "4.5.2",
53
- "typescript-to-lua": "^1.2.0"
54
- }
55
- }
1
+ {
2
+ "name": "typed-factorio",
3
+ "version": "0.18.0",
4
+ "description": "Featureful typescript definitions for the the Factorio modding lua api.",
5
+ "keywords": [
6
+ "factorio",
7
+ "types",
8
+ "typescript-to-lua",
9
+ "tstl"
10
+ ],
11
+ "repository": "https://github.com/GlassBricks/typed-factorio",
12
+ "license": "MIT",
13
+ "files": [
14
+ "**/*.d.ts"
15
+ ],
16
+ "homepage": "https://github.com/GlassBricks/typed-factorio#readme",
17
+ "scripts": {
18
+ "gen": "ts-node -P generator/tsconfig.json generator/main.ts",
19
+ "generate": "yarn run gen --in ./generatorSrc --out ./generated --warn-as-error",
20
+ "generate:dev": "yarn run gen --in ./generatorSrc --out ./generated --no-format",
21
+ "clean": "rimraf generated",
22
+ "pretest": "yarn run generate",
23
+ "test": "jest",
24
+ "lint": "eslint .",
25
+ "check": "yarn run lint && yarn run test",
26
+ "prepublishOnly": "yarn run check",
27
+ "download-latest-runtime-api": "ts-node ./scripts/downloadLatest.ts"
28
+ },
29
+ "peerDependencies": {
30
+ "lua-types": "^2.11.0",
31
+ "typescript-to-lua": "^1.3.1"
32
+ },
33
+ "devDependencies": {
34
+ "@types/jest": "^27.0.3",
35
+ "@types/node": "^16.11.12",
36
+ "@types/prettier": "^2.4.2",
37
+ "@typescript-eslint/eslint-plugin": "^5.6.0",
38
+ "@typescript-eslint/parser": "^5.6.0",
39
+ "chalk": "^3.0.0",
40
+ "commander": "^8.3.0",
41
+ "eslint": "^8.4.1",
42
+ "eslint-config-prettier": "^8.3.0",
43
+ "eslint-config-standard": "^16.0.3",
44
+ "eslint-import-resolver-typescript": "^2.5.0",
45
+ "eslint-plugin-import": "^2.25.3",
46
+ "eslint-plugin-node": "^11.1.0",
47
+ "eslint-plugin-prettier": "^4.0.0",
48
+ "eslint-plugin-promise": "^5.2.0",
49
+ "jest": "^27.4.3",
50
+ "lua-types": "^2.11.0",
51
+ "prettier": "^2.5.1",
52
+ "prettier-plugin-jsdoc": "^0.3.30",
53
+ "ts-jest": "^27.1.0",
54
+ "ts-node": "^10.4.0",
55
+ "typescript": "4.5.2",
56
+ "typescript-to-lua": "^1.3.1"
57
+ }
58
+ }
@@ -1,10 +1,10 @@
1
- /// <reference types="lua-types/5.2" />
2
-
3
- /// <reference path="../generated/index.d.ts" />
4
-
5
- /// <reference path="librariesAndFunctions.d.ts" />
6
- /// <reference path="pairs.d.ts" />
7
-
8
- // lualib
9
- /// <reference path="util.d.ts" />
10
- /// <reference path="mod-gui.d.ts" />
1
+ /// <reference types="lua-types/5.2" />
2
+
3
+ /// <reference path="../generated/index.d.ts" />
4
+
5
+ /// <reference path="librariesAndFunctions.d.ts" />
6
+ /// <reference path="pairs.d.ts" />
7
+
8
+ // lualib
9
+ /// <reference path="util.d.ts" />
10
+ /// <reference path="mod-gui.d.ts" />
@@ -1,123 +1,123 @@
1
- // from https://lua-api.factorio.com/latest/Libraries.html
2
- // last updated for 1.1.35, 1.1.36, 1.1.37
3
-
4
- /** @noSelfInFile */
5
-
6
- /** @noSelf */
7
- interface SerpentOptions {
8
- /** Indentation; triggers long multi-line output. */
9
- indent: string
10
- /** Provide stringified value in a comment (up to maxlevel of depth). */
11
- comment: boolean | number
12
- /** Sort keys. */
13
- sortkeys: boolean | ((this: void, keys: any[], table: any) => void)
14
- /** Force sparse encoding (no nil filling based on #t). */
15
- sparse: boolean
16
- /** Remove spaces. */
17
- compact: boolean
18
- /** Raise fatal error on non-serializable values. */
19
- fatal: boolean
20
- /** Disable bytecode serialization for easy comparison. */
21
- nocode: boolean
22
- /** Disable checking numbers against undefined and huge values. */
23
- nohuge: boolean
24
- /** Specify max level up to which to expand nested tables. */
25
- maxlevel: number
26
- /** Specify max number of elements in a table. */
27
- maxnum: number
28
- /** Specify max length for all table elements. */
29
- maxlength: number
30
- /**
31
- * Use __tostring metamethod when serializing tables (v0.29); set to false to disable and serialize the table as is,
32
- * even when __tostring is present.
33
- */
34
- metatostring: boolean
35
- /**
36
- * Specify format for numeric values as shortest possible round-trippable double (v0.30). Use "%.16g" for better
37
- * readability and "%.17g" (the default value) to preserve floating point precision.
38
- */
39
- numformat: string
40
- /** Allows to specify a list of values to ignore (as keys). */
41
- valignore: string[]
42
- /** Allows to specify the list of keys to be serialized. Any keys not in this list are not included in final output (as keys). */
43
- keyallow: string[]
44
- /** Allows to specity the list of keys to ignore in serialization. */
45
- keyignore: string[]
46
- /** Allows to specify a list of value types to ignore (as keys). */
47
- valtypeignore: string[]
48
- /** Provide custom output for tables. */
49
- custom(opts: {
50
- /** The name of the current element with '=' or an empty string in case of array index, */
51
- tag: string
52
- /** An opening table bracket { and associated indentation and newline (if any), */
53
- head: string
54
- /** Table elements concatenated into a string using commas and indentation/newlines (if any), */
55
- body: string
56
- /** A closing table bracket } and associated indentation and newline (if any), and */
57
- tail: string
58
- /** The current level. */
59
- level: number
60
- }): string
61
- /** Name; triggers full serialization with self-ref section. */
62
- name: string
63
-
64
- refcomment: boolean | number
65
- tablecomment: boolean | number
66
- }
67
-
68
- /**
69
- * Factorio provides the {@link https://github.com/pkulchenko/serpent serpent library} as a global variable `serpent` for
70
- * all mods to use. It allows for easy debugging of tables, because serpent makes it trivial to print them, for example
71
- * by using `serpent.block()`. However, serpent cannot pretty-print LuaObjects such as LuaEntity. The serpent library
72
- * was modified to improve determinism, e.g. comments are turned off by default to avoid returning table addresses.
73
- * Furthermore, two options were added: `refcomment` (true/false/maxlevel) and `tablecomment` (true/false/maxlevel),
74
- * which allow to separately control the self-reference and table value output of the `comment` option.
75
- */
76
- declare namespace serpent {
77
- /** Full serialization; sets name, compact and sparse options; */
78
- function dump(tbl: unknown, options?: Partial<SerpentOptions>): string
79
-
80
- /** Single line pretty printing, no self-ref section; sets sortkeys and comment options; */
81
- function line(tbl: unknown, options?: Partial<SerpentOptions>): string
82
-
83
- /** Multi-line indented pretty printing, no self-ref section; sets indent, sortkeys, and comment options. */
84
- function block(tbl: unknown, options?: Partial<SerpentOptions>): string
85
-
86
- /**
87
- * For loading serialized fragments, serpent also provides `load` function that adds safety checks and reports an
88
- * error if there is any executable code in the fragment.
89
- */
90
- function load<T>(str: string, options?: { safe?: boolean }): LuaMultiReturn<[true, T] | [false, string]>
91
- }
92
-
93
- /**
94
- * This function allows to log {@link LocalisedString} to the Factorio
95
- * {@link https://wiki.factorio.com/Log_file log file}. This, in combination with serpent, makes debugging in the data
96
- * stage easier, because it allows to simply inspect entire prototype tables. For example, this allows to see all
97
- * properties of the sulfur item prototype: `log(serpent.block(data.raw["item"]["sulfur"]))`
98
- */
99
- declare function log(ls: LocalisedString): void
100
-
101
- /**
102
- * This function allows printing {@link LocalisedString}s to stdout without polluting the logfile. This is primarily
103
- * useful for communicating with external tools that launch Factorio as a child process.
104
- */
105
- declare function localised_print(ls: LocalisedString): void
106
-
107
- /**
108
- * Factorio provides the function `table_size()` as a simple way to find the size of tables with non-continuous keys,
109
- * because the standard `#` does not work correctly for these. The function is a C++-side implementation of the
110
- * following Lua code, thus it is faster than using this code in Lua:
111
- *
112
- * local function size(t)
113
- * local count = 0
114
- * for k,v in pairs(t) do
115
- * count = count + 1
116
- * end
117
- * return count
118
- * end
119
- *
120
- * Note that `table_size()` does not work correctly for {@link LuaCustomTable}s, their size has to be determined with
121
- * {@link LuaCustomTable.length LuaCustomTable::operator #} instead.
122
- */
123
- declare function table_size(tbl: table): number
1
+ // from https://lua-api.factorio.com/latest/Libraries.html
2
+ // last updated for 1.1.35, 1.1.36, 1.1.37
3
+
4
+ /** @noSelfInFile */
5
+
6
+ /** @noSelf */
7
+ interface SerpentOptions {
8
+ /** Indentation; triggers long multi-line output. */
9
+ indent: string
10
+ /** Provide stringified value in a comment (up to maxlevel of depth). */
11
+ comment: boolean | number
12
+ /** Sort keys. */
13
+ sortkeys: boolean | ((this: void, keys: any[], table: any) => void)
14
+ /** Force sparse encoding (no nil filling based on #t). */
15
+ sparse: boolean
16
+ /** Remove spaces. */
17
+ compact: boolean
18
+ /** Raise fatal error on non-serializable values. */
19
+ fatal: boolean
20
+ /** Disable bytecode serialization for easy comparison. */
21
+ nocode: boolean
22
+ /** Disable checking numbers against undefined and huge values. */
23
+ nohuge: boolean
24
+ /** Specify max level up to which to expand nested tables. */
25
+ maxlevel: number
26
+ /** Specify max number of elements in a table. */
27
+ maxnum: number
28
+ /** Specify max length for all table elements. */
29
+ maxlength: number
30
+ /**
31
+ * Use __tostring metamethod when serializing tables (v0.29); set to false to disable and serialize the table as is,
32
+ * even when __tostring is present.
33
+ */
34
+ metatostring: boolean
35
+ /**
36
+ * Specify format for numeric values as shortest possible round-trippable double (v0.30). Use "%.16g" for better
37
+ * readability and "%.17g" (the default value) to preserve floating point precision.
38
+ */
39
+ numformat: string
40
+ /** Allows to specify a list of values to ignore (as keys). */
41
+ valignore: string[]
42
+ /** Allows to specify the list of keys to be serialized. Any keys not in this list are not included in final output (as keys). */
43
+ keyallow: string[]
44
+ /** Allows to specity the list of keys to ignore in serialization. */
45
+ keyignore: string[]
46
+ /** Allows to specify a list of value types to ignore (as keys). */
47
+ valtypeignore: string[]
48
+ /** Provide custom output for tables. */
49
+ custom(opts: {
50
+ /** The name of the current element with '=' or an empty string in case of array index, */
51
+ tag: string
52
+ /** An opening table bracket { and associated indentation and newline (if any), */
53
+ head: string
54
+ /** Table elements concatenated into a string using commas and indentation/newlines (if any), */
55
+ body: string
56
+ /** A closing table bracket } and associated indentation and newline (if any), and */
57
+ tail: string
58
+ /** The current level. */
59
+ level: number
60
+ }): string
61
+ /** Name; triggers full serialization with self-ref section. */
62
+ name: string
63
+
64
+ refcomment: boolean | number
65
+ tablecomment: boolean | number
66
+ }
67
+
68
+ /**
69
+ * Factorio provides the {@link https://github.com/pkulchenko/serpent serpent library} as a global variable `serpent` for
70
+ * all mods to use. It allows for easy debugging of tables, because serpent makes it trivial to print them, for example
71
+ * by using `serpent.block()`. However, serpent cannot pretty-print LuaObjects such as LuaEntity. The serpent library
72
+ * was modified to improve determinism, e.g. comments are turned off by default to avoid returning table addresses.
73
+ * Furthermore, two options were added: `refcomment` (true/false/maxlevel) and `tablecomment` (true/false/maxlevel),
74
+ * which allow to separately control the self-reference and table value output of the `comment` option.
75
+ */
76
+ declare namespace serpent {
77
+ /** Full serialization; sets name, compact and sparse options; */
78
+ function dump(tbl: unknown, options?: Partial<SerpentOptions>): string
79
+
80
+ /** Single line pretty printing, no self-ref section; sets sortkeys and comment options; */
81
+ function line(tbl: unknown, options?: Partial<SerpentOptions>): string
82
+
83
+ /** Multi-line indented pretty printing, no self-ref section; sets indent, sortkeys, and comment options. */
84
+ function block(tbl: unknown, options?: Partial<SerpentOptions>): string
85
+
86
+ /**
87
+ * For loading serialized fragments, serpent also provides `load` function that adds safety checks and reports an
88
+ * error if there is any executable code in the fragment.
89
+ */
90
+ function load<T>(str: string, options?: { safe?: boolean }): LuaMultiReturn<[true, T] | [false, string]>
91
+ }
92
+
93
+ /**
94
+ * This function allows to log {@link LocalisedString} to the Factorio
95
+ * {@link https://wiki.factorio.com/Log_file log file}. This, in combination with serpent, makes debugging in the data
96
+ * stage easier, because it allows to simply inspect entire prototype tables. For example, this allows to see all
97
+ * properties of the sulfur item prototype: `log(serpent.block(data.raw["item"]["sulfur"]))`
98
+ */
99
+ declare function log(ls: LocalisedString): void
100
+
101
+ /**
102
+ * This function allows printing {@link LocalisedString}s to stdout without polluting the logfile. This is primarily
103
+ * useful for communicating with external tools that launch Factorio as a child process.
104
+ */
105
+ declare function localised_print(ls: LocalisedString): void
106
+
107
+ /**
108
+ * Factorio provides the function `table_size()` as a simple way to find the size of tables with non-continuous keys,
109
+ * because the standard `#` does not work correctly for these. The function is a C++-side implementation of the
110
+ * following Lua code, thus it is faster than using this code in Lua:
111
+ *
112
+ * local function size(t)
113
+ * local count = 0
114
+ * for k,v in pairs(t) do
115
+ * count = count + 1
116
+ * end
117
+ * return count
118
+ * end
119
+ *
120
+ * Note that `table_size()` does not work correctly for {@link LuaCustomTable}s, their size has to be determined with
121
+ * {@link LuaCustomTable.length LuaCustomTable::operator #} instead.
122
+ */
123
+ declare function table_size(tbl: table): number
@@ -1,11 +1,11 @@
1
- /** @noSelfInFile */
2
-
3
- /** @noResolution */
4
- declare module "mod-gui" {
5
- const button_style: string
6
- const frame_style: string
7
-
8
- function get_button_flow(player: LuaPlayer): FrameGuiElement
9
-
10
- function get_frame_flow(player: LuaPlayer): FlowGuiElement
11
- }
1
+ /** @noSelfInFile */
2
+
3
+ /** @noResolution */
4
+ declare module "mod-gui" {
5
+ const button_style: string
6
+ const frame_style: string
7
+
8
+ function get_button_flow(player: LuaPlayer): FrameGuiElement
9
+
10
+ function get_frame_flow(player: LuaPlayer): FlowGuiElement
11
+ }
@@ -1,13 +1,14 @@
1
- /** @noSelfInFile */
2
-
3
- /** Iterating with `pairs` will only iterate the array part of a {@link LuaCustomTable}. */
4
- declare function pairs<V>(table: LuaCustomTable<number | string, V>): LuaIterable<LuaMultiReturn<[number, V]>>
5
-
6
- declare function pairs<K extends keyof any, V>(table: LuaCustomTable<K, V>): LuaIterable<LuaMultiReturn<[K, V]>>
7
-
8
- /**
9
- * {@link LuaCustomTable} cannot be iterated with `ipairs`. Use `pairs` instead.
10
- *
11
- * @deprecated
12
- */
13
- declare function ipairs(table: LuaCustomTable<any, any>): never
1
+ /** @noSelfInFile */
2
+
3
+ /**
4
+ * Iterating with `pairs` will only iterate the array part of a {@link LuaCustomTable}.
5
+ *
6
+ * **Note**: you can also iterate on a LuaCustomTable directly without using `pairs`, e.g. `for(const [k, v] of table)`.
7
+ */
8
+ declare function pairs<V>(table: LuaCustomTable<number | string, V>): LuaIterable<LuaMultiReturn<[number, V]>>
9
+
10
+ /** **Note**: you can also iterate on a LuaCustomTable directly without using `pairs`, e.g. `for(const [k, v] of table)`. */
11
+ declare function pairs<K extends number | string, V>(table: LuaCustomTable<K, V>): LuaIterable<LuaMultiReturn<[K, V]>>
12
+
13
+ /** @deprecated {@link LuaCustomTable} cannot be iterated with `ipairs`; Use {@link pairs} instead. */
14
+ declare function ipairs(table: LuaCustomTable<any, any>): never