# cipherxof/w3ts architecture

> Architecture diagram of the GitHub repository cipherxof/w3ts, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/cipherxof/w3ts
- Repository: https://github.com/cipherxof/w3ts

## Overview

w3ts is a TypeScript API for Warcraft III custom maps. Map authors use its handle wrappers to operate on players, units, world objects, UI, and gameplay events; timer, sync, and host-detection utilities support runtime coordination. The map preserves the documented breadth of the handle API and the sampled sync/host workflow. Source evidence is uneven: unsampled subsystems are represented by exact directories, and only supported relationships are connected.

Main entry points: [`index.ts`](https://github.com/cipherxof/w3ts/blob/master/index.ts) (w3ts API), [`system/sync.ts`](https://github.com/cipherxof/w3ts/blob/master/system/sync.ts) (Player sync), [`handles/player.ts`](https://github.com/cipherxof/w3ts/blob/master/handles/player.ts) (Players), [`handles/unit.ts`](https://github.com/cipherxof/w3ts/blob/master/handles/unit.ts) (Units and orders)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_handles["Game handles"]
  node_player["Players<br/>[player.ts]"]
  node_units["Units and orders<br/>[unit.ts]"]
  node_world["World objects"]
  node_ui["UI and scoreboards"]
  node_handle_base["Handle identity<br/>[handle.ts]"]
end

subgraph group_events["Events and hooks"]
  node_triggers["Triggers<br/>[trigger.ts]"]
  node_script_hooks["Script hooks<br/>[index.ts]"]
end

subgraph group_runtime["Runtime coordination"]
  node_timer["Timers<br/>[timer.ts]"]
  node_sync["Player sync<br/>[sync.ts]"]
  node_host["Host detection<br/>[host.ts]"]
  node_game_time["Elapsed time<br/>[gametime.ts]"]
end

subgraph group_utilities["Data utilities"]
  node_encoding["Base64 codec<br/>[base64.ts]"]
  node_binary_reader["Binary reader<br/>[binaryreader.ts]"]
  node_binary_writer["Binary writer<br/>[binarywriter.ts]"]
  node_file["File access<br/>[file.ts]"]
  node_colors["Color helpers<br/>[color.ts]"]
end

node_map_author(("Map author"))
node_api["w3ts API<br/>[index.ts]"]
node_warcraft["Warcraft III runtime"]

node_map_author -->|"uses"| node_api
node_api -->|"exports"| node_player
node_api -->|"exports"| node_units
node_api -->|"exports"| node_world
node_api -->|"exports"| node_ui
node_api -->|"exports"| node_triggers
node_api -->|"exports"| node_sync
node_api -->|"exports"| node_file
node_player -->|"extends"| node_handle_base
node_units -->|"extends"| node_handle_base
node_world -.->|"wraps handles"| node_handle_base
node_triggers -->|"extends"| node_handle_base
node_units -->|"uses owners"| node_player
node_units -->|"uses objects"| node_world
node_triggers -->|"registers events"| node_player
node_triggers -->|"registers events"| node_units
node_host -->|"requests sync"| node_sync
node_host -->|"selects host"| node_player
node_host -->|"schedules check"| node_timer
node_host -->|"registers hook"| node_script_hooks
node_sync -->|"encodes packets"| node_encoding
node_sync -->|"reads packets"| node_binary_reader
node_sync -->|"writes packets"| node_binary_writer
node_sync -->|"sends as player"| node_player
node_sync -->|"starts timeout"| node_timer
node_sync -->|"measures elapsed"| node_game_time
node_script_hooks -->|"wraps entry points"| node_warcraft
node_player -.->|"calls game API"| node_warcraft
node_units -.->|"calls game API"| node_warcraft

click node_api "https://github.com/cipherxof/w3ts/blob/master/index.ts"
click node_player "https://github.com/cipherxof/w3ts/blob/master/handles/player.ts"
click node_units "https://github.com/cipherxof/w3ts/blob/master/handles/unit.ts"
click node_world "https://github.com/cipherxof/w3ts/tree/master/handles"
click node_ui "https://github.com/cipherxof/w3ts/tree/master/handles"
click node_handle_base "https://github.com/cipherxof/w3ts/blob/master/handles/handle.ts"
click node_triggers "https://github.com/cipherxof/w3ts/blob/master/handles/trigger.ts"
click node_script_hooks "https://github.com/cipherxof/w3ts/blob/master/hooks/index.ts"
click node_timer "https://github.com/cipherxof/w3ts/blob/master/handles/timer.ts"
click node_sync "https://github.com/cipherxof/w3ts/blob/master/system/sync.ts"
click node_host "https://github.com/cipherxof/w3ts/blob/master/system/host.ts"
click node_game_time "https://github.com/cipherxof/w3ts/blob/master/system/gametime.ts"
click node_encoding "https://github.com/cipherxof/w3ts/blob/master/system/base64.ts"
click node_binary_reader "https://github.com/cipherxof/w3ts/blob/master/system/binaryreader.ts"
click node_binary_writer "https://github.com/cipherxof/w3ts/blob/master/system/binarywriter.ts"
click node_file "https://github.com/cipherxof/w3ts/blob/master/system/file.ts"
click node_colors "https://github.com/cipherxof/w3ts/blob/master/utils/color.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_player,node_units,node_world,node_ui,node_handle_base toneBlue
class node_triggers,node_script_hooks toneAmber
class node_timer,node_sync,node_host,node_game_time,node_api toneMint
class node_encoding,node_binary_reader,node_binary_writer,node_file,node_colors toneRose
class node_map_author,node_warcraft toneIndigo
```

## Components

### Game handles

- [Players](https://github.com/cipherxof/w3ts/blob/master/handles/player.ts): `handles/player.ts`
- [Units and orders](https://github.com/cipherxof/w3ts/blob/master/handles/unit.ts): `handles/unit.ts`
- [World objects](https://github.com/cipherxof/w3ts/tree/master/handles): `handles`
- [UI and scoreboards](https://github.com/cipherxof/w3ts/tree/master/handles): `handles`
- [Handle identity](https://github.com/cipherxof/w3ts/blob/master/handles/handle.ts): `handles/handle.ts`

### Events and hooks

- [Triggers](https://github.com/cipherxof/w3ts/blob/master/handles/trigger.ts): `handles/trigger.ts`
- [Script hooks](https://github.com/cipherxof/w3ts/blob/master/hooks/index.ts): `hooks/index.ts`

### Runtime coordination

- [Timers](https://github.com/cipherxof/w3ts/blob/master/handles/timer.ts): `handles/timer.ts`
- [Player sync](https://github.com/cipherxof/w3ts/blob/master/system/sync.ts): `system/sync.ts`
- [Host detection](https://github.com/cipherxof/w3ts/blob/master/system/host.ts): `system/host.ts`
- [Elapsed time](https://github.com/cipherxof/w3ts/blob/master/system/gametime.ts): `system/gametime.ts`

### Data utilities

- [Base64 codec](https://github.com/cipherxof/w3ts/blob/master/system/base64.ts): `system/base64.ts`
- [Binary reader](https://github.com/cipherxof/w3ts/blob/master/system/binaryreader.ts): `system/binaryreader.ts`
- [Binary writer](https://github.com/cipherxof/w3ts/blob/master/system/binarywriter.ts): `system/binarywriter.ts`
- [File access](https://github.com/cipherxof/w3ts/blob/master/system/file.ts): `system/file.ts`
- [Color helpers](https://github.com/cipherxof/w3ts/blob/master/utils/color.ts): `utils/color.ts`

### Other components

- **Map author**
- [w3ts API](https://github.com/cipherxof/w3ts/blob/master/index.ts): `index.ts`
- **Warcraft III runtime**

## Connections

- Map author → w3ts API: uses (evidence: `README.md`)
- w3ts API → Players: exports (evidence: `index.ts`)
- w3ts API → Units and orders: exports (evidence: `index.ts`)
- w3ts API → World objects: exports (evidence: `index.ts`)
- w3ts API → UI and scoreboards: exports (evidence: `index.ts`)
- w3ts API → Triggers: exports (evidence: `index.ts`)
- w3ts API → Player sync: exports (evidence: `index.ts`)
- w3ts API → File access: exports (evidence: `index.ts`)
- Players → Handle identity: extends (evidence: `handles/player.ts`)
- Units and orders → Handle identity: extends (evidence: `handles/unit.ts`)
- World objects → Handle identity: wraps handles (evidence: `handles/unit.ts`)
- Triggers → Handle identity: extends (evidence: `handles/trigger.ts`)
- Units and orders → Players: uses owners (evidence: `handles/unit.ts`)
- Units and orders → World objects: uses objects (evidence: `handles/unit.ts`)
- Triggers → Players: registers events (evidence: `handles/trigger.ts`)
- Triggers → Units and orders: registers events (evidence: `handles/trigger.ts`)
- Host detection → Player sync: requests sync (evidence: `system/host.ts`)
- Host detection → Players: selects host (evidence: `system/host.ts`)
- Host detection → Timers: schedules check (evidence: `system/host.ts`)
- Host detection → Script hooks: registers hook (evidence: `system/host.ts`)
- Player sync → Base64 codec: encodes packets (evidence: `system/sync.ts`)
- Player sync → Binary reader: reads packets (evidence: `system/sync.ts`)
- Player sync → Binary writer: writes packets (evidence: `system/sync.ts`)
- Player sync → Players: sends as player (evidence: `system/sync.ts`)
- Player sync → Timers: starts timeout (evidence: `system/sync.ts`)
- Player sync → Elapsed time: measures elapsed (evidence: `system/sync.ts`)
- Script hooks → Warcraft III runtime: wraps entry points (evidence: `hooks/index.ts`)
- Players → Warcraft III runtime: calls game API
- Units and orders → Warcraft III runtime: calls game API
