castle-web-cli 0.4.237 → 0.4.239

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 (239) hide show
  1. package/dist/bundle.d.ts +24 -0
  2. package/dist/bundle.js +447 -4
  3. package/dist/bundleLatin1.d.ts +6 -0
  4. package/dist/bundleLatin1.js +333 -0
  5. package/dist/castle-host/host.d.ts +10 -1
  6. package/dist/castle-host/host.js +133 -9
  7. package/dist/castleJson.d.ts +2 -0
  8. package/dist/castleJson.js +1 -0
  9. package/dist/deckExports.d.ts +35 -0
  10. package/dist/deckExports.js +365 -0
  11. package/dist/importCheckHook.d.ts +1 -0
  12. package/dist/importCheckHook.js +1 -1
  13. package/dist/index.js +21 -0
  14. package/dist/init.js +2 -1
  15. package/dist/multiplayerDoc.d.ts +1 -1
  16. package/dist/multiplayerDoc.js +9 -0
  17. package/dist/platformDoc.js +2 -1
  18. package/dist/playPagePolicy.d.ts +1 -0
  19. package/dist/playPagePolicy.js +8 -3
  20. package/dist/roomLogs.d.ts +39 -0
  21. package/dist/roomLogs.js +166 -0
  22. package/dist/save-deck.js +4 -0
  23. package/kits/base/CLAUDE.md +1 -0
  24. package/kits/base/castle.json +1 -1
  25. package/kits/base/sdk/README.md +113 -2
  26. package/kits/base/sdk/castle.d.ts +6 -2
  27. package/kits/base/sdk/castle.js +2 -0
  28. package/kits/base/sdk/commands.d.ts +56 -1
  29. package/kits/base/sdk/commands.js +29 -1
  30. package/kits/base/sdk/hub.d.ts +17 -0
  31. package/kits/base/sdk/hub.js +33 -9
  32. package/kits/base/sdk/localCache.d.ts +27 -0
  33. package/kits/base/sdk/localCache.js +115 -0
  34. package/kits/base/sdk/localCacheStore.d.ts +15 -0
  35. package/kits/base/sdk/localCacheStore.js +358 -0
  36. package/kits/base/sdk/multiplayer.js +30 -0
  37. package/kits/base/sdk/rooms.d.ts +11 -0
  38. package/kits/base/sdk/rooms.js +22 -0
  39. package/kits/base/sdk/store.d.ts +8 -2
  40. package/kits/base/sdk/store.js +5 -1
  41. package/kits/base/sdk/transport.d.ts +1 -0
  42. package/kits/base/sdk/transport.js +4 -5
  43. package/kits/hub-game/CLAUDE.md +22 -2
  44. package/kits/hub-game/castle.json +8 -5
  45. package/kits/hub-game/code/client/act.js +66 -91
  46. package/kits/hub-game/code/client/actCore.js +134 -0
  47. package/kits/hub-game/code/client/car.js +35 -0
  48. package/kits/hub-game/code/client/chrome.js +208 -381
  49. package/kits/hub-game/code/client/crowdNames.js +2 -2
  50. package/kits/hub-game/code/client/emoteWheel.js +109 -0
  51. package/kits/hub-game/code/client/hats.js +2 -0
  52. package/kits/hub-game/code/client/hookLayer.js +99 -48
  53. package/kits/hub-game/code/client/hostGo.js +77 -0
  54. package/kits/hub-game/code/client/hubControls.js +125 -0
  55. package/kits/hub-game/code/client/hubEntry.js +187 -0
  56. package/kits/hub-game/code/client/hudSurface.js +148 -0
  57. package/kits/hub-game/code/client/hudTree.js +96 -0
  58. package/kits/hub-game/code/client/idle.js +59 -13
  59. package/kits/hub-game/code/client/invites.js +13 -4
  60. package/kits/hub-game/code/client/menuIcons.js +8 -0
  61. package/kits/hub-game/code/client/menuRows.js +8 -2
  62. package/kits/hub-game/code/client/noTrips.js +38 -0
  63. package/kits/hub-game/code/client/qualityEntry.js +6 -1
  64. package/kits/hub-game/code/client/rehello.js +3 -1
  65. package/kits/hub-game/code/client/riders.js +26 -0
  66. package/kits/hub-game/code/client/role.js +79 -0
  67. package/kits/hub-game/code/client/safeLayout.js +32 -3
  68. package/kits/hub-game/code/client/sound.js +10 -3
  69. package/kits/hub-game/code/client/soundscape.js +2 -2
  70. package/kits/hub-game/code/client/soundscapeAmbience.js +38 -8
  71. package/kits/hub-game/code/client/soundscapeBaked.js +24 -5
  72. package/kits/hub-game/code/client/soundscapeCues.js +2 -1
  73. package/kits/hub-game/code/client/state.js +19 -0
  74. package/kits/hub-game/code/client/stuck.js +2 -1
  75. package/kits/hub-game/code/client/talkSurface.js +178 -0
  76. package/kits/hub-game/code/client/talkTree.js +238 -0
  77. package/kits/hub-game/code/client/tiers.js +8 -5
  78. package/kits/hub-game/code/client/uiDom.js +600 -0
  79. package/kits/hub-game/code/client/uiTree.js +359 -0
  80. package/kits/hub-game/code/client/vehicle.js +156 -0
  81. package/kits/hub-game/code/client/wear.js +27 -5
  82. package/kits/hub-game/code/client/worldLabels.js +13 -3
  83. package/kits/hub-game/code/client/yours.js +10 -3
  84. package/kits/hub-game/code/server/actors.js +4 -3
  85. package/kits/hub-game/code/server/analytics.js +61 -18
  86. package/kits/hub-game/code/server/decor.js +56 -16
  87. package/kits/hub-game/code/server/doorAnalytics.js +2 -5
  88. package/kits/hub-game/code/server/hub.js +261 -46
  89. package/kits/hub-game/code/server/idle.js +118 -5
  90. package/kits/hub-game/code/server/loadAbandon.js +2 -5
  91. package/kits/hub-game/code/server/manifest.js +46 -4
  92. package/kits/hub-game/code/server/npcs.js +4 -2
  93. package/kits/hub-game/code/server/players.js +3 -0
  94. package/kits/hub-game/code/server/role.js +142 -0
  95. package/kits/hub-game/code/server/standing.js +6 -4
  96. package/kits/hub-game/code/server/trackQueue.js +29 -0
  97. package/kits/hub-game/code/server/vehicle.js +126 -0
  98. package/kits/hub-game/code/shared/car.js +52 -0
  99. package/kits/hub-game/code/shared/deckFlags.js +34 -0
  100. package/kits/hub-game/code/shared/deviceClass.js +39 -0
  101. package/kits/hub-game/code/shared/expression.js +9 -0
  102. package/kits/hub-game/code/systems/hub.js +281 -86
  103. package/kits/hub-game/docs/analytics.md +15 -3
  104. package/kits/hub-game/docs/contract.md +352 -14
  105. package/kits/hub-game/docs/vehicle-preset.md +132 -0
  106. package/kits/hub-game/models/hats/baker-cap.pxmodel +89 -0
  107. package/kits/hub-game/models/hats/chef-toque.pxmodel +60 -0
  108. package/kits/hub-game/models/hats/delivery-cap.pxmodel +105 -0
  109. package/kits/hub-game/models/hats/fire-helmet.pxmodel +87 -0
  110. package/kits/hub-game/models/hats/hard-hat.pxmodel +71 -0
  111. package/kits/hub-game/models/hats/nurse-cap.pxmodel +61 -0
  112. package/kits/hub-game/models/hats/police-cap.pxmodel +105 -0
  113. package/kits/hub-game/models/hats/teacher-beret.pxmodel +52 -0
  114. package/kits/hub-game/models/role/square/top-apron.pxmodel +109 -0
  115. package/kits/hub-game/models/role/square/top-cardigan.pxmodel +141 -0
  116. package/kits/hub-game/models/role/square/top-coat.pxmodel +157 -0
  117. package/kits/hub-game/models/role/square/top-scrubs.pxmodel +93 -0
  118. package/kits/hub-game/models/role/square/top-tabard.pxmodel +109 -0
  119. package/kits/hub-game/models/role/square/top-vest.pxmodel +109 -0
  120. package/kits/hub-game/models/role/tool-bag.pxmodel +75 -0
  121. package/kits/hub-game/models/role/tool-bell.pxmodel +71 -0
  122. package/kits/hub-game/models/role/tool-hose.pxmodel +60 -0
  123. package/kits/hub-game/models/role/tool-parcel.pxmodel +61 -0
  124. package/kits/hub-game/models/role/tool-torch.pxmodel +55 -0
  125. package/kits/hub-game/models/role/tool-tray.pxmodel +75 -0
  126. package/kits/hub-game/models/role/top-apron.pxmodel +70 -0
  127. package/kits/hub-game/models/role/top-cardigan.pxmodel +102 -0
  128. package/kits/hub-game/models/role/top-coat.pxmodel +79 -0
  129. package/kits/hub-game/models/role/top-scrubs.pxmodel +54 -0
  130. package/kits/hub-game/models/role/top-tabard.pxmodel +70 -0
  131. package/kits/hub-game/models/role/top-vest.pxmodel +70 -0
  132. package/kits/hub-game/package-lock.json +1 -1
  133. package/kits/hub-game/package.json +1 -1
  134. package/kits/hub-game/scripts/check.mjs +7 -4
  135. package/kits/hub-game/scripts/fixtures/car-vectors.json +279 -0
  136. package/kits/hub-game/scripts/fixtures/decor-keyless-draw.json +2 -1
  137. package/kits/hub-game/scripts/fixtures/hud-surface.json +670 -0
  138. package/kits/hub-game/scripts/fixtures/talk-surface.json +3930 -0
  139. package/kits/hub-game/scripts/gen-hats.mjs +46 -2
  140. package/kits/hub-game/scripts/gen-role.mjs +80 -0
  141. package/kits/hub-game/scripts/test-act-core.mjs +167 -0
  142. package/kits/hub-game/scripts/test-actions-client.mjs +34 -0
  143. package/kits/hub-game/scripts/test-actors.mjs +48 -0
  144. package/kits/hub-game/scripts/test-analytics.mjs +100 -6
  145. package/kits/hub-game/scripts/test-apply-deck.mjs +122 -0
  146. package/kits/hub-game/scripts/test-back-visibility.mjs +3 -1
  147. package/kits/hub-game/scripts/test-ballot.mjs +2 -0
  148. package/kits/hub-game/scripts/test-car.mjs +43 -0
  149. package/kits/hub-game/scripts/test-decor-client.mjs +2 -1
  150. package/kits/hub-game/scripts/test-decor.mjs +77 -0
  151. package/kits/hub-game/scripts/test-device-class.mjs +83 -0
  152. package/kits/hub-game/scripts/test-door-analytics.mjs +1 -1
  153. package/kits/hub-game/scripts/test-emote-wheel.mjs +374 -0
  154. package/kits/hub-game/scripts/test-hats.mjs +5 -4
  155. package/kits/hub-game/scripts/test-host-go.mjs +265 -0
  156. package/kits/hub-game/scripts/test-hub-controls.mjs +108 -0
  157. package/kits/hub-game/scripts/test-hub-entry.mjs +531 -0
  158. package/kits/hub-game/scripts/test-hub-ops.mjs +103 -0
  159. package/kits/hub-game/scripts/test-hub-trip.mjs +20 -1
  160. package/kits/hub-game/scripts/test-hud-clear.mjs +12 -2
  161. package/kits/hub-game/scripts/test-hud-rate.mjs +6 -2
  162. package/kits/hub-game/scripts/test-hud-surface.mjs +272 -0
  163. package/kits/hub-game/scripts/test-idle.mjs +347 -1
  164. package/kits/hub-game/scripts/test-interest-cells.mjs +8 -1
  165. package/kits/hub-game/scripts/test-invites-client.mjs +42 -1
  166. package/kits/hub-game/scripts/test-load-abandon.mjs +2 -2
  167. package/kits/hub-game/scripts/test-manifest.mjs +30 -0
  168. package/kits/hub-game/scripts/test-menu-client.mjs +1 -1
  169. package/kits/hub-game/scripts/test-no-trips.mjs +42 -0
  170. package/kits/hub-game/scripts/test-placement-cache.mjs +1 -1
  171. package/kits/hub-game/scripts/test-quality.mjs +13 -0
  172. package/kits/hub-game/scripts/test-rehello.mjs +258 -3
  173. package/kits/hub-game/scripts/test-resume-pose-server.mjs +203 -0
  174. package/kits/hub-game/scripts/test-resync.mjs +196 -0
  175. package/kits/hub-game/scripts/test-role-client.mjs +427 -0
  176. package/kits/hub-game/scripts/test-role.mjs +350 -0
  177. package/kits/hub-game/scripts/test-safe-layout.mjs +50 -1
  178. package/kits/hub-game/scripts/test-soundscape.mjs +124 -7
  179. package/kits/hub-game/scripts/test-standing.mjs +15 -1
  180. package/kits/hub-game/scripts/test-talk-surface.mjs +296 -0
  181. package/kits/hub-game/scripts/test-tiers.mjs +13 -0
  182. package/kits/hub-game/scripts/test-track-queue.mjs +64 -0
  183. package/kits/hub-game/scripts/test-ui-dom-dom.mjs +96 -0
  184. package/kits/hub-game/scripts/test-ui-tree.mjs +711 -0
  185. package/kits/hub-game/scripts/test-vehicle-client.mjs +168 -0
  186. package/kits/hub-game/scripts/test-vehicle.mjs +135 -0
  187. package/kits/hub-game/scripts/test-world-labels.mjs +40 -0
  188. package/kits/hub-game/scripts/test-yours.mjs +33 -0
  189. package/kits/hub-game/tools/hubScene/export.mjs +613 -0
  190. package/kits/hub-game/tools/hubScene/hubdata.mjs +921 -0
  191. package/kits/hub-game/tools/hubScene/merge-root.mjs +39 -0
  192. package/kits/hub-game/tools/hubScene/nodeworld.mjs +227 -0
  193. package/kits/hub-game/tools/hubScene/test/export-fixture.mjs +810 -0
  194. package/kits/hub-game/tools/hubScene/test/fixture.json +637 -0
  195. package/kits/hub-game/tools/hubScene/test/paint-export.mjs +40 -0
  196. package/kits/hub-game/tools/hubScene/test/upload.test.mjs +655 -0
  197. package/kits/hub-game/tools/hubScene/upload.mjs +636 -0
  198. package/kits/hub-game/tools/hubScene/validate-manifest.mjs +301 -0
  199. package/kits/multiplayer-3d/castle.json +4 -4
  200. package/kits/multiplayer-3d/code/client/resumeGate.js +30 -2
  201. package/kits/multiplayer-3d/code/client/steer.js +3 -1
  202. package/kits/multiplayer-3d/code/systems/multiplayer.js +30 -2
  203. package/kits/multiplayer-3d/package-lock.json +1 -1
  204. package/kits/multiplayer-3d/scripts/test-resume-gate.mjs +74 -2
  205. package/kits/physics-3d/CLAUDE.md +1 -1
  206. package/kits/physics-3d/behaviors/Player.jsx +37 -27
  207. package/kits/physics-3d/castle.json +2 -2
  208. package/kits/physics-3d/docs/engine-geometry-memory.md +23 -0
  209. package/kits/physics-3d/engine3d/memoryprofile.js +17 -0
  210. package/kits/physics-3d/engine3d/playerRun.js +6 -1
  211. package/kits/physics-3d/engine3d/pxmodel.js +6 -1
  212. package/kits/physics-3d/engine3d/world3d.js +6 -3
  213. package/kits/physics-3d/package.json +1 -1
  214. package/kits/physics-3d/play/behaviors/Player.js +40 -28
  215. package/kits/physics-3d/scripts/test-memory-profile.mjs +237 -0
  216. package/kits/physics-3d/systems/physics3d.js +5 -2
  217. package/kits/real-time/castle.json +2 -2
  218. package/kits/real-time/code/client/messages.js +5 -0
  219. package/kits/real-time/code/server/session.js +28 -1
  220. package/kits/real-time/package-lock.json +1 -1
  221. package/package.json +5 -4
  222. package/vendor/three/LICENSE +21 -0
  223. package/vendor/three/build/three.core.js +58773 -0
  224. package/vendor/three/build/three.module.js +18251 -0
  225. package/vendor/three/examples/jsm/controls/OrbitControls.js +1860 -0
  226. package/vendor/three/examples/jsm/controls/TransformControls.js +1918 -0
  227. package/vendor/three/examples/jsm/exporters/GLTFExporter.js +3595 -0
  228. package/vendor/three/examples/jsm/geometries/RoundedBoxGeometry.js +216 -0
  229. package/vendor/three/examples/jsm/math/MeshSurfaceSampler.js +315 -0
  230. package/vendor/three/examples/jsm/postprocessing/EffectComposer.js +363 -0
  231. package/vendor/three/examples/jsm/postprocessing/MaskPass.js +195 -0
  232. package/vendor/three/examples/jsm/postprocessing/OutputPass.js +139 -0
  233. package/vendor/three/examples/jsm/postprocessing/Pass.js +191 -0
  234. package/vendor/three/examples/jsm/postprocessing/RenderPass.js +183 -0
  235. package/vendor/three/examples/jsm/postprocessing/ShaderPass.js +135 -0
  236. package/vendor/three/examples/jsm/shaders/CopyShader.js +52 -0
  237. package/vendor/three/examples/jsm/shaders/OutputShader.js +103 -0
  238. package/vendor/three/examples/jsm/utils/BufferGeometryUtils.js +1435 -0
  239. package/vendor/three/package.json +134 -0
@@ -0,0 +1,333 @@
1
+ import { parseAst } from 'vite';
2
+ const wide = /[\u0100-\u{10ffff}]/u;
3
+ const wideGlobal = /[\u0100-\u{10ffff}]/gu;
4
+ const unitEscape = (s) => s.split('').map((c) => `\\u${c.charCodeAt(0).toString(16).padStart(4, '0')}`).join('');
5
+ const pointEscape = (s) => `\\u{${s.codePointAt(0).toString(16)}}`;
6
+ export function countWideCharacters(source) {
7
+ return source.match(wideGlobal)?.length ?? 0;
8
+ }
9
+ // Consume existing escapes first: replacing only the character in `\漢`
10
+ // would turn an identity escape into a literal backslash followed by "u6f22".
11
+ function escapeRaw(source, escape, lineContinuations = false) {
12
+ return source.replace(/\\[\s\S]|[\u0100-\u{10ffff}]/gu, (token) => {
13
+ const c = token.startsWith('\\') ? token.slice(1) : token;
14
+ if (lineContinuations && token.startsWith('\\') && /[\u2028\u2029]/.test(c))
15
+ return '\\\n';
16
+ return wide.test(c) ? escape(c) : token;
17
+ });
18
+ }
19
+ /** Preserve unknown syntax and tagged-template raw text; callers count leftovers. */
20
+ export function latin1JavaScript(source) {
21
+ if (!wide.test(source))
22
+ return source;
23
+ try {
24
+ const ast = parseAst(source);
25
+ const protectedRanges = [];
26
+ const pending = [{ value: ast, tagged: false }];
27
+ while (pending.length) {
28
+ const { value, tagged } = pending.pop();
29
+ if (Array.isArray(value)) {
30
+ for (const child of value)
31
+ pending.push({ value: child, tagged });
32
+ continue;
33
+ }
34
+ if (!value || typeof value !== 'object')
35
+ continue;
36
+ const node = value;
37
+ if (typeof node.type !== 'string')
38
+ continue;
39
+ const raw = source.slice(node.start, node.end);
40
+ let text = raw;
41
+ if (node.type === 'Literal') {
42
+ const regex = node.regex;
43
+ if (wide.test(raw)) {
44
+ if (regex)
45
+ text = escapeRaw(raw, /[uv]/.test(regex.flags) ? pointEscape : unitEscape);
46
+ else if (typeof node.value === 'string')
47
+ text = escapeRaw(raw, unitEscape, true);
48
+ }
49
+ }
50
+ else if (node.type === 'Identifier' || node.type === 'PrivateIdentifier') {
51
+ // Supplementary identifier characters require a code-point escape;
52
+ // adjacent surrogate escapes are not legal identifier syntax.
53
+ text = raw.replace(wideGlobal, (c) => c.length === 2 ? pointEscape(c) : unitEscape(c));
54
+ }
55
+ else if (node.type === 'TemplateElement') {
56
+ if (!tagged && wide.test(raw)) {
57
+ text = escapeRaw(raw, unitEscape, true);
58
+ }
59
+ }
60
+ else {
61
+ for (const [key, child] of Object.entries(node)) {
62
+ pending.push({ value: child, tagged: (node.type === 'TaggedTemplateExpression' && key === 'quasi') ||
63
+ (node.type === 'TemplateLiteral' && key === 'quasis' && tagged) });
64
+ }
65
+ continue;
66
+ }
67
+ protectedRanges.push({ start: node.start, end: node.end, text });
68
+ }
69
+ // A hashbang is a comment through its first line terminator, even if it
70
+ // contains what looks like a block-comment opener.
71
+ if (source.startsWith('#!')) {
72
+ const lineEnd = source.search(/[\r\n\u2028\u2029]/);
73
+ const end = lineEnd < 0 ? source.length : lineEnd;
74
+ protectedRanges.push({ start: 0, end, text: source.slice(0, end).replace(wideGlobal, '?') });
75
+ }
76
+ protectedRanges.sort((a, b) => a.start - b.start || b.end - a.end);
77
+ // Everything between literal/identifier/quasi tokens is code or a comment.
78
+ // Only touch comments and JS whitespace there, preserving line boundaries.
79
+ const gap = (s) => s.replace(/\/\/[^\r\n\u2028\u2029]*|\/\*[\s\S]*?\*\/|[\u0100-\u{10ffff}]/gu, (token) => token.startsWith('/')
80
+ ? token.replace(wideGlobal, (c) => /[\u2028\u2029]/.test(c) ? '\n' : '?')
81
+ : /\s/u.test(token) ? (/[\u2028\u2029]/.test(token) ? '\n' : ' ') : token);
82
+ const parts = [];
83
+ let offset = 0;
84
+ for (const edit of protectedRanges) {
85
+ if (edit.start < offset)
86
+ continue; // e.g. shorthand property key/value
87
+ parts.push(gap(source.slice(offset, edit.start)), edit.text);
88
+ offset = edit.end;
89
+ }
90
+ parts.push(gap(source.slice(offset)));
91
+ return parts.join('');
92
+ }
93
+ catch {
94
+ // Parsing and AST materialization/traversal can both fail on deep syntax.
95
+ // Keep the original bytes so the caller's leftover warning accounts for it.
96
+ return source;
97
+ }
98
+ }
99
+ export function latin1Css(source) {
100
+ return escapeRaw(source, (c) => `\\${c.codePointAt(0).toString(16).padStart(6, '0')} `);
101
+ }
102
+ const htmlReferences = (s) => s.replace(wideGlobal, (c) => {
103
+ const point = c.codePointAt(0);
104
+ // HTML references cannot represent isolated surrogates.
105
+ return point >= 0xd800 && point <= 0xdfff ? c : `&#${point};`;
106
+ });
107
+ const asciiLower = (s) => s.replace(/[A-Z]/g, (c) => c.toLowerCase());
108
+ const htmlText = (s) => /<[a-zA-Z!/?]/.test(s) ? s : htmlReferences(s);
109
+ function dataScript(source) {
110
+ try {
111
+ JSON.parse(source);
112
+ return source.replace(/"(?:[^"\\]|\\[\s\S])*"/g, (s) => s.replace(wideGlobal, unitEscape));
113
+ }
114
+ catch {
115
+ return source;
116
+ }
117
+ }
118
+ const htmlSpace = (c) => /[\t\n\f\r ]/.test(c);
119
+ // Each character belongs to exactly one name/value scan. In particular, a
120
+ // quoted value cannot also be retried as an unquoted one on an incomplete tag.
121
+ function scanTag(source, start) {
122
+ let i = start + 1;
123
+ const closing = source[i] === '/';
124
+ if (closing)
125
+ i++;
126
+ const nameStart = i;
127
+ while (i < source.length && !htmlSpace(source[i]) && source[i] !== '/' && source[i] !== '>')
128
+ i++;
129
+ const tagName = asciiLower(source.slice(nameStart, i));
130
+ const name = closing ? undefined : tagName;
131
+ let selfClosing = false;
132
+ const attrs = new Map();
133
+ const values = [];
134
+ while (i < source.length) {
135
+ const spaceStart = i;
136
+ while (i < source.length && htmlSpace(source[i]))
137
+ i++;
138
+ if (source[i] === '/') {
139
+ // The tokenizer self-closes only on "/>"; "/ >" is an ignored solidus.
140
+ selfClosing = source[i + 1] === '>';
141
+ i++;
142
+ while (i < source.length && htmlSpace(source[i]))
143
+ i++;
144
+ if (source[i] !== '>')
145
+ return { end: i };
146
+ }
147
+ if (source[i] === '>') {
148
+ const parts = [];
149
+ let offset = start;
150
+ for (const value of values) {
151
+ parts.push(source.slice(offset, value.start), value.text);
152
+ offset = value.end;
153
+ }
154
+ parts.push(source.slice(offset, i + 1));
155
+ return { end: i + 1, name, closeName: closing ? tagName : undefined, selfClosing, attrs, text: parts.join('') };
156
+ }
157
+ if (i === spaceStart || i === source.length)
158
+ return { end: i };
159
+ const keyStart = i;
160
+ while (i < source.length && !htmlSpace(source[i]) && !'=/>'.includes(source[i]))
161
+ i++;
162
+ if (i === keyStart)
163
+ return { end: i };
164
+ const key = asciiLower(source.slice(keyStart, i));
165
+ const keyEnd = i;
166
+ while (i < source.length && htmlSpace(source[i]))
167
+ i++;
168
+ if (source[i] !== '=') {
169
+ i = keyEnd; // Let the next iteration consume the attribute separator.
170
+ continue;
171
+ }
172
+ i++;
173
+ while (i < source.length && htmlSpace(source[i]))
174
+ i++;
175
+ const valueStart = i;
176
+ const quote = source[i] === '"' || source[i] === "'" ? source[i++] : undefined;
177
+ const bareStart = i;
178
+ if (quote) {
179
+ while (i < source.length && source[i] !== quote)
180
+ i++;
181
+ if (i === source.length)
182
+ return { end: i };
183
+ }
184
+ else {
185
+ while (i < source.length && !htmlSpace(source[i]) && source[i] !== '>')
186
+ i++;
187
+ if (i === valueStart)
188
+ return { end: i };
189
+ }
190
+ if (!attrs.has(key))
191
+ attrs.set(key, source.slice(bareStart, i));
192
+ if (quote)
193
+ i++;
194
+ values.push({ start: valueStart, end: i, text: htmlReferences(source.slice(valueStart, i)) });
195
+ }
196
+ return { end: i };
197
+ }
198
+ function commentEnd(source, start) {
199
+ // The comment-start states also accept abrupt empty-comment endings.
200
+ if (source[start + 4] === '>')
201
+ return start + 5;
202
+ if (source.startsWith('->', start + 4))
203
+ return start + 6;
204
+ let i = start + 4;
205
+ while ((i = source.indexOf('>', i)) !== -1) {
206
+ if ((i >= start + 6 && source.slice(i - 2, i) === '--') ||
207
+ (i >= start + 7 && source.slice(i - 3, i) === '--!'))
208
+ return i + 1;
209
+ i++;
210
+ }
211
+ return source.length;
212
+ }
213
+ // Inside svg/math, raw-text names are ordinary elements (a self-closing
214
+ // <style/> opens nothing). These start tags break out of foreign content or
215
+ // switch back to HTML rules there; the scanner preserves the rest instead.
216
+ const foreignExits = new Set(['b', 'big', 'blockquote', 'body', 'br', 'center', 'code', 'dd', 'div', 'dl', 'dt',
217
+ 'em', 'embed', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'hr', 'i', 'img', 'li', 'listing', 'menu', 'meta',
218
+ 'nobr', 'ol', 'p', 'pre', 'ruby', 's', 'small', 'span', 'strong', 'strike', 'sub', 'sup', 'table', 'tt', 'u',
219
+ 'ul', 'var', 'font', 'foreignobject', 'desc', 'title', 'mi', 'mo', 'mn', 'ms', 'mtext', 'annotation-xml']);
220
+ // A source-preserving HTML scanner: only attribute VALUES and text support
221
+ // character references. Names, declarations and unknown raw-text bodies stay
222
+ // intact. No DOM serialization, so Latin-1-only bundles retain their bytes.
223
+ export function latin1Html(source) {
224
+ if (!wide.test(source))
225
+ return source;
226
+ const parts = [];
227
+ let offset = 0;
228
+ let cursor = 0;
229
+ let plaintext = false;
230
+ const foreign = []; // open elements inside svg/math
231
+ // Frameset and select insertion modes drop an svg/math start tag, so what
232
+ // follows it is HTML. Seeing either makes a later svg/math unmodelled.
233
+ let dropsForeign = false;
234
+ while ((cursor = source.indexOf('<', cursor)) !== -1) {
235
+ const start = cursor;
236
+ if (source.startsWith('<!', start) || source.startsWith('<?', start)) {
237
+ const comment = source.startsWith('<!--', start);
238
+ // CDATA exists only in foreign content; in HTML it is a bogus comment.
239
+ const cdata = foreign.length > 0 && source.startsWith('<![CDATA[', start);
240
+ const terminator = cdata ? ']]>' : '>';
241
+ const end = comment ? commentEnd(source, start) : source.indexOf(terminator, start + 2);
242
+ cursor = comment ? end : end < 0 ? source.length : end + terminator.length;
243
+ // Incomplete declarations were not recognized by the original scanner.
244
+ if (!comment && !cdata && end < 0)
245
+ break;
246
+ parts.push(htmlText(source.slice(offset, start)));
247
+ const tag = source.slice(start, cursor);
248
+ parts.push(comment ? tag.replace(wideGlobal, '?') : tag);
249
+ offset = cursor;
250
+ continue;
251
+ }
252
+ if (!/^<\/?[a-zA-Z]/.test(source.slice(start, start + 3))) {
253
+ // "</" before anything but a letter is a bogus comment through ">".
254
+ if (source[start + 1] === '/') {
255
+ const end = source.indexOf('>', start + 2);
256
+ cursor = end < 0 ? source.length : end + 1;
257
+ parts.push(htmlText(source.slice(offset, start)), source.slice(start, cursor).replace(wideGlobal, '?'));
258
+ offset = cursor;
259
+ continue;
260
+ }
261
+ cursor++;
262
+ continue;
263
+ }
264
+ const tag = scanTag(source, start);
265
+ cursor = tag.end;
266
+ // Do not look for apparent tags inside an incomplete/unsupported tag: they
267
+ // may belong to an attribute value. Preserve the rest rather than guess.
268
+ if (tag.text === undefined)
269
+ return parts.join('') + source.slice(offset);
270
+ const { name, closeName, selfClosing, attrs } = tag;
271
+ if (foreign.length) {
272
+ // Only a balanced svg/math subtree is followed; anything else may
273
+ // change the tokenizer's context in ways this scanner does not model.
274
+ if (name ? foreignExits.has(name) : closeName !== foreign.at(-1))
275
+ return parts.join('') + source.slice(offset);
276
+ parts.push(htmlText(source.slice(offset, start)), tag.text);
277
+ offset = cursor;
278
+ if (name && !selfClosing)
279
+ foreign.push(name);
280
+ else if (!name)
281
+ foreign.pop();
282
+ continue;
283
+ }
284
+ parts.push(htmlText(source.slice(offset, start)), tag.text);
285
+ offset = cursor;
286
+ if (name === 'frameset' || name === 'select')
287
+ dropsForeign = true;
288
+ if ((name === 'svg' || name === 'math') && !selfClosing) {
289
+ if (dropsForeign)
290
+ return parts.join('') + source.slice(offset);
291
+ foreign.push(name);
292
+ continue;
293
+ }
294
+ if (name === 'plaintext') {
295
+ plaintext = true;
296
+ break;
297
+ }
298
+ if (!name || !['script', 'style', 'xmp', 'iframe', 'noembed', 'noframes', 'noscript', 'textarea', 'title'].includes(name))
299
+ continue;
300
+ const close = new RegExp(`</${name}[\\t\\n\\f\\r />]`, 'gi');
301
+ close.lastIndex = offset;
302
+ const end = close.exec(source)?.index ?? source.length;
303
+ const body = source.slice(offset, end);
304
+ let text = body;
305
+ if (name === 'style')
306
+ text = latin1Css(body);
307
+ else if (name === 'textarea' || name === 'title')
308
+ text = htmlReferences(body);
309
+ else if (name === 'script') {
310
+ const declaredType = attrs.get('type') ?? (attrs.get('language') ? `text/${attrs.get('language')}` : '');
311
+ const type = asciiLower(declaredType.replace(/^[\t\n\f\r ]+|[\t\n\f\r ]+$/g, ''));
312
+ // Script's escaped/double-escaped HTML tokenizer states need more than
313
+ // an end-tag search. Leave such unusual markup alone rather than guess.
314
+ if (body.includes('<!--'))
315
+ return parts.join('') + source.slice(offset);
316
+ if (!type || type === 'module' || /^(?:text|application)\/(?:java|ecma)script$/.test(type)) {
317
+ text = latin1JavaScript(body);
318
+ }
319
+ else if (/^(?:application\/(?:[\w.-]+\+)?json|importmap|speculationrules)$/.test(type)) {
320
+ text = dataScript(body);
321
+ }
322
+ }
323
+ parts.push(text);
324
+ offset = end;
325
+ cursor = end;
326
+ }
327
+ parts.push(plaintext ? source.slice(offset) : htmlText(source.slice(offset)));
328
+ return parts.join('');
329
+ }
330
+ export function warnWideCharacters(count) {
331
+ if (count)
332
+ console.warn(`Warning: deck bundle retains ${count} characters above U+00FF that could not be safely escaped.`);
333
+ }
@@ -8,6 +8,7 @@ import type { CastleLeaderboardPayload } from './leaderboardPanel.js';
8
8
 
9
9
  export interface HostContext {
10
10
  deckId: string | null;
11
+ runningDeckId?: string | null;
11
12
  sessionId: string | null;
12
13
  userId: string | null;
13
14
  username: string | null;
@@ -73,6 +74,13 @@ export interface HostCapabilities {
73
74
  signal?: AbortSignal,
74
75
  ) => Promise<MultiplayerJoinDestinationResult>;
75
76
  hub?: HostHub;
77
+ localCache?: HostLocalCache;
78
+ }
79
+
80
+ export interface HostLocalCache {
81
+ get(deckId: string, key: string): Promise<ArrayBuffer | string | null>;
82
+ set(deckId: string, key: string, value: ArrayBuffer | string): Promise<void>;
83
+ remove(deckId: string, key: string): Promise<void>;
76
84
  }
77
85
 
78
86
  export type OracleStream = (url: string, body: string, sink: OracleStreamSink) => () => void;
@@ -238,7 +246,8 @@ export interface HostHub {
238
246
  reportChat?(messageId: string, ctx: HostContext, block?: boolean, confirmBlock?: HubChatBlockConfirmation, signal?: AbortSignal): Promise<HubReportResult>;
239
247
  commit(sessionId: string, ctx: HostContext): Promise<HubCommitResult>;
240
248
  cancel(sessionId: string | null, ctx: HostContext): Promise<HubCancelResult>;
241
- sessionAcquired?(sessionId: string, ctx: HostContext): void;
249
+ sessionAcquisitionStarted?(ctx: HostContext): number;
250
+ sessionAcquired?(sessionId: string, ctx: HostContext, acquisition?: number): void;
242
251
  }
243
252
 
244
253
  export interface LeaderboardStreakCredit {
@@ -99,7 +99,11 @@ const COMMAND_NAMES = [
99
99
  "cauldronStorage.boardTop",
100
100
  "cauldronStorage.boardGet",
101
101
  "cauldronStorage.usage",
102
+ "rooms.list",
102
103
  "lifecycle.restoreState",
104
+ "localCache.get",
105
+ "localCache.set",
106
+ "localCache.remove",
103
107
  ];
104
108
  // Platform/capability commands: NOT serviced by graphqlFetch. They're dispatched
105
109
  // to the host's optional platformHandler (mobile renders native UI; web shows an
@@ -171,10 +175,13 @@ export async function executeCommand(ctx, command, params, capabilities, options
171
175
  },
172
176
  };
173
177
  }
178
+ const acquisition = isSessionAcquisition(command)
179
+ ? capabilities.hub?.sessionAcquisitionStarted?.(ctx)
180
+ : undefined;
174
181
  try {
175
182
  const data = await dispatchCommand(ctx, command, (params ?? {}), capabilities, options);
176
183
  capabilities.hub?.assertActive?.();
177
- noteAcquiredSession(ctx, command, data, capabilities);
184
+ noteAcquiredSession(ctx, command, data, capabilities, acquisition);
178
185
  return { ok: true, data };
179
186
  }
180
187
  catch (error) {
@@ -185,17 +192,21 @@ function dispatchCommand(ctx, command, params, caps, options) {
185
192
  if (isTrustedDataCommand(command)) {
186
193
  return runTrustedDataCommand(ctx, command, params, caps.graphqlFetch);
187
194
  }
195
+ if (isLocalCacheCommand(command)) {
196
+ return runLocalCacheCommand(ctx, command, params, caps.localCache);
197
+ }
188
198
  return runCommand(ctx, command, params, caps, options);
189
199
  }
190
- // A door's source is the session the deck last acquired in its place.
191
- function noteAcquiredSession(ctx, command, data, caps) {
192
- if (!caps.hub?.sessionAcquired ||
193
- (command !== "multiplayer.getSession" && command !== "multiplayer.joinDestination")) {
200
+ function isSessionAcquisition(command) {
201
+ return command === "multiplayer.getSession" || command === "multiplayer.joinDestination";
202
+ }
203
+ // A door's source is the session of the acquisition the deck started last in its place.
204
+ function noteAcquiredSession(ctx, command, data, caps, acquisition) {
205
+ if (!caps.hub?.sessionAcquired || !isSessionAcquisition(command))
194
206
  return;
195
- }
196
207
  const result = data;
197
208
  if (result?.status === "ok" && typeof result.sessionId === "string" && result.sessionId) {
198
- caps.hub.sessionAcquired(result.sessionId, ctx);
209
+ caps.hub.sessionAcquired(result.sessionId, ctx, acquisition);
199
210
  }
200
211
  }
201
212
  const HUB_VISIT_COMMANDS = new Set([
@@ -329,6 +340,8 @@ function runCommand(ctx, command, params, caps, options) {
329
340
  return cauldronStorageBoardGet(ctx, params, gql);
330
341
  case "cauldronStorage.usage":
331
342
  return cauldronStorageUsage(ctx, gql);
343
+ case "rooms.list":
344
+ return roomsList(ctx, gql);
332
345
  // Platform commands are handled above; listed here to keep the switch
333
346
  // exhaustive over CommandName.
334
347
  case "pass.offer":
@@ -369,6 +382,32 @@ function runTrustedDataCommand(ctx, command, params, gql) {
369
382
  return partySay(params, gql);
370
383
  }
371
384
  }
385
+ function isLocalCacheCommand(command) {
386
+ return command.startsWith("localCache.");
387
+ }
388
+ async function runLocalCacheCommand(ctx, command, params, store) {
389
+ const deckId = ctx.runningDeckId;
390
+ if (!deckId) {
391
+ throw new HostCommandError("MISSING_DECK_ID", "Save this deck to Castle before using this API.", command);
392
+ }
393
+ const key = asBoundedText(params.key, "key", command, 1_024, 4_096);
394
+ switch (command) {
395
+ case "localCache.get":
396
+ return { value: store ? await store.get(deckId, key) : null };
397
+ case "localCache.set":
398
+ await store?.set(deckId, key, asLocalCacheValue(params.value, command));
399
+ return {};
400
+ case "localCache.remove":
401
+ await store?.remove(deckId, key);
402
+ return {};
403
+ }
404
+ }
405
+ function asLocalCacheValue(value, command) {
406
+ if (typeof value === "string" || value instanceof ArrayBuffer) {
407
+ return value;
408
+ }
409
+ throw new HostCommandError("INVALID_ARGUMENT", `Castle command ${command} requires a value that is an ArrayBuffer or a string.`, command);
410
+ }
372
411
  async function multiplayerGetSession(ctx, params, caps) {
373
412
  const request = multiplayerSessionRequest(params);
374
413
  const deckId = requireDeckId(ctx, "multiplayer.getSession");
@@ -2360,6 +2399,45 @@ async function cauldronStorageUsage(ctx, gql) {
2360
2399
  const data = await graphql(gql, CAULDRON_STORAGE_USAGE_QUERY, { deckId }, "cauldronStorage.usage");
2361
2400
  return { usage: data.cauldronStorageUsage };
2362
2401
  }
2402
+ async function roomsList(ctx, gql) {
2403
+ const deckId = requireDeckId(ctx, "rooms.list");
2404
+ const data = await graphql(gql, ROOMS_LIST_QUERY, { deckId }, "rooms.list");
2405
+ // Ghost answers null to anyone but the deck's owner, a Castle admin or a
2406
+ // member of the presence gate, and for a deck the player cannot see.
2407
+ const presence = data.cauldronDeckPresence;
2408
+ if (typeof presence !== "object" || presence === null)
2409
+ return null;
2410
+ const record = presence;
2411
+ const rooms = Array.isArray(record.routes) ? record.routes.flatMap(publicRoomSummary) : [];
2412
+ const total = record.total;
2413
+ return {
2414
+ total: isCount(total) ? total : rooms.reduce((sum, room) => sum + room.players, 0),
2415
+ rooms,
2416
+ };
2417
+ }
2418
+ function publicRoomSummary(raw) {
2419
+ if (typeof raw !== "object" || raw === null)
2420
+ return [];
2421
+ const record = raw;
2422
+ const sessionId = asOptionalString(record.sessionId);
2423
+ const { players, maxPlayers } = record;
2424
+ if (!sessionId || !isCount(players) || !isCount(maxPlayers))
2425
+ return [];
2426
+ const routeId = asOptionalString(record.routeId);
2427
+ const slot = asOptionalString(record.slot);
2428
+ return [
2429
+ {
2430
+ sessionId,
2431
+ ...(routeId ? { routeId } : {}),
2432
+ ...(slot ? { slot } : {}),
2433
+ players,
2434
+ maxPlayers,
2435
+ },
2436
+ ];
2437
+ }
2438
+ function isCount(value) {
2439
+ return Number.isSafeInteger(value) && value >= 0;
2440
+ }
2363
2441
  const CHARACTER_OPERATION_FIELDS = `
2364
2442
  operationId
2365
2443
  characterId
@@ -2961,11 +3039,24 @@ const CAULDRON_STORAGE_BOARD_TOP_QUERY = `
2961
3039
  }
2962
3040
  }
2963
3041
  `;
3042
+ const ROOMS_LIST_QUERY = `
3043
+ query CastleRoomsList($deckId: ID!) {
3044
+ cauldronDeckPresence(deckId: $deckId) {
3045
+ total
3046
+ routes { sessionId routeId slot players maxPlayers }
3047
+ }
3048
+ }
3049
+ `;
2964
3050
  const CAULDRON_STORAGE_USAGE_QUERY = `
2965
3051
  query CastleCauldronStorageUsage($deckId: ID!) {
2966
3052
  cauldronStorageUsage(deckId: $deckId) {
2967
3053
  player { keyCount keyLimit byteCount byteLimit }
2968
3054
  shared { keyCount keyLimit byteCount byteLimit }
3055
+ rate {
3056
+ callerClass
3057
+ caller { opsUsed opsLimit bytesUsed bytesLimit }
3058
+ deck { opsUsed opsLimit bytesUsed bytesLimit }
3059
+ }
2969
3060
  }
2970
3061
  }
2971
3062
  `;
@@ -3319,6 +3410,23 @@ function invalidPartyArgument(command, detail) {
3319
3410
  export function hubBackEnvelope() {
3320
3411
  return { castleSdk: 1, hub: { type: "back" } };
3321
3412
  }
3413
+ // What a host posts to the deck to take the player through a door of the place
3414
+ // it shows, e.g. a trip begun outside this page. The deck answers it like a
3415
+ // fired pad (Hub.go behind its door animation); a deck that does not know the
3416
+ // door, or an older deck, ignores it. `owner` is the user id whose House a
3417
+ // House door leads to.
3418
+ export function hubGoEnvelope(go) {
3419
+ return {
3420
+ castleSdk: 1,
3421
+ hub: {
3422
+ type: "go",
3423
+ doorId: go.doorId,
3424
+ ...(go.owner !== undefined ? { owner: go.owner } : {}),
3425
+ ...(go.title !== undefined ? { title: go.title } : {}),
3426
+ ...(go.party !== undefined ? { party: go.party } : {}),
3427
+ },
3428
+ };
3429
+ }
3322
3430
  // Ghost's source check reads the session's heartbeat roster, which can lag an
3323
3431
  // arrival by up to 15 s: a door used in that window answers `forbidden`.
3324
3432
  const HUB_ROSTER_LAG_MS = 16_000;
@@ -3472,7 +3580,8 @@ export function createGhostHubVisit(options) {
3472
3580
  reportChat: (messageId, _ctx, block, confirmBlock, signal) => visit.reportChat(messageId, block, confirmBlock, signal),
3473
3581
  commit: (nonce) => visit.commit(nonce),
3474
3582
  cancel: (nonce) => visit.cancel(nonce),
3475
- sessionAcquired: (sessionId) => visit.sessionAcquired(sessionId),
3583
+ sessionAcquisitionStarted: () => visit.sessionAcquisitionStarted(),
3584
+ sessionAcquired: (sessionId, _ctx, acquisition) => visit.sessionAcquired(sessionId, acquisition),
3476
3585
  placeDeckId: () => visit.place,
3477
3586
  state: () => visit.state(),
3478
3587
  };
@@ -3561,6 +3670,8 @@ class GhostHubVisitImpl {
3561
3670
  arrivalDoorId = null;
3562
3671
  placeKind = "place";
3563
3672
  session = null;
3673
+ sessionAcquisitions = 0;
3674
+ acceptedSessionAcquisition = 0;
3564
3675
  chatSenders = new Map();
3565
3676
  chatBlockPending = null;
3566
3677
  chatBlockNextAt = 0;
@@ -3604,8 +3715,21 @@ class GhostHubVisitImpl {
3604
3715
  : null,
3605
3716
  };
3606
3717
  }
3607
- sessionAcquired(sessionId) {
3718
+ // The deck keeps the connection of the join it started last that succeeded,
3719
+ // so an earlier join that answers after a later one (ghost placed it in another
3720
+ // shard) must not replace its session as the door source, or the player stands
3721
+ // in one session while every door names the other. A later join that failed
3722
+ // replaces nothing: the deck keeps its earlier connection then.
3723
+ sessionAcquisitionStarted() {
3724
+ return ++this.sessionAcquisitions;
3725
+ }
3726
+ sessionAcquired(sessionId, acquisition) {
3608
3727
  this.assertActive();
3728
+ if (acquisition !== undefined) {
3729
+ if (acquisition < this.acceptedSessionAcquisition)
3730
+ return;
3731
+ this.acceptedSessionAcquisition = acquisition;
3732
+ }
3609
3733
  this.chatBlockPending?.abort();
3610
3734
  this.chatSenders.clear();
3611
3735
  this.session = { sessionId, at: this.now() };
@@ -39,6 +39,7 @@ export interface CastleJson {
39
39
  starterConfig?: Record<string, unknown>;
40
40
  onCheck?: string;
41
41
  onPack?: string;
42
+ exports?: Record<string, string>;
42
43
  devDecks?: Record<string, string>;
43
44
  experiments?: Record<string, ExperimentConfig>;
44
45
  devExperiments?: Record<string, string>;
@@ -129,6 +130,7 @@ export interface ServerHubPlaceConfig {
129
130
  title?: unknown;
130
131
  result?: unknown;
131
132
  maxDurationSec?: unknown;
133
+ houseResume?: unknown;
132
134
  }
133
135
  export interface ServerHubConfig extends ServerHubPlaceConfig {
134
136
  analytics?: boolean;
@@ -267,6 +267,7 @@ function hubPlaceConfig(place) {
267
267
  ...(place.title === undefined ? {} : { title: place.title }),
268
268
  ...(place.result === undefined ? {} : { result: place.result }),
269
269
  ...(place.maxDurationSec === undefined ? {} : { maxDurationSec: place.maxDurationSec }),
270
+ ...(place.houseResume === undefined ? {} : { houseResume: place.houseResume }),
270
271
  };
271
272
  }
272
273
  function pushConfig(value) {
@@ -0,0 +1,35 @@
1
+ /** The env var that turns exporters on for `save-deck`. */
2
+ export declare const SAVE_EXPORTS_ENV = "CASTLE_SAVE_EXPORTS";
3
+ export interface ExportTarget {
4
+ alias: string;
5
+ name: string;
6
+ modulePath: string;
7
+ outDir: string;
8
+ cacheDir: string;
9
+ }
10
+ export interface ExportOutcome {
11
+ alias: string;
12
+ name: string;
13
+ ok: boolean;
14
+ /** The JSON the exporter printed last, or null when it printed none. */
15
+ summary: unknown;
16
+ error?: string;
17
+ }
18
+ /** `~/.castle/export-cache/<name>/`, shared by every deck on this machine. */
19
+ export declare function exportCacheRoot(): string;
20
+ export declare function exportCacheDir(name: string): string;
21
+ /**
22
+ * Every exporter that applies to this deck and may run here: each import's, in
23
+ * pin order, then the deck's own (only for a kit this CLI ships, as with
24
+ * `onCheck`). The first to claim a name keeps it.
25
+ */
26
+ export declare function exportTargets(deckDir: string, log: (message: string) => void): ExportTarget[];
27
+ /** Run every applicable exporter, one at a time. */
28
+ export declare function runDeckExports(deckDir: string, log?: (message: string) => void): Promise<ExportOutcome[]>;
29
+ /** `castle-web export [dir]`: prints each summary; exits 1 when one failed. */
30
+ export declare function exportCommand(dir: string): Promise<void>;
31
+ /**
32
+ * After a successful save, under CASTLE_SAVE_EXPORTS=1 only. Never throws:
33
+ * whatever an exporter does, the save already happened and stands.
34
+ */
35
+ export declare function runSaveExports(deckDir: string): Promise<void>;