@matchomag/cs2-replay 0.0.0-stage → 0.3.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/FORMAT.md +350 -0
- package/README.md +453 -2
- package/bin/demo-replay-darwin-amd64 +0 -0
- package/bin/demo-replay-darwin-arm64 +0 -0
- package/bin/demo-replay-linux-amd64 +0 -0
- package/bin/demo-replay-linux-arm64 +0 -0
- package/bin/demo-replay-windows-amd64.exe +0 -0
- package/bin/demo-replay.js +22 -0
- package/dist/2d/index.js +1 -0
- package/dist/3d/index.js +11 -0
- package/dist/chunks/actors-EZRYEB4I.js +177 -0
- package/dist/chunks/chunk-5BFKVD63.js +1 -0
- package/dist/chunks/chunk-D5ST2XVO.js +106 -0
- package/dist/chunks/chunk-DQPOBPMK.js +1 -0
- package/dist/chunks/chunk-FBSLUYGT.js +1 -0
- package/dist/chunks/chunk-Q37CWKZX.js +12 -0
- package/dist/chunks/chunk-VSIECNZM.js +1 -0
- package/dist/chunks/chunk-YJG3LSSB.js +1 -0
- package/dist/chunks/chunk-YO73RW3Y.js +1 -0
- package/dist/chunks/look-2WBUGHMJ.js +669 -0
- package/dist/index.js +1 -0
- package/dist/maps/index.js +1 -0
- package/dist/parse/index.js +1 -0
- package/dist/parse/wasm/replay.wasm +0 -0
- package/dist/parse/worker.js +1 -0
- package/dist/types/2d/index.d.ts +17 -0
- package/dist/types/2d/radar.d.ts +35 -0
- package/dist/types/3d/actors.d.ts +90 -0
- package/dist/types/3d/characters/anim.d.ts +93 -0
- package/dist/types/3d/characters/ao.d.ts +3 -0
- package/dist/types/3d/characters/body.d.ts +37 -0
- package/dist/types/3d/characters/builder.d.ts +82 -0
- package/dist/types/3d/characters/index.d.ts +74 -0
- package/dist/types/3d/characters/rig.d.ts +73 -0
- package/dist/types/3d/characters/textures.d.ts +4 -0
- package/dist/types/3d/characters/viewmodel.d.ts +51 -0
- package/dist/types/3d/characters/weapons.d.ts +25 -0
- package/dist/types/3d/follow.d.ts +43 -0
- package/dist/types/3d/fx/batch.d.ts +87 -0
- package/dist/types/3d/fx/context.d.ts +34 -0
- package/dist/types/3d/fx/explosion.d.ts +14 -0
- package/dist/types/3d/fx/fire.d.ts +11 -0
- package/dist/types/3d/fx/index.d.ts +84 -0
- package/dist/types/3d/fx/lights.d.ts +25 -0
- package/dist/types/3d/fx/meshes.d.ts +18 -0
- package/dist/types/3d/fx/misc.d.ts +15 -0
- package/dist/types/3d/fx/random.d.ts +21 -0
- package/dist/types/3d/fx/smoke.d.ts +10 -0
- package/dist/types/3d/fx/textures.d.ts +29 -0
- package/dist/types/3d/fx/types.d.ts +117 -0
- package/dist/types/3d/greybox.d.ts +22 -0
- package/dist/types/3d/index.d.ts +127 -0
- package/dist/types/3d/look.d.ts +49 -0
- package/dist/types/3d/markers.d.ts +23 -0
- package/dist/types/3d/smoke/volume.d.ts +95 -0
- package/dist/types/3d/smoke/voxels.d.ts +87 -0
- package/dist/types/3d/world/index.d.ts +179 -0
- package/dist/types/3d/world/look.d.ts +16 -0
- package/dist/types/3d/world/material.d.ts +128 -0
- package/dist/types/3d/world/post.d.ts +75 -0
- package/dist/types/3d/world/probes.d.ts +39 -0
- package/dist/types/3d/world/release.d.ts +28 -0
- package/dist/types/3d/world/stage.d.ts +84 -0
- package/dist/types/core/format.d.ts +163 -0
- package/dist/types/core/live.d.ts +115 -0
- package/dist/types/core/model.d.ts +164 -0
- package/dist/types/core/playback.d.ts +82 -0
- package/dist/types/core/theme.d.ts +46 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/maps/index.d.ts +258 -0
- package/dist/types/parse/index.d.ts +108 -0
- package/dist/types/ui/shell.d.ts +131 -0
- package/dist/types/ui/styles.d.ts +1 -0
- package/package.json +68 -4
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import type { Replay, ReplayRound } from "../core/format";
|
|
2
|
+
import { LiveReplay } from "../core/live";
|
|
3
|
+
import { type ModelOptions, type ReplayModel, type Snapshot } from "../core/model";
|
|
4
|
+
import { type Theme, type ThemeInput } from "../core/theme";
|
|
5
|
+
/** Options shared by the 2D and 3D viewers. */
|
|
6
|
+
export interface ViewerOptions extends ModelOptions {
|
|
7
|
+
/** Colors and fonts; anything left out comes from --replay-* CSS properties or the defaults. */
|
|
8
|
+
theme?: ThemeInput;
|
|
9
|
+
/** Which panels to show; all are on by default. */
|
|
10
|
+
hud?: {
|
|
11
|
+
scoreboard?: boolean;
|
|
12
|
+
killFeed?: boolean;
|
|
13
|
+
roster?: boolean;
|
|
14
|
+
controls?: boolean;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Keyboard shortcuts: "focus" (default) only while the viewer has focus,
|
|
18
|
+
* "global" anywhere on the page outside form fields, false for none.
|
|
19
|
+
*/
|
|
20
|
+
keyboard?: "focus" | "global" | false;
|
|
21
|
+
/** Start at this round number (as in the game, from 1). Defaults to the first round. */
|
|
22
|
+
round?: number;
|
|
23
|
+
autoplay?: boolean;
|
|
24
|
+
/** Initial playback speed, 1 by default. */
|
|
25
|
+
speed?: number;
|
|
26
|
+
/** Speed steps for the speed menu and the -/= keys. */
|
|
27
|
+
speeds?: number[];
|
|
28
|
+
/**
|
|
29
|
+
* Draw at most this many frames per second; 0 for every display refresh. Default: 60 in
|
|
30
|
+
* the 3D game look (a 120 Hz screen would otherwise draw it twice as often), no limit
|
|
31
|
+
* otherwise. Either way nothing is drawn while nothing changes.
|
|
32
|
+
*/
|
|
33
|
+
maxFps?: number;
|
|
34
|
+
}
|
|
35
|
+
export interface ViewerEvents extends Record<string, unknown> {
|
|
36
|
+
/** The current round changed, while playing or seeking. */
|
|
37
|
+
round: {
|
|
38
|
+
index: number;
|
|
39
|
+
round: ReplayRound | null;
|
|
40
|
+
};
|
|
41
|
+
/** The whole frame changed (at most hz times per second of game time). */
|
|
42
|
+
frame: number;
|
|
43
|
+
play: void;
|
|
44
|
+
pause: void;
|
|
45
|
+
/** A player was picked in the roster. */
|
|
46
|
+
player: {
|
|
47
|
+
index: number;
|
|
48
|
+
};
|
|
49
|
+
/** Live replays: following the live edge started or stopped, or the broadcast ended. */
|
|
50
|
+
live: {
|
|
51
|
+
following: boolean;
|
|
52
|
+
ended: boolean;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/** A mounted viewer. */
|
|
56
|
+
export interface Viewer {
|
|
57
|
+
readonly element: HTMLElement;
|
|
58
|
+
readonly replay: Replay | null;
|
|
59
|
+
readonly model: ReplayModel | null;
|
|
60
|
+
readonly playing: boolean;
|
|
61
|
+
/** Current (fractional) frame. */
|
|
62
|
+
readonly frame: number;
|
|
63
|
+
readonly round: ReplayRound | null;
|
|
64
|
+
speed: number;
|
|
65
|
+
play(): void;
|
|
66
|
+
pause(): void;
|
|
67
|
+
toggle(): void;
|
|
68
|
+
seek(frame: number): void;
|
|
69
|
+
/** Jumps to a round by its number (from 1), a few seconds before freeze time ends. */
|
|
70
|
+
gotoRound(num: number): void;
|
|
71
|
+
/** The live replay this viewer follows (its `replay` came from openPlaycast()), else null. */
|
|
72
|
+
readonly live: LiveReplay | null;
|
|
73
|
+
/** Live replays: playing at the live edge. */
|
|
74
|
+
readonly following: boolean;
|
|
75
|
+
/** Live replays: jumps to the live edge and follows it (key L). */
|
|
76
|
+
goLive(): void;
|
|
77
|
+
/** Overrides theme values; call without arguments after the page's CSS changed in a way the viewer can't see. */
|
|
78
|
+
setTheme(theme?: ThemeInput): void;
|
|
79
|
+
on<K extends keyof ViewerEvents>(event: K, fn: (value: ViewerEvents[K]) => void): () => void;
|
|
80
|
+
destroy(): void;
|
|
81
|
+
}
|
|
82
|
+
export interface RenderContext {
|
|
83
|
+
snapshot: Snapshot | null;
|
|
84
|
+
theme: Theme;
|
|
85
|
+
/** Real seconds since the last render. */
|
|
86
|
+
dt: number;
|
|
87
|
+
}
|
|
88
|
+
/** What a renderer (2D radar, 3D world) gives the shell. */
|
|
89
|
+
export interface Renderer {
|
|
90
|
+
/** Appended to the stage, sized to fill it. */
|
|
91
|
+
readonly element: HTMLElement;
|
|
92
|
+
/** Render every animation frame, not only when something changed. */
|
|
93
|
+
readonly continuous?: boolean;
|
|
94
|
+
/** Frames per second at most, unless ViewerOptions.maxFps says otherwise (0: no limit). */
|
|
95
|
+
readonly maxFps?: number;
|
|
96
|
+
/** Seconds to keep rendering after the last change (e.g. while auto exposure settles). */
|
|
97
|
+
readonly settle?: number;
|
|
98
|
+
resize(width: number, height: number): void;
|
|
99
|
+
render(ctx: RenderContext): void;
|
|
100
|
+
/** Roster click. */
|
|
101
|
+
focusPlayer?(index: number, snapshot: Snapshot): void;
|
|
102
|
+
/** Gets keys before the viewer's shortcuts; return true when handled. */
|
|
103
|
+
handleKey?(e: KeyboardEvent): boolean;
|
|
104
|
+
/** A live replay grew: pick up new players, grenades, shots… (the model is already refreshed). */
|
|
105
|
+
replayChanged?(): void;
|
|
106
|
+
/**
|
|
107
|
+
* Goes at the top of the overlay roster panel. The panel stays for it when the roster is
|
|
108
|
+
* off, and on narrow views, where the roster is hidden.
|
|
109
|
+
*/
|
|
110
|
+
readonly rosterControls?: HTMLElement;
|
|
111
|
+
destroy(): void;
|
|
112
|
+
}
|
|
113
|
+
export interface ShellContext {
|
|
114
|
+
root: HTMLElement;
|
|
115
|
+
stage: HTMLElement;
|
|
116
|
+
model: ReplayModel | null;
|
|
117
|
+
/** Ask for a render on the next animation frame. */
|
|
118
|
+
invalidate(): void;
|
|
119
|
+
theme(): Theme;
|
|
120
|
+
/** Emits a viewer event (renderer-specific ones too). */
|
|
121
|
+
emit(event: string, value: unknown): void;
|
|
122
|
+
/** The state at the playhead, null without a replay. */
|
|
123
|
+
snapshot(): Snapshot | null;
|
|
124
|
+
}
|
|
125
|
+
export interface ShellSetup {
|
|
126
|
+
/** "sides" puts each team's roster beside the stage; "overlay" floats one roster panel over it. */
|
|
127
|
+
rosterLayout: "sides" | "overlay";
|
|
128
|
+
createRenderer(ctx: ShellContext): Renderer;
|
|
129
|
+
}
|
|
130
|
+
export declare const esc: (s: unknown) => string;
|
|
131
|
+
export declare function createShell(host: HTMLElement, replay: Replay | null, options: ViewerOptions, setup: ShellSetup): Viewer;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function injectStyles(doc?: Document): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,70 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@matchomag/cs2-replay",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "CS2 demo replay viewers: a 2D radar and a 3D grey-box view on one replay format, plus an in-browser demo parser.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "UNLICENSED",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public",
|
|
9
|
+
"registry": "https://registry.npmjs.org/"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"bin",
|
|
14
|
+
"FORMAT.md"
|
|
15
|
+
],
|
|
16
|
+
"bin": {
|
|
17
|
+
"demo-replay": "bin/demo-replay.js"
|
|
18
|
+
},
|
|
19
|
+
"sideEffects": [
|
|
20
|
+
"./dist/parse/worker.js"
|
|
21
|
+
],
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"types": "./dist/types/index.d.ts",
|
|
25
|
+
"default": "./dist/index.js"
|
|
26
|
+
},
|
|
27
|
+
"./2d": {
|
|
28
|
+
"types": "./dist/types/2d/index.d.ts",
|
|
29
|
+
"default": "./dist/2d/index.js"
|
|
30
|
+
},
|
|
31
|
+
"./3d": {
|
|
32
|
+
"types": "./dist/types/3d/index.d.ts",
|
|
33
|
+
"default": "./dist/3d/index.js"
|
|
34
|
+
},
|
|
35
|
+
"./maps": {
|
|
36
|
+
"types": "./dist/types/maps/index.d.ts",
|
|
37
|
+
"default": "./dist/maps/index.js"
|
|
38
|
+
},
|
|
39
|
+
"./parse": {
|
|
40
|
+
"types": "./dist/types/parse/index.d.ts",
|
|
41
|
+
"default": "./dist/parse/index.js"
|
|
42
|
+
},
|
|
43
|
+
"./package.json": "./package.json"
|
|
44
|
+
},
|
|
45
|
+
"scripts": {
|
|
46
|
+
"dev": "vite",
|
|
47
|
+
"build": "node scripts/build.mjs",
|
|
48
|
+
"build:wasm": "../../extractor/build.sh wasm src/parse/wasm",
|
|
49
|
+
"build:bin": "scripts/build-bin.sh",
|
|
50
|
+
"test": "vitest run",
|
|
51
|
+
"typecheck": "tsc --noEmit",
|
|
52
|
+
"prepublishOnly": "npm run build"
|
|
53
|
+
},
|
|
54
|
+
"peerDependencies": {
|
|
55
|
+
"three": ">=0.160.0"
|
|
56
|
+
},
|
|
57
|
+
"peerDependenciesMeta": {
|
|
58
|
+
"three": {
|
|
59
|
+
"optional": true
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
"devDependencies": {
|
|
63
|
+
"@types/three": "^0.186.0",
|
|
64
|
+
"esbuild": "^0.28.2",
|
|
65
|
+
"three": "^0.186.1",
|
|
66
|
+
"typescript": "^7.0.2",
|
|
67
|
+
"vite": "^8.3.8",
|
|
68
|
+
"vitest": "^5.1.0"
|
|
69
|
+
}
|
|
70
|
+
}
|