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.
- package/dist/castle-host/host.js +11 -3
- package/dist/castleJson.d.ts +1 -0
- package/dist/castleJson.js +14 -0
- package/dist/ide.js +4 -0
- package/dist/imports.js +18 -12
- package/dist/init.js +28 -12
- package/dist/platformDoc.js +68 -0
- package/dist/save-deck.js +14 -9
- package/dist/serve.js +91 -18
- package/dist/serveSecurity.d.ts +6 -0
- package/dist/serveSecurity.js +38 -4
- package/dist/shell/assets/{index-Dlhc3eZW.js → index-DsDkYFvP.js} +2 -2
- package/dist/shell/index.html +1 -1
- package/kits/blank/castle.json +1 -1
- package/kits/blank/node_modules/.package-lock.json +13 -0
- package/kits/blank/node_modules/castle-web-fonts/README.md +114 -0
- package/kits/blank/node_modules/castle-web-fonts/dist/catalog.d.ts +18 -0
- package/kits/blank/node_modules/castle-web-fonts/dist/catalog.js +142 -0
- package/kits/blank/node_modules/castle-web-fonts/dist/face.d.ts +1 -0
- package/kits/blank/node_modules/castle-web-fonts/dist/face.js +52 -0
- package/kits/blank/node_modules/castle-web-fonts/dist/faces/Bore.d.ts +3 -0
- package/kits/blank/node_modules/castle-web-fonts/dist/faces/Bore.js +10 -0
- package/kits/blank/node_modules/castle-web-fonts/dist/faces/CourierPrime.d.ts +3 -0
- package/kits/blank/node_modules/castle-web-fonts/dist/faces/CourierPrime.js +10 -0
- package/kits/blank/node_modules/castle-web-fonts/dist/faces/DMSans.d.ts +3 -0
- package/kits/blank/node_modules/castle-web-fonts/dist/faces/DMSans.js +10 -0
- package/kits/blank/node_modules/castle-web-fonts/dist/faces/Glacier.d.ts +3 -0
- package/kits/blank/node_modules/castle-web-fonts/dist/faces/Glacier.js +10 -0
- package/kits/blank/node_modules/castle-web-fonts/dist/faces/HelicoCentrica.d.ts +3 -0
- package/kits/blank/node_modules/castle-web-fonts/dist/faces/HelicoCentrica.js +10 -0
- package/kits/blank/node_modules/castle-web-fonts/dist/faces/Piazzolla.d.ts +3 -0
- package/kits/blank/node_modules/castle-web-fonts/dist/faces/Piazzolla.js +10 -0
- package/kits/blank/node_modules/castle-web-fonts/dist/faces/Synco.d.ts +3 -0
- package/kits/blank/node_modules/castle-web-fonts/dist/faces/Synco.js +10 -0
- package/kits/blank/node_modules/castle-web-fonts/dist/faces/Tektur.d.ts +3 -0
- package/kits/blank/node_modules/castle-web-fonts/dist/faces/Tektur.js +10 -0
- package/kits/blank/node_modules/castle-web-fonts/dist/faces/YatraOne.d.ts +3 -0
- package/kits/blank/node_modules/castle-web-fonts/dist/faces/YatraOne.js +10 -0
- package/kits/blank/node_modules/castle-web-fonts/dist/index.d.ts +16 -0
- package/kits/blank/node_modules/castle-web-fonts/dist/index.js +15 -0
- package/kits/blank/node_modules/castle-web-fonts/licenses/CC-BY-ND-4.0.txt +393 -0
- package/kits/blank/node_modules/castle-web-fonts/licenses/FONTS.md +64 -0
- package/kits/blank/node_modules/castle-web-fonts/licenses/OFL-1.1.txt +95 -0
- package/kits/blank/node_modules/castle-web-fonts/package.json +47 -0
- package/kits/blank/node_modules/castle-web-fonts/woff2/Bore.woff2 +0 -0
- package/kits/blank/node_modules/castle-web-fonts/woff2/CourierPrime.woff2 +0 -0
- package/kits/blank/node_modules/castle-web-fonts/woff2/DMSans.woff2 +0 -0
- package/kits/blank/node_modules/castle-web-fonts/woff2/Glacier.woff2 +0 -0
- package/kits/blank/node_modules/castle-web-fonts/woff2/HelicoCentrica.woff2 +0 -0
- package/kits/blank/node_modules/castle-web-fonts/woff2/Piazzolla.woff2 +0 -0
- package/kits/blank/node_modules/castle-web-fonts/woff2/SOURCE.txt +2 -0
- package/kits/blank/node_modules/castle-web-fonts/woff2/Synco.woff2 +0 -0
- package/kits/blank/node_modules/castle-web-fonts/woff2/Tektur.woff2 +0 -0
- package/kits/blank/node_modules/castle-web-fonts/woff2/YatraOne.woff2 +0 -0
- package/kits/blank/package-lock.json +10 -1
- package/kits/blank/package.json +3 -1
- package/kits/physics-2d/CLAUDE.md +158 -40
- package/kits/physics-2d/castle.json +3 -2
- package/kits/physics-2d/editors/SingleEditor.jsx +52 -19
- package/kits/physics-2d/editors/StyleEditor.jsx +139 -40
- package/kits/physics-2d/editors/deckFont.js +88 -0
- package/kits/physics-2d/editors/fontPreview.js +66 -0
- package/kits/physics-2d/editors/styleEditor.module.css +30 -3
- package/kits/physics-2d/editors/styleTheme.js +13 -2
- package/kits/physics-2d/engine/ScenePlayer.jsx +17 -2
- package/kits/physics-2d/engine/SceneUI.jsx +8 -0
- package/kits/physics-2d/engine/files.js +20 -9
- package/kits/physics-2d/engine/fonts.js +79 -0
- package/kits/physics-2d/engine/scene.js +6 -0
- package/kits/physics-2d/fonts.generated.js +9 -0
- package/kits/physics-2d/main.jsx +11 -0
- package/kits/physics-2d/package-lock.json +8 -1
- package/kits/physics-2d/package.json +1 -0
- package/kits/physics-2d/theme.style +2 -1
- package/kits/physics-3d/castle.json +1 -1
- package/kits/physics-3d/engine3d/PxModelEditor.jsx +3 -4
- package/kits/physics-3d/engine3d/Scene3DEditor.jsx +12 -8
- package/kits/physics-3d/engine3d/editorChrome.jsx +11 -6
- package/kits/physics-3d/engine3d/modelFiles.js +4 -5
- package/kits/physics-3d/package-lock.json +8 -1
- package/kits/physics-3d/package.json +1 -0
- package/kits/tabletop/.prettierrc +8 -0
- package/kits/tabletop/CLAUDE.md +309 -0
- package/kits/tabletop/castle.json +34 -0
- package/kits/tabletop/index.html +20 -0
- package/kits/tabletop/main.jsx +8 -0
- package/kits/tabletop/package-lock.json +341 -0
- package/kits/tabletop/package.json +29 -0
- package/kits/tabletop/room.js +269 -0
- package/kits/tabletop/testing.js +569 -0
- package/package.json +1 -1
- package/kits/blank/.castle/agent/children.json +0 -1
- package/kits/blank/.castle/agent/messages.json +0 -9
- package/kits/blank/.castle/agent/pending-sends.json +0 -1
- package/kits/blank/.castle/agent/tasks/index.md +0 -2
- package/kits/blank/.castle/docs/platform.md +0 -36
- package/kits/blank/node_modules/.vite/deps/_metadata.json +0 -8
- package/kits/blank/node_modules/.vite/deps/package.json +0 -3
package/dist/serveSecurity.js
CHANGED
|
@@ -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
|
|
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
|
}
|