castle-web-cli 0.4.193 → 0.4.195
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/agent-prompts.d.ts +1 -0
- package/dist/agent-prompts.js +14 -5
- package/dist/agent.js +101 -4
- package/dist/api.d.ts +1 -0
- package/dist/api.js +5 -0
- package/dist/bundle.js +2 -1
- package/dist/castleJson.d.ts +1 -2
- package/dist/castleJson.js +0 -39
- package/dist/check.js +14 -6
- package/dist/devSessionFrameBudget.d.ts +14 -0
- package/dist/devSessionFrameBudget.js +64 -0
- package/dist/devSessionServer.d.ts +6 -0
- package/dist/devSessionServer.js +38 -1
- package/dist/editorConfig.d.ts +1 -1
- package/dist/editorConfig.js +12 -4
- package/dist/filesChanged.js +7 -3
- package/dist/ide.js +28 -59
- package/dist/importUpdateHook.d.ts +31 -0
- package/dist/importUpdateHook.js +135 -0
- package/dist/importUpdateHookRunner.d.ts +2 -0
- package/dist/importUpdateHookRunner.js +24 -0
- package/dist/imports.js +58 -10
- package/dist/index.js +58 -7
- package/dist/init.d.ts +1 -0
- package/dist/init.js +15 -9
- package/dist/multiplayerDoc.d.ts +1 -0
- package/dist/multiplayerDoc.js +228 -0
- package/dist/native/loop.js +29 -9
- package/dist/platformDoc.d.ts +1 -0
- package/dist/platformDoc.js +25 -6
- package/dist/remix.js +4 -1
- package/dist/scriptErrors.d.ts +23 -0
- package/dist/scriptErrors.js +147 -0
- package/dist/serve.js +366 -36
- package/dist/serverBundle.js +1 -1
- package/dist/shell/assets/index-kMH1qj6D.js +449 -0
- package/dist/shell/index.html +1 -1
- package/dist/versions.d.ts +14 -0
- package/dist/versions.js +21 -0
- package/dist/viteClientStub.d.ts +18 -0
- package/dist/viteClientStub.js +193 -0
- package/dist/vitePlugins.d.ts +1 -0
- package/dist/vitePlugins.js +18 -0
- package/kits/base/CLAUDE.md +3 -3
- package/kits/base/castle.json +1 -3
- package/kits/base/sdk/README.md +17 -0
- package/kits/multiplayer-2d/CLAUDE.md +9 -2
- package/kits/multiplayer-2d/blueprints/crate.scene +32 -4
- package/kits/multiplayer-2d/blueprints/other-player.scene +31 -4
- package/kits/multiplayer-2d/blueprints/player.scene +38 -6
- package/kits/multiplayer-2d/blueprints/wall.scene +25 -3
- package/kits/multiplayer-2d/castle.json +3 -12
- package/kits/multiplayer-2d/test/two-client-test.mjs +4 -4
- package/kits/multiplayer-3d/CLAUDE.md +5 -2
- package/kits/multiplayer-3d/castle.json +3 -11
- package/kits/multiplayer-3d/scenes/main.scene +128 -0
- package/kits/physics-2d/CLAUDE.md +16 -11
- package/kits/physics-2d/behaviors/Camera.jsx +5 -6
- package/kits/physics-2d/behaviors/Goal.jsx +5 -2
- package/kits/physics-2d/behaviors/Joints.jsx +4 -3
- package/kits/physics-2d/behaviors/Layout.jsx +120 -3
- package/kits/physics-2d/behaviors/Sprite.jsx +9 -9
- package/kits/physics-2d/behaviors/Style.jsx +22 -15
- package/kits/physics-2d/behaviors/Text.jsx +7 -6
- package/kits/physics-2d/blueprints/ball.scene +27 -5
- package/kits/physics-2d/blueprints/block.scene +16 -3
- package/kits/physics-2d/blueprints/cauldron.scene +3 -1
- package/kits/physics-2d/blueprints/crate.scene +23 -4
- package/kits/physics-2d/blueprints/goal.scene +12 -2
- package/kits/physics-2d/blueprints/text.scene +13 -3
- package/kits/physics-2d/castle.json +2 -11
- package/kits/physics-2d/editors/SceneEditor.jsx +68 -5
- package/kits/physics-2d/editors/SelectionOverlay.jsx +27 -20
- package/kits/physics-2d/editors/behaviorRegistry.js +8 -2
- package/kits/physics-2d/engine/ErrorOverlay.jsx +69 -0
- package/kits/physics-2d/engine/ScenePlayer.jsx +2 -67
- package/kits/physics-2d/engine/blueprint.js +111 -54
- package/kits/physics-2d/engine/blueprintCore.js +59 -0
- package/kits/physics-2d/engine/collider.js +28 -17
- package/kits/physics-2d/engine/layout.js +61 -0
- package/kits/physics-2d/engine/layoutOriginMigration.js +223 -0
- package/kits/physics-2d/engine/liveReload.js +5 -4
- package/kits/physics-2d/engine/physics/PhysicsSystem.js +11 -7
- package/kits/physics-2d/engine/physics/controls.js +4 -8
- package/kits/physics-2d/engine/physics/matterBridge.js +13 -8
- package/kits/physics-2d/engine/scene.js +38 -34
- package/kits/physics-2d/engine/spriteGeometry.js +17 -9
- package/kits/physics-2d/engine/tap.js +4 -3
- package/kits/physics-2d/scenes/main.scene +59 -6
- package/kits/physics-2d/scenes/sandbox.scene +69 -7
- package/kits/physics-2d/scripts/onUpdate.mjs +199 -0
- package/kits/physics-3d/castle.json +0 -11
- package/kits/real-time/castle.json +2 -8
- package/kits/real-time/code/server/persist.js +14 -0
- package/kits/turn-based/CLAUDE.md +18 -10
- package/kits/turn-based/blueprints/board.scene +3 -1
- package/kits/turn-based/blueprints/square.scene +3 -1
- package/kits/turn-based/castle.json +3 -14
- package/kits/turn-based/code/behaviors/Board.jsx +33 -21
- package/package.json +1 -1
- package/dist/shell/assets/index-ColHKJYj.js +0 -449
package/dist/shell/index.html
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
<link rel="icon" type="image/png" sizes="32x32" href="/__castle/ide/favicon-32x32.png" />
|
|
11
11
|
<link rel="icon" type="image/png" sizes="16x16" href="/__castle/ide/favicon-16x16.png" />
|
|
12
12
|
<link rel="icon" href="/__castle/ide/favicon.ico" sizes="any" />
|
|
13
|
-
<script type="module" crossorigin src="/__castle/ide/assets/index-
|
|
13
|
+
<script type="module" crossorigin src="/__castle/ide/assets/index-kMH1qj6D.js"></script>
|
|
14
14
|
<link rel="stylesheet" crossorigin href="/__castle/ide/assets/index-D6leLNUq.css">
|
|
15
15
|
</head>
|
|
16
16
|
<body>
|
package/dist/versions.d.ts
CHANGED
|
@@ -35,6 +35,20 @@ export declare function pendingChanges(projectDir: string): {
|
|
|
35
35
|
path: string;
|
|
36
36
|
kind: ChangeKind;
|
|
37
37
|
}[];
|
|
38
|
+
/**
|
|
39
|
+
* Put the working tree back at head, throwing away everything not saved. The
|
|
40
|
+
* paths it touched, as a list.
|
|
41
|
+
*
|
|
42
|
+
* `applyVersionRestore` cannot express this: head IS the target, so it returns
|
|
43
|
+
* `alreadyThere` without looking at the tree. This is the rollback for an
|
|
44
|
+
* operation that saved a version and then wrote deck files -- see
|
|
45
|
+
* importUpdateHook.ts, where a kit's migration failing halfway has to leave the
|
|
46
|
+
* deck's own files exactly as the update found them.
|
|
47
|
+
*
|
|
48
|
+
* The cover is exempt for the same reason it is everywhere else (it is dirty by
|
|
49
|
+
* construction), which `pendingChanges` already handles.
|
|
50
|
+
*/
|
|
51
|
+
export declare function discardPendingChanges(projectDir: string): string[];
|
|
38
52
|
/**
|
|
39
53
|
* The deck's history newest first. From head (no `fromId`): the chain forward
|
|
40
54
|
* from head -- marked `later` -- then head, then its ancestors. From a named
|
package/dist/versions.js
CHANGED
|
@@ -155,6 +155,27 @@ export function pendingChanges(projectDir) {
|
|
|
155
155
|
.filter(([path]) => isReportableChange(path))
|
|
156
156
|
.map(([path, change]) => ({ path, kind: changeKind(change) }));
|
|
157
157
|
}
|
|
158
|
+
/**
|
|
159
|
+
* Put the working tree back at head, throwing away everything not saved. The
|
|
160
|
+
* paths it touched, as a list.
|
|
161
|
+
*
|
|
162
|
+
* `applyVersionRestore` cannot express this: head IS the target, so it returns
|
|
163
|
+
* `alreadyThere` without looking at the tree. This is the rollback for an
|
|
164
|
+
* operation that saved a version and then wrote deck files -- see
|
|
165
|
+
* importUpdateHook.ts, where a kit's migration failing halfway has to leave the
|
|
166
|
+
* deck's own files exactly as the update found them.
|
|
167
|
+
*
|
|
168
|
+
* The cover is exempt for the same reason it is everywhere else (it is dirty by
|
|
169
|
+
* construction), which `pendingChanges` already handles.
|
|
170
|
+
*/
|
|
171
|
+
export function discardPendingChanges(projectDir) {
|
|
172
|
+
const headFiles = store.parentManifest(projectDir, store.readHead(projectDir));
|
|
173
|
+
const actions = pendingChanges(projectDir)
|
|
174
|
+
.map(({ path: rel }) => [rel, headFiles[rel] ?? null])
|
|
175
|
+
.sort((a, b) => a[0].localeCompare(b[0]));
|
|
176
|
+
applyRestore(projectDir, actions);
|
|
177
|
+
return actions.map(([rel]) => rel);
|
|
178
|
+
}
|
|
158
179
|
function toSummary(version, later) {
|
|
159
180
|
return {
|
|
160
181
|
id: version.id,
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Plugin } from 'vite';
|
|
2
|
+
/** The five names the real client entry exports (last line of client.mjs). */
|
|
3
|
+
export declare const VITE_CLIENT_EXPORTS: readonly ["ErrorOverlay", "createHotContext", "injectQuery", "removeStyle", "updateStyle"];
|
|
4
|
+
/**
|
|
5
|
+
* Vite resolves `/@vite/client` to `normalizePath(CLIENT_ENTRY)`, i.e. the
|
|
6
|
+
* client entry's absolute path with forward slashes (see the `vite:client-inject`
|
|
7
|
+
* plugin in vite/dist/node/chunks/node.js). Resolve and normalize it the same
|
|
8
|
+
* way so the id comparison holds on Windows too.
|
|
9
|
+
*/
|
|
10
|
+
export declare function viteClientEntryId(): string;
|
|
11
|
+
/**
|
|
12
|
+
* Replaces the body of Vite's HMR client entry with a socket-free stub.
|
|
13
|
+
*
|
|
14
|
+
* `enforce: 'pre'` puts the `load` hook ahead of Vite's own file load for that
|
|
15
|
+
* id, so the stub source is what gets transformed and served for
|
|
16
|
+
* `/@vite/client`. Every other id falls through untouched.
|
|
17
|
+
*/
|
|
18
|
+
export declare function viteClientStubPlugin(): Plugin;
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import * as path from 'path';
|
|
2
|
+
import { createRequire } from 'module';
|
|
3
|
+
// Castle's dev serve runs Vite with `server.hmr: false` on purpose: reload
|
|
4
|
+
// decisions belong to the consumers of the `files_changed` broadcast (the kit
|
|
5
|
+
// engine, editors, the shell), never to Vite -- see the header comment in
|
|
6
|
+
// filesChanged.ts. Vite still injects `<script type="module"
|
|
7
|
+
// src="/@vite/client">` into every HTML page, and its CSS and
|
|
8
|
+
// import-analysis transforms still emit imports of `updateStyle`,
|
|
9
|
+
// `removeStyle`, `injectQuery` and `createHotContext` from `/@vite/client`, so
|
|
10
|
+
// the module cannot simply be removed. But the real client
|
|
11
|
+
// (node_modules/vite/dist/client/client.mjs) opens a `vite-hmr` WebSocket the
|
|
12
|
+
// moment it loads, and with HMR off nothing ever accepts it: every deck open
|
|
13
|
+
// printed `[vite] failed to connect to websocket` plus a direct-connection
|
|
14
|
+
// fallback warning, which reads as a bug and trains people to ignore the
|
|
15
|
+
// console. This plugin swaps the client entry's module body for a stub that
|
|
16
|
+
// never opens a socket while keeping the exact same public exports, so every
|
|
17
|
+
// transformed module keeps working unchanged.
|
|
18
|
+
/** The five names the real client entry exports (last line of client.mjs). */
|
|
19
|
+
export const VITE_CLIENT_EXPORTS = [
|
|
20
|
+
'ErrorOverlay',
|
|
21
|
+
'createHotContext',
|
|
22
|
+
'injectQuery',
|
|
23
|
+
'removeStyle',
|
|
24
|
+
'updateStyle',
|
|
25
|
+
];
|
|
26
|
+
/**
|
|
27
|
+
* Vite resolves `/@vite/client` to `normalizePath(CLIENT_ENTRY)`, i.e. the
|
|
28
|
+
* client entry's absolute path with forward slashes (see the `vite:client-inject`
|
|
29
|
+
* plugin in vite/dist/node/chunks/node.js). Resolve and normalize it the same
|
|
30
|
+
* way so the id comparison holds on Windows too.
|
|
31
|
+
*/
|
|
32
|
+
export function viteClientEntryId() {
|
|
33
|
+
const pkgJson = createRequire(import.meta.url).resolve('vite/package.json');
|
|
34
|
+
return path.resolve(path.dirname(pkgJson), 'dist/client/client.mjs').split(path.sep).join('/');
|
|
35
|
+
}
|
|
36
|
+
// The stub's own module body. `updateStyle` / `removeStyle` are copied from the
|
|
37
|
+
// real client.mjs so dev-mode CSS imports behave exactly as before;
|
|
38
|
+
// `injectQuery` is Vite's own `__vite__injectQuery`; `createHotContext` returns
|
|
39
|
+
// an inert context with the same surface as client.mjs's HMRContext (the CSS
|
|
40
|
+
// transform calls `.accept()` and `.prune()` on it); `ErrorOverlay` is a real
|
|
41
|
+
// custom element because Vite's inline-CSS html-proxy error path does
|
|
42
|
+
// `new ErrorOverlay(err)` after dynamically importing `/@vite/client`.
|
|
43
|
+
const STUB_SOURCE = `// Castle stub for Vite's HMR client. HMR is off by design in the Castle dev
|
|
44
|
+
// serve (server.hmr: false; see cli/src/filesChanged.ts) -- reload decisions
|
|
45
|
+
// belong to the consumers of files_changed, not to Vite. The real client opens
|
|
46
|
+
// a vite-hmr socket on load and logs a connection failure forever when nothing
|
|
47
|
+
// accepts it, so this replaces its body with the same five exports and no
|
|
48
|
+
// socket, no ping and no reload.
|
|
49
|
+
|
|
50
|
+
const cspNonce =
|
|
51
|
+
'document' in globalThis
|
|
52
|
+
? document.querySelector('meta[property=csp-nonce]')?.nonce
|
|
53
|
+
: undefined;
|
|
54
|
+
|
|
55
|
+
const sheetsMap = /* @__PURE__ */ new Map();
|
|
56
|
+
const linkSheetsMap = /* @__PURE__ */ new Map();
|
|
57
|
+
if ('document' in globalThis) {
|
|
58
|
+
document.querySelectorAll('style[data-vite-dev-id]').forEach((el) => {
|
|
59
|
+
sheetsMap.set(el.getAttribute('data-vite-dev-id'), el);
|
|
60
|
+
});
|
|
61
|
+
document.querySelectorAll('link[rel="stylesheet"][data-vite-dev-id]').forEach((el) => {
|
|
62
|
+
linkSheetsMap.set(el.getAttribute('data-vite-dev-id'), el);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
let lastInsertedStyle;
|
|
67
|
+
|
|
68
|
+
export function updateStyle(id, content) {
|
|
69
|
+
if (linkSheetsMap.has(id)) return;
|
|
70
|
+
let style = sheetsMap.get(id);
|
|
71
|
+
if (!style) {
|
|
72
|
+
style = document.createElement('style');
|
|
73
|
+
style.setAttribute('type', 'text/css');
|
|
74
|
+
style.setAttribute('data-vite-dev-id', id);
|
|
75
|
+
style.textContent = content;
|
|
76
|
+
if (cspNonce) style.setAttribute('nonce', cspNonce);
|
|
77
|
+
if (!lastInsertedStyle) {
|
|
78
|
+
document.head.appendChild(style);
|
|
79
|
+
setTimeout(() => {
|
|
80
|
+
lastInsertedStyle = undefined;
|
|
81
|
+
}, 0);
|
|
82
|
+
} else {
|
|
83
|
+
lastInsertedStyle.insertAdjacentElement('afterend', style);
|
|
84
|
+
}
|
|
85
|
+
lastInsertedStyle = style;
|
|
86
|
+
} else {
|
|
87
|
+
style.textContent = content;
|
|
88
|
+
}
|
|
89
|
+
sheetsMap.set(id, style);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export function removeStyle(id) {
|
|
93
|
+
if (linkSheetsMap.has(id)) {
|
|
94
|
+
document.querySelectorAll('link[rel="stylesheet"][data-vite-dev-id]').forEach((el) => {
|
|
95
|
+
if (el.getAttribute('data-vite-dev-id') === id) el.remove();
|
|
96
|
+
});
|
|
97
|
+
linkSheetsMap.delete(id);
|
|
98
|
+
}
|
|
99
|
+
const style = sheetsMap.get(id);
|
|
100
|
+
if (style) {
|
|
101
|
+
document.head.removeChild(style);
|
|
102
|
+
sheetsMap.delete(id);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Vite's own __vite__injectQuery, used by import-analysis for dynamic imports
|
|
107
|
+
// it could not statically analyze.
|
|
108
|
+
export function injectQuery(url, queryToInject) {
|
|
109
|
+
if (url[0] !== '.' && url[0] !== '/') return url;
|
|
110
|
+
const pathname = url.replace(/[?#].*$/, '');
|
|
111
|
+
const { search, hash } = new URL(url, 'http://vite.dev');
|
|
112
|
+
return \`\${pathname}?\${queryToInject}\${search ? '&' + search.slice(1) : ''}\${hash || ''}\`;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Same surface as client.mjs's HMRContext, all inert: nothing dispatches HMR
|
|
116
|
+
// updates, so a registered callback would never fire anyway.
|
|
117
|
+
export function createHotContext(ownerPath) {
|
|
118
|
+
const noop = () => {};
|
|
119
|
+
return {
|
|
120
|
+
data: {},
|
|
121
|
+
accept: noop,
|
|
122
|
+
acceptExports: noop,
|
|
123
|
+
dispose: noop,
|
|
124
|
+
prune: noop,
|
|
125
|
+
decline: noop,
|
|
126
|
+
invalidate: noop,
|
|
127
|
+
on: noop,
|
|
128
|
+
off: noop,
|
|
129
|
+
send: noop,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Vite's error middleware serves a page that does
|
|
134
|
+
// \`document.body.appendChild(new ErrorOverlay(err))\` and nothing else, so the
|
|
135
|
+
// element has to render the error itself or that 500 page is blank. Styled
|
|
136
|
+
// inline in the same palette as the serve's FRAME_ERROR_CAPTURE redbox, and
|
|
137
|
+
// filled through textContent only -- err.message is untrusted text.
|
|
138
|
+
export class ErrorOverlay extends HTMLElement {
|
|
139
|
+
constructor(err) {
|
|
140
|
+
super();
|
|
141
|
+
this.err = err;
|
|
142
|
+
console.error('[castle] ' + ((err && err.message) || err));
|
|
143
|
+
this.style.cssText =
|
|
144
|
+
'position:fixed;left:0;top:0;right:0;bottom:0;z-index:2147483000;box-sizing:border-box;padding:18px 20px;overflow:auto;background:rgba(20,8,8,0.96);color:#ffd9dc;font:13px/1.5 SFMono-Regular,Consolas,Liberation Mono,monospace';
|
|
145
|
+
const title = document.createElement('div');
|
|
146
|
+
title.style.cssText = 'font-size:15px;font-weight:700;color:#ff6b74;margin-bottom:10px';
|
|
147
|
+
title.textContent = 'Script error';
|
|
148
|
+
this.appendChild(title);
|
|
149
|
+
const message = document.createElement('div');
|
|
150
|
+
message.style.cssText = 'word-break:break-word;white-space:pre-wrap';
|
|
151
|
+
message.textContent = (err && err.message) || String(err);
|
|
152
|
+
this.appendChild(message);
|
|
153
|
+
const detail = (err && (err.frame || err.stack)) || '';
|
|
154
|
+
if (detail) {
|
|
155
|
+
const pre = document.createElement('pre');
|
|
156
|
+
pre.style.cssText =
|
|
157
|
+
'margin:6px 0 0;color:#e79aa0;font-size:12px;white-space:pre-wrap;word-break:break-word';
|
|
158
|
+
pre.textContent = detail;
|
|
159
|
+
this.appendChild(pre);
|
|
160
|
+
}
|
|
161
|
+
const hint = document.createElement('div');
|
|
162
|
+
hint.style.cssText = 'margin-top:12px;color:#c98a8f;font-size:12px';
|
|
163
|
+
hint.textContent = 'Fix the file and reload.';
|
|
164
|
+
this.appendChild(hint);
|
|
165
|
+
}
|
|
166
|
+
close() {
|
|
167
|
+
this.remove();
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (typeof customElements !== 'undefined' && !customElements.get('castle-vite-error-overlay')) {
|
|
172
|
+
customElements.define('castle-vite-error-overlay', ErrorOverlay);
|
|
173
|
+
}
|
|
174
|
+
`;
|
|
175
|
+
/**
|
|
176
|
+
* Replaces the body of Vite's HMR client entry with a socket-free stub.
|
|
177
|
+
*
|
|
178
|
+
* `enforce: 'pre'` puts the `load` hook ahead of Vite's own file load for that
|
|
179
|
+
* id, so the stub source is what gets transformed and served for
|
|
180
|
+
* `/@vite/client`. Every other id falls through untouched.
|
|
181
|
+
*/
|
|
182
|
+
export function viteClientStubPlugin() {
|
|
183
|
+
const clientEntry = viteClientEntryId();
|
|
184
|
+
return {
|
|
185
|
+
name: 'castle:vite-client-stub',
|
|
186
|
+
enforce: 'pre',
|
|
187
|
+
load(id) {
|
|
188
|
+
if (id === clientEntry)
|
|
189
|
+
return STUB_SOURCE;
|
|
190
|
+
return null;
|
|
191
|
+
},
|
|
192
|
+
};
|
|
193
|
+
}
|
package/dist/vitePlugins.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Plugin } from 'vite';
|
|
2
2
|
export declare function importsAliasPlugin(): Plugin;
|
|
3
3
|
export declare function sdkAliasPlugin(): Plugin;
|
|
4
|
+
export declare function singleFileBuildCompatPlugin(): Plugin;
|
|
4
5
|
export declare function forksOverlayPlugin(): Plugin;
|
|
5
6
|
export declare function sceneFilesPlugin(): Plugin;
|
package/dist/vitePlugins.js
CHANGED
|
@@ -89,6 +89,24 @@ export function sdkAliasPlugin() {
|
|
|
89
89
|
},
|
|
90
90
|
};
|
|
91
91
|
}
|
|
92
|
+
// vite-plugin-singlefile still writes Rollup's deprecated inlineDynamicImports
|
|
93
|
+
// option. Rolldown's equivalent keeps the one-chunk output without the warning.
|
|
94
|
+
export function singleFileBuildCompatPlugin() {
|
|
95
|
+
return {
|
|
96
|
+
name: 'castle-single-file-build-compat',
|
|
97
|
+
enforce: 'post',
|
|
98
|
+
config(config) {
|
|
99
|
+
const output = config.build?.rollupOptions?.output;
|
|
100
|
+
if (!output)
|
|
101
|
+
return;
|
|
102
|
+
const outputs = Array.isArray(output) ? output : [output];
|
|
103
|
+
for (const options of outputs) {
|
|
104
|
+
delete options.inlineDynamicImports;
|
|
105
|
+
options.codeSplitting = false;
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
}
|
|
92
110
|
// `<path>?raw` -> ['<path>', '?raw']; no query -> ['<path>', ''].
|
|
93
111
|
function splitQuery(id) {
|
|
94
112
|
const at = id.indexOf('?');
|
package/kits/base/CLAUDE.md
CHANGED
|
@@ -65,9 +65,9 @@ imports/ other decks this one imports, read-only. `castle.base` (this
|
|
|
65
65
|
|
|
66
66
|
- `initialPanels` — what the workspace opens with (`files`, `playtest`,
|
|
67
67
|
`editor`).
|
|
68
|
-
- `
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
- `hiddenPaths` — globs the Files panel leaves out. Nothing is hidden unless the
|
|
69
|
+
deck names it, and the panel's show-hidden control appears only when something
|
|
70
|
+
is hidden.
|
|
71
71
|
- `fileTypes` — the deck's own file types; see `## Editors`.
|
|
72
72
|
- `defaultPlayFile` — what the play panel opens with. A deck that declares none
|
|
73
73
|
just loads `index.html`.
|
package/kits/base/castle.json
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"editor": {
|
|
3
|
-
"hiddenPaths": [],
|
|
4
|
-
"visiblePaths": [],
|
|
5
3
|
"fileTypes": [
|
|
6
4
|
{
|
|
7
5
|
"ext": ".md",
|
|
@@ -84,7 +82,7 @@
|
|
|
84
82
|
"title": "base",
|
|
85
83
|
"deckId": "yRcmH4_aYllE",
|
|
86
84
|
"cardId": "zkFdingmIm3m",
|
|
87
|
-
"publishedVersion": "2026-09-
|
|
85
|
+
"publishedVersion": "2026-09-17T20:55:24.712Z",
|
|
88
86
|
"provides": [
|
|
89
87
|
"castle-web-sdk"
|
|
90
88
|
]
|
package/kits/base/sdk/README.md
CHANGED
|
@@ -59,6 +59,23 @@ nothing. `soloReason` says why: `private_deck` or `no_server_bundle` are the
|
|
|
59
59
|
creator's to fix (change the deck's visibility, or publish a deck that has a
|
|
60
60
|
server entry); anything else reports `unavailable`. Client→server frames are limited to 16 KB on the wire.
|
|
61
61
|
|
|
62
|
+
### Limits
|
|
63
|
+
|
|
64
|
+
A client may send about 30 messages per second; going past that closes the
|
|
65
|
+
socket, so throttle pose or input sends rather than sending one per animation
|
|
66
|
+
frame.
|
|
67
|
+
|
|
68
|
+
A session may send about `40 + 40 × connected players` frames per second, with
|
|
69
|
+
roughly two seconds of burst and about 1 MiB/s of bytes. `session.send` costs
|
|
70
|
+
one frame per call, `session.broadcast(data)` costs one frame however many
|
|
71
|
+
players are connected, and `session.broadcast(data, { except })` is a loop of
|
|
72
|
+
sends, so it costs one frame per recipient. Frames over the budget are dropped
|
|
73
|
+
silently and never retried — the session keeps running — so broadcast one
|
|
74
|
+
snapshot per tick instead of sending a tailored message per player. Each client
|
|
75
|
+
reads every entry in that snapshot, its own included: the server's copy of its
|
|
76
|
+
hp, score and match state is authoritative, and only its own position stays
|
|
77
|
+
locally predicted.
|
|
78
|
+
|
|
62
79
|
### Binary messages
|
|
63
80
|
|
|
64
81
|
Pass any typed array, `DataView`, or `ArrayBuffer` to client `send`, server `send`,
|
|
@@ -67,8 +67,11 @@ then `Smoothing.smooth(…)`. File names stay lowercase.
|
|
|
67
67
|
Identity comes from `player.playerId` / `player.userId`, never from a body.
|
|
68
68
|
- The kit ships `code/systems/multiplayer.js`, the frame loop. A deck that writes
|
|
69
69
|
its own file of that path gets its own instead; most decks should not.
|
|
70
|
-
- Two players is the test that matters: `castle-web serve`,
|
|
71
|
-
two tabs
|
|
70
|
+
- Two players is the test that matters: run `castle-web serve`, open the shell
|
|
71
|
+
URL it prints in two tabs, and open the Play panel in each. If you use
|
|
72
|
+
`.castle/serve.json`'s `contentPlayUrl` directly, open `/index.html?edit=0`;
|
|
73
|
+
its bare origin is the edit surface, where multiplayer does not join. The room
|
|
74
|
+
persists in deck storage across serve restarts; a fresh one
|
|
72
75
|
means removing its `world:<room>`, `game:<room>` and `player:<room>:*` rows
|
|
73
76
|
(the local serve's room is `dev`).
|
|
74
77
|
|
|
@@ -172,6 +175,10 @@ node ../../cli/dist/index.js serve . --port 5762 --detach
|
|
|
172
175
|
node test/two-client-test.mjs
|
|
173
176
|
```
|
|
174
177
|
|
|
178
|
+
The test resolves `playwright-core` from this repo's `cli/package.json`, so run
|
|
179
|
+
the repo's normal `npm install` first; no machine-specific checkout path or
|
|
180
|
+
global Playwright install is required.
|
|
181
|
+
|
|
175
182
|
The room's state persists, so crates stay where the last run pushed them. Each
|
|
176
183
|
client publishes what it believes about the room on `globalThis.__multiplayer`,
|
|
177
184
|
which is what the test reads.
|
|
@@ -3,10 +3,38 @@
|
|
|
3
3
|
"actors": [
|
|
4
4
|
{
|
|
5
5
|
"components": {
|
|
6
|
-
"Layout": {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
"Layout": {
|
|
7
|
+
"width": 44,
|
|
8
|
+
"height": 44,
|
|
9
|
+
"z": 2,
|
|
10
|
+
"originX": 0,
|
|
11
|
+
"originY": 0
|
|
12
|
+
},
|
|
13
|
+
"Box": {
|
|
14
|
+
"color": "#bd9354",
|
|
15
|
+
"edge": "#7a5c31",
|
|
16
|
+
"radius": 3
|
|
17
|
+
},
|
|
18
|
+
"Collider": {
|
|
19
|
+
"shapes": [
|
|
20
|
+
{
|
|
21
|
+
"type": "box",
|
|
22
|
+
"x": 0.5,
|
|
23
|
+
"y": 0.5,
|
|
24
|
+
"w": 1,
|
|
25
|
+
"h": 1
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
"friction": 0.3,
|
|
29
|
+
"frictionStatic": 0.4,
|
|
30
|
+
"bounciness": 0
|
|
31
|
+
},
|
|
32
|
+
"RigidBody": {
|
|
33
|
+
"bodyType": "dynamic",
|
|
34
|
+
"gravityScale": 0,
|
|
35
|
+
"drag": 0.09,
|
|
36
|
+
"angularDrag": 2
|
|
37
|
+
}
|
|
10
38
|
}
|
|
11
39
|
}
|
|
12
40
|
]
|
|
@@ -3,10 +3,37 @@
|
|
|
3
3
|
"actors": [
|
|
4
4
|
{
|
|
5
5
|
"components": {
|
|
6
|
-
"Layout": {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
"Layout": {
|
|
7
|
+
"width": 34,
|
|
8
|
+
"height": 34,
|
|
9
|
+
"z": 3,
|
|
10
|
+
"originX": 0,
|
|
11
|
+
"originY": 0
|
|
12
|
+
},
|
|
13
|
+
"Box": {
|
|
14
|
+
"color": "#ff79c6",
|
|
15
|
+
"edge": "#8c3f6b",
|
|
16
|
+
"radius": 17,
|
|
17
|
+
"showFacing": true
|
|
18
|
+
},
|
|
19
|
+
"Collider": {
|
|
20
|
+
"shapes": [
|
|
21
|
+
{
|
|
22
|
+
"type": "circle",
|
|
23
|
+
"x": 0.5,
|
|
24
|
+
"y": 0.5,
|
|
25
|
+
"r": 0.5
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
"friction": 0.05,
|
|
29
|
+
"bounciness": 0
|
|
30
|
+
},
|
|
31
|
+
"RigidBody": {
|
|
32
|
+
"bodyType": "kinematic",
|
|
33
|
+
"gravityScale": 0,
|
|
34
|
+
"drag": 0,
|
|
35
|
+
"freezeRotation": true
|
|
36
|
+
}
|
|
10
37
|
}
|
|
11
38
|
}
|
|
12
39
|
]
|
|
@@ -3,12 +3,44 @@
|
|
|
3
3
|
"actors": [
|
|
4
4
|
{
|
|
5
5
|
"components": {
|
|
6
|
-
"Layout": {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
"Layout": {
|
|
7
|
+
"width": 34,
|
|
8
|
+
"height": 34,
|
|
9
|
+
"z": 3,
|
|
10
|
+
"originX": 0,
|
|
11
|
+
"originY": 0
|
|
12
|
+
},
|
|
13
|
+
"Box": {
|
|
14
|
+
"color": "#8be9fd",
|
|
15
|
+
"edge": "#3f7f8c",
|
|
16
|
+
"radius": 17,
|
|
17
|
+
"showFacing": true
|
|
18
|
+
},
|
|
19
|
+
"Collider": {
|
|
20
|
+
"shapes": [
|
|
21
|
+
{
|
|
22
|
+
"type": "circle",
|
|
23
|
+
"x": 0.5,
|
|
24
|
+
"y": 0.5,
|
|
25
|
+
"r": 0.5
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
"friction": 0.05,
|
|
29
|
+
"bounciness": 0
|
|
30
|
+
},
|
|
31
|
+
"RigidBody": {
|
|
32
|
+
"bodyType": "dynamic",
|
|
33
|
+
"gravityScale": 0,
|
|
34
|
+
"drag": 0.3,
|
|
35
|
+
"freezeRotation": true
|
|
36
|
+
},
|
|
37
|
+
"Player": {
|
|
38
|
+
"speed": 4
|
|
39
|
+
},
|
|
40
|
+
"AnalogStick": {
|
|
41
|
+
"speed": 4,
|
|
42
|
+
"maxRadius": 70
|
|
43
|
+
}
|
|
12
44
|
}
|
|
13
45
|
}
|
|
14
46
|
]
|
|
@@ -3,9 +3,31 @@
|
|
|
3
3
|
"actors": [
|
|
4
4
|
{
|
|
5
5
|
"components": {
|
|
6
|
-
"Layout": {
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
"Layout": {
|
|
7
|
+
"width": 100,
|
|
8
|
+
"height": 24,
|
|
9
|
+
"z": 1,
|
|
10
|
+
"originX": 0,
|
|
11
|
+
"originY": 0
|
|
12
|
+
},
|
|
13
|
+
"Box": {
|
|
14
|
+
"color": "#2b2d3d",
|
|
15
|
+
"edge": "#3d4159",
|
|
16
|
+
"radius": 2
|
|
17
|
+
},
|
|
18
|
+
"Collider": {
|
|
19
|
+
"shapes": [
|
|
20
|
+
{
|
|
21
|
+
"type": "box",
|
|
22
|
+
"x": 0.5,
|
|
23
|
+
"y": 0.5,
|
|
24
|
+
"w": 1,
|
|
25
|
+
"h": 1
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
"friction": 0.1,
|
|
29
|
+
"bounciness": 0
|
|
30
|
+
}
|
|
9
31
|
}
|
|
10
32
|
}
|
|
11
33
|
]
|
|
@@ -1,25 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"title": "multiplayer-2d",
|
|
3
3
|
"editor": {
|
|
4
|
-
"hiddenPaths": [],
|
|
5
|
-
"visiblePaths": [
|
|
6
|
-
"code/**",
|
|
7
|
-
"behaviors/**",
|
|
8
|
-
"scenes/**",
|
|
9
|
-
"blueprints/**",
|
|
10
|
-
"theme.style",
|
|
11
|
-
"fonts.generated.js"
|
|
12
|
-
],
|
|
13
4
|
"defaultPlayFile": "scenes/main.scene"
|
|
14
5
|
},
|
|
15
6
|
"imports": {
|
|
16
7
|
"castle.real-time": {
|
|
17
8
|
"deckId": "xFVr-afOLuUQ",
|
|
18
|
-
"version": "2026-09-
|
|
9
|
+
"version": "2026-09-16T21:18:06.448Z"
|
|
19
10
|
},
|
|
20
11
|
"castle.physics-2d": {
|
|
21
12
|
"deckId": "ckRZGFW4iPrx",
|
|
22
|
-
"version": "2026-09-
|
|
13
|
+
"version": "2026-09-16T21:17:53.144Z"
|
|
23
14
|
},
|
|
24
15
|
"castle.base": {
|
|
25
16
|
"deckId": "yRcmH4_aYllE",
|
|
@@ -35,5 +26,5 @@
|
|
|
35
26
|
},
|
|
36
27
|
"deckId": "oiFu96LkwZ09",
|
|
37
28
|
"cardId": "nkJgrvrCby3H",
|
|
38
|
-
"publishedVersion": "2026-09-
|
|
29
|
+
"publishedVersion": "2026-09-16T21:20:14.363Z"
|
|
39
30
|
}
|
|
@@ -7,10 +7,10 @@ import path from 'path';
|
|
|
7
7
|
import { fileURLToPath } from 'url';
|
|
8
8
|
import { createRequire } from 'module';
|
|
9
9
|
|
|
10
|
-
const require = createRequire('/
|
|
11
|
-
// Playwright
|
|
12
|
-
//
|
|
13
|
-
const { chromium } = require('playwright');
|
|
10
|
+
const require = createRequire(new URL('../../../cli/package.json', import.meta.url));
|
|
11
|
+
// Playwright is a CLI dependency. Workspace browser automation is restricted to
|
|
12
|
+
// Castle decks, and both pages opened here are this served deck.
|
|
13
|
+
const { chromium } = require('playwright-core');
|
|
14
14
|
|
|
15
15
|
const deckDir = path.dirname(path.dirname(fileURLToPath(import.meta.url)));
|
|
16
16
|
|
|
@@ -99,8 +99,11 @@ File names stay lowercase.
|
|
|
99
99
|
Identity comes from `player.playerId` / `player.userId`, never from a body.
|
|
100
100
|
- The kit ships `code/systems/multiplayer.js`, the frame loop. A deck that writes
|
|
101
101
|
its own file of that path gets its own instead; most decks should not.
|
|
102
|
-
- Two players is the test that matters: `castle-web serve`,
|
|
103
|
-
two tabs
|
|
102
|
+
- Two players is the test that matters: run `castle-web serve`, open the shell
|
|
103
|
+
URL it prints in two tabs, and open the Play panel in each. If you use
|
|
104
|
+
`.castle/serve.json`'s `contentPlayUrl` directly, open `/index.html?edit=0`;
|
|
105
|
+
its bare origin is the edit surface, where multiplayer does not join. The room
|
|
106
|
+
persists in deck storage across serve restarts; a fresh one
|
|
104
107
|
means removing its `world:<room>`, `game:<room>` and `player:<room>:*` rows
|
|
105
108
|
(the local serve's room is `dev`).
|
|
106
109
|
|