Files
feuerwerk/tools/lib/builders.mjs
T
rootandClaude Fable 5.1 6471671f7d Refactor round: ship web/index.html, drop the remote browser, fix stale comments and README
- `.gitignore` said `index.html` unanchored, which also caught the Vite source page;
  a fresh clone could neither `dev` nor `build`. Anchored to `/index.html`, page added.
- Removed GM_REMOTE (tools/remote/gm-browser.ps1 and the ssh/scp branch in browser.mjs):
  the Windows test machine is gone and the only flaky check that lived on it is closed (#37).
- Removed `npm run preview`, undocumented and unused.
- Comments: wrong number in collider.test.ts (250 → 200), the "declarations used to…"
  history in listItems.ts and friends, the 24 px/28 contradiction, section banners in
  nodes/index.ts, node-catalog.test.ts and api/index.php, name paraphrases, and the stale
  step numbers in tools/e2e/11-…23- from the old global count.
- README: asset types include `animation`, kind order Number/Text/Boolean, tagged colour
  and texture items, 6/5 kinds, the `Texture` node, `./build.sh`, PROJECT_FORMAT_VERSION,
  and the file tree (kinds.ts, listItems.ts, propertyPorts.ts, Breadcrumb.ts, beads.ts,
  tools/assets/).
- tests/helpers.ts takes the duplicated `findObject` and `sceneWithCamera`.

Proof: ./check.sh 797 tests, full e2e ALL PASSED 633 checks against this bundle.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-12 15:44:05 +02:00

76 lines
2.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* Small factories for writing project documents by hand (the seed scripts). They produce the
* exact shape `src/core/store/serialize.ts` reads; optional fields get their defaults.
*/
/** A scene object (also a container template entry). Position defaults to the origin. */
export const sceneObject = (
id,
assetId,
{ name = '', x = 0, y = 0, z = 0, overrides = {}, parentId = '', instanceEdits, editorOffset } = {},
) => ({
id,
assetId,
name,
position: { x, y, z },
overrides,
parentId,
...(instanceEdits ? { instanceEdits } : {}),
...(editorOffset ? { editorOffset } : {}),
});
/**
* The id an object of a placed container resolves to: `<instance>~<template ids>`. A placed
* container stores nothing but itself, so this is how its content is addressed – in the editor,
* in a running game and in the check scripts alike (see `src/core/model/instance.ts`).
*/
export const instanceChild = (instanceId, ...templatePath) => `${instanceId}~${templatePath.join('/')}`;
export const edge = (id, from, fromPort, to, toPort) => ({
id,
from: { node: from, port: fromPort },
to: { node: to, port: toPort },
});
/** A graph node; `params` holds settings and inline input values alike. `ports` only on the types that declare them. */
export const node = (id, type, x, y, params = {}, ports) => ({
id,
type,
x,
y,
params,
...(ports ? { ports } : {}),
});
/** A port a node declares: an input of a start node, a field of a struct, a variable read by `Variables`. */
export const port = (key, kind) => ({ key, kind });
/** A variable a `Variables` node writes as well as reads. */
export const written = (key, kind) => ({ key, kind, write: true });
/** The settings of a `Properties` node: the object type it offers ports from, and for `behavior` which one. */
export const propertiesOf = (objectType, objectBehavior) => ({
objectType,
...(objectBehavior ? { objectBehavior } : {}),
});
/**
* A behavior variable declaration. `fields` is the shape of a `struct`; a `list` declares nothing,
* its items each carry their own kind (a colour or a texture as `tagged`).
*/
export const variable = (key, kind, value, fields) => ({
key,
label: key,
kind,
default: value,
...(fields ? { fields } : {}),
});
export const field = (key, kind = 'number') => ({ key, kind });
/**
* A list item of a kind JSON cannot show: inside a list a colour would be a plain number and a
* texture id a plain text, so it wears its kind as a tag – `{ $color: 0xff0000 }`.
*/
export const tagged = (kind, value) => ({ [`$${kind}`]: value });