castle-web-cli 0.4.114 → 0.4.116

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 (95) hide show
  1. package/dist/agent-prompts.js +2 -2
  2. package/dist/agent.d.ts +9 -9
  3. package/dist/agent.js +590 -589
  4. package/dist/castleJson.d.ts +7 -0
  5. package/dist/castleJson.js +10 -0
  6. package/dist/editorConfig.d.ts +34 -0
  7. package/dist/editorConfig.js +125 -0
  8. package/dist/ide.js +245 -120
  9. package/dist/imports.d.ts +10 -0
  10. package/dist/imports.js +149 -17
  11. package/dist/init.d.ts +3 -0
  12. package/dist/init.js +113 -88
  13. package/dist/install.d.ts +1 -1
  14. package/dist/install.js +26 -24
  15. package/dist/serve.js +16 -0
  16. package/dist/shell/assets/index-DiPlPGyg.js +144 -0
  17. package/dist/shell/assets/index-Y6cJRRCX.css +1 -0
  18. package/dist/shell/index.html +2 -2
  19. package/dist/unsupportedMedia.d.ts +1 -0
  20. package/dist/unsupportedMedia.js +54 -0
  21. package/dist/vitePlugins.js +13 -20
  22. package/kits/basic-2d/castle.json +1 -1
  23. package/kits/basic-2d/editors/behaviorRegistry.js +5 -7
  24. package/kits/physics-2d/CLAUDE.md +65 -34
  25. package/kits/physics-2d/{physics/behaviors → behaviors}/AnalogStick.jsx +3 -3
  26. package/kits/physics-2d/behaviors/Collider.jsx +1 -1
  27. package/kits/physics-2d/{physics/behaviors → behaviors}/Draggable.jsx +3 -3
  28. package/kits/physics-2d/{physics/behaviors → behaviors}/Joints.jsx +5 -5
  29. package/kits/physics-2d/{physics/behaviors → behaviors}/RigidBody.jsx +2 -2
  30. package/kits/physics-2d/{physics/behaviors → behaviors}/Slingshot.jsx +3 -3
  31. package/kits/physics-2d/behaviors/Sound.jsx +152 -0
  32. package/kits/physics-2d/behaviors/Sprite.jsx +112 -42
  33. package/kits/physics-2d/behaviors/Tone.jsx +83 -0
  34. package/kits/physics-2d/behaviors/Video.jsx +111 -0
  35. package/kits/physics-2d/behaviors/tint.js +24 -9
  36. package/kits/physics-2d/blueprints/ball.scene +1 -1
  37. package/kits/physics-2d/blueprints/block.scene +1 -1
  38. package/kits/physics-2d/blueprints/cauldron.scene +1 -1
  39. package/kits/physics-2d/blueprints/crate.scene +1 -1
  40. package/kits/physics-2d/castle.json +74 -4
  41. package/kits/physics-2d/docs/pxart-format.md +537 -51
  42. package/kits/physics-2d/editors/BlueprintLibrary.jsx +7 -3
  43. package/kits/physics-2d/editors/ImageViewer.jsx +206 -0
  44. package/kits/physics-2d/editors/MediaPlayer.jsx +57 -0
  45. package/kits/physics-2d/editors/PxArtEditor.jsx +1794 -65
  46. package/kits/physics-2d/editors/SceneEditor.jsx +7 -3
  47. package/kits/physics-2d/editors/SingleEditor.jsx +8 -0
  48. package/kits/physics-2d/editors/behaviorRegistry.js +5 -7
  49. package/kits/physics-2d/editors/brushFit.js +535 -0
  50. package/kits/physics-2d/editors/brushShapes.js +140 -0
  51. package/kits/physics-2d/editors/mediaFile.js +31 -0
  52. package/kits/physics-2d/editors/mediaViewer.module.css +128 -0
  53. package/kits/physics-2d/editors/pathOverlay.js +340 -0
  54. package/kits/physics-2d/editors/pathTools.js +1906 -0
  55. package/kits/physics-2d/editors/pixelCanvas.js +13 -0
  56. package/kits/physics-2d/editors/pixelEditorChrome.jsx +2 -2
  57. package/kits/physics-2d/editors/pixelGeometry.js +4 -2
  58. package/kits/physics-2d/editors/pixelInspector.jsx +410 -37
  59. package/kits/physics-2d/editors/pxArtEditorModel.js +172 -16
  60. package/kits/physics-2d/editors/pxArtTimeline.jsx +163 -43
  61. package/kits/physics-2d/editors/pxArtTimeline.module.css +31 -5
  62. package/kits/physics-2d/engine/ScenePlayer.jsx +1 -0
  63. package/kits/physics-2d/engine/art.js +105 -0
  64. package/kits/physics-2d/engine/assets.js +12 -4
  65. package/kits/physics-2d/engine/audioContext.js +34 -0
  66. package/kits/physics-2d/engine/blueprint.js +3 -3
  67. package/kits/physics-2d/engine/collider.js +28 -17
  68. package/kits/physics-2d/engine/files.js +77 -1
  69. package/kits/physics-2d/engine/liveReload.js +1 -1
  70. package/kits/physics-2d/engine/media.js +212 -0
  71. package/kits/physics-2d/{physics → engine/physics}/PhysicsSystem.js +1 -1
  72. package/kits/physics-2d/{physics → engine/physics}/jointArt.js +3 -4
  73. package/kits/physics-2d/{physics → engine/physics}/matterBridge.js +2 -9
  74. package/kits/physics-2d/engine/pxart.js +153 -35
  75. package/kits/physics-2d/engine/pxartPath.js +1356 -0
  76. package/kits/physics-2d/engine/pxartSmooth.js +276 -125
  77. package/kits/physics-2d/engine/scene.js +12 -0
  78. package/kits/physics-2d/engine/tone.js +112 -0
  79. package/kits/physics-2d/engine/ui.jsx +22 -1
  80. package/kits/physics-2d/engine/ui.module.css +36 -12
  81. package/kits/physics-2d/package-lock.json +1 -1
  82. package/kits/physics-2d/scripts/draw.mjs +7 -7
  83. package/kits/physics-2d/scripts/import-svg.mjs +1231 -0
  84. package/kits/physics-2d/scripts/svg-emission-guide.md +92 -0
  85. package/kits/physics-2d/systems/media.js +34 -0
  86. package/kits/physics-2d/systems/physics.js +12 -3
  87. package/package.json +1 -1
  88. package/dist/shell/assets/index-CqpY1xZR.js +0 -144
  89. package/dist/shell/assets/index-DCwVFL5u.css +0 -1
  90. package/kits/physics-2d/physics/index.js +0 -26
  91. /package/kits/physics-2d/drawings/{block.pxart → block.sprite} +0 -0
  92. /package/kits/physics-2d/drawings/{cauldron.pxart → cauldron.sprite} +0 -0
  93. /package/kits/physics-2d/drawings/{joint-rope.pxart → joint-rope.sprite} +0 -0
  94. /package/kits/physics-2d/{physics → engine/physics}/controls.js +0 -0
  95. /package/kits/physics-2d/{physics → engine/physics}/joints.js +0 -0
@@ -5,6 +5,7 @@ import {
5
5
  faArrowsAltH,
6
6
  faArrowsAltV,
7
7
  faBars,
8
+ faBezierCurve,
8
9
  faChevronDown,
9
10
  faChevronRight,
10
11
  faChevronUp,
@@ -12,6 +13,8 @@ import {
12
13
  faClone,
13
14
  faCode,
14
15
  faCodeBranch,
16
+ faDotCircle,
17
+ faDrawPolygon,
15
18
  faEraser,
16
19
  faExpand,
17
20
  faExternalLinkAlt,
@@ -22,9 +25,12 @@ import {
22
25
  faGlobe,
23
26
  faImage,
24
27
  faLayerGroup,
28
+ faLocationArrow,
25
29
  faObjectGroup,
30
+ faPaintBrush,
26
31
  faPalette,
27
32
  faPencilAlt,
33
+ faPenNib,
28
34
  faPlay,
29
35
  faPlus,
30
36
  faRedo,
@@ -37,6 +43,7 @@ import {
37
43
  faStamp,
38
44
  faStop,
39
45
  faSyncAlt,
46
+ faTh,
40
47
  faTimes,
41
48
  faTrash,
42
49
  faUndo,
@@ -190,6 +197,7 @@ export function IconButton({ icon, label, active = false, variant = '', ...props
190
197
  }
191
198
  const icons = {
192
199
  bars: faBars,
200
+ 'bezier-curve': faBezierCurve,
193
201
  camera: faVideo,
194
202
  'chevron-down': faChevronDown,
195
203
  'chevron-right': faChevronRight,
@@ -199,6 +207,8 @@ const icons = {
199
207
  code: faCode,
200
208
  // FA5 has no faCodeFork (that's the FA6 name); faCodeBranch is the fork glyph.
201
209
  'code-fork': faCodeBranch,
210
+ 'dot-circle': faDotCircle,
211
+ 'draw-polygon': faDrawPolygon,
202
212
  eraser: faEraser,
203
213
  expand: faExpand,
204
214
  external: faExternalLinkAlt,
@@ -209,13 +219,18 @@ const icons = {
209
219
  file: faFile,
210
220
  film: faFilm,
211
221
  globe: faGlobe,
222
+ grid: faTh,
212
223
  image: faImage,
213
224
  'layer-group': faLayerGroup,
225
+ // FA's location-arrow points up-right; flip it for a path-select cursor feel.
226
+ 'location-arrow': { ...faLocationArrow, flipX: true },
214
227
  marquee: faVectorSquare,
215
228
  move: faArrowsAlt,
216
229
  'object-group': faObjectGroup,
230
+ paintbrush: faPaintBrush,
217
231
  palette: faPalette,
218
232
  pencil: faPencilAlt,
233
+ 'pen-nib': faPenNib,
219
234
  play: faPlay,
220
235
  plus: faPlus,
221
236
  redo: faRedo,
@@ -244,7 +259,13 @@ export function Icon({ name }) {
244
259
  <svg
245
260
  viewBox={`0 0 ${width} ${height}`}
246
261
  aria-hidden="true"
247
- style={{ width: '1em', height: '1em', display: 'inline-block', fill: 'currentColor' }}>
262
+ style={{
263
+ width: '1em',
264
+ height: '1em',
265
+ display: 'inline-block',
266
+ fill: 'currentColor',
267
+ ...(def.flipX ? { transform: 'scaleX(-1)' } : {}),
268
+ }}>
248
269
  <path d={d} />
249
270
  </svg>
250
271
  );
@@ -1591,7 +1591,7 @@
1591
1591
  color: var(--castle-inspector-muted);
1592
1592
  }
1593
1593
 
1594
- .cornerRadiusBar {
1594
+ .finishBar {
1595
1595
  display: flex;
1596
1596
  align-items: center;
1597
1597
  gap: 6px;
@@ -1600,21 +1600,23 @@
1600
1600
  color: var(--castle-inspector-muted);
1601
1601
  }
1602
1602
 
1603
- /* Corner-radius segmented control (0 / ¼ / ½) — same bordered-row-of-
1604
- buttons pattern as .drawingShapeModeRow, sized for short text labels
1605
- instead of square glyph buttons. */
1606
- .cornerRadiusSegments {
1603
+ /* Finish segmented control (square / ¼ / ½ / circle) — bordered row of
1604
+ short text + icon segments. */
1605
+ .finishSegments {
1607
1606
  display: flex;
1608
1607
  border: 1px solid var(--castle-inspector-border);
1609
1608
  border-radius: var(--castle-radius);
1610
1609
  overflow: hidden;
1611
1610
  }
1612
1611
 
1613
- .cornerRadiusSegments > * + * {
1612
+ .finishSegments > * + * {
1614
1613
  border-left: 1px solid var(--castle-inspector-border);
1615
1614
  }
1616
1615
 
1617
- .cornerRadiusSegment {
1616
+ .finishSegment {
1617
+ display: inline-flex;
1618
+ align-items: center;
1619
+ justify-content: center;
1618
1620
  min-width: 28px;
1619
1621
  padding: 3px 8px;
1620
1622
  border: 0;
@@ -1626,15 +1628,15 @@
1626
1628
  line-height: 1.35;
1627
1629
  }
1628
1630
 
1629
- .cornerRadiusSegment:hover {
1631
+ .finishSegment:hover {
1630
1632
  background: var(--castle-inspector-input-bg);
1631
1633
  }
1632
1634
 
1633
- /* Compound selector (not a bare `.cornerRadiusSegmentOn`) for the same reason
1635
+ /* Compound selector (not a bare `.finishSegmentOn`) for the same reason
1634
1636
  documented above `.drawingToolButton.drawingToolSelected`: it must beat
1635
- `.cornerRadiusSegment:hover` on specificity no matter source order. */
1636
- .cornerRadiusSegment.cornerRadiusSegmentOn,
1637
- .cornerRadiusSegment.cornerRadiusSegmentOn:hover {
1637
+ `.finishSegment:hover` on specificity no matter source order. */
1638
+ .finishSegment.finishSegmentOn,
1639
+ .finishSegment.finishSegmentOn:hover {
1638
1640
  background: var(--castle-selected);
1639
1641
  color: var(--castle-selected-ink);
1640
1642
  }
@@ -1873,6 +1875,7 @@
1873
1875
  height: 100%;
1874
1876
  pointer-events: none;
1875
1877
  z-index: -1;
1878
+ image-rendering: auto;
1876
1879
  }
1877
1880
 
1878
1881
  .drawingCanvas {
@@ -1888,6 +1891,19 @@
1888
1891
  outline: none;
1889
1892
  }
1890
1893
 
1894
+ /* Smooth/rounded finish: the main canvas is transparent (smooth layer below).
1895
+ Pixelated upscaling of the native grid would paint a visible cell lattice
1896
+ over the whole artboard — use auto scaling instead. */
1897
+ .drawingCanvasSmooth {
1898
+ image-rendering: auto;
1899
+ position: absolute;
1900
+ inset: 0;
1901
+ width: 100%;
1902
+ height: 100%;
1903
+ flex: 0 0 auto;
1904
+ outline: none;
1905
+ }
1906
+
1891
1907
  .palette {
1892
1908
  display: grid;
1893
1909
  grid-template-columns: repeat(12, minmax(0, 1fr));
@@ -2010,6 +2026,14 @@
2010
2026
  color: var(--castle-selected-ink);
2011
2027
  }
2012
2028
 
2029
+ /* Groups of shape-action rows (fill/stroke · transform · punch/delete). */
2030
+ .drawingShapeModeGroups {
2031
+ display: flex;
2032
+ flex-wrap: wrap;
2033
+ gap: 8px;
2034
+ align-items: flex-start;
2035
+ }
2036
+
2013
2037
  /* Horizontal segmented row of shape sub-mode buttons in the wide-layout Tool
2014
2038
  Settings panel. Reuses .drawingToolButton glyph buttons with shared borders. */
2015
2039
  .drawingShapeModeRow {
@@ -28,7 +28,7 @@
28
28
  },
29
29
  "../../sdk": {
30
30
  "name": "castle-web-sdk",
31
- "version": "0.4.11",
31
+ "version": "0.4.12",
32
32
  "devDependencies": {
33
33
  "eslint": "^9.0.0",
34
34
  "jscpd": "^4.0.5",
@@ -2,7 +2,7 @@
2
2
  //
3
3
  // Reads an <svg> with one <rect> per pixel from stdin (or `--from <file>`),
4
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).
5
+ // single-frame `drawings/<name>.sprite` in the deck (the script's cwd).
6
6
  //
7
7
  // This is a kit-layer concern: the `.pxart` format lives entirely in the kit
8
8
  // (engine/pxart.js); the harness has no knowledge of it.
@@ -31,19 +31,19 @@ function readStdin() {
31
31
  });
32
32
  }
33
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
34
+ // Normalize a requested sprite name into a relative `drawings/<...>.sprite`
35
+ // path. Tolerates a leading `drawings/` and/or a trailing `.sprite`/`.pxart`/`.px.json`
36
+ // so `draw ship`, `draw ship.sprite`, and `draw drawings/ship.pxart` all land in
37
37
  // the same place.
38
38
  function resolveSpritePath(dir, name) {
39
39
  let rel = name.trim().replace(/\\/g, '/');
40
40
  rel = rel.replace(/^\.?\/*/, '');
41
41
  if (rel.startsWith('drawings/')) rel = rel.slice('drawings/'.length);
42
- rel = rel.replace(/\.px\.json$/i, '').replace(/\.pxart$/i, '');
42
+ rel = rel.replace(/\.px\.json$/i, '').replace(/\.(?:pxart|sprite)$/i, '');
43
43
  if (!rel) return null;
44
44
 
45
45
  const drawingsDir = path.resolve(dir, 'drawings');
46
- const filepath = path.resolve(drawingsDir, `${rel}.pxart`);
46
+ const filepath = path.resolve(drawingsDir, `${rel}.sprite`);
47
47
  const within = path.relative(drawingsDir, filepath);
48
48
  if (within.startsWith('..') || path.isAbsolute(within)) return null;
49
49
  return filepath;
@@ -72,7 +72,7 @@ function positionals() {
72
72
  async function main() {
73
73
  const name = positionals()[0];
74
74
  if (!name) {
75
- console.error('Usage: npm run draw -- <name> [--from FILE] (svg-rect on stdin -> drawings/<name>.pxart)');
75
+ console.error('Usage: npm run draw -- <name> [--from FILE] (svg-rect on stdin -> drawings/<name>.sprite)');
76
76
  process.exit(1);
77
77
  }
78
78