@homie-rocks/studio 0.58.26 → 0.58.28
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 +30 -0
- package/lib/cloudflare.mjs +3 -0
- package/lib/migration-ledger.mjs +124 -0
- package/lib/template-history.json +84 -0
- package/netplay/NETPLAY.md +2 -2
- package/package.json +1 -1
- package/worker/build-id.mjs +1 -1
- package/worker/room.mjs +11 -6
- package/worker/table.mjs +1 -0
- package/worker/version.mjs +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -17,6 +17,36 @@ To bring a studio up to date, tell Claude: "Upgrade my studio to the newest Homi
|
|
|
17
17
|
`npx -y @homie-rocks/studio@latest upgrade`, which shows what's new since the version your studio pins (from this
|
|
18
18
|
file) and what the upgrade would change, and changes nothing until you agree.
|
|
19
19
|
|
|
20
|
+
## [0.58.28] - 2026-10-30
|
|
21
|
+
|
|
22
|
+
**Plugin 0.58.15**
|
|
23
|
+
|
|
24
|
+
Security fix for the multiplayer rooms (GHSA-px89-jm6h-gwww, medium). Thanks to @bmoconnor1969-ai for the report,
|
|
25
|
+
the fixes and the tests.
|
|
26
|
+
|
|
27
|
+
### Fixed
|
|
28
|
+
|
|
29
|
+
- A visitor who sends a different made-up message type each time is now paced and then disconnected for flooding,
|
|
30
|
+
like any other flood. Before, each new type got its own allowance, so the socket was never slowed down and the
|
|
31
|
+
room's memory grew with every message.
|
|
32
|
+
- A public room (`pub-N`, or a server's `s-<id>-<n>`) now keeps the studio's seat count. Before, its first visitor
|
|
33
|
+
could send `hello.max: 1` and turn everyone after them into a spectator. A named room (`?room=`) still lets its
|
|
34
|
+
first visitor lower the count, as NETPLAY.md says.
|
|
35
|
+
|
|
36
|
+
### Upgrade notes
|
|
37
|
+
|
|
38
|
+
- Upgrade studios that run multiplayer games: "Upgrade my studio to the newest Homie."
|
|
39
|
+
|
|
40
|
+
## [0.58.27] - 2026-10-30
|
|
41
|
+
|
|
42
|
+
**Plugin 0.58.15**
|
|
43
|
+
|
|
44
|
+
A deploy no longer stops on "duplicate column" when the database already has the schema its migrations make.
|
|
45
|
+
|
|
46
|
+
### Fixed
|
|
47
|
+
|
|
48
|
+
- `homie-studio deploy` (local and CI, preview and live): when the D1 database already has the tables, columns, indexes and triggers of migration files that its ledger (`d1_migrations`) does not list, as after a database was made from the studio's schema in one go, those files are recorded as applied before `wrangler d1 migrations apply` runs, instead of being replayed and failing with `duplicate column name` (for example `server` from `0006_studio_servers.sql` or `expires_at` from `0010`). What each file makes is read by running the studio's own migrations on an empty in-memory SQLite and comparing `PRAGMA table_info` and `sqlite_master` before and after each file, not by reading the SQL. A file is only recorded when everything it adds is already in the live database; a file that only changes data, a file that is half there, and every file after it run as before. If the check cannot run, the deploy applies migrations exactly as it did.
|
|
49
|
+
|
|
20
50
|
## [0.58.26] - 2026-10-29
|
|
21
51
|
|
|
22
52
|
**Plugin 0.58.15**
|
package/lib/cloudflare.mjs
CHANGED
|
@@ -51,6 +51,7 @@ import { MAX_ASSET_BYTES, R2_COST, mediaPlan, r2OverOf, recordMove, sha256File,
|
|
|
51
51
|
import { whyFailed } from './net.mjs';
|
|
52
52
|
import { repoOf } from './repo.mjs';
|
|
53
53
|
import { keptRoutes, readConfig, readZoneRoutes, routesOf, shadowedDomain, wideRouteRefusal, zoneFinding } from './routes.mjs';
|
|
54
|
+
import { reconcileBeforeApply } from './migration-ledger.mjs';
|
|
54
55
|
import { ensureLocalIgnored, ensureMigrations, migrationWord } from './scaffold.mjs';
|
|
55
56
|
import { LOCAL_STATE, configPath, domainOrigin, isRulesGame, isWorkersDev, layoutOf, listExperiences as listGames, readLocal, readStudio, siteUrl, workerDir, writeLocal, writeStudio } from './studio.mjs';
|
|
56
57
|
|
|
@@ -446,6 +447,7 @@ async function deployLocked(root, { log = () => {}, homie, fetchFn = null, ownRo
|
|
|
446
447
|
if (routes) step(`kept the studio's own route${routes.length === 1 ? '' : 's'} in wrangler.jsonc: ${routes.map((r) => r.pattern).join(', ')}`);
|
|
447
448
|
for (const added of ensureMigrations(root)) step(`added ${added} (${migrationWord(added)})`);
|
|
448
449
|
try {await ensureBackgroundQueues(root,w,{accountId,...(fetchFn?{fetchFn}:{})});for(const key of readStudio(root).cloudflare.created??[])created.add(key);} catch(error) {return refuse(error.message);}
|
|
450
|
+
await reconcileBeforeApply(root, w, cf.d1, { step });
|
|
449
451
|
const migrate = w(['d1', 'migrations', 'apply', cf.d1, '--remote']);
|
|
450
452
|
if (migrate.code !== 0) return refuse(`D1 migrations failed: ${wranglerError(migrate.out)}`, migrate.out);
|
|
451
453
|
try {const replication=await enableReadReplication(root,w,{accountId,databaseId:db.uuid,...(fetchFn?{fetchFn}:{})});step(replication.enabled?'D1 read replication enabled':`D1 uses the primary: ${replication.reason}`);} catch(error) {step(`D1 uses the primary: ${error.message}`);}
|
|
@@ -672,6 +674,7 @@ export async function ciDeploy(root, { log = () => {}, wrangler = null, preview
|
|
|
672
674
|
// A platform target's queues are the platform's (lib/dispatch-target.mjs).
|
|
673
675
|
if (!target) { try {await ensureBackgroundQueues(root,w);} catch(error) {return refuse(error.message);} }
|
|
674
676
|
const apply = () => w(['d1', 'migrations', 'apply', names.binding, '--remote']);
|
|
677
|
+
await reconcileBeforeApply(root, w, names.binding, { step });
|
|
675
678
|
let migrate = apply();
|
|
676
679
|
const first = !target && migrate.code !== 0 && /not found|could(?:n't| not) find|does not exist|no database|database_id/i.test(migrate.out);
|
|
677
680
|
if (migrate.code !== 0 && !first) return refuse(`D1 migrations failed: ${wranglerError(migrate.out)}`, migrate.out);
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import {existsSync,readdirSync,readFileSync} from 'node:fs';
|
|
2
|
+
import {isAbsolute,join} from 'node:path';
|
|
3
|
+
import {readConfig} from './routes.mjs';
|
|
4
|
+
import {workerDir} from './studio.mjs';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Reconcile Wrangler's migration ledger with a database that already has the schema.
|
|
8
|
+
*
|
|
9
|
+
* `wrangler d1 migrations apply` decides what to run from the ledger table (d1_migrations) alone. A database whose
|
|
10
|
+
* schema was made some other way (provisioned in one batch from a template, restored from an export, or a ledger
|
|
11
|
+
* that was lost) still lists those files as unapplied, and the first `ALTER TABLE … ADD COLUMN` stops the deploy on
|
|
12
|
+
* "duplicate column name". Before applying, this works out what each migration file makes by running the studio's
|
|
13
|
+
* own files, in order, on an empty in-memory SQLite (node:sqlite), and comparing the schema before and after each one:
|
|
14
|
+
* tables, columns (PRAGMA table_info), indexes, triggers and views. It then reads the live schema the same way. An
|
|
15
|
+
* unapplied file is recorded as applied only when everything it adds is already there and nothing it removes is; it
|
|
16
|
+
* stops at the first file that is not (a file that only changes data, or a half-made schema), so Wrangler runs that one
|
|
17
|
+
* and everything after it as usual. Nothing is guessed from the SQL text, and nothing in the studio's own tables is
|
|
18
|
+
* changed. Any failure here leaves the ledger alone: `migrations apply` then behaves exactly as before.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
const OBJECTS = `SELECT 'table:'||m.name AS o FROM sqlite_master m WHERE m.type='table' AND m.name NOT LIKE 'sqlite_%' AND m.name NOT LIKE '_cf_%'
|
|
22
|
+
UNION ALL SELECT 'column:'||m.name||'.'||p.name FROM sqlite_master m JOIN pragma_table_info(m.name) p WHERE m.type='table' AND m.name NOT LIKE 'sqlite_%' AND m.name NOT LIKE '_cf_%'
|
|
23
|
+
UNION ALL SELECT m.type||':'||m.name FROM sqlite_master m WHERE m.type IN ('index','trigger','view') AND m.name NOT LIKE 'sqlite_%' AND m.name NOT LIKE '_cf_%'`;
|
|
24
|
+
export const SCHEMA_OBJECTS_SQL = OBJECTS.replace(/\n/g, ' ');
|
|
25
|
+
const NAME = /^[A-Za-z_][A-Za-z0-9_]{0,63}$/;
|
|
26
|
+
|
|
27
|
+
/** The studio's migration files, in Wrangler's order (by file name), with their SQL. */
|
|
28
|
+
export function migrationFiles(root, { config = readConfig(root) } = {}) {
|
|
29
|
+
const db = config?.d1_databases?.[0];
|
|
30
|
+
if (!db?.migrations_dir) return { table: db?.migrations_table ?? 'd1_migrations', files: [] };
|
|
31
|
+
const dir = isAbsolute(db.migrations_dir) ? db.migrations_dir : join(workerDir(root), db.migrations_dir);
|
|
32
|
+
const files = existsSync(dir) ? readdirSync(dir).filter((n) => n.endsWith('.sql')).sort().map((name) => ({ name, sql: readFileSync(join(dir, name), 'utf8') })) : [];
|
|
33
|
+
return { table: db.migrations_table ?? 'd1_migrations', files };
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* What each file adds and removes, from running them in order on an empty database. The list ends at the first file
|
|
38
|
+
* that does not run here (its effects, and those of every file after it, are unknown and never reconciled).
|
|
39
|
+
*/
|
|
40
|
+
export async function migrationEffects(files, { open = openMemory } = {}) {
|
|
41
|
+
const db = await open();
|
|
42
|
+
if (!db) return [];
|
|
43
|
+
const effects = [];
|
|
44
|
+
try {
|
|
45
|
+
let before = schemaOf(db);
|
|
46
|
+
for (const file of files) {
|
|
47
|
+
try { db.exec(file.sql); } catch { break; }
|
|
48
|
+
const after = schemaOf(db);
|
|
49
|
+
effects.push({ name: file.name, adds: [...after].filter((o) => !before.has(o)), removes: [...before].filter((o) => !after.has(o)) });
|
|
50
|
+
before = after;
|
|
51
|
+
}
|
|
52
|
+
} finally { try { db.close(); } catch { /* closed */ } }
|
|
53
|
+
return effects;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** The unapplied files whose schema is already all there, from the first unapplied file up to the first that is not. */
|
|
57
|
+
export function alreadyApplied({ effects, applied, live }) {
|
|
58
|
+
const done = new Set(applied), have = new Set(live), out = [];
|
|
59
|
+
for (const e of effects) {
|
|
60
|
+
if (done.has(e.name)) continue;
|
|
61
|
+
const changes = e.adds.length + e.removes.length;
|
|
62
|
+
if (!changes || !e.adds.every((o) => have.has(o)) || e.removes.some((o) => have.has(o))) break;
|
|
63
|
+
out.push(e.name);
|
|
64
|
+
}
|
|
65
|
+
return out;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Before `migrations apply`: record the files the live database already has the schema of. `run(sql)` executes one
|
|
70
|
+
* statement on the target database and resolves to its rows (or throws). Returns the names it recorded.
|
|
71
|
+
*/
|
|
72
|
+
export async function reconcileLedger({ files, table = 'd1_migrations', run, open = openMemory }) {
|
|
73
|
+
if (!files.length || !NAME.test(table)) return [];
|
|
74
|
+
// One read when nothing needs doing: the live schema, which also says whether the ledger table exists.
|
|
75
|
+
const live = (await run(SCHEMA_OBJECTS_SQL)).map((r) => String(r.o));
|
|
76
|
+
// A database with none of the schema yet (a new studio) has nothing to reconcile.
|
|
77
|
+
if (!live.length) return [];
|
|
78
|
+
const applied = live.includes(`table:${table}`) ? (await run(`SELECT name FROM ${table}`)).map((r) => String(r.name)) : [];
|
|
79
|
+
if (files.every((f) => applied.includes(f.name))) return [];
|
|
80
|
+
const names = alreadyApplied({ effects: await migrationEffects(files, { open }), applied, live });
|
|
81
|
+
if (!names.length) return [];
|
|
82
|
+
for (const n of names) if (!/^[\w.-]+\.sql$/.test(n)) throw new Error(`Unexpected migration file name ${n}`);
|
|
83
|
+
// Wrangler's own ledger table, as `migrations apply` makes it.
|
|
84
|
+
await run(`CREATE TABLE IF NOT EXISTS ${table}(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT UNIQUE, applied_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL); ${names.map((n) => `INSERT OR IGNORE INTO ${table}(name) VALUES ('${n}');`).join(' ')}`);
|
|
85
|
+
return names;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** `wrangler d1 execute <db> --remote|--local --json --command <sql>` as rows; throws on a failed command. */
|
|
89
|
+
export function wranglerRows(w, database, where) {
|
|
90
|
+
return async (sql) => {
|
|
91
|
+
const r = w(['d1', 'execute', database, where, '--json', '--command', sql]);
|
|
92
|
+
if (r.code !== 0) throw new Error(`d1 execute failed: ${String(r.out).slice(-300)}`);
|
|
93
|
+
const text = r.stdout ?? r.out, start = text.indexOf('[');
|
|
94
|
+
const parsed = JSON.parse(text.slice(start));
|
|
95
|
+
return parsed.flatMap((x) => x?.results ?? []);
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** The deploy step: reconcile, and say what happened. Never fails the deploy. */
|
|
100
|
+
export async function reconcileBeforeApply(root, w, database, { where = '--remote', step = () => {}, open = openMemory } = {}) {
|
|
101
|
+
try {
|
|
102
|
+
const { files, table } = migrationFiles(root);
|
|
103
|
+
const names = await reconcileLedger({ files, table, run: wranglerRows(w, database, where), open });
|
|
104
|
+
if (names.length) step(`recorded ${names.length} migration${names.length === 1 ? '' : 's'} the database already had the schema of (${names[0]}${names.length > 1 ? ` … ${names.at(-1)}` : ''})`);
|
|
105
|
+
return names;
|
|
106
|
+
} catch (error) {
|
|
107
|
+
step(`migration ledger not checked (${String(error?.message ?? error).slice(0, 160)}); applying as usual`);
|
|
108
|
+
return [];
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function schemaOf(db) {
|
|
113
|
+
return new Set(db.prepare(SCHEMA_OBJECTS_SQL).all().map((r) => String(r.o)));
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
async function openMemory() {
|
|
117
|
+
// node:sqlite needs Node 22.5+ (no flag from 22.13). Without it nothing is reconciled.
|
|
118
|
+
const emit = process.emitWarning;
|
|
119
|
+
try {
|
|
120
|
+
process.emitWarning = (w, ...rest) => (/SQLite/i.test(String(w?.message ?? w)) ? undefined : emit.call(process, w, ...rest));
|
|
121
|
+
const { DatabaseSync } = await import('node:sqlite');
|
|
122
|
+
return new DatabaseSync(':memory:');
|
|
123
|
+
} catch { return null; } finally { process.emitWarning = emit; }
|
|
124
|
+
}
|
|
@@ -5076,6 +5076,90 @@
|
|
|
5076
5076
|
}
|
|
5077
5077
|
}
|
|
5078
5078
|
}
|
|
5079
|
+
},
|
|
5080
|
+
"0.58.27": {
|
|
5081
|
+
"files": {
|
|
5082
|
+
"CLAUDE.md": "ddf2b2a0376202f6",
|
|
5083
|
+
"README.md": "684b3cca8001673c",
|
|
5084
|
+
"HANDOFF.md": "29337e2ace95b2e7",
|
|
5085
|
+
"games/README.md": "5ad32fe80c61f117",
|
|
5086
|
+
"music/README.md": "a3dc042dadd39df8",
|
|
5087
|
+
"videos/README.md": "16babc3437d5545b",
|
|
5088
|
+
"posts/README.md": "37841aae476bd540",
|
|
5089
|
+
"site/README.md": "1dbdf22c03a1e505",
|
|
5090
|
+
"site/src/worker.mjs": "6cc5c6131eaf6fd0"
|
|
5091
|
+
},
|
|
5092
|
+
"sections": {
|
|
5093
|
+
"AGENTS.md": {
|
|
5094
|
+
"(intro)": "af7f2f732505d379",
|
|
5095
|
+
"## Version-matched authoring guides": "f6261a0e5801b96b",
|
|
5096
|
+
"## Layout": "f3a280b8c96cd068",
|
|
5097
|
+
"## Apps: one screen, roles and parts": "2ecf713305fd26f5",
|
|
5098
|
+
"## Commands (all through the pinned CLI in node_modules)": "661cbdf5d6a9dbae",
|
|
5099
|
+
"## The site": "0cb8dd9a6f8a0096",
|
|
5100
|
+
"## Making games": "644c1e7608bb9740",
|
|
5101
|
+
"## The Game Codex and progress": "0738ef719cef3a4c",
|
|
5102
|
+
"## Art direction and models": "a48fff7bf0a5f2fc",
|
|
5103
|
+
"## Running live games (the back office)": "51ebf2ab756f6e4d",
|
|
5104
|
+
"## Servers and AI seats": "1904f45b599a33e4",
|
|
5105
|
+
"## Selling things (the shop)": "e5bd380cb77f2b11",
|
|
5106
|
+
"## Continuing a build from the Claude app": "0d68081e924ca419",
|
|
5107
|
+
"## Rules": "b2234d80f6cbe71d",
|
|
5108
|
+
"## Telling Homie": "80b46fdd9e578db8",
|
|
5109
|
+
"## Beta": "9d02638207a26e73"
|
|
5110
|
+
}
|
|
5111
|
+
},
|
|
5112
|
+
"named": {
|
|
5113
|
+
"Homie Arcade": {
|
|
5114
|
+
"sections": {
|
|
5115
|
+
"AGENTS.md": {
|
|
5116
|
+
"## Commands (all through the pinned CLI in node_modules)": "0a7b2c36414a29a0"
|
|
5117
|
+
}
|
|
5118
|
+
}
|
|
5119
|
+
}
|
|
5120
|
+
}
|
|
5121
|
+
},
|
|
5122
|
+
"0.58.28": {
|
|
5123
|
+
"files": {
|
|
5124
|
+
"CLAUDE.md": "ddf2b2a0376202f6",
|
|
5125
|
+
"README.md": "684b3cca8001673c",
|
|
5126
|
+
"HANDOFF.md": "29337e2ace95b2e7",
|
|
5127
|
+
"games/README.md": "5ad32fe80c61f117",
|
|
5128
|
+
"music/README.md": "a3dc042dadd39df8",
|
|
5129
|
+
"videos/README.md": "16babc3437d5545b",
|
|
5130
|
+
"posts/README.md": "37841aae476bd540",
|
|
5131
|
+
"site/README.md": "1dbdf22c03a1e505",
|
|
5132
|
+
"site/src/worker.mjs": "6cc5c6131eaf6fd0"
|
|
5133
|
+
},
|
|
5134
|
+
"sections": {
|
|
5135
|
+
"AGENTS.md": {
|
|
5136
|
+
"(intro)": "af7f2f732505d379",
|
|
5137
|
+
"## Version-matched authoring guides": "f6261a0e5801b96b",
|
|
5138
|
+
"## Layout": "f3a280b8c96cd068",
|
|
5139
|
+
"## Apps: one screen, roles and parts": "2ecf713305fd26f5",
|
|
5140
|
+
"## Commands (all through the pinned CLI in node_modules)": "661cbdf5d6a9dbae",
|
|
5141
|
+
"## The site": "0cb8dd9a6f8a0096",
|
|
5142
|
+
"## Making games": "644c1e7608bb9740",
|
|
5143
|
+
"## The Game Codex and progress": "0738ef719cef3a4c",
|
|
5144
|
+
"## Art direction and models": "a48fff7bf0a5f2fc",
|
|
5145
|
+
"## Running live games (the back office)": "51ebf2ab756f6e4d",
|
|
5146
|
+
"## Servers and AI seats": "1904f45b599a33e4",
|
|
5147
|
+
"## Selling things (the shop)": "e5bd380cb77f2b11",
|
|
5148
|
+
"## Continuing a build from the Claude app": "0d68081e924ca419",
|
|
5149
|
+
"## Rules": "b2234d80f6cbe71d",
|
|
5150
|
+
"## Telling Homie": "80b46fdd9e578db8",
|
|
5151
|
+
"## Beta": "9d02638207a26e73"
|
|
5152
|
+
}
|
|
5153
|
+
},
|
|
5154
|
+
"named": {
|
|
5155
|
+
"Homie Arcade": {
|
|
5156
|
+
"sections": {
|
|
5157
|
+
"AGENTS.md": {
|
|
5158
|
+
"## Commands (all through the pinned CLI in node_modules)": "0a7b2c36414a29a0"
|
|
5159
|
+
}
|
|
5160
|
+
}
|
|
5161
|
+
}
|
|
5162
|
+
}
|
|
5079
5163
|
}
|
|
5080
5164
|
}
|
|
5081
5165
|
}
|
package/netplay/NETPLAY.md
CHANGED
|
@@ -268,8 +268,8 @@ code.
|
|
|
268
268
|
`netplay.maxPlayers`, or a `netplay.json` beside game.json or in the game's build
|
|
269
269
|
(`maxPlayers` or `players.max`), else game.json's `players.max`, else 8. **A room holds
|
|
270
270
|
chosen by the studio** (`players.max`). `homie-studio build` writes the number into the catalogue and
|
|
271
|
-
the site's Table takes it from there; the first visitor of an empty room may lower it
|
|
272
|
-
(`hello.max`), never raise it.
|
|
271
|
+
the site's Table takes it from there; the first visitor of an empty named room may lower it
|
|
272
|
+
(`hello.max`), never raise it; a public room (`pub-N`, `s-<id>-<n>`) always keeps the studio's number.
|
|
273
273
|
- **A dropped seat is held 60 s** for its token, which covers a reload or a network blip.
|
|
274
274
|
**A visitor who is present beats one who left:** when no seat is free, the relay
|
|
275
275
|
reclaims the seat that has been absent longest. Visitors who leave can never lock a
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@homie-rocks/studio",
|
|
3
|
-
"version": "0.58.
|
|
3
|
+
"version": "0.58.28",
|
|
4
4
|
"description": "Open-source tools that let your AI build and run a multiplayer game studio on its own Cloudflare: an MCP server, multiplayer starters, Workers and Durable Objects.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
package/worker/build-id.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by lib/build-identity.mjs; identifies the bundled runtime sources.
|
|
2
|
-
export const STUDIO_BUILD = Object.freeze({"version":"0.58.
|
|
2
|
+
export const STUDIO_BUILD = Object.freeze({"version":"0.58.28","sha256":"13fcfdee87b1f6f602445bf54d0cb8f61ef8ed8e0574dd9918b341d770adcf1c"});
|
package/worker/room.mjs
CHANGED
|
@@ -29,7 +29,7 @@ export class NetRoom {
|
|
|
29
29
|
* each stamped `at` (ISO time) with its room; never a token, a ticket, a browser key or a frame's contents
|
|
30
30
|
*/
|
|
31
31
|
constructor({
|
|
32
|
-
code, rules = false, tickHz = 20, maxPlayers = 8, maxScreens = 16, perIp = 12, stallMs = 1500, silentMs = 2500, idleMs = 10_000,
|
|
32
|
+
code, rules = false, tickHz = 20, maxPlayers = 8, lowerable = true, maxScreens = 16, perIp = 12, stallMs = 1500, silentMs = 2500, idleMs = 10_000,
|
|
33
33
|
holdMs = 60_000, forgetMs = 60_000, persistMs = 30_000, store = null, now = Date.now, log = () => {},
|
|
34
34
|
rates = null, agentsAloneMs = AGENTS_ALONE_MS, voteMs = VOTE.ms, voteCooldownMs = VOTE.cooldownMs, autoVoteMs = VOTE.autoMs,
|
|
35
35
|
}) {
|
|
@@ -61,6 +61,8 @@ export class NetRoom {
|
|
|
61
61
|
this.rules = rules === true;
|
|
62
62
|
this.tickHz = tickHz;
|
|
63
63
|
this.seatCap = maxPlayers;
|
|
64
|
+
// A room strangers are matched into (a pool room: pub-N, s-<id>-<n>) keeps its seats: only a named room's first visitor may lower them.
|
|
65
|
+
this.lowerable = lowerable;
|
|
64
66
|
this.maxPlayers = maxPlayers;
|
|
65
67
|
this.maxScreens = maxScreens;
|
|
66
68
|
this.perIp = perIp;
|
|
@@ -675,10 +677,13 @@ export class NetRoom {
|
|
|
675
677
|
// (speech, chat, reactions) keeps its pace, and so does every room a player's own browser hosts, where the
|
|
676
678
|
// caps are what stands between that phone and the rest of the room.
|
|
677
679
|
const social = t === 'say' || t === 'react' || t === 'ev' && SPEECH.test(kind ?? '');
|
|
678
|
-
|
|
679
|
-
|
|
680
|
+
// A type the relay does not know shares the "other" bucket: a socket that invents a new type for every
|
|
681
|
+
// message must not get a fresh allowance (and a fresh map entry) each time.
|
|
682
|
+
const bucket = Object.hasOwn(RATES, t) || (this.rates && Object.hasOwn(this.rates, t)) ? t : 'other';
|
|
683
|
+
const preset = this.server && !social ? null : t === 'ev' ? EV_RATES[view ? (c.seat === null ? 'screen' : 'replica') : this.roleOf(c)] : (RATES[bucket] ?? RATES.other);
|
|
684
|
+
const limit = (this.rates && Object.hasOwn(this.rates, bucket) ? this.rates[bucket] : undefined) ?? preset;
|
|
680
685
|
if (!(Number.isFinite(limit) && limit > 0)) return true;
|
|
681
|
-
const rateKey = view ? `${
|
|
686
|
+
const rateKey = view ? `${bucket}:view` : bucket;
|
|
682
687
|
const list = c.rates.get(rateKey) ?? [];
|
|
683
688
|
while (list.length && list[0] <= now - 1000) list.shift();
|
|
684
689
|
c.rates.set(rateKey, list);
|
|
@@ -969,7 +974,7 @@ export class NetRoom {
|
|
|
969
974
|
c.typed = c.agent || this.policy.kids ? '' : typeof m.name === 'string' ? stripAi(m.name.replace(/\s+/g, ' ').trim()).slice(0, 24) : '';
|
|
970
975
|
if (Array.isArray(m.caps)) for (const k of m.caps) if (CAPS.includes(k)) c.caps.add(k);
|
|
971
976
|
// The manifest's player count, from the first visitor of an empty room (the site's Table reads the manifest).
|
|
972
|
-
if (!this.server && !this.rules && Number.isInteger(m.max) && !this.seats.size && !live.length) { this.askedMax = m.max; this.maxPlayers = Math.max(1, Math.min(this.seatCap, m.max)); }
|
|
977
|
+
if (this.lowerable && !this.server && !this.rules && Number.isInteger(m.max) && !this.seats.size && !live.length) { this.askedMax = m.max; this.maxPlayers = Math.max(1, Math.min(this.seatCap, m.max)); }
|
|
973
978
|
this.reapSeats(now);
|
|
974
979
|
// The verified pass names one AI. Reopening its socket resumes that seat and replaces the old socket.
|
|
975
980
|
const agentStay = c.agent?.pass ? [...this.seats.values()].find(s => s.agent?.pass === c.agent.pass) : null;
|
|
@@ -1761,7 +1766,7 @@ export class NetRoom {
|
|
|
1761
1766
|
restore(saved, graceMs = 3000) {
|
|
1762
1767
|
const now = this.now();
|
|
1763
1768
|
if (!saved || saved.v !== NET_VERSION || !(now - Number(saved.savedAt) < 120_000)) return false;
|
|
1764
|
-
if (!this.server && !this.rules && saved.hosted !== 'server' && Number.isInteger(saved.maxPlayers)) this.maxPlayers = Math.max(1, Math.min(this.seatCap, saved.maxPlayers));
|
|
1769
|
+
if (this.lowerable && !this.server && !this.rules && saved.hosted !== 'server' && Number.isInteger(saved.maxPlayers)) this.maxPlayers = Math.max(1, Math.min(this.seatCap, saved.maxPlayers));
|
|
1765
1770
|
if (Number.isFinite(saved.openedAt) && saved.openedAt > 0) this.openedAt = saved.openedAt;
|
|
1766
1771
|
for (const [seat, token, name, agent, occ, since] of saved.seats ?? []) this.seats.set(seat, { token, name, since: saved.durable && Number.isFinite(since) ? since : now, present: false, agent: agent && typeof agent === 'object' ? agent : null, ...(Number.isInteger(occ) ? { occ } : {}) });
|
|
1767
1772
|
// A stay's number is never given twice while a checkpoint may still name it.
|
package/worker/table.mjs
CHANGED
package/worker/version.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** The @homie-rocks/studio version this Worker code is (package.json's; a test keeps them equal). Cache-busts /_homie/site.js. */
|
|
2
|
-
export const STUDIO_VERSION_TAG = '0.58.
|
|
2
|
+
export const STUDIO_VERSION_TAG = '0.58.28';
|