@vgai/editor 0.2.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/LICENSE +661 -0
- package/README.md +35 -0
- package/dist/a/b/c/test-nested.json +1 -0
- package/dist/assets/CCDIKSolver-Dz-ysxZF.js +1 -0
- package/dist/assets/SelectionBox-BXsv_6aH.js +1 -0
- package/dist/assets/browser-project-scripts-DOru4L1x.js +2 -0
- package/dist/assets/browserAll-CEkWYlFk.js +1 -0
- package/dist/assets/collision-world-DniMB0qq.glb +0 -0
- package/dist/assets/create-runtime-DYIWr3va.js +1 -0
- package/dist/assets/data-asset-Bb9sIM7i.js +5 -0
- package/dist/assets/esbuild-BHljloGq.wasm +0 -0
- package/dist/assets/fake-three-BMTQ9rl_.js +1 -0
- package/dist/assets/game-8SDZPPgH.js +1 -0
- package/dist/assets/game-BI111o5f.js +10 -0
- package/dist/assets/game-CevorxyV.js +1 -0
- package/dist/assets/game-Di1H0gFj.js +1 -0
- package/dist/assets/game-Di7XlywD.js +1 -0
- package/dist/assets/game-DjnCaw8R.js +1 -0
- package/dist/assets/game-Q9A0aXSV.js +1 -0
- package/dist/assets/game-pt_1lQLv.js +1 -0
- package/dist/assets/game-source-CvidN7AB.js +1 -0
- package/dist/assets/game-xsOho_wg.js +83 -0
- package/dist/assets/index-Bp5cecD6.js +12 -0
- package/dist/assets/index-CPVV6pjw.js +1 -0
- package/dist/assets/index-CpOnYyeD.js +213 -0
- package/dist/assets/index-Cs8xwv3e.js +1 -0
- package/dist/assets/index-DL7RcQ0n.js +27 -0
- package/dist/assets/index-Dr8H_6Rl.js +1 -0
- package/dist/assets/index-_bCaipUk.js +13650 -0
- package/dist/assets/ingest-siblings-Dz8eEqrV.js +1 -0
- package/dist/assets/mount-manifest-Bhk0ohsl.js +1 -0
- package/dist/assets/recast-navigation.wasm-compat-CvP4UGK6.js +1 -0
- package/dist/assets/scene-query-BivAHhJu.js +1 -0
- package/dist/assets/stats.module--VATS4Kh.js +1 -0
- package/dist/assets/webworkerAll-BLrH0F6F.js +1 -0
- package/dist/assets/xstate-animation-binding-1NGLmw6y.js +1 -0
- package/dist/assets/xstate.esm-BgUD33nl.js +3 -0
- package/dist/index.html +37 -0
- package/dist/ingest/racing-game/UPSTREAM.md +68 -0
- package/dist/ingest/racing-game/a/Inter-Black.woff +0 -0
- package/dist/ingest/racing-game/a/Inter-Black.woff2 +0 -0
- package/dist/ingest/racing-game/a/Inter-BlackItalic.woff +0 -0
- package/dist/ingest/racing-game/a/Inter-BlackItalic.woff2 +0 -0
- package/dist/ingest/racing-game/a/Inter-Bold.woff +0 -0
- package/dist/ingest/racing-game/a/Inter-Bold.woff2 +0 -0
- package/dist/ingest/racing-game/a/Inter-BoldItalic.woff +0 -0
- package/dist/ingest/racing-game/a/Inter-BoldItalic.woff2 +0 -0
- package/dist/ingest/racing-game/a/Inter-ExtraBold.woff +0 -0
- package/dist/ingest/racing-game/a/Inter-ExtraBold.woff2 +0 -0
- package/dist/ingest/racing-game/a/Inter-ExtraBoldItalic.woff +0 -0
- package/dist/ingest/racing-game/a/Inter-ExtraBoldItalic.woff2 +0 -0
- package/dist/ingest/racing-game/a/Inter-ExtraLight.woff +0 -0
- package/dist/ingest/racing-game/a/Inter-ExtraLight.woff2 +0 -0
- package/dist/ingest/racing-game/a/Inter-ExtraLightItalic.woff +0 -0
- package/dist/ingest/racing-game/a/Inter-ExtraLightItalic.woff2 +0 -0
- package/dist/ingest/racing-game/a/Inter-Italic.woff +0 -0
- package/dist/ingest/racing-game/a/Inter-Italic.woff2 +0 -0
- package/dist/ingest/racing-game/a/Inter-Light.woff +0 -0
- package/dist/ingest/racing-game/a/Inter-Light.woff2 +0 -0
- package/dist/ingest/racing-game/a/Inter-LightItalic.woff +0 -0
- package/dist/ingest/racing-game/a/Inter-LightItalic.woff2 +0 -0
- package/dist/ingest/racing-game/a/Inter-Medium.woff +0 -0
- package/dist/ingest/racing-game/a/Inter-Medium.woff2 +0 -0
- package/dist/ingest/racing-game/a/Inter-MediumItalic.woff +0 -0
- package/dist/ingest/racing-game/a/Inter-MediumItalic.woff2 +0 -0
- package/dist/ingest/racing-game/a/Inter-Regular.woff +0 -0
- package/dist/ingest/racing-game/a/Inter-Regular.woff2 +0 -0
- package/dist/ingest/racing-game/a/Inter-SemiBold.woff +0 -0
- package/dist/ingest/racing-game/a/Inter-SemiBold.woff2 +0 -0
- package/dist/ingest/racing-game/a/Inter-SemiBoldItalic.woff +0 -0
- package/dist/ingest/racing-game/a/Inter-SemiBoldItalic.woff2 +0 -0
- package/dist/ingest/racing-game/a/Inter-Thin.woff +0 -0
- package/dist/ingest/racing-game/a/Inter-Thin.woff2 +0 -0
- package/dist/ingest/racing-game/a/Inter-ThinItalic.woff +0 -0
- package/dist/ingest/racing-game/a/Inter-ThinItalic.woff2 +0 -0
- package/dist/ingest/racing-game/a/Inter-italic.var.woff2 +0 -0
- package/dist/ingest/racing-game/a/Inter-roman.var.woff2 +0 -0
- package/dist/ingest/racing-game/a/Inter.var.woff2 +0 -0
- package/dist/ingest/racing-game/a/index.css +1 -0
- package/dist/ingest/racing-game/images/bronze.png +0 -0
- package/dist/ingest/racing-game/images/gold.png +0 -0
- package/dist/ingest/racing-game/images/silver.png +0 -0
- package/dist/ingest/racing-game/index.html +15 -0
- package/dist/ingest/racing-game/models/chassis-draco.glb +0 -0
- package/dist/ingest/racing-game/models/track-draco.glb +0 -0
- package/dist/ingest/racing-game/models/wheel-draco.glb +0 -0
- package/dist/ingest/racing-game/rg-entry.js +1 -0
- package/dist/ingest/racing-game/sounds/accelerate.mp3 +0 -0
- package/dist/ingest/racing-game/sounds/boost.mp3 +0 -0
- package/dist/ingest/racing-game/sounds/crash.mp3 +0 -0
- package/dist/ingest/racing-game/sounds/engine.mp3 +0 -0
- package/dist/ingest/racing-game/sounds/honk.mp3 +0 -0
- package/dist/ingest/racing-game/sounds/tire-brake.mp3 +0 -0
- package/dist/ingest/racing-game/sounds/train.mp3 +0 -0
- package/dist/ingest/racing-game/sounds/water.mp3 +0 -0
- package/dist/ingest/racing-game/textures/cursor.svg +3 -0
- package/dist/ingest/racing-game/textures/dikhololo_night_1k.hdr +0 -0
- package/dist/ingest/racing-game/textures/heightmap_1024.png +0 -0
- package/dist/ingest/racing-game/textures/mask.svg +11 -0
- package/dist/ingest/racing-game/textures/no_sound.png +0 -0
- package/dist/ingest/racing-game/three-r139.module.js +50617 -0
- package/dist/ingest/racing-game/vendor.js +179 -0
- package/dist/ingest/racing-game/vgai.game.json +20 -0
- package/dist/ingest/simcity/UPSTREAM.md +65 -0
- package/dist/ingest/simcity/favicon.ico +0 -0
- package/dist/ingest/simcity/fonts/Bebas-Regular.otf +0 -0
- package/dist/ingest/simcity/fonts/Digitalt.otf +0 -0
- package/dist/ingest/simcity/fonts/Stanberry.ttf +0 -0
- package/dist/ingest/simcity/icons/bulldozer-color.png +0 -0
- package/dist/ingest/simcity/icons/bulldozer.png +0 -0
- package/dist/ingest/simcity/icons/calendar.png +0 -0
- package/dist/ingest/simcity/icons/factory-color.png +0 -0
- package/dist/ingest/simcity/icons/factory.png +0 -0
- package/dist/ingest/simcity/icons/house-color.png +0 -0
- package/dist/ingest/simcity/icons/house.png +0 -0
- package/dist/ingest/simcity/icons/job.png +0 -0
- package/dist/ingest/simcity/icons/office.png +0 -0
- package/dist/ingest/simcity/icons/pause-color.png +0 -0
- package/dist/ingest/simcity/icons/pause.png +0 -0
- package/dist/ingest/simcity/icons/person.png +0 -0
- package/dist/ingest/simcity/icons/play-color.png +0 -0
- package/dist/ingest/simcity/icons/play.png +0 -0
- package/dist/ingest/simcity/icons/power-color.png +0 -0
- package/dist/ingest/simcity/icons/power-line-color.png +0 -0
- package/dist/ingest/simcity/icons/power.png +0 -0
- package/dist/ingest/simcity/icons/road-color.png +0 -0
- package/dist/ingest/simcity/icons/road.png +0 -0
- package/dist/ingest/simcity/icons/select-color.png +0 -0
- package/dist/ingest/simcity/icons/select.png +0 -0
- package/dist/ingest/simcity/icons/store-color.png +0 -0
- package/dist/ingest/simcity/index.html +94 -0
- package/dist/ingest/simcity/index.js +58 -0
- package/dist/ingest/simcity/main.css +233 -0
- package/dist/ingest/simcity/models/armored-truck.glb +0 -0
- package/dist/ingest/simcity/models/building-block-4floor-corner.glb +0 -0
- package/dist/ingest/simcity/models/building-block-4floor-short.glb +0 -0
- package/dist/ingest/simcity/models/building-block-5floor.glb +0 -0
- package/dist/ingest/simcity/models/building-burger-joint.glb +0 -0
- package/dist/ingest/simcity/models/building-cafe.glb +0 -0
- package/dist/ingest/simcity/models/building-casino.glb +0 -0
- package/dist/ingest/simcity/models/building-cinema.glb +0 -0
- package/dist/ingest/simcity/models/building-house-block-big.glb +0 -0
- package/dist/ingest/simcity/models/building-house-family-large.glb +0 -0
- package/dist/ingest/simcity/models/building-house-family-small.glb +0 -0
- package/dist/ingest/simcity/models/building-office-balcony.glb +0 -0
- package/dist/ingest/simcity/models/building-office-big.glb +0 -0
- package/dist/ingest/simcity/models/building-office-pyramid.glb +0 -0
- package/dist/ingest/simcity/models/building-office-tall.glb +0 -0
- package/dist/ingest/simcity/models/building-office.glb +0 -0
- package/dist/ingest/simcity/models/building-restaurant.glb +0 -0
- package/dist/ingest/simcity/models/building-skyscraper.glb +0 -0
- package/dist/ingest/simcity/models/car-ambulance-pickup.glb +0 -0
- package/dist/ingest/simcity/models/car-baywatch.glb +0 -0
- package/dist/ingest/simcity/models/car-hippie-van.glb +0 -0
- package/dist/ingest/simcity/models/car-passenger-race.glb +0 -0
- package/dist/ingest/simcity/models/car-passenger.glb +0 -0
- package/dist/ingest/simcity/models/car-police.glb +0 -0
- package/dist/ingest/simcity/models/car-taxi.glb +0 -0
- package/dist/ingest/simcity/models/car-tow-truck.glb +0 -0
- package/dist/ingest/simcity/models/car-truck-dump.glb +0 -0
- package/dist/ingest/simcity/models/car-veteran.glb +0 -0
- package/dist/ingest/simcity/models/construction-small.glb +0 -0
- package/dist/ingest/simcity/models/data-center.glb +0 -0
- package/dist/ingest/simcity/models/industry-factory-old.glb +0 -0
- package/dist/ingest/simcity/models/industry-factory.glb +0 -0
- package/dist/ingest/simcity/models/industry-refinery.glb +0 -0
- package/dist/ingest/simcity/models/industry-warehouse.glb +0 -0
- package/dist/ingest/simcity/models/power_line_pole_modified.glb +0 -0
- package/dist/ingest/simcity/models/tile-plain_grass.glb +0 -0
- package/dist/ingest/simcity/models/tile-road-curve.glb +0 -0
- package/dist/ingest/simcity/models/tile-road-end.glb +0 -0
- package/dist/ingest/simcity/models/tile-road-intersection-t.glb +0 -0
- package/dist/ingest/simcity/models/tile-road-intersection.glb +0 -0
- package/dist/ingest/simcity/models/tile-road-straight.glb +0 -0
- package/dist/ingest/simcity/models/truck.glb +0 -0
- package/dist/ingest/simcity/statusIcons/no-power.png +0 -0
- package/dist/ingest/simcity/statusIcons/no-road-access.png +0 -0
- package/dist/ingest/simcity/textures/base.png +0 -0
- package/dist/ingest/simcity/textures/grid.png +0 -0
- package/dist/ingest/simcity/textures/specular.png +0 -0
- package/dist/ingest/simcity/three-r155.module.js +51466 -0
- package/dist/ingest/simcity/vgai.game.json +20 -0
- package/dist/ingest/tanks/UPSTREAM.md +69 -0
- package/dist/ingest/tanks/index.html +214 -0
- package/dist/ingest/tanks/models/pixelTank.fbx +0 -0
- package/dist/ingest/tanks/tanks-entry.js +92 -0
- package/dist/ingest/tanks/three-r170.module.js +54571 -0
- package/dist/ingest/tanks/vgai.game.json +20 -0
- package/dist/inputmaps/default.inputmap.json +41 -0
- package/dist/jsm/libs/draco/gltf/draco_decoder.js +33 -0
- package/dist/jsm/libs/draco/gltf/draco_decoder.wasm +0 -0
- package/dist/jsm/libs/draco/gltf/draco_wasm_wrapper.js +116 -0
- package/dist/scenes/untitled.vscn.json +29 -0
- package/dist/textures/waternormals.jpg +0 -0
- package/dist-server/packaged.mjs +18155 -0
- package/package.json +36 -0
- package/server/asset-library-routes.ts +833 -0
- package/server/canonical-path.ts +50 -0
- package/server/cloud-asset-catalog.ts +101 -0
- package/server/dev.ts +350 -0
- package/server/editor-server.ts +1537 -0
- package/server/editor-sse.ts +73 -0
- package/server/game-globals-shadow.ts +58 -0
- package/server/local-asset-catalog.ts +163 -0
- package/server/packaged.ts +571 -0
- package/server/prod.ts +75 -0
- package/server/project-optimize-deps-entries.ts +149 -0
- package/server/project-view.ts +65 -0
- package/server/server-utils.ts +430 -0
- package/server/session-registry.ts +93 -0
- package/src/EditorContext.tsx +87 -0
- package/src/achieved-tier.ts +126 -0
- package/src/action-registry.ts +268 -0
- package/src/adapter-resolver.ts +1858 -0
- package/src/asset-events.ts +100 -0
- package/src/authoring/active-adapter.ts +98 -0
- package/src/authoring/active-systems.ts +50 -0
- package/src/authoring/boundary-authoring-adapter.ts +178 -0
- package/src/authoring/composite-authoring-adapter.ts +891 -0
- package/src/authoring/design-time-layers.ts +776 -0
- package/src/authoring/edit-mode-authoring.ts +643 -0
- package/src/authoring/embed-only-adapter.ts +57 -0
- package/src/authoring/ephemeral-persistence.ts +26 -0
- package/src/authoring/eyedropper-session.ts +69 -0
- package/src/authoring/first-party-hierarchy-menu.ts +74 -0
- package/src/authoring/first-party-inspector/AddSectionMenu.tsx +118 -0
- package/src/authoring/first-party-inspector/EnvironmentSection.tsx +550 -0
- package/src/authoring/first-party-inspector/HeaderSection.tsx +329 -0
- package/src/authoring/first-party-inspector/is-first-party-selection.ts +44 -0
- package/src/authoring/first-party-inspector/register.tsx +108 -0
- package/src/authoring/ingest-authoring-adapter.ts +475 -0
- package/src/authoring/ingest-capture.ts +94 -0
- package/src/authoring/ingest-game-adapter.ts +291 -0
- package/src/authoring/ingest-iframe-adapter.ts +38 -0
- package/src/authoring/ingest-iframe-reachable-adapter.ts +401 -0
- package/src/authoring/ingest-overlay.ts +193 -0
- package/src/authoring/layered-pick.ts +87 -0
- package/src/authoring/mount-failure-report.ts +112 -0
- package/src/authoring/overlay-report.ts +52 -0
- package/src/authoring/project-scenes.ts +111 -0
- package/src/authoring/react-dom-authoring-adapter.ts +795 -0
- package/src/authoring/react-inspector-section.tsx +1041 -0
- package/src/authoring/react-world-authoring-adapter.ts +2400 -0
- package/src/authoring/root-activation.ts +61 -0
- package/src/authoring/scene-ui-layer.ts +485 -0
- package/src/authoring/story-overlay.ts +48 -0
- package/src/authoring/ui-authoring-adapter.ts +325 -0
- package/src/authoring/ui-hierarchy-menu.ts +40 -0
- package/src/authoring/ui-inspector-sections.tsx +156 -0
- package/src/authoring/undo-timeline.ts +145 -0
- package/src/authoring/vgai-scene-authoring-adapter.ts +746 -0
- package/src/authoring/viewport-pick-context.ts +31 -0
- package/src/authoring/viewport-raycast.ts +80 -0
- package/src/authoring/world-overlay.ts +76 -0
- package/src/authoring/world-pan-state.ts +115 -0
- package/src/authoring/world-session-state.ts +102 -0
- package/src/authoring/world2d-authoring-adapter.ts +313 -0
- package/src/browser-external-watch.ts +98 -0
- package/src/browser-play-entry.ts +112 -0
- package/src/browser-project-scripts.ts +112 -0
- package/src/browser-transpile.ts +246 -0
- package/src/browser-watch-reload.ts +100 -0
- package/src/command-listener.ts +326 -0
- package/src/components/AlignToolbar.tsx +189 -0
- package/src/components/AppRoot.tsx +73 -0
- package/src/components/AssetBrowser.tsx +502 -0
- package/src/components/BottomPanel.tsx +326 -0
- package/src/components/BuildPanel.tsx +455 -0
- package/src/components/CameraInfo.tsx +56 -0
- package/src/components/CommandPalette.tsx +265 -0
- package/src/components/ConsolePanel.tsx +272 -0
- package/src/components/DataPanel.tsx +1268 -0
- package/src/components/DefaultEditorLayout.tsx +509 -0
- package/src/components/FolderTree.tsx +179 -0
- package/src/components/GameHierarchy.tsx +1349 -0
- package/src/components/Inspector.tsx +671 -0
- package/src/components/InspectorToolSection.tsx +74 -0
- package/src/components/MountFailureBanner.tsx +110 -0
- package/src/components/NetworkSection.tsx +109 -0
- package/src/components/OnlineAssetBrowser.tsx +448 -0
- package/src/components/OverlayReportBanner.tsx +122 -0
- package/src/components/PlayBar.tsx +356 -0
- package/src/components/PrefabSaveDialog.tsx +201 -0
- package/src/components/ProjectHeader.tsx +174 -0
- package/src/components/ProjectScreen.tsx +1004 -0
- package/src/components/RightPanel.tsx +166 -0
- package/src/components/RootActivateDialog.tsx +105 -0
- package/src/components/SaveDialog.tsx +197 -0
- package/src/components/SaveStatus.tsx +69 -0
- package/src/components/StatsOverlay.tsx +35 -0
- package/src/components/ToolHost.tsx +80 -0
- package/src/components/Toolbar.tsx +307 -0
- package/src/components/ViewportOverlay.tsx +234 -0
- package/src/components/ViewportPanel.tsx +369 -0
- package/src/components/WorldContextMenu.tsx +257 -0
- package/src/components/WorldSelectionOverlay.tsx +2003 -0
- package/src/components/WorldTextEditor.tsx +86 -0
- package/src/components/asset-viewers/AssetViewer.tsx +38 -0
- package/src/components/asset-viewers/AudioViewer.tsx +149 -0
- package/src/components/asset-viewers/GenericJsonViewer.tsx +77 -0
- package/src/components/asset-viewers/ImageViewer.tsx +65 -0
- package/src/components/asset-viewers/InputMapViewer.tsx +206 -0
- package/src/components/asset-viewers/ModelViewer.tsx +180 -0
- package/src/components/asset-viewers/OnlineAssetDetail.tsx +236 -0
- package/src/components/data-csv.ts +301 -0
- package/src/components/entity-name-commit.ts +18 -0
- package/src/components/inspector-property-grouping.ts +65 -0
- package/src/components/inspector-widgets/AlignmentGrid.tsx +188 -0
- package/src/components/inspector-widgets/BorderEditor.tsx +305 -0
- package/src/components/inspector-widgets/ColorPicker.tsx +548 -0
- package/src/components/inspector-widgets/FilterEditor.tsx +108 -0
- package/src/components/inspector-widgets/FontPicker.tsx +196 -0
- package/src/components/inspector-widgets/GradientEditor.tsx +277 -0
- package/src/components/inspector-widgets/ScrubbableInput.tsx +152 -0
- package/src/components/inspector-widgets/ShadowEditor.tsx +332 -0
- package/src/components/inspector-widgets/color-utils.ts +202 -0
- package/src/components/inspector-widgets/gallery-main.tsx +167 -0
- package/src/components/inspector-widgets/index.ts +22 -0
- package/src/components/inspector-widgets/shared.tsx +135 -0
- package/src/components/inspectors/AnimationSection.tsx +143 -0
- package/src/components/inspectors/AudioSection.tsx +215 -0
- package/src/components/inspectors/BoneAttachmentSection.tsx +82 -0
- package/src/components/inspectors/CameraSection.tsx +105 -0
- package/src/components/inspectors/ComponentsSection.tsx +358 -0
- package/src/components/inspectors/JointsSection.tsx +255 -0
- package/src/components/inspectors/LightSection.tsx +116 -0
- package/src/components/inspectors/MaterialSection.tsx +1189 -0
- package/src/components/inspectors/MeshSection.tsx +99 -0
- package/src/components/inspectors/NavigationSection.tsx +58 -0
- package/src/components/inspectors/ParticleSection.tsx +681 -0
- package/src/components/inspectors/PhysicsSection.tsx +326 -0
- package/src/components/inspectors/PostProcessingSection.tsx +1290 -0
- package/src/components/inspectors/RenderingSection.tsx +109 -0
- package/src/components/inspectors/ShadowSection.tsx +84 -0
- package/src/components/inspectors/SplineSection.tsx +191 -0
- package/src/components/inspectors/TransformSection.tsx +191 -0
- package/src/components/inspectors/json-schema-fields.ts +281 -0
- package/src/components/inspectors/multi-edit-utils.ts +49 -0
- package/src/components/inspectors/zod-fields.ts +184 -0
- package/src/components/primitives/ColorInput.tsx +109 -0
- package/src/components/primitives/JsonInput.tsx +98 -0
- package/src/components/primitives/NumberInput.tsx +164 -0
- package/src/components/primitives/Panel.tsx +68 -0
- package/src/components/primitives/SectionHeader.tsx +45 -0
- package/src/components/primitives/Tooltip.tsx +82 -0
- package/src/components/primitives/Vec3Input.tsx +62 -0
- package/src/components/world-overlay-gestures.ts +1438 -0
- package/src/doctor/data-checks.ts +285 -0
- package/src/doctor/report.ts +386 -0
- package/src/editor-api.ts +700 -0
- package/src/editor-console.ts +194 -0
- package/src/editor-hotkeys.ts +441 -0
- package/src/editor-layers.ts +2 -0
- package/src/editor-mode.ts +28 -0
- package/src/editor-store.ts +2225 -0
- package/src/editor-viewport.ts +1924 -0
- package/src/entity-factory.ts +221 -0
- package/src/game-globals-prelude.ts +27 -0
- package/src/gated-globals.ts +131 -0
- package/src/generated/setup-by-example.generated.ts +53 -0
- package/src/gizmo-registry.ts +608 -0
- package/src/handle-system.ts +221 -0
- package/src/hierarchy-menu-registry.ts +70 -0
- package/src/hierarchy-rows.ts +73 -0
- package/src/hosted-example.ts +160 -0
- package/src/hotkeys.ts +142 -0
- package/src/ingest/discovery-react.ts +132 -0
- package/src/ingest/discovery.ts +205 -0
- package/src/ingest/discovery2d.ts +204 -0
- package/src/ingest/esm-entry-resolution.ts +102 -0
- package/src/ingest/games/bloom-composer/game.js +99 -0
- package/src/ingest/games/bloom-composer/vgai.game.json +21 -0
- package/src/ingest/games/embed-bundle/embed.html +10 -0
- package/src/ingest/games/embed-bundle/vgai.game.json +21 -0
- package/src/ingest/games/games-fps/assets/collision-world.glb +0 -0
- package/src/ingest/games/games-fps/game.js +479 -0
- package/src/ingest/games/games-fps/vgai.game.json +24 -0
- package/src/ingest/games/iframe-reachable/game-source.js +58 -0
- package/src/ingest/games/iframe-reachable/vgai.game.json +21 -0
- package/src/ingest/games/interactive-cubes/game.js +139 -0
- package/src/ingest/games/interactive-cubes/vgai.game.json +21 -0
- package/src/ingest/games/mismatched-three/fake-three.js +38 -0
- package/src/ingest/games/mismatched-three/game.js +10 -0
- package/src/ingest/games/mismatched-three/vgai.game.json +22 -0
- package/src/ingest/games/own-three-bundled/game.js +43 -0
- package/src/ingest/games/own-three-bundled/vgai.game.json +21 -0
- package/src/ingest/games/pointerlock-maze/game.js +288 -0
- package/src/ingest/games/pointerlock-maze/vgai.game.json +22 -0
- package/src/ingest/games-2d/_fixtures/first-party-scene.scn2d.json +124 -0
- package/src/ingest/games-2d/bubbo-bubbo/vgai.game.json +25 -0
- package/src/ingest/games-2d/bunnymark/game.ts +88 -0
- package/src/ingest/games-2d/bunnymark/vgai.game.json +21 -0
- package/src/ingest/games-2d/flappy/game.ts +148 -0
- package/src/ingest/games-2d/flappy/vgai.game.json +21 -0
- package/src/ingest/games-2d/flappy-pixi/vgai.game.json +25 -0
- package/src/ingest/games-2d/puzzling-potions/vgai.game.json +25 -0
- package/src/ingest/games-2d/tilemap-camera/game.ts +115 -0
- package/src/ingest/games-2d/tilemap-camera/vgai.game.json +21 -0
- package/src/ingest/games-react/react-rpg/entry.tsx +185 -0
- package/src/ingest/games-react/react-rpg/shims.d.ts +26 -0
- package/src/ingest/games-react/react-rpg/src/ui/game-state.tsx +129 -0
- package/src/ingest/games-react/react-rpg/vgai.game.json +21 -0
- package/src/ingest/host-namespace-registry.ts +196 -0
- package/src/ingest/types.ts +127 -0
- package/src/ingest-hierarchy-rows.ts +207 -0
- package/src/ingest-mode.ts +2092 -0
- package/src/ingest-siblings.ts +466 -0
- package/src/initial-scene.ts +194 -0
- package/src/inspector-section-registry.ts +117 -0
- package/src/interactive-edit-scope.ts +34 -0
- package/src/main.tsx +23 -0
- package/src/manifest-project.ts +43 -0
- package/src/model-thumbnail.ts +156 -0
- package/src/module-mode.ts +513 -0
- package/src/navmesh-handler.ts +94 -0
- package/src/packaged-runtime.ts +49 -0
- package/src/play-mode.ts +1148 -0
- package/src/playground/main.ts +206 -0
- package/src/project-manager.ts +173 -0
- package/src/scene-diff.ts +112 -0
- package/src/scene-serializer.ts +144 -0
- package/src/scene-sync.ts +587 -0
- package/src/scene-ui-mode/active-scene-ui.ts +58 -0
- package/src/scene-ui-mode/scene-ui-palette-panel.tsx +152 -0
- package/src/scene-ui-mode/scene-ui-timeline-tab.tsx +29 -0
- package/src/scene-ui-mode/ui-prefab-dialog-host.tsx +74 -0
- package/src/scene-ui-mode/ui-prefab-hierarchy-menu.ts +49 -0
- package/src/scene-ui-mode/ui-prefab-io.ts +76 -0
- package/src/script-loader.ts +143 -0
- package/src/storage/fsa-storage.ts +55 -0
- package/src/storage/handle-storage.ts +150 -0
- package/src/storage/handle-store.ts +116 -0
- package/src/storage/http-storage.ts +137 -0
- package/src/storage/index.ts +147 -0
- package/src/storage/mem-storage.ts +135 -0
- package/src/storage/opfs-storage.ts +25 -0
- package/src/storage/paths.ts +26 -0
- package/src/storage/seed.ts +106 -0
- package/src/storage/types.ts +110 -0
- package/src/tool-loader.ts +291 -0
- package/src/ui-editor/inspector.tsx +563 -0
- package/src/ui-editor/node-ops.ts +266 -0
- package/src/ui-editor/overlay.tsx +380 -0
- package/src/ui-editor/palette.tsx +114 -0
- package/src/ui-editor/react-store.ts +78 -0
- package/src/ui-editor/timeline-panel.tsx +443 -0
- package/src/ui-editor/ui-edit-store.ts +552 -0
- package/src/ui-editor/ui-prefab.ts +95 -0
- package/src/ui-source/inspect.ts +544 -0
- package/src/ui-source/oid-transform.ts +133 -0
- package/src/ui-source/source-write-backend.ts +203 -0
- package/src/ui-source/tailwind-map.ts +174 -0
- package/src/ui-source/writer.ts +1175 -0
- package/src/widgets/index.ts +73 -0
- package/template/.claude/skills/editor/SKILL.md +252 -0
- package/template/CLAUDE.md +512 -0
- package/template/LICENSE +30 -0
- package/template/emit-schemas.ts +42 -0
- package/template/index.html +17 -0
- package/template/package.json +53 -0
- package/template/project.json +9 -0
- package/template/public/audio/ambient-arena.wav +0 -0
- package/template/public/audio/ambient-music.wav +0 -0
- package/template/public/audio/ambient-nature.wav +0 -0
- package/template/public/audio/ambient-wind.wav +0 -0
- package/template/public/inputmaps/default.inputmap.json +41 -0
- package/template/public/jsm/libs/draco/gltf/draco_decoder.js +33 -0
- package/template/public/jsm/libs/draco/gltf/draco_decoder.wasm +0 -0
- package/template/public/jsm/libs/draco/gltf/draco_encoder.js +33 -0
- package/template/public/jsm/libs/draco/gltf/draco_wasm_wrapper.js +116 -0
- package/template/public/scenes/default.vscn.json +43 -0
- package/template/public/scenes/untitled.vscn.json +29 -0
- package/template/public/textures/waternormals.jpg +0 -0
- package/template/server/colyseus-setup.ts +85 -0
- package/template/server/main.ts +34 -0
- package/template/server/rooms/arena-room.ts +420 -0
- package/template/server/rooms/game-room.ts +162 -0
- package/template/server/rooms.ts +15 -0
- package/template/server/tsconfig.json +19 -0
- package/template/src/data/README.md +40 -0
- package/template/src/data/assets.ts +31 -0
- package/template/src/data/tuning.data.json +5 -0
- package/template/src/data/tuning.schema.json +21 -0
- package/template/src/data/tuning.schema.ts +34 -0
- package/template/src/data/tuning.ts +24 -0
- package/template/src/main.ts +157 -0
- package/template/src/scripts/components/data-spinner.ts +45 -0
- package/template/src/scripts/components/scene-camera.ts +40 -0
- package/template/src/scripts/main.ts +94 -0
- package/template/src/scripts/registry.ts +46 -0
- package/template/src/tools/README.md +14 -0
- package/template/src/tools/example.tool.tsx +91 -0
- package/template/src/tools/spin.tool.tsx +101 -0
- package/template/src/ui/Button.tsx +27 -0
- package/template/src/ui/DefaultHud.tsx +40 -0
- package/template/src/ui/KeyHint.tsx +25 -0
- package/template/src/ui/Panel.tsx +52 -0
- package/template/src/ui/RebindPanel.tsx +129 -0
- package/template/src/ui/Slider.tsx +28 -0
- package/template/src/ui/StatusDot.tsx +22 -0
- package/template/src/ui/Toggle.tsx +19 -0
- package/template/src/ui/game-state.tsx +37 -0
- package/template/src/ui/index.ts +7 -0
- package/template/src/ui/mount-default-hud.tsx +19 -0
- package/template/src/ui/mount-ui.ts +15 -0
- package/template/tsconfig.json +36 -0
- package/template/validate-asset-content.ts +78 -0
- package/template/validate-manifest.ts +55 -0
- package/template/validate-scenes.ts +211 -0
- package/template/vgai.game.json +21 -0
- package/template/vite.config.ts +128 -0
- package/vite-plugin-example-assets.ts +60 -0
- package/vite-plugin-game-globals.ts +46 -0
- package/vite-plugin-game-static.ts +71 -0
- package/vite-plugin-project-game-static.ts +84 -0
- package/vite-plugin-react-game-static.ts +98 -0
- package/vite-plugin-react-world-provider.ts +81 -0
- package/vite-plugin-react-world-runtime.ts +76 -0
- package/vite-plugin-ui-oid.ts +561 -0
|
@@ -0,0 +1,1004 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project screen — shown before the editor when no project is specified.
|
|
3
|
+
*
|
|
4
|
+
* Displays recent projects, lets the user create new projects from templates,
|
|
5
|
+
* or open existing projects via native folder dialog or path input.
|
|
6
|
+
* No Three.js, no EditorStore — pure React + fetch.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { useCallback, useEffect, useReducer, useRef, useState } from 'react';
|
|
10
|
+
import {
|
|
11
|
+
browseFolder,
|
|
12
|
+
createProject,
|
|
13
|
+
type ExampleInfo,
|
|
14
|
+
listExamples,
|
|
15
|
+
listRecentProjects,
|
|
16
|
+
openProjectOnServer,
|
|
17
|
+
type RecentProject,
|
|
18
|
+
revealInFinder,
|
|
19
|
+
} from '../editor-api';
|
|
20
|
+
import { getEditorMode } from '../editor-mode';
|
|
21
|
+
import { type ActiveProject, type ProjectConfig, setActiveProject } from '../project-manager';
|
|
22
|
+
import {
|
|
23
|
+
getHostCapabilities,
|
|
24
|
+
peekPersistedProjectRootName,
|
|
25
|
+
reopenPersistedProjectRoot,
|
|
26
|
+
type StorageBackend,
|
|
27
|
+
} from '../storage';
|
|
28
|
+
import { readProjectManifest, seedIfEmpty } from '../storage/seed';
|
|
29
|
+
|
|
30
|
+
// ---------------------------------------------------------------------------
|
|
31
|
+
// Injected stylesheet for interactive states
|
|
32
|
+
// ---------------------------------------------------------------------------
|
|
33
|
+
|
|
34
|
+
const STYLE_ID = 'vgai-project-screen';
|
|
35
|
+
|
|
36
|
+
const CSS = `
|
|
37
|
+
.ps-card {
|
|
38
|
+
position: relative;
|
|
39
|
+
background: #222;
|
|
40
|
+
border: 1px solid #333;
|
|
41
|
+
border-radius: 8px;
|
|
42
|
+
padding: 14px 14px 12px;
|
|
43
|
+
cursor: pointer;
|
|
44
|
+
text-align: left;
|
|
45
|
+
font: inherit;
|
|
46
|
+
color: inherit;
|
|
47
|
+
transition: border-color 0.15s, background 0.15s;
|
|
48
|
+
width: 100%;
|
|
49
|
+
}
|
|
50
|
+
.ps-card:hover { border-color: #555; background: #2a2a2a; }
|
|
51
|
+
.ps-card:focus-visible { outline: 1px solid #579eff; outline-offset: 1px; }
|
|
52
|
+
.ps-card:disabled { opacity: 0.5; cursor: default; }
|
|
53
|
+
|
|
54
|
+
.ps-card-remove {
|
|
55
|
+
position: absolute;
|
|
56
|
+
top: 6px;
|
|
57
|
+
right: 6px;
|
|
58
|
+
background: #333;
|
|
59
|
+
border: none;
|
|
60
|
+
color: #888;
|
|
61
|
+
font-size: 14px;
|
|
62
|
+
width: 20px;
|
|
63
|
+
height: 20px;
|
|
64
|
+
border-radius: 4px;
|
|
65
|
+
cursor: pointer;
|
|
66
|
+
opacity: 0;
|
|
67
|
+
transition: opacity 0.15s;
|
|
68
|
+
display: flex;
|
|
69
|
+
align-items: center;
|
|
70
|
+
justify-content: center;
|
|
71
|
+
}
|
|
72
|
+
.ps-card:hover .ps-card-remove { opacity: 1; }
|
|
73
|
+
.ps-card-remove:hover { background: #444; color: #ccc; }
|
|
74
|
+
|
|
75
|
+
.ps-btn-primary {
|
|
76
|
+
background: #3a8eef;
|
|
77
|
+
color: #fff;
|
|
78
|
+
border: none;
|
|
79
|
+
border-radius: 6px;
|
|
80
|
+
padding: 10px 20px;
|
|
81
|
+
font-size: 14px;
|
|
82
|
+
font-weight: 600;
|
|
83
|
+
font-family: inherit;
|
|
84
|
+
cursor: pointer;
|
|
85
|
+
transition: background 0.15s;
|
|
86
|
+
}
|
|
87
|
+
.ps-btn-primary:hover { background: #4a9eff; }
|
|
88
|
+
.ps-btn-primary:focus-visible { outline: 1px solid #579eff; outline-offset: 1px; }
|
|
89
|
+
.ps-btn-primary:disabled { opacity: 0.5; cursor: default; }
|
|
90
|
+
|
|
91
|
+
.ps-btn-secondary {
|
|
92
|
+
background: #333;
|
|
93
|
+
color: #c5c8ce;
|
|
94
|
+
border: none;
|
|
95
|
+
border-radius: 6px;
|
|
96
|
+
padding: 10px 20px;
|
|
97
|
+
font-size: 14px;
|
|
98
|
+
font-family: inherit;
|
|
99
|
+
cursor: pointer;
|
|
100
|
+
transition: background 0.15s;
|
|
101
|
+
white-space: nowrap;
|
|
102
|
+
}
|
|
103
|
+
.ps-btn-secondary:hover { background: #444; }
|
|
104
|
+
.ps-btn-secondary:focus-visible { outline: 1px solid #579eff; outline-offset: 1px; }
|
|
105
|
+
.ps-btn-secondary:disabled { opacity: 0.5; cursor: default; }
|
|
106
|
+
|
|
107
|
+
.ps-input {
|
|
108
|
+
flex: 1;
|
|
109
|
+
background: #2a2a2a;
|
|
110
|
+
border: 1px solid #333;
|
|
111
|
+
border-radius: 6px;
|
|
112
|
+
padding: 8px 12px;
|
|
113
|
+
font-size: 14px;
|
|
114
|
+
color: #e0e0e0;
|
|
115
|
+
outline: none;
|
|
116
|
+
font-family: inherit;
|
|
117
|
+
}
|
|
118
|
+
.ps-input:focus { border-color: #579eff; }
|
|
119
|
+
|
|
120
|
+
.ps-template {
|
|
121
|
+
flex: 1;
|
|
122
|
+
background: #222;
|
|
123
|
+
border: 1px solid #333;
|
|
124
|
+
border-radius: 8px;
|
|
125
|
+
padding: 12px 14px;
|
|
126
|
+
cursor: pointer;
|
|
127
|
+
text-align: left;
|
|
128
|
+
font: inherit;
|
|
129
|
+
color: inherit;
|
|
130
|
+
transition: border-color 0.15s;
|
|
131
|
+
}
|
|
132
|
+
.ps-template:hover { border-color: #555; }
|
|
133
|
+
.ps-template[data-selected="true"] { border-color: #3a8eef; }
|
|
134
|
+
|
|
135
|
+
.ps-ctx-menu {
|
|
136
|
+
position: fixed;
|
|
137
|
+
background: #2a2a2a;
|
|
138
|
+
border: 1px solid #444;
|
|
139
|
+
border-radius: 6px;
|
|
140
|
+
padding: 4px 0;
|
|
141
|
+
min-width: 160px;
|
|
142
|
+
z-index: 100;
|
|
143
|
+
box-shadow: 0 4px 16px rgba(0,0,0,0.4);
|
|
144
|
+
}
|
|
145
|
+
.ps-ctx-item {
|
|
146
|
+
display: block;
|
|
147
|
+
width: 100%;
|
|
148
|
+
background: none;
|
|
149
|
+
border: none;
|
|
150
|
+
color: #c5c8ce;
|
|
151
|
+
font: inherit;
|
|
152
|
+
font-size: 13px;
|
|
153
|
+
padding: 6px 14px;
|
|
154
|
+
text-align: left;
|
|
155
|
+
cursor: pointer;
|
|
156
|
+
}
|
|
157
|
+
.ps-ctx-item:hover { background: #333; }
|
|
158
|
+
.ps-ctx-sep {
|
|
159
|
+
height: 1px;
|
|
160
|
+
background: #444;
|
|
161
|
+
margin: 4px 0;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.ps-thumbnail {
|
|
165
|
+
width: 100%;
|
|
166
|
+
aspect-ratio: 16/9;
|
|
167
|
+
background: #1a1a1a;
|
|
168
|
+
border-radius: 4px;
|
|
169
|
+
margin-bottom: 8px;
|
|
170
|
+
overflow: hidden;
|
|
171
|
+
display: flex;
|
|
172
|
+
align-items: center;
|
|
173
|
+
justify-content: center;
|
|
174
|
+
color: #333;
|
|
175
|
+
font-size: 24px;
|
|
176
|
+
}
|
|
177
|
+
.ps-thumbnail img {
|
|
178
|
+
width: 100%;
|
|
179
|
+
height: 100%;
|
|
180
|
+
object-fit: cover;
|
|
181
|
+
}
|
|
182
|
+
`;
|
|
183
|
+
|
|
184
|
+
function useStyleSheet(): void {
|
|
185
|
+
useEffect(() => {
|
|
186
|
+
if (document.getElementById(STYLE_ID)) return;
|
|
187
|
+
const el = document.createElement('style');
|
|
188
|
+
el.id = STYLE_ID;
|
|
189
|
+
el.textContent = CSS;
|
|
190
|
+
document.head.appendChild(el);
|
|
191
|
+
return () => el.remove();
|
|
192
|
+
}, []);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// ---------------------------------------------------------------------------
|
|
196
|
+
// State reducer
|
|
197
|
+
// ---------------------------------------------------------------------------
|
|
198
|
+
|
|
199
|
+
interface ScreenState {
|
|
200
|
+
view: 'home' | 'new-project';
|
|
201
|
+
recentProjects: RecentProject[];
|
|
202
|
+
loaded: boolean;
|
|
203
|
+
error: string | null;
|
|
204
|
+
busy: boolean; // opening or creating
|
|
205
|
+
// New project form
|
|
206
|
+
projectName: string;
|
|
207
|
+
projectLocation: string;
|
|
208
|
+
template: 'starter' | 'empty' | 'example';
|
|
209
|
+
exampleId: string | null;
|
|
210
|
+
availableExamples: ExampleInfo[];
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
type ScreenAction =
|
|
214
|
+
| { type: 'LOADED'; projects: RecentProject[] }
|
|
215
|
+
| { type: 'SET_VIEW'; view: 'home' | 'new-project' }
|
|
216
|
+
| { type: 'SET_ERROR'; error: string | null }
|
|
217
|
+
| { type: 'SET_BUSY'; busy: boolean }
|
|
218
|
+
| { type: 'REMOVE_RECENT'; path: string }
|
|
219
|
+
| { type: 'SET_NAME'; name: string }
|
|
220
|
+
| { type: 'SET_LOCATION'; location: string }
|
|
221
|
+
| { type: 'SET_TEMPLATE'; template: 'starter' | 'empty' | 'example' }
|
|
222
|
+
| { type: 'SET_EXAMPLE_ID'; exampleId: string }
|
|
223
|
+
| { type: 'SET_AVAILABLE_EXAMPLES'; examples: ExampleInfo[] };
|
|
224
|
+
|
|
225
|
+
const initialState: ScreenState = {
|
|
226
|
+
view: 'home',
|
|
227
|
+
recentProjects: [],
|
|
228
|
+
loaded: false,
|
|
229
|
+
error: null,
|
|
230
|
+
busy: false,
|
|
231
|
+
projectName: 'My Game',
|
|
232
|
+
projectLocation: '~/VGAI Projects',
|
|
233
|
+
template: 'starter',
|
|
234
|
+
exampleId: null,
|
|
235
|
+
availableExamples: [],
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
function reducer(state: ScreenState, action: ScreenAction): ScreenState {
|
|
239
|
+
switch (action.type) {
|
|
240
|
+
case 'LOADED':
|
|
241
|
+
return {
|
|
242
|
+
...state,
|
|
243
|
+
recentProjects: action.projects,
|
|
244
|
+
loaded: true,
|
|
245
|
+
view: action.projects.length === 0 ? 'new-project' : 'home',
|
|
246
|
+
};
|
|
247
|
+
case 'SET_VIEW':
|
|
248
|
+
return { ...state, view: action.view, error: null };
|
|
249
|
+
case 'SET_ERROR':
|
|
250
|
+
return { ...state, error: action.error, busy: false };
|
|
251
|
+
case 'SET_BUSY':
|
|
252
|
+
return { ...state, busy: action.busy, error: null };
|
|
253
|
+
case 'REMOVE_RECENT':
|
|
254
|
+
return {
|
|
255
|
+
...state,
|
|
256
|
+
recentProjects: state.recentProjects.filter((p) => p.path !== action.path),
|
|
257
|
+
};
|
|
258
|
+
case 'SET_NAME':
|
|
259
|
+
return { ...state, projectName: action.name };
|
|
260
|
+
case 'SET_LOCATION':
|
|
261
|
+
return { ...state, projectLocation: action.location };
|
|
262
|
+
case 'SET_TEMPLATE':
|
|
263
|
+
return { ...state, template: action.template };
|
|
264
|
+
case 'SET_EXAMPLE_ID':
|
|
265
|
+
return { ...state, exampleId: action.exampleId };
|
|
266
|
+
case 'SET_AVAILABLE_EXAMPLES':
|
|
267
|
+
return { ...state, availableExamples: action.examples };
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// ---------------------------------------------------------------------------
|
|
272
|
+
// Main component
|
|
273
|
+
// ---------------------------------------------------------------------------
|
|
274
|
+
|
|
275
|
+
interface ProjectScreenProps {
|
|
276
|
+
onOpen: (project: ActiveProject) => void;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
export function ProjectScreen({ onOpen }: ProjectScreenProps) {
|
|
280
|
+
useStyleSheet();
|
|
281
|
+
const [state, dispatch] = useReducer(reducer, initialState);
|
|
282
|
+
// Name of a previously-picked on-disk folder whose permission needs a fresh
|
|
283
|
+
// gesture to reopen (browser mode only). Drives the "Reopen …" affordance.
|
|
284
|
+
const [persistedRootName, setPersistedRootName] = useState<string | null>(null);
|
|
285
|
+
|
|
286
|
+
useEffect(() => {
|
|
287
|
+
listRecentProjects().then((projects) => {
|
|
288
|
+
dispatch({ type: 'LOADED', projects });
|
|
289
|
+
});
|
|
290
|
+
// Fire-and-forget, same as above — an empty list just hides the "From
|
|
291
|
+
// example" option's picker contents, it never blocks LOADED.
|
|
292
|
+
listExamples().then((examples) => {
|
|
293
|
+
dispatch({ type: 'SET_AVAILABLE_EXAMPLES', examples });
|
|
294
|
+
});
|
|
295
|
+
if (getEditorMode() === 'browser') {
|
|
296
|
+
peekPersistedProjectRootName().then(setPersistedRootName);
|
|
297
|
+
}
|
|
298
|
+
}, []);
|
|
299
|
+
|
|
300
|
+
// Phase A cleanup: `openProjectOnServer`/`createProject`/`browseFolder` now
|
|
301
|
+
// THROW a clear, honest error in browser mode (there is no Node server to
|
|
302
|
+
// scaffold-to-disk / native-dialog against) instead of doing a doomed
|
|
303
|
+
// fetch. Every handler below now wraps its call in try/catch and routes the
|
|
304
|
+
// message into the SAME `SET_ERROR` state the existing `ErrorBanner`
|
|
305
|
+
// already renders (which also resets `busy` — see the reducer) — previously
|
|
306
|
+
// these had NO try/catch at all, so an uncaught rejection left `busy` stuck
|
|
307
|
+
// `true` forever (a real hang, in BOTH modes, not just browser). The
|
|
308
|
+
// affordances stay visible rather than being hidden in browser mode:
|
|
309
|
+
// `ProjectScreen` is also reachable there with no persisted FSA root and no
|
|
310
|
+
// File System Access support at all (a plain-OPFS browser after "Close
|
|
311
|
+
// Project"), where hiding them would be a dead end with zero way back into
|
|
312
|
+
// a project — a clear thrown error is strictly better than either a silent
|
|
313
|
+
// no-op or removing the only visible action.
|
|
314
|
+
const openProject = useCallback(
|
|
315
|
+
async (path: string) => {
|
|
316
|
+
dispatch({ type: 'SET_BUSY', busy: true });
|
|
317
|
+
try {
|
|
318
|
+
const result = await openProjectOnServer(path);
|
|
319
|
+
if (result.ok && result.config) {
|
|
320
|
+
const project: ActiveProject = { rootPath: path, config: result.config as ProjectConfig };
|
|
321
|
+
setActiveProject(project);
|
|
322
|
+
onOpen(project);
|
|
323
|
+
} else {
|
|
324
|
+
dispatch({ type: 'SET_ERROR', error: `Failed to open project at ${path}` });
|
|
325
|
+
}
|
|
326
|
+
} catch (err) {
|
|
327
|
+
dispatch({ type: 'SET_ERROR', error: err instanceof Error ? err.message : String(err) });
|
|
328
|
+
}
|
|
329
|
+
},
|
|
330
|
+
[onOpen],
|
|
331
|
+
);
|
|
332
|
+
|
|
333
|
+
const handleCreate = useCallback(async () => {
|
|
334
|
+
dispatch({ type: 'SET_BUSY', busy: true });
|
|
335
|
+
try {
|
|
336
|
+
const result =
|
|
337
|
+
state.template === 'example' && state.exampleId
|
|
338
|
+
? await createProject(
|
|
339
|
+
state.projectName,
|
|
340
|
+
state.projectLocation,
|
|
341
|
+
state.template,
|
|
342
|
+
state.exampleId,
|
|
343
|
+
)
|
|
344
|
+
: await createProject(state.projectName, state.projectLocation, state.template);
|
|
345
|
+
if (result.ok && result.path && result.config) {
|
|
346
|
+
const openResult = await openProjectOnServer(result.path);
|
|
347
|
+
if (openResult.ok) {
|
|
348
|
+
const project: ActiveProject = {
|
|
349
|
+
rootPath: result.path,
|
|
350
|
+
config: result.config as ProjectConfig,
|
|
351
|
+
};
|
|
352
|
+
setActiveProject(project);
|
|
353
|
+
onOpen(project);
|
|
354
|
+
} else {
|
|
355
|
+
dispatch({ type: 'SET_ERROR', error: 'Project created but failed to open.' });
|
|
356
|
+
}
|
|
357
|
+
} else {
|
|
358
|
+
dispatch({ type: 'SET_ERROR', error: result.error ?? 'Failed to create project.' });
|
|
359
|
+
}
|
|
360
|
+
} catch (err) {
|
|
361
|
+
dispatch({ type: 'SET_ERROR', error: err instanceof Error ? err.message : String(err) });
|
|
362
|
+
}
|
|
363
|
+
}, [state.projectName, state.projectLocation, state.template, state.exampleId, onOpen]);
|
|
364
|
+
|
|
365
|
+
const handleBrowseOpen = useCallback(async () => {
|
|
366
|
+
try {
|
|
367
|
+
const path = await browseFolder('Select a project folder');
|
|
368
|
+
if (path) openProject(path);
|
|
369
|
+
} catch (err) {
|
|
370
|
+
dispatch({ type: 'SET_ERROR', error: err instanceof Error ? err.message : String(err) });
|
|
371
|
+
}
|
|
372
|
+
}, [openProject]);
|
|
373
|
+
|
|
374
|
+
const handleBrowseLocation = useCallback(async () => {
|
|
375
|
+
try {
|
|
376
|
+
const path = await browseFolder('Choose project location');
|
|
377
|
+
if (path) dispatch({ type: 'SET_LOCATION', location: path });
|
|
378
|
+
} catch (err) {
|
|
379
|
+
dispatch({ type: 'SET_ERROR', error: err instanceof Error ? err.message : String(err) });
|
|
380
|
+
}
|
|
381
|
+
}, []);
|
|
382
|
+
|
|
383
|
+
// Seed a Starter if the folder is empty, read its manifest, and open it as
|
|
384
|
+
// the active project. Shared by the pick-a-folder and reopen-remembered paths.
|
|
385
|
+
const openFsaBackend = useCallback(
|
|
386
|
+
async (backend: StorageBackend) => {
|
|
387
|
+
await seedIfEmpty(backend);
|
|
388
|
+
const config = await readProjectManifest(backend);
|
|
389
|
+
const project: ActiveProject = { rootPath: 'fsa', config };
|
|
390
|
+
setActiveProject(project);
|
|
391
|
+
onOpen(project);
|
|
392
|
+
},
|
|
393
|
+
[onOpen],
|
|
394
|
+
);
|
|
395
|
+
|
|
396
|
+
// Browser-first mode: open a REAL on-disk folder via the File System Access
|
|
397
|
+
// API (Chromium). The picked folder is remembered so a reload reopens it.
|
|
398
|
+
const handleOpenFolderFsa = useCallback(async () => {
|
|
399
|
+
const pick = getHostCapabilities().pickProjectRoot;
|
|
400
|
+
if (!pick) return;
|
|
401
|
+
const backend = await pick();
|
|
402
|
+
if (backend) await openFsaBackend(backend);
|
|
403
|
+
}, [openFsaBackend]);
|
|
404
|
+
|
|
405
|
+
// Reopen the remembered on-disk folder — re-grants read/write permission
|
|
406
|
+
// (this click IS the required user gesture) and opens it.
|
|
407
|
+
const handleReopenFolder = useCallback(async () => {
|
|
408
|
+
const backend = await reopenPersistedProjectRoot();
|
|
409
|
+
if (backend) await openFsaBackend(backend);
|
|
410
|
+
}, [openFsaBackend]);
|
|
411
|
+
|
|
412
|
+
const slug = state.projectName
|
|
413
|
+
.toLowerCase()
|
|
414
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
415
|
+
.replace(/^-|-$/g, '');
|
|
416
|
+
|
|
417
|
+
return (
|
|
418
|
+
<div style={S.root} data-testid="project-screen">
|
|
419
|
+
<div style={S.inner}>
|
|
420
|
+
<header style={S.header}>
|
|
421
|
+
<div style={S.title}>VGAI ENGINE</div>
|
|
422
|
+
<div style={S.version}>v0.1.0</div>
|
|
423
|
+
</header>
|
|
424
|
+
|
|
425
|
+
{state.error && (
|
|
426
|
+
<ErrorBanner
|
|
427
|
+
message={state.error}
|
|
428
|
+
onDismiss={() => dispatch({ type: 'SET_ERROR', error: null })}
|
|
429
|
+
/>
|
|
430
|
+
)}
|
|
431
|
+
|
|
432
|
+
{getEditorMode() === 'browser' && (
|
|
433
|
+
<div
|
|
434
|
+
style={{
|
|
435
|
+
display: 'flex',
|
|
436
|
+
gap: 10,
|
|
437
|
+
alignItems: 'center',
|
|
438
|
+
margin: '2px 0 14px',
|
|
439
|
+
color: '#8b919b',
|
|
440
|
+
fontSize: 13,
|
|
441
|
+
}}
|
|
442
|
+
>
|
|
443
|
+
<span>Projects are stored in your browser (OPFS) — nothing leaves this device.</span>
|
|
444
|
+
{typeof window !== 'undefined' && 'showDirectoryPicker' in window && (
|
|
445
|
+
<>
|
|
446
|
+
{persistedRootName && (
|
|
447
|
+
<button
|
|
448
|
+
type="button"
|
|
449
|
+
className="ps-btn-primary"
|
|
450
|
+
onClick={handleReopenFolder}
|
|
451
|
+
data-testid="reopen-folder"
|
|
452
|
+
>
|
|
453
|
+
Reopen “{persistedRootName}”
|
|
454
|
+
</button>
|
|
455
|
+
)}
|
|
456
|
+
<button type="button" className="ps-btn-secondary" onClick={handleOpenFolderFsa}>
|
|
457
|
+
Open Folder…
|
|
458
|
+
</button>
|
|
459
|
+
</>
|
|
460
|
+
)}
|
|
461
|
+
</div>
|
|
462
|
+
)}
|
|
463
|
+
|
|
464
|
+
{state.view === 'home' && (
|
|
465
|
+
<HomeView
|
|
466
|
+
projects={state.recentProjects}
|
|
467
|
+
loaded={state.loaded}
|
|
468
|
+
busy={state.busy}
|
|
469
|
+
onOpen={openProject}
|
|
470
|
+
onBrowse={handleBrowseOpen}
|
|
471
|
+
onNewProject={() => dispatch({ type: 'SET_VIEW', view: 'new-project' })}
|
|
472
|
+
onRemove={(path) => dispatch({ type: 'REMOVE_RECENT', path })}
|
|
473
|
+
/>
|
|
474
|
+
)}
|
|
475
|
+
|
|
476
|
+
{state.view === 'new-project' && (
|
|
477
|
+
<NewProjectForm
|
|
478
|
+
name={state.projectName}
|
|
479
|
+
location={state.projectLocation}
|
|
480
|
+
template={state.template}
|
|
481
|
+
exampleId={state.exampleId}
|
|
482
|
+
availableExamples={state.availableExamples}
|
|
483
|
+
slug={slug}
|
|
484
|
+
busy={state.busy}
|
|
485
|
+
onNameChange={(name) => dispatch({ type: 'SET_NAME', name })}
|
|
486
|
+
onLocationChange={(location) => dispatch({ type: 'SET_LOCATION', location })}
|
|
487
|
+
onTemplateChange={(template) => dispatch({ type: 'SET_TEMPLATE', template })}
|
|
488
|
+
onExampleIdChange={(exampleId) => dispatch({ type: 'SET_EXAMPLE_ID', exampleId })}
|
|
489
|
+
onBrowseLocation={handleBrowseLocation}
|
|
490
|
+
onCancel={() => dispatch({ type: 'SET_VIEW', view: 'home' })}
|
|
491
|
+
onCreate={handleCreate}
|
|
492
|
+
/>
|
|
493
|
+
)}
|
|
494
|
+
</div>
|
|
495
|
+
</div>
|
|
496
|
+
);
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
// ---------------------------------------------------------------------------
|
|
500
|
+
// HomeView — recent projects + actions
|
|
501
|
+
// ---------------------------------------------------------------------------
|
|
502
|
+
|
|
503
|
+
interface HomeViewProps {
|
|
504
|
+
projects: RecentProject[];
|
|
505
|
+
loaded: boolean;
|
|
506
|
+
busy: boolean;
|
|
507
|
+
onOpen: (path: string) => void;
|
|
508
|
+
onBrowse: () => void;
|
|
509
|
+
onNewProject: () => void;
|
|
510
|
+
onRemove: (path: string) => void;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
function HomeView({
|
|
514
|
+
projects,
|
|
515
|
+
loaded,
|
|
516
|
+
busy,
|
|
517
|
+
onOpen,
|
|
518
|
+
onBrowse,
|
|
519
|
+
onNewProject,
|
|
520
|
+
onRemove,
|
|
521
|
+
}: HomeViewProps) {
|
|
522
|
+
return (
|
|
523
|
+
<>
|
|
524
|
+
<section style={S.section}>
|
|
525
|
+
<div style={S.sectionTitle}>Recent Projects</div>
|
|
526
|
+
{!loaded ? (
|
|
527
|
+
<div style={S.empty}>Loading...</div>
|
|
528
|
+
) : projects.length === 0 ? (
|
|
529
|
+
<div style={S.empty}>No recent projects. Create one to get started.</div>
|
|
530
|
+
) : (
|
|
531
|
+
<div style={S.grid}>
|
|
532
|
+
{projects.map((project) => (
|
|
533
|
+
<ProjectCard
|
|
534
|
+
key={project.path}
|
|
535
|
+
project={project}
|
|
536
|
+
disabled={busy}
|
|
537
|
+
onOpen={() => onOpen(project.path)}
|
|
538
|
+
onRemove={() => onRemove(project.path)}
|
|
539
|
+
/>
|
|
540
|
+
))}
|
|
541
|
+
</div>
|
|
542
|
+
)}
|
|
543
|
+
</section>
|
|
544
|
+
|
|
545
|
+
<div style={S.actions}>
|
|
546
|
+
<button type="button" className="ps-btn-primary" onClick={onNewProject}>
|
|
547
|
+
+ New Project
|
|
548
|
+
</button>
|
|
549
|
+
<button type="button" className="ps-btn-secondary" onClick={onBrowse}>
|
|
550
|
+
Open Project...
|
|
551
|
+
</button>
|
|
552
|
+
</div>
|
|
553
|
+
</>
|
|
554
|
+
);
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
// ---------------------------------------------------------------------------
|
|
558
|
+
// ProjectCard — single recent project
|
|
559
|
+
// ---------------------------------------------------------------------------
|
|
560
|
+
|
|
561
|
+
interface ProjectCardProps {
|
|
562
|
+
project: RecentProject;
|
|
563
|
+
disabled: boolean;
|
|
564
|
+
onOpen: () => void;
|
|
565
|
+
onRemove: () => void;
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
function ProjectCard({ project, disabled, onOpen, onRemove }: ProjectCardProps) {
|
|
569
|
+
const [ctxMenu, setCtxMenu] = useState<{ x: number; y: number } | null>(null);
|
|
570
|
+
|
|
571
|
+
const handleContextMenu = useCallback((e: React.MouseEvent) => {
|
|
572
|
+
e.preventDefault();
|
|
573
|
+
setCtxMenu({ x: e.clientX, y: e.clientY });
|
|
574
|
+
}, []);
|
|
575
|
+
|
|
576
|
+
return (
|
|
577
|
+
<>
|
|
578
|
+
<button
|
|
579
|
+
type="button"
|
|
580
|
+
className="ps-card"
|
|
581
|
+
onClick={onOpen}
|
|
582
|
+
onContextMenu={handleContextMenu}
|
|
583
|
+
disabled={disabled}
|
|
584
|
+
>
|
|
585
|
+
<div className="ps-thumbnail">
|
|
586
|
+
{project.thumbnail ? <img src={project.thumbnail} alt={project.name} /> : '\u25a6'}
|
|
587
|
+
</div>
|
|
588
|
+
<div style={S.cardName}>{project.name}</div>
|
|
589
|
+
<div style={S.cardMeta} title={project.path}>
|
|
590
|
+
{shortenPath(project.path)}
|
|
591
|
+
</div>
|
|
592
|
+
<div style={S.cardMeta}>{formatRelativeTime(project.lastOpened)}</div>
|
|
593
|
+
<button
|
|
594
|
+
type="button"
|
|
595
|
+
className="ps-card-remove"
|
|
596
|
+
title="Remove from list"
|
|
597
|
+
onClick={(e) => {
|
|
598
|
+
e.stopPropagation();
|
|
599
|
+
onRemove();
|
|
600
|
+
}}
|
|
601
|
+
>
|
|
602
|
+
×
|
|
603
|
+
</button>
|
|
604
|
+
</button>
|
|
605
|
+
|
|
606
|
+
{ctxMenu && (
|
|
607
|
+
<ContextMenu
|
|
608
|
+
x={ctxMenu.x}
|
|
609
|
+
y={ctxMenu.y}
|
|
610
|
+
onClose={() => setCtxMenu(null)}
|
|
611
|
+
items={[
|
|
612
|
+
{ label: 'Open', action: onOpen },
|
|
613
|
+
// Phase A cleanup: no OS path to reveal in browser mode (this
|
|
614
|
+
// list is always empty there anyway — `listRecentProjects`
|
|
615
|
+
// returns `[]` — but filtered explicitly for clarity).
|
|
616
|
+
...(getEditorMode() === 'server'
|
|
617
|
+
? [{ label: 'Show in Finder', action: () => revealInFinder(project.path) }]
|
|
618
|
+
: []),
|
|
619
|
+
{ separator: true },
|
|
620
|
+
{ label: 'Remove from List', action: onRemove },
|
|
621
|
+
]}
|
|
622
|
+
/>
|
|
623
|
+
)}
|
|
624
|
+
</>
|
|
625
|
+
);
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
// ---------------------------------------------------------------------------
|
|
629
|
+
// ContextMenu
|
|
630
|
+
// ---------------------------------------------------------------------------
|
|
631
|
+
|
|
632
|
+
type ContextMenuItem =
|
|
633
|
+
| { label: string; action: () => void; separator?: undefined }
|
|
634
|
+
| { separator: true; label?: undefined; action?: undefined };
|
|
635
|
+
|
|
636
|
+
interface ContextMenuProps {
|
|
637
|
+
x: number;
|
|
638
|
+
y: number;
|
|
639
|
+
onClose: () => void;
|
|
640
|
+
items: ContextMenuItem[];
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
function ContextMenu({ x, y, onClose, items }: ContextMenuProps) {
|
|
644
|
+
const ref = useRef<HTMLDivElement>(null);
|
|
645
|
+
|
|
646
|
+
useEffect(() => {
|
|
647
|
+
const handleClick = (e: MouseEvent) => {
|
|
648
|
+
if (ref.current && !ref.current.contains(e.target as Node)) onClose();
|
|
649
|
+
};
|
|
650
|
+
const handleKey = (e: KeyboardEvent) => {
|
|
651
|
+
if (e.key === 'Escape') onClose();
|
|
652
|
+
};
|
|
653
|
+
document.addEventListener('mousedown', handleClick);
|
|
654
|
+
document.addEventListener('keydown', handleKey);
|
|
655
|
+
return () => {
|
|
656
|
+
document.removeEventListener('mousedown', handleClick);
|
|
657
|
+
document.removeEventListener('keydown', handleKey);
|
|
658
|
+
};
|
|
659
|
+
}, [onClose]);
|
|
660
|
+
|
|
661
|
+
return (
|
|
662
|
+
<div ref={ref} className="ps-ctx-menu" style={{ left: x, top: y }}>
|
|
663
|
+
{items.map((item, i) =>
|
|
664
|
+
item.separator ? (
|
|
665
|
+
<div key={`sep-${i}`} className="ps-ctx-sep" />
|
|
666
|
+
) : (
|
|
667
|
+
<button
|
|
668
|
+
key={item.label}
|
|
669
|
+
type="button"
|
|
670
|
+
className="ps-ctx-item"
|
|
671
|
+
onClick={() => {
|
|
672
|
+
item.action();
|
|
673
|
+
onClose();
|
|
674
|
+
}}
|
|
675
|
+
>
|
|
676
|
+
{item.label}
|
|
677
|
+
</button>
|
|
678
|
+
),
|
|
679
|
+
)}
|
|
680
|
+
</div>
|
|
681
|
+
);
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
// ---------------------------------------------------------------------------
|
|
685
|
+
// NewProjectForm
|
|
686
|
+
// ---------------------------------------------------------------------------
|
|
687
|
+
|
|
688
|
+
interface NewProjectFormProps {
|
|
689
|
+
name: string;
|
|
690
|
+
location: string;
|
|
691
|
+
template: 'starter' | 'empty' | 'example';
|
|
692
|
+
exampleId: string | null;
|
|
693
|
+
availableExamples: ExampleInfo[];
|
|
694
|
+
slug: string;
|
|
695
|
+
busy: boolean;
|
|
696
|
+
onNameChange: (name: string) => void;
|
|
697
|
+
onLocationChange: (location: string) => void;
|
|
698
|
+
onTemplateChange: (template: 'starter' | 'empty' | 'example') => void;
|
|
699
|
+
onExampleIdChange: (exampleId: string) => void;
|
|
700
|
+
onBrowseLocation: () => void;
|
|
701
|
+
onCancel: () => void;
|
|
702
|
+
onCreate: () => void;
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
function NewProjectForm({
|
|
706
|
+
name,
|
|
707
|
+
location,
|
|
708
|
+
template,
|
|
709
|
+
exampleId,
|
|
710
|
+
availableExamples,
|
|
711
|
+
slug,
|
|
712
|
+
busy,
|
|
713
|
+
onNameChange,
|
|
714
|
+
onLocationChange,
|
|
715
|
+
onTemplateChange,
|
|
716
|
+
onExampleIdChange,
|
|
717
|
+
onBrowseLocation,
|
|
718
|
+
onCancel,
|
|
719
|
+
onCreate,
|
|
720
|
+
}: NewProjectFormProps) {
|
|
721
|
+
return (
|
|
722
|
+
<div style={S.form}>
|
|
723
|
+
<div style={S.sectionTitle}>New Project</div>
|
|
724
|
+
|
|
725
|
+
<label style={S.label}>
|
|
726
|
+
Name
|
|
727
|
+
<input className="ps-input" value={name} onChange={(e) => onNameChange(e.target.value)} />
|
|
728
|
+
</label>
|
|
729
|
+
|
|
730
|
+
<label style={S.label}>
|
|
731
|
+
Location
|
|
732
|
+
<div style={S.locationRow}>
|
|
733
|
+
<input
|
|
734
|
+
className="ps-input"
|
|
735
|
+
value={location}
|
|
736
|
+
onChange={(e) => onLocationChange(e.target.value)}
|
|
737
|
+
/>
|
|
738
|
+
<button type="button" className="ps-btn-secondary" onClick={onBrowseLocation}>
|
|
739
|
+
Browse
|
|
740
|
+
</button>
|
|
741
|
+
</div>
|
|
742
|
+
</label>
|
|
743
|
+
|
|
744
|
+
<div style={S.label}>
|
|
745
|
+
Template
|
|
746
|
+
<div style={S.templateRow}>
|
|
747
|
+
<button
|
|
748
|
+
type="button"
|
|
749
|
+
className="ps-template"
|
|
750
|
+
data-selected={template === 'starter'}
|
|
751
|
+
onClick={() => onTemplateChange('starter')}
|
|
752
|
+
>
|
|
753
|
+
<div style={S.templateName}>Starter</div>
|
|
754
|
+
<div style={S.templateDesc}>
|
|
755
|
+
7 example scenes, prefabs, input maps, animation graphs
|
|
756
|
+
</div>
|
|
757
|
+
</button>
|
|
758
|
+
<button
|
|
759
|
+
type="button"
|
|
760
|
+
className="ps-template"
|
|
761
|
+
data-selected={template === 'empty'}
|
|
762
|
+
onClick={() => onTemplateChange('empty')}
|
|
763
|
+
>
|
|
764
|
+
<div style={S.templateName}>Empty</div>
|
|
765
|
+
<div style={S.templateDesc}>Blank project with a default scene</div>
|
|
766
|
+
</button>
|
|
767
|
+
<button
|
|
768
|
+
type="button"
|
|
769
|
+
className="ps-template"
|
|
770
|
+
data-selected={template === 'example'}
|
|
771
|
+
onClick={() => onTemplateChange('example')}
|
|
772
|
+
>
|
|
773
|
+
<div style={S.templateName}>From example</div>
|
|
774
|
+
<div style={S.templateDesc}>
|
|
775
|
+
Start from a real example project (e.g. the multiplayer arena)
|
|
776
|
+
</div>
|
|
777
|
+
</button>
|
|
778
|
+
</div>
|
|
779
|
+
{template === 'example' && (
|
|
780
|
+
<select
|
|
781
|
+
className="ps-input"
|
|
782
|
+
style={{ marginTop: 10 }}
|
|
783
|
+
value={exampleId ?? ''}
|
|
784
|
+
onChange={(e) => onExampleIdChange(e.target.value)}
|
|
785
|
+
>
|
|
786
|
+
<option value="" disabled>
|
|
787
|
+
{availableExamples.length === 0 ? 'Loading examples...' : 'Select an example...'}
|
|
788
|
+
</option>
|
|
789
|
+
{availableExamples.map((ex) => (
|
|
790
|
+
<option key={ex.id} value={ex.id}>
|
|
791
|
+
{ex.name}
|
|
792
|
+
</option>
|
|
793
|
+
))}
|
|
794
|
+
</select>
|
|
795
|
+
)}
|
|
796
|
+
</div>
|
|
797
|
+
|
|
798
|
+
{slug && (
|
|
799
|
+
<div style={S.previewPath}>
|
|
800
|
+
Will create: {location}/{slug}/
|
|
801
|
+
</div>
|
|
802
|
+
)}
|
|
803
|
+
|
|
804
|
+
<div style={S.formActions}>
|
|
805
|
+
<button type="button" className="ps-btn-secondary" onClick={onCancel} disabled={busy}>
|
|
806
|
+
Cancel
|
|
807
|
+
</button>
|
|
808
|
+
<button
|
|
809
|
+
type="button"
|
|
810
|
+
className="ps-btn-primary"
|
|
811
|
+
onClick={onCreate}
|
|
812
|
+
disabled={
|
|
813
|
+
busy || !name.trim() || !location.trim() || (template === 'example' && !exampleId)
|
|
814
|
+
}
|
|
815
|
+
>
|
|
816
|
+
{busy ? 'Creating...' : 'Create Project'}
|
|
817
|
+
</button>
|
|
818
|
+
</div>
|
|
819
|
+
</div>
|
|
820
|
+
);
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
// ---------------------------------------------------------------------------
|
|
824
|
+
// ErrorBanner
|
|
825
|
+
// ---------------------------------------------------------------------------
|
|
826
|
+
|
|
827
|
+
function ErrorBanner({ message, onDismiss }: { message: string; onDismiss: () => void }) {
|
|
828
|
+
return (
|
|
829
|
+
<div style={S.error}>
|
|
830
|
+
<span>{message}</span>
|
|
831
|
+
<button type="button" style={S.errorClose} onClick={onDismiss}>
|
|
832
|
+
×
|
|
833
|
+
</button>
|
|
834
|
+
</div>
|
|
835
|
+
);
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
// ---------------------------------------------------------------------------
|
|
839
|
+
// Helpers
|
|
840
|
+
// ---------------------------------------------------------------------------
|
|
841
|
+
|
|
842
|
+
function shortenPath(p: string): string {
|
|
843
|
+
if (p.startsWith('/Users/')) return `~${p.slice(p.indexOf('/', 7))}`;
|
|
844
|
+
if (p.startsWith('/home/')) return `~${p.slice(p.indexOf('/', 6))}`;
|
|
845
|
+
return p;
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
function formatRelativeTime(iso: string): string {
|
|
849
|
+
const diff = Date.now() - new Date(iso).getTime();
|
|
850
|
+
const minutes = Math.floor(diff / 60000);
|
|
851
|
+
if (minutes < 1) return 'just now';
|
|
852
|
+
if (minutes < 60) return `${minutes}m ago`;
|
|
853
|
+
const hours = Math.floor(minutes / 60);
|
|
854
|
+
if (hours < 24) return `${hours}h ago`;
|
|
855
|
+
const days = Math.floor(hours / 24);
|
|
856
|
+
if (days < 7) return `${days}d ago`;
|
|
857
|
+
const weeks = Math.floor(days / 7);
|
|
858
|
+
return `${weeks}w ago`;
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
// ---------------------------------------------------------------------------
|
|
862
|
+
// Layout styles (structural only — interactive states handled by CSS above)
|
|
863
|
+
// ---------------------------------------------------------------------------
|
|
864
|
+
|
|
865
|
+
const S = {
|
|
866
|
+
root: {
|
|
867
|
+
position: 'absolute' as const,
|
|
868
|
+
top: 0,
|
|
869
|
+
left: 0,
|
|
870
|
+
width: '100%',
|
|
871
|
+
height: '100%',
|
|
872
|
+
background: '#1a1a1a',
|
|
873
|
+
display: 'flex',
|
|
874
|
+
alignItems: 'center',
|
|
875
|
+
justifyContent: 'center',
|
|
876
|
+
fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
|
|
877
|
+
color: '#c5c8ce',
|
|
878
|
+
pointerEvents: 'auto' as const,
|
|
879
|
+
},
|
|
880
|
+
inner: {
|
|
881
|
+
width: '100%',
|
|
882
|
+
maxWidth: 640,
|
|
883
|
+
padding: '40px 32px',
|
|
884
|
+
},
|
|
885
|
+
header: {
|
|
886
|
+
textAlign: 'center' as const,
|
|
887
|
+
marginBottom: 32,
|
|
888
|
+
},
|
|
889
|
+
title: {
|
|
890
|
+
fontSize: 28,
|
|
891
|
+
fontWeight: 700,
|
|
892
|
+
color: '#e0e0e0',
|
|
893
|
+
letterSpacing: 2,
|
|
894
|
+
},
|
|
895
|
+
version: {
|
|
896
|
+
fontSize: 13,
|
|
897
|
+
color: '#666',
|
|
898
|
+
marginTop: 4,
|
|
899
|
+
},
|
|
900
|
+
error: {
|
|
901
|
+
background: '#3a1c1c',
|
|
902
|
+
border: '1px solid #6b2c2c',
|
|
903
|
+
borderRadius: 6,
|
|
904
|
+
padding: '10px 16px',
|
|
905
|
+
marginBottom: 16,
|
|
906
|
+
fontSize: 13,
|
|
907
|
+
color: '#e8a0a0',
|
|
908
|
+
display: 'flex',
|
|
909
|
+
justifyContent: 'space-between',
|
|
910
|
+
alignItems: 'center',
|
|
911
|
+
},
|
|
912
|
+
errorClose: {
|
|
913
|
+
background: 'none',
|
|
914
|
+
border: 'none',
|
|
915
|
+
color: '#e8a0a0',
|
|
916
|
+
fontSize: 18,
|
|
917
|
+
cursor: 'pointer',
|
|
918
|
+
padding: '0 4px',
|
|
919
|
+
},
|
|
920
|
+
section: {
|
|
921
|
+
marginBottom: 24,
|
|
922
|
+
},
|
|
923
|
+
sectionTitle: {
|
|
924
|
+
fontSize: 13,
|
|
925
|
+
color: '#888',
|
|
926
|
+
textTransform: 'uppercase' as const,
|
|
927
|
+
letterSpacing: 1,
|
|
928
|
+
marginBottom: 12,
|
|
929
|
+
},
|
|
930
|
+
empty: {
|
|
931
|
+
color: '#555',
|
|
932
|
+
fontSize: 13,
|
|
933
|
+
padding: '24px 0',
|
|
934
|
+
textAlign: 'center' as const,
|
|
935
|
+
},
|
|
936
|
+
grid: {
|
|
937
|
+
display: 'grid',
|
|
938
|
+
gridTemplateColumns: 'repeat(auto-fill, minmax(170px, 1fr))',
|
|
939
|
+
gap: 10,
|
|
940
|
+
},
|
|
941
|
+
cardName: {
|
|
942
|
+
fontSize: 14,
|
|
943
|
+
fontWeight: 600,
|
|
944
|
+
color: '#e0e0e0',
|
|
945
|
+
marginBottom: 2,
|
|
946
|
+
overflow: 'hidden',
|
|
947
|
+
textOverflow: 'ellipsis',
|
|
948
|
+
whiteSpace: 'nowrap' as const,
|
|
949
|
+
},
|
|
950
|
+
cardMeta: {
|
|
951
|
+
fontSize: 11,
|
|
952
|
+
color: '#666',
|
|
953
|
+
overflow: 'hidden',
|
|
954
|
+
textOverflow: 'ellipsis',
|
|
955
|
+
whiteSpace: 'nowrap' as const,
|
|
956
|
+
},
|
|
957
|
+
actions: {
|
|
958
|
+
display: 'flex',
|
|
959
|
+
gap: 10,
|
|
960
|
+
},
|
|
961
|
+
form: {
|
|
962
|
+
display: 'flex',
|
|
963
|
+
flexDirection: 'column' as const,
|
|
964
|
+
gap: 16,
|
|
965
|
+
},
|
|
966
|
+
label: {
|
|
967
|
+
display: 'flex',
|
|
968
|
+
flexDirection: 'column' as const,
|
|
969
|
+
gap: 6,
|
|
970
|
+
fontSize: 13,
|
|
971
|
+
color: '#888',
|
|
972
|
+
},
|
|
973
|
+
locationRow: {
|
|
974
|
+
display: 'flex',
|
|
975
|
+
gap: 8,
|
|
976
|
+
},
|
|
977
|
+
templateRow: {
|
|
978
|
+
display: 'flex',
|
|
979
|
+
gap: 10,
|
|
980
|
+
marginTop: 4,
|
|
981
|
+
},
|
|
982
|
+
templateName: {
|
|
983
|
+
fontSize: 14,
|
|
984
|
+
fontWeight: 600,
|
|
985
|
+
color: '#e0e0e0',
|
|
986
|
+
marginBottom: 4,
|
|
987
|
+
},
|
|
988
|
+
templateDesc: {
|
|
989
|
+
fontSize: 11,
|
|
990
|
+
color: '#666',
|
|
991
|
+
lineHeight: 1.4,
|
|
992
|
+
},
|
|
993
|
+
previewPath: {
|
|
994
|
+
fontSize: 12,
|
|
995
|
+
color: '#555',
|
|
996
|
+
fontFamily: 'monospace',
|
|
997
|
+
},
|
|
998
|
+
formActions: {
|
|
999
|
+
display: 'flex',
|
|
1000
|
+
justifyContent: 'flex-end',
|
|
1001
|
+
gap: 10,
|
|
1002
|
+
marginTop: 8,
|
|
1003
|
+
},
|
|
1004
|
+
};
|