@parallelworks/ui 0.44.0 → 0.46.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +348 -25
- package/dist/ai/agent/diff.d.ts +2 -1
- package/dist/ai/agent/diff.js +4 -12
- package/dist/ai/agent/diffHighlight.d.ts +1 -1
- package/dist/ai/agent/diffHighlight.js +4 -3
- package/dist/ai/agent/index.d.ts +2 -1
- package/dist/ai/agent/permissions.d.ts +1 -1
- package/dist/ai/agent/permissions.js +1 -1
- package/dist/ai/agent/toolStrings.d.ts +37 -0
- package/dist/ai/agent/toolStrings.js +35 -0
- package/dist/ai/agent/toolfmt.d.ts +8 -3
- package/dist/ai/agent/toolfmt.js +50 -65
- package/dist/ai/ai.css +22 -35
- package/dist/ai/components/AllocationSelector.js +2 -2
- package/dist/ai/components/AttachmentManager.js +28 -29
- package/dist/ai/components/AttachmentUpload.js +25 -30
- package/dist/ai/components/BlockedGroupBanner.js +2 -2
- package/dist/ai/components/BranchNavigator.js +3 -4
- package/dist/ai/components/ChatEmptyState.js +8 -7
- package/dist/ai/components/ChatInput.js +10 -12
- package/dist/ai/components/ChatLayout.js +3 -3
- package/dist/ai/components/ChatMessage.js +49 -61
- package/dist/ai/components/ChatMessageList.js +46 -42
- package/dist/ai/components/ChatSidebar.js +26 -34
- package/dist/ai/components/ChatStage.d.ts +1 -1
- package/dist/ai/components/ChatStage.js +2 -2
- package/dist/ai/components/ComposerChrome.js +3 -4
- package/dist/ai/components/DragOverlay.js +6 -4
- package/dist/ai/components/ModelSelector.js +14 -15
- package/dist/ai/components/PastedText.js +18 -14
- package/dist/ai/components/ProviderIssueBanner.js +3 -4
- package/dist/ai/components/Reasoning.d.ts +12 -6
- package/dist/ai/components/Reasoning.js +31 -18
- package/dist/ai/components/ShareDialog.js +25 -28
- package/dist/ai/components/SlashMenu.js +3 -3
- package/dist/ai/components/agent/ActivityLine.d.ts +0 -5
- package/dist/ai/components/agent/ActivityLine.js +17 -54
- package/dist/ai/components/agent/AgentMessageParts.js +139 -149
- package/dist/ai/components/conversationActions.js +16 -16
- package/dist/ai/core/ChatProvider.d.ts +2 -4
- package/dist/ai/core/ChatProvider.js +25 -38
- package/dist/ai/core/exportConversation.js +4 -4
- package/dist/ai/core/pasteLanguage.d.ts +1 -1
- package/dist/ai/core/pasteLanguage.js +1 -1
- package/dist/ai/core/sidebarState.d.ts +8 -6
- package/dist/ai/core/sidebarState.js +21 -28
- package/dist/ai/core/useKeyboardShortcuts.js +14 -5
- package/dist/ai/index.d.ts +4 -5
- package/dist/ai/index.js +7 -7
- package/dist/ai/strings.d.ts +14 -31
- package/dist/ai/strings.js +19 -39
- package/dist/ai/types.d.ts +0 -5
- package/dist/ai/ui/ConversationSidebar.d.ts +12 -9
- package/dist/ai/ui/ConversationSidebar.js +43 -87
- package/dist/ai/ui/Markdown.d.ts +3 -6
- package/dist/ai/ui/Markdown.js +6 -73
- package/dist/ai/ui/Notice.js +10 -12
- package/dist/ai/ui/chip.d.ts +2 -2
- package/dist/ai/ui/chip.js +1 -1
- package/dist/ai/ui/sidebar.d.ts +4 -20
- package/dist/ai/ui/sidebar.js +30 -67
- package/dist/ai/utils.d.ts +0 -1
- package/dist/ai/utils.js +1 -14
- package/dist/brandIcons.d.ts +51 -0
- package/dist/brandIcons.js +75 -0
- package/dist/components/Avatar.d.ts +3 -1
- package/dist/components/Avatar.js +34 -28
- package/dist/components/Button.d.ts +12 -7
- package/dist/components/Button.js +39 -44
- package/dist/components/Callout.js +18 -12
- package/dist/components/Card.d.ts +18 -8
- package/dist/components/Card.js +17 -6
- package/dist/components/Checkbox.d.ts +9 -0
- package/dist/components/Checkbox.js +30 -0
- package/dist/components/Combobox.d.ts +9 -1
- package/dist/components/Combobox.js +71 -44
- package/dist/components/ConfirmModal.js +11 -11
- package/dist/components/ContextMenu.d.ts +2 -8
- package/dist/components/ContextMenu.js +2 -29
- package/dist/components/CopyToClipboard.js +17 -36
- package/dist/components/CreateModal.d.ts +3 -24
- package/dist/components/CreateModal.js +46 -113
- package/dist/components/DatePicker.d.ts +31 -0
- package/dist/components/DatePicker.js +191 -0
- package/dist/components/DescriptionList.js +4 -4
- package/dist/components/Disclosure.d.ts +34 -0
- package/dist/components/Disclosure.js +46 -0
- package/dist/components/Drawer.d.ts +47 -0
- package/dist/components/Drawer.js +120 -0
- package/dist/components/EmptyState.d.ts +15 -10
- package/dist/components/EmptyState.js +13 -8
- package/dist/components/ExternalLink.d.ts +8 -0
- package/dist/components/ExternalLink.js +29 -0
- package/dist/components/Field.d.ts +70 -0
- package/dist/components/Field.js +159 -0
- package/dist/components/HoverCard.js +11 -14
- package/dist/components/IconButton.d.ts +16 -13
- package/dist/components/IconButton.js +27 -18
- package/dist/components/InfoTip.js +16 -23
- package/dist/components/Input.d.ts +10 -9
- package/dist/components/Input.js +54 -96
- package/dist/components/LetterBadge.js +2 -2
- package/dist/components/Loader.d.ts +15 -8
- package/dist/components/Loader.js +29 -19
- package/dist/components/Markdown.d.ts +7 -1
- package/dist/components/Markdown.js +2 -0
- package/dist/components/MarkdownImpl.d.ts +1 -1
- package/dist/components/MarkdownImpl.js +55 -14
- package/dist/components/Menu.js +13 -15
- package/dist/components/MenuEntries.js +11 -16
- package/dist/components/Meter.d.ts +48 -0
- package/dist/components/Meter.js +94 -0
- package/dist/components/Modal.js +11 -14
- package/dist/components/NumberInput.d.ts +25 -0
- package/dist/components/NumberInput.js +55 -0
- package/dist/components/Overview.js +12 -10
- package/dist/components/PageHeader.d.ts +2 -3
- package/dist/components/PageHeader.js +30 -21
- package/dist/components/Pagination.d.ts +27 -14
- package/dist/components/Pagination.js +86 -25
- package/dist/components/Popover.d.ts +47 -0
- package/dist/components/Popover.js +63 -0
- package/dist/components/Provider.d.ts +200 -83
- package/dist/components/Provider.js +203 -121
- package/dist/components/Radio.d.ts +1 -1
- package/dist/components/Radio.js +4 -4
- package/dist/components/RefreshButton.d.ts +15 -0
- package/dist/components/RefreshButton.js +53 -0
- package/dist/components/RunStatusIcon.d.ts +12 -0
- package/dist/components/RunStatusIcon.js +84 -0
- package/dist/components/SearchInput.d.ts +16 -0
- package/dist/components/SearchInput.js +52 -0
- package/dist/components/Section.d.ts +28 -0
- package/dist/components/Section.js +76 -0
- package/dist/components/SegmentedControl.d.ts +7 -11
- package/dist/components/SegmentedControl.js +25 -56
- package/dist/components/Select.d.ts +5 -1
- package/dist/components/Select.js +43 -44
- package/dist/components/SettingModeOption.d.ts +3 -5
- package/dist/components/SettingModeOption.js +5 -6
- package/dist/components/SettingsCard.d.ts +32 -19
- package/dist/components/SettingsCard.js +40 -13
- package/dist/components/Skeleton.d.ts +22 -0
- package/dist/components/Skeleton.js +34 -0
- package/dist/components/Slider.d.ts +16 -0
- package/dist/components/Slider.js +30 -0
- package/dist/components/Sort.js +4 -6
- package/dist/components/StatusBadge.d.ts +5 -3
- package/dist/components/StatusBadge.js +10 -33
- package/dist/components/StatusIcons.d.ts +0 -4
- package/dist/components/StatusIcons.js +5 -13
- package/dist/components/Switch.d.ts +5 -1
- package/dist/components/Switch.js +23 -6
- package/dist/components/Table.js +13 -20
- package/dist/components/Tabs.d.ts +52 -0
- package/dist/components/Tabs.js +75 -0
- package/dist/components/ThemeEditor.d.ts +29 -0
- package/dist/components/ThemeEditor.js +397 -0
- package/dist/components/Toast.d.ts +57 -0
- package/dist/components/Toast.js +203 -0
- package/dist/components/Tooltip.js +12 -15
- package/dist/components/buttonClasses.d.ts +18 -0
- package/dist/components/buttonClasses.js +31 -0
- package/dist/components/codeTheme.d.ts +5 -0
- package/dist/components/codeTheme.js +93 -0
- package/dist/components/comboboxItems.d.ts +1 -1
- package/dist/components/fieldBox.d.ts +14 -0
- package/dist/components/fieldBox.js +29 -0
- package/dist/components/floating.d.ts +26 -5
- package/dist/components/floating.js +31 -9
- package/dist/{ai/ui/codeBreaks.js → components/markdownCodeBreaks.js} +1 -1
- package/dist/components/persistedState.d.ts +2 -0
- package/dist/components/persistedState.js +63 -0
- package/dist/components/relativeTime.d.ts +36 -8
- package/dist/components/relativeTime.js +106 -23
- package/dist/components/segmented.d.ts +17 -0
- package/dist/components/segmented.js +27 -0
- package/dist/components/shortcutKey.d.ts +4 -0
- package/dist/components/shortcutKey.js +27 -0
- package/dist/components/splitter.d.ts +26 -0
- package/dist/components/splitter.js +69 -0
- package/dist/components/tone.d.ts +9 -0
- package/dist/components/tone.js +30 -0
- package/dist/components/useCopy.d.ts +14 -0
- package/dist/components/useCopy.js +31 -0
- package/dist/components/useCssIsDark.d.ts +2 -0
- package/dist/components/useCssIsDark.js +2 -1
- package/dist/components/useTheme.d.ts +10 -0
- package/dist/components/useTheme.js +40 -0
- package/dist/cx.d.ts +5 -0
- package/dist/cx.js +11 -0
- package/dist/editing.d.ts +1 -1
- package/dist/editor/Editor.js +2 -2
- package/dist/editor/EditorField.js +7 -10
- package/dist/editor/FormCodePanel.js +10 -23
- package/dist/editor/Monaco.js +7 -4
- package/dist/editor/index.d.ts +1 -1
- package/dist/editor/index.js +2 -2
- package/dist/editor/themes.d.ts +4 -0
- package/dist/editor/themes.js +75 -76
- package/dist/file-explorer/FileExplorer.js +180 -187
- package/dist/file-explorer/FileExplorerContext.js +45 -67
- package/dist/file-explorer/FilePreview/CodePreviewEditor.js +2 -1
- package/dist/file-explorer/FilePreview/Inline.js +9 -7
- package/dist/file-explorer/FilePreview/StreamedBadge.js +2 -2
- package/dist/file-explorer/FilePreview/Viewer.js +32 -34
- package/dist/file-explorer/FilePreview/index.js +60 -92
- package/dist/file-explorer/FilePreview/useObjectBlobUrl.js +4 -4
- package/dist/file-explorer/FilePreview/useObjectText.js +4 -4
- package/dist/file-explorer/FilePreview/usePresignedUrl.js +4 -4
- package/dist/file-explorer/FileRow.js +10 -15
- package/dist/file-explorer/FileRowsWindow.js +2 -6
- package/dist/file-explorer/FileTable.js +2 -2
- package/dist/file-explorer/FileTableHeaders.js +8 -11
- package/dist/file-explorer/LoadMoreRow.js +8 -9
- package/dist/file-explorer/TreeView.js +16 -16
- package/dist/file-explorer/helpers.d.ts +1 -4
- package/dist/file-explorer/helpers.js +101 -114
- package/dist/file-explorer/lib/types.d.ts +2 -2
- package/dist/file-explorer/lib/utils.d.ts +0 -2
- package/dist/file-explorer/lib/utils.js +1 -25
- package/dist/file-explorer/toasts.js +109 -190
- package/dist/form/Fields/BooleanField.js +12 -14
- package/dist/form/Fields/CheckboxGroupField.d.ts +1 -1
- package/dist/form/Fields/CheckboxGroupField.js +16 -18
- package/dist/form/Fields/ColorField.js +11 -11
- package/dist/form/Fields/DropdownField.d.ts +1 -1
- package/dist/form/Fields/DropdownField.js +20 -36
- package/dist/form/Fields/DurationField.d.ts +1 -1
- package/dist/form/Fields/DurationField.js +36 -50
- package/dist/form/Fields/LabelField.js +2 -2
- package/dist/form/Fields/MultiDropdownField.d.ts +1 -1
- package/dist/form/Fields/MultiDropdownField.js +9 -14
- package/dist/form/Fields/NumberField.d.ts +1 -1
- package/dist/form/Fields/NumberField.js +13 -48
- package/dist/form/Fields/ObjectField.js +3 -3
- package/dist/form/Fields/RadioField.d.ts +1 -1
- package/dist/form/Fields/RadioField.js +15 -18
- package/dist/form/Fields/RangeField.js +34 -35
- package/dist/form/Fields/StringField.d.ts +1 -1
- package/dist/form/Fields/StringField.js +15 -25
- package/dist/form/Fields/TextAreaField.js +10 -15
- package/dist/form/Form.d.ts +7 -2
- package/dist/form/Form.js +144 -49
- package/dist/form/FormLayout.js +18 -12
- package/dist/form/Wizard/WizardContainer.js +44 -18
- package/dist/form/Wizard/WizardNavigation.d.ts +1 -1
- package/dist/form/Wizard/WizardNavigation.js +31 -56
- package/dist/form/Wizard/WizardStepIndicator.d.ts +3 -0
- package/dist/form/Wizard/WizardStepIndicator.js +98 -114
- package/dist/form/Wizard/types.d.ts +2 -2
- package/dist/form/fieldFrame.d.ts +7 -0
- package/dist/form/fieldFrame.js +19 -0
- package/dist/form/index.d.ts +5 -5
- package/dist/form/index.js +4 -6
- package/dist/form/layoutCSS.js +5 -4
- package/dist/form/types/fieldComponentTypes.d.ts +5 -3
- package/dist/form/useChoiceField.js +2 -3
- package/dist/form/useFieldValue.d.ts +3 -0
- package/dist/form/useFieldValue.js +24 -7
- package/dist/form/utils/duration.d.ts +2 -2
- package/dist/form/utils/duration.js +3 -3
- package/dist/form/utils/fieldItems.d.ts +1 -1
- package/dist/form/utils/fieldPath.d.ts +5 -3
- package/dist/form/utils/fieldPath.js +18 -3
- package/dist/form/utils/secondaryField.d.ts +0 -7
- package/dist/form/utils/secondaryField.js +1 -12
- package/dist/form/validation.d.ts +29 -0
- package/dist/form/validation.js +14 -0
- package/dist/format.d.ts +28 -0
- package/dist/format.js +64 -0
- package/dist/graph/AnnotationBanner.js +20 -31
- package/dist/graph/Connectors.js +1 -1
- package/dist/graph/DependencyGraph.js +51 -65
- package/dist/graph/GraphEditor.js +24 -28
- package/dist/graph/GraphEditorDialogs.js +239 -245
- package/dist/graph/InputDialog.js +93 -112
- package/dist/graph/InputsEditor.js +83 -84
- package/dist/graph/JobSummary.js +10 -11
- package/dist/graph/MatrixGroup.js +3 -3
- package/dist/graph/ProblemsButton.js +9 -10
- package/dist/graph/ShortcutsButton.js +12 -17
- package/dist/graph/SuggestionInput.d.ts +2 -3
- package/dist/graph/SuggestionInput.js +2 -4
- package/dist/graph/TreeView.js +47 -45
- package/dist/graph/WorkflowSettingsDialog.js +97 -102
- package/dist/graph/editorChrome.js +10 -12
- package/dist/graph/editorFields.d.ts +19 -16
- package/dist/graph/editorFields.js +97 -135
- package/dist/graph/editorPrimitives.d.ts +2 -2
- package/dist/graph/editorPrimitives.js +3 -3
- package/dist/graph/editorRows.js +22 -25
- package/dist/graph/editorStrings.d.ts +18 -21
- package/dist/graph/editorStrings.js +15 -27
- package/dist/graph/fieldProblems.js +2 -2
- package/dist/graph/graphEditorState.d.ts +4 -4
- package/dist/graph/inputRefs.d.ts +0 -13
- package/dist/graph/inputRefs.js +122 -160
- package/dist/graph/settingsViews.js +5 -3
- package/dist/graph/stepWith.js +100 -100
- package/dist/graph/toolbarPanel.d.ts +8 -0
- package/dist/graph/toolbarPanel.js +11 -0
- package/dist/icons.d.ts +234 -23
- package/dist/icons.js +249 -264
- package/dist/index.d.ts +38 -21
- package/dist/index.js +42 -21
- package/dist/list/ActionToolbar.d.ts +1 -5
- package/dist/list/ActionToolbar.js +21 -20
- package/dist/list/ListPage.js +7 -7
- package/dist/list/ListTable.d.ts +3 -2
- package/dist/list/ListTable.js +33 -29
- package/dist/list/ListViewControls.d.ts +0 -17
- package/dist/list/ListViewControls.js +50 -118
- package/dist/list/UserHoverCard.js +24 -32
- package/dist/list/index.d.ts +2 -4
- package/dist/list/index.js +3 -5
- package/dist/list/listSearch.d.ts +1 -1
- package/dist/list/listSearch.js +19 -14
- package/dist/list/rowMenu.js +20 -26
- package/dist/logviewer/LogViewer.js +268 -382
- package/dist/logviewer/logviewer.css +53 -41
- package/dist/logviewer/segments.d.ts +1 -1
- package/dist/logviewer/segments.js +1 -1
- package/dist/styles/base.css +16 -40
- package/dist/styles/theme.css +75 -106
- package/dist/styles.css +1 -1
- package/dist/theme/color.d.ts +40 -0
- package/dist/theme/color.js +228 -0
- package/dist/theme/contrast.d.ts +42 -0
- package/dist/theme/contrast.js +145 -0
- package/dist/theme/derive.d.ts +25 -0
- package/dist/theme/derive.js +475 -0
- package/dist/theme/fit.d.ts +35 -0
- package/dist/theme/fit.js +185 -0
- package/dist/theme/index.d.ts +14 -29
- package/dist/theme/index.js +20 -279
- package/dist/theme/model.d.ts +64 -0
- package/dist/theme/model.js +219 -0
- package/package.json +9 -5
- package/dist/ai/ui/Avatar.d.ts +0 -7
- package/dist/ai/ui/Avatar.js +0 -24
- package/dist/components/Filter.d.ts +0 -15
- package/dist/components/Filter.js +0 -32
- package/dist/components/FilterPill.d.ts +0 -7
- package/dist/components/FilterPill.js +0 -14
- package/dist/components/Indicator.d.ts +0 -4
- package/dist/components/Indicator.js +0 -44
- package/dist/components/SectionHeader.d.ts +0 -8
- package/dist/components/SectionHeader.js +0 -11
- package/dist/components/SettingRow.d.ts +0 -18
- package/dist/components/SettingRow.js +0 -35
- package/dist/components/SettingsGroup.d.ts +0 -8
- package/dist/components/SettingsGroup.js +0 -17
- package/dist/components/ghostButton.d.ts +0 -4
- package/dist/components/ghostButton.js +0 -7
- package/dist/components/inputClasses.d.ts +0 -1
- package/dist/components/inputClasses.js +0 -4
- package/dist/duration.d.ts +0 -3
- package/dist/duration.js +0 -17
- package/dist/form/FieldGroup.d.ts +0 -11
- package/dist/form/FieldGroup.js +0 -36
- package/dist/form/FieldWrapper.d.ts +0 -16
- package/dist/form/FieldWrapper.js +0 -55
- package/dist/form/fieldContext.d.ts +0 -19
- package/dist/form/fieldContext.js +0 -26
- package/dist/graph/Collapse.d.ts +0 -7
- package/dist/graph/Collapse.js +0 -15
- package/dist/graph/ToolbarPopover.d.ts +0 -13
- package/dist/graph/ToolbarPopover.js +0 -39
- package/dist/icons/ai/AiOutlineRollback.js +0 -16
- package/dist/icons/bi/BiBell.js +0 -16
- package/dist/icons/bi/BiBellOff.js +0 -16
- package/dist/icons/bi/BiBuildings.js +0 -20
- package/dist/icons/bi/BiError.js +0 -20
- package/dist/icons/bi/BiExpandVertical.js +0 -16
- package/dist/icons/bi/BiPause.js +0 -16
- package/dist/icons/bi/BiPlay.js +0 -16
- package/dist/icons/bi/BiRedo.js +0 -16
- package/dist/icons/bi/BiSolidCheckShield.js +0 -16
- package/dist/icons/bi/BiSolidTrashAlt.js +0 -16
- package/dist/icons/bi/BiStop.js +0 -16
- package/dist/icons/bi/BiUndo.js +0 -16
- package/dist/icons/bs/BsArrowsCollapse.js +0 -22
- package/dist/icons/bs/BsBank2.js +0 -19
- package/dist/icons/bs/BsBriefcase.js +0 -19
- package/dist/icons/bs/BsBucket.js +0 -19
- package/dist/icons/bs/BsCalendarX.js +0 -23
- package/dist/icons/bs/BsChatLeft.js +0 -19
- package/dist/icons/bs/BsChevronDoubleDown.js +0 -29
- package/dist/icons/bs/BsChevronDoubleUp.js +0 -29
- package/dist/icons/bs/BsClipboardCheck.js +0 -34
- package/dist/icons/bs/BsCurrencyDollar.js +0 -19
- package/dist/icons/bs/BsDash.js +0 -19
- package/dist/icons/bs/BsFileEarmarkZip.js +0 -23
- package/dist/icons/bs/BsFiles.js +0 -19
- package/dist/icons/bs/BsGeoAlt.js +0 -23
- package/dist/icons/bs/BsGrid.js +0 -19
- package/dist/icons/bs/BsLayers.js +0 -19
- package/dist/icons/bs/BsLayoutThreeColumns.js +0 -19
- package/dist/icons/bs/BsListUl.js +0 -22
- package/dist/icons/bs/BsMortarboard.js +0 -23
- package/dist/icons/bs/BsMusicNoteBeamed.js +0 -34
- package/dist/icons/bs/BsOpenai.js +0 -19
- package/dist/icons/bs/BsPersonPlus.js +0 -26
- package/dist/icons/bs/BsSearch.js +0 -19
- package/dist/icons/bs/BsSend.js +0 -19
- package/dist/icons/bs/BsShieldSlash.js +0 -22
- package/dist/icons/bs/BsStar.js +0 -19
- package/dist/icons/bs/BsStarFill.js +0 -19
- package/dist/icons/bs/BsStopCircle.js +0 -23
- package/dist/icons/bs/BsTag.js +0 -23
- package/dist/icons/bs/BsTelephone.js +0 -19
- package/dist/icons/bs/BsTerminal.js +0 -23
- package/dist/icons/bs/BsTerminalFill.js +0 -19
- package/dist/icons/bs/BsThreeDots.js +0 -19
- package/dist/icons/bs/BsThreeDotsVertical.js +0 -19
- package/dist/icons/bs/BsZoomIn.js +0 -37
- package/dist/icons/fa/FaAmazon.js +0 -16
- package/dist/icons/fa/FaAngleDown.js +0 -16
- package/dist/icons/fa/FaAngleLeft.js +0 -16
- package/dist/icons/fa/FaAngleRight.js +0 -16
- package/dist/icons/fa/FaAngleUp.js +0 -16
- package/dist/icons/fa/FaArrowDown.js +0 -16
- package/dist/icons/fa/FaArrowLeft.js +0 -16
- package/dist/icons/fa/FaArrowRight.js +0 -16
- package/dist/icons/fa/FaArrowUp.js +0 -16
- package/dist/icons/fa/FaBalanceScale.js +0 -16
- package/dist/icons/fa/FaCaretDown.js +0 -16
- package/dist/icons/fa/FaCentos.js +0 -16
- package/dist/icons/fa/FaChartLine.js +0 -16
- package/dist/icons/fa/FaChartPie.js +0 -16
- package/dist/icons/fa/FaCheck.js +0 -16
- package/dist/icons/fa/FaChevronDown.js +0 -16
- package/dist/icons/fa/FaChevronUp.js +0 -16
- package/dist/icons/fa/FaChrome.js +0 -16
- package/dist/icons/fa/FaCircleNotch.js +0 -16
- package/dist/icons/fa/FaCloud.js +0 -16
- package/dist/icons/fa/FaCloudDownloadAlt.js +0 -16
- package/dist/icons/fa/FaCog.js +0 -16
- package/dist/icons/fa/FaCogs.js +0 -16
- package/dist/icons/fa/FaComments.js +0 -16
- package/dist/icons/fa/FaCompress.js +0 -16
- package/dist/icons/fa/FaDesktop.js +0 -16
- package/dist/icons/fa/FaDocker.js +0 -16
- package/dist/icons/fa/FaDollarSign.js +0 -16
- package/dist/icons/fa/FaEdge.js +0 -16
- package/dist/icons/fa/FaEdit.js +0 -16
- package/dist/icons/fa/FaExclamationTriangle.js +0 -16
- package/dist/icons/fa/FaExpand.js +0 -16
- package/dist/icons/fa/FaEye.js +0 -16
- package/dist/icons/fa/FaEyeSlash.js +0 -16
- package/dist/icons/fa/FaFile.js +0 -16
- package/dist/icons/fa/FaFilePdf.js +0 -16
- package/dist/icons/fa/FaFilter.js +0 -16
- package/dist/icons/fa/FaFirefoxBrowser.js +0 -16
- package/dist/icons/fa/FaFlask.js +0 -16
- package/dist/icons/fa/FaFolder.js +0 -16
- package/dist/icons/fa/FaGithub.js +0 -16
- package/dist/icons/fa/FaGitlab.js +0 -16
- package/dist/icons/fa/FaGlobe.js +0 -16
- package/dist/icons/fa/FaGlobeAmericas.js +0 -16
- package/dist/icons/fa/FaImage.js +0 -16
- package/dist/icons/fa/FaInfoCircle.js +0 -16
- package/dist/icons/fa/FaKey.js +0 -16
- package/dist/icons/fa/FaLayerGroup.js +0 -16
- package/dist/icons/fa/FaLink.js +0 -16
- package/dist/icons/fa/FaLinkedin.js +0 -16
- package/dist/icons/fa/FaLinux.js +0 -16
- package/dist/icons/fa/FaList.js +0 -16
- package/dist/icons/fa/FaLock.js +0 -16
- package/dist/icons/fa/FaOpenid.js +0 -16
- package/dist/icons/fa/FaOpera.js +0 -16
- package/dist/icons/fa/FaPaperclip.js +0 -16
- package/dist/icons/fa/FaPlus.js +0 -16
- package/dist/icons/fa/FaPowerOff.js +0 -16
- package/dist/icons/fa/FaPrint.js +0 -16
- package/dist/icons/fa/FaQrcode.js +0 -16
- package/dist/icons/fa/FaQuestionCircle.js +0 -16
- package/dist/icons/fa/FaRedhat.js +0 -16
- package/dist/icons/fa/FaRegCircle.js +0 -16
- package/dist/icons/fa/FaRegFileImage.js +0 -16
- package/dist/icons/fa/FaRegFolder.js +0 -16
- package/dist/icons/fa/FaRobot.js +0 -16
- package/dist/icons/fa/FaRocket.js +0 -16
- package/dist/icons/fa/FaRunning.js +0 -16
- package/dist/icons/fa/FaSafari.js +0 -16
- package/dist/icons/fa/FaSave.js +0 -16
- package/dist/icons/fa/FaSearch.js +0 -16
- package/dist/icons/fa/FaShieldAlt.js +0 -16
- package/dist/icons/fa/FaSlack.js +0 -16
- package/dist/icons/fa/FaStar.js +0 -16
- package/dist/icons/fa/FaStop.js +0 -16
- package/dist/icons/fa/FaSuse.js +0 -16
- package/dist/icons/fa/FaTerminal.js +0 -16
- package/dist/icons/fa/FaTimes.js +0 -16
- package/dist/icons/fa/FaUbuntu.js +0 -16
- package/dist/icons/fa/FaUndoAlt.js +0 -16
- package/dist/icons/fa/FaUnlink.js +0 -16
- package/dist/icons/fa/FaUser.js +0 -16
- package/dist/icons/fa/FaUsers.js +0 -16
- package/dist/icons/fa/FaWindows.js +0 -16
- package/dist/icons/fa6/FaApple.js +0 -16
- package/dist/icons/fa6/FaArrowsRotate.js +0 -16
- package/dist/icons/fa6/FaDebian.js +0 -16
- package/dist/icons/fa6/FaFilterCircleXmark.js +0 -16
- package/dist/icons/fa6/FaInbox.js +0 -16
- package/dist/icons/fa6/FaLocationDot.js +0 -16
- package/dist/icons/fa6/FaRegFilePdf.js +0 -16
- package/dist/icons/fa6/FaRegFolderOpen.js +0 -16
- package/dist/icons/fa6/FaUpRightFromSquare.js +0 -16
- package/dist/icons/fa6/FaWandMagicSparkles.js +0 -16
- package/dist/icons/fa6/FaXTwitter.js +0 -16
- package/dist/icons/fi/FiActivity.js +0 -23
- package/dist/icons/fi/FiAlertCircle.js +0 -49
- package/dist/icons/fi/FiChevronDown.js +0 -23
- package/dist/icons/fi/FiClock.js +0 -31
- package/dist/icons/fi/FiCopy.js +0 -34
- package/dist/icons/fi/FiDownload.js +0 -40
- package/dist/icons/fi/FiFile.js +0 -27
- package/dist/icons/fi/FiFileText.js +0 -55
- package/dist/icons/fi/FiHardDrive.js +0 -55
- package/dist/icons/fi/FiRotateCcw.js +0 -27
- package/dist/icons/fi/FiUpload.js +0 -40
- package/dist/icons/fi/FiX.js +0 -37
- package/dist/icons/fi/FiZap.js +0 -23
- package/dist/icons/gi/GiSpy.js +0 -16
- package/dist/icons/go/GoGitCommit.js +0 -16
- package/dist/icons/go/GoGitPullRequest.js +0 -20
- package/dist/icons/go/GoIssueOpened.js +0 -16
- package/dist/icons/go/GoPlus.js +0 -16
- package/dist/icons/go/GoRepoForked.js +0 -28
- package/dist/icons/go/GoSignOut.js +0 -16
- package/dist/icons/go/GoSkip.js +0 -20
- package/dist/icons/go/GoVideo.js +0 -20
- package/dist/icons/gr/GrCloudComputer.js +0 -20
- package/dist/icons/gr/GrInbox.js +0 -20
- package/dist/icons/gr/GrServerCluster.js +0 -20
- package/dist/icons/gr/GrStorage.js +0 -20
- package/dist/icons/gr/GrTasks.js +0 -20
- package/dist/icons/hi/HiCog.js +0 -24
- package/dist/icons/hi/HiDuplicate.js +0 -24
- package/dist/icons/hi/HiOutlineArchive.js +0 -26
- package/dist/icons/hi/HiOutlineClipboardCopy.js +0 -26
- package/dist/icons/hi/HiOutlineHome.js +0 -26
- package/dist/icons/hi/HiQuestionMarkCircle.js +0 -24
- package/dist/icons/hi/HiServer.js +0 -24
- package/dist/icons/hi2/HiMiniCheckCircle.js +0 -24
- package/dist/icons/hi2/HiMiniLanguage.js +0 -28
- package/dist/icons/hi2/HiMiniMinusCircle.js +0 -24
- package/dist/icons/hi2/HiMiniXCircle.js +0 -24
- package/dist/icons/hi2/HiSparkles.js +0 -24
- package/dist/icons/im/ImSpinner5.js +0 -19
- package/dist/icons/io/IoIosNotifications.js +0 -16
- package/dist/icons/io/IoMdBuild.js +0 -16
- package/dist/icons/io/IoMdClose.js +0 -16
- package/dist/icons/io5/IoCloudUploadOutline.js +0 -32
- package/dist/icons/io5/IoDocumentTextOutline.js +0 -31
- package/dist/icons/io5/IoFileTrayFullOutline.js +0 -31
- package/dist/icons/io5/IoHeart.js +0 -16
- package/dist/icons/io5/IoHeartDislike.js +0 -16
- package/dist/icons/io5/IoHeartOutline.js +0 -22
- package/dist/icons/io5/IoInformationCircleOutline.js +0 -50
- package/dist/icons/io5/IoSettingsOutline.js +0 -22
- package/dist/icons/io5/IoWarningOutline.js +0 -40
- package/dist/icons/lu/LuArrowRight.js +0 -27
- package/dist/icons/lu/LuBadgeCheck.js +0 -27
- package/dist/icons/lu/LuBraces.js +0 -27
- package/dist/icons/lu/LuBrainCircuit.js +0 -101
- package/dist/icons/lu/LuCalendar.js +0 -46
- package/dist/icons/lu/LuCheck.js +0 -23
- package/dist/icons/lu/LuChevronLeft.js +0 -23
- package/dist/icons/lu/LuChevronRight.js +0 -23
- package/dist/icons/lu/LuCode.js +0 -27
- package/dist/icons/lu/LuExternalLink.js +0 -35
- package/dist/icons/lu/LuEye.js +0 -31
- package/dist/icons/lu/LuEyeOff.js +0 -40
- package/dist/icons/lu/LuFolderTree.js +0 -40
- package/dist/icons/lu/LuIdCard.js +0 -55
- package/dist/icons/lu/LuKeyboard.js +0 -71
- package/dist/icons/lu/LuLogs.js +0 -65
- package/dist/icons/lu/LuMail.js +0 -33
- package/dist/icons/lu/LuMegaphone.js +0 -27
- package/dist/icons/lu/LuMoon.js +0 -23
- package/dist/icons/lu/LuNetwork.js +0 -63
- package/dist/icons/lu/LuPartyPopper.js +0 -65
- package/dist/icons/lu/LuSettings2.js +0 -48
- package/dist/icons/lu/LuSheet.js +0 -72
- package/dist/icons/lu/LuShield.js +0 -23
- package/dist/icons/lu/LuSun.js +0 -69
- package/dist/icons/lu/LuTextCursorInput.js +0 -45
- package/dist/icons/lu/LuX.js +0 -27
- package/dist/icons/lu/LuZoomIn.js +0 -59
- package/dist/icons/lu/LuZoomOut.js +0 -49
- package/dist/icons/md/MdClear.js +0 -23
- package/dist/icons/md/MdDragHandle.js +0 -23
- package/dist/icons/md/MdInstallDesktop.js +0 -31
- package/dist/icons/md/MdOutlineAttachMoney.js +0 -23
- package/dist/icons/md/MdOutlineMoneyOff.js +0 -23
- package/dist/icons/md/MdPieChart.js +0 -23
- package/dist/icons/md/MdRefresh.js +0 -23
- package/dist/icons/md/MdReplay.js +0 -23
- package/dist/icons/md/MdSmartphone.js +0 -23
- package/dist/icons/pi/PiArrowBendUpRightBold.js +0 -19
- package/dist/icons/pi/PiPlugsConnectedFill.js +0 -19
- package/dist/icons/pi/PiRectangleDashed.js +0 -19
- package/dist/icons/pi/PiShareBold.js +0 -19
- package/dist/icons/si/SiAnthropic.js +0 -19
- package/dist/icons/si/SiHelm.js +0 -19
- package/dist/icons/si/SiKubernetes.js +0 -19
- package/dist/icons/tb/TbAlertTriangle.js +0 -35
- package/dist/icons/tb/TbAlertTriangleFilled.js +0 -19
- package/dist/icons/tb/TbApi.js +0 -40
- package/dist/icons/tb/TbBrain.js +0 -50
- package/dist/icons/tb/TbBuildingTunnel.js +0 -65
- package/dist/icons/tb/TbEdit.js +0 -35
- package/dist/icons/tb/TbLayoutSidebar.js +0 -27
- package/dist/icons/tb/TbLayoutSidebarLeftCollapse.js +0 -35
- package/dist/icons/tb/TbLayoutSidebarRightCollapse.js +0 -35
- package/dist/icons/tb/TbUser.js +0 -27
- package/dist/icons/tb/TbUserOff.js +0 -35
- package/dist/icons/tb/TbWorldShare.js +0 -55
- package/dist/icons/tb/TbWorldWww.js +0 -65
- package/dist/icons/ti/TiArrowSortedDown.js +0 -20
- package/dist/icons/ti/TiArrowSortedUp.js +0 -20
- package/dist/icons/ti/TiArrowUnsorted.js +0 -20
- package/dist/icons/ti/TiCancel.js +0 -20
- package/dist/icons/vsc/VscChromeMinimize.js +0 -19
- package/dist/icons/vsc/VscJson.js +0 -19
- package/dist/icons/vsc/VscLayoutSidebarLeft.js +0 -19
- package/dist/icons/vsc/VscPass.js +0 -27
- package/dist/icons/vsc/VscSplitHorizontal.js +0 -19
- package/dist/icons/vsc/VscTerminalPowershell.js +0 -19
- package/dist/list/ListPager.d.ts +0 -14
- package/dist/list/ListPager.js +0 -62
- package/dist/list/textEntry.d.ts +0 -2
- package/dist/list/textEntry.js +0 -10
- /package/dist/{ai/ui/codeBreaks.d.ts → components/markdownCodeBreaks.d.ts} +0 -0
|
@@ -0,0 +1,475 @@
|
|
|
1
|
+
import { JND, deltaE, mixOklab, oklch, rendered, toHex, toP3, withAlpha } from "./color.js";
|
|
2
|
+
import { contrastRatio, isDarkColor, meets, meetsIn, over, shown, solve } from "./contrast.js";
|
|
3
|
+
import "./model.js";
|
|
4
|
+
//#region src/theme/derive.ts
|
|
5
|
+
var THEME_TOKENS = [
|
|
6
|
+
"--theme-app-bg",
|
|
7
|
+
"--theme-panel-bg",
|
|
8
|
+
"--theme-panel-hover",
|
|
9
|
+
"--theme-muted-panel-bg",
|
|
10
|
+
"--theme-hover",
|
|
11
|
+
"--theme-input-bg",
|
|
12
|
+
"--theme-input-disabled-bg",
|
|
13
|
+
"--theme-app",
|
|
14
|
+
"--theme-muted-text-color",
|
|
15
|
+
"--theme-placeholder",
|
|
16
|
+
"--theme-link",
|
|
17
|
+
"--theme-border",
|
|
18
|
+
"--theme-border-strong",
|
|
19
|
+
"--theme-accent",
|
|
20
|
+
"--theme-accent-text",
|
|
21
|
+
"--theme-accent-hover",
|
|
22
|
+
"--theme-accent-subtle",
|
|
23
|
+
"--theme-focus",
|
|
24
|
+
"--theme-focus-ring",
|
|
25
|
+
"--theme-success",
|
|
26
|
+
"--theme-success-muted",
|
|
27
|
+
"--theme-error",
|
|
28
|
+
"--theme-error-muted",
|
|
29
|
+
"--theme-warning",
|
|
30
|
+
"--theme-warning-muted",
|
|
31
|
+
"--theme-info",
|
|
32
|
+
"--theme-info-muted",
|
|
33
|
+
"--theme-favorite",
|
|
34
|
+
"--theme-favorite-muted",
|
|
35
|
+
"--theme-shadow-sm",
|
|
36
|
+
"--theme-shadow",
|
|
37
|
+
"--theme-shadow-lg",
|
|
38
|
+
"--theme-shadow-xl",
|
|
39
|
+
"--theme-sidebar-bg",
|
|
40
|
+
"--theme-sidebar-text",
|
|
41
|
+
"--theme-sidebar-hover",
|
|
42
|
+
"--theme-sidebar-active-bg",
|
|
43
|
+
"--theme-sidebar-active-text",
|
|
44
|
+
"--theme-code-bg",
|
|
45
|
+
"--theme-code-text",
|
|
46
|
+
"--theme-code-comment",
|
|
47
|
+
"--theme-code-keyword",
|
|
48
|
+
"--theme-code-string",
|
|
49
|
+
"--theme-code-number",
|
|
50
|
+
"--theme-code-function",
|
|
51
|
+
"--theme-code-type",
|
|
52
|
+
"--theme-code-property",
|
|
53
|
+
"--theme-ansi-black",
|
|
54
|
+
"--theme-ansi-red",
|
|
55
|
+
"--theme-ansi-green",
|
|
56
|
+
"--theme-ansi-yellow",
|
|
57
|
+
"--theme-ansi-blue",
|
|
58
|
+
"--theme-ansi-magenta",
|
|
59
|
+
"--theme-ansi-cyan",
|
|
60
|
+
"--theme-ansi-white"
|
|
61
|
+
];
|
|
62
|
+
/** The tokens the sidebar owns. A host's chrome may supply its own fallbacks, so the stylesheet gives them no defaults. */
|
|
63
|
+
var SIDEBAR_TOKENS = THEME_TOKENS.filter((t) => t.startsWith("--theme-sidebar-"));
|
|
64
|
+
var clamp = (v, lo, hi) => Math.min(hi, Math.max(lo, v));
|
|
65
|
+
/** Between the values at contrast 0, 30 (the default) and 100. */
|
|
66
|
+
/**
|
|
67
|
+
* The color text starts from on a surface, before its lightness is solved. Dark text on a tinted light
|
|
68
|
+
* surface carries several times the surface's own chroma, as hand-made slate and gray scales do; light
|
|
69
|
+
* text on a dark surface carries less than the surface, or it reads as colored. The surface's chroma is
|
|
70
|
+
* added in OKLab to its tint, so the surface's hue leads and the accent only leans it, and a white
|
|
71
|
+
* surface keeps neutral text whatever the accent.
|
|
72
|
+
*/
|
|
73
|
+
function inkFor(surface, tint, dark) {
|
|
74
|
+
const rad = Math.PI / 180;
|
|
75
|
+
if (dark) return {
|
|
76
|
+
...tint,
|
|
77
|
+
c: Math.min(tint.c, .03)
|
|
78
|
+
};
|
|
79
|
+
const extra = Math.min(.035, surface.c * 7);
|
|
80
|
+
const a = tint.c * Math.cos(tint.h * rad) + extra * Math.cos(surface.h * rad);
|
|
81
|
+
const b = tint.c * Math.sin(tint.h * rad) + extra * Math.sin(surface.h * rad);
|
|
82
|
+
return {
|
|
83
|
+
l: surface.l,
|
|
84
|
+
c: Math.hypot(a, b),
|
|
85
|
+
h: (Math.atan2(b, a) / rad + 360) % 360
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function byContrast(k, [at0, at30, at100]) {
|
|
89
|
+
return k <= 30 ? at0 + (at30 - at0) * k / 30 : at30 + (at100 - at30) * (k - 30) / 70;
|
|
90
|
+
}
|
|
91
|
+
/** The roles' targets at a contrast. WCAG AA is the floor at every contrast. */
|
|
92
|
+
function targets(k) {
|
|
93
|
+
const at = (wcag, apca) => ({
|
|
94
|
+
wcag: byContrast(k, wcag),
|
|
95
|
+
apca: byContrast(k, apca)
|
|
96
|
+
});
|
|
97
|
+
return {
|
|
98
|
+
primary: at([
|
|
99
|
+
4.5,
|
|
100
|
+
7,
|
|
101
|
+
12
|
|
102
|
+
], [
|
|
103
|
+
75,
|
|
104
|
+
90,
|
|
105
|
+
105
|
|
106
|
+
]),
|
|
107
|
+
secondary: at([
|
|
108
|
+
4.5,
|
|
109
|
+
4.5,
|
|
110
|
+
7
|
|
111
|
+
], [
|
|
112
|
+
60,
|
|
113
|
+
70,
|
|
114
|
+
85
|
|
115
|
+
]),
|
|
116
|
+
placeholder: at([
|
|
117
|
+
3,
|
|
118
|
+
3,
|
|
119
|
+
4.5
|
|
120
|
+
], [
|
|
121
|
+
45,
|
|
122
|
+
50,
|
|
123
|
+
65
|
|
124
|
+
]),
|
|
125
|
+
focus: { wcag: byContrast(k, [
|
|
126
|
+
3,
|
|
127
|
+
3,
|
|
128
|
+
4.5
|
|
129
|
+
]) },
|
|
130
|
+
control: { wcag: byContrast(k, [
|
|
131
|
+
1.6,
|
|
132
|
+
2.2,
|
|
133
|
+
3
|
|
134
|
+
]) },
|
|
135
|
+
onAccent: { wcag: 4.5 }
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
var STATUS = {
|
|
139
|
+
success: 150,
|
|
140
|
+
error: 27,
|
|
141
|
+
warning: 70,
|
|
142
|
+
info: 255,
|
|
143
|
+
favorite: 5
|
|
144
|
+
};
|
|
145
|
+
var ANSI = {
|
|
146
|
+
red: 27,
|
|
147
|
+
green: 145,
|
|
148
|
+
yellow: 90,
|
|
149
|
+
blue: 255,
|
|
150
|
+
magenta: 330,
|
|
151
|
+
cyan: 200
|
|
152
|
+
};
|
|
153
|
+
var SYNTAX = {
|
|
154
|
+
string: 145,
|
|
155
|
+
number: 55,
|
|
156
|
+
function: 300,
|
|
157
|
+
type: 195,
|
|
158
|
+
property: 240
|
|
159
|
+
};
|
|
160
|
+
var CODE_CHROMA = {
|
|
161
|
+
balanced: .13,
|
|
162
|
+
vivid: .19,
|
|
163
|
+
muted: .07,
|
|
164
|
+
mono: 0
|
|
165
|
+
};
|
|
166
|
+
/** The largest share, 0–1, of a fill's step from its surface that still lets the readable
|
|
167
|
+
* pole, black or white, meet a target on it. */
|
|
168
|
+
function roomFor(fill, target) {
|
|
169
|
+
const fits = (share) => {
|
|
170
|
+
const bg = toHex(fill(share));
|
|
171
|
+
return meets(isDarkColor(bg) ? "#ffffff" : "#000000", [bg], target);
|
|
172
|
+
};
|
|
173
|
+
if (fits(1)) return 1;
|
|
174
|
+
let lo = 0;
|
|
175
|
+
let hi = 1;
|
|
176
|
+
while (hi - lo > .01) {
|
|
177
|
+
const mid = (lo + hi) / 2;
|
|
178
|
+
if (fits(mid)) lo = mid;
|
|
179
|
+
else hi = mid;
|
|
180
|
+
}
|
|
181
|
+
return lo;
|
|
182
|
+
}
|
|
183
|
+
/** A fixed hue moved off the accent's, so syntax never reads as the brand. */
|
|
184
|
+
function awayFrom(hue, accentHue) {
|
|
185
|
+
const d = (hue - accentHue + 540) % 360 - 180;
|
|
186
|
+
return Math.abs(d) < 30 ? (hue + (d < 0 ? -45 : 45) + 360) % 360 : hue;
|
|
187
|
+
}
|
|
188
|
+
/** Every token as sRGB, plus display-p3 overrides that keep every contrast the sRGB output meets. */
|
|
189
|
+
function generateTheme(scheme, options = {}) {
|
|
190
|
+
const { srgb, paints, checks } = build(scheme, options);
|
|
191
|
+
return {
|
|
192
|
+
srgb,
|
|
193
|
+
p3: p3Overrides(paints, checks)
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
function build(scheme, options) {
|
|
197
|
+
const base = oklch(scheme.interface.base);
|
|
198
|
+
const accent = oklch(scheme.interface.accent);
|
|
199
|
+
const k = clamp(scheme.interface.contrast ?? 30, 0, 100);
|
|
200
|
+
const s = .6 + .4 * (Math.min(k, 30) + Math.max(k - 30, 0) * .25) / 30;
|
|
201
|
+
const b = byContrast(k, [
|
|
202
|
+
.6,
|
|
203
|
+
1,
|
|
204
|
+
1.8
|
|
205
|
+
]);
|
|
206
|
+
const dark = isDarkColor(toHex(base));
|
|
207
|
+
const dir = dark ? 1 : -1;
|
|
208
|
+
const t = targets(k);
|
|
209
|
+
const paints = {};
|
|
210
|
+
const checks = [];
|
|
211
|
+
const hexOf = (d) => typeof d === "string" ? toHex(paints[d].color) : compositeHex(paints[d.fill], paints[d.over]);
|
|
212
|
+
const set = (token, color, alpha) => {
|
|
213
|
+
paints[token] = alpha === void 0 ? { color } : {
|
|
214
|
+
color,
|
|
215
|
+
alpha
|
|
216
|
+
};
|
|
217
|
+
return color;
|
|
218
|
+
};
|
|
219
|
+
/** A color that must keep a contrast on its backdrops, in both outputs. */
|
|
220
|
+
const keep = (token, color, on, target) => {
|
|
221
|
+
checks.push({
|
|
222
|
+
fg: token,
|
|
223
|
+
on,
|
|
224
|
+
target
|
|
225
|
+
});
|
|
226
|
+
return set(token, color);
|
|
227
|
+
};
|
|
228
|
+
/** A foreground solved on its backdrops. */
|
|
229
|
+
const solved = (token, start, on, target) => keep(token, solve(start, on.map(hexOf), target), on, target);
|
|
230
|
+
const tint = mixOklab(base, accent, Math.min(.5, (dark ? .05 : .04) * (1 + base.c / .03)));
|
|
231
|
+
const neutral = (l, lift = 0) => ({
|
|
232
|
+
l: clamp(l, 0, 1),
|
|
233
|
+
c: tint.c + (dark ? .004 * lift : 0),
|
|
234
|
+
h: tint.h
|
|
235
|
+
});
|
|
236
|
+
const ink = inkFor(base, tint, dark);
|
|
237
|
+
const paper = base.l > .97 && base.c < .02;
|
|
238
|
+
const raised = (towardWhite, darkStep) => dark ? neutral(base.l + darkStep * s, 1) : paper ? {
|
|
239
|
+
l: 1,
|
|
240
|
+
c: 0,
|
|
241
|
+
h: 0
|
|
242
|
+
} : {
|
|
243
|
+
...neutral(base.l + (1 - base.l) * towardWhite),
|
|
244
|
+
c: tint.c * .5
|
|
245
|
+
};
|
|
246
|
+
const step = (light, darkStep) => neutral(base.l + dir * (dark ? darkStep : light) * s, 1);
|
|
247
|
+
set("--theme-app-bg", base);
|
|
248
|
+
set("--theme-panel-hover", neutral(set("--theme-panel-bg", raised(.85, .035)).l + dir * (dark ? .04 : .025) * s, 1));
|
|
249
|
+
const mutedPanel = set("--theme-muted-panel-bg", step(.03, .065));
|
|
250
|
+
set("--theme-hover", step(.045, .08));
|
|
251
|
+
set("--theme-input-bg", raised(.7, .05));
|
|
252
|
+
set("--theme-input-disabled-bg", step(.02, .025));
|
|
253
|
+
set("--theme-accent-subtle", {
|
|
254
|
+
l: base.l + dir * (dark ? .07 : .04) * s,
|
|
255
|
+
c: Math.min(accent.c, dark ? .045 : .035),
|
|
256
|
+
h: accent.h
|
|
257
|
+
});
|
|
258
|
+
const border = set("--theme-border", neutral(base.l + dir * (dark ? .14 : .12) * b));
|
|
259
|
+
const textOn = [
|
|
260
|
+
"--theme-app-bg",
|
|
261
|
+
"--theme-panel-bg",
|
|
262
|
+
"--theme-panel-hover",
|
|
263
|
+
"--theme-muted-panel-bg",
|
|
264
|
+
"--theme-hover",
|
|
265
|
+
"--theme-input-bg",
|
|
266
|
+
"--theme-accent-subtle"
|
|
267
|
+
];
|
|
268
|
+
solved("--theme-app", ink, textOn, t.primary);
|
|
269
|
+
solved("--theme-muted-text-color", ink, textOn, t.secondary);
|
|
270
|
+
solved("--theme-placeholder", ink, [
|
|
271
|
+
"--theme-input-bg",
|
|
272
|
+
"--theme-input-disabled-bg",
|
|
273
|
+
"--theme-app-bg",
|
|
274
|
+
"--theme-panel-bg"
|
|
275
|
+
], t.placeholder);
|
|
276
|
+
solved("--theme-link", accent, [
|
|
277
|
+
"--theme-app-bg",
|
|
278
|
+
"--theme-panel-bg",
|
|
279
|
+
"--theme-muted-panel-bg",
|
|
280
|
+
"--theme-hover"
|
|
281
|
+
], t.secondary);
|
|
282
|
+
set("--theme-focus-ring", solved("--theme-focus", accent, [
|
|
283
|
+
"--theme-app-bg",
|
|
284
|
+
"--theme-panel-bg",
|
|
285
|
+
"--theme-input-bg"
|
|
286
|
+
], t.focus), dark ? .35 : .25);
|
|
287
|
+
solved("--theme-border-strong", border, [
|
|
288
|
+
"--theme-app-bg",
|
|
289
|
+
"--theme-panel-bg",
|
|
290
|
+
"--theme-input-bg"
|
|
291
|
+
], t.control);
|
|
292
|
+
set("--theme-accent", accent);
|
|
293
|
+
const white = contrastRatio("#ffffff", toHex(accent)) >= 4.5;
|
|
294
|
+
set("--theme-accent-hover", {
|
|
295
|
+
...accent,
|
|
296
|
+
l: accent.l + (white ? -.05 : .05)
|
|
297
|
+
});
|
|
298
|
+
keep("--theme-accent-text", {
|
|
299
|
+
l: white ? 1 : 0,
|
|
300
|
+
c: 0,
|
|
301
|
+
h: 0
|
|
302
|
+
}, ["--theme-accent", "--theme-accent-hover"], t.onAccent);
|
|
303
|
+
const mutedAlpha = dark ? .15 : .1;
|
|
304
|
+
for (const [name, hue] of Object.entries(STATUS)) {
|
|
305
|
+
const token = `--theme-${name}`;
|
|
306
|
+
const muted = `--theme-${name}-muted`;
|
|
307
|
+
const plain = [
|
|
308
|
+
"--theme-app-bg",
|
|
309
|
+
"--theme-panel-bg",
|
|
310
|
+
"--theme-muted-panel-bg"
|
|
311
|
+
];
|
|
312
|
+
const on = [
|
|
313
|
+
...plain,
|
|
314
|
+
{
|
|
315
|
+
fill: muted,
|
|
316
|
+
over: "--theme-app-bg"
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
fill: muted,
|
|
320
|
+
over: "--theme-panel-bg"
|
|
321
|
+
}
|
|
322
|
+
];
|
|
323
|
+
let color = solve({
|
|
324
|
+
l: dark ? .75 : .55,
|
|
325
|
+
c: .17,
|
|
326
|
+
h: hue
|
|
327
|
+
}, plain.map(hexOf), t.secondary);
|
|
328
|
+
for (let round = 0; round < 6; round++) {
|
|
329
|
+
set(muted, color, mutedAlpha);
|
|
330
|
+
const next = solve(color, on.map(hexOf), t.secondary);
|
|
331
|
+
if (next === color) break;
|
|
332
|
+
color = next;
|
|
333
|
+
}
|
|
334
|
+
keep(token, color, on, t.secondary);
|
|
335
|
+
}
|
|
336
|
+
const sidebarBase = scheme.sidebar?.base ? oklch(scheme.sidebar.base) : neutral(dark ? Math.max(.08, base.l - .035 * s) : base.l - .035 * s);
|
|
337
|
+
const sidebarAccent = scheme.sidebar?.accent ? oklch(scheme.sidebar.accent) : accent;
|
|
338
|
+
const sidebarDark = isDarkColor(toHex(sidebarBase));
|
|
339
|
+
const sidebarDir = sidebarDark ? 1 : -1;
|
|
340
|
+
set("--theme-sidebar-bg", sidebarBase);
|
|
341
|
+
set("--theme-sidebar-hover", {
|
|
342
|
+
...sidebarBase,
|
|
343
|
+
l: sidebarBase.l + sidebarDir * (sidebarDark ? .08 : .05) * s
|
|
344
|
+
});
|
|
345
|
+
const activeAt = (f) => ({
|
|
346
|
+
l: sidebarBase.l + sidebarDir * (sidebarDark ? .12 : .07) * s * f,
|
|
347
|
+
c: Math.min(sidebarAccent.c, .08),
|
|
348
|
+
h: sidebarAccent.h
|
|
349
|
+
});
|
|
350
|
+
set("--theme-sidebar-active-bg", activeAt(roomFor(activeAt, t.primary)));
|
|
351
|
+
solved("--theme-sidebar-text", inkFor(sidebarBase, sidebarBase, sidebarDark), ["--theme-sidebar-bg", "--theme-sidebar-hover"], t.primary);
|
|
352
|
+
solved("--theme-sidebar-active-text", {
|
|
353
|
+
l: sidebarBase.l,
|
|
354
|
+
c: Math.min(sidebarAccent.c, .04),
|
|
355
|
+
h: sidebarAccent.h
|
|
356
|
+
}, ["--theme-sidebar-active-bg"], t.primary);
|
|
357
|
+
const style = options.code ?? "balanced";
|
|
358
|
+
set("--theme-code-bg", mutedPanel);
|
|
359
|
+
const codeOn = [
|
|
360
|
+
"--theme-code-bg",
|
|
361
|
+
"--theme-panel-bg",
|
|
362
|
+
"--theme-app-bg"
|
|
363
|
+
];
|
|
364
|
+
const codeText = solved("--theme-code-text", ink, codeOn, t.primary);
|
|
365
|
+
const comment = solved("--theme-code-comment", ink, codeOn, t.secondary);
|
|
366
|
+
const syntaxL = dark ? .78 : .5;
|
|
367
|
+
const chroma = CODE_CHROMA[style];
|
|
368
|
+
const syntax = (token, hue) => solved(token, {
|
|
369
|
+
l: syntaxL,
|
|
370
|
+
c: chroma,
|
|
371
|
+
h: awayFrom(hue, accent.h)
|
|
372
|
+
}, codeOn, t.secondary);
|
|
373
|
+
if (style === "mono") {
|
|
374
|
+
keep("--theme-code-keyword", codeText, codeOn, t.primary);
|
|
375
|
+
keep("--theme-code-property", comment, codeOn, t.secondary);
|
|
376
|
+
} else {
|
|
377
|
+
solved("--theme-code-keyword", {
|
|
378
|
+
l: syntaxL,
|
|
379
|
+
c: Math.min(accent.c, chroma + .04),
|
|
380
|
+
h: accent.h
|
|
381
|
+
}, codeOn, t.secondary);
|
|
382
|
+
syntax("--theme-code-property", SYNTAX.property);
|
|
383
|
+
}
|
|
384
|
+
syntax("--theme-code-string", SYNTAX.string);
|
|
385
|
+
syntax("--theme-code-number", SYNTAX.number);
|
|
386
|
+
syntax("--theme-code-function", SYNTAX.function);
|
|
387
|
+
syntax("--theme-code-type", SYNTAX.type);
|
|
388
|
+
for (const [name, hue] of Object.entries(ANSI)) solved(`--theme-ansi-${name}`, {
|
|
389
|
+
l: syntaxL,
|
|
390
|
+
c: .15,
|
|
391
|
+
h: hue
|
|
392
|
+
}, codeOn, t.secondary);
|
|
393
|
+
keep("--theme-ansi-black", dark ? comment : codeText, codeOn, t.secondary);
|
|
394
|
+
keep("--theme-ansi-white", dark ? codeText : comment, codeOn, t.secondary);
|
|
395
|
+
const shade = dark ? .35 : .07;
|
|
396
|
+
const a = (v) => Number((v * b).toFixed(3));
|
|
397
|
+
const shadows = {
|
|
398
|
+
"--theme-shadow-sm": `0 1px 2px rgba(0, 0, 0, ${a(shade)})`,
|
|
399
|
+
"--theme-shadow": `0 4px 6px -1px rgba(0, 0, 0, ${a(shade)}), 0 2px 4px -2px rgba(0, 0, 0, ${a(shade)})`,
|
|
400
|
+
"--theme-shadow-lg": `0 10px 15px -3px rgba(0, 0, 0, ${a(shade)}), 0 4px 6px -4px rgba(0, 0, 0, ${a(shade)})`,
|
|
401
|
+
"--theme-shadow-xl": `0 25px 80px -20px rgba(0, 0, 0, ${a(dark ? .6 : .2)}), 0 10px 30px -10px rgba(0, 0, 0, ${a(dark ? .4 : .1)})`
|
|
402
|
+
};
|
|
403
|
+
const srgb = {};
|
|
404
|
+
for (const token of THEME_TOKENS) {
|
|
405
|
+
const paint = paints[token];
|
|
406
|
+
srgb[token] = paint ? paint.alpha === void 0 ? toHex(paint.color) : withAlpha(toHex(paint.color), paint.alpha) : shadows[token];
|
|
407
|
+
}
|
|
408
|
+
return {
|
|
409
|
+
srgb,
|
|
410
|
+
paints,
|
|
411
|
+
checks
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
var FILLS = [
|
|
415
|
+
["--theme-focus-ring", "--theme-focus"],
|
|
416
|
+
["--theme-success-muted", "--theme-success"],
|
|
417
|
+
["--theme-error-muted", "--theme-error"],
|
|
418
|
+
["--theme-warning-muted", "--theme-warning"],
|
|
419
|
+
["--theme-info-muted", "--theme-info"],
|
|
420
|
+
["--theme-favorite-muted", "--theme-favorite"]
|
|
421
|
+
];
|
|
422
|
+
/** The tokens a display-p3 screen shows noticeably more of, keeping only those
|
|
423
|
+
* whose contrast checks still hold when the screen shows them. */
|
|
424
|
+
function p3Overrides(paints, checks) {
|
|
425
|
+
const wide = new Set(Object.keys(paints).filter((token) => deltaE(rendered(paints[token].color, "p3"), rendered(paints[token].color)) > JND));
|
|
426
|
+
const gamutOf = (token) => wide.has(token) ? "p3" : "srgb";
|
|
427
|
+
const show = (token) => shown(paints[token].color, gamutOf(token));
|
|
428
|
+
const backdrop = (d) => {
|
|
429
|
+
if (typeof d === "string") return show(d);
|
|
430
|
+
const fill = paints[d.fill];
|
|
431
|
+
return over(show(d.fill), fill.alpha ?? 1, rendered(paints[d.over].color, gamutOf(d.over)));
|
|
432
|
+
};
|
|
433
|
+
const passes = (check) => meetsIn(show(check.fg), check.on.map(backdrop), check.target);
|
|
434
|
+
for (let round = 0; round < 4; round++) {
|
|
435
|
+
let changed = false;
|
|
436
|
+
for (const check of checks) {
|
|
437
|
+
if (passes(check)) continue;
|
|
438
|
+
if (wide.delete(check.fg)) {
|
|
439
|
+
changed = true;
|
|
440
|
+
if (passes(check)) continue;
|
|
441
|
+
}
|
|
442
|
+
for (const d of check.on) for (const token of typeof d === "string" ? [d] : [d.fill, d.over]) changed = wide.delete(token) || changed;
|
|
443
|
+
}
|
|
444
|
+
if (!changed) break;
|
|
445
|
+
}
|
|
446
|
+
for (const [fill, color] of FILLS) if (!wide.has(color)) wide.delete(fill);
|
|
447
|
+
const out = {};
|
|
448
|
+
for (const token of THEME_TOKENS) if (wide.has(token)) out[token] = toP3(paints[token].color, paints[token].alpha);
|
|
449
|
+
return out;
|
|
450
|
+
}
|
|
451
|
+
function compositeHex(fill, backdrop) {
|
|
452
|
+
const f = toHex(fill.color);
|
|
453
|
+
const u = toHex(backdrop.color);
|
|
454
|
+
const a = fill.alpha ?? 1;
|
|
455
|
+
const channel = (hex, i) => Number.parseInt(hex.slice(i, i + 2), 16);
|
|
456
|
+
return `#${[
|
|
457
|
+
1,
|
|
458
|
+
3,
|
|
459
|
+
5
|
|
460
|
+
].map((i) => Math.round(channel(f, i) * a + channel(u, i) * (1 - a)).toString(16).padStart(2, "0")).join("")}`;
|
|
461
|
+
}
|
|
462
|
+
/** Every `--theme-*` token for a scheme, in sRGB. */
|
|
463
|
+
function deriveTheme(scheme, options = {}) {
|
|
464
|
+
return build(scheme, options).srgb;
|
|
465
|
+
}
|
|
466
|
+
/** A stylesheet for a scheme: sRGB under `selector`, and the display-p3 overrides under
|
|
467
|
+
* `@media (color-gamut: p3)`. `omit` leaves tokens out, such as ones a host supplies. */
|
|
468
|
+
function themeStylesheet(selector, scheme, options = {}) {
|
|
469
|
+
const { srgb, p3 } = generateTheme(scheme, options);
|
|
470
|
+
const block = (vars, indent) => THEME_TOKENS.filter((token) => !options.omit?.includes(token) && vars[token] !== void 0).map((token) => `${indent}${token}: ${vars[token]};`).join("\n");
|
|
471
|
+
const wide = block(p3, " ");
|
|
472
|
+
return `${selector} {\n${block(srgb, " ")}\n}\n${wide ? `\n@media (color-gamut: p3) {\n ${selector} {\n${wide}\n }\n}\n` : ""}`;
|
|
473
|
+
}
|
|
474
|
+
//#endregion
|
|
475
|
+
export { SIDEBAR_TOKENS, THEME_TOKENS, deriveTheme, generateTheme, themeStylesheet };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type ThemeToken } from './derive.js';
|
|
2
|
+
import { type CodeStyle, type Mode, type Scheme } from './model.js';
|
|
3
|
+
export interface FitOptions {
|
|
4
|
+
/** How much each token counts toward the fit; 1 by default. */
|
|
5
|
+
weights?: Partial<Record<ThemeToken, number>>;
|
|
6
|
+
}
|
|
7
|
+
export interface FitToken {
|
|
8
|
+
token: ThemeToken;
|
|
9
|
+
target: string;
|
|
10
|
+
fitted: string;
|
|
11
|
+
/** ΔEOK × 100, so 2 is about one just-noticeable difference. */
|
|
12
|
+
deltaE: number;
|
|
13
|
+
/** The target failed WCAG AA against its background, so the fitted color is meant to differ. */
|
|
14
|
+
correctedForContrast: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface FitReport {
|
|
17
|
+
tokens: FitToken[];
|
|
18
|
+
/** Mean and largest ΔEOK × 100 over the tokens not corrected for contrast. */
|
|
19
|
+
mean: number;
|
|
20
|
+
max: number;
|
|
21
|
+
/** Up to three tokens furthest from their target, worst first. */
|
|
22
|
+
worst: ThemeToken[];
|
|
23
|
+
/** faithful: the main surfaces and colors within 2 and nothing past 5; close: within 5 and 10; changed: past that. */
|
|
24
|
+
verdict: 'faithful' | 'close' | 'changed';
|
|
25
|
+
}
|
|
26
|
+
export interface FitResult {
|
|
27
|
+
scheme: Scheme;
|
|
28
|
+
mode: Mode;
|
|
29
|
+
code: CodeStyle;
|
|
30
|
+
report: FitReport;
|
|
31
|
+
}
|
|
32
|
+
type Target = Partial<Record<ThemeToken, string>>;
|
|
33
|
+
/** The scheme whose derived tokens come closest to `target`, a partial map of tokens a host has colors for, with how close each came. */
|
|
34
|
+
export declare function fitSeed(target: Target, options?: FitOptions): FitResult;
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { composite, deltaE, parseColor, toHex } from "./color.js";
|
|
2
|
+
import { contrastRatio, isDarkColor } from "./contrast.js";
|
|
3
|
+
import { CODE_STYLES, DEFAULT_THEME, schemeFor } from "./model.js";
|
|
4
|
+
import { deriveTheme } from "./derive.js";
|
|
5
|
+
//#region src/theme/fit.ts
|
|
6
|
+
var MAIN = [
|
|
7
|
+
"--theme-app-bg",
|
|
8
|
+
"--theme-app",
|
|
9
|
+
"--theme-panel-bg",
|
|
10
|
+
"--theme-accent",
|
|
11
|
+
"--theme-link",
|
|
12
|
+
"--theme-border",
|
|
13
|
+
"--theme-sidebar-bg"
|
|
14
|
+
];
|
|
15
|
+
var FLOORS = {
|
|
16
|
+
"--theme-app": ["--theme-app-bg", 4.5],
|
|
17
|
+
"--theme-muted-text-color": ["--theme-app-bg", 4.5],
|
|
18
|
+
"--theme-link": ["--theme-app-bg", 4.5],
|
|
19
|
+
"--theme-placeholder": ["--theme-input-bg", 3],
|
|
20
|
+
"--theme-focus": ["--theme-app-bg", 3],
|
|
21
|
+
"--theme-accent-text": ["--theme-accent", 4.5],
|
|
22
|
+
"--theme-success": ["--theme-app-bg", 4.5],
|
|
23
|
+
"--theme-error": ["--theme-app-bg", 4.5],
|
|
24
|
+
"--theme-warning": ["--theme-app-bg", 4.5],
|
|
25
|
+
"--theme-info": ["--theme-app-bg", 4.5],
|
|
26
|
+
"--theme-sidebar-text": ["--theme-sidebar-bg", 4.5],
|
|
27
|
+
"--theme-sidebar-active-text": ["--theme-sidebar-active-bg", 4.5],
|
|
28
|
+
"--theme-code-text": ["--theme-code-bg", 4.5],
|
|
29
|
+
"--theme-code-comment": ["--theme-code-bg", 4.5]
|
|
30
|
+
};
|
|
31
|
+
var isColor = (v) => /^#[\da-f]{6}$/i.test(v) || /^rgba\(/.test(v) || parseColor(v) !== null;
|
|
32
|
+
/** A color as the hex it shows as over a backdrop. */
|
|
33
|
+
function shown(value, backdrop) {
|
|
34
|
+
if (value.startsWith("rgba(")) return composite(value, backdrop);
|
|
35
|
+
return toHex(parseColor(value) ?? {
|
|
36
|
+
l: 0,
|
|
37
|
+
c: 0,
|
|
38
|
+
h: 0
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
function corrected(target, token, background) {
|
|
42
|
+
const floor = FLOORS[token];
|
|
43
|
+
const value = target[token];
|
|
44
|
+
if (!floor || !value) return false;
|
|
45
|
+
const against = target[floor[0]] ? shown(target[floor[0]], background) : null;
|
|
46
|
+
return against !== null && contrastRatio(shown(value, background), against) < floor[1];
|
|
47
|
+
}
|
|
48
|
+
function measure(target, fitted, background) {
|
|
49
|
+
return Object.keys(target).filter((token) => isColor(target[token]) && fitted[token] !== void 0).map((token) => {
|
|
50
|
+
const want = shown(target[token], background);
|
|
51
|
+
const got = shown(fitted[token], fitted["--theme-app-bg"]);
|
|
52
|
+
const a = parseColor(want);
|
|
53
|
+
const b = parseColor(got);
|
|
54
|
+
return {
|
|
55
|
+
token,
|
|
56
|
+
target: target[token],
|
|
57
|
+
fitted: fitted[token],
|
|
58
|
+
deltaE: a && b ? Math.round(deltaE(a, b) * 1e4) / 100 : 100,
|
|
59
|
+
correctedForContrast: corrected(target, token, background)
|
|
60
|
+
};
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
function score(tokens, weights) {
|
|
64
|
+
let sum = 0;
|
|
65
|
+
let total = 0;
|
|
66
|
+
for (const t of tokens) {
|
|
67
|
+
if (t.correctedForContrast) continue;
|
|
68
|
+
const w = weights?.[t.token] ?? 1;
|
|
69
|
+
sum += t.deltaE * w;
|
|
70
|
+
total += w;
|
|
71
|
+
}
|
|
72
|
+
return total ? sum / total : 0;
|
|
73
|
+
}
|
|
74
|
+
/** The scheme whose derived tokens come closest to `target`, a partial map of tokens a host has colors for, with how close each came. */
|
|
75
|
+
function fitSeed(target, options = {}) {
|
|
76
|
+
const fallback = schemeFor(DEFAULT_THEME, "light").interface;
|
|
77
|
+
const given = parseColor(target["--theme-app-bg"] ?? "");
|
|
78
|
+
const background = given ? toHex(given) : fallback.base;
|
|
79
|
+
const mode = isDarkColor(background) ? "dark" : "light";
|
|
80
|
+
const accentSource = target["--theme-accent"] ?? target["--theme-link"];
|
|
81
|
+
const accent = accentSource ? shown(accentSource, background) : fallback.accent;
|
|
82
|
+
const sidebarBg = target["--theme-sidebar-bg"];
|
|
83
|
+
const activeBg = target["--theme-sidebar-active-bg"];
|
|
84
|
+
const evaluate = (scheme, code) => {
|
|
85
|
+
const fitted = deriveTheme(scheme, { code });
|
|
86
|
+
return {
|
|
87
|
+
tokens: measure(target, fitted, background),
|
|
88
|
+
fitted
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
const cost = (scheme, code) => score(evaluate(scheme, code).tokens, options.weights);
|
|
92
|
+
const withContrast = (scheme, contrast) => ({
|
|
93
|
+
...scheme,
|
|
94
|
+
interface: {
|
|
95
|
+
...scheme.interface,
|
|
96
|
+
contrast: Math.round(contrast * 10) / 10
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
let scheme = { interface: {
|
|
100
|
+
base: background,
|
|
101
|
+
accent
|
|
102
|
+
} };
|
|
103
|
+
let code = "balanced";
|
|
104
|
+
if (sidebarBg) {
|
|
105
|
+
const own = shown(sidebarBg, background);
|
|
106
|
+
const generated = deriveTheme(scheme)["--theme-sidebar-bg"];
|
|
107
|
+
const a = parseColor(own);
|
|
108
|
+
const b = parseColor(generated);
|
|
109
|
+
if (a && b && deltaE(a, b) > .02) scheme = {
|
|
110
|
+
...scheme,
|
|
111
|
+
sidebar: { base: own }
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
const findContrast = (s) => {
|
|
115
|
+
let best = 30;
|
|
116
|
+
let bestCost = Number.POSITIVE_INFINITY;
|
|
117
|
+
for (let k = 0; k <= 100; k += 5) {
|
|
118
|
+
const c = cost(withContrast(s, k), code);
|
|
119
|
+
if (c < bestCost) {
|
|
120
|
+
best = k;
|
|
121
|
+
bestCost = c;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
let lo = Math.max(0, best - 5);
|
|
125
|
+
let hi = Math.min(100, best + 5);
|
|
126
|
+
const phi = (Math.sqrt(5) - 1) / 2;
|
|
127
|
+
let x1 = hi - phi * (hi - lo);
|
|
128
|
+
let x2 = lo + phi * (hi - lo);
|
|
129
|
+
let f1 = cost(withContrast(s, x1), code);
|
|
130
|
+
let f2 = cost(withContrast(s, x2), code);
|
|
131
|
+
while (hi - lo > .2) if (f1 <= f2) {
|
|
132
|
+
hi = x2;
|
|
133
|
+
x2 = x1;
|
|
134
|
+
f2 = f1;
|
|
135
|
+
x1 = hi - phi * (hi - lo);
|
|
136
|
+
f1 = cost(withContrast(s, x1), code);
|
|
137
|
+
} else {
|
|
138
|
+
lo = x1;
|
|
139
|
+
x1 = x2;
|
|
140
|
+
f1 = f2;
|
|
141
|
+
x2 = lo + phi * (hi - lo);
|
|
142
|
+
f2 = cost(withContrast(s, x2), code);
|
|
143
|
+
}
|
|
144
|
+
return [best, (lo + hi) / 2].reduce((a, c) => cost(withContrast(s, c), code) < cost(withContrast(s, a), code) ? c : a);
|
|
145
|
+
};
|
|
146
|
+
scheme = withContrast(scheme, findContrast(scheme));
|
|
147
|
+
const active = activeBg ? parseColor(shown(activeBg, background)) : null;
|
|
148
|
+
if (active && active.c > .02) {
|
|
149
|
+
const page = parseColor(accent);
|
|
150
|
+
const sidebarAccent = toHex({
|
|
151
|
+
...page,
|
|
152
|
+
h: active.h,
|
|
153
|
+
c: Math.max(page.c, active.c)
|
|
154
|
+
});
|
|
155
|
+
const candidate = {
|
|
156
|
+
...scheme,
|
|
157
|
+
sidebar: {
|
|
158
|
+
...scheme.sidebar,
|
|
159
|
+
accent: sidebarAccent
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
if (cost(candidate, code) < cost(scheme, code)) scheme = candidate;
|
|
163
|
+
}
|
|
164
|
+
if (Object.keys(target).some((t) => t.startsWith("--theme-code-"))) code = CODE_STYLES.reduce((a, c) => cost(scheme, c) < cost(scheme, a) ? c : a);
|
|
165
|
+
const tokens = evaluate(scheme, code).tokens;
|
|
166
|
+
const counted = tokens.filter((t) => !t.correctedForContrast);
|
|
167
|
+
const max = counted.reduce((m, t) => Math.max(m, t.deltaE), 0);
|
|
168
|
+
const mainMax = counted.filter((t) => MAIN.includes(t.token)).reduce((m, t) => Math.max(m, t.deltaE), 0);
|
|
169
|
+
const mean = counted.length ? counted.reduce((s, t) => s + t.deltaE, 0) / counted.length : 0;
|
|
170
|
+
const verdict = mainMax <= 2 && max <= 5 ? "faithful" : mainMax <= 5 && max <= 10 ? "close" : "changed";
|
|
171
|
+
return {
|
|
172
|
+
scheme,
|
|
173
|
+
mode,
|
|
174
|
+
code,
|
|
175
|
+
report: {
|
|
176
|
+
tokens,
|
|
177
|
+
mean: Math.round(mean * 100) / 100,
|
|
178
|
+
max,
|
|
179
|
+
worst: [...counted].sort((a, b) => b.deltaE - a.deltaE).slice(0, 3).filter((t) => t.deltaE > 0).map((t) => t.token),
|
|
180
|
+
verdict
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
//#endregion
|
|
185
|
+
export { fitSeed };
|