castle-web-cli 0.4.115 → 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 (55) 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 +6 -0
  5. package/dist/castleJson.js +10 -0
  6. package/dist/editorConfig.js +27 -3
  7. package/dist/imports.d.ts +4 -0
  8. package/dist/imports.js +59 -10
  9. package/dist/init.d.ts +3 -0
  10. package/dist/init.js +99 -87
  11. package/dist/install.d.ts +1 -1
  12. package/dist/install.js +26 -24
  13. package/dist/shell/assets/{index-CUamb8rK.js → index-DiPlPGyg.js} +2 -2
  14. package/dist/shell/index.html +1 -1
  15. package/dist/vitePlugins.js +1 -1
  16. package/kits/physics-2d/CLAUDE.md +28 -16
  17. package/kits/physics-2d/behaviors/Joints.jsx +1 -1
  18. package/kits/physics-2d/behaviors/Sprite.jsx +17 -12
  19. package/kits/physics-2d/blueprints/ball.scene +1 -1
  20. package/kits/physics-2d/blueprints/block.scene +1 -1
  21. package/kits/physics-2d/blueprints/cauldron.scene +1 -1
  22. package/kits/physics-2d/blueprints/crate.scene +1 -1
  23. package/kits/physics-2d/castle.json +11 -3
  24. package/kits/physics-2d/docs/pxart-format.md +537 -51
  25. package/kits/physics-2d/editors/PxArtEditor.jsx +1794 -65
  26. package/kits/physics-2d/editors/brushFit.js +535 -0
  27. package/kits/physics-2d/editors/brushShapes.js +140 -0
  28. package/kits/physics-2d/editors/mediaFile.js +12 -1
  29. package/kits/physics-2d/editors/pathOverlay.js +340 -0
  30. package/kits/physics-2d/editors/pathTools.js +1906 -0
  31. package/kits/physics-2d/editors/pixelCanvas.js +13 -0
  32. package/kits/physics-2d/editors/pixelEditorChrome.jsx +2 -2
  33. package/kits/physics-2d/editors/pixelGeometry.js +4 -2
  34. package/kits/physics-2d/editors/pixelInspector.jsx +410 -37
  35. package/kits/physics-2d/editors/pxArtEditorModel.js +172 -16
  36. package/kits/physics-2d/editors/pxArtTimeline.jsx +163 -43
  37. package/kits/physics-2d/editors/pxArtTimeline.module.css +31 -5
  38. package/kits/physics-2d/engine/assets.js +1 -1
  39. package/kits/physics-2d/engine/blueprint.js +3 -3
  40. package/kits/physics-2d/engine/files.js +3 -1
  41. package/kits/physics-2d/engine/liveReload.js +1 -1
  42. package/kits/physics-2d/engine/physics/jointArt.js +3 -3
  43. package/kits/physics-2d/engine/pxart.js +153 -35
  44. package/kits/physics-2d/engine/pxartPath.js +1356 -0
  45. package/kits/physics-2d/engine/pxartSmooth.js +276 -125
  46. package/kits/physics-2d/engine/ui.jsx +22 -1
  47. package/kits/physics-2d/engine/ui.module.css +36 -12
  48. package/kits/physics-2d/package-lock.json +1 -1
  49. package/kits/physics-2d/scripts/draw.mjs +7 -7
  50. package/kits/physics-2d/scripts/import-svg.mjs +1231 -0
  51. package/kits/physics-2d/scripts/svg-emission-guide.md +92 -0
  52. package/package.json +1 -1
  53. /package/kits/physics-2d/drawings/{block.pxart → block.sprite} +0 -0
  54. /package/kits/physics-2d/drawings/{cauldron.pxart → cauldron.sprite} +0 -0
  55. /package/kits/physics-2d/drawings/{joint-rope.pxart → joint-rope.sprite} +0 -0
package/dist/install.js CHANGED
@@ -1,16 +1,27 @@
1
- import { execSync } from "child_process";
2
- import * as fs from "fs";
3
- import * as path from "path";
4
- import { restoreMissingImports, syncImportDependencies } from "./imports.js";
1
+ import { execSync, spawn } from 'child_process';
2
+ import * as fs from 'fs';
3
+ import * as path from 'path';
4
+ import { restoreMissingImports, syncImportDependencies } from './imports.js';
5
5
  function hasPnpm() {
6
6
  try {
7
- execSync("pnpm --version", { stdio: "ignore" });
7
+ execSync('pnpm --version', { stdio: 'ignore' });
8
8
  return true;
9
9
  }
10
10
  catch {
11
11
  return false;
12
12
  }
13
13
  }
14
+ // Run an install command without blocking the event loop. `installDeps` also runs
15
+ // INSIDE the serve (an import from the editor adds deps), and an `execSync` there
16
+ // would freeze vite, the file API and the serve websocket for the whole install --
17
+ // the editor would look hung, not busy.
18
+ function run(command, cwd) {
19
+ return new Promise((resolve, reject) => {
20
+ const child = spawn(command, { cwd, shell: true, stdio: 'inherit' });
21
+ child.on('error', reject);
22
+ child.on('close', (code) => code === 0 ? resolve() : reject(new Error(`\`${command}\` exited with code ${code}`)));
23
+ });
24
+ }
14
25
  // Install a deck's deps. Prefer pnpm -- in the e2b template a pnpm store is baked
15
26
  // in, so this is near-instant (hardlinks from the store, no download). Fall back to
16
27
  // npm when pnpm isn't on PATH (e.g. a laptop that never installed it).
@@ -18,15 +29,12 @@ function hasPnpm() {
18
29
  // scripts (pnpm 10+ gates them and exits non-zero otherwise, and the deck's deps are
19
30
  // all prebuilt pure JS that don't need them). `frozen` installs straight from the
20
31
  // shipped lockfile (skips resolution -> no network, fast + deterministic).
21
- export function installDeps(projectDir, frozen) {
32
+ export async function installDeps(projectDir, frozen) {
22
33
  if (hasPnpm()) {
23
- console.log("Installing deps (pnpm)...");
24
- const frozenFlag = frozen ? "--frozen-lockfile " : "";
34
+ console.log('Installing deps (pnpm)...');
35
+ const frozenFlag = frozen ? '--frozen-lockfile ' : '';
25
36
  try {
26
- execSync(`pnpm install ${frozenFlag}--prefer-offline --ignore-scripts`, {
27
- cwd: projectDir,
28
- stdio: "inherit",
29
- });
37
+ await run(`pnpm install ${frozenFlag}--prefer-offline --ignore-scripts`, projectDir);
30
38
  }
31
39
  catch (err) {
32
40
  if (!frozen)
@@ -36,19 +44,13 @@ export function installDeps(projectDir, frozen) {
36
44
  // wasn't regenerated). Rather than leave the deck with no node_modules,
37
45
  // retry with resolution allowed -- a little slower (re-resolves + may
38
46
  // fetch), but self-heals the drift instead of breaking.
39
- console.warn("Frozen install failed; retrying with resolution (lockfile drift?)...");
40
- execSync("pnpm install --prefer-offline --ignore-scripts", {
41
- cwd: projectDir,
42
- stdio: "inherit",
43
- });
47
+ console.warn('Frozen install failed; retrying with resolution (lockfile drift?)...');
48
+ await run('pnpm install --prefer-offline --ignore-scripts', projectDir);
44
49
  }
45
50
  }
46
51
  else {
47
- console.log("Installing deps (npm)...");
48
- execSync("npm install --no-audit --no-fund --loglevel=error", {
49
- cwd: projectDir,
50
- stdio: "inherit",
51
- });
52
+ console.log('Installing deps (npm)...');
53
+ await run('npm install --no-audit --no-fund --loglevel=error', projectDir);
52
54
  }
53
55
  }
54
56
  // `castle-web install <dir>`: put node_modules in place for a deck that already has
@@ -56,7 +58,7 @@ export function installDeps(projectDir, frozen) {
56
58
  // (the cloud hosts treat it as regenerable and don't snapshot it).
57
59
  export async function install(dir) {
58
60
  const projectDir = path.resolve(dir);
59
- if (!fs.existsSync(path.join(projectDir, "package.json"))) {
61
+ if (!fs.existsSync(path.join(projectDir, 'package.json'))) {
60
62
  console.error(`No package.json in ${projectDir}.`);
61
63
  process.exit(1);
62
64
  }
@@ -72,6 +74,6 @@ export async function install(dir) {
72
74
  const added = syncImportDependencies(projectDir);
73
75
  for (const dep of added)
74
76
  console.log(`Added dependency ${dep} from an import`);
75
- installDeps(projectDir, fs.existsSync(path.join(projectDir, "pnpm-lock.yaml")));
77
+ await installDeps(projectDir, fs.existsSync(path.join(projectDir, 'pnpm-lock.yaml')));
76
78
  console.log(`Installed deps in ${projectDir}`);
77
79
  }