cajonzero 0.1.0 → 0.1.2
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/README.md +20 -22
- package/dist/bin/cj0.js +404 -92
- package/dist/{config-Che_6xEE.d.ts → config-BOzAyP7m.d.ts} +1 -3
- package/dist/core.d.ts +8 -32
- package/dist/core.js +65 -141
- package/dist/index.d.ts +5 -7
- package/dist/index.js +6270 -6341
- package/dist/{providers-CJgLgWh4.d.ts → providers-BX7e4pNW.d.ts} +110 -30
- package/dist/scaffold.d.ts +60 -2
- package/dist/scaffold.js +307 -84
- package/dist/serve.d.ts +2 -4
- package/dist/serve.js +137 -208
- package/dist/ui/assets/index-Bhv7LV8L.css +2 -0
- package/dist/ui/assets/index-CaAHje8X.js +4404 -0
- package/dist/ui/assets/{main-BwrBUsrr.js → main-BeABKxzY.js} +22 -22
- package/dist/ui/index.html +2 -2
- package/package.json +7 -6
- package/dist/bin/cj0.js.map +0 -1
- package/dist/core.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/scaffold.js.map +0 -1
- package/dist/serve.js.map +0 -1
- package/dist/ui/assets/index-BLz2Y_Tv.js +0 -4405
- package/dist/ui/assets/index-W1HlDaw6.css +0 -2
|
@@ -199,7 +199,7 @@ declare function createMemoryStore(): Store;
|
|
|
199
199
|
* cajonzero — typed repositories over the unstorage layer (T4).
|
|
200
200
|
*
|
|
201
201
|
* Thin, dependency-injected repositories for the embedded account system
|
|
202
|
-
* (`accounts`, `sessions`, `bans
|
|
202
|
+
* (`accounts`, `sessions`, `bans`), runtime settings, and the
|
|
203
203
|
* map-script storage-kv API (`mapStorage`). Each is a small closure over a
|
|
204
204
|
* {@link Store}; no repository knows about HTTP, Hono, or Cloudflare globals, so
|
|
205
205
|
* every one is exercisable on the in-memory driver.
|
|
@@ -332,21 +332,6 @@ interface BansRepo {
|
|
|
332
332
|
deleteByKey(key: string): Promise<boolean>;
|
|
333
333
|
isActive(ban: BanRecord, at?: number): boolean;
|
|
334
334
|
}
|
|
335
|
-
/** Fixed-window rate-limit state. */
|
|
336
|
-
interface RateLimitState {
|
|
337
|
-
count: number;
|
|
338
|
-
windowStart: number;
|
|
339
|
-
expiresAt: number;
|
|
340
|
-
}
|
|
341
|
-
interface RateLimitIncrementOptions {
|
|
342
|
-
readonly windowSeconds?: number;
|
|
343
|
-
readonly amount?: number;
|
|
344
|
-
}
|
|
345
|
-
interface RateLimitsRepo {
|
|
346
|
-
increment(scope: string, hash: string, options?: RateLimitIncrementOptions): Promise<RateLimitState>;
|
|
347
|
-
get(scope: string, hash: string): Promise<RateLimitState | undefined>;
|
|
348
|
-
reset(scope: string, hash: string): Promise<void>;
|
|
349
|
-
}
|
|
350
335
|
interface SettingsRepo {
|
|
351
336
|
get<T = JSONValue>(key: string): Promise<T | undefined>;
|
|
352
337
|
set(key: string, value: JSONValue): Promise<void>;
|
|
@@ -384,7 +369,6 @@ interface Repos {
|
|
|
384
369
|
readonly accounts: AccountsRepo;
|
|
385
370
|
readonly sessions: SessionsRepo;
|
|
386
371
|
readonly bans: BansRepo;
|
|
387
|
-
readonly ratelimits: RateLimitsRepo;
|
|
388
372
|
readonly settings: SettingsRepo;
|
|
389
373
|
/** Builds a map-script storage repo for one `(scope, namespace)`. */
|
|
390
374
|
mapStorage(scope: string, namespace: string): MapStorageRepo;
|
|
@@ -551,11 +535,6 @@ interface MapEntry {
|
|
|
551
535
|
readonly version?: string;
|
|
552
536
|
/** Cover image URL for the lobby. */
|
|
553
537
|
readonly cover?: string;
|
|
554
|
-
/**
|
|
555
|
-
* Cache revision (content hash, release tag, …). Seeds are cached in KV only
|
|
556
|
-
* when a revision is present, so bump it whenever the uploaded map changes.
|
|
557
|
-
*/
|
|
558
|
-
readonly etag?: string;
|
|
559
538
|
/** Optional CDN root for browser assets; defaults to {@link root}. */
|
|
560
539
|
readonly assetRoot?: string;
|
|
561
540
|
}
|
|
@@ -924,6 +903,35 @@ declare class MuStruct<Spec extends {
|
|
|
924
903
|
constructor(spec: Spec);
|
|
925
904
|
}
|
|
926
905
|
|
|
906
|
+
interface Dictionary<Schema extends MuSchema<any>> {
|
|
907
|
+
[key: string]: Schema['identity'];
|
|
908
|
+
}
|
|
909
|
+
declare class MuDictionary<ValueSchema extends MuSchema<any>> implements MuSchema<Dictionary<ValueSchema>> {
|
|
910
|
+
readonly muType = "dictionary";
|
|
911
|
+
readonly identity: Dictionary<ValueSchema>;
|
|
912
|
+
readonly muData: ValueSchema;
|
|
913
|
+
readonly json: object;
|
|
914
|
+
readonly capacity: number;
|
|
915
|
+
private _isPrimitive;
|
|
916
|
+
allocCount: number;
|
|
917
|
+
freeCount: number;
|
|
918
|
+
stats(): {
|
|
919
|
+
allocCount: number;
|
|
920
|
+
freeCount: number;
|
|
921
|
+
poolSize: number;
|
|
922
|
+
};
|
|
923
|
+
constructor(schema: ValueSchema, capacity: number, identity?: Dictionary<ValueSchema>);
|
|
924
|
+
alloc(): Dictionary<ValueSchema>;
|
|
925
|
+
free(dict: Dictionary<ValueSchema>): void;
|
|
926
|
+
equal(a: Dictionary<ValueSchema>, b: Dictionary<ValueSchema>): boolean;
|
|
927
|
+
clone(dict: Dictionary<ValueSchema>): Dictionary<ValueSchema>;
|
|
928
|
+
assign: (dst: Dictionary<ValueSchema>, src: Dictionary<ValueSchema>) => Dictionary<ValueSchema>;
|
|
929
|
+
diff(base: Dictionary<ValueSchema>, target: Dictionary<ValueSchema>, out: MuWriteStream): boolean;
|
|
930
|
+
patch(base: Dictionary<ValueSchema>, inp: MuReadStream): Dictionary<ValueSchema>;
|
|
931
|
+
toJSON(dict: Dictionary<ValueSchema>): Dictionary<any>;
|
|
932
|
+
fromJSON(x: Dictionary<any>): Dictionary<ValueSchema>;
|
|
933
|
+
}
|
|
934
|
+
|
|
927
935
|
declare class QuantizedScalar implements MuSchema<number> {
|
|
928
936
|
precision: number;
|
|
929
937
|
invPrecision: number;
|
|
@@ -2265,6 +2273,48 @@ declare const NetPublicSchema: MuStruct<{
|
|
|
2265
2273
|
}>;
|
|
2266
2274
|
type NetPublic = typeof NetPublicSchema.identity;
|
|
2267
2275
|
|
|
2276
|
+
declare class RelativeArray<TSchema extends MuSchema<any>> implements MuSchema<TSchema['identity'][]> {
|
|
2277
|
+
identity: TSchema['identity'][];
|
|
2278
|
+
muType: string;
|
|
2279
|
+
muData: TSchema;
|
|
2280
|
+
json: any;
|
|
2281
|
+
arraySchema: MuArray<TSchema>;
|
|
2282
|
+
alloc: () => TSchema['identity'][];
|
|
2283
|
+
free: (x: TSchema['identity'][]) => void;
|
|
2284
|
+
clone: (x: TSchema['identity'][]) => TSchema['identity'][];
|
|
2285
|
+
equal: (x: TSchema['identity'][], y: TSchema['identity'][]) => boolean;
|
|
2286
|
+
assign: (x: TSchema['identity'][], y: TSchema['identity'][]) => TSchema['identity'][];
|
|
2287
|
+
toJSON: (x: TSchema['identity'][]) => any[];
|
|
2288
|
+
fromJSON: (x: any) => TSchema['identity'][];
|
|
2289
|
+
constructor(schema: TSchema, capacity: number, identity?: TSchema['identity'][]);
|
|
2290
|
+
diff(base: TSchema['identity'][], target: TSchema['identity'][], stream: MuWriteStream): boolean;
|
|
2291
|
+
patch(base: TSchema['identity'][], stream: MuReadStream): TSchema['identity'][];
|
|
2292
|
+
}
|
|
2293
|
+
|
|
2294
|
+
declare const BlockInfoSchema: MuStruct<{
|
|
2295
|
+
ids: RelativeArray<MuRelativeVarint>;
|
|
2296
|
+
names: MuArray<MuUTF8>;
|
|
2297
|
+
emissive: RelativeArray<MuVarint>;
|
|
2298
|
+
texture: RelativeArray<MuRelativeVarint>;
|
|
2299
|
+
animLength: RelativeArray<MuVarint>;
|
|
2300
|
+
friction: RelativeArray<MuQuantizedFloat>;
|
|
2301
|
+
restitution: RelativeArray<MuQuantizedFloat>;
|
|
2302
|
+
velocity: RelativeArray<MuFloat32>;
|
|
2303
|
+
fluids: MuArray<MuStruct<{
|
|
2304
|
+
id: MuVarint;
|
|
2305
|
+
info: MuUint32;
|
|
2306
|
+
mass: MuFloat64;
|
|
2307
|
+
}>>;
|
|
2308
|
+
category: MuDictionary<RelativeArray<MuRelativeVarint>>;
|
|
2309
|
+
atlasRadius: MuVarint;
|
|
2310
|
+
blockBumpShift: MuVarint;
|
|
2311
|
+
blockColorShift: MuVarint;
|
|
2312
|
+
colorAtlas: MuArray<MuASCII>;
|
|
2313
|
+
materialAtlas: MuArray<MuASCII>;
|
|
2314
|
+
bumpAtlas: MuArray<MuASCII>;
|
|
2315
|
+
}>;
|
|
2316
|
+
type BlockInfo = typeof BlockInfoSchema.identity;
|
|
2317
|
+
|
|
2268
2318
|
/**
|
|
2269
2319
|
* cajonzero — map-driven world seed (T26 slice 2, priority 1).
|
|
2270
2320
|
*
|
|
@@ -2406,6 +2456,15 @@ interface WorldSeed {
|
|
|
2406
2456
|
entityCount: number;
|
|
2407
2457
|
/** Human-readable record of anything skipped (never silently dropped). */
|
|
2408
2458
|
warnings: string[];
|
|
2459
|
+
/**
|
|
2460
|
+
* Decoded block palette, when the loader managed to read it.
|
|
2461
|
+
*
|
|
2462
|
+
* Server-only and **not JSON-safe** (typed arrays + schema refs): the seed is
|
|
2463
|
+
* never serialized any more, but do not persist this field. The engine uses
|
|
2464
|
+
* it to build the real `BlockIndex` (conveyors/materials) instead of the
|
|
2465
|
+
* neutral palette.
|
|
2466
|
+
*/
|
|
2467
|
+
blockInfo?: BlockInfo;
|
|
2409
2468
|
}
|
|
2410
2469
|
/**
|
|
2411
2470
|
* Read one archive-relative file. Implementations: an in-memory map (tests /
|
|
@@ -3759,6 +3818,12 @@ interface SnapshotClient {
|
|
|
3759
3818
|
admin: boolean;
|
|
3760
3819
|
loginState: number;
|
|
3761
3820
|
}
|
|
3821
|
+
/** Identity of the map a snapshot's world belongs to. */
|
|
3822
|
+
interface SnapshotMap {
|
|
3823
|
+
slug: string;
|
|
3824
|
+
root: string;
|
|
3825
|
+
worldId?: string;
|
|
3826
|
+
}
|
|
3762
3827
|
/** The durable room state written to Durable Object storage. */
|
|
3763
3828
|
interface RoomSnapshot {
|
|
3764
3829
|
version: number;
|
|
@@ -3768,6 +3833,12 @@ interface RoomSnapshot {
|
|
|
3768
3833
|
/** Opaque, JSON-safe world state produced by `RoomEngine.capture()`. */
|
|
3769
3834
|
engine: unknown;
|
|
3770
3835
|
clients: SnapshotClient[];
|
|
3836
|
+
/**
|
|
3837
|
+
* Map the captured world came from. Absent for snapshots written before the
|
|
3838
|
+
* field existed (or by a room that never had a map); those must not be
|
|
3839
|
+
* restored over a freshly seeded world.
|
|
3840
|
+
*/
|
|
3841
|
+
map?: SnapshotMap;
|
|
3771
3842
|
}
|
|
3772
3843
|
|
|
3773
3844
|
declare enum HashType {
|
|
@@ -4876,7 +4947,6 @@ interface RoomStateLike {
|
|
|
4876
4947
|
* the effective fetch policy from `cajonzero/config.json`.
|
|
4877
4948
|
*/
|
|
4878
4949
|
interface RoomMapBootstrap extends MapEntry {
|
|
4879
|
-
readonly cacheTtlSeconds?: number;
|
|
4880
4950
|
readonly maxDownloadBytes?: number;
|
|
4881
4951
|
readonly concurrency?: number;
|
|
4882
4952
|
readonly requestTimeoutMs?: number;
|
|
@@ -4966,7 +5036,6 @@ declare class Room {
|
|
|
4966
5036
|
private script;
|
|
4967
5037
|
private readonly explicitScriptHost;
|
|
4968
5038
|
private readonly mapLoader;
|
|
4969
|
-
private readonly seedCacheKv;
|
|
4970
5039
|
private readonly sockets;
|
|
4971
5040
|
/** mudb wire codec: protocol envelope + netcode frames. */
|
|
4972
5041
|
private readonly codec;
|
|
@@ -5008,6 +5077,8 @@ declare class Room {
|
|
|
5008
5077
|
private mapLoading;
|
|
5009
5078
|
private worldReady;
|
|
5010
5079
|
private snapshotRestored;
|
|
5080
|
+
/** One-shot guard for the "proof without sessionSecret" diagnostic. */
|
|
5081
|
+
private guestWarningLogged;
|
|
5011
5082
|
private persistence;
|
|
5012
5083
|
private socketsStarted;
|
|
5013
5084
|
private perf;
|
|
@@ -5019,6 +5090,10 @@ declare class Room {
|
|
|
5019
5090
|
private readonly inboundIds;
|
|
5020
5091
|
/** Snapshot parked by `init()` until the seeded engine exists. */
|
|
5021
5092
|
private pendingEngineSnapshot;
|
|
5093
|
+
/** Map identity stored with the parked snapshot (absent on legacy snapshots). */
|
|
5094
|
+
private pendingEngineMap;
|
|
5095
|
+
/** Identity of the map the current engine was seeded from. */
|
|
5096
|
+
private seededMap;
|
|
5022
5097
|
private heartbeatBeats;
|
|
5023
5098
|
private ticksRun;
|
|
5024
5099
|
private lastTickError;
|
|
@@ -5055,7 +5130,15 @@ declare class Room {
|
|
|
5055
5130
|
* any connection is admitted.
|
|
5056
5131
|
*/
|
|
5057
5132
|
private ensureWorld;
|
|
5058
|
-
/**
|
|
5133
|
+
/**
|
|
5134
|
+
* Apply a snapshot parked by `init()` exactly once.
|
|
5135
|
+
*
|
|
5136
|
+
* A snapshot describes the world of the map it was captured from. Restoring
|
|
5137
|
+
* one that came from another map (or from a room that never had a map) would
|
|
5138
|
+
* replace the freshly seeded entities with nothing, leaving terrain but no
|
|
5139
|
+
* models — so it is dropped instead. Dropping it also resets the tick
|
|
5140
|
+
* counters, which `init()` had adopted optimistically.
|
|
5141
|
+
*/
|
|
5059
5142
|
private applyPendingEngineSnapshot;
|
|
5060
5143
|
private loadWorld;
|
|
5061
5144
|
private loadSeed;
|
|
@@ -5263,8 +5346,6 @@ interface RuntimeProviders {
|
|
|
5263
5346
|
readonly adminToken?: EnvProvider<string>;
|
|
5264
5347
|
/** Deployment label; `"development"` relaxes cookie `Secure`. */
|
|
5265
5348
|
readonly environment?: EnvProvider<string>;
|
|
5266
|
-
/** KV used for the resolved map-seed cache. */
|
|
5267
|
-
readonly mapSeedKv?: EnvProvider<KVNamespace>;
|
|
5268
5349
|
/** Durable Object namespace that hosts rooms. */
|
|
5269
5350
|
readonly rooms?: EnvProvider<DurableObjectNamespace>;
|
|
5270
5351
|
/** Defaults for settings that have never been persisted. */
|
|
@@ -5277,9 +5358,8 @@ declare function getRuntimeProviders(): RuntimeProviders;
|
|
|
5277
5358
|
declare function resolveSessionSecret(env: Env): string | undefined;
|
|
5278
5359
|
declare function resolveAdminToken(env: Env): string | undefined;
|
|
5279
5360
|
declare function resolveEnvironment(env: Env): string | undefined;
|
|
5280
|
-
declare function resolveMapSeedKv(env: Env): KVNamespace | undefined;
|
|
5281
5361
|
declare function resolveRooms(env: Env): DurableObjectNamespace | undefined;
|
|
5282
5362
|
declare function resolveSettingDefaults(env: Env): SettingDefaults | undefined;
|
|
5283
5363
|
|
|
5284
|
-
export { parseMapCatalog as A, resolveAdminToken as B, resolveEnvironment as C,
|
|
5285
|
-
export type { DurableObjectNamespace as D, EnvProvider as E,
|
|
5364
|
+
export { parseMapCatalog as A, resolveAdminToken as B, resolveEnvironment as C, resolveRooms as F, resolveSessionSecret as G, resolveSettingDefaults as H, resolveStore as I, setRuntimeProviders as J, setStorageFactory as K, Room as R, EMPTY_MAP_CATALOG as c, SETTINGS as h, SETTING_KEYS as i, SettingsError as l, configureDefaultKV as r, createMemoryStore as s, createRepos as t, createSettingsService as u, createStore as v, findMap as w, getRuntimeProviders as x, isSettingKey as y, memoryDriver as z };
|
|
5365
|
+
export type { DurableObjectNamespace as D, EnvProvider as E, SessionsRepo as L, MapEntry as M, NetPublic as N, NetSecret as O, StorageSource as S, TimestampedClientInput as T, WorldSeed as W, SettingDefaults as a, Env as b, MapCatalog as d, Repos as e, RoomOptions as f, RuntimeProviders as g, SettingDefinition as j, Settings as k, SettingsErrorCode as m, SettingsService as n, StorageFactory as o, Store as p, WorldSeedReader as q };
|
package/dist/scaffold.d.ts
CHANGED
|
@@ -146,5 +146,63 @@ declare function toPackageName(folder: string): string;
|
|
|
146
146
|
*/
|
|
147
147
|
declare function createProject(folder: string, options?: CreateProjectOptions): ScaffoldResult;
|
|
148
148
|
|
|
149
|
-
|
|
150
|
-
|
|
149
|
+
/** Where one setup value is written. */
|
|
150
|
+
type SetupKind = "var" | "secret";
|
|
151
|
+
/** One configurable value. */
|
|
152
|
+
interface SetupField {
|
|
153
|
+
readonly name: string;
|
|
154
|
+
/** Chinese prompt label. */
|
|
155
|
+
readonly label: string;
|
|
156
|
+
readonly kind: SetupKind;
|
|
157
|
+
/** `true` for the values a project cannot run without. */
|
|
158
|
+
readonly required: boolean;
|
|
159
|
+
/** Default shown in the prompt (secrets: generated when absent). */
|
|
160
|
+
readonly default?: string;
|
|
161
|
+
/** Short explanation printed next to the prompt. */
|
|
162
|
+
readonly hint?: string;
|
|
163
|
+
}
|
|
164
|
+
/** Every value `setup` manages. */
|
|
165
|
+
declare const SETUP_FIELDS: readonly SetupField[];
|
|
166
|
+
/** Files `setup` touched. */
|
|
167
|
+
interface SetupResult {
|
|
168
|
+
readonly configPath: string;
|
|
169
|
+
readonly devVarsPath: string;
|
|
170
|
+
/** Non-secret values written to `wrangler.jsonc`. */
|
|
171
|
+
readonly vars: Record<string, string>;
|
|
172
|
+
/** Secrets written to `.dev.vars`. */
|
|
173
|
+
readonly secrets: Record<string, string>;
|
|
174
|
+
}
|
|
175
|
+
interface SetupOptions {
|
|
176
|
+
readonly cwd?: string;
|
|
177
|
+
/** Wrangler config path (default `wrangler.jsonc`). */
|
|
178
|
+
readonly configPath?: string;
|
|
179
|
+
/** Values to write; managed keys absent here are removed. */
|
|
180
|
+
readonly values: Readonly<Record<string, string>>;
|
|
181
|
+
}
|
|
182
|
+
/** Generated default for a required secret. */
|
|
183
|
+
declare function generateSecret(): string;
|
|
184
|
+
/** Generated default for the owner token (shorter, URL-safe). */
|
|
185
|
+
declare function generateAdminToken(): string;
|
|
186
|
+
/** Default value for a field when it has no configured value yet. */
|
|
187
|
+
declare function suggestedValue(field: SetupField): string | undefined;
|
|
188
|
+
/** Parse `.dev.vars` (`KEY=value`, `#` comments). */
|
|
189
|
+
declare function parseDevVars(text: string): Record<string, string>;
|
|
190
|
+
/** Serialize `.dev.vars` (stable order, trailing newline). */
|
|
191
|
+
declare function serializeDevVars(values: Record<string, string>): string;
|
|
192
|
+
/**
|
|
193
|
+
* Merge `vars` into the `wrangler.jsonc` `"vars"` object.
|
|
194
|
+
*
|
|
195
|
+
* Keys not managed by cajonzero are preserved; managed keys absent from `vars`
|
|
196
|
+
* are removed so clearing a setting falls back to its default.
|
|
197
|
+
*/
|
|
198
|
+
declare function setWranglerVars(raw: string, vars: Readonly<Record<string, string>>): string;
|
|
199
|
+
/** Read currently configured values (wrangler vars + `.dev.vars`). */
|
|
200
|
+
declare function readSetupValues(cwd: string, configPath: string, devVarsPath: string): Record<string, string>;
|
|
201
|
+
/**
|
|
202
|
+
* Apply the answers: non-secret values to `wrangler.jsonc`, secrets to
|
|
203
|
+
* `.dev.vars`. Throws when the project files are missing.
|
|
204
|
+
*/
|
|
205
|
+
declare function applySetup(options: SetupOptions): SetupResult;
|
|
206
|
+
|
|
207
|
+
export { SCAFFOLD_COMPATIBILITY_DATE, SCAFFOLD_CONFIG_CONTENT, SCAFFOLD_ENTRY_CONTENT, SCAFFOLD_ENTRY_PATH, SCAFFOLD_KV_PLACEHOLDER_ID, SCAFFOLD_MAPS_CONTENT, SETUP_FIELDS, ScaffoldError, applySetup, buildScaffoldFiles, createProject, generateAdminToken, generateSecret, parseDevVars, readCajonzeroPackage, readSetupValues, serializeDevVars, setWranglerVars, suggestedValue, toPackageName };
|
|
208
|
+
export type { CajonzeroPackageInfo, CreateProjectOptions, ScaffoldErrorCode, ScaffoldFile, ScaffoldResult, ScaffoldTemplateOptions, SetupField, SetupKind, SetupOptions, SetupResult };
|