@shipload/sdk 1.0.0-next.6 → 1.0.0-next.61

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.
Files changed (156) hide show
  1. package/lib/scan.d.ts +52 -0
  2. package/lib/scan.js +162 -0
  3. package/lib/scan.js.map +1 -0
  4. package/lib/scan.m.js +152 -0
  5. package/lib/scan.m.js.map +1 -0
  6. package/lib/shipload.d.ts +3601 -1364
  7. package/lib/shipload.js +15671 -5261
  8. package/lib/shipload.js.map +1 -1
  9. package/lib/shipload.m.js +15392 -5209
  10. package/lib/shipload.m.js.map +1 -1
  11. package/lib/testing.d.ts +1173 -0
  12. package/lib/testing.js +4971 -0
  13. package/lib/testing.js.map +1 -0
  14. package/lib/testing.m.js +4965 -0
  15. package/lib/testing.m.js.map +1 -0
  16. package/package.json +20 -2
  17. package/src/capabilities/craftable.test.ts +82 -0
  18. package/src/capabilities/craftable.ts +82 -0
  19. package/src/capabilities/crafting.test.ts +35 -0
  20. package/src/capabilities/crafting.ts +34 -7
  21. package/src/capabilities/gathering.test.ts +29 -0
  22. package/src/capabilities/gathering.ts +37 -19
  23. package/src/capabilities/hauling.ts +0 -5
  24. package/src/capabilities/index.ts +0 -1
  25. package/src/capabilities/modules.ts +27 -30
  26. package/src/capabilities/movement.ts +1 -1
  27. package/src/capabilities/storage.ts +16 -1
  28. package/src/contracts/platform.ts +231 -3
  29. package/src/contracts/server.ts +1518 -501
  30. package/src/coordinates/address.ts +88 -0
  31. package/src/coordinates/constants.test.ts +15 -0
  32. package/src/coordinates/constants.ts +23 -0
  33. package/src/coordinates/index.ts +15 -0
  34. package/src/coordinates/memo.test.ts +47 -0
  35. package/src/coordinates/memo.ts +20 -0
  36. package/src/coordinates/permutation.ts +77 -0
  37. package/src/coordinates/regions.ts +48 -0
  38. package/src/coordinates/sectors.ts +115 -0
  39. package/src/data/capabilities.ts +49 -18
  40. package/src/data/capability-formulas.ts +26 -14
  41. package/src/data/catalog.ts +7 -8
  42. package/src/data/colors.ts +14 -48
  43. package/src/data/entities.json +380 -15
  44. package/src/data/item-ids.ts +51 -13
  45. package/src/data/items.json +318 -77
  46. package/src/data/kind-registry.json +195 -0
  47. package/src/data/kind-registry.ts +182 -0
  48. package/src/data/metadata.ts +291 -51
  49. package/src/data/recipes-runtime.ts +6 -23
  50. package/src/data/recipes.json +2260 -173
  51. package/src/data/tiers.ts +9 -6
  52. package/src/derivation/build-methods.test.ts +13 -0
  53. package/src/derivation/build-methods.ts +48 -0
  54. package/src/derivation/capabilities.test.ts +348 -0
  55. package/src/derivation/capabilities.ts +693 -0
  56. package/src/derivation/capability-mappings.ts +60 -16
  57. package/src/derivation/crafting.test.ts +17 -0
  58. package/src/derivation/crafting.ts +57 -34
  59. package/src/derivation/index.ts +27 -2
  60. package/src/derivation/recipe-usage.test.ts +90 -0
  61. package/src/derivation/recipe-usage.ts +141 -0
  62. package/src/derivation/reserve-regen.ts +34 -0
  63. package/src/derivation/resources.ts +9 -1
  64. package/src/derivation/rollups.test.ts +55 -0
  65. package/src/derivation/rollups.ts +72 -0
  66. package/src/derivation/stars.test.ts +67 -0
  67. package/src/derivation/stars.ts +25 -0
  68. package/src/derivation/stat-scaling.ts +12 -0
  69. package/src/derivation/stats.ts +6 -6
  70. package/src/derivation/stratum.ts +26 -22
  71. package/src/derivation/tiers.ts +40 -7
  72. package/src/derivation/upgrades.ts +14 -0
  73. package/src/derivation/wormhole.ts +154 -0
  74. package/src/entities/entity.ts +102 -0
  75. package/src/entities/gamestate.ts +3 -28
  76. package/src/entities/makers.ts +141 -135
  77. package/src/entities/slot-multiplier.ts +43 -0
  78. package/src/errors.ts +12 -16
  79. package/src/format.ts +26 -4
  80. package/src/index-module.ts +333 -35
  81. package/src/managers/actions.ts +668 -103
  82. package/src/managers/base.ts +6 -2
  83. package/src/managers/cluster.test.ts +39 -0
  84. package/src/managers/cluster.ts +53 -0
  85. package/src/managers/construction-types.ts +80 -0
  86. package/src/managers/construction.ts +443 -0
  87. package/src/managers/context.ts +29 -1
  88. package/src/managers/coordinates.ts +14 -0
  89. package/src/managers/entities.ts +27 -66
  90. package/src/managers/epochs.ts +40 -0
  91. package/src/managers/index.ts +20 -1
  92. package/src/managers/locations.ts +25 -29
  93. package/src/managers/nft.test.ts +14 -0
  94. package/src/managers/nft.ts +70 -0
  95. package/src/managers/players.ts +25 -0
  96. package/src/managers/plot.ts +122 -0
  97. package/src/nft/atomicassets.abi.json +1342 -0
  98. package/src/nft/atomicassets.ts +237 -0
  99. package/src/nft/atomicdata.ts +130 -0
  100. package/src/nft/buildImmutableData.ts +388 -0
  101. package/src/nft/description.ts +215 -99
  102. package/src/nft/index.ts +3 -0
  103. package/src/planner/index.ts +242 -0
  104. package/src/planner/planner.test.ts +334 -0
  105. package/src/resolution/describe-module.ts +43 -25
  106. package/src/resolution/display-name.ts +38 -10
  107. package/src/resolution/resolve-item.test.ts +48 -0
  108. package/src/resolution/resolve-item.ts +112 -58
  109. package/src/scan/index.ts +244 -0
  110. package/src/scan/scan-wasm.base64.ts +2 -0
  111. package/src/scheduling/accessor.ts +65 -23
  112. package/src/scheduling/availability.test.ts +204 -0
  113. package/src/scheduling/availability.ts +211 -0
  114. package/src/scheduling/cancel.test.ts +542 -0
  115. package/src/scheduling/cancel.ts +254 -0
  116. package/src/scheduling/cluster-stock.test.ts +31 -0
  117. package/src/scheduling/cluster-stock.ts +15 -0
  118. package/src/scheduling/energy.ts +47 -0
  119. package/src/scheduling/idle-resolve.ts +45 -0
  120. package/src/scheduling/jobs.ts +71 -0
  121. package/src/scheduling/lane-core.ts +128 -0
  122. package/src/scheduling/lanes.test.ts +250 -0
  123. package/src/scheduling/lanes.ts +227 -0
  124. package/src/scheduling/projection.ts +257 -133
  125. package/src/scheduling/schedule.test.ts +119 -0
  126. package/src/scheduling/schedule.ts +257 -117
  127. package/src/scheduling/task-cargo.test.ts +44 -0
  128. package/src/scheduling/task-cargo.ts +46 -0
  129. package/src/scheduling/unwrap.test.ts +86 -0
  130. package/src/scheduling/unwrap.ts +190 -0
  131. package/src/shipload.ts +26 -1
  132. package/src/subscriptions/manager.cluster.test.ts +51 -0
  133. package/src/subscriptions/manager.ts +245 -172
  134. package/src/subscriptions/mappers.ts +5 -8
  135. package/src/subscriptions/types.ts +28 -3
  136. package/src/testing/catalog-hash.ts +19 -0
  137. package/src/testing/index.ts +2 -0
  138. package/src/testing/projection-parity.ts +167 -0
  139. package/src/travel/reach.ts +21 -0
  140. package/src/travel/route-planner.ts +288 -0
  141. package/src/travel/route-simulator.ts +170 -0
  142. package/src/travel/travel.ts +188 -122
  143. package/src/types/capabilities.ts +37 -8
  144. package/src/types/entity.ts +3 -3
  145. package/src/types/index.ts +0 -1
  146. package/src/types.ts +51 -16
  147. package/src/utils/cargo.test.ts +14 -0
  148. package/src/utils/cargo.ts +29 -0
  149. package/src/utils/display-name.ts +70 -0
  150. package/src/utils/system.ts +15 -16
  151. package/src/capabilities/loading.ts +0 -8
  152. package/src/entities/container.ts +0 -123
  153. package/src/entities/ship-deploy.ts +0 -295
  154. package/src/entities/ship.ts +0 -221
  155. package/src/entities/warehouse.ts +0 -127
  156. package/src/types/entity-traits.ts +0 -69
@@ -0,0 +1,195 @@
1
+ {
2
+ "kinds": [
3
+ {
4
+ "kind": "ship",
5
+ "classification": "OrbitalVessel",
6
+ "capabilityFlags": 19,
7
+ "zCoord": 800,
8
+ "defaultLabel": "Ship"
9
+ },
10
+ {
11
+ "kind": "warehouse",
12
+ "classification": "OrbitalStructure",
13
+ "capabilityFlags": 20,
14
+ "zCoord": 0,
15
+ "defaultLabel": "Warehouse"
16
+ },
17
+ {
18
+ "kind": "extractor",
19
+ "classification": "OrbitalStructure",
20
+ "capabilityFlags": 20,
21
+ "zCoord": 0,
22
+ "defaultLabel": "Mining Rig"
23
+ },
24
+ {
25
+ "kind": "factory",
26
+ "classification": "OrbitalStructure",
27
+ "capabilityFlags": 20,
28
+ "zCoord": 0,
29
+ "defaultLabel": "Factory"
30
+ },
31
+ {
32
+ "kind": "mdriver",
33
+ "classification": "OrbitalStructure",
34
+ "capabilityFlags": 20,
35
+ "zCoord": 0,
36
+ "defaultLabel": "Mass Driver"
37
+ },
38
+ {
39
+ "kind": "mcatcher",
40
+ "classification": "OrbitalStructure",
41
+ "capabilityFlags": 28,
42
+ "zCoord": 0,
43
+ "defaultLabel": "Mass Catcher"
44
+ },
45
+ {
46
+ "kind": "container",
47
+ "classification": "OrbitalVessel",
48
+ "capabilityFlags": 3,
49
+ "zCoord": 300,
50
+ "defaultLabel": "Container"
51
+ },
52
+ {
53
+ "kind": "nexus",
54
+ "classification": "OrbitalVessel",
55
+ "capabilityFlags": 0,
56
+ "zCoord": 800,
57
+ "defaultLabel": "Nexus"
58
+ },
59
+ {
60
+ "kind": "plot",
61
+ "classification": "Plot",
62
+ "capabilityFlags": 0,
63
+ "zCoord": 0,
64
+ "defaultLabel": "Plot"
65
+ },
66
+ {
67
+ "kind": "hub",
68
+ "classification": "OrbitalStructure",
69
+ "capabilityFlags": 4,
70
+ "zCoord": 0,
71
+ "defaultLabel": "Station Hub"
72
+ },
73
+ {
74
+ "kind": "workshop",
75
+ "classification": "OrbitalStructure",
76
+ "capabilityFlags": 20,
77
+ "zCoord": 0,
78
+ "defaultLabel": "Workshop"
79
+ },
80
+ {
81
+ "kind": "builddock",
82
+ "classification": "OrbitalStructure",
83
+ "capabilityFlags": 20,
84
+ "zCoord": 0,
85
+ "defaultLabel": "Construction Dock"
86
+ }
87
+ ],
88
+ "templates": [
89
+ {
90
+ "itemId": 10201,
91
+ "kind": "ship",
92
+ "displayLabel": "Ship"
93
+ },
94
+ {
95
+ "itemId": 10210,
96
+ "kind": "ship",
97
+ "displayLabel": "Roustabout"
98
+ },
99
+ {
100
+ "itemId": 10211,
101
+ "kind": "ship",
102
+ "displayLabel": "Prospector"
103
+ },
104
+ {
105
+ "itemId": 10212,
106
+ "kind": "ship",
107
+ "displayLabel": "Tender"
108
+ },
109
+ {
110
+ "itemId": 10213,
111
+ "kind": "ship",
112
+ "displayLabel": "Wright"
113
+ },
114
+ {
115
+ "itemId": 10214,
116
+ "kind": "ship",
117
+ "displayLabel": "Tug"
118
+ },
119
+ {
120
+ "itemId": 10215,
121
+ "kind": "ship",
122
+ "displayLabel": "Porter"
123
+ },
124
+ {
125
+ "itemId": 10218,
126
+ "kind": "ship",
127
+ "displayLabel": "Smith"
128
+ },
129
+ {
130
+ "itemId": 10202,
131
+ "kind": "warehouse",
132
+ "displayLabel": ""
133
+ },
134
+ {
135
+ "itemId": 10203,
136
+ "kind": "extractor",
137
+ "displayLabel": ""
138
+ },
139
+ {
140
+ "itemId": 10204,
141
+ "kind": "factory",
142
+ "displayLabel": ""
143
+ },
144
+ {
145
+ "itemId": 10205,
146
+ "kind": "mdriver",
147
+ "displayLabel": ""
148
+ },
149
+ {
150
+ "itemId": 10206,
151
+ "kind": "mcatcher",
152
+ "displayLabel": ""
153
+ },
154
+ {
155
+ "itemId": 10200,
156
+ "kind": "container",
157
+ "displayLabel": ""
158
+ },
159
+ {
160
+ "itemId": 11200,
161
+ "kind": "container",
162
+ "displayLabel": ""
163
+ },
164
+ {
165
+ "itemId": 10207,
166
+ "kind": "hub",
167
+ "displayLabel": ""
168
+ },
169
+ {
170
+ "itemId": 10208,
171
+ "kind": "workshop",
172
+ "displayLabel": ""
173
+ },
174
+ {
175
+ "itemId": 10209,
176
+ "kind": "builddock",
177
+ "displayLabel": ""
178
+ },
179
+ {
180
+ "itemId": 11212,
181
+ "kind": "ship",
182
+ "displayLabel": "Prospector"
183
+ },
184
+ {
185
+ "itemId": 11213,
186
+ "kind": "ship",
187
+ "displayLabel": "Prospector"
188
+ },
189
+ {
190
+ "itemId": 11214,
191
+ "kind": "ship",
192
+ "displayLabel": "Dredger"
193
+ }
194
+ ]
195
+ }
@@ -0,0 +1,182 @@
1
+ import {Name, type NameType} from '@wharfkit/antelope'
2
+ import kindRegistryJson from './kind-registry.json'
3
+
4
+ export const CAP_WRAP = 0x01
5
+ export const CAP_UNDEPLOY = 0x02
6
+ export const CAP_DEMOLISH = 0x04
7
+ export const CAP_CATCH = 0x08
8
+ export const CAP_MODULES = 0x10
9
+
10
+ export enum EntityClass {
11
+ OrbitalVessel = 0,
12
+ PlanetaryStructure = 1,
13
+ Plot = 2,
14
+ OrbitalStructure = 3,
15
+ }
16
+
17
+ const CLASSIFICATION_BY_NAME: Record<string, EntityClass> = {
18
+ OrbitalVessel: EntityClass.OrbitalVessel,
19
+ PlanetaryStructure: EntityClass.PlanetaryStructure,
20
+ Plot: EntityClass.Plot,
21
+ OrbitalStructure: EntityClass.OrbitalStructure,
22
+ }
23
+
24
+ export type EntityTypeName =
25
+ | 'ship'
26
+ | 'warehouse'
27
+ | 'extractor'
28
+ | 'factory'
29
+ | 'builddock'
30
+ | 'workshop'
31
+ | 'container'
32
+ | 'nexus'
33
+ | 'plot'
34
+ | 'mdriver'
35
+ | 'mcatcher'
36
+ | 'hub'
37
+
38
+ export interface KindMeta {
39
+ kind: Name
40
+ classification: EntityClass
41
+ capabilityFlags: number
42
+ zCoord: number
43
+ defaultLabel: string
44
+ }
45
+
46
+ export interface TemplateMeta {
47
+ itemId: number
48
+ kind: Name
49
+ displayLabel: string
50
+ }
51
+
52
+ interface RawKindEntry {
53
+ kind: string
54
+ classification: string
55
+ capabilityFlags: number
56
+ zCoord: number
57
+ defaultLabel: string
58
+ }
59
+
60
+ interface RawTemplateEntry {
61
+ itemId: number
62
+ kind: string
63
+ displayLabel: string
64
+ }
65
+
66
+ const KIND_META: Map<string, KindMeta> = (() => {
67
+ const m = new Map<string, KindMeta>()
68
+ for (const r of kindRegistryJson.kinds as RawKindEntry[]) {
69
+ const cls = CLASSIFICATION_BY_NAME[r.classification]
70
+ if (cls === undefined) {
71
+ throw new Error(
72
+ `kind-registry: unknown classification "${r.classification}" for kind ${r.kind}`
73
+ )
74
+ }
75
+ m.set(r.kind, {
76
+ kind: Name.from(r.kind),
77
+ classification: cls,
78
+ capabilityFlags: r.capabilityFlags,
79
+ zCoord: r.zCoord,
80
+ defaultLabel: r.defaultLabel,
81
+ })
82
+ }
83
+ return m
84
+ })()
85
+
86
+ export const ALL_ENTITY_TYPES: readonly EntityTypeName[] = Object.freeze([
87
+ ...KIND_META.keys(),
88
+ ] as EntityTypeName[])
89
+
90
+ const TEMPLATE_BY_ITEM_ID: Map<number, TemplateMeta> = (() => {
91
+ const m = new Map<number, TemplateMeta>()
92
+ for (const r of kindRegistryJson.templates as RawTemplateEntry[]) {
93
+ m.set(r.itemId, {
94
+ itemId: r.itemId,
95
+ kind: Name.from(r.kind),
96
+ displayLabel: r.displayLabel,
97
+ })
98
+ }
99
+ return m
100
+ })()
101
+
102
+ function nameKey(kind: NameType | EntityTypeName): string {
103
+ if (typeof kind === 'string') return kind
104
+ return Name.from(kind).toString()
105
+ }
106
+
107
+ export function getKindMeta(kind: NameType | EntityTypeName): KindMeta | undefined {
108
+ return KIND_META.get(nameKey(kind))
109
+ }
110
+
111
+ export function getTemplateMeta(itemId: number): TemplateMeta | undefined {
112
+ return TEMPLATE_BY_ITEM_ID.get(itemId)
113
+ }
114
+
115
+ export function getPackedEntityType(itemId: number): Name | null {
116
+ return TEMPLATE_BY_ITEM_ID.get(itemId)?.kind ?? null
117
+ }
118
+
119
+ export function kindCan(kind: NameType | EntityTypeName, cap: number): boolean {
120
+ const m = KIND_META.get(nameKey(kind))
121
+ return m !== undefined && (m.capabilityFlags & cap) !== 0
122
+ }
123
+
124
+ export function canCatch(kind: NameType | EntityTypeName): boolean {
125
+ return kindCan(kind, CAP_CATCH)
126
+ }
127
+
128
+ export function getEntityClass(kind: NameType | EntityTypeName): EntityClass {
129
+ const m = KIND_META.get(nameKey(kind))
130
+ if (!m) throw new Error(`Entity type has no class: ${nameKey(kind)}`)
131
+ return m.classification
132
+ }
133
+
134
+ export const ENTITY_SHIP = Name.from('ship')
135
+ export const ENTITY_WAREHOUSE = Name.from('warehouse')
136
+ export const ENTITY_EXTRACTOR = Name.from('extractor')
137
+ export const ENTITY_FACTORY = Name.from('factory')
138
+ export const ENTITY_CONSTRUCTION_DOCK = Name.from('builddock')
139
+ export const ENTITY_WORKSHOP = Name.from('workshop')
140
+ export const ENTITY_CONTAINER = Name.from('container')
141
+ export const ENTITY_NEXUS = Name.from('nexus')
142
+ export const ENTITY_PLOT = Name.from('plot')
143
+ export const ENTITY_MASS_DRIVER = Name.from('mdriver')
144
+ export const ENTITY_MASS_CATCHER = Name.from('mcatcher')
145
+ export const ENTITY_HUB = Name.from('hub')
146
+
147
+ export function isShip(entity: {type?: Name}): boolean {
148
+ return entity.type?.equals(ENTITY_SHIP) ?? false
149
+ }
150
+ export function isWarehouse(entity: {type?: Name}): boolean {
151
+ return entity.type?.equals(ENTITY_WAREHOUSE) ?? false
152
+ }
153
+ export function isExtractor(entity: {type?: Name}): boolean {
154
+ return entity.type?.equals(ENTITY_EXTRACTOR) ?? false
155
+ }
156
+ export function isFactory(entity: {type?: Name}): boolean {
157
+ return entity.type?.equals(ENTITY_FACTORY) ?? false
158
+ }
159
+ export function isConstructionDock(entity: {type?: Name}): boolean {
160
+ return entity.type?.equals(ENTITY_CONSTRUCTION_DOCK) ?? false
161
+ }
162
+ export function isWorkshop(entity: {type?: Name}): boolean {
163
+ return entity.type?.equals(ENTITY_WORKSHOP) ?? false
164
+ }
165
+ export function isContainer(entity: {type?: Name}): boolean {
166
+ return entity.type?.equals(ENTITY_CONTAINER) ?? false
167
+ }
168
+ export function isNexus(entity: {type?: Name}): boolean {
169
+ return entity.type?.equals(ENTITY_NEXUS) ?? false
170
+ }
171
+ export function isPlot(entity: {type?: Name}): boolean {
172
+ return entity.type?.equals(ENTITY_PLOT) ?? false
173
+ }
174
+ export function isMassDriver(entity: {type?: Name}): boolean {
175
+ return entity.type?.equals(ENTITY_MASS_DRIVER) ?? false
176
+ }
177
+ export function isMassCatcher(entity: {type?: Name}): boolean {
178
+ return entity.type?.equals(ENTITY_MASS_CATCHER) ?? false
179
+ }
180
+ export function isHub(entity: {type?: Name}): boolean {
181
+ return entity.type?.equals(ENTITY_HUB) ?? false
182
+ }