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

+49 -20
View File
@@ -1,12 +1,12 @@
import { openTab, pickAssetType } from './lib/scaffold.mjs';
/**
* Plugins (#113, #114). The demo plugin in `plugins/` is copied to `data/plugins/` by the build and
* the seeder, switched on; the editor loads it at start-up through the API. What only a running
* editor can show: that the module really loads and activates, that its tab joins the row, that its
* node board draws one node per asset and follows the asset list – created through the + menu,
* renamed, and taken away again by undo – and that the switch in the Plugins tab stops and starts
* it while the editor runs.
* Plugins (#113, #114, #119). The demo plugin in `plugins/` is copied to `data/plugins/` by the
* build and the seeder; the fixture project switches it on, and the editor loads it before the
* project itself. What only a running editor can show: that the module really loads and activates,
* that its tab joins the row, that its node board draws one node per asset and follows the asset
* list – created through the + menu, renamed, and taken away again by undo – and that the switch in
* the Plugins tab stops and starts it while the editor runs, as an undo step of the project.
*/
export async function plugins(t) {
const { check, sleep, json, evaluate, mutate, clickText, drag, wheel, press, shot, showTab, settle, undo } =
@@ -27,6 +27,11 @@ export async function plugins(t) {
demo?.status === 'active' && demo.meta?.id === 'demo' && demo.meta.api === 1,
JSON.stringify(records),
);
check(
'and it runs because the project switches it on, not the server',
JSON.stringify(await json('__gm.state.project.plugins')) === JSON.stringify(['demo-plugin.js']),
JSON.stringify(await json('__gm.state.project.plugins')),
);
check(
'no plugin failed',
records.every((r) => r.status === 'active'),
@@ -158,7 +163,8 @@ export async function plugins(t) {
await showTab('scene');
check('switching to another tab hides the board', (await board()).visible === false);
// 38i. The Plugins tab (#114): the switch is the server's, and it works while the editor runs.
// 38i. The Plugins tab (#114, #119): the switch belongs to the project, and it works while the
// editor runs.
await openTab(t, 'plugins');
await settle();
const pane = () => json('__gm.plugins.pane()');
@@ -173,17 +179,20 @@ export async function plugins(t) {
JSON.stringify(rows),
);
const settled = async (was) => {
// Loading a module is a fetch, so the switch is applied a moment after the click.
for (let i = 0; i < 50; i++) {
const now = await pane();
if (rowOf(now)?.status !== rowOf(was)?.status) return now;
await sleep(100);
}
return pane();
};
const toggle = async () => {
const at = await json('__gm.plugins.switchAt("demo-plugin.js")');
await t.click(at.x, at.y);
await settle();
// Switching goes to the server and back before it is applied.
for (let i = 0; i < 50; i++) {
const now = await pane();
if (rowOf(now)?.status !== rowOf(rows)?.status) return now;
await sleep(100);
}
return pane();
return settled(rows);
};
rows = await toggle();
@@ -199,16 +208,36 @@ export async function plugins(t) {
(await board()) === null,
JSON.stringify(rowAfterOff),
);
// The switch is the server's, not this browser's: the list says so for everyone. (That a
// switched-off module is not handed out either is the API's own check, not one for here – the
// refusal never reaches the page, the site's firewall answers it with a page of its own.)
// The switch is the project's (#119): it stands in the project file and travels with it. The
// server's own list knows nothing about it any more – it only says which files there are.
const listed = await evaluate(
`fetch('/game-maker/api/index.php?r=plugins').then(async (r) => JSON.stringify(await r.json()))`,
);
const entry = JSON.parse(listed).find((e) => e.file === 'demo-plugin.js');
check(
'the server stores the switch: its list says the plugin is off',
JSON.parse(listed).find((e) => e.file === 'demo-plugin.js')?.active === false,
listed,
'the project says it is off, while the server still lists the file itself',
JSON.stringify(await json('__gm.state.project.plugins')) === '[]' &&
entry !== undefined &&
entry.active === undefined,
JSON.stringify({ plugins: await json('__gm.state.project.plugins'), entry }),
);
// And because it is a change to the project, undo takes it back – plugin, tab and all.
await undo();
rows = await settled(rows);
const afterUndo = await json('__gm.tabRow()');
check(
'undo switches it on again, as a step of the project',
JSON.stringify(await json('__gm.state.project.plugins')) === JSON.stringify(['demo-plugin.js']) &&
rowOf(rows)?.status === 'active' &&
[...afterUndo.shown.map((p) => p.tab), ...afterUndo.hidden].includes('plugin:assets'),
JSON.stringify({ plugins: await json('__gm.state.project.plugins'), row: rowOf(rows) }),
);
rows = await toggle();
check(
'and clicking the switch off again stops it once more',
rowOf(rows)?.status === 'inactive' && JSON.stringify(await json('__gm.state.project.plugins')) === '[]',
JSON.stringify({ row: rowOf(rows), plugins: await json('__gm.state.project.plugins') }),
);
rows = await toggle();