@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.
Files changed (434) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/accessibility/Accessibility.js +152 -165
  3. package/dist/cjs/ai/AI.js +292 -294
  4. package/dist/cjs/ai/BehaviorTree.js +1029 -1113
  5. package/dist/cjs/ai/StateMachine.js +694 -756
  6. package/dist/cjs/animation/Animation.js +232 -241
  7. package/dist/cjs/audio/AudioAdvanced.js +221 -236
  8. package/dist/cjs/audio/AudioBridge.js +441 -435
  9. package/dist/cjs/audio/AudioManager.js +242 -259
  10. package/dist/cjs/build-cloud/BuildOrchestration.js +1059 -1098
  11. package/dist/cjs/build-cloud/GodotBuildCloud.js +641 -670
  12. package/dist/cjs/build-cloud/UnityBuildCloud.js +563 -610
  13. package/dist/cjs/build-cloud/UnrealBuildCloud.js +610 -635
  14. package/dist/cjs/core/EventBus.js +51 -56
  15. package/dist/cjs/core/GameClock.js +62 -66
  16. package/dist/cjs/core/GameConfig.js +72 -79
  17. package/dist/cjs/core/GameLoop.js +80 -89
  18. package/dist/cjs/core/ServiceLocator.js +61 -65
  19. package/dist/cjs/core/Validation.js +72 -82
  20. package/dist/cjs/core/math.js +108 -112
  21. package/dist/cjs/devtools/DevTools.js +542 -563
  22. package/dist/cjs/devtools/DeveloperExperience.js +521 -559
  23. package/dist/cjs/devtools/GameplayAnalytics.js +636 -646
  24. package/dist/cjs/dialogue/DialogueSystem.js +984 -986
  25. package/dist/cjs/docs/DocGenerator.js +339 -364
  26. package/dist/cjs/ecs/World.js +355 -371
  27. package/dist/cjs/editor/AchievementEditor.js +580 -636
  28. package/dist/cjs/editor/AdvancedEditor.js +184 -191
  29. package/dist/cjs/editor/AnimationRetargeting.js +696 -741
  30. package/dist/cjs/editor/AssetBrowser.js +1072 -1160
  31. package/dist/cjs/editor/AssetManager.js +187 -192
  32. package/dist/cjs/editor/ConsolePro.js +971 -1061
  33. package/dist/cjs/editor/CraftingEditor.js +680 -730
  34. package/dist/cjs/editor/DebugTools.js +187 -185
  35. package/dist/cjs/editor/DialogueSystem.js +844 -901
  36. package/dist/cjs/editor/LeaderboardSystem.js +429 -483
  37. package/dist/cjs/editor/NiceGameEditor.js +1903 -1201
  38. package/dist/cjs/editor/PrefabSystem.js +772 -838
  39. package/dist/cjs/editor/ProfilerPanel.js +649 -700
  40. package/dist/cjs/editor/QuestEditor.js +792 -839
  41. package/dist/cjs/editor/ReplaySystem.js +585 -634
  42. package/dist/cjs/editor/SceneEditor.js +176 -200
  43. package/dist/cjs/editor/ScreenshotMode.js +621 -688
  44. package/dist/cjs/editor/ShaderGraph.js +1556 -1582
  45. package/dist/cjs/editor/TimelineEditor.js +715 -778
  46. package/dist/cjs/editor/UndoRedoPro.js +830 -904
  47. package/dist/cjs/editor/VRARMode.js +582 -645
  48. package/dist/cjs/engine/NiceGameEngine.js +141 -164
  49. package/dist/cjs/engine/SaveSystem.js +441 -495
  50. package/dist/cjs/enterprise/Enterprise.js +254 -261
  51. package/dist/cjs/export/BevyExporter.js +927 -967
  52. package/dist/cjs/export/CocosExporter.js +644 -673
  53. package/dist/cjs/export/Construct3Exporter.js +783 -794
  54. package/dist/cjs/export/DefoldExporter.js +1028 -1069
  55. package/dist/cjs/export/GDevelopExporter.js +674 -708
  56. package/dist/cjs/export/GameMakerExporter.js +791 -805
  57. package/dist/cjs/export/GodotExporter.js +1003 -1045
  58. package/dist/cjs/export/MinecraftBedrockExporter.js +573 -578
  59. package/dist/cjs/export/MonoGameExporter.js +1265 -1293
  60. package/dist/cjs/export/Pico8Exporter.js +766 -812
  61. package/dist/cjs/export/PlatformExporter.js +188 -206
  62. package/dist/cjs/export/RPGMakerExporter.js +860 -879
  63. package/dist/cjs/export/RobloxExporter.js +883 -919
  64. package/dist/cjs/export/Solar2DExporter.js +1218 -1256
  65. package/dist/cjs/export/ThreeJSExporter.js +1006 -1073
  66. package/dist/cjs/export/Tic80Exporter.js +1210 -1267
  67. package/dist/cjs/export/UnityExporter.js +1116 -1131
  68. package/dist/cjs/export/UnrealExporter.js +889 -919
  69. package/dist/cjs/export/WebExporter.js +931 -970
  70. package/dist/cjs/export/index.js +42 -65
  71. package/dist/cjs/godot-integration/GodotAssetLibrary.js +659 -692
  72. package/dist/cjs/godot-integration/GodotImport.js +929 -1027
  73. package/dist/cjs/godot-integration/GodotLiveLink.js +915 -945
  74. package/dist/cjs/godot-integration/components/GodotProjectBrowser.js +911 -611
  75. package/dist/cjs/i18n/I18n.js +860 -900
  76. package/dist/cjs/i18n/useTranslation.js +84 -89
  77. package/dist/cjs/import/AsepriteImporter.js +658 -716
  78. package/dist/cjs/import/DragonBonesImporter.js +437 -461
  79. package/dist/cjs/import/GameMakerImporter.js +511 -521
  80. package/dist/cjs/import/GodotSceneImporter.js +788 -822
  81. package/dist/cjs/import/LDtkImporter.js +436 -454
  82. package/dist/cjs/import/Live2DImporter.js +497 -518
  83. package/dist/cjs/import/NdgFormat.js +424 -457
  84. package/dist/cjs/import/OgmoImporter.js +466 -493
  85. package/dist/cjs/import/RPGMakerImporter.js +451 -477
  86. package/dist/cjs/import/SceneImporter.js +378 -423
  87. package/dist/cjs/import/SpineImporter.js +511 -546
  88. package/dist/cjs/import/SpriterImporter.js +590 -613
  89. package/dist/cjs/import/TiledMapImporter.js +811 -846
  90. package/dist/cjs/import/UnitySceneImporter.js +687 -703
  91. package/dist/cjs/import/index.js +206 -251
  92. package/dist/cjs/index.js +275 -278
  93. package/dist/cjs/input/GamepadNavigation.js +185 -205
  94. package/dist/cjs/input/InputManager.js +397 -421
  95. package/dist/cjs/input/useGamepads.js +70 -81
  96. package/dist/cjs/integration/IconSprite.js +129 -256
  97. package/dist/cjs/inventory/InventorySystem.js +920 -995
  98. package/dist/cjs/kids/KidMode.js +997 -1022
  99. package/dist/cjs/kids/KidTools.js +570 -594
  100. package/dist/cjs/monetization/Monetization.js +170 -177
  101. package/dist/cjs/multiplayer/LocalMultiplayer.js +287 -287
  102. package/dist/cjs/multiplayer/MiniGameTypes.js +49 -59
  103. package/dist/cjs/native-engine/AnimationSystem.js +731 -806
  104. package/dist/cjs/native-engine/AssetPipeline.js +454 -515
  105. package/dist/cjs/native-engine/AudioEngine.js +763 -804
  106. package/dist/cjs/native-engine/InputSystem.js +1075 -1145
  107. package/dist/cjs/native-engine/NetworkingSystem.js +733 -793
  108. package/dist/cjs/native-engine/PhysicsEngine.js +583 -607
  109. package/dist/cjs/native-engine/RenderingEngine.js +302 -350
  110. package/dist/cjs/native-engine/SceneGraph.js +769 -808
  111. package/dist/cjs/network/MultiplayerTransport.js +97 -132
  112. package/dist/cjs/network/Networking.js +549 -564
  113. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/AbortController.js +21 -29
  114. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/AccessTokenHttpClient.js +40 -48
  115. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/DefaultHttpClient.js +35 -43
  116. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/DefaultReconnectPolicy.js +10 -15
  117. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/Errors.js +103 -135
  118. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/FetchHttpClient.js +131 -158
  119. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HandshakeProtocol.js +39 -53
  120. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HeaderNames.js +5 -8
  121. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HttpClient.js +40 -48
  122. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HttpConnection.js +494 -572
  123. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HubConnection.js +826 -953
  124. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HubConnectionBuilder.js +125 -146
  125. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/IHubProtocol.js +13 -23
  126. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/ILogger.js +11 -25
  127. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/ITransport.js +13 -24
  128. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/JsonHubProtocol.js +108 -121
  129. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/Loggers.js +10 -14
  130. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/LongPollingTransport.js +150 -185
  131. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/MessageBuffer.js +158 -196
  132. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/ServerSentEventsTransport.js +90 -105
  133. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/Subject.js +30 -35
  134. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/TextMessageFormat.js +16 -21
  135. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/Utils.js +215 -248
  136. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/WebSocketTransport.js +135 -157
  137. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/XhrHttpClient.js +76 -85
  138. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/index.js +24 -27
  139. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/pkg-version.js +3 -4
  140. package/dist/cjs/pathfinding/Pathfinding.js +245 -263
  141. package/dist/cjs/performance/AssetStreaming.js +561 -635
  142. package/dist/cjs/performance/BenchmarkSuite.js +283 -311
  143. package/dist/cjs/performance/DeltaCompression.js +467 -526
  144. package/dist/cjs/performance/DeterministicPhysics.js +450 -498
  145. package/dist/cjs/performance/ECSOptimization.js +644 -695
  146. package/dist/cjs/performance/GameSaveSystem.js +509 -556
  147. package/dist/cjs/performance/HotReload.js +447 -500
  148. package/dist/cjs/performance/InputRecording.js +511 -561
  149. package/dist/cjs/performance/InterestManagement.js +453 -500
  150. package/dist/cjs/performance/LocalizationRuntime.js +376 -423
  151. package/dist/cjs/performance/MemoryManagement.js +410 -470
  152. package/dist/cjs/performance/ModSupport.js +445 -496
  153. package/dist/cjs/performance/MultiThreadedPhysics.js +400 -443
  154. package/dist/cjs/performance/NetworkPrediction.js +424 -482
  155. package/dist/cjs/performance/ObjectPooling.js +569 -617
  156. package/dist/cjs/performance/Performance.js +174 -190
  157. package/dist/cjs/performance/PerformanceAdvanced.js +614 -637
  158. package/dist/cjs/performance/WebGPURenderer.js +656 -683
  159. package/dist/cjs/physics/PhysicsAdvanced.js +345 -379
  160. package/dist/cjs/physics/PhysicsEngine2D.js +391 -427
  161. package/dist/cjs/plugins/PluginSDK.js +432 -466
  162. package/dist/cjs/plugins/PluginTestKit.js +307 -330
  163. package/dist/cjs/procedural/Procedural.js +243 -254
  164. package/dist/cjs/procedural/WorldBuilding.js +297 -314
  165. package/dist/cjs/quest/QuestSystem.js +975 -932
  166. package/dist/cjs/release/MobileExport.js +157 -163
  167. package/dist/cjs/release/Release.js +225 -238
  168. package/dist/cjs/rendering/Camera2D.js +121 -124
  169. package/dist/cjs/rendering/Renderer2D.js +321 -335
  170. package/dist/cjs/rendering/WebGPURenderPipeline.js +632 -651
  171. package/dist/cjs/runtime3d/Runtime3D.js +359 -378
  172. package/dist/cjs/runtime3d/SceneEditor3D.js +252 -263
  173. package/dist/cjs/scene/SceneManager.js +177 -193
  174. package/dist/cjs/scripting/GraphToAST.js +574 -547
  175. package/dist/cjs/scripting/LanguageExporter.js +254 -279
  176. package/dist/cjs/scripting/NodeGraph.js +546 -570
  177. package/dist/cjs/scripting/ScriptAST.js +31 -39
  178. package/dist/cjs/scripting/VisualScripting2.js +1016 -1065
  179. package/dist/cjs/scripting/exporters/CSharpExporter.js +464 -496
  180. package/dist/cjs/scripting/exporters/GDScriptExporter.js +390 -442
  181. package/dist/cjs/scripting/exporters/LuaExporter.js +406 -447
  182. package/dist/cjs/scripting/exporters/PythonExporter.js +484 -549
  183. package/dist/cjs/scripting/exporters/RustExporter.js +459 -512
  184. package/dist/cjs/scripting/exporters/TypeScriptExporter.js +505 -556
  185. package/dist/cjs/social/Social.js +72 -80
  186. package/dist/cjs/systems/LightingSystem.js +844 -931
  187. package/dist/cjs/systems/ParticleSystem2.js +1447 -1451
  188. package/dist/cjs/systems/PhysicsDebugSystem.js +1070 -1141
  189. package/dist/cjs/systems/TerrainSystem.js +985 -1098
  190. package/dist/cjs/templates/ActionTemplates.js +296 -309
  191. package/dist/cjs/templates/FightingTemplate.js +417 -463
  192. package/dist/cjs/templates/MetroidvaniaTemplate.js +353 -405
  193. package/dist/cjs/templates/PartyTemplates.js +190 -202
  194. package/dist/cjs/templates/PuzzleTemplates.js +245 -261
  195. package/dist/cjs/templates/RPGTemplates.js +160 -178
  196. package/dist/cjs/templates/SportsTemplates.js +237 -250
  197. package/dist/cjs/templates/StrategyTemplates.js +143 -153
  198. package/dist/cjs/templates/SurvivalTemplate.js +336 -380
  199. package/dist/cjs/templates/WaveDefense.js +499 -526
  200. package/dist/cjs/tilemap/Tilemap.js +207 -214
  201. package/dist/cjs/tutorials/TutorialBranching.js +396 -417
  202. package/dist/cjs/tutorials/TutorialEngine.js +888 -931
  203. package/dist/cjs/tutorials/TutorialOverlay.js +602 -640
  204. package/dist/cjs/tutorials/content/Tutorials_T05_T08.js +787 -809
  205. package/dist/cjs/tutorials/content/Tutorials_T09_T11.js +736 -756
  206. package/dist/cjs/tutorials/content/Tutorials_T12_T15.js +754 -778
  207. package/dist/cjs/ui/GameUI.js +295 -312
  208. package/dist/cjs/unity-integration/UnityAssetStore.js +700 -741
  209. package/dist/cjs/unity-integration/UnityImport.js +1066 -1176
  210. package/dist/cjs/unity-integration/UnityLiveLink.js +934 -981
  211. package/dist/cjs/unity-integration/components/UnityAssetStoreBrowser.js +1233 -757
  212. package/dist/cjs/unity-integration/components/UnityProjectBrowser.js +1240 -768
  213. package/dist/cjs/unreal-integration/UnrealImport.js +391 -412
  214. package/dist/cjs/unreal-integration/UnrealLiveLink.js +1102 -1137
  215. package/dist/cjs/unreal-integration/UnrealMarketplace.js +436 -473
  216. package/dist/cjs/unreal-integration/components/UnrealProjectBrowser.js +1150 -767
  217. package/dist/cjs/xr/ARVR.js +167 -175
  218. package/dist/esm/accessibility/Accessibility.js +160 -164
  219. package/dist/esm/ai/AI.js +310 -293
  220. package/dist/esm/ai/BehaviorTree.js +1057 -1112
  221. package/dist/esm/ai/StateMachine.js +709 -755
  222. package/dist/esm/animation/Animation.js +237 -240
  223. package/dist/esm/audio/AudioAdvanced.js +239 -235
  224. package/dist/esm/audio/AudioBridge.js +448 -434
  225. package/dist/esm/audio/AudioManager.js +243 -258
  226. package/dist/esm/build-cloud/BuildOrchestration.js +1071 -1097
  227. package/dist/esm/build-cloud/GodotBuildCloud.js +647 -669
  228. package/dist/esm/build-cloud/UnityBuildCloud.js +571 -609
  229. package/dist/esm/build-cloud/UnrealBuildCloud.js +615 -634
  230. package/dist/esm/core/EventBus.js +52 -55
  231. package/dist/esm/core/GameClock.js +63 -65
  232. package/dist/esm/core/GameConfig.js +77 -78
  233. package/dist/esm/core/GameLoop.js +81 -88
  234. package/dist/esm/core/ServiceLocator.js +63 -64
  235. package/dist/esm/core/Validation.js +82 -81
  236. package/dist/esm/core/math.js +109 -111
  237. package/dist/esm/devtools/DevTools.js +546 -562
  238. package/dist/esm/devtools/DeveloperExperience.js +535 -558
  239. package/dist/esm/devtools/GameplayAnalytics.js +647 -645
  240. package/dist/esm/dialogue/DialogueSystem.js +998 -985
  241. package/dist/esm/docs/DocGenerator.js +342 -363
  242. package/dist/esm/ecs/World.js +358 -370
  243. package/dist/esm/editor/AchievementEditor.js +584 -635
  244. package/dist/esm/editor/AdvancedEditor.js +191 -190
  245. package/dist/esm/editor/AnimationRetargeting.js +700 -740
  246. package/dist/esm/editor/AssetBrowser.js +1078 -1159
  247. package/dist/esm/editor/AssetManager.js +188 -191
  248. package/dist/esm/editor/ConsolePro.js +977 -1060
  249. package/dist/esm/editor/CraftingEditor.js +684 -729
  250. package/dist/esm/editor/DebugTools.js +194 -184
  251. package/dist/esm/editor/DialogueSystem.js +849 -900
  252. package/dist/esm/editor/LeaderboardSystem.js +433 -482
  253. package/dist/esm/editor/NiceGameEditor.js +1908 -1200
  254. package/dist/esm/editor/PrefabSystem.js +777 -837
  255. package/dist/esm/editor/ProfilerPanel.js +654 -699
  256. package/dist/esm/editor/QuestEditor.js +795 -838
  257. package/dist/esm/editor/ReplaySystem.js +591 -633
  258. package/dist/esm/editor/SceneEditor.js +189 -199
  259. package/dist/esm/editor/ScreenshotMode.js +628 -687
  260. package/dist/esm/editor/ShaderGraph.js +1565 -1581
  261. package/dist/esm/editor/TimelineEditor.js +733 -777
  262. package/dist/esm/editor/UndoRedoPro.js +835 -903
  263. package/dist/esm/editor/VRARMode.js +586 -644
  264. package/dist/esm/engine/NiceGameEngine.js +142 -163
  265. package/dist/esm/engine/SaveSystem.js +447 -494
  266. package/dist/esm/enterprise/Enterprise.js +265 -260
  267. package/dist/esm/export/BevyExporter.js +929 -966
  268. package/dist/esm/export/CocosExporter.js +646 -672
  269. package/dist/esm/export/Construct3Exporter.js +785 -793
  270. package/dist/esm/export/DefoldExporter.js +1030 -1068
  271. package/dist/esm/export/GDevelopExporter.js +676 -707
  272. package/dist/esm/export/GameMakerExporter.js +793 -804
  273. package/dist/esm/export/GodotExporter.js +1004 -1044
  274. package/dist/esm/export/MinecraftBedrockExporter.js +575 -577
  275. package/dist/esm/export/MonoGameExporter.js +1267 -1292
  276. package/dist/esm/export/Pico8Exporter.js +768 -811
  277. package/dist/esm/export/PlatformExporter.js +193 -205
  278. package/dist/esm/export/RPGMakerExporter.js +862 -878
  279. package/dist/esm/export/RobloxExporter.js +885 -918
  280. package/dist/esm/export/Solar2DExporter.js +1220 -1255
  281. package/dist/esm/export/ThreeJSExporter.js +1007 -1072
  282. package/dist/esm/export/Tic80Exporter.js +1212 -1266
  283. package/dist/esm/export/UnityExporter.js +1117 -1130
  284. package/dist/esm/export/UnrealExporter.js +891 -918
  285. package/dist/esm/export/WebExporter.js +933 -969
  286. package/dist/esm/export/index.js +86 -71
  287. package/dist/esm/godot-integration/GodotAssetLibrary.js +663 -691
  288. package/dist/esm/godot-integration/GodotImport.js +935 -1026
  289. package/dist/esm/godot-integration/GodotLiveLink.js +918 -944
  290. package/dist/esm/godot-integration/components/GodotProjectBrowser.js +912 -610
  291. package/dist/esm/i18n/I18n.js +871 -899
  292. package/dist/esm/i18n/useTranslation.js +88 -88
  293. package/dist/esm/import/AsepriteImporter.js +637 -715
  294. package/dist/esm/import/DragonBonesImporter.js +417 -460
  295. package/dist/esm/import/GameMakerImporter.js +491 -520
  296. package/dist/esm/import/GodotSceneImporter.js +767 -821
  297. package/dist/esm/import/LDtkImporter.js +415 -453
  298. package/dist/esm/import/Live2DImporter.js +477 -517
  299. package/dist/esm/import/NdgFormat.js +410 -456
  300. package/dist/esm/import/OgmoImporter.js +446 -492
  301. package/dist/esm/import/RPGMakerImporter.js +431 -476
  302. package/dist/esm/import/SceneImporter.js +385 -422
  303. package/dist/esm/import/SpineImporter.js +491 -545
  304. package/dist/esm/import/SpriterImporter.js +570 -612
  305. package/dist/esm/import/TiledMapImporter.js +790 -845
  306. package/dist/esm/import/UnitySceneImporter.js +666 -702
  307. package/dist/esm/import/index.js +247 -258
  308. package/dist/esm/index.js +1332 -188
  309. package/dist/esm/input/GamepadNavigation.js +187 -204
  310. package/dist/esm/input/InputManager.js +401 -420
  311. package/dist/esm/input/useGamepads.js +72 -80
  312. package/dist/esm/integration/IconSprite.js +143 -255
  313. package/dist/esm/inventory/InventorySystem.js +925 -994
  314. package/dist/esm/kids/KidMode.js +1003 -1021
  315. package/dist/esm/kids/KidTools.js +573 -593
  316. package/dist/esm/monetization/Monetization.js +180 -176
  317. package/dist/esm/multiplayer/LocalMultiplayer.js +290 -286
  318. package/dist/esm/multiplayer/MiniGameTypes.js +58 -58
  319. package/dist/esm/native-engine/AnimationSystem.js +735 -805
  320. package/dist/esm/native-engine/AssetPipeline.js +456 -514
  321. package/dist/esm/native-engine/AudioEngine.js +765 -803
  322. package/dist/esm/native-engine/InputSystem.js +1079 -1144
  323. package/dist/esm/native-engine/NetworkingSystem.js +740 -792
  324. package/dist/esm/native-engine/PhysicsEngine.js +585 -606
  325. package/dist/esm/native-engine/RenderingEngine.js +304 -349
  326. package/dist/esm/native-engine/SceneGraph.js +773 -807
  327. package/dist/esm/network/MultiplayerTransport.js +99 -131
  328. package/dist/esm/network/Networking.js +556 -563
  329. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/AbortController.js +22 -28
  330. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/AccessTokenHttpClient.js +41 -47
  331. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/DefaultHttpClient.js +36 -42
  332. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/DefaultReconnectPolicy.js +11 -14
  333. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/Errors.js +111 -134
  334. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/FetchHttpClient.js +132 -157
  335. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HandshakeProtocol.js +40 -52
  336. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HeaderNames.js +6 -7
  337. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HttpClient.js +42 -47
  338. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HttpConnection.js +496 -571
  339. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HubConnection.js +828 -952
  340. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HubConnectionBuilder.js +126 -145
  341. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/IHubProtocol.js +14 -23
  342. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/ILogger.js +12 -25
  343. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/ITransport.js +15 -24
  344. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/JsonHubProtocol.js +109 -120
  345. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/Loggers.js +11 -13
  346. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/LongPollingTransport.js +151 -184
  347. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/MessageBuffer.js +159 -195
  348. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/ServerSentEventsTransport.js +91 -104
  349. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/Subject.js +31 -34
  350. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/TextMessageFormat.js +17 -20
  351. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/Utils.js +230 -248
  352. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/WebSocketTransport.js +136 -156
  353. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/XhrHttpClient.js +77 -84
  354. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/index.js +31 -12
  355. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/pkg-version.js +4 -3
  356. package/dist/esm/pathfinding/Pathfinding.js +249 -262
  357. package/dist/esm/performance/AssetStreaming.js +567 -634
  358. package/dist/esm/performance/BenchmarkSuite.js +285 -310
  359. package/dist/esm/performance/DeltaCompression.js +478 -525
  360. package/dist/esm/performance/DeterministicPhysics.js +479 -497
  361. package/dist/esm/performance/ECSOptimization.js +653 -694
  362. package/dist/esm/performance/GameSaveSystem.js +515 -555
  363. package/dist/esm/performance/HotReload.js +454 -499
  364. package/dist/esm/performance/InputRecording.js +520 -560
  365. package/dist/esm/performance/InterestManagement.js +460 -499
  366. package/dist/esm/performance/LocalizationRuntime.js +382 -422
  367. package/dist/esm/performance/MemoryManagement.js +415 -469
  368. package/dist/esm/performance/ModSupport.js +455 -495
  369. package/dist/esm/performance/MultiThreadedPhysics.js +408 -442
  370. package/dist/esm/performance/NetworkPrediction.js +436 -481
  371. package/dist/esm/performance/ObjectPooling.js +582 -616
  372. package/dist/esm/performance/Performance.js +182 -189
  373. package/dist/esm/performance/PerformanceAdvanced.js +621 -636
  374. package/dist/esm/performance/WebGPURenderer.js +660 -682
  375. package/dist/esm/physics/PhysicsAdvanced.js +359 -378
  376. package/dist/esm/physics/PhysicsEngine2D.js +393 -426
  377. package/dist/esm/plugins/PluginSDK.js +435 -465
  378. package/dist/esm/plugins/PluginTestKit.js +315 -329
  379. package/dist/esm/procedural/Procedural.js +248 -253
  380. package/dist/esm/procedural/WorldBuilding.js +316 -313
  381. package/dist/esm/quest/QuestSystem.js +982 -931
  382. package/dist/esm/release/MobileExport.js +163 -162
  383. package/dist/esm/release/Release.js +234 -237
  384. package/dist/esm/rendering/Camera2D.js +122 -123
  385. package/dist/esm/rendering/Renderer2D.js +323 -334
  386. package/dist/esm/rendering/WebGPURenderPipeline.js +647 -650
  387. package/dist/esm/runtime3d/Runtime3D.js +368 -377
  388. package/dist/esm/runtime3d/SceneEditor3D.js +268 -262
  389. package/dist/esm/scene/SceneManager.js +178 -192
  390. package/dist/esm/scripting/GraphToAST.js +576 -546
  391. package/dist/esm/scripting/LanguageExporter.js +263 -278
  392. package/dist/esm/scripting/NodeGraph.js +550 -569
  393. package/dist/esm/scripting/ScriptAST.js +45 -38
  394. package/dist/esm/scripting/VisualScripting2.js +1025 -1064
  395. package/dist/esm/scripting/exporters/CSharpExporter.js +465 -495
  396. package/dist/esm/scripting/exporters/GDScriptExporter.js +391 -441
  397. package/dist/esm/scripting/exporters/LuaExporter.js +407 -446
  398. package/dist/esm/scripting/exporters/PythonExporter.js +485 -548
  399. package/dist/esm/scripting/exporters/RustExporter.js +460 -511
  400. package/dist/esm/scripting/exporters/TypeScriptExporter.js +506 -555
  401. package/dist/esm/social/Social.js +77 -79
  402. package/dist/esm/systems/LightingSystem.js +855 -930
  403. package/dist/esm/systems/ParticleSystem2.js +1453 -1450
  404. package/dist/esm/systems/PhysicsDebugSystem.js +1078 -1140
  405. package/dist/esm/systems/TerrainSystem.js +996 -1097
  406. package/dist/esm/templates/ActionTemplates.js +307 -308
  407. package/dist/esm/templates/FightingTemplate.js +439 -462
  408. package/dist/esm/templates/MetroidvaniaTemplate.js +391 -404
  409. package/dist/esm/templates/PartyTemplates.js +206 -201
  410. package/dist/esm/templates/PuzzleTemplates.js +260 -260
  411. package/dist/esm/templates/RPGTemplates.js +172 -177
  412. package/dist/esm/templates/SportsTemplates.js +251 -249
  413. package/dist/esm/templates/StrategyTemplates.js +158 -152
  414. package/dist/esm/templates/SurvivalTemplate.js +367 -379
  415. package/dist/esm/templates/WaveDefense.js +501 -525
  416. package/dist/esm/tilemap/Tilemap.js +209 -213
  417. package/dist/esm/tutorials/TutorialBranching.js +399 -416
  418. package/dist/esm/tutorials/TutorialEngine.js +893 -930
  419. package/dist/esm/tutorials/TutorialOverlay.js +603 -639
  420. package/dist/esm/tutorials/content/Tutorials_T05_T08.js +792 -808
  421. package/dist/esm/tutorials/content/Tutorials_T09_T11.js +740 -755
  422. package/dist/esm/tutorials/content/Tutorials_T12_T15.js +759 -777
  423. package/dist/esm/ui/GameUI.js +296 -311
  424. package/dist/esm/unity-integration/UnityAssetStore.js +704 -740
  425. package/dist/esm/unity-integration/UnityImport.js +1071 -1175
  426. package/dist/esm/unity-integration/UnityLiveLink.js +938 -980
  427. package/dist/esm/unity-integration/components/UnityAssetStoreBrowser.js +1234 -756
  428. package/dist/esm/unity-integration/components/UnityProjectBrowser.js +1241 -767
  429. package/dist/esm/unreal-integration/UnrealImport.js +395 -411
  430. package/dist/esm/unreal-integration/UnrealLiveLink.js +1105 -1136
  431. package/dist/esm/unreal-integration/UnrealMarketplace.js +442 -472
  432. package/dist/esm/unreal-integration/components/UnrealProjectBrowser.js +1151 -766
  433. package/dist/esm/xr/ARVR.js +181 -174
  434. package/package.json +7 -12
@@ -1,1184 +1,1103 @@
1
- /**
2
- * @file AssetBrowser.ts
3
- * @description Advanced Asset Browser with thumbnails, search, tags, favorites
4
- * PRO-1.4: Professional Editor Features
5
- *
6
- * Features:
7
- * - Thumbnail generation for all asset types
8
- * - Advanced search with filters
9
- * - Tag management and filtering
10
- * - Favorites system
11
- * - Recent assets tracking
12
- * - Collections/folders
13
- * - Asset metadata editing
14
- * - Drag & drop support
15
- * - Import/export
16
- * - Asset dependencies
17
- * - Quick preview
18
- */
19
1
  const DEFAULT_IMPORT_OPTIONS = {
20
- folder: '/',
21
- generateThumbnail: true,
22
- thumbnailSize: 128,
23
- autoTag: true,
24
- preserveStructure: false,
25
- overwriteExisting: false,
26
- optimize: false,
27
- maxImageSize: 4096,
28
- imageQuality: 0.9,
2
+ folder: "/",
3
+ generateThumbnail: true,
4
+ thumbnailSize: 128,
5
+ autoTag: true,
6
+ preserveStructure: false,
7
+ overwriteExisting: false,
8
+ optimize: false,
9
+ maxImageSize: 4096,
10
+ imageQuality: 0.9
29
11
  };
30
12
  const DEFAULT_BROWSER_CONFIG = {
31
- viewMode: 'grid',
32
- sortMode: 'name-asc',
33
- showHiddenFiles: false,
34
- showSystemFolders: false,
35
- thumbnailSize: 'medium',
36
- showDetails: true,
37
- groupByType: false,
38
- recentCount: 20,
39
- importOptions: DEFAULT_IMPORT_OPTIONS,
13
+ viewMode: "grid",
14
+ sortMode: "name-asc",
15
+ showHiddenFiles: false,
16
+ showSystemFolders: false,
17
+ thumbnailSize: "medium",
18
+ showDetails: true,
19
+ groupByType: false,
20
+ recentCount: 20,
21
+ importOptions: DEFAULT_IMPORT_OPTIONS
40
22
  };
41
- // ============================================================
42
- // Thumbnail Generator
43
- // ============================================================
44
23
  class ThumbnailGenerator {
45
- constructor() {
46
- this.audioContext = null;
47
- this.canvas = document.createElement('canvas');
48
- this.ctx = this.canvas.getContext('2d');
49
- }
50
- async generateThumbnail(file, type, size = 128) {
51
- this.canvas.width = size;
52
- this.canvas.height = size;
53
- switch (type) {
54
- case 'image':
55
- case 'sprite':
56
- case 'spritesheet':
57
- return this.generateImageThumbnail(file, size);
58
- case 'audio':
59
- case 'music':
60
- case 'sfx':
61
- return this.generateAudioThumbnail(file, size);
62
- case 'video':
63
- return this.generateVideoThumbnail(file, size);
64
- case 'model':
65
- return this.generateModelThumbnail(size);
66
- case 'material':
67
- return this.generateMaterialThumbnail(size);
68
- case 'shader':
69
- return this.generateShaderThumbnail(size);
70
- case 'script':
71
- return this.generateScriptThumbnail(size);
72
- case 'scene':
73
- return this.generateSceneThumbnail(size);
74
- case 'prefab':
75
- return this.generatePrefabThumbnail(size);
76
- case 'font':
77
- return this.generateFontThumbnail(file, size);
78
- case 'particle':
79
- return this.generateParticleThumbnail(size);
80
- case 'json':
81
- return this.generateJsonThumbnail(size);
82
- default:
83
- return this.generateGenericThumbnail(size);
84
- }
85
- }
86
- async generateImageThumbnail(file, size) {
87
- return new Promise((resolve) => {
88
- const img = new Image();
89
- const url = URL.createObjectURL(file);
90
- img.onload = () => {
91
- const scale = Math.min(size / img.width, size / img.height, 1);
92
- const width = Math.round(img.width * scale);
93
- const height = Math.round(img.height * scale);
94
- this.canvas.width = width;
95
- this.canvas.height = height;
96
- // Draw checkerboard for transparency
97
- this.drawCheckerboard(width, height);
98
- this.ctx.drawImage(img, 0, 0, width, height);
99
- URL.revokeObjectURL(url);
100
- resolve({
101
- dataUrl: this.canvas.toDataURL('image/png'),
102
- width,
103
- height,
104
- generated: Date.now(),
105
- });
106
- };
107
- img.onerror = () => {
108
- URL.revokeObjectURL(url);
109
- resolve(this.generateGenericThumbnail(size, 'image'));
110
- };
111
- img.src = url;
24
+ constructor() {
25
+ this.audioContext = null;
26
+ this.canvas = document.createElement("canvas");
27
+ this.ctx = this.canvas.getContext("2d");
28
+ }
29
+ async generateThumbnail(file, type, size = 128) {
30
+ this.canvas.width = size;
31
+ this.canvas.height = size;
32
+ switch (type) {
33
+ case "image":
34
+ case "sprite":
35
+ case "spritesheet":
36
+ return this.generateImageThumbnail(file, size);
37
+ case "audio":
38
+ case "music":
39
+ case "sfx":
40
+ return this.generateAudioThumbnail(file, size);
41
+ case "video":
42
+ return this.generateVideoThumbnail(file, size);
43
+ case "model":
44
+ return this.generateModelThumbnail(size);
45
+ case "material":
46
+ return this.generateMaterialThumbnail(size);
47
+ case "shader":
48
+ return this.generateShaderThumbnail(size);
49
+ case "script":
50
+ return this.generateScriptThumbnail(size);
51
+ case "scene":
52
+ return this.generateSceneThumbnail(size);
53
+ case "prefab":
54
+ return this.generatePrefabThumbnail(size);
55
+ case "font":
56
+ return this.generateFontThumbnail(file, size);
57
+ case "particle":
58
+ return this.generateParticleThumbnail(size);
59
+ case "json":
60
+ return this.generateJsonThumbnail(size);
61
+ default:
62
+ return this.generateGenericThumbnail(size);
63
+ }
64
+ }
65
+ async generateImageThumbnail(file, size) {
66
+ return new Promise((resolve) => {
67
+ const img = new Image();
68
+ const url = URL.createObjectURL(file);
69
+ img.onload = () => {
70
+ const scale = Math.min(size / img.width, size / img.height, 1);
71
+ const width = Math.round(img.width * scale);
72
+ const height = Math.round(img.height * scale);
73
+ this.canvas.width = width;
74
+ this.canvas.height = height;
75
+ this.drawCheckerboard(width, height);
76
+ this.ctx.drawImage(img, 0, 0, width, height);
77
+ URL.revokeObjectURL(url);
78
+ resolve({
79
+ dataUrl: this.canvas.toDataURL("image/png"),
80
+ width,
81
+ height,
82
+ generated: Date.now()
112
83
  });
113
- }
114
- async generateAudioThumbnail(file, size) {
115
- try {
116
- // Initialize audio context if needed
117
- if (!this.audioContext) {
118
- this.audioContext = new AudioContext();
84
+ };
85
+ img.onerror = () => {
86
+ URL.revokeObjectURL(url);
87
+ resolve(this.generateGenericThumbnail(size, "image"));
88
+ };
89
+ img.src = url;
90
+ });
91
+ }
92
+ async generateAudioThumbnail(file, size) {
93
+ try {
94
+ if (!this.audioContext) {
95
+ this.audioContext = new AudioContext();
96
+ }
97
+ const arrayBuffer = await file.arrayBuffer();
98
+ const audioBuffer = await this.audioContext.decodeAudioData(arrayBuffer);
99
+ this.canvas.width = size;
100
+ this.canvas.height = size;
101
+ this.ctx.fillStyle = "#1a1a2e";
102
+ this.ctx.fillRect(0, 0, size, size);
103
+ const data = audioBuffer.getChannelData(0);
104
+ const step = Math.ceil(data.length / size);
105
+ const amp = size / 4;
106
+ this.ctx.strokeStyle = "#4FC3F7";
107
+ this.ctx.lineWidth = 1;
108
+ this.ctx.beginPath();
109
+ for (let i = 0; i < size; i++) {
110
+ let min = 1;
111
+ let max = -1;
112
+ for (let j = 0; j < step; j++) {
113
+ const sample = data[i * step + j];
114
+ if (sample !== void 0) {
115
+ if (sample < min) {
116
+ min = sample;
119
117
  }
120
- const arrayBuffer = await file.arrayBuffer();
121
- const audioBuffer = await this.audioContext.decodeAudioData(arrayBuffer);
122
- // Draw waveform
123
- this.canvas.width = size;
124
- this.canvas.height = size;
125
- this.ctx.fillStyle = '#1a1a2e';
126
- this.ctx.fillRect(0, 0, size, size);
127
- const data = audioBuffer.getChannelData(0);
128
- const step = Math.ceil(data.length / size);
129
- const amp = size / 4;
130
- this.ctx.strokeStyle = '#4FC3F7';
131
- this.ctx.lineWidth = 1;
132
- this.ctx.beginPath();
133
- for (let i = 0; i < size; i++) {
134
- let min = 1;
135
- let max = -1;
136
- for (let j = 0; j < step; j++) {
137
- const sample = data[i * step + j];
138
- if (sample !== undefined) {
139
- if (sample < min) {
140
- min = sample;
141
- }
142
- if (sample > max) {
143
- max = sample;
144
- }
145
- }
146
- }
147
- const y1 = size / 2 + min * amp;
148
- const y2 = size / 2 + max * amp;
149
- this.ctx.moveTo(i, y1);
150
- this.ctx.lineTo(i, y2);
118
+ if (sample > max) {
119
+ max = sample;
151
120
  }
152
- this.ctx.stroke();
153
- // Draw duration
154
- const duration = audioBuffer.duration;
155
- this.ctx.fillStyle = 'white';
156
- this.ctx.font = '10px sans-serif';
157
- this.ctx.fillText(this.formatDuration(duration), 4, size - 4);
158
- return {
159
- dataUrl: this.canvas.toDataURL('image/png'),
160
- width: size,
161
- height: size,
162
- generated: Date.now(),
163
- };
164
- }
165
- catch {
166
- return this.generateGenericThumbnail(size, 'audio');
121
+ }
167
122
  }
168
- }
169
- async generateVideoThumbnail(file, size) {
170
- return new Promise((resolve) => {
171
- const video = document.createElement('video');
172
- const url = URL.createObjectURL(file);
173
- video.onloadeddata = () => {
174
- // Seek to 1 second or 10% of duration
175
- video.currentTime = Math.min(1, video.duration * 0.1);
176
- };
177
- video.onseeked = () => {
178
- const scale = Math.min(size / video.videoWidth, size / video.videoHeight);
179
- const width = Math.round(video.videoWidth * scale);
180
- const height = Math.round(video.videoHeight * scale);
181
- this.canvas.width = width;
182
- this.canvas.height = height;
183
- this.ctx.drawImage(video, 0, 0, width, height);
184
- // Draw play icon overlay
185
- this.drawPlayIcon(width, height);
186
- // Draw duration
187
- this.ctx.fillStyle = 'rgba(0,0,0,0.7)';
188
- this.ctx.fillRect(width - 40, height - 16, 36, 14);
189
- this.ctx.fillStyle = 'white';
190
- this.ctx.font = '10px sans-serif';
191
- this.ctx.fillText(this.formatDuration(video.duration), width - 38, height - 5);
192
- URL.revokeObjectURL(url);
193
- resolve({
194
- dataUrl: this.canvas.toDataURL('image/png'),
195
- width,
196
- height,
197
- generated: Date.now(),
198
- });
199
- };
200
- video.onerror = () => {
201
- URL.revokeObjectURL(url);
202
- resolve(this.generateGenericThumbnail(size, 'video'));
203
- };
204
- video.src = url;
123
+ const y1 = size / 2 + min * amp;
124
+ const y2 = size / 2 + max * amp;
125
+ this.ctx.moveTo(i, y1);
126
+ this.ctx.lineTo(i, y2);
127
+ }
128
+ this.ctx.stroke();
129
+ const duration = audioBuffer.duration;
130
+ this.ctx.fillStyle = "white";
131
+ this.ctx.font = "10px sans-serif";
132
+ this.ctx.fillText(this.formatDuration(duration), 4, size - 4);
133
+ return {
134
+ dataUrl: this.canvas.toDataURL("image/png"),
135
+ width: size,
136
+ height: size,
137
+ generated: Date.now()
138
+ };
139
+ } catch {
140
+ return this.generateGenericThumbnail(size, "audio");
141
+ }
142
+ }
143
+ async generateVideoThumbnail(file, size) {
144
+ return new Promise((resolve) => {
145
+ const video = document.createElement("video");
146
+ const url = URL.createObjectURL(file);
147
+ video.onloadeddata = () => {
148
+ video.currentTime = Math.min(1, video.duration * 0.1);
149
+ };
150
+ video.onseeked = () => {
151
+ const scale = Math.min(size / video.videoWidth, size / video.videoHeight);
152
+ const width = Math.round(video.videoWidth * scale);
153
+ const height = Math.round(video.videoHeight * scale);
154
+ this.canvas.width = width;
155
+ this.canvas.height = height;
156
+ this.ctx.drawImage(video, 0, 0, width, height);
157
+ this.drawPlayIcon(width, height);
158
+ this.ctx.fillStyle = "rgba(0,0,0,0.7)";
159
+ this.ctx.fillRect(width - 40, height - 16, 36, 14);
160
+ this.ctx.fillStyle = "white";
161
+ this.ctx.font = "10px sans-serif";
162
+ this.ctx.fillText(this.formatDuration(video.duration), width - 38, height - 5);
163
+ URL.revokeObjectURL(url);
164
+ resolve({
165
+ dataUrl: this.canvas.toDataURL("image/png"),
166
+ width,
167
+ height,
168
+ generated: Date.now()
205
169
  });
206
- }
207
- generateModelThumbnail(size) {
208
- this.canvas.width = size;
209
- this.canvas.height = size;
210
- // Draw a simple 3D cube wireframe
211
- this.ctx.fillStyle = '#1a1a2e';
212
- this.ctx.fillRect(0, 0, size, size);
213
- const cx = size / 2;
214
- const cy = size / 2;
215
- const s = size * 0.3;
216
- this.ctx.strokeStyle = '#64B5F6';
217
- this.ctx.lineWidth = 2;
218
- // Front face
219
- this.ctx.strokeRect(cx - s / 2, cy - s / 2 + s * 0.2, s, s);
220
- // Back face connections
221
- this.ctx.beginPath();
222
- this.ctx.moveTo(cx - s / 2, cy - s / 2 + s * 0.2);
223
- this.ctx.lineTo(cx - s / 2 + s * 0.3, cy - s / 2 - s * 0.1);
224
- this.ctx.moveTo(cx + s / 2, cy - s / 2 + s * 0.2);
225
- this.ctx.lineTo(cx + s / 2 + s * 0.3, cy - s / 2 - s * 0.1);
226
- this.ctx.moveTo(cx + s / 2, cy + s / 2 + s * 0.2);
227
- this.ctx.lineTo(cx + s / 2 + s * 0.3, cy + s / 2 - s * 0.1);
228
- this.ctx.stroke();
229
- // Back face
230
- this.ctx.strokeRect(cx - s / 2 + s * 0.3, cy - s / 2 - s * 0.1, s, s);
231
- return {
232
- dataUrl: this.canvas.toDataURL('image/png'),
233
- width: size,
234
- height: size,
235
- generated: Date.now(),
236
- };
237
- }
238
- generateMaterialThumbnail(size) {
239
- this.canvas.width = size;
240
- this.canvas.height = size;
241
- // Draw a sphere-like gradient
242
- const gradient = this.ctx.createRadialGradient(size * 0.4, size * 0.4, 0, size / 2, size / 2, size * 0.4);
243
- gradient.addColorStop(0, '#ffffff');
244
- gradient.addColorStop(0.5, '#4FC3F7');
245
- gradient.addColorStop(1, '#1a1a2e');
246
- this.ctx.fillStyle = '#1a1a2e';
247
- this.ctx.fillRect(0, 0, size, size);
248
- this.ctx.beginPath();
249
- this.ctx.arc(size / 2, size / 2, size * 0.35, 0, Math.PI * 2);
250
- this.ctx.fillStyle = gradient;
251
- this.ctx.fill();
252
- return {
253
- dataUrl: this.canvas.toDataURL('image/png'),
254
- width: size,
255
- height: size,
256
- generated: Date.now(),
257
- };
258
- }
259
- generateShaderThumbnail(size) {
260
- this.canvas.width = size;
261
- this.canvas.height = size;
262
- // Draw shader-like pattern
263
- for (let y = 0; y < size; y++) {
264
- for (let x = 0; x < size; x++) {
265
- const r = Math.sin(x * 0.1 + y * 0.05) * 127 + 128;
266
- const g = Math.cos(y * 0.1) * 127 + 128;
267
- const b = Math.sin((x + y) * 0.05) * 127 + 128;
268
- this.ctx.fillStyle = `rgb(${r},${g},${b})`;
269
- this.ctx.fillRect(x, y, 1, 1);
270
- }
271
- }
272
- return {
273
- dataUrl: this.canvas.toDataURL('image/png'),
274
- width: size,
275
- height: size,
276
- generated: Date.now(),
277
- };
278
- }
279
- generateScriptThumbnail(size) {
280
- this.canvas.width = size;
281
- this.canvas.height = size;
282
- this.ctx.fillStyle = '#1e1e2e';
283
- this.ctx.fillRect(0, 0, size, size);
284
- // Draw code-like lines
285
- const lineHeight = 8;
286
- const colors = ['#f38ba8', '#89b4fa', '#a6e3a1', '#f9e2af', '#cdd6f4'];
287
- for (let i = 0; i < size / lineHeight; i++) {
288
- const y = i * lineHeight + 4;
289
- const indent = (i % 4) * 8;
290
- const width = Math.random() * (size * 0.6) + size * 0.2 - indent;
291
- this.ctx.fillStyle = colors[i % colors.length];
292
- this.ctx.fillRect(8 + indent, y, width, 4);
293
- }
294
- return {
295
- dataUrl: this.canvas.toDataURL('image/png'),
296
- width: size,
297
- height: size,
298
- generated: Date.now(),
299
- };
300
- }
301
- generateSceneThumbnail(size) {
302
- this.canvas.width = size;
303
- this.canvas.height = size;
304
- // Sky gradient
305
- const skyGradient = this.ctx.createLinearGradient(0, 0, 0, size * 0.6);
306
- skyGradient.addColorStop(0, '#1a1a2e');
307
- skyGradient.addColorStop(1, '#4a4a6e');
308
- this.ctx.fillStyle = skyGradient;
309
- this.ctx.fillRect(0, 0, size, size * 0.6);
310
- // Ground
311
- this.ctx.fillStyle = '#2d5a27';
312
- this.ctx.fillRect(0, size * 0.6, size, size * 0.4);
313
- // Sun
314
- this.ctx.beginPath();
315
- this.ctx.arc(size * 0.75, size * 0.25, size * 0.1, 0, Math.PI * 2);
316
- this.ctx.fillStyle = '#f9e2af';
317
- this.ctx.fill();
318
- // Simple tree
319
- this.ctx.fillStyle = '#1a3d1a';
320
- this.ctx.beginPath();
321
- this.ctx.moveTo(size * 0.3, size * 0.4);
322
- this.ctx.lineTo(size * 0.4, size * 0.6);
323
- this.ctx.lineTo(size * 0.2, size * 0.6);
324
- this.ctx.closePath();
325
- this.ctx.fill();
326
- return {
327
- dataUrl: this.canvas.toDataURL('image/png'),
328
- width: size,
329
- height: size,
330
- generated: Date.now(),
331
- };
332
- }
333
- generatePrefabThumbnail(size) {
334
- this.canvas.width = size;
335
- this.canvas.height = size;
336
- this.ctx.fillStyle = '#1a1a2e';
337
- this.ctx.fillRect(0, 0, size, size);
338
- // Draw prefab icon (cube with link)
339
- const cx = size / 2;
340
- const cy = size / 2;
341
- const s = size * 0.3;
342
- this.ctx.fillStyle = '#89b4fa';
343
- this.ctx.fillRect(cx - s / 2, cy - s / 2, s, s);
344
- this.ctx.strokeStyle = '#1a1a2e';
345
- this.ctx.lineWidth = 2;
346
- this.ctx.strokeRect(cx - s / 2, cy - s / 2, s, s);
347
- // Link icon
348
- this.ctx.fillStyle = '#a6e3a1';
349
- this.ctx.beginPath();
350
- this.ctx.arc(cx + s / 2, cy + s / 2, s * 0.2, 0, Math.PI * 2);
351
- this.ctx.fill();
352
- return {
353
- dataUrl: this.canvas.toDataURL('image/png'),
354
- width: size,
355
- height: size,
356
- generated: Date.now(),
357
- };
358
- }
359
- async generateFontThumbnail(file, size) {
360
- this.canvas.width = size;
361
- this.canvas.height = size;
362
- this.ctx.fillStyle = '#1a1a2e';
363
- this.ctx.fillRect(0, 0, size, size);
364
- try {
365
- const fontData = await file.arrayBuffer();
366
- const font = new FontFace('preview-font', fontData);
367
- await font.load();
368
- document.fonts.add(font);
369
- this.ctx.fillStyle = '#cdd6f4';
370
- this.ctx.font = `${size * 0.6}px preview-font`;
371
- this.ctx.textAlign = 'center';
372
- this.ctx.textBaseline = 'middle';
373
- this.ctx.fillText('Aa', size / 2, size / 2);
374
- }
375
- catch {
376
- // Fallback
377
- this.ctx.fillStyle = '#cdd6f4';
378
- this.ctx.font = `${size * 0.4}px serif`;
379
- this.ctx.textAlign = 'center';
380
- this.ctx.textBaseline = 'middle';
381
- this.ctx.fillText('Aa', size / 2, size / 2);
382
- }
383
- return {
384
- dataUrl: this.canvas.toDataURL('image/png'),
385
- width: size,
386
- height: size,
387
- generated: Date.now(),
388
- };
389
- }
390
- generateParticleThumbnail(size) {
391
- this.canvas.width = size;
392
- this.canvas.height = size;
393
- this.ctx.fillStyle = '#1a1a2e';
394
- this.ctx.fillRect(0, 0, size, size);
395
- // Draw particles
396
- const particleCount = 30;
397
- for (let i = 0; i < particleCount; i++) {
398
- const x = size / 2 + (Math.random() - 0.5) * size * 0.6;
399
- const y = size / 2 + (Math.random() - 0.5) * size * 0.6;
400
- const r = Math.random() * 4 + 2;
401
- const alpha = Math.random() * 0.5 + 0.5;
402
- this.ctx.beginPath();
403
- this.ctx.arc(x, y, r, 0, Math.PI * 2);
404
- this.ctx.fillStyle = `rgba(255, 180, 100, ${alpha})`;
405
- this.ctx.fill();
406
- }
407
- return {
408
- dataUrl: this.canvas.toDataURL('image/png'),
409
- width: size,
410
- height: size,
411
- generated: Date.now(),
412
- };
413
- }
414
- generateJsonThumbnail(size) {
415
- this.canvas.width = size;
416
- this.canvas.height = size;
417
- this.ctx.fillStyle = '#1a1a2e';
418
- this.ctx.fillRect(0, 0, size, size);
419
- // Draw JSON brackets
420
- this.ctx.fillStyle = '#f9e2af';
421
- this.ctx.font = `bold ${size * 0.5}px monospace`;
422
- this.ctx.textAlign = 'center';
423
- this.ctx.textBaseline = 'middle';
424
- this.ctx.fillText('{ }', size / 2, size / 2);
425
- return {
426
- dataUrl: this.canvas.toDataURL('image/png'),
427
- width: size,
428
- height: size,
429
- generated: Date.now(),
430
- };
431
- }
432
- generateGenericThumbnail(size, type) {
433
- this.canvas.width = size;
434
- this.canvas.height = size;
435
- this.ctx.fillStyle = '#1a1a2e';
436
- this.ctx.fillRect(0, 0, size, size);
437
- // Draw file icon
438
- const iconColors = {
439
- image: '#89b4fa',
440
- audio: '#f38ba8',
441
- video: '#a6e3a1',
442
- model: '#f9e2af',
443
- script: '#cba6f7',
444
- };
445
- const color = iconColors[type ?? ''] ?? '#cdd6f4';
446
- // File shape
447
- this.ctx.fillStyle = color;
448
- this.ctx.beginPath();
449
- this.ctx.moveTo(size * 0.25, size * 0.15);
450
- this.ctx.lineTo(size * 0.55, size * 0.15);
451
- this.ctx.lineTo(size * 0.75, size * 0.35);
452
- this.ctx.lineTo(size * 0.75, size * 0.85);
453
- this.ctx.lineTo(size * 0.25, size * 0.85);
454
- this.ctx.closePath();
455
- this.ctx.fill();
456
- // Fold corner
457
- this.ctx.fillStyle = '#1a1a2e';
458
- this.ctx.beginPath();
459
- this.ctx.moveTo(size * 0.55, size * 0.15);
460
- this.ctx.lineTo(size * 0.55, size * 0.35);
461
- this.ctx.lineTo(size * 0.75, size * 0.35);
462
- this.ctx.closePath();
463
- this.ctx.fill();
464
- return {
465
- dataUrl: this.canvas.toDataURL('image/png'),
466
- width: size,
467
- height: size,
468
- generated: Date.now(),
469
- };
470
- }
471
- drawCheckerboard(width, height) {
472
- const checkSize = 8;
473
- for (let y = 0; y < height; y += checkSize) {
474
- for (let x = 0; x < width; x += checkSize) {
475
- this.ctx.fillStyle = ((x + y) / checkSize) % 2 === 0 ? '#ffffff' : '#cccccc';
476
- this.ctx.fillRect(x, y, checkSize, checkSize);
477
- }
478
- }
479
- }
480
- drawPlayIcon(width, height) {
481
- const cx = width / 2;
482
- const cy = height / 2;
483
- const r = Math.min(width, height) * 0.15;
484
- this.ctx.fillStyle = 'rgba(0, 0, 0, 0.5)';
485
- this.ctx.beginPath();
486
- this.ctx.arc(cx, cy, r, 0, Math.PI * 2);
487
- this.ctx.fill();
488
- this.ctx.fillStyle = 'white';
489
- this.ctx.beginPath();
490
- this.ctx.moveTo(cx - r * 0.3, cy - r * 0.5);
491
- this.ctx.lineTo(cx + r * 0.5, cy);
492
- this.ctx.lineTo(cx - r * 0.3, cy + r * 0.5);
493
- this.ctx.closePath();
494
- this.ctx.fill();
495
- }
496
- formatDuration(seconds) {
497
- const mins = Math.floor(seconds / 60);
498
- const secs = Math.floor(seconds % 60);
499
- return `${mins}:${secs.toString().padStart(2, '0')}`;
500
- }
170
+ };
171
+ video.onerror = () => {
172
+ URL.revokeObjectURL(url);
173
+ resolve(this.generateGenericThumbnail(size, "video"));
174
+ };
175
+ video.src = url;
176
+ });
177
+ }
178
+ generateModelThumbnail(size) {
179
+ this.canvas.width = size;
180
+ this.canvas.height = size;
181
+ this.ctx.fillStyle = "#1a1a2e";
182
+ this.ctx.fillRect(0, 0, size, size);
183
+ const cx = size / 2;
184
+ const cy = size / 2;
185
+ const s = size * 0.3;
186
+ this.ctx.strokeStyle = "#64B5F6";
187
+ this.ctx.lineWidth = 2;
188
+ this.ctx.strokeRect(cx - s / 2, cy - s / 2 + s * 0.2, s, s);
189
+ this.ctx.beginPath();
190
+ this.ctx.moveTo(cx - s / 2, cy - s / 2 + s * 0.2);
191
+ this.ctx.lineTo(cx - s / 2 + s * 0.3, cy - s / 2 - s * 0.1);
192
+ this.ctx.moveTo(cx + s / 2, cy - s / 2 + s * 0.2);
193
+ this.ctx.lineTo(cx + s / 2 + s * 0.3, cy - s / 2 - s * 0.1);
194
+ this.ctx.moveTo(cx + s / 2, cy + s / 2 + s * 0.2);
195
+ this.ctx.lineTo(cx + s / 2 + s * 0.3, cy + s / 2 - s * 0.1);
196
+ this.ctx.stroke();
197
+ this.ctx.strokeRect(cx - s / 2 + s * 0.3, cy - s / 2 - s * 0.1, s, s);
198
+ return {
199
+ dataUrl: this.canvas.toDataURL("image/png"),
200
+ width: size,
201
+ height: size,
202
+ generated: Date.now()
203
+ };
204
+ }
205
+ generateMaterialThumbnail(size) {
206
+ this.canvas.width = size;
207
+ this.canvas.height = size;
208
+ const gradient = this.ctx.createRadialGradient(
209
+ size * 0.4,
210
+ size * 0.4,
211
+ 0,
212
+ size / 2,
213
+ size / 2,
214
+ size * 0.4
215
+ );
216
+ gradient.addColorStop(0, "#ffffff");
217
+ gradient.addColorStop(0.5, "#4FC3F7");
218
+ gradient.addColorStop(1, "#1a1a2e");
219
+ this.ctx.fillStyle = "#1a1a2e";
220
+ this.ctx.fillRect(0, 0, size, size);
221
+ this.ctx.beginPath();
222
+ this.ctx.arc(size / 2, size / 2, size * 0.35, 0, Math.PI * 2);
223
+ this.ctx.fillStyle = gradient;
224
+ this.ctx.fill();
225
+ return {
226
+ dataUrl: this.canvas.toDataURL("image/png"),
227
+ width: size,
228
+ height: size,
229
+ generated: Date.now()
230
+ };
231
+ }
232
+ generateShaderThumbnail(size) {
233
+ this.canvas.width = size;
234
+ this.canvas.height = size;
235
+ for (let y = 0; y < size; y++) {
236
+ for (let x = 0; x < size; x++) {
237
+ const r = Math.sin(x * 0.1 + y * 0.05) * 127 + 128;
238
+ const g = Math.cos(y * 0.1) * 127 + 128;
239
+ const b = Math.sin((x + y) * 0.05) * 127 + 128;
240
+ this.ctx.fillStyle = `rgb(${r},${g},${b})`;
241
+ this.ctx.fillRect(x, y, 1, 1);
242
+ }
243
+ }
244
+ return {
245
+ dataUrl: this.canvas.toDataURL("image/png"),
246
+ width: size,
247
+ height: size,
248
+ generated: Date.now()
249
+ };
250
+ }
251
+ generateScriptThumbnail(size) {
252
+ this.canvas.width = size;
253
+ this.canvas.height = size;
254
+ this.ctx.fillStyle = "#1e1e2e";
255
+ this.ctx.fillRect(0, 0, size, size);
256
+ const lineHeight = 8;
257
+ const colors = ["#f38ba8", "#89b4fa", "#a6e3a1", "#f9e2af", "#cdd6f4"];
258
+ for (let i = 0; i < size / lineHeight; i++) {
259
+ const y = i * lineHeight + 4;
260
+ const indent = i % 4 * 8;
261
+ const width = Math.random() * (size * 0.6) + size * 0.2 - indent;
262
+ this.ctx.fillStyle = colors[i % colors.length];
263
+ this.ctx.fillRect(8 + indent, y, width, 4);
264
+ }
265
+ return {
266
+ dataUrl: this.canvas.toDataURL("image/png"),
267
+ width: size,
268
+ height: size,
269
+ generated: Date.now()
270
+ };
271
+ }
272
+ generateSceneThumbnail(size) {
273
+ this.canvas.width = size;
274
+ this.canvas.height = size;
275
+ const skyGradient = this.ctx.createLinearGradient(0, 0, 0, size * 0.6);
276
+ skyGradient.addColorStop(0, "#1a1a2e");
277
+ skyGradient.addColorStop(1, "#4a4a6e");
278
+ this.ctx.fillStyle = skyGradient;
279
+ this.ctx.fillRect(0, 0, size, size * 0.6);
280
+ this.ctx.fillStyle = "#2d5a27";
281
+ this.ctx.fillRect(0, size * 0.6, size, size * 0.4);
282
+ this.ctx.beginPath();
283
+ this.ctx.arc(size * 0.75, size * 0.25, size * 0.1, 0, Math.PI * 2);
284
+ this.ctx.fillStyle = "#f9e2af";
285
+ this.ctx.fill();
286
+ this.ctx.fillStyle = "#1a3d1a";
287
+ this.ctx.beginPath();
288
+ this.ctx.moveTo(size * 0.3, size * 0.4);
289
+ this.ctx.lineTo(size * 0.4, size * 0.6);
290
+ this.ctx.lineTo(size * 0.2, size * 0.6);
291
+ this.ctx.closePath();
292
+ this.ctx.fill();
293
+ return {
294
+ dataUrl: this.canvas.toDataURL("image/png"),
295
+ width: size,
296
+ height: size,
297
+ generated: Date.now()
298
+ };
299
+ }
300
+ generatePrefabThumbnail(size) {
301
+ this.canvas.width = size;
302
+ this.canvas.height = size;
303
+ this.ctx.fillStyle = "#1a1a2e";
304
+ this.ctx.fillRect(0, 0, size, size);
305
+ const cx = size / 2;
306
+ const cy = size / 2;
307
+ const s = size * 0.3;
308
+ this.ctx.fillStyle = "#89b4fa";
309
+ this.ctx.fillRect(cx - s / 2, cy - s / 2, s, s);
310
+ this.ctx.strokeStyle = "#1a1a2e";
311
+ this.ctx.lineWidth = 2;
312
+ this.ctx.strokeRect(cx - s / 2, cy - s / 2, s, s);
313
+ this.ctx.fillStyle = "#a6e3a1";
314
+ this.ctx.beginPath();
315
+ this.ctx.arc(cx + s / 2, cy + s / 2, s * 0.2, 0, Math.PI * 2);
316
+ this.ctx.fill();
317
+ return {
318
+ dataUrl: this.canvas.toDataURL("image/png"),
319
+ width: size,
320
+ height: size,
321
+ generated: Date.now()
322
+ };
323
+ }
324
+ async generateFontThumbnail(file, size) {
325
+ this.canvas.width = size;
326
+ this.canvas.height = size;
327
+ this.ctx.fillStyle = "#1a1a2e";
328
+ this.ctx.fillRect(0, 0, size, size);
329
+ try {
330
+ const fontData = await file.arrayBuffer();
331
+ const font = new FontFace("preview-font", fontData);
332
+ await font.load();
333
+ document.fonts.add(font);
334
+ this.ctx.fillStyle = "#cdd6f4";
335
+ this.ctx.font = `${size * 0.6}px preview-font`;
336
+ this.ctx.textAlign = "center";
337
+ this.ctx.textBaseline = "middle";
338
+ this.ctx.fillText("Aa", size / 2, size / 2);
339
+ } catch {
340
+ this.ctx.fillStyle = "#cdd6f4";
341
+ this.ctx.font = `${size * 0.4}px serif`;
342
+ this.ctx.textAlign = "center";
343
+ this.ctx.textBaseline = "middle";
344
+ this.ctx.fillText("Aa", size / 2, size / 2);
345
+ }
346
+ return {
347
+ dataUrl: this.canvas.toDataURL("image/png"),
348
+ width: size,
349
+ height: size,
350
+ generated: Date.now()
351
+ };
352
+ }
353
+ generateParticleThumbnail(size) {
354
+ this.canvas.width = size;
355
+ this.canvas.height = size;
356
+ this.ctx.fillStyle = "#1a1a2e";
357
+ this.ctx.fillRect(0, 0, size, size);
358
+ const particleCount = 30;
359
+ for (let i = 0; i < particleCount; i++) {
360
+ const x = size / 2 + (Math.random() - 0.5) * size * 0.6;
361
+ const y = size / 2 + (Math.random() - 0.5) * size * 0.6;
362
+ const r = Math.random() * 4 + 2;
363
+ const alpha = Math.random() * 0.5 + 0.5;
364
+ this.ctx.beginPath();
365
+ this.ctx.arc(x, y, r, 0, Math.PI * 2);
366
+ this.ctx.fillStyle = `rgba(255, 180, 100, ${alpha})`;
367
+ this.ctx.fill();
368
+ }
369
+ return {
370
+ dataUrl: this.canvas.toDataURL("image/png"),
371
+ width: size,
372
+ height: size,
373
+ generated: Date.now()
374
+ };
375
+ }
376
+ generateJsonThumbnail(size) {
377
+ this.canvas.width = size;
378
+ this.canvas.height = size;
379
+ this.ctx.fillStyle = "#1a1a2e";
380
+ this.ctx.fillRect(0, 0, size, size);
381
+ this.ctx.fillStyle = "#f9e2af";
382
+ this.ctx.font = `bold ${size * 0.5}px monospace`;
383
+ this.ctx.textAlign = "center";
384
+ this.ctx.textBaseline = "middle";
385
+ this.ctx.fillText("{ }", size / 2, size / 2);
386
+ return {
387
+ dataUrl: this.canvas.toDataURL("image/png"),
388
+ width: size,
389
+ height: size,
390
+ generated: Date.now()
391
+ };
392
+ }
393
+ generateGenericThumbnail(size, type) {
394
+ this.canvas.width = size;
395
+ this.canvas.height = size;
396
+ this.ctx.fillStyle = "#1a1a2e";
397
+ this.ctx.fillRect(0, 0, size, size);
398
+ const iconColors = {
399
+ image: "#89b4fa",
400
+ audio: "#f38ba8",
401
+ video: "#a6e3a1",
402
+ model: "#f9e2af",
403
+ script: "#cba6f7"
404
+ };
405
+ const color = iconColors[type ?? ""] ?? "#cdd6f4";
406
+ this.ctx.fillStyle = color;
407
+ this.ctx.beginPath();
408
+ this.ctx.moveTo(size * 0.25, size * 0.15);
409
+ this.ctx.lineTo(size * 0.55, size * 0.15);
410
+ this.ctx.lineTo(size * 0.75, size * 0.35);
411
+ this.ctx.lineTo(size * 0.75, size * 0.85);
412
+ this.ctx.lineTo(size * 0.25, size * 0.85);
413
+ this.ctx.closePath();
414
+ this.ctx.fill();
415
+ this.ctx.fillStyle = "#1a1a2e";
416
+ this.ctx.beginPath();
417
+ this.ctx.moveTo(size * 0.55, size * 0.15);
418
+ this.ctx.lineTo(size * 0.55, size * 0.35);
419
+ this.ctx.lineTo(size * 0.75, size * 0.35);
420
+ this.ctx.closePath();
421
+ this.ctx.fill();
422
+ return {
423
+ dataUrl: this.canvas.toDataURL("image/png"),
424
+ width: size,
425
+ height: size,
426
+ generated: Date.now()
427
+ };
428
+ }
429
+ drawCheckerboard(width, height) {
430
+ const checkSize = 8;
431
+ for (let y = 0; y < height; y += checkSize) {
432
+ for (let x = 0; x < width; x += checkSize) {
433
+ this.ctx.fillStyle = (x + y) / checkSize % 2 === 0 ? "#ffffff" : "#cccccc";
434
+ this.ctx.fillRect(x, y, checkSize, checkSize);
435
+ }
436
+ }
437
+ }
438
+ drawPlayIcon(width, height) {
439
+ const cx = width / 2;
440
+ const cy = height / 2;
441
+ const r = Math.min(width, height) * 0.15;
442
+ this.ctx.fillStyle = "rgba(0, 0, 0, 0.5)";
443
+ this.ctx.beginPath();
444
+ this.ctx.arc(cx, cy, r, 0, Math.PI * 2);
445
+ this.ctx.fill();
446
+ this.ctx.fillStyle = "white";
447
+ this.ctx.beginPath();
448
+ this.ctx.moveTo(cx - r * 0.3, cy - r * 0.5);
449
+ this.ctx.lineTo(cx + r * 0.5, cy);
450
+ this.ctx.lineTo(cx - r * 0.3, cy + r * 0.5);
451
+ this.ctx.closePath();
452
+ this.ctx.fill();
453
+ }
454
+ formatDuration(seconds) {
455
+ const mins = Math.floor(seconds / 60);
456
+ const secs = Math.floor(seconds % 60);
457
+ return `${mins}:${secs.toString().padStart(2, "0")}`;
458
+ }
501
459
  }
502
- // ============================================================
503
- // Asset Browser System
504
- // ============================================================
505
460
  class AssetBrowser {
506
- constructor(config) {
507
- this.config = { ...DEFAULT_BROWSER_CONFIG };
508
- this.assets = new Map();
509
- this.folders = new Map();
510
- this.collections = new Map();
511
- this.blobStore = new Map();
512
- // State
513
- this.currentFolderId = 'root';
514
- this.selectedIds = new Set();
515
- this.recentAssetIds = [];
516
- this.allTags = new Set();
517
- if (config) {
518
- this.config = { ...this.config, ...config };
461
+ constructor(config) {
462
+ this.config = { ...DEFAULT_BROWSER_CONFIG };
463
+ this.assets = /* @__PURE__ */ new Map();
464
+ this.folders = /* @__PURE__ */ new Map();
465
+ this.collections = /* @__PURE__ */ new Map();
466
+ this.blobStore = /* @__PURE__ */ new Map();
467
+ this.currentFolderId = "root";
468
+ this.selectedIds = /* @__PURE__ */ new Set();
469
+ this.recentAssetIds = [];
470
+ this.allTags = /* @__PURE__ */ new Set();
471
+ if (config) {
472
+ this.config = { ...this.config, ...config };
473
+ }
474
+ this.thumbnailGenerator = new ThumbnailGenerator();
475
+ this.folders.set("root", {
476
+ id: "root",
477
+ name: "Assets",
478
+ path: "/",
479
+ parentId: null,
480
+ expanded: true,
481
+ children: [],
482
+ assets: [],
483
+ createdAt: Date.now(),
484
+ isSystem: true
485
+ });
486
+ this.createDefaultCollections();
487
+ }
488
+ createDefaultCollections() {
489
+ this.collections.set("favorites", {
490
+ id: "favorites",
491
+ name: "Favorites",
492
+ description: "Your favorite assets",
493
+ icon: "star",
494
+ color: "#f9e2af",
495
+ assetIds: [],
496
+ createdAt: Date.now(),
497
+ isSmartCollection: true,
498
+ smartFilter: { favorites: true }
499
+ });
500
+ this.collections.set("recent", {
501
+ id: "recent",
502
+ name: "Recent",
503
+ description: "Recently used assets",
504
+ icon: "clock",
505
+ color: "#89b4fa",
506
+ assetIds: [],
507
+ createdAt: Date.now(),
508
+ isSmartCollection: true,
509
+ smartFilter: { recent: true }
510
+ });
511
+ this.collections.set("unused", {
512
+ id: "unused",
513
+ name: "Unused",
514
+ description: "Assets not referenced by any scene",
515
+ icon: "box",
516
+ color: "#cdd6f4",
517
+ assetIds: [],
518
+ createdAt: Date.now(),
519
+ isSmartCollection: true,
520
+ smartFilter: { unused: true }
521
+ });
522
+ }
523
+ // ─── Configuration ─────────────────────────────────────
524
+ setConfig(config) {
525
+ this.config = { ...this.config, ...config };
526
+ this.onChange?.();
527
+ }
528
+ getConfig() {
529
+ return { ...this.config };
530
+ }
531
+ // ─── Asset Import ──────────────────────────────────────
532
+ async importFiles(files, options) {
533
+ const opts = { ...this.config.importOptions, ...options };
534
+ const results = [];
535
+ for (const file of Array.from(files)) {
536
+ const asset = await this.importFile(file, opts);
537
+ if (asset) {
538
+ results.push(asset);
539
+ }
540
+ }
541
+ this.onChange?.();
542
+ return results;
543
+ }
544
+ async importFile(file, options) {
545
+ const opts = { ...this.config.importOptions, ...options };
546
+ const type = this.inferAssetType(file);
547
+ const id = `asset_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
548
+ const now = Date.now();
549
+ const folderId = opts.folder === "/" ? "root" : this.findOrCreateFolder(opts.folder);
550
+ const asset = {
551
+ id,
552
+ name: file.name,
553
+ type,
554
+ path: `${this.getFolderPath(folderId)}/${file.name}`,
555
+ size: file.size,
556
+ mimeType: file.type,
557
+ tags: opts.autoTag ? this.autoGenerateTags(file, type) : [],
558
+ description: "",
559
+ author: "",
560
+ license: "",
561
+ version: "1.0.0",
562
+ customProperties: {},
563
+ createdAt: now,
564
+ modifiedAt: now,
565
+ importedAt: now,
566
+ usageCount: 0,
567
+ lastUsedAt: null,
568
+ folderId,
569
+ dependencies: [],
570
+ dependents: [],
571
+ isFavorite: false,
572
+ importSettings: { ...opts }
573
+ };
574
+ if (opts.generateThumbnail) {
575
+ asset.thumbnailGenerating = true;
576
+ const thumbnail = await this.thumbnailGenerator.generateThumbnail(
577
+ file,
578
+ type,
579
+ opts.thumbnailSize
580
+ );
581
+ if (thumbnail) {
582
+ asset.thumbnail = thumbnail;
583
+ }
584
+ asset.thumbnailGenerating = false;
585
+ }
586
+ this.assets.set(id, asset);
587
+ this.blobStore.set(id, file);
588
+ const folder = this.folders.get(folderId);
589
+ if (folder) {
590
+ folder.assets.push(id);
591
+ }
592
+ for (const tag of asset.tags) {
593
+ this.allTags.add(tag);
594
+ }
595
+ return asset;
596
+ }
597
+ inferAssetType(file) {
598
+ const ext = file.name.split(".").pop()?.toLowerCase() ?? "";
599
+ const mime = file.type;
600
+ if (mime.startsWith("image/")) {
601
+ if (file.name.includes("spritesheet") || file.name.includes("atlas")) {
602
+ return "spritesheet";
603
+ }
604
+ return "image";
605
+ }
606
+ if (mime.startsWith("audio/")) {
607
+ if (file.name.includes("music") || file.name.includes("bgm")) {
608
+ return "music";
609
+ }
610
+ if (file.name.includes("sfx") || file.name.includes("effect")) {
611
+ return "sfx";
612
+ }
613
+ return "audio";
614
+ }
615
+ if (mime.startsWith("video/")) {
616
+ return "video";
617
+ }
618
+ const extMap = {
619
+ // Models
620
+ gltf: "model",
621
+ glb: "model",
622
+ obj: "model",
623
+ fbx: "model",
624
+ dae: "model",
625
+ // Materials & Shaders
626
+ mtl: "material",
627
+ mat: "material",
628
+ shader: "shader",
629
+ vert: "shader",
630
+ frag: "shader",
631
+ glsl: "shader",
632
+ // Scripts
633
+ js: "script",
634
+ ts: "script",
635
+ lua: "script",
636
+ // Data
637
+ json: "json",
638
+ ndg: "scene",
639
+ scene: "scene",
640
+ prefab: "prefab",
641
+ anim: "animation",
642
+ // Fonts
643
+ ttf: "font",
644
+ otf: "font",
645
+ woff: "font",
646
+ woff2: "font",
647
+ // Particles
648
+ particle: "particle",
649
+ emitter: "particle",
650
+ // Terrain
651
+ terrain: "terrain",
652
+ heightmap: "terrain",
653
+ // Tilemaps
654
+ tmx: "tilemap",
655
+ tsx: "tilemap",
656
+ ldtk: "tilemap"
657
+ };
658
+ return extMap[ext] ?? "other";
659
+ }
660
+ autoGenerateTags(file, type) {
661
+ const tags = [type];
662
+ const ext = file.name.split(".").pop()?.toLowerCase();
663
+ if (ext) {
664
+ tags.push(ext);
665
+ }
666
+ if (file.size < 10 * 1024) {
667
+ tags.push("small");
668
+ } else if (file.size > 1024 * 1024) {
669
+ tags.push("large");
670
+ }
671
+ const nameLower = file.name.toLowerCase();
672
+ const keywords = [
673
+ "ui",
674
+ "icon",
675
+ "background",
676
+ "player",
677
+ "enemy",
678
+ "item",
679
+ "effect",
680
+ "ambient",
681
+ "loop"
682
+ ];
683
+ for (const keyword of keywords) {
684
+ if (nameLower.includes(keyword)) {
685
+ tags.push(keyword);
686
+ }
687
+ }
688
+ return tags;
689
+ }
690
+ findOrCreateFolder(path) {
691
+ const parts = path.split("/").filter(Boolean);
692
+ let currentFolder = this.folders.get("root");
693
+ let currentPath = "";
694
+ for (const part of parts) {
695
+ currentPath += "/" + part;
696
+ let childFolder;
697
+ for (const childId of currentFolder.children) {
698
+ const child = this.folders.get(childId);
699
+ if (child?.name === part) {
700
+ childFolder = child;
701
+ break;
519
702
  }
520
- this.thumbnailGenerator = new ThumbnailGenerator();
521
- // Create root folder
522
- this.folders.set('root', {
523
- id: 'root',
524
- name: 'Assets',
525
- path: '/',
526
- parentId: null,
527
- expanded: true,
528
- children: [],
529
- assets: [],
530
- createdAt: Date.now(),
531
- isSystem: true,
532
- });
533
- // Create system collections
534
- this.createDefaultCollections();
535
- }
536
- createDefaultCollections() {
537
- this.collections.set('favorites', {
538
- id: 'favorites',
539
- name: 'Favorites',
540
- description: 'Your favorite assets',
541
- icon: 'star',
542
- color: '#f9e2af',
543
- assetIds: [],
544
- createdAt: Date.now(),
545
- isSmartCollection: true,
546
- smartFilter: { favorites: true },
547
- });
548
- this.collections.set('recent', {
549
- id: 'recent',
550
- name: 'Recent',
551
- description: 'Recently used assets',
552
- icon: 'clock',
553
- color: '#89b4fa',
554
- assetIds: [],
555
- createdAt: Date.now(),
556
- isSmartCollection: true,
557
- smartFilter: { recent: true },
558
- });
559
- this.collections.set('unused', {
560
- id: 'unused',
561
- name: 'Unused',
562
- description: 'Assets not referenced by any scene',
563
- icon: 'box',
564
- color: '#cdd6f4',
565
- assetIds: [],
566
- createdAt: Date.now(),
567
- isSmartCollection: true,
568
- smartFilter: { unused: true },
569
- });
570
- }
571
- // ─── Configuration ─────────────────────────────────────
572
- setConfig(config) {
573
- this.config = { ...this.config, ...config };
574
- this.onChange?.();
575
- }
576
- getConfig() {
577
- return { ...this.config };
578
- }
579
- // ─── Asset Import ──────────────────────────────────────
580
- async importFiles(files, options) {
581
- const opts = { ...this.config.importOptions, ...options };
582
- const results = [];
583
- for (const file of Array.from(files)) {
584
- const asset = await this.importFile(file, opts);
585
- if (asset) {
586
- results.push(asset);
587
- }
588
- }
589
- this.onChange?.();
590
- return results;
591
- }
592
- async importFile(file, options) {
593
- const opts = { ...this.config.importOptions, ...options };
594
- const type = this.inferAssetType(file);
595
- const id = `asset_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
596
- const now = Date.now();
597
- // Get target folder
598
- const folderId = opts.folder === '/' ? 'root' : this.findOrCreateFolder(opts.folder);
599
- const asset = {
600
- id,
601
- name: file.name,
602
- type,
603
- path: `${this.getFolderPath(folderId)}/${file.name}`,
604
- size: file.size,
605
- mimeType: file.type,
606
- tags: opts.autoTag ? this.autoGenerateTags(file, type) : [],
607
- description: '',
608
- author: '',
609
- license: '',
610
- version: '1.0.0',
611
- customProperties: {},
612
- createdAt: now,
613
- modifiedAt: now,
614
- importedAt: now,
615
- usageCount: 0,
616
- lastUsedAt: null,
617
- folderId,
618
- dependencies: [],
619
- dependents: [],
620
- isFavorite: false,
621
- importSettings: { ...opts },
703
+ }
704
+ if (!childFolder) {
705
+ childFolder = {
706
+ id: `folder_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
707
+ name: part,
708
+ path: currentPath,
709
+ parentId: currentFolder.id,
710
+ expanded: false,
711
+ children: [],
712
+ assets: [],
713
+ createdAt: Date.now()
622
714
  };
623
- // Generate thumbnail
624
- if (opts.generateThumbnail) {
625
- asset.thumbnailGenerating = true;
626
- const thumbnail = await this.thumbnailGenerator.generateThumbnail(file, type, opts.thumbnailSize);
627
- if (thumbnail) {
628
- asset.thumbnail = thumbnail;
629
- }
630
- asset.thumbnailGenerating = false;
631
- }
632
- // Store asset and blob
633
- this.assets.set(id, asset);
634
- this.blobStore.set(id, file);
635
- // Add to folder
636
- const folder = this.folders.get(folderId);
637
- if (folder) {
638
- folder.assets.push(id);
639
- }
640
- // Update tags
641
- for (const tag of asset.tags) {
642
- this.allTags.add(tag);
643
- }
644
- return asset;
645
- }
646
- inferAssetType(file) {
647
- const ext = file.name.split('.').pop()?.toLowerCase() ?? '';
648
- const mime = file.type;
649
- // Images
650
- if (mime.startsWith('image/')) {
651
- if (file.name.includes('spritesheet') || file.name.includes('atlas')) {
652
- return 'spritesheet';
653
- }
654
- return 'image';
655
- }
656
- // Audio
657
- if (mime.startsWith('audio/')) {
658
- if (file.name.includes('music') || file.name.includes('bgm')) {
659
- return 'music';
660
- }
661
- if (file.name.includes('sfx') || file.name.includes('effect')) {
662
- return 'sfx';
663
- }
664
- return 'audio';
665
- }
666
- // Video
667
- if (mime.startsWith('video/')) {
668
- return 'video';
669
- }
670
- // By extension
671
- const extMap = {
672
- // Models
673
- gltf: 'model',
674
- glb: 'model',
675
- obj: 'model',
676
- fbx: 'model',
677
- dae: 'model',
678
- // Materials & Shaders
679
- mtl: 'material',
680
- mat: 'material',
681
- shader: 'shader',
682
- vert: 'shader',
683
- frag: 'shader',
684
- glsl: 'shader',
685
- // Scripts
686
- js: 'script',
687
- ts: 'script',
688
- lua: 'script',
689
- // Data
690
- json: 'json',
691
- ndg: 'scene',
692
- scene: 'scene',
693
- prefab: 'prefab',
694
- anim: 'animation',
695
- // Fonts
696
- ttf: 'font',
697
- otf: 'font',
698
- woff: 'font',
699
- woff2: 'font',
700
- // Particles
701
- particle: 'particle',
702
- emitter: 'particle',
703
- // Terrain
704
- terrain: 'terrain',
705
- heightmap: 'terrain',
706
- // Tilemaps
707
- tmx: 'tilemap',
708
- tsx: 'tilemap',
709
- ldtk: 'tilemap',
710
- };
711
- return extMap[ext] ?? 'other';
712
- }
713
- autoGenerateTags(file, type) {
714
- const tags = [type];
715
- // Add extension as tag
716
- const ext = file.name.split('.').pop()?.toLowerCase();
717
- if (ext) {
718
- tags.push(ext);
719
- }
720
- // Size-based tags
721
- if (file.size < 10 * 1024) {
722
- tags.push('small');
723
- }
724
- else if (file.size > 1024 * 1024) {
725
- tags.push('large');
726
- }
727
- // Name-based tags
728
- const nameLower = file.name.toLowerCase();
729
- const keywords = [
730
- 'ui',
731
- 'icon',
732
- 'background',
733
- 'player',
734
- 'enemy',
735
- 'item',
736
- 'effect',
737
- 'ambient',
738
- 'loop',
739
- ];
740
- for (const keyword of keywords) {
741
- if (nameLower.includes(keyword)) {
742
- tags.push(keyword);
743
- }
744
- }
745
- return tags;
746
- }
747
- findOrCreateFolder(path) {
748
- const parts = path.split('/').filter(Boolean);
749
- let currentFolder = this.folders.get('root');
750
- let currentPath = '';
751
- for (const part of parts) {
752
- currentPath += '/' + part;
753
- let childFolder;
754
- for (const childId of currentFolder.children) {
755
- const child = this.folders.get(childId);
756
- if (child?.name === part) {
757
- childFolder = child;
758
- break;
759
- }
760
- }
761
- if (!childFolder) {
762
- // Create folder
763
- childFolder = {
764
- id: `folder_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
765
- name: part,
766
- path: currentPath,
767
- parentId: currentFolder.id,
768
- expanded: false,
769
- children: [],
770
- assets: [],
771
- createdAt: Date.now(),
772
- };
773
- this.folders.set(childFolder.id, childFolder);
774
- currentFolder.children.push(childFolder.id);
775
- }
776
- currentFolder = childFolder;
777
- }
778
- return currentFolder.id;
779
- }
780
- getFolderPath(folderId) {
781
- const folder = this.folders.get(folderId);
782
- return folder?.path ?? '/';
783
- }
784
- // ─── Asset Access ──────────────────────────────────────
785
- getAsset(id) {
786
- return this.assets.get(id);
787
- }
788
- getAssetBlob(id) {
789
- return this.blobStore.get(id);
790
- }
791
- getAllAssets() {
792
- return Array.from(this.assets.values());
793
- }
794
- getFilteredAssets(filter) {
795
- return this.getAllAssets().filter((asset) => this.matchesFilter(asset, filter));
796
- }
797
- matchesFilter(asset, filter) {
798
- // Type filter
799
- if (filter.types && filter.types.length > 0) {
800
- if (!filter.types.includes(asset.type)) {
801
- return false;
802
- }
803
- }
804
- // Tag filter
805
- if (filter.tags && filter.tags.length > 0) {
806
- if (filter.tagsMode === 'all') {
807
- if (!filter.tags.every((tag) => asset.tags.includes(tag))) {
808
- return false;
809
- }
810
- }
811
- else {
812
- if (!filter.tags.some((tag) => asset.tags.includes(tag))) {
813
- return false;
814
- }
815
- }
816
- }
817
- // Search filter
818
- if (filter.search) {
819
- const searchLower = filter.search.toLowerCase();
820
- const fields = filter.searchFields ?? ['name', 'tags', 'description', 'path'];
821
- let found = false;
822
- if (fields.includes('name') && asset.name.toLowerCase().includes(searchLower)) {
823
- found = true;
824
- }
825
- if (fields.includes('path') && asset.path.toLowerCase().includes(searchLower)) {
826
- found = true;
827
- }
828
- if (fields.includes('description') && asset.description.toLowerCase().includes(searchLower)) {
829
- found = true;
830
- }
831
- if (fields.includes('tags') &&
832
- asset.tags.some((t) => t.toLowerCase().includes(searchLower))) {
833
- found = true;
834
- }
835
- if (!found) {
836
- return false;
837
- }
838
- }
839
- // Date range
840
- if (filter.dateRange) {
841
- if (asset.modifiedAt < filter.dateRange.from || asset.modifiedAt > filter.dateRange.to) {
842
- return false;
843
- }
844
- }
845
- // Size range
846
- if (filter.sizeRange) {
847
- if (asset.size < filter.sizeRange.min || asset.size > filter.sizeRange.max) {
848
- return false;
849
- }
850
- }
851
- // Favorites
852
- if (filter.favorites && !asset.isFavorite) {
853
- return false;
854
- }
855
- // Recent
856
- if (filter.recent && !this.recentAssetIds.includes(asset.id)) {
857
- return false;
858
- }
859
- // Unused
860
- if (filter.unused && asset.usageCount > 0) {
861
- return false;
862
- }
863
- // Folder
864
- if (filter.folderId) {
865
- if (filter.includeSubfolders) {
866
- const folderPath = this.getFolderPath(filter.folderId);
867
- if (!asset.path.startsWith(folderPath)) {
868
- return false;
869
- }
870
- }
871
- else {
872
- if (asset.folderId !== filter.folderId) {
873
- return false;
874
- }
875
- }
876
- }
877
- return true;
878
- }
879
- // ─── Sorting ───────────────────────────────────────────
880
- getSortedAssets(assets, sortMode) {
881
- const mode = sortMode ?? this.config.sortMode;
882
- return [...assets].sort((a, b) => {
883
- switch (mode) {
884
- case 'name-asc':
885
- return a.name.localeCompare(b.name);
886
- case 'name-desc':
887
- return b.name.localeCompare(a.name);
888
- case 'date-asc':
889
- return a.modifiedAt - b.modifiedAt;
890
- case 'date-desc':
891
- return b.modifiedAt - a.modifiedAt;
892
- case 'size-asc':
893
- return a.size - b.size;
894
- case 'size-desc':
895
- return b.size - a.size;
896
- case 'type':
897
- return a.type.localeCompare(b.type);
898
- default:
899
- return 0;
900
- }
901
- });
902
- }
903
- // ─── Favorites ─────────────────────────────────────────
904
- toggleFavorite(assetId) {
905
- const asset = this.assets.get(assetId);
906
- if (asset) {
907
- asset.isFavorite = !asset.isFavorite;
908
- this.onChange?.();
715
+ this.folders.set(childFolder.id, childFolder);
716
+ currentFolder.children.push(childFolder.id);
717
+ }
718
+ currentFolder = childFolder;
719
+ }
720
+ return currentFolder.id;
721
+ }
722
+ getFolderPath(folderId) {
723
+ const folder = this.folders.get(folderId);
724
+ return folder?.path ?? "/";
725
+ }
726
+ // ─── Asset Access ──────────────────────────────────────
727
+ getAsset(id) {
728
+ return this.assets.get(id);
729
+ }
730
+ getAssetBlob(id) {
731
+ return this.blobStore.get(id);
732
+ }
733
+ getAllAssets() {
734
+ return Array.from(this.assets.values());
735
+ }
736
+ getFilteredAssets(filter) {
737
+ return this.getAllAssets().filter((asset) => this.matchesFilter(asset, filter));
738
+ }
739
+ matchesFilter(asset, filter) {
740
+ if (filter.types && filter.types.length > 0) {
741
+ if (!filter.types.includes(asset.type)) {
742
+ return false;
743
+ }
744
+ }
745
+ if (filter.tags && filter.tags.length > 0) {
746
+ if (filter.tagsMode === "all") {
747
+ if (!filter.tags.every((tag) => asset.tags.includes(tag))) {
748
+ return false;
909
749
  }
910
- }
911
- getFavorites() {
912
- return this.getAllAssets().filter((a) => a.isFavorite);
913
- }
914
- // ─── Recent ────────────────────────────────────────────
915
- markAsUsed(assetId) {
916
- const asset = this.assets.get(assetId);
917
- if (asset) {
918
- asset.usageCount++;
919
- asset.lastUsedAt = Date.now();
920
- // Update recent list
921
- this.recentAssetIds = this.recentAssetIds.filter((id) => id !== assetId);
922
- this.recentAssetIds.unshift(assetId);
923
- if (this.recentAssetIds.length > this.config.recentCount) {
924
- this.recentAssetIds.pop();
925
- }
750
+ } else {
751
+ if (!filter.tags.some((tag) => asset.tags.includes(tag))) {
752
+ return false;
926
753
  }
927
- }
928
- getRecentAssets() {
929
- return this.recentAssetIds
930
- .map((id) => this.assets.get(id))
931
- .filter((a) => a !== undefined);
932
- }
933
- // ─── Tags ──────────────────────────────────────────────
934
- getAllTags() {
935
- return Array.from(this.allTags).sort();
936
- }
937
- addTag(assetId, tag) {
938
- const asset = this.assets.get(assetId);
939
- if (asset && !asset.tags.includes(tag)) {
940
- asset.tags.push(tag);
941
- this.allTags.add(tag);
942
- this.onChange?.();
754
+ }
755
+ }
756
+ if (filter.search) {
757
+ const searchLower = filter.search.toLowerCase();
758
+ const fields = filter.searchFields ?? ["name", "tags", "description", "path"];
759
+ let found = false;
760
+ if (fields.includes("name") && asset.name.toLowerCase().includes(searchLower)) {
761
+ found = true;
762
+ }
763
+ if (fields.includes("path") && asset.path.toLowerCase().includes(searchLower)) {
764
+ found = true;
765
+ }
766
+ if (fields.includes("description") && asset.description.toLowerCase().includes(searchLower)) {
767
+ found = true;
768
+ }
769
+ if (fields.includes("tags") && asset.tags.some((t) => t.toLowerCase().includes(searchLower))) {
770
+ found = true;
771
+ }
772
+ if (!found) {
773
+ return false;
774
+ }
775
+ }
776
+ if (filter.dateRange) {
777
+ if (asset.modifiedAt < filter.dateRange.from || asset.modifiedAt > filter.dateRange.to) {
778
+ return false;
779
+ }
780
+ }
781
+ if (filter.sizeRange) {
782
+ if (asset.size < filter.sizeRange.min || asset.size > filter.sizeRange.max) {
783
+ return false;
784
+ }
785
+ }
786
+ if (filter.favorites && !asset.isFavorite) {
787
+ return false;
788
+ }
789
+ if (filter.recent && !this.recentAssetIds.includes(asset.id)) {
790
+ return false;
791
+ }
792
+ if (filter.unused && asset.usageCount > 0) {
793
+ return false;
794
+ }
795
+ if (filter.folderId) {
796
+ if (filter.includeSubfolders) {
797
+ const folderPath = this.getFolderPath(filter.folderId);
798
+ if (!asset.path.startsWith(folderPath)) {
799
+ return false;
943
800
  }
944
- }
945
- removeTag(assetId, tag) {
946
- const asset = this.assets.get(assetId);
947
- if (asset) {
948
- asset.tags = asset.tags.filter((t) => t !== tag);
949
- this.onChange?.();
801
+ } else {
802
+ if (asset.folderId !== filter.folderId) {
803
+ return false;
950
804
  }
951
- }
952
- // ─── Folders ───────────────────────────────────────────
953
- getFolder(id) {
954
- return this.folders.get(id);
955
- }
956
- getRootFolder() {
957
- return this.folders.get('root');
958
- }
959
- createFolder(name, parentId = 'root') {
960
- const parent = this.folders.get(parentId);
961
- const path = parent ? `${parent.path}/${name}`.replace('//', '/') : `/${name}`;
962
- const folder = {
963
- id: `folder_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
964
- name,
965
- path,
966
- parentId,
967
- expanded: false,
968
- children: [],
969
- assets: [],
970
- createdAt: Date.now(),
971
- };
972
- this.folders.set(folder.id, folder);
973
- if (parent) {
974
- parent.children.push(folder.id);
975
- }
976
- this.onChange?.();
977
- return folder;
978
- }
979
- setCurrentFolder(folderId) {
980
- this.currentFolderId = folderId;
805
+ }
806
+ }
807
+ return true;
808
+ }
809
+ // ─── Sorting ───────────────────────────────────────────
810
+ getSortedAssets(assets, sortMode) {
811
+ const mode = sortMode ?? this.config.sortMode;
812
+ return [...assets].sort((a, b) => {
813
+ switch (mode) {
814
+ case "name-asc":
815
+ return a.name.localeCompare(b.name);
816
+ case "name-desc":
817
+ return b.name.localeCompare(a.name);
818
+ case "date-asc":
819
+ return a.modifiedAt - b.modifiedAt;
820
+ case "date-desc":
821
+ return b.modifiedAt - a.modifiedAt;
822
+ case "size-asc":
823
+ return a.size - b.size;
824
+ case "size-desc":
825
+ return b.size - a.size;
826
+ case "type":
827
+ return a.type.localeCompare(b.type);
828
+ default:
829
+ return 0;
830
+ }
831
+ });
832
+ }
833
+ // ─── Favorites ─────────────────────────────────────────
834
+ toggleFavorite(assetId) {
835
+ const asset = this.assets.get(assetId);
836
+ if (asset) {
837
+ asset.isFavorite = !asset.isFavorite;
838
+ this.onChange?.();
839
+ }
840
+ }
841
+ getFavorites() {
842
+ return this.getAllAssets().filter((a) => a.isFavorite);
843
+ }
844
+ // ─── Recent ────────────────────────────────────────────
845
+ markAsUsed(assetId) {
846
+ const asset = this.assets.get(assetId);
847
+ if (asset) {
848
+ asset.usageCount++;
849
+ asset.lastUsedAt = Date.now();
850
+ this.recentAssetIds = this.recentAssetIds.filter((id) => id !== assetId);
851
+ this.recentAssetIds.unshift(assetId);
852
+ if (this.recentAssetIds.length > this.config.recentCount) {
853
+ this.recentAssetIds.pop();
854
+ }
855
+ }
856
+ }
857
+ getRecentAssets() {
858
+ return this.recentAssetIds.map((id) => this.assets.get(id)).filter((a) => a !== void 0);
859
+ }
860
+ // ─── Tags ──────────────────────────────────────────────
861
+ getAllTags() {
862
+ return Array.from(this.allTags).sort();
863
+ }
864
+ addTag(assetId, tag) {
865
+ const asset = this.assets.get(assetId);
866
+ if (asset && !asset.tags.includes(tag)) {
867
+ asset.tags.push(tag);
868
+ this.allTags.add(tag);
869
+ this.onChange?.();
870
+ }
871
+ }
872
+ removeTag(assetId, tag) {
873
+ const asset = this.assets.get(assetId);
874
+ if (asset) {
875
+ asset.tags = asset.tags.filter((t) => t !== tag);
876
+ this.onChange?.();
877
+ }
878
+ }
879
+ // ─── Folders ───────────────────────────────────────────
880
+ getFolder(id) {
881
+ return this.folders.get(id);
882
+ }
883
+ getRootFolder() {
884
+ return this.folders.get("root");
885
+ }
886
+ createFolder(name, parentId = "root") {
887
+ const parent = this.folders.get(parentId);
888
+ const path = parent ? `${parent.path}/${name}`.replace("//", "/") : `/${name}`;
889
+ const folder = {
890
+ id: `folder_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
891
+ name,
892
+ path,
893
+ parentId,
894
+ expanded: false,
895
+ children: [],
896
+ assets: [],
897
+ createdAt: Date.now()
898
+ };
899
+ this.folders.set(folder.id, folder);
900
+ if (parent) {
901
+ parent.children.push(folder.id);
902
+ }
903
+ this.onChange?.();
904
+ return folder;
905
+ }
906
+ setCurrentFolder(folderId) {
907
+ this.currentFolderId = folderId;
908
+ this.onChange?.();
909
+ }
910
+ getCurrentFolder() {
911
+ return this.folders.get(this.currentFolderId) ?? this.getRootFolder();
912
+ }
913
+ // ─── Collections ───────────────────────────────────────
914
+ getCollection(id) {
915
+ return this.collections.get(id);
916
+ }
917
+ getAllCollections() {
918
+ return Array.from(this.collections.values());
919
+ }
920
+ createCollection(name, description = "") {
921
+ const collection = {
922
+ id: `collection_${Date.now()}`,
923
+ name,
924
+ description,
925
+ icon: "folder",
926
+ color: "#cdd6f4",
927
+ assetIds: [],
928
+ createdAt: Date.now(),
929
+ isSmartCollection: false
930
+ };
931
+ this.collections.set(collection.id, collection);
932
+ this.onChange?.();
933
+ return collection;
934
+ }
935
+ addToCollection(collectionId, assetId) {
936
+ const collection = this.collections.get(collectionId);
937
+ if (collection && !collection.isSmartCollection) {
938
+ if (!collection.assetIds.includes(assetId)) {
939
+ collection.assetIds.push(assetId);
981
940
  this.onChange?.();
982
- }
983
- getCurrentFolder() {
984
- return this.folders.get(this.currentFolderId) ?? this.getRootFolder();
985
- }
986
- // ─── Collections ───────────────────────────────────────
987
- getCollection(id) {
988
- return this.collections.get(id);
989
- }
990
- getAllCollections() {
991
- return Array.from(this.collections.values());
992
- }
993
- createCollection(name, description = '') {
994
- const collection = {
995
- id: `collection_${Date.now()}`,
996
- name,
997
- description,
998
- icon: 'folder',
999
- color: '#cdd6f4',
1000
- assetIds: [],
1001
- createdAt: Date.now(),
1002
- isSmartCollection: false,
1003
- };
941
+ }
942
+ }
943
+ }
944
+ removeFromCollection(collectionId, assetId) {
945
+ const collection = this.collections.get(collectionId);
946
+ if (collection && !collection.isSmartCollection) {
947
+ collection.assetIds = collection.assetIds.filter((id) => id !== assetId);
948
+ this.onChange?.();
949
+ }
950
+ }
951
+ // ─── Selection ─────────────────────────────────────────
952
+ select(assetId, addToSelection = false) {
953
+ if (!addToSelection) {
954
+ this.selectedIds.clear();
955
+ }
956
+ this.selectedIds.add(assetId);
957
+ this.onSelectionChange?.(Array.from(this.selectedIds));
958
+ }
959
+ deselect(assetId) {
960
+ this.selectedIds.delete(assetId);
961
+ this.onSelectionChange?.(Array.from(this.selectedIds));
962
+ }
963
+ clearSelection() {
964
+ this.selectedIds.clear();
965
+ this.onSelectionChange?.(Array.from(this.selectedIds));
966
+ }
967
+ getSelectedAssets() {
968
+ return Array.from(this.selectedIds).map((id) => this.assets.get(id)).filter((a) => a !== void 0);
969
+ }
970
+ // ─── Asset Modification ────────────────────────────────
971
+ updateAsset(assetId, updates) {
972
+ const asset = this.assets.get(assetId);
973
+ if (asset) {
974
+ Object.assign(asset, updates);
975
+ asset.modifiedAt = Date.now();
976
+ this.onChange?.();
977
+ }
978
+ }
979
+ deleteAsset(assetId) {
980
+ const asset = this.assets.get(assetId);
981
+ if (!asset) {
982
+ return;
983
+ }
984
+ const folder = this.folders.get(asset.folderId);
985
+ if (folder) {
986
+ folder.assets = folder.assets.filter((id) => id !== assetId);
987
+ }
988
+ for (const collection of this.collections.values()) {
989
+ collection.assetIds = collection.assetIds.filter((id) => id !== assetId);
990
+ }
991
+ this.recentAssetIds = this.recentAssetIds.filter((id) => id !== assetId);
992
+ this.selectedIds.delete(assetId);
993
+ this.assets.delete(assetId);
994
+ this.blobStore.delete(assetId);
995
+ this.onChange?.();
996
+ }
997
+ // ─── Export/Import ─────────────────────────────────────
998
+ exportAssetMetadata() {
999
+ const data = {
1000
+ version: 1,
1001
+ assets: Array.from(this.assets.values()).map((a) => ({
1002
+ ...a,
1003
+ thumbnail: void 0
1004
+ // Don't export thumbnails
1005
+ })),
1006
+ folders: Array.from(this.folders.values()),
1007
+ collections: Array.from(this.collections.values()),
1008
+ tags: Array.from(this.allTags)
1009
+ };
1010
+ return JSON.stringify(data, null, 2);
1011
+ }
1012
+ importAssetMetadata(json) {
1013
+ try {
1014
+ const data = JSON.parse(json);
1015
+ if (data.version !== 1) {
1016
+ throw new Error("Unsupported version");
1017
+ }
1018
+ for (const asset of data.assets) {
1019
+ this.assets.set(asset.id, asset);
1020
+ }
1021
+ for (const folder of data.folders) {
1022
+ this.folders.set(folder.id, folder);
1023
+ }
1024
+ for (const collection of data.collections) {
1004
1025
  this.collections.set(collection.id, collection);
1005
- this.onChange?.();
1006
- return collection;
1007
- }
1008
- addToCollection(collectionId, assetId) {
1009
- const collection = this.collections.get(collectionId);
1010
- if (collection && !collection.isSmartCollection) {
1011
- if (!collection.assetIds.includes(assetId)) {
1012
- collection.assetIds.push(assetId);
1013
- this.onChange?.();
1014
- }
1015
- }
1016
- }
1017
- removeFromCollection(collectionId, assetId) {
1018
- const collection = this.collections.get(collectionId);
1019
- if (collection && !collection.isSmartCollection) {
1020
- collection.assetIds = collection.assetIds.filter((id) => id !== assetId);
1021
- this.onChange?.();
1022
- }
1023
- }
1024
- // ─── Selection ─────────────────────────────────────────
1025
- select(assetId, addToSelection = false) {
1026
- if (!addToSelection) {
1027
- this.selectedIds.clear();
1028
- }
1029
- this.selectedIds.add(assetId);
1030
- this.onSelectionChange?.(Array.from(this.selectedIds));
1031
- }
1032
- deselect(assetId) {
1033
- this.selectedIds.delete(assetId);
1034
- this.onSelectionChange?.(Array.from(this.selectedIds));
1035
- }
1036
- clearSelection() {
1037
- this.selectedIds.clear();
1038
- this.onSelectionChange?.(Array.from(this.selectedIds));
1039
- }
1040
- getSelectedAssets() {
1041
- return Array.from(this.selectedIds)
1042
- .map((id) => this.assets.get(id))
1043
- .filter((a) => a !== undefined);
1044
- }
1045
- // ─── Asset Modification ────────────────────────────────
1046
- updateAsset(assetId, updates) {
1047
- const asset = this.assets.get(assetId);
1048
- if (asset) {
1049
- Object.assign(asset, updates);
1050
- asset.modifiedAt = Date.now();
1051
- this.onChange?.();
1052
- }
1053
- }
1054
- deleteAsset(assetId) {
1055
- const asset = this.assets.get(assetId);
1056
- if (!asset) {
1057
- return;
1058
- }
1059
- // Remove from folder
1060
- const folder = this.folders.get(asset.folderId);
1061
- if (folder) {
1062
- folder.assets = folder.assets.filter((id) => id !== assetId);
1063
- }
1064
- // Remove from collections
1065
- for (const collection of this.collections.values()) {
1066
- collection.assetIds = collection.assetIds.filter((id) => id !== assetId);
1067
- }
1068
- // Remove from recent
1069
- this.recentAssetIds = this.recentAssetIds.filter((id) => id !== assetId);
1070
- // Remove from selection
1071
- this.selectedIds.delete(assetId);
1072
- // Remove asset and blob
1073
- this.assets.delete(assetId);
1074
- this.blobStore.delete(assetId);
1075
- this.onChange?.();
1076
- }
1077
- // ─── Export/Import ─────────────────────────────────────
1078
- exportAssetMetadata() {
1079
- const data = {
1080
- version: 1,
1081
- assets: Array.from(this.assets.values()).map((a) => ({
1082
- ...a,
1083
- thumbnail: undefined, // Don't export thumbnails
1084
- })),
1085
- folders: Array.from(this.folders.values()),
1086
- collections: Array.from(this.collections.values()),
1087
- tags: Array.from(this.allTags),
1088
- };
1089
- return JSON.stringify(data, null, 2);
1090
- }
1091
- importAssetMetadata(json) {
1092
- try {
1093
- const data = JSON.parse(json);
1094
- if (data.version !== 1) {
1095
- throw new Error('Unsupported version');
1096
- }
1097
- // Restore assets (without blobs/thumbnails)
1098
- for (const asset of data.assets) {
1099
- this.assets.set(asset.id, asset);
1100
- }
1101
- // Restore folders
1102
- for (const folder of data.folders) {
1103
- this.folders.set(folder.id, folder);
1104
- }
1105
- // Restore collections
1106
- for (const collection of data.collections) {
1107
- this.collections.set(collection.id, collection);
1108
- }
1109
- // Restore tags
1110
- this.allTags = new Set(data.tags);
1111
- this.onChange?.();
1112
- }
1113
- catch (error) {
1114
- console.error('Failed to import asset metadata:', error);
1115
- }
1116
- }
1117
- // ─── Callbacks ─────────────────────────────────────────
1118
- setOnChange(callback) {
1119
- this.onChange = callback;
1120
- }
1121
- setOnSelectionChange(callback) {
1122
- this.onSelectionChange = callback;
1123
- }
1124
- setOnAssetOpen(callback) {
1125
- this.onAssetOpen = callback;
1126
- }
1127
- openAsset(assetId) {
1128
- const asset = this.assets.get(assetId);
1129
- if (asset) {
1130
- this.markAsUsed(assetId);
1131
- this.onAssetOpen?.(asset);
1132
- }
1133
- }
1134
- // ─── Utilities ─────────────────────────────────────────
1135
- formatFileSize(bytes) {
1136
- if (bytes < 1024) {
1137
- return `${bytes} B`;
1138
- }
1139
- if (bytes < 1024 * 1024) {
1140
- return `${(bytes / 1024).toFixed(1)} KB`;
1141
- }
1142
- if (bytes < 1024 * 1024 * 1024) {
1143
- return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
1144
- }
1145
- return `${(bytes / (1024 * 1024 * 1024)).toFixed(2)} GB`;
1146
- }
1147
- /** NiceIcon name for an asset type. */
1148
- getAssetTypeIcon(type) {
1149
- const icons = {
1150
- image: 'image',
1151
- sprite: 'palette',
1152
- spritesheet: 'grid',
1153
- tilemap: 'map-pin',
1154
- audio: 'volume',
1155
- music: 'music',
1156
- sfx: 'zap',
1157
- model: 'box',
1158
- material: 'palette',
1159
- shader: 'wand',
1160
- script: 'code',
1161
- scene: 'video',
1162
- prefab: 'box',
1163
- animation: 'video',
1164
- font: 'type',
1165
- particle: 'star',
1166
- terrain: 'mountain',
1167
- video: 'video',
1168
- json: 'file',
1169
- other: 'file',
1170
- };
1171
- return icons[type] ?? 'file';
1172
- }
1026
+ }
1027
+ this.allTags = new Set(data.tags);
1028
+ this.onChange?.();
1029
+ } catch (error) {
1030
+ console.error("Failed to import asset metadata:", error);
1031
+ }
1032
+ }
1033
+ // ─── Callbacks ─────────────────────────────────────────
1034
+ setOnChange(callback) {
1035
+ this.onChange = callback;
1036
+ }
1037
+ setOnSelectionChange(callback) {
1038
+ this.onSelectionChange = callback;
1039
+ }
1040
+ setOnAssetOpen(callback) {
1041
+ this.onAssetOpen = callback;
1042
+ }
1043
+ openAsset(assetId) {
1044
+ const asset = this.assets.get(assetId);
1045
+ if (asset) {
1046
+ this.markAsUsed(assetId);
1047
+ this.onAssetOpen?.(asset);
1048
+ }
1049
+ }
1050
+ // ─── Utilities ─────────────────────────────────────────
1051
+ formatFileSize(bytes) {
1052
+ if (bytes < 1024) {
1053
+ return `${bytes} B`;
1054
+ }
1055
+ if (bytes < 1024 * 1024) {
1056
+ return `${(bytes / 1024).toFixed(1)} KB`;
1057
+ }
1058
+ if (bytes < 1024 * 1024 * 1024) {
1059
+ return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
1060
+ }
1061
+ return `${(bytes / (1024 * 1024 * 1024)).toFixed(2)} GB`;
1062
+ }
1063
+ /** NiceIcon name for an asset type. */
1064
+ getAssetTypeIcon(type) {
1065
+ const icons = {
1066
+ image: "image",
1067
+ sprite: "palette",
1068
+ spritesheet: "grid",
1069
+ tilemap: "map-pin",
1070
+ audio: "volume",
1071
+ music: "music",
1072
+ sfx: "zap",
1073
+ model: "box",
1074
+ material: "palette",
1075
+ shader: "wand",
1076
+ script: "code",
1077
+ scene: "video",
1078
+ prefab: "box",
1079
+ animation: "video",
1080
+ font: "type",
1081
+ particle: "star",
1082
+ terrain: "mountain",
1083
+ video: "video",
1084
+ json: "file",
1085
+ other: "file"
1086
+ };
1087
+ return icons[type] ?? "file";
1088
+ }
1173
1089
  }
1174
- // ============================================================
1175
- // Factory Functions
1176
- // ============================================================
1177
1090
  function createAssetBrowser(config) {
1178
- return new AssetBrowser(config);
1091
+ return new AssetBrowser(config);
1179
1092
  }
1180
1093
  function createThumbnailGenerator() {
1181
- return new ThumbnailGenerator();
1094
+ return new ThumbnailGenerator();
1182
1095
  }
1183
-
1184
- export { AssetBrowser, DEFAULT_BROWSER_CONFIG, DEFAULT_IMPORT_OPTIONS, ThumbnailGenerator, createAssetBrowser, createThumbnailGenerator };
1096
+ export {
1097
+ AssetBrowser,
1098
+ DEFAULT_BROWSER_CONFIG,
1099
+ DEFAULT_IMPORT_OPTIONS,
1100
+ ThumbnailGenerator,
1101
+ createAssetBrowser,
1102
+ createThumbnailGenerator
1103
+ };