castle-web-cli 0.4.2 → 0.4.4
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/dist/index.js +8 -2
- package/dist/init.js +9 -6
- package/package.json +1 -1
- package/kits/basic-2d-frozen/.prettierrc +0 -8
- package/kits/basic-2d-frozen/CLAUDE.md +0 -131
- package/kits/basic-2d-frozen/behaviors/Camera.jsx +0 -43
- package/kits/basic-2d-frozen/behaviors/Collider.jsx +0 -71
- package/kits/basic-2d-frozen/behaviors/Drawing.jsx +0 -139
- package/kits/basic-2d-frozen/behaviors/Layout.jsx +0 -16
- package/kits/basic-2d-frozen/drawings/floor.drawing +0 -70
- package/kits/basic-2d-frozen/editors/App.jsx +0 -152
- package/kits/basic-2d-frozen/editors/CodeEditor.jsx +0 -112
- package/kits/basic-2d-frozen/editors/DrawingEditor.jsx +0 -222
- package/kits/basic-2d-frozen/editors/FileBrowser.jsx +0 -143
- package/kits/basic-2d-frozen/editors/PlayOnly.jsx +0 -21
- package/kits/basic-2d-frozen/editors/SceneEditor.jsx +0 -1012
- package/kits/basic-2d-frozen/editors/behaviorRegistry.js +0 -24
- package/kits/basic-2d-frozen/editors/editorHistory.js +0 -52
- package/kits/basic-2d-frozen/engine/ScenePlayer.jsx +0 -83
- package/kits/basic-2d-frozen/engine/SceneUI.jsx +0 -67
- package/kits/basic-2d-frozen/engine/TouchControls.jsx +0 -136
- package/kits/basic-2d-frozen/engine/autoInspector.jsx +0 -51
- package/kits/basic-2d-frozen/engine/files.js +0 -62
- package/kits/basic-2d-frozen/engine/scene.js +0 -420
- package/kits/basic-2d-frozen/engine/ui.jsx +0 -344
- package/kits/basic-2d-frozen/engine/ui.module.css +0 -928
- package/kits/basic-2d-frozen/eslint.config.js +0 -50
- package/kits/basic-2d-frozen/index.html +0 -11
- package/kits/basic-2d-frozen/main.jsx +0 -10
- package/kits/basic-2d-frozen/package-lock.json +0 -2706
- package/kits/basic-2d-frozen/package.json +0 -41
- package/kits/basic-2d-frozen/scenes/main.scene +0 -108
- package/kits/basic-2d-frozen/vite.config.js +0 -1
- package/kits/rpg-2d/.prettierrc +0 -8
- package/kits/rpg-2d/behaviors/Camera.tsx +0 -52
- package/kits/rpg-2d/behaviors/Collider.tsx +0 -98
- package/kits/rpg-2d/behaviors/Dialog.tsx +0 -184
- package/kits/rpg-2d/behaviors/Drawing.tsx +0 -161
- package/kits/rpg-2d/behaviors/Friend.tsx +0 -45
- package/kits/rpg-2d/behaviors/Layout.tsx +0 -29
- package/kits/rpg-2d/behaviors/PlayerController.tsx +0 -255
- package/kits/rpg-2d/behaviors/Portal.tsx +0 -60
- package/kits/rpg-2d/behaviors/QuestLog.tsx +0 -90
- package/kits/rpg-2d/behaviors/SaveMenu.tsx +0 -123
- package/kits/rpg-2d/behaviors/Tilemap.tsx +0 -90
- package/kits/rpg-2d/drawings/bld-home.drawing +0 -8136
- package/kits/rpg-2d/drawings/env-crate.drawing +0 -509
- package/kits/rpg-2d/drawings/env-fence.drawing +0 -536
- package/kits/rpg-2d/drawings/env-flower-bed.drawing +0 -607
- package/kits/rpg-2d/drawings/env-fountain.drawing +0 -2622
- package/kits/rpg-2d/drawings/env-hedge.drawing +0 -601
- package/kits/rpg-2d/drawings/env-house-blue.drawing +0 -1
- package/kits/rpg-2d/drawings/env-house-green.drawing +0 -1
- package/kits/rpg-2d/drawings/env-tree-oak.drawing +0 -1540
- package/kits/rpg-2d/drawings/env-tree-pine.drawing +0 -1315
- package/kits/rpg-2d/drawings/floor.drawing +0 -70
- package/kits/rpg-2d/drawings/fx-sparkle.drawing +0 -926
- package/kits/rpg-2d/drawings/npc-juno-idle-down.drawing +0 -1099
- package/kits/rpg-2d/drawings/npc-juno-walk-down.drawing +0 -4177
- package/kits/rpg-2d/drawings/npc-opal-idle-down.drawing +0 -1099
- package/kits/rpg-2d/drawings/npc-opal-walk-down.drawing +0 -4177
- package/kits/rpg-2d/drawings/player-idle-down.drawing +0 -1070
- package/kits/rpg-2d/drawings/player-idle-left.drawing +0 -1070
- package/kits/rpg-2d/drawings/player-idle-right.drawing +0 -1070
- package/kits/rpg-2d/drawings/player-idle-up.drawing +0 -1070
- package/kits/rpg-2d/drawings/player-walk-down.drawing +0 -4148
- package/kits/rpg-2d/drawings/player-walk-left.drawing +0 -4148
- package/kits/rpg-2d/drawings/player-walk-right.drawing +0 -4148
- package/kits/rpg-2d/drawings/player-walk-up.drawing +0 -4148
- package/kits/rpg-2d/editors/App.tsx +0 -163
- package/kits/rpg-2d/editors/CodeEditor.tsx +0 -120
- package/kits/rpg-2d/editors/DrawingEditor.tsx +0 -278
- package/kits/rpg-2d/editors/FileBrowser.tsx +0 -191
- package/kits/rpg-2d/editors/PlayOnly.tsx +0 -26
- package/kits/rpg-2d/editors/SceneEditor.tsx +0 -1093
- package/kits/rpg-2d/editors/behaviorRegistry.ts +0 -33
- package/kits/rpg-2d/editors/editorHistory.ts +0 -75
- package/kits/rpg-2d/editors/editorProps.ts +0 -10
- package/kits/rpg-2d/engine/ScenePlayer.tsx +0 -130
- package/kits/rpg-2d/engine/SceneUI.tsx +0 -74
- package/kits/rpg-2d/engine/TouchControls.tsx +0 -157
- package/kits/rpg-2d/engine/autoInspector.tsx +0 -111
- package/kits/rpg-2d/engine/drawing.ts +0 -81
- package/kits/rpg-2d/engine/files.ts +0 -215
- package/kits/rpg-2d/engine/scene.ts +0 -484
- package/kits/rpg-2d/engine/ui.module.css +0 -928
- package/kits/rpg-2d/engine/ui.tsx +0 -483
- package/kits/rpg-2d/eslint.config.js +0 -46
- package/kits/rpg-2d/index.html +0 -11
- package/kits/rpg-2d/main.tsx +0 -14
- package/kits/rpg-2d/package-lock.json +0 -3149
- package/kits/rpg-2d/package.json +0 -46
- package/kits/rpg-2d/scenes/main.scene +0 -203
- package/kits/rpg-2d/tsconfig.json +0 -17
- package/kits/rpg-2d/vite-env.d.ts +0 -7
- package/kits/rpg-2d/vite.config.js +0 -1
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
import type { CSSProperties } from 'react';
|
|
2
|
-
import React, { useState } from 'react';
|
|
3
|
-
import { basename } from '../engine/files';
|
|
4
|
-
import type { FileMap } from '../engine/files';
|
|
5
|
-
import { cx, Icon, SheetGrabHandle, styles, useMobileSheet } from '../engine/ui';
|
|
6
|
-
|
|
7
|
-
type FileNodeData = {
|
|
8
|
-
type: 'file';
|
|
9
|
-
name: string;
|
|
10
|
-
path: string;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
type DirectoryNodeData = {
|
|
14
|
-
type: 'directory';
|
|
15
|
-
name: string;
|
|
16
|
-
path: string;
|
|
17
|
-
children: TreeNode[];
|
|
18
|
-
childMap?: Map<string, TreeNode>;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
type TreeNode = FileNodeData | DirectoryNodeData;
|
|
22
|
-
|
|
23
|
-
export function FileBrowser({
|
|
24
|
-
files,
|
|
25
|
-
selectedPath,
|
|
26
|
-
onSelect,
|
|
27
|
-
sheetOpen = false,
|
|
28
|
-
onSheetOpenChange,
|
|
29
|
-
}: {
|
|
30
|
-
files: FileMap;
|
|
31
|
-
selectedPath: string;
|
|
32
|
-
onSelect: (path: string) => void;
|
|
33
|
-
sheetOpen?: boolean;
|
|
34
|
-
onSheetOpenChange?: (next: boolean) => void;
|
|
35
|
-
}) {
|
|
36
|
-
const tree = buildFileTree(Object.keys(files));
|
|
37
|
-
const [expanded, setExpanded] = useState<Set<string>>(() => new Set(collectDirectoryPaths(tree)));
|
|
38
|
-
const sheet = useMobileSheet({
|
|
39
|
-
snap: sheetOpen ? 'high' : 'hidden',
|
|
40
|
-
baseClassName: styles.fileBrowser,
|
|
41
|
-
onTransition: (direction) => {
|
|
42
|
-
if (direction !== 'up') onSheetOpenChange?.(false);
|
|
43
|
-
},
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
function toggle(path: string): void {
|
|
47
|
-
setExpanded((current) => {
|
|
48
|
-
const next = new Set(current);
|
|
49
|
-
if (next.has(path)) next.delete(path);
|
|
50
|
-
else next.add(path);
|
|
51
|
-
return next;
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return (
|
|
56
|
-
<aside {...sheet.rootProps}>
|
|
57
|
-
<div {...sheet.grabProps}>
|
|
58
|
-
<SheetGrabHandle label="Files" hint={basename(selectedPath)} />
|
|
59
|
-
</div>
|
|
60
|
-
<div className={styles.fileBrowserHeader}>
|
|
61
|
-
<div>
|
|
62
|
-
<div className={styles.fileBrowserTitle}>Deck Files</div>
|
|
63
|
-
</div>
|
|
64
|
-
</div>
|
|
65
|
-
<div className={styles.fileTree}>
|
|
66
|
-
{tree.children.map((node) => (
|
|
67
|
-
<FileNode
|
|
68
|
-
key={node.path}
|
|
69
|
-
node={node}
|
|
70
|
-
depth={0}
|
|
71
|
-
expanded={expanded}
|
|
72
|
-
selectedPath={selectedPath}
|
|
73
|
-
onSelect={onSelect}
|
|
74
|
-
onToggle={toggle}
|
|
75
|
-
/>
|
|
76
|
-
))}
|
|
77
|
-
</div>
|
|
78
|
-
</aside>
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function FileNode({
|
|
83
|
-
node,
|
|
84
|
-
depth,
|
|
85
|
-
expanded,
|
|
86
|
-
selectedPath,
|
|
87
|
-
onSelect,
|
|
88
|
-
onToggle,
|
|
89
|
-
}: {
|
|
90
|
-
node: TreeNode;
|
|
91
|
-
depth: number;
|
|
92
|
-
expanded: Set<string>;
|
|
93
|
-
selectedPath: string;
|
|
94
|
-
onSelect: (path: string) => void;
|
|
95
|
-
onToggle: (path: string) => void;
|
|
96
|
-
}) {
|
|
97
|
-
const depthStyle = { '--file-depth': depth } as CSSProperties;
|
|
98
|
-
|
|
99
|
-
if (node.type === 'directory') {
|
|
100
|
-
const isExpanded = expanded.has(node.path);
|
|
101
|
-
return (
|
|
102
|
-
<div className={styles.fileBranch}>
|
|
103
|
-
<button
|
|
104
|
-
className={styles.fileDirRow}
|
|
105
|
-
style={depthStyle}
|
|
106
|
-
onClick={() => onToggle(node.path)}>
|
|
107
|
-
<span className={styles.fileDisclosure}>
|
|
108
|
-
<Icon name={isExpanded ? 'chevron-down' : 'chevron-right'} />
|
|
109
|
-
</span>
|
|
110
|
-
<span>{node.name}</span>
|
|
111
|
-
</button>
|
|
112
|
-
{isExpanded ? (
|
|
113
|
-
<div>
|
|
114
|
-
{node.children.map((child) => (
|
|
115
|
-
<FileNode
|
|
116
|
-
key={child.path}
|
|
117
|
-
node={child}
|
|
118
|
-
depth={depth + 1}
|
|
119
|
-
expanded={expanded}
|
|
120
|
-
selectedPath={selectedPath}
|
|
121
|
-
onSelect={onSelect}
|
|
122
|
-
onToggle={onToggle}
|
|
123
|
-
/>
|
|
124
|
-
))}
|
|
125
|
-
</div>
|
|
126
|
-
) : null}
|
|
127
|
-
</div>
|
|
128
|
-
);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// File rows nest under their directory header: extra left padding so
|
|
132
|
-
// file text sits to the right of the parent directory header.
|
|
133
|
-
const fileRowStyle: CSSProperties = {
|
|
134
|
-
...depthStyle,
|
|
135
|
-
paddingLeft: `calc(9px + ${depth} * 16px + 7px)`,
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
return (
|
|
139
|
-
<button
|
|
140
|
-
className={cx(styles.fileRow, selectedPath === node.path && styles.fileRowSelected)}
|
|
141
|
-
style={fileRowStyle}
|
|
142
|
-
onClick={() => onSelect(node.path)}>
|
|
143
|
-
<span>{basename(node.path)}</span>
|
|
144
|
-
</button>
|
|
145
|
-
);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
function buildFileTree(paths: string[]): DirectoryNodeData {
|
|
149
|
-
const root: DirectoryNodeData = {
|
|
150
|
-
type: 'directory',
|
|
151
|
-
name: '',
|
|
152
|
-
path: '',
|
|
153
|
-
children: [],
|
|
154
|
-
childMap: new Map(),
|
|
155
|
-
};
|
|
156
|
-
for (const path of paths) {
|
|
157
|
-
const parts = path.split('/');
|
|
158
|
-
let parent = root;
|
|
159
|
-
for (let index = 0; index < parts.length; index++) {
|
|
160
|
-
const name = parts[index];
|
|
161
|
-
const nodePath = parts.slice(0, index + 1).join('/');
|
|
162
|
-
const isFile = index === parts.length - 1;
|
|
163
|
-
if (!parent.childMap?.has(name)) {
|
|
164
|
-
const node: TreeNode = isFile
|
|
165
|
-
? { type: 'file', name, path: nodePath }
|
|
166
|
-
: { type: 'directory', name, path: nodePath, children: [], childMap: new Map() };
|
|
167
|
-
parent.childMap?.set(name, node);
|
|
168
|
-
parent.children.push(node);
|
|
169
|
-
}
|
|
170
|
-
const child = parent.childMap?.get(name);
|
|
171
|
-
if (!child || child.type !== 'directory') break;
|
|
172
|
-
parent = child;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
pruneChildMaps(root);
|
|
176
|
-
return root;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
function pruneChildMaps(node: TreeNode): void {
|
|
180
|
-
if (node.type !== 'directory') return;
|
|
181
|
-
for (const child of node.children) pruneChildMaps(child);
|
|
182
|
-
delete node.childMap;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
function collectDirectoryPaths(node: TreeNode): string[] {
|
|
186
|
-
if (node.type !== 'directory') return [];
|
|
187
|
-
return [
|
|
188
|
-
...(node.path ? [node.path] : []),
|
|
189
|
-
...node.children.flatMap((child) => collectDirectoryPaths(child)),
|
|
190
|
-
];
|
|
191
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { initialFiles, normalizeDrawing, parseJsonFile } from '../engine/files';
|
|
3
|
-
import type { DrawingData } from '../engine/files';
|
|
4
|
-
import type { SceneData } from '../engine/scene';
|
|
5
|
-
import { ScenePlayer } from '../engine/ScenePlayer';
|
|
6
|
-
import { behaviorClasses } from './behaviorRegistry';
|
|
7
|
-
|
|
8
|
-
// Play-mode entry point. Intentionally thin: it locates the start scene and
|
|
9
|
-
// hands it to the engine's `ScenePlayer`, which owns the runtime and input.
|
|
10
|
-
// Deck/game logic belongs in `scenes/` and `behaviors/`, not here.
|
|
11
|
-
export function PlayOnly() {
|
|
12
|
-
const sceneText = initialFiles['scenes/main.scene'] ?? '';
|
|
13
|
-
const { value: sceneData } = parseJsonFile<SceneData>('scenes/main.scene', sceneText);
|
|
14
|
-
if (!sceneData) return null;
|
|
15
|
-
|
|
16
|
-
const drawings: Record<string, DrawingData> = {};
|
|
17
|
-
for (const [path, text] of Object.entries(initialFiles)) {
|
|
18
|
-
if (!path.endsWith('.drawing')) continue;
|
|
19
|
-
const parsed = parseJsonFile<unknown>(path, text);
|
|
20
|
-
if (parsed.value) drawings[path] = normalizeDrawing(parsed.value);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return (
|
|
24
|
-
<ScenePlayer sceneData={sceneData} drawings={drawings} behaviorClasses={behaviorClasses} />
|
|
25
|
-
);
|
|
26
|
-
}
|