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.
- package/dist/castleJson.d.ts +2 -0
- package/dist/castleJson.js +39 -0
- package/dist/headlessCover.d.ts +13 -0
- package/dist/headlessCover.js +99 -0
- package/dist/ide.js +12 -42
- package/dist/imports.js +42 -2
- package/dist/index.js +1 -9
- package/dist/init.d.ts +1 -0
- package/dist/init.js +15 -1
- package/dist/preview.d.ts +0 -1
- package/dist/preview.js +0 -58
- package/dist/save-deck.js +52 -1
- package/dist/serve.js +16 -0
- package/dist/shell/assets/Basteleur-Bold-CK8LF7Pt.woff +0 -0
- package/dist/shell/assets/Basteleur-Bold-DKFKedNb.woff2 +0 -0
- package/dist/shell/assets/index-BfOPkSej.css +1 -0
- package/dist/shell/assets/index-u0nYFqbF.js +434 -0
- package/dist/shell/index.html +2 -2
- package/kits/physics-2d/CLAUDE.md +2 -2
- package/kits/physics-2d/castle.json +10 -2
- package/kits/physics-2d/docs/pxart-format.md +33 -26
- package/kits/physics-2d/editors/PxArtEditor.jsx +120 -49
- package/kits/physics-2d/editors/SingleEditor.jsx +6 -3
- package/kits/physics-2d/editors/StyleEditor.jsx +95 -0
- package/kits/physics-2d/editors/pathOverlay.js +1 -1
- package/kits/physics-2d/editors/pathTools.js +9 -1
- package/kits/physics-2d/editors/pixelGeometry.js +14 -13
- package/kits/physics-2d/editors/pixelInspector.jsx +202 -53
- package/kits/physics-2d/editors/pxArtEditorModel.js +8 -63
- package/kits/physics-2d/editors/pxArtTools.js +3 -43
- package/kits/physics-2d/editors/styleEditor.module.css +105 -0
- package/kits/physics-2d/editors/styleTheme.js +16 -0
- package/kits/physics-2d/engine/files.js +2 -1
- package/kits/physics-2d/engine/liveReload.js +4 -3
- package/kits/physics-2d/engine/palettes.js +636 -0
- package/kits/physics-2d/engine/pxart.js +6 -6
- package/kits/physics-2d/engine/svgImport.js +1056 -0
- package/kits/physics-2d/engine/ui.jsx +2 -0
- package/kits/physics-2d/engine/ui.module.css +54 -9
- package/kits/physics-2d/package-lock.json +1 -1
- package/kits/physics-2d/package.json +1 -0
- package/kits/physics-2d/scripts/deckTheme.mjs +25 -0
- package/kits/physics-2d/scripts/draw.mjs +5 -3
- package/kits/physics-2d/scripts/import-svg.mjs +16 -1069
- package/kits/physics-2d/scripts/palette.mjs +10 -0
- package/kits/physics-2d/scripts/svg-emission-guide.md +5 -3
- package/kits/physics-2d/theme.style +3 -0
- package/package.json +1 -1
- package/dist/shell/assets/index-CARLHafh.css +0 -1
- 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
|
-
|
|
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(
|
|
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
|
|
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(
|
|
1911
|
-
gap:
|
|
1948
|
+
grid-template-columns: repeat(8, 24px);
|
|
1949
|
+
gap: 1px;
|
|
1912
1950
|
padding-bottom: 12px;
|
|
1913
1951
|
}
|
|
1914
1952
|
|
|
1915
1953
|
.swatch {
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
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
|
|
1974
|
+
0 0 0 1px var(--castle-black);
|
|
1930
1975
|
}
|
|
1931
1976
|
|
|
1932
1977
|
.drawingToolStrip {
|
|
@@ -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
|
|
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
|
|
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) => {
|