typed-factorio 3.9.0 → 3.10.0

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/lualib/util.d.ts CHANGED
@@ -1,151 +1,151 @@
1
- /** @noSelfInFile */
2
-
3
- /** @noResolution */
4
- declare module "util" {
5
- import {
6
- ColorArray as RColorArray,
7
- float,
8
- LuaEntity,
9
- MapPosition,
10
- MapPositionArray,
11
- nil,
12
- table,
13
- } from "factorio:runtime"
14
- import { Color as PrototypeColor, SpriteParameters } from "factorio:prototype"
15
- import { PrototypeData } from "factorio:common"
16
-
17
- type ColorArray = PrototypeColor & float[]
18
- interface ColorTable {
19
- r: float
20
- g: float
21
- b: float
22
- a?: float
23
- }
24
- type AnyColor = PrototypeColor | RColorArray
25
- namespace table {
26
- function deepcopy<T>(table: T): T
27
-
28
- function compare<T extends table>(tb1: T, tb2: T): boolean
29
- }
30
-
31
- function copy<T>(table: T): T
32
-
33
- function distance(position1: MapPosition | MapPositionArray, position2: MapPosition | MapPositionArray): number
34
-
35
- function positiontostr(position: MapPosition | MapPositionArray): string
36
-
37
- function formattime(ticks: number): string
38
-
39
- /** Supports 'rrggbb', 'rgb', 'rrggbbaa', 'rgba', 'ww', 'w' */
40
- function color(hex: string): ColorTable
41
-
42
- function premul_color(color: AnyColor): ColorTable
43
-
44
- function mix_color(c1: AnyColor, c2: AnyColor): ColorArray
45
-
46
- function multiply_color(c1: AnyColor, n: number): ColorArray
47
-
48
- function get_color_with_alpha(color: AnyColor, alpha: number, normalized_alpha?: boolean): ColorTable
49
-
50
- const direction_vectors: Record<defines.direction, MapPositionArray>
51
-
52
- function moveposition(
53
- position: MapPositionArray,
54
- direction: defines.direction.north,
55
- distance: number,
56
- ): MapPositionArray
57
-
58
- function oppositedirection(direction: defines.direction): defines.direction
59
-
60
- /** Creates a new array where each element in `stripes` is duplicated `count` times */
61
- function multiplystripes<T>(count: number, stripes: readonly T[]): T[]
62
-
63
- /** Gets tile position by pixel */
64
- function by_pixel(x: number, y: number): MapPositionArray
65
-
66
- /** Gets tile position by pixel, hr */
67
- function by_pixel_hr(x: number, y: number): MapPositionArray
68
-
69
- type SpriteWithHrVersion<T = unknown> = T & SpriteParameters & { hr_version?: SpriteParameters & T }
70
-
71
- function foreach_sprite_definition<T extends SpriteWithHrVersion>(
72
- sprite: T,
73
- fun: (sprite: T & T["hr_version"]) => void,
74
- ): void
75
-
76
- function add_shift(a: MapPositionArray | nil, b: MapPositionArray): MapPositionArray
77
- function add_shift(a: MapPositionArray, b: MapPositionArray | nil): MapPositionArray
78
- function add_shift(a: MapPositionArray | nil, b: MapPositionArray | nil): MapPositionArray | nil
79
-
80
- function add_shift_offset<T extends SpriteWithHrVersion<{ shift?: MapPositionArray }>>(
81
- offset: MapPositionArray | nil,
82
- sprite: T,
83
- ): T
84
-
85
- function mul_shift(shift: MapPositionArray, scale: number | nil): MapPositionArray
86
- function mul_shift(shift: MapPositionArray | nil, scale: number | nil): MapPositionArray | nil
87
-
88
- function format_number(amount: number, append_suffix?: boolean): string
89
-
90
- function increment(t: number[], luaIndex: number, v?: number): void
91
-
92
- // Omitted: conditional_return; it's literally just `a and b`
93
-
94
- /**
95
- * Recursively merges and/or deep-copies tables. Entries in later tables override entries in earlier ones, unless both
96
- * entries are themselves tables, in which case they are recursively merged. Non-merged tables are deep-copied, so
97
- * that the result is brand new.
98
- */
99
- function merge<T extends object>(tables: readonly T[]): T
100
-
101
- function insert_safe(entity: LuaEntity | nil, item_dict: Record<string, number> | nil): void
102
-
103
- function remove_safe(entity: LuaEntity | nil, item_dict: Record<string, number> | nil): void
104
-
105
- function split_whitespace(string: string): string[]
106
-
107
- // Omitted: split, string_starts_with. Use the builtin tstl functions for that.
108
-
109
- // Omitted: online_players. Use game.connected_players
110
- // The lua code actually logs "But why?" if you do this...
111
-
112
- function clamp(x: number, lower: number, upper: number): number
113
-
114
- function get_walkable_tile(): string
115
-
116
- /**
117
- * This function takes 2 icons tables, and adds the second to the first, but applies scale, shift and tint to the entire second set.
118
- * This allows you to manipulate the entire second icons table in the same way as you would manipulate a single icon when adding to the icons table.
119
- */
120
- function combine_icons<T extends SpriteParameters>(
121
- icons1: readonly T[],
122
- icons2: readonly T[],
123
- inputs: {
124
- scale?: number
125
- shift?: MapPositionArray
126
- tint?: AnyColor
127
- },
128
- ): T[]
129
-
130
- // omitted: technology_icons. Create an issue if you really want to see these
131
-
132
- function parse_energy(energy: string): number
133
-
134
- function product_amount(product: {
135
- probability: number
136
- amount?: number
137
- amount_min?: number
138
- amount_max?: number
139
- }): number
140
-
141
- function empty_sprite(): SpriteParameters
142
-
143
- function draw_as_glow<T extends SpriteWithHrVersion>(sprite: T): T
144
- function remove_tile_references(data: PrototypeData, array_of_tiles_to_remove: readonly string[]): void
145
-
146
- function remove_from_list<T>(list: T[], value: T): boolean
147
-
148
- function list_to_map<V>(list: LuaPairsIterable<any, V>): LuaSet<NonNullable<V>>
149
- function list_to_map<T extends AnyNotNil>(list: T[]): LuaSet<T>
150
- function list_to_map<T extends AnyNotNil>(list: T): LuaSet<NonNullable<T[keyof T]>>
151
- }
1
+ /** @noSelfInFile */
2
+
3
+ /** @noResolution */
4
+ declare module "util" {
5
+ import {
6
+ ColorArray as RColorArray,
7
+ float,
8
+ LuaEntity,
9
+ MapPosition,
10
+ MapPositionArray,
11
+ nil,
12
+ table,
13
+ } from "factorio:runtime"
14
+ import { Color as PrototypeColor, SpriteParameters } from "factorio:prototype"
15
+ import { PrototypeData } from "factorio:common"
16
+
17
+ type ColorArray = PrototypeColor & float[]
18
+ interface ColorTable {
19
+ r: float
20
+ g: float
21
+ b: float
22
+ a?: float
23
+ }
24
+ type AnyColor = PrototypeColor | RColorArray
25
+ namespace table {
26
+ function deepcopy<T>(table: T): T
27
+
28
+ function compare<T extends table>(tb1: T, tb2: T): boolean
29
+ }
30
+
31
+ function copy<T>(table: T): T
32
+
33
+ function distance(position1: MapPosition | MapPositionArray, position2: MapPosition | MapPositionArray): number
34
+
35
+ function positiontostr(position: MapPosition | MapPositionArray): string
36
+
37
+ function formattime(ticks: number): string
38
+
39
+ /** Supports 'rrggbb', 'rgb', 'rrggbbaa', 'rgba', 'ww', 'w' */
40
+ function color(hex: string): ColorTable
41
+
42
+ function premul_color(color: AnyColor): ColorTable
43
+
44
+ function mix_color(c1: AnyColor, c2: AnyColor): ColorArray
45
+
46
+ function multiply_color(c1: AnyColor, n: number): ColorArray
47
+
48
+ function get_color_with_alpha(color: AnyColor, alpha: number, normalized_alpha?: boolean): ColorTable
49
+
50
+ const direction_vectors: Record<defines.direction, MapPositionArray>
51
+
52
+ function moveposition(
53
+ position: MapPositionArray,
54
+ direction: defines.direction.north,
55
+ distance: number,
56
+ ): MapPositionArray
57
+
58
+ function oppositedirection(direction: defines.direction): defines.direction
59
+
60
+ /** Creates a new array where each element in `stripes` is duplicated `count` times */
61
+ function multiplystripes<T>(count: number, stripes: readonly T[]): T[]
62
+
63
+ /** Gets tile position by pixel */
64
+ function by_pixel(x: number, y: number): MapPositionArray
65
+
66
+ /** Gets tile position by pixel, hr */
67
+ function by_pixel_hr(x: number, y: number): MapPositionArray
68
+
69
+ type SpriteWithHrVersion<T = unknown> = T & SpriteParameters & { hr_version?: SpriteParameters & T }
70
+
71
+ function foreach_sprite_definition<T extends SpriteWithHrVersion>(
72
+ sprite: T,
73
+ fun: (sprite: T & T["hr_version"]) => void,
74
+ ): void
75
+
76
+ function add_shift(a: MapPositionArray | nil, b: MapPositionArray): MapPositionArray
77
+ function add_shift(a: MapPositionArray, b: MapPositionArray | nil): MapPositionArray
78
+ function add_shift(a: MapPositionArray | nil, b: MapPositionArray | nil): MapPositionArray | nil
79
+
80
+ function add_shift_offset<T extends SpriteWithHrVersion<{ shift?: MapPositionArray }>>(
81
+ offset: MapPositionArray | nil,
82
+ sprite: T,
83
+ ): T
84
+
85
+ function mul_shift(shift: MapPositionArray, scale: number | nil): MapPositionArray
86
+ function mul_shift(shift: MapPositionArray | nil, scale: number | nil): MapPositionArray | nil
87
+
88
+ function format_number(amount: number, append_suffix?: boolean): string
89
+
90
+ function increment(t: number[], luaIndex: number, v?: number): void
91
+
92
+ // Omitted: conditional_return; it's literally just `a and b`
93
+
94
+ /**
95
+ * Recursively merges and/or deep-copies tables. Entries in later tables override entries in earlier ones, unless both
96
+ * entries are themselves tables, in which case they are recursively merged. Non-merged tables are deep-copied, so
97
+ * that the result is brand new.
98
+ */
99
+ function merge<T extends object>(tables: readonly T[]): T
100
+
101
+ function insert_safe(entity: LuaEntity | nil, item_dict: Record<string, number> | nil): void
102
+
103
+ function remove_safe(entity: LuaEntity | nil, item_dict: Record<string, number> | nil): void
104
+
105
+ function split_whitespace(string: string): string[]
106
+
107
+ // Omitted: split, string_starts_with. Use the builtin tstl functions for that.
108
+
109
+ // Omitted: online_players. Use game.connected_players
110
+ // The lua code actually logs "But why?" if you do this...
111
+
112
+ function clamp(x: number, lower: number, upper: number): number
113
+
114
+ function get_walkable_tile(): string
115
+
116
+ /**
117
+ * This function takes 2 icons tables, and adds the second to the first, but applies scale, shift and tint to the entire second set.
118
+ * This allows you to manipulate the entire second icons table in the same way as you would manipulate a single icon when adding to the icons table.
119
+ */
120
+ function combine_icons<T extends SpriteParameters>(
121
+ icons1: readonly T[],
122
+ icons2: readonly T[],
123
+ inputs: {
124
+ scale?: number
125
+ shift?: MapPositionArray
126
+ tint?: AnyColor
127
+ },
128
+ ): T[]
129
+
130
+ // omitted: technology_icons. Create an issue if you really want to see these
131
+
132
+ function parse_energy(energy: string): number
133
+
134
+ function product_amount(product: {
135
+ probability: number
136
+ amount?: number
137
+ amount_min?: number
138
+ amount_max?: number
139
+ }): number
140
+
141
+ function empty_sprite(): SpriteParameters
142
+
143
+ function draw_as_glow<T extends SpriteWithHrVersion>(sprite: T): T
144
+ function remove_tile_references(data: PrototypeData, array_of_tiles_to_remove: readonly string[]): void
145
+
146
+ function remove_from_list<T>(list: T[], value: T): boolean
147
+
148
+ function list_to_map<V>(list: LuaPairsIterable<any, V>): LuaSet<NonNullable<V>>
149
+ function list_to_map<T extends AnyNotNil>(list: T[]): LuaSet<T>
150
+ function list_to_map<T extends AnyNotNil>(list: T): LuaSet<NonNullable<T[keyof T]>>
151
+ }
package/package.json CHANGED
@@ -1,65 +1,65 @@
1
- {
2
- "name": "typed-factorio",
3
- "version": "3.9.0",
4
- "description": "Featureful typescript definitions for the Factorio modding api.",
5
- "keywords": [
6
- "factorio",
7
- "types",
8
- "typescript-to-lua",
9
- "tstl"
10
- ],
11
- "repository": {
12
- "type": "git",
13
- "url": "git+https://github.com/GlassBricks/typed-factorio.git"
14
- },
15
- "homepage": "https://github.com/GlassBricks/typed-factorio#readme",
16
- "license": "MIT",
17
- "files": [
18
- "**/*.d.ts",
19
- "*.d.ts",
20
- "!generator/**/*"
21
- ],
22
- "type": "module",
23
- "packageManager": "npm@9.5.0",
24
- "scripts": {
25
- "generate": "tsx --tsconfig generator/tsconfig.json generator/main.ts",
26
- "generate-no-format": "tsx --tsconfig generator/tsconfig.json generator/main.ts --no-format",
27
- "clean": "rimraf runtime/generated prototype/generated",
28
- "lint": "eslint .",
29
- "format:check": "prettier --check .",
30
- "format:fix": "prettier --write .",
31
- "check": "npm run lint && npm run format:check && tsc --noEmit",
32
- "prepublishOnly": "npm run generate && npm run check",
33
- "script": "tsx --tsconfig scripts/tsconfig.json",
34
- "download-latest-api-jsons": "npm run script ./scripts/download-latest.ts",
35
- "new-version-changelog": "npm run script ./scripts/new-version-changelog.ts",
36
- "get-current-factorio-version": "npm run script ./scripts/get-current-version.ts",
37
- "next-factorio-version-diff": "npm run script ./scripts/new-version-diff.ts"
38
- },
39
- "peerDependencies": {
40
- "lua-types": "^2.13.1",
41
- "typescript-to-lua": "^1.10.0"
42
- },
43
- "devDependencies": {
44
- "@swc/core": "^1.4.8",
45
- "@types/download": "^8.0.5",
46
- "@types/node": "^20.11.29",
47
- "@typescript-eslint/eslint-plugin": "^7.3.0",
48
- "@typescript-eslint/parser": "^7.3.0",
49
- "download": "^8.0.0",
50
- "eslint": "^8.57.0",
51
- "eslint-config-prettier": "^9.1.0",
52
- "eslint-import-resolver-typescript": "^3.6.1",
53
- "eslint-plugin-eslint-comments": "^3.2.0",
54
- "eslint-plugin-import": "^2.29.1",
55
- "eslint-plugin-node": "^11.1.0",
56
- "eslint-plugin-prettier": "^5.1.3",
57
- "lua-types": "^2.13.1",
58
- "prettier": "^3.2.5",
59
- "rimraf": "^5.0.5",
60
- "tsx": "^4.7.1",
61
- "typescript": "~5.4.2",
62
- "typescript-to-lua": "^1.25.0"
63
- },
64
- "factorioVersion": "2.0.25"
65
- }
1
+ {
2
+ "name": "typed-factorio",
3
+ "version": "3.10.0",
4
+ "description": "Featureful typescript definitions for the Factorio modding api.",
5
+ "keywords": [
6
+ "factorio",
7
+ "types",
8
+ "typescript-to-lua",
9
+ "tstl"
10
+ ],
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/GlassBricks/typed-factorio.git"
14
+ },
15
+ "homepage": "https://github.com/GlassBricks/typed-factorio#readme",
16
+ "license": "MIT",
17
+ "files": [
18
+ "**/*.d.ts",
19
+ "*.d.ts",
20
+ "!generator/**/*"
21
+ ],
22
+ "type": "module",
23
+ "packageManager": "npm@9.5.0",
24
+ "scripts": {
25
+ "generate": "tsx --tsconfig generator/tsconfig.json generator/main.ts",
26
+ "generate-no-format": "tsx --tsconfig generator/tsconfig.json generator/main.ts --no-format",
27
+ "clean": "rimraf runtime/generated prototype/generated",
28
+ "lint": "eslint .",
29
+ "format:check": "prettier --check .",
30
+ "format:fix": "prettier --write .",
31
+ "check": "npm run lint && npm run format:check && tsc --noEmit",
32
+ "prepublishOnly": "npm run generate && npm run check",
33
+ "script": "tsx --tsconfig scripts/tsconfig.json",
34
+ "download-latest-api-jsons": "npm run script ./scripts/download-latest.ts",
35
+ "new-version-changelog": "npm run script ./scripts/new-version-changelog.ts",
36
+ "get-current-factorio-version": "npm run script ./scripts/get-current-version.ts",
37
+ "next-factorio-version-diff": "npm run script ./scripts/new-version-diff.ts"
38
+ },
39
+ "peerDependencies": {
40
+ "lua-types": "^2.13.1",
41
+ "typescript-to-lua": "^1.10.0"
42
+ },
43
+ "devDependencies": {
44
+ "@swc/core": "^1.4.8",
45
+ "@types/download": "^8.0.5",
46
+ "@types/node": "^20.11.29",
47
+ "@typescript-eslint/eslint-plugin": "^7.3.0",
48
+ "@typescript-eslint/parser": "^7.3.0",
49
+ "download": "^8.0.0",
50
+ "eslint": "^8.57.0",
51
+ "eslint-config-prettier": "^9.1.0",
52
+ "eslint-import-resolver-typescript": "^3.6.1",
53
+ "eslint-plugin-eslint-comments": "^3.2.0",
54
+ "eslint-plugin-import": "^2.29.1",
55
+ "eslint-plugin-node": "^11.1.0",
56
+ "eslint-plugin-prettier": "^5.1.3",
57
+ "lua-types": "^2.13.1",
58
+ "prettier": "^3.2.5",
59
+ "rimraf": "^5.0.5",
60
+ "tsx": "^4.7.1",
61
+ "typescript": "~5.4.2",
62
+ "typescript-to-lua": "^1.25.0"
63
+ },
64
+ "factorioVersion": "2.0.28"
65
+ }