@sandustry-modding/types 0.1.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/CHANGELOG.md +19 -0
- package/README.md +66 -0
- package/global.d.ts +38 -0
- package/package.json +44 -0
- package/sandkit/api/action.d.ts +28 -0
- package/sandkit/api/assets.d.ts +30 -0
- package/sandkit/api/authorization.d.ts +54 -0
- package/sandkit/api/building.d.ts +92 -0
- package/sandkit/api/camera.d.ts +23 -0
- package/sandkit/api/collector.d.ts +36 -0
- package/sandkit/api/constants.d.ts +21 -0
- package/sandkit/api/cooldown.d.ts +26 -0
- package/sandkit/api/discoveries.d.ts +18 -0
- package/sandkit/api/effects.d.ts +76 -0
- package/sandkit/api/elements.d.ts +237 -0
- package/sandkit/api/energy.d.ts +70 -0
- package/sandkit/api/events.d.ts +53 -0
- package/sandkit/api/excavation.d.ts +34 -0
- package/sandkit/api/fire.d.ts +26 -0
- package/sandkit/api/gameconfig.d.ts +15 -0
- package/sandkit/api/grid.d.ts +26 -0
- package/sandkit/api/hooks.d.ts +52 -0
- package/sandkit/api/i18n.d.ts +101 -0
- package/sandkit/api/index.d.ts +66 -0
- package/sandkit/api/input.d.ts +119 -0
- package/sandkit/api/items.d.ts +60 -0
- package/sandkit/api/lights.d.ts +66 -0
- package/sandkit/api/maps.d.ts +33 -0
- package/sandkit/api/mods.d.ts +18 -0
- package/sandkit/api/patterns.d.ts +32 -0
- package/sandkit/api/player.d.ts +84 -0
- package/sandkit/api/processing.d.ts +66 -0
- package/sandkit/api/progression.d.ts +22 -0
- package/sandkit/api/projectiles.d.ts +80 -0
- package/sandkit/api/random.d.ts +21 -0
- package/sandkit/api/raycast.d.ts +19 -0
- package/sandkit/api/reactions.d.ts +30 -0
- package/sandkit/api/rendering.d.ts +26 -0
- package/sandkit/api/resources.d.ts +23 -0
- package/sandkit/api/sandkit-api.d.ts +117 -0
- package/sandkit/api/scene.d.ts +15 -0
- package/sandkit/api/schedule.d.ts +14 -0
- package/sandkit/api/settings.d.ts +29 -0
- package/sandkit/api/shared.d.ts +27 -0
- package/sandkit/api/signals.d.ts +25 -0
- package/sandkit/api/sound.d.ts +91 -0
- package/sandkit/api/sprites.d.ts +45 -0
- package/sandkit/api/storage.d.ts +55 -0
- package/sandkit/api/structureBehaviors.d.ts +22 -0
- package/sandkit/api/structures.d.ts +320 -0
- package/sandkit/api/tech.d.ts +66 -0
- package/sandkit/api/terrains.d.ts +125 -0
- package/sandkit/api/time.d.ts +13 -0
- package/sandkit/api/tools.d.ts +35 -0
- package/sandkit/api/triggers.d.ts +24 -0
- package/sandkit/api/ui.d.ts +175 -0
- package/sandkit/api/upgrades.d.ts +63 -0
- package/sandkit/api/utils.d.ts +35 -0
- package/sandkit/api/workers.d.ts +14 -0
- package/sandkit/api/world.d.ts +107 -0
- package/sandkit/engine/api/augments.d.ts +96 -0
- package/sandkit/engine/api/auralite.d.ts +21 -0
- package/sandkit/engine/api/blueprints.d.ts +47 -0
- package/sandkit/engine/api/clipboard.d.ts +46 -0
- package/sandkit/engine/api/colorPicker.d.ts +74 -0
- package/sandkit/engine/api/coloringTool.d.ts +56 -0
- package/sandkit/engine/api/conveyors.d.ts +16 -0
- package/sandkit/engine/api/debug.d.ts +16 -0
- package/sandkit/engine/api/drones.d.ts +21 -0
- package/sandkit/engine/api/entities.d.ts +66 -0
- package/sandkit/engine/api/extensions.d.ts +16 -0
- package/sandkit/engine/api/factory.d.ts +56 -0
- package/sandkit/engine/api/foliage.d.ts +31 -0
- package/sandkit/engine/api/foundationColorPicker.d.ts +16 -0
- package/sandkit/engine/api/game.d.ts +26 -0
- package/sandkit/engine/api/heatTransfer.d.ts +46 -0
- package/sandkit/engine/api/index.d.ts +47 -0
- package/sandkit/engine/api/launchers.d.ts +16 -0
- package/sandkit/engine/api/lightColorPicker.d.ts +16 -0
- package/sandkit/engine/api/matters.d.ts +26 -0
- package/sandkit/engine/api/misc.d.ts +16 -0
- package/sandkit/engine/api/portals.d.ts +16 -0
- package/sandkit/engine/api/prefabData.d.ts +36 -0
- package/sandkit/engine/api/prefabDecor.d.ts +21 -0
- package/sandkit/engine/api/prefabulator.d.ts +21 -0
- package/sandkit/engine/api/prismaline.d.ts +26 -0
- package/sandkit/engine/api/prismite.d.ts +26 -0
- package/sandkit/engine/api/queue.d.ts +41 -0
- package/sandkit/engine/api/shadows.d.ts +26 -0
- package/sandkit/engine/api/strataform.d.ts +36 -0
- package/sandkit/engine/api/swarmConsole.d.ts +71 -0
- package/sandkit/engine/api/sweeperDrone.d.ts +16 -0
- package/sandkit/engine/api/teleportZones.d.ts +46 -0
- package/sandkit/engine/api/tutorialBuild.d.ts +66 -0
- package/sandkit/engine/api/usageTracker.d.ts +26 -0
- package/sandkit/engine/api/wall.d.ts +31 -0
- package/sandkit/engine/api/workerLocal.d.ts +30 -0
- package/sandkit/engine/index.d.ts +135 -0
- package/sandkit/engine/retro-console.d.ts +52 -0
- package/sandkit/engine/state.d.ts +31 -0
- package/sandkit/enums/index.d.ts +444 -0
- package/sandkit/index.d.ts +47 -0
- package/sandkit/react.d.ts +49 -0
- package/shared/api/effects.d.ts +76 -0
- package/shared/api/elements.d.ts +162 -0
- package/shared/api/maps.d.ts +30 -0
- package/shared/api/player.d.ts +31 -0
- package/shared/api/shared.d.ts +46 -0
- package/shared/api/structures.d.ts +138 -0
- package/shared/api/terrains.d.ts +100 -0
- package/shared/api/ui.d.ts +54 -0
- package/shared/api/world.d.ts +71 -0
- package/shared/asset.d.ts +14 -0
- package/shared/engine.d.ts +17 -0
- package/shared/index.d.ts +25 -0
- package/shared/jsonvalue.d.ts +30 -0
- package/shared/nominal.d.ts +31 -0
- package/shared/player.d.ts +173 -0
- package/worker/api/elements.d.ts +60 -0
- package/worker/api/main.d.ts +16 -0
- package/worker/api/shared.d.ts +38 -0
- package/worker/api/worker.d.ts +20 -0
- package/worker/index.d.ts +29 -0
- package/worker/sandkit-api.d.ts +31 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ui as uiNs } from "./api/ui";
|
|
2
|
+
import { player as playerNs } from "./api/player";
|
|
3
|
+
import { world as worldNs } from "./api/world";
|
|
4
|
+
import { terrains as terrainsNs } from "./api/terrains";
|
|
5
|
+
import { structures as structuresNs } from "./api/structures";
|
|
6
|
+
import { elements as elementsNs } from "./api/elements";
|
|
7
|
+
import { maps as mapsNs } from "./api/maps";
|
|
8
|
+
import { effects as effectsNs } from "./api/effects";
|
|
9
|
+
import { shared as sharedBuffersNs } from "./api/shared";
|
|
10
|
+
|
|
11
|
+
/** Shared main/worker API namespaces grouped under `shared.api`. */
|
|
12
|
+
export namespace shared {
|
|
13
|
+
export namespace api {
|
|
14
|
+
export import ui = uiNs;
|
|
15
|
+
export import player = playerNs;
|
|
16
|
+
export import world = worldNs;
|
|
17
|
+
export import terrains = terrainsNs;
|
|
18
|
+
export import structures = structuresNs;
|
|
19
|
+
export import elements = elementsNs;
|
|
20
|
+
export import maps = mapsNs;
|
|
21
|
+
export import effects = effectsNs;
|
|
22
|
+
/** Cross-thread shared memory buffers. */
|
|
23
|
+
export import shared = sharedBuffersNs;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON-serializable value shapes for mod payloads and storage.
|
|
3
|
+
*
|
|
4
|
+
* Used by APIs such as `sandkit.api.gameConfig` and mod storage helpers when
|
|
5
|
+
* values must round-trip through JSON.
|
|
6
|
+
*
|
|
7
|
+
* @internal Base types reused by API declarations. Not a runtime namespace.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* JSON object with string keys and {@link JsonValueV1} values.
|
|
12
|
+
*
|
|
13
|
+
* Use for open-ended config bags and serialized mod data.
|
|
14
|
+
*/
|
|
15
|
+
export interface JsonObjectV1 {
|
|
16
|
+
[key: string]: JsonValueV1
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* JSON value: primitive, object, array, or null.
|
|
21
|
+
*
|
|
22
|
+
* Does not include `undefined` — omit keys instead.
|
|
23
|
+
*/
|
|
24
|
+
export type JsonValueV1 =
|
|
25
|
+
| string
|
|
26
|
+
| number
|
|
27
|
+
| boolean
|
|
28
|
+
| JsonObjectV1
|
|
29
|
+
| JsonValueV1[]
|
|
30
|
+
| null;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Nominal helpers for Sandkit types.
|
|
3
|
+
*
|
|
4
|
+
* `LooseString` / `LooseNumber` keep autocomplete for known literals while
|
|
5
|
+
* still accepting any string or number (the `string & {}` / `number & {}` trick).
|
|
6
|
+
*
|
|
7
|
+
* `TaggedNumber` marks handles so an element type is not a cell id.
|
|
8
|
+
*
|
|
9
|
+
* @internal Not a runtime `sandkit` namespace.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Known string literals plus any other string.
|
|
14
|
+
* `T | string` collapses to `string` and drops autocomplete.
|
|
15
|
+
*/
|
|
16
|
+
export type LooseString<T extends string> = T | (string & {});
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Known numeric literals plus any other number.
|
|
20
|
+
* `T | number` collapses to `number` and drops autocomplete.
|
|
21
|
+
*/
|
|
22
|
+
export type LooseNumber<T extends number> = T | (number & {});
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Number handle that does not mix with a different tag.
|
|
26
|
+
* Plain `number` is not assignable; numeric literals and enum members are.
|
|
27
|
+
*/
|
|
28
|
+
export type TaggedNumber<Tag extends string> = number & { readonly __tag?: Tag };
|
|
29
|
+
|
|
30
|
+
/** Packed simulation cell id from `world.getCellIdAtCell`. */
|
|
31
|
+
export type CellId = TaggedNumber<"cellId">;
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared player and coordinate domain shapes.
|
|
3
|
+
*
|
|
4
|
+
* @internal Base types reused by main and worker API declarations. Not a
|
|
5
|
+
* runtime `sandkit` namespace.
|
|
6
|
+
*/
|
|
7
|
+
import { AssetRef } from "./asset";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Grid cell position as `[cellX, cellY]`.
|
|
11
|
+
*
|
|
12
|
+
* Cell coordinates match `sandkit.api.*AtCell` helpers: column first, then row.
|
|
13
|
+
*/
|
|
14
|
+
export type CellCoordinates = [cellX: number, cellY: number]
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* 2D vector in world or cell space.
|
|
18
|
+
*
|
|
19
|
+
* World positions use pixels. Cell helpers may return pixel or cell units
|
|
20
|
+
* depending on the API.
|
|
21
|
+
*/
|
|
22
|
+
export type Vector2 = {
|
|
23
|
+
/** Horizontal component. */
|
|
24
|
+
x: number;
|
|
25
|
+
/** Vertical component. */
|
|
26
|
+
y: number;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Live player state snapshot (read-only shape for mods).
|
|
31
|
+
*
|
|
32
|
+
* Reflects `sandkit.engine.state` / store player fields exposed to mods.
|
|
33
|
+
*/
|
|
34
|
+
export interface Player {
|
|
35
|
+
/** Player hitbox left edge in world pixels. */
|
|
36
|
+
x: number;
|
|
37
|
+
/** Player hitbox top edge in world pixels. */
|
|
38
|
+
y: number;
|
|
39
|
+
/** Player hitbox width in world pixels. */
|
|
40
|
+
width: number;
|
|
41
|
+
/** Player hitbox height in world pixels. */
|
|
42
|
+
height: number;
|
|
43
|
+
/** Current movement velocity in pixels per second. */
|
|
44
|
+
velocity: Vector2
|
|
45
|
+
/** Movement threshold accumulator used by physics. */
|
|
46
|
+
threshold: Vector2;
|
|
47
|
+
/**
|
|
48
|
+
* Spawn flag. Live physics does not update this field.
|
|
49
|
+
* Use `sandkit.api.player.isOnGround()` (solid cells 1px below the hitbox).
|
|
50
|
+
*/
|
|
51
|
+
onGround: boolean;
|
|
52
|
+
/** Temporary speed-cap bonuses applied on each axis. */
|
|
53
|
+
speedCapOverdrive: {
|
|
54
|
+
x: {
|
|
55
|
+
dir: null;
|
|
56
|
+
active: boolean;
|
|
57
|
+
bonus: number;
|
|
58
|
+
releaseTime: number;
|
|
59
|
+
releaseBonus: number;
|
|
60
|
+
};
|
|
61
|
+
y: {
|
|
62
|
+
dir: null;
|
|
63
|
+
active: boolean;
|
|
64
|
+
bonus: number;
|
|
65
|
+
releaseTime: number;
|
|
66
|
+
releaseBonus: number;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
/** Items currently held in the player inventory. */
|
|
70
|
+
inventory: InventoryItem[];
|
|
71
|
+
/** Structure type ids the player has unlocked for building. */
|
|
72
|
+
buildings: number[];
|
|
73
|
+
/** Tech tree nodes and their unlock metadata. */
|
|
74
|
+
tech: {
|
|
75
|
+
[key: string | number]: {
|
|
76
|
+
x: number,
|
|
77
|
+
y: number,
|
|
78
|
+
descriptionKey: string;
|
|
79
|
+
descriptionParams?: {
|
|
80
|
+
[key: string]: number;
|
|
81
|
+
};
|
|
82
|
+
cost: number;
|
|
83
|
+
branch: string;
|
|
84
|
+
nameKey?: string;
|
|
85
|
+
icon?: {
|
|
86
|
+
spriteName: string;
|
|
87
|
+
};
|
|
88
|
+
unlocks: {
|
|
89
|
+
structures?: string[];
|
|
90
|
+
items?: string[];
|
|
91
|
+
map?: boolean;
|
|
92
|
+
};
|
|
93
|
+
currencyType?: string;
|
|
94
|
+
isElectricity?: boolean;
|
|
95
|
+
electricityNodeStyle?: boolean;
|
|
96
|
+
requires?: (string | number)[];
|
|
97
|
+
isAlien?: boolean;
|
|
98
|
+
radiusUnlockPx?: number;
|
|
99
|
+
locked?: boolean;
|
|
100
|
+
threshold?: number;
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
/** Tech ids explicitly locked for this save. */
|
|
104
|
+
lockedTechs: { [key: string]: boolean },
|
|
105
|
+
/** Active world action, or null when idle. */
|
|
106
|
+
action: null;
|
|
107
|
+
/** Hotbar slots, active indices, and item sprites. */
|
|
108
|
+
hotbar: {
|
|
109
|
+
activeSlotIndex: number;
|
|
110
|
+
hotbarIndex: number;
|
|
111
|
+
bars: AssetRef[][];
|
|
112
|
+
};
|
|
113
|
+
/** True when the grappling hook is equipped or active. */
|
|
114
|
+
grapplingHook: boolean;
|
|
115
|
+
/** Cooldown timestamps for movement particles and slowdown. */
|
|
116
|
+
cooldowns: {
|
|
117
|
+
boostParticle: {
|
|
118
|
+
time: number;
|
|
119
|
+
last: number;
|
|
120
|
+
};
|
|
121
|
+
hoverParticle: {
|
|
122
|
+
time: number;
|
|
123
|
+
last: number;
|
|
124
|
+
};
|
|
125
|
+
slowdown: {
|
|
126
|
+
last: number;
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
/** True when hover movement mode is active. */
|
|
130
|
+
isHovering: boolean;
|
|
131
|
+
/** Per-weapon runtime metadata. */
|
|
132
|
+
weaponsMeta: {
|
|
133
|
+
rocketLauncher: {
|
|
134
|
+
ammo: {
|
|
135
|
+
current: number;
|
|
136
|
+
reload: {
|
|
137
|
+
last: number;
|
|
138
|
+
};
|
|
139
|
+
reloading: boolean;
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** One hotbar or inventory item entry. */
|
|
146
|
+
export interface InventoryItem {
|
|
147
|
+
id: number,
|
|
148
|
+
itemType: number,
|
|
149
|
+
abilities: {
|
|
150
|
+
type: number,
|
|
151
|
+
levelRequirement?: number,
|
|
152
|
+
attributes: {
|
|
153
|
+
[key: string]: {
|
|
154
|
+
opts?: {
|
|
155
|
+
speed?: number,
|
|
156
|
+
angle?: number
|
|
157
|
+
},
|
|
158
|
+
type: number,
|
|
159
|
+
attributes?: {
|
|
160
|
+
blastRadius?: number
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
cooldown: {
|
|
165
|
+
time: number,
|
|
166
|
+
last: number
|
|
167
|
+
}
|
|
168
|
+
}[],
|
|
169
|
+
nameKey: string,
|
|
170
|
+
descriptionKey: string,
|
|
171
|
+
categoryKey: "excavation" | "utility" | "drones",
|
|
172
|
+
sprite?: AssetRef,
|
|
173
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { CellCoordinates } from "../../shared/player";
|
|
2
|
+
import { shared } from "../../shared";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Worker-thread `sandkit.api.elements` — shared reads plus direct mutations.
|
|
6
|
+
*
|
|
7
|
+
* Main thread uses `*WhenIdle` helpers instead of `createAtCell` /
|
|
8
|
+
* `replaceAtCell` / `removeAtCell`. Built on {@link elements} base shapes.
|
|
9
|
+
*
|
|
10
|
+
* @internal Worker extension; not interchangeable with main-thread
|
|
11
|
+
* `sandkit.api.elements`.
|
|
12
|
+
*/
|
|
13
|
+
export namespace elements {
|
|
14
|
+
/** Numeric id for a registered element type. */
|
|
15
|
+
export import ElementType = shared.api.elements.ElementType;
|
|
16
|
+
/** Mod or built-in element string id. */
|
|
17
|
+
export import ElementId = shared.api.elements.ElementId;
|
|
18
|
+
/** Type handle or string id accepted by lookup helpers. */
|
|
19
|
+
export import ElementRef = shared.api.elements.ElementRef;
|
|
20
|
+
/** Matter category for element physics behavior. */
|
|
21
|
+
export import MatterType = shared.api.elements.MatterType;
|
|
22
|
+
/** Full definition used to register a custom element. */
|
|
23
|
+
export import ElementDefinition = shared.api.elements.ElementDefinition;
|
|
24
|
+
/** Options for {@link createAtCell}. */
|
|
25
|
+
export import ElementCreateOptions = shared.api.elements.ElementCreateOptions;
|
|
26
|
+
/** Resolves a string element id to its numeric type. */
|
|
27
|
+
export import getTypeFromId = shared.api.elements.getTypeFromId;
|
|
28
|
+
/** Returns the definition for an element type. */
|
|
29
|
+
export import getDefinitionByType = shared.api.elements.getDefinitionByType;
|
|
30
|
+
/** Returns the element type at a cell, or null. */
|
|
31
|
+
export import getTypeAtCell = shared.api.elements.getTypeAtCell;
|
|
32
|
+
/** Returns the resolved element type at a cell, or null. */
|
|
33
|
+
export import getResolvedTypeAtCell = shared.api.elements.getResolvedTypeAtCell;
|
|
34
|
+
/** Returns the resolved element type from a cell id, or null. */
|
|
35
|
+
export import getResolvedTypeFromCellId = shared.api.elements.getResolvedTypeFromCellId;
|
|
36
|
+
/** Returns element info at a cell, or null. */
|
|
37
|
+
export import getInfoAtCell = shared.api.elements.getInfoAtCell;
|
|
38
|
+
/** Returns the matter type at a cell, or null. */
|
|
39
|
+
export import getMatterTypeAtCell = shared.api.elements.getMatterTypeAtCell;
|
|
40
|
+
/** Returns true when the cell contains the given element type. */
|
|
41
|
+
export import isTypeAtCell = shared.api.elements.isTypeAtCell;
|
|
42
|
+
/** Returns true when the element at the cell is free-falling. */
|
|
43
|
+
export import isFreeFallingAtCell = shared.api.elements.isFreeFallingAtCell;
|
|
44
|
+
/** Returns particle velocity at a cell, or null. */
|
|
45
|
+
export import getVelocityAtCell = shared.api.elements.getVelocityAtCell;
|
|
46
|
+
/** Returns a data field value at a cell, or null. */
|
|
47
|
+
export import getDataFieldAtCell = shared.api.elements.getDataFieldAtCell;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Create an element at a cell immediately on this worker.
|
|
51
|
+
* Main thread: use `createAtCellWhenIdle`.
|
|
52
|
+
* @param cellX - Grid column of the target cell.
|
|
53
|
+
* @param cellY - Grid row of the target cell.
|
|
54
|
+
* @param elementType - Element type to place.
|
|
55
|
+
* @param options - Optional spawn overrides.
|
|
56
|
+
*/
|
|
57
|
+
export function createAtCell(
|
|
58
|
+
...args: [...CellCoordinates, elementType: ElementType, options?: ElementCreateOptions]
|
|
59
|
+
): void;
|
|
60
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Worker thread only.
|
|
3
|
+
*
|
|
4
|
+
* `sandkit.api.main` — send events to the main thread.
|
|
5
|
+
*
|
|
6
|
+
* @internal Base shape reused by {@link WorkerSandkitApi}. Main thread has a
|
|
7
|
+
* larger `sandkit.api` surface; do not assume parity.
|
|
8
|
+
*/
|
|
9
|
+
export namespace main {
|
|
10
|
+
/**
|
|
11
|
+
* Emit a custom event on the main thread.
|
|
12
|
+
* @param eventId - Registered event name.
|
|
13
|
+
* @param payload - Serializable payload passed to main-thread listeners.
|
|
14
|
+
*/
|
|
15
|
+
export function emitEvent<Payload = any>(eventId: string, payload: Payload): void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// Aliased: this module declares its own `shared` namespace below.
|
|
2
|
+
import { shared as sharedApi } from "../../shared";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Worker thread only.
|
|
6
|
+
*
|
|
7
|
+
* `sandkit.api.shared` — shared memory buffers for workers.
|
|
8
|
+
*
|
|
9
|
+
* Workers **require** buffers created on the main thread. Main thread only
|
|
10
|
+
* **gets** existing buffers. See {@link shared} for the shared base declarations.
|
|
11
|
+
*
|
|
12
|
+
* @internal Worker extension of {@link shared}; not interchangeable with
|
|
13
|
+
* main-thread `sandkit.api.shared`.
|
|
14
|
+
*/
|
|
15
|
+
export namespace shared {
|
|
16
|
+
/** Named shared memory buffers for worker threads. */
|
|
17
|
+
export namespace buffers {
|
|
18
|
+
/**
|
|
19
|
+
* Attach to a named shared buffer on this worker.
|
|
20
|
+
*
|
|
21
|
+
* The buffer must already exist on the main thread with the same
|
|
22
|
+
* {@link SharedArrayType} and length as `config`.
|
|
23
|
+
*
|
|
24
|
+
* @param key - Buffer name shared across threads.
|
|
25
|
+
* @param config - Expected array type and length for validation.
|
|
26
|
+
*/
|
|
27
|
+
export function require(key: string, config: { type: SharedArrayType; length: number; }): SharedArray;
|
|
28
|
+
/**
|
|
29
|
+
* Read an existing buffer without validating type or length.
|
|
30
|
+
* @param key - Buffer name shared across threads.
|
|
31
|
+
*/
|
|
32
|
+
export import get = sharedApi.api.shared.buffers.get
|
|
33
|
+
}
|
|
34
|
+
/** Typed array backing store for a shared buffer. */
|
|
35
|
+
export import SharedArray = sharedApi.api.shared.SharedArray
|
|
36
|
+
/** Discriminator for the underlying typed array kind. */
|
|
37
|
+
export import SharedArrayType = sharedApi.api.shared.SharedArrayType
|
|
38
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Worker thread only.
|
|
3
|
+
*
|
|
4
|
+
* `sandkit.api.worker` — identity of the current simulation worker.
|
|
5
|
+
*
|
|
6
|
+
* @internal Base shape reused by {@link WorkerSandkitApi}. Not the same as
|
|
7
|
+
* main-thread APIs.
|
|
8
|
+
*/
|
|
9
|
+
export namespace worker {
|
|
10
|
+
/**
|
|
11
|
+
* Return the zero-based index of this worker in the worker pool.
|
|
12
|
+
* @returns Worker index (`0` … `getCount() - 1`).
|
|
13
|
+
*/
|
|
14
|
+
export function getIndex(): number;
|
|
15
|
+
/**
|
|
16
|
+
* Return the total number of simulation workers.
|
|
17
|
+
* @returns Worker count for the active simulation.
|
|
18
|
+
*/
|
|
19
|
+
export function getCount(): number;
|
|
20
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Worker-thread `sandkit.api` namespaces.
|
|
3
|
+
*
|
|
4
|
+
* Prefer these declarations in `worker.js`. Type `sandkit.api` as
|
|
5
|
+
* {@link WorkerSandkitApi}. Do not assume main-thread methods exist here.
|
|
6
|
+
* See {@link sandkit.api} for the main-thread public API.
|
|
7
|
+
*
|
|
8
|
+
* @module worker
|
|
9
|
+
*/
|
|
10
|
+
export * from "./api/main"
|
|
11
|
+
export * from "./api/shared"
|
|
12
|
+
export * from "./api/worker"
|
|
13
|
+
export * from "./api/elements"
|
|
14
|
+
|
|
15
|
+
// Shared files
|
|
16
|
+
export * from "../sandkit/api/collector"
|
|
17
|
+
export * from "../sandkit/api/fire"
|
|
18
|
+
export * from "../sandkit/api/hooks"
|
|
19
|
+
export * from "../shared/api/maps"
|
|
20
|
+
export * from "../sandkit/api/patterns"
|
|
21
|
+
export * from "../shared/api/player"
|
|
22
|
+
export * from "../sandkit/api/random"
|
|
23
|
+
export * from "../shared/api/structures"
|
|
24
|
+
export * from "../shared/api/terrains"
|
|
25
|
+
export * from "../shared/api/ui"
|
|
26
|
+
export * from "../sandkit/api/utils"
|
|
27
|
+
export * from "../shared/api/world"
|
|
28
|
+
|
|
29
|
+
export type { WorkerSandkitApi } from "./sandkit-api"
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Composed worker-thread `sandkit.api` object.
|
|
3
|
+
*
|
|
4
|
+
* Namespace members are documented under {@link worker}. Use this type in
|
|
5
|
+
* `worker.js` / `worker.ts`:
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* const api = sandkit.api as unknown as WorkerSandkitApi;
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* Main and worker surfaces overlap but are not interchangeable. Do not use
|
|
12
|
+
* {@link sandkit.SandkitApi} on worker threads.
|
|
13
|
+
*/
|
|
14
|
+
export type WorkerSandkitApi = {
|
|
15
|
+
collector: typeof import("../sandkit/api/collector").collector;
|
|
16
|
+
elements: typeof import("./api/elements").elements;
|
|
17
|
+
fire: typeof import("../sandkit/api/fire").fire;
|
|
18
|
+
hooks: typeof import("../sandkit/api/hooks").hooks;
|
|
19
|
+
main: typeof import("./api/main").main;
|
|
20
|
+
maps: typeof import("../shared/api/maps").maps;
|
|
21
|
+
patterns: typeof import("../sandkit/api/patterns").patterns;
|
|
22
|
+
player: typeof import("../shared/api/player").player;
|
|
23
|
+
random: typeof import("../sandkit/api/random").random;
|
|
24
|
+
shared: typeof import("./api/shared").shared;
|
|
25
|
+
structures: typeof import("../shared/api/structures").structures;
|
|
26
|
+
terrains: typeof import("../shared/api/terrains").terrains;
|
|
27
|
+
ui: typeof import("../shared/api/ui").ui;
|
|
28
|
+
utils: typeof import("../sandkit/api/utils").utils;
|
|
29
|
+
worker: typeof import("./api/worker").worker;
|
|
30
|
+
world: typeof import("../shared/api/world").world;
|
|
31
|
+
};
|