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