pi-umbra 0.3.0 → 0.4.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 +3 -4
- package/node_modules/@shikijs/cli/dist/cli.d.mts +13 -6
- package/node_modules/@shikijs/cli/dist/cli.mjs +32 -27
- package/node_modules/@shikijs/cli/dist/{code-to-ansi-BNrZay-4.mjs → code-to-ansi-Dmm_CuZ9.mjs} +15 -7
- package/node_modules/@shikijs/cli/dist/index.d.mts +24 -3
- package/node_modules/@shikijs/cli/dist/index.mjs +1 -1
- package/node_modules/@shikijs/cli/package.json +3 -3
- package/node_modules/@shikijs/core/dist/index.d.mts +28 -28
- package/node_modules/@shikijs/core/dist/index.mjs +15 -12
- package/node_modules/@shikijs/core/package.json +4 -4
- package/node_modules/@shikijs/engine-javascript/dist/{engine-compile-Bdn9ihA2.d.mts → engine-compile-CtqiSkRk.d.mts} +5 -0
- package/node_modules/@shikijs/engine-javascript/dist/engine-compile.d.mts +1 -1
- package/node_modules/@shikijs/engine-javascript/dist/engine-compile.mjs +2 -4
- package/node_modules/@shikijs/engine-javascript/dist/engine-raw.d.mts +2 -3
- package/node_modules/@shikijs/engine-javascript/dist/engine-raw.mjs +2 -4
- package/node_modules/@shikijs/engine-javascript/dist/index.d.mts +1 -1
- package/node_modules/@shikijs/engine-javascript/dist/index.mjs +1 -1
- package/node_modules/@shikijs/engine-javascript/dist/string-TLTPtCPs.mjs +115 -0
- package/node_modules/@shikijs/engine-javascript/package.json +3 -3
- package/node_modules/@shikijs/engine-oniguruma/package.json +3 -3
- package/node_modules/@shikijs/langs/dist/ada.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/ahk.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/beancount.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/coq.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/csharp.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/css.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/dart.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/dotenv.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/emacs-lisp.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/gn.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/handlebars.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/julia.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/latex.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/luau.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/marko.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/moonbit.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/nextflow-groovy.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/nextflow.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/nushell.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/php.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/powershell.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/ruby.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/rust.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/sql.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/svelte.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/twig.mjs +3 -3
- package/node_modules/@shikijs/langs/dist/typespec.mjs +1 -1
- package/node_modules/@shikijs/langs/package.json +3 -3
- package/node_modules/@shikijs/primitive/dist/index.d.mts +31 -32
- package/node_modules/@shikijs/primitive/dist/index.mjs +2 -1
- package/node_modules/@shikijs/primitive/package.json +3 -3
- package/node_modules/@shikijs/themes/dist/monokai.mjs +1 -1
- package/node_modules/@shikijs/themes/dist/one-dark-pro.mjs +1 -1
- package/node_modules/@shikijs/themes/dist/red.mjs +1 -1
- package/node_modules/@shikijs/themes/dist/solarized-dark.mjs +1 -1
- package/node_modules/@shikijs/themes/dist/solarized-light.mjs +1 -1
- package/node_modules/@shikijs/themes/package.json +3 -3
- package/node_modules/@shikijs/types/dist/index.d.mts +76 -76
- package/node_modules/@shikijs/types/package.json +1 -1
- package/node_modules/pi-umbra-copy-chat/README.md +4 -7
- package/node_modules/pi-umbra-copy-chat/extensions/umbra-copy-chat.ts +16 -54
- package/node_modules/pi-umbra-copy-chat/package.json +1 -1
- package/node_modules/pi-umbra-help/checks/umbra-help.check.ts +10 -1
- package/node_modules/pi-umbra-help/extensions/umbra-help.ts +31 -0
- package/node_modules/pi-umbra-help/package.json +1 -1
- package/node_modules/pi-umbra-inputbar/README.md +1 -1
- package/node_modules/pi-umbra-inputbar/extensions/umbra-inputbar.ts +1 -1
- package/node_modules/pi-umbra-inputbar/package.json +2 -2
- package/node_modules/pi-umbra-shimmer/package.json +1 -1
- package/node_modules/pi-umbra-shimmer/patch.mjs +23 -21
- package/node_modules/pi-umbra-skill-matcher/package.json +1 -1
- package/node_modules/pi-umbra-skill-matcher/patch.mjs +7 -0
- package/node_modules/pi-umbra-subagents/README.md +24 -6
- package/node_modules/pi-umbra-subagents/extensions/umbra-subagents/bar/bar-line.ts +250 -102
- package/node_modules/pi-umbra-subagents/extensions/umbra-subagents/bar.check.ts +133 -66
- package/node_modules/pi-umbra-subagents/extensions/umbra-subagents/bar.ts +59 -27
- package/node_modules/pi-umbra-subagents/extensions/umbra-subagents/fan/index.ts +53 -8
- package/node_modules/pi-umbra-subagents/extensions/umbra-subagents/fan/spec.ts +24 -14
- package/node_modules/pi-umbra-subagents/extensions/umbra-subagents/fan/store.check.ts +132 -5
- package/node_modules/pi-umbra-subagents/extensions/umbra-subagents/fan/store.ts +156 -64
- package/node_modules/pi-umbra-subagents/extensions/umbra-subagents/fan/worktree.ts +156 -0
- package/node_modules/pi-umbra-subagents/extensions/umbra-subagents/panel.ts +1 -1
- package/node_modules/pi-umbra-subagents/extensions/umbra-subagents/skills/delegate/state.ts +19 -0
- package/node_modules/pi-umbra-subagents/extensions/umbra-subagents/skills/fan/SKILL.md +25 -4
- package/node_modules/pi-umbra-subagents/package.json +2 -2
- package/node_modules/pi-umbra-theme/checks/umbra-background.check.ts +7 -1
- package/node_modules/pi-umbra-theme/extensions/umbra-background.ts +2 -1
- package/node_modules/pi-umbra-theme/package.json +3 -3
- package/node_modules/shiki/dist/bundle-full.d.mts +4 -4
- package/node_modules/shiki/dist/bundle-web.d.mts +9 -9
- package/node_modules/shiki/dist/types.d.mts +3 -3
- package/node_modules/shiki/package.json +10 -10
- package/package.json +9 -12
- package/node_modules/@shikijs/engine-javascript/dist/scanner-DX8LRFGE.mjs +0 -77
- package/node_modules/pi-umbra-rename/LICENSE +0 -21
- package/node_modules/pi-umbra-rename/README.md +0 -18
- package/node_modules/pi-umbra-rename/checks/umbra-rename.check.ts +0 -55
- package/node_modules/pi-umbra-rename/extensions/umbra-rename.ts +0 -22
- package/node_modules/pi-umbra-rename/package.json +0 -36
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Every pi-umbra package in one install: seven dark themes, tool calls drawn as cards, a
|
|
4
4
|
status footer, an input bar with the session name, a working line that names the running
|
|
5
|
-
tool, parallel read-only
|
|
5
|
+
tool, parallel pi branches (read-only, or editing in their own git worktree) with a live agent tree, and the `/umb-*` commands.
|
|
6
6
|
|
|
7
7
|

|
|
8
8
|
|
|
@@ -10,7 +10,7 @@ tool, parallel read-only branches with a live panel, and the `/umb-*` commands.
|
|
|
10
10
|
pi install npm:pi-umbra
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
The
|
|
13
|
+
The nine packages ship bundled inside this one tarball. Three of them patch pi's bundle, so
|
|
14
14
|
run the three scripts once now and again after every pi update, then restart pi:
|
|
15
15
|
|
|
16
16
|
```sh
|
|
@@ -26,11 +26,10 @@ node ~/.pi/agent/npm/node_modules/pi-umbra/node_modules/pi-umbra-subagents/patch
|
|
|
26
26
|
| [pi-umbra-ask](https://www.npmjs.com/package/pi-umbra-ask) | a tool the model calls to ask you a question and wait |
|
|
27
27
|
| [pi-umbra-shimmer](https://www.npmjs.com/package/pi-umbra-shimmer) | a wave of colour through the working line, `/umb-shimmer` |
|
|
28
28
|
| [pi-umbra-skill-matcher](https://www.npmjs.com/package/pi-umbra-skill-matcher) | `/name` runs `skill:name`, completion mid-sentence |
|
|
29
|
-
| [pi-umbra-rename](https://www.npmjs.com/package/pi-umbra-rename) | `/umb-rename`, session name and terminal title |
|
|
30
29
|
| [pi-umbra-copy-chat](https://www.npmjs.com/package/pi-umbra-copy-chat) | `/umb-copy-chat`, the session on the clipboard |
|
|
31
30
|
| [pi-umbra-preview](https://www.npmjs.com/package/pi-umbra-preview) | `/umb-preview`, render a document in the browser |
|
|
32
31
|
| [pi-umbra-help](https://www.npmjs.com/package/pi-umbra-help) | `/umb-help` and `/umb-doctor` |
|
|
33
|
-
| [pi-umbra-subagents](https://www.npmjs.com/package/pi-umbra-subagents) | parallel read-only
|
|
32
|
+
| [pi-umbra-subagents](https://www.npmjs.com/package/pi-umbra-subagents) | parallel pi branches, read-only or in their own git worktree, with a live agent tree, `/umb-fan`, `/umb-loop` |
|
|
34
33
|
|
|
35
34
|
Full documentation: [github.com/grknbyk/pi-umbra](https://github.com/grknbyk/pi-umbra).
|
|
36
35
|
|
|
@@ -1,10 +1,17 @@
|
|
|
1
|
+
import { Readable } from "node:stream";
|
|
1
2
|
//#region src/cli.d.ts
|
|
2
|
-
declare function isUrl(path: string): boolean;
|
|
3
|
-
declare function getExtFromUrl(url: string): string;
|
|
4
|
-
|
|
3
|
+
export declare function isUrl(path: string): boolean;
|
|
4
|
+
export declare function getExtFromUrl(url: string): string;
|
|
5
|
+
/**
|
|
6
|
+
* Unknown languages fall back to plaintext so the CLI can be used as a `cat` replacement.
|
|
7
|
+
* Known-language grammar load/parse errors are not swallowed.
|
|
8
|
+
*/
|
|
9
|
+
export declare function resolveLanguage(lang: string): string;
|
|
10
|
+
export declare function readSource(path: string): Promise<{
|
|
5
11
|
content: string;
|
|
6
12
|
ext: string;
|
|
7
13
|
}>;
|
|
8
|
-
declare function run(argv?: string[], log?: (...data: any[]) => void
|
|
9
|
-
|
|
10
|
-
|
|
14
|
+
export declare function run(argv?: string[], log?: (...data: any[]) => void, stdin?: Readable & {
|
|
15
|
+
isTTY?: boolean;
|
|
16
|
+
}): Promise<void>;
|
|
17
|
+
//#endregion
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { t as codeToANSI } from "./code-to-ansi-
|
|
1
|
+
import { t as codeToANSI } from "./code-to-ansi-Dmm_CuZ9.mjs";
|
|
2
|
+
import { bundledLanguages, isSpecialLang } from "shiki";
|
|
2
3
|
import fs from "node:fs/promises";
|
|
3
4
|
import { parse } from "node:path";
|
|
4
5
|
import process from "node:process";
|
|
5
6
|
import cac from "cac";
|
|
6
7
|
//#region package.json
|
|
7
|
-
var version = "4.
|
|
8
|
+
var version = "4.5.0";
|
|
8
9
|
//#endregion
|
|
9
10
|
//#region src/cli.ts
|
|
10
11
|
function isUrl(path) {
|
|
@@ -18,6 +19,26 @@ function getExtFromUrl(url) {
|
|
|
18
19
|
return "";
|
|
19
20
|
}
|
|
20
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Unknown languages fall back to plaintext so the CLI can be used as a `cat` replacement.
|
|
24
|
+
* Known-language grammar load/parse errors are not swallowed.
|
|
25
|
+
*/
|
|
26
|
+
function resolveLanguage(lang) {
|
|
27
|
+
const normalized = lang.toLowerCase();
|
|
28
|
+
if (normalized in bundledLanguages || isSpecialLang(normalized)) return normalized;
|
|
29
|
+
return "text";
|
|
30
|
+
}
|
|
31
|
+
async function render(content, lang, theme, format) {
|
|
32
|
+
const resolved = resolveLanguage(lang);
|
|
33
|
+
if (format === "html") {
|
|
34
|
+
const { codeToHtml } = await import("shiki");
|
|
35
|
+
return await codeToHtml(content, {
|
|
36
|
+
lang: resolved,
|
|
37
|
+
theme
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
return await codeToANSI(content, resolved, theme);
|
|
41
|
+
}
|
|
21
42
|
async function readSource(path) {
|
|
22
43
|
if (isUrl(path)) {
|
|
23
44
|
const response = await fetch(path);
|
|
@@ -31,7 +52,7 @@ async function readSource(path) {
|
|
|
31
52
|
ext: parse(path).ext.slice(1).toLowerCase()
|
|
32
53
|
};
|
|
33
54
|
}
|
|
34
|
-
async function run(argv = process.argv, log = console.log) {
|
|
55
|
+
async function run(argv = process.argv, log = console.log, stdin = process.stdin) {
|
|
35
56
|
const cli = cac("shiki");
|
|
36
57
|
cli.option("--theme <theme>", "Color theme to use", { default: "vitesse-dark" }).option("--lang <lang>", "Programming language").option("--format <format>", "Output format (ansi, html)", { default: "ansi" }).option("--list-themes", "List all available themes").option("--list-langs", "List all available languages").help().version(version);
|
|
37
58
|
const { options, args } = cli.parse(argv);
|
|
@@ -41,27 +62,18 @@ async function run(argv = process.argv, log = console.log) {
|
|
|
41
62
|
return;
|
|
42
63
|
}
|
|
43
64
|
if (options.listLangs) {
|
|
44
|
-
const { bundledLanguages } = await import("shiki");
|
|
45
65
|
for (const lang of Object.keys(bundledLanguages)) log(lang);
|
|
46
66
|
return;
|
|
47
67
|
}
|
|
48
68
|
const files = args;
|
|
49
69
|
if (files.length === 0) {
|
|
50
|
-
if (!
|
|
51
|
-
|
|
70
|
+
if (!stdin.isTTY) {
|
|
71
|
+
log(await render(await new Promise((resolve, reject) => {
|
|
52
72
|
let data = "";
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
});
|
|
57
|
-
const lang = options.lang || "text";
|
|
58
|
-
if (options.format === "html") {
|
|
59
|
-
const { codeToHtml } = await import("shiki");
|
|
60
|
-
log(await codeToHtml(content, {
|
|
61
|
-
lang,
|
|
62
|
-
theme: options.theme
|
|
63
|
-
}));
|
|
64
|
-
} else log(await codeToANSI(content, lang, options.theme));
|
|
73
|
+
stdin.on("data", (chunk) => data += chunk);
|
|
74
|
+
stdin.on("end", () => resolve(data));
|
|
75
|
+
stdin.on("error", reject);
|
|
76
|
+
}), options.lang || "text", options.theme, options.format));
|
|
65
77
|
return;
|
|
66
78
|
}
|
|
67
79
|
cli.outputHelp();
|
|
@@ -69,17 +81,10 @@ async function run(argv = process.argv, log = console.log) {
|
|
|
69
81
|
}
|
|
70
82
|
const codes = await Promise.all(files.map(async (path) => {
|
|
71
83
|
const { content, ext } = await readSource(path);
|
|
72
|
-
|
|
73
|
-
if (options.format === "html") {
|
|
74
|
-
const { codeToHtml } = await import("shiki");
|
|
75
|
-
return await codeToHtml(content, {
|
|
76
|
-
lang,
|
|
77
|
-
theme: options.theme
|
|
78
|
-
});
|
|
79
|
-
} else return await codeToANSI(content, lang, options.theme);
|
|
84
|
+
return await render(content, options.lang || ext || "text", options.theme, options.format);
|
|
80
85
|
}));
|
|
81
86
|
for (const code of codes) log(code);
|
|
82
87
|
}
|
|
83
88
|
run();
|
|
84
89
|
//#endregion
|
|
85
|
-
export { getExtFromUrl, isUrl, readSource, run };
|
|
90
|
+
export { getExtFromUrl, isUrl, readSource, resolveLanguage, run };
|
package/node_modules/@shikijs/cli/dist/{code-to-ansi-BNrZay-4.mjs → code-to-ansi-Dmm_CuZ9.mjs}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FontStyle } from "@shikijs/vscode-textmate";
|
|
2
|
-
import
|
|
2
|
+
import { Ansis } from "ansis";
|
|
3
3
|
import { codeToTokensBase, getSingletonHighlighter } from "shiki";
|
|
4
4
|
//#region src/colors.ts
|
|
5
5
|
const RE_HASH = /#/;
|
|
@@ -36,7 +36,15 @@ function hexApplyAlpha(hex, type = "dark") {
|
|
|
36
36
|
}
|
|
37
37
|
//#endregion
|
|
38
38
|
//#region src/code-to-ansi.ts
|
|
39
|
-
|
|
39
|
+
/**
|
|
40
|
+
* Converts code to a string containing ANSI escape codes.
|
|
41
|
+
*
|
|
42
|
+
* The color level is explicit and does not depend on the current environment,
|
|
43
|
+
* as the result is not necessarily printed to the terminal that runs this
|
|
44
|
+
* code. Pass {@link CodeToANSIOptions.colorLevel} to target a different level.
|
|
45
|
+
*/
|
|
46
|
+
async function codeToANSI(code, lang, theme, options = {}) {
|
|
47
|
+
const ansi = new Ansis(options.colorLevel ?? 3);
|
|
40
48
|
let output = "";
|
|
41
49
|
const lines = await codeToTokensBase(code, {
|
|
42
50
|
lang,
|
|
@@ -47,12 +55,12 @@ async function codeToANSI(code, lang, theme) {
|
|
|
47
55
|
for (const token of line) {
|
|
48
56
|
let text = token.content;
|
|
49
57
|
const color = token.color || themeReg.fg;
|
|
50
|
-
if (color) text =
|
|
58
|
+
if (color) text = ansi.hex(hexApplyAlpha(color, themeReg.type))(text);
|
|
51
59
|
if (token.fontStyle) {
|
|
52
|
-
if (token.fontStyle & FontStyle.Bold) text =
|
|
53
|
-
if (token.fontStyle & FontStyle.Italic) text =
|
|
54
|
-
if (token.fontStyle & FontStyle.Underline) text =
|
|
55
|
-
if (token.fontStyle & FontStyle.Strikethrough) text =
|
|
60
|
+
if (token.fontStyle & FontStyle.Bold) text = ansi.bold(text);
|
|
61
|
+
if (token.fontStyle & FontStyle.Italic) text = ansi.italic(text);
|
|
62
|
+
if (token.fontStyle & FontStyle.Underline) text = ansi.underline(text);
|
|
63
|
+
if (token.fontStyle & FontStyle.Strikethrough) text = ansi.strikethrough(text);
|
|
56
64
|
}
|
|
57
65
|
output += text;
|
|
58
66
|
}
|
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
import { BundledLanguage, BundledTheme } from "shiki";
|
|
2
2
|
//#region src/code-to-ansi.d.ts
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
/**
|
|
4
|
+
* The ANSI color level of the emitted escape codes, matching the levels
|
|
5
|
+
* understood by `ansis`: `0` no color, `1` basic (16 colors), `2` 256 colors,
|
|
6
|
+
* `3` truecolor (24-bit).
|
|
7
|
+
*/
|
|
8
|
+
export type ANSIColorLevel = 0 | 1 | 2 | 3;
|
|
9
|
+
export interface CodeToANSIOptions {
|
|
10
|
+
/**
|
|
11
|
+
* The color level to emit.
|
|
12
|
+
*
|
|
13
|
+
* Defaults to `3` (truecolor), so the result does not depend on the
|
|
14
|
+
* environment this code happens to run in.
|
|
15
|
+
*/
|
|
16
|
+
colorLevel?: ANSIColorLevel;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Converts code to a string containing ANSI escape codes.
|
|
20
|
+
*
|
|
21
|
+
* The color level is explicit and does not depend on the current environment,
|
|
22
|
+
* as the result is not necessarily printed to the terminal that runs this
|
|
23
|
+
* code. Pass {@link CodeToANSIOptions.colorLevel} to target a different level.
|
|
24
|
+
*/
|
|
25
|
+
export declare function codeToANSI(code: string, lang: BundledLanguage, theme: BundledTheme, options?: CodeToANSIOptions): Promise<string>;
|
|
26
|
+
//#endregion
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as codeToANSI } from "./code-to-ansi-
|
|
1
|
+
import { t as codeToANSI } from "./code-to-ansi-Dmm_CuZ9.mjs";
|
|
2
2
|
export { codeToANSI };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shikijs/cli",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.5.0",
|
|
5
5
|
"description": "Shiki in the command line",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -40,9 +40,9 @@
|
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@shikijs/vscode-textmate": "^10.0.2",
|
|
43
|
-
"ansis": "^4.
|
|
43
|
+
"ansis": "^4.4.0",
|
|
44
44
|
"cac": "^7.0.0",
|
|
45
|
-
"shiki": "4.
|
|
45
|
+
"shiki": "4.5.0"
|
|
46
46
|
},
|
|
47
47
|
"scripts": {
|
|
48
48
|
"build": "tsdown",
|
|
@@ -24,8 +24,8 @@ export * from "@shikijs/types";
|
|
|
24
24
|
*
|
|
25
25
|
* @param options
|
|
26
26
|
*/
|
|
27
|
-
declare function createBundledHighlighter<BundledLangs extends string, BundledThemes extends string>(options: CreateBundledHighlighterOptions<BundledLangs, BundledThemes>): CreateHighlighterFactory<BundledLangs, BundledThemes>;
|
|
28
|
-
interface ShorthandsBundle<L extends string, T extends string> {
|
|
27
|
+
export declare function createBundledHighlighter<BundledLangs extends string, BundledThemes extends string>(options: CreateBundledHighlighterOptions<BundledLangs, BundledThemes>): CreateHighlighterFactory<BundledLangs, BundledThemes>;
|
|
28
|
+
export interface ShorthandsBundle<L extends string, T extends string> {
|
|
29
29
|
/**
|
|
30
30
|
* Shorthand for `codeToHtml` with auto-loaded theme and language.
|
|
31
31
|
* A singleton highlighter it maintained internally.
|
|
@@ -71,14 +71,14 @@ interface ShorthandsBundle<L extends string, T extends string> {
|
|
|
71
71
|
*/
|
|
72
72
|
getLastGrammarState: ((element: ThemedToken[][] | Root) => GrammarState) | ((code: string, options: CodeToTokensBaseOptions<L, T>) => Promise<GrammarState>);
|
|
73
73
|
}
|
|
74
|
-
declare function makeSingletonHighlighter<L extends string, T extends string>(createHighlighter: CreateHighlighterFactory<L, T>): (options?: Partial<BundledHighlighterOptions<L, T>>) => Promise<HighlighterGeneric<L, T>>;
|
|
75
|
-
interface CreateSingletonShorthandsOptions<L extends string, T extends string> {
|
|
74
|
+
export declare function makeSingletonHighlighter<L extends string, T extends string>(createHighlighter: CreateHighlighterFactory<L, T>): (options?: Partial<BundledHighlighterOptions<L, T>>) => Promise<HighlighterGeneric<L, T>>;
|
|
75
|
+
export interface CreateSingletonShorthandsOptions<L extends string, T extends string> {
|
|
76
76
|
/**
|
|
77
77
|
* A custom function to guess embedded languages to be loaded.
|
|
78
78
|
*/
|
|
79
79
|
guessEmbeddedLanguages?: (code: string, lang: string | undefined, highlighter: HighlighterGeneric<L, T>) => Awaitable<string[] | undefined>;
|
|
80
80
|
}
|
|
81
|
-
declare function createSingletonShorthands<L extends string, T extends string>(createHighlighter: CreateHighlighterFactory<L, T>, config?: CreateSingletonShorthandsOptions<L, T>): ShorthandsBundle<L, T>;
|
|
81
|
+
export declare function createSingletonShorthands<L extends string, T extends string>(createHighlighter: CreateHighlighterFactory<L, T>, config?: CreateSingletonShorthandsOptions<L, T>): ShorthandsBundle<L, T>;
|
|
82
82
|
//#endregion
|
|
83
83
|
//#region src/constructors/highlighter.d.ts
|
|
84
84
|
/**
|
|
@@ -87,7 +87,7 @@ declare function createSingletonShorthands<L extends string, T extends string>(c
|
|
|
87
87
|
*
|
|
88
88
|
* @see http://shiki.style/guide/bundles#fine-grained-bundle
|
|
89
89
|
*/
|
|
90
|
-
declare function createHighlighterCore(options: HighlighterCoreOptions<false>): Promise<HighlighterCore>;
|
|
90
|
+
export declare function createHighlighterCore(options: HighlighterCoreOptions<false>): Promise<HighlighterCore>;
|
|
91
91
|
/**
|
|
92
92
|
* Create a Shiki core highlighter instance, with no languages or themes bundled.
|
|
93
93
|
* Wasm and each language and theme must be loaded manually.
|
|
@@ -96,20 +96,20 @@ declare function createHighlighterCore(options: HighlighterCoreOptions<false>):
|
|
|
96
96
|
*
|
|
97
97
|
* @see http://shiki.style/guide/bundles#fine-grained-bundle
|
|
98
98
|
*/
|
|
99
|
-
declare function createHighlighterCoreSync(options: HighlighterCoreOptions<true>): HighlighterCore;
|
|
100
|
-
declare function makeSingletonHighlighterCore(createHighlighter: typeof createHighlighterCore): (options: HighlighterCoreOptions) => Promise<HighlighterCore>;
|
|
101
|
-
declare const getSingletonHighlighterCore: (options: HighlighterCoreOptions) => Promise<HighlighterCore>;
|
|
99
|
+
export declare function createHighlighterCoreSync(options: HighlighterCoreOptions<true>): HighlighterCore;
|
|
100
|
+
export declare function makeSingletonHighlighterCore(createHighlighter: typeof createHighlighterCore): (options: HighlighterCoreOptions) => Promise<HighlighterCore>;
|
|
101
|
+
export declare const getSingletonHighlighterCore: (options: HighlighterCoreOptions) => Promise<HighlighterCore>;
|
|
102
102
|
//#endregion
|
|
103
103
|
//#region src/highlight/code-to-hast.d.ts
|
|
104
|
-
declare function codeToHast(primitive: ShikiPrimitive, code: string, options: CodeToHastOptions, transformerContext?: ShikiTransformerContextCommon): Root;
|
|
105
|
-
declare function tokensToHast(tokens: ThemedToken[][], options: CodeToHastRenderOptions, transformerContext: ShikiTransformerContextSource, grammarState?: GrammarState | undefined): Root;
|
|
104
|
+
export declare function codeToHast(primitive: ShikiPrimitive, code: string, options: CodeToHastOptions, transformerContext?: ShikiTransformerContextCommon): Root;
|
|
105
|
+
export declare function tokensToHast(tokens: ThemedToken[][], options: CodeToHastRenderOptions, transformerContext: ShikiTransformerContextSource, grammarState?: GrammarState | undefined): Root;
|
|
106
106
|
//#endregion
|
|
107
107
|
//#region src/highlight/code-to-html.d.ts
|
|
108
|
-
declare const hastToHtml: typeof toHtml;
|
|
108
|
+
export declare const hastToHtml: typeof toHtml;
|
|
109
109
|
/**
|
|
110
110
|
* Get highlighted code in HTML.
|
|
111
111
|
*/
|
|
112
|
-
declare function codeToHtml(primitive: ShikiPrimitive, code: string, options: CodeToHastOptions): string;
|
|
112
|
+
export declare function codeToHtml(primitive: ShikiPrimitive, code: string, options: CodeToHastOptions): string;
|
|
113
113
|
//#endregion
|
|
114
114
|
//#region src/highlight/code-to-tokens.d.ts
|
|
115
115
|
/**
|
|
@@ -117,20 +117,20 @@ declare function codeToHtml(primitive: ShikiPrimitive, code: string, options: Co
|
|
|
117
117
|
*
|
|
118
118
|
* It will use `codeToTokensWithThemes` or `codeToTokensBase` based on the options.
|
|
119
119
|
*/
|
|
120
|
-
declare function codeToTokens(primitive: ShikiPrimitive, code: string, options: CodeToTokensOptions): TokensResult;
|
|
120
|
+
export declare function codeToTokens(primitive: ShikiPrimitive, code: string, options: CodeToTokensOptions): TokensResult;
|
|
121
121
|
//#endregion
|
|
122
122
|
//#region src/highlight/code-to-tokens-ansi.d.ts
|
|
123
|
-
declare function tokenizeAnsiWithTheme(theme: ThemeRegistrationResolved, fileContents: string, options?: TokenizeWithThemeOptions): ThemedToken[][];
|
|
123
|
+
export declare function tokenizeAnsiWithTheme(theme: ThemeRegistrationResolved, fileContents: string, options?: TokenizeWithThemeOptions): ThemedToken[][];
|
|
124
124
|
//#endregion
|
|
125
125
|
//#region src/highlight/code-to-tokens-base.d.ts
|
|
126
126
|
/**
|
|
127
127
|
* Code to tokens, with a simple theme.
|
|
128
128
|
* This wraps the tokenizer's implementation to add ANSI support.
|
|
129
129
|
*/
|
|
130
|
-
declare function codeToTokensBase(primitive: ShikiPrimitive, code: string, options?: CodeToTokensBaseOptions): ThemedToken[][];
|
|
130
|
+
export declare function codeToTokensBase(primitive: ShikiPrimitive, code: string, options?: CodeToTokensBaseOptions): ThemedToken[][];
|
|
131
131
|
//#endregion
|
|
132
132
|
//#region src/theme-css-variables.d.ts
|
|
133
|
-
interface CssVariablesThemeOptions {
|
|
133
|
+
export interface CssVariablesThemeOptions {
|
|
134
134
|
/**
|
|
135
135
|
* Theme name. Need to unique if multiple css variables themes are created
|
|
136
136
|
*
|
|
@@ -161,13 +161,13 @@ interface CssVariablesThemeOptions {
|
|
|
161
161
|
*
|
|
162
162
|
* @see https://shiki.style/guide/theme-colors#css-variables-theme
|
|
163
163
|
*/
|
|
164
|
-
declare function createCssVariablesTheme(options?: CssVariablesThemeOptions): ThemeRegistration;
|
|
164
|
+
export declare function createCssVariablesTheme(options?: CssVariablesThemeOptions): ThemeRegistration;
|
|
165
165
|
//#endregion
|
|
166
166
|
//#region src/transformer-decorations.d.ts
|
|
167
167
|
/**
|
|
168
168
|
* A built-in transformer to add decorations to the highlighted code.
|
|
169
169
|
*/
|
|
170
|
-
declare function transformerDecorations(): ShikiTransformer;
|
|
170
|
+
export declare function transformerDecorations(): ShikiTransformer;
|
|
171
171
|
//#endregion
|
|
172
172
|
//#region src/utils/hast.d.ts
|
|
173
173
|
/**
|
|
@@ -175,7 +175,7 @@ declare function transformerDecorations(): ShikiTransformer;
|
|
|
175
175
|
*
|
|
176
176
|
* If the `property.class` is a string, it will be splitted by space and converted to an array.
|
|
177
177
|
*/
|
|
178
|
-
declare function addClassToHast(node: Element, className: string | string[]): Element;
|
|
178
|
+
export declare function addClassToHast(node: Element, className: string | string[]): Element;
|
|
179
179
|
//#endregion
|
|
180
180
|
//#region src/utils/strings.d.ts
|
|
181
181
|
/**
|
|
@@ -183,7 +183,7 @@ declare function addClassToHast(node: Element, className: string | string[]): El
|
|
|
183
183
|
*
|
|
184
184
|
* Overflow/underflow are unchecked.
|
|
185
185
|
*/
|
|
186
|
-
declare function createPositionConverter(code: string): {
|
|
186
|
+
export declare function createPositionConverter(code: string): {
|
|
187
187
|
lines: string[];
|
|
188
188
|
indexToPos: (index: number) => Position;
|
|
189
189
|
posToIndex: (line: number, character: number) => number;
|
|
@@ -207,7 +207,7 @@ declare function createPositionConverter(code: string): {
|
|
|
207
207
|
* guessEmbeddedLanguages('```python\nprint("hi")\n```')
|
|
208
208
|
* ```
|
|
209
209
|
*/
|
|
210
|
-
declare function guessEmbeddedLanguages(code: string, _lang: string | undefined, highlighter?: HighlighterGeneric<any, any>): string[];
|
|
210
|
+
export declare function guessEmbeddedLanguages(code: string, _lang: string | undefined, highlighter?: HighlighterGeneric<any, any>): string[];
|
|
211
211
|
//#endregion
|
|
212
212
|
//#region src/utils/tokens.d.ts
|
|
213
213
|
/**
|
|
@@ -215,13 +215,13 @@ declare function guessEmbeddedLanguages(code: string, _lang: string | undefined,
|
|
|
215
215
|
*
|
|
216
216
|
* The offsets are relative to the token, and should be sorted.
|
|
217
217
|
*/
|
|
218
|
-
declare function splitToken<T extends Pick<ThemedToken, 'content' | 'offset'>>(token: T, offsets: number[]): T[];
|
|
218
|
+
export declare function splitToken<T extends Pick<ThemedToken, 'content' | 'offset'>>(token: T, offsets: number[]): T[];
|
|
219
219
|
/**
|
|
220
220
|
* Split 2D tokens array by given breakpoints.
|
|
221
221
|
*/
|
|
222
|
-
declare function splitTokens<T extends Pick<ThemedToken, 'content' | 'offset'>>(tokens: T[][], breakpoints: number[] | Set<number>): T[][];
|
|
223
|
-
declare function flatTokenVariants(merged: ThemedTokenWithVariants, variantsOrder: string[], cssVariablePrefix: string, defaultColor: CodeOptionsMultipleThemes['defaultColor'], colorsRendering?: CodeOptionsMultipleThemes['colorsRendering']): ThemedToken;
|
|
224
|
-
declare function getTokenStyleObject(token: TokenStyles): Record<string, string>;
|
|
225
|
-
declare function stringifyTokenStyle(token: string | Record<string, string>): string;
|
|
222
|
+
export declare function splitTokens<T extends Pick<ThemedToken, 'content' | 'offset'>>(tokens: T[][], breakpoints: number[] | Set<number>): T[][];
|
|
223
|
+
export declare function flatTokenVariants(merged: ThemedTokenWithVariants, variantsOrder: string[], cssVariablePrefix: string, defaultColor: CodeOptionsMultipleThemes['defaultColor'], colorsRendering?: CodeOptionsMultipleThemes['colorsRendering']): ThemedToken;
|
|
224
|
+
export declare function getTokenStyleObject(token: TokenStyles): Record<string, string>;
|
|
225
|
+
export declare function stringifyTokenStyle(token: string | Record<string, string>): string;
|
|
226
226
|
//#endregion
|
|
227
|
-
export {
|
|
227
|
+
export { ShikiError, applyColorReplacements, codeToTokensWithThemes, createShikiInternal, createShikiInternalSync, createShikiPrimitive, createShikiPrimitiveAsync, getLastGrammarState, isNoneTheme, isPlainLang, isSpecialLang, isSpecialTheme, normalizeGetter, normalizeTheme, resolveColorReplacements, splitLines, toArray, tokenizeWithTheme };
|
|
@@ -177,16 +177,17 @@ function flatTokenVariants(merged, variantsOrder, cssVariablePrefix, defaultColo
|
|
|
177
177
|
styles.forEach((cur, idx) => {
|
|
178
178
|
for (const key of styleKeys) {
|
|
179
179
|
const value = cur[key] || "inherit";
|
|
180
|
-
if (idx === 0 && defaultColor && COLOR_KEYS.includes(key))
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
180
|
+
if (idx === 0 && defaultColor && COLOR_KEYS.includes(key)) {
|
|
181
|
+
if (defaultColor === "light-dark()" && styles.length > 1) {
|
|
182
|
+
const lightIndex = variantsOrder.findIndex((t) => t === "light");
|
|
183
|
+
const darkIndex = variantsOrder.findIndex((t) => t === "dark");
|
|
184
|
+
if (lightIndex === -1 || darkIndex === -1) throw new ShikiError$1("When using `defaultColor: \"light-dark()\"`, you must provide both `light` and `dark` themes");
|
|
185
|
+
const lightValue = styles[lightIndex][key] || "inherit";
|
|
186
|
+
const darkValue = styles[darkIndex][key] || "inherit";
|
|
187
|
+
mergedStyles[key] = `light-dark(${lightValue}, ${darkValue})`;
|
|
188
|
+
if (colorsRendering === "css-vars") mergedStyles[varKey(idx, key)] = value;
|
|
189
|
+
} else mergedStyles[key] = value;
|
|
190
|
+
} else if (colorsRendering === "css-vars") mergedStyles[varKey(idx, key)] = value;
|
|
190
191
|
}
|
|
191
192
|
});
|
|
192
193
|
token.htmlStyle = mergedStyles;
|
|
@@ -829,8 +830,10 @@ function tokensToHast(tokens, options, transformerContext, grammarState = getLas
|
|
|
829
830
|
};
|
|
830
831
|
const { structure = "classic", tabindex = "0" } = options;
|
|
831
832
|
const properties = { class: `shiki ${options.themeName || ""}` };
|
|
832
|
-
if (options.rootStyle !== false)
|
|
833
|
-
|
|
833
|
+
if (options.rootStyle !== false) {
|
|
834
|
+
if (options.rootStyle != null) properties.style = options.rootStyle;
|
|
835
|
+
else properties.style = `background-color:${options.bg};color:${options.fg}`;
|
|
836
|
+
}
|
|
834
837
|
if (tabindex !== false && tabindex != null) properties.tabindex = tabindex.toString();
|
|
835
838
|
for (const [key, value] of Object.entries(options.meta || {})) if (!key.startsWith("_")) properties[key] = value;
|
|
836
839
|
let preNode = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shikijs/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.5.0",
|
|
5
5
|
"description": "Core of Shiki",
|
|
6
6
|
"author": "Pine Wu <octref@gmail.com>; Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -46,11 +46,11 @@
|
|
|
46
46
|
"node": ">=20"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
+
"@shikijs/primitive": "4.5.0",
|
|
50
|
+
"@shikijs/types": "4.5.0",
|
|
49
51
|
"@shikijs/vscode-textmate": "^10.0.2",
|
|
50
52
|
"@types/hast": "^3.0.5",
|
|
51
|
-
"hast-util-to-html": "^9.0.5"
|
|
52
|
-
"@shikijs/primitive": "4.4.3",
|
|
53
|
-
"@shikijs/types": "4.4.3"
|
|
53
|
+
"hast-util-to-html": "^9.0.5"
|
|
54
54
|
},
|
|
55
55
|
"scripts": {
|
|
56
56
|
"build": "tsdown",
|
|
@@ -24,6 +24,11 @@ declare class JavaScriptScanner implements PatternScanner {
|
|
|
24
24
|
patterns: (string | RegExp)[];
|
|
25
25
|
options: JavaScriptRegexScannerOptions;
|
|
26
26
|
regexps: (RegExp | null)[];
|
|
27
|
+
/**
|
|
28
|
+
* Last search of each regexp on the current string, reused the way `vscode-oniguruma` does.
|
|
29
|
+
* `null` for regexps whose searches can't be reused.
|
|
30
|
+
*/
|
|
31
|
+
private lastSearches;
|
|
27
32
|
constructor(patterns: (string | RegExp)[], options?: JavaScriptRegexScannerOptions);
|
|
28
33
|
findNextMatchSync(string: string | RegexEngineString, startPosition: number, _options: number): IOnigMatch | null;
|
|
29
34
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as createJavaScriptRegexEngine, r as defaultJavaScriptRegexConstructor, t as JavaScriptRegexEngineOptions } from "./engine-compile-
|
|
1
|
+
import { n as createJavaScriptRegexEngine, r as defaultJavaScriptRegexConstructor, t as JavaScriptRegexEngineOptions } from "./engine-compile-CtqiSkRk.mjs";
|
|
2
2
|
export { JavaScriptRegexEngineOptions, createJavaScriptRegexEngine, defaultJavaScriptRegexConstructor };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as JavaScriptScanner, t as createJavaScriptEngineString } from "./string-TLTPtCPs.mjs";
|
|
2
2
|
import { toRegExp } from "oniguruma-to-es";
|
|
3
3
|
//#region src/engine-compile.ts
|
|
4
4
|
/**
|
|
@@ -38,9 +38,7 @@ function createJavaScriptRegexEngine(options = {}) {
|
|
|
38
38
|
createScanner(patterns) {
|
|
39
39
|
return new JavaScriptScanner(patterns, _options);
|
|
40
40
|
},
|
|
41
|
-
createString
|
|
42
|
-
return { content: s };
|
|
43
|
-
}
|
|
41
|
+
createString: createJavaScriptEngineString
|
|
44
42
|
};
|
|
45
43
|
}
|
|
46
44
|
//#endregion
|
|
@@ -7,6 +7,5 @@ import { RegexEngine } from "@shikijs/types";
|
|
|
7
7
|
*
|
|
8
8
|
* Zero dependencies.
|
|
9
9
|
*/
|
|
10
|
-
declare function createJavaScriptRawEngine(): RegexEngine;
|
|
11
|
-
//#endregion
|
|
12
|
-
export { createJavaScriptRawEngine };
|
|
10
|
+
export declare function createJavaScriptRawEngine(): RegexEngine;
|
|
11
|
+
//#endregion
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as JavaScriptScanner, t as createJavaScriptEngineString } from "./string-TLTPtCPs.mjs";
|
|
2
2
|
//#region src/engine-raw.ts
|
|
3
3
|
/**
|
|
4
4
|
* Raw JavaScript regex engine that only supports precompiled grammars.
|
|
@@ -18,9 +18,7 @@ function createJavaScriptRawEngine() {
|
|
|
18
18
|
createScanner(patterns) {
|
|
19
19
|
return new JavaScriptScanner(patterns, options);
|
|
20
20
|
},
|
|
21
|
-
createString
|
|
22
|
-
return { content: s };
|
|
23
|
-
}
|
|
21
|
+
createString: createJavaScriptEngineString
|
|
24
22
|
};
|
|
25
23
|
}
|
|
26
24
|
//#endregion
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as JavaScriptScanner, i as JavaScriptRegexScannerOptions, n as createJavaScriptRegexEngine, r as defaultJavaScriptRegexConstructor, t as JavaScriptRegexEngineOptions } from "./engine-compile-
|
|
1
|
+
import { a as JavaScriptScanner, i as JavaScriptRegexScannerOptions, n as createJavaScriptRegexEngine, r as defaultJavaScriptRegexConstructor, t as JavaScriptRegexEngineOptions } from "./engine-compile-CtqiSkRk.mjs";
|
|
2
2
|
import { createJavaScriptRawEngine } from "./engine-raw.mjs";
|
|
3
3
|
export { JavaScriptRegexEngineOptions, JavaScriptRegexScannerOptions, JavaScriptScanner, createJavaScriptRawEngine, createJavaScriptRegexEngine, defaultJavaScriptRegexConstructor };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as JavaScriptScanner } from "./string-TLTPtCPs.mjs";
|
|
2
2
|
import { createJavaScriptRegexEngine, defaultJavaScriptRegexConstructor } from "./engine-compile.mjs";
|
|
3
3
|
import { createJavaScriptRawEngine } from "./engine-raw.mjs";
|
|
4
4
|
export { JavaScriptScanner, createJavaScriptRawEngine, createJavaScriptRegexEngine, defaultJavaScriptRegexConstructor };
|