castle-web-cli 0.4.129 → 0.4.131

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.
Files changed (144) hide show
  1. package/dist/agent-prompts.js +4 -4
  2. package/dist/filesChanged.d.ts +2 -0
  3. package/dist/filesChanged.js +6 -2
  4. package/dist/ide.js +15 -4
  5. package/dist/importBrowse.js +1 -0
  6. package/dist/index.js +10 -4
  7. package/dist/init.js +63 -15
  8. package/dist/native/loop.js +1 -1
  9. package/dist/native/tools.js +1 -1
  10. package/dist/serve.d.ts +1 -0
  11. package/dist/serve.js +20 -1
  12. package/dist/shell/assets/index-BpOLUyVO.js +441 -0
  13. package/dist/shell/assets/{index-CAq6f9B5.css → index-D6K-0YDB.css} +1 -1
  14. package/dist/shell/index.html +2 -2
  15. package/kits/physics-2d/CLAUDE.md +9 -10
  16. package/kits/physics-2d/castle.json +1 -1
  17. package/kits/physics-2d/editors/PlayOnly.jsx +16 -6
  18. package/kits/physics-2d/editors/PxArtEditor.jsx +95 -31
  19. package/kits/physics-2d/editors/SceneEditor.jsx +10 -10
  20. package/kits/physics-2d/editors/SingleEditor.jsx +37 -8
  21. package/kits/physics-2d/editors/StyleEditor.jsx +7 -4
  22. package/kits/physics-2d/editors/pixelEditorChrome.jsx +7 -7
  23. package/kits/physics-2d/editors/pixelInspector.jsx +13 -7
  24. package/kits/physics-2d/editors/pxArtTimeline.jsx +29 -11
  25. package/kits/physics-2d/editors/pxArtTimeline.module.css +11 -0
  26. package/kits/physics-2d/engine/ScenePlayer.jsx +2 -2
  27. package/kits/physics-2d/engine/blueprint.js +23 -5
  28. package/kits/physics-2d/engine/liveReload.js +33 -21
  29. package/kits/physics-2d/engine/scene.js +17 -5
  30. package/kits/physics-2d/engine/systemRegistry.js +1 -1
  31. package/kits/physics-2d/engine/ui.jsx +2 -2
  32. package/kits/physics-2d/engine/ui.module.css +42 -0
  33. package/kits/physics-3d/CLAUDE.md +108 -0
  34. package/kits/physics-3d/behaviors/Body.jsx +51 -0
  35. package/kits/physics-3d/behaviors/Door.jsx +31 -0
  36. package/kits/physics-3d/behaviors/Lookable.jsx +11 -0
  37. package/kits/physics-3d/behaviors/Model.jsx +14 -0
  38. package/kits/physics-3d/behaviors/Pickup.jsx +39 -0
  39. package/kits/physics-3d/behaviors/Player.jsx +172 -0
  40. package/kits/physics-3d/behaviors/Shape.jsx +75 -0
  41. package/kits/physics-3d/behaviors/Solid.jsx +11 -0
  42. package/kits/physics-3d/behaviors/Transform.jsx +24 -0
  43. package/kits/physics-3d/blueprints/barrel.scene +15 -0
  44. package/kits/physics-3d/blueprints/crate.scene +29 -0
  45. package/kits/physics-3d/blueprints/door.scene +35 -0
  46. package/kits/physics-3d/blueprints/gem.scene +26 -0
  47. package/kits/physics-3d/blueprints/pillar.scene +25 -0
  48. package/kits/physics-3d/blueprints/platform.scene +23 -0
  49. package/kits/physics-3d/blueprints/player.scene +29 -0
  50. package/kits/physics-3d/blueprints/rock.scene +14 -0
  51. package/kits/physics-3d/blueprints/statue.scene +26 -0
  52. package/kits/physics-3d/blueprints/tree.scene +14 -0
  53. package/kits/physics-3d/blueprints/wall.scene +26 -0
  54. package/kits/{basic-2d → physics-3d}/castle.json +23 -5
  55. package/kits/physics-3d/docs/pxmodel-format.md +111 -0
  56. package/kits/physics-3d/drawings/crate.pxart +26 -0
  57. package/kits/physics-3d/drawings/door-edge.pxart +26 -0
  58. package/kits/physics-3d/drawings/door.pxart +27 -0
  59. package/kits/physics-3d/drawings/face.pxart +26 -0
  60. package/kits/physics-3d/drawings/floor.pxart +27 -0
  61. package/kits/physics-3d/drawings/platform.pxart +27 -0
  62. package/kits/physics-3d/drawings/statue.pxart +27 -0
  63. package/kits/physics-3d/drawings/wall.pxart +27 -0
  64. package/kits/physics-3d/engine3d/PlayOnly3D.jsx +36 -0
  65. package/kits/physics-3d/engine3d/PxModelEditor.jsx +619 -0
  66. package/kits/physics-3d/engine3d/Scene3DEditor.jsx +618 -0
  67. package/kits/physics-3d/engine3d/Scene3DPlayer.jsx +309 -0
  68. package/kits/physics-3d/engine3d/editor3dData.js +114 -0
  69. package/kits/physics-3d/engine3d/editor3dInspector.jsx +404 -0
  70. package/kits/physics-3d/engine3d/editorChrome.jsx +218 -0
  71. package/kits/physics-3d/engine3d/editorWorld.js +249 -0
  72. package/kits/physics-3d/engine3d/materials.js +174 -0
  73. package/kits/physics-3d/engine3d/meshops.js +123 -0
  74. package/kits/physics-3d/engine3d/modelEditorWorld.js +439 -0
  75. package/kits/physics-3d/engine3d/modelFiles.js +136 -0
  76. package/kits/physics-3d/engine3d/pxmodel.js +265 -0
  77. package/kits/physics-3d/engine3d/thumbnails.js +137 -0
  78. package/kits/physics-3d/engine3d/world3d.js +216 -0
  79. package/kits/{basic-2d → physics-3d}/eslint.config.js +10 -25
  80. package/kits/physics-3d/index.html +20 -0
  81. package/kits/physics-3d/main.jsx +30 -0
  82. package/kits/physics-3d/models/barrel.pxmodel +10 -0
  83. package/kits/physics-3d/models/player.pxmodel +222 -0
  84. package/kits/physics-3d/models/rock.pxmodel +30 -0
  85. package/kits/physics-3d/models/tree.pxmodel +10 -0
  86. package/kits/{basic-2d → physics-3d}/package-lock.json +140 -119
  87. package/kits/{basic-2d → physics-3d}/package.json +11 -9
  88. package/kits/{basic-2d → physics-3d}/pnpm-lock.yaml +162 -137
  89. package/kits/physics-3d/scenes/main.scene +398 -0
  90. package/kits/physics-3d/scenes/model-lab.scene +111 -0
  91. package/kits/physics-3d/systems/physics3d.js +356 -0
  92. package/package.json +5 -2
  93. package/dist/shell/assets/index-DKu9ejyh.js +0 -436
  94. package/kits/basic-2d/CLAUDE.md +0 -221
  95. package/kits/basic-2d/behaviors/Camera.jsx +0 -43
  96. package/kits/basic-2d/behaviors/Collider.jsx +0 -213
  97. package/kits/basic-2d/behaviors/Layout.jsx +0 -53
  98. package/kits/basic-2d/behaviors/Sprite.jsx +0 -357
  99. package/kits/basic-2d/behaviors/tint.js +0 -47
  100. package/kits/basic-2d/blueprints/cauldron.scene +0 -20
  101. package/kits/basic-2d/docs/pxart-format.md +0 -377
  102. package/kits/basic-2d/drawings/cauldron.pxart +0 -113
  103. package/kits/basic-2d/editors/BlueprintLibrary.jsx +0 -270
  104. package/kits/basic-2d/editors/ErrorBoundary.jsx +0 -59
  105. package/kits/basic-2d/editors/PlayOnly.jsx +0 -31
  106. package/kits/basic-2d/editors/PxArtEditor.jsx +0 -1092
  107. package/kits/basic-2d/editors/SceneEditor.jsx +0 -1780
  108. package/kits/basic-2d/editors/SelectionOverlay.jsx +0 -909
  109. package/kits/basic-2d/editors/SingleEditor.jsx +0 -122
  110. package/kits/basic-2d/editors/behaviorRegistry.js +0 -34
  111. package/kits/basic-2d/editors/editorHistory.js +0 -157
  112. package/kits/basic-2d/editors/inspectorSheet.js +0 -13
  113. package/kits/basic-2d/editors/pixelCanvas.js +0 -11
  114. package/kits/basic-2d/editors/pixelEditorChrome.jsx +0 -74
  115. package/kits/basic-2d/editors/pixelGeometry.js +0 -140
  116. package/kits/basic-2d/editors/pixelInspector.jsx +0 -633
  117. package/kits/basic-2d/editors/pxArtEditorModel.js +0 -732
  118. package/kits/basic-2d/editors/pxArtPlayback.js +0 -92
  119. package/kits/basic-2d/editors/pxArtTimeline.jsx +0 -752
  120. package/kits/basic-2d/editors/pxArtTimeline.module.css +0 -506
  121. package/kits/basic-2d/editors/pxArtTools.js +0 -232
  122. package/kits/basic-2d/editors/useArtboardFit.js +0 -105
  123. package/kits/basic-2d/engine/ScenePlayer.jsx +0 -209
  124. package/kits/basic-2d/engine/SceneUI.jsx +0 -59
  125. package/kits/basic-2d/engine/assets.js +0 -15
  126. package/kits/basic-2d/engine/autoInspector.jsx +0 -70
  127. package/kits/basic-2d/engine/behaviorExtensions.js +0 -32
  128. package/kits/basic-2d/engine/blueprint.js +0 -557
  129. package/kits/basic-2d/engine/collider.js +0 -200
  130. package/kits/basic-2d/engine/files.js +0 -141
  131. package/kits/basic-2d/engine/liveReload.js +0 -88
  132. package/kits/basic-2d/engine/pxart.js +0 -1032
  133. package/kits/basic-2d/engine/pxartSmooth.js +0 -222
  134. package/kits/basic-2d/engine/scene.js +0 -696
  135. package/kits/basic-2d/engine/spriteGeometry.js +0 -32
  136. package/kits/basic-2d/engine/systemRegistry.js +0 -16
  137. package/kits/basic-2d/engine/ui.jsx +0 -695
  138. package/kits/basic-2d/engine/ui.module.css +0 -2287
  139. package/kits/basic-2d/index.html +0 -24
  140. package/kits/basic-2d/main.jsx +0 -24
  141. package/kits/basic-2d/scenes/main.scene +0 -16
  142. package/kits/basic-2d/scripts/draw.mjs +0 -121
  143. /package/kits/{basic-2d → physics-3d}/.prettierrc +0 -0
  144. /package/kits/{basic-2d → physics-3d}/vite.config.js +0 -0
@@ -1,24 +0,0 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
5
- <meta name="color-scheme" content="dark" />
6
- <title>Castle Basic 2D JS Kit</title>
7
- <!-- Declare the dark scheme + opaque dark background statically, before the
8
- JS-imported CSS module loads. Otherwise this frame paints with the
9
- default (light) scheme first and only switches to dark once the module
10
- applies -- and Safari fails to repaint a composited iframe on a
11
- color-scheme change (WebKit bug 309097), leaving static panels like the
12
- file list blank until a forced repaint (e.g. opening devtools). -->
13
- <style>
14
- html {
15
- color-scheme: dark;
16
- background: #0a0a0a;
17
- }
18
- </style>
19
- </head>
20
- <body>
21
- <div id="root"></div>
22
- <script type="module" src="/main.jsx"></script>
23
- </body>
24
- </html>
@@ -1,24 +0,0 @@
1
- import React from 'react';
2
- import { createRoot } from 'react-dom/client';
3
- import { isEdit, setup } from 'castle-web-sdk';
4
- import { PlayOnly } from './editors/PlayOnly';
5
- import { ErrorBoundary } from './editors/ErrorBoundary';
6
- import { SingleEditor } from './editors/SingleEditor';
7
- document.body.dataset.castleScreenshotTarget = 'viewport';
8
- setup();
9
- const root = document.getElementById('root');
10
- if (!root) throw new Error('Missing root element');
11
- // Route on URL params so the shell can mount each piece in its own panel iframe.
12
- // File browsing and the code/text editor are now builtin shell panels, so the
13
- // kit only renders the deck (play) and its rich per-file editors (scene/pxart):
14
- // (no edit / ?edit=0) -> play the deck (playtest panel)
15
- // ?file=<path>[&editor=<id>] -> a single rich editor for that file
16
- const params = new URLSearchParams(window.location.search);
17
- function pick() {
18
- const initialScene = params.get('scene') ?? undefined;
19
- if (!isEdit()) return <PlayOnly initialScene={initialScene} />;
20
- const file = params.get('file');
21
- if (file) return <SingleEditor path={file} editor={params.get('editor') ?? undefined} />;
22
- return <PlayOnly initialScene={initialScene} />;
23
- }
24
- createRoot(root).render(<ErrorBoundary>{pick()}</ErrorBoundary>);
@@ -1,16 +0,0 @@
1
- {
2
- "background": "#1a1932",
3
- "actors": [
4
- {
5
- "id": "cauldron",
6
- "blueprint": "blueprints/cauldron.scene",
7
- "components": {
8
- "Layout": {
9
- "x": 200,
10
- "y": 300
11
- }
12
- }
13
- }
14
- ],
15
- "name": "Main"
16
- }
@@ -1,121 +0,0 @@
1
- // `npm run draw -- <name>` — turn a terse svg-rect emission into a sprite.
2
- //
3
- // Reads an <svg> with one <rect> per pixel from stdin (or `--from <file>`),
4
- // decodes + palette-quantizes it onto the agent 16-color subset, and writes a
5
- // single-frame `drawings/<name>.pxart` in the deck (the script's cwd).
6
- //
7
- // This is a kit-layer concern: the `.pxart` format lives entirely in the kit
8
- // (engine/pxart.js); the harness has no knowledge of it.
9
-
10
- import * as fs from 'fs';
11
- import * as path from 'path';
12
- import {
13
- svgRectToPxArt,
14
- serializeCompact,
15
- AGENT_PALETTE_16,
16
- DEFAULT_RESOLUTION,
17
- } from '../engine/pxart.js';
18
-
19
- // Read all of stdin as a UTF-8 string. Resolves '' if stdin is a TTY with no
20
- // piped input so we can give a clear "no input" error instead of hanging.
21
- function readStdin() {
22
- return new Promise((resolve, reject) => {
23
- if (process.stdin.isTTY) {
24
- resolve('');
25
- return;
26
- }
27
- const chunks = [];
28
- process.stdin.on('data', (c) => chunks.push(c));
29
- process.stdin.on('end', () => resolve(Buffer.concat(chunks).toString('utf-8')));
30
- process.stdin.on('error', reject);
31
- });
32
- }
33
-
34
- // Normalize a requested sprite name into a relative `drawings/<...>.pxart`
35
- // path. Tolerates a leading `drawings/` and/or a trailing `.pxart`/`.px.json`
36
- // so `draw ship`, `draw ship.pxart`, and `draw drawings/ship.pxart` all land in
37
- // the same place.
38
- function resolveSpritePath(dir, name) {
39
- let rel = name.trim().replace(/\\/g, '/');
40
- rel = rel.replace(/^\.?\/*/, '');
41
- if (rel.startsWith('drawings/')) rel = rel.slice('drawings/'.length);
42
- rel = rel.replace(/\.px\.json$/i, '').replace(/\.pxart$/i, '');
43
- if (!rel) return null;
44
-
45
- const drawingsDir = path.resolve(dir, 'drawings');
46
- const filepath = path.resolve(drawingsDir, `${rel}.pxart`);
47
- const within = path.relative(drawingsDir, filepath);
48
- if (within.startsWith('..') || path.isAbsolute(within)) return null;
49
- return filepath;
50
- }
51
-
52
- function getFlagValue(flag) {
53
- const idx = process.argv.indexOf(flag);
54
- return idx >= 0 ? process.argv[idx + 1] : undefined;
55
- }
56
-
57
- // All positional (non-flag) args after the script, in order.
58
- function positionals() {
59
- const args = process.argv.slice(2);
60
- const withValues = new Set(['--from']);
61
- const out = [];
62
- for (let i = 0; i < args.length; i++) {
63
- if (args[i].startsWith('--')) {
64
- if (withValues.has(args[i])) i++;
65
- continue;
66
- }
67
- out.push(args[i]);
68
- }
69
- return out;
70
- }
71
-
72
- async function main() {
73
- const name = positionals()[0];
74
- if (!name) {
75
- console.error('Usage: npm run draw -- <name> [--from FILE] (svg-rect on stdin -> drawings/<name>.pxart)');
76
- process.exit(1);
77
- }
78
-
79
- // The script's cwd is the deck; sprites land under <deck>/drawings/.
80
- const dir = process.cwd();
81
- const filepath = resolveSpritePath(dir, name);
82
- if (!filepath) {
83
- console.error(`Invalid sprite name: ${name}`);
84
- process.exit(1);
85
- }
86
-
87
- const fromFile = getFlagValue('--from');
88
- let svg;
89
- if (fromFile) {
90
- try {
91
- svg = fs.readFileSync(path.resolve(fromFile), 'utf-8');
92
- } catch (e) {
93
- console.error(`Could not read --from file ${fromFile}: ${e instanceof Error ? e.message : String(e)}`);
94
- process.exit(1);
95
- }
96
- } else {
97
- svg = await readStdin();
98
- }
99
-
100
- if (!svg.trim()) {
101
- console.error('No svg-rect input. Pipe an <svg> with <rect> cells via stdin or pass --from <file>.');
102
- process.exit(1);
103
- }
104
-
105
- const art = svgRectToPxArt(svg, { resolution: DEFAULT_RESOLUTION, palette: AGENT_PALETTE_16 });
106
- if (!art) {
107
- console.error('Could not decode any pixels from the svg-rect input (no usable <rect fill="...">). Emit one <rect> per filled pixel on a 16x16 viewBox.');
108
- process.exit(1);
109
- }
110
-
111
- fs.mkdirSync(path.dirname(filepath), { recursive: true });
112
- fs.writeFileSync(filepath, serializeCompact(art), 'utf-8');
113
-
114
- const rel = path.relative(path.resolve(dir), filepath);
115
- console.log(`Wrote ${rel}`);
116
- }
117
-
118
- main().catch((e) => {
119
- console.error(e instanceof Error ? e.message : String(e));
120
- process.exit(1);
121
- });
File without changes
File without changes