@adminide-stack/yantra-mobile 12.0.171 → 12.0.172-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. package/lib/components/GatewayConnector/GatewayConnector.js +10 -4
  2. package/lib/components/GatewayConnector/GatewayConnector.js.map +1 -1
  3. package/lib/components/GatewayConnector/GatewayStatusSheet.js +174 -0
  4. package/lib/components/GatewayConnector/GatewayStatusSheet.js.map +1 -0
  5. package/lib/components/GatewayToolbarButtonMobile.js +6 -2
  6. package/lib/components/GatewayToolbarButtonMobile.js.map +1 -1
  7. package/lib/compute.js +51 -1
  8. package/lib/compute.js.map +1 -1
  9. package/lib/config/env-config.js +12 -3
  10. package/lib/config/env-config.js.map +1 -1
  11. package/lib/features/apps/AppsCatalog.js +10 -0
  12. package/lib/features/apps/AppsCatalog.js.map +1 -1
  13. package/lib/features/apps/mobileAppCatalog.js +9 -0
  14. package/lib/features/apps/mobileAppCatalog.js.map +1 -1
  15. package/lib/features/apps/nativeAppHandoff.js +31 -13
  16. package/lib/features/apps/nativeAppHandoff.js.map +1 -1
  17. package/lib/features/apps/nativeSurfaceTwin.js +2 -1
  18. package/lib/features/apps/nativeSurfaceTwin.js.map +1 -1
  19. package/lib/features/canvas/set/agent/prompt.js +4 -5
  20. package/lib/features/canvas/set/agent/prompt.js.map +1 -1
  21. package/lib/features/canvas/set/supplyLibrary.js +1294 -2
  22. package/lib/features/canvas/set/supplyLibrary.js.map +1 -1
  23. package/lib/features/chat/PromptFillBar.js +153 -0
  24. package/lib/features/chat/PromptFillBar.js.map +1 -0
  25. package/lib/features/chat/promptBlanks.js +120 -0
  26. package/lib/features/chat/promptBlanks.js.map +1 -0
  27. package/lib/features/chat/savedReply.js +11 -0
  28. package/lib/features/chat/savedReply.js.map +1 -0
  29. package/lib/features/games/GameInviteCard.js +93 -0
  30. package/lib/features/games/GameInviteCard.js.map +1 -0
  31. package/lib/features/games/cubeforge3D.js +97 -0
  32. package/lib/features/games/cubeforge3D.js.map +1 -0
  33. package/lib/features/games/cubeforgeFriends.js +112 -0
  34. package/lib/features/games/cubeforgeFriends.js.map +1 -0
  35. package/lib/features/games/gameInvite.js +13 -0
  36. package/lib/features/games/gameInvite.js.map +1 -0
  37. package/lib/features/games/useCubeforgeFriends.js +63 -0
  38. package/lib/features/games/useCubeforgeFriends.js.map +1 -0
  39. package/lib/features/games/vendored/core/classroom/permissions.js +76 -0
  40. package/lib/features/games/vendored/core/classroom/permissions.js.map +1 -0
  41. package/lib/features/games/vendored/core/classroom/resourceLink.js +101 -0
  42. package/lib/features/games/vendored/core/classroom/resourceLink.js.map +1 -0
  43. package/lib/features/games/vendored/core/classroom/rules.js +83 -0
  44. package/lib/features/games/vendored/core/classroom/rules.js.map +1 -0
  45. package/lib/features/games/vendored/core/classroom/worldSettings.js +49 -0
  46. package/lib/features/games/vendored/core/classroom/worldSettings.js.map +1 -0
  47. package/lib/features/games/vendored/core/cubeforge/cycle.js +15 -0
  48. package/lib/features/games/vendored/core/cubeforge/cycle.js.map +1 -0
  49. package/lib/features/games/vendored/core/cubeforge/inventory.js +75 -0
  50. package/lib/features/games/vendored/core/cubeforge/inventory.js.map +1 -0
  51. package/lib/features/games/vendored/core/cubeforge/items.js +62 -0
  52. package/lib/features/games/vendored/core/cubeforge/items.js.map +1 -0
  53. package/lib/features/games/vendored/core/cubeforge/nativeWorld.js +4 -0
  54. package/lib/features/games/vendored/core/cubeforge/nativeWorld.js.map +1 -0
  55. package/lib/features/games/vendored/core/cubeforge/nativeWorlds.js +68 -0
  56. package/lib/features/games/vendored/core/cubeforge/nativeWorlds.js.map +1 -0
  57. package/lib/features/games/vendored/core/cubeforge/recipes.js +52 -0
  58. package/lib/features/games/vendored/core/cubeforge/recipes.js.map +1 -0
  59. package/lib/features/games/vendored/core/cubeforge/save.js +92 -0
  60. package/lib/features/games/vendored/core/cubeforge/save.js.map +1 -0
  61. package/lib/features/games/vendored/core/cubeforge/session.js +154 -0
  62. package/lib/features/games/vendored/core/cubeforge/session.js.map +1 -0
  63. package/lib/features/games/vendored/core/cubeforge/sharedWorlds.js +10 -0
  64. package/lib/features/games/vendored/core/cubeforge/sharedWorlds.js.map +1 -0
  65. package/lib/features/games/vendored/core/cubeforge/worldgen.js +44 -0
  66. package/lib/features/games/vendored/core/cubeforge/worldgen.js.map +1 -0
  67. package/lib/features/games/vendored/core/engine/iso.js +41 -0
  68. package/lib/features/games/vendored/core/engine/iso.js.map +1 -0
  69. package/lib/features/games/vendored/core/engine/palette.js +53 -0
  70. package/lib/features/games/vendored/core/engine/palette.js.map +1 -0
  71. package/lib/features/games/vendored/core/engine/world.js +148 -0
  72. package/lib/features/games/vendored/core/engine/world.js.map +1 -0
  73. package/lib/features/games/vendored/core/games/catalog.js +34 -0
  74. package/lib/features/games/vendored/core/games/catalog.js.map +1 -0
  75. package/lib/features/games/vendored/core/lessons/lessons.js +97 -0
  76. package/lib/features/games/vendored/core/lessons/lessons.js.map +1 -0
  77. package/lib/features/games/vendored/core/logging/events.js +24 -0
  78. package/lib/features/games/vendored/core/logging/events.js.map +1 -0
  79. package/lib/features/games/vendored/core/logging/logger.js +54 -0
  80. package/lib/features/games/vendored/core/logging/logger.js.map +1 -0
  81. package/lib/features/games/vendored/core/session/gameSession.js +317 -0
  82. package/lib/features/games/vendored/core/session/gameSession.js.map +1 -0
  83. package/lib/features/games/vendored/core/storage/worldRepository.js +192 -0
  84. package/lib/features/games/vendored/core/storage/worldRepository.js.map +1 -0
  85. package/lib/features/games/vendored/core/store/reactive.js +78 -0
  86. package/lib/features/games/vendored/core/store/reactive.js.map +1 -0
  87. package/lib/features/games/vendored/ui/GamesRoot.js +223 -0
  88. package/lib/features/games/vendored/ui/GamesRoot.js.map +1 -0
  89. package/lib/features/games/vendored/ui/components/BlockPalette.js +64 -0
  90. package/lib/features/games/vendored/ui/components/BlockPalette.js.map +1 -0
  91. package/lib/features/games/vendored/ui/components/IsoCanvas.js +124 -0
  92. package/lib/features/games/vendored/ui/components/IsoCanvas.js.map +1 -0
  93. package/lib/features/games/vendored/ui/components/primitives.js +257 -0
  94. package/lib/features/games/vendored/ui/components/primitives.js.map +1 -0
  95. package/lib/features/games/vendored/ui/hooks/useReactiveQuery.js +3 -0
  96. package/lib/features/games/vendored/ui/hooks/useReactiveQuery.js.map +1 -0
  97. package/lib/features/games/vendored/ui/screens/ActivityScreen.js +68 -0
  98. package/lib/features/games/vendored/ui/screens/ActivityScreen.js.map +1 -0
  99. package/lib/features/games/vendored/ui/screens/BuilderScreen.js +227 -0
  100. package/lib/features/games/vendored/ui/screens/BuilderScreen.js.map +1 -0
  101. package/lib/features/games/vendored/ui/screens/ClassroomScreen.js +95 -0
  102. package/lib/features/games/vendored/ui/screens/ClassroomScreen.js.map +1 -0
  103. package/lib/features/games/vendored/ui/screens/Cubeforge3DHomeScreen.js +296 -0
  104. package/lib/features/games/vendored/ui/screens/Cubeforge3DHomeScreen.js.map +1 -0
  105. package/lib/features/games/vendored/ui/screens/CubeforgeScreen.js +342 -0
  106. package/lib/features/games/vendored/ui/screens/CubeforgeScreen.js.map +1 -0
  107. package/lib/features/games/vendored/ui/screens/HubScreen.js +131 -0
  108. package/lib/features/games/vendored/ui/screens/HubScreen.js.map +1 -0
  109. package/lib/features/games/vendored/ui/screens/ScreenHeader.js +51 -0
  110. package/lib/features/games/vendored/ui/screens/ScreenHeader.js.map +1 -0
  111. package/lib/features/games/vendored/ui/screens/WorldListScreen.js +134 -0
  112. package/lib/features/games/vendored/ui/screens/WorldListScreen.js.map +1 -0
  113. package/lib/features/games/vendored/ui/storage/asyncStorageAdapter.js +23 -0
  114. package/lib/features/games/vendored/ui/storage/asyncStorageAdapter.js.map +1 -0
  115. package/lib/features/games/vendored/ui/theme.js +53 -0
  116. package/lib/features/games/vendored/ui/theme.js.map +1 -0
  117. package/lib/features/messaging/ChatComponents.js +12 -4
  118. package/lib/features/messaging/ChatComponents.js.map +1 -1
  119. package/lib/features/messaging/messageCards.js +22 -0
  120. package/lib/features/messaging/messageCards.js.map +1 -0
  121. package/lib/features/travel/TravelAgentChatPane.js +9 -1
  122. package/lib/features/travel/TravelAgentChatPane.js.map +1 -1
  123. package/lib/hooks/useCdecliAutoConnect.js +8 -1
  124. package/lib/hooks/useCdecliAutoConnect.js.map +1 -1
  125. package/lib/hooks/useCdecliChannel.js +142 -49
  126. package/lib/hooks/useCdecliChannel.js.map +1 -1
  127. package/lib/hooks/useChatApi.js +21 -10
  128. package/lib/hooks/useChatApi.js.map +1 -1
  129. package/lib/hooks/useChatStream.js +18 -5
  130. package/lib/hooks/useChatStream.js.map +1 -1
  131. package/lib/module.js +2 -1
  132. package/lib/module.js.map +1 -1
  133. package/lib/routes.json +50 -0
  134. package/lib/screens/Chat/index.js +23 -15
  135. package/lib/screens/Chat/index.js.map +1 -1
  136. package/lib/screens/GamesNative/index.js +75 -0
  137. package/lib/screens/GamesNative/index.js.map +1 -0
  138. package/lib/screens/Home/HomeScreen.js +147 -33
  139. package/lib/screens/Home/HomeScreen.js.map +1 -1
  140. package/lib/screens/Home/components/HomeSuggestions.js +1 -1
  141. package/lib/screens/Home/components/HomeSuggestions.js.map +1 -1
  142. package/lib/screens/Home/components/homeCatalog.js +68 -16
  143. package/lib/screens/Home/components/homeCatalog.js.map +1 -1
  144. package/package.json +4 -4
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resourceLink.js","sources":["../../../../../../src/features/games/vendored/core/classroom/resourceLink.ts"],"sourcesContent":["/**\n * The teacher resource link.\n *\n * A teacher can set a button name plus a URL; students see that button in the\n * in-world menu and tapping it opens the link. The feature study of a comparable\n * classroom product found its UI shipped with NO scheme/host validation on this\n * field (only a 1024-char cap), leaving it to a native handler. Yantra Games\n * validates here, in shared logic, so an unsafe link can never be stored:\n *\n * - only http / https are accepted (javascript:, data:, file:, etc. are rejected);\n * - loopback, link-local, and private-network hosts are rejected so a link can\n * never point students at an internal/admin address;\n * - the URL is length-capped.\n */\n\nexport interface ResourceLink {\n /** Teacher-chosen button label. Empty => a sensible default label is shown. */\n buttonName: string;\n /** The URL to open. Empty => no resource-link button is shown. */\n url: string;\n}\n\nexport const RESOURCE_LINK_MAX_URL = 1024;\nexport const RESOURCE_LINK_MAX_BUTTON_NAME = 48;\nexport const RESOURCE_LINK_DEFAULT_BUTTON_NAME = 'Open Link';\n\nexport function emptyResourceLink(): ResourceLink {\n return { buttonName: '', url: '' };\n}\n\nexport type ResourceLinkErrorCode = 'too-long' | 'invalid-url' | 'unsupported-scheme' | 'missing-host' | 'blocked-host';\n\nexport type ResourceLinkValidation =\n | { ok: true; url: string; empty: boolean }\n | { ok: false; code: ResourceLinkErrorCode; message: string };\n\nconst ALLOWED_SCHEMES = new Set(['http:', 'https:']);\n\n/**\n * Validate a resource-link URL. An empty string is valid and means \"no link\".\n */\nexport function validateResourceLinkUrl(raw: string): ResourceLinkValidation {\n const trimmed = raw.trim();\n if (trimmed === '') return { ok: true, url: '', empty: true };\n\n if (trimmed.length > RESOURCE_LINK_MAX_URL) {\n return {\n ok: false,\n code: 'too-long',\n message: `Link must be ${RESOURCE_LINK_MAX_URL} characters or fewer.`,\n };\n }\n\n let parsed: URL;\n try {\n parsed = new URL(trimmed);\n } catch {\n return {\n ok: false,\n code: 'invalid-url',\n message: 'Enter a full web address, like https://example.com/page.',\n };\n }\n\n if (!ALLOWED_SCHEMES.has(parsed.protocol)) {\n return {\n ok: false,\n code: 'unsupported-scheme',\n message: 'Only http and https links are allowed.',\n };\n }\n\n const host = parsed.hostname.toLowerCase();\n if (host === '') {\n return { ok: false, code: 'missing-host', message: 'The link is missing a website address.' };\n }\n if (isBlockedHost(host)) {\n return {\n ok: false,\n code: 'blocked-host',\n message: 'Internal and private addresses are not allowed for student links.',\n };\n }\n\n return { ok: true, url: parsed.toString(), empty: false };\n}\n\n/** The label to show on the resource-link button. */\nexport function resourceLinkButtonLabel(link: ResourceLink): string {\n const name = link.buttonName.trim();\n return name === '' ? RESOURCE_LINK_DEFAULT_BUTTON_NAME : name;\n}\n\n/** Whether the resource link is set and valid (and therefore shown to students). */\nexport function isResourceLinkActive(link: ResourceLink): boolean {\n const result = validateResourceLinkUrl(link.url);\n return result.ok && !result.empty;\n}\n\n/**\n * Normalise a resource link for storage: a valid URL is canonicalised, the\n * button name is capped, and an invalid or empty URL collapses to \"no link\".\n */\nexport function normalizeResourceLink(link: ResourceLink): ResourceLink {\n const validation = validateResourceLinkUrl(link.url);\n const url = validation.ok && !validation.empty ? validation.url : '';\n const buttonName = link.buttonName.trim().slice(0, RESOURCE_LINK_MAX_BUTTON_NAME);\n return { buttonName, url };\n}\n\n/** Reject loopback, link-local, and private-network hosts. */\nfunction isBlockedHost(host: string): boolean {\n // Strip IPv6 brackets if present.\n const h = host.startsWith('[') && host.endsWith(']') ? host.slice(1, -1) : host;\n\n if (h === 'localhost' || h.endsWith('.localhost')) return true;\n if (h.endsWith('.local')) return true;\n if (h === '::1' || h === '::' || h.startsWith('fe80:') || h.startsWith('fc') || h.startsWith('fd')) {\n return true;\n }\n\n const v4 = parseIpv4(h);\n if (v4) {\n const [a, b] = v4;\n if (a === 10) return true; // 10.0.0.0/8\n if (a === 127) return true; // loopback\n if (a === 0) return true; // 0.0.0.0/8\n if (a === 169 && b === 254) return true; // link-local\n if (a === 192 && b === 168) return true; // private\n if (a === 172 && b >= 16 && b <= 31) return true; // private\n }\n return false;\n}\n\n/** Parse a dotted IPv4 string into four octets, or null if it is not one. */\nfunction parseIpv4(host: string): [number, number, number, number] | null {\n const parts = host.split('.');\n if (parts.length !== 4) return null;\n const octets: number[] = [];\n for (const part of parts) {\n if (!/^\\d{1,3}$/.test(part)) return null;\n const n = Number(part);\n if (n > 255) return null;\n octets.push(n);\n }\n return [octets[0]!, octets[1]!, octets[2]!, octets[3]!];\n}\n"],"names":[],"mappings":"AAqBO,MAAM,qBAAwB,GAAA;AAC9B,MAAM,6BAAgC,GAAA;AAEtC,SAAS,iBAAkC,GAAA;AAChD,EAAO,OAAA;AAAA,IACL,UAAY,EA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__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 COUPLINGS = [{
21
+ parent: "destructiveItems",
22
+ when: false,
23
+ children: ["tntExplodes", "respawnBlocksExplode", "fireSpreads"],
24
+ force: false,
25
+ reason: "Destructive items are turned off"
26
+ }, {
27
+ parent: "playerDamage",
28
+ when: false,
29
+ children: ["pvp", "friendlyFire"],
30
+ force: false,
31
+ reason: "Player damage is turned off"
32
+ }, {
33
+ parent: "mobsRestricted",
34
+ when: true,
35
+ children: ["mobSpawning"],
36
+ force: false,
37
+ reason: "Mobs are restricted"
38
+ }, {
39
+ parent: "perfectWeather",
40
+ when: true,
41
+ children: ["weatherCycle"],
42
+ force: false,
43
+ reason: "Perfect weather is on"
44
+ }];
45
+ function evaluateRules(settings) {
46
+ const result = {};
47
+ for (const key of BOOLEAN_SETTING_KEYS) {
48
+ result[key] = {
49
+ value: settings[key],
50
+ locked: false
51
+ };
52
+ }
53
+ for (const coupling of COUPLINGS) {
54
+ if (settings[coupling.parent] !== coupling.when) continue;
55
+ for (const child of coupling.children) {
56
+ result[child] = {
57
+ value: coupling.force,
58
+ locked: true,
59
+ lockedReason: coupling.reason
60
+ };
61
+ }
62
+ }
63
+ return result;
64
+ }
65
+ function applyRuleConstraints(settings) {
66
+ const rules = evaluateRules(settings);
67
+ let next = null;
68
+ for (const key of BOOLEAN_SETTING_KEYS) {
69
+ const state = rules[key];
70
+ if (state.locked && settings[key] !== state.value) {
71
+ if (!next) next = __spreadValues({}, settings);
72
+ next[key] = state.value;
73
+ }
74
+ }
75
+ return next != null ? next : settings;
76
+ }
77
+ function setBooleanSetting(settings, key, value) {
78
+ if (evaluateRules(settings)[key].locked) return settings;
79
+ if (settings[key] === value) return applyRuleConstraints(settings);
80
+ return applyRuleConstraints(__spreadProps(__spreadValues({}, settings), {
81
+ [key]: value
82
+ }));
83
+ }export{applyRuleConstraints,evaluateRules,setBooleanSetting};//# sourceMappingURL=rules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rules.js","sources":["../../../../../../src/features/games/vendored/core/classroom/rules.ts"],"sourcesContent":["/**\n * The world-rule coupling engine.\n *\n * Some master classroom rules force dependent rules into a fixed state and lock\n * them. For example, turning \"Destructive items\" off forces explosions and fire\n * spread off and prevents the teacher from turning them back on while it stays\n * off. This module is the single authority for those couplings.\n *\n * Crucially, `setBooleanSetting` and `applyRuleConstraints` *normalise* the\n * stored settings so a forced rule is actually stored in its forced state. That\n * means a saved-and-reloaded world can never come back with a locked toggle in a\n * contradictory position - the UI and the enforced state stay in agreement.\n */\n\nimport { BOOLEAN_SETTING_KEYS, type BooleanSettingKey, type WorldSettings } from './worldSettings';\n\nexport interface RuleState {\n /** The effective value, after couplings are applied. */\n value: boolean;\n /** Whether the teacher is allowed to change it right now. */\n locked: boolean;\n /** Why it is locked, if it is. */\n lockedReason?: string;\n}\n\nexport type EvaluatedRules = Record<BooleanSettingKey, RuleState>;\n\ninterface Coupling {\n readonly parent: BooleanSettingKey;\n /** The parent value that activates this coupling. */\n readonly when: boolean;\n readonly children: readonly BooleanSettingKey[];\n /** The value each child is forced to while the coupling is active. */\n readonly force: boolean;\n readonly reason: string;\n}\n\nconst COUPLINGS: readonly Coupling[] = [\n {\n parent: 'destructiveItems',\n when: false,\n children: ['tntExplodes', 'respawnBlocksExplode', 'fireSpreads'],\n force: false,\n reason: 'Destructive items are turned off',\n },\n {\n parent: 'playerDamage',\n when: false,\n children: ['pvp', 'friendlyFire'],\n force: false,\n reason: 'Player damage is turned off',\n },\n {\n parent: 'mobsRestricted',\n when: true,\n children: ['mobSpawning'],\n force: false,\n reason: 'Mobs are restricted',\n },\n {\n parent: 'perfectWeather',\n when: true,\n children: ['weatherCycle'],\n force: false,\n reason: 'Perfect weather is on',\n },\n];\n\n/** Compute the effective value and lock state of every boolean rule. */\nexport function evaluateRules(settings: WorldSettings): EvaluatedRules {\n const result = {} as EvaluatedRules;\n for (const key of BOOLEAN_SETTING_KEYS) {\n result[key] = { value: settings[key], locked: false };\n }\n for (const coupling of COUPLINGS) {\n if (settings[coupling.parent] !== coupling.when) continue;\n for (const child of coupling.children) {\n result[child] = {\n value: coupling.force,\n locked: true,\n lockedReason: coupling.reason,\n };\n }\n }\n return result;\n}\n\n/** Whether a given rule is currently locked by a master rule. */\nexport function isLocked(settings: WorldSettings, key: BooleanSettingKey): boolean {\n return evaluateRules(settings)[key].locked;\n}\n\n/**\n * Return settings normalised so every locked rule holds its forced value.\n * Returns the same reference when nothing needed changing.\n */\nexport function applyRuleConstraints(settings: WorldSettings): WorldSettings {\n const rules = evaluateRules(settings);\n let next: WorldSettings | null = null;\n for (const key of BOOLEAN_SETTING_KEYS) {\n const state = rules[key];\n if (state.locked && settings[key] !== state.value) {\n if (!next) next = { ...settings };\n next[key] = state.value;\n }\n }\n return next ?? settings;\n}\n\n/**\n * Set a boolean rule, respecting locks and re-normalising couplings.\n * A write to a currently-locked rule is ignored (returns the input unchanged).\n */\nexport function setBooleanSetting(settings: WorldSettings, key: BooleanSettingKey, value: boolean): WorldSettings {\n if (evaluateRules(settings)[key].locked) return settings;\n if (settings[key] === value) return applyRuleConstraints(settings);\n return applyRuleConstraints({ ...settings, [key]: value });\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,CAAI,GAAA;AAAA,QACd,OAAO,QAAS,CAAA,KAAA;AAAA,QAChB,MAAQ,EAAA,IAAA;AAAA,QACR,cAAc,QAAS,CAAA;AAAA,OACzB;AAAA;AACF;AAEF,EAAO,OAAA,MAAA;AACT;AAWO,SAAS,qBAAqB,QAAwC,EAAA;AAC3E,EAAM,MAAA,KAAA,GAAQ,cAAc,QAAQ,CAAA;AACpC,EAAA,IAAI,IAA6B,GAAA,IAAA;AACjC,EAAA,KAAA,MAAW,OAAO,oBAAsB,EAAA;AACtC,IAAM,MAAA,KAAA,GAAQ,MAAM,GAAG,CAAA;AACvB,IAAA,IAAI,MAAM,MAAU,IAAA,QAAA,CAAS,GAAG,CAAA,KAAM,MAAM,KAAO,EAAA;AACjD,MAAI,IAAA,CAAC,IAAM,EAAA,IAAA,GAAO,cACb,CAAA,EAAA,EAAA,QAAA,CAAA;AAEL,MAAK,IAAA,CAAA,GAAG,IAAI,KAAM,CAAA,KAAA;AAAA;AACpB;AAEF,EAAA,OAAO,IAAQ,IAAA,IAAA,GAAA,IAAA,GAAA,QAAA;AACjB;AAMgB,SAAA,iBAAA,CAAkB,QAAyB,EAAA,GAAA,EAAwB,KAA+B,EAAA;AAChH,EAAA,IAAI,cAAc,QAAQ,CAAA,CAAE,GAAG,CAAA,CAAE,QAAe,OAAA,QAAA;AAChD,EAAA,IAAI,SAAS,GAAG,CAAA,KAAM,KAAO,EAAA,OAAO,qBAAqB,QAAQ,CAAA;AACjE,EAAO,OAAA,oBAAA,CAAqB,iCACvB,QADuB,CAAA,EAAA;AAAA,IAE1B,CAAC,GAAG,GAAG;AAAA,GACR,CAAA,CAAA;AACH"}
@@ -0,0 +1,49 @@
1
+ import {emptyResourceLink}from'./resourceLink.js';const BOOLEAN_SETTING_KEYS = ["destructiveItems", "playerDamage", "immutableWorld", "mobsRestricted", "perfectWeather", "showBorderEffects", "tntExplodes", "respawnBlocksExplode", "fireSpreads", "pvp", "friendlyFire", "mobSpawning", "weatherCycle"];
2
+ function defaultWorldSettings() {
3
+ return {
4
+ destructiveItems: true,
5
+ playerDamage: true,
6
+ immutableWorld: false,
7
+ mobsRestricted: false,
8
+ perfectWeather: false,
9
+ showBorderEffects: false,
10
+ tntExplodes: true,
11
+ respawnBlocksExplode: true,
12
+ fireSpreads: true,
13
+ pvp: true,
14
+ friendlyFire: false,
15
+ mobSpawning: true,
16
+ weatherCycle: true,
17
+ resourceLink: emptyResourceLink()
18
+ };
19
+ }
20
+ const SETTING_LABELS = {
21
+ destructiveItems: "Destructive items",
22
+ playerDamage: "Player damage",
23
+ immutableWorld: "Immutable world",
24
+ mobsRestricted: "Mobs restricted",
25
+ perfectWeather: "Perfect weather",
26
+ showBorderEffects: "Show border effects",
27
+ tntExplodes: "Explosives detonate",
28
+ respawnBlocksExplode: "Respawn blocks explode",
29
+ fireSpreads: "Fire spreads",
30
+ pvp: "Player vs player",
31
+ friendlyFire: "Friendly fire",
32
+ mobSpawning: "Creature spawning",
33
+ weatherCycle: "Weather cycle"
34
+ };
35
+ const SETTING_DESCRIPTIONS = {
36
+ destructiveItems: "Allow explosives and harmful items. Off also disables explosions and fire spread.",
37
+ playerDamage: "Players can take damage. Off makes everyone invulnerable and disables combat.",
38
+ immutableWorld: "Players can interact but cannot break or place blocks. Great for demos and assessments.",
39
+ mobsRestricted: "No creatures spawn anywhere in the world.",
40
+ perfectWeather: "Keep the sky clear. Stops the weather from changing.",
41
+ showBorderEffects: "Show a visible effect on the edges of the build area.",
42
+ tntExplodes: "Explosives can detonate and damage the world.",
43
+ respawnBlocksExplode: "Respawn blocks can explode when used in the wrong place.",
44
+ fireSpreads: "Fire can spread from block to block.",
45
+ pvp: "Players can damage one another.",
46
+ friendlyFire: "Players on the same team can damage one another.",
47
+ mobSpawning: "Creatures spawn naturally over time.",
48
+ weatherCycle: "Weather changes on its own over time."
49
+ };export{BOOLEAN_SETTING_KEYS,SETTING_DESCRIPTIONS,SETTING_LABELS,defaultWorldSettings};//# sourceMappingURL=worldSettings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worldSettings.js","sources":["../../../../../../src/features/games/vendored/core/classroom/worldSettings.ts"],"sourcesContent":["/**\n * World settings for a block-building world, including Classroom-mode rules.\n *\n * This is Yantra Games' own model of the configurable world options a teacher\n * can set. It is informed by a generic feature study of classroom-style world\n * rules (lockable worlds, coupled toggles, a teacher resource link, player\n * permissions) and implemented from scratch - no third-party code or assets.\n *\n * The rule *coupling* and *lock* behaviour lives in ./rules; the single source\n * of truth normalises settings there so a view can never show a toggle as\n * editable while the enforced state disagrees.\n */\n\nimport type { ResourceLink } from './resourceLink';\nimport { emptyResourceLink } from './resourceLink';\n\n/** Every boolean world rule, by key. Used by the rule-coupling engine. */\nexport type BooleanSettingKey =\n // Master classroom rules\n | 'destructiveItems'\n | 'playerDamage'\n | 'immutableWorld'\n | 'mobsRestricted'\n | 'perfectWeather'\n | 'showBorderEffects'\n // Dependent world rules (can be force-locked by a master rule above)\n | 'tntExplodes'\n | 'respawnBlocksExplode'\n | 'fireSpreads'\n | 'pvp'\n | 'friendlyFire'\n | 'mobSpawning'\n | 'weatherCycle';\n\nexport const BOOLEAN_SETTING_KEYS: readonly BooleanSettingKey[] = [\n 'destructiveItems',\n 'playerDamage',\n 'immutableWorld',\n 'mobsRestricted',\n 'perfectWeather',\n 'showBorderEffects',\n 'tntExplodes',\n 'respawnBlocksExplode',\n 'fireSpreads',\n 'pvp',\n 'friendlyFire',\n 'mobSpawning',\n 'weatherCycle',\n];\n\nexport interface WorldSettings {\n // --- Master classroom rules ---\n /** When off: no destructive items, and explosion/fire rules are force-locked off. */\n destructiveItems: boolean;\n /** When off: players are invulnerable, and PvP + friendly fire are locked off. */\n playerDamage: boolean;\n /** When on: players may interact with blocks but cannot break or place them. */\n immutableWorld: boolean;\n /** When on: no creatures spawn, and mob spawning is locked off. */\n mobsRestricted: boolean;\n /** When on: weather is held clear, and the weather cycle is locked off. */\n perfectWeather: boolean;\n /** When on: world-border blocks emit a visible effect. */\n showBorderEffects: boolean;\n\n // --- Dependent world rules ---\n tntExplodes: boolean;\n respawnBlocksExplode: boolean;\n fireSpreads: boolean;\n pvp: boolean;\n friendlyFire: boolean;\n mobSpawning: boolean;\n weatherCycle: boolean;\n\n // --- Teacher resource link ---\n resourceLink: ResourceLink;\n}\n\nexport function defaultWorldSettings(): WorldSettings {\n return {\n destructiveItems: true,\n playerDamage: true,\n immutableWorld: false,\n mobsRestricted: false,\n perfectWeather: false,\n showBorderEffects: false,\n tntExplodes: true,\n respawnBlocksExplode: true,\n fireSpreads: true,\n pvp: true,\n friendlyFire: false,\n mobSpawning: true,\n weatherCycle: true,\n resourceLink: emptyResourceLink(),\n };\n}\n\n/** Human-readable label for each setting, for the settings UI. */\nexport const SETTING_LABELS: Record<BooleanSettingKey, string> = {\n destructiveItems: 'Destructive items',\n playerDamage: 'Player damage',\n immutableWorld: 'Immutable world',\n mobsRestricted: 'Mobs restricted',\n perfectWeather: 'Perfect weather',\n showBorderEffects: 'Show border effects',\n tntExplodes: 'Explosives detonate',\n respawnBlocksExplode: 'Respawn blocks explode',\n fireSpreads: 'Fire spreads',\n pvp: 'Player vs player',\n friendlyFire: 'Friendly fire',\n mobSpawning: 'Creature spawning',\n weatherCycle: 'Weather cycle',\n};\n\n/** One-line description for each setting, for the settings UI. */\nexport const SETTING_DESCRIPTIONS: Record<BooleanSettingKey, string> = {\n destructiveItems: 'Allow explosives and harmful items. Off also disables explosions and fire spread.',\n playerDamage: 'Players can take damage. Off makes everyone invulnerable and disables combat.',\n immutableWorld: 'Players can interact but cannot break or place blocks. Great for demos and assessments.',\n mobsRestricted: 'No creatures spawn anywhere in the world.',\n perfectWeather: 'Keep the sky clear. Stops the weather from changing.',\n showBorderEffects: 'Show a visible effect on the edges of the build area.',\n tntExplodes: 'Explosives can detonate and damage the world.',\n respawnBlocksExplode: 'Respawn blocks can explode when used in the wrong place.',\n fireSpreads: 'Fire can spread from block to block.',\n pvp: 'Players can damage one another.',\n friendlyFire: 'Players on the same team can damage one another.',\n mobSpawning: 'Creatures spawn naturally over time.',\n weatherCycle: 'Weather changes on its own over time.',\n};\n"],"names":[],"mappings":"kDAsBO,MAAM,oBAAqD,GAAA,CAAC,kBAAoB,EAAA,cAAA,EAAgB,kBAAkB,gBAAkB,EAAA,gBAAA,EAAkB,mBAAqB,EAAA,aAAA,EAAe,sBAAwB,EAAA,aAAA,EAAe,KAAO,EAAA,cAAA,EAAgB,eAAe,cAAc;AA4BrR,SAAS,oBAAsC,GAAA;AACpD,EAAO,OAAA;AAAA,IACL,gBAAkB,EAAA,IAAA;AAAA,IAClB,YAAc,EAAA,IAAA;AAAA,IACd,cAAgB,EAAA,KAAA;AAAA,IAChB,cAAgB,EAAA,KAAA;AAAA,IAChB,cAAgB,EAAA,KAAA;AAAA,IAChB,iBAAmB,EAAA,KAAA;AAAA,IACnB,WAAa,EAAA,IAAA;AAAA,IACb,oBAAsB,EAAA,IAAA;AAAA,IACtB,WAAa,EAAA,IAAA;AAAA,IACb,GAAK,EAAA,IAAA;AAAA,IACL,YAAc,EAAA,KAAA;AAAA,IACd,WAAa,EAAA,IAAA;AAAA,IACb,YAAc,EAAA,IAAA;AAAA,IACd,cAAc,iBAAkB;AAAA,GAClC;AACF;AAGO,MAAM,cAAoD,GAAA;AAAA,EAC/D,gBAAkB,EAAA,mBAAA;AAAA,EAClB,YAAc,EAAA,eAAA;AAAA,EACd,cAAgB,EAAA,iBAAA;AAAA,EAChB,cAAgB,EAAA,iBAAA;AAAA,EAChB,cAAgB,EAAA,iBAAA;AAAA,EAChB,iBAAmB,EAAA,qBAAA;AAAA,EACnB,WAAa,EAAA,qBAAA;AAAA,EACb,oBAAsB,EAAA,wBAAA;AAAA,EACtB,WAAa,EAAA,cAAA;AAAA,EACb,GAAK,EAAA,kBAAA;AAAA,EACL,YAAc,EAAA,eAAA;AAAA,EACd,WAAa,EAAA,mBAAA;AAAA,EACb,YAAc,EAAA;AAChB;AAGO,MAAM,oBAA0D,GAAA;AAAA,EACrE,gBAAkB,EAAA,mFAAA;AAAA,EAClB,YAAc,EAAA,+EAAA;AAAA,EACd,cAAgB,EAAA,yFAAA;AAAA,EAChB,cAAgB,EAAA,2CAAA;AAAA,EAChB,cAAgB,EAAA,sDAAA;AAAA,EAChB,iBAAmB,EAAA,uDAAA;AAAA,EACnB,WAAa,EAAA,+CAAA;AAAA,EACb,oBAAsB,EAAA,0DAAA;AAAA,EACtB,WAAa,EAAA,sCAAA;AAAA,EACb,GAAK,EAAA,iCAAA;AAAA,EACL,YAAc,EAAA,kDAAA;AAAA,EACd,WAAa,EAAA,sCAAA;AAAA,EACb,YAAc,EAAA;AAChB"}
@@ -0,0 +1,15 @@
1
+ const ENERGY_MAX = 12;
2
+ const DAY_STEPS = 10;
3
+ const NIGHT_STEPS = 6;
4
+ const CYCLE_STEPS = DAY_STEPS + NIGHT_STEPS;
5
+ function phaseAt(step) {
6
+ const s = (Math.floor(step) % CYCLE_STEPS + CYCLE_STEPS) % CYCLE_STEPS;
7
+ return s < DAY_STEPS ? "day" : "night";
8
+ }
9
+ function dayNumber(step) {
10
+ return Math.floor(Math.max(0, step) / CYCLE_STEPS) + 1;
11
+ }
12
+ function clampEnergy(value) {
13
+ if (!Number.isFinite(value)) return ENERGY_MAX;
14
+ return Math.max(0, Math.min(ENERGY_MAX, Math.floor(value)));
15
+ }export{CYCLE_STEPS,DAY_STEPS,ENERGY_MAX,NIGHT_STEPS,clampEnergy,dayNumber,phaseAt};//# sourceMappingURL=cycle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cycle.js","sources":["../../../../../../src/features/games/vendored/core/cubeforge/cycle.ts"],"sourcesContent":["/**\n * Cubeforge day/night cycle and energy model.\n *\n * Time is a monotonically increasing integer `step`; gathering and placing each\n * advance it by one. The cycle alternates day and night. Energy gates how much\n * the player can gather before resting; resting advances to the next dawn and\n * refills energy. Deliberately gentle - this is a learning sandbox, not a\n * punishing survival game.\n */\n\nexport const ENERGY_MAX = 12;\n\n/** Steps of daylight, then steps of night, per full cycle. */\nexport const DAY_STEPS = 10;\nexport const NIGHT_STEPS = 6;\nexport const CYCLE_STEPS = DAY_STEPS + NIGHT_STEPS;\n\nexport type Phase = 'day' | 'night';\n\nexport function phaseAt(step: number): Phase {\n const s = ((Math.floor(step) % CYCLE_STEPS) + CYCLE_STEPS) % CYCLE_STEPS;\n return s < DAY_STEPS ? 'day' : 'night';\n}\n\n/** 1-based day number for display (first dawn is Day 1). */\nexport function dayNumber(step: number): number {\n return Math.floor(Math.max(0, step) / CYCLE_STEPS) + 1;\n}\n\n/** The step index of the next dawn strictly after the current cycle. */\nexport function nextDawnStep(step: number): number {\n return (Math.floor(Math.max(0, step) / CYCLE_STEPS) + 1) * CYCLE_STEPS;\n}\n\nexport function clampEnergy(value: number): number {\n if (!Number.isFinite(value)) return ENERGY_MAX;\n return Math.max(0, Math.min(ENERGY_MAX, Math.floor(value)));\n}\n"],"names":[],"mappings":"AAUO,MAAM,UAAa,GAAA;AAGnB,MAAM,SAAY,GAAA;AAClB,MAAM,WAAc,GAAA;AACpB,MAAM,cAAc,SAAY,GAAA;AAEhC,SAAS,QAAQ,IAAqB,EAAA;AAC3C,EAAA,MAAM,KAAK,IAAK,CAAA,KAAA,CAAM,IAAI,CAAA,GAAI,cAAc,WAAe,IAAA,WAAA;AAC3D,EAAO,OAAA,CAAA,GAAI,YAAY,KAAQ,GAAA,OAAA;AACjC;AAGO,SAAS,UAAU,IAAsB,EAAA;AAC9C,EAAO,OAAA,IAAA,CAAK,MAAM,IAAK,CAAA,GAAA,CAAI,GAAG,IAAI,CAAA,GAAI,WAAW,CAAI,GAAA,CAAA;AACvD;AAMO,SAAS,YAAY,KAAuB,EAAA;AACjD,EAAA,IAAI,CAAC,MAAA,CAAO,QAAS,CAAA,KAAK,GAAU,OAAA,UAAA;AACpC,EAAO,OAAA,IAAA,CAAK,GAAI,CAAA,CAAA,EAAG,IAAK,CAAA,GAAA,CAAI,YAAY,IAAK,CAAA,KAAA,CAAM,KAAK,CAAC,CAAC,CAAA;AAC5D"}
@@ -0,0 +1,75 @@
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, key + "" , value);
4
+ class Inventory {
5
+ constructor(counts) {
6
+ __publicField(this, "counts");
7
+ this.counts = counts != null ? counts : /* @__PURE__ */ new Map();
8
+ }
9
+ /** Build from a persisted record, dropping invalid or non-positive entries. */
10
+ static from(record) {
11
+ const map = /* @__PURE__ */ new Map();
12
+ if (record && typeof record === "object") {
13
+ for (const [key, value] of Object.entries(record)) {
14
+ if (typeof value === "number" && Number.isFinite(value) && value > 0) {
15
+ map.set(key, Math.floor(value));
16
+ }
17
+ }
18
+ }
19
+ return new Inventory(map);
20
+ }
21
+ count(key) {
22
+ var _a;
23
+ return (_a = this.counts.get(key)) != null ? _a : 0;
24
+ }
25
+ has(key, qty = 1) {
26
+ return this.count(key) >= qty;
27
+ }
28
+ /** Total number of items held (sum of all counts). */
29
+ total() {
30
+ let n = 0;
31
+ for (const v of this.counts.values()) n += v;
32
+ return n;
33
+ }
34
+ add(key, qty = 1) {
35
+ if (qty <= 0) return;
36
+ this.counts.set(key, this.count(key) + qty);
37
+ }
38
+ /** Remove `qty` of an item; returns false (and changes nothing) if short. */
39
+ take(key, qty = 1) {
40
+ if (qty <= 0) return false;
41
+ const have = this.count(key);
42
+ if (have < qty) return false;
43
+ const next = have - qty;
44
+ if (next === 0) this.counts.delete(key);
45
+ else this.counts.set(key, next);
46
+ return true;
47
+ }
48
+ canAfford(cost) {
49
+ var _a;
50
+ const need = /* @__PURE__ */ new Map();
51
+ for (const c of cost) need.set(c.item, ((_a = need.get(c.item)) != null ? _a : 0) + c.qty);
52
+ for (const [key, qty] of need) if (this.count(key) < qty) return false;
53
+ return true;
54
+ }
55
+ /** Pay a cost atomically; returns false and changes nothing if unaffordable. */
56
+ pay(cost) {
57
+ if (!this.canAfford(cost)) return false;
58
+ for (const c of cost) this.take(c.item, c.qty);
59
+ return true;
60
+ }
61
+ entries() {
62
+ return [...this.counts.entries()].map(([key, count]) => ({
63
+ key,
64
+ count
65
+ }));
66
+ }
67
+ serialize() {
68
+ const out = {};
69
+ for (const [key, value] of this.counts) out[key] = value;
70
+ return out;
71
+ }
72
+ clone() {
73
+ return new Inventory(new Map(this.counts));
74
+ }
75
+ }export{Inventory};//# sourceMappingURL=inventory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inventory.js","sources":["../../../../../../src/features/games/vendored/core/cubeforge/inventory.ts"],"sourcesContent":["/**\n * Cubeforge inventory: counts of items, keyed by item key.\n *\n * Backed by a Map for O(1) add/take/count, and serialises to a flat record for\n * persistence. Zero-count entries are dropped so the model and saves stay small.\n */\n\nimport type { RecipeCost } from './recipes';\n\nexport type SerializedInventory = Record<string, number>;\n\nexport class Inventory {\n private readonly counts: Map<string, number>;\n\n constructor(counts?: Map<string, number>) {\n this.counts = counts ?? new Map();\n }\n\n /** Build from a persisted record, dropping invalid or non-positive entries. */\n static from(record: SerializedInventory | undefined | null): Inventory {\n const map = new Map<string, number>();\n if (record && typeof record === 'object') {\n for (const [key, value] of Object.entries(record)) {\n if (typeof value === 'number' && Number.isFinite(value) && value > 0) {\n map.set(key, Math.floor(value));\n }\n }\n }\n return new Inventory(map);\n }\n\n count(key: string): number {\n return this.counts.get(key) ?? 0;\n }\n\n has(key: string, qty = 1): boolean {\n return this.count(key) >= qty;\n }\n\n /** Total number of items held (sum of all counts). */\n total(): number {\n let n = 0;\n for (const v of this.counts.values()) n += v;\n return n;\n }\n\n add(key: string, qty = 1): void {\n if (qty <= 0) return;\n this.counts.set(key, this.count(key) + qty);\n }\n\n /** Remove `qty` of an item; returns false (and changes nothing) if short. */\n take(key: string, qty = 1): boolean {\n if (qty <= 0) return false;\n const have = this.count(key);\n if (have < qty) return false;\n const next = have - qty;\n if (next === 0) this.counts.delete(key);\n else this.counts.set(key, next);\n return true;\n }\n\n canAfford(cost: readonly RecipeCost[]): boolean {\n const need = new Map<string, number>();\n for (const c of cost) need.set(c.item, (need.get(c.item) ?? 0) + c.qty);\n for (const [key, qty] of need) if (this.count(key) < qty) return false;\n return true;\n }\n\n /** Pay a cost atomically; returns false and changes nothing if unaffordable. */\n pay(cost: readonly RecipeCost[]): boolean {\n if (!this.canAfford(cost)) return false;\n for (const c of cost) this.take(c.item, c.qty);\n return true;\n }\n\n entries(): Array<{ key: string; count: number }> {\n return [...this.counts.entries()].map(([key, count]) => ({ key, count }));\n }\n\n serialize(): SerializedInventory {\n const out: SerializedInventory = {};\n for (const [key, value] of this.counts) out[key] = value;\n return out;\n }\n\n clone(): Inventory {\n return new Inventory(new Map(this.counts));\n }\n}\n"],"names":[],"mappings":";;;AASO,MAAM,SAAU,CAAA;AAAA,EAErB,YAAY,MAA8B,EAAA;AAD1C,IAAiB,aAAA,CAAA,IAAA,EAAA,QAAA,CAAA;AAEf,IAAK,IAAA,CAAA,MAAA,GAAS,MAAU,IAAA,IAAA,GAAA,MAAA,mBAAA,IAAI,GAAI,EAAA;AAAA;AAClC;AAAA,EAGA,OAAO,KAAK,MAA2D,EAAA;AACrE,IAAM,MAAA,GAAA,uBAAU,GAAoB,EAAA;AACpC,IAAI,IAAA,MAAA,IAAU,OAAO,MAAA,KAAW,QAAU,EAAA;AACxC,MAAA,KAAA,MAAW,CAAC,GAAK,EAAA,KAAK,KAAK,MAAO,CAAA,OAAA,CAAQ,MAAM,CAAG,EAAA;AACjD,QAAI,IAAA,OAAO,UAAU,QAAY,IAAA,MAAA,CAAO,SAAS,KAAK,CAAA,IAAK,QAAQ,CAAG,EAAA;AACpE,UAAA,GAAA,CAAI,GAAI,CAAA,GAAA,EAAK,IAAK,CAAA,KAAA,CAAM,KAAK,CAAC,CAAA;AAAA;AAChC;AACF;AAEF,IAAO,OAAA,IAAI,UAAU,GAAG,CAAA;AAAA;AAC1B,EACA,MAAM,GAAqB,EAAA;AA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color: "#7cc86b",
5
+ kind: "resource",
6
+ placesBlock: 1
7
+ }, {
8
+ key: "soil",
9
+ name: "Soil",
10
+ color: "#b07a4e",
11
+ kind: "resource",
12
+ placesBlock: 2
13
+ }, {
14
+ key: "stone",
15
+ name: "Stone",
16
+ color: "#b9bdc6",
17
+ kind: "resource",
18
+ placesBlock: 3
19
+ }, {
20
+ key: "wood",
21
+ name: "Wood",
22
+ color: "#d6a86a",
23
+ kind: "resource",
24
+ placesBlock: 4
25
+ }, {
26
+ key: "sand",
27
+ name: "Sand",
28
+ color: "#ead9a0",
29
+ kind: "resource",
30
+ placesBlock: 6
31
+ }, {
32
+ key: "brick",
33
+ name: "Bricks",
34
+ color: "#d1684f",
35
+ kind: "crafted",
36
+ placesBlock: 7
37
+ }, {
38
+ key: "glass",
39
+ name: "Glass",
40
+ color: "#bfe9ef",
41
+ kind: "crafted",
42
+ placesBlock: 8
43
+ }, {
44
+ key: "torch",
45
+ name: "Torch",
46
+ color: "#f2c14e",
47
+ kind: "tool"
48
+ }, {
49
+ key: "workbench",
50
+ name: "Workbench",
51
+ color: "#8a6d3b",
52
+ kind: "tool"
53
+ }];
54
+ const BY_KEY = new Map(ITEMS.map((i) => [i.key, i]));
55
+ const BY_BLOCK = /* @__PURE__ */ new Map();
56
+ for (const i of ITEMS) if (i.placesBlock != null) BY_BLOCK.set(i.placesBlock, i);
57
+ function itemByKey(key) {
58
+ return BY_KEY.get(key);
59
+ }
60
+ function itemForBlock(block) {
61
+ return BY_BLOCK.get(block);
62
+ }export{ITEMS,itemByKey,itemForBlock};//# sourceMappingURL=items.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"items.js","sources":["../../../../../../src/features/games/vendored/core/cubeforge/items.ts"],"sourcesContent":["/**\n * Cubeforge item registry.\n *\n * Cubeforge is an original survival/crafting sandbox. Items are what the player\n * gathers, crafts, and places. Placeable items carry a `placesBlock` id from the\n * shared voxel palette so the existing isometric renderer draws them with no new\n * art. Tools have no block - they are crafted goods the player keeps.\n *\n * Original work. Nothing here is ported or copied from any third-party game.\n */\n\nimport type { BlockId } from '../engine/palette';\n\nexport type ItemKind = 'resource' | 'crafted' | 'tool';\n\nexport interface CubeItem {\n /** Stable key used in saves and inventory. */\n readonly key: string;\n readonly name: string;\n /** Chip colour in the UI (taken from the matching block's top face). */\n readonly color: string;\n readonly kind: ItemKind;\n /** When present, the item can be placed into the world as this block. */\n readonly placesBlock?: BlockId;\n}\n\n/**\n * The item catalogue. Resources are gathered from the generated world; crafted\n * items come from recipes; tools are crafted goods with no placed block.\n */\nexport const ITEMS: readonly CubeItem[] = [\n { key: 'grass', name: 'Grass', color: '#7cc86b', kind: 'resource', placesBlock: 1 },\n { key: 'soil', name: 'Soil', color: '#b07a4e', kind: 'resource', placesBlock: 2 },\n { key: 'stone', name: 'Stone', color: '#b9bdc6', kind: 'resource', placesBlock: 3 },\n { key: 'wood', name: 'Wood', color: '#d6a86a', kind: 'resource', placesBlock: 4 },\n { key: 'sand', name: 'Sand', color: '#ead9a0', kind: 'resource', placesBlock: 6 },\n { key: 'brick', name: 'Bricks', color: '#d1684f', kind: 'crafted', placesBlock: 7 },\n { key: 'glass', name: 'Glass', color: '#bfe9ef', kind: 'crafted', placesBlock: 8 },\n { key: 'torch', name: 'Torch', color: '#f2c14e', kind: 'tool' },\n { key: 'workbench', name: 'Workbench', color: '#8a6d3b', kind: 'tool' },\n];\n\nconst BY_KEY = new Map<string, CubeItem>(ITEMS.map((i) => [i.key, i]));\nconst BY_BLOCK = new Map<BlockId, CubeItem>();\nfor (const i of ITEMS) if (i.placesBlock != null) BY_BLOCK.set(i.placesBlock, i);\n\nexport function itemByKey(key: string): CubeItem | undefined {\n return BY_KEY.get(key);\n}\n\n/** The item a placed block yields when gathered, if any. */\nexport function itemForBlock(block: BlockId): CubeItem | undefined {\n return BY_BLOCK.get(block);\n}\n\nexport function isPlaceable(item: CubeItem): boolean {\n return item.placesBlock != null;\n}\n\n/** Items that can be placed into the world, in catalogue order. */\nexport function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A;AAAA,EACN,KAAO,EAAA,SAAA;AAAA,EACP,IAAM,EAAA;AACR,CAAG,EAAA;AAAA,EACD,GAAK,EAAA,WAAA;AAAA,EACL,IAAM,EAAA,WAAA;AAAA,EACN,KAAO,EAAA,SAAA;AAAA,EACP,IAAM,EAAA;AACR,CAAC;AACD,MAAM,MAAA,GAAS,IAAI,GAAA,CAAsB,KAAM,CAAA,GAAA,CAAI,CAAK,CAAA,KAAA,CAAC,CAAE,CAAA,GAAA,EAAK,CAAC,CAAC,CAAC,CAAA;AACnE,MAAM,QAAA,uBAAe,GAAuB,EAAA;AAC5C,KAAW,MAAA,CAAA,IAAK,KAAO,EAAA,IAAI,CAAE,CAAA,WAAA,IAAe,MAAe,QAAA,CAAA,GAAA,CAAI,CAAE,CAAA,WAAA,EAAa,CAAC,CAAA;AACxE,SAAS,UAAU,GAAmC,EAAA;AAC3D,EAAO,OAAA,MAAA,CAAO,IAAI,GAAG,CAAA;AACvB;AAGO,SAAS,aAAa,KAAsC,EAAA;AACjE,EAAO,OAAA,QAAA,CAAS,IAAI,KAAK,CAAA;AAC3B"}
@@ -0,0 +1,4 @@
1
+ function nativeWorldKey(orgName) {
2
+ const key = (orgName || "default").toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/^-+|-+$/g, "");
3
+ return key || "default";
4
+ }export{nativeWorldKey};//# sourceMappingURL=nativeWorld.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nativeWorld.js","sources":["../../../../../../src/features/games/vendored/core/cubeforge/nativeWorld.ts"],"sourcesContent":["/**\n * Helpers for hosts that run Cubeforge in a native 3D engine (see\n * `native/cubeforge`). The 3D world keeps its own save; these keep its identity\n * stable and safe to use in a file name.\n */\n\n/** A file-name-safe key for an org's native 3D world (`[a-z0-9_-]+`). */\nexport function nativeWorldKey(orgName: string): string {\n const key = (orgName || 'default')\n .toLowerCase()\n .replace(/[^a-z0-9_-]+/g, '-')\n .replace(/^-+|-+$/g, '');\n return key || 'default';\n}\n"],"names":[],"mappings":"AAOO,SAAS,eAAe,OAAyB,EAAA;AACtD,EAAM,MAAA,GAAA,GAAA,CAAO,OAAW,IAAA,SAAA,EAAW,WAAY,EAAA,CAAE,OAAQ,CAAA,eAAA,EAAiB,GAAG,CAAA,CAAE,OAAQ,CAAA,UAAA,EAAY,EAAE,CAAA;AACrG,EAAA,OAAO,GAAO,IAAA,SAAA;AAChB"}
@@ -0,0 +1,68 @@
1
+ import {nativeWorldKey}from'./nativeWorld.js';import {seedFromString}from'./worldgen.js';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 MAX_NAME_CHARS = 40;
5
+ const FIRST_WORLD_NAME = "My world";
6
+ const NEW_WORLD_NAME = "New world";
7
+ function isNativeWorld(v) {
8
+ const w = v;
9
+ return !!w && typeof w.key === "string" && !!w.key && typeof w.name === "string" && Number.isFinite(w.seed);
10
+ }
11
+ class NativeWorldRepository {
12
+ constructor(storage, orgName, now = Date.now) {
13
+ this.storage = storage;
14
+ this.now = now;
15
+ __publicField(this, "storageKey");
16
+ __publicField(this, "first");
17
+ const org = orgName || "default";
18
+ this.storageKey = `yantra-games:cubeforge3d-worlds:${org}`;
19
+ this.first = {
20
+ key: nativeWorldKey(org),
21
+ name: FIRST_WORLD_NAME,
22
+ seed: seedFromString(org)
23
+ };
24
+ }
25
+ async read() {
26
+ const raw = await this.storage.getItem(this.storageKey);
27
+ if (!raw) return [];
28
+ try {
29
+ const parsed = JSON.parse(raw);
30
+ return Array.isArray(parsed.worlds) ? parsed.worlds.filter(isNativeWorld) : [];
31
+ } catch (e) {
32
+ return [];
33
+ }
34
+ }
35
+ async write(worlds) {
36
+ const payload = {
37
+ worlds
38
+ };
39
+ await this.storage.setItem(this.storageKey, JSON.stringify(payload));
40
+ }
41
+ /** The org's first world, then the others, newest first. */
42
+ async list() {
43
+ return [this.first, ...(await this.read()).filter((w) => w.key !== this.first.key)];
44
+ }
45
+ async create(name) {
46
+ const worlds = await this.read();
47
+ const stamp = this.now().toString(36);
48
+ let key = `${this.first.key}-${stamp}`;
49
+ for (let n = 2; worlds.some((w) => w.key === key); n += 1) key = `${this.first.key}-${stamp}-${n}`;
50
+ const trimmed = name.trim().slice(0, MAX_NAME_CHARS) || NEW_WORLD_NAME;
51
+ const world = {
52
+ key,
53
+ name: trimmed,
54
+ seed: seedFromString(key)
55
+ };
56
+ await this.write([world, ...worlds]);
57
+ return world;
58
+ }
59
+ /** Forget a world. The org's first world cannot be removed. */
60
+ async remove(key) {
61
+ if (key === this.first.key) return false;
62
+ const worlds = await this.read();
63
+ const next = worlds.filter((w) => w.key !== key);
64
+ if (next.length === worlds.length) return false;
65
+ await this.write(next);
66
+ return true;
67
+ }
68
+ }export{NativeWorldRepository};//# sourceMappingURL=nativeWorlds.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nativeWorlds.js","sources":["../../../../../../src/features/games/vendored/core/cubeforge/nativeWorlds.ts"],"sourcesContent":["/**\n * The list of solo 3D worlds on this device. Each world's terrain and progress\n * live in the engine's own save file, named by `key`; this is just the index.\n * The org's first world always exists and keeps the key older builds used.\n */\nimport type { KeyValueStorage } from '../storage/storage';\nimport { nativeWorldKey } from './nativeWorld';\nimport { seedFromString } from './worldgen';\n\nexport interface NativeWorld {\n key: string;\n name: string;\n seed: number;\n}\n\nconst MAX_NAME_CHARS = 40;\nconst FIRST_WORLD_NAME = 'My world';\nconst NEW_WORLD_NAME = 'New world';\n\ninterface StoredList {\n worlds: NativeWorld[];\n}\n\nfunction isNativeWorld(v: unknown): v is NativeWorld {\n const w = v as NativeWorld;\n return !!w && typeof w.key === 'string' && !!w.key && typeof w.name === 'string' && Number.isFinite(w.seed);\n}\n\nexport class NativeWorldRepository {\n private readonly storageKey: string;\n private readonly first: NativeWorld;\n\n constructor(\n private readonly storage: KeyValueStorage,\n orgName: string,\n /** Injected so tests are repeatable. */\n private readonly now: () => number = Date.now,\n ) {\n const org = orgName || 'default';\n this.storageKey = `yantra-games:cubeforge3d-worlds:${org}`;\n this.first = { key: nativeWorldKey(org), name: FIRST_WORLD_NAME, seed: seedFromString(org) };\n }\n\n private async read(): Promise<NativeWorld[]> {\n const raw = await this.storage.getItem(this.storageKey);\n if (!raw) return [];\n try {\n const parsed = JSON.parse(raw) as StoredList;\n return Array.isArray(parsed.worlds) ? parsed.worlds.filter(isNativeWorld) : [];\n } catch {\n return [];\n }\n }\n\n private async write(worlds: NativeWorld[]): Promise<void> {\n const payload: StoredList = { worlds };\n await this.storage.setItem(this.storageKey, JSON.stringify(payload));\n }\n\n /** The org's first world, then the others, newest first. */\n async list(): Promise<NativeWorld[]> {\n return [this.first, ...(await this.read()).filter((w) => w.key !== this.first.key)];\n }\n\n async create(name: string): Promise<NativeWorld> {\n const worlds = await this.read();\n const stamp = this.now().toString(36);\n let key = `${this.first.key}-${stamp}`;\n for (let n = 2; worlds.some((w) => w.key === key); n += 1) key = `${this.first.key}-${stamp}-${n}`;\n const trimmed = name.trim().slice(0, MAX_NAME_CHARS) || NEW_WORLD_NAME;\n const world: NativeWorld = { key, name: trimmed, seed: seedFromString(key) };\n await this.write([world, ...worlds]);\n return world;\n }\n\n /** Forget a world. The org's first world cannot be removed. */\n async remove(key: string): Promise<boolean> {\n if (key === this.first.key) return false;\n const worlds = await this.read();\n const next = worlds.filter((w) => w.key !== key);\n if (next.length === worlds.length) return false;\n await this.write(next);\n return true;\n }\n}\n"],"names":[],"mappings":";;;AAaA,MAAM,cAAiB,GAAA,EAAA;AACvB,MAAM,gBAAmB,GAAA,UAAA;AACzB,MAAM,cAAiB,GAAA,WAAA;AAIvB,SAAS,cAAc,CAA8B,EAAA;AACnD,EAAA,MAAM,CAAI,GAAA,CAAA;AACV,EAAA,OAAO,CAAC,CAAC,CAAA,IAAK,OAAO,CAAE,CAAA,GAAA,KAAQ,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KAAA,IAAA,CAAK,KAAM,CAAA,GAAA,EAAY,OAAA,KAAA;AACnC,IAAM,MAAA,MAAA,GAAS,MAAM,IAAA,CAAK,IAAK,EAAA;AAC/B,IAAA,MAAM,OAAO,MAAO,CAAA,MAAA,CAAO,CAAK,CAAA,KAAA,CAAA,CAAE,QAAQ,GAAG,CAAA;AAC7C,IAAA,IAAI,IAAK,CAAA,MAAA,KAAW,MAAO,CAAA,MAAA,EAAe,OAAA,KAAA;AAC1C,IAAM,MAAA,IAAA,CAAK,MAAM,IAAI,CAAA;AACrB,IAAO,OAAA,IAAA;AAAA;AAEX"}
@@ -0,0 +1,52 @@
1
+ const RECIPES = [{
2
+ id: "bricks",
3
+ name: "Bricks",
4
+ inputs: [{
5
+ item: "soil",
6
+ qty: 2
7
+ }],
8
+ output: {
9
+ item: "brick",
10
+ qty: 1
11
+ }
12
+ }, {
13
+ id: "glass",
14
+ name: "Glass",
15
+ inputs: [{
16
+ item: "sand",
17
+ qty: 2
18
+ }],
19
+ output: {
20
+ item: "glass",
21
+ qty: 1
22
+ }
23
+ }, {
24
+ id: "torch",
25
+ name: "Torch",
26
+ inputs: [{
27
+ item: "wood",
28
+ qty: 1
29
+ }, {
30
+ item: "stone",
31
+ qty: 1
32
+ }],
33
+ output: {
34
+ item: "torch",
35
+ qty: 1
36
+ }
37
+ }, {
38
+ id: "workbench",
39
+ name: "Workbench",
40
+ inputs: [{
41
+ item: "wood",
42
+ qty: 3
43
+ }],
44
+ output: {
45
+ item: "workbench",
46
+ qty: 1
47
+ }
48
+ }];
49
+ const BY_ID = new Map(RECIPES.map((r) => [r.id, r]));
50
+ function recipeById(id) {
51
+ return BY_ID.get(id);
52
+ }export{RECIPES,recipeById};//# sourceMappingURL=recipes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recipes.js","sources":["../../../../../../src/features/games/vendored/core/cubeforge/recipes.ts"],"sourcesContent":["/**\n * Cubeforge crafting recipes.\n *\n * A recipe turns a set of input items into one output item. Recipes are pure\n * data; the session checks affordability against the inventory and applies them.\n * Original design - small, readable, and classroom-friendly.\n */\n\nexport interface RecipeCost {\n readonly item: string;\n readonly qty: number;\n}\n\nexport interface Recipe {\n readonly id: string;\n readonly name: string;\n readonly inputs: readonly RecipeCost[];\n readonly output: RecipeCost;\n}\n\nexport const RECIPES: readonly Recipe[] = [\n { id: 'bricks', name: 'Bricks', inputs: [{ item: 'soil', qty: 2 }], output: { item: 'brick', qty: 1 } },\n { id: 'glass', name: 'Glass', inputs: [{ item: 'sand', qty: 2 }], output: { item: 'glass', qty: 1 } },\n {\n id: 'torch',\n name: 'Torch',\n inputs: [\n { item: 'wood', qty: 1 },\n { item: 'stone', qty: 1 },\n ],\n output: { item: 'torch', qty: 1 },\n },\n { id: 'workbench', name: 'Workbench', inputs: [{ item: 'wood', qty: 3 }], output: { item: 'workbench', qty: 1 } },\n];\n\nconst BY_ID = new Map<string, Recipe>(RECIPES.map((r) => [r.id, r]));\n\nexport function recipeById(id: string): Recipe | undefined {\n return BY_ID.get(id);\n}\n\n/** Sum a recipe's inputs by item key (handles repeated items defensively). */\nexport function totalCost(recipe: Recipe): Map<string, number> {\n const need = new Map<string, number>();\n for (const c of recipe.inputs) need.set(c.item, (need.get(c.item) ?? 0) + c.qty);\n return need;\n}\n"],"names":[],"mappings":"AAkBO,MAAM,UAA6B,CAAC;AAAA,EACzC,EAAI,EAAA,QAAA;AAAA,EACJ,IAAM,EAAA,QAAA;AAAA,EACN,QAAQ,CAAC;AAAA,IACP,IAAM,EAAA,MAAA;AAAA,IACN,GAAK,EAAA;AAAA,GACN,CAAA;AAAA,EACD,MAAQ,EAAA;AAAA,IACN,IAAM,EAAA,OAAA;AAAA,IACN,GAAK,EAAA;AAAA;AAET,CAAG,EAAA;AAAA,EACD,EAAI,EAAA,OAAA;AAAA,EACJ,IAAM,EAAA,OAAA;AAAA,EACN,QAAQ,CAAC;AAAA,IACP,IAAM,EAAA,MAAA;AAAA,IACN,GAAK,EAAA;AAAA,GACN,CAAA;AAAA,EACD,MAAQ,EAAA;AAAA,IACN,IAAM,EAAA,OAAA;AAAA,IACN,GAAK,EAAA;AAAA;AAET,CAAG,EAAA;AAAA,EACD,EAAI,EAAA,OAAA;AAAA,EACJ,IAAM,EAAA,OAAA;AAAA,EACN,QAAQ,CAAC;AAAA,IACP,IAAM,EAAA,MAAA;AAAA,IACN,GAAK,EAAA;AAAA,GACJ,EAAA;AAAA,IACD,IAAM,EAAA,OAAA;AAAA,IACN,GAAK,EAAA;AAAA,GACN,CAAA;AAAA,EACD,MAAQ,EAAA;AAAA,IACN,IAAM,EAAA,OAAA;AAAA,IACN,GAAK,EAAA;AAAA;AAET,CAAG,EAAA;AAAA,EACD,EAAI,EAAA,WAAA;AAAA,EACJ,IAAM,EAAA,WAAA;AAAA,EACN,QAAQ,CAAC;AAAA,IACP,IAAM,EAAA,MAAA;AAAA,IACN,GAAK,EAAA;AAAA,GACN,CAAA;AAAA,EACD,MAAQ,EAAA;AAAA,IACN,IAAM,EAAA,WAAA;AAAA,IACN,GAAK,EAAA;AAAA;AAET,CAAC;AACD,MAAM,KAAA,GAAQ,IAAI,GAAA,CAAoB,OAAQ,CAAA,GAAA,CAAI,CAAK,CAAA,KAAA,CAAC,CAAE,CAAA,EAAA,EAAI,CAAC,CAAC,CAAC,CAAA;AAC1D,SAAS,WAAW,EAAgC,EAAA;AACzD,EAAO,OAAA,KAAA,CAAM,IAAI,EAAE,CAAA;AACrB"}
@@ -0,0 +1,92 @@
1
+ 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 CUBEFORGE_VERSION = "v1";
21
+ const CUBEFORGE_PREFIX = `yantra.games.cubeforge.${CUBEFORGE_VERSION}`;
22
+ class CubeforgeRepository {
23
+ constructor(storage, namespace, now = () => Date.now()) {
24
+ this.storage = storage;
25
+ this.namespace = namespace;
26
+ this.now = now;
27
+ }
28
+ async load() {
29
+ const raw = await this.storage.getItem(this.key());
30
+ if (raw === null) return null;
31
+ let parsed;
32
+ try {
33
+ parsed = JSON.parse(raw);
34
+ } catch (e) {
35
+ return null;
36
+ }
37
+ return coerce(parsed);
38
+ }
39
+ async save(snapshot) {
40
+ const record = __spreadProps(__spreadValues({}, snapshot), {
41
+ updatedAt: this.now()
42
+ });
43
+ await this.storage.setItem(this.key(), JSON.stringify(record));
44
+ }
45
+ async clear() {
46
+ await this.storage.removeItem(this.key());
47
+ }
48
+ key() {
49
+ return `${CUBEFORGE_PREFIX}:${this.namespace}`;
50
+ }
51
+ }
52
+ function coerce(value) {
53
+ if (!value || typeof value !== "object") return null;
54
+ const v = value;
55
+ if (typeof v.seed !== "number") return null;
56
+ const init = {
57
+ seed: v.seed >>> 0
58
+ };
59
+ const world = coerceWorld(v.world);
60
+ if (world) init.world = world;
61
+ if (v.inventory && typeof v.inventory === "object") {
62
+ const inv = {};
63
+ for (const [key, n] of Object.entries(v.inventory)) {
64
+ if (typeof n === "number" && Number.isFinite(n) && n > 0) inv[key] = Math.floor(n);
65
+ }
66
+ init.inventory = inv;
67
+ }
68
+ if (typeof v.energy === "number") init.energy = v.energy;
69
+ if (typeof v.step === "number") init.step = v.step;
70
+ if (typeof v.selectedItem === "string") init.selectedItem = v.selectedItem;
71
+ return init;
72
+ }
73
+ function coerceWorld(value) {
74
+ if (!value || typeof value !== "object") return void 0;
75
+ const v = value;
76
+ const bounds = v.bounds;
77
+ if (!bounds || typeof bounds.x !== "number" || typeof bounds.y !== "number" || typeof bounds.z !== "number" || !v.blocks || typeof v.blocks !== "object") {
78
+ return void 0;
79
+ }
80
+ const blocks = {};
81
+ for (const [key, id] of Object.entries(v.blocks)) {
82
+ if (typeof id === "number") blocks[key] = id;
83
+ }
84
+ return {
85
+ bounds: {
86
+ x: bounds.x,
87
+ y: bounds.y,
88
+ z: bounds.z
89
+ },
90
+ blocks
91
+ };
92
+ }export{CUBEFORGE_PREFIX,CUBEFORGE_VERSION,CubeforgeRepository};//# sourceMappingURL=save.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"save.js","sources":["../../../../../../src/features/games/vendored/core/cubeforge/save.ts"],"sourcesContent":["/**\n * Cubeforge persistence.\n *\n * Cubeforge is one continuous world per organisation, so it needs only a single\n * namespaced key (not the multi-world index Blockwright uses). Reads are\n * defensive: a corrupt or partial save returns `null` or a best-effort partial,\n * and the session regenerates anything missing from the seed.\n *\n * yantra.games.cubeforge.v1:<org> -> CubeforgeSave\n */\n\nimport type { KeyValueStorage } from '../storage/storage';\nimport type { CubeforgeInit, CubeforgeSnapshot } from './session';\nimport type { SerializedWorld } from '../engine/world';\n\nexport const CUBEFORGE_VERSION = 'v1';\nexport const CUBEFORGE_PREFIX = `yantra.games.cubeforge.${CUBEFORGE_VERSION}`;\n\nexport interface CubeforgeSave extends CubeforgeSnapshot {\n updatedAt: number;\n}\n\nexport class CubeforgeRepository {\n constructor(\n private readonly storage: KeyValueStorage,\n private readonly namespace: string,\n private readonly now: () => number = () => Date.now(),\n ) {}\n\n async load(): Promise<CubeforgeInit | null> {\n const raw = await this.storage.getItem(this.key());\n if (raw === null) return null;\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch {\n return null;\n }\n return coerce(parsed);\n }\n\n async save(snapshot: CubeforgeSnapshot): Promise<void> {\n const record: CubeforgeSave = { ...snapshot, updatedAt: this.now() };\n await this.storage.setItem(this.key(), JSON.stringify(record));\n }\n\n async clear(): Promise<void> {\n await this.storage.removeItem(this.key());\n }\n\n private key(): string {\n return `${CUBEFORGE_PREFIX}:${this.namespace}`;\n }\n}\n\nfunction coerce(value: unknown): CubeforgeInit | null {\n if (!value || typeof value !== 'object') return null;\n const v = value as Record<string, unknown>;\n if (typeof v.seed !== 'number') return null;\n\n const init: CubeforgeInit = { seed: v.seed >>> 0 };\n\n const world = coerceWorld(v.world);\n if (world) init.world = world;\n\n if (v.inventory && typeof v.inventory === 'object') {\n const inv: Record<string, number> = {};\n for (const [key, n] of Object.entries(v.inventory as Record<string, unknown>)) {\n if (typeof n === 'number' && Number.isFinite(n) && n > 0) inv[key] = Math.floor(n);\n }\n init.inventory = inv;\n }\n\n if (typeof v.energy === 'number') init.energy = v.energy;\n if (typeof v.step === 'number') init.step = v.step;\n if (typeof v.selectedItem === 'string') init.selectedItem = v.selectedItem;\n\n return init;\n}\n\n/** Accept a world only if it has the right shape; the session sanitises cells. */\nfunction coerceWorld(value: unknown): SerializedWorld | undefined {\n if (!value || typeof value !== 'object') return undefined;\n const v = value as Record<string, unknown>;\n const bounds = v.bounds as Record<string, unknown> | undefined;\n if (\n !bounds ||\n typeof bounds.x !== 'number' ||\n typeof bounds.y !== 'number' ||\n typeof bounds.z !== 'number' ||\n !v.blocks ||\n typeof v.blocks !== 'object'\n ) {\n return undefined;\n }\n const blocks: Record<string, number> = {};\n for (const [key, id] of Object.entries(v.blocks as Record<string, unknown>)) {\n if (typeof id === 'number') blocks[key] = id;\n }\n return { bounds: { x: bounds.x, y: bounds.y, z: bounds.z }, blocks };\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAcO,MAAM,iBAAoB,GAAA;AACpB,MAAA,gBAAA,GAAmB,0BAA0B,iBAAiB,CAAA;AAIpE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