cajonzero 0.1.2 → 0.2.0

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.
@@ -0,0 +1,67 @@
1
+ /**
2
+ * cajonzero — the map catalog (`cajonzero/maps.json`).
3
+ *
4
+ * A map root is either:
5
+ *
6
+ * - a same-origin path (`/maps/<slug>/`) that lives in the deployment's static
7
+ * assets — `cj0 add` writes it there and the worker reads it through
8
+ * `env.ASSETS`; or
9
+ * - an absolute `http(s)://…/` URL for maps hosted on an external OSS/CDN
10
+ * (the manual/split-CDN escape hatch).
11
+ *
12
+ * Expected layout under `entry.root` (exactly the archive layout):
13
+ *
14
+ * ```text
15
+ * <root>/bundle.json
16
+ * <root>/worlds/<worldId>/manifest.json
17
+ * <root>/worlds/<worldId>/data/project-state.json
18
+ * <root>/worlds/<worldId>/data/blobs/<cid>
19
+ * ```
20
+ *
21
+ * Worker path: URL handling + validation only, no Node globals.
22
+ */
23
+ /** The only catalog version this build understands. */
24
+ declare const MAP_CATALOG_VERSION = 1;
25
+ /** One map in the catalog. */
26
+ interface MapEntry {
27
+ /** Stable room/catalog id (`omega`, `drift`, …). */
28
+ readonly slug: string;
29
+ /** Same-origin path (`/maps/<slug>/`) or absolute `http(s)://…/` map root. */
30
+ readonly root: string;
31
+ /** `worlds/<worldId>` directory name; derived from `bundle.json` when absent. */
32
+ readonly worldId?: string;
33
+ /** Display name (falls back to the map's own manifest). */
34
+ readonly name?: string;
35
+ readonly author?: string;
36
+ readonly version?: string;
37
+ /** Optional content revision (e.g. `v1.0.4`); invalidates precomputed seeds. */
38
+ readonly etag?: string;
39
+ /** Cover image URL for the lobby. */
40
+ readonly cover?: string;
41
+ /** Optional CDN root for browser assets; defaults to {@link root}. */
42
+ readonly assetRoot?: string;
43
+ /**
44
+ * Project-relative private script pack (`cajonzero/private/<slug>.json.gz`).
45
+ * Written by `cj0 add/update`; `cj0 deploy` uploads it to KV and it is never
46
+ * served from `public/`.
47
+ */
48
+ readonly scriptsFile?: string;
49
+ }
50
+ /** The `maps.json` document. */
51
+ interface MapCatalog {
52
+ readonly version: typeof MAP_CATALOG_VERSION;
53
+ readonly maps: readonly MapEntry[];
54
+ }
55
+ /** No maps configured (the scaffold default). */
56
+ declare const EMPTY_MAP_CATALOG: MapCatalog;
57
+ /**
58
+ * Validate a parsed `maps.json`.
59
+ *
60
+ * @throws {MapCatalogError} for a malformed document, entry, or duplicate slug.
61
+ */
62
+ declare function parseMapCatalog(input: unknown): MapCatalog;
63
+ /** Look up a map by slug. */
64
+ declare function findMap(catalog: MapCatalog, slug: string): MapEntry | undefined;
65
+
66
+ export { EMPTY_MAP_CATALOG as E, findMap as f, parseMapCatalog as p };
67
+ export type { MapEntry as M, MapCatalog as a };
@@ -1,4 +1,4 @@
1
- import { T as TimestampedClientInput, N as NetPublic, O as NetSecret } from './providers-BX7e4pNW.js';
1
+ import { T as TimestampedClientInput, N as NetPublic, I as NetSecret } from './providers-Bu0-iMVs.js';
2
2
 
3
3
  /**
4
4
  * cajonzero — mudb protocol envelope (message-id tables + `raw` channel).
package/dist/core.d.ts CHANGED
@@ -1,6 +1,8 @@
1
- import { M as MapEntry, W as WorldSeed } from './providers-BX7e4pNW.js';
2
- export { c as EMPTY_MAP_CATALOG, E as EnvProvider, d as MapCatalog, e as Repos, R as Room, f as RoomOptions, g as RuntimeProviders, h as SETTINGS, i as SETTING_KEYS, a as SettingDefaults, j as SettingDefinition, k as Settings, l as SettingsError, m as SettingsErrorCode, n as SettingsService, o as StorageFactory, S as StorageSource, p as Store, q as WorldSeedReader, r as configureDefaultKV, s as createMemoryStore, t as createRepos, u as createSettingsService, v as createStore, w as findMap, x as getRuntimeProviders, y as isSettingKey, z as memoryDriver, A as parseMapCatalog, B as resolveAdminToken, C as resolveEnvironment, F as resolveRooms, G as resolveSessionSecret, H as resolveSettingDefaults, I as resolveStore, J as setRuntimeProviders, K as setStorageFactory } from './providers-BX7e4pNW.js';
3
- export { C as CajonzeroConfig, D as DEFAULT_CONFIG, G as GAME_NET_INBOUND_BASE, a as GAME_NET_OUTBOUND_BASE, I as INBOUND_LAYOUT, M as MAX_INBOUND_FRAME_BYTES, b as MapsConfig, N as NetCodec, c as NetCodecError, d as NetCodecErrorCode, e as NetCodecHandlers, f as NetCodecOptions, O as OFFICIAL_PREFIX, g as OUTBOUND_LAYOUT, P as ProtocolDirection, h as ProtocolLayout, i as ProtocolSchemaLike, R as RoomConfig, j as chainLayouts, l as layoutMessages, k as layoutProtocol, m as matchesLayout, n as messageIds, o as messageNameAt, r as readNetFrameHeader, p as readNetMessageType, q as resolveConfig } from './config-BOzAyP7m.js';
1
+ import { W as WorldSeed } from './providers-Bu0-iMVs.js';
2
+ export { E as EnvProvider, c as Repos, R as Room, d as RoomOptions, e as RuntimeProviders, f as SETTINGS, g as SETTING_KEYS, a as SettingDefaults, h as SettingDefinition, i as Settings, j as SettingsError, k as SettingsErrorCode, l as SettingsService, m as StorageFactory, S as StorageSource, n as Store, o as WorldSeedReader, p as configureDefaultKV, q as createMemoryStore, r as createRepos, s as createSettingsService, t as createStore, u as getRuntimeProviders, v as isSettingKey, w as memoryDriver, x as resolveAdminToken, y as resolveEnvironment, z as resolveRooms, A as resolveSessionSecret, B as resolveSettingDefaults, C as resolveStore, F as setRuntimeProviders, G as setStorageFactory } from './providers-Bu0-iMVs.js';
3
+ export { C as CajonzeroConfig, D as DEFAULT_CONFIG, G as GAME_NET_INBOUND_BASE, a as GAME_NET_OUTBOUND_BASE, I as INBOUND_LAYOUT, M as MAX_INBOUND_FRAME_BYTES, b as MapsConfig, N as NetCodec, c as NetCodecError, d as NetCodecErrorCode, e as NetCodecHandlers, f as NetCodecOptions, O as OFFICIAL_PREFIX, g as OUTBOUND_LAYOUT, P as ProtocolDirection, h as ProtocolLayout, i as ProtocolSchemaLike, R as RoomConfig, j as chainLayouts, l as layoutMessages, k as layoutProtocol, m as matchesLayout, n as messageIds, o as messageNameAt, r as readNetFrameHeader, p as readNetMessageType, q as resolveConfig } from './config-glwUbUbx.js';
4
+ import { M as MapEntry } from './catalog-BRO-mQoP.js';
5
+ export { E as EMPTY_MAP_CATALOG, a as MapCatalog, f as findMap, p as parseMapCatalog } from './catalog-BRO-mQoP.js';
4
6
  import 'unstorage';
5
7
  import 'gl-matrix';
6
8
  import 'zod';
@@ -14,8 +16,11 @@ import 'zod';
14
16
  * voxel chunk blobs. Meshes/audio are never downloaded by the server — the
15
17
  * browser loads those straight from the same root.
16
18
  *
17
- * The seed is resolved on demand from object storage: map bytes stay on the
18
- * CDN, never in the deployment KV.
19
+ * The seed is resolved on demand from the map root: map bytes stay on the CDN
20
+ * or in static assets, never in the deployment KV. When a precomputed
21
+ * `seed.json[.gz]` pack is present (`cj0 add` writes one), the whole graph is
22
+ * replaced by a single request — which is what keeps room startup inside Worker
23
+ * quotas.
19
24
  *
20
25
  * Worker path: `fetch`, `AbortController`, `TextDecoder` only.
21
26
  */
@@ -41,6 +46,11 @@ interface HttpMapOptions {
41
46
  maxDownloadBytes?: number;
42
47
  /** Parallel voxel-chunk reads. Default 8. */
43
48
  concurrency?: number;
49
+ /**
50
+ * Try the precomputed `<root>seed.json[.gz]` pack before resolving the full
51
+ * map graph. Default `true`; disable it to force a graph re-read.
52
+ */
53
+ preferSeedPack?: boolean;
44
54
  }
45
55
  /**
46
56
  * A {@link WorldSeedReader} over one unpacked map root.
@@ -66,9 +76,10 @@ declare class HttpMapSource {
66
76
  /**
67
77
  * Load one map entry into a resolved {@link WorldSeed}.
68
78
  *
69
- * Reads `bundle.json`/manifest and the project graph straight from object
70
- * storage. Nothing is cached server-side: map bytes belong on the CDN, not in
71
- * the deployment KV.
79
+ * Prefers the precomputed seed pack (`<root>seed.json[.gz]`) — one request and
80
+ * no graph traversal, which is what keeps room startup inside Worker quotas.
81
+ * Falls back to reading `bundle.json`/manifest and the project graph when no
82
+ * pack is present.
72
83
  */
73
84
  declare function loadWorldSeedFromHttp(entry: MapEntry, options?: HttpMapOptions): Promise<WorldSeed>;
74
85