castle-web-cli 0.4.156 → 0.4.158
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-failures.d.ts +1 -0
- package/dist/agent-failures.js +6 -4
- package/dist/agent-prompts.js +4 -0
- package/dist/agent.d.ts +11 -0
- package/dist/agent.js +175 -15
- package/dist/bundle.js +8 -2
- package/dist/castle-host/host.js +114 -8
- package/dist/castleJson.js +6 -1
- package/dist/check.d.ts +1 -0
- package/dist/check.js +25 -0
- package/dist/devSessionServer.js +31 -7
- package/dist/imports.js +1 -19
- package/dist/index.js +15 -1
- package/dist/init.d.ts +2 -2
- package/dist/init.js +78 -42
- package/dist/mcpPlaytest.d.ts +1 -0
- package/dist/mcpPlaytest.js +182 -0
- package/dist/metering.d.ts +24 -0
- package/dist/metering.js +87 -0
- package/dist/sdkResolve.d.ts +3 -0
- package/dist/sdkResolve.js +55 -0
- package/dist/serve.js +50 -4
- package/dist/serverBundle.js +8 -3
- package/dist/shell/assets/{index-DsDkYFvP.js → index-BuSYLy-C.js} +64 -64
- package/dist/shell/assets/{index-DwezawBs.css → index-DfZmu3XC.css} +1 -1
- package/dist/shell/index.html +2 -2
- package/dist/vitePlugins.d.ts +1 -0
- package/dist/vitePlugins.js +20 -0
- package/kits/base/CLAUDE.md +196 -0
- package/kits/{blank → base}/castle.json +5 -2
- package/kits/base/editorHost.js +172 -0
- package/kits/{blank → base}/node_modules/.package-lock.json +3 -2
- package/kits/{blank → base}/package-lock.json +7 -4
- package/kits/{blank → base}/package.json +4 -2
- package/kits/base/sdk/README.md +569 -0
- package/kits/base/sdk/castle.d.ts +27 -0
- package/kits/base/sdk/castle.js +16 -0
- package/kits/base/sdk/commands.d.ts +181 -0
- package/kits/base/sdk/commands.js +16 -0
- package/kits/base/sdk/context.d.ts +17 -0
- package/kits/base/sdk/context.js +15 -0
- package/kits/base/sdk/errors.d.ts +22 -0
- package/kits/base/sdk/errors.js +16 -0
- package/kits/base/sdk/files.d.ts +15 -0
- package/kits/base/sdk/files.js +52 -0
- package/kits/base/sdk/haptics.d.ts +6 -0
- package/kits/base/sdk/haptics.js +36 -0
- package/kits/base/sdk/leaderboard.d.ts +26 -0
- package/kits/base/sdk/leaderboard.js +296 -0
- package/kits/base/sdk/lifecycle.d.ts +4 -0
- package/kits/base/sdk/lifecycle.js +13 -0
- package/kits/base/sdk/multiplayer.d.ts +43 -0
- package/kits/base/sdk/multiplayer.js +464 -0
- package/kits/base/sdk/multiplayerProtocol.d.ts +51 -0
- package/kits/base/sdk/multiplayerProtocol.js +5 -0
- package/kits/base/sdk/passes.d.ts +7 -0
- package/kits/base/sdk/passes.js +84 -0
- package/kits/base/sdk/portal.d.ts +7 -0
- package/kits/base/sdk/portal.js +35 -0
- package/kits/base/sdk/runtime.d.ts +62 -0
- package/kits/base/sdk/runtime.js +970 -0
- package/kits/base/sdk/saveQueue.d.ts +27 -0
- package/kits/base/sdk/saveQueue.js +205 -0
- package/kits/base/sdk/server/platformHandle.d.ts +25 -0
- package/kits/base/sdk/server/platformHandle.js +1 -0
- package/kits/base/sdk/server/wrapper.d.ts +28 -0
- package/kits/base/sdk/server/wrapper.js +109 -0
- package/kits/base/sdk/storage.d.ts +16 -0
- package/kits/base/sdk/storage.js +323 -0
- package/kits/base/sdk/time.d.ts +17 -0
- package/kits/base/sdk/time.js +120 -0
- package/kits/base/sdk/transport.d.ts +17 -0
- package/kits/base/sdk/transport.js +141 -0
- package/kits/base/sdk/types.d.ts +3 -0
- package/kits/base/sdk/types.js +1 -0
- package/kits/base/sdk/user.d.ts +10 -0
- package/kits/base/sdk/user.js +45 -0
- package/kits/multiplayer-2d/.prettierrc +5 -0
- package/kits/multiplayer-2d/CLAUDE.md +129 -0
- package/kits/multiplayer-2d/behaviors/Box.jsx +92 -0
- package/kits/multiplayer-2d/behaviors/Player.jsx +86 -0
- package/kits/multiplayer-2d/blueprints/crate.scene +13 -0
- package/kits/multiplayer-2d/blueprints/other-player.scene +13 -0
- package/kits/multiplayer-2d/blueprints/player.scene +15 -0
- package/kits/multiplayer-2d/blueprints/wall.scene +12 -0
- package/kits/multiplayer-2d/castle.json +39 -0
- package/kits/multiplayer-2d/code/client/avatars.js +79 -0
- package/kits/multiplayer-2d/code/client/poses.js +168 -0
- package/kits/multiplayer-2d/code/server/index.js +26 -0
- package/kits/multiplayer-2d/code/server/limits.js +99 -0
- package/kits/multiplayer-2d/code/server/ownership.js +177 -0
- package/kits/multiplayer-2d/code/server/players.js +127 -0
- package/kits/multiplayer-2d/code/server/sceneBodies.js +98 -0
- package/kits/multiplayer-2d/code/server/world.js +337 -0
- package/kits/multiplayer-2d/code/systems/multiplayer.js +424 -0
- package/kits/multiplayer-2d/eslint.config.js +21 -0
- package/kits/multiplayer-2d/fonts.generated.js +9 -0
- package/kits/multiplayer-2d/index.html +25 -0
- package/kits/multiplayer-2d/main.jsx +10 -0
- package/kits/multiplayer-2d/package-lock.json +351 -0
- package/kits/multiplayer-2d/package.json +30 -0
- package/kits/multiplayer-2d/scenes/main.scene +20 -0
- package/kits/multiplayer-2d/test/two-client-test.mjs +341 -0
- package/kits/multiplayer-2d/theme.style +4 -0
- package/kits/multiplayer-3d/.prettierrc +5 -0
- package/kits/multiplayer-3d/CLAUDE.md +215 -0
- package/kits/multiplayer-3d/blueprints/ball.scene +21 -0
- package/kits/multiplayer-3d/blueprints/other-player.scene +21 -0
- package/kits/multiplayer-3d/castle.json +43 -0
- package/kits/multiplayer-3d/code/client/avatars.js +136 -0
- package/kits/multiplayer-3d/code/client/nameTags.js +101 -0
- package/kits/multiplayer-3d/code/client/poses.js +220 -0
- package/kits/multiplayer-3d/code/server/index.js +23 -0
- package/kits/multiplayer-3d/code/server/limits.js +107 -0
- package/kits/multiplayer-3d/code/server/ownership.js +157 -0
- package/kits/multiplayer-3d/code/server/players.js +114 -0
- package/kits/multiplayer-3d/code/server/sceneBodies.js +88 -0
- package/kits/multiplayer-3d/code/server/world.js +306 -0
- package/kits/multiplayer-3d/code/systems/multiplayer.js +427 -0
- package/kits/multiplayer-3d/eslint.config.js +20 -0
- package/kits/multiplayer-3d/fonts.generated.js +9 -0
- package/kits/multiplayer-3d/index.html +22 -0
- package/kits/multiplayer-3d/main.jsx +9 -0
- package/kits/multiplayer-3d/package-lock.json +368 -0
- package/kits/multiplayer-3d/package.json +32 -0
- package/kits/multiplayer-3d/scenes/main.scene +409 -0
- package/kits/multiplayer-3d/theme.style +3 -0
- package/kits/physics-2d/CLAUDE.md +6 -0
- package/kits/physics-2d/castle.json +7 -1
- package/kits/physics-2d/editors/behaviorRegistry.js +5 -0
- package/kits/physics-2d/editors/editorRegistry.jsx +3 -1
- package/kits/physics-2d/engine/files.js +9 -5
- package/kits/physics-2d/engine/systemRegistry.js +2 -0
- package/kits/physics-2d/engine/ui.module.css +11 -0
- package/kits/physics-2d/package-lock.json +8 -2
- package/kits/physics-2d/package.json +2 -2
- package/kits/physics-3d/CLAUDE.md +4 -4
- package/kits/physics-3d/behaviors/Shape.jsx +1 -1
- package/kits/physics-3d/blueprints/crate.scene +1 -1
- package/kits/physics-3d/blueprints/door.scene +4 -4
- package/kits/physics-3d/blueprints/pillar.scene +1 -1
- package/kits/physics-3d/blueprints/platform.scene +1 -1
- package/kits/physics-3d/blueprints/statue.scene +1 -1
- package/kits/physics-3d/blueprints/wall.scene +1 -1
- package/kits/physics-3d/castle.json +8 -11
- package/kits/physics-3d/docs/pxmodel-format.md +1 -1
- package/kits/physics-3d/engine3d/materials.js +3 -3
- package/kits/physics-3d/engine3d/modelFiles.js +4 -2
- package/kits/physics-3d/engine3d/world3d.js +1 -1
- package/kits/physics-3d/fonts.generated.js +9 -0
- package/kits/physics-3d/main.jsx +1 -1
- package/kits/physics-3d/package-lock.json +85 -2
- package/kits/physics-3d/package.json +6 -2
- package/kits/physics-3d/scenes/main.scene +1 -1
- package/kits/physics-3d/scenes/model-lab.scene +1 -1
- package/kits/real-time/.prettierrc +5 -0
- package/kits/real-time/CLAUDE.md +60 -0
- package/kits/real-time/castle.json +19 -0
- package/kits/real-time/code/client/clock.js +68 -0
- package/kits/real-time/code/client/connection.js +134 -0
- package/kits/real-time/code/client/gameHooks.js +50 -0
- package/kits/real-time/code/client/interpolate.js +82 -0
- package/kits/real-time/code/client/messages.js +55 -0
- package/kits/real-time/code/client/ownership.js +94 -0
- package/kits/real-time/code/client/smooth.js +54 -0
- package/kits/real-time/code/server/blockDelta.js +48 -0
- package/kits/real-time/code/server/gameHooks.js +47 -0
- package/kits/real-time/code/server/limits.js +35 -0
- package/kits/real-time/code/server/session.js +251 -0
- package/kits/real-time/eslint.config.js +22 -0
- package/kits/real-time/index.html +45 -0
- package/kits/real-time/package.json +14 -0
- package/kits/{tabletop → turn-based}/CLAUDE.md +42 -49
- package/kits/turn-based/blueprints/board.scene +15 -0
- package/kits/turn-based/blueprints/square.scene +25 -0
- package/kits/turn-based/castle.json +37 -0
- package/kits/turn-based/code/behaviors/Board.jsx +169 -0
- package/kits/turn-based/code/behaviors/Square.jsx +26 -0
- package/kits/turn-based/code/server/index.js +152 -0
- package/kits/turn-based/drawings/square.sprite +25 -0
- package/kits/turn-based/eslint.config.js +12 -0
- package/kits/turn-based/fonts.generated.js +9 -0
- package/kits/{tabletop → turn-based}/index.html +5 -3
- package/kits/{tabletop → turn-based}/main.jsx +2 -2
- package/kits/{tabletop → turn-based}/package-lock.json +17 -4
- package/kits/{tabletop → turn-based}/package.json +5 -2
- package/kits/turn-based/room.js +289 -0
- package/kits/turn-based/scenes/main.scene +227 -0
- package/kits/{tabletop → turn-based}/testing.js +131 -99
- package/kits/turn-based/theme.style +3 -0
- package/package.json +1 -1
- package/kits/blank/CLAUDE.md +0 -198
- package/kits/tabletop/castle.json +0 -34
- package/kits/tabletop/room.js +0 -269
- /package/kits/{blank → base}/index.html +0 -0
- /package/kits/{blank → base}/node_modules/castle-web-fonts/README.md +0 -0
- /package/kits/{blank → base}/node_modules/castle-web-fonts/dist/catalog.d.ts +0 -0
- /package/kits/{blank → base}/node_modules/castle-web-fonts/dist/catalog.js +0 -0
- /package/kits/{blank → base}/node_modules/castle-web-fonts/dist/face.d.ts +0 -0
- /package/kits/{blank → base}/node_modules/castle-web-fonts/dist/face.js +0 -0
- /package/kits/{blank → base}/node_modules/castle-web-fonts/dist/faces/Bore.d.ts +0 -0
- /package/kits/{blank → base}/node_modules/castle-web-fonts/dist/faces/Bore.js +0 -0
- /package/kits/{blank → base}/node_modules/castle-web-fonts/dist/faces/CourierPrime.d.ts +0 -0
- /package/kits/{blank → base}/node_modules/castle-web-fonts/dist/faces/CourierPrime.js +0 -0
- /package/kits/{blank → base}/node_modules/castle-web-fonts/dist/faces/DMSans.d.ts +0 -0
- /package/kits/{blank → base}/node_modules/castle-web-fonts/dist/faces/DMSans.js +0 -0
- /package/kits/{blank → base}/node_modules/castle-web-fonts/dist/faces/Glacier.d.ts +0 -0
- /package/kits/{blank → base}/node_modules/castle-web-fonts/dist/faces/Glacier.js +0 -0
- /package/kits/{blank → base}/node_modules/castle-web-fonts/dist/faces/HelicoCentrica.d.ts +0 -0
- /package/kits/{blank → base}/node_modules/castle-web-fonts/dist/faces/HelicoCentrica.js +0 -0
- /package/kits/{blank → base}/node_modules/castle-web-fonts/dist/faces/Piazzolla.d.ts +0 -0
- /package/kits/{blank → base}/node_modules/castle-web-fonts/dist/faces/Piazzolla.js +0 -0
- /package/kits/{blank → base}/node_modules/castle-web-fonts/dist/faces/Synco.d.ts +0 -0
- /package/kits/{blank → base}/node_modules/castle-web-fonts/dist/faces/Synco.js +0 -0
- /package/kits/{blank → base}/node_modules/castle-web-fonts/dist/faces/Tektur.d.ts +0 -0
- /package/kits/{blank → base}/node_modules/castle-web-fonts/dist/faces/Tektur.js +0 -0
- /package/kits/{blank → base}/node_modules/castle-web-fonts/dist/faces/YatraOne.d.ts +0 -0
- /package/kits/{blank → base}/node_modules/castle-web-fonts/dist/faces/YatraOne.js +0 -0
- /package/kits/{blank → base}/node_modules/castle-web-fonts/dist/index.d.ts +0 -0
- /package/kits/{blank → base}/node_modules/castle-web-fonts/dist/index.js +0 -0
- /package/kits/{blank → base}/node_modules/castle-web-fonts/licenses/CC-BY-ND-4.0.txt +0 -0
- /package/kits/{blank → base}/node_modules/castle-web-fonts/licenses/FONTS.md +0 -0
- /package/kits/{blank → base}/node_modules/castle-web-fonts/licenses/OFL-1.1.txt +0 -0
- /package/kits/{blank → base}/node_modules/castle-web-fonts/package.json +0 -0
- /package/kits/{blank → base}/node_modules/castle-web-fonts/woff2/Bore.woff2 +0 -0
- /package/kits/{blank → base}/node_modules/castle-web-fonts/woff2/CourierPrime.woff2 +0 -0
- /package/kits/{blank → base}/node_modules/castle-web-fonts/woff2/DMSans.woff2 +0 -0
- /package/kits/{blank → base}/node_modules/castle-web-fonts/woff2/Glacier.woff2 +0 -0
- /package/kits/{blank → base}/node_modules/castle-web-fonts/woff2/HelicoCentrica.woff2 +0 -0
- /package/kits/{blank → base}/node_modules/castle-web-fonts/woff2/Piazzolla.woff2 +0 -0
- /package/kits/{blank → base}/node_modules/castle-web-fonts/woff2/SOURCE.txt +0 -0
- /package/kits/{blank → base}/node_modules/castle-web-fonts/woff2/Synco.woff2 +0 -0
- /package/kits/{blank → base}/node_modules/castle-web-fonts/woff2/Tektur.woff2 +0 -0
- /package/kits/{blank → base}/node_modules/castle-web-fonts/woff2/YatraOne.woff2 +0 -0
- /package/kits/physics-3d/drawings/{crate.pxart → crate.sprite} +0 -0
- /package/kits/physics-3d/drawings/{door-edge.pxart → door-edge.sprite} +0 -0
- /package/kits/physics-3d/drawings/{door.pxart → door.sprite} +0 -0
- /package/kits/physics-3d/drawings/{face.pxart → face.sprite} +0 -0
- /package/kits/physics-3d/drawings/{floor.pxart → floor.sprite} +0 -0
- /package/kits/physics-3d/drawings/{platform.pxart → platform.sprite} +0 -0
- /package/kits/physics-3d/drawings/{statue.pxart → statue.sprite} +0 -0
- /package/kits/physics-3d/drawings/{wall.pxart → wall.sprite} +0 -0
- /package/kits/{tabletop → turn-based}/.prettierrc +0 -0
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import type { Json } from "./types";
|
|
2
|
+
export declare const CASTLE_SDK_PROTOCOL = 1;
|
|
3
|
+
export type StorageBlob = Record<string, string>;
|
|
4
|
+
export type SharedScope = "deck" | "user";
|
|
5
|
+
export interface StorageUpdate {
|
|
6
|
+
key: string;
|
|
7
|
+
value: string | null;
|
|
8
|
+
}
|
|
9
|
+
export interface RawLeaderboardEntry {
|
|
10
|
+
place?: string | number | null;
|
|
11
|
+
score?: string | number | null;
|
|
12
|
+
user?: {
|
|
13
|
+
userId?: string | null;
|
|
14
|
+
username?: string | null;
|
|
15
|
+
} | null;
|
|
16
|
+
}
|
|
17
|
+
export interface RawLeaderboard {
|
|
18
|
+
list?: RawLeaderboardEntry[] | null;
|
|
19
|
+
yourScore?: {
|
|
20
|
+
score?: string | number | null;
|
|
21
|
+
} | null;
|
|
22
|
+
}
|
|
23
|
+
export type LeaderboardShowStatus = "shown" | "unavailable";
|
|
24
|
+
export interface LeaderboardShowResult {
|
|
25
|
+
status: LeaderboardShowStatus;
|
|
26
|
+
}
|
|
27
|
+
export interface LeaderboardStreakCredit {
|
|
28
|
+
deckId: string | null;
|
|
29
|
+
kind: string;
|
|
30
|
+
priorStreak: number;
|
|
31
|
+
newStreak: number;
|
|
32
|
+
}
|
|
33
|
+
export type PassOfferStatus = "purchased" | "alreadyOwned" | "cancelled" | "unavailable";
|
|
34
|
+
export interface PassOfferResult {
|
|
35
|
+
status: PassOfferStatus;
|
|
36
|
+
}
|
|
37
|
+
export type PortalOpenStatus = "navigating" | "unavailable";
|
|
38
|
+
export interface PortalOpenResult {
|
|
39
|
+
status: PortalOpenStatus;
|
|
40
|
+
}
|
|
41
|
+
export type PortalPrefetchStatus = "prefetching" | "rejected" | "unavailable";
|
|
42
|
+
export interface PortalPrefetchResult {
|
|
43
|
+
status: PortalPrefetchStatus;
|
|
44
|
+
}
|
|
45
|
+
export type HapticStyle = "light" | "medium" | "heavy" | "selection" | "success" | "warning" | "error";
|
|
46
|
+
export type HapticsStatus = "triggered" | "unavailable";
|
|
47
|
+
export interface HapticsResult {
|
|
48
|
+
status: HapticsStatus;
|
|
49
|
+
}
|
|
50
|
+
export type MultiplayerMode = "named" | "party" | "public";
|
|
51
|
+
export interface MultiplayerGetSessionParams {
|
|
52
|
+
mode: MultiplayerMode;
|
|
53
|
+
key?: string | null;
|
|
54
|
+
}
|
|
55
|
+
export interface MultiplayerGetSessionResult {
|
|
56
|
+
status: "ok" | "solo" | "unavailable";
|
|
57
|
+
url: string | null;
|
|
58
|
+
nonce: string | null;
|
|
59
|
+
sessionId: string | null;
|
|
60
|
+
}
|
|
61
|
+
export interface CommandParams {
|
|
62
|
+
"deckStorage.load": Record<string, never>;
|
|
63
|
+
"deckStorage.update": {
|
|
64
|
+
updates: StorageUpdate[];
|
|
65
|
+
unload?: boolean;
|
|
66
|
+
};
|
|
67
|
+
"sharedDeckStorage.load": {
|
|
68
|
+
scope: SharedScope;
|
|
69
|
+
userId?: string | null;
|
|
70
|
+
keys: string[];
|
|
71
|
+
};
|
|
72
|
+
"sharedDeckStorage.update": {
|
|
73
|
+
scope: SharedScope;
|
|
74
|
+
updates: StorageUpdate[];
|
|
75
|
+
unload?: boolean;
|
|
76
|
+
};
|
|
77
|
+
"leaderboard.fetch": {
|
|
78
|
+
variable: string;
|
|
79
|
+
type: "high" | "low";
|
|
80
|
+
scope?: string | null;
|
|
81
|
+
score?: number | null;
|
|
82
|
+
};
|
|
83
|
+
"leaderboard.save": {
|
|
84
|
+
variable: string;
|
|
85
|
+
score: number;
|
|
86
|
+
scope?: string | null;
|
|
87
|
+
};
|
|
88
|
+
"leaderboard.show": {
|
|
89
|
+
variable: string;
|
|
90
|
+
type: "high" | "low";
|
|
91
|
+
scope?: string | null;
|
|
92
|
+
label?: string | null;
|
|
93
|
+
score?: number | null;
|
|
94
|
+
};
|
|
95
|
+
"user.getCurrent": Record<string, never>;
|
|
96
|
+
"time.getServerTime": Record<string, never>;
|
|
97
|
+
"pass.has": {
|
|
98
|
+
passId: string;
|
|
99
|
+
};
|
|
100
|
+
"pass.offer": {
|
|
101
|
+
passId: string;
|
|
102
|
+
};
|
|
103
|
+
"portal.open": {
|
|
104
|
+
targetDeckId: string;
|
|
105
|
+
};
|
|
106
|
+
"portal.prefetch": {
|
|
107
|
+
targetDeckId: string;
|
|
108
|
+
};
|
|
109
|
+
"haptics.play": {
|
|
110
|
+
style: HapticStyle;
|
|
111
|
+
};
|
|
112
|
+
"multiplayer.getSession": MultiplayerGetSessionParams;
|
|
113
|
+
}
|
|
114
|
+
export interface CommandResult {
|
|
115
|
+
"deckStorage.load": {
|
|
116
|
+
blob: StorageBlob;
|
|
117
|
+
};
|
|
118
|
+
"deckStorage.update": {
|
|
119
|
+
blob: StorageBlob;
|
|
120
|
+
};
|
|
121
|
+
"sharedDeckStorage.load": {
|
|
122
|
+
blob: StorageBlob;
|
|
123
|
+
};
|
|
124
|
+
"sharedDeckStorage.update": {
|
|
125
|
+
ok: true;
|
|
126
|
+
};
|
|
127
|
+
"leaderboard.fetch": {
|
|
128
|
+
leaderboard: RawLeaderboard;
|
|
129
|
+
currentUserId: string | null;
|
|
130
|
+
};
|
|
131
|
+
"leaderboard.save": {
|
|
132
|
+
ok: true;
|
|
133
|
+
};
|
|
134
|
+
"leaderboard.show": LeaderboardShowResult;
|
|
135
|
+
"user.getCurrent": {
|
|
136
|
+
user: {
|
|
137
|
+
userId: string;
|
|
138
|
+
username: string;
|
|
139
|
+
isAnonymous?: boolean;
|
|
140
|
+
} | null;
|
|
141
|
+
};
|
|
142
|
+
"time.getServerTime": {
|
|
143
|
+
timestamp: number;
|
|
144
|
+
timezoneOffset: number;
|
|
145
|
+
castleEpochData: Json;
|
|
146
|
+
};
|
|
147
|
+
"pass.has": {
|
|
148
|
+
hasPass: boolean;
|
|
149
|
+
};
|
|
150
|
+
"pass.offer": PassOfferResult;
|
|
151
|
+
"portal.open": PortalOpenResult;
|
|
152
|
+
"portal.prefetch": PortalPrefetchResult;
|
|
153
|
+
"haptics.play": HapticsResult;
|
|
154
|
+
"multiplayer.getSession": MultiplayerGetSessionResult;
|
|
155
|
+
}
|
|
156
|
+
export type CommandName = keyof CommandParams;
|
|
157
|
+
export interface SerializedCommandError {
|
|
158
|
+
code: string;
|
|
159
|
+
message: string;
|
|
160
|
+
command?: string;
|
|
161
|
+
extensions?: Record<string, unknown>;
|
|
162
|
+
}
|
|
163
|
+
export interface CommandRequestEnvelope {
|
|
164
|
+
castleSdk: typeof CASTLE_SDK_PROTOCOL;
|
|
165
|
+
requestId: string;
|
|
166
|
+
command: CommandName;
|
|
167
|
+
params: unknown;
|
|
168
|
+
}
|
|
169
|
+
export interface CommandResponseEnvelope {
|
|
170
|
+
castleSdk: typeof CASTLE_SDK_PROTOCOL;
|
|
171
|
+
requestId: string;
|
|
172
|
+
ok: boolean;
|
|
173
|
+
data?: unknown;
|
|
174
|
+
error?: SerializedCommandError;
|
|
175
|
+
}
|
|
176
|
+
export declare function isResponseEnvelope(value: unknown): value is CommandResponseEnvelope;
|
|
177
|
+
export type LifecycleEvent = "ready";
|
|
178
|
+
export interface LifecycleEnvelope {
|
|
179
|
+
castleSdk: typeof CASTLE_SDK_PROTOCOL;
|
|
180
|
+
lifecycle: LifecycleEvent;
|
|
181
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// The SDK↔host command contract. This is the single source of truth for the
|
|
2
|
+
// wire protocol shared by the deck-side command-poster (`transport.ts`) and the
|
|
3
|
+
// host-side executor (`host.ts`). It carries ONLY names and types — no GraphQL
|
|
4
|
+
// query strings and no auth — so importing it into a deck bundle reveals
|
|
5
|
+
// nothing privileged.
|
|
6
|
+
// Marker + protocol version. Doubles as a discriminator so host messages can't
|
|
7
|
+
// be confused with embed.js `castlexyz:` strings or RN console messages.
|
|
8
|
+
export const CASTLE_SDK_PROTOCOL = 1;
|
|
9
|
+
export function isResponseEnvelope(value) {
|
|
10
|
+
if (typeof value !== "object" || value === null)
|
|
11
|
+
return false;
|
|
12
|
+
const record = value;
|
|
13
|
+
return (record.castleSdk === CASTLE_SDK_PROTOCOL &&
|
|
14
|
+
typeof record.requestId === "string" &&
|
|
15
|
+
typeof record.ok === "boolean");
|
|
16
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type CastleHost = "web" | "mobile" | "dev";
|
|
2
|
+
export interface CastleEmbed {
|
|
3
|
+
edit?: boolean;
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated Hosts should not set this for new behavior. The SDK now infers
|
|
6
|
+
* host-framed vs standalone presentation from its runtime context.
|
|
7
|
+
*/
|
|
8
|
+
feed?: boolean;
|
|
9
|
+
host?: CastleHost;
|
|
10
|
+
}
|
|
11
|
+
declare global {
|
|
12
|
+
interface Window {
|
|
13
|
+
CastleEmbed?: CastleEmbed;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export declare function getCastleEmbed(): CastleEmbed | undefined;
|
|
17
|
+
export declare function isEdit(): boolean;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function getCastleEmbed() {
|
|
2
|
+
return typeof window === "undefined" ? undefined : window.CastleEmbed;
|
|
3
|
+
}
|
|
4
|
+
export function isEdit() {
|
|
5
|
+
try {
|
|
6
|
+
const params = new URLSearchParams(window.location.search);
|
|
7
|
+
const override = params.get("edit");
|
|
8
|
+
if (override === "0" || override === "false")
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
// ignore -- window.location may be unavailable
|
|
13
|
+
}
|
|
14
|
+
return !!getCastleEmbed()?.edit;
|
|
15
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface GraphqlErrorPayload {
|
|
2
|
+
message?: string;
|
|
3
|
+
extensions?: Record<string, unknown>;
|
|
4
|
+
path?: Array<string | number>;
|
|
5
|
+
}
|
|
6
|
+
interface CastleErrorInput {
|
|
7
|
+
code: string;
|
|
8
|
+
message: string;
|
|
9
|
+
operation?: string;
|
|
10
|
+
status?: number;
|
|
11
|
+
extensions?: Record<string, unknown>;
|
|
12
|
+
errors?: GraphqlErrorPayload[];
|
|
13
|
+
}
|
|
14
|
+
export declare class CastleError extends Error {
|
|
15
|
+
code: string;
|
|
16
|
+
operation?: string;
|
|
17
|
+
status?: number;
|
|
18
|
+
extensions?: Record<string, unknown>;
|
|
19
|
+
errors?: GraphqlErrorPayload[];
|
|
20
|
+
constructor(input: CastleErrorInput);
|
|
21
|
+
}
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export class CastleError extends Error {
|
|
2
|
+
code;
|
|
3
|
+
operation;
|
|
4
|
+
status;
|
|
5
|
+
extensions;
|
|
6
|
+
errors;
|
|
7
|
+
constructor(input) {
|
|
8
|
+
super(input.message);
|
|
9
|
+
this.name = "CastleError";
|
|
10
|
+
this.code = input.code;
|
|
11
|
+
this.operation = input.operation;
|
|
12
|
+
this.status = input.status;
|
|
13
|
+
this.extensions = input.extensions;
|
|
14
|
+
this.errors = input.errors;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const IMPORTS_PREFIX = "@imports/";
|
|
2
|
+
export declare const IMPORTS_DIR = "imports";
|
|
3
|
+
export declare function deckPrefixOf(filePath: string): string;
|
|
4
|
+
/**
|
|
5
|
+
* Resolve a reference to the key it names in the deck's file map.
|
|
6
|
+
*
|
|
7
|
+
* @param ref the reference as written -- `drawings/rock.pxart` or
|
|
8
|
+
* `@imports/someone.pack/drawings/rock.pxart`
|
|
9
|
+
* @param from the path of the file the reference was written in; a reference in
|
|
10
|
+
* a deck's own file resolves against the deck root, one in an
|
|
11
|
+
* import's file against that import.
|
|
12
|
+
*/
|
|
13
|
+
export declare function resolveDeckFile(ref: string, from?: string): string;
|
|
14
|
+
/** Whether a path names a file some import owns (rather than the deck's own). */
|
|
15
|
+
export declare function isImportedFile(filePath: string): boolean;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// How a deck names a file -- one rule, everywhere a path appears: in JS module
|
|
2
|
+
// specifiers, in a scene's `blueprint`, in a Sprite's `file`, in anything a kit
|
|
3
|
+
// invents later.
|
|
4
|
+
//
|
|
5
|
+
// drawings/rock.pxart a file of the deck the REFERENCE lives in
|
|
6
|
+
// @imports/<alias>/drawings/rock.pxart a file of that import
|
|
7
|
+
//
|
|
8
|
+
// The unprefixed form is deck-relative, and "the deck" means whichever deck the
|
|
9
|
+
// referencing file belongs to. So a kit's blueprint saying `drawings/cauldron.pxart`
|
|
10
|
+
// means the kit's own drawing whether the kit is the deck being played or an
|
|
11
|
+
// import of it -- the same text keeps meaning the same file after the kit is
|
|
12
|
+
// imported by somebody else. That is what makes a deck publishable as a
|
|
13
|
+
// dependency without rewriting its insides.
|
|
14
|
+
//
|
|
15
|
+
// `@imports/` is the only way to name someone else's file, so a cross-deck
|
|
16
|
+
// reference is visible as one at a glance, and it means the same thing from any
|
|
17
|
+
// depth: imports are flattened into one `imports/` at the deck root, so the
|
|
18
|
+
// prefix is positional in nothing.
|
|
19
|
+
export const IMPORTS_PREFIX = '@imports/';
|
|
20
|
+
// Where imports live on disk, relative to the deck root. `@imports/x/y` is
|
|
21
|
+
// exactly `imports/x/y` -- the alias exists so the reference reads as a
|
|
22
|
+
// cross-deck one and does not depend on where the referencing file sits.
|
|
23
|
+
export const IMPORTS_DIR = 'imports';
|
|
24
|
+
function stripDotSlash(path) {
|
|
25
|
+
return path.replace(/^\.\//, '');
|
|
26
|
+
}
|
|
27
|
+
// The deck a file belongs to, as a path prefix: `imports/<alias>/` for a file of
|
|
28
|
+
// an import, `''` for one of the deck's own.
|
|
29
|
+
export function deckPrefixOf(filePath) {
|
|
30
|
+
const match = new RegExp(`^(${IMPORTS_DIR}/[^/]+/)`).exec(filePath ?? '');
|
|
31
|
+
return match ? match[1] : '';
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Resolve a reference to the key it names in the deck's file map.
|
|
35
|
+
*
|
|
36
|
+
* @param ref the reference as written -- `drawings/rock.pxart` or
|
|
37
|
+
* `@imports/someone.pack/drawings/rock.pxart`
|
|
38
|
+
* @param from the path of the file the reference was written in; a reference in
|
|
39
|
+
* a deck's own file resolves against the deck root, one in an
|
|
40
|
+
* import's file against that import.
|
|
41
|
+
*/
|
|
42
|
+
export function resolveDeckFile(ref, from = '') {
|
|
43
|
+
const path = stripDotSlash(String(ref ?? ''));
|
|
44
|
+
if (path.startsWith(IMPORTS_PREFIX)) {
|
|
45
|
+
return `${IMPORTS_DIR}/${path.slice(IMPORTS_PREFIX.length)}`;
|
|
46
|
+
}
|
|
47
|
+
return deckPrefixOf(stripDotSlash(from)) + path;
|
|
48
|
+
}
|
|
49
|
+
/** Whether a path names a file some import owns (rather than the deck's own). */
|
|
50
|
+
export function isImportedFile(filePath) {
|
|
51
|
+
return deckPrefixOf(filePath) !== '';
|
|
52
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { HapticStyle, HapticsResult } from "./commands";
|
|
2
|
+
export type { HapticStyle, HapticsResult, HapticsStatus } from "./commands";
|
|
3
|
+
export interface CastleHapticsApi {
|
|
4
|
+
play(style: HapticStyle): Promise<HapticsResult>;
|
|
5
|
+
}
|
|
6
|
+
export declare const Haptics: CastleHapticsApi;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// Haptics — a deck-facing capability for playing a device haptic (a "buzz").
|
|
2
|
+
// Like pass and portal, the deck stays capability-AGNOSTIC: it asks for a
|
|
3
|
+
// haptic and gets back one normalized outcome regardless of platform. The host
|
|
4
|
+
// owns the effect:
|
|
5
|
+
// - mobile app : plays a native haptic (Taptic Engine / VibrationEffect),
|
|
6
|
+
// subject to the host's own rate-limiting and device support
|
|
7
|
+
// - web player : best-effort navigator.vibrate; `unavailable` where the
|
|
8
|
+
// browser has no vibration API (e.g. iOS Safari)
|
|
9
|
+
// - dev CLI : no host handler, so `unavailable`
|
|
10
|
+
// A haptic is a fleeting device effect, not deck-scoped state, so unlike
|
|
11
|
+
// pass/portal the host requires no deckId. Decks usually fire-and-forget (don't
|
|
12
|
+
// await); the returned status just says whether the host could play it.
|
|
13
|
+
import { CastleError } from "./errors";
|
|
14
|
+
import { hostRequest } from "./transport";
|
|
15
|
+
const HAPTIC_STYLES = [
|
|
16
|
+
"light",
|
|
17
|
+
"medium",
|
|
18
|
+
"heavy",
|
|
19
|
+
"selection",
|
|
20
|
+
"success",
|
|
21
|
+
"warning",
|
|
22
|
+
"error",
|
|
23
|
+
];
|
|
24
|
+
export const Haptics = {
|
|
25
|
+
play,
|
|
26
|
+
};
|
|
27
|
+
async function play(style) {
|
|
28
|
+
if (!HAPTIC_STYLES.includes(style)) {
|
|
29
|
+
throw new CastleError({
|
|
30
|
+
code: "INVALID_ARGUMENT",
|
|
31
|
+
message: `Haptics.play style must be one of: ${HAPTIC_STYLES.join(", ")}.`,
|
|
32
|
+
operation: "Haptics.play",
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
return hostRequest("haptics.play", { style });
|
|
36
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type LeaderboardShowResult } from "./commands";
|
|
2
|
+
export type { LeaderboardShowResult, LeaderboardShowStatus } from "./commands";
|
|
3
|
+
export type LeaderboardSort = "high" | "low";
|
|
4
|
+
export type LeaderboardScope = string;
|
|
5
|
+
export interface LeaderboardOptions {
|
|
6
|
+
scope?: LeaderboardScope | null;
|
|
7
|
+
}
|
|
8
|
+
export interface LeaderboardShowOptions extends LeaderboardOptions {
|
|
9
|
+
label?: string | null;
|
|
10
|
+
}
|
|
11
|
+
export interface LeaderboardEntry {
|
|
12
|
+
place: number;
|
|
13
|
+
value: number;
|
|
14
|
+
username: string;
|
|
15
|
+
userId?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface LeaderboardData {
|
|
18
|
+
list: LeaderboardEntry[];
|
|
19
|
+
playerRank?: number;
|
|
20
|
+
playerValue?: number;
|
|
21
|
+
}
|
|
22
|
+
export declare const Leaderboard: {
|
|
23
|
+
readonly write: (variable: string, score: number, options?: LeaderboardOptions) => void;
|
|
24
|
+
readonly fetch: (variable: string, type: LeaderboardSort, options?: LeaderboardOptions) => Promise<LeaderboardData>;
|
|
25
|
+
readonly show: (variable: string, type: LeaderboardSort, options?: LeaderboardShowOptions) => Promise<LeaderboardShowResult>;
|
|
26
|
+
};
|