@pierre/diffs 1.5.2 → 1.6.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 +4 -3
- package/dist/components/CodeView.d.ts +3 -2
- package/dist/components/CodeView.d.ts.map +1 -1
- package/dist/components/CodeView.js +24 -19
- package/dist/components/CodeView.js.map +1 -1
- package/dist/components/File.d.ts +31 -9
- package/dist/components/File.d.ts.map +1 -1
- package/dist/components/File.js +176 -90
- package/dist/components/File.js.map +1 -1
- package/dist/components/FileDiff.d.ts +32 -9
- package/dist/components/FileDiff.d.ts.map +1 -1
- package/dist/components/FileDiff.js +225 -131
- package/dist/components/FileDiff.js.map +1 -1
- package/dist/components/FileStream.d.ts +6 -4
- package/dist/components/FileStream.d.ts.map +1 -1
- package/dist/components/FileStream.js +49 -36
- package/dist/components/FileStream.js.map +1 -1
- package/dist/components/UnresolvedFile.d.ts +14 -4
- package/dist/components/UnresolvedFile.d.ts.map +1 -1
- package/dist/components/UnresolvedFile.js +35 -16
- package/dist/components/UnresolvedFile.js.map +1 -1
- package/dist/components/VirtualizedFile.d.ts +3 -2
- package/dist/components/VirtualizedFile.d.ts.map +1 -1
- package/dist/components/VirtualizedFile.js +28 -20
- package/dist/components/VirtualizedFile.js.map +1 -1
- package/dist/components/VirtualizedFileDiff.d.ts +3 -2
- package/dist/components/VirtualizedFileDiff.d.ts.map +1 -1
- package/dist/components/VirtualizedFileDiff.js +31 -24
- package/dist/components/VirtualizedFileDiff.js.map +1 -1
- package/dist/constants.d.ts +4 -2
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +3 -1
- package/dist/constants.js.map +1 -1
- package/dist/editor/editor.d.ts +2 -1
- package/dist/editor/editor.d.ts.map +1 -1
- package/dist/editor/editor.js +5 -1
- package/dist/editor/editor.js.map +1 -1
- package/dist/editor/platform.d.ts +1 -1
- package/dist/editor/platform.js +5 -4
- package/dist/editor/platform.js.map +1 -1
- package/dist/editor/selection.d.ts +2 -2
- package/dist/editor/selection.d.ts.map +1 -1
- package/dist/editor/selection.js +31 -6
- package/dist/editor/selection.js.map +1 -1
- package/dist/editor/tokenizer.d.ts +6 -4
- package/dist/editor/tokenizer.d.ts.map +1 -1
- package/dist/editor/tokenizer.js +25 -470
- package/dist/editor/tokenizer.js.map +1 -1
- package/dist/highlighter/DiffsEditorTokenizer.d.ts +16 -0
- package/dist/highlighter/DiffsEditorTokenizer.d.ts.map +1 -0
- package/dist/highlighter/DiffsEditorTokenizer.js +0 -0
- package/dist/highlighter/DiffsHighlighter.d.ts +41 -0
- package/dist/highlighter/DiffsHighlighter.d.ts.map +1 -0
- package/dist/highlighter/DiffsHighlighter.js +39 -0
- package/dist/highlighter/DiffsHighlighter.js.map +1 -0
- package/dist/highlighter/backends/highlights.d.ts +26 -0
- package/dist/highlighter/backends/highlights.d.ts.map +1 -0
- package/dist/highlighter/backends/highlights.js +71 -0
- package/dist/highlighter/backends/highlights.js.map +1 -0
- package/dist/highlighter/backends/shiki.d.ts +27 -0
- package/dist/highlighter/backends/shiki.d.ts.map +1 -0
- package/dist/highlighter/backends/shiki.js +107 -0
- package/dist/highlighter/backends/shiki.js.map +1 -0
- package/dist/highlighter/highlighterType.d.ts +13 -0
- package/dist/highlighter/highlighterType.d.ts.map +1 -0
- package/dist/highlighter/highlighterType.js +32 -0
- package/dist/highlighter/highlighterType.js.map +1 -0
- package/dist/highlighter/highlights-editor.d.ts +24 -0
- package/dist/highlighter/highlights-editor.d.ts.map +1 -0
- package/dist/highlighter/highlights-editor.js +166 -0
- package/dist/highlighter/highlights-editor.js.map +1 -0
- package/dist/highlighter/highlights-stream.d.ts +20 -0
- package/dist/highlighter/highlights-stream.d.ts.map +1 -0
- package/dist/highlighter/highlights-stream.js +93 -0
- package/dist/highlighter/highlights-stream.js.map +1 -0
- package/dist/highlighter/languages/areLanguagesAttached.d.ts +2 -1
- package/dist/highlighter/languages/areLanguagesAttached.d.ts.map +1 -1
- package/dist/highlighter/languages/areLanguagesAttached.js +4 -6
- package/dist/highlighter/languages/areLanguagesAttached.js.map +1 -1
- package/dist/highlighter/languages/attachResolvedLanguages.d.ts +6 -1
- package/dist/highlighter/languages/attachResolvedLanguages.d.ts.map +1 -1
- package/dist/highlighter/languages/attachResolvedLanguages.js +6 -11
- package/dist/highlighter/languages/attachResolvedLanguages.js.map +1 -1
- package/dist/highlighter/languages/constants.d.ts +1 -1
- package/dist/highlighter/languages/getResolvedLanguages.d.ts +1 -1
- package/dist/highlighter/languages/getResolvedOrResolveLanguage.d.ts +1 -1
- package/dist/highlighter/languages/resolveLanguage.d.ts +1 -1
- package/dist/highlighter/languages/resolveLanguage.d.ts.map +1 -1
- package/dist/highlighter/languages/resolveLanguage.js +19 -16
- package/dist/highlighter/languages/resolveLanguage.js.map +1 -1
- package/dist/highlighter/languages/resolveLanguages.d.ts +1 -1
- package/dist/highlighter/shared_highlighter.d.ts +24 -9
- package/dist/highlighter/shared_highlighter.d.ts.map +1 -1
- package/dist/highlighter/shared_highlighter.js +59 -47
- package/dist/highlighter/shared_highlighter.js.map +1 -1
- package/dist/highlighter/shiki-editor.d.ts +25 -0
- package/dist/highlighter/shiki-editor.d.ts.map +1 -0
- package/dist/highlighter/shiki-editor.js +483 -0
- package/dist/highlighter/shiki-editor.js.map +1 -0
- package/dist/highlighter/shiki-stream.d.ts +20 -0
- package/dist/highlighter/shiki-stream.d.ts.map +1 -0
- package/dist/highlighter/shiki-stream.js +60 -0
- package/dist/highlighter/shiki-stream.js.map +1 -0
- package/dist/highlighter/stream-tokenizer.d.ts +40 -0
- package/dist/highlighter/stream-tokenizer.d.ts.map +1 -0
- package/dist/highlighter/stream-tokenizer.js +70 -0
- package/dist/highlighter/stream-tokenizer.js.map +1 -0
- package/dist/highlighter/themes/areThemesAttached.d.ts +3 -2
- package/dist/highlighter/themes/areThemesAttached.d.ts.map +1 -1
- package/dist/highlighter/themes/areThemesAttached.js +5 -4
- package/dist/highlighter/themes/areThemesAttached.js.map +1 -1
- package/dist/highlighter/themes/attachResolvedThemes.d.ts +5 -2
- package/dist/highlighter/themes/attachResolvedThemes.d.ts.map +1 -1
- package/dist/highlighter/themes/attachResolvedThemes.js +4 -16
- package/dist/highlighter/themes/attachResolvedThemes.js.map +1 -1
- package/dist/highlighter/themes/cleanUpResolvedThemes.d.ts +3 -1
- package/dist/highlighter/themes/cleanUpResolvedThemes.d.ts.map +1 -1
- package/dist/highlighter/themes/cleanUpResolvedThemes.js +8 -5
- package/dist/highlighter/themes/cleanUpResolvedThemes.js.map +1 -1
- package/dist/highlighter/themes/createCSSVariablesTheme.d.ts +7 -0
- package/dist/highlighter/themes/createCSSVariablesTheme.d.ts.map +1 -0
- package/dist/highlighter/themes/createCSSVariablesTheme.js +89 -0
- package/dist/highlighter/themes/createCSSVariablesTheme.js.map +1 -0
- package/dist/highlighter/themes/createCachedLoader.d.ts +5 -0
- package/dist/highlighter/themes/createCachedLoader.d.ts.map +1 -0
- package/dist/highlighter/themes/createCachedLoader.js +15 -0
- package/dist/highlighter/themes/createCachedLoader.js.map +1 -0
- package/dist/highlighter/themes/getResolvedOrResolveTheme.d.ts +3 -2
- package/dist/highlighter/themes/getResolvedOrResolveTheme.d.ts.map +1 -1
- package/dist/highlighter/themes/getResolvedOrResolveTheme.js +4 -4
- package/dist/highlighter/themes/getResolvedOrResolveTheme.js.map +1 -1
- package/dist/highlighter/themes/getResolvedThemes.d.ts +3 -2
- package/dist/highlighter/themes/getResolvedThemes.d.ts.map +1 -1
- package/dist/highlighter/themes/getResolvedThemes.js +4 -3
- package/dist/highlighter/themes/getResolvedThemes.js.map +1 -1
- package/dist/highlighter/themes/hasResolvedThemes.d.ts +2 -2
- package/dist/highlighter/themes/hasResolvedThemes.d.ts.map +1 -1
- package/dist/highlighter/themes/hasResolvedThemes.js +4 -3
- package/dist/highlighter/themes/hasResolvedThemes.js.map +1 -1
- package/dist/highlighter/themes/registerCustomCSSVariableTheme.d.ts.map +1 -1
- package/dist/highlighter/themes/registerCustomCSSVariableTheme.js +3 -3
- package/dist/highlighter/themes/registerCustomCSSVariableTheme.js.map +1 -1
- package/dist/highlighter/themes/registerCustomTheme.d.ts +9 -4
- package/dist/highlighter/themes/registerCustomTheme.d.ts.map +1 -1
- package/dist/highlighter/themes/registerCustomTheme.js +8 -16
- package/dist/highlighter/themes/registerCustomTheme.js.map +1 -1
- package/dist/highlighter/themes/resolveTheme.d.ts +3 -2
- package/dist/highlighter/themes/resolveTheme.d.ts.map +1 -1
- package/dist/highlighter/themes/resolveTheme.js +4 -7
- package/dist/highlighter/themes/resolveTheme.js.map +1 -1
- package/dist/highlighter/themes/resolveThemes.d.ts +3 -2
- package/dist/highlighter/themes/resolveThemes.d.ts.map +1 -1
- package/dist/highlighter/themes/resolveThemes.js +4 -7
- package/dist/highlighter/themes/resolveThemes.js.map +1 -1
- package/dist/highlighter/themes/themeResolver.d.ts +10 -4
- package/dist/highlighter/themes/themeResolver.d.ts.map +1 -1
- package/dist/highlighter/themes/themeResolver.js +141 -2
- package/dist/highlighter/themes/themeResolver.js.map +1 -1
- package/dist/highlighter/themes/types.d.ts +23 -0
- package/dist/highlighter/themes/types.d.ts.map +1 -0
- package/dist/highlighter/themes/types.js +0 -0
- package/dist/highlighter/tokenizer-types.d.ts +35 -0
- package/dist/highlighter/tokenizer-types.d.ts.map +1 -0
- package/dist/highlighter/tokenizer-types.js +0 -0
- package/dist/highlighter/types.d.ts +55 -0
- package/dist/highlighter/types.d.ts.map +1 -0
- package/dist/highlighter/types.js +0 -0
- package/dist/index.d.ts +22 -13
- package/dist/index.js +21 -18
- package/dist/managers/InteractionManager.d.ts.map +1 -1
- package/dist/managers/InteractionManager.js +2 -2
- package/dist/managers/InteractionManager.js.map +1 -1
- package/dist/node_modules/.pnpm/@types_hast@3.0.4/node_modules/@types/hast/index.d.ts +9 -1
- package/dist/node_modules/.pnpm/@types_hast@3.0.4/node_modules/@types/hast/index.d.ts.map +1 -1
- package/dist/react/CodeView.d.ts +4 -3
- package/dist/react/CodeView.d.ts.map +1 -1
- package/dist/react/CodeView.js +47 -38
- package/dist/react/CodeView.js.map +1 -1
- package/dist/react/File.js +3 -3
- package/dist/react/File.js.map +1 -1
- package/dist/react/FileDiff.js +3 -3
- package/dist/react/FileDiff.js.map +1 -1
- package/dist/react/MultiFileDiff.js +2 -2
- package/dist/react/MultiFileDiff.js.map +1 -1
- package/dist/react/PatchDiff.js +3 -3
- package/dist/react/PatchDiff.js.map +1 -1
- package/dist/react/UnresolvedFile.js +2 -2
- package/dist/react/UnresolvedFile.js.map +1 -1
- package/dist/react/index.d.ts +9 -4
- package/dist/react/types.d.ts +4 -2
- package/dist/react/types.d.ts.map +1 -1
- package/dist/react/utils/renderDiffChildren.js +1 -1
- package/dist/react/utils/renderDiffChildren.js.map +1 -1
- package/dist/react/utils/renderFileChildren.js +1 -1
- package/dist/react/utils/renderFileChildren.js.map +1 -1
- package/dist/react/utils/useFileDiffInstance.d.ts +1 -0
- package/dist/react/utils/useFileDiffInstance.d.ts.map +1 -1
- package/dist/react/utils/useFileDiffInstance.js +29 -24
- package/dist/react/utils/useFileDiffInstance.js.map +1 -1
- package/dist/react/utils/useFileInstance.d.ts +2 -0
- package/dist/react/utils/useFileInstance.d.ts.map +1 -1
- package/dist/react/utils/useFileInstance.js +38 -28
- package/dist/react/utils/useFileInstance.js.map +1 -1
- package/dist/react/utils/useForceUpdate.d.ts +5 -0
- package/dist/react/utils/useForceUpdate.d.ts.map +1 -0
- package/dist/react/utils/useForceUpdate.js +27 -0
- package/dist/react/utils/useForceUpdate.js.map +1 -0
- package/dist/react/utils/useNextRenderData.d.ts +9 -0
- package/dist/react/utils/useNextRenderData.d.ts.map +1 -0
- package/dist/react/utils/useNextRenderData.js +9 -0
- package/dist/react/utils/useNextRenderData.js.map +1 -0
- package/dist/react/utils/useUnresolvedFileInstance.d.ts +1 -0
- package/dist/react/utils/useUnresolvedFileInstance.d.ts.map +1 -1
- package/dist/react/utils/useUnresolvedFileInstance.js +26 -11
- package/dist/react/utils/useUnresolvedFileInstance.js.map +1 -1
- package/dist/renderers/DiffHunksRenderer.d.ts +4 -2
- package/dist/renderers/DiffHunksRenderer.d.ts.map +1 -1
- package/dist/renderers/DiffHunksRenderer.js +82 -43
- package/dist/renderers/DiffHunksRenderer.js.map +1 -1
- package/dist/renderers/FileRenderer.d.ts +6 -2
- package/dist/renderers/FileRenderer.d.ts.map +1 -1
- package/dist/renderers/FileRenderer.js +77 -43
- package/dist/renderers/FileRenderer.js.map +1 -1
- package/dist/renderers/UnresolvedFileHunksRenderer.d.ts.map +1 -1
- package/dist/renderers/UnresolvedFileHunksRenderer.js +1 -1
- package/dist/renderers/UnresolvedFileHunksRenderer.js.map +1 -1
- package/dist/shiki-stream/index.d.ts +3 -3
- package/dist/shiki-stream/index.js +1 -2
- package/dist/shiki-stream/stream.d.ts +4 -4
- package/dist/shiki-stream/stream.d.ts.map +1 -1
- package/dist/shiki-stream/stream.js +20 -9
- package/dist/shiki-stream/stream.js.map +1 -1
- package/dist/shiki-stream/types.d.ts +7 -38
- package/dist/shiki-stream/types.d.ts.map +1 -1
- package/dist/ssr/index.d.ts +7 -2
- package/dist/ssr/renderHTML.js +2 -2
- package/dist/ssr/renderHTML.js.map +1 -1
- package/dist/style.js +1 -1
- package/dist/style.js.map +1 -1
- package/dist/types.d.ts +20 -11
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/canUseWASM.d.ts +13 -0
- package/dist/utils/canUseWASM.d.ts.map +1 -0
- package/dist/utils/canUseWASM.js +59 -0
- package/dist/utils/canUseWASM.js.map +1 -0
- package/dist/utils/createSpanNodeFromToken.d.ts +3 -2
- package/dist/utils/createSpanNodeFromToken.d.ts.map +1 -1
- package/dist/utils/createSpanNodeFromToken.js +4 -5
- package/dist/utils/createSpanNodeFromToken.js.map +1 -1
- package/dist/utils/cssWrappers.d.ts.map +1 -1
- package/dist/utils/cssWrappers.js +12 -0
- package/dist/utils/cssWrappers.js.map +1 -1
- package/dist/utils/getCodeViewItemRenderData.d.ts +10 -0
- package/dist/utils/getCodeViewItemRenderData.d.ts.map +1 -0
- package/dist/utils/getCodeViewItemRenderData.js +19 -0
- package/dist/utils/getCodeViewItemRenderData.js.map +1 -0
- package/dist/utils/getHighlighterOptions.d.ts.map +1 -1
- package/dist/utils/getHighlighterOptions.js +3 -2
- package/dist/utils/getHighlighterOptions.js.map +1 -1
- package/dist/utils/getHighlighterThemeStyles.d.ts +2 -1
- package/dist/utils/getHighlighterThemeStyles.d.ts.map +1 -1
- package/dist/utils/getHighlighterThemeStyles.js +13 -3
- package/dist/utils/getHighlighterThemeStyles.js.map +1 -1
- package/dist/utils/getTokenOptions.d.ts +7 -0
- package/dist/utils/getTokenOptions.d.ts.map +1 -0
- package/dist/utils/getTokenOptions.js +16 -0
- package/dist/utils/getTokenOptions.js.map +1 -0
- package/dist/utils/hastToHtml.d.ts +10 -0
- package/dist/utils/hastToHtml.d.ts.map +1 -0
- package/dist/utils/hastToHtml.js +125 -0
- package/dist/utils/hastToHtml.js.map +1 -0
- package/dist/utils/hydratePartialDiff.js +4 -0
- package/dist/utils/hydratePartialDiff.js.map +1 -1
- package/dist/utils/parseDiffDecorations.d.ts +2 -1
- package/dist/utils/parseDiffDecorations.d.ts.map +1 -1
- package/dist/utils/parseMergeConflictDiffFromFile.d.ts.map +1 -1
- package/dist/utils/parseMergeConflictDiffFromFile.js +2 -0
- package/dist/utils/parseMergeConflictDiffFromFile.js.map +1 -1
- package/dist/utils/parsePatchFiles.d.ts.map +1 -1
- package/dist/utils/parsePatchFiles.js +24 -4
- package/dist/utils/parsePatchFiles.js.map +1 -1
- package/dist/utils/renderDiffWithHighlighter.d.ts +3 -2
- package/dist/utils/renderDiffWithHighlighter.d.ts.map +1 -1
- package/dist/utils/renderDiffWithHighlighter.js +33 -48
- package/dist/utils/renderDiffWithHighlighter.js.map +1 -1
- package/dist/utils/renderFileWithHighlighter.d.ts +3 -2
- package/dist/utils/renderFileWithHighlighter.d.ts.map +1 -1
- package/dist/utils/renderFileWithHighlighter.js +10 -26
- package/dist/utils/renderFileWithHighlighter.js.map +1 -1
- package/dist/utils/renderTokenLines.d.ts +22 -0
- package/dist/utils/renderTokenLines.d.ts.map +1 -0
- package/dist/utils/renderTokenLines.js +250 -0
- package/dist/utils/renderTokenLines.js.map +1 -0
- package/dist/utils/resolvePreferredHighlighter.d.ts +13 -0
- package/dist/utils/resolvePreferredHighlighter.d.ts.map +1 -0
- package/dist/utils/resolvePreferredHighlighter.js +11 -0
- package/dist/utils/resolvePreferredHighlighter.js.map +1 -0
- package/dist/utils/resolveRegion.js +20 -10
- package/dist/utils/resolveRegion.js.map +1 -1
- package/dist/utils/setDeferredArrayItem.d.ts +5 -0
- package/dist/utils/setDeferredArrayItem.d.ts.map +1 -0
- package/dist/utils/setDeferredArrayItem.js +39 -0
- package/dist/utils/setDeferredArrayItem.js.map +1 -0
- package/dist/utils/tokenStyle.d.ts +11 -0
- package/dist/utils/tokenStyle.d.ts.map +1 -0
- package/dist/utils/tokenStyle.js +32 -0
- package/dist/utils/tokenStyle.js.map +1 -0
- package/dist/utils/tokensToHtml.d.ts +11 -0
- package/dist/utils/tokensToHtml.d.ts.map +1 -0
- package/dist/utils/tokensToHtml.js +48 -0
- package/dist/utils/tokensToHtml.js.map +1 -0
- package/dist/utils/updateDiffHunks.d.ts +2 -2
- package/dist/utils/updateDiffHunks.d.ts.map +1 -1
- package/dist/utils/updateDiffHunks.js +7 -3
- package/dist/utils/updateDiffHunks.js.map +1 -1
- package/dist/utils/wrapTokenFragments.js.map +1 -1
- package/dist/worker/WorkerPoolManager.d.ts +14 -2
- package/dist/worker/WorkerPoolManager.d.ts.map +1 -1
- package/dist/worker/WorkerPoolManager.js +155 -67
- package/dist/worker/WorkerPoolManager.js.map +1 -1
- package/dist/worker/hastLinesTransport.d.ts +14 -0
- package/dist/worker/hastLinesTransport.d.ts.map +1 -0
- package/dist/worker/hastLinesTransport.js +156 -0
- package/dist/worker/hastLinesTransport.js.map +1 -0
- package/dist/worker/highlights-CpZm9DAR.js +317 -0
- package/dist/worker/highlights-CpZm9DAR.js.map +1 -0
- package/dist/worker/index.d.ts +1 -1
- package/dist/worker/shiki-Ci4cdHsM.js +697 -0
- package/dist/worker/shiki-Ci4cdHsM.js.map +1 -0
- package/dist/worker/stream-tokenizer-DK9xp5M5.js +427 -0
- package/dist/worker/stream-tokenizer-DK9xp5M5.js.map +1 -0
- package/dist/worker/types.d.ts +16 -3
- package/dist/worker/types.d.ts.map +1 -1
- package/dist/worker/worker-portable.js +41 -13337
- package/dist/worker/worker-portable.js.map +1 -1
- package/dist/worker/worker.js +681 -349
- package/dist/worker/worker.js.map +1 -1
- package/dist/worker/workerMessage.d.ts +24 -0
- package/dist/worker/workerMessage.d.ts.map +1 -0
- package/dist/worker/workerMessage.js +0 -0
- package/package.json +5 -3
- package/dist/highlighter/themes/constants.d.ts +0 -5
- package/dist/highlighter/themes/constants.d.ts.map +0 -1
- package/dist/highlighter/themes/constants.js +0 -6
- package/dist/highlighter/themes/constants.js.map +0 -1
- package/dist/highlighter/themes/themeResolution.d.ts +0 -7
- package/dist/highlighter/themes/themeResolution.d.ts.map +0 -1
- package/dist/highlighter/themes/themeResolution.js +0 -21
- package/dist/highlighter/themes/themeResolution.js.map +0 -1
- package/dist/shiki-stream/tokenizer.d.ts +0 -23
- package/dist/shiki-stream/tokenizer.d.ts.map +0 -1
- package/dist/shiki-stream/tokenizer.js +0 -72
- package/dist/shiki-stream/tokenizer.js.map +0 -1
- package/dist/utils/createTransformerWithState.d.ts +0 -12
- package/dist/utils/createTransformerWithState.d.ts.map +0 -1
- package/dist/utils/createTransformerWithState.js +0 -89
- package/dist/utils/createTransformerWithState.js.map +0 -1
- package/dist/worker/wasm-B9ZqxnKj.js +0 -8
- package/dist/worker/wasm-B9ZqxnKj.js.map +0 -1
|
@@ -1,21 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { createTheme } from "@pierre/theming/themes";
|
|
3
|
-
import { DuplicateThemeError } from "@pierre/theming";
|
|
1
|
+
import { customThemes } from "./themeResolver.js";
|
|
4
2
|
//#region src/highlighter/themes/registerCustomTheme.ts
|
|
5
|
-
function registerCustomTheme(themeName, loader) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
});
|
|
11
|
-
themeResolver.registerTheme(descriptor.name, descriptor.load);
|
|
12
|
-
} catch (error) {
|
|
13
|
-
if (error instanceof DuplicateThemeError) {
|
|
14
|
-
console.error("SharedHighlight.registerCustomTheme: theme name already registered", themeName);
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
throw error;
|
|
3
|
+
function registerCustomTheme(themeName, loader, type = "textmate") {
|
|
4
|
+
const themes = customThemes.get(themeName) ?? {};
|
|
5
|
+
if (themes[type] != null) {
|
|
6
|
+
console.error("SharedHighlight.registerCustomTheme: theme name and type already registered", themeName, type);
|
|
7
|
+
return;
|
|
18
8
|
}
|
|
9
|
+
themes[type] = loader;
|
|
10
|
+
customThemes.set(themeName, themes);
|
|
19
11
|
}
|
|
20
12
|
//#endregion
|
|
21
13
|
export { registerCustomTheme };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registerCustomTheme.js","names":[],"sources":["../../../src/highlighter/themes/registerCustomTheme.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"registerCustomTheme.js","names":[],"sources":["../../../src/highlighter/themes/registerCustomTheme.ts"],"sourcesContent":["import type {\n Theme as ZedTheme,\n ThemeFamily as ZedThemeFamily,\n} from '@pierre/highlights';\nimport type { ThemeLoader } from '@pierre/theming';\nimport type { ThemeRegistration } from 'shiki';\n\nimport { type CustomThemeLoader, customThemes } from './themeResolver';\nimport type { DiffsTheme } from './types';\n\nexport type { CustomThemeLoader } from './themeResolver';\n\n/** Register a lazy TextMate, Zed, or shared Diffs theme loader. */\nexport function registerCustomTheme(\n themeName: string,\n loader: ThemeLoader<ThemeRegistration>,\n type?: 'textmate'\n): void;\nexport function registerCustomTheme(\n themeName: string,\n loader: ThemeLoader<ZedTheme | ZedThemeFamily>,\n type: 'zed'\n): void;\nexport function registerCustomTheme(\n themeName: string,\n loader: ThemeLoader<DiffsTheme>,\n type: 'diffs'\n): void;\nexport function registerCustomTheme(\n themeName: string,\n loader: CustomThemeLoader,\n type: 'textmate' | 'zed' | 'diffs' = 'textmate'\n): void {\n const themes = customThemes.get(themeName) ?? {};\n if (themes[type] != null) {\n console.error(\n 'SharedHighlight.registerCustomTheme: theme name and type already registered',\n themeName,\n type\n );\n return;\n }\n themes[type] = loader;\n customThemes.set(themeName, themes);\n}\n"],"mappings":";;AA4BA,SAAgB,oBACd,WACA,QACA,OAAqC,YAC/B;CACN,MAAM,SAAS,aAAa,IAAI,SAAS,KAAK,CAAC;CAC/C,IAAI,OAAO,SAAS,MAAM;EACxB,QAAQ,MACN,+EACA,WACA,IACF;EACA;CACF;CACA,OAAO,QAAQ;CACf,aAAa,IAAI,WAAW,MAAM;AACpC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DiffsTheme } from "./types.js";
|
|
2
|
+
import { DiffsThemeNames, HighlighterTypes } from "../../types.js";
|
|
2
3
|
//#region src/highlighter/themes/resolveTheme.d.ts
|
|
3
|
-
declare function resolveTheme(themeName: DiffsThemeNames): Promise<
|
|
4
|
+
declare function resolveTheme(themeName: DiffsThemeNames, backend?: HighlighterTypes): Promise<DiffsTheme>;
|
|
4
5
|
//#endregion
|
|
5
6
|
export { resolveTheme };
|
|
6
7
|
//# sourceMappingURL=resolveTheme.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveTheme.d.ts","names":[],"sources":["../../../src/highlighter/themes/resolveTheme.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"resolveTheme.d.ts","names":[],"sources":["../../../src/highlighter/themes/resolveTheme.ts"],"mappings":";;;iBAKgB,aACd,WAAW,iBACX,UAAS,mBACR,QAAQ"}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { resolveHighlighterType } from "../highlighterType.js";
|
|
2
|
+
import { createDiffsThemeResolver } from "./themeResolver.js";
|
|
3
3
|
//#region src/highlighter/themes/resolveTheme.ts
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const theme = await themeResolver.resolveTheme(themeName);
|
|
7
|
-
validateResolvedThemeName(themeName, theme);
|
|
8
|
-
return theme;
|
|
4
|
+
function resolveTheme(themeName, backend = resolveHighlighterType()) {
|
|
5
|
+
return createDiffsThemeResolver(backend).resolveTheme(themeName);
|
|
9
6
|
}
|
|
10
7
|
//#endregion
|
|
11
8
|
export { resolveTheme };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveTheme.js","names":[],"sources":["../../../src/highlighter/themes/resolveTheme.ts"],"sourcesContent":["import type { DiffsThemeNames,
|
|
1
|
+
{"version":3,"file":"resolveTheme.js","names":[],"sources":["../../../src/highlighter/themes/resolveTheme.ts"],"sourcesContent":["import type { DiffsThemeNames, HighlighterTypes } from '../../types';\nimport { resolveHighlighterType } from '../highlighterType';\nimport { createDiffsThemeResolver } from './themeResolver';\nimport type { DiffsTheme } from './types';\n\nexport function resolveTheme(\n themeName: DiffsThemeNames,\n backend: HighlighterTypes = resolveHighlighterType()\n): Promise<DiffsTheme> {\n return createDiffsThemeResolver(backend).resolveTheme(themeName);\n}\n"],"mappings":";;;AAKA,SAAgB,aACd,WACA,UAA4B,uBAAuB,GAC9B;CACrB,OAAO,yBAAyB,OAAO,CAAC,CAAC,aAAa,SAAS;AACjE"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DiffsTheme } from "./types.js";
|
|
2
|
+
import { DiffsThemeNames, HighlighterTypes } from "../../types.js";
|
|
2
3
|
//#region src/highlighter/themes/resolveThemes.d.ts
|
|
3
|
-
declare function resolveThemes(themes: DiffsThemeNames[]): Promise<
|
|
4
|
+
declare function resolveThemes(themes: DiffsThemeNames[], backend?: HighlighterTypes): Promise<DiffsTheme[]>;
|
|
4
5
|
//#endregion
|
|
5
6
|
export { resolveThemes };
|
|
6
7
|
//# sourceMappingURL=resolveThemes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveThemes.d.ts","names":[],"sources":["../../../src/highlighter/themes/resolveThemes.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"resolveThemes.d.ts","names":[],"sources":["../../../src/highlighter/themes/resolveThemes.ts"],"mappings":";;;iBAKgB,cACd,QAAQ,mBACR,UAAS,mBACR,QAAQ"}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { resolveHighlighterType } from "../highlighterType.js";
|
|
2
|
+
import { createDiffsThemeResolver } from "./themeResolver.js";
|
|
3
3
|
//#region src/highlighter/themes/resolveThemes.ts
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const resolvedThemes = await themeResolver.resolveThemes(themes);
|
|
7
|
-
for (let i = 0; i < themes.length; i++) validateResolvedThemeName(themes[i], resolvedThemes[i]);
|
|
8
|
-
return resolvedThemes;
|
|
4
|
+
function resolveThemes(themes, backend = resolveHighlighterType()) {
|
|
5
|
+
return createDiffsThemeResolver(backend).resolveThemes(themes);
|
|
9
6
|
}
|
|
10
7
|
//#endregion
|
|
11
8
|
export { resolveThemes };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveThemes.js","names":[],"sources":["../../../src/highlighter/themes/resolveThemes.ts"],"sourcesContent":["import type { DiffsThemeNames,
|
|
1
|
+
{"version":3,"file":"resolveThemes.js","names":[],"sources":["../../../src/highlighter/themes/resolveThemes.ts"],"sourcesContent":["import type { DiffsThemeNames, HighlighterTypes } from '../../types';\nimport { resolveHighlighterType } from '../highlighterType';\nimport { createDiffsThemeResolver } from './themeResolver';\nimport type { DiffsTheme } from './types';\n\nexport function resolveThemes(\n themes: DiffsThemeNames[],\n backend: HighlighterTypes = resolveHighlighterType()\n): Promise<DiffsTheme[]> {\n return createDiffsThemeResolver(backend).resolveThemes(themes);\n}\n"],"mappings":";;;AAKA,SAAgB,cACd,QACA,UAA4B,uBAAuB,GAC5B;CACvB,OAAO,yBAAyB,OAAO,CAAC,CAAC,cAAc,MAAM;AAC/D"}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { DiffsTheme } from "./types.js";
|
|
2
|
+
import { HighlighterTypes } from "../../types.js";
|
|
3
|
+
import { ThemeLoader, ThemeResolver } from "@pierre/theming";
|
|
4
|
+
import { ThemeRegistration } from "shiki";
|
|
5
|
+
import { Theme, ThemeFamily } from "@pierre/highlights";
|
|
3
6
|
//#region src/highlighter/themes/themeResolver.d.ts
|
|
4
|
-
|
|
7
|
+
type CustomThemeLoader = ThemeLoader<ThemeRegistration | DiffsTheme | Theme | ThemeFamily>;
|
|
8
|
+
declare const customThemes: Map<string, Partial<Record<'textmate' | 'zed' | 'diffs', CustomThemeLoader>>>;
|
|
9
|
+
/** Keep caches separate because the same name can have TextMate and Zed palettes. */
|
|
10
|
+
declare function createDiffsThemeResolver(backend: HighlighterTypes): ThemeResolver<DiffsTheme>;
|
|
5
11
|
//#endregion
|
|
6
|
-
export {
|
|
12
|
+
export { CustomThemeLoader, createDiffsThemeResolver, customThemes };
|
|
7
13
|
//# sourceMappingURL=themeResolver.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"themeResolver.d.ts","names":[],"sources":["../../../src/highlighter/themes/themeResolver.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"themeResolver.d.ts","names":[],"sources":["../../../src/highlighter/themes/themeResolver.ts"],"mappings":";;;;;;KAkBY,oBAAoB,YAC9B,oBAAoB,aAAa,QAAW;cAEjC,cAAc,YAEzB,QAAQ,qCAAqC;;iBA6F/B,yBACd,SAAS,mBACR,cAAc"}
|
|
@@ -1,7 +1,146 @@
|
|
|
1
|
+
import { isWorkerContext } from "../../utils/isWorkerContext.js";
|
|
2
|
+
import { createCachedLoader } from "./createCachedLoader.js";
|
|
1
3
|
import { createThemeResolver } from "@pierre/theming";
|
|
2
4
|
//#region src/highlighter/themes/themeResolver.ts
|
|
3
|
-
const
|
|
5
|
+
const customThemes = /* @__PURE__ */ new Map();
|
|
6
|
+
const resolvers = /* @__PURE__ */ new Map();
|
|
7
|
+
const loadHighlightsThemeCatalog = createCachedLoader(() => import("@pierre/highlights/themes/loader"));
|
|
8
|
+
const loadPierreThemeCatalog = createCachedLoader(() => import("@pierre/theming/themes"));
|
|
9
|
+
const loadShikiCore = createCachedLoader(() => import("shiki/core"));
|
|
10
|
+
const ZED_COLOR_ALIASES = [
|
|
11
|
+
["editor.lineHighlightBackground", "editor.active_line.background"],
|
|
12
|
+
["editor.selectionBackground", "element.selected"],
|
|
13
|
+
["editor.findMatchBackground", "search.match_background"],
|
|
14
|
+
["editor.findMatchHighlightBackground", "search.match_background"],
|
|
15
|
+
["editorBracketMatch.background", "editor.document_highlight.bracket_background"],
|
|
16
|
+
["editorError.foreground", "error"],
|
|
17
|
+
["editorWarning.foreground", "warning"],
|
|
18
|
+
["editorInfo.foreground", "info"],
|
|
19
|
+
["editorHint.foreground", "hint"],
|
|
20
|
+
[
|
|
21
|
+
"gitDecoration.addedResourceForeground",
|
|
22
|
+
"created",
|
|
23
|
+
"terminal.ansi.green"
|
|
24
|
+
],
|
|
25
|
+
[
|
|
26
|
+
"gitDecoration.deletedResourceForeground",
|
|
27
|
+
"deleted",
|
|
28
|
+
"terminal.ansi.red"
|
|
29
|
+
],
|
|
30
|
+
[
|
|
31
|
+
"gitDecoration.modifiedResourceForeground",
|
|
32
|
+
"modified",
|
|
33
|
+
"terminal.ansi.blue"
|
|
34
|
+
]
|
|
35
|
+
];
|
|
36
|
+
function createHighlightsTheme(name, raw) {
|
|
37
|
+
const theme = "themes" in raw ? raw.themes[0] : raw;
|
|
38
|
+
if (theme == null) throw new Error(`Theme "${name}" is an empty Zed theme family.`);
|
|
39
|
+
const zed = {
|
|
40
|
+
...theme,
|
|
41
|
+
name
|
|
42
|
+
};
|
|
43
|
+
const colors = {};
|
|
44
|
+
for (const [key, value] of Object.entries(zed.style)) if (typeof value === "string") colors[key] = value;
|
|
45
|
+
const player = zed.style.players?.[0];
|
|
46
|
+
if (player?.cursor != null) colors["editorCursor.foreground"] ??= player.cursor;
|
|
47
|
+
if (player?.selection != null) colors["editor.selectionBackground"] ??= player.selection;
|
|
48
|
+
for (const [target, ...sources] of ZED_COLOR_ALIASES) {
|
|
49
|
+
if (colors[target] != null) continue;
|
|
50
|
+
const source = sources.find((key) => colors[key] != null);
|
|
51
|
+
if (source != null) colors[target] = colors[source];
|
|
52
|
+
}
|
|
53
|
+
if (zed.cssVariables === true) {
|
|
54
|
+
colors["editor.foreground"] = "var(--hls-foreground)";
|
|
55
|
+
colors["editor.background"] = "var(--hls-background)";
|
|
56
|
+
} else if (typeof zed.cssVariables === "object") {
|
|
57
|
+
colors["editor.foreground"] ??= colors.text ?? colors.foreground ?? "foreground";
|
|
58
|
+
colors["editor.background"] ??= colors.background ?? "background";
|
|
59
|
+
const { prefix = "--hls-", defaults } = zed.cssVariables;
|
|
60
|
+
for (const [key, value] of Object.entries(colors)) {
|
|
61
|
+
const fallback = defaults?.[value];
|
|
62
|
+
colors[key] = `var(${prefix}${value}${fallback ? `, ${fallback}` : ""})`;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const type = zed.appearance === "light" ? "light" : "dark";
|
|
66
|
+
return {
|
|
67
|
+
name,
|
|
68
|
+
type,
|
|
69
|
+
colors,
|
|
70
|
+
zed,
|
|
71
|
+
fg: colors["editor.foreground"] ?? colors.text ?? colors.foreground ?? (type === "light" ? "#333333" : "#bbbbbb"),
|
|
72
|
+
bg: colors["editor.background"] ?? colors.background ?? (type === "light" ? "#ffffff" : "#1e1e1e")
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/** Keep caches separate because the same name can have TextMate and Zed palettes. */
|
|
76
|
+
function createDiffsThemeResolver(backend) {
|
|
77
|
+
let resolver = resolvers.get(backend);
|
|
78
|
+
if (resolver != null) return resolver;
|
|
79
|
+
resolver = createThemeResolver({
|
|
80
|
+
fallbackLoader: async (name) => {
|
|
81
|
+
if (typeof __DIFFS_WORKER__ !== "undefined" ? __DIFFS_WORKER__ : isWorkerContext()) throw new Error(`Theme "${name}" cannot be resolved from a worker context. Themes must be pre-resolved on the main thread and passed to the worker via the resolvedThemes parameter.`);
|
|
82
|
+
const custom = customThemes.get(name);
|
|
83
|
+
if (backend === "highlights") {
|
|
84
|
+
const loader = custom?.zed ?? custom?.diffs;
|
|
85
|
+
if (loader != null) {
|
|
86
|
+
const loaded = await loader();
|
|
87
|
+
const theme = "default" in loaded ? loaded.default : loaded;
|
|
88
|
+
if ("zed" in theme && theme.zed != null) return theme;
|
|
89
|
+
if ("style" in theme || "themes" in theme) return createHighlightsTheme(name, theme);
|
|
90
|
+
throw new Error(`Theme "${name}" is a TextMate theme; register a Zed theme with registerCustomTheme(name, loader, 'zed') for Highlights.`);
|
|
91
|
+
}
|
|
92
|
+
const catalog = loadHighlightsThemeCatalog();
|
|
93
|
+
const { themes } = catalog instanceof Promise ? await catalog : catalog;
|
|
94
|
+
const bundledLoader = themes[name];
|
|
95
|
+
if (bundledLoader != null) return createHighlightsTheme(name, (await bundledLoader()).default);
|
|
96
|
+
if (custom?.textmate != null) throw new Error(`Theme "${name}" is only registered for TextMate; use registerCustomTheme(name, loader, 'zed') for Highlights.`);
|
|
97
|
+
} else {
|
|
98
|
+
const loader = custom?.textmate ?? custom?.diffs;
|
|
99
|
+
let loaded;
|
|
100
|
+
if (loader != null) {
|
|
101
|
+
const result = await loader();
|
|
102
|
+
loaded = "default" in result ? result.default : result;
|
|
103
|
+
} else {
|
|
104
|
+
const catalog = loadPierreThemeCatalog();
|
|
105
|
+
const { themes } = catalog instanceof Promise ? await catalog : catalog;
|
|
106
|
+
const descriptor = themes.getTheme(name);
|
|
107
|
+
if (descriptor == null && custom?.zed != null) throw new Error(`Theme "${name}" is only registered for Zed; use registerCustomTheme(name, loader, 'textmate') for Shiki.`);
|
|
108
|
+
if (descriptor == null) throw new Error(`No valid theme loader registered for "${name}"`);
|
|
109
|
+
const result = await descriptor.load();
|
|
110
|
+
loaded = "default" in result ? result.default : result;
|
|
111
|
+
}
|
|
112
|
+
if ("style" in loaded || "themes" in loaded) throw new Error(`Theme "${name}" is a Zed theme; use preferredHighlighter: 'highlights' or register a TextMate theme for Shiki.`);
|
|
113
|
+
const core = loadShikiCore();
|
|
114
|
+
const { normalizeTheme, createCssVariablesTheme } = core instanceof Promise ? await core : core;
|
|
115
|
+
if ("cssVariables" in loaded && loaded.cssVariables != null) return {
|
|
116
|
+
...loaded,
|
|
117
|
+
textmate: normalizeTheme(createCssVariablesTheme(loaded.cssVariables))
|
|
118
|
+
};
|
|
119
|
+
if ("textmate" in loaded && loaded.textmate != null) return {
|
|
120
|
+
...loaded,
|
|
121
|
+
textmate: normalizeTheme(loaded.textmate)
|
|
122
|
+
};
|
|
123
|
+
const textmate = normalizeTheme(loaded);
|
|
124
|
+
return {
|
|
125
|
+
name: textmate.name,
|
|
126
|
+
type: textmate.type,
|
|
127
|
+
fg: textmate.fg,
|
|
128
|
+
bg: textmate.bg,
|
|
129
|
+
colors: textmate.colors,
|
|
130
|
+
textmate
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
throw new Error(`No valid theme loader registered for "${name}"`);
|
|
134
|
+
},
|
|
135
|
+
normalizeTheme: (theme, name) => {
|
|
136
|
+
if (theme.name !== name) throw new Error(`resolvedTheme: themeName: ${name} does not match theme.name: ${theme.name}`);
|
|
137
|
+
return theme;
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
resolvers.set(backend, resolver);
|
|
141
|
+
return resolver;
|
|
142
|
+
}
|
|
4
143
|
//#endregion
|
|
5
|
-
export {
|
|
144
|
+
export { createDiffsThemeResolver, customThemes };
|
|
6
145
|
|
|
7
146
|
//# sourceMappingURL=themeResolver.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"themeResolver.js","names":[],"sources":["../../../src/highlighter/themes/themeResolver.ts"],"sourcesContent":["import { createThemeResolver, type ThemeResolver } from '@pierre/theming';\n\nimport type { ThemeRegistrationResolved } from '../../types';\n\n// The single diffs-owned theme resolver. It replaces the former hand-rolled\n// ResolvedThemes (sync cache) + ResolvingThemes (in-flight dedupe) +\n// RegisteredCustomThemes (loader registry) trio with one shared\n// @pierre/theming resolver: the resolver owns the cache, the concurrent-load\n// dedupe, and the name→loader registry internally.\n//\n// This module is intentionally NOT re-exported from the package index — the\n// resolver and the registered-name set are diffs internals. Public callers go\n// through the wrapper functions (resolveTheme, getResolvedThemes, etc.) that\n// add the diffs-specific behavior the generic resolver knows nothing about:\n// the worker-context guard, Shiki normalization, the bundled-theme fallback,\n// and the theme.name validation.\nexport const themeResolver: ThemeResolver<ThemeRegistrationResolved> =\n createThemeResolver<ThemeRegistrationResolved>();\n"],"mappings":";;AAgBA,MAAa,gBACX,oBAA+C"}
|
|
1
|
+
{"version":3,"file":"themeResolver.js","names":[],"sources":["../../../src/highlighter/themes/themeResolver.ts"],"sourcesContent":["import type {\n Theme as ZedTheme,\n ThemeFamily as ZedThemeFamily,\n} from '@pierre/highlights';\nimport {\n createThemeResolver,\n type ThemeLoader,\n type ThemeResolver,\n} from '@pierre/theming';\nimport type { ThemeRegistration } from 'shiki';\n\nimport type { HighlighterTypes } from '../../types';\nimport { isWorkerContext } from '../../utils/isWorkerContext';\nimport { createCachedLoader } from './createCachedLoader';\nimport type { DiffsTheme } from './types';\n\ndeclare const __DIFFS_WORKER__: boolean | undefined;\n\nexport type CustomThemeLoader = ThemeLoader<\n ThemeRegistration | DiffsTheme | ZedTheme | ZedThemeFamily\n>;\nexport const customThemes: Map<\n string,\n Partial<Record<'textmate' | 'zed' | 'diffs', CustomThemeLoader>>\n> = new Map();\nconst resolvers = new Map<HighlighterTypes, ThemeResolver<DiffsTheme>>();\n\nconst loadHighlightsThemeCatalog = createCachedLoader(\n () => import('@pierre/highlights/themes/loader')\n);\nconst loadPierreThemeCatalog = createCachedLoader(\n () => import('@pierre/theming/themes')\n);\nconst loadShikiCore = createCachedLoader(() => import('shiki/core'));\n\n// Map Zed colors to the VS Code keys used by editor and diff overlays.\nconst ZED_COLOR_ALIASES: readonly (readonly [\n target: string,\n ...sources: string[],\n])[] = [\n ['editor.lineHighlightBackground', 'editor.active_line.background'],\n ['editor.selectionBackground', 'element.selected'],\n ['editor.findMatchBackground', 'search.match_background'],\n ['editor.findMatchHighlightBackground', 'search.match_background'],\n [\n 'editorBracketMatch.background',\n 'editor.document_highlight.bracket_background',\n ],\n ['editorError.foreground', 'error'],\n ['editorWarning.foreground', 'warning'],\n ['editorInfo.foreground', 'info'],\n ['editorHint.foreground', 'hint'],\n ['gitDecoration.addedResourceForeground', 'created', 'terminal.ansi.green'],\n ['gitDecoration.deletedResourceForeground', 'deleted', 'terminal.ansi.red'],\n [\n 'gitDecoration.modifiedResourceForeground',\n 'modified',\n 'terminal.ansi.blue',\n ],\n];\n\nfunction createHighlightsTheme(\n name: string,\n raw: ZedTheme | ZedThemeFamily\n): DiffsTheme {\n const theme = 'themes' in raw ? raw.themes[0] : raw;\n if (theme == null)\n throw new Error(`Theme \"${name}\" is an empty Zed theme family.`);\n const zed = { ...theme, name };\n const colors: Record<string, string> = {};\n for (const [key, value] of Object.entries(zed.style)) {\n if (typeof value === 'string') colors[key] = value;\n }\n // Zed keeps the local user's caret and selection in the first player slot.\n const player = zed.style.players?.[0];\n if (player?.cursor != null)\n colors['editorCursor.foreground'] ??= player.cursor;\n if (player?.selection != null)\n colors['editor.selectionBackground'] ??= player.selection;\n for (const [target, ...sources] of ZED_COLOR_ALIASES) {\n if (colors[target] != null) continue;\n const source = sources.find((key) => colors[key] != null);\n if (source != null) colors[target] = colors[source];\n }\n if (zed.cssVariables === true) {\n colors['editor.foreground'] = 'var(--hls-foreground)';\n colors['editor.background'] = 'var(--hls-background)';\n } else if (typeof zed.cssVariables === 'object') {\n colors['editor.foreground'] ??=\n colors.text ?? colors.foreground ?? 'foreground';\n colors['editor.background'] ??= colors.background ?? 'background';\n const { prefix = '--hls-', defaults } = zed.cssVariables;\n for (const [key, value] of Object.entries(colors)) {\n const fallback = defaults?.[value];\n colors[key] = `var(${prefix}${value}${fallback ? `, ${fallback}` : ''})`;\n }\n }\n const type = zed.appearance === 'light' ? 'light' : 'dark';\n return {\n name,\n type,\n colors,\n zed,\n fg:\n colors['editor.foreground'] ??\n colors.text ??\n colors.foreground ??\n (type === 'light' ? '#333333' : '#bbbbbb'),\n bg:\n colors['editor.background'] ??\n colors.background ??\n (type === 'light' ? '#ffffff' : '#1e1e1e'),\n };\n}\n\n/** Keep caches separate because the same name can have TextMate and Zed palettes. */\nexport function createDiffsThemeResolver(\n backend: HighlighterTypes\n): ThemeResolver<DiffsTheme> {\n let resolver = resolvers.get(backend);\n if (resolver != null) return resolver;\n resolver = createThemeResolver<DiffsTheme>({\n fallbackLoader: async (name) => {\n if (\n typeof __DIFFS_WORKER__ !== 'undefined'\n ? __DIFFS_WORKER__\n : isWorkerContext()\n ) {\n throw new Error(\n `Theme \"${name}\" cannot be resolved from a worker context. Themes must be pre-resolved on the main thread and passed to the worker via the resolvedThemes parameter.`\n );\n }\n const custom = customThemes.get(name);\n if (backend === 'highlights') {\n const loader = custom?.zed ?? custom?.diffs;\n if (loader != null) {\n const loaded = await loader();\n const theme = 'default' in loaded ? loaded.default : loaded;\n if ('zed' in theme && theme.zed != null) return theme;\n if ('style' in theme || 'themes' in theme)\n return createHighlightsTheme(name, theme);\n throw new Error(\n `Theme \"${name}\" is a TextMate theme; register a Zed theme with registerCustomTheme(name, loader, 'zed') for Highlights.`\n );\n }\n const catalog = loadHighlightsThemeCatalog();\n const { themes } = catalog instanceof Promise ? await catalog : catalog;\n const bundledLoader = themes[name];\n if (bundledLoader != null) {\n const loaded = await bundledLoader();\n return createHighlightsTheme(name, loaded.default);\n }\n if (custom?.textmate != null) {\n throw new Error(\n `Theme \"${name}\" is only registered for TextMate; use registerCustomTheme(name, loader, 'zed') for Highlights.`\n );\n }\n } else {\n const loader = custom?.textmate ?? custom?.diffs;\n let loaded: ThemeRegistration | DiffsTheme | ZedTheme | ZedThemeFamily;\n if (loader != null) {\n const result = await loader();\n loaded = 'default' in result ? result.default : result;\n } else {\n const catalog = loadPierreThemeCatalog();\n const { themes } =\n catalog instanceof Promise ? await catalog : catalog;\n const descriptor = themes.getTheme(name);\n if (descriptor == null && custom?.zed != null) {\n throw new Error(\n `Theme \"${name}\" is only registered for Zed; use registerCustomTheme(name, loader, 'textmate') for Shiki.`\n );\n }\n if (descriptor == null)\n throw new Error(`No valid theme loader registered for \"${name}\"`);\n const result = await descriptor.load();\n loaded = 'default' in result ? result.default : result;\n }\n if ('style' in loaded || 'themes' in loaded) {\n throw new Error(\n `Theme \"${name}\" is a Zed theme; use preferredHighlighter: 'highlights' or register a TextMate theme for Shiki.`\n );\n }\n const core = loadShikiCore();\n const { normalizeTheme, createCssVariablesTheme } =\n core instanceof Promise ? await core : core;\n if ('cssVariables' in loaded && loaded.cssVariables != null) {\n return {\n ...loaded,\n textmate: normalizeTheme(\n createCssVariablesTheme(loaded.cssVariables)\n ),\n };\n }\n if ('textmate' in loaded && loaded.textmate != null) {\n return { ...loaded, textmate: normalizeTheme(loaded.textmate) };\n }\n const textmate = normalizeTheme(loaded);\n return {\n name: textmate.name,\n type: textmate.type,\n fg: textmate.fg,\n bg: textmate.bg,\n colors: textmate.colors,\n textmate,\n };\n }\n throw new Error(`No valid theme loader registered for \"${name}\"`);\n },\n normalizeTheme: (theme, name) => {\n if (theme.name !== name)\n throw new Error(\n `resolvedTheme: themeName: ${name} does not match theme.name: ${theme.name}`\n );\n return theme;\n },\n });\n resolvers.set(backend, resolver);\n return resolver;\n}\n"],"mappings":";;;;AAqBA,MAAa,+BAGT,IAAI,IAAI;AACZ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S,MACjB,MAAM,IAAI,MACR,6BAA6B,KAAK,8BAA8B,MAAM,MACxE;GACF,OAAO;EACT;CACF,CAAC;CACD,UAAU,IAAI,SAAS,QAAQ;CAC/B,OAAO;AACT"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ThemeLike } from "@pierre/theming";
|
|
2
|
+
import { ThemeRegistrationResolved } from "shiki";
|
|
3
|
+
import { Theme } from "@pierre/highlights";
|
|
4
|
+
//#region src/highlighter/themes/types.d.ts
|
|
5
|
+
/** Shared editor colors with the syntax theme for each supported backend. */
|
|
6
|
+
interface DiffsTheme extends ThemeLike {
|
|
7
|
+
name: string;
|
|
8
|
+
type: 'dark' | 'light';
|
|
9
|
+
fg: string;
|
|
10
|
+
bg: string;
|
|
11
|
+
textmate?: ThemeRegistrationResolved;
|
|
12
|
+
zed?: Theme;
|
|
13
|
+
cssVariables?: CSSVariablesThemeOptions;
|
|
14
|
+
}
|
|
15
|
+
interface CSSVariablesThemeOptions {
|
|
16
|
+
name?: string;
|
|
17
|
+
variablePrefix?: string;
|
|
18
|
+
variableDefaults?: Record<string, string>;
|
|
19
|
+
fontStyle?: boolean;
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
export { CSSVariablesThemeOptions, DiffsTheme };
|
|
23
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/highlighter/themes/types.ts"],"mappings":";;;;;UAKiB,mBAAmB;EAClC;EACA;EACA;EACA;EACA,WAAW;EACX,MAAM;EACN,eAAe;;UAGA;EACf;EACA;EACA,mBAAmB;EACnB"}
|
|
File without changes
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ThemedToken } from "./types.js";
|
|
2
|
+
import { HighlightedToken } from "../types.js";
|
|
3
|
+
import { TextDocument } from "../editor/textDocument.js";
|
|
4
|
+
//#region src/highlighter/tokenizer-types.d.ts
|
|
5
|
+
/** Document and callbacks owned by an editor's incremental tokenizer. */
|
|
6
|
+
interface DiffsEditorTokenizerOptions {
|
|
7
|
+
textDocument: Pick<TextDocument, 'getText' | 'getLineText' | 'lineCount' | 'languageId' | 'version'>;
|
|
8
|
+
theme: string;
|
|
9
|
+
tokenizeMaxLineLength?: number;
|
|
10
|
+
matchBrackets?: boolean;
|
|
11
|
+
onDeferTokenize: (lines: Map<number, HighlightedToken[]>) => void;
|
|
12
|
+
__debug?: boolean;
|
|
13
|
+
}
|
|
14
|
+
/** Previously emitted provisional tokens to remove before applying new tokens. */
|
|
15
|
+
interface RecallToken {
|
|
16
|
+
recall: number;
|
|
17
|
+
}
|
|
18
|
+
interface DiffsStreamTokenizerEnqueueResult {
|
|
19
|
+
recall: number;
|
|
20
|
+
stable: ThemedToken[];
|
|
21
|
+
unstable: ThemedToken[];
|
|
22
|
+
}
|
|
23
|
+
/** Incremental source chunks with a replaceable final line. */
|
|
24
|
+
interface DiffsStreamTokenizer {
|
|
25
|
+
enqueue(chunk: string): DiffsStreamTokenizerEnqueueResult | Promise<DiffsStreamTokenizerEnqueueResult>;
|
|
26
|
+
close(): {
|
|
27
|
+
stable: ThemedToken[];
|
|
28
|
+
};
|
|
29
|
+
clear(): void;
|
|
30
|
+
clone(): DiffsStreamTokenizer;
|
|
31
|
+
dispose(): void;
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
export { DiffsEditorTokenizerOptions, DiffsStreamTokenizer, DiffsStreamTokenizerEnqueueResult, RecallToken };
|
|
35
|
+
//# sourceMappingURL=tokenizer-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokenizer-types.d.ts","names":[],"sources":["../../src/highlighter/tokenizer-types.ts"],"mappings":";;;;;UAKiB;EACf,cAAc,KACZ;EAGF;EACA;EACA;EACA,kBAAkB,OAAO,YAAY;EACrC;;;UAIe;EACf;;UAGe;EACf;EACA,QAAQ;EACR,UAAU;;;UAIK;EACf,QACE,gBAEE,oCACA,QAAQ;EACZ;IAAW,QAAQ;;EACnB;EACA,SAAS;EACT"}
|
|
File without changes
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Properties } from "../node_modules/.pnpm/@types_hast@3.0.4/node_modules/@types/hast/index.js";
|
|
2
|
+
import { DiffsEditorTokenizer } from "./DiffsEditorTokenizer.js";
|
|
3
|
+
import { DiffsEditorTokenizerOptions, DiffsStreamTokenizer } from "./tokenizer-types.js";
|
|
4
|
+
import { DiffsHighlighter } from "./DiffsHighlighter.js";
|
|
5
|
+
//#region src/highlighter/types.d.ts
|
|
6
|
+
/** One styled run, with its absolute UTF-16 offset in the source. */
|
|
7
|
+
interface ThemedToken {
|
|
8
|
+
content: string;
|
|
9
|
+
offset: number;
|
|
10
|
+
color?: string;
|
|
11
|
+
bgColor?: string;
|
|
12
|
+
fontStyle?: number;
|
|
13
|
+
htmlStyle?: Record<string, string>;
|
|
14
|
+
htmlAttrs?: Record<string, string>;
|
|
15
|
+
type?: number;
|
|
16
|
+
}
|
|
17
|
+
interface DecorationItem {
|
|
18
|
+
start: number | {
|
|
19
|
+
line: number;
|
|
20
|
+
character: number;
|
|
21
|
+
};
|
|
22
|
+
end: number | {
|
|
23
|
+
line: number;
|
|
24
|
+
character: number;
|
|
25
|
+
};
|
|
26
|
+
properties?: Properties;
|
|
27
|
+
alwaysWrap?: boolean;
|
|
28
|
+
}
|
|
29
|
+
type CodeToTokensOptions = {
|
|
30
|
+
lang: string;
|
|
31
|
+
defaultColor?: string | false;
|
|
32
|
+
cssVariablePrefix?: string;
|
|
33
|
+
tokenizeMaxLineLength?: number;
|
|
34
|
+
tokenizeTimeLimit?: number;
|
|
35
|
+
mergeWhitespaces?: 'never' | 'always';
|
|
36
|
+
} & ({
|
|
37
|
+
theme: string;
|
|
38
|
+
themes?: undefined;
|
|
39
|
+
} | {
|
|
40
|
+
theme?: undefined;
|
|
41
|
+
themes: Record<string, string>;
|
|
42
|
+
});
|
|
43
|
+
type CodeToHtmlOptions = CodeToTokensOptions & {
|
|
44
|
+
decorations?: DecorationItem[];
|
|
45
|
+
};
|
|
46
|
+
interface TokensResult {
|
|
47
|
+
tokens: ThemedToken[][];
|
|
48
|
+
fg?: string;
|
|
49
|
+
bg?: string;
|
|
50
|
+
themeName?: string;
|
|
51
|
+
rootStyle?: string | false;
|
|
52
|
+
}
|
|
53
|
+
//#endregion
|
|
54
|
+
export { CodeToHtmlOptions, CodeToTokensOptions, DecorationItem, type DiffsEditorTokenizer, type DiffsEditorTokenizerOptions, type DiffsHighlighter, type DiffsStreamTokenizer, ThemedToken, TokensResult };
|
|
55
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../../src/highlighter/types.ts"],"mappings":";;;;;;UAUiB;EACf;EACA;EACA;EACA;EACA;EACA,YAAY;EACZ,YAAY;EACZ;;UAGe;EACf;IAAkB;IAAc;;EAChC;IAAgB;IAAc;;EAC9B,aAAa;EACb;;KAGU;EACV;EACA;EACA;EACA;EACA;EACA;;EAEI;EAAe;;EACf;EAAmB,QAAQ;;KAGrB,oBAAoB;EAC9B,cAAc;;UAGC;EACf,QAAQ;EACR;EACA;EACA;EACA"}
|
|
File without changes
|