@puredesktop/puredesktop-ui-bridge 1.0.0-beta.1
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/package.json +96 -0
- package/src/agents/runtime/agentLiveReducer.test.ts +72 -0
- package/src/agents/runtime/agentLiveReducer.ts +139 -0
- package/src/agents/runtime/agentRunEventTypes.ts +115 -0
- package/src/agents/runtime/contextWindowUsage.test.ts +38 -0
- package/src/agents/runtime/contextWindowUsage.ts +25 -0
- package/src/agents/runtime/index.ts +24 -0
- package/src/agents/runtime/mapAgentMessages.ts +54 -0
- package/src/agents/runtime/mapAgentSnapshot.ts +71 -0
- package/src/agents/runtime/mergeUsageTurn.ts +23 -0
- package/src/agents/runtime/pendingToolCalls.test.ts +85 -0
- package/src/agents/runtime/pendingToolCalls.ts +14 -0
- package/src/agents/runtime/toolRequiresApproval.ts +20 -0
- package/src/agents/runtime/unresolvedToolCalls.ts +42 -0
- package/src/bridge/agentModelTiers.ts +50 -0
- package/src/bridge/agentToolHandlers.ts +23 -0
- package/src/bridge/agentToolHelpers.test.ts +27 -0
- package/src/bridge/agentToolHelpers.ts +20 -0
- package/src/bridge/agentTypes.ts +294 -0
- package/src/bridge/agents.d.mts +113 -0
- package/src/bridge/agents.mjs +233 -0
- package/src/bridge/agents.ts +62 -0
- package/src/bridge/appSettings.d.mts +9 -0
- package/src/bridge/appSettings.mjs +18 -0
- package/src/bridge/appSettings.ts +4 -0
- package/src/bridge/applyThemeFromHost.d.mts +7 -0
- package/src/bridge/applyThemeFromHost.mjs +33 -0
- package/src/bridge/assets.d.mts +66 -0
- package/src/bridge/assets.mjs +121 -0
- package/src/bridge/catalog.d.mts +5 -0
- package/src/bridge/catalog.mjs +24 -0
- package/src/bridge/catalog.ts +1 -0
- package/src/bridge/client.d.mts +19 -0
- package/src/bridge/client.mjs +147 -0
- package/src/bridge/collectionAssetAdapter.ts +63 -0
- package/src/bridge/collectionAssets.d.mts +1 -0
- package/src/bridge/collectionAssets.mjs +2 -0
- package/src/bridge/collectionAssets.ts +1 -0
- package/src/bridge/collectionDocumentHtml.test.ts +71 -0
- package/src/bridge/collectionDocumentHtml.ts +118 -0
- package/src/bridge/collectionImagePaste.test.ts +32 -0
- package/src/bridge/collectionImagePaste.ts +130 -0
- package/src/bridge/context.mjs +12 -0
- package/src/bridge/credentials.mjs +22 -0
- package/src/bridge/dialog.d.mts +5 -0
- package/src/bridge/dialog.mjs +13 -0
- package/src/bridge/events.d.mts +14 -0
- package/src/bridge/events.mjs +12 -0
- package/src/bridge/filePreviewKind.test.ts +43 -0
- package/src/bridge/filePreviewKind.ts +76 -0
- package/src/bridge/fs.d.mts +41 -0
- package/src/bridge/fs.mjs +82 -0
- package/src/bridge/fs.test.ts +16 -0
- package/src/bridge/fs.ts +10 -0
- package/src/bridge/index.ts +12 -0
- package/src/bridge/inlinePreview.d.mts +35 -0
- package/src/bridge/inlinePreview.mjs +99 -0
- package/src/bridge/inlinePreview.test.ts +56 -0
- package/src/bridge/inlinePreview.ts +13 -0
- package/src/bridge/methods.d.mts +115 -0
- package/src/bridge/methods.mjs +132 -0
- package/src/bridge/os.d.mts +11 -0
- package/src/bridge/os.mjs +26 -0
- package/src/bridge/plugins.d.mts +9 -0
- package/src/bridge/plugins.mjs +31 -0
- package/src/bridge/plugins.ts +5 -0
- package/src/bridge/preferences.d.mts +7 -0
- package/src/bridge/preferences.mjs +17 -0
- package/src/bridge/preferences.ts +13 -0
- package/src/bridge/printDocument.test.ts +47 -0
- package/src/bridge/printDocument.ts +75 -0
- package/src/bridge/pureRender/adapters.test.ts +144 -0
- package/src/bridge/pureRender/adapters.ts +175 -0
- package/src/bridge/pureRender/assets.test.ts +44 -0
- package/src/bridge/pureRender/base.css +76 -0
- package/src/bridge/pureRender/compiler.test.ts +279 -0
- package/src/bridge/pureRender/compiler.ts +660 -0
- package/src/bridge/pureRender/document.test.ts +283 -0
- package/src/bridge/pureRender/document.ts +35 -0
- package/src/bridge/pureRender/extraction.test.ts +432 -0
- package/src/bridge/pureRender/extraction.ts +1023 -0
- package/src/bridge/pureRender/flow.css +3 -0
- package/src/bridge/pureRender/index.ts +66 -0
- package/src/bridge/pureRender/normalize.test.ts +442 -0
- package/src/bridge/pureRender/normalize.ts +682 -0
- package/src/bridge/pureRender/presets.ts +365 -0
- package/src/bridge/pureRender/profiles/book.css +19 -0
- package/src/bridge/pureRender/profiles/manuscript.css +11 -0
- package/src/bridge/pureRender/profiles/writer.css +10 -0
- package/src/bridge/pureRender/reset.css +5 -0
- package/src/bridge/pureRender/samples.ts +94 -0
- package/src/bridge/pureRender/styles.ts +164 -0
- package/src/bridge/pureRender/theme.test.ts +53 -0
- package/src/bridge/pureRender/theme.ts +258 -0
- package/src/bridge/pureRender/tokens/default.css +36 -0
- package/src/bridge/pureRender/tokens/default.json +32 -0
- package/src/bridge/pureRender/types.ts +264 -0
- package/src/bridge/pureRender/visualLayoutInspection.test.ts +57 -0
- package/src/bridge/pureRender/visualLayoutInspection.ts +161 -0
- package/src/bridge/react/useDebouncedEffect.ts +21 -0
- package/src/bridge/react/useIpc.tsx +75 -0
- package/src/bridge/react/usePlatformAgentRunLiveState.tsx +78 -0
- package/src/bridge/react/usePlatformAgentSessionDrive.tsx +729 -0
- package/src/bridge/react/usePlatformAgentSessions.tsx +60 -0
- package/src/bridge/react/usePlatformAgentTools.tsx +82 -0
- package/src/bridge/react/usePlatformAppManifest.tsx +32 -0
- package/src/bridge/react/usePlatformBridge.tsx +56 -0
- package/src/bridge/react/usePlatformDeepLink.tsx +57 -0
- package/src/bridge/react/usePlatformFileBinaryDataUrl.tsx +54 -0
- package/src/bridge/react/usePlatformFilePreview.tsx +92 -0
- package/src/bridge/react/usePlatformPreferences.tsx +77 -0
- package/src/bridge/react/usePlatformThemeDocumentAttrs.ts +35 -0
- package/src/bridge/react/usePlatformThemeFromBridge.tsx +16 -0
- package/src/bridge/react/usePlatformViewportResource.test.tsx +106 -0
- package/src/bridge/react/usePlatformViewportResource.tsx +72 -0
- package/src/bridge/react/useScheduledTask.tsx +59 -0
- package/src/bridge/render.d.mts +31 -0
- package/src/bridge/render.mjs +62 -0
- package/src/bridge/render.ts +8 -0
- package/src/bridge/screenAnnotation.test.ts +103 -0
- package/src/bridge/screenAnnotation.ts +269 -0
- package/src/bridge/theme.d.mts +3 -0
- package/src/bridge/theme.mjs +9 -0
- package/src/bridge/types.ts +439 -0
- package/src/bridge/watch.d.mts +9 -0
- package/src/bridge/watch.mjs +34 -0
- package/src/bridge/watch.ts +1 -0
- package/src/bridge/window.d.mts +44 -0
- package/src/bridge/window.mjs +33 -0
- package/src/chrome/index.ts +1 -0
- package/src/components/accessibility/AccessibilityReviewDialog.test.tsx +104 -0
- package/src/components/accessibility/AccessibilityReviewDialog.tsx +350 -0
- package/src/components/accessibility/accessibilityReview.test.ts +101 -0
- package/src/components/accessibility/accessibilityReview.ts +639 -0
- package/src/components/accessibility/index.ts +16 -0
- package/src/components/agent-feedback/ScreenAnnotationAgentDialog.tsx +509 -0
- package/src/components/agent-feedback/index.ts +5 -0
- package/src/components/agents/AgentComposer.tsx +34 -0
- package/src/components/agents/AgentContextUsageBar.tsx +127 -0
- package/src/components/agents/AgentDrawerPanel.tsx +82 -0
- package/src/components/agents/AgentMarkdown.tsx +12 -0
- package/src/components/agents/AgentMessageBubble.tsx +82 -0
- package/src/components/agents/AgentMessageList.tsx +47 -0
- package/src/components/agents/AgentModelMenu.tsx +55 -0
- package/src/components/agents/AgentThinkingBlock.tsx +66 -0
- package/src/components/agents/AgentToolApprovalActions.tsx +65 -0
- package/src/components/agents/AgentToolCallCard.tsx +26 -0
- package/src/components/agents/AgentToolPendingList.tsx +39 -0
- package/src/components/agents/AgentToolPendingReview.tsx +118 -0
- package/src/components/agents/agentPanelStyles.ts +79 -0
- package/src/components/agents/agentTypes.ts +96 -0
- package/src/components/agents/formatToolCallArguments.test.ts +16 -0
- package/src/components/agents/formatToolCallArguments.ts +9 -0
- package/src/components/agents/index.ts +40 -0
- package/src/components/assets/AssetLibraryDialog.tsx +5 -0
- package/src/components/assets/asset-library/AssetLibraryDialog.tsx +43 -0
- package/src/components/assets/asset-library/AssetLibraryWorkspace.tsx +54 -0
- package/src/components/assets/asset-library/detail/AssetLibraryDetailActions.tsx +68 -0
- package/src/components/assets/asset-library/detail/AssetLibraryDetailHeader.tsx +56 -0
- package/src/components/assets/asset-library/detail/AssetLibraryDetailPane.tsx +90 -0
- package/src/components/assets/asset-library/detail/AssetLibraryDetailPreview.tsx +67 -0
- package/src/components/assets/asset-library/detail/AssetLibraryInlinePreview.tsx +87 -0
- package/src/components/assets/asset-library/detail/AssetLibraryInlineSourceField.tsx +29 -0
- package/src/components/assets/asset-library/detail/AssetLibraryMetadataFields.tsx +34 -0
- package/src/components/assets/asset-library/detail/AssetLibraryUsagePanel.tsx +46 -0
- package/src/components/assets/asset-library/detail/AssetLibraryVersionsPanel.tsx +145 -0
- package/src/components/assets/asset-library/helpers/assetKind.ts +74 -0
- package/src/components/assets/asset-library/helpers.ts +41 -0
- package/src/components/assets/asset-library/hooks/useAssetDetailDraft.ts +81 -0
- package/src/components/assets/asset-library/hooks/useAssetLibraryDialog.ts +233 -0
- package/src/components/assets/asset-library/hooks/useAssetLibraryMutations.ts +266 -0
- package/src/components/assets/asset-library/hooks/useAssetLibrarySelectionSync.ts +24 -0
- package/src/components/assets/asset-library/hooks/useAssetLibraryVersions.ts +145 -0
- package/src/components/assets/asset-library/hooks/useInlineAssetPreview.ts +44 -0
- package/src/components/assets/asset-library/index.ts +19 -0
- package/src/components/assets/asset-library/layout/assetLibraryLayout.ts +201 -0
- package/src/components/assets/asset-library/shared/fieldStyles.ts +62 -0
- package/src/components/assets/asset-library/sidebar/AssetLibraryFilterPills.tsx +89 -0
- package/src/components/assets/asset-library/sidebar/AssetLibraryList.tsx +91 -0
- package/src/components/assets/asset-library/sidebar/AssetLibraryListRow.tsx +99 -0
- package/src/components/assets/asset-library/sidebar/AssetLibraryListStatus.tsx +24 -0
- package/src/components/assets/asset-library/sidebar/AssetLibrarySidebar.tsx +48 -0
- package/src/components/assets/asset-library/sidebar/AssetLibrarySidebarActions.tsx +38 -0
- package/src/components/assets/asset-library/sidebar/AssetLibrarySidebarToolbar.tsx +78 -0
- package/src/components/assets/asset-library/sidebar/AssetListThumbnail.tsx +86 -0
- package/src/components/assets/asset-library/types.ts +128 -0
- package/src/components/assets/asset-library/utils/assetLibraryUtils.ts +181 -0
- package/src/components/assets/asset-library/utils/pathBasename.ts +5 -0
- package/src/components/assets/asset-library/utils/sanitizeUploadFileName.ts +7 -0
- package/src/components/assets/asset-library/utils/uploadCollectionAsset.ts +52 -0
- package/src/components/chrome/OverlayActionCapsule.test.tsx +82 -0
- package/src/components/chrome/OverlayActionCapsule.tsx +90 -0
- package/src/components/chrome/PanelTabStrip.tsx +113 -0
- package/src/components/chrome/PlatformIcon.tsx +27 -0
- package/src/components/chrome/PureAppWordmark.tsx +89 -0
- package/src/components/chrome/ShellWindowControls.tsx +51 -0
- package/src/components/chrome/ThemeModeButton.tsx +16 -0
- package/src/components/chrome/Titlebar.tsx +79 -0
- package/src/components/chrome/WorkspaceTabStrip.tsx +300 -0
- package/src/components/chrome/index.ts +31 -0
- package/src/components/chrome/workspaceTabTypes.ts +29 -0
- package/src/components/common/buttons/Button.tsx +241 -0
- package/src/components/common/buttons/ChoiceChip.tsx +73 -0
- package/src/components/common/buttons/CleanButton.tsx +34 -0
- package/src/components/common/buttons/IconButton.tsx +89 -0
- package/src/components/common/buttons/QuietAction.tsx +29 -0
- package/src/components/common/buttons/SegmentedControl.tsx +67 -0
- package/src/components/common/buttons/TextActionButton.tsx +55 -0
- package/src/components/common/buttons/TextLink.tsx +38 -0
- package/src/components/common/canvas/CanvasElementFrame.test.tsx +79 -0
- package/src/components/common/canvas/CanvasElementFrame.tsx +182 -0
- package/src/components/common/canvas/canvasGeometry.test.ts +66 -0
- package/src/components/common/canvas/canvasGeometry.ts +133 -0
- package/src/components/common/canvas/index.ts +27 -0
- package/src/components/common/canvas/useCanvasDragResize.test.tsx +152 -0
- package/src/components/common/canvas/useCanvasDragResize.ts +161 -0
- package/src/components/common/chat/ChatAssistantMessage.tsx +81 -0
- package/src/components/common/chat/ChatBox.tsx +189 -0
- package/src/components/common/chat/ChatMarkdown.tsx +109 -0
- package/src/components/common/chat/ChatModelMenu.tsx +258 -0
- package/src/components/common/chat/ChatStatusRow.tsx +24 -0
- package/src/components/common/chat/ChatThinkingIndicator.tsx +54 -0
- package/src/components/common/chat/ChatThread.tsx +59 -0
- package/src/components/common/chat/ChatToolRow.tsx +141 -0
- package/src/components/common/chat/ChatUserBubble.tsx +45 -0
- package/src/components/common/chat/chatUtils.ts +7 -0
- package/src/components/common/chat/index.ts +24 -0
- package/src/components/common/connections/ConnectionSetup.tsx +529 -0
- package/src/components/common/connections/index.ts +26 -0
- package/src/components/common/containers/AppFrame.test.tsx +47 -0
- package/src/components/common/containers/AppFrame.tsx +65 -0
- package/src/components/common/containers/AppHeader.tsx +60 -0
- package/src/components/common/containers/AutoFillGrid.tsx +37 -0
- package/src/components/common/containers/Collapsible.tsx +43 -0
- package/src/components/common/containers/CollapsibleGrid.tsx +174 -0
- package/src/components/common/containers/MotionScope.tsx +32 -0
- package/src/components/common/containers/PageHeader.tsx +35 -0
- package/src/components/common/containers/PanelToolbarHeader.tsx +113 -0
- package/src/components/common/containers/QuietDisclosure.tsx +91 -0
- package/src/components/common/containers/QuietSurface.tsx +41 -0
- package/src/components/common/containers/ScrollPanel.tsx +33 -0
- package/src/components/common/containers/StatusBar.tsx +42 -0
- package/src/components/common/containers/SurfacePanel.tsx +66 -0
- package/src/components/common/containers/ToolbarStrip.tsx +80 -0
- package/src/components/common/containers/flex.ts +117 -0
- package/src/components/common/containers/useOpenTransition.ts +33 -0
- package/src/components/common/context/ContextSelector.tsx +269 -0
- package/src/components/common/context/index.ts +7 -0
- package/src/components/common/desk/ActionReader.tsx +270 -0
- package/src/components/common/desk/ActivityLedger.tsx +143 -0
- package/src/components/common/desk/CreationDesk.tsx +139 -0
- package/src/components/common/desk/DailyBrief.tsx +160 -0
- package/src/components/common/desk/DeskCard.tsx +157 -0
- package/src/components/common/desk/index.ts +30 -0
- package/src/components/common/dropdown/ContextMenu.tsx +87 -0
- package/src/components/common/dropdown/MenuButtonDropdown.tsx +121 -0
- package/src/components/common/dropdown/MenuDropdown.tsx +63 -0
- package/src/components/common/dropdown/MenuDropdownEntry.tsx +51 -0
- package/src/components/common/dropdown/MenuDropdownItem.tsx +82 -0
- package/src/components/common/dropdown/MenuDropdownSubmenu.tsx +145 -0
- package/src/components/common/dropdown/MenuPanel.tsx +69 -0
- package/src/components/common/dropdown/MenuPortal.tsx +162 -0
- package/src/components/common/dropdown/MenuPortalLayer.tsx +6 -0
- package/src/components/common/dropdown/SelectMenu.tsx +243 -0
- package/src/components/common/dropdown/SelectMenuControl.tsx +23 -0
- package/src/components/common/dropdown/SelectMenuOptions.tsx +38 -0
- package/src/components/common/dropdown/menuPortalConstants.ts +11 -0
- package/src/components/common/dropdown/menuTypes.ts +71 -0
- package/src/components/common/dropdown/menuViewportPosition.test.ts +139 -0
- package/src/components/common/dropdown/menuViewportPosition.ts +122 -0
- package/src/components/common/dropdown/selectMenuLayout.test.ts +42 -0
- package/src/components/common/dropdown/selectMenuLayout.ts +123 -0
- package/src/components/common/dropdown/useMenuAnchorPosition.ts +109 -0
- package/src/components/common/dropdown/useSelectMenuAnchor.ts +30 -0
- package/src/components/common/evidence/StructuredEvidenceView.test.tsx +77 -0
- package/src/components/common/evidence/StructuredEvidenceView.tsx +312 -0
- package/src/components/common/evidence/index.ts +13 -0
- package/src/components/common/feedback/Badge.tsx +33 -0
- package/src/components/common/feedback/CapabilityPills.tsx +36 -0
- package/src/components/common/feedback/EmptyState.tsx +132 -0
- package/src/components/common/feedback/InfoHint.tsx +67 -0
- package/src/components/common/feedback/InlineBanner.tsx +82 -0
- package/src/components/common/feedback/PlatformChip.tsx +104 -0
- package/src/components/common/feedback/QuietPill.tsx +75 -0
- package/src/components/common/feedback/WorkProgressPanel.tsx +156 -0
- package/src/components/common/feedback/index.ts +33 -0
- package/src/components/common/inputs/BareInput.tsx +31 -0
- package/src/components/common/inputs/BareTextarea.tsx +10 -0
- package/src/components/common/inputs/Checkbox.tsx +13 -0
- package/src/components/common/inputs/FieldControlShell.tsx +49 -0
- package/src/components/common/inputs/FormField.tsx +40 -0
- package/src/components/common/inputs/HybridSearchField.tsx +280 -0
- package/src/components/common/inputs/InlineComposer.tsx +197 -0
- package/src/components/common/inputs/PaletteCirclePicker.tsx +26 -0
- package/src/components/common/inputs/PaletteDropdown.tsx +413 -0
- package/src/components/common/inputs/Radio.tsx +19 -0
- package/src/components/common/inputs/SearchField.tsx +128 -0
- package/src/components/common/inputs/SelectField.tsx +169 -0
- package/src/components/common/inputs/SurfacePalettePicker.tsx +54 -0
- package/src/components/common/inputs/TextAreaField.tsx +22 -0
- package/src/components/common/inputs/TextField.tsx +51 -0
- package/src/components/common/inputs/ToggleSwitch.tsx +110 -0
- package/src/components/common/inputs/WorkspacePicker.tsx +349 -0
- package/src/components/common/inputs/fieldStyles.ts +137 -0
- package/src/components/common/layout/PanelGroup.tsx +479 -0
- package/src/components/common/layout/index.ts +31 -0
- package/src/components/common/layout/panelLayoutConstants.ts +7 -0
- package/src/components/common/layout/panelLayoutPersistence.ts +35 -0
- package/src/components/common/layout/panelLayoutState.test.ts +38 -0
- package/src/components/common/layout/panelLayoutState.ts +174 -0
- package/src/components/common/layout/panelLayoutTypes.ts +19 -0
- package/src/components/common/layout/tabs/Tabs.tsx +136 -0
- package/src/components/common/lists/listRowStyles.ts +32 -0
- package/src/components/common/lists/quiet-ledger/QuietActivityList.tsx +64 -0
- package/src/components/common/lists/quiet-ledger/QuietLedgerRow.tsx +119 -0
- package/src/components/common/lists/quiet-ledger/index.ts +9 -0
- package/src/components/common/lists/reorderable/DragHandle.tsx +65 -0
- package/src/components/common/lists/reorderable/ReorderableList.tsx +280 -0
- package/src/components/common/lists/reorderable/ReorderableListRow.tsx +102 -0
- package/src/components/common/lists/reorderable/ReorderableSections.tsx +344 -0
- package/src/components/common/lists/reorderable/ReorderableSectionsDemo.tsx +94 -0
- package/src/components/common/lists/reorderable/index.ts +15 -0
- package/src/components/common/lists/reorderable/reorderableUtils.test.ts +28 -0
- package/src/components/common/lists/reorderable/reorderableUtils.ts +23 -0
- package/src/components/common/lists/reorderable/types.ts +40 -0
- package/src/components/common/lists/reorderable/useReorderableDragState.ts +49 -0
- package/src/components/common/media/ImageReferencePicker.tsx +242 -0
- package/src/components/common/menubar/MenuBar.tsx +78 -0
- package/src/components/common/menubar/MenuBarTrigger.tsx +70 -0
- package/src/components/common/narrative/NarrativeMention.tsx +74 -0
- package/src/components/common/navigation/PathBreadcrumbs.tsx +78 -0
- package/src/components/common/navigation/UnderlineTabs.tsx +83 -0
- package/src/components/common/overlays/InstallAppPromptDialog.tsx +59 -0
- package/src/components/common/overlays/Modal.tsx +285 -0
- package/src/components/common/overlays/ModalChromeHeader.tsx +105 -0
- package/src/components/common/overlays/ObjectActionStrip.tsx +80 -0
- package/src/components/common/people/AutoUpdateReviewList.tsx +182 -0
- package/src/components/common/people/EntityList.tsx +122 -0
- package/src/components/common/people/EntityPortrait.tsx +64 -0
- package/src/components/common/people/LinkedDossierList.tsx +99 -0
- package/src/components/common/people/OpportunityList.tsx +94 -0
- package/src/components/common/people/PeopleSourceList.tsx +145 -0
- package/src/components/common/people/RelationshipDossier.tsx +168 -0
- package/src/components/common/people/RelationshipMap.tsx +362 -0
- package/src/components/common/people/index.ts +40 -0
- package/src/components/common/preview/FileAudioPreview.tsx +89 -0
- package/src/components/common/preview/FileImagePreview.tsx +88 -0
- package/src/components/common/preview/FilePdfPreview.tsx +87 -0
- package/src/components/common/preview/FileTextPreview.tsx +96 -0
- package/src/components/common/preview/FileVideoPreview.tsx +87 -0
- package/src/components/common/preview/PlatformFilePreview.tsx +166 -0
- package/src/components/common/preview/previewLayout.ts +27 -0
- package/src/components/common/render/Each.tsx +42 -0
- package/src/components/common/research/EvidenceDossier.tsx +894 -0
- package/src/components/common/research/index.ts +7 -0
- package/src/components/common/tiles/CatalogCard.tsx +116 -0
- package/src/components/common/tiles/Tile.tsx +45 -0
- package/src/components/common/tiles/TileGrid.tsx +13 -0
- package/src/components/common/typography/Heading.tsx +27 -0
- package/src/components/common/typography/Kicker.tsx +30 -0
- package/src/components/common/typography/Text.tsx +80 -0
- package/src/components/credentials/CredentialsPanel.tsx +169 -0
- package/src/components/credentials/credentialsTypes.ts +14 -0
- package/src/components/data/DataChart.tsx +913 -0
- package/src/components/data/dataTable.ts +99 -0
- package/src/components/editor/EditorCommentPromptDialog.tsx +124 -0
- package/src/components/editor/EditorLinkPromptDialog.tsx +65 -0
- package/src/components/print-design/PrintDesignPanel.test.tsx +1446 -0
- package/src/components/print-design/PrintDesignPanel.tsx +3043 -0
- package/src/components/print-design/index.ts +9 -0
- package/src/components/proofing/PagedProofDialog.tsx +453 -0
- package/src/components/proofing/index.ts +4 -0
- package/src/editor/DocumentEditor.tsx +28 -0
- package/src/editor/EditorViewModeToggle.tsx +35 -0
- package/src/editor/index.ts +97 -0
- package/src/editor/toolbarOverlays.ts +8 -0
- package/src/index.ts +209 -0
- package/src/theme/ThemeProvider.tsx +113 -0
- package/src/theme/appAccents.ts +87 -0
- package/src/theme/buildThemeBridgePayload.ts +23 -0
- package/src/theme/composePlatformTheme.test.ts +30 -0
- package/src/theme/composePlatformTheme.ts +23 -0
- package/src/theme/platformFont.d.mts +7 -0
- package/src/theme/platformFont.mjs +20 -0
- package/src/theme/platformFont.ts +6 -0
- package/src/theme/reportsShellChromeSelectors.ts +136 -0
- package/src/theme/styled.d.ts +5 -0
- package/src/theme/surfacePalettes.ts +178 -0
- package/src/theme/surfaceRoleSelectors.ts +113 -0
- package/src/theme/themeVars.ts +13 -0
- package/src/theme/themes/dark.ts +59 -0
- package/src/theme/themes/light.ts +60 -0
- package/src/theme/themes/palette.ts +44 -0
- package/src/theme/themes/shared.ts +68 -0
- package/src/theme/tokens.ts +114 -0
- package/src/theme/utils/GlobalStyles.ts +88 -0
- package/src/theme/utils/appFrameDocumentStyles.d.mts +5 -0
- package/src/theme/utils/appFrameDocumentStyles.mjs +89 -0
- package/src/theme/utils/appFrameDocumentStyles.ts +5 -0
- package/src/theme/utils/applyTheme.ts +50 -0
- package/src/theme/utils/cssVariables.ts +49 -0
- package/src/theme/utils/useInjectThemeIntoIframe.ts +40 -0
- package/src/utils/extensionIconMap.ts +123 -0
- package/src/utils/generalUtils.ts +157 -0
- package/src/writing/DraftAssistantDialog.tsx +279 -0
- package/src/writing/WritingStyleManager.tsx +416 -0
- package/src/writing/condenseWritingStyle.ts +103 -0
- package/src/writing/draftTextWithAgent.ts +134 -0
- package/src/writing/index.ts +39 -0
- package/src/writing/styleStore.ts +32 -0
- package/src/writing/writingStyle.test.ts +122 -0
- package/src/writing/writingStyle.ts +217 -0
|
@@ -0,0 +1,1446 @@
|
|
|
1
|
+
// @vitest-environment happy-dom
|
|
2
|
+
import { act } from 'react'
|
|
3
|
+
import type React from 'react'
|
|
4
|
+
import { createRoot, type Root } from 'react-dom/client'
|
|
5
|
+
import { afterEach, describe, expect, it, vi } from 'vitest'
|
|
6
|
+
import {
|
|
7
|
+
DEFAULT_PURE_RENDER_THEME,
|
|
8
|
+
PURE_RENDER_THEME_PRESETS,
|
|
9
|
+
parsePureRenderThemeJson,
|
|
10
|
+
reconcilePrintStyleProfiles,
|
|
11
|
+
type PrintStyleProfile,
|
|
12
|
+
} from '../../bridge/pureRender/index.js'
|
|
13
|
+
import { PrintDesignPanel, PrintDesignPopover } from './PrintDesignPanel.js'
|
|
14
|
+
;(
|
|
15
|
+
globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }
|
|
16
|
+
).IS_REACT_ACT_ENVIRONMENT = true
|
|
17
|
+
|
|
18
|
+
function render(ui: React.ReactElement): {
|
|
19
|
+
container: HTMLDivElement
|
|
20
|
+
root: Root
|
|
21
|
+
} {
|
|
22
|
+
const container = document.createElement('div')
|
|
23
|
+
document.body.appendChild(container)
|
|
24
|
+
const root = createRoot(container)
|
|
25
|
+
act(() => {
|
|
26
|
+
root.render(ui)
|
|
27
|
+
})
|
|
28
|
+
return { container, root }
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function buttonByText(container: Element, text: string): HTMLButtonElement {
|
|
32
|
+
const button = Array.from(container.querySelectorAll('button')).find(
|
|
33
|
+
candidate => candidate.textContent?.trim() === text,
|
|
34
|
+
)
|
|
35
|
+
expect(button).toBeDefined()
|
|
36
|
+
return button as HTMLButtonElement
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function click(button: HTMLButtonElement): void {
|
|
40
|
+
act(() => {
|
|
41
|
+
button.dispatchEvent(new MouseEvent('click', { bubbles: true }))
|
|
42
|
+
})
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function fillTextarea(
|
|
46
|
+
textarea: HTMLTextAreaElement | null,
|
|
47
|
+
value: string,
|
|
48
|
+
): void {
|
|
49
|
+
expect(textarea).not.toBeNull()
|
|
50
|
+
const setter = Object.getOwnPropertyDescriptor(
|
|
51
|
+
HTMLTextAreaElement.prototype,
|
|
52
|
+
'value',
|
|
53
|
+
)?.set
|
|
54
|
+
act(() => {
|
|
55
|
+
setter?.call(textarea, value)
|
|
56
|
+
textarea?.dispatchEvent(new Event('input', { bubbles: true }))
|
|
57
|
+
})
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function changeInput(
|
|
61
|
+
input: HTMLInputElement | HTMLSelectElement,
|
|
62
|
+
value: string,
|
|
63
|
+
): void {
|
|
64
|
+
const setter = Object.getOwnPropertyDescriptor(
|
|
65
|
+
Object.getPrototypeOf(input),
|
|
66
|
+
'value',
|
|
67
|
+
)?.set
|
|
68
|
+
act(() => {
|
|
69
|
+
setter?.call(input, value)
|
|
70
|
+
input.dispatchEvent(new Event('input', { bubbles: true }))
|
|
71
|
+
input.dispatchEvent(new Event('change', { bubbles: true }))
|
|
72
|
+
})
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
afterEach(() => {
|
|
76
|
+
document.body.innerHTML = ''
|
|
77
|
+
vi.clearAllMocks()
|
|
78
|
+
delete (globalThis as { createImageBitmap?: unknown }).createImageBitmap
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
describe('PrintDesignPanel', () => {
|
|
82
|
+
it('closes the popover when pressing outside it', () => {
|
|
83
|
+
const onClose = vi.fn()
|
|
84
|
+
const { container } = render(
|
|
85
|
+
<div>
|
|
86
|
+
<PrintDesignPopover open onClose={onClose}>
|
|
87
|
+
<button type="button">Inside</button>
|
|
88
|
+
</PrintDesignPopover>
|
|
89
|
+
<button type="button">Outside</button>
|
|
90
|
+
</div>,
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
click(buttonByText(container, 'Inside'))
|
|
94
|
+
expect(onClose).not.toHaveBeenCalled()
|
|
95
|
+
|
|
96
|
+
buttonByText(container, 'Outside').dispatchEvent(
|
|
97
|
+
new Event('pointerdown', { bubbles: true }),
|
|
98
|
+
)
|
|
99
|
+
expect(onClose).toHaveBeenCalledOnce()
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
it('uses the workspace panel as the modal chrome without a legacy title bar', () => {
|
|
103
|
+
const onClose = vi.fn()
|
|
104
|
+
const { container } = render(
|
|
105
|
+
<PrintDesignPopover open title={null} onClose={onClose}>
|
|
106
|
+
<PrintDesignPanel
|
|
107
|
+
variant="workspace"
|
|
108
|
+
actions={[
|
|
109
|
+
{
|
|
110
|
+
id: 'export-pdf',
|
|
111
|
+
label: 'Export PDF',
|
|
112
|
+
onClick: vi.fn(),
|
|
113
|
+
},
|
|
114
|
+
]}
|
|
115
|
+
/>
|
|
116
|
+
</PrintDesignPopover>,
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
expect(container.textContent).toContain('Design - PDF Typesetter')
|
|
120
|
+
expect(container.textContent).toContain('Export PDF')
|
|
121
|
+
expect(container.querySelector('[aria-label="Print design"]')).not.toBeNull()
|
|
122
|
+
expect(
|
|
123
|
+
container.querySelector('[aria-label="Close print design"]'),
|
|
124
|
+
).not.toBeNull()
|
|
125
|
+
expect(container.textContent?.match(/Design - PDF Typesetter/g)).toHaveLength(
|
|
126
|
+
1,
|
|
127
|
+
)
|
|
128
|
+
expect(document.head.textContent).toMatch(/width:\s*100vw/)
|
|
129
|
+
expect(document.head.textContent).toMatch(/height:\s*100vh/)
|
|
130
|
+
expect(document.head.textContent).toMatch(/border-radius:\s*0/)
|
|
131
|
+
})
|
|
132
|
+
|
|
133
|
+
it('renders quiet source labels, compact presets, and secondary status copy', () => {
|
|
134
|
+
const onThemeChange = vi.fn()
|
|
135
|
+
const { container } = render(
|
|
136
|
+
<PrintDesignPanel variant="popover" onThemeChange={onThemeChange} />,
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
expect(container.textContent).toContain('Design')
|
|
140
|
+
expect(container.textContent).toContain('Beta vision typesetting')
|
|
141
|
+
expect(container.textContent).toContain('Tune')
|
|
142
|
+
expect(container.textContent).toContain('Image')
|
|
143
|
+
expect(container.textContent).toContain('Describe')
|
|
144
|
+
expect(container.textContent).not.toContain('JSON')
|
|
145
|
+
expect(container.textContent).not.toContain('Concerns')
|
|
146
|
+
expect(container.textContent).toContain('Clean')
|
|
147
|
+
expect(container.textContent).toContain('Journal Article')
|
|
148
|
+
expect(container.textContent).toContain('Quiet Book')
|
|
149
|
+
expect(container.textContent).toContain('Draft Writer')
|
|
150
|
+
expect(container.textContent).toContain('Aa')
|
|
151
|
+
expect(container.textContent).toContain('Preset/manual only')
|
|
152
|
+
expect(
|
|
153
|
+
container.querySelector('[aria-label="Active theme swatches"]'),
|
|
154
|
+
).toBeNull()
|
|
155
|
+
expect(container.querySelector('[data-mode-count="2"]')).not.toBeNull()
|
|
156
|
+
expect(
|
|
157
|
+
container
|
|
158
|
+
.querySelector('section[aria-label="Print design"]')
|
|
159
|
+
?.getAttribute('data-density'),
|
|
160
|
+
).toBe('compact')
|
|
161
|
+
|
|
162
|
+
const selected = buttonByText(container, 'CleanAa')
|
|
163
|
+
expect(selected.getAttribute('aria-pressed')).toBe('true')
|
|
164
|
+
|
|
165
|
+
click(buttonByText(container, 'Journal ArticleAa'))
|
|
166
|
+
|
|
167
|
+
expect(onThemeChange).toHaveBeenCalledWith(
|
|
168
|
+
PURE_RENDER_THEME_PRESETS.find(preset => preset.id === 'journal-article')
|
|
169
|
+
?.theme,
|
|
170
|
+
)
|
|
171
|
+
expect(container.textContent).toContain('Ready')
|
|
172
|
+
expect(container.textContent).toContain('Journal Article preset selected')
|
|
173
|
+
expect(container.querySelector('details')).toBeNull()
|
|
174
|
+
})
|
|
175
|
+
|
|
176
|
+
it('shows beta vision typesetting controls and report', () => {
|
|
177
|
+
const onToggle = vi.fn()
|
|
178
|
+
const onExport = vi.fn()
|
|
179
|
+
const { container } = render(
|
|
180
|
+
<PrintDesignPanel
|
|
181
|
+
visionTypesetting={{
|
|
182
|
+
enabled: true,
|
|
183
|
+
status: 'Enabled with test vision.',
|
|
184
|
+
report: [
|
|
185
|
+
['pass', 'Reference pages inspected.'],
|
|
186
|
+
['apply', 'Safe print tokens compiled.'],
|
|
187
|
+
],
|
|
188
|
+
onToggle,
|
|
189
|
+
onExport,
|
|
190
|
+
}}
|
|
191
|
+
/>,
|
|
192
|
+
)
|
|
193
|
+
|
|
194
|
+
click(buttonByText(container, 'Beta vision typesetting'))
|
|
195
|
+
|
|
196
|
+
expect(container.textContent).toContain('Use beta vision typesetting')
|
|
197
|
+
expect(container.textContent).toContain('Enabled with test vision.')
|
|
198
|
+
expect(container.textContent).toContain('Reference pages inspected.')
|
|
199
|
+
|
|
200
|
+
const checkbox = container.querySelector<HTMLInputElement>(
|
|
201
|
+
'input[type="checkbox"]',
|
|
202
|
+
)
|
|
203
|
+
expect(checkbox?.checked).toBe(true)
|
|
204
|
+
act(() => {
|
|
205
|
+
checkbox?.dispatchEvent(new MouseEvent('click', { bubbles: true }))
|
|
206
|
+
})
|
|
207
|
+
expect(onToggle).toHaveBeenCalledWith(false)
|
|
208
|
+
|
|
209
|
+
click(buttonByText(container, 'Export PDF'))
|
|
210
|
+
expect(onExport).toHaveBeenCalledOnce()
|
|
211
|
+
})
|
|
212
|
+
|
|
213
|
+
it('shows a sample page inspection when beta vision has not run yet', () => {
|
|
214
|
+
const { container } = render(
|
|
215
|
+
<PrintDesignPanel
|
|
216
|
+
variant="popover"
|
|
217
|
+
visionTypesetting={{
|
|
218
|
+
enabled: false,
|
|
219
|
+
status: 'Ready for beta inspection.',
|
|
220
|
+
onToggle: vi.fn(),
|
|
221
|
+
}}
|
|
222
|
+
/>,
|
|
223
|
+
)
|
|
224
|
+
|
|
225
|
+
click(buttonByText(container, 'Beta vision typesetting'))
|
|
226
|
+
|
|
227
|
+
expect(container.textContent).toContain('Sample page snapshot')
|
|
228
|
+
expect(container.textContent).toContain('Visual preflight sample')
|
|
229
|
+
expect(container.textContent).toContain('No export inspection has run yet.')
|
|
230
|
+
expect(container.textContent).toContain(
|
|
231
|
+
'The next beta export will render with Paged.js and capture a real page snapshot.',
|
|
232
|
+
)
|
|
233
|
+
expect(
|
|
234
|
+
container.querySelector('[aria-label="Sample PDF page snapshot"]'),
|
|
235
|
+
).not.toBeNull()
|
|
236
|
+
})
|
|
237
|
+
|
|
238
|
+
it('shows a provided live beta vision snapshot instead of the sample page', () => {
|
|
239
|
+
const { container } = render(
|
|
240
|
+
<PrintDesignPanel
|
|
241
|
+
variant="popover"
|
|
242
|
+
visionTypesetting={{
|
|
243
|
+
enabled: true,
|
|
244
|
+
snapshotUrl: 'file:///tmp/pure-render-page-2.png',
|
|
245
|
+
snapshotAlt: 'Rendered PDF page 2',
|
|
246
|
+
report: [['pass', 'Rendered page 2 inspected.']],
|
|
247
|
+
}}
|
|
248
|
+
/>,
|
|
249
|
+
)
|
|
250
|
+
|
|
251
|
+
click(buttonByText(container, 'Beta vision typesetting'))
|
|
252
|
+
|
|
253
|
+
const image = container.querySelector<HTMLImageElement>(
|
|
254
|
+
'img[alt="Rendered PDF page 2"]',
|
|
255
|
+
)
|
|
256
|
+
expect(image?.getAttribute('src')).toBe(
|
|
257
|
+
'file:///tmp/pure-render-page-2.png',
|
|
258
|
+
)
|
|
259
|
+
expect(
|
|
260
|
+
container.querySelector('[aria-label="Sample PDF page snapshot"]'),
|
|
261
|
+
).toBeNull()
|
|
262
|
+
expect(container.textContent).toContain('Rendered page 2 inspected.')
|
|
263
|
+
})
|
|
264
|
+
|
|
265
|
+
it('shows multiple beta vision evidence snapshots with annotations', () => {
|
|
266
|
+
const { container } = render(
|
|
267
|
+
<PrintDesignPanel
|
|
268
|
+
variant="popover"
|
|
269
|
+
visionTypesetting={{
|
|
270
|
+
enabled: true,
|
|
271
|
+
evidence: [
|
|
272
|
+
{
|
|
273
|
+
id: 'baseline',
|
|
274
|
+
label: 'Baseline page 2',
|
|
275
|
+
imageUrl: 'preview:///tmp/baseline.png',
|
|
276
|
+
imageAlt: 'Baseline problem page',
|
|
277
|
+
note: 'A section heading is separated from its figure.',
|
|
278
|
+
tone: 'warning',
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
id: 'compact-figure',
|
|
282
|
+
label: 'Compact figure candidate page 2',
|
|
283
|
+
imageUrl: 'preview:///tmp/candidate.png',
|
|
284
|
+
imageAlt: 'Candidate problem page',
|
|
285
|
+
note: 'Candidate reduced the pre-figure blank.',
|
|
286
|
+
tone: 'candidate',
|
|
287
|
+
},
|
|
288
|
+
],
|
|
289
|
+
report: [['warn', 'A section heading appears separated.']],
|
|
290
|
+
}}
|
|
291
|
+
/>,
|
|
292
|
+
)
|
|
293
|
+
|
|
294
|
+
click(buttonByText(container, 'Beta vision typesetting'))
|
|
295
|
+
|
|
296
|
+
expect(container.textContent).toContain('Baseline page 2')
|
|
297
|
+
expect(container.textContent).toContain(
|
|
298
|
+
'A section heading is separated from its figure.',
|
|
299
|
+
)
|
|
300
|
+
expect(container.textContent).toContain('Compact figure candidate page 2')
|
|
301
|
+
expect(container.textContent).toContain(
|
|
302
|
+
'Candidate reduced the pre-figure blank.',
|
|
303
|
+
)
|
|
304
|
+
expect(container.textContent).not.toContain('Visual preflight sample')
|
|
305
|
+
expect(
|
|
306
|
+
container.querySelector('img[alt="Baseline problem page"]'),
|
|
307
|
+
).not.toBeNull()
|
|
308
|
+
expect(
|
|
309
|
+
container.querySelector('img[alt="Candidate problem page"]'),
|
|
310
|
+
).not.toBeNull()
|
|
311
|
+
})
|
|
312
|
+
|
|
313
|
+
it('shows multi-page beta vision evidence in a carousel', () => {
|
|
314
|
+
const { container } = render(
|
|
315
|
+
<PrintDesignPanel
|
|
316
|
+
variant="popover"
|
|
317
|
+
visionTypesetting={{
|
|
318
|
+
enabled: true,
|
|
319
|
+
maxFixesPerIssue: 3,
|
|
320
|
+
onMaxFixesPerIssueChange: vi.fn(),
|
|
321
|
+
evidence: [
|
|
322
|
+
{
|
|
323
|
+
id: 'baseline',
|
|
324
|
+
label: 'Baseline issue',
|
|
325
|
+
note: 'Figure moved to the next page.',
|
|
326
|
+
tone: 'warning',
|
|
327
|
+
snapshots: [
|
|
328
|
+
{
|
|
329
|
+
page: 2,
|
|
330
|
+
pageCount: 5,
|
|
331
|
+
role: 'problem',
|
|
332
|
+
imageUrl: 'preview:///tmp/page-2.png',
|
|
333
|
+
imageAlt: 'Problem page',
|
|
334
|
+
},
|
|
335
|
+
{
|
|
336
|
+
page: 3,
|
|
337
|
+
pageCount: 5,
|
|
338
|
+
role: 'figure',
|
|
339
|
+
imageUrl: 'preview:///tmp/page-3.png',
|
|
340
|
+
imageAlt: 'Figure page',
|
|
341
|
+
},
|
|
342
|
+
],
|
|
343
|
+
},
|
|
344
|
+
],
|
|
345
|
+
}}
|
|
346
|
+
/>,
|
|
347
|
+
)
|
|
348
|
+
|
|
349
|
+
click(buttonByText(container, 'Beta vision typesetting'))
|
|
350
|
+
|
|
351
|
+
expect(container.textContent).toContain('Baseline issue')
|
|
352
|
+
expect(container.textContent).toContain('Figure moved to the next page.')
|
|
353
|
+
expect(container.textContent).toContain(
|
|
354
|
+
'Baseline issue · problem · page 2 of 5',
|
|
355
|
+
)
|
|
356
|
+
expect(container.querySelector('img[alt="Problem page"]')).not.toBeNull()
|
|
357
|
+
|
|
358
|
+
click(
|
|
359
|
+
container.querySelector(
|
|
360
|
+
'button[aria-label="Next page for Baseline issue"]',
|
|
361
|
+
) as HTMLButtonElement,
|
|
362
|
+
)
|
|
363
|
+
|
|
364
|
+
expect(container.textContent).toContain(
|
|
365
|
+
'Baseline issue · figure · page 3 of 5',
|
|
366
|
+
)
|
|
367
|
+
expect(container.querySelector('img[alt="Figure page"]')).not.toBeNull()
|
|
368
|
+
})
|
|
369
|
+
|
|
370
|
+
it('shows high-level beta progress above evidence', () => {
|
|
371
|
+
const { container } = render(
|
|
372
|
+
<PrintDesignPanel
|
|
373
|
+
variant="popover"
|
|
374
|
+
visionTypesetting={{
|
|
375
|
+
enabled: true,
|
|
376
|
+
progress: {
|
|
377
|
+
state: 'running',
|
|
378
|
+
label: 'Pass 1 · Fix 1 rendering compact figure candidate',
|
|
379
|
+
},
|
|
380
|
+
}}
|
|
381
|
+
/>,
|
|
382
|
+
)
|
|
383
|
+
|
|
384
|
+
click(buttonByText(container, 'Beta vision typesetting'))
|
|
385
|
+
|
|
386
|
+
expect(container.textContent).toContain('In flight')
|
|
387
|
+
expect(container.textContent).toContain(
|
|
388
|
+
'Pass 1 · Fix 1 rendering compact figure candidate',
|
|
389
|
+
)
|
|
390
|
+
})
|
|
391
|
+
|
|
392
|
+
it('uses a workspace layout with persistent readout and vision evidence canvas', () => {
|
|
393
|
+
const { container } = render(
|
|
394
|
+
<PrintDesignPanel
|
|
395
|
+
variant="workspace"
|
|
396
|
+
visionTypesetting={{
|
|
397
|
+
enabled: true,
|
|
398
|
+
progress: {
|
|
399
|
+
state: 'running',
|
|
400
|
+
label: 'Pass 2 · checking Fix 1',
|
|
401
|
+
},
|
|
402
|
+
report: [
|
|
403
|
+
['pdf', 'Baseline PDF: /tmp/baseline.pdf'],
|
|
404
|
+
['issue', 'Issue 1: stranded heading on page 2.'],
|
|
405
|
+
['fix', 'Fix 1 rendering compact figure candidate.'],
|
|
406
|
+
],
|
|
407
|
+
evidence: [
|
|
408
|
+
{
|
|
409
|
+
id: 'issue-1',
|
|
410
|
+
label: 'Baseline page 2',
|
|
411
|
+
note: 'A section heading is separated from the figure.',
|
|
412
|
+
tone: 'warning',
|
|
413
|
+
snapshots: [
|
|
414
|
+
{
|
|
415
|
+
page: 2,
|
|
416
|
+
pageCount: 5,
|
|
417
|
+
role: 'problem',
|
|
418
|
+
imageUrl: 'preview:///tmp/page-2.png',
|
|
419
|
+
imageAlt: 'Problem page',
|
|
420
|
+
},
|
|
421
|
+
],
|
|
422
|
+
},
|
|
423
|
+
],
|
|
424
|
+
}}
|
|
425
|
+
actions={[
|
|
426
|
+
{
|
|
427
|
+
id: 'export-pdf',
|
|
428
|
+
label: 'Export PDF',
|
|
429
|
+
onClick: vi.fn(),
|
|
430
|
+
},
|
|
431
|
+
]}
|
|
432
|
+
/>,
|
|
433
|
+
)
|
|
434
|
+
|
|
435
|
+
click(buttonByText(container, 'Beta vision typesetting'))
|
|
436
|
+
|
|
437
|
+
expect(
|
|
438
|
+
container.querySelector('[data-panel-variant="workspace"]'),
|
|
439
|
+
).not.toBeNull()
|
|
440
|
+
expect(container.textContent).toContain('Design - PDF Typesetter')
|
|
441
|
+
expect(container.textContent).toContain('Clean · Justified · 34rem')
|
|
442
|
+
expect(container.textContent).toContain('In flight')
|
|
443
|
+
expect(container.textContent).toContain('Pass 2 · checking Fix 1')
|
|
444
|
+
expect(container.textContent).toContain('Beta settings')
|
|
445
|
+
expect(container.textContent).toContain('Use beta vision typesetting')
|
|
446
|
+
expect(container.textContent).toContain('Max fixes per issue')
|
|
447
|
+
expect(container.textContent).toContain('Baseline page 2')
|
|
448
|
+
expect(container.textContent).toContain('Live readout')
|
|
449
|
+
expect(container.textContent).toContain('FIX')
|
|
450
|
+
expect(container.textContent).toContain('ISSUE')
|
|
451
|
+
expect(container.textContent).toContain('PDF')
|
|
452
|
+
expect(document.head.textContent).not.toMatch(
|
|
453
|
+
/grid-template-columns:\s*minmax\(190px,\s*240px\)\s*minmax\(0,\s*1fr\)/,
|
|
454
|
+
)
|
|
455
|
+
})
|
|
456
|
+
|
|
457
|
+
it('keeps the workspace readout visible when switching away from vision', () => {
|
|
458
|
+
const { container } = render(
|
|
459
|
+
<PrintDesignPanel
|
|
460
|
+
variant="workspace"
|
|
461
|
+
visionTypesetting={{
|
|
462
|
+
enabled: true,
|
|
463
|
+
progress: {
|
|
464
|
+
state: 'running',
|
|
465
|
+
label: 'Pass 1 · inspecting baseline',
|
|
466
|
+
},
|
|
467
|
+
report: [
|
|
468
|
+
['pdf', 'PDF (Jun 18, 2026, 10:50 AM): /tmp/baseline.pdf'],
|
|
469
|
+
['issue', 'Issue 1: stranded heading on page 2.'],
|
|
470
|
+
],
|
|
471
|
+
evidence: [
|
|
472
|
+
{
|
|
473
|
+
id: 'issue-1',
|
|
474
|
+
label: 'Baseline page 2',
|
|
475
|
+
note: 'A section heading is separated from the figure.',
|
|
476
|
+
tone: 'warning',
|
|
477
|
+
snapshots: [
|
|
478
|
+
{
|
|
479
|
+
page: 2,
|
|
480
|
+
pageCount: 5,
|
|
481
|
+
role: 'problem',
|
|
482
|
+
imageUrl: 'preview:///tmp/page-2.png',
|
|
483
|
+
imageAlt: 'Problem page',
|
|
484
|
+
},
|
|
485
|
+
],
|
|
486
|
+
},
|
|
487
|
+
],
|
|
488
|
+
}}
|
|
489
|
+
/>,
|
|
490
|
+
)
|
|
491
|
+
|
|
492
|
+
click(buttonByText(container, 'Beta vision typesetting'))
|
|
493
|
+
|
|
494
|
+
expect(container.textContent).toContain('Baseline page 2')
|
|
495
|
+
|
|
496
|
+
click(buttonByText(container, 'Design'))
|
|
497
|
+
|
|
498
|
+
const readout = container.querySelector(
|
|
499
|
+
'[aria-label="Live design readout"]',
|
|
500
|
+
)
|
|
501
|
+
expect(readout?.textContent).toContain('Issue 1: stranded heading')
|
|
502
|
+
expect(readout?.textContent).toContain('baseline.pdf')
|
|
503
|
+
expect(container.textContent).not.toContain('Baseline page 2')
|
|
504
|
+
})
|
|
505
|
+
|
|
506
|
+
it('groups workspace readout entries by visual pass', () => {
|
|
507
|
+
const { container } = render(
|
|
508
|
+
<PrintDesignPanel
|
|
509
|
+
variant="workspace"
|
|
510
|
+
visionTypesetting={{
|
|
511
|
+
enabled: true,
|
|
512
|
+
report: [
|
|
513
|
+
['pdf', 'PDF (Jun 18, 2026, 10:50 AM): /tmp/baseline.pdf'],
|
|
514
|
+
['issue', 'Pass 1 · Issue 1: stranded heading on page 2.'],
|
|
515
|
+
['fix', 'Pass 1 · Fix 1: compact figure candidate.'],
|
|
516
|
+
['check', 'Pass 2 · checking downstream issue positions.'],
|
|
517
|
+
],
|
|
518
|
+
}}
|
|
519
|
+
/>,
|
|
520
|
+
)
|
|
521
|
+
|
|
522
|
+
click(buttonByText(container, 'Beta vision typesetting'))
|
|
523
|
+
|
|
524
|
+
const readout = container.querySelector(
|
|
525
|
+
'[aria-label="Live design readout"]',
|
|
526
|
+
)
|
|
527
|
+
expect(
|
|
528
|
+
readout?.querySelector('[aria-label="Pass 2 event group"]'),
|
|
529
|
+
).not.toBeNull()
|
|
530
|
+
expect(
|
|
531
|
+
readout?.querySelector('[aria-label="Pass 1 event group"]'),
|
|
532
|
+
).not.toBeNull()
|
|
533
|
+
expect(readout?.textContent).toContain('CHECK')
|
|
534
|
+
expect(readout?.textContent).toContain('FIX')
|
|
535
|
+
expect(readout?.textContent).toContain('ISSUE')
|
|
536
|
+
expect(readout?.textContent).toContain('baseline.pdf')
|
|
537
|
+
})
|
|
538
|
+
|
|
539
|
+
it('opens passed fix comparisons from evidence only when available', () => {
|
|
540
|
+
const write = vi.fn()
|
|
541
|
+
const close = vi.fn()
|
|
542
|
+
const open = vi.spyOn(window, 'open').mockReturnValue({
|
|
543
|
+
document: { write, close },
|
|
544
|
+
} as unknown as Window)
|
|
545
|
+
const { container } = render(
|
|
546
|
+
<PrintDesignPanel
|
|
547
|
+
variant="popover"
|
|
548
|
+
visionTypesetting={{
|
|
549
|
+
enabled: true,
|
|
550
|
+
report: [['fix', 'Fix 1 rendering compact figure candidate.']],
|
|
551
|
+
evidence: [
|
|
552
|
+
{
|
|
553
|
+
id: 'baseline',
|
|
554
|
+
label: 'Baseline issue',
|
|
555
|
+
note: 'Issue is still present.',
|
|
556
|
+
tone: 'warning',
|
|
557
|
+
snapshots: [
|
|
558
|
+
{
|
|
559
|
+
page: 2,
|
|
560
|
+
pageCount: 5,
|
|
561
|
+
role: 'problem',
|
|
562
|
+
imageUrl: 'preview:///tmp/baseline-page-2.png',
|
|
563
|
+
},
|
|
564
|
+
],
|
|
565
|
+
},
|
|
566
|
+
{
|
|
567
|
+
id: 'fixed',
|
|
568
|
+
label: 'Fix 1',
|
|
569
|
+
note: 'Issue resolved.',
|
|
570
|
+
tone: 'pass',
|
|
571
|
+
snapshots: [
|
|
572
|
+
{
|
|
573
|
+
page: 2,
|
|
574
|
+
pageCount: 5,
|
|
575
|
+
role: 'candidate',
|
|
576
|
+
imageUrl: 'preview:///tmp/fix-page-2.png',
|
|
577
|
+
},
|
|
578
|
+
],
|
|
579
|
+
comparison: {
|
|
580
|
+
title: 'Issue 1 · Fix 1 comparison',
|
|
581
|
+
issueLabel: 'Issue 1: stranded heading',
|
|
582
|
+
fixLabel: 'Fix 1: compact figure',
|
|
583
|
+
resultSummary: 'Resolved by compacting the figure.',
|
|
584
|
+
baseline: {
|
|
585
|
+
label: 'Baseline issue',
|
|
586
|
+
note: 'Issue is still present.',
|
|
587
|
+
pdfPath: '/tmp/baseline.pdf',
|
|
588
|
+
snapshots: [
|
|
589
|
+
{
|
|
590
|
+
page: 2,
|
|
591
|
+
pageCount: 5,
|
|
592
|
+
role: 'problem',
|
|
593
|
+
imageUrl: 'preview:///tmp/baseline-page-2.png',
|
|
594
|
+
},
|
|
595
|
+
],
|
|
596
|
+
},
|
|
597
|
+
fixed: {
|
|
598
|
+
label: 'Fix 1',
|
|
599
|
+
note: 'Issue resolved.',
|
|
600
|
+
pdfPath: '/tmp/fixed.pdf',
|
|
601
|
+
snapshots: [
|
|
602
|
+
{
|
|
603
|
+
page: 2,
|
|
604
|
+
pageCount: 5,
|
|
605
|
+
role: 'candidate',
|
|
606
|
+
imageUrl: 'preview:///tmp/fix-page-2.png',
|
|
607
|
+
},
|
|
608
|
+
],
|
|
609
|
+
},
|
|
610
|
+
},
|
|
611
|
+
},
|
|
612
|
+
],
|
|
613
|
+
}}
|
|
614
|
+
/>,
|
|
615
|
+
)
|
|
616
|
+
|
|
617
|
+
click(buttonByText(container, 'Beta vision typesetting'))
|
|
618
|
+
|
|
619
|
+
expect(container.textContent).toContain('FIX')
|
|
620
|
+
expect(container.textContent).toContain('View fix comparison')
|
|
621
|
+
expect(
|
|
622
|
+
Array.from(container.querySelectorAll('button')).filter(button =>
|
|
623
|
+
button.textContent?.includes('View fix comparison'),
|
|
624
|
+
),
|
|
625
|
+
).toHaveLength(1)
|
|
626
|
+
|
|
627
|
+
click(buttonByText(container, 'View fix comparison'))
|
|
628
|
+
|
|
629
|
+
expect(open).toHaveBeenCalledWith('', '_blank')
|
|
630
|
+
expect(write).toHaveBeenCalledWith(
|
|
631
|
+
expect.stringContaining('Issue 1 · Fix 1 comparison'),
|
|
632
|
+
)
|
|
633
|
+
expect(write).toHaveBeenCalledWith(
|
|
634
|
+
expect.stringContaining('preview:///tmp/baseline-page-2.png'),
|
|
635
|
+
)
|
|
636
|
+
expect(write).toHaveBeenCalledWith(
|
|
637
|
+
expect.stringContaining('preview:///tmp/fix-page-2.png'),
|
|
638
|
+
)
|
|
639
|
+
expect(close).toHaveBeenCalledOnce()
|
|
640
|
+
})
|
|
641
|
+
|
|
642
|
+
it('reports max beta vision fixes per issue changes', () => {
|
|
643
|
+
const onMaxFixesPerIssueChange = vi.fn()
|
|
644
|
+
const { container } = render(
|
|
645
|
+
<PrintDesignPanel
|
|
646
|
+
variant="popover"
|
|
647
|
+
visionTypesetting={{
|
|
648
|
+
enabled: true,
|
|
649
|
+
maxFixesPerIssue: 2,
|
|
650
|
+
onMaxFixesPerIssueChange,
|
|
651
|
+
}}
|
|
652
|
+
/>,
|
|
653
|
+
)
|
|
654
|
+
|
|
655
|
+
click(buttonByText(container, 'Beta vision typesetting'))
|
|
656
|
+
const input = Array.from(container.querySelectorAll('input')).find(
|
|
657
|
+
candidate => candidate.getAttribute('type') === 'number',
|
|
658
|
+
) as HTMLInputElement
|
|
659
|
+
changeInput(input, '5')
|
|
660
|
+
|
|
661
|
+
expect(onMaxFixesPerIssueChange).toHaveBeenCalledWith(5)
|
|
662
|
+
})
|
|
663
|
+
|
|
664
|
+
it('ships parseable shared presets for manuscript, book, and writer', () => {
|
|
665
|
+
expect(PURE_RENDER_THEME_PRESETS.map(preset => preset.id)).toEqual([
|
|
666
|
+
'default-manuscript',
|
|
667
|
+
'journal-article',
|
|
668
|
+
'quiet-book',
|
|
669
|
+
'classic-essay',
|
|
670
|
+
'modern-report',
|
|
671
|
+
'scholarly-book',
|
|
672
|
+
'conference-paper',
|
|
673
|
+
'draft-writer',
|
|
674
|
+
])
|
|
675
|
+
|
|
676
|
+
for (const preset of PURE_RENDER_THEME_PRESETS) {
|
|
677
|
+
expect(parsePureRenderThemeJson(JSON.stringify(preset.theme)).name).toBe(
|
|
678
|
+
preset.theme.name,
|
|
679
|
+
)
|
|
680
|
+
}
|
|
681
|
+
})
|
|
682
|
+
|
|
683
|
+
it('marks a persisted preset theme as selected after app reload', () => {
|
|
684
|
+
const reloadedPreset = PURE_RENDER_THEME_PRESETS.find(
|
|
685
|
+
preset => preset.id === 'quiet-book',
|
|
686
|
+
)
|
|
687
|
+
expect(reloadedPreset).toBeDefined()
|
|
688
|
+
|
|
689
|
+
const { container } = render(
|
|
690
|
+
<PrintDesignPanel value={reloadedPreset?.theme} />,
|
|
691
|
+
)
|
|
692
|
+
|
|
693
|
+
expect(
|
|
694
|
+
buttonByText(container, 'Quiet BookAa').getAttribute('aria-pressed'),
|
|
695
|
+
).toBe('true')
|
|
696
|
+
})
|
|
697
|
+
|
|
698
|
+
it('updates tune controls to match the selected preset theme', () => {
|
|
699
|
+
const journalPreset = PURE_RENDER_THEME_PRESETS.find(
|
|
700
|
+
preset => preset.id === 'journal-article',
|
|
701
|
+
)
|
|
702
|
+
expect(journalPreset).toBeDefined()
|
|
703
|
+
const { container } = render(<PrintDesignPanel />)
|
|
704
|
+
|
|
705
|
+
click(buttonByText(container, 'Journal ArticleAa'))
|
|
706
|
+
|
|
707
|
+
const colorInputs = Array.from(
|
|
708
|
+
container.querySelectorAll<HTMLInputElement>('input[type="color"]'),
|
|
709
|
+
)
|
|
710
|
+
expect(colorInputs[0]?.value.toLowerCase()).toBe(
|
|
711
|
+
journalPreset!.theme.color.ink.toLowerCase(),
|
|
712
|
+
)
|
|
713
|
+
expect(colorInputs[1]?.value.toLowerCase()).toBe(
|
|
714
|
+
(
|
|
715
|
+
journalPreset!.theme.color.paper ??
|
|
716
|
+
journalPreset!.theme.color.surface ??
|
|
717
|
+
'#ffffff'
|
|
718
|
+
).toLowerCase(),
|
|
719
|
+
)
|
|
720
|
+
expect(colorInputs[2]?.value.toLowerCase()).toBe(
|
|
721
|
+
journalPreset!.theme.color.accent.toLowerCase(),
|
|
722
|
+
)
|
|
723
|
+
|
|
724
|
+
const textInputs = Array.from(
|
|
725
|
+
container.querySelectorAll<HTMLInputElement>('input:not([type])'),
|
|
726
|
+
)
|
|
727
|
+
expect(textInputs[0]?.value).toBe(journalPreset!.theme.type.measure)
|
|
728
|
+
expect(textInputs[1]?.value).toBe(String(journalPreset!.theme.type.lead))
|
|
729
|
+
})
|
|
730
|
+
|
|
731
|
+
it('allows a compact density in sidebar placement for app panels', () => {
|
|
732
|
+
const { container } = render(<PrintDesignPanel density="compact" />)
|
|
733
|
+
|
|
734
|
+
expect(
|
|
735
|
+
container
|
|
736
|
+
.querySelector('section[aria-label="Print design"]')
|
|
737
|
+
?.getAttribute('data-density'),
|
|
738
|
+
).toBe('compact')
|
|
739
|
+
})
|
|
740
|
+
|
|
741
|
+
it('renders quiet busy labels for print actions', () => {
|
|
742
|
+
const { container } = render(
|
|
743
|
+
<PrintDesignPanel
|
|
744
|
+
density="compact"
|
|
745
|
+
actions={[
|
|
746
|
+
{
|
|
747
|
+
id: 'render-pdf',
|
|
748
|
+
label: 'Export PDF',
|
|
749
|
+
busyLabel: 'Rendering…',
|
|
750
|
+
busy: true,
|
|
751
|
+
onClick: vi.fn(),
|
|
752
|
+
},
|
|
753
|
+
]}
|
|
754
|
+
/>,
|
|
755
|
+
)
|
|
756
|
+
|
|
757
|
+
expect(container.textContent).toContain('Rendering…')
|
|
758
|
+
expect(container.textContent).not.toContain('Rendering...')
|
|
759
|
+
})
|
|
760
|
+
|
|
761
|
+
it('can hide extraction modes for preset/manual-only app surfaces', () => {
|
|
762
|
+
const { container } = render(
|
|
763
|
+
<PrintDesignPanel modes={['preset', 'manual', 'json']} />,
|
|
764
|
+
)
|
|
765
|
+
|
|
766
|
+
expect(container.querySelector('[data-mode-count="3"]')).not.toBeNull()
|
|
767
|
+
expect(container.textContent).toContain('Preset')
|
|
768
|
+
expect(container.textContent).toContain('Tune')
|
|
769
|
+
expect(container.textContent).toContain('JSON')
|
|
770
|
+
expect(container.textContent).not.toContain('Image')
|
|
771
|
+
expect(container.textContent).not.toContain('Describe')
|
|
772
|
+
})
|
|
773
|
+
|
|
774
|
+
it('applies manual controls as theme tokens without CSS output', () => {
|
|
775
|
+
const onThemeChange = vi.fn()
|
|
776
|
+
const { container } = render(
|
|
777
|
+
<PrintDesignPanel onThemeChange={onThemeChange} />,
|
|
778
|
+
)
|
|
779
|
+
|
|
780
|
+
const colorInputs = Array.from(
|
|
781
|
+
container.querySelectorAll<HTMLInputElement>('input[type="color"]'),
|
|
782
|
+
)
|
|
783
|
+
expect(colorInputs).toHaveLength(3)
|
|
784
|
+
changeInput(colorInputs[0]!, '#222222')
|
|
785
|
+
changeInput(colorInputs[1]!, '#ffffff')
|
|
786
|
+
changeInput(colorInputs[2]!, '#5f7f6c')
|
|
787
|
+
const textInputs = Array.from(
|
|
788
|
+
container.querySelectorAll<HTMLInputElement>('input:not([type])'),
|
|
789
|
+
)
|
|
790
|
+
changeInput(textInputs[0]!, '32rem')
|
|
791
|
+
changeInput(textInputs[1]!, '1.6')
|
|
792
|
+
const selects = Array.from(container.querySelectorAll('select'))
|
|
793
|
+
expect(selects).toHaveLength(4)
|
|
794
|
+
changeInput(selects[0]!, 'sans')
|
|
795
|
+
changeInput(selects[1]!, 'serif')
|
|
796
|
+
changeInput(selects[2]!, 'sans')
|
|
797
|
+
changeInput(selects[3]!, 'flush-left')
|
|
798
|
+
|
|
799
|
+
expect(onThemeChange).toHaveBeenCalledWith(
|
|
800
|
+
expect.objectContaining({
|
|
801
|
+
name: 'Manual Theme',
|
|
802
|
+
color: expect.objectContaining({
|
|
803
|
+
ink: '#222222',
|
|
804
|
+
paper: '#ffffff',
|
|
805
|
+
accent: '#5f7f6c',
|
|
806
|
+
}),
|
|
807
|
+
type: expect.objectContaining({
|
|
808
|
+
measure: '32rem',
|
|
809
|
+
lead: 1.6,
|
|
810
|
+
fonts: expect.objectContaining({
|
|
811
|
+
display: '"Source Sans 3", system-ui, sans-serif',
|
|
812
|
+
serif: '"Source Serif 4", Georgia, serif',
|
|
813
|
+
sans: '"Source Sans 3", system-ui, sans-serif',
|
|
814
|
+
}),
|
|
815
|
+
}),
|
|
816
|
+
setting: expect.objectContaining({
|
|
817
|
+
align: 'flush-left',
|
|
818
|
+
hyphenate: false,
|
|
819
|
+
}),
|
|
820
|
+
profile_rules: expect.objectContaining({
|
|
821
|
+
caption: expect.objectContaining({ label_style: 'small-caps' }),
|
|
822
|
+
}),
|
|
823
|
+
}),
|
|
824
|
+
)
|
|
825
|
+
expect(container.textContent).toContain(
|
|
826
|
+
'sans display, serif body, sans labels',
|
|
827
|
+
)
|
|
828
|
+
expect(container.textContent).toContain('manual controls emit theme tokens')
|
|
829
|
+
})
|
|
830
|
+
|
|
831
|
+
it('validates image type before extraction', () => {
|
|
832
|
+
const onProfileExtractRequest = vi.fn()
|
|
833
|
+
const { container } = render(
|
|
834
|
+
<PrintDesignPanel onProfileExtractRequest={onProfileExtractRequest} />,
|
|
835
|
+
)
|
|
836
|
+
|
|
837
|
+
const input =
|
|
838
|
+
container.querySelector<HTMLInputElement>('input[type="file"]')
|
|
839
|
+
expect(input).not.toBeNull()
|
|
840
|
+
Object.defineProperty(input, 'files', {
|
|
841
|
+
configurable: true,
|
|
842
|
+
value: [new File(['not image'], 'notes.txt', { type: 'text/plain' })],
|
|
843
|
+
})
|
|
844
|
+
act(() => {
|
|
845
|
+
input?.dispatchEvent(new Event('change', { bubbles: true }))
|
|
846
|
+
})
|
|
847
|
+
|
|
848
|
+
expect(container.textContent).toContain('Use PNG, JPEG, or WebP')
|
|
849
|
+
expect(
|
|
850
|
+
container.querySelector('[title="Use PNG, JPEG, or WebP"]'),
|
|
851
|
+
).not.toBeNull()
|
|
852
|
+
click(buttonByText(container, 'Choose image'))
|
|
853
|
+
expect(onProfileExtractRequest).not.toHaveBeenCalled()
|
|
854
|
+
})
|
|
855
|
+
|
|
856
|
+
it('accepts supported image filenames when the browser omits MIME type', async () => {
|
|
857
|
+
const onProfileExtractRequest = vi.fn(
|
|
858
|
+
async (): Promise<PrintStyleProfile> => ({
|
|
859
|
+
schema_version: '1.0',
|
|
860
|
+
sources: [{ id: 'mime-empty' }],
|
|
861
|
+
exemplar_quality: {
|
|
862
|
+
usable: true,
|
|
863
|
+
reason: 'test profile',
|
|
864
|
+
confidence: 0.8,
|
|
865
|
+
},
|
|
866
|
+
observations: {},
|
|
867
|
+
rules: [{ rule: 'safe image extraction', confidence: 0.8 }],
|
|
868
|
+
derived: null,
|
|
869
|
+
}),
|
|
870
|
+
)
|
|
871
|
+
const { container } = render(
|
|
872
|
+
<PrintDesignPanel onProfileExtractRequest={onProfileExtractRequest} />,
|
|
873
|
+
)
|
|
874
|
+
|
|
875
|
+
const input =
|
|
876
|
+
container.querySelector<HTMLInputElement>('input[type="file"]')
|
|
877
|
+
expect(input).not.toBeNull()
|
|
878
|
+
Object.defineProperty(input, 'files', {
|
|
879
|
+
configurable: true,
|
|
880
|
+
value: [new File(['image bytes'], 'reference.PNG', { type: '' })],
|
|
881
|
+
})
|
|
882
|
+
await act(async () => {
|
|
883
|
+
input?.dispatchEvent(new Event('change', { bubbles: true }))
|
|
884
|
+
})
|
|
885
|
+
|
|
886
|
+
expect(onProfileExtractRequest).toHaveBeenCalledWith(
|
|
887
|
+
expect.objectContaining({
|
|
888
|
+
image: expect.objectContaining({ name: 'reference.PNG' }),
|
|
889
|
+
images: [expect.objectContaining({ name: 'reference.PNG' })],
|
|
890
|
+
}),
|
|
891
|
+
)
|
|
892
|
+
expect(container.textContent).toContain('Compiled')
|
|
893
|
+
expect(container.textContent).not.toContain('Apply')
|
|
894
|
+
})
|
|
895
|
+
|
|
896
|
+
it('validates image size before extraction', () => {
|
|
897
|
+
const onProfileExtractRequest = vi.fn()
|
|
898
|
+
const { container } = render(
|
|
899
|
+
<PrintDesignPanel onProfileExtractRequest={onProfileExtractRequest} />,
|
|
900
|
+
)
|
|
901
|
+
|
|
902
|
+
const input =
|
|
903
|
+
container.querySelector<HTMLInputElement>('input[type="file"]')
|
|
904
|
+
expect(input).not.toBeNull()
|
|
905
|
+
Object.defineProperty(input, 'files', {
|
|
906
|
+
configurable: true,
|
|
907
|
+
value: [
|
|
908
|
+
new File([new Uint8Array(8 * 1024 * 1024 + 1)], 'huge.png', {
|
|
909
|
+
type: 'image/png',
|
|
910
|
+
}),
|
|
911
|
+
],
|
|
912
|
+
})
|
|
913
|
+
act(() => {
|
|
914
|
+
input?.dispatchEvent(new Event('change', { bubbles: true }))
|
|
915
|
+
})
|
|
916
|
+
|
|
917
|
+
expect(container.textContent).toContain('Image too large')
|
|
918
|
+
expect(container.querySelector('[title="Image too large"]')).not.toBeNull()
|
|
919
|
+
click(buttonByText(container, 'Choose image'))
|
|
920
|
+
expect(onProfileExtractRequest).not.toHaveBeenCalled()
|
|
921
|
+
})
|
|
922
|
+
|
|
923
|
+
it('keeps long reference image names constrained in compact image controls', async () => {
|
|
924
|
+
const { container } = render(
|
|
925
|
+
<PrintDesignPanel variant="popover" onProfileExtractRequest={vi.fn()} />,
|
|
926
|
+
)
|
|
927
|
+
|
|
928
|
+
const longName =
|
|
929
|
+
'comparative-manuscript-reference-spread-with-running-heads-tables-and-ornaments.png'
|
|
930
|
+
const input =
|
|
931
|
+
container.querySelector<HTMLInputElement>('input[type="file"]')
|
|
932
|
+
Object.defineProperty(input, 'files', {
|
|
933
|
+
configurable: true,
|
|
934
|
+
value: [new File(['fake'], longName, { type: 'image/png' })],
|
|
935
|
+
})
|
|
936
|
+
await act(async () => {
|
|
937
|
+
input?.dispatchEvent(new Event('change', { bubbles: true }))
|
|
938
|
+
})
|
|
939
|
+
|
|
940
|
+
const imageLabel = container.querySelector(`[title="${longName}"]`)
|
|
941
|
+
expect(imageLabel).not.toBeNull()
|
|
942
|
+
expect(imageLabel?.textContent).toContain(longName)
|
|
943
|
+
expect(buttonByText(container, 'Replace image')).toBeDefined()
|
|
944
|
+
expect(buttonByText(container, 'Replace image').textContent).not.toContain(
|
|
945
|
+
longName,
|
|
946
|
+
)
|
|
947
|
+
})
|
|
948
|
+
|
|
949
|
+
it('passes multiple reference images to extraction requests', async () => {
|
|
950
|
+
const onProfileExtractRequest = vi.fn(
|
|
951
|
+
async (): Promise<PrintStyleProfile> => ({
|
|
952
|
+
schema_version: '1.0',
|
|
953
|
+
sources: [{ id: 'multi-image' }],
|
|
954
|
+
exemplar_quality: {
|
|
955
|
+
usable: true,
|
|
956
|
+
reason: 'test profile',
|
|
957
|
+
confidence: 0.8,
|
|
958
|
+
},
|
|
959
|
+
observations: {},
|
|
960
|
+
rules: [{ rule: 'quiet print', confidence: 0.8 }],
|
|
961
|
+
derived: null,
|
|
962
|
+
}),
|
|
963
|
+
)
|
|
964
|
+
const { container } = render(
|
|
965
|
+
<PrintDesignPanel onProfileExtractRequest={onProfileExtractRequest} />,
|
|
966
|
+
)
|
|
967
|
+
|
|
968
|
+
const files = [
|
|
969
|
+
new File(['a'], 'spread-a.png', { type: 'image/png' }),
|
|
970
|
+
new File(['b'], 'spread-b.jpg', { type: 'image/jpeg' }),
|
|
971
|
+
]
|
|
972
|
+
const input =
|
|
973
|
+
container.querySelector<HTMLInputElement>('input[type="file"]')
|
|
974
|
+
Object.defineProperty(input, 'files', {
|
|
975
|
+
configurable: true,
|
|
976
|
+
value: files,
|
|
977
|
+
})
|
|
978
|
+
await act(async () => {
|
|
979
|
+
input?.dispatchEvent(new Event('change', { bubbles: true }))
|
|
980
|
+
})
|
|
981
|
+
|
|
982
|
+
expect(container.textContent).toContain('2 images')
|
|
983
|
+
|
|
984
|
+
expect(onProfileExtractRequest).toHaveBeenCalledWith(
|
|
985
|
+
expect.objectContaining({
|
|
986
|
+
mode: 'image',
|
|
987
|
+
image: files[0],
|
|
988
|
+
images: files,
|
|
989
|
+
}),
|
|
990
|
+
)
|
|
991
|
+
})
|
|
992
|
+
|
|
993
|
+
it('shows multi-image reference conflicts in extraction decisions', async () => {
|
|
994
|
+
const onThemeChange = vi.fn()
|
|
995
|
+
const onProfileExtractRequest = vi.fn(
|
|
996
|
+
async (): Promise<PrintStyleProfile> =>
|
|
997
|
+
reconcilePrintStyleProfiles([
|
|
998
|
+
{
|
|
999
|
+
schema_version: '1.0',
|
|
1000
|
+
sources: [{ id: 'journal-page.png' }],
|
|
1001
|
+
exemplar_quality: {
|
|
1002
|
+
usable: true,
|
|
1003
|
+
reason: 'usable',
|
|
1004
|
+
confidence: 0.82,
|
|
1005
|
+
},
|
|
1006
|
+
observations: {
|
|
1007
|
+
palette: [
|
|
1008
|
+
{
|
|
1009
|
+
role: 'surface',
|
|
1010
|
+
approx_hex: '#ffffff',
|
|
1011
|
+
confidence: 0.96,
|
|
1012
|
+
},
|
|
1013
|
+
{
|
|
1014
|
+
role: 'ink',
|
|
1015
|
+
approx_hex: '#171717',
|
|
1016
|
+
confidence: 0.84,
|
|
1017
|
+
},
|
|
1018
|
+
{
|
|
1019
|
+
role: 'accent',
|
|
1020
|
+
approx_hex: '#9a1f2e',
|
|
1021
|
+
confidence: 0.82,
|
|
1022
|
+
},
|
|
1023
|
+
],
|
|
1024
|
+
type: [
|
|
1025
|
+
{
|
|
1026
|
+
role: 'body',
|
|
1027
|
+
class: 'serif',
|
|
1028
|
+
serif_detail: 'bracketed',
|
|
1029
|
+
confidence: 0.86,
|
|
1030
|
+
},
|
|
1031
|
+
],
|
|
1032
|
+
text_setting: { alignment: 'justified', confidence: 0.82 },
|
|
1033
|
+
},
|
|
1034
|
+
rules: [{ rule: 'keep scholarly spacing', confidence: 0.8 }],
|
|
1035
|
+
derived: null,
|
|
1036
|
+
},
|
|
1037
|
+
{
|
|
1038
|
+
schema_version: '1.0',
|
|
1039
|
+
sources: [{ id: 'book-opener.png' }],
|
|
1040
|
+
exemplar_quality: {
|
|
1041
|
+
usable: true,
|
|
1042
|
+
reason: 'usable',
|
|
1043
|
+
confidence: 0.8,
|
|
1044
|
+
},
|
|
1045
|
+
observations: {
|
|
1046
|
+
palette: [
|
|
1047
|
+
{
|
|
1048
|
+
role: 'surface',
|
|
1049
|
+
approx_hex: '#ffffff',
|
|
1050
|
+
confidence: 0.96,
|
|
1051
|
+
},
|
|
1052
|
+
{
|
|
1053
|
+
role: 'ink',
|
|
1054
|
+
approx_hex: '#171717',
|
|
1055
|
+
confidence: 0.84,
|
|
1056
|
+
},
|
|
1057
|
+
{
|
|
1058
|
+
role: 'accent',
|
|
1059
|
+
approx_hex: '#174f7a',
|
|
1060
|
+
confidence: 0.8,
|
|
1061
|
+
},
|
|
1062
|
+
],
|
|
1063
|
+
type: [{ role: 'body', class: 'sans', confidence: 0.74 }],
|
|
1064
|
+
text_setting: { alignment: 'flush-left', confidence: 0.78 },
|
|
1065
|
+
},
|
|
1066
|
+
rules: [{ rule: 'keep book opener restrained', confidence: 0.72 }],
|
|
1067
|
+
derived: null,
|
|
1068
|
+
},
|
|
1069
|
+
]),
|
|
1070
|
+
)
|
|
1071
|
+
const { container } = render(
|
|
1072
|
+
<PrintDesignPanel
|
|
1073
|
+
onThemeChange={onThemeChange}
|
|
1074
|
+
onProfileExtractRequest={onProfileExtractRequest}
|
|
1075
|
+
/>,
|
|
1076
|
+
)
|
|
1077
|
+
|
|
1078
|
+
const files = [
|
|
1079
|
+
new File(['a'], 'journal-page.png', { type: 'image/png' }),
|
|
1080
|
+
new File(['b'], 'book-opener.png', { type: 'image/png' }),
|
|
1081
|
+
]
|
|
1082
|
+
const input =
|
|
1083
|
+
container.querySelector<HTMLInputElement>('input[type="file"]')
|
|
1084
|
+
Object.defineProperty(input, 'files', {
|
|
1085
|
+
configurable: true,
|
|
1086
|
+
value: files,
|
|
1087
|
+
})
|
|
1088
|
+
await act(async () => {
|
|
1089
|
+
input?.dispatchEvent(new Event('change', { bubbles: true }))
|
|
1090
|
+
})
|
|
1091
|
+
|
|
1092
|
+
expect(container.textContent).toContain('Compiled')
|
|
1093
|
+
expect(container.textContent).toContain(
|
|
1094
|
+
'Reference conflict: accent color disagrees',
|
|
1095
|
+
)
|
|
1096
|
+
expect(container.textContent).toContain(
|
|
1097
|
+
'Reference conflict: body font class disagrees',
|
|
1098
|
+
)
|
|
1099
|
+
expect(onThemeChange).toHaveBeenCalledWith(
|
|
1100
|
+
expect.objectContaining({
|
|
1101
|
+
enforced_rules: expect.not.arrayContaining([
|
|
1102
|
+
expect.stringContaining('Reference conflict:'),
|
|
1103
|
+
]),
|
|
1104
|
+
}),
|
|
1105
|
+
)
|
|
1106
|
+
})
|
|
1107
|
+
|
|
1108
|
+
it('reports extraction unavailable without blocking manual themes', () => {
|
|
1109
|
+
const onThemeChange = vi.fn()
|
|
1110
|
+
const { container } = render(
|
|
1111
|
+
<PrintDesignPanel onThemeChange={onThemeChange} />,
|
|
1112
|
+
)
|
|
1113
|
+
|
|
1114
|
+
expect(container.textContent).toContain('Preset/manual only')
|
|
1115
|
+
expect(buttonByText(container, 'Choose image').disabled).toBe(false)
|
|
1116
|
+
expect(buttonByText(container, 'Extract from description').disabled).toBe(
|
|
1117
|
+
true,
|
|
1118
|
+
)
|
|
1119
|
+
|
|
1120
|
+
const colorInputs = Array.from(
|
|
1121
|
+
container.querySelectorAll<HTMLInputElement>('input[type="color"]'),
|
|
1122
|
+
)
|
|
1123
|
+
changeInput(colorInputs[0]!, '#222222')
|
|
1124
|
+
|
|
1125
|
+
expect(onThemeChange).toHaveBeenCalledWith(
|
|
1126
|
+
expect.objectContaining({ name: 'Manual Theme' }),
|
|
1127
|
+
)
|
|
1128
|
+
})
|
|
1129
|
+
|
|
1130
|
+
it('explains provider image limits while keeping other design paths available', () => {
|
|
1131
|
+
const onThemeChange = vi.fn()
|
|
1132
|
+
const onProfileExtractRequest = vi.fn()
|
|
1133
|
+
const { container } = render(
|
|
1134
|
+
<PrintDesignPanel
|
|
1135
|
+
onThemeChange={onThemeChange}
|
|
1136
|
+
onProfileExtractRequest={onProfileExtractRequest}
|
|
1137
|
+
extractionCapability={{
|
|
1138
|
+
image: false,
|
|
1139
|
+
description: true,
|
|
1140
|
+
imageReason:
|
|
1141
|
+
'Selected model cannot read images. Presets/manual still work.',
|
|
1142
|
+
}}
|
|
1143
|
+
/>,
|
|
1144
|
+
)
|
|
1145
|
+
|
|
1146
|
+
expect(container.textContent).toContain('Preset')
|
|
1147
|
+
expect(buttonByText(container, 'Choose image').disabled).toBe(false)
|
|
1148
|
+
expect(buttonByText(container, 'Extract from description').disabled).toBe(
|
|
1149
|
+
false,
|
|
1150
|
+
)
|
|
1151
|
+
|
|
1152
|
+
const colorInputs = Array.from(
|
|
1153
|
+
container.querySelectorAll<HTMLInputElement>('input[type="color"]'),
|
|
1154
|
+
)
|
|
1155
|
+
changeInput(colorInputs[0]!, '#222222')
|
|
1156
|
+
|
|
1157
|
+
expect(onThemeChange).toHaveBeenCalledWith(
|
|
1158
|
+
expect.objectContaining({ name: 'Manual Theme' }),
|
|
1159
|
+
)
|
|
1160
|
+
expect(onProfileExtractRequest).not.toHaveBeenCalled()
|
|
1161
|
+
})
|
|
1162
|
+
|
|
1163
|
+
it('samples image colors into manual tokens even when extraction is unavailable', async () => {
|
|
1164
|
+
const onThemeChange = vi.fn()
|
|
1165
|
+
const bitmap = { close: vi.fn() }
|
|
1166
|
+
;(globalThis as { createImageBitmap?: unknown }).createImageBitmap = vi.fn(
|
|
1167
|
+
async () => bitmap,
|
|
1168
|
+
)
|
|
1169
|
+
const originalGetContext = HTMLCanvasElement.prototype.getContext
|
|
1170
|
+
vi.spyOn(HTMLCanvasElement.prototype, 'getContext').mockImplementation(((
|
|
1171
|
+
contextId: string,
|
|
1172
|
+
) => {
|
|
1173
|
+
if (contextId !== '2d')
|
|
1174
|
+
return originalGetContext.call(
|
|
1175
|
+
document.createElement('canvas'),
|
|
1176
|
+
contextId,
|
|
1177
|
+
)
|
|
1178
|
+
return {
|
|
1179
|
+
drawImage: vi.fn(),
|
|
1180
|
+
getImageData: vi.fn(() => {
|
|
1181
|
+
const data = new Uint8ClampedArray(48)
|
|
1182
|
+
data.set([16, 16, 16, 255], 0)
|
|
1183
|
+
data.set([255, 255, 255, 255], 16)
|
|
1184
|
+
data.set([120, 40, 180, 255], 32)
|
|
1185
|
+
return { data }
|
|
1186
|
+
}),
|
|
1187
|
+
} as unknown as CanvasRenderingContext2D
|
|
1188
|
+
}) as typeof HTMLCanvasElement.prototype.getContext)
|
|
1189
|
+
|
|
1190
|
+
const { container } = render(
|
|
1191
|
+
<PrintDesignPanel
|
|
1192
|
+
onThemeChange={onThemeChange}
|
|
1193
|
+
onProfileExtractRequest={vi.fn()}
|
|
1194
|
+
extractionCapability={{
|
|
1195
|
+
image: false,
|
|
1196
|
+
imageReason: 'Selected model cannot read images.',
|
|
1197
|
+
}}
|
|
1198
|
+
/>,
|
|
1199
|
+
)
|
|
1200
|
+
|
|
1201
|
+
const image = new File(['fake'], 'reference.png', { type: 'image/png' })
|
|
1202
|
+
const input =
|
|
1203
|
+
container.querySelector<HTMLInputElement>('input[type="file"]')
|
|
1204
|
+
Object.defineProperty(input, 'files', {
|
|
1205
|
+
configurable: true,
|
|
1206
|
+
value: [image],
|
|
1207
|
+
})
|
|
1208
|
+
await act(async () => {
|
|
1209
|
+
input?.dispatchEvent(new Event('change', { bubbles: true }))
|
|
1210
|
+
})
|
|
1211
|
+
|
|
1212
|
+
expect(container.textContent).toContain('Selected model cannot read images')
|
|
1213
|
+
expect(container.textContent).toContain(
|
|
1214
|
+
'accent #7828b4 from local image colors',
|
|
1215
|
+
)
|
|
1216
|
+
expect(container.querySelector('details')).toBeNull()
|
|
1217
|
+
expect(bitmap.close).toHaveBeenCalledOnce()
|
|
1218
|
+
|
|
1219
|
+
expect(onThemeChange).toHaveBeenCalledWith(
|
|
1220
|
+
expect.objectContaining({
|
|
1221
|
+
color: expect.objectContaining({
|
|
1222
|
+
ink: '#101010',
|
|
1223
|
+
paper: '#ffffff',
|
|
1224
|
+
accent: '#7828b4',
|
|
1225
|
+
}),
|
|
1226
|
+
}),
|
|
1227
|
+
)
|
|
1228
|
+
})
|
|
1229
|
+
|
|
1230
|
+
it('keeps advanced JSON mode available without replacing the quiet preset surface', () => {
|
|
1231
|
+
const onThemeChange = vi.fn()
|
|
1232
|
+
const { container } = render(
|
|
1233
|
+
<PrintDesignPanel
|
|
1234
|
+
modes={['preset', 'json']}
|
|
1235
|
+
value={DEFAULT_PURE_RENDER_THEME}
|
|
1236
|
+
onThemeChange={onThemeChange}
|
|
1237
|
+
/>,
|
|
1238
|
+
)
|
|
1239
|
+
|
|
1240
|
+
click(buttonByText(container, 'JSON'))
|
|
1241
|
+
|
|
1242
|
+
const textarea = container.querySelector('textarea')
|
|
1243
|
+
expect(textarea?.getAttribute('placeholder')).toBe('Paste theme JSON')
|
|
1244
|
+
|
|
1245
|
+
fillTextarea(textarea, JSON.stringify(DEFAULT_PURE_RENDER_THEME))
|
|
1246
|
+
|
|
1247
|
+
click(buttonByText(container, 'Use JSON'))
|
|
1248
|
+
|
|
1249
|
+
expect(onThemeChange).toHaveBeenCalledWith(DEFAULT_PURE_RENDER_THEME)
|
|
1250
|
+
expect(container.textContent).toContain('Applied')
|
|
1251
|
+
})
|
|
1252
|
+
|
|
1253
|
+
it('renders shared print workflow actions from host apps', () => {
|
|
1254
|
+
const onRenderPdf = vi.fn()
|
|
1255
|
+
const { container } = render(
|
|
1256
|
+
<PrintDesignPanel
|
|
1257
|
+
actions={[
|
|
1258
|
+
{
|
|
1259
|
+
id: 'render-pdf',
|
|
1260
|
+
label: 'Render PDF',
|
|
1261
|
+
variant: 'primary',
|
|
1262
|
+
onClick: onRenderPdf,
|
|
1263
|
+
},
|
|
1264
|
+
]}
|
|
1265
|
+
/>,
|
|
1266
|
+
)
|
|
1267
|
+
|
|
1268
|
+
click(buttonByText(container, 'Render PDF'))
|
|
1269
|
+
|
|
1270
|
+
expect(onRenderPdf).toHaveBeenCalledOnce()
|
|
1271
|
+
})
|
|
1272
|
+
|
|
1273
|
+
it('routes persistent export through beta vision when enabled', () => {
|
|
1274
|
+
const onRenderPdf = vi.fn()
|
|
1275
|
+
const onVisionExport = vi.fn()
|
|
1276
|
+
const { container } = render(
|
|
1277
|
+
<PrintDesignPanel
|
|
1278
|
+
actions={[
|
|
1279
|
+
{
|
|
1280
|
+
id: 'render-pdf',
|
|
1281
|
+
label: 'Export PDF',
|
|
1282
|
+
variant: 'primary',
|
|
1283
|
+
onClick: onRenderPdf,
|
|
1284
|
+
},
|
|
1285
|
+
]}
|
|
1286
|
+
visionTypesetting={{
|
|
1287
|
+
enabled: true,
|
|
1288
|
+
status: 'Enabled',
|
|
1289
|
+
onExport: onVisionExport,
|
|
1290
|
+
}}
|
|
1291
|
+
/>,
|
|
1292
|
+
)
|
|
1293
|
+
|
|
1294
|
+
click(buttonByText(container, 'Export PDF'))
|
|
1295
|
+
|
|
1296
|
+
expect(onVisionExport).toHaveBeenCalledOnce()
|
|
1297
|
+
expect(onRenderPdf).not.toHaveBeenCalled()
|
|
1298
|
+
})
|
|
1299
|
+
|
|
1300
|
+
it('keeps beta vision report entries in the persistent live readout', () => {
|
|
1301
|
+
const { container } = render(
|
|
1302
|
+
<PrintDesignPanel
|
|
1303
|
+
variant="popover"
|
|
1304
|
+
visionTypesetting={{
|
|
1305
|
+
enabled: true,
|
|
1306
|
+
status: 'Enabled',
|
|
1307
|
+
report: [
|
|
1308
|
+
['status', 'Vision beta is enabled.'],
|
|
1309
|
+
['apply', 'Safe print tokens will be used.'],
|
|
1310
|
+
],
|
|
1311
|
+
onToggle: vi.fn(),
|
|
1312
|
+
}}
|
|
1313
|
+
/>,
|
|
1314
|
+
)
|
|
1315
|
+
|
|
1316
|
+
expect(
|
|
1317
|
+
buttonByText(container, 'Design').getAttribute('aria-selected'),
|
|
1318
|
+
).toBe('true')
|
|
1319
|
+
const readout = container.querySelector(
|
|
1320
|
+
'[aria-label="Live design readout"]',
|
|
1321
|
+
)
|
|
1322
|
+
expect(readout?.textContent).toContain('Vision beta is enabled.')
|
|
1323
|
+
expect(readout?.textContent).toContain('Safe print tokens will be used.')
|
|
1324
|
+
expect(readout?.querySelector('details')).toBeNull()
|
|
1325
|
+
})
|
|
1326
|
+
|
|
1327
|
+
it('routes extraction through the compiler and shows decisions in the event stream', async () => {
|
|
1328
|
+
const onThemeChange = vi.fn()
|
|
1329
|
+
const onProfileExtractRequest = vi.fn(
|
|
1330
|
+
async (): Promise<PrintStyleProfile> => {
|
|
1331
|
+
return {
|
|
1332
|
+
schema_version: '1.0',
|
|
1333
|
+
sources: [{ id: 'description', note: 'test design description' }],
|
|
1334
|
+
exemplar_quality: {
|
|
1335
|
+
usable: true,
|
|
1336
|
+
reason: 'test profile',
|
|
1337
|
+
confidence: 0.9,
|
|
1338
|
+
},
|
|
1339
|
+
observations: {
|
|
1340
|
+
palette: [
|
|
1341
|
+
{
|
|
1342
|
+
role: 'ink',
|
|
1343
|
+
approx_hex: '#111111',
|
|
1344
|
+
coverage: 'frequent',
|
|
1345
|
+
where_seen: 'body text',
|
|
1346
|
+
confidence: 0.9,
|
|
1347
|
+
},
|
|
1348
|
+
{
|
|
1349
|
+
role: 'surface',
|
|
1350
|
+
approx_hex: '#ffffff',
|
|
1351
|
+
coverage: 'dominant',
|
|
1352
|
+
where_seen: 'paper',
|
|
1353
|
+
confidence: 0.9,
|
|
1354
|
+
},
|
|
1355
|
+
{
|
|
1356
|
+
role: 'accent',
|
|
1357
|
+
approx_hex: '#335f8f',
|
|
1358
|
+
coverage: 'sparse',
|
|
1359
|
+
where_seen: 'headings',
|
|
1360
|
+
confidence: 0.8,
|
|
1361
|
+
},
|
|
1362
|
+
],
|
|
1363
|
+
type: [
|
|
1364
|
+
{
|
|
1365
|
+
role: 'display',
|
|
1366
|
+
class: 'serif',
|
|
1367
|
+
serif_detail: 'hairline',
|
|
1368
|
+
confidence: 0.8,
|
|
1369
|
+
},
|
|
1370
|
+
{
|
|
1371
|
+
role: 'body',
|
|
1372
|
+
class: 'serif',
|
|
1373
|
+
serif_detail: 'bracketed',
|
|
1374
|
+
confidence: 0.8,
|
|
1375
|
+
},
|
|
1376
|
+
{ role: 'caption', class: 'sans', confidence: 0.8 },
|
|
1377
|
+
],
|
|
1378
|
+
type_pairing: { size_contrast: 'moderate', confidence: 0.8 },
|
|
1379
|
+
text_setting: {
|
|
1380
|
+
alignment: 'justified',
|
|
1381
|
+
hyphenation: 'present',
|
|
1382
|
+
measure_cpl: 62,
|
|
1383
|
+
leading_feel: 'normal',
|
|
1384
|
+
confidence: 0.8,
|
|
1385
|
+
},
|
|
1386
|
+
type_scale: {
|
|
1387
|
+
body_pt: 10.8,
|
|
1388
|
+
title_scale: 2.1,
|
|
1389
|
+
section_scale: 1.28,
|
|
1390
|
+
confidence: 0.82,
|
|
1391
|
+
},
|
|
1392
|
+
page_model: { columns: 1, confidence: 0.7 },
|
|
1393
|
+
opener: {
|
|
1394
|
+
spacing: 'generous',
|
|
1395
|
+
ornament: 'rule',
|
|
1396
|
+
confidence: 0.75,
|
|
1397
|
+
},
|
|
1398
|
+
ornaments: {
|
|
1399
|
+
kind: 'fleuron',
|
|
1400
|
+
weight: 'hairline',
|
|
1401
|
+
placement: 'chapter opener',
|
|
1402
|
+
confidence: 0.72,
|
|
1403
|
+
},
|
|
1404
|
+
},
|
|
1405
|
+
rules: [
|
|
1406
|
+
{
|
|
1407
|
+
rule: 'Use restrained rules.',
|
|
1408
|
+
evidence: 'test profile rule',
|
|
1409
|
+
confidence: 0.8,
|
|
1410
|
+
},
|
|
1411
|
+
],
|
|
1412
|
+
derived: null,
|
|
1413
|
+
}
|
|
1414
|
+
},
|
|
1415
|
+
)
|
|
1416
|
+
const { container } = render(
|
|
1417
|
+
<PrintDesignPanel
|
|
1418
|
+
onThemeChange={onThemeChange}
|
|
1419
|
+
onProfileExtractRequest={onProfileExtractRequest}
|
|
1420
|
+
/>,
|
|
1421
|
+
)
|
|
1422
|
+
|
|
1423
|
+
const textarea = container.querySelector('textarea')
|
|
1424
|
+
fillTextarea(textarea, 'scholarly but quiet')
|
|
1425
|
+
|
|
1426
|
+
await act(async () => {
|
|
1427
|
+
buttonByText(container, 'Extract from description').dispatchEvent(
|
|
1428
|
+
new MouseEvent('click', { bubbles: true }),
|
|
1429
|
+
)
|
|
1430
|
+
})
|
|
1431
|
+
|
|
1432
|
+
expect(onProfileExtractRequest).toHaveBeenCalledWith(
|
|
1433
|
+
expect.objectContaining({ mode: 'description' }),
|
|
1434
|
+
)
|
|
1435
|
+
expect(onThemeChange).toHaveBeenCalled()
|
|
1436
|
+
expect(container.textContent).toContain('Compiled')
|
|
1437
|
+
|
|
1438
|
+
expect(container.querySelector('details')).toBeNull()
|
|
1439
|
+
expect(container.textContent).toContain('licensed substitutes')
|
|
1440
|
+
expect(container.textContent).toContain('point sizes are approximate')
|
|
1441
|
+
expect(container.textContent).toContain('page geometry is approximate')
|
|
1442
|
+
expect(container.textContent).toContain('custom ornament replication')
|
|
1443
|
+
expect(container.textContent).toContain('#111111')
|
|
1444
|
+
expect(container.textContent).toContain('#335f8f')
|
|
1445
|
+
})
|
|
1446
|
+
})
|