@adminide-stack/yantra-mobile 12.0.172 → 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 +2 -2
- 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,148 +0,0 @@
|
|
|
1
|
-
import {isValidBlockId,EMPTY}from'./palette.js';import {depthKey}from'./iso.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
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
21
|
-
const DEFAULT_BOUNDS = {
|
|
22
|
-
x: 12,
|
|
23
|
-
y: 12,
|
|
24
|
-
z: 8
|
|
25
|
-
};
|
|
26
|
-
class VoxelWorld {
|
|
27
|
-
constructor(bounds, blocks) {
|
|
28
|
-
__publicField(this, "bounds");
|
|
29
|
-
__publicField(this, "blocks");
|
|
30
|
-
this.bounds = bounds;
|
|
31
|
-
this.blocks = blocks != null ? blocks : /* @__PURE__ */ new Map();
|
|
32
|
-
}
|
|
33
|
-
static create(bounds = DEFAULT_BOUNDS) {
|
|
34
|
-
return new VoxelWorld(bounds);
|
|
35
|
-
}
|
|
36
|
-
static deserialize(data) {
|
|
37
|
-
const blocks = /* @__PURE__ */ new Map();
|
|
38
|
-
for (const [key, id] of Object.entries(data.blocks)) {
|
|
39
|
-
const coord = parseKey(key);
|
|
40
|
-
if (!coord) continue;
|
|
41
|
-
if (!isValidBlockId(id)) continue;
|
|
42
|
-
if (!inBounds(coord.x, coord.y, coord.z, data.bounds)) continue;
|
|
43
|
-
blocks.set(key, id);
|
|
44
|
-
}
|
|
45
|
-
return new VoxelWorld(data.bounds, blocks);
|
|
46
|
-
}
|
|
47
|
-
serialize() {
|
|
48
|
-
const blocks = {};
|
|
49
|
-
for (const [key, id] of this.blocks) blocks[key] = id;
|
|
50
|
-
return {
|
|
51
|
-
bounds: this.bounds,
|
|
52
|
-
blocks
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
inBounds(x, y, z) {
|
|
56
|
-
return inBounds(x, y, z, this.bounds);
|
|
57
|
-
}
|
|
58
|
-
get(x, y, z) {
|
|
59
|
-
var _a;
|
|
60
|
-
return (_a = this.blocks.get(keyOf(x, y, z))) != null ? _a : EMPTY;
|
|
61
|
-
}
|
|
62
|
-
has(x, y, z) {
|
|
63
|
-
return this.blocks.has(keyOf(x, y, z));
|
|
64
|
-
}
|
|
65
|
-
place(x, y, z, block) {
|
|
66
|
-
if (!isValidBlockId(block)) return {
|
|
67
|
-
ok: false,
|
|
68
|
-
reason: "invalid-block"
|
|
69
|
-
};
|
|
70
|
-
if (!this.inBounds(x, y, z)) return {
|
|
71
|
-
ok: false,
|
|
72
|
-
reason: "out-of-bounds"
|
|
73
|
-
};
|
|
74
|
-
if (this.has(x, y, z)) return {
|
|
75
|
-
ok: false,
|
|
76
|
-
reason: "occupied"
|
|
77
|
-
};
|
|
78
|
-
this.blocks.set(keyOf(x, y, z), block);
|
|
79
|
-
return {
|
|
80
|
-
ok: true
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
break(x, y, z) {
|
|
84
|
-
if (!this.inBounds(x, y, z)) return {
|
|
85
|
-
ok: false,
|
|
86
|
-
reason: "out-of-bounds"
|
|
87
|
-
};
|
|
88
|
-
const key = keyOf(x, y, z);
|
|
89
|
-
const existing = this.blocks.get(key);
|
|
90
|
-
if (existing === void 0) return {
|
|
91
|
-
ok: false,
|
|
92
|
-
reason: "empty"
|
|
93
|
-
};
|
|
94
|
-
this.blocks.delete(key);
|
|
95
|
-
return {
|
|
96
|
-
ok: true,
|
|
97
|
-
removed: existing
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
clear() {
|
|
101
|
-
this.blocks.clear();
|
|
102
|
-
}
|
|
103
|
-
count() {
|
|
104
|
-
return this.blocks.size;
|
|
105
|
-
}
|
|
106
|
-
/** Count of placed blocks of a specific type. */
|
|
107
|
-
countOf(block) {
|
|
108
|
-
let n = 0;
|
|
109
|
-
for (const id of this.blocks.values()) if (id === block) n += 1;
|
|
110
|
-
return n;
|
|
111
|
-
}
|
|
112
|
-
list() {
|
|
113
|
-
const out = [];
|
|
114
|
-
for (const [key, block] of this.blocks) {
|
|
115
|
-
const coord = parseKey(key);
|
|
116
|
-
if (coord) out.push(__spreadProps(__spreadValues({}, coord), {
|
|
117
|
-
block
|
|
118
|
-
}));
|
|
119
|
-
}
|
|
120
|
-
return out;
|
|
121
|
-
}
|
|
122
|
-
/** Blocks sorted back-to-front for painter's-algorithm rendering. */
|
|
123
|
-
drawOrder() {
|
|
124
|
-
return this.list().sort((a, b) => depthKey(a.x, a.y, a.z) - depthKey(b.x, b.y, b.z));
|
|
125
|
-
}
|
|
126
|
-
clone() {
|
|
127
|
-
return new VoxelWorld(this.bounds, new Map(this.blocks));
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
function keyOf(x, y, z) {
|
|
131
|
-
return `${x},${y},${z}`;
|
|
132
|
-
}
|
|
133
|
-
function parseKey(key) {
|
|
134
|
-
const parts = key.split(",");
|
|
135
|
-
if (parts.length !== 3) return null;
|
|
136
|
-
const x = Number(parts[0]);
|
|
137
|
-
const y = Number(parts[1]);
|
|
138
|
-
const z = Number(parts[2]);
|
|
139
|
-
if (!Number.isInteger(x) || !Number.isInteger(y) || !Number.isInteger(z)) return null;
|
|
140
|
-
return {
|
|
141
|
-
x,
|
|
142
|
-
y,
|
|
143
|
-
z
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
function inBounds(x, y, z, bounds) {
|
|
147
|
-
return Number.isInteger(x) && Number.isInteger(y) && Number.isInteger(z) && x >= 0 && y >= 0 && z >= 0 && x < bounds.x && y < bounds.y && z < bounds.z;
|
|
148
|
-
}export{DEFAULT_BOUNDS,VoxelWorld};//# sourceMappingURL=world.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"world.js","sources":["../../../../../../src/features/games/vendored/core/engine/world.ts"],"sourcesContent":["/**\n * The voxel world: a bounded integer grid of blocks. Pure data structure with\n * no rule logic - rule enforcement lives in the game session, which owns a world\n * and gates mutations. Stored sparsely (only non-empty cells) and serialisable.\n */\n\nimport { EMPTY, isValidBlockId, type BlockId } from './palette';\nimport { depthKey } from './iso';\n\nexport interface WorldBounds {\n readonly x: number;\n readonly y: number;\n readonly z: number;\n}\n\nexport interface PlacedBlock {\n readonly x: number;\n readonly y: number;\n readonly z: number;\n readonly block: BlockId;\n}\n\nexport interface SerializedWorld {\n readonly bounds: WorldBounds;\n /** Sparse map of \"x,y,z\" -> block id. */\n readonly blocks: Record<string, BlockId>;\n}\n\nexport type PlaceResult = { ok: true } | { ok: false; reason: 'out-of-bounds' | 'occupied' | 'invalid-block' };\n\nexport type BreakResult = { ok: true; removed: BlockId } | { ok: false; reason: 'out-of-bounds' | 'empty' };\n\nexport const DEFAULT_BOUNDS: WorldBounds = { x: 12, y: 12, z: 8 };\n\nexport class VoxelWorld {\n readonly bounds: WorldBounds;\n private readonly blocks: Map<string, BlockId>;\n\n constructor(bounds: WorldBounds, blocks?: Map<string, BlockId>) {\n this.bounds = bounds;\n this.blocks = blocks ?? new Map();\n }\n\n static create(bounds: WorldBounds = DEFAULT_BOUNDS): VoxelWorld {\n return new VoxelWorld(bounds);\n }\n\n static deserialize(data: SerializedWorld): VoxelWorld {\n const blocks = new Map<string, BlockId>();\n for (const [key, id] of Object.entries(data.blocks)) {\n const coord = parseKey(key);\n if (!coord) continue;\n if (!isValidBlockId(id)) continue;\n if (!inBounds(coord.x, coord.y, coord.z, data.bounds)) continue;\n blocks.set(key, id);\n }\n return new VoxelWorld(data.bounds, blocks);\n }\n\n serialize(): SerializedWorld {\n const blocks: Record<string, BlockId> = {};\n for (const [key, id] of this.blocks) blocks[key] = id;\n return { bounds: this.bounds, blocks };\n }\n\n inBounds(x: number, y: number, z: number): boolean {\n return inBounds(x, y, z, this.bounds);\n }\n\n get(x: number, y: number, z: number): BlockId {\n return this.blocks.get(keyOf(x, y, z)) ?? EMPTY;\n }\n\n has(x: number, y: number, z: number): boolean {\n return this.blocks.has(keyOf(x, y, z));\n }\n\n place(x: number, y: number, z: number, block: BlockId): PlaceResult {\n if (!isValidBlockId(block)) return { ok: false, reason: 'invalid-block' };\n if (!this.inBounds(x, y, z)) return { ok: false, reason: 'out-of-bounds' };\n if (this.has(x, y, z)) return { ok: false, reason: 'occupied' };\n this.blocks.set(keyOf(x, y, z), block);\n return { ok: true };\n }\n\n break(x: number, y: number, z: number): BreakResult {\n if (!this.inBounds(x, y, z)) return { ok: false, reason: 'out-of-bounds' };\n const key = keyOf(x, y, z);\n const existing = this.blocks.get(key);\n if (existing === undefined) return { ok: false, reason: 'empty' };\n this.blocks.delete(key);\n return { ok: true, removed: existing };\n }\n\n clear(): void {\n this.blocks.clear();\n }\n\n count(): number {\n return this.blocks.size;\n }\n\n /** Count of placed blocks of a specific type. */\n countOf(block: BlockId): number {\n let n = 0;\n for (const id of this.blocks.values()) if (id === block) n += 1;\n return n;\n }\n\n list(): PlacedBlock[] {\n const out: PlacedBlock[] = [];\n for (const [key, block] of this.blocks) {\n const coord = parseKey(key);\n if (coord) out.push({ ...coord, block });\n }\n return out;\n }\n\n /** Blocks sorted back-to-front for painter's-algorithm rendering. */\n drawOrder(): PlacedBlock[] {\n return this.list().sort((a, b) => depthKey(a.x, a.y, a.z) - depthKey(b.x, b.y, b.z));\n }\n\n clone(): VoxelWorld {\n return new VoxelWorld(this.bounds, new Map(this.blocks));\n }\n}\n\nfunction keyOf(x: number, y: number, z: number): string {\n return `${x},${y},${z}`;\n}\n\nfunction parseKey(key: string): { x: number; y: number; z: number } | null {\n const parts = key.split(',');\n if (parts.length !== 3) return null;\n const x = Number(parts[0]);\n const y = Number(parts[1]);\n const z = Number(parts[2]);\n if (!Number.isInteger(x) || !Number.isInteger(y) || !Number.isInteger(z)) return null;\n return { x, y, z };\n}\n\nfunction inBounds(x: number, y: number, z: number, bounds: WorldBounds): boolean {\n return (\n Number.isInteger(x) &&\n Number.isInteger(y) &&\n Number.isInteger(z) &&\n x >= 0 &&\n y >= 0 &&\n z >= 0 &&\n x < bounds.x &&\n y < bounds.y &&\n z < bounds.z\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAqCO,MAAM,cAA8B,GAAA;AAAA,EACzC,CAAG,EAAA,EAAA;AAAA,EACH,CAAG,EAAA,EAAA;AAAA,EACH,CAAG,EAAA;AACL;AACO,MAAM,UAAW,CAAA;AAAA,EAGtB,WAAA,CAAY,QAAqB,MAA+B,EAAA;AAFhE,IAAS,aAAA,CAAA,IAAA,EAAA,QAAA,CAAA;AACT,IAAiB,aAAA,CAAA,IAAA,EAAA,QAAA,CAAA;AAEf,IAAA,IAAA,CAAK,MAAS,GAAA,MAAA;AACd,IAAK,IAAA,CAAA,MAAA,GAAS,MAAU,IAAA,IAAA,GAAA,MAAA,mBAAA,IAAI,GAAI,EAAA;AAAA;AAClC,EACA,OAAO,MAAO,CAAA,MAAA,GAAsB,cAA4B,EAAA;AAC9D,IAAO,OAAA,IAAI,WAAW,MAAM,CAAA;AAAA;AAC9B,EACA,OAAO,YAAY,IAAmC,EAAA;AACpD,IAAM,MAAA,MAAA,uBAAa,GAAqB,EAAA;AACxC,IAAW,KAAA,MAAA,CAAC,KAAK,EAAE,CAAA,IAAK,OAAO,OAAQ,CAAA,IAAA,CAAK,MAAM,CAAG,EAAA;AACnD,MAAM,MAAA,KAAA,GAAQ,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right",
|
|
6
|
-
tagline: "Build worlds block by block, with guided lessons and a classroom mode.",
|
|
7
|
-
status: "available",
|
|
8
|
-
accent: "#7cc86b",
|
|
9
|
-
icon: "cube-outline"
|
|
10
|
-
}, {
|
|
11
|
-
id: CUBEFORGE_ID,
|
|
12
|
-
name: "Cubeforge",
|
|
13
|
-
tagline: "Gather, craft, and build to survive - day turns to night.",
|
|
14
|
-
status: "available",
|
|
15
|
-
accent: "#e0a24e",
|
|
16
|
-
icon: "pickaxe"
|
|
17
|
-
}, {
|
|
18
|
-
id: "numberforge",
|
|
19
|
-
name: "Numberforge",
|
|
20
|
-
tagline: "Shape numbers into towers and patterns. Coming soon.",
|
|
21
|
-
status: "coming-soon",
|
|
22
|
-
accent: "#5bb3e6",
|
|
23
|
-
icon: "numeric"
|
|
24
|
-
}, {
|
|
25
|
-
id: "wordsmith",
|
|
26
|
-
name: "Wordsmith",
|
|
27
|
-
tagline: "Craft words from letter blocks. Coming soon.",
|
|
28
|
-
status: "coming-soon",
|
|
29
|
-
accent: "#d1684f",
|
|
30
|
-
icon: "alphabetical-variant"
|
|
31
|
-
}];
|
|
32
|
-
function gameById(id) {
|
|
33
|
-
return GAMES.find((g) => g.id === id);
|
|
34
|
-
}export{BLOCKWRIGHT_ID,CUBEFORGE_ID,GAMES,gameById};//# sourceMappingURL=catalog.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"catalog.js","sources":["../../../../../../src/features/games/vendored/core/games/catalog.ts"],"sourcesContent":["/**\n * The games hub catalog. The hub screen renders this list. New games are added\n * here; the flagship block-building game (\"Blockwright\") is the first available\n * title, with placeholders expressing the wider learning-games direction.\n *\n * All titles, taglines, and art direction are original to Yantra.\n */\n\nexport type GameStatus = 'available' | 'coming-soon';\n\nexport interface GameDefinition {\n readonly id: string;\n readonly name: string;\n readonly tagline: string;\n readonly status: GameStatus;\n /** Accent colour for the hub tile. */\n readonly accent: string;\n /** MaterialCommunityIcons glyph name used by the app shell. */\n readonly icon: string;\n}\n\nexport const BLOCKWRIGHT_ID = 'blockwright';\nexport const CUBEFORGE_ID = 'cubeforge';\n\nexport const GAMES: readonly GameDefinition[] = [\n {\n id: BLOCKWRIGHT_ID,\n name: 'Blockwright',\n tagline: 'Build worlds block by block, with guided lessons and a classroom mode.',\n status: 'available',\n accent: '#7cc86b',\n icon: 'cube-outline',\n },\n {\n id: CUBEFORGE_ID,\n name: 'Cubeforge',\n tagline: 'Gather, craft, and build to survive - day turns to night.',\n status: 'available',\n accent: '#e0a24e',\n icon: 'pickaxe',\n },\n {\n id: 'numberforge',\n name: 'Numberforge',\n tagline: 'Shape numbers into towers and patterns. Coming soon.',\n status: 'coming-soon',\n accent: '#5bb3e6',\n icon: 'numeric',\n },\n {\n id: 'wordsmith',\n name: 'Wordsmith',\n tagline: 'Craft words from letter blocks. Coming soon.',\n status: 'coming-soon',\n accent: '#d1684f',\n icon: 'alphabetical-variant',\n },\n];\n\nexport function availableGames(): GameDefinition[] {\n return GAMES.filter((g) => g.status === 'available');\n}\n\nexport function gameById(id: string): GameDefinition | undefined {\n return GAMES.find((g) => g.id === id);\n}\n"],"names":[],"mappings":"AAmBO,MAAM,cAAiB,GAAA;AACvB,MAAM,YAAe,GAAA;AACrB,MAAM,QAAmC,CAAC;AAAA,EAC/C,EAAI,EAAA,cAAA;AAAA,EACJ,IAAM,EAAA,aAAA;AAAA,EACN,OAAS,EAAA,wEAAA;AAAA,EACT,MAAQ,EAAA,WAAA;AAAA,EACR,MAAQ,EAAA,SAAA;AAAA,EACR,IAAM,EAAA;AACR,CAAG,EAAA;AAAA,EACD,EAAI,EAAA,YAAA;AAAA,EACJ,IAAM,EAAA,WAAA;AAAA,EACN,OAAS,EAAA,2DAAA;AAAA,EACT,MAAQ,EAAA,WAAA;AAAA,EACR,MAAQ,EAAA,SAAA;AAAA,EACR,IAAM,EAAA;AACR,CAAG,EAAA;AAAA,EACD,EAAI,EAAA,aAAA;AAAA,EACJ,IAAM,EAAA,aAAA;AAAA,EACN,OAAS,EAAA,sDAAA;AAAA,EACT,MAAQ,EAAA,aAAA;AAAA,EACR,MAAQ,EAAA,SAAA;AAAA,EACR,IAAM,EAAA;AACR,CAAG,EAAA;AAAA,EACD,EAAI,EAAA,WAAA;AAAA,EACJ,IAAM,EAAA,WAAA;AAAA,EACN,OAAS,EAAA,8CAAA;AAAA,EACT,MAAQ,EAAA,aAAA;AAAA,EACR,MAAQ,EAAA,SAAA;AAAA,EACR,IAAM,EAAA;AACR,CAAC;AAIM,SAAS,SAAS,EAAwC,EAAA;AAC/D,EAAA,OAAO,KAAM,CAAA,IAAA,CAAK,CAAK,CAAA,KAAA,CAAA,CAAE,OAAO,EAAE,CAAA;AACpC"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
function describeEvent(event) {
|
|
2
|
-
switch (event.type) {
|
|
3
|
-
case "session.start":
|
|
4
|
-
return "Opened the world";
|
|
5
|
-
case "block.place":
|
|
6
|
-
return `Placed a block at ${event.x}, ${event.y}, ${event.z}`;
|
|
7
|
-
case "block.break":
|
|
8
|
-
return `Removed a block at ${event.x}, ${event.y}, ${event.z}`;
|
|
9
|
-
case "world.reset":
|
|
10
|
-
return "Cleared the world";
|
|
11
|
-
case "world.undo":
|
|
12
|
-
return "Undid a change";
|
|
13
|
-
case "setting.change":
|
|
14
|
-
return `Changed "${event.key}" to ${event.value ? "on" : "off"}`;
|
|
15
|
-
case "resourceLink.set":
|
|
16
|
-
return event.hasUrl ? "Set the resource link" : "Cleared the resource link";
|
|
17
|
-
case "resourceLink.open":
|
|
18
|
-
return `Opened the resource link (${event.host})`;
|
|
19
|
-
case "permission.change":
|
|
20
|
-
return `Changed ${event.field} to ${String(event.value)}`;
|
|
21
|
-
case "lesson.complete":
|
|
22
|
-
return `Completed lesson "${event.lessonId}"`;
|
|
23
|
-
}
|
|
24
|
-
}export{describeEvent};//# sourceMappingURL=events.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"events.js","sources":["../../../../../../src/features/games/vendored/core/logging/events.ts"],"sourcesContent":["/**\n * Game activity events.\n *\n * The analysed classroom product routes activity through a native `telemetry`\n * surface. Yantra Games keeps an equivalent, but local-first and\n * privacy-respecting: events carry no personal data (just what happened, where,\n * and when), nothing leaves the device by default, and the host app may attach a\n * sink to forward events to Yantra telemetry if a deployment opts in.\n */\n\nimport type { BlockId } from '../engine/palette';\nimport type { BooleanSettingKey } from '../classroom/worldSettings';\nimport type { PermissionLevel } from '../classroom/permissions';\n\ntype Ev<T extends string, P = Record<never, never>> = { type: T } & P;\n\n/** An event before it is time-stamped by the logger. */\nexport type GameEventInput =\n | Ev<'session.start', { worldId?: string }>\n | Ev<'block.place', { block: BlockId; x: number; y: number; z: number }>\n | Ev<'block.break', { x: number; y: number; z: number }>\n | Ev<'world.reset'>\n | Ev<'world.undo'>\n | Ev<'setting.change', { key: BooleanSettingKey; value: boolean }>\n | Ev<'resourceLink.set', { hasUrl: boolean }>\n | Ev<'resourceLink.open', { host: string }>\n | Ev<'permission.change', { field: 'hostEnabled' | 'defaultLevel'; value: boolean | PermissionLevel }>\n | Ev<'lesson.complete', { lessonId: string }>;\n\n/** A time-stamped event as stored and surfaced. */\nexport type GameEvent = GameEventInput & { at: number };\n\nexport type GameEventType = GameEvent['type'];\n\n/** Short, human-readable one-liner for an activity-log row. */\nexport function describeEvent(event: GameEvent): string {\n switch (event.type) {\n case 'session.start':\n return 'Opened the world';\n case 'block.place':\n return `Placed a block at ${event.x}, ${event.y}, ${event.z}`;\n case 'block.break':\n return `Removed a block at ${event.x}, ${event.y}, ${event.z}`;\n case 'world.reset':\n return 'Cleared the world';\n case 'world.undo':\n return 'Undid a change';\n case 'setting.change':\n return `Changed \"${event.key}\" to ${event.value ? 'on' : 'off'}`;\n case 'resourceLink.set':\n return event.hasUrl ? 'Set the resource link' : 'Cleared the resource link';\n case 'resourceLink.open':\n return `Opened the resource link (${event.host})`;\n case 'permission.change':\n return `Changed ${event.field} to ${String(event.value)}`;\n case 'lesson.complete':\n return `Completed lesson \"${event.lessonId}\"`;\n }\n}\n"],"names":[],"mappings":"AAkDO,SAAS,cAAc,KAA0B,EAAA;AACtD,EAAA,QAAQ,MAAM,IAAM;AAAA,IAClB,KAAK,eAAA;AACH,MAAO,OAAA,kBAAA;AAAA,IACT,KAAK,aAAA;AACH,MAAO,OAAA,CAAA,kBAAA,EAAqB,MAAM,CAAC,CAAA,EAAA,EAAK,MAAM,CAAC,CAAA,EAAA,EAAK,MAAM,CAAC,CAAA,CAAA;AAAA,IAC7D,KAAK,aAAA;AACH,MAAO,OAAA,CAAA,mBAAA,EAAsB,MAAM,CAAC,CAAA,EAAA,EAAK,MAAM,CAAC,CAAA,EAAA,EAAK,MAAM,CAAC,CAAA,CAAA;AAAA,IAC9D,KAAK,aAAA;AACH,MAAO,OAAA,mBAAA;AAAA,IACT,KAAK,YAAA;AACH,MAAO,OAAA,gBAAA;AAAA,IACT,KAAK,gBAAA;AACH,MAAA,OAAO,YAAY,KAAM,CAAA,GAAG,QAAQ,KAAM,CAAA,KAAA,GAAQ,OAAO,KAAK,CAAA,CAAA;AAAA,IAChE,KAAK,kBAAA;AACH,MAAO,OAAA,KAAA,CAAM,SAAS,uBAA0B,GAAA,2BAAA;AAAA,IAClD,KAAK,mBAAA;AACH,MAAO,OAAA,CAAA,0BAAA,EAA6B,MAAM,IAAI,CAAA,CAAA,CAAA;AAAA,IAChD,KAAK,mBAAA;AACH,MAAA,OAAO,WAAW,KAAM,CAAA,KAAK,OAAO,MAAO,CAAA,KAAA,CAAM,KAAK,CAAC,CAAA,CAAA;AAAA,IACzD,KAAK,iBAAA;AACH,MAAO,OAAA,CAAA,kBAAA,EAAqB,MAAM,QAAQ,CAAA,CAAA,CAAA;AAAA;AAEhD"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import {ReactiveValue}from'../store/reactive.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
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
21
|
-
const DEFAULT_RECENT_LIMIT = 200;
|
|
22
|
-
class GameLogger {
|
|
23
|
-
constructor(sinks = [], clock = () => Date.now(), recentLimit = DEFAULT_RECENT_LIMIT) {
|
|
24
|
-
this.clock = clock;
|
|
25
|
-
this.recentLimit = recentLimit;
|
|
26
|
-
__publicField(this, "sinks");
|
|
27
|
-
__publicField(this, "recentBuffer");
|
|
28
|
-
this.sinks = [...sinks];
|
|
29
|
-
this.recentBuffer = new ReactiveValue([]);
|
|
30
|
-
}
|
|
31
|
-
/** Newest-first reactive buffer of recent events. */
|
|
32
|
-
get recent() {
|
|
33
|
-
return this.recentBuffer;
|
|
34
|
-
}
|
|
35
|
-
log(input) {
|
|
36
|
-
const event = __spreadProps(__spreadValues({}, input), {
|
|
37
|
-
at: this.clock()
|
|
38
|
-
});
|
|
39
|
-
this.recentBuffer.update((prev) => [event, ...prev].slice(0, this.recentLimit));
|
|
40
|
-
for (const sink of this.sinks) {
|
|
41
|
-
try {
|
|
42
|
-
sink.write(event);
|
|
43
|
-
} catch (e) {
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return event;
|
|
47
|
-
}
|
|
48
|
-
addSink(sink) {
|
|
49
|
-
this.sinks.push(sink);
|
|
50
|
-
}
|
|
51
|
-
clear() {
|
|
52
|
-
this.recentBuffer.set([]);
|
|
53
|
-
}
|
|
54
|
-
}export{GameLogger};//# sourceMappingURL=logger.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sources":["../../../../../../src/features/games/vendored/core/logging/logger.ts"],"sourcesContent":["/**\n * The game activity logger.\n *\n * Fans events out to zero or more sinks and keeps a bounded, reactive buffer of\n * recent events for an in-app activity view. Sinks are pluggable: nothing is\n * emitted off-device unless the host app attaches a sink that does so.\n */\n\nimport { ReactiveValue, type Query } from '../store/reactive';\nimport type { GameEvent, GameEventInput } from './events';\n\nexport interface LogSink {\n write(event: GameEvent): void;\n}\n\n/** Buffers every event in memory - handy for tests and an activity view. */\nexport class MemorySink implements LogSink {\n readonly events: GameEvent[] = [];\n write(event: GameEvent): void {\n this.events.push(event);\n }\n}\n\n/** Writes a compact line per event to the console. Opt-in (debug aid). */\nexport class ConsoleSink implements LogSink {\n constructor(private readonly prefix = '[yantra-games]') {}\n write(event: GameEvent): void {\n // eslint-disable-next-line no-console\n console.log(this.prefix, event.type, event);\n }\n}\n\nconst DEFAULT_RECENT_LIMIT = 200;\n\nexport class GameLogger {\n private readonly sinks: LogSink[];\n private readonly recentBuffer: ReactiveValue<readonly GameEvent[]>;\n\n constructor(\n sinks: LogSink[] = [],\n private readonly clock: () => number = () => Date.now(),\n private readonly recentLimit: number = DEFAULT_RECENT_LIMIT,\n ) {\n this.sinks = [...sinks];\n this.recentBuffer = new ReactiveValue<readonly GameEvent[]>([]);\n }\n\n /** Newest-first reactive buffer of recent events. */\n get recent(): Query<readonly GameEvent[]> {\n return this.recentBuffer;\n }\n\n log(input: GameEventInput): GameEvent {\n const event = { ...input, at: this.clock() } as GameEvent;\n this.recentBuffer.update((prev) => [event, ...prev].slice(0, this.recentLimit));\n for (const sink of this.sinks) {\n try {\n sink.write(event);\n } catch {\n // A misbehaving sink must never break gameplay.\n }\n }\n return event;\n }\n\n addSink(sink: LogSink): void {\n this.sinks.push(sink);\n }\n\n clear(): void {\n this.recentBuffer.set([]);\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AA8BA,MAAM,oBAAuB,GAAA,GAAA;AACtB,MAAM,UAAW,CAAA;AAAA,EAGtB,WAAA,CAAY,KAAmB,GAAA,EAAqB,EAAA,KAAA,GAAsB,MAAM,IAAK,CAAA,GAAA,EAAwB,EAAA,WAAA,GAAsB,oBAAsB,EAAA;AAArG,IAAA,IAAA,CAAA,KAAA,GAAA,KAAA;AAAyD,IAAA,IAAA,CAAA,WAAA,GAAA,WAAA;AAF7G,IAAiB,aAAA,CAAA,IAAA,EAAA,OAAA,CAAA;AACjB,IAAiB,aAAA,CAAA,IAAA,EAAA,cAAA,CAAA;AAEf,IAAK,IAAA,CAAA,KAAA,GAAQ,CAAC,GAAG,KAAK,CAAA;AACtB,IAAA,IAAA,CAAK,YAAe,GAAA,IAAI,aAAoC,CAAA,EAAE,CAAA;AAAA;AAChE;AAAA,EAGA,IAAI,MAAsC,GAAA;AACxC,IAAA,OAAO,IAAK,CAAA,YAAA;AAAA;AACd,EACA,IAAI,KAAkC,EAAA;AACpC,IAAM,MAAA,KAAA,GAAQ,iCACT,KADS,CAAA,EAAA;AAAA,MAEZ,EAAA,EAAI,KAAK,KAAM;AAAA,KACjB,CAAA;AACA,IAAA,IAAA,CAAK,YAAa,CAAA,MAAA,CAAO,CAAQ,IAAA,KAAA,CAAC,KAAO,EAAA,GAAG,IAAI,CAAA,CAAE,KAAM,CAAA,CAAA,EAAG,IAAK,CAAA,WAAW,CAAC,CAAA;AAC5E,IAAW,KAAA,MAAA,IAAA,IAAQ,KAAK,KAAO,EAAA;AAC7B,MAAI,IAAA;AACF,QAAA,IAAA,CAAK,MAAM,KAAK,CAAA;AAAA,OACV,CAAA,OAAA,CAAA,EAAA;AAAA;AAER;AAEF,IAAO,OAAA,KAAA;AAAA;AACT,EACA,QAAQ,IAAqB,EAAA;AAC3B,IAAK,IAAA,CAAA,KAAA,CAAM,KAAK,IAAI,CAAA;AAAA;AACtB,EACA,KAAc,GAAA;AACZ,IAAK,IAAA,CAAA,YAAA,CAAa,GAAI,CAAA,EAAE,CAAA;AAAA;AAE5B"}
|
|
@@ -1,317 +0,0 @@
|
|
|
1
|
-
import {ReactiveValue}from'../store/reactive.js';import {VoxelWorld,DEFAULT_BOUNDS}from'../engine/world.js';import {BLOCKS,EMPTY,isValidBlockId}from'../engine/palette.js';import {defaultWorldSettings}from'../classroom/worldSettings.js';import {applyRuleConstraints,setBooleanSetting}from'../classroom/rules.js';import {normalizeResourceLink,validateResourceLinkUrl}from'../classroom/resourceLink.js';import {defaultPermissionModel,effectiveCapabilities}from'../classroom/permissions.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
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
21
|
-
const UNDO_LIMIT = 100;
|
|
22
|
-
class GameSession {
|
|
23
|
-
constructor(init = {}) {
|
|
24
|
-
__publicField(this, "world");
|
|
25
|
-
__publicField(this, "settings");
|
|
26
|
-
__publicField(this, "permissions");
|
|
27
|
-
__publicField(this, "actingLevel");
|
|
28
|
-
__publicField(this, "selectedBlock");
|
|
29
|
-
__publicField(this, "undoStack", []);
|
|
30
|
-
__publicField(this, "state");
|
|
31
|
-
__publicField(this, "logger");
|
|
32
|
-
__publicField(this, "transport");
|
|
33
|
-
__publicField(this, "disposers", []);
|
|
34
|
-
var _a, _b, _c, _d, _e, _f;
|
|
35
|
-
this.world = init.world ? VoxelWorld.deserialize(init.world) : VoxelWorld.create(DEFAULT_BOUNDS);
|
|
36
|
-
this.settings = applyRuleConstraints((_a = init.settings) != null ? _a : defaultWorldSettings());
|
|
37
|
-
this.permissions = (_b = init.permissions) != null ? _b : defaultPermissionModel();
|
|
38
|
-
this.actingLevel = (_c = init.actingLevel) != null ? _c : "operator";
|
|
39
|
-
const firstBlock = (_e = (_d = BLOCKS[0]) == null ? void 0 : _d.id) != null ? _e : EMPTY;
|
|
40
|
-
this.selectedBlock = init.selectedBlock && isValidBlockId(init.selectedBlock) ? init.selectedBlock : firstBlock;
|
|
41
|
-
this.logger = init.logger;
|
|
42
|
-
this.transport = init.transport;
|
|
43
|
-
this.state = new ReactiveValue(this.snapshot());
|
|
44
|
-
(_f = this.logger) == null ? void 0 : _f.log({
|
|
45
|
-
type: "session.start",
|
|
46
|
-
worldId: init.worldId
|
|
47
|
-
});
|
|
48
|
-
if (this.transport) {
|
|
49
|
-
this.disposers.push(this.transport.subscribe((msg) => this.onRemote(msg)));
|
|
50
|
-
this.disposers.push(this.transport.peers.subscribe(() => this.publish()));
|
|
51
|
-
this.transport.send({
|
|
52
|
-
kind: "hello"
|
|
53
|
-
});
|
|
54
|
-
this.publish();
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
get query() {
|
|
58
|
-
return this.state;
|
|
59
|
-
}
|
|
60
|
-
getState() {
|
|
61
|
-
return this.state.get();
|
|
62
|
-
}
|
|
63
|
-
// --- block editing ---
|
|
64
|
-
selectBlock(block) {
|
|
65
|
-
if (!isValidBlockId(block) || this.selectedBlock === block) return;
|
|
66
|
-
this.selectedBlock = block;
|
|
67
|
-
this.publish();
|
|
68
|
-
}
|
|
69
|
-
placeBlock(x, y, z) {
|
|
70
|
-
var _a, _b;
|
|
71
|
-
if (!this.canEdit()) return false;
|
|
72
|
-
const op = {
|
|
73
|
-
t: "place",
|
|
74
|
-
x,
|
|
75
|
-
y,
|
|
76
|
-
z,
|
|
77
|
-
block: this.selectedBlock
|
|
78
|
-
};
|
|
79
|
-
if (!this.applyOp(op)) return false;
|
|
80
|
-
this.publish();
|
|
81
|
-
(_a = this.logger) == null ? void 0 : _a.log({
|
|
82
|
-
type: "block.place",
|
|
83
|
-
block: this.selectedBlock,
|
|
84
|
-
x,
|
|
85
|
-
y,
|
|
86
|
-
z
|
|
87
|
-
});
|
|
88
|
-
(_b = this.transport) == null ? void 0 : _b.send({
|
|
89
|
-
kind: "edit",
|
|
90
|
-
op
|
|
91
|
-
});
|
|
92
|
-
return true;
|
|
93
|
-
}
|
|
94
|
-
breakBlock(x, y, z) {
|
|
95
|
-
var _a, _b;
|
|
96
|
-
if (!this.canEdit()) return false;
|
|
97
|
-
const op = {
|
|
98
|
-
t: "break",
|
|
99
|
-
x,
|
|
100
|
-
y,
|
|
101
|
-
z
|
|
102
|
-
};
|
|
103
|
-
if (!this.applyOp(op)) return false;
|
|
104
|
-
this.publish();
|
|
105
|
-
(_a = this.logger) == null ? void 0 : _a.log({
|
|
106
|
-
type: "block.break",
|
|
107
|
-
x,
|
|
108
|
-
y,
|
|
109
|
-
z
|
|
110
|
-
});
|
|
111
|
-
(_b = this.transport) == null ? void 0 : _b.send({
|
|
112
|
-
kind: "edit",
|
|
113
|
-
op
|
|
114
|
-
});
|
|
115
|
-
return true;
|
|
116
|
-
}
|
|
117
|
-
undo() {
|
|
118
|
-
var _a, _b;
|
|
119
|
-
const previous = this.undoStack.pop();
|
|
120
|
-
if (!previous) return false;
|
|
121
|
-
this.world = VoxelWorld.deserialize(previous);
|
|
122
|
-
this.publish();
|
|
123
|
-
(_a = this.logger) == null ? void 0 : _a.log({
|
|
124
|
-
type: "world.undo"
|
|
125
|
-
});
|
|
126
|
-
(_b = this.transport) == null ? void 0 : _b.send({
|
|
127
|
-
kind: "snapshot",
|
|
128
|
-
world: this.world.serialize()
|
|
129
|
-
});
|
|
130
|
-
return true;
|
|
131
|
-
}
|
|
132
|
-
reset() {
|
|
133
|
-
var _a, _b;
|
|
134
|
-
const op = {
|
|
135
|
-
t: "reset"
|
|
136
|
-
};
|
|
137
|
-
if (!this.applyOp(op)) return;
|
|
138
|
-
this.publish();
|
|
139
|
-
(_a = this.logger) == null ? void 0 : _a.log({
|
|
140
|
-
type: "world.reset"
|
|
141
|
-
});
|
|
142
|
-
(_b = this.transport) == null ? void 0 : _b.send({
|
|
143
|
-
kind: "edit",
|
|
144
|
-
op
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
/** Leave multiplayer and release subscriptions. Safe to call once. */
|
|
148
|
-
dispose() {
|
|
149
|
-
var _a;
|
|
150
|
-
for (const off of this.disposers.splice(0)) off();
|
|
151
|
-
(_a = this.transport) == null ? void 0 : _a.close();
|
|
152
|
-
}
|
|
153
|
-
// --- acting player (teacher can preview as a given level) ---
|
|
154
|
-
setActingLevel(level) {
|
|
155
|
-
if (this.actingLevel === level) return;
|
|
156
|
-
this.actingLevel = level;
|
|
157
|
-
this.publish();
|
|
158
|
-
}
|
|
159
|
-
// --- classroom settings ---
|
|
160
|
-
setBooleanSetting(key, value) {
|
|
161
|
-
var _a;
|
|
162
|
-
const next = setBooleanSetting(this.settings, key, value);
|
|
163
|
-
if (next === this.settings) return;
|
|
164
|
-
this.settings = next;
|
|
165
|
-
this.publish();
|
|
166
|
-
(_a = this.logger) == null ? void 0 : _a.log({
|
|
167
|
-
type: "setting.change",
|
|
168
|
-
key,
|
|
169
|
-
value: next[key]
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
setResourceLink(link) {
|
|
173
|
-
var _a;
|
|
174
|
-
const normalized = normalizeResourceLink(link);
|
|
175
|
-
this.settings = __spreadProps(__spreadValues({}, this.settings), {
|
|
176
|
-
resourceLink: normalized
|
|
177
|
-
});
|
|
178
|
-
this.publish();
|
|
179
|
-
(_a = this.logger) == null ? void 0 : _a.log({
|
|
180
|
-
type: "resourceLink.set",
|
|
181
|
-
hasUrl: normalized.url !== ""
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* Validate and "open" the teacher resource link. Returns the safe URL for the
|
|
186
|
-
* host app to navigate to, and logs the open. Returns ok:false if no valid
|
|
187
|
-
* link is set.
|
|
188
|
-
*/
|
|
189
|
-
openResourceLink() {
|
|
190
|
-
var _a;
|
|
191
|
-
const validation = validateResourceLinkUrl(this.settings.resourceLink.url);
|
|
192
|
-
if (!validation.ok || validation.empty) return {
|
|
193
|
-
ok: false
|
|
194
|
-
};
|
|
195
|
-
let host = "";
|
|
196
|
-
try {
|
|
197
|
-
host = new URL(validation.url).host;
|
|
198
|
-
} catch (e) {
|
|
199
|
-
host = "";
|
|
200
|
-
}
|
|
201
|
-
(_a = this.logger) == null ? void 0 : _a.log({
|
|
202
|
-
type: "resourceLink.open",
|
|
203
|
-
host
|
|
204
|
-
});
|
|
205
|
-
return {
|
|
206
|
-
ok: true,
|
|
207
|
-
url: validation.url
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
setHostEnabled(enabled) {
|
|
211
|
-
var _a;
|
|
212
|
-
if (this.permissions.hostEnabled === enabled) return;
|
|
213
|
-
this.permissions = __spreadProps(__spreadValues({}, this.permissions), {
|
|
214
|
-
hostEnabled: enabled
|
|
215
|
-
});
|
|
216
|
-
this.publish();
|
|
217
|
-
(_a = this.logger) == null ? void 0 : _a.log({
|
|
218
|
-
type: "permission.change",
|
|
219
|
-
field: "hostEnabled",
|
|
220
|
-
value: enabled
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
|
-
setDefaultLevel(level) {
|
|
224
|
-
var _a;
|
|
225
|
-
if (this.permissions.defaultLevel === level) return;
|
|
226
|
-
this.permissions = __spreadProps(__spreadValues({}, this.permissions), {
|
|
227
|
-
defaultLevel: level
|
|
228
|
-
});
|
|
229
|
-
this.publish();
|
|
230
|
-
(_a = this.logger) == null ? void 0 : _a.log({
|
|
231
|
-
type: "permission.change",
|
|
232
|
-
field: "defaultLevel",
|
|
233
|
-
value: level
|
|
234
|
-
});
|
|
235
|
-
}
|
|
236
|
-
// --- persistence helpers ---
|
|
237
|
-
exportWorld() {
|
|
238
|
-
return this.world.serialize();
|
|
239
|
-
}
|
|
240
|
-
exportSettings() {
|
|
241
|
-
return this.settings;
|
|
242
|
-
}
|
|
243
|
-
exportPermissions() {
|
|
244
|
-
return this.permissions;
|
|
245
|
-
}
|
|
246
|
-
// --- internals ---
|
|
247
|
-
canEdit() {
|
|
248
|
-
return effectiveCapabilities(this.actingLevel, this.settings).canBuild;
|
|
249
|
-
}
|
|
250
|
-
/** Apply a world op to the model (no permission gating). Returns true if it changed. */
|
|
251
|
-
applyOp(op) {
|
|
252
|
-
if (op.t === "reset") {
|
|
253
|
-
if (this.world.count() === 0) return false;
|
|
254
|
-
this.pushUndo();
|
|
255
|
-
this.world = VoxelWorld.create(this.world.bounds);
|
|
256
|
-
return true;
|
|
257
|
-
}
|
|
258
|
-
if (op.t === "place") {
|
|
259
|
-
this.pushUndo();
|
|
260
|
-
const result2 = this.world.place(op.x, op.y, op.z, op.block);
|
|
261
|
-
if (!result2.ok) {
|
|
262
|
-
this.undoStack.pop();
|
|
263
|
-
return false;
|
|
264
|
-
}
|
|
265
|
-
return true;
|
|
266
|
-
}
|
|
267
|
-
this.pushUndo();
|
|
268
|
-
const result = this.world.break(op.x, op.y, op.z);
|
|
269
|
-
if (!result.ok) {
|
|
270
|
-
this.undoStack.pop();
|
|
271
|
-
return false;
|
|
272
|
-
}
|
|
273
|
-
return true;
|
|
274
|
-
}
|
|
275
|
-
/** Handle a message from a peer. Remote edits apply without re-broadcasting. */
|
|
276
|
-
onRemote(message) {
|
|
277
|
-
var _a;
|
|
278
|
-
if (message.kind === "edit") {
|
|
279
|
-
if (this.applyOp(message.op)) this.publish();
|
|
280
|
-
return;
|
|
281
|
-
}
|
|
282
|
-
if (message.kind === "hello") {
|
|
283
|
-
if (this.world.count() > 0) {
|
|
284
|
-
(_a = this.transport) == null ? void 0 : _a.send({
|
|
285
|
-
kind: "snapshot",
|
|
286
|
-
world: this.world.serialize()
|
|
287
|
-
});
|
|
288
|
-
}
|
|
289
|
-
return;
|
|
290
|
-
}
|
|
291
|
-
if (this.world.count() === 0 && this.undoStack.length === 0) {
|
|
292
|
-
this.world = VoxelWorld.deserialize(message.world);
|
|
293
|
-
this.publish();
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
pushUndo() {
|
|
297
|
-
this.undoStack.push(this.world.serialize());
|
|
298
|
-
if (this.undoStack.length > UNDO_LIMIT) this.undoStack.shift();
|
|
299
|
-
}
|
|
300
|
-
publish() {
|
|
301
|
-
this.state.set(this.snapshot());
|
|
302
|
-
}
|
|
303
|
-
snapshot() {
|
|
304
|
-
return {
|
|
305
|
-
bounds: this.world.bounds,
|
|
306
|
-
blocks: this.world.drawOrder(),
|
|
307
|
-
blockCount: this.world.count(),
|
|
308
|
-
settings: this.settings,
|
|
309
|
-
permissions: this.permissions,
|
|
310
|
-
actingLevel: this.actingLevel,
|
|
311
|
-
selectedBlock: this.selectedBlock,
|
|
312
|
-
canEdit: this.canEdit(),
|
|
313
|
-
canUndo: this.undoStack.length > 0,
|
|
314
|
-
peers: this.transport ? this.transport.peers.get() : []
|
|
315
|
-
};
|
|
316
|
-
}
|
|
317
|
-
}export{GameSession};//# sourceMappingURL=gameSession.js.map
|