Plugins belong to the project, and they load before it: the project file gained the field plugins: ["demo-plugin.js"] (default empty, no formatVersion bump), the Plugins tab's switch writes into it as an ordinary undo step (SetPluginActiveCommand) instead of into a server-wide plugins.json, and the start order is turned around - startPlugins only fetches the list of files, then editor.boot() runs and ProjectStore.load(id, prepare) hands the raw JSON through before it is deserialized, where pluginsOf(raw) reads the list and PluginManager.syncTo() activates exactly those; that is the point of the issue, because what a plugin registers has to stand there before normalizeGraph would throw it away as unknown (#126, #127), a project switch first stops what the new project does not name and then starts what it does, a file the server does not have is passed over silently, and after signing out the manager is dead so a late event cannot start anything in a torn-down session; on the server plugins.json, PluginStore::setActive, isActive, the route PUT ?r=plugins/{file} and the 403 for inactive modules are gone and GET ?r=plugins only answers {file,bytes,updatedAt}, which makes every plugin file fetchable - the consequence accepted in #117, written down in the wiki for #115 and #116; publishPlugins(root) only copies files now, the seeder switches the demo plugin on in the fixture project, and the Plugins tab carries a puzzle piece as its icon while only a plugin's own tab still goes without one (the knob and the socket are cubic curves, not arcs, which Pixi's parser draws as a spike after an L); 3 new e2e checks in module 38 and 5 new unit tests cover the project as the owner of the switch, its undo, the order, pluginsOf against crude input and an unknown file name (#119)
game-maker / gate (push) Successful in 3m32s
game-maker / suite (push) Failing after 8m21s

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
adminandClaude Opus 5 committed 2026-09-20 14:24:27 +02:00
1 parent c830c7a3aa
commit 5ba796a2b6
28 files changed
+425 -269

No files matched your search

+11 -46
View File
@@ -1,64 +1,29 @@
import {
chownSync,
copyFileSync,
existsSync,
mkdirSync,
readdirSync,
readFileSync,
statSync,
writeFileSync,
} from 'node:fs';
import { chownSync, copyFileSync, existsSync, mkdirSync, readdirSync, statSync } from 'node:fs';
import { resolve } from 'node:path';
/** The demo plugin the seed projects switch on (#119); `DEMO_PLUGIN` is its file name. */
export const DEMO_PLUGIN = 'demo-plugin.js';
/**
* Puts the plugins that ship with the repository (`plugins/*.js`) where the editor loads them from,
* `data/plugins/`, and switches them on in `plugins.json` (#114) – a plugin put there by hand stays
* off until someone switches it on in the Plugins tab. Used by the build and by the e2e seeder.
* `data/plugins/`. Used by the build and by the e2e seeder.
*
* `force` is the seeder's: the checks need the demo plugin on, whatever a person did with the
* switch. The build only switches on what the state does not name yet, so a plugin switched off
* on the server stays off across deployments.
* Which of them run is not decided here any more (#119): a plugin is switched on by the project
* that wants it, so the seeders name it in the projects they write. What lies in `data/plugins/`
* is only what is available.
*
* The API writes `plugins.json` as the web server's user. When this runs as root (the build on the
* The API reads the folder as the web server's user. When this runs as root (the build on the
* host), the folder and what it wrote are handed to the owner of `data/`, which is that user.
*/
export function publishPlugins(root, { force = false } = {}) {
export function publishPlugins(root) {
const target = resolve(root, 'data/plugins');
mkdirSync(target, { recursive: true });
const written = [target];
const shipped = readdirSync(resolve(root, 'plugins')).filter((f) => f.endsWith('.js'));
for (const file of shipped) {
for (const file of readdirSync(resolve(root, 'plugins')).filter((f) => f.endsWith('.js'))) {
copyFileSync(resolve(root, 'plugins', file), resolve(target, file));
written.push(resolve(target, file));
}
const statePath = resolve(target, 'plugins.json');
let state = {};
if (existsSync(statePath)) {
try {
state = JSON.parse(readFileSync(statePath, 'utf8'));
} catch {
console.warn(`${statePath} is not readable JSON – left as it is, no plugin switched on`);
state = null;
}
}
if (state && typeof state === 'object') {
let changed = false;
for (const file of shipped) {
if (!force && Object.hasOwn(state, file)) continue;
if (state[file]?.active === true) continue;
state[file] = { active: true };
changed = true;
}
if (changed) {
const sorted = Object.fromEntries(
Object.entries(state).sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0)),
);
writeFileSync(statePath, `${JSON.stringify(sorted, null, 4)}\n`);
}
written.push(statePath);
}
if (process.getuid?.() === 0) {
const { uid, gid } = statSync(resolve(root, 'data'));
for (const path of written) if (existsSync(path)) chownSync(path, uid, gid);