@kensio/colophon 2.7.0 → 2.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/content/props.d.ts +3 -0
- package/dist/content/props.d.ts.map +1 -1
- package/dist/content/props.js +14 -3
- package/dist/content/props.js.map +1 -1
- package/dist/highlight/index.d.ts +1 -1
- package/dist/highlight/index.d.ts.map +1 -1
- package/dist/highlight/index.js +3 -3
- package/dist/highlight/index.js.map +1 -1
- package/dist/highlight/language.d.ts +10 -1
- package/dist/highlight/language.d.ts.map +1 -1
- package/dist/highlight/language.js +16 -2
- package/dist/highlight/language.js.map +1 -1
- package/dist/highlight/probe.d.ts +4 -0
- package/dist/highlight/probe.d.ts.map +1 -0
- package/dist/highlight/probe.js +4 -0
- package/dist/highlight/probe.js.map +1 -0
- package/dist/highlight/themes.d.ts +27 -0
- package/dist/highlight/themes.d.ts.map +1 -0
- package/dist/highlight/themes.js +88 -0
- package/dist/highlight/themes.js.map +1 -0
- package/package.json +2 -1
package/dist/content/props.d.ts
CHANGED
|
@@ -10,6 +10,9 @@ export declare function coerceString(value: unknown): string | undefined;
|
|
|
10
10
|
* `props` mapper reading the frontmatter it already has. Where both speak the
|
|
11
11
|
* post wins, field by field. The mapper describes the site's usual shape, and
|
|
12
12
|
* a post that says otherwise is saying so on purpose.
|
|
13
|
+
*
|
|
14
|
+
* The title has a third place to come from, which is the post's own top-level
|
|
15
|
+
* `title`, used where neither of the other two set one.
|
|
13
16
|
*/
|
|
14
17
|
export declare function extractProps(frontmatter: Record<string, unknown>, options?: Pick<ContentOptions, "propsKey" | "templateField" | "defaultTemplate" | "props">): MetaImageProps | undefined;
|
|
15
18
|
//# sourceMappingURL=props.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../src/content/props.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAKlE,qEAAqE;AACrE,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAc/D;AASD
|
|
1
|
+
{"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../src/content/props.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAKlE,qEAAqE;AACrE,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAc/D;AASD;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAC1B,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACpC,OAAO,GAAE,IAAI,CACX,cAAc,EACd,UAAU,GAAG,eAAe,GAAG,iBAAiB,GAAG,OAAO,CACtD,GACL,cAAc,GAAG,SAAS,CA0D5B"}
|
package/dist/content/props.js
CHANGED
|
@@ -26,6 +26,9 @@ const namedFields = new Set(["template", "title", "subtitle", "version"]);
|
|
|
26
26
|
* `props` mapper reading the frontmatter it already has. Where both speak the
|
|
27
27
|
* post wins, field by field. The mapper describes the site's usual shape, and
|
|
28
28
|
* a post that says otherwise is saying so on purpose.
|
|
29
|
+
*
|
|
30
|
+
* The title has a third place to come from, which is the post's own top-level
|
|
31
|
+
* `title`, used where neither of the other two set one.
|
|
29
32
|
*/
|
|
30
33
|
export function extractProps(frontmatter, options = {}) {
|
|
31
34
|
const propsKey = options.propsKey ?? defaultPropsKey;
|
|
@@ -49,9 +52,17 @@ export function extractProps(frontmatter, options = {}) {
|
|
|
49
52
|
if (template === undefined) {
|
|
50
53
|
return undefined;
|
|
51
54
|
}
|
|
52
|
-
//
|
|
53
|
-
//
|
|
54
|
-
|
|
55
|
+
// A post that says nothing about its title gets the one it already has, so
|
|
56
|
+
// the common case of an image titled after its post needs no props for it.
|
|
57
|
+
//
|
|
58
|
+
// This is the last word rather than the first: the props block wins, then
|
|
59
|
+
// the mapper, then this. It also cannot opt a post in. A post with no props
|
|
60
|
+
// block and no mapper has already been skipped above, so a top-level title
|
|
61
|
+
// never turns a file that wanted no image into one that gets an image.
|
|
62
|
+
//
|
|
63
|
+
// Title is optional even so. Templates such as `code` describe the image
|
|
64
|
+
// entirely from their own fields, and a post carrying neither still renders.
|
|
65
|
+
const title = coerceString(record["title"]) ?? coerceString(frontmatter["title"]);
|
|
55
66
|
const subtitle = coerceString(record["subtitle"]);
|
|
56
67
|
const version = coerceString(record["version"]);
|
|
57
68
|
const extras = {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"props.js","sourceRoot":"","sources":["../../src/content/props.ts"],"names":[],"mappings":"AAEA,MAAM,eAAe,GAAG,gBAAgB,CAAC;AACzC,MAAM,oBAAoB,GAAG,UAAU,CAAC;AAExC,qEAAqE;AACrE,MAAM,UAAU,YAAY,CAAC,KAAc;IACzC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IACE,OAAO,KAAK,KAAK,QAAQ;QACzB,OAAO,KAAK,KAAK,SAAS;QAC1B,OAAO,KAAK,KAAK,QAAQ,EACzB,CAAC;QACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,0EAA0E;AAC1E,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,CAAC,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC,CAAC;AAE1E
|
|
1
|
+
{"version":3,"file":"props.js","sourceRoot":"","sources":["../../src/content/props.ts"],"names":[],"mappings":"AAEA,MAAM,eAAe,GAAG,gBAAg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AAG,CAAC,OAAO,KAAK,SAAS,IAAI,EAAE,OAAO,EAAE,CAAC;KAC1C,CAAC;AACJ,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { HighlightedCode, HighlightOptions } from "./types.js";
|
|
2
2
|
export { dedent, expandTabs } from "./normalise.js";
|
|
3
|
-
export { resolveLanguage, resolveTheme } from "./language.js";
|
|
3
|
+
export { loadTheme, resolveLanguage, resolveTheme } from "./language.js";
|
|
4
4
|
export type { CodeToken, HighlightedCode, HighlightOptions } from "./types.js";
|
|
5
5
|
/**
|
|
6
6
|
* Tokenise a snippet with Shiki and flatten it onto a character grid.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/highlight/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEpE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/highlight/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEpE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AACzE,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE/E;;;;;GAKG;AACH,wBAAsB,aAAa,CACjC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,eAAe,CAAC,CAoB1B"}
|
package/dist/highlight/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { codeToTokens } from "shiki";
|
|
2
2
|
import { gridLine } from "./grid.js";
|
|
3
|
-
import {
|
|
3
|
+
import { loadTheme, resolveLanguage } from "./language.js";
|
|
4
4
|
import { normaliseSnippet } from "./normalise.js";
|
|
5
5
|
export { dedent, expandTabs } from "./normalise.js";
|
|
6
|
-
export { resolveLanguage, resolveTheme } from "./language.js";
|
|
6
|
+
export { loadTheme, resolveLanguage, resolveTheme } from "./language.js";
|
|
7
7
|
/**
|
|
8
8
|
* Tokenise a snippet with Shiki and flatten it onto a character grid.
|
|
9
9
|
*
|
|
@@ -13,7 +13,7 @@ export { resolveLanguage, resolveTheme } from "./language.js";
|
|
|
13
13
|
export async function highlightCode(code, options) {
|
|
14
14
|
const result = await codeToTokens(normaliseSnippet(code, options.tabSize), {
|
|
15
15
|
lang: resolveLanguage(options.language),
|
|
16
|
-
theme:
|
|
16
|
+
theme: await loadTheme(options.theme),
|
|
17
17
|
});
|
|
18
18
|
let longestLine = 0;
|
|
19
19
|
const lines = result.tokens.map((tokens) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/highlight/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAErC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/highlight/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAErC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGlD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAGzE;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,IAAY,EACZ,OAAyB;IAEzB,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,gBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE;QACzE,IAAI,EAAE,eAAe,CAAC,OAAO,CAAC,QAAQ,CAAC;QACvC,KAAK,EAAE,MAAM,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC;KACtC,CAAC,CAAC;IAEH,IAAI,WAAW,GAAG,CAAC,CAAC;IAEpB,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;QACzC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC;QACzC,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;QAC3C,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,KAAK;QACL,UAAU,EAAE,MAAM,CAAC,EAAE,IAAI,SAAS;QAClC,UAAU,EAAE,MAAM,CAAC,EAAE,IAAI,SAAS;QAClC,WAAW;KACZ,CAAC;AACJ,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BundledLanguage, BundledTheme, SpecialLanguage } from "shiki";
|
|
1
|
+
import type { BundledLanguage, BundledTheme, SpecialLanguage, ThemeRegistration } from "shiki";
|
|
2
2
|
/**
|
|
3
3
|
* Map a frontmatter language name onto one Shiki understands, falling back to
|
|
4
4
|
* plain text so an unrecognised language still produces a readable image
|
|
@@ -10,4 +10,13 @@ export declare function resolveLanguage(language: string): BundledLanguage | Spe
|
|
|
10
10
|
* fall back quietly, but a bad theme is a config mistake worth failing on.
|
|
11
11
|
*/
|
|
12
12
|
export declare function resolveTheme(theme: string): BundledTheme;
|
|
13
|
+
/**
|
|
14
|
+
* Load a configured theme's data.
|
|
15
|
+
*
|
|
16
|
+
* Shiki takes a theme as a name or as the thing itself, and this hands it the
|
|
17
|
+
* thing, so the only registry either side of the call reads is the one in
|
|
18
|
+
* `themes.ts`. See there for why that matters. The import is cached by the
|
|
19
|
+
* module system, so a build highlighting a hundred snippets loads a theme once.
|
|
20
|
+
*/
|
|
21
|
+
export declare function loadTheme(theme: string): Promise<ThemeRegistration>;
|
|
13
22
|
//# sourceMappingURL=language.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"language.d.ts","sourceRoot":"","sources":["../../src/highlight/language.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"language.d.ts","sourceRoot":"","sources":["../../src/highlight/language.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,YAAY,EACZ,eAAe,EACf,iBAAiB,EAClB,MAAM,OAAO,CAAC;AAwBf;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,MAAM,GACf,eAAe,GAAG,eAAe,CAOnC;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,CAQxD;AAED;;;;;;;GAOG;AACH,wBAAsB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAKzE"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { bundledLanguages
|
|
1
|
+
import { bundledLanguages } from "shiki";
|
|
2
|
+
import { codeThemes } from "./themes.js";
|
|
2
3
|
/**
|
|
3
4
|
* Language names that differ between Pygments (which the original Python
|
|
4
5
|
* script used) and Shiki. Everything else is passed through, since Shiki
|
|
@@ -33,9 +34,22 @@ export function resolveLanguage(language) {
|
|
|
33
34
|
* fall back quietly, but a bad theme is a config mistake worth failing on.
|
|
34
35
|
*/
|
|
35
36
|
export function resolveTheme(theme) {
|
|
36
|
-
if (!Object.hasOwn(
|
|
37
|
+
if (!Object.hasOwn(codeThemes, theme)) {
|
|
37
38
|
throw new Error(`Unknown code theme "${theme}". See https://shiki.style/themes for the available names.`);
|
|
38
39
|
}
|
|
39
40
|
return theme;
|
|
40
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Load a configured theme's data.
|
|
44
|
+
*
|
|
45
|
+
* Shiki takes a theme as a name or as the thing itself, and this hands it the
|
|
46
|
+
* thing, so the only registry either side of the call reads is the one in
|
|
47
|
+
* `themes.ts`. See there for why that matters. The import is cached by the
|
|
48
|
+
* module system, so a build highlighting a hundred snippets loads a theme once.
|
|
49
|
+
*/
|
|
50
|
+
export async function loadTheme(theme) {
|
|
51
|
+
const load = codeThemes[resolveTheme(theme)];
|
|
52
|
+
const loaded = await load();
|
|
53
|
+
return loaded.default;
|
|
54
|
+
}
|
|
41
55
|
//# sourceMappingURL=language.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"language.js","sourceRoot":"","sources":["../../src/highlight/language.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"language.js","sourceRoot":"","sources":["../../src/highlight/language.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAEzC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC;;;;;GAKG;AACH,MAAM,eAAe,GAAgC,IAAI,GAAG,CAAC;IAC3D,CAAC,iBAAiB,EAAE,YAAY,CAAC;IACjC,CAAC,aAAa,EAAE,YAAY,CAAC;IAC7B,CAAC,YAAY,EAAE,YAAY,CAAC;IAC5B,CAAC,UAAU,EAAE,KAAK,CAAC;IACnB,CAAC,SAAS,EAAE,cAAc,CAAC;IAC3B,CAAC,eAAe,EAAE,cAAc,CAAC;IACjC,CAAC,MAAM,EAAE,WAAW,CAAC;IACrB,CAAC,OAAO,EAAE,WAAW,CAAC;CACvB,CAAC,CAAC;AAEH,MAAM,SAAS,GAAoB,WAAW,CAAC;AAE/C;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAC7B,QAAgB;IAEhB,MAAM,UAAU,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACjD,MAAM,OAAO,GAAG,eAAe,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,UAAU,CAAC;IAE9D,OAAO,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAAE,OAAO,CAAC;QAC7C,CAAC,CAAE,OAA2B;QAC9B,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,KAAa;IACxC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,KAAK,CACb,uBAAuB,KAAK,4DAA4D,CACzF,CAAC;IACJ,CAAC;IAED,OAAO,KAAqB,CAAC;AAC/B,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,KAAa;IAC3C,MAAM,IAAI,GAAG,UAAU,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;IAC7C,MAAM,MAAM,GAAG,MAAM,IAAI,EAAE,CAAC;IAE5B,OAAO,MAAM,CAAC,OAAO,CAAC;AACxB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"probe.d.ts","sourceRoot":"","sources":["../../src/highlight/probe.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,aAAa;;CAEzB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"probe.js","sourceRoot":"","sources":["../../src/highlight/probe.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE1C,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,WAAW,CAC7C,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAC/C,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { BundledTheme, ThemeRegistration } from "shiki";
|
|
2
|
+
/** Loads one theme's data, which is a chunk of its own in a bundle. */
|
|
3
|
+
export type CodeThemeLoader = () => Promise<{
|
|
4
|
+
default: ThemeRegistration;
|
|
5
|
+
}>;
|
|
6
|
+
/**
|
|
7
|
+
* Every theme Shiki bundles, as a registry of Colophon's own.
|
|
8
|
+
*
|
|
9
|
+
* Shiki has this map already, and reading it was what this used to do. It does
|
|
10
|
+
* not survive every browser build. Expressive Code, which a Starlight site runs
|
|
11
|
+
* by default, rewrites Shiki's own `themes.mjs` during the build to drop every
|
|
12
|
+
* theme its configuration does not name, under an option called
|
|
13
|
+
* `removeUnusedThemes`. That transform applies to the file rather than to one
|
|
14
|
+
* importer of it, so a second Shiki caller in the same build, which is what
|
|
15
|
+
* Colophon is on a site with a browser playground, is left with an empty
|
|
16
|
+
* registry: every theme name is unknown, including the default nobody typed.
|
|
17
|
+
*
|
|
18
|
+
* Owning the map is what makes that irrelevant, since these imports are
|
|
19
|
+
* Colophon's own and nothing rewrites them. The loaded theme is then passed to
|
|
20
|
+
* `codeToTokens` as an object rather than as a name, so Shiki's registry is not
|
|
21
|
+
* consulted on the way through either.
|
|
22
|
+
*
|
|
23
|
+
* The type is what keeps the list honest: `Record<BundledTheme, ...>` fails to
|
|
24
|
+
* compile if a Shiki upgrade adds a theme that is missing here, or renames one.
|
|
25
|
+
*/
|
|
26
|
+
export declare const codeThemes: Record<BundledTheme, CodeThemeLoader>;
|
|
27
|
+
//# sourceMappingURL=themes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"themes.d.ts","sourceRoot":"","sources":["../../src/highlight/themes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE7D,uEAAuE;AACvE,MAAM,MAAM,eAAe,GAAG,MAAM,OAAO,CAAC;IAAE,OAAO,EAAE,iBAAiB,CAAA;CAAE,CAAC,CAAC;AAE5E;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,YAAY,EAAE,eAAe,CAuE5D,CAAC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every theme Shiki bundles, as a registry of Colophon's own.
|
|
3
|
+
*
|
|
4
|
+
* Shiki has this map already, and reading it was what this used to do. It does
|
|
5
|
+
* not survive every browser build. Expressive Code, which a Starlight site runs
|
|
6
|
+
* by default, rewrites Shiki's own `themes.mjs` during the build to drop every
|
|
7
|
+
* theme its configuration does not name, under an option called
|
|
8
|
+
* `removeUnusedThemes`. That transform applies to the file rather than to one
|
|
9
|
+
* importer of it, so a second Shiki caller in the same build, which is what
|
|
10
|
+
* Colophon is on a site with a browser playground, is left with an empty
|
|
11
|
+
* registry: every theme name is unknown, including the default nobody typed.
|
|
12
|
+
*
|
|
13
|
+
* Owning the map is what makes that irrelevant, since these imports are
|
|
14
|
+
* Colophon's own and nothing rewrites them. The loaded theme is then passed to
|
|
15
|
+
* `codeToTokens` as an object rather than as a name, so Shiki's registry is not
|
|
16
|
+
* consulted on the way through either.
|
|
17
|
+
*
|
|
18
|
+
* The type is what keeps the list honest: `Record<BundledTheme, ...>` fails to
|
|
19
|
+
* compile if a Shiki upgrade adds a theme that is missing here, or renames one.
|
|
20
|
+
*/
|
|
21
|
+
export const codeThemes = {
|
|
22
|
+
andromeeda: () => import("@shikijs/themes/andromeeda"),
|
|
23
|
+
"aurora-x": () => import("@shikijs/themes/aurora-x"),
|
|
24
|
+
"ayu-dark": () => import("@shikijs/themes/ayu-dark"),
|
|
25
|
+
"ayu-light": () => import("@shikijs/themes/ayu-light"),
|
|
26
|
+
"ayu-mirage": () => import("@shikijs/themes/ayu-mirage"),
|
|
27
|
+
"catppuccin-frappe": () => import("@shikijs/themes/catppuccin-frappe"),
|
|
28
|
+
"catppuccin-latte": () => import("@shikijs/themes/catppuccin-latte"),
|
|
29
|
+
"catppuccin-macchiato": () => import("@shikijs/themes/catppuccin-macchiato"),
|
|
30
|
+
"catppuccin-mocha": () => import("@shikijs/themes/catppuccin-mocha"),
|
|
31
|
+
"dark-plus": () => import("@shikijs/themes/dark-plus"),
|
|
32
|
+
dracula: () => import("@shikijs/themes/dracula"),
|
|
33
|
+
"dracula-soft": () => import("@shikijs/themes/dracula-soft"),
|
|
34
|
+
"everforest-dark": () => import("@shikijs/themes/everforest-dark"),
|
|
35
|
+
"everforest-light": () => import("@shikijs/themes/everforest-light"),
|
|
36
|
+
"github-dark": () => import("@shikijs/themes/github-dark"),
|
|
37
|
+
"github-dark-default": () => import("@shikijs/themes/github-dark-default"),
|
|
38
|
+
"github-dark-dimmed": () => import("@shikijs/themes/github-dark-dimmed"),
|
|
39
|
+
"github-dark-high-contrast": () => import("@shikijs/themes/github-dark-high-contrast"),
|
|
40
|
+
"github-light": () => import("@shikijs/themes/github-light"),
|
|
41
|
+
"github-light-default": () => import("@shikijs/themes/github-light-default"),
|
|
42
|
+
"github-light-high-contrast": () => import("@shikijs/themes/github-light-high-contrast"),
|
|
43
|
+
"gruvbox-dark-hard": () => import("@shikijs/themes/gruvbox-dark-hard"),
|
|
44
|
+
"gruvbox-dark-medium": () => import("@shikijs/themes/gruvbox-dark-medium"),
|
|
45
|
+
"gruvbox-dark-soft": () => import("@shikijs/themes/gruvbox-dark-soft"),
|
|
46
|
+
"gruvbox-light-hard": () => import("@shikijs/themes/gruvbox-light-hard"),
|
|
47
|
+
"gruvbox-light-medium": () => import("@shikijs/themes/gruvbox-light-medium"),
|
|
48
|
+
"gruvbox-light-soft": () => import("@shikijs/themes/gruvbox-light-soft"),
|
|
49
|
+
horizon: () => import("@shikijs/themes/horizon"),
|
|
50
|
+
"horizon-bright": () => import("@shikijs/themes/horizon-bright"),
|
|
51
|
+
houston: () => import("@shikijs/themes/houston"),
|
|
52
|
+
"kanagawa-dragon": () => import("@shikijs/themes/kanagawa-dragon"),
|
|
53
|
+
"kanagawa-lotus": () => import("@shikijs/themes/kanagawa-lotus"),
|
|
54
|
+
"kanagawa-wave": () => import("@shikijs/themes/kanagawa-wave"),
|
|
55
|
+
laserwave: () => import("@shikijs/themes/laserwave"),
|
|
56
|
+
"light-plus": () => import("@shikijs/themes/light-plus"),
|
|
57
|
+
"material-theme": () => import("@shikijs/themes/material-theme"),
|
|
58
|
+
"material-theme-darker": () => import("@shikijs/themes/material-theme-darker"),
|
|
59
|
+
"material-theme-lighter": () => import("@shikijs/themes/material-theme-lighter"),
|
|
60
|
+
"material-theme-ocean": () => import("@shikijs/themes/material-theme-ocean"),
|
|
61
|
+
"material-theme-palenight": () => import("@shikijs/themes/material-theme-palenight"),
|
|
62
|
+
"min-dark": () => import("@shikijs/themes/min-dark"),
|
|
63
|
+
"min-light": () => import("@shikijs/themes/min-light"),
|
|
64
|
+
monokai: () => import("@shikijs/themes/monokai"),
|
|
65
|
+
"night-owl": () => import("@shikijs/themes/night-owl"),
|
|
66
|
+
"night-owl-light": () => import("@shikijs/themes/night-owl-light"),
|
|
67
|
+
nord: () => import("@shikijs/themes/nord"),
|
|
68
|
+
"one-dark-pro": () => import("@shikijs/themes/one-dark-pro"),
|
|
69
|
+
"one-light": () => import("@shikijs/themes/one-light"),
|
|
70
|
+
plastic: () => import("@shikijs/themes/plastic"),
|
|
71
|
+
poimandres: () => import("@shikijs/themes/poimandres"),
|
|
72
|
+
red: () => import("@shikijs/themes/red"),
|
|
73
|
+
"rose-pine": () => import("@shikijs/themes/rose-pine"),
|
|
74
|
+
"rose-pine-dawn": () => import("@shikijs/themes/rose-pine-dawn"),
|
|
75
|
+
"rose-pine-moon": () => import("@shikijs/themes/rose-pine-moon"),
|
|
76
|
+
"slack-dark": () => import("@shikijs/themes/slack-dark"),
|
|
77
|
+
"slack-ochin": () => import("@shikijs/themes/slack-ochin"),
|
|
78
|
+
"snazzy-light": () => import("@shikijs/themes/snazzy-light"),
|
|
79
|
+
"solarized-dark": () => import("@shikijs/themes/solarized-dark"),
|
|
80
|
+
"solarized-light": () => import("@shikijs/themes/solarized-light"),
|
|
81
|
+
"synthwave-84": () => import("@shikijs/themes/synthwave-84"),
|
|
82
|
+
"tokyo-night": () => import("@shikijs/themes/tokyo-night"),
|
|
83
|
+
vesper: () => import("@shikijs/themes/vesper"),
|
|
84
|
+
"vitesse-black": () => import("@shikijs/themes/vitesse-black"),
|
|
85
|
+
"vitesse-dark": () => import("@shikijs/themes/vitesse-dark"),
|
|
86
|
+
"vitesse-light": () => import("@shikijs/themes/vitesse-light"),
|
|
87
|
+
};
|
|
88
|
+
//# sourceMappingURL=themes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"themes.js","sourceRoot":"","sources":["../../src/highlight/themes.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,MAAM,UAAU,GAA0C;IAC/D,UAAU,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,4BAA4B,CAAC;IACtD,UAAU,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,0BAA0B,CAAC;IACpD,UAAU,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,0BAA0B,CAAC;IACpD,WAAW,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,2BAA2B,CAAC;IACtD,YAAY,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,4BAA4B,CAAC;IACxD,mBAAmB,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,mCAAmC,CAAC;IACtE,kBAAkB,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,kCAAkC,CAAC;IACpE,sBAAsB,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,sCAAsC,CAAC;IAC5E,kBAAkB,EAAE,GAAG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
|
},
|
|
9
9
|
"homepage": "https://github.com/KensioSoftware/colophon#readme",
|
|
10
10
|
"license": "Apache-2.0",
|
|
11
|
-
"version": "2.
|
|
11
|
+
"version": "2.9.0",
|
|
12
12
|
"type": "module",
|
|
13
13
|
"main": "./dist/index.js",
|
|
14
14
|
"types": "./dist/index.d.ts",
|
|
@@ -98,6 +98,7 @@
|
|
|
98
98
|
},
|
|
99
99
|
"dependencies": {
|
|
100
100
|
"@resvg/resvg-js": "^2.6.2",
|
|
101
|
+
"@shikijs/themes": "^4.3.1",
|
|
101
102
|
"fontkit": "^2.0.4",
|
|
102
103
|
"gray-matter": "^4.0.3",
|
|
103
104
|
"sharp": "^0.35.3",
|