Skip to content

Commit f83d41c

Browse files
clockwork-labs-botraincloutiertyler
authored
docs: consolidate outstanding docs fixes (clockworklabs#5166)
## Summary Consolidates the outstanding docs PRs opened by `clockwork-labs-bot` / Docs Gremlin into one reviewable PR: - clockworklabs#4958 - clockworklabs#5085 - clockworklabs#5089 - clockworklabs#5097 - clockworklabs#5112 - clockworklabs#5114 - clockworklabs#5117 - clockworklabs#5127 - clockworklabs#5138 - clockworklabs#5165 - clockworklabs#5175 - clockworklabs#5222 This combines docs updates for: - getting-started links - server-issued auth token reconnect behavior in the Unity tutorial - C++ module/client language coverage - Unreal client ticking / `FrameTick` guidance - C# connection callback signatures and codegen language spelling - deterministic schedule-table sample time - client frame ticking troubleshooting - corrected `spacetime generate` usage for Unreal bindings - TypeScript framework integration reference updates for SolidJS and current React query-builder tuple usage ## Validation - `rg -n '^(<<<<<<<|=======|>>>>>>>)' docs crates skills` - `git diff --check origin/master...HEAD` - `pnpm --dir docs typecheck` - `pnpm --dir docs build` --------- Co-authored-by: clockwork-labs-bot <clockwork-labs-bot@users.noreply.github.com> Co-authored-by: rain <rain@rain.local> Co-authored-by: Tyler Cloutier <cloutiertyler@users.noreply.github.com>
1 parent 7a2a697 commit f83d41c

29 files changed

Lines changed: 262 additions & 78 deletions

File tree

crates/cli/src/subcommands/dev.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ pub fn cli() -> Command {
8181
Arg::new("client-lang")
8282
.long("client-lang")
8383
.value_parser(clap::value_parser!(Language))
84-
.help("The programming language for the generated client module bindings (e.g., typescript, csharp, python). If not specified, it will be detected from the project."),
84+
.help("The programming language for the generated client module bindings (e.g., typescript, csharp, rust, unrealcpp). If not specified, it will be detected from the project."),
8585
)
8686
.arg(common_args::server().help("The nickname, host name or URL of the server to publish to"))
8787
.arg(common_args::yes())

crates/cli/src/subcommands/generate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ fn get_filtered_generate_configs<'a>(
168168
pub fn cli() -> clap::Command {
169169
clap::Command::new("generate")
170170
.about("Generate client files for a spacetime module.")
171-
.override_usage("generate [DATABASE] --lang <LANG> --out-dir <DIR> [--module-path <DIR> | --bin-path <PATH> | --unreal-module-name <MODULE_NAME> | --uproject-dir <DIR> | --include-private]")
171+
.override_usage("generate [DATABASE] --lang <LANG> [--module-path <DIR> | --bin-path <PATH> | --js-path <PATH>] [--out-dir <DIR> | --uproject-dir <DIR>] [--unreal-module-name <MODULE_NAME>] [OPTIONS]")
172172
.arg(
173173
Arg::new("database")
174174
.help("Database name or glob pattern to filter which databases to generate for"),

crates/update/src/cli/self_install.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ following line to your shell configuration and open a new shell session:
9696
eprintln!(
9797
"\
9898
The install process is complete; check out our quickstart guide to get started!
99-
<https://spacetimedb.com/docs/getting-started>"
99+
<https://spacetimedb.com/docs/>"
100100
);
101101

102102
Ok(ExitCode::SUCCESS)

docs/docs/00100-intro/00100-getting-started/00250-zen-of-spacetimedb.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ Perfect consistency, always.
8080

8181
## Everything is Programmable
8282

83-
SpacetimeDB doesn't limit you to declarative rules or configuration files. Your module is real code (Rust, C#, or TypeScript) running inside the database. You have the full power of a procedural, normal programming language at your disposal.
83+
SpacetimeDB doesn't limit you to declarative rules or configuration files. Your module is real code (Rust, C#, TypeScript, or C++) running inside the database. You have the full power of a procedural, normal programming language at your disposal.
8484

8585
Need custom authorization logic? Write a function. Need to validate complex business rules? Write a function. Need to transform data before storing it? Write a function.
8686

docs/docs/00100-intro/00100-getting-started/00300-language-support.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ slug: /intro/language-support
66

77
## Server Database Modules
88

9-
SpacetimeDB modules define your database schema and server-side business logic. Modules can be written in three languages:
9+
SpacetimeDB modules define your database schema and server-side business logic. Modules can be written in four languages:
1010

1111
- **[Rust](../../00200-core-concepts/00100-databases.md)** - High performance, compiled to WebAssembly [(Quickstart)](../00200-quickstarts/00500-rust.md)
1212
- **[C#](../../00200-core-concepts/00100-databases.md)** - Great for Unity developers, compiled to WebAssembly [(Quickstart)](../00200-quickstarts/00600-c-sharp.md)
1313
- **[TypeScript](../../00200-core-concepts/00100-databases.md)** - Ideal for web developers, runs on V8 [(Quickstart)](../00200-quickstarts/00400-typescript.md)
14+
- **[C++](../../00200-core-concepts/00100-databases.md)** - Fits Unreal and C++ workflows, compiled to WebAssembly [(Quickstart)](../00200-quickstarts/00700-cpp.md)
1415

1516
## Client SDKs
1617

docs/docs/00100-intro/00100-getting-started/00500-faq.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ SpacetimeDB replaces the entire server. Your game state lives in tables, your ga
6060

6161
Firebase and Supabase are Backend-as-a-Service platforms. They give you a database with an API layer on top, but your application logic still runs elsewhere (cloud functions, edge functions, or your own server). Complex business logic is awkward to express as database triggers or serverless functions.
6262

63-
SpacetimeDB lets you write your entire application as a module in a real programming language (Rust, C#, TypeScript) that runs inside the database. You get full transactional guarantees, direct table access, and real-time subscriptions without the cold starts, execution limits, or awkward abstractions of serverless functions.
63+
SpacetimeDB lets you write your entire application as a module in a real programming language (Rust, C#, TypeScript, or C++) that runs inside the database. You get full transactional guarantees, direct table access, and real-time subscriptions without the cold starts, execution limits, or awkward abstractions of serverless functions.
6464

6565
### How is SpacetimeDB different from a regular database (PostgreSQL, MySQL)?
6666

@@ -149,7 +149,7 @@ SpacetimeDB 2.0 also includes a **type-safe query builder** for client-side subs
149149

150150
1. Install the CLI: `curl -sSf https://install.spacetimedb.com | sh`
151151
2. Start a local instance: `spacetime start`
152-
3. Create a project: `spacetime init --lang rust` (or `csharp`, `typescript`)
152+
3. Create a project: `spacetime init --lang rust` (or `csharp`, `typescript`, `cpp`)
153153
4. Write your module, publish it: `spacetime publish my-app`
154154
5. Generate client bindings: `spacetime generate --lang typescript --out-dir src/module_bindings`
155155
6. Connect from your client using the generated code

docs/docs/00100-intro/00300-tutorials/00300-unity-tutorial/00300-part-2.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,21 @@ public class GameManager : MonoBehaviour
743743
void HandleConnect(DbConnection _conn, Identity identity, string token)
744744
{
745745
Debug.Log("Connected.");
746+
// Only the WebGL player has the browser WebSocket header limitation.
747+
// The Unity Editor uses the normal desktop transport even when the
748+
// selected build target is WebGL, so keep the normal behavior there.
749+
#if UNITY_WEBGL && !UNITY_EDITOR
750+
if (AuthToken.Token == "")
751+
{
752+
// No token was supplied to the connection, so this is the
753+
// long-lived server-issued token for the new identity. Save it.
754+
// If a token already exists, this connect may have used a
755+
// short-lived WebSocket token, which should not overwrite it.
756+
AuthToken.SaveToken(token);
757+
}
758+
#else
746759
AuthToken.SaveToken(token);
760+
#endif
747761
LocalIdentity = identity;
748762

749763
OnConnected?.Invoke();
@@ -787,6 +801,8 @@ public class GameManager : MonoBehaviour
787801
}
788802
```
789803

804+
> Unity WebGL needs one extra precaution here. Browser WebSocket APIs cannot set an `Authorization` header, so reconnecting with a saved server-issued token may yield a short-lived WebSocket token in `HandleConnect`. The `#if UNITY_WEBGL` guard keeps the original saved token instead of overwriting it during reconnect.
805+
790806
Here we configure the connection to the database, by passing it some callbacks in addition to providing the `SERVER_URI` and `MODULE_NAME` to the connection. When the client connects, the SpacetimeDB SDK will call the `HandleConnect` method, allowing us to start up the game.
791807

792808
In our `HandleConnect` callback we build a subscription and call `Subscribe`, subscribing to all data in the database. This causes SpacetimeDB to synchronize the state of all your tables with your Unity client's SDK client cache.

docs/docs/00100-intro/00300-tutorials/00300-unity-tutorial/00400-part-3.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1351,7 +1351,21 @@ Next lets add some callbacks when rows change in the database. Modify the `Handl
13511351
void HandleConnect(DbConnection conn, Identity identity, string token)
13521352
{
13531353
Debug.Log("Connected.");
1354+
// Only the WebGL player has the browser WebSocket header limitation.
1355+
// The Unity Editor uses the normal desktop transport even when the
1356+
// selected build target is WebGL, so keep the normal behavior there.
1357+
#if UNITY_WEBGL && !UNITY_EDITOR
1358+
if (AuthToken.Token == "")
1359+
{
1360+
// No token was supplied to the connection, so this is the
1361+
// long-lived server-issued token for the new identity. Save it.
1362+
// If a token already exists, this connect may have used a
1363+
// short-lived WebSocket token, which should not overwrite it.
1364+
AuthToken.SaveToken(token);
1365+
}
1366+
#else
13541367
AuthToken.SaveToken(token);
1368+
#endif
13551369
LocalIdentity = identity;
13561370

13571371
conn.Db.Circle.OnInsert += CircleOnInsert;
@@ -1370,6 +1384,8 @@ void HandleConnect(DbConnection conn, Identity identity, string token)
13701384
}
13711385
```
13721386

1387+
Keep the same WebGL guard from Part 2 here as well. On Unity WebGL, a reconnect can surface a short-lived WebSocket token in `HandleConnect`, so you should not overwrite an already-saved long-lived server-issued token.
1388+
13731389
Next add the following implementations for those callbacks to the `GameManager` class.
13741390

13751391
```csharp

docs/docs/00200-core-concepts/00100-databases/00500-cheat-sheet.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { CppModuleVersionNotice } from "@site/src/components/CppModuleVersionNot
88
import Tabs from '@theme/Tabs';
99
import TabItem from '@theme/TabItem';
1010

11-
Quick reference for SpacetimeDB module syntax across Rust, C#, and TypeScript.
11+
Quick reference for SpacetimeDB module syntax across Rust, C#, TypeScript, and C++.
1212

1313
## Project Setup
1414

@@ -600,23 +600,23 @@ SPACETIMEDB_PROCEDURE(std::string, fetch_data, ProcedureContext ctx, std::string
600600
601601
```typescript
602602
// Return single row
603-
export const my_player = spacetimedb.view({ name: 'my_player' }, {}, t.option(player.rowType), ctx => {
603+
export const my_player = spacetimedb.view({ name: 'my_player', public: true }, t.option(player.rowType), ctx => {
604604
return ctx.db.player.identity.find(ctx.sender);
605605
});
606606
607607
// Return potentially multiple rows
608-
export const top_players = spacetimedb.view({ name: 'top_players' }, {}, t.array(player.rowType), ctx => {
608+
export const top_players = spacetimedb.view({ name: 'top_players', public: true }, t.array(player.rowType), ctx => {
609609
return ctx.db.player.score.filter(1000);
610610
});
611611
612612
// Perform a generic filter using the query builder.
613613
// Equivalent to `SELECT * FROM player WHERE score < 1000`.
614-
export const bottom_players = spacetimedb.view({ name: 'bottom_players' }, {}, t.array(player.rowType), ctx => {
614+
export const bottom_players = spacetimedb.view({ name: 'bottom_players', public: true }, t.array(player.rowType), ctx => {
615615
return ctx.from.player.where(p => p.score.lt(1000))
616616
});
617617
618618
// Count rows in a table.
619-
export const player_count = spacetimedb.anonymousView({ name: 'player_count' }, {}, t.array(t.row('PlayerCount', {
619+
export const player_count = spacetimedb.anonymousView({ name: 'player_count', public: true }, t.array(t.row('PlayerCount', {
620620
count: t.u64(),
621621
})), ctx => {
622622
return [{ count: ctx.db.player.count() }];

docs/docs/00200-core-concepts/00300-tables.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ import { table, t } from 'spacetimedb/server';
403403
404404
// Define the shared column schema
405405
const playerColumns = {
406-
identity: t.Identity.primaryKey(),
406+
identity: t.identity().primaryKey(),
407407
playerId: t.i32().unique().autoInc(),
408408
name: t.string(),
409409
};

0 commit comments

Comments
 (0)