@nice2dev/game-engine 1.3.15 → 1.3.17
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/CHANGELOG.md +13 -0
- package/dist/cjs/accessibility/Accessibility.js +152 -165
- package/dist/cjs/ai/AI.js +292 -294
- package/dist/cjs/ai/BehaviorTree.js +1029 -1113
- package/dist/cjs/ai/StateMachine.js +694 -756
- package/dist/cjs/animation/Animation.js +232 -241
- package/dist/cjs/audio/AudioAdvanced.js +221 -236
- package/dist/cjs/audio/AudioBridge.js +441 -435
- package/dist/cjs/audio/AudioManager.js +242 -259
- package/dist/cjs/build-cloud/BuildOrchestration.js +1059 -1098
- package/dist/cjs/build-cloud/GodotBuildCloud.js +641 -670
- package/dist/cjs/build-cloud/UnityBuildCloud.js +563 -610
- package/dist/cjs/build-cloud/UnrealBuildCloud.js +610 -635
- package/dist/cjs/core/EventBus.js +51 -56
- package/dist/cjs/core/GameClock.js +62 -66
- package/dist/cjs/core/GameConfig.js +72 -79
- package/dist/cjs/core/GameLoop.js +80 -89
- package/dist/cjs/core/ServiceLocator.js +61 -65
- package/dist/cjs/core/Validation.js +72 -82
- package/dist/cjs/core/math.js +108 -112
- package/dist/cjs/devtools/DevTools.js +542 -563
- package/dist/cjs/devtools/DeveloperExperience.js +521 -559
- package/dist/cjs/devtools/GameplayAnalytics.js +636 -646
- package/dist/cjs/dialogue/DialogueSystem.js +984 -986
- package/dist/cjs/docs/DocGenerator.js +339 -364
- package/dist/cjs/ecs/World.js +355 -371
- package/dist/cjs/editor/AchievementEditor.js +580 -636
- package/dist/cjs/editor/AdvancedEditor.js +184 -191
- package/dist/cjs/editor/AnimationRetargeting.js +696 -741
- package/dist/cjs/editor/AssetBrowser.js +1072 -1160
- package/dist/cjs/editor/AssetManager.js +187 -192
- package/dist/cjs/editor/ConsolePro.js +971 -1061
- package/dist/cjs/editor/CraftingEditor.js +680 -730
- package/dist/cjs/editor/DebugTools.js +187 -185
- package/dist/cjs/editor/DialogueSystem.js +844 -901
- package/dist/cjs/editor/LeaderboardSystem.js +429 -483
- package/dist/cjs/editor/NiceGameEditor.js +1903 -1201
- package/dist/cjs/editor/PrefabSystem.js +772 -838
- package/dist/cjs/editor/ProfilerPanel.js +649 -700
- package/dist/cjs/editor/QuestEditor.js +792 -839
- package/dist/cjs/editor/ReplaySystem.js +585 -634
- package/dist/cjs/editor/SceneEditor.js +176 -200
- package/dist/cjs/editor/ScreenshotMode.js +621 -688
- package/dist/cjs/editor/ShaderGraph.js +1556 -1582
- package/dist/cjs/editor/TimelineEditor.js +715 -778
- package/dist/cjs/editor/UndoRedoPro.js +830 -904
- package/dist/cjs/editor/VRARMode.js +582 -645
- package/dist/cjs/engine/NiceGameEngine.js +141 -164
- package/dist/cjs/engine/SaveSystem.js +441 -495
- package/dist/cjs/enterprise/Enterprise.js +254 -261
- package/dist/cjs/export/BevyExporter.js +927 -967
- package/dist/cjs/export/CocosExporter.js +644 -673
- package/dist/cjs/export/Construct3Exporter.js +783 -794
- package/dist/cjs/export/DefoldExporter.js +1028 -1069
- package/dist/cjs/export/GDevelopExporter.js +674 -708
- package/dist/cjs/export/GameMakerExporter.js +791 -805
- package/dist/cjs/export/GodotExporter.js +1003 -1045
- package/dist/cjs/export/MinecraftBedrockExporter.js +573 -578
- package/dist/cjs/export/MonoGameExporter.js +1265 -1293
- package/dist/cjs/export/Pico8Exporter.js +766 -812
- package/dist/cjs/export/PlatformExporter.js +188 -206
- package/dist/cjs/export/RPGMakerExporter.js +860 -879
- package/dist/cjs/export/RobloxExporter.js +883 -919
- package/dist/cjs/export/Solar2DExporter.js +1218 -1256
- package/dist/cjs/export/ThreeJSExporter.js +1006 -1073
- package/dist/cjs/export/Tic80Exporter.js +1210 -1267
- package/dist/cjs/export/UnityExporter.js +1116 -1131
- package/dist/cjs/export/UnrealExporter.js +889 -919
- package/dist/cjs/export/WebExporter.js +931 -970
- package/dist/cjs/export/index.js +42 -65
- package/dist/cjs/godot-integration/GodotAssetLibrary.js +659 -692
- package/dist/cjs/godot-integration/GodotImport.js +929 -1027
- package/dist/cjs/godot-integration/GodotLiveLink.js +915 -945
- package/dist/cjs/godot-integration/components/GodotProjectBrowser.js +911 -611
- package/dist/cjs/i18n/I18n.js +860 -900
- package/dist/cjs/i18n/useTranslation.js +84 -89
- package/dist/cjs/import/AsepriteImporter.js +658 -716
- package/dist/cjs/import/DragonBonesImporter.js +437 -461
- package/dist/cjs/import/GameMakerImporter.js +511 -521
- package/dist/cjs/import/GodotSceneImporter.js +788 -822
- package/dist/cjs/import/LDtkImporter.js +436 -454
- package/dist/cjs/import/Live2DImporter.js +497 -518
- package/dist/cjs/import/NdgFormat.js +424 -457
- package/dist/cjs/import/OgmoImporter.js +466 -493
- package/dist/cjs/import/RPGMakerImporter.js +451 -477
- package/dist/cjs/import/SceneImporter.js +378 -423
- package/dist/cjs/import/SpineImporter.js +511 -546
- package/dist/cjs/import/SpriterImporter.js +590 -613
- package/dist/cjs/import/TiledMapImporter.js +811 -846
- package/dist/cjs/import/UnitySceneImporter.js +687 -703
- package/dist/cjs/import/index.js +206 -251
- package/dist/cjs/index.js +275 -278
- package/dist/cjs/input/GamepadNavigation.js +185 -205
- package/dist/cjs/input/InputManager.js +397 -421
- package/dist/cjs/input/useGamepads.js +70 -81
- package/dist/cjs/integration/IconSprite.js +129 -256
- package/dist/cjs/inventory/InventorySystem.js +920 -995
- package/dist/cjs/kids/KidMode.js +997 -1022
- package/dist/cjs/kids/KidTools.js +570 -594
- package/dist/cjs/monetization/Monetization.js +170 -177
- package/dist/cjs/multiplayer/LocalMultiplayer.js +287 -287
- package/dist/cjs/multiplayer/MiniGameTypes.js +49 -59
- package/dist/cjs/native-engine/AnimationSystem.js +731 -806
- package/dist/cjs/native-engine/AssetPipeline.js +454 -515
- package/dist/cjs/native-engine/AudioEngine.js +763 -804
- package/dist/cjs/native-engine/InputSystem.js +1075 -1145
- package/dist/cjs/native-engine/NetworkingSystem.js +733 -793
- package/dist/cjs/native-engine/PhysicsEngine.js +583 -607
- package/dist/cjs/native-engine/RenderingEngine.js +302 -350
- package/dist/cjs/native-engine/SceneGraph.js +769 -808
- package/dist/cjs/network/MultiplayerTransport.js +97 -132
- package/dist/cjs/network/Networking.js +549 -564
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/AbortController.js +21 -29
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/AccessTokenHttpClient.js +40 -48
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/DefaultHttpClient.js +35 -43
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/DefaultReconnectPolicy.js +10 -15
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/Errors.js +103 -135
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/FetchHttpClient.js +131 -158
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HandshakeProtocol.js +39 -53
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HeaderNames.js +5 -8
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HttpClient.js +40 -48
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HttpConnection.js +494 -572
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HubConnection.js +826 -953
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HubConnectionBuilder.js +125 -146
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/IHubProtocol.js +13 -23
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/ILogger.js +11 -25
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/ITransport.js +13 -24
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/JsonHubProtocol.js +108 -121
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/Loggers.js +10 -14
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/LongPollingTransport.js +150 -185
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/MessageBuffer.js +158 -196
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/ServerSentEventsTransport.js +90 -105
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/Subject.js +30 -35
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/TextMessageFormat.js +16 -21
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/Utils.js +215 -248
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/WebSocketTransport.js +135 -157
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/XhrHttpClient.js +76 -85
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/index.js +24 -27
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/pkg-version.js +3 -4
- package/dist/cjs/pathfinding/Pathfinding.js +245 -263
- package/dist/cjs/performance/AssetStreaming.js +561 -635
- package/dist/cjs/performance/BenchmarkSuite.js +283 -311
- package/dist/cjs/performance/DeltaCompression.js +467 -526
- package/dist/cjs/performance/DeterministicPhysics.js +450 -498
- package/dist/cjs/performance/ECSOptimization.js +644 -695
- package/dist/cjs/performance/GameSaveSystem.js +509 -556
- package/dist/cjs/performance/HotReload.js +447 -500
- package/dist/cjs/performance/InputRecording.js +511 -561
- package/dist/cjs/performance/InterestManagement.js +453 -500
- package/dist/cjs/performance/LocalizationRuntime.js +376 -423
- package/dist/cjs/performance/MemoryManagement.js +410 -470
- package/dist/cjs/performance/ModSupport.js +445 -496
- package/dist/cjs/performance/MultiThreadedPhysics.js +400 -443
- package/dist/cjs/performance/NetworkPrediction.js +424 -482
- package/dist/cjs/performance/ObjectPooling.js +569 -617
- package/dist/cjs/performance/Performance.js +174 -190
- package/dist/cjs/performance/PerformanceAdvanced.js +614 -637
- package/dist/cjs/performance/WebGPURenderer.js +656 -683
- package/dist/cjs/physics/PhysicsAdvanced.js +345 -379
- package/dist/cjs/physics/PhysicsEngine2D.js +391 -427
- package/dist/cjs/plugins/PluginSDK.js +432 -466
- package/dist/cjs/plugins/PluginTestKit.js +307 -330
- package/dist/cjs/procedural/Procedural.js +243 -254
- package/dist/cjs/procedural/WorldBuilding.js +297 -314
- package/dist/cjs/quest/QuestSystem.js +975 -932
- package/dist/cjs/release/MobileExport.js +157 -163
- package/dist/cjs/release/Release.js +225 -238
- package/dist/cjs/rendering/Camera2D.js +121 -124
- package/dist/cjs/rendering/Renderer2D.js +321 -335
- package/dist/cjs/rendering/WebGPURenderPipeline.js +632 -651
- package/dist/cjs/runtime3d/Runtime3D.js +359 -378
- package/dist/cjs/runtime3d/SceneEditor3D.js +252 -263
- package/dist/cjs/scene/SceneManager.js +177 -193
- package/dist/cjs/scripting/GraphToAST.js +574 -547
- package/dist/cjs/scripting/LanguageExporter.js +254 -279
- package/dist/cjs/scripting/NodeGraph.js +546 -570
- package/dist/cjs/scripting/ScriptAST.js +31 -39
- package/dist/cjs/scripting/VisualScripting2.js +1016 -1065
- package/dist/cjs/scripting/exporters/CSharpExporter.js +464 -496
- package/dist/cjs/scripting/exporters/GDScriptExporter.js +390 -442
- package/dist/cjs/scripting/exporters/LuaExporter.js +406 -447
- package/dist/cjs/scripting/exporters/PythonExporter.js +484 -549
- package/dist/cjs/scripting/exporters/RustExporter.js +459 -512
- package/dist/cjs/scripting/exporters/TypeScriptExporter.js +505 -556
- package/dist/cjs/social/Social.js +72 -80
- package/dist/cjs/systems/LightingSystem.js +844 -931
- package/dist/cjs/systems/ParticleSystem2.js +1447 -1451
- package/dist/cjs/systems/PhysicsDebugSystem.js +1070 -1141
- package/dist/cjs/systems/TerrainSystem.js +985 -1098
- package/dist/cjs/templates/ActionTemplates.js +296 -309
- package/dist/cjs/templates/FightingTemplate.js +417 -463
- package/dist/cjs/templates/MetroidvaniaTemplate.js +353 -405
- package/dist/cjs/templates/PartyTemplates.js +190 -202
- package/dist/cjs/templates/PuzzleTemplates.js +245 -261
- package/dist/cjs/templates/RPGTemplates.js +160 -178
- package/dist/cjs/templates/SportsTemplates.js +237 -250
- package/dist/cjs/templates/StrategyTemplates.js +143 -153
- package/dist/cjs/templates/SurvivalTemplate.js +336 -380
- package/dist/cjs/templates/WaveDefense.js +499 -526
- package/dist/cjs/tilemap/Tilemap.js +207 -214
- package/dist/cjs/tutorials/TutorialBranching.js +396 -417
- package/dist/cjs/tutorials/TutorialEngine.js +888 -931
- package/dist/cjs/tutorials/TutorialOverlay.js +602 -640
- package/dist/cjs/tutorials/content/Tutorials_T05_T08.js +787 -809
- package/dist/cjs/tutorials/content/Tutorials_T09_T11.js +736 -756
- package/dist/cjs/tutorials/content/Tutorials_T12_T15.js +754 -778
- package/dist/cjs/ui/GameUI.js +295 -312
- package/dist/cjs/unity-integration/UnityAssetStore.js +700 -741
- package/dist/cjs/unity-integration/UnityImport.js +1066 -1176
- package/dist/cjs/unity-integration/UnityLiveLink.js +934 -981
- package/dist/cjs/unity-integration/components/UnityAssetStoreBrowser.js +1233 -757
- package/dist/cjs/unity-integration/components/UnityProjectBrowser.js +1240 -768
- package/dist/cjs/unreal-integration/UnrealImport.js +391 -412
- package/dist/cjs/unreal-integration/UnrealLiveLink.js +1102 -1137
- package/dist/cjs/unreal-integration/UnrealMarketplace.js +436 -473
- package/dist/cjs/unreal-integration/components/UnrealProjectBrowser.js +1150 -767
- package/dist/cjs/xr/ARVR.js +167 -175
- package/dist/esm/accessibility/Accessibility.js +160 -164
- package/dist/esm/ai/AI.js +310 -293
- package/dist/esm/ai/BehaviorTree.js +1057 -1112
- package/dist/esm/ai/StateMachine.js +709 -755
- package/dist/esm/animation/Animation.js +237 -240
- package/dist/esm/audio/AudioAdvanced.js +239 -235
- package/dist/esm/audio/AudioBridge.js +448 -434
- package/dist/esm/audio/AudioManager.js +243 -258
- package/dist/esm/build-cloud/BuildOrchestration.js +1071 -1097
- package/dist/esm/build-cloud/GodotBuildCloud.js +647 -669
- package/dist/esm/build-cloud/UnityBuildCloud.js +571 -609
- package/dist/esm/build-cloud/UnrealBuildCloud.js +615 -634
- package/dist/esm/core/EventBus.js +52 -55
- package/dist/esm/core/GameClock.js +63 -65
- package/dist/esm/core/GameConfig.js +77 -78
- package/dist/esm/core/GameLoop.js +81 -88
- package/dist/esm/core/ServiceLocator.js +63 -64
- package/dist/esm/core/Validation.js +82 -81
- package/dist/esm/core/math.js +109 -111
- package/dist/esm/devtools/DevTools.js +546 -562
- package/dist/esm/devtools/DeveloperExperience.js +535 -558
- package/dist/esm/devtools/GameplayAnalytics.js +647 -645
- package/dist/esm/dialogue/DialogueSystem.js +998 -985
- package/dist/esm/docs/DocGenerator.js +342 -363
- package/dist/esm/ecs/World.js +358 -370
- package/dist/esm/editor/AchievementEditor.js +584 -635
- package/dist/esm/editor/AdvancedEditor.js +191 -190
- package/dist/esm/editor/AnimationRetargeting.js +700 -740
- package/dist/esm/editor/AssetBrowser.js +1078 -1159
- package/dist/esm/editor/AssetManager.js +188 -191
- package/dist/esm/editor/ConsolePro.js +977 -1060
- package/dist/esm/editor/CraftingEditor.js +684 -729
- package/dist/esm/editor/DebugTools.js +194 -184
- package/dist/esm/editor/DialogueSystem.js +849 -900
- package/dist/esm/editor/LeaderboardSystem.js +433 -482
- package/dist/esm/editor/NiceGameEditor.js +1908 -1200
- package/dist/esm/editor/PrefabSystem.js +777 -837
- package/dist/esm/editor/ProfilerPanel.js +654 -699
- package/dist/esm/editor/QuestEditor.js +795 -838
- package/dist/esm/editor/ReplaySystem.js +591 -633
- package/dist/esm/editor/SceneEditor.js +189 -199
- package/dist/esm/editor/ScreenshotMode.js +628 -687
- package/dist/esm/editor/ShaderGraph.js +1565 -1581
- package/dist/esm/editor/TimelineEditor.js +733 -777
- package/dist/esm/editor/UndoRedoPro.js +835 -903
- package/dist/esm/editor/VRARMode.js +586 -644
- package/dist/esm/engine/NiceGameEngine.js +142 -163
- package/dist/esm/engine/SaveSystem.js +447 -494
- package/dist/esm/enterprise/Enterprise.js +265 -260
- package/dist/esm/export/BevyExporter.js +929 -966
- package/dist/esm/export/CocosExporter.js +646 -672
- package/dist/esm/export/Construct3Exporter.js +785 -793
- package/dist/esm/export/DefoldExporter.js +1030 -1068
- package/dist/esm/export/GDevelopExporter.js +676 -707
- package/dist/esm/export/GameMakerExporter.js +793 -804
- package/dist/esm/export/GodotExporter.js +1004 -1044
- package/dist/esm/export/MinecraftBedrockExporter.js +575 -577
- package/dist/esm/export/MonoGameExporter.js +1267 -1292
- package/dist/esm/export/Pico8Exporter.js +768 -811
- package/dist/esm/export/PlatformExporter.js +193 -205
- package/dist/esm/export/RPGMakerExporter.js +862 -878
- package/dist/esm/export/RobloxExporter.js +885 -918
- package/dist/esm/export/Solar2DExporter.js +1220 -1255
- package/dist/esm/export/ThreeJSExporter.js +1007 -1072
- package/dist/esm/export/Tic80Exporter.js +1212 -1266
- package/dist/esm/export/UnityExporter.js +1117 -1130
- package/dist/esm/export/UnrealExporter.js +891 -918
- package/dist/esm/export/WebExporter.js +933 -969
- package/dist/esm/export/index.js +86 -71
- package/dist/esm/godot-integration/GodotAssetLibrary.js +663 -691
- package/dist/esm/godot-integration/GodotImport.js +935 -1026
- package/dist/esm/godot-integration/GodotLiveLink.js +918 -944
- package/dist/esm/godot-integration/components/GodotProjectBrowser.js +912 -610
- package/dist/esm/i18n/I18n.js +871 -899
- package/dist/esm/i18n/useTranslation.js +88 -88
- package/dist/esm/import/AsepriteImporter.js +637 -715
- package/dist/esm/import/DragonBonesImporter.js +417 -460
- package/dist/esm/import/GameMakerImporter.js +491 -520
- package/dist/esm/import/GodotSceneImporter.js +767 -821
- package/dist/esm/import/LDtkImporter.js +415 -453
- package/dist/esm/import/Live2DImporter.js +477 -517
- package/dist/esm/import/NdgFormat.js +410 -456
- package/dist/esm/import/OgmoImporter.js +446 -492
- package/dist/esm/import/RPGMakerImporter.js +431 -476
- package/dist/esm/import/SceneImporter.js +385 -422
- package/dist/esm/import/SpineImporter.js +491 -545
- package/dist/esm/import/SpriterImporter.js +570 -612
- package/dist/esm/import/TiledMapImporter.js +790 -845
- package/dist/esm/import/UnitySceneImporter.js +666 -702
- package/dist/esm/import/index.js +247 -258
- package/dist/esm/index.js +1332 -188
- package/dist/esm/input/GamepadNavigation.js +187 -204
- package/dist/esm/input/InputManager.js +401 -420
- package/dist/esm/input/useGamepads.js +72 -80
- package/dist/esm/integration/IconSprite.js +143 -255
- package/dist/esm/inventory/InventorySystem.js +925 -994
- package/dist/esm/kids/KidMode.js +1003 -1021
- package/dist/esm/kids/KidTools.js +573 -593
- package/dist/esm/monetization/Monetization.js +180 -176
- package/dist/esm/multiplayer/LocalMultiplayer.js +290 -286
- package/dist/esm/multiplayer/MiniGameTypes.js +58 -58
- package/dist/esm/native-engine/AnimationSystem.js +735 -805
- package/dist/esm/native-engine/AssetPipeline.js +456 -514
- package/dist/esm/native-engine/AudioEngine.js +765 -803
- package/dist/esm/native-engine/InputSystem.js +1079 -1144
- package/dist/esm/native-engine/NetworkingSystem.js +740 -792
- package/dist/esm/native-engine/PhysicsEngine.js +585 -606
- package/dist/esm/native-engine/RenderingEngine.js +304 -349
- package/dist/esm/native-engine/SceneGraph.js +773 -807
- package/dist/esm/network/MultiplayerTransport.js +99 -131
- package/dist/esm/network/Networking.js +556 -563
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/AbortController.js +22 -28
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/AccessTokenHttpClient.js +41 -47
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/DefaultHttpClient.js +36 -42
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/DefaultReconnectPolicy.js +11 -14
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/Errors.js +111 -134
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/FetchHttpClient.js +132 -157
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HandshakeProtocol.js +40 -52
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HeaderNames.js +6 -7
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HttpClient.js +42 -47
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HttpConnection.js +496 -571
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HubConnection.js +828 -952
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HubConnectionBuilder.js +126 -145
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/IHubProtocol.js +14 -23
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/ILogger.js +12 -25
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/ITransport.js +15 -24
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/JsonHubProtocol.js +109 -120
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/Loggers.js +11 -13
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/LongPollingTransport.js +151 -184
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/MessageBuffer.js +159 -195
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/ServerSentEventsTransport.js +91 -104
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/Subject.js +31 -34
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/TextMessageFormat.js +17 -20
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/Utils.js +230 -248
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/WebSocketTransport.js +136 -156
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/XhrHttpClient.js +77 -84
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/index.js +31 -12
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/pkg-version.js +4 -3
- package/dist/esm/pathfinding/Pathfinding.js +249 -262
- package/dist/esm/performance/AssetStreaming.js +567 -634
- package/dist/esm/performance/BenchmarkSuite.js +285 -310
- package/dist/esm/performance/DeltaCompression.js +478 -525
- package/dist/esm/performance/DeterministicPhysics.js +479 -497
- package/dist/esm/performance/ECSOptimization.js +653 -694
- package/dist/esm/performance/GameSaveSystem.js +515 -555
- package/dist/esm/performance/HotReload.js +454 -499
- package/dist/esm/performance/InputRecording.js +520 -560
- package/dist/esm/performance/InterestManagement.js +460 -499
- package/dist/esm/performance/LocalizationRuntime.js +382 -422
- package/dist/esm/performance/MemoryManagement.js +415 -469
- package/dist/esm/performance/ModSupport.js +455 -495
- package/dist/esm/performance/MultiThreadedPhysics.js +408 -442
- package/dist/esm/performance/NetworkPrediction.js +436 -481
- package/dist/esm/performance/ObjectPooling.js +582 -616
- package/dist/esm/performance/Performance.js +182 -189
- package/dist/esm/performance/PerformanceAdvanced.js +621 -636
- package/dist/esm/performance/WebGPURenderer.js +660 -682
- package/dist/esm/physics/PhysicsAdvanced.js +359 -378
- package/dist/esm/physics/PhysicsEngine2D.js +393 -426
- package/dist/esm/plugins/PluginSDK.js +435 -465
- package/dist/esm/plugins/PluginTestKit.js +315 -329
- package/dist/esm/procedural/Procedural.js +248 -253
- package/dist/esm/procedural/WorldBuilding.js +316 -313
- package/dist/esm/quest/QuestSystem.js +982 -931
- package/dist/esm/release/MobileExport.js +163 -162
- package/dist/esm/release/Release.js +234 -237
- package/dist/esm/rendering/Camera2D.js +122 -123
- package/dist/esm/rendering/Renderer2D.js +323 -334
- package/dist/esm/rendering/WebGPURenderPipeline.js +647 -650
- package/dist/esm/runtime3d/Runtime3D.js +368 -377
- package/dist/esm/runtime3d/SceneEditor3D.js +268 -262
- package/dist/esm/scene/SceneManager.js +178 -192
- package/dist/esm/scripting/GraphToAST.js +576 -546
- package/dist/esm/scripting/LanguageExporter.js +263 -278
- package/dist/esm/scripting/NodeGraph.js +550 -569
- package/dist/esm/scripting/ScriptAST.js +45 -38
- package/dist/esm/scripting/VisualScripting2.js +1025 -1064
- package/dist/esm/scripting/exporters/CSharpExporter.js +465 -495
- package/dist/esm/scripting/exporters/GDScriptExporter.js +391 -441
- package/dist/esm/scripting/exporters/LuaExporter.js +407 -446
- package/dist/esm/scripting/exporters/PythonExporter.js +485 -548
- package/dist/esm/scripting/exporters/RustExporter.js +460 -511
- package/dist/esm/scripting/exporters/TypeScriptExporter.js +506 -555
- package/dist/esm/social/Social.js +77 -79
- package/dist/esm/systems/LightingSystem.js +855 -930
- package/dist/esm/systems/ParticleSystem2.js +1453 -1450
- package/dist/esm/systems/PhysicsDebugSystem.js +1078 -1140
- package/dist/esm/systems/TerrainSystem.js +996 -1097
- package/dist/esm/templates/ActionTemplates.js +307 -308
- package/dist/esm/templates/FightingTemplate.js +439 -462
- package/dist/esm/templates/MetroidvaniaTemplate.js +391 -404
- package/dist/esm/templates/PartyTemplates.js +206 -201
- package/dist/esm/templates/PuzzleTemplates.js +260 -260
- package/dist/esm/templates/RPGTemplates.js +172 -177
- package/dist/esm/templates/SportsTemplates.js +251 -249
- package/dist/esm/templates/StrategyTemplates.js +158 -152
- package/dist/esm/templates/SurvivalTemplate.js +367 -379
- package/dist/esm/templates/WaveDefense.js +501 -525
- package/dist/esm/tilemap/Tilemap.js +209 -213
- package/dist/esm/tutorials/TutorialBranching.js +399 -416
- package/dist/esm/tutorials/TutorialEngine.js +893 -930
- package/dist/esm/tutorials/TutorialOverlay.js +603 -639
- package/dist/esm/tutorials/content/Tutorials_T05_T08.js +792 -808
- package/dist/esm/tutorials/content/Tutorials_T09_T11.js +740 -755
- package/dist/esm/tutorials/content/Tutorials_T12_T15.js +759 -777
- package/dist/esm/ui/GameUI.js +296 -311
- package/dist/esm/unity-integration/UnityAssetStore.js +704 -740
- package/dist/esm/unity-integration/UnityImport.js +1071 -1175
- package/dist/esm/unity-integration/UnityLiveLink.js +938 -980
- package/dist/esm/unity-integration/components/UnityAssetStoreBrowser.js +1234 -756
- package/dist/esm/unity-integration/components/UnityProjectBrowser.js +1241 -767
- package/dist/esm/unreal-integration/UnrealImport.js +395 -411
- package/dist/esm/unreal-integration/UnrealLiveLink.js +1105 -1136
- package/dist/esm/unreal-integration/UnrealMarketplace.js +442 -472
- package/dist/esm/unreal-integration/components/UnrealProjectBrowser.js +1151 -766
- package/dist/esm/xr/ARVR.js +181 -174
- package/package.json +7 -12
|
@@ -1,526 +1,472 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
/* ────────────────────────────────────────────────────────────────
|
|
4
|
-
Save System v2 — Cloud saves, migration, compression
|
|
5
|
-
|
|
6
|
-
Enhanced save system with:
|
|
7
|
-
- Multiple save slots with metadata
|
|
8
|
-
- LZ77-style compression for save data
|
|
9
|
-
- Schema versioning with automatic migration
|
|
10
|
-
- Cloud sync with conflict resolution
|
|
11
|
-
- Auto-save with configurable interval
|
|
12
|
-
- Save data integrity (checksums)
|
|
13
|
-
──────────────────────────────────────────────────────────────── */
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
14
3
|
const DEFAULT_SAVE_CONFIG = {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
4
|
+
schemaVersion: 1,
|
|
5
|
+
storageBackend: "indexeddb",
|
|
6
|
+
storageKey: "nice-game-saves",
|
|
7
|
+
maxSlots: 20,
|
|
8
|
+
compressionEnabled: true,
|
|
9
|
+
autoSave: {
|
|
10
|
+
enabled: true,
|
|
11
|
+
intervalMs: 6e4,
|
|
12
|
+
maxAutoSaves: 3,
|
|
13
|
+
requireSafeState: true
|
|
14
|
+
},
|
|
15
|
+
cloud: {
|
|
16
|
+
enabled: false,
|
|
17
|
+
conflictStrategy: "newest-wins",
|
|
18
|
+
syncIntervalMs: 3e5,
|
|
19
|
+
maxCloudSlots: 10
|
|
20
|
+
}
|
|
32
21
|
};
|
|
33
|
-
/* ══════════════════════════════════════════════════════════════
|
|
34
|
-
COMPRESSION — LZ77-style + RLE for save data
|
|
35
|
-
══════════════════════════════════════════════════════════════ */
|
|
36
|
-
/** Simple compression for JSON save data (dictionary-based) */
|
|
37
22
|
function compressSaveData(json) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
let
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
for (let
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
if (raw[i + j] !== dictBytes[j]) {
|
|
76
|
-
match = false;
|
|
77
|
-
break;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
if (match) {
|
|
81
|
-
chunks.push(255); // escape byte = dict reference
|
|
82
|
-
chunks.push(d); // dict index
|
|
83
|
-
i += dictBytes.length;
|
|
84
|
-
matched = true;
|
|
85
|
-
break;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
23
|
+
const encoder = new TextEncoder();
|
|
24
|
+
const raw = encoder.encode(json);
|
|
25
|
+
if (raw.length < 256) {
|
|
26
|
+
const out = new Uint8Array(1 + raw.length);
|
|
27
|
+
out[0] = 0;
|
|
28
|
+
out.set(raw, 1);
|
|
29
|
+
return out;
|
|
30
|
+
}
|
|
31
|
+
const dictionary = [
|
|
32
|
+
'":"',
|
|
33
|
+
'","',
|
|
34
|
+
'":true',
|
|
35
|
+
'":false',
|
|
36
|
+
'":null',
|
|
37
|
+
'":0',
|
|
38
|
+
'":1',
|
|
39
|
+
'{"',
|
|
40
|
+
'"}',
|
|
41
|
+
'["',
|
|
42
|
+
'"]',
|
|
43
|
+
"\\n",
|
|
44
|
+
"\\t"
|
|
45
|
+
];
|
|
46
|
+
const chunks = [1];
|
|
47
|
+
chunks.push(dictionary.length);
|
|
48
|
+
let i = 0;
|
|
49
|
+
while (i < raw.length) {
|
|
50
|
+
let matched = false;
|
|
51
|
+
for (let d = 0; d < dictionary.length; d++) {
|
|
52
|
+
const dictBytes = encoder.encode(dictionary[d]);
|
|
53
|
+
if (i + dictBytes.length <= raw.length) {
|
|
54
|
+
let match = true;
|
|
55
|
+
for (let j = 0; j < dictBytes.length; j++) {
|
|
56
|
+
if (raw[i + j] !== dictBytes[j]) {
|
|
57
|
+
match = false;
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
88
60
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
chunks.push(254); // escape byte = RLE
|
|
96
|
-
chunks.push(runLen);
|
|
97
|
-
chunks.push(raw[i]);
|
|
98
|
-
i += runLen;
|
|
99
|
-
matched = true;
|
|
61
|
+
if (match) {
|
|
62
|
+
chunks.push(255);
|
|
63
|
+
chunks.push(d);
|
|
64
|
+
i += dictBytes.length;
|
|
65
|
+
matched = true;
|
|
66
|
+
break;
|
|
100
67
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (!matched && i + 3 < raw.length && raw[i] === raw[i + 1] && raw[i] === raw[i + 2]) {
|
|
71
|
+
let runLen = 1;
|
|
72
|
+
while (i + runLen < raw.length && raw[i + runLen] === raw[i] && runLen < 127) {
|
|
73
|
+
runLen++;
|
|
74
|
+
}
|
|
75
|
+
chunks.push(254);
|
|
76
|
+
chunks.push(runLen);
|
|
77
|
+
chunks.push(raw[i]);
|
|
78
|
+
i += runLen;
|
|
79
|
+
matched = true;
|
|
80
|
+
}
|
|
81
|
+
if (!matched) {
|
|
82
|
+
if (raw[i] === 254 || raw[i] === 255) {
|
|
83
|
+
chunks.push(253);
|
|
84
|
+
}
|
|
85
|
+
chunks.push(raw[i]);
|
|
86
|
+
i++;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return new Uint8Array(chunks);
|
|
111
90
|
}
|
|
112
|
-
/** Decompress save data */
|
|
113
91
|
function decompressSaveData(data) {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
for (const b of dictBytes[dictIdx]) {
|
|
144
|
-
output.push(b);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
i += 2;
|
|
148
|
-
}
|
|
149
|
-
else if (data[i] === 254) {
|
|
150
|
-
// RLE
|
|
151
|
-
const runLen = data[i + 1];
|
|
152
|
-
const val = data[i + 2];
|
|
153
|
-
for (let j = 0; j < runLen; j++) {
|
|
154
|
-
output.push(val);
|
|
155
|
-
}
|
|
156
|
-
i += 3;
|
|
157
|
-
}
|
|
158
|
-
else if (data[i] === 253) {
|
|
159
|
-
// Escaped literal
|
|
160
|
-
output.push(data[i + 1]);
|
|
161
|
-
i += 2;
|
|
92
|
+
const decoder = new TextDecoder();
|
|
93
|
+
const encoder = new TextEncoder();
|
|
94
|
+
if (data[0] === 0) {
|
|
95
|
+
return decoder.decode(data.slice(1));
|
|
96
|
+
}
|
|
97
|
+
const dictionary = [
|
|
98
|
+
'":"',
|
|
99
|
+
'","',
|
|
100
|
+
'":true',
|
|
101
|
+
'":false',
|
|
102
|
+
'":null',
|
|
103
|
+
'":0',
|
|
104
|
+
'":1',
|
|
105
|
+
'{"',
|
|
106
|
+
'"}',
|
|
107
|
+
'["',
|
|
108
|
+
'"]',
|
|
109
|
+
"\\n",
|
|
110
|
+
"\\t"
|
|
111
|
+
];
|
|
112
|
+
const dictBytes = dictionary.map((s) => encoder.encode(s));
|
|
113
|
+
const output = [];
|
|
114
|
+
let i = 2;
|
|
115
|
+
while (i < data.length) {
|
|
116
|
+
if (data[i] === 255) {
|
|
117
|
+
const dictIdx = data[i + 1];
|
|
118
|
+
if (dictIdx < dictBytes.length) {
|
|
119
|
+
for (const b of dictBytes[dictIdx]) {
|
|
120
|
+
output.push(b);
|
|
162
121
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
122
|
+
}
|
|
123
|
+
i += 2;
|
|
124
|
+
} else if (data[i] === 254) {
|
|
125
|
+
const runLen = data[i + 1];
|
|
126
|
+
const val = data[i + 2];
|
|
127
|
+
for (let j = 0; j < runLen; j++) {
|
|
128
|
+
output.push(val);
|
|
129
|
+
}
|
|
130
|
+
i += 3;
|
|
131
|
+
} else if (data[i] === 253) {
|
|
132
|
+
output.push(data[i + 1]);
|
|
133
|
+
i += 2;
|
|
134
|
+
} else {
|
|
135
|
+
output.push(data[i]);
|
|
136
|
+
i++;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return decoder.decode(new Uint8Array(output));
|
|
169
140
|
}
|
|
170
|
-
/* ══════════════════════════════════════════════════════════════
|
|
171
|
-
CHECKSUM — CRC32 for data integrity
|
|
172
|
-
══════════════════════════════════════════════════════════════ */
|
|
173
141
|
const CRC32_TABLE = [];
|
|
174
142
|
for (let i = 0; i < 256; i++) {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
143
|
+
let c = i;
|
|
144
|
+
for (let j = 0; j < 8; j++) {
|
|
145
|
+
c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;
|
|
146
|
+
}
|
|
147
|
+
CRC32_TABLE[i] = c;
|
|
180
148
|
}
|
|
181
149
|
function crc32(data) {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
150
|
+
let crc = 4294967295;
|
|
151
|
+
for (let i = 0; i < data.length; i++) {
|
|
152
|
+
crc = CRC32_TABLE[(crc ^ data[i]) & 255] ^ crc >>> 8;
|
|
153
|
+
}
|
|
154
|
+
return (crc ^ 4294967295) >>> 0;
|
|
187
155
|
}
|
|
188
|
-
/* ══════════════════════════════════════════════════════════════
|
|
189
|
-
MIGRATION ENGINE
|
|
190
|
-
══════════════════════════════════════════════════════════════ */
|
|
191
156
|
class MigrationEngine {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
throw new Error(`No migration found for version ${version} → ${version + 1}`);
|
|
210
|
-
}
|
|
211
|
-
current = migration.migrate(current);
|
|
212
|
-
applied.push(migration.description);
|
|
213
|
-
version = migration.toVersion;
|
|
214
|
-
}
|
|
157
|
+
constructor() {
|
|
158
|
+
this.migrations = [];
|
|
159
|
+
}
|
|
160
|
+
register(migration) {
|
|
161
|
+
this.migrations.push(migration);
|
|
162
|
+
this.migrations.sort((a, b) => a.fromVersion - b.fromVersion);
|
|
163
|
+
}
|
|
164
|
+
/** Migrate payload from fromVersion to toVersion */
|
|
165
|
+
migrate(payload, fromVersion, toVersion) {
|
|
166
|
+
const applied = [];
|
|
167
|
+
let current = { ...payload };
|
|
168
|
+
let version = fromVersion;
|
|
169
|
+
if (fromVersion < toVersion) {
|
|
170
|
+
while (version < toVersion) {
|
|
171
|
+
const migration = this.migrations.find((m) => m.fromVersion === version);
|
|
172
|
+
if (!migration) {
|
|
173
|
+
throw new Error(`No migration found for version ${version} → ${version + 1}`);
|
|
215
174
|
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
version = migration.fromVersion;
|
|
226
|
-
}
|
|
175
|
+
current = migration.migrate(current);
|
|
176
|
+
applied.push(migration.description);
|
|
177
|
+
version = migration.toVersion;
|
|
178
|
+
}
|
|
179
|
+
} else if (fromVersion > toVersion) {
|
|
180
|
+
while (version > toVersion) {
|
|
181
|
+
const migration = this.migrations.find((m) => m.toVersion === version);
|
|
182
|
+
if (!migration || !migration.rollback) {
|
|
183
|
+
throw new Error(`No rollback found for version ${version} → ${version - 1}`);
|
|
227
184
|
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
185
|
+
current = migration.rollback(current);
|
|
186
|
+
applied.push(`Rollback: ${migration.description}`);
|
|
187
|
+
version = migration.fromVersion;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return { payload: current, applied };
|
|
191
|
+
}
|
|
192
|
+
getRegistered() {
|
|
193
|
+
return this.migrations;
|
|
194
|
+
}
|
|
195
|
+
canMigrate(from, to) {
|
|
196
|
+
let v = from;
|
|
197
|
+
if (from < to) {
|
|
198
|
+
while (v < to) {
|
|
199
|
+
const m = this.migrations.find((mm) => mm.fromVersion === v);
|
|
200
|
+
if (!m) {
|
|
201
|
+
return false;
|
|
243
202
|
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
}
|
|
203
|
+
v = m.toVersion;
|
|
204
|
+
}
|
|
205
|
+
} else {
|
|
206
|
+
while (v > to) {
|
|
207
|
+
const m = this.migrations.find((mm) => mm.toVersion === v);
|
|
208
|
+
if (!m || !m.rollback) {
|
|
209
|
+
return false;
|
|
252
210
|
}
|
|
253
|
-
|
|
211
|
+
v = m.fromVersion;
|
|
212
|
+
}
|
|
254
213
|
}
|
|
214
|
+
return true;
|
|
215
|
+
}
|
|
255
216
|
}
|
|
256
|
-
/* ══════════════════════════════════════════════════════════════
|
|
257
|
-
SAVE SYSTEM V2
|
|
258
|
-
══════════════════════════════════════════════════════════════ */
|
|
259
217
|
class SaveSystem {
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
218
|
+
constructor(eventBus, config = {}) {
|
|
219
|
+
this.migrationEngine = new MigrationEngine();
|
|
220
|
+
this.slots = /* @__PURE__ */ new Map();
|
|
221
|
+
this.autoSaveTimer = null;
|
|
222
|
+
this.autoSaveCounter = 0;
|
|
223
|
+
this.safeToSave = true;
|
|
224
|
+
this.config = { ...DEFAULT_SAVE_CONFIG, ...config };
|
|
225
|
+
this.eventBus = eventBus;
|
|
226
|
+
this.setupEventHandlers();
|
|
227
|
+
}
|
|
228
|
+
setupEventHandlers() {
|
|
229
|
+
this.eventBus.on("game:safe-state", (data) => {
|
|
230
|
+
this.safeToSave = data.safe;
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
/** Register a schema migration */
|
|
234
|
+
registerMigration(migration) {
|
|
235
|
+
this.migrationEngine.register(migration);
|
|
236
|
+
}
|
|
237
|
+
/** Save game state to a slot */
|
|
238
|
+
save(slotId, payload, options = {}) {
|
|
239
|
+
const encoder = new TextEncoder();
|
|
240
|
+
const json = JSON.stringify(payload);
|
|
241
|
+
const compressed = this.config.compressionEnabled ? compressSaveData(json) : encoder.encode(json);
|
|
242
|
+
const checksum = crc32(compressed);
|
|
243
|
+
const now = Date.now();
|
|
244
|
+
const existingMeta = this.slots.get(slotId)?.meta;
|
|
245
|
+
const meta = {
|
|
246
|
+
slotId,
|
|
247
|
+
type: options.type ?? "manual",
|
|
248
|
+
label: options.label ?? `Save ${slotId}`,
|
|
249
|
+
schemaVersion: this.config.schemaVersion,
|
|
250
|
+
createdAt: existingMeta?.createdAt ?? now,
|
|
251
|
+
updatedAt: now,
|
|
252
|
+
playtimeMs: existingMeta ? existingMeta.playtimeMs + (now - existingMeta.updatedAt) : 0,
|
|
253
|
+
location: options.location ?? "",
|
|
254
|
+
thumbnail: options.thumbnail,
|
|
255
|
+
sizeBytes: compressed.length,
|
|
256
|
+
checksum,
|
|
257
|
+
cloudSynced: false,
|
|
258
|
+
tags: options.tags ?? []
|
|
259
|
+
};
|
|
260
|
+
this.slots.set(slotId, { meta, payload });
|
|
261
|
+
this.persistSlot(slotId, compressed, meta);
|
|
262
|
+
this.eventBus.emit("save:saved", { slotId, sizeBytes: compressed.length });
|
|
263
|
+
return {
|
|
264
|
+
success: true,
|
|
265
|
+
slotId,
|
|
266
|
+
sizeBytes: compressed.length,
|
|
267
|
+
compressed: this.config.compressionEnabled
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
/** Load game state from a slot */
|
|
271
|
+
load(slotId) {
|
|
272
|
+
const data = this.slots.get(slotId);
|
|
273
|
+
if (!data) {
|
|
274
|
+
return null;
|
|
275
|
+
}
|
|
276
|
+
let payload = { ...data.payload };
|
|
277
|
+
let migrated = false;
|
|
278
|
+
if (data.meta.schemaVersion !== this.config.schemaVersion) {
|
|
279
|
+
if (this.migrationEngine.canMigrate(data.meta.schemaVersion, this.config.schemaVersion)) {
|
|
280
|
+
const result = this.migrationEngine.migrate(
|
|
281
|
+
payload,
|
|
282
|
+
data.meta.schemaVersion,
|
|
283
|
+
this.config.schemaVersion
|
|
284
|
+
);
|
|
285
|
+
payload = result.payload;
|
|
286
|
+
migrated = true;
|
|
287
|
+
this.eventBus.emit("save:migrated", {
|
|
288
|
+
slotId,
|
|
289
|
+
from: data.meta.schemaVersion,
|
|
290
|
+
to: this.config.schemaVersion,
|
|
291
|
+
steps: result.applied
|
|
273
292
|
});
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
return
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
return
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
return;
|
|
373
|
-
}
|
|
374
|
-
const slotId = `auto-${this.autoSaveCounter % this.config.autoSave.maxAutoSaves}`;
|
|
375
|
-
this.autoSaveCounter++;
|
|
376
|
-
this.save(slotId, getPayload(), {
|
|
377
|
-
type: 'auto',
|
|
378
|
-
label: `Auto Save ${this.autoSaveCounter}`,
|
|
379
|
-
location: getLocation(),
|
|
380
|
-
});
|
|
381
|
-
}, this.config.autoSave.intervalMs);
|
|
382
|
-
}
|
|
383
|
-
/** Stop auto-save */
|
|
384
|
-
stopAutoSave() {
|
|
385
|
-
if (this.autoSaveTimer) {
|
|
386
|
-
clearInterval(this.autoSaveTimer);
|
|
387
|
-
this.autoSaveTimer = null;
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
/** Quick save (overwriting the single quick save slot) */
|
|
391
|
-
quickSave(payload, location) {
|
|
392
|
-
return this.save('quicksave', payload, { type: 'quick', label: 'Quick Save', location });
|
|
393
|
-
}
|
|
394
|
-
/** Quick load */
|
|
395
|
-
quickLoad() {
|
|
396
|
-
return this.load('quicksave');
|
|
397
|
-
}
|
|
398
|
-
/* ── Cloud Sync ─────────────────────────────────────────────── */
|
|
399
|
-
/** Sync local saves to cloud (stub — needs actual endpoint) */
|
|
400
|
-
async syncToCloud() {
|
|
401
|
-
if (!this.config.cloud.enabled) {
|
|
402
|
-
return { synced: [], conflicts: [] };
|
|
403
|
-
}
|
|
404
|
-
const synced = [];
|
|
405
|
-
const conflicts = [];
|
|
406
|
-
for (const [slotId, data] of this.slots) {
|
|
407
|
-
if (!data.meta.cloudSynced) {
|
|
408
|
-
// In production, this would POST to the cloud endpoint
|
|
409
|
-
// Here we simulate a successful sync
|
|
410
|
-
data.meta.cloudSynced = true;
|
|
411
|
-
data.meta.cloudTimestamp = Date.now();
|
|
412
|
-
synced.push(slotId);
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
this.eventBus.emit('save:cloud-sync', { synced, conflicts });
|
|
416
|
-
return { synced, conflicts };
|
|
417
|
-
}
|
|
418
|
-
/** Resolve a cloud sync conflict */
|
|
419
|
-
resolveConflict(conflict, strategy) {
|
|
420
|
-
conflict.resolvedWith = strategy;
|
|
421
|
-
switch (strategy) {
|
|
422
|
-
case 'local-wins':
|
|
423
|
-
return conflict.localMeta;
|
|
424
|
-
case 'remote-wins':
|
|
425
|
-
return conflict.remoteMeta;
|
|
426
|
-
case 'newest-wins':
|
|
427
|
-
return conflict.localMeta.updatedAt >= conflict.remoteMeta.updatedAt
|
|
428
|
-
? conflict.localMeta
|
|
429
|
-
: conflict.remoteMeta;
|
|
430
|
-
default:
|
|
431
|
-
return conflict.localMeta; // merge/prompt fallback
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
/* ── Storage Backend ────────────────────────────────────────── */
|
|
435
|
-
persistSlot(slotId, _data, _meta) {
|
|
436
|
-
switch (this.config.storageBackend) {
|
|
437
|
-
case 'localstorage': {
|
|
438
|
-
const key = `${this.config.storageKey}:${slotId}`;
|
|
439
|
-
try {
|
|
440
|
-
const serialized = JSON.stringify({
|
|
441
|
-
meta: _meta,
|
|
442
|
-
payload: this.slots.get(slotId)?.payload,
|
|
443
|
-
});
|
|
444
|
-
localStorage.setItem(key, serialized);
|
|
445
|
-
}
|
|
446
|
-
catch {
|
|
447
|
-
/* quota exceeded — emit event */
|
|
448
|
-
this.eventBus.emit('save:error', { slotId, error: 'Storage quota exceeded' });
|
|
449
|
-
}
|
|
450
|
-
break;
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
removeFromStorage(slotId) {
|
|
455
|
-
if (this.config.storageBackend === 'localstorage') {
|
|
456
|
-
localStorage.removeItem(`${this.config.storageKey}:${slotId}`);
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
/** Load all slots from storage backend */
|
|
460
|
-
async loadFromStorage() {
|
|
461
|
-
if (this.config.storageBackend === 'localstorage') {
|
|
462
|
-
let count = 0;
|
|
463
|
-
const prefix = `${this.config.storageKey}:`;
|
|
464
|
-
for (let i = 0; i < localStorage.length; i++) {
|
|
465
|
-
const key = localStorage.key(i);
|
|
466
|
-
if (key?.startsWith(prefix)) {
|
|
467
|
-
try {
|
|
468
|
-
const raw = localStorage.getItem(key);
|
|
469
|
-
if (raw) {
|
|
470
|
-
const parsed = JSON.parse(raw);
|
|
471
|
-
this.slots.set(parsed.meta.slotId, parsed);
|
|
472
|
-
count++;
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
catch {
|
|
476
|
-
/* corrupt entry — skip */
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
return count;
|
|
481
|
-
}
|
|
482
|
-
return 0;
|
|
483
|
-
}
|
|
484
|
-
/** Export all saves as a downloadable blob */
|
|
485
|
-
exportAll() {
|
|
486
|
-
const all = Array.from(this.slots.values());
|
|
487
|
-
const json = JSON.stringify(all);
|
|
488
|
-
return new Blob([json], { type: 'application/json' });
|
|
489
|
-
}
|
|
490
|
-
/** Import saves from a blob */
|
|
491
|
-
async importAll(blob) {
|
|
492
|
-
const text = await blob.text();
|
|
493
|
-
let parsed;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
this.eventBus.emit("save:loaded", { slotId });
|
|
296
|
+
return { payload, meta: { ...data.meta }, migrated };
|
|
297
|
+
}
|
|
298
|
+
/** Delete a save slot */
|
|
299
|
+
delete(slotId) {
|
|
300
|
+
const existed = this.slots.delete(slotId);
|
|
301
|
+
if (existed) {
|
|
302
|
+
this.removeFromStorage(slotId);
|
|
303
|
+
this.eventBus.emit("save:deleted", { slotId });
|
|
304
|
+
}
|
|
305
|
+
return existed;
|
|
306
|
+
}
|
|
307
|
+
/** List all save slot metadata (sorted by updatedAt desc) */
|
|
308
|
+
listSlots() {
|
|
309
|
+
return Array.from(this.slots.values()).map((s) => ({ ...s.meta })).sort((a, b) => b.updatedAt - a.updatedAt);
|
|
310
|
+
}
|
|
311
|
+
/** Get slot metadata without loading payload */
|
|
312
|
+
getSlotMeta(slotId) {
|
|
313
|
+
const data = this.slots.get(slotId);
|
|
314
|
+
return data ? { ...data.meta } : null;
|
|
315
|
+
}
|
|
316
|
+
/** Check if a slot exists */
|
|
317
|
+
hasSlot(slotId) {
|
|
318
|
+
return this.slots.has(slotId);
|
|
319
|
+
}
|
|
320
|
+
/** Start auto-save timer */
|
|
321
|
+
startAutoSave(getPayload, getLocation) {
|
|
322
|
+
if (!this.config.autoSave.enabled) {
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
this.stopAutoSave();
|
|
326
|
+
this.autoSaveTimer = setInterval(() => {
|
|
327
|
+
if (this.config.autoSave.requireSafeState && !this.safeToSave) {
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
const slotId = `auto-${this.autoSaveCounter % this.config.autoSave.maxAutoSaves}`;
|
|
331
|
+
this.autoSaveCounter++;
|
|
332
|
+
this.save(slotId, getPayload(), {
|
|
333
|
+
type: "auto",
|
|
334
|
+
label: `Auto Save ${this.autoSaveCounter}`,
|
|
335
|
+
location: getLocation()
|
|
336
|
+
});
|
|
337
|
+
}, this.config.autoSave.intervalMs);
|
|
338
|
+
}
|
|
339
|
+
/** Stop auto-save */
|
|
340
|
+
stopAutoSave() {
|
|
341
|
+
if (this.autoSaveTimer) {
|
|
342
|
+
clearInterval(this.autoSaveTimer);
|
|
343
|
+
this.autoSaveTimer = null;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
/** Quick save (overwriting the single quick save slot) */
|
|
347
|
+
quickSave(payload, location) {
|
|
348
|
+
return this.save("quicksave", payload, { type: "quick", label: "Quick Save", location });
|
|
349
|
+
}
|
|
350
|
+
/** Quick load */
|
|
351
|
+
quickLoad() {
|
|
352
|
+
return this.load("quicksave");
|
|
353
|
+
}
|
|
354
|
+
/* ── Cloud Sync ─────────────────────────────────────────────── */
|
|
355
|
+
/** Sync local saves to cloud (stub — needs actual endpoint) */
|
|
356
|
+
async syncToCloud() {
|
|
357
|
+
if (!this.config.cloud.enabled) {
|
|
358
|
+
return { synced: [], conflicts: [] };
|
|
359
|
+
}
|
|
360
|
+
const synced = [];
|
|
361
|
+
const conflicts = [];
|
|
362
|
+
for (const [slotId, data] of this.slots) {
|
|
363
|
+
if (!data.meta.cloudSynced) {
|
|
364
|
+
data.meta.cloudSynced = true;
|
|
365
|
+
data.meta.cloudTimestamp = Date.now();
|
|
366
|
+
synced.push(slotId);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
this.eventBus.emit("save:cloud-sync", { synced, conflicts });
|
|
370
|
+
return { synced, conflicts };
|
|
371
|
+
}
|
|
372
|
+
/** Resolve a cloud sync conflict */
|
|
373
|
+
resolveConflict(conflict, strategy) {
|
|
374
|
+
conflict.resolvedWith = strategy;
|
|
375
|
+
switch (strategy) {
|
|
376
|
+
case "local-wins":
|
|
377
|
+
return conflict.localMeta;
|
|
378
|
+
case "remote-wins":
|
|
379
|
+
return conflict.remoteMeta;
|
|
380
|
+
case "newest-wins":
|
|
381
|
+
return conflict.localMeta.updatedAt >= conflict.remoteMeta.updatedAt ? conflict.localMeta : conflict.remoteMeta;
|
|
382
|
+
default:
|
|
383
|
+
return conflict.localMeta;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
/* ── Storage Backend ────────────────────────────────────────── */
|
|
387
|
+
persistSlot(slotId, _data, _meta) {
|
|
388
|
+
switch (this.config.storageBackend) {
|
|
389
|
+
case "localstorage": {
|
|
390
|
+
const key = `${this.config.storageKey}:${slotId}`;
|
|
494
391
|
try {
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
392
|
+
const serialized = JSON.stringify({
|
|
393
|
+
meta: _meta,
|
|
394
|
+
payload: this.slots.get(slotId)?.payload
|
|
395
|
+
});
|
|
396
|
+
localStorage.setItem(key, serialized);
|
|
397
|
+
} catch {
|
|
398
|
+
this.eventBus.emit("save:error", { slotId, error: "Storage quota exceeded" });
|
|
502
399
|
}
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
400
|
+
break;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
removeFromStorage(slotId) {
|
|
405
|
+
if (this.config.storageBackend === "localstorage") {
|
|
406
|
+
localStorage.removeItem(`${this.config.storageKey}:${slotId}`);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
/** Load all slots from storage backend */
|
|
410
|
+
async loadFromStorage() {
|
|
411
|
+
if (this.config.storageBackend === "localstorage") {
|
|
412
|
+
let count = 0;
|
|
413
|
+
const prefix = `${this.config.storageKey}:`;
|
|
414
|
+
for (let i = 0; i < localStorage.length; i++) {
|
|
415
|
+
const key = localStorage.key(i);
|
|
416
|
+
if (key?.startsWith(prefix)) {
|
|
417
|
+
try {
|
|
418
|
+
const raw = localStorage.getItem(key);
|
|
419
|
+
if (raw) {
|
|
420
|
+
const parsed = JSON.parse(raw);
|
|
421
|
+
this.slots.set(parsed.meta.slotId, parsed);
|
|
422
|
+
count++;
|
|
509
423
|
}
|
|
424
|
+
} catch {
|
|
425
|
+
}
|
|
510
426
|
}
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
427
|
+
}
|
|
428
|
+
return count;
|
|
429
|
+
}
|
|
430
|
+
return 0;
|
|
431
|
+
}
|
|
432
|
+
/** Export all saves as a downloadable blob */
|
|
433
|
+
exportAll() {
|
|
434
|
+
const all = Array.from(this.slots.values());
|
|
435
|
+
const json = JSON.stringify(all);
|
|
436
|
+
return new Blob([json], { type: "application/json" });
|
|
437
|
+
}
|
|
438
|
+
/** Import saves from a blob */
|
|
439
|
+
async importAll(blob) {
|
|
440
|
+
const text = await blob.text();
|
|
441
|
+
let parsed;
|
|
442
|
+
try {
|
|
443
|
+
parsed = JSON.parse(text);
|
|
444
|
+
} catch {
|
|
445
|
+
return 0;
|
|
446
|
+
}
|
|
447
|
+
if (!Array.isArray(parsed)) {
|
|
448
|
+
return 0;
|
|
449
|
+
}
|
|
450
|
+
let count = 0;
|
|
451
|
+
for (const entry of parsed) {
|
|
452
|
+
if (entry && typeof entry === "object" && "meta" in entry && "payload" in entry) {
|
|
453
|
+
const saveData = entry;
|
|
454
|
+
this.slots.set(saveData.meta.slotId, saveData);
|
|
455
|
+
count++;
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
return count;
|
|
459
|
+
}
|
|
460
|
+
getConfig() {
|
|
461
|
+
return this.config;
|
|
462
|
+
}
|
|
463
|
+
getMigrationEngine() {
|
|
464
|
+
return this.migrationEngine;
|
|
465
|
+
}
|
|
466
|
+
destroy() {
|
|
467
|
+
this.stopAutoSave();
|
|
468
|
+
}
|
|
522
469
|
}
|
|
523
|
-
|
|
524
470
|
exports.DEFAULT_SAVE_CONFIG = DEFAULT_SAVE_CONFIG;
|
|
525
471
|
exports.MigrationEngine = MigrationEngine;
|
|
526
472
|
exports.SaveSystem = SaveSystem;
|