@vgai/editor 0.2.0 → 0.4.0-canary.20260715.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -0
- package/dist/assets/axe-C7YBtOuM.js +30 -0
- package/dist/assets/browserAll-DDtGGE48.js +1 -0
- package/dist/assets/create-runtime-DbTlBlKG.js +1 -0
- package/dist/assets/{game-BI111o5f.js → game-BE0r7DMI.js} +3 -3
- package/dist/assets/game-BdTHR2_X.js +1 -0
- package/dist/assets/{game-pt_1lQLv.js → game-C3iQGSqo.js} +1 -1
- package/dist/assets/game-CcHfYxjP.js +1 -0
- package/dist/assets/game-Cqzj_lpD.js +1 -0
- package/dist/assets/game-DSZdeCHu.js +1 -0
- package/dist/assets/game-Dch9sAPc.js +1 -0
- package/dist/assets/{game-xsOho_wg.js → game-SAFn90pA.js} +3 -3
- package/dist/assets/game-loop-DMIgSMV-.js +1 -0
- package/dist/assets/{game-source-CvidN7AB.js → game-source-Dk83w26t.js} +1 -1
- package/dist/assets/{index-Bp5cecD6.js → index-4idIsHHJ.js} +2 -2
- package/dist/assets/{index-DL7RcQ0n.js → index-C-LhOTBN.js} +1 -1
- package/dist/assets/{index-Cs8xwv3e.js → index-CDkxceqE.js} +1 -1
- package/dist/assets/index-CQEfi217.js +15412 -0
- package/dist/assets/index-Dvi-V0NE.css +1 -0
- package/dist/assets/ingest-siblings-s0P5I1Ub.js +1 -0
- package/dist/assets/mount-manifest-DXMOlF79.js +1 -0
- package/dist/assets/react-18-C9eHn8x1.js +1 -0
- package/dist/assets/webworkerAll-Fn0e-ouF.js +1 -0
- package/dist/assets/world-documents-GM0a9Kv7.js +1 -0
- package/dist/index.html +15 -13
- package/dist/ingest/racing-game/vgai.game.json +5 -4
- package/dist/ingest/simcity/vgai.game.json +5 -4
- package/dist/ingest/tanks/vgai.game.json +5 -4
- package/dist/project-scripts.bundle.js +3917 -0
- package/dist/scenes/untitled.vscn.json +2 -0
- package/dist-server/packaged.mjs +7697 -3435
- package/package.json +31 -4
- package/scripts/probe-reporter.ts +349 -0
- package/scripts/run-probe.ts +2260 -0
- package/server/asset-catalog-audit.ts +268 -0
- package/server/asset-catalog-v2.ts +146 -0
- package/server/asset-library-routes.ts +276 -58
- package/server/canonical-path.ts +1 -1
- package/server/dev.ts +148 -44
- package/server/editor-server.ts +888 -61
- package/server/editor-sse.ts +115 -4
- package/server/harness-chat-service.ts +796 -0
- package/server/local-asset-catalog.ts +157 -22
- package/server/packaged.ts +51 -21
- package/server/process-shutdown.ts +136 -0
- package/server/prod.ts +9 -6
- package/server/project-hmr-files.ts +41 -0
- package/server/project-operations.ts +343 -0
- package/server/project-optimize-deps-entries.ts +4 -4
- package/server/project-output-writer.ts +156 -0
- package/server/project-validation.ts +140 -0
- package/server/project-view.ts +8 -50
- package/server/server-utils.ts +75 -10
- package/server/session-registry.ts +12 -0
- package/src/EditorContext.tsx +107 -3
- package/src/action-registry.ts +115 -17
- package/src/adapter-resolver.ts +213 -478
- package/src/asset-events.ts +64 -1
- package/src/asset-preview.ts +906 -0
- package/src/asset-selection.ts +121 -0
- package/src/asset-workflow/asset-capabilities.ts +259 -0
- package/src/asset-workflow/asset-editor-errors.ts +46 -0
- package/src/asset-workflow/asset-import-pipeline.ts +176 -0
- package/src/asset-workflow/asset-library-query.ts +107 -0
- package/src/asset-workflow/asset-types.ts +192 -0
- package/src/asset-workflow/asset-workflow-quality.ts +65 -0
- package/src/asset-workflow/import-contract.ts +113 -0
- package/src/asset-workflow/model-conversion.ts +126 -0
- package/src/asset-workflow/model-inspection.ts +185 -0
- package/src/asset-workflow/project-asset-commands.ts +23 -0
- package/src/asset-workflow/project-asset-health.ts +153 -0
- package/src/asset-workflow/project-asset-operations.ts +119 -0
- package/src/asset-workflow/thumbnail-system.ts +172 -0
- package/src/authoring/active-systems.ts +15 -0
- package/src/authoring/boundary-authoring-adapter.ts +16 -5
- package/src/authoring/composite-authoring-adapter.ts +305 -124
- package/src/authoring/design-time-layers.ts +300 -117
- package/src/authoring/edit-mode-authoring.ts +278 -293
- package/src/authoring/embed-only-adapter.ts +4 -2
- package/src/authoring/first-party-hierarchy-menu.ts +7 -2
- package/src/authoring/first-party-inspector/AddSectionMenu.tsx +5 -12
- package/src/authoring/first-party-inspector/EnvironmentSection.tsx +53 -126
- package/src/authoring/first-party-inspector/HeaderSection.tsx +54 -65
- package/src/authoring/first-party-inspector/is-first-party-selection.ts +30 -11
- package/src/authoring/first-party-inspector/register.tsx +13 -2
- package/src/authoring/ingest-authoring-adapter.ts +142 -45
- package/src/authoring/mount-failure-report.ts +5 -5
- package/src/authoring/provenance.ts +41 -0
- package/src/authoring/react-dom-authoring-adapter.ts +92 -92
- package/src/authoring/react-inspector-section.tsx +489 -51
- package/src/authoring/react-world-authoring-adapter.ts +541 -306
- package/src/authoring/story-overlay.ts +1 -1
- package/src/authoring/story-types.ts +11 -0
- package/src/authoring/vgai-scene-authoring-adapter.ts +54 -25
- package/src/authoring/viewport-tool-context.ts +78 -0
- package/src/authoring/world-canvas-viewport-state.ts +35 -0
- package/src/authoring/world-hidden-viewport.ts +186 -0
- package/src/authoring/world-pan-state.ts +33 -17
- package/src/authoring/world-session-state.ts +1 -1
- package/src/authoring/world2d-authoring-adapter.ts +109 -52
- package/src/availability-tick.ts +56 -0
- package/src/browser-play-entry.ts +5 -5
- package/src/browser-project-scripts.ts +1 -0
- package/src/build-identity.ts +15 -0
- package/src/command-listener.ts +893 -19
- package/src/components/AlignToolbar.tsx +74 -63
- package/src/components/AppRoot.tsx +193 -26
- package/src/components/ApplicationMenus.tsx +272 -0
- package/src/components/AssetBrowser.tsx +1450 -293
- package/src/components/AssetEditorShell.tsx +141 -0
- package/src/components/AssetImportDetails.tsx +218 -0
- package/src/components/AssetLibraryPanel.tsx +14 -0
- package/src/components/CameraInfo.tsx +11 -20
- package/src/components/CenterDocuments.tsx +585 -0
- package/src/components/CommandPalette.tsx +75 -30
- package/src/components/ConsolePanel.css +55 -0
- package/src/components/ConsolePanel.tsx +57 -112
- package/src/components/DebugConsolePanel.tsx +461 -0
- package/src/components/DebuggerPanel.tsx +165 -0
- package/src/components/DefaultEditorLayout.tsx +167 -231
- package/src/components/GameHierarchy.tsx +873 -290
- package/src/components/GamePerformanceOverlay.tsx +46 -0
- package/src/components/HarnessChatPanel.tsx +2352 -0
- package/src/components/HistoryPanel.tsx +226 -0
- package/src/components/Inspector.tsx +153 -99
- package/src/components/InspectorToolSection.tsx +6 -4
- package/src/components/MountFailureBanner.tsx +31 -48
- package/src/components/NetworkSection.tsx +25 -14
- package/src/components/OnlineAssetBrowser.tsx +794 -343
- package/src/components/OverlayReportBanner.tsx +38 -64
- package/src/components/PerformancePanel.tsx +206 -0
- package/src/components/PlayBar.tsx +93 -263
- package/src/components/PrefabSaveDialog.tsx +55 -127
- package/src/components/ProjectHeader.css +60 -0
- package/src/components/ProjectHeader.tsx +170 -105
- package/src/components/ProjectScreen.tsx +246 -184
- package/src/components/ReactCanvasControls.tsx +185 -0
- package/src/components/ResolutionPicker.tsx +85 -0
- package/src/components/RootActivateDialog.tsx +39 -68
- package/src/components/SaveDialog.tsx +55 -127
- package/src/components/SaveStatus.tsx +11 -29
- package/src/components/StartupLoadingScreen.tsx +96 -0
- package/src/components/StateWatchPanel.tsx +302 -0
- package/src/components/StatsOverlay.tsx +12 -5
- package/src/components/StatusBar.tsx +64 -0
- package/src/components/ThemeManagerDialog.css +89 -0
- package/src/components/ThemeManagerDialog.tsx +371 -0
- package/src/components/ToolHost.tsx +26 -15
- package/src/components/Toolbar.tsx +117 -214
- package/src/components/VgaiVoxelLogo.tsx +89 -0
- package/src/components/ViewportOverlay.tsx +97 -172
- package/src/components/ViewportPanel.tsx +130 -31
- package/src/components/WorkspaceDock.tsx +891 -0
- package/src/components/WorldSelectionOverlay.tsx +51 -63
- package/src/components/WorldTextEditor.tsx +9 -5
- package/src/components/asset-documents.tsx +390 -0
- package/src/components/asset-editor-persistence.ts +44 -0
- package/src/components/asset-selection-section.tsx +338 -0
- package/src/components/asset-viewers/AudioViewer.tsx +73 -21
- package/src/components/asset-viewers/GenericJsonViewer.tsx +26 -11
- package/src/components/asset-viewers/ImageViewer.tsx +43 -11
- package/src/components/asset-viewers/InputMapViewer.tsx +512 -134
- package/src/components/asset-viewers/MaterialAssetEditor.tsx +540 -0
- package/src/components/asset-viewers/ModelViewer.tsx +805 -121
- package/src/components/asset-viewers/OnlineAssetDetail.tsx +177 -60
- package/src/components/asset-viewers/SourceAssetViewer.tsx +121 -0
- package/src/components/asset-workflow.css +506 -0
- package/src/components/build-documents.tsx +696 -0
- package/src/components/core-utilities.tsx +75 -0
- package/src/components/data-documents.tsx +364 -0
- package/src/components/{DataPanel.tsx → data-editor.tsx} +138 -288
- package/src/components/debugger-panel-state.ts +57 -0
- package/src/components/inspector-widgets/AlignmentGrid.tsx +8 -14
- package/src/components/inspector-widgets/BorderEditor.tsx +41 -33
- package/src/components/inspector-widgets/ColorPicker.tsx +39 -39
- package/src/components/inspector-widgets/FontPicker.tsx +13 -21
- package/src/components/inspector-widgets/GradientEditor.tsx +11 -19
- package/src/components/inspector-widgets/ScrubbableInput.tsx +6 -3
- package/src/components/inspector-widgets/ShadowEditor.tsx +20 -33
- package/src/components/inspector-widgets/shared.tsx +90 -49
- package/src/components/inspectors/AnimationSection.tsx +39 -40
- package/src/components/inspectors/AudioSection.tsx +28 -39
- package/src/components/inspectors/BoneAttachmentSection.tsx +19 -24
- package/src/components/inspectors/CameraSection.tsx +14 -23
- package/src/components/inspectors/ComponentsSection.tsx +39 -43
- package/src/components/inspectors/JointsSection.tsx +34 -43
- package/src/components/inspectors/LightSection.tsx +90 -35
- package/src/components/inspectors/MaterialSection.tsx +137 -174
- package/src/components/inspectors/MeshSection.tsx +9 -17
- package/src/components/inspectors/NavigationSection.tsx +8 -15
- package/src/components/inspectors/ParticleSection.tsx +91 -76
- package/src/components/inspectors/PhysicsSection.tsx +42 -46
- package/src/components/inspectors/PostProcessingSection.tsx +28 -36
- package/src/components/inspectors/RenderingSection.tsx +12 -20
- package/src/components/inspectors/ShadowSection.tsx +7 -8
- package/src/components/inspectors/SplineSection.tsx +31 -42
- package/src/components/inspectors/TransformSection.tsx +14 -22
- package/src/components/patterns/Dialog.tsx +95 -0
- package/src/components/patterns/Fields.tsx +44 -0
- package/src/components/patterns/List.tsx +25 -0
- package/src/components/patterns/StateSurface.tsx +40 -0
- package/src/components/patterns/Surfaces.tsx +115 -0
- package/src/components/patterns/Tabs.tsx +80 -0
- package/src/components/patterns/Toolbar.tsx +51 -0
- package/src/components/patterns/Tree.tsx +72 -0
- package/src/components/primitives/Button.tsx +46 -0
- package/src/components/primitives/ColorInput.tsx +11 -47
- package/src/components/primitives/EditorIcon.tsx +99 -0
- package/src/components/primitives/FormControls.tsx +71 -0
- package/src/components/primitives/JsonInput.tsx +15 -2
- package/src/components/primitives/Layout.tsx +100 -0
- package/src/components/primitives/Menu.tsx +105 -0
- package/src/components/primitives/NumberInput.tsx +8 -35
- package/src/components/primitives/Panel.tsx +49 -44
- package/src/components/primitives/SectionHeader.tsx +10 -28
- package/src/components/primitives/Text.tsx +46 -0
- package/src/components/primitives/Tooltip.tsx +20 -12
- package/src/components/primitives/Vec3Input.tsx +3 -0
- package/src/components/primitives/banner-tones.ts +33 -0
- package/src/components/primitives/editor-icons.ts +102 -0
- package/src/components/primitives/panel-header-styles.ts +30 -0
- package/src/components/project-operation-documents.tsx +226 -0
- package/src/components/status-contributions.tsx +175 -0
- package/src/components/story-documents-register.ts +15 -0
- package/src/components/story-documents.tsx +1185 -0
- package/src/components/tool-documents.tsx +110 -0
- package/src/components/workspace-dock.css +293 -0
- package/src/components/workspace-history.ts +33 -0
- package/src/components/world-documents.tsx +145 -0
- package/src/components/xstate-documents.tsx +209 -0
- package/src/composite-screenshot.ts +248 -0
- package/src/design-system/index.ts +70 -0
- package/src/design-system-stories/Foundation.stories.tsx +183 -0
- package/src/design-system-stories/Patterns.stories.tsx +251 -0
- package/src/design-system-stories/Workspace.stories.tsx +538 -0
- package/src/doctor/report.ts +57 -13
- package/src/editor-api.ts +295 -31
- package/src/editor-compatibility.ts +200 -0
- package/src/editor-console.ts +35 -17
- package/src/editor-hotkeys.ts +85 -33
- package/src/editor-store.ts +538 -233
- package/src/editor-viewport.ts +160 -34
- package/src/entity-factory.ts +14 -3
- package/src/gizmo-registry.ts +21 -5
- package/src/harness-chat-editor-context.ts +37 -0
- package/src/harness-chat-indicator.ts +68 -0
- package/src/harness-chat-layout.ts +53 -0
- package/src/harness-chat-lifecycle.ts +170 -0
- package/src/harness-chat-reconnect.ts +85 -0
- package/src/harness-chat-types.ts +409 -0
- package/src/hierarchy-drop.ts +50 -0
- package/src/hierarchy-expansion-state.ts +100 -0
- package/src/hierarchy-menu-registry.ts +1 -1
- package/src/hierarchy-projection.ts +76 -0
- package/src/history/editor-session.ts +21 -0
- package/src/history/history-commands.ts +147 -0
- package/src/history/history-service.ts +904 -0
- package/src/history/json-history-resource.ts +165 -0
- package/src/history/persistence-coordinator.ts +35 -0
- package/src/history/project-file-history.ts +266 -0
- package/src/history/project-root-history-backends.ts +53 -0
- package/src/history/resource-registry.ts +209 -0
- package/src/history/snapshot-store.ts +108 -0
- package/src/history/source-history-backend.ts +374 -0
- package/src/history/types.ts +100 -0
- package/src/hmr-registration-group.ts +67 -0
- package/src/hmr-stable-react-context.ts +23 -0
- package/src/hosted-example.ts +12 -2
- package/src/hotkeys.ts +89 -18
- package/src/ingest/discovery-react.ts +9 -10
- package/src/ingest/discovery.ts +4 -4
- package/src/ingest/discovery2d.ts +5 -5
- package/src/ingest/games/bloom-composer/vgai.game.json +3 -3
- package/src/ingest/games/embed-bundle/vgai.game.json +3 -3
- package/src/ingest/games/games-fps/vgai.game.json +3 -3
- package/src/ingest/games/iframe-reachable/vgai.game.json +3 -3
- package/src/ingest/games/interactive-cubes/vgai.game.json +3 -3
- package/src/ingest/games/mismatched-three/vgai.game.json +3 -3
- package/src/ingest/games/own-three-bundled/vgai.game.json +3 -3
- package/src/ingest/games/pointerlock-maze/vgai.game.json +7 -4
- package/src/ingest/games-2d/bubbo-bubbo/vgai.game.json +3 -3
- package/src/ingest/games-2d/bunnymark/vgai.game.json +3 -3
- package/src/ingest/games-2d/flappy/vgai.game.json +3 -3
- package/src/ingest/games-2d/flappy-pixi/vgai.game.json +3 -3
- package/src/ingest/games-2d/puzzling-potions/vgai.game.json +3 -3
- package/src/ingest/games-2d/tilemap-camera/vgai.game.json +3 -3
- package/src/ingest/games-react/react-rpg/vgai.game.json +3 -3
- package/src/ingest/types.ts +1 -1
- package/src/ingest-mode.ts +47 -52
- package/src/ingest-siblings.ts +23 -33
- package/src/initial-scene.ts +1 -2
- package/src/main.tsx +16 -8
- package/src/manifest-project.ts +10 -12
- package/src/model-thumbnail.ts +261 -26
- package/src/module-mode.ts +44 -50
- package/src/play-log-events.ts +26 -0
- package/src/play-mode.ts +495 -401
- package/src/play-scene-adoption.ts +23 -0
- package/src/playground/main.ts +68 -24
- package/src/playwright-shim.ts +473 -0
- package/src/project-manager.ts +90 -10
- package/src/project-operations.ts +112 -0
- package/src/project-story-discovery.ts +25 -0
- package/src/project-tool-discovery.ts +43 -0
- package/src/scene-serializer.ts +0 -6
- package/src/scene-sync.ts +7 -2
- package/src/script-loader.ts +3 -3
- package/src/skeleton-helper.ts +57 -0
- package/src/storage/seed.ts +68 -8
- package/src/stories/StoryPreviewMount.tsx +265 -0
- package/src/stories/action-stories.fixture.tsx +44 -0
- package/src/stories/button-stories.fixture.tsx +50 -0
- package/src/stories/compose-project-stories.ts +182 -0
- package/src/stories/loader-stories.fixture.tsx +53 -0
- package/src/stories/story-discovery.ts +130 -0
- package/src/stories/story-registry.ts +146 -0
- package/src/theme-css.ts +1049 -0
- package/src/theme-library.ts +238 -0
- package/src/theme-preference.ts +130 -0
- package/src/theme.ts +527 -0
- package/src/tool-loader.ts +80 -24
- package/src/ui-source/inspect.ts +27 -4
- package/src/ui-source/source-write-backend.ts +83 -22
- package/src/widgets/index.ts +9 -18
- package/src/workspace-aux-commands.ts +11 -0
- package/src/workspace-dock-controller.ts +64 -0
- package/src/workspace-document-ids.ts +5 -0
- package/src/workspace-document-registry.ts +367 -0
- package/src/workspace-state-persistence.ts +455 -0
- package/src/workspace-status-registry.ts +110 -0
- package/src/workspace-utility-commands.ts +49 -0
- package/src/workspace-utility-registry.ts +161 -0
- package/src/world-document-routing.ts +16 -0
- package/src/xstate-inspect/XStateMachineInspector.tsx +544 -0
- package/src/xstate-inspect/character-animation-machine.fixture.ts +74 -0
- package/src/xstate-inspect/use-live-actor-state.ts +39 -0
- package/src/xstate-inspect/xstate-graph.ts +265 -0
- package/src/xstate-inspect/xstate-layout.ts +76 -0
- package/src/z-index.ts +26 -0
- package/template/.claude/skills/editor/SKILL.md +129 -90
- package/template/AGENTS.md +1110 -0
- package/template/CLAUDE.md +1 -512
- package/template/IDIOMS.md +50 -0
- package/template/check-idioms.ts +706 -0
- package/template/manifest-entry-modules-plugin.ts +53 -0
- package/template/package.json +13 -4
- package/template/public/scenes/default.scn2d.json +6 -0
- package/template/public/scenes/default.vscn.json +7 -1
- package/template/public/scenes/untitled.vscn.json +10 -0
- package/template/scripts/playtest.ts +40 -0
- package/template/server/loopback.ts +75 -0
- package/template/server/rooms/arena-room.ts +69 -1
- package/template/server/rooms/game-room.ts +68 -1
- package/template/src/data/README.md +9 -4
- package/template/src/data/data-ref.ts +35 -0
- package/template/src/data/tuning.schema.ts +1 -1
- package/template/src/main.ts +41 -62
- package/template/src/manifest-entry-modules.d.ts +3 -0
- package/template/src/operations/README.md +88 -0
- package/template/src/runtime/pixi-adapter.ts +24 -0
- package/template/src/scripts/components/data-spinner.ts +43 -2
- package/template/src/scripts/components/spin-lap-math.ts +27 -0
- package/template/src/tools/README.md +5 -3
- package/template/src/tools/example.tool.tsx +13 -7
- package/template/src/ui/Button.stories.tsx +66 -0
- package/template/src/ui/RebindPanel.tsx +2 -6
- package/template/src/ui/game.tsx +17 -0
- package/template/tests/acceptance/example.spec.ts +64 -0
- package/template/tests/logic/example.test.ts +31 -0
- package/template/tests/logic/room.test.ts +100 -0
- package/template/tests/tsconfig.json +30 -0
- package/template/validate-manifest.ts +5 -5
- package/template/validate-scenes.ts +50 -18
- package/template/vgai.game.json +20 -13
- package/template/vite.config.ts +77 -16
- package/vite-plugin-ui-oid.ts +261 -17
- package/dist/assets/CCDIKSolver-Dz-ysxZF.js +0 -1
- package/dist/assets/SelectionBox-BXsv_6aH.js +0 -1
- package/dist/assets/browser-project-scripts-DOru4L1x.js +0 -2
- package/dist/assets/browserAll-CEkWYlFk.js +0 -1
- package/dist/assets/create-runtime-DYIWr3va.js +0 -1
- package/dist/assets/data-asset-Bb9sIM7i.js +0 -5
- package/dist/assets/game-8SDZPPgH.js +0 -1
- package/dist/assets/game-CevorxyV.js +0 -1
- package/dist/assets/game-Di7XlywD.js +0 -1
- package/dist/assets/game-DjnCaw8R.js +0 -1
- package/dist/assets/game-Q9A0aXSV.js +0 -1
- package/dist/assets/index-CPVV6pjw.js +0 -1
- package/dist/assets/index-CpOnYyeD.js +0 -213
- package/dist/assets/index-Dr8H_6Rl.js +0 -1
- package/dist/assets/index-_bCaipUk.js +0 -13650
- package/dist/assets/ingest-siblings-Dz8eEqrV.js +0 -1
- package/dist/assets/mount-manifest-Bhk0ohsl.js +0 -1
- package/dist/assets/scene-query-BivAHhJu.js +0 -1
- package/dist/assets/webworkerAll-BLrH0F6F.js +0 -1
- package/dist/assets/xstate-animation-binding-1NGLmw6y.js +0 -1
- package/dist/assets/xstate.esm-BgUD33nl.js +0 -3
- package/src/authoring/scene-ui-layer.ts +0 -485
- package/src/authoring/ui-authoring-adapter.ts +0 -325
- package/src/authoring/ui-hierarchy-menu.ts +0 -40
- package/src/authoring/ui-inspector-sections.tsx +0 -156
- package/src/authoring/undo-timeline.ts +0 -145
- package/src/components/BottomPanel.tsx +0 -326
- package/src/components/BuildPanel.tsx +0 -455
- package/src/components/FolderTree.tsx +0 -179
- package/src/components/RightPanel.tsx +0 -166
- package/src/components/WorldContextMenu.tsx +0 -257
- package/src/components/asset-viewers/AssetViewer.tsx +0 -38
- package/src/ingest/games-react/react-rpg/src/ui/game-state.tsx +0 -129
- package/src/scene-ui-mode/active-scene-ui.ts +0 -58
- package/src/scene-ui-mode/scene-ui-palette-panel.tsx +0 -152
- package/src/scene-ui-mode/scene-ui-timeline-tab.tsx +0 -29
- package/src/scene-ui-mode/ui-prefab-dialog-host.tsx +0 -74
- package/src/scene-ui-mode/ui-prefab-hierarchy-menu.ts +0 -49
- package/src/scene-ui-mode/ui-prefab-io.ts +0 -76
- package/src/ui-editor/inspector.tsx +0 -563
- package/src/ui-editor/node-ops.ts +0 -266
- package/src/ui-editor/overlay.tsx +0 -380
- package/src/ui-editor/palette.tsx +0 -114
- package/src/ui-editor/react-store.ts +0 -78
- package/src/ui-editor/timeline-panel.tsx +0 -443
- package/src/ui-editor/ui-edit-store.ts +0 -552
- package/src/ui-editor/ui-prefab.ts +0 -95
- package/template/project.json +0 -9
- package/template/src/scripts/main.ts +0 -94
- package/template/src/ui/DefaultHud.tsx +0 -40
- package/template/src/ui/game-state.tsx +0 -37
- package/template/src/ui/mount-default-hud.tsx +0 -19
- package/template/src/ui/mount-ui.ts +0 -15
- package/vite-plugin-react-world-provider.ts +0 -81
|
@@ -1,455 +0,0 @@
|
|
|
1
|
-
import { faGlobe } from '@fortawesome/free-solid-svg-icons';
|
|
2
|
-
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
3
|
-
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
4
|
-
import { getDownloadUrl, saveFile, startExport } from '../editor-api';
|
|
5
|
-
|
|
6
|
-
type BuildTarget = 'web';
|
|
7
|
-
type BuildPhase = 'idle' | 'building' | 'done';
|
|
8
|
-
|
|
9
|
-
interface BuildResult {
|
|
10
|
-
ok: boolean;
|
|
11
|
-
code: number | null;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
interface ProjectConfig {
|
|
15
|
-
name: string;
|
|
16
|
-
resolution: { width: number; height: number };
|
|
17
|
-
appId: string;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const DEFAULT_CONFIG: ProjectConfig = {
|
|
21
|
-
name: 'My Game',
|
|
22
|
-
resolution: { width: 1280, height: 720 },
|
|
23
|
-
appId: 'com.example.mygame',
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const TARGETS: {
|
|
27
|
-
id: BuildTarget;
|
|
28
|
-
label: string;
|
|
29
|
-
subtitle: string;
|
|
30
|
-
output: string;
|
|
31
|
-
icon: typeof faGlobe;
|
|
32
|
-
}[] = [
|
|
33
|
-
{ id: 'web', label: 'Web', subtitle: 'HTML5 for itch.io', output: 'vgai-web.zip', icon: faGlobe },
|
|
34
|
-
];
|
|
35
|
-
|
|
36
|
-
export function BuildPanel() {
|
|
37
|
-
const [config, setConfig] = useState<ProjectConfig>(DEFAULT_CONFIG);
|
|
38
|
-
const [phase, setPhase] = useState<BuildPhase>('idle');
|
|
39
|
-
const [selected, setSelected] = useState<BuildTarget>('web');
|
|
40
|
-
const [log, setLog] = useState<string[]>([]);
|
|
41
|
-
const [result, setResult] = useState<BuildResult | null>(null);
|
|
42
|
-
const logRef = useRef<HTMLDivElement>(null);
|
|
43
|
-
const abortRef = useRef<AbortController | null>(null);
|
|
44
|
-
const saveTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
45
|
-
|
|
46
|
-
// Load config on mount
|
|
47
|
-
useEffect(() => {
|
|
48
|
-
fetch('/project.json')
|
|
49
|
-
.then((res) => (res.ok ? res.json() : DEFAULT_CONFIG))
|
|
50
|
-
.then((data) => setConfig({ ...DEFAULT_CONFIG, ...data }))
|
|
51
|
-
.catch(() => {});
|
|
52
|
-
}, []);
|
|
53
|
-
|
|
54
|
-
// Auto-scroll log
|
|
55
|
-
useEffect(() => {
|
|
56
|
-
if (logRef.current) logRef.current.scrollTop = logRef.current.scrollHeight;
|
|
57
|
-
}, [log]);
|
|
58
|
-
|
|
59
|
-
// Debounced save
|
|
60
|
-
const saveConfig = useCallback((cfg: ProjectConfig) => {
|
|
61
|
-
if (saveTimerRef.current) clearTimeout(saveTimerRef.current);
|
|
62
|
-
saveTimerRef.current = setTimeout(() => {
|
|
63
|
-
saveFile('project.json', JSON.stringify(cfg, null, 2)).catch(() => {});
|
|
64
|
-
}, 500);
|
|
65
|
-
}, []);
|
|
66
|
-
|
|
67
|
-
const updateConfig = useCallback(
|
|
68
|
-
(patch: Partial<ProjectConfig>) => {
|
|
69
|
-
setConfig((prev) => {
|
|
70
|
-
const next = { ...prev, ...patch };
|
|
71
|
-
saveConfig(next);
|
|
72
|
-
return next;
|
|
73
|
-
});
|
|
74
|
-
},
|
|
75
|
-
[saveConfig],
|
|
76
|
-
);
|
|
77
|
-
|
|
78
|
-
const updateResolution = useCallback(
|
|
79
|
-
(key: 'width' | 'height', value: number) => {
|
|
80
|
-
setConfig((prev) => {
|
|
81
|
-
const next = { ...prev, resolution: { ...prev.resolution, [key]: Math.round(value) } };
|
|
82
|
-
saveConfig(next);
|
|
83
|
-
return next;
|
|
84
|
-
});
|
|
85
|
-
},
|
|
86
|
-
[saveConfig],
|
|
87
|
-
);
|
|
88
|
-
|
|
89
|
-
const startBuild = useCallback(async () => {
|
|
90
|
-
setPhase('building');
|
|
91
|
-
setLog([]);
|
|
92
|
-
setResult(null);
|
|
93
|
-
|
|
94
|
-
const controller = new AbortController();
|
|
95
|
-
abortRef.current = controller;
|
|
96
|
-
|
|
97
|
-
try {
|
|
98
|
-
const res = await startExport(selected, controller.signal);
|
|
99
|
-
|
|
100
|
-
if (!res.ok) {
|
|
101
|
-
const err = await res.json().catch(() => ({ error: 'Build request failed' }));
|
|
102
|
-
setLog((prev) => [...prev, `Error: ${err.error ?? res.statusText}`]);
|
|
103
|
-
setResult({ ok: false, code: null });
|
|
104
|
-
setPhase('done');
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
const reader = res.body!.getReader();
|
|
109
|
-
const decoder = new TextDecoder();
|
|
110
|
-
let buffer = '';
|
|
111
|
-
|
|
112
|
-
while (true) {
|
|
113
|
-
const { done, value } = await reader.read();
|
|
114
|
-
if (done) break;
|
|
115
|
-
buffer += decoder.decode(value, { stream: true });
|
|
116
|
-
|
|
117
|
-
const parts = buffer.split('\n\n');
|
|
118
|
-
buffer = parts.pop()!;
|
|
119
|
-
|
|
120
|
-
for (const part of parts) {
|
|
121
|
-
if (part.startsWith(':')) continue;
|
|
122
|
-
const lines = part.split('\n');
|
|
123
|
-
let event = '';
|
|
124
|
-
let data = '';
|
|
125
|
-
for (const line of lines) {
|
|
126
|
-
if (line.startsWith('event: ')) event = line.slice(7);
|
|
127
|
-
else if (line.startsWith('data: ')) data = line.slice(6);
|
|
128
|
-
}
|
|
129
|
-
if (event === 'log') {
|
|
130
|
-
try {
|
|
131
|
-
const text = JSON.parse(data) as string;
|
|
132
|
-
setLog((prev) => [...prev, text]);
|
|
133
|
-
} catch {
|
|
134
|
-
setLog((prev) => [...prev, data]);
|
|
135
|
-
}
|
|
136
|
-
} else if (event === 'done') {
|
|
137
|
-
try {
|
|
138
|
-
const r = JSON.parse(data) as BuildResult;
|
|
139
|
-
setResult(r);
|
|
140
|
-
} catch {
|
|
141
|
-
setResult({ ok: false, code: null });
|
|
142
|
-
}
|
|
143
|
-
setPhase('done');
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
} catch (err: unknown) {
|
|
148
|
-
if ((err as Error).name !== 'AbortError') {
|
|
149
|
-
setLog((prev) => [...prev, `Error: ${(err as Error).message}`]);
|
|
150
|
-
setResult({ ok: false, code: null });
|
|
151
|
-
setPhase('done');
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}, [selected]);
|
|
155
|
-
|
|
156
|
-
const cancelBuild = useCallback(() => {
|
|
157
|
-
abortRef.current?.abort();
|
|
158
|
-
setPhase('idle');
|
|
159
|
-
}, []);
|
|
160
|
-
|
|
161
|
-
const targetInfo = TARGETS.find((t) => t.id === selected)!;
|
|
162
|
-
|
|
163
|
-
return (
|
|
164
|
-
<div style={{ display: 'flex', flex: 1, minHeight: 0, background: '#2c2c2c' }}>
|
|
165
|
-
{/* Left: target list */}
|
|
166
|
-
<div style={targetListStyle}>
|
|
167
|
-
{TARGETS.map((t) => (
|
|
168
|
-
<div
|
|
169
|
-
key={t.id}
|
|
170
|
-
onClick={() => {
|
|
171
|
-
if (phase !== 'building') setSelected(t.id);
|
|
172
|
-
}}
|
|
173
|
-
style={{
|
|
174
|
-
padding: '8px 12px',
|
|
175
|
-
cursor: phase === 'building' ? 'default' : 'pointer',
|
|
176
|
-
background: selected === t.id ? '#353535' : 'transparent',
|
|
177
|
-
borderLeft: `3px solid ${selected === t.id ? '#579EFF' : 'transparent'}`,
|
|
178
|
-
opacity: phase === 'building' && selected !== t.id ? 0.4 : 1,
|
|
179
|
-
}}
|
|
180
|
-
>
|
|
181
|
-
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
|
|
182
|
-
<FontAwesomeIcon
|
|
183
|
-
icon={t.icon}
|
|
184
|
-
style={{ fontSize: 13, color: selected === t.id ? '#579EFF' : '#888' }}
|
|
185
|
-
/>
|
|
186
|
-
<div>
|
|
187
|
-
<div
|
|
188
|
-
style={{
|
|
189
|
-
fontSize: 12,
|
|
190
|
-
fontWeight: 600,
|
|
191
|
-
color: selected === t.id ? '#c5c8ce' : '#999',
|
|
192
|
-
}}
|
|
193
|
-
>
|
|
194
|
-
{t.label}
|
|
195
|
-
</div>
|
|
196
|
-
<div style={{ fontSize: 10, color: '#666', marginTop: 1 }}>{t.subtitle}</div>
|
|
197
|
-
</div>
|
|
198
|
-
</div>
|
|
199
|
-
</div>
|
|
200
|
-
))}
|
|
201
|
-
</div>
|
|
202
|
-
|
|
203
|
-
{/* Right: phase-dependent content */}
|
|
204
|
-
<div style={{ flex: 1, display: 'flex', flexDirection: 'column', minWidth: 0 }}>
|
|
205
|
-
{/* Idle: settings + build button */}
|
|
206
|
-
{phase === 'idle' && (
|
|
207
|
-
<div style={{ flex: 1, display: 'flex', flexDirection: 'column', padding: '10px 16px' }}>
|
|
208
|
-
<div style={sectionHeaderStyle}>Project</div>
|
|
209
|
-
|
|
210
|
-
<div style={fieldRowStyle}>
|
|
211
|
-
<label style={labelStyle}>Name</label>
|
|
212
|
-
<input
|
|
213
|
-
style={textInputStyle}
|
|
214
|
-
value={config.name}
|
|
215
|
-
onChange={(e) => updateConfig({ name: e.target.value })}
|
|
216
|
-
/>
|
|
217
|
-
</div>
|
|
218
|
-
|
|
219
|
-
<div style={fieldRowStyle}>
|
|
220
|
-
<label style={labelStyle}>Resolution</label>
|
|
221
|
-
<div style={{ display: 'flex', alignItems: 'center', gap: 4, flex: 1 }}>
|
|
222
|
-
<input
|
|
223
|
-
type="number"
|
|
224
|
-
style={{ ...textInputStyle, width: 0, flex: 1 }}
|
|
225
|
-
value={config.resolution.width}
|
|
226
|
-
onChange={(e) => {
|
|
227
|
-
const v = Number.parseInt(e.target.value, 10);
|
|
228
|
-
if (Number.isFinite(v) && v > 0) updateResolution('width', v);
|
|
229
|
-
}}
|
|
230
|
-
/>
|
|
231
|
-
<span style={{ fontSize: 10, color: '#666' }}>×</span>
|
|
232
|
-
<input
|
|
233
|
-
type="number"
|
|
234
|
-
style={{ ...textInputStyle, width: 0, flex: 1 }}
|
|
235
|
-
value={config.resolution.height}
|
|
236
|
-
onChange={(e) => {
|
|
237
|
-
const v = Number.parseInt(e.target.value, 10);
|
|
238
|
-
if (Number.isFinite(v) && v > 0) updateResolution('height', v);
|
|
239
|
-
}}
|
|
240
|
-
/>
|
|
241
|
-
</div>
|
|
242
|
-
</div>
|
|
243
|
-
|
|
244
|
-
<div style={fieldRowStyle}>
|
|
245
|
-
<label style={labelStyle}>App ID</label>
|
|
246
|
-
<input
|
|
247
|
-
style={textInputStyle}
|
|
248
|
-
value={config.appId}
|
|
249
|
-
onChange={(e) => updateConfig({ appId: e.target.value })}
|
|
250
|
-
/>
|
|
251
|
-
</div>
|
|
252
|
-
|
|
253
|
-
<div style={{ ...fieldRowStyle, marginTop: 4 }}>
|
|
254
|
-
<label style={labelStyle}>Output</label>
|
|
255
|
-
<span style={{ fontSize: 12, color: '#888' }}>{targetInfo.output}</span>
|
|
256
|
-
</div>
|
|
257
|
-
|
|
258
|
-
<div
|
|
259
|
-
style={{
|
|
260
|
-
marginTop: 'auto',
|
|
261
|
-
display: 'flex',
|
|
262
|
-
justifyContent: 'flex-end',
|
|
263
|
-
paddingTop: 8,
|
|
264
|
-
}}
|
|
265
|
-
>
|
|
266
|
-
<button type="button" onClick={startBuild} style={buildBtnStyle}>
|
|
267
|
-
Build
|
|
268
|
-
</button>
|
|
269
|
-
</div>
|
|
270
|
-
</div>
|
|
271
|
-
)}
|
|
272
|
-
|
|
273
|
-
{/* Building: log */}
|
|
274
|
-
{phase === 'building' && (
|
|
275
|
-
<div style={{ flex: 1, display: 'flex', flexDirection: 'column' }}>
|
|
276
|
-
<div style={buildingHeaderStyle}>
|
|
277
|
-
<span>Building for {targetInfo.label}...</span>
|
|
278
|
-
<button type="button" onClick={cancelBuild} style={smallBtnStyle}>
|
|
279
|
-
Cancel
|
|
280
|
-
</button>
|
|
281
|
-
</div>
|
|
282
|
-
<div ref={logRef} style={logBoxStyle}>
|
|
283
|
-
{log.map((line, i) => (
|
|
284
|
-
<div key={i}>{line || '\u00A0'}</div>
|
|
285
|
-
))}
|
|
286
|
-
<div
|
|
287
|
-
style={{
|
|
288
|
-
display: 'inline-block',
|
|
289
|
-
width: 6,
|
|
290
|
-
height: 14,
|
|
291
|
-
background: '#579EFF',
|
|
292
|
-
animation: 'blink 1s step-end infinite',
|
|
293
|
-
}}
|
|
294
|
-
/>
|
|
295
|
-
</div>
|
|
296
|
-
</div>
|
|
297
|
-
)}
|
|
298
|
-
|
|
299
|
-
{/* Done: result */}
|
|
300
|
-
{phase === 'done' && (
|
|
301
|
-
<div
|
|
302
|
-
style={{
|
|
303
|
-
flex: 1,
|
|
304
|
-
display: 'flex',
|
|
305
|
-
flexDirection: 'column',
|
|
306
|
-
alignItems: 'center',
|
|
307
|
-
justifyContent: 'center',
|
|
308
|
-
gap: 8,
|
|
309
|
-
padding: 16,
|
|
310
|
-
}}
|
|
311
|
-
>
|
|
312
|
-
<div style={{ fontSize: 28, color: result?.ok ? '#4ec9b0' : '#ff6b6b' }}>
|
|
313
|
-
{result?.ok ? '\u2713' : '\u2717'}
|
|
314
|
-
</div>
|
|
315
|
-
<div style={{ fontSize: 13, fontWeight: 600, color: '#c5c8ce' }}>
|
|
316
|
-
{result?.ok ? 'Build Complete' : 'Build Failed'}
|
|
317
|
-
</div>
|
|
318
|
-
{result?.ok ? (
|
|
319
|
-
<div style={{ fontSize: 12, color: '#888' }}>{targetInfo.output}</div>
|
|
320
|
-
) : (
|
|
321
|
-
<div style={{ fontSize: 12, color: '#888' }}>
|
|
322
|
-
Exit code: {result?.code ?? 'unknown'}
|
|
323
|
-
</div>
|
|
324
|
-
)}
|
|
325
|
-
<div style={{ display: 'flex', gap: 8, marginTop: 8 }}>
|
|
326
|
-
{result?.ok && selected === 'web' && (
|
|
327
|
-
<a
|
|
328
|
-
href={getDownloadUrl(targetInfo.output)}
|
|
329
|
-
download={targetInfo.output}
|
|
330
|
-
style={downloadBtnStyle}
|
|
331
|
-
>
|
|
332
|
-
Download
|
|
333
|
-
</a>
|
|
334
|
-
)}
|
|
335
|
-
<button
|
|
336
|
-
type="button"
|
|
337
|
-
onClick={() => {
|
|
338
|
-
setPhase('idle');
|
|
339
|
-
setLog([]);
|
|
340
|
-
setResult(null);
|
|
341
|
-
}}
|
|
342
|
-
style={buildBtnStyle}
|
|
343
|
-
>
|
|
344
|
-
Build Again
|
|
345
|
-
</button>
|
|
346
|
-
</div>
|
|
347
|
-
</div>
|
|
348
|
-
)}
|
|
349
|
-
</div>
|
|
350
|
-
</div>
|
|
351
|
-
);
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
/* ---- Styles ---- */
|
|
355
|
-
|
|
356
|
-
const targetListStyle: React.CSSProperties = {
|
|
357
|
-
width: 140,
|
|
358
|
-
flexShrink: 0,
|
|
359
|
-
borderRight: '1px solid #333',
|
|
360
|
-
overflowY: 'auto',
|
|
361
|
-
};
|
|
362
|
-
|
|
363
|
-
const sectionHeaderStyle: React.CSSProperties = {
|
|
364
|
-
fontSize: 10,
|
|
365
|
-
fontWeight: 700,
|
|
366
|
-
textTransform: 'uppercase',
|
|
367
|
-
color: '#666',
|
|
368
|
-
letterSpacing: '0.05em',
|
|
369
|
-
marginBottom: 6,
|
|
370
|
-
};
|
|
371
|
-
|
|
372
|
-
const fieldRowStyle: React.CSSProperties = {
|
|
373
|
-
display: 'flex',
|
|
374
|
-
alignItems: 'center',
|
|
375
|
-
gap: 6,
|
|
376
|
-
marginBottom: 4,
|
|
377
|
-
};
|
|
378
|
-
|
|
379
|
-
const labelStyle: React.CSSProperties = {
|
|
380
|
-
width: 65,
|
|
381
|
-
fontSize: 11,
|
|
382
|
-
color: '#8c8c8c',
|
|
383
|
-
flexShrink: 0,
|
|
384
|
-
};
|
|
385
|
-
|
|
386
|
-
const textInputStyle: React.CSSProperties = {
|
|
387
|
-
flex: 1,
|
|
388
|
-
background: '#1e1e1e',
|
|
389
|
-
color: '#c5c8ce',
|
|
390
|
-
border: '1px solid #333',
|
|
391
|
-
borderRadius: 2,
|
|
392
|
-
padding: '2px 6px',
|
|
393
|
-
fontSize: 12,
|
|
394
|
-
outline: 'none',
|
|
395
|
-
minWidth: 0,
|
|
396
|
-
};
|
|
397
|
-
|
|
398
|
-
const buildingHeaderStyle: React.CSSProperties = {
|
|
399
|
-
display: 'flex',
|
|
400
|
-
alignItems: 'center',
|
|
401
|
-
justifyContent: 'space-between',
|
|
402
|
-
padding: '8px 12px',
|
|
403
|
-
fontSize: 12,
|
|
404
|
-
fontWeight: 600,
|
|
405
|
-
color: '#579EFF',
|
|
406
|
-
flexShrink: 0,
|
|
407
|
-
borderBottom: '1px solid #333',
|
|
408
|
-
};
|
|
409
|
-
|
|
410
|
-
const smallBtnStyle: React.CSSProperties = {
|
|
411
|
-
background: '#333',
|
|
412
|
-
color: '#c5c8ce',
|
|
413
|
-
border: '1px solid #444',
|
|
414
|
-
borderRadius: 4,
|
|
415
|
-
padding: '4px 12px',
|
|
416
|
-
fontSize: 11,
|
|
417
|
-
cursor: 'pointer',
|
|
418
|
-
};
|
|
419
|
-
|
|
420
|
-
const buildBtnStyle: React.CSSProperties = {
|
|
421
|
-
background: '#579EFF',
|
|
422
|
-
color: '#fff',
|
|
423
|
-
border: '1px solid #6AADFF',
|
|
424
|
-
borderRadius: 4,
|
|
425
|
-
padding: '6px 16px',
|
|
426
|
-
fontSize: 12,
|
|
427
|
-
fontWeight: 600,
|
|
428
|
-
cursor: 'pointer',
|
|
429
|
-
};
|
|
430
|
-
|
|
431
|
-
const downloadBtnStyle: React.CSSProperties = {
|
|
432
|
-
background: '#333',
|
|
433
|
-
color: '#c5c8ce',
|
|
434
|
-
border: '1px solid #444',
|
|
435
|
-
borderRadius: 4,
|
|
436
|
-
padding: '6px 16px',
|
|
437
|
-
fontSize: 12,
|
|
438
|
-
cursor: 'pointer',
|
|
439
|
-
textDecoration: 'none',
|
|
440
|
-
display: 'inline-block',
|
|
441
|
-
};
|
|
442
|
-
|
|
443
|
-
const logBoxStyle: React.CSSProperties = {
|
|
444
|
-
flex: 1,
|
|
445
|
-
overflowY: 'auto',
|
|
446
|
-
background: '#1a1a1a',
|
|
447
|
-
padding: '4px 8px',
|
|
448
|
-
fontFamily: 'ui-monospace, "SF Mono", Menlo, Consolas, monospace',
|
|
449
|
-
fontSize: 11,
|
|
450
|
-
lineHeight: '16px',
|
|
451
|
-
color: '#aaa',
|
|
452
|
-
whiteSpace: 'pre-wrap',
|
|
453
|
-
wordBreak: 'break-all',
|
|
454
|
-
minHeight: 0,
|
|
455
|
-
};
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
import { faChevronDown, faChevronRight, faFolder } from '@fortawesome/free-solid-svg-icons';
|
|
2
|
-
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
3
|
-
import { useCallback, useEffect, useReducer, useRef, useState } from 'react';
|
|
4
|
-
import { listAssets } from '../editor-api';
|
|
5
|
-
|
|
6
|
-
// --- Types ---
|
|
7
|
-
|
|
8
|
-
interface FolderTreeNode {
|
|
9
|
-
id: string;
|
|
10
|
-
name: string;
|
|
11
|
-
root: string;
|
|
12
|
-
path: string;
|
|
13
|
-
children: FolderTreeNode[];
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
interface FolderTreeProps {
|
|
17
|
-
currentPath: string;
|
|
18
|
-
currentRoot: string;
|
|
19
|
-
onNavigate: (root: string, path: string) => void;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
interface FolderRow {
|
|
23
|
-
node: FolderTreeNode;
|
|
24
|
-
depth: number;
|
|
25
|
-
hasChildren: boolean;
|
|
26
|
-
isOpen: boolean;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// --- Helpers ---
|
|
30
|
-
|
|
31
|
-
function makeNodeId(root: string, path: string): string {
|
|
32
|
-
return `${root}:${path}`;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
async function fetchSubfolders(root: string, dir: string): Promise<FolderTreeNode[]> {
|
|
36
|
-
const entries = await listAssets(root, dir);
|
|
37
|
-
return entries
|
|
38
|
-
.filter((e) => e.type === 'directory')
|
|
39
|
-
.map((e) => {
|
|
40
|
-
const path = dir ? `${dir}/${e.name}` : e.name;
|
|
41
|
-
return {
|
|
42
|
-
id: makeNodeId(root, path),
|
|
43
|
-
name: e.name,
|
|
44
|
-
root,
|
|
45
|
-
path,
|
|
46
|
-
children: [],
|
|
47
|
-
};
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/** Recursively replace children of a target node by ID. */
|
|
52
|
-
function updateNodeChildren(
|
|
53
|
-
nodes: FolderTreeNode[],
|
|
54
|
-
targetId: string,
|
|
55
|
-
newChildren: FolderTreeNode[],
|
|
56
|
-
): FolderTreeNode[] {
|
|
57
|
-
return nodes.map((node) => {
|
|
58
|
-
if (node.id === targetId) return { ...node, children: newChildren };
|
|
59
|
-
if (node.children.length > 0) {
|
|
60
|
-
const updated = updateNodeChildren(node.children, targetId, newChildren);
|
|
61
|
-
if (updated !== node.children) return { ...node, children: updated };
|
|
62
|
-
}
|
|
63
|
-
return node;
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function flattenFolderRows(nodes: FolderTreeNode[], openIds: Set<string>, depth = 0): FolderRow[] {
|
|
68
|
-
const rows: FolderRow[] = [];
|
|
69
|
-
for (const node of nodes) {
|
|
70
|
-
const isOpen = openIds.has(node.id);
|
|
71
|
-
// Show as having children if explicitly opened (children may be loading)
|
|
72
|
-
// or if children array is non-empty
|
|
73
|
-
const hasChildren = node.children.length > 0 || isOpen;
|
|
74
|
-
rows.push({ node, depth, hasChildren, isOpen });
|
|
75
|
-
if (isOpen && node.children.length > 0) {
|
|
76
|
-
rows.push(...flattenFolderRows(node.children, openIds, depth + 1));
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
return rows;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// --- Main Component ---
|
|
83
|
-
|
|
84
|
-
export function FolderTree({ currentPath, currentRoot, onNavigate }: FolderTreeProps) {
|
|
85
|
-
const [treeData, setTreeData] = useState<FolderTreeNode[]>([]);
|
|
86
|
-
const openIdsRef = useRef(new Set<string>());
|
|
87
|
-
const loadedRef = useRef(new Set<string>());
|
|
88
|
-
const [, forceUpdate] = useReducer((x: number) => x + 1, 0);
|
|
89
|
-
|
|
90
|
-
// Load top-level folders directly (no wrapper "public" node)
|
|
91
|
-
useEffect(() => {
|
|
92
|
-
fetchSubfolders('public', '').then((topFolders) => {
|
|
93
|
-
setTreeData(topFolders);
|
|
94
|
-
});
|
|
95
|
-
}, []);
|
|
96
|
-
|
|
97
|
-
const loadChildren = useCallback((id: string, root: string, path: string) => {
|
|
98
|
-
if (loadedRef.current.has(id)) return;
|
|
99
|
-
loadedRef.current.add(id);
|
|
100
|
-
fetchSubfolders(root, path).then((children) => {
|
|
101
|
-
setTreeData((prev) => updateNodeChildren(prev, id, children));
|
|
102
|
-
});
|
|
103
|
-
}, []);
|
|
104
|
-
|
|
105
|
-
const selectedId = makeNodeId(currentRoot, currentPath);
|
|
106
|
-
const rows = flattenFolderRows(treeData, openIdsRef.current);
|
|
107
|
-
|
|
108
|
-
return (
|
|
109
|
-
<div style={{ flex: 1, minHeight: 0, overflow: 'auto', paddingTop: 4 }}>
|
|
110
|
-
{rows.map((row) => {
|
|
111
|
-
const data = row.node;
|
|
112
|
-
const isActive = data.id === selectedId;
|
|
113
|
-
|
|
114
|
-
return (
|
|
115
|
-
<div
|
|
116
|
-
key={data.id}
|
|
117
|
-
style={{
|
|
118
|
-
display: 'flex',
|
|
119
|
-
alignItems: 'center',
|
|
120
|
-
height: 24,
|
|
121
|
-
gap: 4,
|
|
122
|
-
paddingLeft: row.depth * 14,
|
|
123
|
-
cursor: 'pointer',
|
|
124
|
-
background: isActive ? '#579EFF33' : 'transparent',
|
|
125
|
-
color: isActive ? '#fff' : '#c5c8ce',
|
|
126
|
-
borderRadius: 2,
|
|
127
|
-
whiteSpace: 'nowrap',
|
|
128
|
-
overflow: 'hidden',
|
|
129
|
-
fontSize: 12,
|
|
130
|
-
}}
|
|
131
|
-
onClick={() => {
|
|
132
|
-
onNavigate(data.root, data.path);
|
|
133
|
-
if (!row.isOpen) {
|
|
134
|
-
openIdsRef.current.add(data.id);
|
|
135
|
-
loadChildren(data.id, data.root, data.path);
|
|
136
|
-
forceUpdate();
|
|
137
|
-
}
|
|
138
|
-
}}
|
|
139
|
-
onMouseEnter={(e) => {
|
|
140
|
-
if (!isActive) (e.currentTarget as HTMLDivElement).style.background = '#333';
|
|
141
|
-
}}
|
|
142
|
-
onMouseLeave={(e) => {
|
|
143
|
-
if (!isActive) (e.currentTarget as HTMLDivElement).style.background = 'transparent';
|
|
144
|
-
}}
|
|
145
|
-
>
|
|
146
|
-
{/* Expand/collapse arrow */}
|
|
147
|
-
<span
|
|
148
|
-
onClick={(e) => {
|
|
149
|
-
e.stopPropagation();
|
|
150
|
-
const set = openIdsRef.current;
|
|
151
|
-
if (set.has(data.id)) {
|
|
152
|
-
set.delete(data.id);
|
|
153
|
-
} else {
|
|
154
|
-
set.add(data.id);
|
|
155
|
-
loadChildren(data.id, data.root, data.path);
|
|
156
|
-
}
|
|
157
|
-
forceUpdate();
|
|
158
|
-
}}
|
|
159
|
-
style={{
|
|
160
|
-
width: 10,
|
|
161
|
-
fontSize: 8,
|
|
162
|
-
textAlign: 'center',
|
|
163
|
-
flexShrink: 0,
|
|
164
|
-
color: '#8c8c8c',
|
|
165
|
-
userSelect: 'none',
|
|
166
|
-
}}
|
|
167
|
-
>
|
|
168
|
-
<FontAwesomeIcon icon={row.isOpen ? faChevronDown : faChevronRight} />
|
|
169
|
-
</span>
|
|
170
|
-
<span style={{ fontSize: 12, color: '#e8a740' }}>
|
|
171
|
-
<FontAwesomeIcon icon={faFolder} />
|
|
172
|
-
</span>
|
|
173
|
-
<span style={{ overflow: 'hidden', textOverflow: 'ellipsis' }}>{data.name}</span>
|
|
174
|
-
</div>
|
|
175
|
-
);
|
|
176
|
-
})}
|
|
177
|
-
</div>
|
|
178
|
-
);
|
|
179
|
-
}
|