Skip to content

Commit 7345567

Browse files
committed
Generate index.d.ts
1 parent ea488fd commit 7345567

File tree

7 files changed

+4364
-4457
lines changed

7 files changed

+4364
-4457
lines changed

lib/dist/index.cjs.js

+2,097-2,097
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/dist/index.d.ts

+29-225
Original file line numberDiff line numberDiff line change
@@ -1,228 +1,32 @@
1-
import type React from "react";
1+
type LanguageAlias = "abap" | "actionscript-3" | "ada" | "apache" | "apex" | "apl" | "applescript" | "asm" | "astro" | "awk" | "ballerina" | "bat" | "batch" | "berry" | "be" | "bibtex" | "bicep" | "blade" | "c" | "cadence" | "cdc" | "clarity" | "clojure" | "clj" | "cmake" | "cobol" | "codeql" | "ql" | "coffee" | "cpp" | "crystal" | "csharp" | "c#" | "cs" | "css" | "cue" | "d" | "dart" | "diff" | "docker" | "dream-maker" | "elixir" | "elm" | "erb" | "erlang" | "erl" | "fish" | "fsharp" | "f#" | "fs" | "gherkin" | "git-commit" | "git-rebase" | "glsl" | "gnuplot" | "go" | "graphql" | "groovy" | "hack" | "haml" | "handlebars" | "hbs" | "haskell" | "hs" | "hcl" | "hlsl" | "html" | "http" | "imba" | "ini" | "java" | "javascript" | "js" | "jinja-html" | "json" | "json5" | "jsonc" | "jsonnet" | "jssm" | "fsl" | "jsx" | "julia" | "kotlin" | "latex" | "less" | "liquid" | "lisp" | "logo" | "lua" | "make" | "makefile" | "markdown" | "md" | "marko" | "matlab" | "mdx" | "mermaid" | "nginx" | "nim" | "nix" | "objective-c" | "objc" | "objective-cpp" | "ocaml" | "pascal" | "perl" | "php" | "plsql" | "postcss" | "powershell" | "ps" | "ps1" | "prisma" | "prolog" | "proto" | "pug" | "jade" | "puppet" | "purescript" | "python" | "py" | "r" | "raku" | "perl6" | "razor" | "rel" | "riscv" | "rst" | "ruby" | "rb" | "rust" | "rs" | "sas" | "sass" | "scala" | "scheme" | "scss" | "shaderlab" | "shader" | "shellscript" | "shell" | "bash" | "sh" | "zsh" | "smalltalk" | "solidity" | "sparql" | "sql" | "ssh-config" | "stata" | "stylus" | "styl" | "svelte" | "swift" | "system-verilog" | "tasl" | "tcl" | "tex" | "toml" | "tsx" | "turtle" | "twig" | "typescript" | "ts" | "v" | "vb" | "cmd" | "verilog" | "vhdl" | "viml" | "vim" | "vimscript" | "vue-html" | "vue" | "wasm" | "wenyan" | "文言" | "xml" | "xsl" | "yaml" | "yml" | "zenscript";
2+
type LanguageName = "abap" | "actionscript-3" | "ada" | "apache" | "apex" | "apl" | "applescript" | "asm" | "astro" | "awk" | "ballerina" | "bat" | "berry" | "bibtex" | "bicep" | "blade" | "c" | "cadence" | "clarity" | "clojure" | "cmake" | "cobol" | "codeql" | "coffee" | "cpp" | "crystal" | "csharp" | "css" | "cue" | "d" | "dart" | "diff" | "docker" | "dream-maker" | "elixir" | "elm" | "erb" | "erlang" | "fish" | "fsharp" | "gherkin" | "git-commit" | "git-rebase" | "glsl" | "gnuplot" | "go" | "graphql" | "groovy" | "hack" | "haml" | "handlebars" | "haskell" | "hcl" | "hlsl" | "html" | "http" | "imba" | "ini" | "java" | "javascript" | "jinja-html" | "json" | "json5" | "jsonc" | "jsonnet" | "jssm" | "jsx" | "julia" | "kotlin" | "latex" | "less" | "liquid" | "lisp" | "logo" | "lua" | "make" | "markdown" | "marko" | "matlab" | "mdx" | "mermaid" | "nginx" | "nim" | "nix" | "objective-c" | "objective-cpp" | "ocaml" | "pascal" | "perl" | "php" | "plsql" | "postcss" | "powershell" | "prisma" | "prolog" | "proto" | "pug" | "puppet" | "purescript" | "python" | "r" | "raku" | "razor" | "rel" | "riscv" | "rst" | "ruby" | "rust" | "sas" | "sass" | "scala" | "scheme" | "scss" | "shaderlab" | "shellscript" | "smalltalk" | "solidity" | "sparql" | "sql" | "ssh-config" | "stata" | "stylus" | "svelte" | "swift" | "system-verilog" | "tasl" | "tcl" | "tex" | "toml" | "tsx" | "turtle" | "twig" | "typescript" | "v" | "vb" | "verilog" | "vhdl" | "viml" | "vue-html" | "vue" | "wasm" | "wenyan" | "xml" | "xsl" | "yaml" | "zenscript";
23

3-
type StringTheme =
4-
| "dark-plus"
5-
| "dracula-soft"
6-
| "dracula"
7-
| "github-dark"
8-
| "github-dark-dimmed"
9-
| "github-light"
10-
| "light-plus"
11-
| "material-darker"
12-
| "material-default"
13-
| "material-lighter"
14-
| "material-ocean"
15-
| "material-palenight"
16-
| "min-dark"
17-
| "min-light"
18-
| "monokai"
19-
| "nord"
20-
| "one-dark-pro"
21-
| "poimandres"
22-
| "slack-dark"
23-
| "slack-ochin"
24-
| "solarized-dark"
25-
| "solarized-light";
26-
27-
export type Lang =
28-
| "abap"
29-
| "actionscript-3"
30-
| "ada"
31-
| "apache"
32-
| "apex"
33-
| "apl"
34-
| "applescript"
35-
| "asm"
36-
| "astro"
37-
| "awk"
38-
| "ballerina"
39-
| "bash"
40-
| "bat"
41-
| "batch"
42-
| "be"
43-
| "berry"
44-
| "bibtex"
45-
| "bicep"
46-
| "blade"
47-
| "c"
48-
| "c#"
49-
| "cadence"
50-
| "cdc"
51-
| "clarity"
52-
| "clj"
53-
| "clojure"
54-
| "cmake"
55-
| "cmd"
56-
| "cobol"
57-
| "codeql"
58-
| "coffee"
59-
| "cpp"
60-
| "crystal"
61-
| "csharp"
62-
| "css"
63-
| "cue"
64-
| "d"
65-
| "dart"
66-
| "diff"
67-
| "docker"
68-
| "dream-maker"
69-
| "elixir"
70-
| "elm"
71-
| "erb"
72-
| "erl"
73-
| "erlang"
74-
| "f#"
75-
| "fish"
76-
| "fsharp"
77-
| "fsl"
78-
| "gherkin"
79-
| "git-commit"
80-
| "git-rebase"
81-
| "glsl"
82-
| "gnuplot"
83-
| "go"
84-
| "graphql"
85-
| "groovy"
86-
| "hack"
87-
| "haml"
88-
| "handlebars"
89-
| "haskell"
90-
| "hbs"
91-
| "hcl"
92-
| "hlsl"
93-
| "hs"
94-
| "html"
95-
| "ini"
96-
| "jade"
97-
| "java"
98-
| "javascript"
99-
| "jinja-html"
100-
| "js"
101-
| "json"
102-
| "jsonc"
103-
| "jsonnet"
104-
| "jssm"
105-
| "jsx"
106-
| "julia"
107-
| "kotlin"
108-
| "latex"
109-
| "less"
110-
| "liquid"
111-
| "lisp"
112-
| "logo"
113-
| "lua"
114-
| "make"
115-
| "makefile"
116-
| "markdown"
117-
| "marko"
118-
| "matlab"
119-
| "md"
120-
| "mdx"
121-
| "mermaid"
122-
| "nginx"
123-
| "nim"
124-
| "nix"
125-
| "objc"
126-
| "objective-c"
127-
| "objective-cpp"
128-
| "ocaml"
129-
| "pascal"
130-
| "perl"
131-
| "perl6"
132-
| "php"
133-
| "plsql"
134-
| "postcss"
135-
| "powershell"
136-
| "prisma"
137-
| "prolog"
138-
| "ps"
139-
| "ps1"
140-
| "pug"
141-
| "puppet"
142-
| "purescript"
143-
| "py"
144-
| "python"
145-
| "ql"
146-
| "r"
147-
| "raku"
148-
| "razor"
149-
| "rb"
150-
| "rel"
151-
| "riscv"
152-
| "rs"
153-
| "rst"
154-
| "ruby"
155-
| "rust"
156-
| "sas"
157-
| "sass"
158-
| "scala"
159-
| "scheme"
160-
| "scss"
161-
| "sh"
162-
| "shader"
163-
| "shaderlab"
164-
| "shell"
165-
| "shellscript"
166-
| "smalltalk"
167-
| "solidity"
168-
| "sparql"
169-
| "sql"
170-
| "ssh-config"
171-
| "stata"
172-
| "styl"
173-
| "stylus"
174-
| "svelte"
175-
| "swift"
176-
| "system-verilog"
177-
| "tasl"
178-
| "tcl"
179-
| "tex"
180-
| "toml"
181-
| "ts"
182-
| "tsx"
183-
| "turtle"
184-
| "twig"
185-
| "typescript"
186-
| "vb"
187-
| "verilog"
188-
| "vhdl"
189-
| "vim"
190-
| "viml"
191-
| "vimscript"
192-
| "vue"
193-
| "vue-html"
194-
| "wasm"
195-
| "wenyan"
196-
| "xml"
197-
| "xsl"
198-
| "yaml"
199-
| "zenscript"
200-
| "zsh"
201-
| "文言";
202-
203-
export type Token = { style: React.CSSProperties; content: string };
204-
205-
export type Theme = StringTheme | Object;
206-
207-
export class UnknownLanguageError extends Error {
208-
alias: string;
4+
declare function highlight(code: string, alias: LanguageAlias, themeOrThemeName?: string): Promise<{
5+
background: any;
6+
foreground: any;
7+
colorScheme: string;
8+
lineNumberForeground: any;
9+
selectionBackground: any;
10+
editorBackground: any;
11+
editorGroupHeaderBackground: any;
12+
activeTabBackground: any;
13+
activeTabForeground: any;
14+
tabBorder: any;
15+
activeTabBorder: any;
16+
lines: {
17+
content: string;
18+
style: {
19+
color: string;
20+
fontStyle?: "italic";
21+
fontWeight?: "bold";
22+
textDecoration?: "underline" | "line-through";
23+
};
24+
}[][];
25+
lang: LanguageName;
26+
}>;
27+
declare class UnknownLanguageError extends Error {
28+
alias: string;
29+
constructor(alias: string);
20930
}
21031

211-
export const highlight: (
212-
code: string,
213-
lang: Lang,
214-
theme?: Theme
215-
) => Promise<{
216-
lines: Token[][];
217-
foreground: string;
218-
background: string;
219-
colorScheme: string;
220-
lineNumberForeground: string;
221-
selectionBackground: string;
222-
editorBackground: string;
223-
editorGroupHeaderBackground: string;
224-
activeTabBackground: string;
225-
activeTabForeground: string;
226-
tabBorder: string;
227-
activeTabBorder: string;
228-
}>;
32+
export { UnknownLanguageError, highlight };

lib/dist/index.esm.mjs

+2,097-2,097
Large diffs are not rendered by default.

lib/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@
1717
"@rollup/plugin-json": "^6.0.0",
1818
"@rollup/plugin-node-resolve": "^14.0.0",
1919
"@rollup/plugin-replace": "^5.0.1",
20-
"@rollup/plugin-typescript": "^11.0.0",
2120
"@rollup/pluginutils": "^5.0.2",
2221
"@types/react": "^18.0.26",
2322
"rollup": "^2.79.0",
23+
"rollup-plugin-dts": "^5.1.1",
24+
"rollup-plugin-typescript2": "^0.34.1",
2425
"tslib": "^2.4.1",
2526
"typescript": "^4.9.4",
2627
"vscode-oniguruma": "^1.0.0",

lib/rollup.config.js

+37-25
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,43 @@ import commonjs from "@rollup/plugin-commonjs";
33
import { arraybuffer } from "./load-buffer";
44
import replace from "@rollup/plugin-replace";
55
import json from "@rollup/plugin-json";
6-
import typescript from "@rollup/plugin-typescript";
6+
import typescript from "rollup-plugin-typescript2";
7+
import dts from "rollup-plugin-dts";
78

89
const pkg = require("./package.json");
910

10-
export default {
11-
input: "src/index.ts",
12-
output: [
13-
{
14-
file: "dist/index.cjs.js",
15-
format: "cjs",
16-
},
17-
{
18-
file: "dist/index.esm.mjs",
19-
format: "esm",
20-
},
21-
],
22-
plugins: [
23-
replace({
24-
__LIGHTER_VERSION__: `${pkg.version}`,
25-
preventAssignment: false,
26-
}),
27-
json(),
28-
typescript(),
29-
nodeResolve(),
30-
arraybuffer({ include: "**/*.wasm" }),
31-
commonjs(),
32-
],
33-
};
11+
export default [
12+
{
13+
input: "src/index.ts",
14+
output: [
15+
{
16+
file: "dist/index.cjs.js",
17+
format: "cjs",
18+
},
19+
{
20+
file: "dist/index.esm.mjs",
21+
format: "esm",
22+
},
23+
],
24+
plugins: [
25+
replace({
26+
__LIGHTER_VERSION__: `${pkg.version}`,
27+
preventAssignment: false,
28+
}),
29+
json(),
30+
nodeResolve(),
31+
typescript({
32+
tsconfigDefaults: {
33+
compilerOptions: { module: "esnext" },
34+
},
35+
}),
36+
arraybuffer({ include: "**/*.wasm" }),
37+
commonjs(),
38+
],
39+
},
40+
{
41+
input: "./src/index.ts",
42+
output: [{ file: "dist/index.d.ts", format: "es" }],
43+
plugins: [dts()],
44+
},
45+
];

lib/tsconfig.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"compilerOptions": {
3+
"moduleResolution": "node"
4+
}
5+
}

0 commit comments

Comments
 (0)