@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 @@
|
|
|
1
|
+
import{ao as s}from"./index-_bCaipUk.js";function c(r){const e=s(r,"tags");if(Array.isArray(e))return e;const t=s(r,"entity")?.tags;return Array.isArray(t)?t:[]}function o(r){const e=s(r,"components");if(Array.isArray(e))return e;if(e&&typeof e=="object")return Object.keys(e);const t=s(r,"entity")?.components;return t&&typeof t=="object"?Object.keys(t):[]}function i(r,e){const t=[];return r.traverse(n=>{c(n).includes(e)&&t.push(n)}),t}function u(r,e){const t=[];return r.traverse(n=>{n.name===e&&t.push(n)}),t}function f(r,e){const t=[];return r.traverse(n=>{o(n).includes(e)&&t.push(n)}),t}export{f as queryByComponent,u as queryByName,i as queryByTag};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var P=function(){var m=0,a=document.createElement("div");a.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",a.addEventListener("click",function(n){n.preventDefault(),o(++m%a.children.length)},!1);function i(n){return a.appendChild(n.dom),n}function o(n){for(var l=0;l<a.children.length;l++)a.children[l].style.display=l===n?"block":"none";m=n}var f=(performance||Date).now(),r=f,e=0,u=i(new P.Panel("FPS","#0ff","#002")),v=i(new P.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var h=i(new P.Panel("MB","#f08","#201"));return o(0),{REVISION:16,dom:a,addPanel:i,showPanel:o,begin:function(){f=(performance||Date).now()},end:function(){e++;var n=(performance||Date).now();if(v.update(n-f,200),n>=r+1e3&&(u.update(e*1e3/(n-r),100),r=n,e=0,h)){var l=performance.memory;h.update(l.usedJSHeapSize/1048576,l.jsHeapSizeLimit/1048576)}return n},update:function(){f=this.end()},domElement:a,setMode:o}};P.Panel=function(m,a,i){var o=1/0,f=0,r=Math.round,e=r(window.devicePixelRatio||1),u=80*e,v=48*e,h=3*e,n=2*e,l=3*e,c=15*e,d=74*e,s=30*e,p=document.createElement("canvas");p.width=u,p.height=v,p.style.cssText="width:80px;height:48px";var t=p.getContext("2d");return t.font="bold "+9*e+"px Helvetica,Arial,sans-serif",t.textBaseline="top",t.fillStyle=i,t.fillRect(0,0,u,v),t.fillStyle=a,t.fillText(m,h,n),t.fillRect(l,c,d,s),t.fillStyle=i,t.globalAlpha=.9,t.fillRect(l,c,d,s),{dom:p,update:function(x,S){o=Math.min(o,x),f=Math.max(f,x),t.fillStyle=i,t.globalAlpha=1,t.fillRect(0,0,u,c),t.fillStyle=a,t.fillText(r(x)+" "+m+" ("+r(o)+"-"+r(f)+")",h,n),t.drawImage(p,l+e,c,d-e,s,l,c,d-e,s),t.fillRect(l+d-e,c,e,s),t.fillStyle=i,t.globalAlpha=.9,t.fillRect(l+d-e,c,e,r((1-x/S)*s))}}};export{P as S};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ax as a,iL as i,iM as s,iN as e}from"./index-_bCaipUk.js";a.add(i,s);a.add(e);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{aD as V,aE as v,aF as w,aG as j,aH as y,aI as q,aJ as T,aK as B,aL as K,aM as z}from"./index-_bCaipUk.js";function C(e,s){switch(e.type){case"1D":return G(e,s);case"2D":return J(e,s);case"direct":return U(e);default:return e.children.map(n=>({clip:n.clip,weight:1/e.children.length}))}}function G(e,s){const n=Number(s.get(e.parameter)??0),a=[...e.children].sort((h,f)=>h.threshold-f.threshold),o=a.map(h=>({clip:h.clip,weight:0}));if(a.length===0)return o;if(a.length===1||n<=a[0].threshold)return o[0].weight=1,o;if(n>=a[a.length-1].threshold)return o[o.length-1].weight=1,o;for(let h=0;h<a.length-1;h++){const f=a[h],p=a[h+1];if(n>=f.threshold&&n<=p.threshold){const m=p.threshold-f.threshold,g=m>0?(n-f.threshold)/m:0;return o[h].weight=1-g,o[h+1].weight=g,o}}return o}function J(e,s){const n=Number(s.get(e.parameter)??0),a=Number(s.get(e.parameterY??"")??0),o=e.children,h=o.map(m=>({clip:m.clip,weight:0}));let f=0;const p=[];for(const m of o){const g=n-m.threshold,d=a-(m.thresholdY??0),b=Math.sqrt(g*g+d*d),S=b<.001?1e3:1/b;p.push(S),f+=S}if(f>0)for(let m=0;m<h.length;m++)h[m].weight=p[m]/f;return h}function U(e){const s=e.children.map(a=>({clip:a.clip,weight:a.weight??0})),n=s.reduce((a,o)=>a+o.weight,0);if(n>0)for(const a of s)a.weight/=n;return s}const W=v({clip:y().min(1).describe("Animation clip name this child plays"),threshold:w().describe("1D/2D blend position on the primary parameter axis"),thresholdY:w().optional().describe("2D blend position on the secondary parameter axis (2D blend trees only)"),weight:w().min(0).optional().describe('Explicit weight for "direct" blend trees (ignored by 1D/2D)')}).strict(),Q=v({type:B("1D").describe("Interpolates linearly between sorted children by threshold"),parameter:y().min(1).describe("Context/selector value driving the blend"),children:T(W).min(2,"1D blend tree needs at least 2 children to interpolate between")}).strict(),Z=v({type:B("2D").describe("Inverse-distance-weights children by (parameter, parameterY) position"),parameter:y().min(1).describe("Primary axis context/selector value"),parameterY:y().min(1).describe("Secondary axis context/selector value"),children:T(W.extend({thresholdY:w()})).min(1,"2D blend tree needs at least 1 child")}).strict(),_=v({type:B("direct").describe("Each child has an explicit weight, normalized to sum to 1"),parameter:y().default(""),children:T(W.extend({weight:w().min(0)})).min(1,"direct blend tree needs at least 1 child")}).strict(),ee=q("type",[Q,Z,_]),L=v({duration:w().min(0).default(0).describe("Seconds to blend from the previously active clip into this state on entry, applied via native `AnimationAction.crossFadeTo`/`fadeIn` (E2). 0 = instant activation, no fade."),warp:j().default(!1).describe("Passed through to AnimationAction.crossFadeTo's `warp` param — linearly warps timeScale across the two clips during the blend so differing clip lengths line up. Default false.")}).strict().describe("Blend-in/out/crossfade timing for entering this state"),te=v({clip:y().min(1).describe("Single clip to play while this XState state is active"),loop:j().default(!0).describe("Loop the clip (THREE.LoopRepeat) vs play once (THREE.LoopOnce, clamped on last frame)"),speed:w().positive().default(1).describe("Playback speed multiplier (AnimationAction.timeScale)"),crossfade:L.optional()}).strict(),ie=v({blendTree:ee.describe("Multiple clips blended by a live context/selector-driven parameter"),crossfade:L.optional()}).strict(),ne=V([te,ie]);function ae(e){return"clip"in e}function A(e){return"blendTree"in e}class se extends Error{constructor(s,n,a){super(s),this.stateId=n,this.issues=a,this.name="AnimationMetaValidationError"}}function oe(e,s){const n=ne.safeParse(s);if(!n.success){const a=n.error.issues.map(o=>`${o.path.length?o.path.join("."):"(root)"}: ${o.message}`).join("; ");throw new se(`[xstate-animation] invalid meta.animation for state "${e}": ${a}`,e,n.error.issues)}return n.data}function re(e){const s=[],n=a=>{a.meta&&"animation"in a.meta&&a.meta.animation!==void 0&&s.push({stateId:a.id,meta:oe(a.id,a.meta.animation)});for(const o of Object.values(a.states??{}))n(o)};return n(e),s}function ce(e){return ae(e)?[e.clip]:e.blendTree.children.map(s=>s.clip)}class I extends Error{constructor(s,n){super(s),this.stateId=n,this.name="AnimationBindingError"}}function le(e){return e.reduce((s,n)=>n.weight>s.weight?n:s,e[0])}function de(e){return A(e)?[]:[{clip:e.clip,weight:1}]}function pe(e,s,n,a={}){const o=e.logic.root,h=re(o),f=new Map(h.map(t=>[t.stateId,t.meta]));for(const t of h)for(const i of ce(t.meta))if(!n.has(i))throw new I(`[bindXStateAnimation] state "${t.stateId}" references clip "${i}", which is not present in the supplied clips map. Known clips: ${[...n.keys()].join(", ")||"(none)"}`,t.stateId);const p=new Map;function m(t,i,c){let r=p.get(t);if(!r){const l=n.get(t);if(!l)throw new I(`[bindXStateAnimation] clip "${t}" not found`);r=s.clipAction(l),r.setEffectiveWeight(0),r.play(),p.set(t,r)}return r.setLoop(i?K:z,1/0),r.clampWhenFinished=!i,r.timeScale=c,r}function g(t){const i=a.selectParameters?a.selectParameters(t):t;return new Map(Object.entries(i??{}))}let d=null,b=!1;function S(t,i,c){for(const{clip:r}of t){if(r===i)continue;const l=p.get(r);l&&(c>0?l.fadeOut(c):l.setEffectiveWeight(0))}}function N(t,i,c,r){for(const{clip:u}of t)m(u,c,r);const l=p.get(i);l.reset(),l.setEffectiveWeight(1);for(const{clip:u}of t){if(u===i)continue;const D=p.get(u);D.reset(),D.setEffectiveWeight(0)}return l}function P(t,i,c,r){if(!i){c>0?t.fadeIn(c):t.setEffectiveWeight(1);return}S(i.natural,i.dominantClip,c);const l=p.get(i.dominantClip);if(l&&c>0){l.crossFadeTo(t,c,r);return}l?.setEffectiveWeight(0),t.setEffectiveWeight(1)}function O(t,i,c){const r=A(i),l=r?C(i.blendTree,g(c)):de(i),u=le(l),D=r?!0:i.loop,X=r?1:i.speed,k=N(l,u.clip,D,X),M=i.crossfade?.duration??0,H=i.crossfade?.warp??!1;P(k,d,M,H),d={stateId:t,meta:i,natural:l,dominantClip:u.clip,crossfadeRemaining:M},r&&M<=0&&E(d,c)}function E(t,i){if(!A(t.meta))return;const c=g(i),r=C(t.meta.blendTree,c);t.natural=r;for(const{clip:l,weight:u}of r)p.get(l)?.setEffectiveWeight(u)}const R=e.getSnapshot(),x=$(R,f);x&&O(x,f.get(x),R.context);const Y=e.subscribe(t=>{if(b)return;const i=$(t,f),c=i?f.get(i):void 0;c&&i&&i!==d?.stateId&&O(i,c,t.context)});function F(t){b||(d&&d.crossfadeRemaining>0?(d.crossfadeRemaining=Math.max(0,d.crossfadeRemaining-t),d.crossfadeRemaining<=0&&A(d.meta)&&E(d,e.getSnapshot().context)):d&&A(d.meta)&&E(d,e.getSnapshot().context),s.update(t))}return{tick:F,actor:e,dispose(){if(!b){b=!0,Y.unsubscribe();for(const[t,i]of p)i.stop(),s.uncacheAction(i.getClip(),i.getRoot()),p.delete(t);d=null}}}}function $(e,s){const n=Object.keys(e.getMeta()).filter(a=>s.has(a));if(n.length>1)throw new I(`[bindXStateAnimation] more than one animated state is simultaneously active (${n.join(", ")}) — parallel-region animation composition is not supported by this binding; exactly one active meta.animation state is required.`);return n[0]}export{I as AnimationBindingError,pe as bindXStateAnimation};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
function te(){if(typeof globalThis<"u")return globalThis;if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global}function ee(){const n=te();if(n.__xstate__)return n.__xstate__}const ne=n=>{if(typeof window>"u")return;const t=ee();t&&t.register(n)};class vt{constructor(t){this._process=t,this._active=!1,this._current=null,this._last=null}start(){this._active=!0,this.flush()}clear(){this._current&&(this._current.next=null,this._last=this._current)}enqueue(t){const e={value:t,next:null};if(this._current){this._last.next=e,this._last=e;return}this._current=e,this._last=e,this._active&&this.flush()}flush(){for(;this._current;){const t=this._current;this._process(t.value),this._current=t.next}this._last=null}}const Ot=".",se="",Mt="",ie="#",re="*",Rt="xstate.init",oe="xstate.error",w="xstate.stop";function ce(n,t){return{type:`xstate.after.${n}.${t}`}}function et(n,t){return{type:`xstate.done.state.${n}`,output:t}}function ae(n,t){return{type:`xstate.done.actor.${n}`,output:t,actorId:n}}function jt(n,t){return{type:`xstate.error.actor.${n}`,error:t,actorId:n}}function ot(n){return{type:Rt,input:n}}function v(n){setTimeout(()=>{throw n})}const ue=typeof Symbol=="function"&&Symbol.observable||"@@observable";function Ct(n,t){const e=_t(n),s=_t(t);return typeof s=="string"?typeof e=="string"?s===e:!1:typeof e=="string"?e in s:Object.keys(e).every(i=>i in s?Ct(e[i],s[i]):!1)}function ct(n){if(Lt(n))return n;const t=[];let e="";for(let s=0;s<n.length;s++){switch(n.charCodeAt(s)){case 92:e+=n[s+1],s++;continue;case 46:t.push(e),e="";continue}e+=n[s]}return t.push(e),t}function _t(n){if(He(n))return n.value;if(typeof n!="string")return n;const t=ct(n);return fe(t)}function fe(n){if(n.length===1)return n[0];const t={};let e=t;for(let s=0;s<n.length-1;s++)if(s===n.length-2)e[n[s]]=n[s+1];else{const i=e;e={},i[n[s]]=e}return t}function St(n,t){const e={},s=Object.keys(n);for(let i=0;i<s.length;i++){const r=s[i];e[r]=t(n[r],r,n,i)}return e}function Dt(n){return Lt(n)?n:[n]}function _(n){return n===void 0?[]:Dt(n)}function nt(n,t,e,s){return typeof n=="function"?n({context:t,event:e,self:s}):n}function Lt(n){return Array.isArray(n)}function de(n){return n.type.startsWith("xstate.error.actor")}function O(n){return Dt(n).map(t=>typeof t>"u"||typeof t=="string"?{target:t}:t)}function Bt(n){if(!(n===void 0||n===se))return _(n)}function X(n,t,e){const s=typeof n=="object",i=s?n:void 0;return{next:(s?n.next:n)?.bind(i),error:(s?n.error:t)?.bind(i),complete:(s?n.complete:e)?.bind(i)}}function bt(n,t){return`${t}.${n}`}function at(n,t){const e=t.match(/^xstate\.invoke\.(\d+)\.(.*)/);if(!e)return n.implementations.actors[t];const[,s,i]=e,o=n.getStateNodeById(i).config.invoke;return(Array.isArray(o)?o[s]:o).src}function wn(n){return[...new Set([...n._nodes.flatMap(t=>t.ownEvents)])]}function Pt(n,t){if(t===n||t===re)return!0;if(!t.endsWith(".*"))return!1;const e=t.split("."),s=n.split(".");for(let i=0;i<e.length;i++){const r=e[i],o=s[i];if(r==="*")return i===e.length-1;if(r!==o)return!1}return!0}function xt(n,t){return`${n.sessionId}.${t}`}let he=0;function Jt(n,t){const e=new Map,s=new Map,i=new WeakMap,r=new Set,o={},{clock:c,logger:u}=t,h={schedule:(a,d,l,y,g=Math.random().toString(36).slice(2))=>{const A={source:a,target:d,event:l,delay:y,id:g,startedAt:Date.now()},k=xt(a,g);f._snapshot._scheduledEvents[k]=A;const Nt=c.setTimeout(()=>{delete o[k],delete f._snapshot._scheduledEvents[k],f._relay(a,d,l)},y);o[k]=Nt},cancel:(a,d)=>{const l=xt(a,d),y=o[l];delete o[l],delete f._snapshot._scheduledEvents[l],y!==void 0&&c.clearTimeout(y)},cancelAll:a=>{for(const d in f._snapshot._scheduledEvents){const l=f._snapshot._scheduledEvents[d];l.source===a&&h.cancel(a,l.id)}}},p=a=>{if(!r.size)return;const d={...a,rootId:n.sessionId};r.forEach(l=>l.next?.(d))},f={_snapshot:{_scheduledEvents:(t?.snapshot&&t.snapshot.scheduler)??{}},_bookId:()=>`x:${he++}`,_register:(a,d)=>(e.set(a,d),a),_unregister:a=>{e.delete(a.sessionId);const d=i.get(a);d!==void 0&&(s.delete(d),i.delete(a))},get:a=>s.get(a),getAll:()=>Object.fromEntries(s.entries()),_set:(a,d)=>{const l=s.get(a);if(l&&l!==d)throw new Error(`Actor with system ID '${a}' already exists.`);s.set(a,d),i.set(d,a)},inspect:a=>{const d=X(a);return r.add(d),{unsubscribe(){r.delete(d)}}},_sendInspectionEvent:p,_relay:(a,d,l)=>{f._sendInspectionEvent({type:"@xstate.event",sourceRef:a,actorRef:d,event:l}),d._send(l)},scheduler:h,getSnapshot:()=>({_scheduledEvents:{...f._snapshot._scheduledEvents}}),start:()=>{const a=f._snapshot._scheduledEvents;f._snapshot._scheduledEvents={};for(const d in a){const{source:l,target:y,event:g,delay:A,id:k}=a[d];h.schedule(l,y,g,A,k)}},_clock:c,_logger:u};return f}let Q=!1;const ut=1;let m=(function(n){return n[n.NotStarted=0]="NotStarted",n[n.Running=1]="Running",n[n.Stopped=2]="Stopped",n})({});const le={clock:{setTimeout:(n,t)=>setTimeout(n,t),clearTimeout:n=>clearTimeout(n)},logger:console.log.bind(console),devTools:!1};class pe{constructor(t,e){this.logic=t,this._snapshot=void 0,this.clock=void 0,this.options=void 0,this.id=void 0,this.mailbox=new vt(this._process.bind(this)),this.observers=new Set,this.eventListeners=new Map,this.logger=void 0,this._processingStatus=m.NotStarted,this._parent=void 0,this._syncSnapshot=void 0,this.ref=void 0,this._actorScope=void 0,this.systemId=void 0,this.sessionId=void 0,this.system=void 0,this._doneEvent=void 0,this.src=void 0,this._deferred=[];const s={...le,...e},{clock:i,logger:r,parent:o,syncSnapshot:c,id:u,systemId:h,inspect:p}=s;this.system=o?o.system:Jt(this,{clock:i,logger:r}),p&&!o&&this.system.inspect(X(p)),this.sessionId=this.system._bookId(),this.id=u??this.sessionId,this.logger=e?.logger??this.system._logger,this.clock=e?.clock??this.system._clock,this._parent=o,this._syncSnapshot=c,this.options=s,this.src=s.src??t,this.ref=this,this._actorScope={self:this,id:this.id,sessionId:this.sessionId,logger:this.logger,defer:f=>{this._deferred.push(f)},system:this.system,stopChild:f=>{if(f._parent!==this)throw new Error(`Cannot stop child actor ${f.id} of ${this.id} because it is not a child`);f._stop()},emit:f=>{const a=this.eventListeners.get(f.type),d=this.eventListeners.get("*");if(!a&&!d)return;const l=[...a?a.values():[],...d?d.values():[]];for(const y of l)try{y(f)}catch(g){v(g)}},actionExecutor:f=>{const a=()=>{if(this._actorScope.system._sendInspectionEvent({type:"@xstate.action",actorRef:this,action:{type:f.type,params:f.params}}),!f.exec)return;const d=Q;try{Q=!0,f.exec(f.info,f.params)}finally{Q=d}};this._processingStatus===m.Running?a():this._deferred.push(a)}},this.send=this.send.bind(this),this.system._sendInspectionEvent({type:"@xstate.actor",actorRef:this}),h&&(this.systemId=h,this.system._set(h,this)),this._initState(e?.snapshot??e?.state),h&&this._snapshot.status!=="active"&&this.system._unregister(this)}_initState(t){try{this._snapshot=t?this.logic.restoreSnapshot?this.logic.restoreSnapshot(t,this._actorScope):t:this.logic.getInitialSnapshot(this._actorScope,this.options?.input)}catch(e){this._snapshot={status:"error",output:void 0,error:e}}}update(t,e){this._snapshot=t;let s;for(;s=this._deferred.shift();)try{s()}catch(i){this._deferred.length=0,this._snapshot={...t,status:"error",error:i}}switch(this._snapshot.status){case"active":for(const i of this.observers)try{i.next?.(t)}catch(r){v(r)}break;case"done":for(const i of this.observers)try{i.next?.(t)}catch(r){v(r)}this._stopProcedure(),this._complete(),this._doneEvent=ae(this.id,this._snapshot.output),this._parent&&this.system._relay(this,this._parent,this._doneEvent);break;case"error":this._error(this._snapshot.error);break}this.system._sendInspectionEvent({type:"@xstate.snapshot",actorRef:this,event:e,snapshot:t})}subscribe(t,e,s){const i=X(t,e,s);if(this._processingStatus!==m.Stopped)this.observers.add(i);else switch(this._snapshot.status){case"done":try{i.complete?.()}catch(r){v(r)}break;case"error":{const r=this._snapshot.error;if(!i.error)v(r);else try{i.error(r)}catch(o){v(o)}break}}return{unsubscribe:()=>{this.observers.delete(i)}}}on(t,e){let s=this.eventListeners.get(t);s||(s=new Set,this.eventListeners.set(t,s));const i=e.bind(void 0);return s.add(i),{unsubscribe:()=>{s.delete(i)}}}select(t,e=Object.is){return{subscribe:s=>{const i=X(s),r=this.getSnapshot();let o=t(r);return this.subscribe(c=>{const u=t(c);e(o,u)||(o=u,i.next?.(u))})},get:()=>t(this.getSnapshot())}}start(){if(this._processingStatus===m.Running)return this;this._syncSnapshot&&this.subscribe({next:s=>{s.status==="active"&&this.system._relay(this,this._parent,{type:`xstate.snapshot.${this.id}`,snapshot:s})},error:()=>{}}),this.system._register(this.sessionId,this),this.systemId&&this.system._set(this.systemId,this),this._processingStatus=m.Running;const t=ot(this.options.input);switch(this.system._sendInspectionEvent({type:"@xstate.event",sourceRef:this._parent,actorRef:this,event:t}),this._snapshot.status){case"done":return this.update(this._snapshot,t),this;case"error":return this._error(this._snapshot.error),this}if(this._parent||this.system.start(),this.logic.start)try{this.logic.start(this._snapshot,this._actorScope)}catch(s){return this._snapshot={...this._snapshot,status:"error",error:s},this._error(s),this}return this.update(this._snapshot,t),this.options.devTools&&this.attachDevTools(),this.mailbox.start(),this}_process(t){let e,s;try{e=this.logic.transition(this._snapshot,t,this._actorScope)}catch(i){s={err:i}}if(s){const{err:i}=s;this._snapshot={...this._snapshot,status:"error",error:i},this._error(i);return}this.update(e,t),t.type===w&&(this._stopProcedure(),this._complete())}_stop(){return this._processingStatus===m.Stopped?this:(this.mailbox.clear(),this._processingStatus===m.NotStarted?(this._processingStatus=m.Stopped,this):(this.mailbox.enqueue({type:w}),this))}stop(){if(this._parent)throw new Error("A non-root actor cannot be stopped directly.");return this._stop()}_complete(){for(const t of this.observers)try{t.complete?.()}catch(e){v(e)}this.observers.clear(),this.eventListeners.clear()}_reportError(t){if(!this.observers.size){this._parent||v(t),this.eventListeners.clear();return}let e=!1;for(const s of this.observers){const i=s.error;e||=!i;try{i?.(t)}catch(r){v(r)}}this.observers.clear(),this.eventListeners.clear(),e&&v(t)}_error(t){this._stopProcedure(),this._reportError(t),this._parent&&this.system._relay(this,this._parent,jt(this.id,t))}_stopProcedure(){return this._processingStatus!==m.Running?this:(this.system.scheduler.cancelAll(this),this.mailbox.clear(),this.mailbox=new vt(this._process.bind(this)),this._processingStatus=m.Stopped,this.system._unregister(this),this)}_send(t){this._processingStatus!==m.Stopped&&this.mailbox.enqueue(t)}send(t){this.system._relay(void 0,this,t)}attachDevTools(){const{devTools:t}=this.options;t&&(typeof t=="function"?t:ne)(this)}toJSON(){return{xstate$$type:ut,id:this.id}}getPersistedSnapshot(t){return this.logic.getPersistedSnapshot(this._snapshot,t)}[ue](){return this}getSnapshot(){return this._snapshot}}function E(n,...[t]){return new pe(n,t)}const En=E;function ye(n,t,e,s,{sendId:i}){const r=typeof i=="function"?i(e,s):i;return[t,{sendId:r},void 0]}function ge(n,t){n.defer(()=>{n.system.scheduler.cancel(n.self,t.sendId)})}function ft(n){function t(e,s){}return t.type="xstate.cancel",t.sendId=n,t.resolve=ye,t.execute=ge,t}function me(n,t,e,s,{id:i,systemId:r,src:o,input:c,syncSnapshot:u}){const h=typeof o=="string"?at(t.machine,o):o,p=typeof i=="function"?i(e):i;let f,a;return h&&(a=typeof c=="function"?c({context:t.context,event:e.event,self:n.self}):c,f=E(h,{id:p,src:o,parent:n.self,syncSnapshot:u,systemId:r,input:a})),[T(t,{children:{...t.children,[p]:f}}),{id:i,systemId:r,actorRef:f,src:o,input:a},void 0]}function ve(n,{actorRef:t}){t&&n.defer(()=>{t._processingStatus!==m.Stopped&&t.start()})}function dt(...[n,{id:t,systemId:e,input:s,syncSnapshot:i=!1}={}]){function r(o,c){}return r.type="xstate.spawnChild",r.id=t,r.systemId=e,r.src=n,r.input=s,r.syncSnapshot=i,r.resolve=me,r.execute=ve,r}function _e(n,t,e,s,{actorRef:i}){const r=typeof i=="function"?i(e,s):i,o=typeof r=="string"?t.children[r]:r;let c=t.children;return o&&(c={...c},delete c[o.id]),[T(t,{children:c}),o,void 0]}function zt(n,t){const e=t.getSnapshot();if(e&&"children"in e)for(const s of Object.values(e.children))zt(n,s);n.system._unregister(t)}function Se(n,t){if(t){if(zt(n,t),t._processingStatus!==m.Running){n.stopChild(t);return}n.defer(()=>{n.stopChild(t)})}}function z(n){function t(e,s){}return t.type="xstate.stopChild",t.actorRef=n,t.resolve=_e,t.execute=Se,t}const Tn=z;function be(n,t,{stateValue:e}){if(typeof e=="string"&&W(e)){const s=n.machine.getStateNodeById(e);return n._nodes.some(i=>i===s)}return n.matches(e)}function In(n){function t(){return!1}return t.check=be,t.stateValue=n,t}function xe(n,{context:t,event:e},{guards:s}){return!I(s[0],t,e,n)}function An(n){function t(e,s){return!1}return t.check=xe,t.guards=[n],t}function we(n,{context:t,event:e},{guards:s}){return s.every(i=>I(i,t,e,n))}function Ee(n){function t(e,s){return!1}return t.check=we,t.guards=n,t}function Te(n,{context:t,event:e},{guards:s}){return s.some(i=>I(i,t,e,n))}function kn(n){function t(e,s){return!1}return t.check=Te,t.guards=n,t}function I(n,t,e,s){const{machine:i}=s,r=typeof n=="function",o=r?n:i.implementations.guards[typeof n=="string"?n:n.type];if(!r&&!o)throw new Error(`Guard '${typeof n=="string"?n:n.type}' is not implemented.'.`);if(typeof o!="function")return I(o,t,e,s);const c={context:t,event:e},u=r||typeof n=="string"?void 0:"params"in n?typeof n.params=="function"?n.params({context:t,event:e}):n.params:void 0;return"check"in o?o.check(s,c,o):o(c,u)}function q(n){return n.type==="atomic"||n.type==="final"}function R(n){return Object.values(n.states).filter(t=>t.type!=="history")}function D(n,t){const e=[];if(t===n)return e;let s=n.parent;for(;s&&s!==t;)e.push(s),s=s.parent;return e}function U(n){const t=new Set(n),e=Wt(t);for(const s of t)if(s.type==="compound"&&(!e.get(s)||!e.get(s).length))wt(s).forEach(i=>t.add(i));else if(s.type==="parallel"){for(const i of R(s))if(i.type!=="history"&&!t.has(i)){const r=wt(i);for(const o of r)t.add(o)}}for(const s of t){let i=s.parent;for(;i;)t.add(i),i=i.parent}return t}function qt(n,t){const e=t.get(n);if(!e)return{};if(n.type==="compound"){const i=e[0];if(i){if(q(i))return i.key}else return{}}const s={};for(const i of e)s[i.key]=qt(i,t);return s}function Wt(n){const t=new Map;for(const e of n)t.has(e)||t.set(e,[]),e.parent&&(t.has(e.parent)||t.set(e.parent,[]),t.get(e.parent).push(e));return t}function Xt(n,t){const e=U(t);return qt(n,Wt(e))}function ht(n,t){return t.type==="compound"?R(t).some(e=>e.type==="final"&&n.has(e)):t.type==="parallel"?R(t).every(e=>ht(n,e)):t.type==="final"}const W=n=>n[0]===ie;function Ie(n,t){const e=n.transitions.get(t),s=[...n.transitions.keys()].filter(i=>i!==t&&Pt(t,i)).sort((i,r)=>r.length-i.length).flatMap(i=>n.transitions.get(i));return e?[...e,...s]:s}function Ae(n){const t=n.config.after;if(!t)return[];const e=i=>{const r=ce(i,n.id),o=r.type;return n.entry.push(yt(r,{id:o,delay:i})),n.exit.push(ft(o)),o};return Object.keys(t).flatMap(i=>{const r=t[i],o=typeof r=="string"?{target:r}:r,c=Number.isNaN(+i)?i:+i,u=e(c);return _(o).map(h=>({...h,event:u,delay:c}))}).map(i=>{const{delay:r}=i;return{...S(n,i.event,i),delay:r}})}function S(n,t,e){const s=Bt(e.target),i=e.reenter??!1,r=Me(n,s),o={...e,actions:_(e.actions),guard:e.guard,target:r,source:n,reenter:i,eventType:t,toJSON:()=>({...o,source:`#${n.id}`,target:r?r.map(c=>`#${c.id}`):void 0})};return o}function ke(n){const t=new Map;if(n.config.on)for(const e of Object.keys(n.config.on)){if(e===Mt)throw new Error('Null events ("") cannot be specified as a transition key. Use `always: { ... }` instead.');const s=n.config.on[e];t.set(e,O(s).map(i=>S(n,e,i)))}if(n.config.onDone){const e=`xstate.done.state.${n.id}`;t.set(e,O(n.config.onDone).map(s=>S(n,e,s)))}for(const e of n.invoke){if(e.onDone){const s=`xstate.done.actor.${e.id}`;t.set(s,O(e.onDone).map(i=>S(n,s,i)))}if(e.onError){const s=`xstate.error.actor.${e.id}`;t.set(s,O(e.onError).map(i=>S(n,s,i)))}if(e.onSnapshot){const s=`xstate.snapshot.${e.id}`;t.set(s,O(e.onSnapshot).map(i=>S(n,s,i)))}}for(const e of n.after){let s=t.get(e.eventType);s||(s=[],t.set(e.eventType,s)),s.push(e)}return t}function $e(n){const t=[],e=s=>{Object.values(s).forEach(i=>{if(i.config.route&&i.config.id){const r=i.config.id,o=i.config.route.guard,c=({event:h})=>h.to===`#${r}`,u={...i.config.route,guard:o?Ee([c,o]):c,target:`#${r}`};t.push(S(n,"xstate.route",u))}i.states&&e(i.states)})};e(n.states),t.length>0&&n.transitions.set("xstate.route",t)}function Oe(n,t){const e=typeof t=="string"?n.states[t]:t?n.states[t.target]:void 0;if(!e&&t)throw new Error(`Initial state node "${t}" not found on parent state node #${n.id}`);const s={source:n,actions:!t||typeof t=="string"?[]:_(t.actions),eventType:null,reenter:!1,target:e?[e]:[],toJSON:()=>({...s,source:`#${n.id}`,target:e?[`#${e.id}`]:[]})};return s}function Me(n,t){if(t!==void 0)return t.map(e=>{if(typeof e!="string")return e;if(W(e))return n.machine.getStateNodeById(e);const s=e[0]===Ot;if(s&&!n.parent)return H(n,e.slice(1));const i=s?n.key+e:e;if(n.parent)try{return H(n.parent,i)}catch(r){throw new Error(`Invalid transition definition for state node '${n.id}':
|
|
2
|
+
${r.message}`)}else throw new Error(`Invalid target: "${e}" is not a valid target from the root node. Did you mean ".${e}"?`)})}function Gt(n){const t=Bt(n.config.target);return t?{target:t.map(e=>typeof e=="string"?H(n.parent,e):e)}:n.parent.type==="parallel"?{target:[n.parent]}:n.parent.initial}function x(n){return n.type==="history"}function wt(n){const t=Ut(n);for(const e of t)for(const s of D(e,n))t.add(s);return t}function Ut(n){const t=new Set;function e(s){if(!t.has(s)){if(t.add(s),s.type==="compound")e(s.initial.target[0]);else if(s.type==="parallel")for(const i of R(s))e(i)}}return e(n),t}function j(n,t){if(W(t))return n.machine.getStateNodeById(t);if(!n.states)throw new Error(`Unable to retrieve child state '${t}' from '${n.id}'; no child states exist.`);const e=n.states[t];if(!e)throw new Error(`Child state '${t}' does not exist on '${n.id}'`);return e}function H(n,t){if(typeof t=="string"&&W(t))try{return n.machine.getStateNodeById(t)}catch{}const e=ct(t).slice();let s=n;for(;e.length;){const i=e.shift();if(!i.length)break;s=j(s,i)}return s}function Y(n,t){if(typeof t=="string"){const i=n.states[t];if(!i)throw new Error(`State '${t}' does not exist on '${n.id}'`);return[n,i]}const e=Object.keys(t),s=e.map(i=>j(n,i)).filter(Boolean);return[n.machine.root,n].concat(s,e.reduce((i,r)=>{const o=j(n,r);if(!o)return i;const c=Y(o,t[r]);return i.concat(c)},[]))}function Re(n,t,e,s){const r=j(n,t).next(e,s);return!r||!r.length?n.next(e,s):r}function je(n,t,e,s){const i=Object.keys(t),r=j(n,i[0]),o=lt(r,t[i[0]],e,s);return!o||!o.length?n.next(e,s):o}function Ce(n,t,e,s){const i=[];for(const r of Object.keys(t)){const o=t[r];if(!o)continue;const c=j(n,r),u=lt(c,o,e,s);u&&i.push(...u)}return i.length?i:n.next(e,s)}function lt(n,t,e,s){return typeof t=="string"?Re(n,t,e,s):Object.keys(t).length===1?je(n,t,e,s):Ce(n,t,e,s)}function De(n){return Object.keys(n.states).map(t=>n.states[t]).filter(t=>t.type==="history")}function b(n,t){let e=n;for(;e.parent&&e.parent!==t;)e=e.parent;return e.parent===t}function Le(n,t){const e=new Set(n),s=new Set(t);for(const i of e)if(s.has(i))return!0;for(const i of s)if(e.has(i))return!0;return!1}function Ht(n,t,e){const s=new Set;for(const i of n){let r=!1;const o=new Set;for(const c of s)if(Le(st([i],t,e),st([c],t,e)))if(b(i.source,c.source))o.add(c);else{r=!0;break}if(!r){for(const c of o)s.delete(c);s.add(i)}}return Array.from(s)}function Be(n){const[t,...e]=n;for(const s of D(t,void 0))if(e.every(i=>b(i,s)))return s}function pt(n,t){if(!n.target)return[];const e=new Set;for(const s of n.target)if(x(s))if(t[s.id])for(const i of t[s.id])e.add(i);else for(const i of pt(Gt(s),t))e.add(i);else e.add(s);return[...e]}function Yt(n,t){const e=pt(n,t);if(!e)return;if(!n.reenter&&e.every(i=>i===n.source||b(i,n.source)))return n.source;const s=Be(e.concat(n.source));if(s)return s;if(!n.reenter)return n.source.machine.root}function st(n,t,e){const s=new Set;for(const i of n)if(i.target?.length){const r=Yt(i,e);i.reenter&&i.source===r&&s.add(r);for(const o of t)b(o,r)&&s.add(o)}return[...s]}function Pe(n,t){if(n.length!==t.size)return!1;for(const e of n)if(!t.has(e))return!1;return!0}function Kt(n,t,e,s,i){return it([{target:[...Ut(n)],source:n,reenter:!0,actions:[],eventType:null,toJSON:null}],t,e,s,!0,i)}function it(n,t,e,s,i,r){const o=[];if(!n.length)return[t,o];const c=e.actionExecutor;e.actionExecutor=u=>{o.push(u),c(u)};try{const u=new Set(t._nodes);let h=t.historyValue;const p=Ht(n,u,h);let f=t;i||([f,h]=We(f,s,e,p,u,h,r,e.actionExecutor)),f=C(f,s,e,p.flatMap(d=>d.actions),r,void 0),f=ze(f,s,e,p,u,r,h,i);const a=[...u];f.status==="done"&&(f=C(f,s,e,a.sort((d,l)=>l.order-d.order).flatMap(d=>d.exit),r,void 0));try{return h===t.historyValue&&Pe(t._nodes,u)?[f,o]:[T(f,{_nodes:a,historyValue:h}),o]}catch(d){throw d}}finally{e.actionExecutor=c}}function Je(n,t,e,s,i){if(s.output===void 0)return;const r=et(i.id,i.output!==void 0&&i.parent?nt(i.output,n.context,t,e.self):void 0);return nt(s.output,n.context,r,e.self)}function ze(n,t,e,s,i,r,o,c){let u=n;const h=new Set,p=new Set;qe(s,o,p,h),c&&p.add(n.machine.root);const f=new Set;for(const a of[...h].sort((d,l)=>d.order-l.order)){i.add(a);const d=[];d.push(...a.entry);for(const l of a.invoke)d.push(dt(l.src,{...l,syncSnapshot:!!l.onSnapshot}));if(p.has(a)){const l=a.initial.actions;d.push(...l)}if(u=C(u,t,e,d,r,a.invoke.map(l=>l.id)),a.type==="final"){const l=a.parent;let y=l?.type==="parallel"?l:l?.parent,g=y||a;for(l?.type==="compound"&&r.push(et(l.id,a.output!==void 0?nt(a.output,u.context,t,e.self):void 0));y?.type==="parallel"&&!f.has(y)&&ht(i,y);)f.add(y),r.push(et(y.id)),g=y,y=y.parent;if(y)continue;u=T(u,{status:"done",output:Je(u,t,e,u.machine.root,g)})}}return u}function qe(n,t,e,s){for(const i of n){const r=Yt(i,t);for(const c of i.target||[])!x(c)&&(i.source!==c||i.source!==r||i.reenter)&&(s.add(c),e.add(c)),M(c,t,e,s);const o=pt(i,t);for(const c of o){const u=D(c,r);r?.type==="parallel"&&u.push(r),Zt(s,t,e,u,!i.source.parent&&i.reenter?void 0:r)}}}function M(n,t,e,s){if(x(n))if(t[n.id]){const i=t[n.id];for(const r of i)s.add(r),M(r,t,e,s);for(const r of i)N(r,n.parent,s,t,e)}else{const i=Gt(n);for(const r of i.target)s.add(r),i===n.parent?.initial&&e.add(n.parent),M(r,t,e,s);for(const r of i.target)N(r,n.parent,s,t,e)}else if(n.type==="compound"){const[i]=n.initial.target;x(i)||(s.add(i),e.add(i)),M(i,t,e,s),N(i,n,s,t,e)}else if(n.type==="parallel")for(const i of R(n).filter(r=>!x(r)))[...s].some(r=>b(r,i))||(x(i)||(s.add(i),e.add(i)),M(i,t,e,s))}function Zt(n,t,e,s,i){for(const r of s)if((!i||b(r,i))&&n.add(r),r.type==="parallel")for(const o of R(r).filter(c=>!x(c)))[...n].some(c=>b(c,o))||(n.add(o),M(o,t,e,n))}function N(n,t,e,s,i){Zt(e,s,i,D(n,t))}function We(n,t,e,s,i,r,o,c){let u=n;const h=st(s,i,r);h.sort((f,a)=>a.order-f.order);let p;for(const f of h)for(const a of De(f)){let d;a.history==="deep"?d=l=>q(l)&&b(l,f):d=l=>l.parent===f,p??={...r},p[a.id]=Array.from(i).filter(d)}for(const f of h)u=C(u,t,e,[...f.exit,...f.invoke.map(a=>z(a.id))],o,void 0),i.delete(f);return[u,p||r]}function Xe(n,t){return n.implementations.actions[t]}function Ft(n,t,e,s,i,r){const{machine:o}=n;let c=n;for(const u of s){const h=typeof u=="function",p=h?u:Xe(o,typeof u=="string"?u:u.type),f={context:c.context,event:t,self:e.self,system:e.system},a=h||typeof u=="string"?void 0:"params"in u?typeof u.params=="function"?u.params({context:c.context,event:t}):u.params:void 0;if(!p||!("resolve"in p)){e.actionExecutor({type:typeof u=="string"?u:typeof u=="object"?u.type:u.name||"(anonymous)",info:f,params:a,exec:p});continue}const d=p,[l,y,g]=d.resolve(e,c,f,a,p,i);c=l,"retryResolve"in d&&r?.push([d,y]),"execute"in d&&e.actionExecutor({type:d.type,info:f,params:y,exec:d.execute.bind(null,e,y)}),g&&(c=Ft(c,t,e,g,i,r))}return c}function C(n,t,e,s,i,r){const o=r?[]:void 0,c=Ft(n,t,e,s,{internalQueue:i,deferredActorIds:r},o);return o?.forEach(([u,h])=>{u.retryResolve(e,c,h)}),c}function J(n,t,e,s){let i=n;const r=[];function o(f,a,d){e.system._sendInspectionEvent({type:"@xstate.microstep",actorRef:e.self,event:a,snapshot:f[0],_transitions:d}),r.push(f)}if(t.type===w)return i=T(Et(i,t,e),{status:"stopped"}),o([i,[]],t,[]),{snapshot:i,microsteps:r};let c=t;if(c.type!==Rt){const f=c,a=de(f),d=Tt(f,i);if(a&&!d.length)return i=T(n,{status:"error",error:f.error}),o([i,[]],f,[]),{snapshot:i,microsteps:r};const l=it(d,n,e,c,!1,s);i=l[0],o(l,f,d)}let u=!0;const h=n.machine.options?.maxIterations??1/0;let p=0;for(;i.status==="active";){if(p++,p>h)throw new Error(`Infinite loop detected: the machine has processed more than ${h} microsteps without reaching a stable state. This usually happens when there's a cycle of transitions (e.g., eventless transitions or raised events causing state A -> B -> C -> A).`);let f=u?Ge(i,c):[];const a=f.length?i:void 0;if(!f.length){if(!s.length)break;c=s.shift(),f=Tt(c,i)}const d=it(f,i,e,c,!1,s);i=d[0],u=i!==a,o(d,c,f)}return i.status!=="active"&&Et(i,c,e),{snapshot:i,microsteps:r}}function Et(n,t,e){return C(n,t,e,Object.values(n.children).map(s=>z(s)),[],void 0)}function Tt(n,t){return t.machine.getTransitionData(t,n)}function Ge(n,t){const e=new Set,s=n._nodes.filter(q);for(const i of s)t:for(const r of[i].concat(D(i,void 0)))if(r.always){for(const o of r.always)if(o.guard===void 0||I(o.guard,n.context,t,n)){e.add(o);break t}}return Ht(Array.from(e),new Set(n._nodes),n.historyValue)}function Ue(n,t){const e=U(Y(n,t));return Xt(n,[...e])}function He(n){return!!n&&typeof n=="object"&&"machine"in n&&"value"in n}const Ye=function(t){return Ct(t,this.value)},Ke=function(t){return this.tags.has(t)},Ze=function(t){const e=this.machine.getTransitionData(this,t);return!!e?.length&&e.some(s=>s.target!==void 0||s.actions.length)},Fe=function(){const{_nodes:t,tags:e,machine:s,getMeta:i,toJSON:r,can:o,hasTag:c,matches:u,...h}=this;return{...h,tags:Array.from(e)}},Ve=function(){return this._nodes.reduce((t,e)=>(e.meta!==void 0&&(t[e.id]=e.meta),t),{})};function G(n,t){return{status:n.status,output:n.output,error:n.error,machine:t,context:n.context,_nodes:n._nodes,value:Xt(t.root,n._nodes),tags:new Set(n._nodes.flatMap(e=>e.tags)),children:n.children,historyValue:n.historyValue||{},matches:Ye,hasTag:Ke,can:Ze,getMeta:Ve,toJSON:Fe}}function T(n,t={}){return G({...n,...t},n.machine)}function Qe(n){if(typeof n!="object"||n===null)return{};const t={};for(const e in n){const s=n[e];Array.isArray(s)&&(t[e]=s.map(i=>({id:i.id})))}return t}function Ne(n,t){const{_nodes:e,tags:s,machine:i,children:r,context:o,can:c,hasTag:u,matches:h,getMeta:p,toJSON:f,...a}=n,d={};for(const y in r){const g=r[y];d[y]={snapshot:g.getPersistedSnapshot(t),src:g.src,systemId:g.systemId,syncSnapshot:g._syncSnapshot}}return{...a,context:Vt(o),children:d,historyValue:Qe(a.historyValue)}}function Vt(n){let t;for(const e in n){const s=n[e];if(s&&typeof s=="object")if("sessionId"in s&&"send"in s&&"ref"in s)t??=Array.isArray(n)?n.slice():{...n},t[e]={xstate$$type:ut,id:s.id};else{const i=Vt(s);i!==s&&(t??=Array.isArray(n)?n.slice():{...n},t[e]=i)}}return t??n}function tn(n,t,e,s,{event:i,id:r,delay:o},{internalQueue:c}){const u=t.machine.implementations.delays;if(typeof i=="string")throw new Error(`Only event objects may be used with raise; use raise({ type: "${i}" }) instead`);const h=typeof i=="function"?i(e,s):i;let p;if(typeof o=="string"){const f=u&&u[o];p=typeof f=="function"?f(e,s):f}else p=typeof o=="function"?o(e,s):o;return typeof p!="number"&&c.push(h),[t,{event:h,id:r,delay:p},void 0]}function en(n,t){const{event:e,delay:s,id:i}=t;if(typeof s=="number"){n.defer(()=>{const r=n.self;n.system.scheduler.schedule(r,r,e,s,i)});return}}function yt(n,t){function e(s,i){}return e.type="xstate.raise",e.event=n,e.id=t?.id,e.delay=t?.delay,e.resolve=tn,e.execute=en,e}function nn(n,t){return{config:n,transition:(e,s,i)=>({...e,context:n(e.context,s,i)}),getInitialSnapshot:(e,s)=>({status:"active",output:void 0,error:void 0,context:typeof t=="function"?t({input:s}):t}),getPersistedSnapshot:e=>e,restoreSnapshot:e=>e}}const tt=new WeakMap;function $n(n){return{config:n,start:(e,s)=>{const{self:i,system:r,emit:o}=s,c={receivers:void 0,dispose:void 0};tt.set(i,c),c.dispose=n({input:e.input,system:r,self:i,sendBack:u=>{i.getSnapshot().status!=="stopped"&&i._parent&&r._relay(i,i._parent,u)},receive:u=>{c.receivers??=new Set,c.receivers.add(u)},emit:o})},transition:(e,s,i)=>{const r=tt.get(i.self);return s.type===w?(e={...e,status:"stopped",error:void 0},tt.delete(i.self),r.receivers?.clear(),r.dispose?.(),e):(r.receivers?.forEach(o=>o(s)),e)},getInitialSnapshot:(e,s)=>({status:"active",output:void 0,error:void 0,input:s}),getPersistedSnapshot:e=>e,restoreSnapshot:e=>e}}const It="xstate.observable.next",K="xstate.observable.error",Z="xstate.observable.complete";function On(n){return{config:n,transition:(e,s)=>{if(e.status!=="active")return e;switch(s.type){case It:return{...e,context:s.data};case K:return{...e,status:"error",error:s.data,input:void 0,_subscription:void 0};case Z:return{...e,status:"done",input:void 0,_subscription:void 0};case w:return e._subscription.unsubscribe(),{...e,status:"stopped",input:void 0,_subscription:void 0};default:return e}},getInitialSnapshot:(e,s)=>({status:"active",output:void 0,error:void 0,context:void 0,input:s,_subscription:void 0}),start:(e,{self:s,system:i,emit:r})=>{e.status!=="done"&&(e._subscription=n({input:e.input,system:i,self:s,emit:r}).subscribe({next:o=>{i._relay(s,s,{type:It,data:o})},error:o=>{i._relay(s,s,{type:K,data:o})},complete:()=>{i._relay(s,s,{type:Z})}}))},getPersistedSnapshot:({_subscription:e,...s})=>s,restoreSnapshot:e=>({...e,_subscription:void 0})}}function Mn(n){return{config:n,transition:(e,s)=>{if(e.status!=="active")return e;switch(s.type){case K:return{...e,status:"error",error:s.data,input:void 0,_subscription:void 0};case Z:return{...e,status:"done",input:void 0,_subscription:void 0};case w:return e._subscription.unsubscribe(),{...e,status:"stopped",input:void 0,_subscription:void 0};default:return e}},getInitialSnapshot:(e,s)=>({status:"active",output:void 0,error:void 0,context:void 0,input:s,_subscription:void 0}),start:(e,{self:s,system:i,emit:r})=>{e.status!=="done"&&(e._subscription=n({input:e.input,system:i,self:s,emit:r}).subscribe({next:o=>{s._parent&&i._relay(s,s._parent,o)},error:o=>{i._relay(s,s,{type:K,data:o})},complete:()=>{i._relay(s,s,{type:Z})}}))},getPersistedSnapshot:({_subscription:e,...s})=>s,restoreSnapshot:e=>({...e,_subscription:void 0})}}const At="xstate.promise.resolve",kt="xstate.promise.reject",B=new WeakMap;function Rn(n){return{config:n,transition:(e,s,i)=>{if(e.status!=="active")return e;switch(s.type){case At:{const r=s.data;return{...e,status:"done",output:r,input:void 0}}case kt:return{...e,status:"error",error:s.data,input:void 0};case w:return B.get(i.self)?.abort(),B.delete(i.self),{...e,status:"stopped",input:void 0};default:return e}},start:(e,{self:s,system:i,emit:r})=>{if(e.status!=="active")return;const o=new AbortController;B.set(s,o),Promise.resolve(n({input:e.input,system:i,self:s,signal:o.signal,emit:r})).then(u=>{s.getSnapshot().status==="active"&&(B.delete(s),i._relay(s,s,{type:At,data:u}))},u=>{s.getSnapshot().status==="active"&&(B.delete(s),i._relay(s,s,{type:kt,data:u}))})},getInitialSnapshot:(e,s)=>({status:"active",output:void 0,error:void 0,input:s}),getPersistedSnapshot:e=>e,restoreSnapshot:e=>e}}const sn=nn(n=>{},void 0);function jn(){return E(sn)}function rn(n,{machine:t,context:e},s,i){const r=(o,c)=>{if(typeof o=="string"){const u=at(t,o);if(!u)throw new Error(`Actor logic '${o}' not implemented in machine '${t.id}'`);const h=E(u,{id:c?.id,parent:n.self,syncSnapshot:c?.syncSnapshot,input:typeof c?.input=="function"?c.input({context:e,event:s,self:n.self}):c?.input,src:o,systemId:c?.systemId});return i[h.id]=h,h}else return E(o,{id:c?.id,parent:n.self,syncSnapshot:c?.syncSnapshot,input:c?.input,src:o,systemId:c?.systemId})};return(o,c)=>{const u=r(o,c);return i[u.id]=u,n.defer(()=>{u._processingStatus!==m.Stopped&&u.start()}),u}}function on(n,t,e,s,{assignment:i}){if(!t.context)throw new Error("Cannot assign to undefined `context`. Ensure that `context` is defined in the machine config.");const r={},o={context:t.context,event:e.event,spawn:rn(n,t,e.event,r),self:n.self,system:n.system};let c={};if(typeof i=="function")c=i(o,s);else for(const h of Object.keys(i)){const p=i[h];c[h]=typeof p=="function"?p(o,s):p}const u=Object.assign({},t.context,c);return[T(t,{context:u,children:Object.keys(r).length?{...t.children,...r}:t.children}),void 0,void 0]}function gt(n){function t(e,s){}return t.type="xstate.assign",t.assignment=n,t.resolve=on,t}const $t=new WeakMap;function $(n,t,e){let s=$t.get(n);return s?t in s||(s[t]=e()):(s={[t]:e()},$t.set(n,s)),s[t]}const cn={},P=n=>typeof n=="string"?{type:n}:typeof n=="function"?"resolve"in n?{type:n.type}:{type:n.name}:n;class F{constructor(t,e){if(this.config=t,this.key=void 0,this.id=void 0,this.type=void 0,this.path=void 0,this.states=void 0,this.history=void 0,this.entry=void 0,this.exit=void 0,this.parent=void 0,this.machine=void 0,this.meta=void 0,this.output=void 0,this.order=-1,this.description=void 0,this.tags=[],this.transitions=void 0,this.always=void 0,this.parent=e._parent,this.key=e._key,this.machine=e._machine,this.path=this.parent?this.parent.path.concat(this.key):[],this.id=this.config.id||[this.machine.id,...this.path].join(Ot),this.type=this.config.type||(this.config.states&&Object.keys(this.config.states).length?"compound":this.config.history?"history":"atomic"),this.description=this.config.description,this.order=this.machine.idMap.size,this.machine.idMap.set(this.id,this),this.states=this.config.states?St(this.config.states,(s,i)=>new F(s,{_parent:this,_key:i,_machine:this.machine})):cn,this.type==="compound"&&!this.config.initial)throw new Error(`No initial state specified for compound state node "#${this.id}". Try adding { initial: "${Object.keys(this.states)[0]}" } to the state config.`);this.history=this.config.history===!0?"shallow":this.config.history||!1,this.entry=_(this.config.entry).slice(),this.exit=_(this.config.exit).slice(),this.meta=this.config.meta,this.output=this.type==="final"||!this.parent?this.config.output:void 0,this.tags=_(t.tags).slice()}_initialize(){this.transitions=ke(this),this.config.always&&(this.always=O(this.config.always).map(t=>S(this,Mt,t))),Object.keys(this.states).forEach(t=>{this.states[t]._initialize()})}get definition(){return{id:this.id,key:this.key,version:this.machine.version,type:this.type,initial:this.initial?{target:this.initial.target,source:this,actions:this.initial.actions.map(P),eventType:null,reenter:!1,toJSON:()=>({target:this.initial.target.map(t=>`#${t.id}`),source:`#${this.id}`,actions:this.initial.actions.map(P),eventType:null})}:void 0,history:this.history,states:St(this.states,t=>t.definition),on:this.on,transitions:[...this.transitions.values()].flat().map(t=>({...t,actions:t.actions.map(P)})),entry:this.entry.map(P),exit:this.exit.map(P),meta:this.meta,order:this.order||-1,output:this.output,invoke:this.invoke,description:this.description,tags:this.tags}}toJSON(){return this.definition}get invoke(){return $(this,"invoke",()=>_(this.config.invoke).map((t,e)=>{const{src:s,systemId:i}=t,r=t.id??bt(this.id,e),o=typeof s=="string"?s:`xstate.invoke.${bt(this.id,e)}`;return{...t,src:o,id:r,systemId:i,toJSON(){const{onDone:c,onError:u,...h}=t;return{...h,type:"xstate.invoke",src:o,id:r}}}}))}get on(){return $(this,"on",()=>[...this.transitions].flatMap(([e,s])=>s.map(i=>[e,i])).reduce((e,[s,i])=>(e[s]=e[s]||[],e[s].push(i),e),{}))}get after(){return $(this,"delayedTransitions",()=>Ae(this))}get initial(){return $(this,"initial",()=>Oe(this,this.config.initial))}next(t,e){const s=e.type,i=[];let r;const o=$(this,`candidates-${s}`,()=>Ie(this,s));for(const c of o){const{guard:u}=c,h=t.context;let p=!1;try{p=!u||I(u,h,e,t)}catch(f){const a=typeof u=="string"?u:typeof u=="object"?u.type:void 0;throw new Error(`Unable to evaluate guard ${a?`'${a}' `:""}in transition for event '${s}' in state node '${this.id}':
|
|
3
|
+
${f.message}`)}if(p){i.push(...c.actions),r=c;break}}return r?[r]:void 0}get events(){return $(this,"events",()=>{const{states:t}=this,e=new Set(this.ownEvents);if(t)for(const s of Object.keys(t)){const i=t[s];if(i.states)for(const r of i.events)e.add(`${r}`)}return Array.from(e)})}get ownEvents(){const t=Object.keys(Object.fromEntries(this.transitions)),e=new Set(t.filter(s=>this.transitions.get(s).some(i=>!(!i.target&&!i.actions.length&&!i.reenter))));return Array.from(e)}}const an="#";class mt{constructor(t,e){this.config=t,this.version=void 0,this.schemas=void 0,this.implementations=void 0,this.options=void 0,this.__xstatenode=!0,this.idMap=new Map,this.root=void 0,this.id=void 0,this.states=void 0,this.events=void 0,this.id=t.id||"(machine)",this.implementations={actors:e?.actors??{},actions:e?.actions??{},delays:e?.delays??{},guards:e?.guards??{}},this.version=this.config.version,this.schemas=this.config.schemas,this.options={maxIterations:1/0,...this.config.options},this.transition=this.transition.bind(this),this.getInitialSnapshot=this.getInitialSnapshot.bind(this),this.getPersistedSnapshot=this.getPersistedSnapshot.bind(this),this.restoreSnapshot=this.restoreSnapshot.bind(this),this.start=this.start.bind(this),this.root=new F(t,{_key:this.id,_machine:this}),this.root._initialize(),$e(this.root),this.states=this.root.states,this.events=this.root.events}provide(t){const{actions:e,guards:s,actors:i,delays:r}=this.implementations;return new mt(this.config,{actions:{...e,...t.actions},guards:{...s,...t.guards},actors:{...i,...t.actors},delays:{...r,...t.delays}})}resolveState(t){const e=Ue(this.root,t.value),s=U(Y(this.root,e));return G({_nodes:[...s],context:t.context||{},children:{},status:ht(s,this.root)?"done":t.status||"active",output:t.output,error:t.error,historyValue:t.historyValue},this)}transition(t,e,s){return J(t,e,s,[]).snapshot}microstep(t,e,s){return J(t,e,s,[]).microsteps.map(([i])=>i)}getTransitionData(t,e){return lt(this.root,t.value,t,e)||[]}_getPreInitialState(t,e,s){const{context:i}=this.config,r=G({context:typeof i!="function"&&i?i:{},_nodes:[this.root],children:{},status:"active"},this);return typeof i=="function"?C(r,e,t,[gt(({spawn:c,event:u,self:h})=>i({spawn:c,input:u.input,self:h}))],s,void 0):r}getInitialSnapshot(t,e){const s=ot(e),i=[],r=this._getPreInitialState(t,s,i),[o]=Kt(this.root,r,t,s,i),{snapshot:c}=J(o,s,t,i);return c}start(t){Object.values(t.children).forEach(e=>{e.getSnapshot().status==="active"&&e.start()})}getStateNodeById(t){const e=ct(t),s=e.slice(1),i=W(e[0])?e[0].slice(an.length):e[0],r=this.idMap.get(i);if(!r)throw new Error(`Child state node '#${i}' does not exist on machine '${this.id}'`);return H(r,s)}get definition(){return this.root.definition}toJSON(){return this.definition}getPersistedSnapshot(t,e){return Ne(t,e)}restoreSnapshot(t,e){const s={},i=t.children;Object.keys(i).forEach(f=>{const a=i[f],d=a.snapshot,l=a.src,y=typeof l=="string"?at(this,l):l;if(!y)return;const g=E(y,{id:f,parent:e.self,syncSnapshot:a.syncSnapshot,snapshot:d,src:l,systemId:a.systemId});s[f]=g});function r(f,a){if(a instanceof F)return a;try{return f.machine.getStateNodeById(a.id)}catch{}}function o(f,a){if(!a||typeof a!="object")return{};const d={};for(const l in a){const y=a[l];for(const g of y){const A=r(f,g);A&&(d[l]??=[],d[l].push(A))}}return d}const c=o(this.root,t.historyValue),u=G({...t,children:s,_nodes:Array.from(U(Y(this.root,t.value))),historyValue:c},this),h=new Set;function p(f,a){if(!h.has(f)){h.add(f);for(const d in f){const l=f[d];if(l&&typeof l=="object"){if("xstate$$type"in l&&l.xstate$$type===ut){f[d]=a[l.id];continue}p(l,a)}}}}return p(u.context,s),u}}function un(n,t,e,s,{event:i}){const r=typeof i=="function"?i(e,s):i;return[t,{event:r},void 0]}function fn(n,{event:t}){n.defer(()=>n.emit(t))}function Qt(n){function t(e,s){}return t.type="xstate.emit",t.event=n,t.resolve=un,t.execute=fn,t}let rt=(function(n){return n.Parent="#_parent",n.Internal="#_internal",n})({});function dn(n,t,e,s,{to:i,event:r,id:o,delay:c},u){const h=t.machine.implementations.delays;if(typeof r=="string")throw new Error(`Only event objects may be used with sendTo; use sendTo({ type: "${r}" }) instead`);const p=typeof r=="function"?r(e,s):r;let f;if(typeof c=="string"){const l=h&&h[c];f=typeof l=="function"?l(e,s):l}else f=typeof c=="function"?c(e,s):c;const a=typeof i=="function"?i(e,s):i;let d;if(typeof a=="string"){if(a===rt.Parent?d=n.self._parent:a===rt.Internal?d=n.self:a.startsWith("#_")?d=t.children[a.slice(2)]:d=u.deferredActorIds?.includes(a)?a:t.children[a],!d)throw new Error(`Unable to send event to actor '${a}' from machine '${t.machine.id}'.`)}else d=a||n.self;return[t,{to:d,targetId:typeof a=="string"?a:void 0,event:p,id:o,delay:f},void 0]}function hn(n,t,e){typeof e.to=="string"&&(e.to=t.children[e.to])}function ln(n,t){n.defer(()=>{const{to:e,event:s,delay:i,id:r}=t;if(typeof i=="number"){n.system.scheduler.schedule(n.self,e,s,i,r);return}n.system._relay(n.self,e,s.type===oe?jt(n.self.id,s.data):s)})}function V(n,t,e){function s(i,r){}return s.type="xstate.sendTo",s.to=n,s.event=t,s.id=e?.id,s.delay=e?.delay,s.resolve=dn,s.retryResolve=hn,s.execute=ln,s}function pn(n,t){return V(rt.Parent,n,t)}function Cn(n,t){return V(n,({event:e})=>e,t)}function yn(n,t,e,s,{collect:i}){const r=[],o=function(u){r.push(u)};return o.assign=(...c)=>{r.push(gt(...c))},o.cancel=(...c)=>{r.push(ft(...c))},o.raise=(...c)=>{r.push(yt(...c))},o.sendTo=(...c)=>{r.push(V(...c))},o.sendParent=(...c)=>{r.push(pn(...c))},o.spawnChild=(...c)=>{r.push(dt(...c))},o.stopChild=(...c)=>{r.push(z(...c))},o.emit=(...c)=>{r.push(Qt(...c))},i({context:e.context,event:e.event,enqueue:o,check:c=>I(c,t.context,e.event,t),self:n.self,system:n.system},s),[t,void 0,r]}function gn(n){function t(e,s){}return t.type="xstate.enqueueActions",t.collect=n,t.resolve=yn,t}function mn(n,t,e,s,{value:i,label:r}){return[t,{value:typeof i=="function"?i(e,s):i,label:r},void 0]}function vn({logger:n},{value:t,label:e}){e?n(e,t):n(t)}function _n(n=({context:e,event:s})=>({context:e,event:s}),t){function e(s,i){}return e.type="xstate.log",e.value=n,e.label=t,e.resolve=mn,e.execute=vn,e}function Dn(n,t){const e=_(t);if(!e.some(i=>Pt(n.type,i))){const i=e.length===1?`type matching "${e[0]}"`:`one of types matching "${e.join('", "')}"`;throw new Error(`Expected event ${JSON.stringify(n)} to have ${i}`)}}function Sn(n,t){return new mt(n,t)}function Ln(n,t){const e=[],s=(r,o)=>{let c=r;for(const u of o){if(!c?.states)return;const h=c.states;if(!(u in h))return;c=h[u]}return c},i=new Set;for(const r of n._nodes.filter(q)){let o=r;for(;o&&!i.has(o);){i.add(o);const c=s(t,o.path);c?.map&&e.push({stateNode:o,result:c.map(n)}),o=o.parent}}return e}function L(n){const t=E(n),e=Jt(t,{clock:t.system._clock,logger:t.system._logger});return t.system=e,{self:t,defer:()=>{},id:"",logger:()=>{},sessionId:"",stopChild:()=>{},system:e,emit:()=>{},actionExecutor:()=>{}}}function Bn(n,...[t]){const e=L(n);return n.getInitialSnapshot(e,t)}function Pn(n,t,e){const s=L(n);return s.self._snapshot=t,n.transition(t,e,s)}function bn({schemas:n,actors:t,actions:e,guards:s,delays:i}){return{assign:gt,sendTo:V,raise:yt,log:_n,cancel:ft,stopChild:z,enqueueActions:gn,emit:Qt,spawnChild:dt,createStateConfig:r=>r,createAction:r=>r,createMachine:r=>Sn({...r,schemas:n},{actors:t,actions:e,guards:s,delays:i}),extend:r=>bn({schemas:n,actors:t,actions:{...e,...r.actions},guards:{...s,...r.guards},delays:{...i,...r.delays}})}}class Jn{constructor(){this.timeouts=new Map,this._now=0,this._id=0,this._flushing=!1,this._flushingInvalidated=!1}now(){return this._now}getId(){return this._id++}setTimeout(t,e){this._flushingInvalidated=this._flushing;const s=this.getId();return this.timeouts.set(s,{start:this.now(),timeout:e,fn:t}),s}clearTimeout(t){this._flushingInvalidated=this._flushing,this.timeouts.delete(t)}set(t){if(this._now>t)throw new Error("Unable to travel back in time");this._now=t,this.flushTimeouts()}flushTimeouts(){if(this._flushing){this._flushingInvalidated=!0;return}this._flushing=!0;const t=[...this.timeouts].sort(([e,s],[i,r])=>{const o=s.start+s.timeout;return r.start+r.timeout>o?-1:1});for(const[e,s]of t){if(this._flushingInvalidated){this._flushingInvalidated=!1,this._flushing=!1,this.flushTimeouts();return}this.now()-s.start>=s.timeout&&(this.timeouts.delete(e),s.fn.call(null))}this._flushing=!1}increment(t){this._now+=t,this.flushTimeouts()}}function zn(n){return new Promise((t,e)=>{n.subscribe({complete:()=>{t(n.getSnapshot().output)},error:e})})}function qn(n,t,e){const s=[],i=L(n);return i.actionExecutor=o=>{s.push(o)},[n.transition(t,e,i),s]}function Wn(n,...[t]){const e=[],s=L(n);return s.actionExecutor=r=>{e.push(r)},[n.getInitialSnapshot(s,t),e]}function Xn(n,t,e){const s=L(n),{microsteps:i}=J(t,e,s,[]);return i}function Gn(n,...[t]){const e=L(n),s=ot(t),i=[],r=n._getPreInitialState(e,s,i),o=Kt(n.root,r,e,s,i),{microsteps:c}=J(o[0],s,e,i);return[o,...c]}function Un(n){const t=[],e=n._nodes.filter(q),s=new Set;for(const i of e)for(const r of[i].concat(D(i,void 0)))if(!s.has(r.id)){s.add(r.id);for(const[,o]of r.transitions)t.push(...o);r.always&&t.push(...r.always)}return t}const xn={timeout:1/0};function Hn(n,t,e){const s={...xn,...e};return new Promise((i,r)=>{const{signal:o}=s;if(o?.aborted){r(o.reason);return}let c=!1;const u=s.timeout===1/0?void 0:setTimeout(()=>{h(),r(new Error(`Timeout of ${s.timeout} ms exceeded`))},s.timeout),h=()=>{clearTimeout(u),c=!0,a?.unsubscribe(),f&&o.removeEventListener("abort",f)};function p(d){t(d)&&(h(),i(d))}let f,a;p(n.getSnapshot()),!c&&(o&&(f=()=>{h(),r(o.reason)},o.addEventListener("abort",f)),a=n.subscribe({next:p,error:d=>{h(),r(d)},complete:()=>{h(),r(new Error("Actor terminated without satisfying predicate"))}}),c&&a.unsubscribe())})}export{pe as Actor,Jn as SimulatedClock,rt as SpecialTargets,mt as StateMachine,F as StateNode,wn as __unsafe_getAllOwnEventDescriptors,Ee as and,Dn as assertEvent,gt as assign,ft as cancel,E as createActor,jn as createEmptyActor,Sn as createMachine,Qt as emit,gn as enqueueActions,Cn as forwardTo,$n as fromCallback,Mn as fromEventObservable,On as fromObservable,Rn as fromPromise,nn as fromTransition,Gn as getInitialMicrosteps,Bn as getInitialSnapshot,Xn as getMicrosteps,Pn as getNextSnapshot,Un as getNextTransitions,Y as getStateNodes,Wn as initialTransition,En as interpret,He as isMachineSnapshot,_n as log,Ln as mapState,Ct as matchesState,An as not,kn as or,fe as pathToStateValue,yt as raise,pn as sendParent,V as sendTo,bn as setup,dt as spawnChild,In as stateIn,Tn as stop,z as stopChild,X as toObserver,zn as toPromise,qn as transition,Hn as waitFor};
|
package/dist/index.html
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<!-- The single editor entry, served at `/` in every mode (dev server, prod
|
|
7
|
+
server, and the browser-first static build `npm run build:web`). Static
|
|
8
|
+
hosts (e.g. GitHub Pages) serve the editor as index.html. -->
|
|
9
|
+
<!-- Inline favicon: avoids a /favicon.ico 404 on every editor load. -->
|
|
10
|
+
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><rect width='16' height='16' rx='3' fill='%23579EFF'/></svg>" />
|
|
11
|
+
<title>VGAI Scene Editor</title>
|
|
12
|
+
<style>
|
|
13
|
+
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
14
|
+
html, body { width: 100%; height: 100%; overflow: hidden; background: #1a1a1a; display: flex; flex-direction: column; }
|
|
15
|
+
#editor-main { flex: 1; position: relative; min-height: 0; overflow: hidden; }
|
|
16
|
+
#editor-root {
|
|
17
|
+
position: absolute; top: 0; left: 0; width: 100%; height: 100%;
|
|
18
|
+
pointer-events: none; z-index: 10;
|
|
19
|
+
}
|
|
20
|
+
#editor-bottom {
|
|
21
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
22
|
+
font-size: 13px;
|
|
23
|
+
color: #c5c8ce;
|
|
24
|
+
}
|
|
25
|
+
*::-webkit-scrollbar { display: none; }
|
|
26
|
+
* { scrollbar-width: none; }
|
|
27
|
+
@keyframes editor-spin { to { transform: rotate(360deg); } }
|
|
28
|
+
</style>
|
|
29
|
+
<script type="module" crossorigin src="/assets/index-_bCaipUk.js"></script>
|
|
30
|
+
</head>
|
|
31
|
+
<body>
|
|
32
|
+
<div id="editor-main">
|
|
33
|
+
<div id="editor-root"></div>
|
|
34
|
+
</div>
|
|
35
|
+
<div id="editor-bottom"></div>
|
|
36
|
+
</body>
|
|
37
|
+
</html>
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# pmndrs/racing-game — vendored bundle (marquee ingest proof)
|
|
2
|
+
|
|
3
|
+
A REAL, UNMODIFIED marquee game ingested through the VGAI adapter primitives, at the
|
|
4
|
+
**zero-source-diff** bar.
|
|
5
|
+
|
|
6
|
+
## Upstream
|
|
7
|
+
|
|
8
|
+
- Repo: https://github.com/pmndrs/racing-game
|
|
9
|
+
- Commit: **`7816a5d954b75e6ad853ae4e4f0cbbd628072643`** (2023-02-23)
|
|
10
|
+
- Stack: React 18 + `@react-three/fiber` 8 + `@react-three/drei` 9 + `@react-three/cannon` + **three r0.139** + Vite 2
|
|
11
|
+
- License: **MIT** (Copyright (c) 2021 Poimandres) — see the upstream `LICENSE`.
|
|
12
|
+
|
|
13
|
+
## Zero source diff (the bar)
|
|
14
|
+
|
|
15
|
+
The game's `src/` and `public/` are **byte-for-byte upstream** — `git diff 7816a5d -- src public`
|
|
16
|
+
is empty; e.g. `git hash-object src/App.tsx` == the upstream blob hash. NO game file was edited.
|
|
17
|
+
The only out-of-tree additions are a host-supplied build config (`vite.ingest.config.ts`) and this
|
|
18
|
+
manifest — neither touches the game's source.
|
|
19
|
+
|
|
20
|
+
## Build (host-supplied — no game edits)
|
|
21
|
+
|
|
22
|
+
Built by the game's OWN Vite toolchain with one externalization passed from outside:
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
external: (id) => id === 'three' // do not bundle three
|
|
26
|
+
output.paths: { three: '/ingest/racing-game/three-r139.module.js' } // resolve it to the served r139 module
|
|
27
|
+
base: '/ingest/racing-game/'
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
So the built bundle's `import … from "three"` becomes
|
|
31
|
+
`import … from "/ingest/racing-game/three-r139.module.js"` — it self-resolves three to the
|
|
32
|
+
vendored r139 module, with no importmap.
|
|
33
|
+
|
|
34
|
+
## Vendored files
|
|
35
|
+
|
|
36
|
+
| File | What |
|
|
37
|
+
|---|---|
|
|
38
|
+
| `rg-entry.js`, `vendor.js` | the built bundle (artifacts of the unmodified source) |
|
|
39
|
+
| `three-r139.module.js` | the game's OWN three (r0.139) — its native renderer |
|
|
40
|
+
| `models/`, `textures/`, `sounds/`, `images/` | upstream assets, verbatim |
|
|
41
|
+
|
|
42
|
+
## How it is hosted (through the adapter)
|
|
43
|
+
|
|
44
|
+
`/marquee-proof.html` + `/marquee-proof.ts` (served by the editor's own Vite):
|
|
45
|
+
|
|
46
|
+
1. import the served r139 module into the page realm,
|
|
47
|
+
2. install the **engine `installSceneCapture`** render-accessor trap on it,
|
|
48
|
+
3. run the unmodified bundle (it self-resolves three to the same r139 module → **single realm**,
|
|
49
|
+
same instance → the trap sees its renderer),
|
|
50
|
+
4. wait for the scene to settle, then author the live `Object3D` tree through the **editor
|
|
51
|
+
`IngestAuthoringAdapter`** (both are type-only over three → version-agnostic),
|
|
52
|
+
5. recolor + move a live mesh through the adapter; the live object mutates.
|
|
53
|
+
|
|
54
|
+
Proven by `packages/editor/e2e/tests/14-ingest-marquee-bundled.spec.ts`
|
|
55
|
+
(rev 139, ~71 meshes captured, live recolor + move, recorded screenshot, zero errors).
|
|
56
|
+
|
|
57
|
+
### Why single-realm (not the editor's r170 three / not an iframe)
|
|
58
|
+
|
|
59
|
+
A 31-version gap (game r139 vs editor r170) is too large to collapse onto the host:
|
|
60
|
+
1. **missing exports** — r152+ removed `sRGBEncoding`/`LinearEncoding` (fixable with aliases);
|
|
61
|
+
2. **renderer format** — r139 geometry buffers are rejected by an r170 `WebGLRenderer`
|
|
62
|
+
(`Unsupported buffer data format`) — needs the matched r139 renderer;
|
|
63
|
+
3. **cross-realm** — running the game in an iframe makes its `Float32Array`s fail `instanceof`
|
|
64
|
+
in a parent-realm three.
|
|
65
|
+
|
|
66
|
+
Running single-realm on the game's OWN three sidesteps all three — the honest host for a
|
|
67
|
+
far-version bundle. (Version-compatible bundles can instead collapse onto the host three via the
|
|
68
|
+
iframe-reachable path; see `ingest-iframe-reachable-adapter.ts`.)
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@font-face{font-family:Inter;font-style:normal;font-weight:100;font-display:swap;src:url(/ingest/racing-game/a/Inter-Thin.woff2?v=3.19) format("woff2"),url(/ingest/racing-game/a/Inter-Thin.woff?v=3.19) format("woff")}@font-face{font-family:Inter;font-style:italic;font-weight:100;font-display:swap;src:url(/ingest/racing-game/a/Inter-ThinItalic.woff2?v=3.19) format("woff2"),url(/ingest/racing-game/a/Inter-ThinItalic.woff?v=3.19) format("woff")}@font-face{font-family:Inter;font-style:normal;font-weight:200;font-display:swap;src:url(/ingest/racing-game/a/Inter-ExtraLight.woff2?v=3.19) format("woff2"),url(/ingest/racing-game/a/Inter-ExtraLight.woff?v=3.19) format("woff")}@font-face{font-family:Inter;font-style:italic;font-weight:200;font-display:swap;src:url(/ingest/racing-game/a/Inter-ExtraLightItalic.woff2?v=3.19) format("woff2"),url(/ingest/racing-game/a/Inter-ExtraLightItalic.woff?v=3.19) format("woff")}@font-face{font-family:Inter;font-style:normal;font-weight:300;font-display:swap;src:url(/ingest/racing-game/a/Inter-Light.woff2?v=3.19) format("woff2"),url(/ingest/racing-game/a/Inter-Light.woff?v=3.19) format("woff")}@font-face{font-family:Inter;font-style:italic;font-weight:300;font-display:swap;src:url(/ingest/racing-game/a/Inter-LightItalic.woff2?v=3.19) format("woff2"),url(/ingest/racing-game/a/Inter-LightItalic.woff?v=3.19) format("woff")}@font-face{font-family:Inter;font-style:normal;font-weight:400;font-display:swap;src:url(/ingest/racing-game/a/Inter-Regular.woff2?v=3.19) format("woff2"),url(/ingest/racing-game/a/Inter-Regular.woff?v=3.19) format("woff")}@font-face{font-family:Inter;font-style:italic;font-weight:400;font-display:swap;src:url(/ingest/racing-game/a/Inter-Italic.woff2?v=3.19) format("woff2"),url(/ingest/racing-game/a/Inter-Italic.woff?v=3.19) format("woff")}@font-face{font-family:Inter;font-style:normal;font-weight:500;font-display:swap;src:url(/ingest/racing-game/a/Inter-Medium.woff2?v=3.19) format("woff2"),url(/ingest/racing-game/a/Inter-Medium.woff?v=3.19) format("woff")}@font-face{font-family:Inter;font-style:italic;font-weight:500;font-display:swap;src:url(/ingest/racing-game/a/Inter-MediumItalic.woff2?v=3.19) format("woff2"),url(/ingest/racing-game/a/Inter-MediumItalic.woff?v=3.19) format("woff")}@font-face{font-family:Inter;font-style:normal;font-weight:600;font-display:swap;src:url(/ingest/racing-game/a/Inter-SemiBold.woff2?v=3.19) format("woff2"),url(/ingest/racing-game/a/Inter-SemiBold.woff?v=3.19) format("woff")}@font-face{font-family:Inter;font-style:italic;font-weight:600;font-display:swap;src:url(/ingest/racing-game/a/Inter-SemiBoldItalic.woff2?v=3.19) format("woff2"),url(/ingest/racing-game/a/Inter-SemiBoldItalic.woff?v=3.19) format("woff")}@font-face{font-family:Inter;font-style:normal;font-weight:700;font-display:swap;src:url(/ingest/racing-game/a/Inter-Bold.woff2?v=3.19) format("woff2"),url(/ingest/racing-game/a/Inter-Bold.woff?v=3.19) format("woff")}@font-face{font-family:Inter;font-style:italic;font-weight:700;font-display:swap;src:url(/ingest/racing-game/a/Inter-BoldItalic.woff2?v=3.19) format("woff2"),url(/ingest/racing-game/a/Inter-BoldItalic.woff?v=3.19) format("woff")}@font-face{font-family:Inter;font-style:normal;font-weight:800;font-display:swap;src:url(/ingest/racing-game/a/Inter-ExtraBold.woff2?v=3.19) format("woff2"),url(/ingest/racing-game/a/Inter-ExtraBold.woff?v=3.19) format("woff")}@font-face{font-family:Inter;font-style:italic;font-weight:800;font-display:swap;src:url(/ingest/racing-game/a/Inter-ExtraBoldItalic.woff2?v=3.19) format("woff2"),url(/ingest/racing-game/a/Inter-ExtraBoldItalic.woff?v=3.19) format("woff")}@font-face{font-family:Inter;font-style:normal;font-weight:900;font-display:swap;src:url(/ingest/racing-game/a/Inter-Black.woff2?v=3.19) format("woff2"),url(/ingest/racing-game/a/Inter-Black.woff?v=3.19) format("woff")}@font-face{font-family:Inter;font-style:italic;font-weight:900;font-display:swap;src:url(/ingest/racing-game/a/Inter-BlackItalic.woff2?v=3.19) format("woff2"),url(/ingest/racing-game/a/Inter-BlackItalic.woff?v=3.19) format("woff")}@font-face{font-family:Inter var;font-weight:100 900;font-style:normal;font-named-instance:"Regular";font-display:swap;src:url(/ingest/racing-game/a/Inter-roman.var.woff2?v=3.19) format("woff2 supports variations(gvar)"),url(/ingest/racing-game/a/Inter-roman.var.woff2?v=3.19) format("woff2-variations"),url(/ingest/racing-game/a/Inter-roman.var.woff2?v=3.19) format("woff2")}@font-face{font-family:Inter var;font-weight:100 900;font-style:italic;font-named-instance:"Italic";font-display:swap;src:url(/ingest/racing-game/a/Inter-italic.var.woff2?v=3.19) format("woff2 supports variations(gvar)"),url(/ingest/racing-game/a/Inter-italic.var.woff2?v=3.19) format("woff2-variations"),url(/ingest/racing-game/a/Inter-italic.var.woff2?v=3.19) format("woff2")}@font-face{font-family:Inter var experimental;font-weight:100 900;font-style:oblique 0deg 10deg;font-display:swap;src:url(/ingest/racing-game/a/Inter.var.woff2?v=3.19) format("woff2-variations"),url(/ingest/racing-game/a/Inter.var.woff2?v=3.19) format("woff2")}*{box-sizing:border-box}html,body,#root{width:100vw;height:100vh;margin:0;padding:0;overflow:hidden}body{background:#101010;color:#fff;font-family:Inter var,sans-serif}.clock{position:absolute;top:60px;left:60px;font-weight:200;font-size:5em;font-variant-numeric:tabular-nums;letter-spacing:-5px}.checkpoint{position:absolute;top:28%;left:50%;font-weight:500;font-size:1em;font-variant-numeric:tabular-nums;width:200px;transform:translate(-50%,-50%);text-align:center}.checkpoint .green{color:green}.checkpoint .red{color:red}.auth-providers{display:flex;flex-direction:column;justify-content:center;align-items:center}.auth-provider{font-size:.7em;border:1px solid transparent;border-bottom:3px solid #a0a0a0;border-radius:3px;padding:8px 12px;background:white;color:#000;display:flex;align-items:center;justify-content:center;margin-bottom:10px;width:200px;height:45px}.auth-provider:hover{border-bottom:1px solid #a0a0a0}.auth-provider svg{width:24px;margin-right:10px}.auth-header{color:#b0b0b0;font-weight:600;font-size:1.1em;text-align:center}.finished{align-items:center;display:flex;flex-direction:column;height:100%;text-align:center;background:#101010;bottom:0;position:absolute;width:100vw;z-index:10}.finished-header{max-height:120px}.finished-leaderboard{flex:1;overflow-y:scroll}.finished-auth{height:auto}.finished-restart{align-items:center;display:flex;height:60px}.leaderboard-name img{position:relative;right:2px;margin-right:2px}.leaderboard-bottom li{margin-bottom:10px;text-align:center;counter-increment:listCounter}.leaderboard b{margin-right:5px}.leaderboard li{margin-bottom:10px;text-align:center;counter-increment:listCounter;justify-content:space-between}.leaderboard-bottom{list-style:none;padding:0;margin-top:20px;counter-reset:listCounter;max-height:auto;overflow:auto}.pickcolor-container{margin-top:16px;width:346px}.speed{position:absolute;bottom:60px;right:60px;font-size:2.5em;font-weight:200;font-variant-numeric:tabular-nums;letter-spacing:-2px}.speed span{font-weight:600;font-size:1.5em;letter-spacing:-5px}.speed-gauge{position:relative;width:200px}.speed-foreground,.speed-background{position:absolute;width:100%}.speed-text{margin-top:-40px}.boost-bar{position:relative;top:15px}.boost-bg-path{stroke:#132237;stroke-width:13px;stroke-dasharray:295px}.boost-path{stroke-width:9px;stroke-dasharray:100%}.boost-path.blink{animation:boostBlink .5s infinite}@keyframes boostBlink{to,0%{stroke:#500}60%{stroke:red}}.boost-text{stroke:#fff;fill:#fff;font-size:13px;letter-spacing:.1px;font-weight:700}.help{position:absolute;top:60px;right:60px}.popup{position:fixed;right:0;top:0;display:flex;align-items:center;justify-content:center;opacity:0;transition:all .3s ease-in-out;transform:translateY(-100%)}.popup.open{opacity:1;transform:translateY(0)}.popup-close{position:absolute;top:0;right:0}.popup-content{display:flex;flex-direction:column;align-items:center;padding:3em;background:rgba(0,0,0,.8)}.popup-item{display:flex;justify-content:space-between;width:274px;height:25px;padding-right:24px;margin:0}.popup-item:hover{padding-right:0}.keys-row:hover .add-button{display:flex}.keys-row .add-button{display:none}.with-error{color:#700707}.popup-item-keys{display:flex;align-items:center;justify-content:center}.popup-item-key{position:relative;min-height:auto;font-size:.7em;min-width:24px;border:1px solid transparent;border-bottom:3px solid #a0a0a0;border-radius:3px;padding:2px 5px;margin:2px;background:white;color:#000;display:flex;align-items:center;justify-content:center}.key-button:hover:before{width:100%;content:"-";position:absolute;background-color:#fff}.hovered-item{cursor:pointer;background:transparent;color:#999;border:1px dashed #999}button{min-width:32px;min-height:32px;color:inherit;border:none;font:inherit;cursor:pointer;outline:inherit;background:white;color:#000}.fullscreen{position:absolute;top:0;left:0;width:100%;height:100%;display:flex;flex-direction:column;justify-content:center;align-items:center;transition:all 1s;z-index:9999}.stack{width:100%;display:flex;justify-content:space-around;align-items:center;color:#606060}.bg{background:#101010}.fullscreen .logout{background:transparent;border:none;width:auto;color:#fff;display:block;margin:10px auto}.fullscreen .start-link{text-decoration:none;transition:all 1s;width:20%;text-align:center}.fullscreen.loading .start-link{cursor:auto;color:#606060}.fullscreen.loaded .start-link{cursor:pointer;color:#fff}.fullscreen.clicked{pointer-events:none;opacity:0}.pmndrs-menu{position:absolute;top:0;left:0;width:100%;height:100%;display:flex;color:gray;padding:40px;pointer-events:none;justify-content:center;align-items:flex-end;flex-direction:row;font-size:10px;line-height:1.5em}.pmndrs-menu.left{justify-content:flex-start}.pmndrs-menu.right{justify-content:flex-end}.pmndrs-menu>div{word-wrap:none;word-break:none;white-space:pre;padding-left:25px;padding-right:25px;display:flex;justify-content:flex-start;align-items:flex-start;flex-direction:column}.pmndrs-menu>div b{font-weight:600;color:#b0b0b0}.pmndrs-menu a{pointer-events:all;cursor:pointer;color:inherit;text-decoration:none}.pmndrs-menu a:hover{text-decoration:underline;color:inherit}.nosound{position:absolute;top:20px;right:20px;height:24px;width:24px;background:url(./textures/no_sound.png) no-repeat;background-size:24px 24px;opacity:1;animation:hideSoundIcon 3s forwards}.key-input-wrapper{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);background-color:#101010;border:1px solid #a0a0a0}.key-input{width:300px;height:100px;display:flex;justify-content:center;align-items:center}@keyframes hideSoundIcon{0%{opacity:1}to{opacity:0}}@-webkit-keyframes hideSoundIcon{0%{opacity:1}to{opacity:0}}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>@pmndrs/racing-game</title>
|
|
7
|
+
<script type="module" crossorigin src="/ingest/racing-game/rg-entry.js"></script>
|
|
8
|
+
<link rel="modulepreload" href="/ingest/racing-game/vendor.js">
|
|
9
|
+
<link rel="stylesheet" href="/ingest/racing-game/a/index.css">
|
|
10
|
+
</head>
|
|
11
|
+
<body>
|
|
12
|
+
<div id="root"></div>
|
|
13
|
+
|
|
14
|
+
</body>
|
|
15
|
+
</html>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var yt=Object.defineProperty,vt=Object.defineProperties;var xt=Object.getOwnPropertyDescriptors;var oe=Object.getOwnPropertySymbols;var Fe=Object.prototype.hasOwnProperty,ze=Object.prototype.propertyIsEnumerable;var De=(t,e,n)=>e in t?yt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,d=(t,e)=>{for(var n in e||(e={}))Fe.call(e,n)&&De(t,n,e[n]);if(oe)for(var n of oe(e))ze.call(e,n)&&De(t,n,e[n]);return t},f=(t,e)=>vt(t,xt(e));var O=(t,e)=>{var n={};for(var o in t)Fe.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(t!=null&&oe)for(var o of oe(t))e.indexOf(o)<0&&ze.call(t,o)&&(n[o]=t[o]);return n};import{c as bt,s as wt,r as c,d as Xe,u as F,j as r,P as W,O as le,a as p,F as _,b as Qe,e as ce,f as kt,g as Ct,h as j,M as St,i as me,k as Mt,l as It,m as Pt,n as ue,o as Et,p as q,q as Rt,t as he,v as Nt,w as ne,x as Bt,y as Lt,z as Tt,A as At,B as _t,J as Dt,C as Ft,D as zt,S as Ot,E as Vt,G as $t,H as Wt,I as Ht,K as Ut}from"./vendor.js";import{MathUtils as V,Vector3 as D,Matrix4 as Re,Object3D as Ne,Quaternion as Gt,Euler as jt,DoubleSide as Yt,Color as qt,Vector2 as Kt,Scene as Jt,Box3 as Xt,Layers as Qt}from"/ingest/racing-game/three-r139.module.js";const Zt=function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))o(s);new MutationObserver(s=>{for(const a of s)if(a.type==="childList")for(const i of a.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&o(i)}).observe(document,{childList:!0,subtree:!0});function n(s){const a={};return s.integrity&&(a.integrity=s.integrity),s.referrerpolicy&&(a.referrerPolicy=s.referrerpolicy),s.crossorigin==="use-credentials"?a.credentials="include":s.crossorigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function o(s){if(s.ep)return;s.ep=!0;const a=n(s);fetch(s.href,a)}};Zt();const ee=t=>Object.keys(t),Ze=[0,.5,0],se=["DEFAULT","FIRST_PERSON","BIRD_EYE"],et=1.5,de=1,Be=100,tt=[-110,.75,220],rt=[0,Math.PI/2+.35,0],Le={width:1.7,height:-.3,front:1.35,back:-1.3,steer:.3,force:1800,maxBrake:65,maxSpeed:88},Te={axleLocal:[-1,0,0],customSlidingRotationalSpeed:-.01,directionLocal:[0,-1,0],frictionSlip:1.5,radius:.38,rollInfluence:0,sideAcceleration:3,suspensionRestLength:.35,suspensionStiffness:30,useCustomSlidingRotationalSpeed:!0},Se={binding:!1,debug:!1,editor:!1,help:!1,leaderboard:!1,map:!0,pickcolor:!1,ready:!1,shadows:!0,stats:!1,sound:!0},ot=["help","leaderboard","pickcolor"],er=t=>ot.includes(t),Me={backward:!1,boost:!1,brake:!1,forward:!1,honk:!1,left:!1,right:!1},tr=t=>Object.hasOwnProperty.call(Me,t),rr={backward:["arrowdown","s"],boost:["shift"],brake:[" "],camera:["c"],editor:["."],forward:["arrowup","w","z"],help:["i"],honk:["h"],leaderboard:["l"],left:["arrowleft","a","q"],map:["m"],pickcolor:["p"],reset:["r"],right:["arrowright","d","e"],sound:["u"]},or=(t,e)=>()=>t(n=>d({},ot.reduce((o,s)=>f(d({},o),{[s]:s===e?!n[e]:!1}),n))),Ae=bt((t,e)=>{const n=ee(Me).reduce((a,i)=>(a[i]=l=>t(u=>({controls:f(d({},u.controls),{[i]:l})})),a),{}),o=ee(Se).reduce((a,i)=>(a[i]=er(i)?or(t,i):()=>t(l=>f(d({},l),{[i]:!l[i]})),a),{}),s=f(d(d({},o),n),{camera:()=>t(a=>({camera:se[(se.indexOf(a.camera)+1)%se.length]})),onCheckpoint:()=>{const{start:a}=e();if(a){const i=Date.now()-a;t({checkpoint:i})}},onFinish:()=>{const{finished:a,start:i}=e();i&&!a&&t({finished:Math.max(Date.now()-i,0)})},onStart:()=>{t({finished:0,start:Date.now()})},reset:()=>{b.boost=Be,t(a=>{var i,l,u,h;return(i=a.api)==null||i.angularVelocity.set(...Ze),(l=a.api)==null||l.position.set(...tt),(u=a.api)==null||u.rotation.set(...rt),(h=a.api)==null||h.velocity.set(0,0,0),f(d({},a),{finished:0,start:0})})}});return f(d({},Se),{actionInputMap:rr,actions:s,api:null,bestCheckpoint:0,camera:se[0],chassisBody:c.exports.createRef(),checkpoint:0,color:"#FFFF00",controls:Me,keyBindingsWithError:[],dpr:et,finished:0,get:e,keyInput:null,level:c.exports.createRef(),session:null,set:t,start:0,vehicleConfig:Le,wheelInfo:Te,wheels:[c.exports.createRef(),c.exports.createRef(),c.exports.createRef(),c.exports.createRef()]})}),b={boost:Be,rpmTarget:0,sliding:!1,speed:0,velocity:[0,0,0]},v=t=>Ae(t,wt);Object.assign(v,Ae);const{getState:z,setState:G}=Ae;function nr(){const[t,e,n]=v(({actionInputMap:o,actions:s,binding:a})=>[o,s,a]);return c.exports.useEffect(()=>{if(n)return;const o=ee(t).reduce((i,l)=>d(d({},i),t[l].reduce((u,h)=>f(d({},u),{[h]:l}),{})),{}),s=({key:i,target:l})=>{const u=o[i.toLowerCase()];!u||l.nodeName==="INPUT"||!tr(u)||e[u](!0)},a=({key:i,target:l})=>{const u=o[i.toLowerCase()];!u||l.nodeName==="INPUT"||e[u](!1)};return window.addEventListener("keydown",s,{passive:!0}),window.addEventListener("keyup",a,{passive:!0}),()=>{window.removeEventListener("keydown",s),window.removeEventListener("keyup",a)}},[t,n]),null}function sr({delay:t=3e3}){return c.exports.useEffect(()=>{let e=!0;const n=Xe(()=>{e=!0,document.documentElement.style.cursor="none"},t),o=()=>{e&&(e=!1,document.documentElement.style.cursor=""),n()};return window.addEventListener("mousemove",o,{passive:!0}),()=>window.removeEventListener("mousemove",o)},[t]),null}const{lerp:ar}=V,ir=()=>{const t=c.exports.useRef(null),e=v(({vehicleConfig:{maxSpeed:o}})=>o),n=()=>2*b.speed/e;return F((o,s)=>{var a,i;(a=t.current)==null||a.setVolume(n()),(i=t.current)==null||i.setPlaybackRate(ar(t.current.playbackRate,b.rpmTarget+.5,s*10))}),c.exports.useEffect(()=>(t.current&&!t.current.isPlaying&&(t.current.setVolume(n()),t.current.play()),()=>{t.current&&t.current.isPlaying&&t.current.stop()}),[]),r(W,{ref:t,url:"/sounds/accelerate.mp3",loop:!0,distance:5})},lr=()=>{const t=c.exports.useRef(null),[e,n,o]=v(({controls:{boost:s},vehicleConfig:{maxSpeed:a},sound:i})=>[s,a,i]);return F(()=>{var a,i,l;const s=Math.pow(b.speed/n,1.5)+.5;(a=t.current)==null||a.setVolume(s*1.5),(i=t.current)==null||i.setPlaybackRate(s),!b.boost&&((l=t.current)==null?void 0:l.isPlaying)&&t.current.stop()}),c.exports.useEffect(()=>{if(t.current&&o){const s=e&&b.boost>0;s&&!t.current.isPlaying&&t.current.play(),!s&&t.current.isPlaying&&t.current.stop()}return()=>{t.current&&t.current.isPlaying&&t.current.stop()}},[e,o]),r(W,{ref:t,url:"/sounds/boost.mp3",distance:5})},cr=()=>{const t=c.exports.useRef(null),[e,n]=v(({controls:{brake:o},sound:s})=>[o,s]);return F(()=>{var o;b.speed<=10&&((o=t.current)==null?void 0:o.isPlaying)&&t.current.stop()}),c.exports.useEffect(()=>{if(t.current&&n){const o=e&&b.speed>10;o&&!t.current.isPlaying&&t.current.play(),!o&&t.current.isPlaying&&t.current.stop()}return()=>{t.current&&t.current.isPlaying&&t.current.stop()}},[e,n]),r(W,{ref:t,url:"/sounds/tire-brake.mp3",distance:10})},{lerp:ur}=V,dr=()=>{const t=c.exports.useRef(null),e=v(({vehicleConfig:{maxSpeed:o}})=>o),n=()=>1-b.speed/e;return F((o,s)=>{var a,i;(a=t.current)==null||a.setVolume(n()),(i=t.current)==null||i.setPlaybackRate(ur(t.current.playbackRate,b.rpmTarget+1,s*10))}),c.exports.useEffect(()=>(t.current&&!t.current.isPlaying&&(t.current.setVolume(n()),t.current.play()),()=>{t.current&&t.current.isPlaying&&t.current.stop()}),[]),r(W,{autoplay:!0,ref:t,url:"/sounds/engine.mp3",loop:!0,distance:5})},mr=()=>{const t=c.exports.useRef(null),[e,n]=v(({controls:{honk:o},sound:s})=>[o,s]);return c.exports.useEffect(()=>(t.current&&n&&(e&&!t.current.isPlaying&&t.current.play(),!e&&t.current.isPlaying&&t.current.stop()),()=>{t.current&&t.current.isPlaying&&t.current.stop()}),[e,n]),r(W,{ref:t,url:"/sounds/honk.mp3",distance:10})};function hr(){const[t,e]=v(n=>[n.camera,n.editor]);return e?r(le,{makeDefault:e,position:[0,50,0],zoom:20}):p(_,{children:[r(Qe,{makeDefault:!e&&t!=="BIRD_EYE",fov:75,rotation:[0,Math.PI,0],position:[0,10,-20]}),r(le,{makeDefault:!e&&t==="BIRD_EYE",position:[0,100,0],rotation:[-1*Math.PI/2,0,Math.PI],zoom:15})]})}const ae=new D,Ve=new Re,$=new Ne,pr=new Gt;function gr({count:t=200,opacity:e=.1,size:n=1}){const o=v(y=>y.wheels),s=c.exports.useRef(null);let a,i=0,l=0,u=0,h=0;return F((y,w)=>{if(!!s.current)if(a=z().controls.brake,u=V.lerp(u,Number(b.sliding||a)*b.speed/40,w*8),y.clock.getElapsedTime()-h>.02&&o[2].current&&o[3].current)h=y.clock.getElapsedTime(),$e(s.current,o[2].current.getWorldPosition(ae),l++,u),$e(s.current,o[3].current.getWorldPosition(ae),l++,u),l===t&&(l=0);else for(i=0;i<t;i++)s.current.getMatrixAt(i,Ve),Ve.decompose($.position,pr,ae),$.scale.setScalar(Math.max(0,ae.x-.005)),$.updateMatrix(),s.current.setMatrixAt(i,$.matrix),s.current.instanceMatrix.needsUpdate=!0}),p("instancedMesh",{ref:s,args:[void 0,void 0,t],children:[r("sphereGeometry",{args:[n,10,10]}),r("meshBasicMaterial",{color:"white",transparent:!0,opacity:e,depthWrite:!1})]})}let ge;function $e(t,e,n,o){ge=V.randFloatSpread(.25),$.position.set(e.x+ge,e.y-.4,e.z+ge),$.scale.setScalar(Math.random()*o),$.updateMatrix(),t.setMatrixAt(n,$.matrix),t.instanceMatrix.needsUpdate=!0}const K=new Ne,Q=[new D(-.4,-.5,-1.8),new D(.4,-.5,-1.8)];function fr({count:t=12,opacity:e=.5,size:n=.1}){const o=c.exports.useRef(null);let s,a=!1,i,l,u;return F(h=>{for(a=b.boost>0&&z().controls.boost,s=0;s<t;s+=Q.length)for(l=V.randFloatSpread(.05),i=0;i<Q.length;i++)u=(h.clock.getElapsedTime()+(s+i)*.2)%1,K.position.set(Q[i].x+l,Q[i].y,Q[i].z-u*.75),K.rotation.z+=u/2,K.scale.setScalar(a?(1-u)*2:0),K.matrixWorldNeedsUpdate=!0,K.updateMatrixWorld(),o.current&&(o.current.setMatrixAt(s+i,K.matrixWorld),o.current.instanceMatrix.needsUpdate=!0)}),p("instancedMesh",{ref:o,args:[void 0,void 0,t],children:[r("boxGeometry",{args:[n,n,n]}),r("meshBasicMaterial",{color:"#5ecfff",transparent:!0,opacity:e,depthWrite:!0})]})}const fe=new jt,yr=new Re,Z=new Ne,vr=new D;function xr({count:t=500,opacity:e=.5,size:n=.4}){const o=c.exports.useRef(null),[s,a]=v(u=>[u.chassisBody,u.wheels]);let i,l=0;return F(()=>{i=z().controls.brake,s.current&&a[2].current&&a[3].current&&i&&b.speed>10&&(fe.setFromRotationMatrix(yr.extractRotation(s.current.matrix)),We(o.current,fe,a[2].current,l++),We(o.current,fe,a[3].current,l++),l===t&&(l=0))}),c.exports.useLayoutEffect(()=>(o.current.geometry.rotateX(-Math.PI/2),()=>{o.current.geometry.rotateX(Math.PI/2)})),p("instancedMesh",{ref:o,args:[void 0,void 0,t],children:[r("planeGeometry",{args:[n,n*2]}),r("meshBasicMaterial",{color:"black",transparent:!0,opacity:e,depthWrite:!1})]})}function We(t,e,n,o){Z.position.copy(n.getWorldPosition(vr)),Z.rotation.copy(e),Z.scale.setScalar(1),Z.updateMatrix(),t.setMatrixAt(o,Z.matrix),t.instanceMatrix.needsUpdate=!0}const Ie=document.createElement("canvas"),J=Ie.getContext("2d");J&&(J.imageSmoothingEnabled=!1);function br(t){if(!J)throw new Error("Heightfield could not be created");const e=t.width,n=t.height,o=Array(e),s=Array(n),a=40;let i;Ie.width=e,Ie.height=n,J.drawImage(t,0,0,e,n);const{data:l}=J.getImageData(0,0,e,n);for(let u=0;u<e;u++){for(let h=0;h<n;h++)i=l[4*(h*e+u)]*a/255,s[h]=Number(Math.max(0,i).toPrecision(2))/4;o[u]=[...s]}return J.clearRect(0,0,e,n),o}function wr({elementSize:t,position:e,rotation:n}){const o=ce("/textures/heightmap_1024.png"),s=kt(async()=>br(o.image),o);return Ct(()=>({args:[s,{elementSize:t}],position:e,rotation:n}),void 0,[t,e,n]),null}const A=(t,e)=>n=>{const o=Array.isArray(e)?e:[e];return v(a=>o.map(i=>a[i])).every(a=>!!a)?r(t,d({},n)):n.children?r(_,{children:n.children}):null};function kr(){const t=v(l=>l.level),{nodes:e,materials:n}=j("/models/track-draco.glb"),o={receiveShadow:!0,castShadow:!0,"material-roughness":1},s=c.exports.useRef(null),a=c.exports.useRef(null);c.exports.useLayoutEffect(()=>{var l;return void((l=t.current)==null?void 0:l.traverse(u=>u.layers.enable(de)))},[]),F((l,u)=>{s.current.children.forEach((h,y)=>h.rotation.y+=u/y),a.current.children.forEach((h,y)=>h.rotation.y+=u/25/y)});const i=A(W,["ready","sound"]);return p("group",{dispose:null,children:[r("mesh",d({geometry:e.track_2.geometry,material:n["Material.001"]},o)),r("mesh",d({geometry:e.tube.geometry,material:n.default},o)),p("group",{ref:t,children:[r("mesh",d({geometry:e.strip.geometry,material:e.strip.material},o)),r("mesh",d({geometry:e.track_1.geometry,material:e.track_1.material},o)),r("mesh",d({geometry:e.mountains.geometry,material:e.mountains.material},o)),r("mesh",d({geometry:e.terrain.geometry,material:e.terrain.material},o)),p("mesh",{geometry:e.water.geometry,children:[r(St,{speed:4,map:n.ColorPaletteWater.map,roughness:0,side:Yt}),r(i,{url:"/sounds/water.mp3",loop:!0,autoplay:!0,distance:10})]})]}),p("group",{ref:s,children:[r("mesh",d({geometry:e.bird001.geometry,material:e.bird001.material},o)),r("mesh",d({geometry:e.bird002.geometry,material:e.bird002.material},o)),r("mesh",d({geometry:e.bird003.geometry,material:e.bird003.material},o)),r("mesh",d({geometry:e.bird.geometry,material:e.bird.material},o))]}),r("mesh",d({geometry:e.blade001.geometry,material:e.blade001.material},o)),r("mesh",d({geometry:e.blade002.geometry,material:e.blade002.material},o)),r("mesh",d({geometry:e.blade003.geometry,material:e.blade003.material},o)),r("mesh",d({geometry:e.blade004.geometry,material:e.blade004.material},o)),r("mesh",d({geometry:e.blade005.geometry,material:e.blade005.material},o)),r("mesh",d({geometry:e.blade006.geometry,material:e.blade006.material},o)),r("mesh",d({geometry:e.blade.geometry,material:e.blade.material},o)),p("group",{ref:a,children:[r("mesh",{geometry:e.cloud001.geometry,material:e.cloud001.material,position:[-8.55,27.94,-7.84],rotation:[0,.26,0]}),r("mesh",{geometry:e.cloud003.geometry,material:e.cloud003.material,position:[-8.55,7.47,-7.84]}),r("mesh",{geometry:e.cloud006.geometry,material:e.cloud006.material,position:[-43,11.66,8.15]}),r("mesh",{geometry:e.cloud008.geometry,material:e.cloud008.material,position:[16.29,8.22,-7.84]}),r("mesh",{geometry:e.cloud010.geometry,material:e.cloud010.material,position:[6.63,7.79,-7.84]}),r("mesh",{geometry:e.cloud011.geometry,material:e.cloud011.material,position:[-8.55,-8.74,-7.84]}),r("mesh",{geometry:e.cloud002.geometry,material:e.cloud002.material,position:[49.41,27.94,-17.5],rotation:[-Math.PI,.92,-Math.PI]}),r("mesh",{geometry:e.cloud004.geometry,material:e.cloud004.material,position:[10.77,11.73,17],rotation:[-Math.PI,1.19,-Math.PI]}),r("mesh",{geometry:e.cloud012.geometry,material:e.cloud012.material,position:[11.47,-16.12,-66.08],rotation:[-Math.PI,.92,-Math.PI]}),r("mesh",{geometry:e.cloud007.geometry,material:e.cloud007.material,position:[-8.55,22.81,-7.84],rotation:[Math.PI,-1.43,Math.PI]}),r("mesh",{geometry:e.cloud009.geometry,material:e.cloud009.material,position:[-32.93,17.92,-7.84],rotation:[Math.PI,-.79,Math.PI]}),r("mesh",{geometry:e.cloud.geometry,material:e.cloud.material,position:[-66.73,-4.76,-17.35],rotation:[Math.PI,-.79,Math.PI]}),r("mesh",{geometry:e.cloud005.geometry,material:e.cloud005.material,position:[25.95,27.94,-23.02],rotation:[-Math.PI,.31,-Math.PI]})]})]})}function Cr({args:t=[38,8,10],position:e=[-145.84,3.42,54.67],rotation:n=[0,-.09,0]}){const o=c.exports.useRef(null),{animations:s,nodes:a,materials:i}=j("/models/track-draco.glb"),[,l]=me(()=>({mass:1e4,type:"Kinematic",args:t,position:e,rotation:n}),o,[t,e,n]),{actions:u}=Mt(s,o),h={receiveShadow:!0,castShadow:!0,"material-roughness":1};c.exports.useLayoutEffect(()=>{var w;return void((w=u.train)==null?void 0:w.play())},[u]),F(()=>{l.position.set(o.current.position.x,o.current.position.y,o.current.position.z),l.rotation.set(o.current.rotation.x,o.current.rotation.y-.09,o.current.rotation.z)});const y=A(W,["ready","sound"]);return p("group",{ref:o,name:"train",position:e,rotation:n,dispose:null,children:[r("mesh",d({geometry:a.train_1.geometry,material:i.custom7Clone},h)),r("mesh",d({geometry:a.train_2.geometry,material:i.blueSteelClone},h)),r("mesh",d({geometry:a.train_3.geometry,material:i.custom12Clone},h)),r("mesh",d({geometry:a.train_4.geometry,material:i.custom14Clone},h)),r("mesh",d({geometry:a.train_5.geometry,material:i.defaultMatClone},h)),r("mesh",d({geometry:a.train_6.geometry,material:i.glassClone},h)),r("mesh",d({geometry:a.train_7.geometry,material:i.steelClone},h)),r("mesh",d({geometry:a.train_8.geometry,material:i.lightRedClone},h)),r("mesh",d({geometry:a.train_9.geometry,material:i.darkClone},h)),r(y,{url:"/sounds/train.mp3",loop:!0,autoplay:!0,distance:5})]})}const{lerp:ye}=V,Sr=10,ie=new qt,Mr=new D,Ir=c.exports.forwardRef((a,s)=>{var i=a,{args:t=[2,1.1,4.7],mass:e=500,children:n}=i,o=O(i,["args","mass","children"]);const l=c.exports.useRef(null),u=c.exports.useRef(null),h=c.exports.useRef(null),y=c.exports.useRef(null),w=c.exports.useRef(null),k=c.exports.useRef(null),[I]=v(M=>[M.vehicleConfig.maxSpeed]),{nodes:g,materials:x}=j("/models/chassis-draco.glb"),C=c.exports.useCallback(Xe(M=>{M.body.userData.trigger||!z().sound||!k.current||(k.current.setVolume(It(M.contact.impactVelocity/10,.2,1)),k.current.isPlaying||k.current.play())},200),[]),[,B]=me(()=>d({mass:e,args:t,allowSleep:!1,onCollide:C},o),s);c.exports.useEffect(()=>(G({api:B}),()=>G({api:null})),[B]),c.exports.useLayoutEffect(()=>B.velocity.subscribe(M=>{const R=Mr.set(...M).length(),m=R/(I/Sr),Y=Math.max((m%1+Math.log(m))/6,0);Object.assign(b,{rpmTarget:Y,speed:R,velocity:M})}),[I]);let E,S;return F((M,R)=>{E=z().camera,S=z().controls,u.current.material.color.lerp(ie.set(S.brake?"#555":"white"),R*10),u.current.material.emissive.lerp(ie.set((S.brake,"red")),R*10),u.current.material.opacity=ye(u.current.material.opacity,S.brake?1:.3,R*10),l.current.material.opacity=ye(l.current.material.opacity,E==="FIRST_PERSON"?.1:.75,R),l.current.material.color.lerp(ie.set(E==="FIRST_PERSON"?"white":"black"),R),h.current&&(h.current.rotation.z=ye(h.current.rotation.z,S.left?-Math.PI:S.right?Math.PI:0,R)),y.current.rotation.y=b.speed/I*-Math.PI*2-.9,w.current.material.color.lerp(ie.set(z().color),.1)}),p("group",{ref:s,dispose:null,children:[p("group",{position:[0,-.2,-.2],children:[r("mesh",{ref:w,castShadow:!0,receiveShadow:!0,geometry:g.Chassis_1.geometry,material:x.BodyPaint,"material-color":"#f0c050"}),r("mesh",{castShadow:!0,geometry:g.Chassis_2.geometry,material:g.Chassis_2.material,"material-color":"#353535"}),r("mesh",{castShadow:!0,ref:l,geometry:g.Glass.geometry,material:x.Glass,"material-transparent":!0}),r("mesh",{ref:u,geometry:g.BrakeLights.geometry,material:x.BrakeLight,"material-transparent":!0}),r("mesh",{geometry:g.HeadLights.geometry,material:x.HeadLight}),r("mesh",{geometry:g.Cabin_Grilles.geometry,material:x.Black}),r("mesh",{geometry:g.Undercarriage.geometry,material:x.Undercarriage}),r("mesh",{geometry:g.TurnSignals.geometry,material:x.TurnSignal}),r("mesh",{geometry:g.Chrome.geometry,material:g.Chrome.material}),p("group",{ref:h,position:[.37,.25,.46],children:[r("mesh",{geometry:g.Wheel_1.geometry,material:g.Wheel_1.material}),r("mesh",{geometry:g.Wheel_2.geometry,material:g.Wheel_2.material})]}),p("group",{position:[0,0,0],children:[r("mesh",{geometry:g.License_1.geometry,material:x.License}),r("mesh",{geometry:g.License_2.geometry,material:g.License_2.material})]}),p("group",{position:[.2245,.3045,.6806],scale:[.0594,.0594,.0594],children:[r("mesh",{geometry:g.Cube013.geometry,material:g.Cube013.material}),r("mesh",{geometry:g.Cube013_1.geometry,material:g.Cube013_1.material}),r("mesh",{geometry:g.Cube013_2.geometry,material:g.Cube013_2.material})]}),r("mesh",{geometry:g["pointer-left"].geometry,material:g["pointer-left"].material,position:[.5107,.3045,.6536],rotation:[Math.PI/2,-1.1954,0],scale:[.0209,.0209,.0209]}),r("mesh",{ref:y,geometry:g["pointer-right"].geometry,material:g["pointer-right"].material,position:[.2245,.3045,.6536],rotation:[-Math.PI/2,-.9187,Math.PI],scale:[.0209,.0209,.0209]})]}),n,r(W,{ref:k,url:"/sounds/crash.mp3",loop:!1,distance:5})]})}),Pr=c.exports.forwardRef((o,n)=>{var s=o,{leftSide:t}=s,e=O(s,["leftSide"]);const{radius:a}=v(h=>h.wheelInfo),{nodes:i,materials:l}=j("/models/wheel-draco.glb"),u=a/.34;return Pt(()=>d({mass:50,type:"Kinematic",material:"wheel",collisionFilterGroup:0,shapes:[{args:[a,a,.5,16],rotation:[0,0,-Math.PI/2],type:"Cylinder"}]},e),n,[a]),r("group",{ref:n,dispose:null,children:r("group",{scale:u,children:p("group",{scale:t?-1:1,children:[r("mesh",{castShadow:!0,geometry:i.Mesh_14.geometry,material:l["Material.002"]}),r("mesh",{castShadow:!0,geometry:i.Mesh_14_1.geometry,material:l["Material.009"]})]})})})}),{lerp:ve}=V,xe=new D;function Er({angularVelocity:t,children:e,position:n,rotation:o}){const s=ue(P=>P.camera),[a,i,l,u]=v(P=>[P.chassisBody,P.vehicleConfig,P.wheelInfo,P.wheels]),{back:h,force:y,front:w,height:k,maxBrake:I,steer:g,maxSpeed:x,width:C}=i,B=u.map((P,N)=>{const gt=N<2?w:h,ft=N%2?.5:-.5;return f(d({},l),{chassisConnectionPointLocal:[C*ft,k,gt],isFrontWheel:Boolean(N%2)})}),E={chassisBody:a,wheels:u,wheelInfos:B},[,S]=Et(()=>E,null,[l]);c.exports.useLayoutEffect(()=>S.sliding.subscribe(P=>b.sliding=P),[S]);let M,R,m,Y=0,L=0,H=!1,T=0,U=0,pe=0,_e=0,re=0;F((P,N)=>{for(M=z().camera,R=z().editor,m=z().controls,T=b.speed,H=m.boost&&b.boost>0,H&&(b.boost=Math.max(b.boost-1,0)),Y=ve(Y,m.forward||m.backward?y*(m.forward&&!m.backward?H?-1.5:-1:1):0,N*20),U=ve(U,m.left||m.right?g*(m.left&&!m.right?1:-1):0,N*20),L=2;L<4;L++)S.applyEngineForce(T<x?Y:0,L);for(L=0;L<2;L++)S.setSteeringValue(U,L);for(L=2;L<4;L++)S.setBrake(m.brake?m.forward?I/1.5:I:0,L);R||(M==="FIRST_PERSON"?xe.set(.3+Math.sin(-U)*T/30,.4,-.1):M==="DEFAULT"&&xe.set(Math.sin(U)*T/2.5,1.25+Y/1e3*-.5,-5-T/15+(m.brake?1:0)),s.position.lerp(xe,N),s.rotation.z=ve(s.rotation.z,(M!=="BIRD_EYE"?0:Math.PI)+-U*T/(M==="DEFAULT"?40:60),N)),a.current.children[0].rotation.z=V.lerp(a.current.children[0].rotation.z,-U*T/200,N*4),pe=H?60:30,_e=H?T/x*8:T/x*2,re=H?(T/x+.25)*30:V.lerp(re,_e,N*(H?10:20)),s.rotation.z+=Math.sin(P.clock.elapsedTime*pe*.9)/1e3*re,s.rotation.x+=Math.sin(P.clock.elapsedTime*pe)/1e3*re,a.current.children[0].rotation.x=Math.sin(P.clock.getElapsedTime()*20)*(T/x)/100,a.current.children[0].rotation.z=Math.cos(P.clock.getElapsedTime()*20)*(T/x)/100});const ht=A(ir,["ready","sound"]),pt=A(dr,["ready","sound"]);return p("group",{children:[p(Ir,{ref:a,angularVelocity:t,position:n,rotation:o,children:[r(ht,{}),r(lr,{}),r(cr,{}),r(pt,{}),r(mr,{}),r(fr,{}),e]}),r(_,{children:u.map((P,N)=>r(Pr,{ref:P,leftSide:!(N%2)},N))}),r(gr,{}),r(xr,{})]})}const Rr=({depth:t,height:e,position:[n,o,s],width:a})=>{const[i]=v(({actions:{reset:k}})=>[k]),l={isTrigger:!0,onCollide:i,userData:{trigger:!0}},u=t/2,h=e/2,y=Math.PI/2,w=a/2;return q(()=>d(f(d({},l),{position:[n-w,o,s],rotation:[0,y,0]}),l)),q(()=>f(d({},l),{position:[n,o-h,s],rotation:[y,0,0]})),q(()=>f(d({},l),{position:[n,o,s-u],rotation:[0,0,0]})),q(()=>f(d({},l),{position:[n+w,o,s],rotation:[0,-y,0]})),q(()=>f(d({},l),{position:[n,o+h,s],rotation:[-y,0,0]})),q(()=>f(d({},l),{position:[n,o,s+u],rotation:[0,Math.PI,0]})),null};function Nr(n){var o=n,{args:t}=o,e=O(o,["args"]);const[s]=me(()=>d({type:"Static",args:t},e),c.exports.useRef(null),[t,e]);return p("mesh",{castShadow:!0,receiveShadow:!0,ref:s,children:[r("boxGeometry",{args:t}),r("meshStandardMaterial",{color:"indianred"})]})}function be(n){var o=n,{args:t=[1,1,1]}=o,e=O(o,["args"]);return me(()=>d({isTrigger:!0,args:t,userData:{trigger:!0}},e),void 0,[t,e]),null}const{VITE_SUPABASE_ANON_KEY:He,VITE_SUPABASE_URL:Ue}={BASE_URL:"/ingest/racing-game/",MODE:"production",DEV:!1,PROD:!0},nt={key:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoiYW5vbiIsImlhdCI6MTYyMzMyMTAxOCwiZXhwIjoxOTM4ODk3MDE4fQ.YISggSEzSk6WsMNkvN2a5MHYWBVjQ84nHwWYne9sTA0",url:"https://tfvnrohsjcgsekfnggks.supabase.co"},st=t=>typeof t=="string",Br=st(He)?He:nt.key,Lr=st(Ue)?Ue:nt.url,X=Rt(Lr,Br),at=(t=50)=>X.from("scores").select().gt("time",1337).limit(t).order("time").then(({data:e})=>e||[]),Tr=({name:t,thumbnail:e,time:n})=>X.from("scores").insert({name:t,thumbnail:e,time:n}).then(({data:o})=>o||[]),Ar=t=>{t({session:X.auth.session()}),X.auth.onAuthStateChange((e,n)=>{t({session:n})})},_r=t=>X.auth.signIn({provider:t}),Dr=()=>X.auth.signOut();function Fr(){const[t,e]=c.exports.useState([]),[n,o]=c.exports.useState(0),[s,a]=v(l=>[l.leaderboard,l.set]),i=()=>a(l=>f(d({},l),{leaderboard:!1}));return c.exports.useEffect(()=>{!s||Date.now()-n<3e3||(at(10).then(e),o(Date.now()))},[s]),p("div",{className:`leaderboard popup ${s?"open":""}`,children:[r("button",{className:"popup-close",onClick:i,children:"L"}),r(it,{className:"popup-content leaderboard-bottom",scores:t})]})}const zr={1:"images/gold.png",2:"images/silver.png",3:"images/bronze.png"},te=t=>(t/1e3).toFixed(2),Or=({name:t,standing:e,time:n})=>p("li",{className:"popup-item",children:[r("span",{className:"leaderboard-name",children:e===1||e===2||e===3?p(_,{children:[r("img",{src:zr[e],width:13,height:13}),t]}):`${e} ${t}`}),r("span",{className:"popup-item-key",children:r("span",{children:te(n)})})]}),it=n=>{var o=n,{scores:t}=o,e=O(o,["scores"]);return r("ul",f(d({},e),{children:t.map((s,a)=>c.exports.createElement(Or,f(d({},s),{standing:a+1,key:a})))}))},Ge=(t,e)=>{const n=e&&!t?Date.now()-e:0;return`${te(n)}`};function Vr(){const t=c.exports.useRef(null),{finished:e,start:n}=v(({finished:s,start:a})=>({finished:s,start:a}));let o=Ge(e,n);return c.exports.useEffect(()=>{let s=0;return he(a=>{!t.current||a-s<100||(s=a,o=Ge(e,n),t.current.innerText!==o&&(t.current.innerText=o))})},[e,n]),r("div",{className:"clock",children:r("span",{ref:t,children:o})})}const lt=30,$r=60,je=()=>b.boost<=lt,Ye=()=>b.boost>$r?"#00FF00":b.boost>lt?"#FFE600":"#FF0000",qe=()=>`${(100*(1-b.boost/Be)).toFixed()}%`;function Wr(){const t=c.exports.useRef(null);let e=je(),n=Ye(),o=qe();return c.exports.useEffect(()=>he(()=>{!t.current||(e=je(),t.current.classList.contains("blink")!==e&&t.current.classList.toggle("blink",e),n=Ye(),t.current.style.stroke!==n&&(t.current.style.stroke=n),o=qe(),t.current.style.strokeDashoffset!==o&&(t.current.style.strokeDashoffset=o))})),r("div",{className:"boost-bar",children:p("svg",{width:289,height:55,viewBox:"0 0 289 55",xmlns:"http://www.w3.org/2000/svg",children:[r("path",{className:"boost-bg-path",d:"M13,12 L200,12"}),r("path",{className:"boost-path",d:"M15,12 L198,12",ref:t,style:{stroke:n,strokeDashoffset:o}}),r("text",{className:"boost-text",x:"0",y:"17px",children:r("tspan",{children:"N"})})]})})}const Hr=c.exports.forwardRef(({offset:t},e)=>p("svg",{className:"speed-background",width:289,height:55,viewBox:"0 0 289 55",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[r("defs",{children:p("linearGradient",{id:"progress",x1:"1",y1:"0",x2:"0",y2:"0",children:[r("stop",{id:"stop1",offset:t,ref:e,stopColor:"#1B3049"}),r("stop",{id:"stop2",stopColor:"#3EB4C8"})]})}),r("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M0 40c175.256-2.308 227.867-13.823 289-40v55H0V40z",fill:"url(#progress)"})]})),Ur=()=>r("svg",{className:"speed-foreground",width:289,height:55,viewBox:"0 0 289 55",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:r("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M0 40c175.256-2.308 227.867-13.823 289-40v55H0V40zm7.5 9.5v-5h9v5h-9zm24 0h-8v-5h8v5zm7-5v5h9v-5h-9zm16 0v5h9v-5h-9zm16-1v6h8v-6h-8zm16 0v6h8v-6h-8zm24 6h-9v-7h9v7zm15 0h-8v-8h8v8zm16 0h-9v-10h9v10zm16 0h-9v-11h9v11zm15 0h-9v-13l9-.5v13.5zm16 0h-9v-15l9-1v16zm15 0h-9v-17l9-1v18zm16 0h-10v-19l10-1v20zm16 0h-10v-21l10-2v23zm15.5 0h-9.5v-25L251 22v27.5zm16 0h-10v-29l10-3.5v32.5zm16 0h-10V15l10-4v38.5z",fill:"#132237"})}),Gr=t=>()=>`${Math.max(1-b.speed/t,0).toFixed(2)}`,jr=()=>{const t=c.exports.useRef(null),e=v(s=>s.vehicleConfig.maxSpeed),n=Gr(e);let o=n();return c.exports.useEffect(()=>he(()=>{!t.current||(o=n(),t.current.getAttribute("offset")!==o&&t.current.setAttribute("offset",o))})),p("div",{className:"speed-gauge",children:[r(Hr,{offset:o,ref:t}),r(Ur,{})]})},Ke=()=>`${b.speed.toFixed()}`,Yr=()=>{const t=c.exports.useRef(null);let e=Ke();return c.exports.useEffect(()=>he(()=>{!t.current||(e=Ke(),t.current.innerText!==e&&(t.current.innerText=e))})),p("div",{className:"speed-text",children:[r("span",{ref:t,children:e})," mph"]})};function qr(){return p("div",{className:"speed",children:[r(jr,{}),r(Yr,{}),r(Wr,{})]})}const Oe=Te,{directionLocal:xo,axleLocal:bo,rollInfluence:wo}=Oe,Kr=O(Oe,["directionLocal","axleLocal","rollInfluence"]),{debug:Jr,shadows:Xr,stats:Qr}=Se,Zr=d(d({debug:Jr,dpr:et,shadows:Xr,stats:Qr},Kr),Le);function eo(){const[t,e,n,o,s,a]=v(m=>[m.get,m.set,m.debug,m.dpr,m.shadows,m.stats]),{back:i,force:l,front:u,height:h,maxBrake:y,maxSpeed:w,steer:k,width:I}=Le,{customSlidingRotationalSpeed:g,frictionSlip:x,radius:C,sideAcceleration:B,suspensionStiffness:E,suspensionRestLength:S,useCustomSlidingRotationalSpeed:M}=Te,[,R]=Nt(()=>({Performance:ne({dpr:{value:o,min:1,max:2,step:.5,onChange:m=>e({dpr:m})},shadows:{value:s,onChange:m=>e({shadows:m})}}),Vehicle:ne({radius:{value:C,min:.1,max:2,step:.01,onChange:m=>e({wheelInfo:f(d({},t().wheelInfo),{radius:m})})},width:{value:I,min:.1,max:10,step:.01,onChange:m=>e({vehicleConfig:f(d({},t().vehicleConfig),{width:m})})},height:{value:h,min:-5,max:5,step:.01,onChange:m=>e({vehicleConfig:f(d({},t().vehicleConfig),{height:m})})},front:{value:u,min:-10,max:10,step:.05,onChange:m=>e({vehicleConfig:f(d({},t().vehicleConfig),{front:m})})},back:{value:i,min:-10,max:10,step:.05,onChange:m=>e({vehicleConfig:f(d({},t().vehicleConfig),{back:m})})},steer:{value:k,min:.1,max:1,step:.01,onChange:m=>e({vehicleConfig:f(d({},t().vehicleConfig),{steer:m})})},force:{value:l,min:0,max:3e3,step:1,onChange:m=>e({vehicleConfig:f(d({},t().vehicleConfig),{force:m})})},maxBrake:{value:y,min:.1,max:100,step:.01,onChange:m=>e({vehicleConfig:f(d({},t().vehicleConfig),{maxBrake:m})})},maxSpeed:{value:w,min:1,max:150,step:1,onChange:m=>e({vehicleConfig:f(d({},t().vehicleConfig),{maxSpeed:m})})}},{collapsed:!0}),Suspension:ne({suspensionStiffness:{value:E,min:0,max:500,step:1,onChange:m=>e({wheelInfo:f(d({},t().wheelInfo),{suspensionStiffness:m})})},suspensionRestLength:{value:S,min:-10,max:10,step:.01,onChange:m=>e({wheelInfo:f(d({},t().wheelInfo),{suspensionRestLength:m})})},useCustomSlidingRotationalSpeed:{value:M,onChange:m=>e({wheelInfo:f(d({},t().wheelInfo),{useCustomSlidingRotationalSpeed:m})})},customSlidingRotationalSpeed:{value:g,min:-10,max:10,step:.01,onChange:m=>e({wheelInfo:f(d({},t().wheelInfo),{customSlidingRotationalSpeed:m})})},frictionSlip:{value:x,min:-10,max:10,step:.01,onChange:m=>e({wheelInfo:f(d({},t().wheelInfo),{frictionSlip:m})})},sideAcceleration:{value:B,min:-10,max:10,step:.01,onChange:m=>e({wheelInfo:f(d({},t().wheelInfo),{sideAcceleration:m})})}},{collapsed:!0}),Debug:ne({debug:{value:n,onChange:m=>e({debug:m})},stats:{value:a,onChange:m=>e({stats:m})}},{collapsed:!0}),reset:Bt(()=>{R(Zr)})}));return null}const to=[{provider:"google",label:"Sign in with Google",Logo:()=>p("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 70 72",children:[r("path",{fill:"#4285F4",d:"m70 37-1-7H36v14h19c-1 4-3 8-7 10v9h11c7-6 11-15 11-26z"}),r("path",{fill:"#34A853",d:"M36 72c9 0 17-3 23-9l-11-9a21 21 0 0 1-32-11H4v9c6 12 18 20 32 20z"}),r("path",{fill:"#FBBC05",d:"M16 43a21 21 0 0 1 0-13V20H4a36 36 0 0 0 0 32l12-9z"}),r("path",{fill:"#EA4335",d:"M36 15c5 0 10 2 13 5l11-10A36.6 36.6 0 0 0 4 20l12 10c3-9 10-15 20-15z"})]})},{provider:"github",label:"Sign in with Github",Logo:()=>p("svg",{role:"img",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:[r("title",{children:"GitHub"}),r("path",{fill:"#181717",d:"M12 .3a12 12 0 0 0-3.8 23.4c.6.1.8-.3.8-.6v-2c-3.3.7-4-1.6-4-1.6-.6-1.4-1.4-1.8-1.4-1.8-1-.7.1-.7.1-.7 1.2 0 1.9 1.2 1.9 1.2 1 1.8 2.8 1.3 3.5 1 0-.8.4-1.3.7-1.6-2.7-.3-5.5-1.3-5.5-6 0-1.2.5-2.3 1.3-3.1-.2-.4-.6-1.6 0-3.2 0 0 1-.3 3.4 1.2a11.5 11.5 0 0 1 6 0c2.3-1.5 3.3-1.2 3.3-1.2.6 1.6.2 2.8 0 3.2a4 4 0 0 1 1.3 3.2c0 4.6-2.8 5.6-5.5 5.9.5.4.9 1 .9 2.2v3.3c0 .3.1.7.8.6A12 12 0 0 0 12 .3"})]})}];function ct(){const t=async e=>{try{await _r(e)}catch(n){alert(n.error_description||n.message)}};return p("div",{children:[r("h2",{className:"auth-header",children:"Want to save your score?"}),r("div",{className:"auth-providers",children:to.map(({provider:e,label:n,Logo:o},s)=>p("button",{className:"auth-provider",onClick:()=>t(e),children:[r(o,{}),r("span",{children:n})]},s))})]})}const ro=()=>{var C,B;const[t,e,n]=v(({actions:{reset:E},finished:S,session:M})=>[E,M,S]),[o,s]=c.exports.useState(""),[a,i]=c.exports.useState([]),[l,u]=c.exports.useState(0),h=((C=e==null?void 0:e.user)==null?void 0:C.aud)==="authenticated",y=(B=e==null?void 0:e.user)==null?void 0:B.user_metadata,w=y==null?void 0:y.full_name,k=y==null?void 0:y.avatar_url,I=()=>{const E=a.findIndex(S=>S.id===o);u(E&&E+1)},g=()=>{at().then(i)},x=()=>{Tr({name:w,thumbnail:k,time:n}).then(([{id:E}])=>s(E)).then(g).then(I)};return c.exports.useEffect(g,[n]),c.exports.useEffect(I,[o,a]),p("div",{className:"finished",children:[r("div",{className:"finished-header",children:p("h1",{children:["Good job! Your time was ",te(n)," seconds"]})}),r("div",{className:"finished-leaderboard",children:r(it,{className:"leaderboard",scores:a})}),r("div",{className:"finished-auth",children:h?r(_,{children:o?l?p("h1",{children:["You are number #",l]}):null:p(_,{children:[p("h2",{children:["You belong on our leaderboard, ",w,"! "]}),r("button",{onClick:x,style:{margin:"0 auto",width:"auto"},className:"popup-item-key",children:"Add my score"})]})}):r(ct,{})}),r("div",{className:"finished-restart",children:r("button",{className:"restart-btn",onClick:t,children:"Restart"})})]})},ut={alt:"Alt \u2325",arrowdown:"\u2193",arrowleft:"\u2190",arrowright:"\u2192",arrowup:"\u2191",backspace:"Backspace \u232B",capslock:"CapsLock \u21EA",control:"Control \u2303",enter:"Enter \u21B5",meta:"Meta \u2318",shift:"Shift \u21E7"," ":"Space \u2423",tab:"Tab \u21E5"},oo=t=>Object.hasOwnProperty.call(ut,t),Pe={backward:{displayName:"Backward",order:1},boost:{displayName:"Turbo Boost",order:6},brake:{displayName:"Drift",order:4},camera:{displayName:"Toggle Camera",order:14},editor:{displayName:"Editor",order:8},forward:{displayName:"Forward",order:0},help:{displayName:"Help",order:9},honk:{displayName:"Honk",order:5},leaderboard:{displayName:"Leaderboards",order:10},left:{displayName:"Left",order:2},map:{displayName:"Map",order:11},pickcolor:{displayName:"Pick Car Color",order:12},reset:{displayName:"Reset",order:7},right:{displayName:"Right",order:3},sound:{displayName:"Toggle Mute",order:13}};function no({actionName:t,hasError:e,inputs:n,onAdd:o,onRemove:s}){return p("div",{className:`keys-row popup-item${e?" with-error":""}`,children:[r("div",{children:Pe[t].displayName}),p("div",{className:"popup-item-keys",children:[n.map((a,i)=>r("button",{onClick:()=>{s(t,a)},className:"key-button popup-item-key",children:r("span",{children:oo(a)?ut[a]:a.toUpperCase()})},i)),r("button",{className:"add-button popup-item-key hovered-item",onClick:()=>{o(t)},children:r("span",{children:"+"})})]})]})}function so({onAdd:t}){const[e]=v(({actionInputMap:o})=>[o]),n=c.exports.useCallback((o,s)=>{G(l=>{var u=l,{actionInputMap:a}=u,i=O(u,["actionInputMap"]);return d({actionInputMap:f(d({},a),{[o]:a[o].filter(h=>h!==s)})},i)})},[]);return r(_,{children:ee(e).sort((o,s)=>Pe[o].order-Pe[s].order).map((o,s)=>r(no,{actionName:o,inputs:e[o],onRemove:n,onAdd:t,hasError:!e[o].length},s))})}function ao({onKeyup:t}){return c.exports.useEffect(()=>(window.addEventListener("keyup",t,{passive:!0}),()=>{window.removeEventListener("keyup",t)}),[t]),r("div",{className:"key-input-wrapper",children:r("div",{className:"key-input",children:"Press new key"})})}function dt(t){const[e,n]=c.exports.useState(null),[o,s]=v(({actions:l,binding:u})=>[l,u]),a=c.exports.useCallback(l=>{n(l),s||o.binding()},[s]),i=c.exports.useCallback(({key:l})=>{if(!e)return;const u=l.toLowerCase();if(u==="escape")return n(null);G(w=>{var k=w,{actionInputMap:h}=k,y=O(k,["actionInputMap"]);return d({actionInputMap:ee(h).reduce((I,g)=>f(d({},I),{[g]:g===e?h[g].concat(u):h[g].filter(x=>x!==u)}),{})},y)}),n(null),s&&o.binding()},[s,e]);return p(_,{children:[r("div",f(d({},t),{children:r(so,{onAdd:a})})),e&&r(ao,{onKeyup:i})]})}function io(){const[t,e,n]=v(o=>[o.set,o.help,o.sound]);return p(_,{children:[r("div",{className:`${n?"sound":"nosound"}`}),p("div",{className:"help",children:[!e&&r("button",{onClick:()=>t({help:!0}),children:"i"}),p("div",{className:`popup ${e?"open":""}`,children:[r("button",{className:"popup-close",onClick:()=>t({help:!1}),children:"i"}),r("div",{className:"popup-content",children:r(dt,{})})]})]})]})}const we=new Re,lo=new D,ke=new D,Je=new Kt,Ce=new D;function mt(){const[t]=c.exports.useState(()=>new Xt),[e]=c.exports.useState(()=>new D),[n]=c.exports.useState(()=>new D),o=v(s=>s.level);return c.exports.useLayoutEffect(()=>{var s;!((s=o.current)!=null&&s.parent)||(o.current.parent.updateWorldMatrix(!1,!1),t.setFromObject(o.current),t.getCenter(e),t.getSize(n))},[]),[t,e,n]}function co({buffer:t}){const e=c.exports.useRef(null),n=ue(i=>i.gl),o=ue(i=>i.scene),[s,a]=mt();return c.exports.useEffect(()=>{!e.current||(n.setRenderTarget(t),e.current.bottom=s.min.z-a.z,e.current.top=s.max.z-a.z,e.current.left=s.min.x-a.x,e.current.right=s.max.x-a.x,e.current.position.set(a.x,a.y+s.max.y,a.z),e.current.updateProjectionMatrix(),n.render(o,e.current),n.setRenderTarget(null))},[s,a]),c.exports.useLayoutEffect(()=>{!e.current||(e.current.layers.disableAll(),e.current.layers.enable(de))},[de]),r(le,{ref:e,makeDefault:!1,rotation:[-Math.PI/2,0,0],near:20,far:500})}function uo({size:t=200}){const e=c.exports.useRef(null),n=c.exports.useRef(null),o=c.exports.useRef(null),[s]=c.exports.useState(()=>new Jt),a=ce("textures/mask.svg"),i=ce("textures/cursor.svg"),l=Lt(t*2,t*2),{gl:u,camera:h,scene:y,size:{height:w,width:k}}=ue(),[,I,g]=mt(),x=v(B=>B.chassisBody),C=c.exports.useMemo(()=>new D(k/-2-t/-2+30,w/-2-t/-2+30,0),[w,k,t]);return F(()=>{!n.current||!o.current||(u.autoClear=!0,u.render(y,h),u.autoClear=!1,u.clearDepth(),we.copy(h.matrix).invert(),n.current.quaternion.setFromRotationMatrix(we),x.current&&e.current&&(Ce.subVectors(x.current.getWorldPosition(lo),I),e.current.quaternion.setFromRotationMatrix(we),e.current.position.set(C.x+Ce.x/g.x*t,C.y-Ce.z/g.z*t,0),x.current.getWorldDirection(ke),Je.set(ke.x,ke.z),e.current.material.rotation=Math.PI/2-Je.angle()),u.render(s,o.current))},1),p(_,{children:[Tt(p(_,{children:[r("ambientLight",{intensity:1}),r("sprite",{ref:n,position:C,scale:[t,t,1],children:r("spriteMaterial",{map:l.texture,alphaMap:a})}),r("sprite",{ref:e,position:C,scale:[t/20,t/20,1],children:r("spriteMaterial",{color:"white",alphaMap:i})})]}),s),r(le,{ref:o,position:[0,0,.1]}),r(co,{buffer:l})]})}function mo({children:t}){var u;const[e,n]=c.exports.useState(!1),[o,s]=c.exports.useState(!0),{progress:a}=At(),[i,l]=v(h=>[h.session,h.set]);return c.exports.useEffect(()=>{e&&!o&&l({ready:!0})},[e,o]),c.exports.useEffect(()=>{a===100&&s(!1)},[a]),c.exports.useEffect(()=>{Ar(l)},[]),p(_,{children:[r(c.exports.Suspense,{fallback:null,children:t}),p("div",{className:`fullscreen bg ${o?"loading":"loaded"} ${e&&"clicked"}`,children:[p("div",{className:"stack",children:[p("div",{className:"intro-keys",children:[r(dt,{style:{paddingBottom:20}}),r("a",{className:"start-link",href:"#",onClick:()=>n(!0),children:o?`loading ${a.toFixed()} %`:"Click to start"})]}),((u=i==null?void 0:i.user)==null?void 0:u.aud)!=="authenticated"?r(ct,{}):p("div",{children:["Hello ",i.user.user_metadata.full_name,r("button",{className:"logout",onClick:Dr,children:"Logout"})," "]})]}),r(_t,{date:"2. June",year:"2021",link1:r("a",{href:"https://github.com/pmndrs/react-three-fiber",children:"@react-three/fiber"}),link2:r("a",{href:"https://github.com/pmndrs/racing-game",children:"/racing-game"})})]})]})}function ho(){const[t,e]=v(({bestCheckpoint:i,checkpoint:l})=>[i,l]),n=!t||e<t,o=t?e-t:e;c.exports.useEffect(()=>{if(!e)return;const i=setTimeout(()=>{G({bestCheckpoint:e&&n?e:t,checkpoint:0})},3e3);return()=>clearTimeout(i)});const s=n?"green":"red",a=`${n?"":"+"}${te(o)}`;return p("div",{className:"checkpoint",children:[r("p",{children:te(e)}),r("p",{className:s,children:a})]})}function po(){const[t,e]=v(a=>[a.color,a.pickcolor]),n=a=>G({color:a}),o=()=>G({pickcolor:!1}),s=A(Dt,"pickcolor");return p("div",{className:`pickcolor popup ${e?"open":""}`,children:[r("button",{className:"popup-close",onClick:o,children:"P"}),r("div",{className:"pickcolor-container popup-content",children:r(s,{color:t,onChange:n})})]})}const Ee=new Qt;Ee.enable(de);function go(){const[t,e]=c.exports.useState(null),[n,o,s,a]=v(C=>[C.actions,C.dpr,C.editor,C.shadows]),{onCheckpoint:i,onFinish:l,onStart:u}=n,h=A(ho,"checkpoint"),y=A(Wt,"debug"),w=A(eo,"editor"),k=A(ro,"finished"),I=A(uo,"map"),g=A(Ft,"editor"),x=A(Ht,"stats");return p(mo,{children:[p(zt,{dpr:[1,o],shadows:a,camera:{position:[0,5,15],fov:50},children:[r("fog",{attach:"fog",args:["white",0,500]}),r(Ot,{sunPosition:[100,10,100],distance:1e3}),r("ambientLight",{layers:Ee,intensity:.1}),r("directionalLight",{ref:e,layers:Ee,position:[0,50,150],intensity:1,"shadow-bias":-.001,"shadow-mapSize":[4096,4096],"shadow-camera-left":-150,"shadow-camera-right":150,"shadow-camera-top":150,"shadow-camera-bottom":-150,castShadow:!0}),r(Qe,{makeDefault:s,fov:75,position:[0,20,20]}),r(Vt,{allowSleep:!0,broadphase:"SAP",defaultContactMaterial:{contactEquationRelaxation:4,friction:.001},children:p(y,{scale:1.0001,color:"white",children:[p(Er,{angularVelocity:[...Ze],position:[...tt],rotation:[...rt],children:[t&&r("primitive",{object:t.target}),r(hr,{})]}),r(Cr,{}),r(Nr,{args:[30,6,8],position:[2,-1,168.55],rotation:[0,.49,Math.PI/15]}),r(wr,{elementSize:.5085,position:[327-66.5,-3.3,-473+213],rotation:[-Math.PI/2,0,-Math.PI]}),r(be,{args:[.001,10,18],onCollideBegin:u,rotation:[0,.55,0],position:[-27,1,180]}),r(be,{args:[.001,10,18],onCollideBegin:l,rotation:[0,-1.2,0],position:[-104,1,-189]}),r(be,{args:[.001,10,18],onCollideBegin:i,rotation:[0,-.5,0],position:[-50,1,-5]}),r(Rr,{depth:512,height:100,position:[0,40,0],width:512})]})}),r(kr,{}),r($t,{files:"textures/dikhololo_night_1k.hdr"}),r(I,{}),r(g,{})]},`${o}${a}`),r(Vr,{}),r(w,{}),r(k,{}),r(io,{}),r(qr,{}),r(x,{}),r(h,{}),r(Fr,{}),r(po,{}),r(sr,{}),r(nr,{})]})}ce.preload("/textures/heightmap_1024.png");j.preload("/models/track-draco.glb");j.preload("/models/chassis-draco.glb");j.preload("/models/wheel-draco.glb");Ut(document.getElementById("root")).render(r(go,{}));
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
<svg version="1.0" width="1706.667" height="1706.667" viewBox="0 0 1280 1280" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M31.4 1C11.9 5.1-2.1 25.2.5 45.5c.6 5.1 38.3 81.1 304 612.5 290.1 580.1 303.6 606.9 308.2 611 6.1 5.4 15.7 9.9 23.1 10.6 11.8 1.3 25.8-4 33.4-12.5 3.1-3.5 77.1-150.8 307-610.6 292.4-584.9 302.9-606.2 303.5-612.6 1.5-17.3-7.6-32.6-23.7-40.3-5.9-2.7-7.4-3-16-3-7.9.1-10.4.5-15 2.6-3 1.3-135.9 89.4-295.3 195.6L640 392 350.3 198.8C190.9 92.6 58 4.6 55 3.2 48.9.5 38.2-.5 31.4 1z" fill="#fff"/>
|
|
3
|
+
</svg>
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<svg width="450" height="450" viewBox="0 0 450 450" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<g clip-path="url(#clip0)">
|
|
3
|
+
<path d="M450 0H0V450H450V0Z" fill="black" stroke="#808080" stroke-width="0.1"/>
|
|
4
|
+
<rect x="50" y="50" width="350" height="350" fill="white"/>
|
|
5
|
+
</g>
|
|
6
|
+
<defs>
|
|
7
|
+
<clipPath id="clip0">
|
|
8
|
+
<rect width="450" height="450" fill="white"/>
|
|
9
|
+
</clipPath>
|
|
10
|
+
</defs>
|
|
11
|
+
</svg>
|
|
Binary file
|