castle-web-cli 0.4.151 → 0.4.153

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 (98) hide show
  1. package/dist/castle-host/host.js +11 -3
  2. package/dist/castleJson.d.ts +1 -0
  3. package/dist/castleJson.js +14 -0
  4. package/dist/ide.js +4 -0
  5. package/dist/imports.js +18 -12
  6. package/dist/init.js +28 -12
  7. package/dist/platformDoc.js +68 -0
  8. package/dist/save-deck.js +14 -9
  9. package/dist/serve.js +91 -18
  10. package/dist/serveSecurity.d.ts +6 -0
  11. package/dist/serveSecurity.js +38 -4
  12. package/dist/shell/assets/{index-Dlhc3eZW.js → index-DsDkYFvP.js} +2 -2
  13. package/dist/shell/index.html +1 -1
  14. package/kits/blank/castle.json +1 -1
  15. package/kits/blank/node_modules/.package-lock.json +13 -0
  16. package/kits/blank/node_modules/castle-web-fonts/README.md +114 -0
  17. package/kits/blank/node_modules/castle-web-fonts/dist/catalog.d.ts +18 -0
  18. package/kits/blank/node_modules/castle-web-fonts/dist/catalog.js +142 -0
  19. package/kits/blank/node_modules/castle-web-fonts/dist/face.d.ts +1 -0
  20. package/kits/blank/node_modules/castle-web-fonts/dist/face.js +52 -0
  21. package/kits/blank/node_modules/castle-web-fonts/dist/faces/Bore.d.ts +3 -0
  22. package/kits/blank/node_modules/castle-web-fonts/dist/faces/Bore.js +10 -0
  23. package/kits/blank/node_modules/castle-web-fonts/dist/faces/CourierPrime.d.ts +3 -0
  24. package/kits/blank/node_modules/castle-web-fonts/dist/faces/CourierPrime.js +10 -0
  25. package/kits/blank/node_modules/castle-web-fonts/dist/faces/DMSans.d.ts +3 -0
  26. package/kits/blank/node_modules/castle-web-fonts/dist/faces/DMSans.js +10 -0
  27. package/kits/blank/node_modules/castle-web-fonts/dist/faces/Glacier.d.ts +3 -0
  28. package/kits/blank/node_modules/castle-web-fonts/dist/faces/Glacier.js +10 -0
  29. package/kits/blank/node_modules/castle-web-fonts/dist/faces/HelicoCentrica.d.ts +3 -0
  30. package/kits/blank/node_modules/castle-web-fonts/dist/faces/HelicoCentrica.js +10 -0
  31. package/kits/blank/node_modules/castle-web-fonts/dist/faces/Piazzolla.d.ts +3 -0
  32. package/kits/blank/node_modules/castle-web-fonts/dist/faces/Piazzolla.js +10 -0
  33. package/kits/blank/node_modules/castle-web-fonts/dist/faces/Synco.d.ts +3 -0
  34. package/kits/blank/node_modules/castle-web-fonts/dist/faces/Synco.js +10 -0
  35. package/kits/blank/node_modules/castle-web-fonts/dist/faces/Tektur.d.ts +3 -0
  36. package/kits/blank/node_modules/castle-web-fonts/dist/faces/Tektur.js +10 -0
  37. package/kits/blank/node_modules/castle-web-fonts/dist/faces/YatraOne.d.ts +3 -0
  38. package/kits/blank/node_modules/castle-web-fonts/dist/faces/YatraOne.js +10 -0
  39. package/kits/blank/node_modules/castle-web-fonts/dist/index.d.ts +16 -0
  40. package/kits/blank/node_modules/castle-web-fonts/dist/index.js +15 -0
  41. package/kits/blank/node_modules/castle-web-fonts/licenses/CC-BY-ND-4.0.txt +393 -0
  42. package/kits/blank/node_modules/castle-web-fonts/licenses/FONTS.md +64 -0
  43. package/kits/blank/node_modules/castle-web-fonts/licenses/OFL-1.1.txt +95 -0
  44. package/kits/blank/node_modules/castle-web-fonts/package.json +47 -0
  45. package/kits/blank/node_modules/castle-web-fonts/woff2/Bore.woff2 +0 -0
  46. package/kits/blank/node_modules/castle-web-fonts/woff2/CourierPrime.woff2 +0 -0
  47. package/kits/blank/node_modules/castle-web-fonts/woff2/DMSans.woff2 +0 -0
  48. package/kits/blank/node_modules/castle-web-fonts/woff2/Glacier.woff2 +0 -0
  49. package/kits/blank/node_modules/castle-web-fonts/woff2/HelicoCentrica.woff2 +0 -0
  50. package/kits/blank/node_modules/castle-web-fonts/woff2/Piazzolla.woff2 +0 -0
  51. package/kits/blank/node_modules/castle-web-fonts/woff2/SOURCE.txt +2 -0
  52. package/kits/blank/node_modules/castle-web-fonts/woff2/Synco.woff2 +0 -0
  53. package/kits/blank/node_modules/castle-web-fonts/woff2/Tektur.woff2 +0 -0
  54. package/kits/blank/node_modules/castle-web-fonts/woff2/YatraOne.woff2 +0 -0
  55. package/kits/blank/package-lock.json +10 -1
  56. package/kits/blank/package.json +3 -1
  57. package/kits/physics-2d/CLAUDE.md +158 -40
  58. package/kits/physics-2d/castle.json +3 -2
  59. package/kits/physics-2d/editors/SingleEditor.jsx +52 -19
  60. package/kits/physics-2d/editors/StyleEditor.jsx +139 -40
  61. package/kits/physics-2d/editors/deckFont.js +88 -0
  62. package/kits/physics-2d/editors/fontPreview.js +66 -0
  63. package/kits/physics-2d/editors/styleEditor.module.css +30 -3
  64. package/kits/physics-2d/editors/styleTheme.js +13 -2
  65. package/kits/physics-2d/engine/ScenePlayer.jsx +17 -2
  66. package/kits/physics-2d/engine/SceneUI.jsx +8 -0
  67. package/kits/physics-2d/engine/files.js +20 -9
  68. package/kits/physics-2d/engine/fonts.js +79 -0
  69. package/kits/physics-2d/engine/scene.js +6 -0
  70. package/kits/physics-2d/fonts.generated.js +9 -0
  71. package/kits/physics-2d/main.jsx +11 -0
  72. package/kits/physics-2d/package-lock.json +8 -1
  73. package/kits/physics-2d/package.json +1 -0
  74. package/kits/physics-2d/theme.style +2 -1
  75. package/kits/physics-3d/castle.json +1 -1
  76. package/kits/physics-3d/engine3d/PxModelEditor.jsx +3 -4
  77. package/kits/physics-3d/engine3d/Scene3DEditor.jsx +12 -8
  78. package/kits/physics-3d/engine3d/editorChrome.jsx +11 -6
  79. package/kits/physics-3d/engine3d/modelFiles.js +4 -5
  80. package/kits/physics-3d/package-lock.json +8 -1
  81. package/kits/physics-3d/package.json +1 -0
  82. package/kits/tabletop/.prettierrc +8 -0
  83. package/kits/tabletop/CLAUDE.md +309 -0
  84. package/kits/tabletop/castle.json +34 -0
  85. package/kits/tabletop/index.html +20 -0
  86. package/kits/tabletop/main.jsx +8 -0
  87. package/kits/tabletop/package-lock.json +341 -0
  88. package/kits/tabletop/package.json +29 -0
  89. package/kits/tabletop/room.js +269 -0
  90. package/kits/tabletop/testing.js +569 -0
  91. package/package.json +1 -1
  92. package/kits/blank/.castle/agent/children.json +0 -1
  93. package/kits/blank/.castle/agent/messages.json +0 -9
  94. package/kits/blank/.castle/agent/pending-sends.json +0 -1
  95. package/kits/blank/.castle/agent/tasks/index.md +0 -2
  96. package/kits/blank/.castle/docs/platform.md +0 -36
  97. package/kits/blank/node_modules/.vite/deps/_metadata.json +0 -8
  98. package/kits/blank/node_modules/.vite/deps/package.json +0 -3
@@ -59,6 +59,7 @@ export class ServeSecurity {
59
59
  serveNonce = base32Lower(randomBytes(8));
60
60
  tickets = new Map();
61
61
  localContentPorts;
62
+ localContentHost = '127.0.0.1';
62
63
  constructor(publicPort, localContentPorts) {
63
64
  this.publicPort = publicPort;
64
65
  this.localContentPorts = localContentPorts ?? null;
@@ -70,6 +71,10 @@ export class ServeSecurity {
70
71
  throw new Error('edit and play content ports must be distinct');
71
72
  this.localContentPorts = ports;
72
73
  }
74
+ // The host a browser should use to reach deck content; see contentBindHost.
75
+ setLocalContentHost(host) {
76
+ this.localContentHost = host;
77
+ }
73
78
  authorizeHttp(req) {
74
79
  const value = req.headers['x-castle-serve-token'];
75
80
  return typeof value === 'string' && safeEqual(value, this.serveToken);
@@ -88,6 +93,17 @@ export class ServeSecurity {
88
93
  this.tickets.set(ticket, { endpoint, expiresAt: Date.now() + 30_000 });
89
94
  return ticket;
90
95
  }
96
+ /** One-use admission for an SDK that predates the shell's MessagePort bridge. */
97
+ issueLegacyContentTicket(role) {
98
+ this.pruneTickets();
99
+ const ticket = randomBytes(16).toString('base64url');
100
+ this.tickets.set(ticket, {
101
+ endpoint: 'legacy-content',
102
+ role,
103
+ expiresAt: Date.now() + 30_000,
104
+ });
105
+ return ticket;
106
+ }
91
107
  consumeTicket(req, endpoint) {
92
108
  this.pruneTickets();
93
109
  let ticket = '';
@@ -103,6 +119,26 @@ export class ServeSecurity {
103
119
  this.tickets.delete(ticket);
104
120
  return record.endpoint === endpoint && record.expiresAt > Date.now();
105
121
  }
122
+ /** Consume and recover the edit/play role bound to a legacy content ticket. */
123
+ consumeLegacyContentTicket(req) {
124
+ this.pruneTickets();
125
+ let ticket = '';
126
+ try {
127
+ ticket = new URL(req.url || '/', 'http://localhost').searchParams.get('ticket') || '';
128
+ }
129
+ catch {
130
+ return null;
131
+ }
132
+ const record = this.tickets.get(ticket);
133
+ if (!record)
134
+ return null;
135
+ this.tickets.delete(ticket);
136
+ return record.endpoint === 'legacy-content' &&
137
+ (record.role === 'edit' || record.role === 'play') &&
138
+ record.expiresAt > Date.now()
139
+ ? record.role
140
+ : null;
141
+ }
106
142
  pruneTickets() {
107
143
  const now = Date.now();
108
144
  for (const [ticket, record] of this.tickets) {
@@ -208,7 +244,7 @@ window.fetch=function(input,init){
208
244
  const port = this.localContentPorts?.[role];
209
245
  if (!port)
210
246
  throw new Error('local content ports are not configured');
211
- return `http://127.0.0.1:${port}`;
247
+ return `http://${this.localContentHost}:${port}`;
212
248
  }
213
249
  /** A short-lived play URL for one shared-browser admission attempt. */
214
250
  browserContentOrigin(role = 'play') {
@@ -216,9 +252,7 @@ window.fetch=function(input,init){
216
252
  if (!sandboxId || !/^[a-z0-9]{14}$/.test(sandboxId))
217
253
  return null;
218
254
  const env = process.env.CASTLE_SANDBOX_ENV === 'staging' ? 'staging' : 'prod';
219
- const domain = env === 'staging'
220
- ? 'sandboxes-staging.castlexyz.com'
221
- : 'sandboxes.castlexyz.com';
255
+ const domain = env === 'staging' ? 'sandboxes-staging.castlexyz.com' : 'sandboxes.castlexyz.com';
222
256
  const expiresAtSeconds = Math.floor(Date.now() / 1000) + BROWSER_GRANT_SECONDS;
223
257
  return `https://${this.mintContentLabel(role, sandboxId, expiresAtSeconds)}.${domain}`;
224
258
  }