@hyperframes/studio 0.8.50 → 0.8.53-desktop.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/dist/assets/{hyperframes-player-CxxDxHTW.js → hyperframes-player-PTEnAHhg.js} +3 -3
- package/dist/assets/{index-DUAIWxkI.js → index--myXp8ui.js} +1 -1
- package/dist/assets/{index-Dt3qBI-9.js → index-BjslOS9g.js} +1 -1
- package/dist/assets/index-BnXZuIJD.css +1 -0
- package/dist/assets/index-CNyviK_l.js +390 -0
- package/dist/index.css +29 -0
- package/dist/index.css.map +1 -0
- package/dist/index.d.ts +825 -24
- package/dist/index.html +2 -2
- package/dist/index.js +8911 -9853
- package/dist/index.js.map +1 -1
- package/dist/styles/tailwind-preset.js.map +1 -1
- package/package.json +13 -12
- package/src/App.tsx +145 -163
- package/src/captions/components/CaptionAnimationPanel.tsx +4 -4
- package/src/captions/components/CaptionOverlay.sender.test.tsx +52 -0
- package/src/captions/components/CaptionOverlay.tsx +8 -4
- package/src/captions/components/CaptionOverlayUtils.ts +2 -3
- package/src/captions/components/CaptionPropertyPanel.tsx +3 -3
- package/src/captions/components/CaptionTimeline.tsx +1 -1
- package/src/captions/components/shared.tsx +2 -2
- package/src/components/AskAgentModal.tsx +5 -5
- package/src/components/EditorShell.selectionSync.test.tsx +9 -4
- package/src/components/EditorShell.tsx +59 -62
- package/src/components/ExternalFileConflictBanner.tsx +16 -16
- package/src/components/LintModal.tsx +6 -16
- package/src/components/MediaPreview.tsx +2 -2
- package/src/components/RightPanelTabs.test.tsx +151 -0
- package/src/components/RightPanelTabs.tsx +59 -0
- package/src/components/SaveQueuePausedBanner.tsx +2 -2
- package/src/components/StudioHeader.dom.test.tsx +181 -0
- package/src/components/StudioHeader.test.ts +0 -12
- package/src/components/StudioHeader.tsx +118 -221
- package/src/components/StudioLeftPanels.tsx +202 -0
- package/src/components/StudioOverlays.tsx +1 -1
- package/src/components/{StudioRightPanel.tsx → StudioRightPanels.tsx} +57 -194
- package/src/components/{StudioRightPanel.types.ts → StudioRightPanels.types.ts} +4 -3
- package/src/components/StudioToast.tsx +2 -2
- package/src/components/TimelineHistoryButtons.dom.test.tsx +117 -0
- package/src/components/TimelineHistoryButtons.tsx +54 -0
- package/src/components/TimelineToolbar.test.tsx +8 -0
- package/src/components/TimelineToolbar.tsx +8 -12
- package/src/components/dock/Dock.test.tsx +274 -0
- package/src/components/dock/Dock.tsx +291 -0
- package/src/components/dock/dock.css +28 -0
- package/src/components/dock/dockAccessibility.test.ts +166 -0
- package/src/components/dock/dockAccessibility.ts +98 -0
- package/src/components/dock/dockLayout.test.ts +134 -0
- package/src/components/dock/dockLayout.ts +105 -0
- package/src/components/dock/dockLayoutSchema.ts +66 -0
- package/src/components/dock/dockLayoutStore.test.ts +28 -0
- package/src/components/dock/dockLayoutStore.ts +108 -0
- package/src/components/dock/dockTestHarness.ts +11 -0
- package/src/components/dock/panelRegistry.ts +67 -0
- package/src/components/editor/AnimationCard.tsx +4 -4
- package/src/components/editor/AnimationCardParts.tsx +6 -6
- package/src/components/editor/BlockParamsPanel.tsx +4 -4
- package/src/components/editor/BorderRadiusEditor.tsx +1 -1
- package/src/components/editor/CanvasContextMenu.tsx +1 -1
- package/src/components/editor/ComputedTweenNotice.tsx +1 -1
- package/src/components/editor/DomEditOverlay.tsx +1 -1
- package/src/components/editor/EaseCurveSection.tsx +1 -1
- package/src/components/editor/EaseParamFields.tsx +5 -5
- package/src/components/editor/FileTree.tsx +4 -4
- package/src/components/editor/FileTreeIcons.tsx +1 -1
- package/src/components/editor/FileTreeNodes.tsx +13 -13
- package/src/components/editor/InlineTextToolbar.tsx +1 -1
- package/src/components/editor/InspectorHeaderActions.tsx +3 -3
- package/src/components/editor/KeyframeDiamond.tsx +1 -1
- package/src/components/editor/KeyframeEaseList.tsx +1 -1
- package/src/components/editor/LayersPanel.test.ts +97 -1
- package/src/components/editor/LayersPanel.tsx +7 -5
- package/src/components/editor/MarqueeOverlay.tsx +1 -1
- package/src/components/editor/OffCanvasIndicators.tsx +1 -1
- package/src/components/editor/PreviewGuides.tsx +1 -1
- package/src/components/editor/PromotableControl.tsx +2 -2
- package/src/components/editor/PropertyPanelEmptyState.tsx +7 -7
- package/src/components/editor/PropertyPanelFlatHeader.tsx +2 -2
- package/src/components/editor/SnapToolbar.test.tsx +0 -3
- package/src/components/editor/SnapToolbar.tsx +2 -2
- package/src/components/editor/TimelineFxPopover.tsx +1 -1
- package/src/components/editor/TopologyLens.test.tsx +28 -0
- package/src/components/editor/TopologyLens.tsx +7 -5
- package/src/components/editor/Transform3DCube.tsx +2 -2
- package/src/components/editor/audioFxRevealTarget.ts +1 -0
- package/src/components/editor/domEditing.test.ts +1 -1
- package/src/components/editor/domEditingAgentPrompt.test.ts +8 -6
- package/src/components/editor/domEditingAgentPrompt.ts +4 -3
- package/src/components/editor/propertyPanelColor.tsx +11 -11
- package/src/components/editor/propertyPanelColorCurveGraph.tsx +1 -1
- package/src/components/editor/propertyPanelColorGradingControls.tsx +7 -9
- package/src/components/editor/propertyPanelColorGradingSection.tsx +6 -6
- package/src/components/editor/propertyPanelColorGradingSlider.tsx +5 -5
- package/src/components/editor/propertyPanelColorWheels.tsx +1 -1
- package/src/components/editor/propertyPanelCommitField.tsx +1 -1
- package/src/components/editor/propertyPanelFill.tsx +4 -4
- package/src/components/editor/propertyPanelFlatColorGradingAccessory.tsx +3 -3
- package/src/components/editor/propertyPanelFlatColorGradingSection.tsx +7 -7
- package/src/components/editor/propertyPanelFlatEffectsSection.tsx +4 -4
- package/src/components/editor/propertyPanelFlatMediaSection.tsx +3 -3
- package/src/components/editor/propertyPanelFlatOverlaysSection.tsx +1 -1
- package/src/components/editor/propertyPanelFlatPrimitives.tsx +10 -10
- package/src/components/editor/propertyPanelFlatSelectRow.tsx +3 -3
- package/src/components/editor/propertyPanelFlatTextSection.test.tsx +8 -9
- package/src/components/editor/propertyPanelFlatTextSection.tsx +5 -5
- package/src/components/editor/propertyPanelFlatToggle.tsx +1 -1
- package/src/components/editor/propertyPanelFont.tsx +5 -5
- package/src/components/editor/propertyPanelFxCarveModule.tsx +1 -1
- package/src/components/editor/propertyPanelFxControls.test.tsx +1 -1
- package/src/components/editor/propertyPanelFxControls.tsx +6 -6
- package/src/components/editor/propertyPanelFxEqModule.tsx +2 -2
- package/src/components/editor/propertyPanelFxPresetStyle.ts +2 -2
- package/src/components/editor/propertyPanelGradingNumberField.tsx +1 -1
- package/src/components/editor/propertyPanelMediaSection.tsx +1 -1
- package/src/components/editor/propertyPanelPrimitives.tsx +7 -7
- package/src/components/editor/propertyPanelSections.tsx +8 -8
- package/src/components/editor/useColorGradingController.test.ts +38 -0
- package/src/components/editor/useColorGradingController.ts +9 -1
- package/src/components/editor/useColorGradingPreviews.test.ts +76 -0
- package/src/components/editor/useColorGradingPreviews.ts +11 -1
- package/src/components/editor/usePreviewCompositionRect.test.tsx +95 -0
- package/src/components/editor/usePreviewCompositionRect.ts +21 -0
- package/src/components/feedback/StudioFeedbackCard.tsx +7 -7
- package/src/components/feedback/feedbackTrigger.ts +0 -1
- package/src/components/nle/AssetPreviewOverlay.tsx +6 -2
- package/src/components/nle/CompositionBreadcrumb.tsx +3 -3
- package/src/components/nle/NLEContext.tsx +0 -43
- package/src/components/nle/NLEPreview.tsx +3 -3
- package/src/components/nle/PreviewOverlays.tsx +6 -6
- package/src/components/nle/PreviewPane.tsx +3 -3
- package/src/components/nle/TimelinePane.tsx +53 -67
- package/src/components/panels/SlideshowPanel.tsx +3 -3
- package/src/components/panels/SlideshowSubPanels.tsx +20 -17
- package/src/components/panels/VariablesBindElement.tsx +2 -2
- package/src/components/panels/VariablesDeclarationForm.tsx +2 -2
- package/src/components/panels/VariablesOtherCompositions.tsx +1 -1
- package/src/components/panels/VariablesPanel.tsx +4 -4
- package/src/components/panels/VariablesValueControls.tsx +2 -2
- package/src/components/pointerTargetSize.test.tsx +8 -0
- package/src/components/renders/FfmpegRequiredNotice.tsx +5 -5
- package/src/components/renders/RenderQueue.test.tsx +7 -0
- package/src/components/renders/RenderQueue.tsx +7 -7
- package/src/components/renders/RenderQueueItem.tsx +6 -6
- package/src/components/renders/RenderQueuePanel.tsx +1 -1
- package/src/components/sidebar/AssetCard.tsx +8 -8
- package/src/components/sidebar/AssetContextMenu.tsx +8 -8
- package/src/components/sidebar/AssetsTab.tsx +2 -2
- package/src/components/sidebar/AudioRow.tsx +6 -6
- package/src/components/sidebar/BlocksTab.tsx +6 -6
- package/src/components/sidebar/{LeftSidebar.masterComposition.test.tsx → CompositionsPanel.masterComposition.test.tsx} +6 -9
- package/src/components/sidebar/CompositionsPanel.tsx +15 -0
- package/src/components/sidebar/CompositionsTab.tsx +5 -5
- package/src/components/sidebar/GlobalAssetsView.tsx +1 -1
- package/src/components/sidebar/PromptPreviewModal.tsx +3 -3
- package/src/components/sidebar/SidebarLintButton.test.tsx +53 -0
- package/src/components/sidebar/SidebarLintButton.tsx +50 -0
- package/src/components/timelineToolbarStyles.ts +5 -0
- package/src/components/ui/Button.test.tsx +252 -0
- package/src/components/ui/Button.tsx +89 -126
- package/src/components/ui/IconButton.tsx +38 -0
- package/src/components/ui/Input.tsx +115 -0
- package/src/components/ui/Menu.test.tsx +374 -0
- package/src/components/ui/Menu.tsx +213 -0
- package/src/components/ui/NumberField.tsx +122 -0
- package/src/components/ui/Popover.tsx +74 -0
- package/src/components/ui/SearchInput.tsx +2 -2
- package/src/components/ui/Select.tsx +100 -0
- package/src/components/ui/Slider.tsx +153 -0
- package/src/components/ui/Tabs.test.tsx +98 -0
- package/src/components/ui/Tabs.tsx +71 -0
- package/src/components/ui/Toggle.tsx +63 -0
- package/src/components/ui/Tooltip.test.tsx +110 -0
- package/src/components/ui/Tooltip.tsx +38 -112
- package/src/components/ui/cn.test.ts +30 -0
- package/src/components/ui/cn.ts +25 -0
- package/src/components/ui/index.ts +29 -2
- package/src/components/ui/mountHost.testHelpers.ts +24 -0
- package/src/components/ui/valueControls.test.tsx +524 -0
- package/src/contexts/PanelLayoutContext.tsx +3 -57
- package/src/hooks/appHotkeysDispatch.ts +3 -4
- package/src/hooks/timelineEditPermission.ts +31 -0
- package/src/hooks/useAppHotkeys.previewForwarding.test.tsx +0 -2
- package/src/hooks/useAppHotkeys.test.ts +0 -1
- package/src/hooks/useAppHotkeys.textEditing.test.tsx +0 -3
- package/src/hooks/useAppHotkeys.ts +21 -84
- package/src/hooks/useCaptionDetection.sender.test.tsx +46 -0
- package/src/hooks/useCaptionDetection.ts +3 -1
- package/src/hooks/useDomEditPreviewSync.ts +4 -6
- package/src/hooks/useDomEditSession.ts +0 -7
- package/src/hooks/useDomEditWiring.ts +4 -9
- package/src/hooks/useEditHistoryActions.test.tsx +90 -0
- package/src/hooks/useEditHistoryActions.ts +106 -0
- package/src/hooks/useFileManager.ts +21 -123
- package/src/hooks/useLintModal.test.tsx +65 -0
- package/src/hooks/useLintModal.ts +3 -0
- package/src/hooks/usePanelLayout.test.ts +108 -296
- package/src/hooks/usePanelLayout.ts +50 -255
- package/src/hooks/usePersistentEditHistory.ts +1 -1
- package/src/hooks/useProjectFileWriter.ts +150 -0
- package/src/hooks/useRightPanelIntents.test.ts +181 -0
- package/src/hooks/useRightPanelIntents.ts +63 -0
- package/src/hooks/useSdkSession.lifecycle.test.tsx +49 -4
- package/src/hooks/useSdkSession.ts +43 -10
- package/src/hooks/useServerConnection.hashProject.test.tsx +94 -0
- package/src/hooks/useServerConnection.ts +43 -10
- package/src/hooks/useSlideshowTabState.test.ts +9 -31
- package/src/hooks/useSlideshowTabState.ts +6 -19
- package/src/hooks/useStudioContextValue.test.ts +6 -18
- package/src/hooks/useStudioContextValue.ts +5 -26
- package/src/hooks/useTimelineAssetDropOps.test.tsx +41 -1
- package/src/hooks/useTimelineAssetDropOps.ts +52 -11
- package/src/hooks/useTimelineDeleteOps.test.tsx +111 -0
- package/src/hooks/useTimelineEditing.test.tsx +322 -3
- package/src/hooks/useTimelineEditing.ts +103 -16
- package/src/hooks/useTimelineEditingTypes.ts +3 -0
- package/src/hooks/useTrackPendingTimelineEdit.test.tsx +62 -0
- package/src/hooks/useTrackPendingTimelineEdit.ts +22 -0
- package/src/hostMount.test.tsx +222 -0
- package/src/index.ts +87 -0
- package/src/main.tsx +9 -3
- package/src/player/components/AudioWaveform.tsx +1 -1
- package/src/player/components/AutomationSelectionMenu.tsx +3 -3
- package/src/player/components/ClipContextMenu.tsx +3 -3
- package/src/player/components/CompositionThumbnail.test.ts +0 -3
- package/src/player/components/CompositionThumbnail.tsx +3 -4
- package/src/player/components/EditModal.tsx +1 -1
- package/src/player/components/ImageThumbnail.tsx +1 -1
- package/src/player/components/KeyframeDiamondContextMenu.tsx +4 -4
- package/src/player/components/LayerDisclosureRow.tsx +2 -2
- package/src/player/components/PlayerControls.tsx +1 -1
- package/src/player/components/ShortcutsPanel.tsx +9 -9
- package/src/player/components/SpeedMenu.tsx +3 -5
- package/src/player/components/Timeline.tsx +3 -2
- package/src/player/components/TimelineCanvas.tsx +21 -14
- package/src/player/components/TimelineClip.tsx +0 -1
- package/src/player/components/TimelineDiamondConnectors.tsx +1 -1
- package/src/player/components/TimelineEmptyState.tsx +5 -5
- package/src/player/components/TimelineFxButton.tsx +6 -6
- package/src/player/components/TimelineGroupHeader.tsx +5 -5
- package/src/player/components/TimelineGroupLaneLabels.tsx +1 -1
- package/src/player/components/TimelineGroupRow.tsx +1 -1
- package/src/player/components/TimelineLanes.test.tsx +32 -0
- package/src/player/components/TimelineLanes.tsx +2 -5
- package/src/player/components/TimelineLayerGroupHeader.tsx +2 -2
- package/src/player/components/TimelineRuler.tsx +1 -1
- package/src/player/components/TimelineShortcutHint.tsx +1 -1
- package/src/player/components/TimelineTrackHeader.test.tsx +26 -5
- package/src/player/components/TimelineTrackHeader.tsx +2 -2
- package/src/player/components/TimelineTrackPlainHeader.tsx +3 -3
- package/src/player/components/TimelineTypes.ts +2 -1
- package/src/player/components/TrackGapContextMenu.tsx +1 -1
- package/src/player/components/VideoThumbnail.tsx +4 -2
- package/src/player/components/VolumeControl.tsx +2 -2
- package/src/player/components/timelineCallbacks.ts +8 -8
- package/src/player/components/timelineClipDragPreview.ts +51 -27
- package/src/player/components/timelineClipDragTypes.ts +3 -0
- package/src/player/components/timelineDragDrop.test.tsx +61 -1
- package/src/player/components/timelineDragDrop.ts +57 -15
- package/src/player/components/timelineLaneProps.ts +3 -0
- package/src/player/components/timelineSnapping.test.ts +27 -0
- package/src/player/components/timelineSnapping.ts +14 -1
- package/src/player/components/timelineTheme.test.ts +4 -4
- package/src/player/components/timelineTheme.ts +30 -30
- package/src/player/components/trackHeaderLabelRows.tsx +4 -4
- package/src/player/components/useTimelineClipDrag.resize.test.tsx +136 -2
- package/src/player/components/useTimelineClipDrag.ts +30 -3
- package/src/player/lib/describeClips.ts +3 -54
- package/src/player/lib/playbackShortcuts.ts +2 -0
- package/src/player/lib/timelinePerformanceDiagnostics.test.ts +3 -2
- package/src/player/lib/timelinePerformanceDiagnostics.ts +1 -1
- package/src/player/store/previewIframeStore.notify.test.tsx +75 -0
- package/src/player/store/previewIframeStore.test.tsx +29 -0
- package/src/player/store/previewIframeStore.ts +25 -0
- package/src/renderQueueExports.test.tsx +58 -0
- package/src/styles/classCandidates.test.ts +105 -0
- package/src/styles/classCandidates.ts +281 -0
- package/src/styles/hex-baseline.json +84 -0
- package/src/styles/hexRatchet.test.ts +201 -0
- package/src/styles/iconTokens.ts +20 -0
- package/src/styles/palette-reset.css +6 -0
- package/src/styles/studio.css +24 -21
- package/src/styles/styleSources.test.ts +20 -0
- package/src/styles/styleSources.ts +47 -0
- package/src/styles/tailwind-preset.shared.js +3 -0
- package/src/styles/theme.css +270 -0
- package/src/styles/theme.test.ts +183 -0
- package/src/styles/tokenGate.test.ts +109 -0
- package/src/utils/sourcePatcher.ts +1 -1
- package/src/utils/studioHelpers.test.ts +18 -0
- package/src/utils/studioHelpers.ts +11 -8
- package/src/utils/studioUiPreferences.test.ts +10 -16
- package/src/utils/studioUiPreferences.ts +7 -16
- package/src/utils/timelineDropTrackInsert.test.ts +134 -0
- package/src/utils/timelineDropTrackInsert.ts +83 -0
- package/src/utils/typingTarget.ts +4 -0
- package/dist/assets/index-n2ml4tUn.js +0 -442
- package/dist/assets/index-pO6p0H27.css +0 -1
- package/src/components/PanelTabButton.tsx +0 -31
- package/src/components/StudioLeftSidebar.tsx +0 -204
- package/src/components/nle/TimelineResizeDivider.tsx +0 -101
- package/src/components/sidebar/LeftSidebar.storage.test.ts +0 -28
- package/src/components/sidebar/LeftSidebar.tsx +0 -334
- package/src/components/storyboard/AgentChatMessageButton.test.tsx +0 -47
- package/src/components/storyboard/AgentChatMessageButton.tsx +0 -45
- package/src/components/storyboard/FramePoster.test.tsx +0 -61
- package/src/components/storyboard/FramePoster.tsx +0 -86
- package/src/components/storyboard/StoryboardDirection.tsx +0 -45
- package/src/components/storyboard/StoryboardFrameFocus.tsx +0 -412
- package/src/components/storyboard/StoryboardFrameTile.tsx +0 -117
- package/src/components/storyboard/StoryboardGrid.tsx +0 -55
- package/src/components/storyboard/StoryboardLoaded.tsx +0 -307
- package/src/components/storyboard/StoryboardReviewGuide.tsx +0 -300
- package/src/components/storyboard/StoryboardScriptPanel.tsx +0 -26
- package/src/components/storyboard/StoryboardSourceEditor.tsx +0 -231
- package/src/components/storyboard/StoryboardStatusLegend.tsx +0 -21
- package/src/components/storyboard/StoryboardView.tsx +0 -169
- package/src/components/storyboard/StoryboardViewModeGuard.test.tsx +0 -187
- package/src/components/storyboard/frameComments.test.ts +0 -95
- package/src/components/storyboard/frameComments.ts +0 -115
- package/src/components/storyboard/frameStatus.ts +0 -36
- package/src/components/storyboard/storyboardReviewStage.test.ts +0 -40
- package/src/components/storyboard/storyboardReviewStage.ts +0 -45
- package/src/components/storyboard/useFrameComments.ts +0 -98
- package/src/contexts/ViewModeContext.tsx +0 -142
- package/src/hooks/useInspectorSplitResize.ts +0 -51
- package/src/hooks/useProjectSignaturePoll.test.tsx +0 -135
- package/src/hooks/useProjectSignaturePoll.ts +0 -68
- package/src/hooks/useStoryboard.ts +0 -99
- package/src/utils/fitPanels.test.ts +0 -164
- package/src/utils/fitPanels.ts +0 -151
|
@@ -1,18 +1,13 @@
|
|
|
1
|
-
import { useState, useCallback,
|
|
1
|
+
import { useState, useCallback, useRef } from "react";
|
|
2
2
|
import type { EditingFile } from "../utils/studioHelpers";
|
|
3
3
|
import { FONT_EXT, isMediaFile } from "../utils/mediaTypes";
|
|
4
4
|
import { fontFamilyFromAssetPath, type ImportedFontAsset } from "../components/editor/fontAssets";
|
|
5
5
|
import type { EditHistoryKind } from "../utils/editHistory";
|
|
6
6
|
import { findTagByTarget, type PatchTarget } from "../utils/sourcePatcher";
|
|
7
|
-
import {
|
|
8
|
-
createStudioSaveHttpError,
|
|
9
|
-
retryStudioSave,
|
|
10
|
-
StudioFileConflictError,
|
|
11
|
-
StudioSaveNetworkError,
|
|
12
|
-
} from "../utils/studioSaveDiagnostics";
|
|
13
|
-
import { studioExpectedFileVersion, studioWriteHeaders } from "../utils/studioFileVersion";
|
|
7
|
+
import { StudioFileConflictError } from "../utils/studioSaveDiagnostics";
|
|
14
8
|
import { useFileTree } from "./useFileTree";
|
|
15
9
|
import { useEditorSave } from "./useEditorSave";
|
|
10
|
+
import { useProjectFileWriter } from "./useProjectFileWriter";
|
|
16
11
|
|
|
17
12
|
// ── Types ──
|
|
18
13
|
|
|
@@ -50,17 +45,13 @@ export function useFileManager({
|
|
|
50
45
|
projectIdRef.current = projectId;
|
|
51
46
|
|
|
52
47
|
const importedFontAssetsRef = useRef<ImportedFontAsset[]>([]);
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
fileVersions.set(path, version);
|
|
61
|
-
},
|
|
62
|
-
[fileVersions],
|
|
63
|
-
);
|
|
48
|
+
const {
|
|
49
|
+
fileVersions,
|
|
50
|
+
readProjectFile,
|
|
51
|
+
writeProjectFile: writeProjectFileRaw,
|
|
52
|
+
readOptionalProjectFile,
|
|
53
|
+
observeProjectFileVersion,
|
|
54
|
+
} = useProjectFileWriter({ projectId });
|
|
64
55
|
|
|
65
56
|
// ── File tree ──
|
|
66
57
|
|
|
@@ -74,117 +65,24 @@ export function useFileManager({
|
|
|
74
65
|
fontAssets,
|
|
75
66
|
} = useFileTree({ projectId, projectIdRef });
|
|
76
67
|
|
|
77
|
-
// ── Core file I/O ──
|
|
78
|
-
|
|
79
|
-
const readProjectFile = useCallback(
|
|
80
|
-
async (path: string): Promise<string> => {
|
|
81
|
-
if (!projectId) throw new Error("No active project");
|
|
82
|
-
const response = await fetch(
|
|
83
|
-
`/api/projects/${encodeURIComponent(projectId)}/files/${encodeURIComponent(path)}`,
|
|
84
|
-
);
|
|
85
|
-
if (!response.ok) throw new Error(`Failed to read ${path}`);
|
|
86
|
-
const data = (await response.json()) as { content?: string; version?: string };
|
|
87
|
-
if (typeof data.content !== "string") throw new Error(`Missing file contents for ${path}`);
|
|
88
|
-
fileVersions.set(path, data.version ?? response.headers.get("etag"));
|
|
89
|
-
return data.content;
|
|
90
|
-
},
|
|
91
|
-
[fileVersions, projectId],
|
|
92
|
-
);
|
|
93
|
-
|
|
94
|
-
const writeProjectFile = useCallback(
|
|
95
|
-
async (path: string, content: string, expectedContent?: string): Promise<void> => {
|
|
96
|
-
if (!projectId) throw new Error("No active project");
|
|
97
|
-
const writeProjectId = projectId;
|
|
98
|
-
let expectedVersion = await studioExpectedFileVersion(fileVersions, path, expectedContent);
|
|
99
|
-
if (expectedVersion === undefined) {
|
|
100
|
-
const preflight = await fetch(
|
|
101
|
-
`/api/projects/${encodeURIComponent(writeProjectId)}/files/${encodeURIComponent(path)}`,
|
|
102
|
-
);
|
|
103
|
-
if (preflight.ok) {
|
|
104
|
-
const data = (await preflight.json()) as { content?: string; version?: string };
|
|
105
|
-
throw new StudioFileConflictError({
|
|
106
|
-
filePath: path,
|
|
107
|
-
currentVersion: data.version ?? preflight.headers.get("etag"),
|
|
108
|
-
currentContent: data.content ?? null,
|
|
109
|
-
attemptedContent: content,
|
|
110
|
-
});
|
|
111
|
-
} else if (preflight.status === 404) {
|
|
112
|
-
expectedVersion = null;
|
|
113
|
-
} else {
|
|
114
|
-
throw await createStudioSaveHttpError(preflight, `Failed to read ${path} before save`);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
await retryStudioSave(async () => {
|
|
118
|
-
// Each request gets its own receipt identity. If a committed request loses its response,
|
|
119
|
-
// the retry can produce a second filesystem receipt that must be suppressed independently.
|
|
120
|
-
let response: Response;
|
|
121
|
-
try {
|
|
122
|
-
response = await fetch(
|
|
123
|
-
`/api/projects/${encodeURIComponent(writeProjectId)}/files/${encodeURIComponent(path)}`,
|
|
124
|
-
{
|
|
125
|
-
method: "PUT",
|
|
126
|
-
headers: {
|
|
127
|
-
"Content-Type": "text/plain",
|
|
128
|
-
...studioWriteHeaders(),
|
|
129
|
-
...(expectedVersion ? { "If-Match": expectedVersion } : { "If-None-Match": "*" }),
|
|
130
|
-
},
|
|
131
|
-
body: content,
|
|
132
|
-
},
|
|
133
|
-
);
|
|
134
|
-
} catch (error) {
|
|
135
|
-
throw new StudioSaveNetworkError(`Failed to save ${path}: network error`, {
|
|
136
|
-
cause: error,
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
if (response.status === 409) {
|
|
140
|
-
const conflict = (await response.json().catch(() => null)) as {
|
|
141
|
-
currentVersion?: string | null;
|
|
142
|
-
currentContent?: string | null;
|
|
143
|
-
} | null;
|
|
144
|
-
const currentVersion = conflict?.currentVersion ?? null;
|
|
145
|
-
if (currentVersion && conflict?.currentContent === content) {
|
|
146
|
-
fileVersions.set(path, currentVersion);
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
throw new StudioFileConflictError({
|
|
150
|
-
filePath: path,
|
|
151
|
-
currentVersion,
|
|
152
|
-
currentContent: conflict?.currentContent ?? null,
|
|
153
|
-
attemptedContent: content,
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
if (!response.ok) throw await createStudioSaveHttpError(response, `Failed to save ${path}`);
|
|
157
|
-
const result = (await response.json()) as { version?: string };
|
|
158
|
-
const version = result.version ?? response.headers.get("etag");
|
|
159
|
-
if (!version)
|
|
160
|
-
throw new Error(`Save response for ${path} did not include a content version`);
|
|
161
|
-
fileVersions.set(path, version);
|
|
162
|
-
});
|
|
163
|
-
if (projectIdRef.current === writeProjectId && editingPathRef.current === path) {
|
|
164
|
-
setEditingFile({ path, content });
|
|
165
|
-
}
|
|
166
|
-
},
|
|
167
|
-
[fileVersions, projectId],
|
|
168
|
-
);
|
|
169
|
-
|
|
170
68
|
const updateEditingFileContent = useCallback((path: string, content: string) => {
|
|
171
69
|
if (editingPathRef.current === path) {
|
|
172
70
|
setEditingFile({ path, content });
|
|
173
71
|
}
|
|
174
72
|
}, []);
|
|
175
73
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
74
|
+
// Studio's own editor tab mirrors whatever it just wrote, on top of the
|
|
75
|
+
// shared writer — a host mounting useProjectFileWriter directly has no
|
|
76
|
+
// editor tab and does not need this.
|
|
77
|
+
const writeProjectFile = useCallback(
|
|
78
|
+
async (path: string, content: string, expectedContent?: string): Promise<void> => {
|
|
79
|
+
const writeProjectId = projectIdRef.current;
|
|
80
|
+
await writeProjectFileRaw(path, content, expectedContent);
|
|
81
|
+
if (projectIdRef.current === writeProjectId && editingPathRef.current === path) {
|
|
82
|
+
setEditingFile({ path, content });
|
|
83
|
+
}
|
|
186
84
|
},
|
|
187
|
-
[
|
|
85
|
+
[writeProjectFileRaw],
|
|
188
86
|
);
|
|
189
87
|
|
|
190
88
|
// ── Editor save (debounced content change) ──
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// @vitest-environment happy-dom
|
|
2
|
+
|
|
3
|
+
import { act } from "react";
|
|
4
|
+
import { createRoot, type Root } from "react-dom/client";
|
|
5
|
+
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
6
|
+
import { useLintModal } from "./useLintModal";
|
|
7
|
+
|
|
8
|
+
(globalThis as unknown as { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
|
|
9
|
+
|
|
10
|
+
let root: Root | null = null;
|
|
11
|
+
let latest: ReturnType<typeof useLintModal> | null = null;
|
|
12
|
+
|
|
13
|
+
function Probe() {
|
|
14
|
+
latest = useLintModal("demo");
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
afterEach(() => {
|
|
19
|
+
if (root) act(() => root?.unmount());
|
|
20
|
+
root = null;
|
|
21
|
+
latest = null;
|
|
22
|
+
vi.unstubAllGlobals();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
async function mountWithLint(response: () => Promise<unknown>) {
|
|
26
|
+
vi.stubGlobal("fetch", vi.fn(response));
|
|
27
|
+
root = createRoot(document.createElement("div"));
|
|
28
|
+
await act(async () => root?.render(<Probe />));
|
|
29
|
+
await act(async () => {
|
|
30
|
+
await latest?.handleLint();
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const lintResponse = (findings: Array<{ severity: string; message: string }>) => async () => ({
|
|
35
|
+
json: async () => ({ findings }),
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
describe("useLintModal hasLintError", () => {
|
|
39
|
+
it("is true when a finding is an error and false for warnings only", async () => {
|
|
40
|
+
await mountWithLint(lintResponse([{ severity: "error", message: "nested" }]));
|
|
41
|
+
expect(latest?.hasLintError).toBe(true);
|
|
42
|
+
act(() => root?.unmount());
|
|
43
|
+
root = null;
|
|
44
|
+
await mountWithLint(lintResponse([{ severity: "warning", message: "soft" }]));
|
|
45
|
+
expect(latest?.hasLintError).toBe(false);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("is true for a mixed error and warning list", async () => {
|
|
49
|
+
await mountWithLint(
|
|
50
|
+
lintResponse([
|
|
51
|
+
{ severity: "warning", message: "soft" },
|
|
52
|
+
{ severity: "error", message: "nested" },
|
|
53
|
+
]),
|
|
54
|
+
);
|
|
55
|
+
expect(latest?.hasLintError).toBe(true);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it("is true when the manual lint itself fails, matching the badge count", async () => {
|
|
59
|
+
await mountWithLint(async () => {
|
|
60
|
+
throw new Error("offline");
|
|
61
|
+
});
|
|
62
|
+
expect(latest?.lintModal).toHaveLength(1);
|
|
63
|
+
expect(latest?.hasLintError).toBe(true);
|
|
64
|
+
});
|
|
65
|
+
});
|
|
@@ -96,6 +96,8 @@ export function useLintModal(projectId: string | null, refreshKey?: number) {
|
|
|
96
96
|
|
|
97
97
|
const findingsByElement = useMemo(() => groupFindings((f) => f.elementId), [groupFindings]);
|
|
98
98
|
const findingsByFile = useMemo(() => groupFindings((f) => f.file), [groupFindings]);
|
|
99
|
+
// Reads the list the badge count reads: the manual result when present, else the background one.
|
|
100
|
+
const hasLintError = (lintModal ?? backgroundFindings).some((f) => f.severity === "error");
|
|
99
101
|
|
|
100
102
|
// Sync lint findings directly to the player store — eliminates the
|
|
101
103
|
// mirroring useEffect that was previously in App.tsx.
|
|
@@ -111,5 +113,6 @@ export function useLintModal(projectId: string | null, refreshKey?: number) {
|
|
|
111
113
|
backgroundFindings,
|
|
112
114
|
findingsByElement,
|
|
113
115
|
findingsByFile,
|
|
116
|
+
hasLintError,
|
|
114
117
|
};
|
|
115
118
|
}
|