Consolidate duplicated editor code, trim comments, refresh README
Split GraphCanvas (1076 -> 831 lines) into EdgeLayer and graphMenus; the port and marker menus were the same list and are now one function. Value specs of the inspector and the list tab share valueSpecs.ts, and the remaining copies (compound commands, type glyphs, typed asset lookup, name rule, play/editor world setup, marquee) are merged. Four copies had already drifted apart; merging them fixes: - "Disconnect N links" in the port menu is one undo step, not N - "+ Add collider" is hidden on a placed container instance, as in the hierarchy menu, instead of always failing - a bool property coerced from the text "false" becomes false - a port command on an unknown node type reports instead of crashing Comment-only edits leave the bundle byte-identical. README corrected in 35 places (step limit, jump-run clock, suite duration, 409 body, ...). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9212e61c4c
commit
8f92a06c84
96 files changed
+999
-1261
No files matched your search
@@ -1,9 +1,4 @@
|
||||
/**
|
||||
* A list holds primitives or structs. Depth stops there and it stops in the declaration, not by
|
||||
* convention: a list says what its items are (`ListItemKind`, struct included), a struct field
|
||||
* says what it holds (`FieldKind`, primitives only). So `list → struct → primitive` is the deepest
|
||||
* a stored value goes, which is what keeps the deep compare and the editor finite.
|
||||
*/
|
||||
/** The declarations cap depth: `list → struct → primitive` is the deepest a stored value goes. */
|
||||
export type ListValue = readonly (number | string | boolean | StructValue)[];
|
||||
|
||||
/** What a struct field may hold. A field is never itself a struct – see `ListValue`. */
|
||||
@@ -40,6 +35,19 @@ export function textOf(value: PropertyValue | undefined): string {
|
||||
return String(value);
|
||||
}
|
||||
|
||||
/** The spelling of a text counts: `Boolean('false')` would be true. */
|
||||
export function booleanOf(value: unknown): boolean {
|
||||
if (typeof value !== 'string') return Boolean(value);
|
||||
const s = value.trim().toLowerCase();
|
||||
return !(s === '' || s === 'false' || s === '0' || s === 'no');
|
||||
}
|
||||
|
||||
/** A number, or a hex text with or without `#`, clamped to 0…0xffffff. */
|
||||
export function colorOf(value: PropertyValue, fallback: number): number {
|
||||
const n = typeof value === 'number' ? value : parseInt(textOf(value).replace('#', ''), 16);
|
||||
return Number.isFinite(n) ? Math.max(0, Math.min(0xffffff, Math.floor(n))) : fallback;
|
||||
}
|
||||
|
||||
/** Values are compared by content, because two equal lists (or structs) are never the same object. */
|
||||
export function sameValue(a: PropertyValue | undefined, b: PropertyValue | undefined): boolean {
|
||||
if (isList(a) || isList(b)) {
|
||||
|
||||
Reference in new issue
Block a user