ball2d 0.1.1 → 0.2.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/LICENSE +42 -0
- package/README.md +184 -138
- package/dist/browser.js +1790 -1251
- package/dist/core.wasm +0 -0
- package/dist/node.js +104 -43358
- package/dist/stadiums/big.hbs +515 -85
- package/dist/stadiums/big_easy.hbs +515 -85
- package/dist/stadiums/big_hockey.hbs +612 -87
- package/dist/stadiums/big_rounded.hbs +611 -100
- package/dist/stadiums/classic.hbs +515 -85
- package/dist/stadiums/easy.hbs +515 -85
- package/dist/stadiums/hockey.hbs +612 -87
- package/dist/stadiums/huge.hbs +515 -85
- package/dist/stadiums/provenance.json +24 -22
- package/dist/stadiums/rounded.hbs +611 -100
- package/dist/stadiums/small.hbs +515 -85
- package/dist/types/announcement.d.ts +1 -0
- package/dist/types/browser.d.ts +10 -0
- package/dist/types/config.d.ts +9 -0
- package/dist/types/disc.d.ts +4 -0
- package/dist/types/{core/match-state.d.ts → match-state.d.ts} +2 -0
- package/dist/types/node.d.ts +15 -0
- package/dist/types/{core/host-types.d.ts → player.d.ts} +1 -1
- package/dist/types/{core/replay-types.d.ts → replay.d.ts} +3 -3
- package/dist/types/{sdk/types.d.ts → room.d.ts} +6 -4
- package/dist/types/stadium.d.ts +5 -0
- package/dist/types/team.d.ts +6 -0
- package/package.json +28 -6
- package/dist/types/client/announcement.d.ts +0 -10
- package/dist/types/client/connection-stats.d.ts +0 -11
- package/dist/types/client/headless.d.ts +0 -130
- package/dist/types/client/host-config.d.ts +0 -11
- package/dist/types/client/host-runtime.d.ts +0 -10
- package/dist/types/client/network-runtime.d.ts +0 -8
- package/dist/types/client/network.d.ts +0 -91
- package/dist/types/client/stadium-library.d.ts +0 -4
- package/dist/types/client/startup-scope.d.ts +0 -6
- package/dist/types/client/traffic.d.ts +0 -9
- package/dist/types/core/avatar.d.ts +0 -2
- package/dist/types/core/build-id.d.ts +0 -2
- package/dist/types/core/control.d.ts +0 -5
- package/dist/types/core/disc-properties.d.ts +0 -7
- package/dist/types/core/engine.d.ts +0 -68
- package/dist/types/core/protocol.d.ts +0 -24
- package/dist/types/core/replay-codec.d.ts +0 -6
- package/dist/types/core/replay-wire.d.ts +0 -5
- package/dist/types/core/replay.d.ts +0 -48
- package/dist/types/core/stadium.d.ts +0 -91
- package/dist/types/core/team-colors.d.ts +0 -8
- package/dist/types/sdk/browser.d.ts +0 -11
- package/dist/types/sdk/command-queue.d.ts +0 -11
- package/dist/types/sdk/config.d.ts +0 -6
- package/dist/types/sdk/node-transport.d.ts +0 -4
- package/dist/types/sdk/node.d.ts +0 -18
- package/dist/types/sdk/replay.d.ts +0 -4
- package/dist/types/sdk/room.d.ts +0 -7
- package/dist/types/sdk/stadium.d.ts +0 -9
- package/dist/types/shared/room-link.d.ts +0 -6
- /package/dist/types/{sdk/create-options.d.ts → creation.d.ts} +0 -0
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
export declare const FLAGS: Record<string, number>;
|
|
2
|
-
export type Vec = [number, number];
|
|
3
|
-
export interface Disc {
|
|
4
|
-
pos: Vec;
|
|
5
|
-
speed: Vec;
|
|
6
|
-
gravity: Vec;
|
|
7
|
-
radius: number;
|
|
8
|
-
invMass: number;
|
|
9
|
-
damping: number;
|
|
10
|
-
bCoef: number;
|
|
11
|
-
cGroup: number;
|
|
12
|
-
cMask: number;
|
|
13
|
-
color: string;
|
|
14
|
-
}
|
|
15
|
-
export interface Segment {
|
|
16
|
-
a: Vec;
|
|
17
|
-
b: Vec;
|
|
18
|
-
bCoef: number;
|
|
19
|
-
cGroup: number;
|
|
20
|
-
cMask: number;
|
|
21
|
-
bias: number;
|
|
22
|
-
color: string;
|
|
23
|
-
vis: boolean;
|
|
24
|
-
renderOnly?: boolean;
|
|
25
|
-
}
|
|
26
|
-
export interface Arc extends Segment {
|
|
27
|
-
center: Vec;
|
|
28
|
-
radius: number;
|
|
29
|
-
start: number;
|
|
30
|
-
sweep: number;
|
|
31
|
-
major: boolean;
|
|
32
|
-
}
|
|
33
|
-
export interface Stadium {
|
|
34
|
-
version: 1;
|
|
35
|
-
physicsMode: 'hbs' | 'substeps';
|
|
36
|
-
name: string;
|
|
37
|
-
canBeStored: boolean;
|
|
38
|
-
width: number;
|
|
39
|
-
height: number;
|
|
40
|
-
maxViewWidth: number;
|
|
41
|
-
cameraFollow: 'ball' | 'player';
|
|
42
|
-
bg: {
|
|
43
|
-
type: 'grass' | 'hockey' | 'none';
|
|
44
|
-
width: number;
|
|
45
|
-
height: number;
|
|
46
|
-
color: string;
|
|
47
|
-
kickOffRadius: number;
|
|
48
|
-
cornerRadius: number;
|
|
49
|
-
goalLine: number;
|
|
50
|
-
};
|
|
51
|
-
discs: Disc[];
|
|
52
|
-
segments: Segment[];
|
|
53
|
-
arcs: Arc[];
|
|
54
|
-
colliders: (Segment | Arc)[];
|
|
55
|
-
planes: {
|
|
56
|
-
normal: Vec;
|
|
57
|
-
dist: number;
|
|
58
|
-
bCoef: number;
|
|
59
|
-
cGroup: number;
|
|
60
|
-
cMask: number;
|
|
61
|
-
}[];
|
|
62
|
-
goals: {
|
|
63
|
-
p0: Vec;
|
|
64
|
-
p1: Vec;
|
|
65
|
-
team: 1 | 2;
|
|
66
|
-
}[];
|
|
67
|
-
joints: {
|
|
68
|
-
d0: number;
|
|
69
|
-
d1: number;
|
|
70
|
-
min: number;
|
|
71
|
-
max: number;
|
|
72
|
-
strength: number | 'rigid';
|
|
73
|
-
color: string;
|
|
74
|
-
}[];
|
|
75
|
-
redSpawnPoints: Vec[];
|
|
76
|
-
blueSpawnPoints: Vec[];
|
|
77
|
-
player: Disc & {
|
|
78
|
-
acceleration: number;
|
|
79
|
-
kickingAcceleration: number;
|
|
80
|
-
kickingDamping: number;
|
|
81
|
-
kickStrength: number;
|
|
82
|
-
kickback: number;
|
|
83
|
-
};
|
|
84
|
-
spawnDistance: number;
|
|
85
|
-
kickOffReset: 'full' | 'partial';
|
|
86
|
-
warnings: string[];
|
|
87
|
-
}
|
|
88
|
-
/** Conservative per-tick work bound, including all possible player slots and static discs. */
|
|
89
|
-
export declare function assertCollisionBudget(mode: Stadium['physicsMode'], discs: number, segments: number, constraints: number, radius: number): void;
|
|
90
|
-
export declare function parseStadium(text: string): Stadium;
|
|
91
|
-
export declare function arenaSource(name?: string, width?: number, height?: number): string;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export interface TeamColors {
|
|
2
|
-
angle: number;
|
|
3
|
-
textColor: number;
|
|
4
|
-
colors: number[];
|
|
5
|
-
}
|
|
6
|
-
export declare function teamColors(angle: number, textColor: number, colors: number[]): TeamColors;
|
|
7
|
-
export type TeamStyles = [TeamColors | null, TeamColors | null];
|
|
8
|
-
export declare function readTeamStyles(value: unknown): TeamStyles;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { CreateRoomOptions } from './create-options.js';
|
|
2
|
-
export type { CreateRoomOptions } from './create-options.js';
|
|
3
|
-
import { type RoomConfig } from './config.js';
|
|
4
|
-
import type { Room } from './types.js';
|
|
5
|
-
/** Browser host SDK. Requires the matching Ball2D assets and API on this origin. */
|
|
6
|
-
export declare function createRoom(config?: RoomConfig, options?: CreateRoomOptions): Promise<Room>;
|
|
7
|
-
export { readReplay, type Replay } from './replay.js';
|
|
8
|
-
export type { HostPlayer, HostScores, HostDiscProperties } from '../core/host-types.js';
|
|
9
|
-
export type { Room } from './types.js';
|
|
10
|
-
export type { RoomConfig } from './config.js';
|
|
11
|
-
export { validateStadium, type StadiumValidation } from './stadium.js';
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export declare class CommandQueue {
|
|
2
|
-
private readonly onError;
|
|
3
|
-
private pending;
|
|
4
|
-
private active?;
|
|
5
|
-
private scheduled;
|
|
6
|
-
private closed;
|
|
7
|
-
constructor(onError?: (error: unknown) => void);
|
|
8
|
-
enqueue<T>(run: () => T | Promise<T>): Promise<T>;
|
|
9
|
-
private drain;
|
|
10
|
-
close(): void;
|
|
11
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { type HostConfig } from '../client/host-config.js';
|
|
2
|
-
export interface RoomConfig extends Omit<HostConfig, 'roomName'> {
|
|
3
|
-
roomName?: string;
|
|
4
|
-
}
|
|
5
|
-
/** SDK defaults follow the reference room contract; legacy page defaults are separate. */
|
|
6
|
-
export declare function roomConfig(input: unknown): HostConfig;
|
package/dist/types/sdk/node.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { CreateRoomOptions } from './create-options.js';
|
|
2
|
-
export type { CreateRoomOptions } from './create-options.js';
|
|
3
|
-
import { type RoomConfig } from './config.js';
|
|
4
|
-
import type { Room } from './types.js';
|
|
5
|
-
export interface NodeRoomConfig extends RoomConfig {
|
|
6
|
-
/** Ball2D signaling service. Defaults to https://ball2d.com. */
|
|
7
|
-
serviceOrigin?: string;
|
|
8
|
-
/** Optional account-owned SDK key. Keep it in an environment variable, never browser code. */
|
|
9
|
-
apiKey?: string;
|
|
10
|
-
}
|
|
11
|
-
export type NodeRoom = Room & {
|
|
12
|
-
readonly closed: Promise<void>;
|
|
13
|
-
};
|
|
14
|
-
/** Native Node host. close() begins shutdown; closed settles after peer cleanup. */
|
|
15
|
-
export declare function createRoom(config?: NodeRoomConfig, creation?: CreateRoomOptions): Promise<NodeRoom>;
|
|
16
|
-
export { readReplay, type Replay } from './replay.js';
|
|
17
|
-
export { validateStadium, type StadiumValidation } from './stadium.js';
|
|
18
|
-
export type { HostPlayer, HostScores, HostDiscProperties } from '../core/host-types.js';
|
package/dist/types/sdk/room.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { HeadlessRoom } from '../client/headless.js';
|
|
2
|
-
import type { Room } from './types.js';
|
|
3
|
-
export type { Room } from './types.js';
|
|
4
|
-
export declare function roomFacade(host: HeadlessRoom): Room;
|
|
5
|
-
export declare function roomFacade(host: HeadlessRoom, closed: Promise<void>): Room & {
|
|
6
|
-
readonly closed: Promise<void>;
|
|
7
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export interface StadiumValidation {
|
|
2
|
-
readonly name: string;
|
|
3
|
-
readonly canBeStored: boolean;
|
|
4
|
-
readonly warnings: readonly string[];
|
|
5
|
-
}
|
|
6
|
-
/** Validates Ball2D's supported HBS contract without allocating a host or WASM engine.
|
|
7
|
-
* Throws on malformed or unsupported input. Warnings describe ignored field names.
|
|
8
|
-
*/
|
|
9
|
-
export declare function validateStadium(source: string): StadiumValidation;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/** Room codes are public addresses, never host credentials. */
|
|
2
|
-
export declare function normalizeRoomId(value: string): string | null;
|
|
3
|
-
export declare function invitePath(id: string): string;
|
|
4
|
-
export declare function roomFromPath(path: string): string | null;
|
|
5
|
-
export declare function parseRoomLink(input: string): string | null;
|
|
6
|
-
export declare function createRoomCode(): string;
|
|
File without changes
|