@halo-dev/shiki-code-element 1.0.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/LICENSE +674 -0
- package/README.md +108 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1021 -0
- package/dist/shiki-code.d.ts +37 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/utils/copy-to-clipboard.d.ts +1 -0
- package/dist/variants/base.d.ts +8 -0
- package/dist/variants/mac.d.ts +11 -0
- package/dist/variants/simple.d.ts +10 -0
- package/package.json +39 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
import { ThemeRegistrationResolved } from 'shiki';
|
|
3
|
+
export declare class ShikiCode extends LitElement {
|
|
4
|
+
lightTheme: string;
|
|
5
|
+
darkTheme?: string;
|
|
6
|
+
variant: "simple" | "mac";
|
|
7
|
+
fontSize: string;
|
|
8
|
+
loading: boolean;
|
|
9
|
+
html: string;
|
|
10
|
+
languageCode: string;
|
|
11
|
+
languageName: string;
|
|
12
|
+
lightThemeRegistration: ThemeRegistrationResolved | null;
|
|
13
|
+
darkThemeRegistration: ThemeRegistrationResolved | null;
|
|
14
|
+
code: string;
|
|
15
|
+
copied: boolean;
|
|
16
|
+
error: string;
|
|
17
|
+
private _observer;
|
|
18
|
+
private _media;
|
|
19
|
+
private _colorScheme;
|
|
20
|
+
get _themeRegistration(): ThemeRegistrationResolved | null;
|
|
21
|
+
connectedCallback(): void;
|
|
22
|
+
disconnectedCallback(): void;
|
|
23
|
+
isDarkMode(): boolean | undefined;
|
|
24
|
+
updateTheme(): void;
|
|
25
|
+
render(): import('lit').TemplateResult<1>;
|
|
26
|
+
renderCodeBlockBody(): import('lit').TemplateResult<1> | undefined;
|
|
27
|
+
handleSlotchange(e: Event): void;
|
|
28
|
+
process(codeElement: HTMLElement): Promise<void>;
|
|
29
|
+
extractLanguageCode(classList: DOMTokenList): string | null;
|
|
30
|
+
renderCodeAsHtml(code: string, language: string): Promise<string>;
|
|
31
|
+
static styles: import('lit').CSSResult[];
|
|
32
|
+
}
|
|
33
|
+
declare global {
|
|
34
|
+
interface HTMLElementTagNameMap {
|
|
35
|
+
"shiki-code": ShikiCode;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ThemeRegistration } from 'shiki';
|
|
2
|
+
export type ColorScheme = "light" | "dark";
|
|
3
|
+
export interface VariantOptions {
|
|
4
|
+
html: string;
|
|
5
|
+
code: string;
|
|
6
|
+
languageName: string;
|
|
7
|
+
colorScheme: ColorScheme;
|
|
8
|
+
theme: ThemeRegistration | null;
|
|
9
|
+
fontSize: string;
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function copyText(text: string, cb: () => void): void;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { LitElement, PropertyValues } from 'lit';
|
|
2
|
+
import { VariantOptions } from '../types';
|
|
3
|
+
export declare class ShikiCodeBaseVariant extends LitElement {
|
|
4
|
+
options: VariantOptions;
|
|
5
|
+
copied: boolean;
|
|
6
|
+
protected updated(_changedProperties: PropertyValues): void;
|
|
7
|
+
handleCopyCode(): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ShikiCodeBaseVariant } from './base';
|
|
2
|
+
export declare class ShikiCodeMacVariant extends ShikiCodeBaseVariant {
|
|
3
|
+
fold: boolean;
|
|
4
|
+
render(): import('lit').TemplateResult<1>;
|
|
5
|
+
static styles: import('lit').CSSResult[];
|
|
6
|
+
}
|
|
7
|
+
declare global {
|
|
8
|
+
interface HTMLElementTagNameMap {
|
|
9
|
+
"shiki-code-mac-variant": ShikiCodeMacVariant;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ShikiCodeBaseVariant } from './base';
|
|
2
|
+
export declare class ShikiCodeSimpleVariant extends ShikiCodeBaseVariant {
|
|
3
|
+
render(): import('lit').TemplateResult<1>;
|
|
4
|
+
static styles: import('lit').CSSResult[];
|
|
5
|
+
}
|
|
6
|
+
declare global {
|
|
7
|
+
interface HTMLElementTagNameMap {
|
|
8
|
+
"shiki-code-simple-variant": ShikiCodeSimpleVariant;
|
|
9
|
+
}
|
|
10
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@halo-dev/shiki-code-element",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "https://github.com/halo-sigs/plugin-shiki.git",
|
|
7
|
+
"directory": "shiki-code-element"
|
|
8
|
+
},
|
|
9
|
+
"type": "module",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"main": "./dist/index.js",
|
|
17
|
+
"module": "./dist/index.js",
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"files": [
|
|
20
|
+
"dist"
|
|
21
|
+
],
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"lit": "^3.3.1"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@iconify/json": "^2.2.395",
|
|
27
|
+
"@unocss/reset": "^66.5.4",
|
|
28
|
+
"unocss": "^66.5.4",
|
|
29
|
+
"vite-plugin-dts": "^4.5.4"
|
|
30
|
+
},
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"@shikijs/transformers": "^3",
|
|
33
|
+
"shiki": "^3"
|
|
34
|
+
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"build": "tsc && vite build --config vite.lib.config.ts",
|
|
37
|
+
"dev": "vite --config vite.dev.config.ts"
|
|
38
|
+
}
|
|
39
|
+
}
|