@adminide-stack/yantra-mobile 12.0.172-alpha.1 → 12.0.173
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/lib/features/apps/mobileAppCatalog.js +2 -2
- package/lib/features/apps/mobileAppCatalog.js.map +1 -1
- package/lib/features/chat/NotionPageWidgetCard.js +98 -0
- package/lib/features/chat/NotionPageWidgetCard.js.map +1 -0
- package/lib/features/chat/hostTranscriptProtocol.js +5 -1
- package/lib/features/chat/hostTranscriptProtocol.js.map +1 -1
- package/lib/features/chat/notionPageWidget.js +34 -0
- package/lib/features/chat/notionPageWidget.js.map +1 -0
- package/lib/features/games/cubeforge3D.js +11 -6
- package/lib/features/games/cubeforge3D.js.map +1 -1
- package/lib/features/games/vendored/core/cubeforge/items.js +2 -8
- package/lib/features/games/vendored/core/cubeforge/items.js.map +1 -1
- package/lib/features/games/vendored/core/cubeforge/recipes.js +1 -4
- package/lib/features/games/vendored/core/cubeforge/recipes.js.map +1 -1
- package/lib/features/games/vendored/core/cubeforge/skin.js +83 -0
- package/lib/features/games/vendored/core/cubeforge/skin.js.map +1 -0
- package/lib/features/games/vendored/core/cubeforge/worldgen.js +2 -38
- package/lib/features/games/vendored/core/cubeforge/worldgen.js.map +1 -1
- package/lib/features/games/vendored/core/engine/palette.js +2 -9
- package/lib/features/games/vendored/core/engine/palette.js.map +1 -1
- package/lib/features/games/vendored/core/lessons/lessons.js +2 -96
- package/lib/features/games/vendored/core/lessons/lessons.js.map +1 -1
- package/lib/features/games/vendored/ui/GamesRoot.js +87 -144
- package/lib/features/games/vendored/ui/GamesRoot.js.map +1 -1
- package/lib/features/games/vendored/ui/components/primitives.js +2 -50
- package/lib/features/games/vendored/ui/components/primitives.js.map +1 -1
- package/lib/features/games/vendored/ui/screens/Cubeforge3DHomeScreen.js +20 -3
- package/lib/features/games/vendored/ui/screens/Cubeforge3DHomeScreen.js.map +1 -1
- package/lib/features/games/vendored/ui/screens/SkinEditorScreen.js +169 -0
- package/lib/features/games/vendored/ui/screens/SkinEditorScreen.js.map +1 -0
- package/lib/features/games/vendored/ui/theme.js +1 -3
- package/lib/features/games/vendored/ui/theme.js.map +1 -1
- package/lib/features/notion/notionEditorModel.js +3 -1
- package/lib/features/notion/notionEditorModel.js.map +1 -1
- package/lib/screens/GamesNative/index.js +1 -1
- package/lib/screens/Home/components/homeCatalog.js +2 -2
- package/lib/screens/Home/components/homeCatalog.js.map +1 -1
- package/package.json +4 -4
- package/lib/features/games/vendored/core/classroom/permissions.js +0 -76
- package/lib/features/games/vendored/core/classroom/permissions.js.map +0 -1
- package/lib/features/games/vendored/core/classroom/resourceLink.js +0 -101
- package/lib/features/games/vendored/core/classroom/resourceLink.js.map +0 -1
- package/lib/features/games/vendored/core/classroom/rules.js +0 -83
- package/lib/features/games/vendored/core/classroom/rules.js.map +0 -1
- package/lib/features/games/vendored/core/classroom/worldSettings.js +0 -49
- package/lib/features/games/vendored/core/classroom/worldSettings.js.map +0 -1
- package/lib/features/games/vendored/core/cubeforge/cycle.js +0 -15
- package/lib/features/games/vendored/core/cubeforge/cycle.js.map +0 -1
- package/lib/features/games/vendored/core/cubeforge/inventory.js +0 -75
- package/lib/features/games/vendored/core/cubeforge/inventory.js.map +0 -1
- package/lib/features/games/vendored/core/cubeforge/save.js +0 -92
- package/lib/features/games/vendored/core/cubeforge/save.js.map +0 -1
- package/lib/features/games/vendored/core/cubeforge/session.js +0 -154
- package/lib/features/games/vendored/core/cubeforge/session.js.map +0 -1
- package/lib/features/games/vendored/core/engine/iso.js +0 -41
- package/lib/features/games/vendored/core/engine/iso.js.map +0 -1
- package/lib/features/games/vendored/core/engine/world.js +0 -148
- package/lib/features/games/vendored/core/engine/world.js.map +0 -1
- package/lib/features/games/vendored/core/games/catalog.js +0 -34
- package/lib/features/games/vendored/core/games/catalog.js.map +0 -1
- package/lib/features/games/vendored/core/logging/events.js +0 -24
- package/lib/features/games/vendored/core/logging/events.js.map +0 -1
- package/lib/features/games/vendored/core/logging/logger.js +0 -54
- package/lib/features/games/vendored/core/logging/logger.js.map +0 -1
- package/lib/features/games/vendored/core/session/gameSession.js +0 -317
- package/lib/features/games/vendored/core/session/gameSession.js.map +0 -1
- package/lib/features/games/vendored/core/storage/worldRepository.js +0 -192
- package/lib/features/games/vendored/core/storage/worldRepository.js.map +0 -1
- package/lib/features/games/vendored/core/store/reactive.js +0 -78
- package/lib/features/games/vendored/core/store/reactive.js.map +0 -1
- package/lib/features/games/vendored/ui/components/BlockPalette.js +0 -64
- package/lib/features/games/vendored/ui/components/BlockPalette.js.map +0 -1
- package/lib/features/games/vendored/ui/components/IsoCanvas.js +0 -124
- package/lib/features/games/vendored/ui/components/IsoCanvas.js.map +0 -1
- package/lib/features/games/vendored/ui/hooks/useReactiveQuery.js +0 -3
- package/lib/features/games/vendored/ui/hooks/useReactiveQuery.js.map +0 -1
- package/lib/features/games/vendored/ui/screens/ActivityScreen.js +0 -68
- package/lib/features/games/vendored/ui/screens/ActivityScreen.js.map +0 -1
- package/lib/features/games/vendored/ui/screens/BuilderScreen.js +0 -227
- package/lib/features/games/vendored/ui/screens/BuilderScreen.js.map +0 -1
- package/lib/features/games/vendored/ui/screens/ClassroomScreen.js +0 -95
- package/lib/features/games/vendored/ui/screens/ClassroomScreen.js.map +0 -1
- package/lib/features/games/vendored/ui/screens/CubeforgeScreen.js +0 -342
- package/lib/features/games/vendored/ui/screens/CubeforgeScreen.js.map +0 -1
- package/lib/features/games/vendored/ui/screens/HubScreen.js +0 -131
- package/lib/features/games/vendored/ui/screens/HubScreen.js.map +0 -1
- package/lib/features/games/vendored/ui/screens/WorldListScreen.js +0 -134
- package/lib/features/games/vendored/ui/screens/WorldListScreen.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"gameSession.js","sources":["../../../../../../src/features/games/vendored/core/session/gameSession.ts"],"sourcesContent":["/**\n * The game session: the single source of truth for one open world.\n *\n * It owns the world, its settings, the permission model, and who is currently\n * acting, and it exposes a reactive read model plus commands. Every mutation is\n * gated by the enforced rules here, so a view can never place a block the rules\n * forbid - the UI reads `canEdit` from the same authority that rejects the write.\n */\n\nimport { ReactiveValue, type Query, type Unsubscribe } from '../store/reactive';\nimport { VoxelWorld, DEFAULT_BOUNDS, type PlacedBlock, type SerializedWorld, type WorldBounds } from '../engine/world';\nimport type { MultiplayerMessage, MultiplayerTransport, PlayerIdentity, WorldOp } from '../multiplayer/transport';\nimport { BLOCKS, EMPTY, isValidBlockId, type BlockId } from '../engine/palette';\nimport { defaultWorldSettings, type BooleanSettingKey, type WorldSettings } from '../classroom/worldSettings';\nimport { applyRuleConstraints, setBooleanSetting } from '../classroom/rules';\nimport { normalizeResourceLink, validateResourceLinkUrl, type ResourceLink } from '../classroom/resourceLink';\nimport {\n defaultPermissionModel,\n effectiveCapabilities,\n type PermissionLevel,\n type PermissionModel,\n} from '../classroom/permissions';\nimport type { GameLogger } from '../logging/logger';\n\nexport interface GameSessionState {\n readonly bounds: WorldBounds;\n /** Blocks, ordered back-to-front for rendering. */\n readonly blocks: readonly PlacedBlock[];\n readonly blockCount: number;\n readonly settings: WorldSettings;\n readonly permissions: PermissionModel;\n readonly actingLevel: PermissionLevel;\n readonly selectedBlock: BlockId;\n /** Whether the acting player may place/break blocks right now. */\n readonly canEdit: boolean;\n readonly canUndo: boolean;\n /** Players currently in the world (self + peers); empty when single-player. */\n readonly peers: readonly PlayerIdentity[];\n}\n\nexport interface GameSessionInit {\n world?: SerializedWorld;\n settings?: WorldSettings;\n permissions?: PermissionModel;\n actingLevel?: PermissionLevel;\n selectedBlock?: BlockId;\n /** Optional activity logger. Events carry no personal data. */\n logger?: GameLogger;\n /** Id of the persisted world, recorded in the session.start event. */\n worldId?: string;\n /** Optional live-multiplayer transport. When set, edits sync to peers. */\n transport?: MultiplayerTransport;\n}\n\nexport type OpenResourceLinkResult = { ok: true; url: string } | { ok: false };\n\nconst UNDO_LIMIT = 100;\n\nexport class GameSession {\n private world: VoxelWorld;\n private settings: WorldSettings;\n private permissions: PermissionModel;\n private actingLevel: PermissionLevel;\n private selectedBlock: BlockId;\n private readonly undoStack: SerializedWorld[] = [];\n private readonly state: ReactiveValue<GameSessionState>;\n private readonly logger?: GameLogger;\n private readonly transport?: MultiplayerTransport;\n private readonly disposers: Unsubscribe[] = [];\n\n constructor(init: GameSessionInit = {}) {\n this.world = init.world ? VoxelWorld.deserialize(init.world) : VoxelWorld.create(DEFAULT_BOUNDS);\n this.settings = applyRuleConstraints(init.settings ?? defaultWorldSettings());\n this.permissions = init.permissions ?? defaultPermissionModel();\n this.actingLevel = init.actingLevel ?? 'operator';\n const firstBlock = BLOCKS[0]?.id ?? EMPTY;\n this.selectedBlock = init.selectedBlock && isValidBlockId(init.selectedBlock) ? init.selectedBlock : firstBlock;\n this.logger = init.logger;\n this.transport = init.transport;\n this.state = new ReactiveValue<GameSessionState>(this.snapshot());\n this.logger?.log({ type: 'session.start', worldId: init.worldId });\n\n if (this.transport) {\n this.disposers.push(this.transport.subscribe((msg) => this.onRemote(msg)));\n this.disposers.push(this.transport.peers.subscribe(() => this.publish()));\n // Ask whoever is already here for the current world, then show as present.\n this.transport.send({ kind: 'hello' });\n this.publish();\n }\n }\n\n get query(): Query<GameSessionState> {\n return this.state;\n }\n\n getState(): GameSessionState {\n return this.state.get();\n }\n\n // --- block editing ---\n\n selectBlock(block: BlockId): void {\n if (!isValidBlockId(block) || this.selectedBlock === block) return;\n this.selectedBlock = block;\n this.publish();\n }\n\n placeBlock(x: number, y: number, z: number): boolean {\n if (!this.canEdit()) return false;\n const op: WorldOp = { t: 'place', x, y, z, block: this.selectedBlock };\n if (!this.applyOp(op)) return false;\n this.publish();\n this.logger?.log({ type: 'block.place', block: this.selectedBlock, x, y, z });\n this.transport?.send({ kind: 'edit', op });\n return true;\n }\n\n breakBlock(x: number, y: number, z: number): boolean {\n if (!this.canEdit()) return false;\n const op: WorldOp = { t: 'break', x, y, z };\n if (!this.applyOp(op)) return false;\n this.publish();\n this.logger?.log({ type: 'block.break', x, y, z });\n this.transport?.send({ kind: 'edit', op });\n return true;\n }\n\n undo(): boolean {\n const previous = this.undoStack.pop();\n if (!previous) return false;\n this.world = VoxelWorld.deserialize(previous);\n this.publish();\n this.logger?.log({ type: 'world.undo' });\n // Undo rewrites history, so realign peers with a snapshot.\n this.transport?.send({ kind: 'snapshot', world: this.world.serialize() });\n return true;\n }\n\n reset(): void {\n const op: WorldOp = { t: 'reset' };\n if (!this.applyOp(op)) return;\n this.publish();\n this.logger?.log({ type: 'world.reset' });\n this.transport?.send({ kind: 'edit', op });\n }\n\n /** Leave multiplayer and release subscriptions. Safe to call once. */\n dispose(): void {\n for (const off of this.disposers.splice(0)) off();\n this.transport?.close();\n }\n\n // --- acting player (teacher can preview as a given level) ---\n\n setActingLevel(level: PermissionLevel): void {\n if (this.actingLevel === level) return;\n this.actingLevel = level;\n this.publish();\n }\n\n // --- classroom settings ---\n\n setBooleanSetting(key: BooleanSettingKey, value: boolean): void {\n const next = setBooleanSetting(this.settings, key, value);\n if (next === this.settings) return;\n this.settings = next;\n this.publish();\n this.logger?.log({ type: 'setting.change', key, value: next[key] });\n }\n\n setResourceLink(link: ResourceLink): void {\n const normalized = normalizeResourceLink(link);\n this.settings = { ...this.settings, resourceLink: normalized };\n this.publish();\n this.logger?.log({ type: 'resourceLink.set', hasUrl: normalized.url !== '' });\n }\n\n /**\n * Validate and \"open\" the teacher resource link. Returns the safe URL for the\n * host app to navigate to, and logs the open. Returns ok:false if no valid\n * link is set.\n */\n openResourceLink(): OpenResourceLinkResult {\n const validation = validateResourceLinkUrl(this.settings.resourceLink.url);\n if (!validation.ok || validation.empty) return { ok: false };\n let host = '';\n try {\n host = new URL(validation.url).host;\n } catch {\n host = '';\n }\n this.logger?.log({ type: 'resourceLink.open', host });\n return { ok: true, url: validation.url };\n }\n\n setHostEnabled(enabled: boolean): void {\n if (this.permissions.hostEnabled === enabled) return;\n this.permissions = { ...this.permissions, hostEnabled: enabled };\n this.publish();\n this.logger?.log({ type: 'permission.change', field: 'hostEnabled', value: enabled });\n }\n\n setDefaultLevel(level: PermissionLevel): void {\n if (this.permissions.defaultLevel === level) return;\n this.permissions = { ...this.permissions, defaultLevel: level };\n this.publish();\n this.logger?.log({ type: 'permission.change', field: 'defaultLevel', value: level });\n }\n\n // --- persistence helpers ---\n\n exportWorld(): SerializedWorld {\n return this.world.serialize();\n }\n\n exportSettings(): WorldSettings {\n return this.settings;\n }\n\n exportPermissions(): PermissionModel {\n return this.permissions;\n }\n\n // --- internals ---\n\n private canEdit(): boolean {\n return effectiveCapabilities(this.actingLevel, this.settings).canBuild;\n }\n\n /** Apply a world op to the model (no permission gating). Returns true if it changed. */\n private applyOp(op: WorldOp): boolean {\n if (op.t === 'reset') {\n if (this.world.count() === 0) return false;\n this.pushUndo();\n this.world = VoxelWorld.create(this.world.bounds);\n return true;\n }\n if (op.t === 'place') {\n this.pushUndo();\n const result = this.world.place(op.x, op.y, op.z, op.block);\n if (!result.ok) {\n this.undoStack.pop();\n return false;\n }\n return true;\n }\n this.pushUndo();\n const result = this.world.break(op.x, op.y, op.z);\n if (!result.ok) {\n this.undoStack.pop();\n return false;\n }\n return true;\n }\n\n /** Handle a message from a peer. Remote edits apply without re-broadcasting. */\n private onRemote(message: MultiplayerMessage): void {\n if (message.kind === 'edit') {\n if (this.applyOp(message.op)) this.publish();\n return;\n }\n if (message.kind === 'hello') {\n if (this.world.count() > 0) {\n this.transport?.send({ kind: 'snapshot', world: this.world.serialize() });\n }\n return;\n }\n // snapshot: adopt only before any local edits, so we don't clobber our work.\n if (this.world.count() === 0 && this.undoStack.length === 0) {\n this.world = VoxelWorld.deserialize(message.world);\n this.publish();\n }\n }\n\n private pushUndo(): void {\n this.undoStack.push(this.world.serialize());\n if (this.undoStack.length > UNDO_LIMIT) this.undoStack.shift();\n }\n\n private publish(): void {\n this.state.set(this.snapshot());\n }\n\n private snapshot(): GameSessionState {\n return {\n bounds: this.world.bounds,\n blocks: this.world.drawOrder(),\n blockCount: this.world.count(),\n settings: this.settings,\n permissions: this.permissions,\n actingLevel: this.actingLevel,\n selectedBlock: this.selectedBlock,\n canEdit: this.canEdit(),\n canUndo: this.undoStack.length > 0,\n peers: this.transport ? this.transport.peers.get() : [],\n };\n }\n}\n"],"names":["result"],"mappings":";;;;;;;;;;;;;;;;;;;;AAoDA,MAAM,UAAa,GAAA,GAAA;AACZ,MAAM,WAAY,CAAA;AAAA,EAWvB,WAAA,CAAY,IAAwB,GAAA,EAAI,EAAA;AAVxC,IAAQ,aAAA,CAAA,IAAA,EAAA,OAAA,CAAA;AACR,IAAQ,aAAA,CAAA,IAAA,EAAA,UAAA,CAAA;AACR,IAAQ,aAAA,CAAA,IAAA,EAAA,aAAA,CAAA;AACR,IAAQ,aAAA,CAAA,IAAA,EAAA,aAAA,CAAA;AACR,IAAQ,aAAA,CAAA,IAAA,EAAA,eAAA,CAAA;AACR,IAAA,aAAA,CAAA,IAAA,EAAiB,aAA+B,EAAC,CAAA;AACjD,IAAiB,aAAA,CAAA,IAAA,EAAA,OAAA,CAAA;AACjB,IAAiB,aAAA,CAAA,IAAA,EAAA,QAAA,CAAA;AACjB,IAAiB,aAAA,CAAA,IAAA,EAAA,WAAA,CAAA;AACjB,IAAA,aAAA,CAAA,IAAA,EAAiB,aAA2B,EAAC,CAAA;AA/D/C,IAAA,IAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA;AAiEI,IAAK,IAAA,CAAA,KAAA,GAAQ,IAAK,CAAA,KAAA,GAAQ,UAAW,CAAA,WAAA,CAAY,KAAK,KAAK,CAAA,GAAI,UAAW,CAAA,MAAA,CAAO,cAAc,CAAA;AAC/F,IAAA,IAAA,CAAK,WAAW,oBAAqB,CAAA,CAAA,EAAA,GAAA,IAAA,CAAK,QAAL,KAAA,IAAA,GAAA,EAAA,GAAiB,sBAAsB,CAAA;AAC5E,IAAA,IAAA,CAAK,WAAc,GAAA,CAAA,EAAA,GAA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EAAA;AAAA,MAC7B,UAAU,IAAK,CAAA,QAAA;AAAA,MACf,aAAa,IAAK,CAAA,WAAA;AAAA,MAClB,aAAa,IAAK,CAAA,WAAA;AAAA,MAClB,eAAe,IAAK,CAAA,aAAA;AAAA,MACpB,OAAA,EAAS,KAAK,OAAQ,EAAA;AAAA,MACtB,OAAA,EAAS,IAAK,CAAA,SAAA,CAAU,MAAS,GAAA,CAAA;AAAA,MACjC,KAAA,EAAO,KAAK,SAAY,GAAA,IAAA,CAAK,UAAU,KAAM,CAAA,GAAA,KAAQ;AAAC,KACxD;AAAA;AAEJ"}
|
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
import {defaultWorldSettings}from'../classroom/worldSettings.js';import {applyRuleConstraints}from'../classroom/rules.js';import {defaultPermissionModel}from'../classroom/permissions.js';import {VoxelWorld,DEFAULT_BOUNDS}from'../engine/world.js';var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
const STORAGE_VERSION = "v1";
|
|
21
|
-
const STORAGE_PREFIX = `yantra.games.${STORAGE_VERSION}`;
|
|
22
|
-
class WorldRepository {
|
|
23
|
-
constructor(storage, namespace, now = () => Date.now(), makeId = defaultMakeId) {
|
|
24
|
-
this.storage = storage;
|
|
25
|
-
this.namespace = namespace;
|
|
26
|
-
this.now = now;
|
|
27
|
-
this.makeId = makeId;
|
|
28
|
-
}
|
|
29
|
-
async list() {
|
|
30
|
-
const raw = await this.storage.getItem(this.indexKey());
|
|
31
|
-
const parsed = safeParse(raw);
|
|
32
|
-
if (!Array.isArray(parsed)) return [];
|
|
33
|
-
const out = [];
|
|
34
|
-
for (const entry of parsed) {
|
|
35
|
-
const summary = coerceSummary(entry);
|
|
36
|
-
if (summary) out.push(summary);
|
|
37
|
-
}
|
|
38
|
-
return out.sort((a, b) => b.updatedAt - a.updatedAt);
|
|
39
|
-
}
|
|
40
|
-
async load(id) {
|
|
41
|
-
const raw = await this.storage.getItem(this.worldKey(id));
|
|
42
|
-
const parsed = safeParse(raw);
|
|
43
|
-
if (!parsed || typeof parsed !== "object") return null;
|
|
44
|
-
return coerceRecord(parsed);
|
|
45
|
-
}
|
|
46
|
-
async create(name) {
|
|
47
|
-
const ts = this.now();
|
|
48
|
-
const record = {
|
|
49
|
-
id: this.makeId(),
|
|
50
|
-
name: cleanName(name),
|
|
51
|
-
createdAt: ts,
|
|
52
|
-
updatedAt: ts,
|
|
53
|
-
settings: defaultWorldSettings(),
|
|
54
|
-
permissions: defaultPermissionModel(),
|
|
55
|
-
world: VoxelWorld.create(DEFAULT_BOUNDS).serialize()
|
|
56
|
-
};
|
|
57
|
-
await this.save(record);
|
|
58
|
-
return record;
|
|
59
|
-
}
|
|
60
|
-
async save(record) {
|
|
61
|
-
const normalized = __spreadProps(__spreadValues({}, record), {
|
|
62
|
-
name: cleanName(record.name),
|
|
63
|
-
settings: applyRuleConstraints(record.settings),
|
|
64
|
-
updatedAt: this.now()
|
|
65
|
-
});
|
|
66
|
-
await this.storage.setItem(this.worldKey(normalized.id), JSON.stringify(normalized));
|
|
67
|
-
await this.updateIndex((index) => {
|
|
68
|
-
const summary = {
|
|
69
|
-
id: normalized.id,
|
|
70
|
-
name: normalized.name,
|
|
71
|
-
updatedAt: normalized.updatedAt,
|
|
72
|
-
blockCount: Object.keys(normalized.world.blocks).length
|
|
73
|
-
};
|
|
74
|
-
const without = index.filter((s) => s.id !== normalized.id);
|
|
75
|
-
return [summary, ...without];
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
async rename(id, name) {
|
|
79
|
-
const record = await this.load(id);
|
|
80
|
-
if (!record) return;
|
|
81
|
-
await this.save(__spreadProps(__spreadValues({}, record), {
|
|
82
|
-
name: cleanName(name)
|
|
83
|
-
}));
|
|
84
|
-
}
|
|
85
|
-
async delete(id) {
|
|
86
|
-
await this.storage.removeItem(this.worldKey(id));
|
|
87
|
-
await this.updateIndex((index) => index.filter((s) => s.id !== id));
|
|
88
|
-
}
|
|
89
|
-
async updateIndex(update) {
|
|
90
|
-
const current = await this.list();
|
|
91
|
-
const next = update(current).sort((a, b) => b.updatedAt - a.updatedAt);
|
|
92
|
-
await this.storage.setItem(this.indexKey(), JSON.stringify(next));
|
|
93
|
-
}
|
|
94
|
-
indexKey() {
|
|
95
|
-
return `${STORAGE_PREFIX}:${this.namespace}:index`;
|
|
96
|
-
}
|
|
97
|
-
worldKey(id) {
|
|
98
|
-
return `${STORAGE_PREFIX}:${this.namespace}:world:${id}`;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
function defaultMakeId() {
|
|
102
|
-
const rand = Math.random().toString(36).slice(2, 10);
|
|
103
|
-
return `w_${Date.now().toString(36)}_${rand}`;
|
|
104
|
-
}
|
|
105
|
-
function cleanName(name) {
|
|
106
|
-
const trimmed = (name != null ? name : "").trim().slice(0, 60);
|
|
107
|
-
return trimmed === "" ? "Untitled World" : trimmed;
|
|
108
|
-
}
|
|
109
|
-
function safeParse(raw) {
|
|
110
|
-
if (raw === null) return null;
|
|
111
|
-
try {
|
|
112
|
-
return JSON.parse(raw);
|
|
113
|
-
} catch (e) {
|
|
114
|
-
return null;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
function coerceSummary(entry) {
|
|
118
|
-
if (!entry || typeof entry !== "object") return null;
|
|
119
|
-
const e = entry;
|
|
120
|
-
if (typeof e.id !== "string" || typeof e.name !== "string") return null;
|
|
121
|
-
return {
|
|
122
|
-
id: e.id,
|
|
123
|
-
name: e.name,
|
|
124
|
-
updatedAt: typeof e.updatedAt === "number" ? e.updatedAt : 0,
|
|
125
|
-
blockCount: typeof e.blockCount === "number" ? e.blockCount : 0
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
function coerceRecord(e) {
|
|
129
|
-
if (typeof e.id !== "string") return null;
|
|
130
|
-
const world = coerceWorld(e.world);
|
|
131
|
-
return {
|
|
132
|
-
id: e.id,
|
|
133
|
-
name: typeof e.name === "string" ? cleanName(e.name) : "Untitled World",
|
|
134
|
-
createdAt: typeof e.createdAt === "number" ? e.createdAt : 0,
|
|
135
|
-
updatedAt: typeof e.updatedAt === "number" ? e.updatedAt : 0,
|
|
136
|
-
settings: applyRuleConstraints(coerceSettings(e.settings)),
|
|
137
|
-
permissions: coercePermissions(e.permissions),
|
|
138
|
-
world
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
function coerceWorld(value) {
|
|
142
|
-
const fallback = VoxelWorld.create(DEFAULT_BOUNDS).serialize();
|
|
143
|
-
if (!value || typeof value !== "object") return fallback;
|
|
144
|
-
const v = value;
|
|
145
|
-
const bounds = v.bounds;
|
|
146
|
-
if (!bounds || typeof bounds.x !== "number" || typeof bounds.y !== "number" || typeof bounds.z !== "number") {
|
|
147
|
-
return fallback;
|
|
148
|
-
}
|
|
149
|
-
const blocks = {};
|
|
150
|
-
if (v.blocks && typeof v.blocks === "object") {
|
|
151
|
-
for (const [key, id] of Object.entries(v.blocks)) {
|
|
152
|
-
if (typeof id === "number") blocks[key] = id;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
return VoxelWorld.deserialize({
|
|
156
|
-
bounds: {
|
|
157
|
-
x: bounds.x,
|
|
158
|
-
y: bounds.y,
|
|
159
|
-
z: bounds.z
|
|
160
|
-
},
|
|
161
|
-
blocks
|
|
162
|
-
}).serialize();
|
|
163
|
-
}
|
|
164
|
-
function coerceSettings(value) {
|
|
165
|
-
const base = defaultWorldSettings();
|
|
166
|
-
if (!value || typeof value !== "object") return base;
|
|
167
|
-
const v = value;
|
|
168
|
-
const merged = __spreadValues({}, base);
|
|
169
|
-
for (const key of Object.keys(base)) {
|
|
170
|
-
if (key === "resourceLink") continue;
|
|
171
|
-
if (typeof v[key] === "boolean") {
|
|
172
|
-
merged[key] = v[key];
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
const link = v.resourceLink;
|
|
176
|
-
if (link && typeof link === "object") {
|
|
177
|
-
merged.resourceLink = {
|
|
178
|
-
buttonName: typeof link.buttonName === "string" ? link.buttonName : "",
|
|
179
|
-
url: typeof link.url === "string" ? link.url : ""
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
return merged;
|
|
183
|
-
}
|
|
184
|
-
function coercePermissions(value) {
|
|
185
|
-
const base = defaultPermissionModel();
|
|
186
|
-
if (!value || typeof value !== "object") return base;
|
|
187
|
-
const v = value;
|
|
188
|
-
return {
|
|
189
|
-
hostEnabled: typeof v.hostEnabled === "boolean" ? v.hostEnabled : base.hostEnabled,
|
|
190
|
-
defaultLevel: v.defaultLevel === "visitor" || v.defaultLevel === "member" || v.defaultLevel === "operator" ? v.defaultLevel : base.defaultLevel
|
|
191
|
-
};
|
|
192
|
-
}export{STORAGE_PREFIX,STORAGE_VERSION,WorldRepository};//# sourceMappingURL=worldRepository.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"worldRepository.js","sources":["../../../../../../src/features/games/vendored/core/storage/worldRepository.ts"],"sourcesContent":["/**\n * Persists a player's worlds via a KeyValueStorage adapter.\n *\n * Keys are namespaced by organisation so one device signed into different orgs\n * keeps separate collections:\n * yantra.games.v1:<org>:index -> WorldSummary[]\n * yantra.games.v1:<org>:world:<id> -> WorldRecord\n *\n * Reads are defensive: corrupt or partial records are skipped or repaired with\n * defaults rather than throwing, so one bad entry can't break the library.\n */\n\nimport type { KeyValueStorage } from './storage';\nimport { defaultWorldSettings, type WorldSettings } from '../classroom/worldSettings';\nimport { applyRuleConstraints } from '../classroom/rules';\nimport { defaultPermissionModel, type PermissionModel } from '../classroom/permissions';\nimport { DEFAULT_BOUNDS, VoxelWorld, type SerializedWorld } from '../engine/world';\n\nexport const STORAGE_VERSION = 'v1';\nexport const STORAGE_PREFIX = `yantra.games.${STORAGE_VERSION}`;\n\nexport interface WorldRecord {\n id: string;\n name: string;\n createdAt: number;\n updatedAt: number;\n settings: WorldSettings;\n permissions: PermissionModel;\n world: SerializedWorld;\n}\n\nexport interface WorldSummary {\n id: string;\n name: string;\n updatedAt: number;\n blockCount: number;\n}\n\nexport class WorldRepository {\n constructor(\n private readonly storage: KeyValueStorage,\n private readonly namespace: string,\n private readonly now: () => number = () => Date.now(),\n private readonly makeId: () => string = defaultMakeId,\n ) {}\n\n async list(): Promise<WorldSummary[]> {\n const raw = await this.storage.getItem(this.indexKey());\n const parsed = safeParse(raw);\n if (!Array.isArray(parsed)) return [];\n const out: WorldSummary[] = [];\n for (const entry of parsed) {\n const summary = coerceSummary(entry);\n if (summary) out.push(summary);\n }\n return out.sort((a, b) => b.updatedAt - a.updatedAt);\n }\n\n async load(id: string): Promise<WorldRecord | null> {\n const raw = await this.storage.getItem(this.worldKey(id));\n const parsed = safeParse(raw);\n if (!parsed || typeof parsed !== 'object') return null;\n return coerceRecord(parsed as Record<string, unknown>);\n }\n\n async create(name: string): Promise<WorldRecord> {\n const ts = this.now();\n const record: WorldRecord = {\n id: this.makeId(),\n name: cleanName(name),\n createdAt: ts,\n updatedAt: ts,\n settings: defaultWorldSettings(),\n permissions: defaultPermissionModel(),\n world: VoxelWorld.create(DEFAULT_BOUNDS).serialize(),\n };\n await this.save(record);\n return record;\n }\n\n async save(record: WorldRecord): Promise<void> {\n const normalized: WorldRecord = {\n ...record,\n name: cleanName(record.name),\n settings: applyRuleConstraints(record.settings),\n updatedAt: this.now(),\n };\n await this.storage.setItem(this.worldKey(normalized.id), JSON.stringify(normalized));\n await this.updateIndex((index) => {\n const summary: WorldSummary = {\n id: normalized.id,\n name: normalized.name,\n updatedAt: normalized.updatedAt,\n blockCount: Object.keys(normalized.world.blocks).length,\n };\n const without = index.filter((s) => s.id !== normalized.id);\n return [summary, ...without];\n });\n }\n\n async rename(id: string, name: string): Promise<void> {\n const record = await this.load(id);\n if (!record) return;\n await this.save({ ...record, name: cleanName(name) });\n }\n\n async delete(id: string): Promise<void> {\n await this.storage.removeItem(this.worldKey(id));\n await this.updateIndex((index) => index.filter((s) => s.id !== id));\n }\n\n private async updateIndex(update: (index: WorldSummary[]) => WorldSummary[]): Promise<void> {\n const current = await this.list();\n const next = update(current).sort((a, b) => b.updatedAt - a.updatedAt);\n await this.storage.setItem(this.indexKey(), JSON.stringify(next));\n }\n\n private indexKey(): string {\n return `${STORAGE_PREFIX}:${this.namespace}:index`;\n }\n\n private worldKey(id: string): string {\n return `${STORAGE_PREFIX}:${this.namespace}:world:${id}`;\n }\n}\n\nfunction defaultMakeId(): string {\n const rand = Math.random().toString(36).slice(2, 10);\n return `w_${Date.now().toString(36)}_${rand}`;\n}\n\nfunction cleanName(name: string): string {\n const trimmed = (name ?? '').trim().slice(0, 60);\n return trimmed === '' ? 'Untitled World' : trimmed;\n}\n\nfunction safeParse(raw: string | null): unknown {\n if (raw === null) return null;\n try {\n return JSON.parse(raw);\n } catch {\n return null;\n }\n}\n\nfunction coerceSummary(entry: unknown): WorldSummary | null {\n if (!entry || typeof entry !== 'object') return null;\n const e = entry as Record<string, unknown>;\n if (typeof e.id !== 'string' || typeof e.name !== 'string') return null;\n return {\n id: e.id,\n name: e.name,\n updatedAt: typeof e.updatedAt === 'number' ? e.updatedAt : 0,\n blockCount: typeof e.blockCount === 'number' ? e.blockCount : 0,\n };\n}\n\nfunction coerceRecord(e: Record<string, unknown>): WorldRecord | null {\n if (typeof e.id !== 'string') return null;\n const world = coerceWorld(e.world);\n return {\n id: e.id,\n name: typeof e.name === 'string' ? cleanName(e.name) : 'Untitled World',\n createdAt: typeof e.createdAt === 'number' ? e.createdAt : 0,\n updatedAt: typeof e.updatedAt === 'number' ? e.updatedAt : 0,\n settings: applyRuleConstraints(coerceSettings(e.settings)),\n permissions: coercePermissions(e.permissions),\n world,\n };\n}\n\nfunction coerceWorld(value: unknown): SerializedWorld {\n const fallback = VoxelWorld.create(DEFAULT_BOUNDS).serialize();\n if (!value || typeof value !== 'object') return fallback;\n const v = value as Record<string, unknown>;\n const bounds = v.bounds as Record<string, unknown> | undefined;\n if (!bounds || typeof bounds.x !== 'number' || typeof bounds.y !== 'number' || typeof bounds.z !== 'number') {\n return fallback;\n }\n const blocks: Record<string, number> = {};\n if (v.blocks && typeof v.blocks === 'object') {\n for (const [key, id] of Object.entries(v.blocks as Record<string, unknown>)) {\n if (typeof id === 'number') blocks[key] = id;\n }\n }\n // Round-trip through the model so out-of-bounds / invalid cells are dropped.\n return VoxelWorld.deserialize({\n bounds: { x: bounds.x, y: bounds.y, z: bounds.z },\n blocks,\n }).serialize();\n}\n\nfunction coerceSettings(value: unknown): WorldSettings {\n const base = defaultWorldSettings();\n if (!value || typeof value !== 'object') return base;\n const v = value as Record<string, unknown>;\n const merged: WorldSettings = { ...base };\n for (const key of Object.keys(base) as (keyof WorldSettings)[]) {\n if (key === 'resourceLink') continue;\n if (typeof v[key] === 'boolean') {\n (merged[key] as boolean) = v[key] as boolean;\n }\n }\n const link = v.resourceLink as Record<string, unknown> | undefined;\n if (link && typeof link === 'object') {\n merged.resourceLink = {\n buttonName: typeof link.buttonName === 'string' ? link.buttonName : '',\n url: typeof link.url === 'string' ? link.url : '',\n };\n }\n return merged;\n}\n\nfunction coercePermissions(value: unknown): PermissionModel {\n const base = defaultPermissionModel();\n if (!value || typeof value !== 'object') return base;\n const v = value as Record<string, unknown>;\n return {\n hostEnabled: typeof v.hostEnabled === 'boolean' ? v.hostEnabled : base.hostEnabled,\n defaultLevel:\n v.defaultLevel === 'visitor' || v.defaultLevel === 'member' || v.defaultLevel === 'operator'\n ? v.defaultLevel\n : base.defaultLevel,\n };\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAiBO,MAAM,eAAkB,GAAA;AAClB,MAAA,cAAA,GAAiB,gBAAgB,eAAe,CAAA;AAgBtD,MAAM,eAAgB,CAAA;AAAA,EAC3B,WAAA,CAA6B,SAA2C,SAAoC,EAAA,GAAA,GAAoB,MAAM,IAAK,CAAA,GAAA,EAAwB,EAAA,MAAA,GAAuB,aAAe,EAAA;AAA5K,IAAA,IAAA,CAAA,OAAA,GAAA,OAAA;AAA2C,IAAA,IAAA,CAAA,SAAA,GAAA,SAAA;AAAoC,IAAA,IAAA,CAAA,GAAA,GAAA,GAAA;AAAuD,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AAAA;AAAuC,EAC1M,MAAM,IAAgC,GAAA;AACpC,IAAA,MAAM,MAAM,MAAM,IAAA,CAAK,QAAQ,OAAQ,CAAA,IAAA,CAAK,UAAU,CAAA;AACtD,IAAM,MAAA,MAAA,GAAS,UAAU,GAAG,CAAA;AAC5B,IAAA,IAAI,CAAC,KAAM,CAAA,OAAA,CAAQ,MAAM,CAAA,SAAU,EAAC;AACpC,IAAA,MAAM,MAAsB,EAAC;AAC7B,IAAA,KAAA,MAAW,SAAS,MAAQ,EAAA;AAC1B,MAAM,MAAA,OAAA,GAAU,cAAc,KAAK,CAAA;AACnC,MAAI,IAAA,OAAA,EAAa,GAAA,CAAA,IAAA,CAAK,OAAO,CAAA;AAAA;AAE/B,IAAO,OAAA,GAAA,CAAI,KAAK,CAAC,CAAA,E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AC5B,IAAA,IAAI,OAAO,CAAA,CAAE,GAAG,CAAA,KAAM,SAAW,EAAA;AAC/B,MAAC,MAAO,CAAA,GAAG,CAAgB,GAAA,CAAA,CAAE,GAAG,CAAA;AAAA;AAClC;AAEF,EAAA,MAAM,OAAO,CAAE,CAAA,YAAA;AACf,EAAI,IAAA,IAAA,IAAQ,OAAO,IAAA,KAAS,QAAU,EAAA;AACpC,IAAA,MAAA,CAAO,YAAe,GAAA;AAAA,MACpB,YAAY,OAAO,IAAA,CAAK,UAAe,KAAA,QAAA,GAAW,KAAK,UAAa,GAAA,EAAA;AAAA,MACpE,KAAK,OAAO,IAAA,CAAK,GAAQ,KAAA,QAAA,GAAW,KAAK,GAAM,GAAA;AAAA,KACjD;AAAA;AAEF,EAAO,OAAA,MAAA;AACT;AACA,SAAS,kBAAkB,KAAiC,EAAA;AAC1D,EAAA,MAAM,OAAO,sBAAuB,EAAA;AACpC,EAAA,IAAI,CAAC,KAAA,IAAS,OAAO,KAAA,KAAU,UAAiB,OAAA,IAAA;AAChD,EAAA,MAAM,CAAI,GAAA,KAAA;AACV,EAAO,OAAA;AAAA,IACL,aAAa,OAAO,CAAA,CAAE,gBAAgB,SAAY,GAAA,CAAA,CAAE,cAAc,IAAK,CAAA,WAAA;AAAA,IACvE,YAAc,EAAA,CAAA,CAAE,YAAiB,KAAA,SAAA,IAAa,CAAE,CAAA,YAAA,KAAiB,QAAY,IAAA,CAAA,CAAE,YAAiB,KAAA,UAAA,GAAa,CAAE,CAAA,YAAA,GAAe,IAAK,CAAA;AAAA,GACrI;AACF"}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
const refEquals = (a, b) => Object.is(a, b);
|
|
5
|
-
class ReactiveValue {
|
|
6
|
-
constructor(initial, equals = refEquals) {
|
|
7
|
-
__publicField(this, "value");
|
|
8
|
-
__publicField(this, "listeners", /* @__PURE__ */ new Set());
|
|
9
|
-
__publicField(this, "equals");
|
|
10
|
-
this.value = initial;
|
|
11
|
-
this.equals = equals;
|
|
12
|
-
}
|
|
13
|
-
get() {
|
|
14
|
-
return this.value;
|
|
15
|
-
}
|
|
16
|
-
/** Replace the value. Listeners fire only when it actually changes. */
|
|
17
|
-
set(next) {
|
|
18
|
-
if (this.equals(this.value, next)) return;
|
|
19
|
-
this.value = next;
|
|
20
|
-
this.emit();
|
|
21
|
-
}
|
|
22
|
-
/** Functional update. Listeners fire only when the result changes. */
|
|
23
|
-
update(updater) {
|
|
24
|
-
this.set(updater(this.value));
|
|
25
|
-
}
|
|
26
|
-
subscribe(listener) {
|
|
27
|
-
this.listeners.add(listener);
|
|
28
|
-
return () => {
|
|
29
|
-
this.listeners.delete(listener);
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
select(selector, equals = refEquals) {
|
|
33
|
-
return new DerivedQuery(this, selector, equals);
|
|
34
|
-
}
|
|
35
|
-
emit() {
|
|
36
|
-
for (const listener of [...this.listeners]) listener(this.value);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
class DerivedQuery {
|
|
40
|
-
constructor(source, selector, equals) {
|
|
41
|
-
this.source = source;
|
|
42
|
-
this.selector = selector;
|
|
43
|
-
this.equals = equals;
|
|
44
|
-
__publicField(this, "listeners", /* @__PURE__ */ new Set());
|
|
45
|
-
__publicField(this, "cached");
|
|
46
|
-
__publicField(this, "sourceUnsub", null);
|
|
47
|
-
__publicField(this, "onSource", (value) => {
|
|
48
|
-
const next = this.selector(value);
|
|
49
|
-
if (this.equals(this.cached, next)) return;
|
|
50
|
-
this.cached = next;
|
|
51
|
-
for (const listener of [...this.listeners]) listener(next);
|
|
52
|
-
});
|
|
53
|
-
this.cached = selector(source.get());
|
|
54
|
-
}
|
|
55
|
-
get() {
|
|
56
|
-
if (this.listeners.size === 0) {
|
|
57
|
-
this.cached = this.selector(this.source.get());
|
|
58
|
-
}
|
|
59
|
-
return this.cached;
|
|
60
|
-
}
|
|
61
|
-
subscribe(listener) {
|
|
62
|
-
if (this.listeners.size === 0) {
|
|
63
|
-
this.cached = this.selector(this.source.get());
|
|
64
|
-
this.sourceUnsub = this.source.subscribe(this.onSource);
|
|
65
|
-
}
|
|
66
|
-
this.listeners.add(listener);
|
|
67
|
-
return () => {
|
|
68
|
-
this.listeners.delete(listener);
|
|
69
|
-
if (this.listeners.size === 0 && this.sourceUnsub) {
|
|
70
|
-
this.sourceUnsub();
|
|
71
|
-
this.sourceUnsub = null;
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
select(selector, equals = refEquals) {
|
|
76
|
-
return new DerivedQuery(this, selector, equals);
|
|
77
|
-
}
|
|
78
|
-
}export{ReactiveValue};//# sourceMappingURL=reactive.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reactive.js","sources":["../../../../../../src/features/games/vendored/core/store/reactive.ts"],"sourcesContent":["/**\n * Reactive store primitives.\n *\n * This is Yantra Games' own, original take on the \"observable read model + write\n * channel\" idea: the UI never owns domain state, it subscribes to a `Query<T>`\n * (a read-only, observable view) and mutates through a typed command group.\n * The store is the single source of truth, so a view can never drift out of sync\n * with enforced game rules.\n *\n * Pure TypeScript - no React, no React Native - so it is fully unit-testable.\n */\n\nexport type Listener<T> = (value: T) => void;\nexport type Unsubscribe = () => void;\nexport type Equals<T> = (a: T, b: T) => boolean;\n\nconst refEquals = <T>(a: T, b: T): boolean => Object.is(a, b);\n\n/** Read-only, observable view over a value. */\nexport interface Query<T> {\n /** Current value. Cheap and synchronous. */\n get(): T;\n /** Subscribe to changes. Returns an unsubscribe function. */\n subscribe(listener: Listener<T>): Unsubscribe;\n /** Derive a new query from this one. The derived value is memoized. */\n select<U>(selector: (value: T) => U, equals?: Equals<U>): Query<U>;\n}\n\n/** A mutable reactive value that is also a `Query`. */\nexport class ReactiveValue<T> implements Query<T> {\n private value: T;\n private readonly listeners = new Set<Listener<T>>();\n private readonly equals: Equals<T>;\n\n constructor(initial: T, equals: Equals<T> = refEquals) {\n this.value = initial;\n this.equals = equals;\n }\n\n get(): T {\n return this.value;\n }\n\n /** Replace the value. Listeners fire only when it actually changes. */\n set(next: T): void {\n if (this.equals(this.value, next)) return;\n this.value = next;\n this.emit();\n }\n\n /** Functional update. Listeners fire only when the result changes. */\n update(updater: (prev: T) => T): void {\n this.set(updater(this.value));\n }\n\n subscribe(listener: Listener<T>): Unsubscribe {\n this.listeners.add(listener);\n return () => {\n this.listeners.delete(listener);\n };\n }\n\n select<U>(selector: (value: T) => U, equals: Equals<U> = refEquals): Query<U> {\n return new DerivedQuery<T, U>(this, selector, equals);\n }\n\n private emit(): void {\n // Snapshot so a listener that unsubscribes mid-emit cannot corrupt iteration.\n for (const listener of [...this.listeners]) listener(this.value);\n }\n}\n\n/** A lazily-computed, memoized view derived from another query. */\nclass DerivedQuery<S, T> implements Query<T> {\n private readonly listeners = new Set<Listener<T>>();\n private cached: T;\n private sourceUnsub: Unsubscribe | null = null;\n\n constructor(\n private readonly source: Query<S>,\n private readonly selector: (value: S) => T,\n private readonly equals: Equals<T>,\n ) {\n this.cached = selector(source.get());\n }\n\n get(): T {\n // When nobody is subscribed we are not tracking the source, so recompute.\n if (this.listeners.size === 0) {\n this.cached = this.selector(this.source.get());\n }\n return this.cached;\n }\n\n subscribe(listener: Listener<T>): Unsubscribe {\n if (this.listeners.size === 0) {\n this.cached = this.selector(this.source.get());\n this.sourceUnsub = this.source.subscribe(this.onSource);\n }\n this.listeners.add(listener);\n return () => {\n this.listeners.delete(listener);\n if (this.listeners.size === 0 && this.sourceUnsub) {\n this.sourceUnsub();\n this.sourceUnsub = null;\n }\n };\n }\n\n select<U>(selector: (value: T) => U, equals: Equals<U> = refEquals): Query<U> {\n return new DerivedQuery<T, U>(this, selector, equals);\n }\n\n private readonly onSource = (value: S): void => {\n const next = this.selector(value);\n if (this.equals(this.cached, next)) return;\n this.cached = next;\n for (const listener of [...this.listeners]) listener(next);\n };\n}\n\n/**\n * A store = an observable read model (`query`) plus a typed write channel\n * (`commands`). Mirrors the analysed app's query-facet / command-group split,\n * reimplemented from scratch.\n */\nexport interface Store<TState, TCommands> {\n readonly query: Query<TState>;\n readonly commands: TCommands;\n}\n\n/** Shallow structural equality for flat objects - handy for settings records. */\nexport function shallowEquals<T extends Record<string, unknown>>(a: T, b: T): boolean {\n if (Object.is(a, b)) return true;\n const ak = Object.keys(a);\n const bk = Object.keys(b);\n if (ak.length !== bk.length) return false;\n for (const k of ak) {\n if (!Object.is(a[k], b[k])) return false;\n }\n return true;\n}\n"],"names":[],"mappings":";;;AAeA,MAAM,YAAY,CAAK,CAAA,EAAM,MAAkB,MAAO,CAAA,EAAA,CAAG,GAAG,CAAC,CAAA;AAatD,MAAM,aAAqC,CAAA;AAAA,EAIhD,WAAA,CAAY,OAAY,EAAA,MAAA,GAAoB,SAAW,EAAA;AAHvD,IAAQ,aAAA,CAAA,IAAA,EAAA,OAAA,CAAA;AACR,IAAiB,aAAA,CAAA,IAAA,EAAA,WAAA,sBAAgB,GAAiB,EAAA,CAAA;AAClD,IAAiB,aAAA,CAAA,IAAA,EAAA,QAAA,CAAA;AAEf,IAAA,IAAA,CAAK,KAAQ,GAAA,OAAA;AACb,IAAA,IAAA,CAAK,MAAS,GAAA,MAAA;AAAA;AAChB,EACA,GAAS,GAAA;AACP,IAAA,OAAO,IAAK,CAAA,KAAA;AAAA;AACd;AAAA,EAGA,IAAI,IAAe,EAAA;AACjB,IAAA,IAAI,IAAK,CAAA,MAAA,CAAO,IAAK,CAAA,KAAA,EAAO,IAAI,CAAG,EAAA;AACnC,IAAA,IAAA,CAAK,KAAQ,GAAA,IAAA;AACb,IAAA,IAAA,CAAK,IAAK,EAAA;AAAA;AACZ;AAAA,EAGA,OAAO,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}from'react/jsx-runtime';import {ScrollView,StyleSheet,Pressable,View,Text}from'react-native';import {BLOCKS}from'../../core/engine/palette.js';import'../../core/lessons/lessons.js';import'../../core/cubeforge/items.js';import'../../core/cubeforge/recipes.js';import {spacing,radius}from'../theme.js';function BlockPalette(props) {
|
|
2
|
-
const {
|
|
3
|
-
theme,
|
|
4
|
-
selected,
|
|
5
|
-
onSelect,
|
|
6
|
-
disabled
|
|
7
|
-
} = props;
|
|
8
|
-
return /* @__PURE__ */ jsx(ScrollView, { horizontal: true, showsHorizontalScrollIndicator: false, contentContainerStyle: styles.row, style: {
|
|
9
|
-
opacity: disabled ? 0.5 : 1
|
|
10
|
-
}, children: BLOCKS.map((block) => {
|
|
11
|
-
const active = block.id === selected;
|
|
12
|
-
return /* @__PURE__ */ jsxs(Pressable, { accessibilityRole: "button", accessibilityLabel: block.name, accessibilityState: {
|
|
13
|
-
selected: active
|
|
14
|
-
}, disabled, onPress: () => onSelect(block.id), style: [styles.swatch, {
|
|
15
|
-
borderColor: active ? theme.primary : theme.border,
|
|
16
|
-
backgroundColor: theme.surface
|
|
17
|
-
}, active && styles.swatchActive], children: [
|
|
18
|
-
/* @__PURE__ */ jsx(View, { style: [styles.swatchColor, {
|
|
19
|
-
backgroundColor: block.faces[0]
|
|
20
|
-
}], children: /* @__PURE__ */ jsx(View, { style: [styles.swatchSide, {
|
|
21
|
-
backgroundColor: block.faces[2]
|
|
22
|
-
}] }) }),
|
|
23
|
-
/* @__PURE__ */ jsx(Text, { style: [styles.swatchLabel, {
|
|
24
|
-
color: active ? theme.text : theme.textMuted
|
|
25
|
-
}], children: block.name })
|
|
26
|
-
] }, block.id);
|
|
27
|
-
}) });
|
|
28
|
-
}
|
|
29
|
-
const styles = StyleSheet.create({
|
|
30
|
-
row: {
|
|
31
|
-
gap: spacing.sm,
|
|
32
|
-
paddingHorizontal: spacing.xs,
|
|
33
|
-
paddingVertical: spacing.xs
|
|
34
|
-
},
|
|
35
|
-
swatch: {
|
|
36
|
-
width: 64,
|
|
37
|
-
borderRadius: radius.md,
|
|
38
|
-
borderWidth: 2,
|
|
39
|
-
padding: spacing.xs,
|
|
40
|
-
alignItems: "center",
|
|
41
|
-
gap: 4
|
|
42
|
-
},
|
|
43
|
-
swatchActive: {
|
|
44
|
-
transform: [{
|
|
45
|
-
translateY: -2
|
|
46
|
-
}]
|
|
47
|
-
},
|
|
48
|
-
swatchColor: {
|
|
49
|
-
width: 36,
|
|
50
|
-
height: 28,
|
|
51
|
-
borderRadius: 6,
|
|
52
|
-
overflow: "hidden",
|
|
53
|
-
justifyContent: "flex-end",
|
|
54
|
-
alignItems: "flex-end"
|
|
55
|
-
},
|
|
56
|
-
swatchSide: {
|
|
57
|
-
width: "45%",
|
|
58
|
-
height: "55%"
|
|
59
|
-
},
|
|
60
|
-
swatchLabel: {
|
|
61
|
-
fontSize: 11,
|
|
62
|
-
fontWeight: "600"
|
|
63
|
-
}
|
|
64
|
-
});export{BlockPalette};//# sourceMappingURL=BlockPalette.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BlockPalette.js","sources":["../../../../../../src/features/games/vendored/ui/components/BlockPalette.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Pressable, ScrollView, StyleSheet, Text, View } from 'react-native';\nimport { BLOCKS, type BlockId } from '../../core';\nimport { radius, spacing, type Theme } from '../theme';\n\nexport function BlockPalette(props: {\n theme: Theme;\n selected: BlockId;\n onSelect: (block: BlockId) => void;\n disabled?: boolean;\n}): React.ReactElement {\n const { theme, selected, onSelect, disabled } = props;\n return (\n <ScrollView\n horizontal\n showsHorizontalScrollIndicator={false}\n contentContainerStyle={styles.row}\n style={{ opacity: disabled ? 0.5 : 1 }}\n >\n {BLOCKS.map((block) => {\n const active = block.id === selected;\n return (\n <Pressable\n key={block.id}\n accessibilityRole=\"button\"\n accessibilityLabel={block.name}\n accessibilityState={{ selected: active }}\n disabled={disabled}\n onPress={() => onSelect(block.id)}\n style={[\n styles.swatch,\n {\n borderColor: active ? theme.primary : theme.border,\n backgroundColor: theme.surface,\n },\n active && styles.swatchActive,\n ]}\n >\n <View style={[styles.swatchColor, { backgroundColor: block.faces[0] }]}>\n <View style={[styles.swatchSide, { backgroundColor: block.faces[2] }]} />\n </View>\n <Text style={[styles.swatchLabel, { color: active ? theme.text : theme.textMuted }]}>\n {block.name}\n </Text>\n </Pressable>\n );\n })}\n </ScrollView>\n );\n}\n\nconst styles = StyleSheet.create({\n row: { gap: spacing.sm, paddingHorizontal: spacing.xs, paddingVertical: spacing.xs },\n swatch: {\n width: 64,\n borderRadius: radius.md,\n borderWidth: 2,\n padding: spacing.xs,\n alignItems: 'center',\n gap: 4,\n },\n swatchActive: { transform: [{ translateY: -2 }] },\n swatchColor: {\n width: 36,\n height: 28,\n borderRadius: 6,\n overflow: 'hidden',\n justifyContent: 'flex-end',\n alignItems: 'flex-end',\n },\n swatchSide: { width: '45%', height: '55%' },\n swatchLabel: { fontSize: 11, fontWeight: '600' },\n});\n"],"names":[],"mappings":"6TAIO,SAAS,aAAa,KAKN,EAAA;AACrB,EAAM,MAAA;AAAA,IACJ,KAAA;AAAA,IACA,QAAA;AAAA,IACA,QAAA;AAAA,IACA;AAAA,GACE,GAAA,KAAA;AACJ,EAAO,uBAAA,GAAA,CAAC,cAAW,UAAU,EAAA,IAAA,EAAC,gCAAgC,KAAO,EAAA,qBAAA,EAAuB,MAAO,CAAA,GAAA,EAAK,KAAO,EAAA;AAAA,IAC7G,OAAA,EAAS,WAAW,GAAM,GAAA;AAAA,GAC5B,EACW,QAAO,EAAA,MAAA,CAAA,GAAA,CAAI,CAAS,KAAA,KAAA;AAC3B,IAAM,MAAA,MAAA,GAAS,MAAM,EAAO,KAAA,QAAA;AAC5B,IAAA,4BAAQ,SAAyB,EAAA,EAAA,iBAAA,EAAkB,UAAS,kBAAoB,EAAA,KAAA,CAAM,MAAM,kBAAoB,EAAA;AAAA,MAC9G,QAAU,EAAA;AAAA,KACZ,EAAG,QAAoB,EAAA,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AA,EAAA;AAAA,IACjB,UAAY,EAAA,QAAA;AAAA,IACZ,GAAK,EAAA;AAAA,GACP;AAAA,EACA,YAAc,EAAA;AAAA,IACZ,WAAW,CAAC;AAAA,MACV,UAAY,EAAA;AAAA,KACb;AAAA,GACH;AAAA,EACA,WAAa,EAAA;AAAA,IACX,KAAO,EAAA,EAAA;AAAA,IACP,MAAQ,EAAA,EAAA;AAAA,IACR,YAAc,EAAA,CAAA;AAAA,IACd,QAAU,EAAA,QAAA;AAAA,IACV,cAAgB,EAAA,UAAA;AAAA,IAChB,UAAY,EAAA;AAAA,GACd;AAAA,EACA,UAAY,EAAA;AAAA,IACV,KAAO,EAAA,KAAA;AAAA,IACP,MAAQ,EAAA;AAAA,GACV;AAAA,EACA,WAAa,EAAA;AAAA,IACX,QAAU,EAAA,EAAA;AAAA,IACV,UAAY,EAAA;AAAA;AAEhB,CAAC,CAAA"}
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import {jsx,jsxs}from'react/jsx-runtime';import*as React from'react';import {useState,useMemo}from'react';import {View,Pressable}from'react-native';import Svg,{Polygon}from'react-native-svg';import {project,unprojectToCell,toSvgPoints,blockFaces}from'../../core/engine/iso.js';import {blockById}from'../../core/engine/palette.js';import'../../core/lessons/lessons.js';import'../../core/cubeforge/items.js';import'../../core/cubeforge/recipes.js';var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
const BASE_TILE_W = 42;
|
|
21
|
-
const BASE_TILE_H = 21;
|
|
22
|
-
const BASE_BLOCK_H = 24;
|
|
23
|
-
const MARGIN = 12;
|
|
24
|
-
function computeLayout(bounds, availWidth) {
|
|
25
|
-
const corners = [[0, 0], [bounds.x, 0], [0, bounds.y], [bounds.x, bounds.y]];
|
|
26
|
-
const base = {
|
|
27
|
-
tileWidth: BASE_TILE_W,
|
|
28
|
-
tileHeight: BASE_TILE_H,
|
|
29
|
-
blockHeight: BASE_BLOCK_H,
|
|
30
|
-
originX: 0,
|
|
31
|
-
originY: 0
|
|
32
|
-
};
|
|
33
|
-
let minSx = Infinity;
|
|
34
|
-
let maxSx = -Infinity;
|
|
35
|
-
for (const [x, y] of corners) {
|
|
36
|
-
const p = project(x, y, 0, base);
|
|
37
|
-
minSx = Math.min(minSx, p.sx);
|
|
38
|
-
maxSx = Math.max(maxSx, p.sx);
|
|
39
|
-
}
|
|
40
|
-
const rawWidth = maxSx - minSx;
|
|
41
|
-
const scale = Math.min(1, (availWidth - 2 * MARGIN) / rawWidth);
|
|
42
|
-
const cfg = {
|
|
43
|
-
tileWidth: BASE_TILE_W * scale,
|
|
44
|
-
tileHeight: BASE_TILE_H * scale,
|
|
45
|
-
blockHeight: BASE_BLOCK_H * scale,
|
|
46
|
-
originX: 0,
|
|
47
|
-
originY: 0
|
|
48
|
-
};
|
|
49
|
-
let nMinSx = Infinity;
|
|
50
|
-
let nMaxSx = -Infinity;
|
|
51
|
-
let nMinSy = Infinity;
|
|
52
|
-
let nMaxSy = -Infinity;
|
|
53
|
-
for (const [x, y] of corners) {
|
|
54
|
-
const floor = project(x, y, 0, cfg);
|
|
55
|
-
const top = project(x, y, bounds.z, cfg);
|
|
56
|
-
nMinSx = Math.min(nMinSx, floor.sx);
|
|
57
|
-
nMaxSx = Math.max(nMaxSx, floor.sx);
|
|
58
|
-
nMinSy = Math.min(nMinSy, top.sy);
|
|
59
|
-
nMaxSy = Math.max(nMaxSy, floor.sy);
|
|
60
|
-
}
|
|
61
|
-
const originX = availWidth / 2 - (nMinSx + nMaxSx) / 2;
|
|
62
|
-
const originY = MARGIN - nMinSy;
|
|
63
|
-
const height = nMaxSy - nMinSy + 2 * MARGIN;
|
|
64
|
-
return {
|
|
65
|
-
cfg: __spreadProps(__spreadValues({}, cfg), {
|
|
66
|
-
originX,
|
|
67
|
-
originY
|
|
68
|
-
}),
|
|
69
|
-
width: availWidth,
|
|
70
|
-
height
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
function IsoCanvas(props) {
|
|
74
|
-
const {
|
|
75
|
-
bounds,
|
|
76
|
-
blocks,
|
|
77
|
-
theme,
|
|
78
|
-
onCellTap
|
|
79
|
-
} = props;
|
|
80
|
-
const [width, setWidth] = useState(0);
|
|
81
|
-
const layout = useMemo(() => width > 0 ? computeLayout(bounds, width) : null, [bounds, width]);
|
|
82
|
-
const onLayout = (e) => {
|
|
83
|
-
const w = Math.round(e.nativeEvent.layout.width);
|
|
84
|
-
if (w !== width) setWidth(w);
|
|
85
|
-
};
|
|
86
|
-
const handlePress = (localX, localY) => {
|
|
87
|
-
if (!layout) return;
|
|
88
|
-
const cell = unprojectToCell(localX, localY, 0, layout.cfg);
|
|
89
|
-
if (cell.x < 0 || cell.y < 0 || cell.x >= bounds.x || cell.y >= bounds.y) return;
|
|
90
|
-
onCellTap(cell.x, cell.y);
|
|
91
|
-
};
|
|
92
|
-
return /* @__PURE__ */ jsx(View, { onLayout, style: {
|
|
93
|
-
width: "100%"
|
|
94
|
-
}, children: layout ? /* @__PURE__ */ jsx(Pressable, { onPress: (e) => handlePress(e.nativeEvent.locationX, e.nativeEvent.locationY), style: {
|
|
95
|
-
width: layout.width,
|
|
96
|
-
height: layout.height
|
|
97
|
-
}, children: /* @__PURE__ */ jsxs(Svg, { width: layout.width, height: layout.height, children: [
|
|
98
|
-
renderFloor(bounds, layout.cfg, theme),
|
|
99
|
-
blocks.map((b) => renderBlock(b, layout.cfg))
|
|
100
|
-
] }) }) : null });
|
|
101
|
-
}
|
|
102
|
-
function renderFloor(bounds, cfg, theme) {
|
|
103
|
-
const tiles = [];
|
|
104
|
-
for (let x = 0; x < bounds.x; x += 1) {
|
|
105
|
-
for (let y = 0; y < bounds.y; y += 1) {
|
|
106
|
-
const pts = toSvgPoints([project(x, y, 0, cfg), project(x + 1, y, 0, cfg), project(x + 1, y + 1, 0, cfg), project(x, y + 1, 0, cfg)]);
|
|
107
|
-
const fill = (x + y) % 2 === 0 ? theme.gridFill : theme.gridFillAlt;
|
|
108
|
-
tiles.push(/* @__PURE__ */ jsx(Polygon, { points: pts, fill, stroke: theme.gridLine, strokeWidth: 0.5 }, `f-${x}-${y}`));
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
return tiles;
|
|
112
|
-
}
|
|
113
|
-
function renderBlock(b, cfg) {
|
|
114
|
-
var _a;
|
|
115
|
-
const type = blockById(b.block);
|
|
116
|
-
const faces = blockFaces(b.x, b.y, b.z, cfg);
|
|
117
|
-
const [top, left, right] = (_a = type == null ? void 0 : type.faces) != null ? _a : ["#999", "#777", "#555"];
|
|
118
|
-
const key = `b-${b.x}-${b.y}-${b.z}`;
|
|
119
|
-
return /* @__PURE__ */ jsxs(React.Fragment, { children: [
|
|
120
|
-
/* @__PURE__ */ jsx(Polygon, { points: toSvgPoints(faces.left), fill: left }),
|
|
121
|
-
/* @__PURE__ */ jsx(Polygon, { points: toSvgPoints(faces.right), fill: right }),
|
|
122
|
-
/* @__PURE__ */ jsx(Polygon, { points: toSvgPoints(faces.top), fill: top, stroke: "rgba(0,0,0,0.12)", strokeWidth: 0.5 })
|
|
123
|
-
] }, key);
|
|
124
|
-
}export{IsoCanvas};//# sourceMappingURL=IsoCanvas.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IsoCanvas.js","sources":["../../../../../../src/features/games/vendored/ui/components/IsoCanvas.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useMemo, useState } from 'react';\nimport { Pressable, View, type LayoutChangeEvent } from 'react-native';\nimport Svg, { Polygon } from 'react-native-svg';\nimport {\n blockById,\n blockFaces,\n project,\n toSvgPoints,\n unprojectToCell,\n type IsoConfig,\n type PlacedBlock,\n type WorldBounds,\n} from '../../core';\nimport type { Theme } from '../theme';\n\nconst BASE_TILE_W = 42;\nconst BASE_TILE_H = 21;\nconst BASE_BLOCK_H = 24;\nconst MARGIN = 12;\n\ninterface IsoLayout {\n cfg: IsoConfig;\n width: number;\n height: number;\n}\n\nfunction computeLayout(bounds: WorldBounds, availWidth: number): IsoLayout {\n const corners: Array<[number, number]> = [\n [0, 0],\n [bounds.x, 0],\n [0, bounds.y],\n [bounds.x, bounds.y],\n ];\n const base: IsoConfig = {\n tileWidth: BASE_TILE_W,\n tileHeight: BASE_TILE_H,\n blockHeight: BASE_BLOCK_H,\n originX: 0,\n originY: 0,\n };\n let minSx = Infinity;\n let maxSx = -Infinity;\n for (const [x, y] of corners) {\n const p = project(x, y, 0, base);\n minSx = Math.min(minSx, p.sx);\n maxSx = Math.max(maxSx, p.sx);\n }\n const rawWidth = maxSx - minSx;\n const scale = Math.min(1, (availWidth - 2 * MARGIN) / rawWidth);\n\n const cfg: IsoConfig = {\n tileWidth: BASE_TILE_W * scale,\n tileHeight: BASE_TILE_H * scale,\n blockHeight: BASE_BLOCK_H * scale,\n originX: 0,\n originY: 0,\n };\n\n // Recompute extents at the scaled size to centre and size the canvas.\n let nMinSx = Infinity;\n let nMaxSx = -Infinity;\n let nMinSy = Infinity;\n let nMaxSy = -Infinity;\n for (const [x, y] of corners) {\n const floor = project(x, y, 0, cfg);\n const top = project(x, y, bounds.z, cfg);\n nMinSx = Math.min(nMinSx, floor.sx);\n nMaxSx = Math.max(nMaxSx, floor.sx);\n nMinSy = Math.min(nMinSy, top.sy);\n nMaxSy = Math.max(nMaxSy, floor.sy);\n }\n const originX = availWidth / 2 - (nMinSx + nMaxSx) / 2;\n const originY = MARGIN - nMinSy;\n const height = nMaxSy - nMinSy + 2 * MARGIN;\n return { cfg: { ...cfg, originX, originY }, width: availWidth, height };\n}\n\nexport function IsoCanvas(props: {\n bounds: WorldBounds;\n blocks: readonly PlacedBlock[];\n theme: Theme;\n onCellTap: (x: number, y: number) => void;\n}): React.ReactElement {\n const { bounds, blocks, theme, onCellTap } = props;\n const [width, setWidth] = useState(0);\n\n const layout = useMemo(() => (width > 0 ? computeLayout(bounds, width) : null), [bounds, width]);\n\n const onLayout = (e: LayoutChangeEvent) => {\n const w = Math.round(e.nativeEvent.layout.width);\n if (w !== width) setWidth(w);\n };\n\n const handlePress = (localX: number, localY: number) => {\n if (!layout) return;\n const cell = unprojectToCell(localX, localY, 0, layout.cfg);\n if (cell.x < 0 || cell.y < 0 || cell.x >= bounds.x || cell.y >= bounds.y) return;\n onCellTap(cell.x, cell.y);\n };\n\n return (\n <View onLayout={onLayout} style={{ width: '100%' }}>\n {layout ? (\n <Pressable\n onPress={(e) => handlePress(e.nativeEvent.locationX, e.nativeEvent.locationY)}\n style={{ width: layout.width, height: layout.height }}\n >\n <Svg width={layout.width} height={layout.height}>\n {/* Ground tiles (checkerboard floor). */}\n {renderFloor(bounds, layout.cfg, theme)}\n {/* Placed blocks, painted back-to-front. */}\n {blocks.map((b) => renderBlock(b, layout.cfg))}\n </Svg>\n </Pressable>\n ) : null}\n </View>\n );\n}\n\nfunction renderFloor(bounds: WorldBounds, cfg: IsoConfig, theme: Theme): React.ReactElement[] {\n const tiles: React.ReactElement[] = [];\n for (let x = 0; x < bounds.x; x += 1) {\n for (let y = 0; y < bounds.y; y += 1) {\n const pts = toSvgPoints([\n project(x, y, 0, cfg),\n project(x + 1, y, 0, cfg),\n project(x + 1, y + 1, 0, cfg),\n project(x, y + 1, 0, cfg),\n ]);\n const fill = (x + y) % 2 === 0 ? theme.gridFill : theme.gridFillAlt;\n tiles.push(\n <Polygon key={`f-${x}-${y}`} points={pts} fill={fill} stroke={theme.gridLine} strokeWidth={0.5} />,\n );\n }\n }\n return tiles;\n}\n\nfunction renderBlock(b: PlacedBlock, cfg: IsoConfig): React.ReactElement {\n const type = blockById(b.block);\n const faces = blockFaces(b.x, b.y, b.z, cfg);\n const [top, left, right] = type?.faces ?? ['#999', '#777', '#555'];\n const key = `b-${b.x}-${b.y}-${b.z}`;\n return (\n <React.Fragment key={key}>\n <Polygon points={toSvgPoints(faces.left)} fill={left} />\n <Polygon points={toSvgPoints(faces.right)} fill={right} />\n <Polygon points={toSvgPoints(faces.top)} fill={top} stroke=\"rgba(0,0,0,0.12)\" strokeWidth={0.5} />\n </React.Fragment>\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAMA,MAAM,WAAc,GAAA,EAAA;AACpB,MAAM,WAAc,GAAA,EAAA;AACpB,MAAM,YAAe,GAAA,EAAA;AACrB,MAAM,MAAS,GAAA,EAAA;AAMf,SAAS,aAAA,CAAc,QAAqB,UAA+B,EAAA;AACzE,EAAM,MAAA,OAAA,GAAmC,CAAC,CAAC,CAAA,EAAG,CAAC,CAAG,EAAA,CAAC,OAAO,CAAG,EAAA,CAAC,GAAG,CAAC,CAAA,EAAG,OAAO,CAAC,CAAA,EAAG,CAAC,MAAO,CAAA,CAAA,EAAG,MAAO,CAAA,CAAC,CAAC,CAAA;AACpG,EAAA,MAAM,IAAkB,GAAA;AAAA,IACtB,SAAW,EAAA,WAAA;AAAA,IACX,UAAY,EAAA,WAAA;AAAA,IACZ,WAAa,EAAA,YAAA;AAAA,IACb,OAAS,EAAA,CAAA;AAAA,IACT,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3C,EAAM,MAAA,CAAC,GAAK,EAAA,IAAA,EAAM,KAAK,CAAA,GAAA,CAAI,EAAM,GAAA,IAAA,IAAA,IAAA,GAAA,MAAA,GAAA,IAAA,CAAA,KAAA,KAAN,IAAe,GAAA,EAAA,GAAA,CAAC,MAAQ,EAAA,MAAA,EAAQ,MAAM,CAAA;AACjE,EAAM,MAAA,GAAA,GAAM,KAAK,CAAE,CAAA,CAAC,IAAI,CAAE,CAAA,CAAC,CAAI,CAAA,EAAA,CAAA,CAAE,CAAC,CAAA,CAAA;AAClC,EAAO,uBAAA,IAAA,CAAC,KAAM,CAAA,QAAA,EAAN,EACE,QAAA,EAAA;AAAA,oBAAA,GAAA,CAAC,WAAQ,MAAQ,EAAA,WAAA,CAAY,MAAM,IAAI,CAAA,EAAG,MAAM,IAAM,EAAA,CAAA;AAAA,oBACtD,GAAA,CAAC,WAAQ,MAAQ,EAAA,WAAA,CAAY,MAAM,KAAK,CAAA,EAAG,MAAM,KAAO,EAAA,CAAA;AAAA,oBACvD,GAAA,CAAA,OAAA,EAAA,EAAQ,MAAQ,EAAA,WAAA,CAAY,KAAM,CAAA,GAAG,CAAG,EAAA,IAAA,EAAM,GAAK,EAAA,MAAA,EAAO,kBAAmB,EAAA,WAAA,EAAa,GAAK,EAAA;AAAA,GAAA,EAAA,EAH9E,GAItB,CAAA;AACR"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useReactiveQuery.js","sources":["../../../../../../src/features/games/vendored/ui/hooks/useReactiveQuery.ts"],"sourcesContent":["import { useSyncExternalStore } from 'react';\nimport type { Query } from '../../core';\n\n/**\n * Bind a reactive core `Query<T>` to a React component. Re-renders only when the\n * query's value changes; works with concurrent rendering via useSyncExternalStore.\n */\nexport function useReactiveQuery<T>(query: Query<T>): T {\n return useSyncExternalStore(\n (onChange) => query.subscribe(onChange),\n () => query.get(),\n () => query.get(),\n );\n}\n"],"names":[],"mappings":"yCAOO,SAAS,iBAAoB,KAAoB,EAAA;AACtD,EAAA,OAAO,oBAAqB,CAAA,CAAA,QAAA,KAAY,KAAM,CAAA,SAAA,CAAU,QAAQ,CAAA,EAAG,MAAM,KAAA,CAAM,GAAI,EAAA,EAAG,MAAM,KAAA,CAAM,KAAK,CAAA;AACzG"}
|