@arborium/arborium 0.0.7 → 0.700.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/arborium.iife.js +2 -114
- package/dist/arborium.iife.js.map +1 -1
- package/dist/arborium.js +239 -203
- package/dist/arborium.js.map +1 -1
- package/dist/arborium_host.js +482 -0
- package/dist/arborium_host_bg.wasm +0 -0
- package/dist/loader.d.ts +23 -11
- package/dist/types.d.ts +5 -1
- package/dist/wasi-shims.d.ts +65 -12
- package/package.json +28 -25
package/dist/loader.d.ts
CHANGED
|
@@ -1,12 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Arborium loader - loads grammar plugins and highlights code.
|
|
3
|
+
*
|
|
4
|
+
* Architecture:
|
|
5
|
+
* 1. Fetch plugins.json from arborium.bearcove.eu to get grammar CDN URLs
|
|
6
|
+
* 2. Load grammar WIT components on demand from @arborium/<lang> packages
|
|
7
|
+
* 3. Parse and highlight using the grammar's tree-sitter parser
|
|
8
|
+
*/
|
|
9
|
+
import type { ArboriumConfig, Grammar, Span } from './types.js';
|
|
10
|
+
export declare const defaultConfig: Required<ArboriumConfig>;
|
|
11
|
+
/** Highlight source code */
|
|
12
|
+
export declare function highlight(language: string, source: string, _config?: ArboriumConfig): Promise<string>;
|
|
13
|
+
/** Load a grammar for direct use */
|
|
14
|
+
export declare function loadGrammar(language: string, _config?: ArboriumConfig): Promise<Grammar | null>;
|
|
15
|
+
/** Convert spans to HTML */
|
|
7
16
|
export declare function spansToHtml(source: string, spans: Span[]): string;
|
|
8
|
-
/**
|
|
9
|
-
export declare function
|
|
10
|
-
/**
|
|
11
|
-
export declare function
|
|
12
|
-
|
|
17
|
+
/** Get current config, optionally merging with overrides */
|
|
18
|
+
export declare function getConfig(overrides?: Partial<ArboriumConfig>): Required<ArboriumConfig>;
|
|
19
|
+
/** Set/merge config */
|
|
20
|
+
export declare function setConfig(newConfig: Partial<ArboriumConfig>): void;
|
|
21
|
+
/** Check if a language is available */
|
|
22
|
+
export declare function isLanguageAvailable(language: string): Promise<boolean>;
|
|
23
|
+
/** Get list of available languages */
|
|
24
|
+
export declare function getAvailableLanguages(): Promise<string[]>;
|
package/dist/types.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ export interface Grammar {
|
|
|
24
24
|
/** Languages this grammar may inject */
|
|
25
25
|
injectionLanguages(): string[];
|
|
26
26
|
/** Highlight source code, returning HTML string */
|
|
27
|
-
highlight(source: string): string
|
|
27
|
+
highlight(source: string): string | Promise<string>;
|
|
28
28
|
/** Parse source code, returning raw spans */
|
|
29
29
|
parse(source: string): ParseResult;
|
|
30
30
|
/** Dispose of resources */
|
|
@@ -42,6 +42,10 @@ export interface ArboriumConfig {
|
|
|
42
42
|
cdn?: string;
|
|
43
43
|
/** Package version to load (default: "latest") */
|
|
44
44
|
version?: string;
|
|
45
|
+
/** URL to plugins.json manifest (for local testing) */
|
|
46
|
+
pluginsUrl?: string;
|
|
47
|
+
/** Base URL for the Rust host module (for local testing) */
|
|
48
|
+
hostUrl?: string;
|
|
45
49
|
}
|
|
46
50
|
/** Global config set before script loads */
|
|
47
51
|
declare global {
|
package/dist/wasi-shims.d.ts
CHANGED
|
@@ -19,31 +19,83 @@ declare class InputStream {
|
|
|
19
19
|
subscribe(): void;
|
|
20
20
|
}
|
|
21
21
|
export declare function createWasiImports(): {
|
|
22
|
+
'wasi:cli/environment': {
|
|
23
|
+
getEnvironment: () => Array<[string, string]>;
|
|
24
|
+
getArguments: () => string[];
|
|
25
|
+
};
|
|
26
|
+
'wasi:cli/exit': {
|
|
27
|
+
exit: (status: {
|
|
28
|
+
tag: string;
|
|
29
|
+
val?: number;
|
|
30
|
+
}) => void;
|
|
31
|
+
};
|
|
32
|
+
'wasi:cli/stdin': {
|
|
33
|
+
getStdin: () => InputStream;
|
|
34
|
+
};
|
|
35
|
+
'wasi:cli/stdout': {
|
|
36
|
+
getStdout: () => OutputStream;
|
|
37
|
+
};
|
|
38
|
+
'wasi:cli/stderr': {
|
|
39
|
+
getStderr: () => OutputStream;
|
|
40
|
+
};
|
|
41
|
+
'wasi:clocks/wall-clock': {
|
|
42
|
+
now: () => {
|
|
43
|
+
seconds: bigint;
|
|
44
|
+
nanoseconds: number;
|
|
45
|
+
};
|
|
46
|
+
resolution: () => {
|
|
47
|
+
seconds: bigint;
|
|
48
|
+
nanoseconds: number;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
'wasi:filesystem/types': {
|
|
52
|
+
Descriptor: {
|
|
53
|
+
new (): {};
|
|
54
|
+
};
|
|
55
|
+
DirectoryEntryStream: {
|
|
56
|
+
new (): {};
|
|
57
|
+
};
|
|
58
|
+
filesystemErrorCode: () => null;
|
|
59
|
+
};
|
|
60
|
+
'wasi:filesystem/preopens': {
|
|
61
|
+
getDirectories: () => Array<[unknown, string]>;
|
|
62
|
+
};
|
|
63
|
+
'wasi:io/error': {
|
|
64
|
+
Error: typeof WasiError;
|
|
65
|
+
};
|
|
66
|
+
'wasi:io/streams': {
|
|
67
|
+
InputStream: typeof InputStream;
|
|
68
|
+
OutputStream: typeof OutputStream;
|
|
69
|
+
};
|
|
70
|
+
'wasi:random/random': {
|
|
71
|
+
getRandomBytes: (len: bigint) => Uint8Array;
|
|
72
|
+
getRandomU64: () => bigint;
|
|
73
|
+
};
|
|
22
74
|
'wasi:cli/environment@0.2.3': {
|
|
23
|
-
getEnvironment()
|
|
24
|
-
getArguments()
|
|
75
|
+
getEnvironment: () => Array<[string, string]>;
|
|
76
|
+
getArguments: () => string[];
|
|
25
77
|
};
|
|
26
78
|
'wasi:cli/exit@0.2.3': {
|
|
27
|
-
exit(status: {
|
|
79
|
+
exit: (status: {
|
|
28
80
|
tag: string;
|
|
29
81
|
val?: number;
|
|
30
|
-
})
|
|
82
|
+
}) => void;
|
|
31
83
|
};
|
|
32
84
|
'wasi:cli/stdin@0.2.3': {
|
|
33
|
-
getStdin()
|
|
85
|
+
getStdin: () => InputStream;
|
|
34
86
|
};
|
|
35
87
|
'wasi:cli/stdout@0.2.3': {
|
|
36
|
-
getStdout()
|
|
88
|
+
getStdout: () => OutputStream;
|
|
37
89
|
};
|
|
38
90
|
'wasi:cli/stderr@0.2.3': {
|
|
39
|
-
getStderr()
|
|
91
|
+
getStderr: () => OutputStream;
|
|
40
92
|
};
|
|
41
93
|
'wasi:clocks/wall-clock@0.2.3': {
|
|
42
|
-
now()
|
|
94
|
+
now: () => {
|
|
43
95
|
seconds: bigint;
|
|
44
96
|
nanoseconds: number;
|
|
45
97
|
};
|
|
46
|
-
resolution()
|
|
98
|
+
resolution: () => {
|
|
47
99
|
seconds: bigint;
|
|
48
100
|
nanoseconds: number;
|
|
49
101
|
};
|
|
@@ -55,9 +107,10 @@ export declare function createWasiImports(): {
|
|
|
55
107
|
DirectoryEntryStream: {
|
|
56
108
|
new (): {};
|
|
57
109
|
};
|
|
110
|
+
filesystemErrorCode: () => null;
|
|
58
111
|
};
|
|
59
112
|
'wasi:filesystem/preopens@0.2.3': {
|
|
60
|
-
getDirectories()
|
|
113
|
+
getDirectories: () => Array<[unknown, string]>;
|
|
61
114
|
};
|
|
62
115
|
'wasi:io/error@0.2.3': {
|
|
63
116
|
Error: typeof WasiError;
|
|
@@ -67,8 +120,8 @@ export declare function createWasiImports(): {
|
|
|
67
120
|
OutputStream: typeof OutputStream;
|
|
68
121
|
};
|
|
69
122
|
'wasi:random/random@0.2.3': {
|
|
70
|
-
getRandomBytes(len: bigint)
|
|
71
|
-
getRandomU64()
|
|
123
|
+
getRandomBytes: (len: bigint) => Uint8Array;
|
|
124
|
+
getRandomU64: () => bigint;
|
|
72
125
|
};
|
|
73
126
|
};
|
|
74
127
|
export declare const grammarTypesImport: {
|
package/package.json
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
"
|
|
2
|
+
"author": "Amos Wenger <amos@bearcove.eu>",
|
|
3
|
+
"bugs": {
|
|
4
|
+
"url": "https://github.com/bearcove/arborium/issues"
|
|
5
|
+
},
|
|
4
6
|
"description": "High-performance syntax highlighting powered by tree-sitter and WebAssembly",
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
"devDependencies": {
|
|
8
|
+
"typescript": "^5.7.2",
|
|
9
|
+
"vite": "^7.2.6",
|
|
10
|
+
"vite-plugin-dts": "^4.5.0"
|
|
11
|
+
},
|
|
9
12
|
"exports": {
|
|
10
13
|
".": {
|
|
11
14
|
"import": "./dist/arborium.js",
|
|
@@ -14,18 +17,13 @@
|
|
|
14
17
|
"./iife": {
|
|
15
18
|
"import": "./dist/arborium.iife.js"
|
|
16
19
|
},
|
|
17
|
-
"./themes/
|
|
18
|
-
"./themes/
|
|
20
|
+
"./themes/github-light.css": "./dist/themes/github-light.css",
|
|
21
|
+
"./themes/tokyo-night.css": "./dist/themes/tokyo-night.css"
|
|
19
22
|
},
|
|
20
23
|
"files": [
|
|
21
24
|
"dist"
|
|
22
25
|
],
|
|
23
|
-
"
|
|
24
|
-
"dev": "vite",
|
|
25
|
-
"build": "vite build && tsc --emitDeclarationOnly",
|
|
26
|
-
"preview": "vite preview",
|
|
27
|
-
"typecheck": "tsc --noEmit"
|
|
28
|
-
},
|
|
26
|
+
"homepage": "https://github.com/bearcove/arborium",
|
|
29
27
|
"keywords": [
|
|
30
28
|
"syntax-highlighting",
|
|
31
29
|
"tree-sitter",
|
|
@@ -34,20 +32,25 @@
|
|
|
34
32
|
"code",
|
|
35
33
|
"highlight"
|
|
36
34
|
],
|
|
37
|
-
"author": "Amos Wenger <amos@bearcove.net>",
|
|
38
35
|
"license": "MIT OR Apache-2.0",
|
|
36
|
+
"main": "./dist/arborium.js",
|
|
37
|
+
"module": "./dist/arborium.js",
|
|
38
|
+
"name": "@arborium/arborium",
|
|
39
39
|
"repository": {
|
|
40
|
+
"directory": "packages/arborium",
|
|
40
41
|
"type": "git",
|
|
41
|
-
"url": "git+https://github.com/bearcove/arborium.git"
|
|
42
|
-
"directory": "packages/arborium"
|
|
42
|
+
"url": "git+https://github.com/bearcove/arborium.git"
|
|
43
43
|
},
|
|
44
|
-
"
|
|
45
|
-
|
|
46
|
-
"
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "vite build && vite build --config vite.config.iife.ts && tsc --emitDeclarationOnly && npm run copy:host",
|
|
46
|
+
"build:esm": "vite build",
|
|
47
|
+
"build:iife": "vite build --config vite.config.iife.ts",
|
|
48
|
+
"copy:host": "cp ../../demo/pkg/arborium_host.js ../../demo/pkg/arborium_host_bg.wasm dist/",
|
|
49
|
+
"dev": "vite",
|
|
50
|
+
"preview": "vite preview",
|
|
51
|
+
"typecheck": "tsc --noEmit"
|
|
47
52
|
},
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
"vite-plugin-dts": "^4.5.0"
|
|
52
|
-
}
|
|
53
|
+
"type": "module",
|
|
54
|
+
"types": "./dist/arborium.d.ts",
|
|
55
|
+
"version": "0.700.0"
|
|
53
56
|
}
|