castle-web-cli 0.4.123 → 0.4.124

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 (50) hide show
  1. package/dist/castleJson.d.ts +2 -0
  2. package/dist/castleJson.js +39 -0
  3. package/dist/headlessCover.d.ts +13 -0
  4. package/dist/headlessCover.js +99 -0
  5. package/dist/ide.js +12 -42
  6. package/dist/imports.js +42 -2
  7. package/dist/index.js +1 -9
  8. package/dist/init.d.ts +1 -0
  9. package/dist/init.js +15 -1
  10. package/dist/preview.d.ts +0 -1
  11. package/dist/preview.js +0 -58
  12. package/dist/save-deck.js +52 -1
  13. package/dist/serve.js +16 -0
  14. package/dist/shell/assets/Basteleur-Bold-CK8LF7Pt.woff +0 -0
  15. package/dist/shell/assets/Basteleur-Bold-DKFKedNb.woff2 +0 -0
  16. package/dist/shell/assets/index-BfOPkSej.css +1 -0
  17. package/dist/shell/assets/index-u0nYFqbF.js +434 -0
  18. package/dist/shell/index.html +2 -2
  19. package/kits/physics-2d/CLAUDE.md +2 -2
  20. package/kits/physics-2d/castle.json +10 -2
  21. package/kits/physics-2d/docs/pxart-format.md +33 -26
  22. package/kits/physics-2d/editors/PxArtEditor.jsx +120 -49
  23. package/kits/physics-2d/editors/SingleEditor.jsx +6 -3
  24. package/kits/physics-2d/editors/StyleEditor.jsx +95 -0
  25. package/kits/physics-2d/editors/pathOverlay.js +1 -1
  26. package/kits/physics-2d/editors/pathTools.js +9 -1
  27. package/kits/physics-2d/editors/pixelGeometry.js +14 -13
  28. package/kits/physics-2d/editors/pixelInspector.jsx +202 -53
  29. package/kits/physics-2d/editors/pxArtEditorModel.js +8 -63
  30. package/kits/physics-2d/editors/pxArtTools.js +3 -43
  31. package/kits/physics-2d/editors/styleEditor.module.css +105 -0
  32. package/kits/physics-2d/editors/styleTheme.js +16 -0
  33. package/kits/physics-2d/engine/files.js +2 -1
  34. package/kits/physics-2d/engine/liveReload.js +4 -3
  35. package/kits/physics-2d/engine/palettes.js +636 -0
  36. package/kits/physics-2d/engine/pxart.js +6 -6
  37. package/kits/physics-2d/engine/svgImport.js +1056 -0
  38. package/kits/physics-2d/engine/ui.jsx +2 -0
  39. package/kits/physics-2d/engine/ui.module.css +54 -9
  40. package/kits/physics-2d/package-lock.json +1 -1
  41. package/kits/physics-2d/package.json +1 -0
  42. package/kits/physics-2d/scripts/deckTheme.mjs +25 -0
  43. package/kits/physics-2d/scripts/draw.mjs +5 -3
  44. package/kits/physics-2d/scripts/import-svg.mjs +16 -1069
  45. package/kits/physics-2d/scripts/palette.mjs +10 -0
  46. package/kits/physics-2d/scripts/svg-emission-guide.md +5 -3
  47. package/kits/physics-2d/theme.style +3 -0
  48. package/package.json +1 -1
  49. package/dist/shell/assets/index-CARLHafh.css +0 -1
  50. package/dist/shell/assets/index-DWgt4KzC.js +0 -434
@@ -7,6 +7,7 @@ import {
7
7
  faBars,
8
8
  faBezierCurve,
9
9
  faChevronDown,
10
+ faChevronLeft,
10
11
  faChevronRight,
11
12
  faChevronUp,
12
13
  faCircle,
@@ -200,6 +201,7 @@ const icons = {
200
201
  'bezier-curve': faBezierCurve,
201
202
  camera: faVideo,
202
203
  'chevron-down': faChevronDown,
204
+ 'chevron-left': faChevronLeft,
203
205
  'chevron-right': faChevronRight,
204
206
  'chevron-up': faChevronUp,
205
207
  circle: faCircle,
@@ -1504,7 +1504,8 @@
1504
1504
  }
1505
1505
 
1506
1506
  .drawingEditor {
1507
- grid-template-columns: minmax(320px, 1fr) minmax(50px, 250px);
1507
+ /* 8*24 + 7*1 + 2*16 content, plus the inspector's 1px left divider. */
1508
+ grid-template-columns: minmax(320px, 1fr) 232px;
1508
1509
  grid-template-rows: minmax(0, 1fr);
1509
1510
  }
1510
1511
 
@@ -1795,11 +1796,11 @@
1795
1796
  .palettePopover {
1796
1797
  position: fixed;
1797
1798
  z-index: 200;
1798
- width: min(280px, calc(100vw - 16px));
1799
+ width: min(231px, calc(100vw - 16px));
1799
1800
  max-height: min(420px, calc(100vh - 16px));
1800
1801
  box-sizing: border-box;
1801
1802
  overflow: auto;
1802
- padding: 12px 14px 14px;
1803
+ padding: 12px 16px 14px;
1803
1804
  border: 1px solid var(--castle-inspector-border);
1804
1805
  border-radius: var(--castle-radius);
1805
1806
  background: var(--castle-workspace-bg);
@@ -1905,17 +1906,59 @@
1905
1906
  outline: none;
1906
1907
  }
1907
1908
 
1909
+ .paletteFullNote {
1910
+ font-size: 11px;
1911
+ color: #c44;
1912
+ padding: 0 0 8px;
1913
+ }
1914
+
1915
+ .paletteSpriteRow {
1916
+ display: flex;
1917
+ flex-wrap: wrap;
1918
+ gap: 1px;
1919
+ padding-bottom: 8px;
1920
+ }
1921
+
1922
+ .palettePager {
1923
+ display: flex;
1924
+ align-items: center;
1925
+ gap: 8px;
1926
+ padding: 2px 0 6px;
1927
+ }
1928
+
1929
+ .palettePagerName {
1930
+ flex: 1;
1931
+ min-width: 0;
1932
+ font-size: 12px;
1933
+ font-weight: 600;
1934
+ color: var(--castle-inspector-text);
1935
+ overflow: hidden;
1936
+ text-overflow: ellipsis;
1937
+ white-space: nowrap;
1938
+ }
1939
+
1940
+ .palettePagerBtns {
1941
+ display: flex;
1942
+ gap: 4px;
1943
+ margin-left: auto;
1944
+ }
1945
+
1908
1946
  .palette {
1909
1947
  display: grid;
1910
- grid-template-columns: repeat(12, minmax(0, 1fr));
1911
- gap: 4px;
1948
+ grid-template-columns: repeat(8, 24px);
1949
+ gap: 1px;
1912
1950
  padding-bottom: 12px;
1913
1951
  }
1914
1952
 
1915
1953
  .swatch {
1916
- aspect-ratio: 1;
1917
- border: 1px solid var(--castle-inspector-border);
1918
- border-radius: var(--castle-radius);
1954
+ box-sizing: border-box;
1955
+ width: 24px;
1956
+ height: 24px;
1957
+ flex: 0 0 24px;
1958
+ padding: 0;
1959
+ border: 0;
1960
+ border-radius: 0;
1961
+ appearance: none;
1919
1962
  cursor: pointer;
1920
1963
  }
1921
1964
 
@@ -1923,10 +1966,12 @@
1923
1966
  outside — so the selection stays legible over ANY of the 64 swatch colors
1924
1967
  (a single-color border can vanish against a similar swatch). */
1925
1968
  .swatchSelected {
1969
+ position: relative;
1970
+ z-index: 1;
1926
1971
  border-color: transparent;
1927
1972
  box-shadow:
1928
1973
  inset 0 0 0 2px #fff,
1929
- 0 0 0 2px var(--castle-black);
1974
+ 0 0 0 1px var(--castle-black);
1930
1975
  }
1931
1976
 
1932
1977
  .drawingToolStrip {
@@ -28,7 +28,7 @@
28
28
  },
29
29
  "../../sdk": {
30
30
  "name": "castle-web-sdk",
31
- "version": "0.4.12",
31
+ "version": "0.4.14",
32
32
  "devDependencies": {
33
33
  "eslint": "^9.0.0",
34
34
  "jscpd": "^4.0.5",
@@ -4,6 +4,7 @@
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "draw": "node scripts/draw.mjs",
7
+ "palette": "node scripts/palette.mjs",
7
8
  "restart": "node ../../cli/dist/index.js restart .",
8
9
  "screenshot": "node ../../cli/dist/index.js screenshot .",
9
10
  "check": "eslint . && jscpd && node --input-type=module -e \"const { bundleProject } = await import('../../cli/dist/bundle.js'); await bundleProject('.');\""
@@ -0,0 +1,25 @@
1
+ // Shared cwd theme.style reader for generation scripts.
2
+ import * as fs from 'fs';
3
+ import * as path from 'path';
4
+ import {
5
+ THEME_STYLE_PATH,
6
+ parseThemeData,
7
+ resolveDeckPalette,
8
+ agentPaletteFor,
9
+ isDefaultDeckPalette,
10
+ } from '../engine/palettes.js';
11
+
12
+ export function loadDeckTheme(dir = process.cwd()) {
13
+ let data = null;
14
+ try {
15
+ data = parseThemeData(fs.readFileSync(path.join(dir, THEME_STYLE_PATH), 'utf8'));
16
+ } catch {
17
+ data = null;
18
+ }
19
+ const deck = resolveDeckPalette(data);
20
+ return { deck, agent: agentPaletteFor(deck.colors), isDefault: isDefaultDeckPalette(deck) };
21
+ }
22
+
23
+ export function formatPaletteLine(deck, agent) {
24
+ return `${deck.name} (${agent.length}): ${agent.join(' ')}`;
25
+ }
@@ -1,7 +1,7 @@
1
1
  // `npm run draw -- <name>` — turn a terse svg-rect emission into a sprite.
2
2
  //
3
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
4
+ // decodes + palette-quantizes it onto the deck's generation palette, and writes a
5
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
@@ -12,9 +12,9 @@ import * as path from 'path';
12
12
  import {
13
13
  svgRectToPxArt,
14
14
  serializeCompact,
15
- AGENT_PALETTE_16,
16
15
  DEFAULT_RESOLUTION,
17
16
  } from '../engine/pxart.js';
17
+ import { formatPaletteLine, loadDeckTheme } from './deckTheme.mjs';
18
18
 
19
19
  // Read all of stdin as a UTF-8 string. Resolves '' if stdin is a TTY with no
20
20
  // piped input so we can give a clear "no input" error instead of hanging.
@@ -102,7 +102,8 @@ async function main() {
102
102
  process.exit(1);
103
103
  }
104
104
 
105
- const art = svgRectToPxArt(svg, { resolution: DEFAULT_RESOLUTION, palette: AGENT_PALETTE_16 });
105
+ const { deck, agent, isDefault } = loadDeckTheme(dir);
106
+ const art = svgRectToPxArt(svg, { resolution: DEFAULT_RESOLUTION, palette: agent });
106
107
  if (!art) {
107
108
  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
109
  process.exit(1);
@@ -113,6 +114,7 @@ async function main() {
113
114
 
114
115
  const rel = path.relative(path.resolve(dir), filepath);
115
116
  console.log(`Wrote ${rel}`);
117
+ if (!isDefault) console.log(`Palette: ${formatPaletteLine(deck, agent)}`);
116
118
  }
117
119
 
118
120
  main().catch((e) => {