@kerebron/wasm 0.4.27 → 0.4.29
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/esm/deno.d.ts +2 -0
- package/esm/deno.d.ts.map +1 -0
- package/esm/deno.js +4 -0
- package/esm/deno.js.map +1 -0
- package/esm/mod.d.ts +12 -0
- package/esm/mod.d.ts.map +1 -0
- package/esm/mod.js +41 -0
- package/esm/mod.js.map +1 -0
- package/esm/package.json +3 -0
- package/esm/wasm.d.ts +138 -0
- package/esm/wasm.d.ts.map +1 -0
- package/esm/wasm.js +121 -0
- package/esm/wasm.js.map +1 -0
- package/package.json +4 -2
- package/src/deno.ts +3 -0
- package/src/mod.ts +56 -0
- package/src/wasm.js +120 -0
package/esm/deno.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deno.d.ts","sourceRoot":"","sources":["../src/deno.ts"],"names":[],"mappings":"AAAA,wBAAgB,OAAO,WAEtB"}
|
package/esm/deno.js
ADDED
package/esm/deno.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deno.js","sourceRoot":"","sources":["../src/deno.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,OAAO;IACrB,OAAO,qEAAY,OAAO,CAAC,WAAW,CAAC,CAAC;AAC1C,CAAC"}
|
package/esm/mod.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import manifest from './wasm.js';
|
|
2
|
+
export declare function getLangsList(): string[];
|
|
3
|
+
export declare function getLangTreeSitter(lang: string, cdnUrl?: string): {
|
|
4
|
+
lang: string;
|
|
5
|
+
repo: string;
|
|
6
|
+
files: string[];
|
|
7
|
+
queries: any;
|
|
8
|
+
};
|
|
9
|
+
export declare function fetchWasm(wasmUrl: string): Promise<Uint8Array>;
|
|
10
|
+
export declare function fetchTextResource(url: string): Promise<string>;
|
|
11
|
+
export { manifest };
|
|
12
|
+
//# sourceMappingURL=mod.d.ts.map
|
package/esm/mod.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,WAAW,CAAC;AAEjC,wBAAgB,YAAY,IAAI,MAAM,EAAE,CAMvC;AAED,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,MAAM,SAAgC;;;;;EAuBvC;AAED,wBAAsB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAOpE;AAED,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAOpE;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
package/esm/mod.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import manifest from './wasm.js';
|
|
2
|
+
export function getLangsList() {
|
|
3
|
+
return manifest
|
|
4
|
+
.map((item) => item.repo.split('-').pop())
|
|
5
|
+
.filter((item) => 'string' === typeof item);
|
|
6
|
+
}
|
|
7
|
+
export function getLangTreeSitter(lang, cdnUrl = 'http://localhost:8000/wasm/') {
|
|
8
|
+
const langManifest = manifest.find((item) => item.repo.endsWith('-' + lang));
|
|
9
|
+
if (!langManifest) {
|
|
10
|
+
throw new Error('No grammar for: ' + lang);
|
|
11
|
+
}
|
|
12
|
+
if (!cdnUrl.endsWith('/')) {
|
|
13
|
+
cdnUrl += '/';
|
|
14
|
+
}
|
|
15
|
+
const dir = langManifest.repo.split('/')[1];
|
|
16
|
+
cdnUrl += dir + '/';
|
|
17
|
+
const queries = Object.entries(langManifest.queries)
|
|
18
|
+
.map((entry) => [entry[0], cdnUrl + entry[0]]);
|
|
19
|
+
return {
|
|
20
|
+
lang,
|
|
21
|
+
repo: langManifest.repo,
|
|
22
|
+
files: langManifest.files.map((file) => cdnUrl + file),
|
|
23
|
+
queries: Object.fromEntries(queries),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export async function fetchWasm(wasmUrl) {
|
|
27
|
+
const response = await fetch(wasmUrl);
|
|
28
|
+
if (response.status >= 400) {
|
|
29
|
+
throw new Error(`Error fetching ${response.status}`);
|
|
30
|
+
}
|
|
31
|
+
return new Uint8Array(await response.arrayBuffer());
|
|
32
|
+
}
|
|
33
|
+
export async function fetchTextResource(url) {
|
|
34
|
+
const responseScm = await fetch(url);
|
|
35
|
+
if (responseScm.status >= 400) {
|
|
36
|
+
throw new Error(`Error fetching ${responseScm.status}`);
|
|
37
|
+
}
|
|
38
|
+
return await responseScm.text();
|
|
39
|
+
}
|
|
40
|
+
export { manifest };
|
|
41
|
+
//# sourceMappingURL=mod.js.map
|
package/esm/mod.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.js","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,WAAW,CAAC;AAEjC,MAAM,UAAU,YAAY;IAC1B,OAAO,QAAQ;SACZ,GAAG,CACF,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CACrC;SACA,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,KAAK,OAAO,IAAI,CAAC,CAAC;AAChD,CAAC;AAED,MAAM,UAAU,iBAAiB,CAC/B,IAAY,EACZ,MAAM,GAAG,6BAA6B;IAEtC,MAAM,YAAY,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC;IAC7E,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAAC;IAC7C,CAAC;IAED,IAAI,CAAC,MAAM,C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AC,MAAM,EAAE,CAAC,CAAC;IAC1D,CAAC;IAED,OAAO,MAAM,WAAW,CAAC,IAAI,EAAE,CAAC;AAClC,CAAC;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
package/esm/package.json
ADDED
package/esm/wasm.d.ts
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
declare const _default: ({
|
|
2
|
+
repo: string;
|
|
3
|
+
version: string;
|
|
4
|
+
files: string[];
|
|
5
|
+
queries: {
|
|
6
|
+
"highlights.scm": string;
|
|
7
|
+
"injections.scm": string;
|
|
8
|
+
"highlights-inline.scm": string;
|
|
9
|
+
"injections-inline.scm": string;
|
|
10
|
+
"highlights-dtd.scm"?: undefined;
|
|
11
|
+
"tags.scm"?: undefined;
|
|
12
|
+
"locals.scm"?: undefined;
|
|
13
|
+
"highlights-jsx.scm"?: undefined;
|
|
14
|
+
"highlights-params.scm"?: undefined;
|
|
15
|
+
};
|
|
16
|
+
} | {
|
|
17
|
+
repo: string;
|
|
18
|
+
version: string;
|
|
19
|
+
files: string[];
|
|
20
|
+
queries: {
|
|
21
|
+
"highlights.scm": string;
|
|
22
|
+
"injections.scm"?: undefined;
|
|
23
|
+
"highlights-inline.scm"?: undefined;
|
|
24
|
+
"injections-inline.scm"?: undefined;
|
|
25
|
+
"highlights-dtd.scm"?: undefined;
|
|
26
|
+
"tags.scm"?: undefined;
|
|
27
|
+
"locals.scm"?: undefined;
|
|
28
|
+
"highlights-jsx.scm"?: undefined;
|
|
29
|
+
"highlights-params.scm"?: undefined;
|
|
30
|
+
};
|
|
31
|
+
} | {
|
|
32
|
+
repo: string;
|
|
33
|
+
version: string;
|
|
34
|
+
files: string[];
|
|
35
|
+
queries: {
|
|
36
|
+
"highlights.scm": string;
|
|
37
|
+
"highlights-dtd.scm": string;
|
|
38
|
+
"injections.scm"?: undefined;
|
|
39
|
+
"highlights-inline.scm"?: undefined;
|
|
40
|
+
"injections-inline.scm"?: undefined;
|
|
41
|
+
"tags.scm"?: undefined;
|
|
42
|
+
"locals.scm"?: undefined;
|
|
43
|
+
"highlights-jsx.scm"?: undefined;
|
|
44
|
+
"highlights-params.scm"?: undefined;
|
|
45
|
+
};
|
|
46
|
+
} | {
|
|
47
|
+
repo: string;
|
|
48
|
+
version: string;
|
|
49
|
+
files: string[];
|
|
50
|
+
queries: {
|
|
51
|
+
"highlights.scm": string;
|
|
52
|
+
"injections.scm": string;
|
|
53
|
+
"highlights-inline.scm"?: undefined;
|
|
54
|
+
"injections-inline.scm"?: undefined;
|
|
55
|
+
"highlights-dtd.scm"?: undefined;
|
|
56
|
+
"tags.scm"?: undefined;
|
|
57
|
+
"locals.scm"?: undefined;
|
|
58
|
+
"highlights-jsx.scm"?: undefined;
|
|
59
|
+
"highlights-params.scm"?: undefined;
|
|
60
|
+
};
|
|
61
|
+
} | {
|
|
62
|
+
repo: string;
|
|
63
|
+
version: string;
|
|
64
|
+
files: string[];
|
|
65
|
+
queries: {
|
|
66
|
+
"highlights.scm": string;
|
|
67
|
+
"injections.scm": string;
|
|
68
|
+
"tags.scm": string;
|
|
69
|
+
"highlights-inline.scm"?: undefined;
|
|
70
|
+
"injections-inline.scm"?: undefined;
|
|
71
|
+
"highlights-dtd.scm"?: undefined;
|
|
72
|
+
"locals.scm"?: undefined;
|
|
73
|
+
"highlights-jsx.scm"?: undefined;
|
|
74
|
+
"highlights-params.scm"?: undefined;
|
|
75
|
+
};
|
|
76
|
+
} | {
|
|
77
|
+
repo: string;
|
|
78
|
+
version: string;
|
|
79
|
+
files: string[];
|
|
80
|
+
queries: {
|
|
81
|
+
"highlights.scm": string;
|
|
82
|
+
"locals.scm": string;
|
|
83
|
+
"tags.scm": string;
|
|
84
|
+
"injections.scm"?: undefined;
|
|
85
|
+
"highlights-inline.scm"?: undefined;
|
|
86
|
+
"injections-inline.scm"?: undefined;
|
|
87
|
+
"highlights-dtd.scm"?: undefined;
|
|
88
|
+
"highlights-jsx.scm"?: undefined;
|
|
89
|
+
"highlights-params.scm"?: undefined;
|
|
90
|
+
};
|
|
91
|
+
} | {
|
|
92
|
+
repo: string;
|
|
93
|
+
version: string;
|
|
94
|
+
files: string[];
|
|
95
|
+
queries: {
|
|
96
|
+
"highlights.scm": string;
|
|
97
|
+
"tags.scm": string;
|
|
98
|
+
"injections.scm"?: undefined;
|
|
99
|
+
"highlights-inline.scm"?: undefined;
|
|
100
|
+
"injections-inline.scm"?: undefined;
|
|
101
|
+
"highlights-dtd.scm"?: undefined;
|
|
102
|
+
"locals.scm"?: undefined;
|
|
103
|
+
"highlights-jsx.scm"?: undefined;
|
|
104
|
+
"highlights-params.scm"?: undefined;
|
|
105
|
+
};
|
|
106
|
+
} | {
|
|
107
|
+
repo: string;
|
|
108
|
+
version: string;
|
|
109
|
+
files: string[];
|
|
110
|
+
queries: {
|
|
111
|
+
"highlights.scm": string;
|
|
112
|
+
"highlights-jsx.scm": string;
|
|
113
|
+
"highlights-params.scm": string;
|
|
114
|
+
"injections.scm": string;
|
|
115
|
+
"locals.scm": string;
|
|
116
|
+
"tags.scm": string;
|
|
117
|
+
"highlights-inline.scm"?: undefined;
|
|
118
|
+
"injections-inline.scm"?: undefined;
|
|
119
|
+
"highlights-dtd.scm"?: undefined;
|
|
120
|
+
};
|
|
121
|
+
} | {
|
|
122
|
+
repo: string;
|
|
123
|
+
files: string[];
|
|
124
|
+
queries: {
|
|
125
|
+
"highlights.scm": string;
|
|
126
|
+
"injections.scm"?: undefined;
|
|
127
|
+
"highlights-inline.scm"?: undefined;
|
|
128
|
+
"injections-inline.scm"?: undefined;
|
|
129
|
+
"highlights-dtd.scm"?: undefined;
|
|
130
|
+
"tags.scm"?: undefined;
|
|
131
|
+
"locals.scm"?: undefined;
|
|
132
|
+
"highlights-jsx.scm"?: undefined;
|
|
133
|
+
"highlights-params.scm"?: undefined;
|
|
134
|
+
};
|
|
135
|
+
version?: undefined;
|
|
136
|
+
})[];
|
|
137
|
+
export default _default;
|
|
138
|
+
//# sourceMappingURL=wasm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wasm.d.ts","sourceRoot":"","sources":["../src/wasm.js"],"names":[],"mappings":""}
|
package/esm/wasm.js
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
export default [
|
|
2
|
+
{
|
|
3
|
+
"repo": "tree-sitter-grammars/tree-sitter-markdown",
|
|
4
|
+
"version": "latest",
|
|
5
|
+
"files": ["tree-sitter-markdown.wasm", "tree-sitter-markdown_inline.wasm"],
|
|
6
|
+
"queries": {
|
|
7
|
+
"highlights.scm": "split_parser/tree-sitter-markdown/queries/highlights.scm",
|
|
8
|
+
"injections.scm": "split_parser/tree-sitter-markdown/queries/injections.scm",
|
|
9
|
+
"highlights-inline.scm": "split_parser/tree-sitter-markdown-inline/queries/highlights.scm",
|
|
10
|
+
"injections-inline.scm": "split_parser/tree-sitter-markdown-inline/queries/injections.scm"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"repo": "tree-sitter-grammars/tree-sitter-diff",
|
|
15
|
+
"version": "latest",
|
|
16
|
+
"files": ["tree-sitter-diff.wasm"],
|
|
17
|
+
"queries": {
|
|
18
|
+
"highlights.scm": "main/queries/highlights.scm"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"repo": "tree-sitter-grammars/tree-sitter-xml",
|
|
23
|
+
"version": "latest",
|
|
24
|
+
"files": ["tree-sitter-xml.wasm", "tree-sitter-dtd.wasm"],
|
|
25
|
+
"queries": {
|
|
26
|
+
"highlights.scm": "master/queries/xml/highlights.scm",
|
|
27
|
+
"highlights-dtd.scm": "master/queries/dtd/highlights.scm"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"repo": "tree-sitter/tree-sitter-html",
|
|
32
|
+
"version": "latest",
|
|
33
|
+
"files": ["tree-sitter-html.wasm"],
|
|
34
|
+
"queries": {
|
|
35
|
+
"highlights.scm": "master/queries/highlights.scm",
|
|
36
|
+
"injections.scm": "master/queries/injections.scm"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"repo": "tree-sitter/tree-sitter-css",
|
|
41
|
+
"version": "latest",
|
|
42
|
+
"files": ["tree-sitter-css.wasm"],
|
|
43
|
+
"queries": {
|
|
44
|
+
"highlights.scm": "master/queries/highlights.scm"
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"repo": "tree-sitter-grammars/tree-sitter-toml",
|
|
49
|
+
"version": "latest",
|
|
50
|
+
"files": ["tree-sitter-toml.wasm"],
|
|
51
|
+
"queries": {
|
|
52
|
+
"highlights.scm": "master/queries/highlights.scm"
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"repo": "tree-sitter/tree-sitter-json",
|
|
57
|
+
"version": "latest",
|
|
58
|
+
"files": ["tree-sitter-json.wasm"],
|
|
59
|
+
"queries": {
|
|
60
|
+
"highlights.scm": "master/queries/highlights.scm"
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"repo": "tree-sitter/tree-sitter-regex",
|
|
65
|
+
"version": "latest",
|
|
66
|
+
"files": ["tree-sitter-regex.wasm"],
|
|
67
|
+
"queries": {
|
|
68
|
+
"highlights.scm": "master/queries/highlights.scm"
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"repo": "tree-sitter/tree-sitter-rust",
|
|
73
|
+
"version": "latest",
|
|
74
|
+
"files": ["tree-sitter-rust.wasm"],
|
|
75
|
+
"queries": {
|
|
76
|
+
"highlights.scm": "master/queries/highlights.scm",
|
|
77
|
+
"injections.scm": "master/queries/injections.scm",
|
|
78
|
+
"tags.scm": "master/queries/tags.scm"
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"repo": "tree-sitter/tree-sitter-typescript",
|
|
83
|
+
"version": "latest",
|
|
84
|
+
"files": ["tree-sitter-typescript.wasm", "tree-sitter-tsx.wasm"],
|
|
85
|
+
"queries": {
|
|
86
|
+
"highlights.scm": "master/queries/highlights.scm",
|
|
87
|
+
"locals.scm": "master/queries/locals.scm",
|
|
88
|
+
"tags.scm": "master/queries/tags.scm"
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"repo": "tree-sitter/tree-sitter-java",
|
|
93
|
+
"version": "latest",
|
|
94
|
+
"files": ["tree-sitter-java.wasm"],
|
|
95
|
+
"queries": {
|
|
96
|
+
"highlights.scm": "master/queries/highlights.scm",
|
|
97
|
+
"tags.scm": "master/queries/tags.scm"
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"repo": "tree-sitter/tree-sitter-javascript",
|
|
102
|
+
"version": "latest",
|
|
103
|
+
"files": ["tree-sitter-javascript.wasm"],
|
|
104
|
+
"queries": {
|
|
105
|
+
"highlights.scm": "master/queries/highlights.scm",
|
|
106
|
+
"highlights-jsx.scm": "master/queries/highlights-jsx.scm",
|
|
107
|
+
"highlights-params.scm": "master/queries/highlights-params.scm",
|
|
108
|
+
"injections.scm": "master/queries/injections.scm",
|
|
109
|
+
"locals.scm": "master/queries/locals.scm",
|
|
110
|
+
"tags.scm": "master/queries/tags.scm"
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"repo": "tree-sitter-grammars/tree-sitter-yaml",
|
|
115
|
+
"files": ["tree-sitter-yaml.wasm"],
|
|
116
|
+
"queries": {
|
|
117
|
+
"highlights.scm": "master/queries/highlights.scm"
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
];
|
|
121
|
+
//# sourceMappingURL=wasm.js.map
|
package/esm/wasm.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wasm.js","sourceRoot":"","sources":["../src/wasm.js"],"names":[],"mappings":"AAAA,eAAe;IACb;QACE,MAAM,EAAE,2CAA2C;QACnD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/wasm",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.29",
|
|
4
4
|
"description": "Mirror of https://github.com/tree-sitter-grammars and other wasm files",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"module": "./esm/mod.js",
|
|
@@ -17,7 +17,9 @@
|
|
|
17
17
|
},
|
|
18
18
|
"scripts": {},
|
|
19
19
|
"files": [
|
|
20
|
-
"
|
|
20
|
+
"esm",
|
|
21
|
+
"src",
|
|
22
|
+
"assets"
|
|
21
23
|
],
|
|
22
24
|
"devDependencies": {
|
|
23
25
|
"@types/node": "^20.9.0"
|
package/src/deno.ts
ADDED
package/src/mod.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import manifest from './wasm.js';
|
|
2
|
+
|
|
3
|
+
export function getLangsList(): string[] {
|
|
4
|
+
return manifest
|
|
5
|
+
.map(
|
|
6
|
+
(item) => item.repo.split('-').pop(),
|
|
7
|
+
)
|
|
8
|
+
.filter((item) => 'string' === typeof item);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function getLangTreeSitter(
|
|
12
|
+
lang: string,
|
|
13
|
+
cdnUrl = 'http://localhost:8000/wasm/',
|
|
14
|
+
) {
|
|
15
|
+
const langManifest = manifest.find((item) => item.repo.endsWith('-' + lang));
|
|
16
|
+
if (!langManifest) {
|
|
17
|
+
throw new Error('No grammar for: ' + lang);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (!cdnUrl.endsWith('/')) {
|
|
21
|
+
cdnUrl += '/';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const dir = langManifest.repo.split('/')[1];
|
|
25
|
+
cdnUrl += dir + '/';
|
|
26
|
+
|
|
27
|
+
const queries = Object.entries(langManifest.queries)
|
|
28
|
+
.map((entry) => [entry[0], cdnUrl + entry[0]]);
|
|
29
|
+
|
|
30
|
+
return {
|
|
31
|
+
lang,
|
|
32
|
+
repo: langManifest.repo,
|
|
33
|
+
files: langManifest.files.map((file) => cdnUrl + file),
|
|
34
|
+
queries: Object.fromEntries(queries),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export async function fetchWasm(wasmUrl: string): Promise<Uint8Array> {
|
|
39
|
+
const response = await fetch(wasmUrl);
|
|
40
|
+
if (response.status >= 400) {
|
|
41
|
+
throw new Error(`Error fetching ${response.status}`);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return new Uint8Array(await response.arrayBuffer());
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export async function fetchTextResource(url: string): Promise<string> {
|
|
48
|
+
const responseScm = await fetch(url);
|
|
49
|
+
if (responseScm.status >= 400) {
|
|
50
|
+
throw new Error(`Error fetching ${responseScm.status}`);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return await responseScm.text();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export { manifest };
|
package/src/wasm.js
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
export default [
|
|
2
|
+
{
|
|
3
|
+
"repo": "tree-sitter-grammars/tree-sitter-markdown",
|
|
4
|
+
"version": "latest",
|
|
5
|
+
"files": ["tree-sitter-markdown.wasm", "tree-sitter-markdown_inline.wasm"],
|
|
6
|
+
"queries": {
|
|
7
|
+
"highlights.scm": "split_parser/tree-sitter-markdown/queries/highlights.scm",
|
|
8
|
+
"injections.scm": "split_parser/tree-sitter-markdown/queries/injections.scm",
|
|
9
|
+
"highlights-inline.scm": "split_parser/tree-sitter-markdown-inline/queries/highlights.scm",
|
|
10
|
+
"injections-inline.scm": "split_parser/tree-sitter-markdown-inline/queries/injections.scm"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"repo": "tree-sitter-grammars/tree-sitter-diff",
|
|
15
|
+
"version": "latest",
|
|
16
|
+
"files": ["tree-sitter-diff.wasm"],
|
|
17
|
+
"queries": {
|
|
18
|
+
"highlights.scm": "main/queries/highlights.scm"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"repo": "tree-sitter-grammars/tree-sitter-xml",
|
|
23
|
+
"version": "latest",
|
|
24
|
+
"files": ["tree-sitter-xml.wasm", "tree-sitter-dtd.wasm"],
|
|
25
|
+
"queries": {
|
|
26
|
+
"highlights.scm": "master/queries/xml/highlights.scm",
|
|
27
|
+
"highlights-dtd.scm": "master/queries/dtd/highlights.scm"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"repo": "tree-sitter/tree-sitter-html",
|
|
32
|
+
"version": "latest",
|
|
33
|
+
"files": ["tree-sitter-html.wasm"],
|
|
34
|
+
"queries": {
|
|
35
|
+
"highlights.scm": "master/queries/highlights.scm",
|
|
36
|
+
"injections.scm": "master/queries/injections.scm"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"repo": "tree-sitter/tree-sitter-css",
|
|
41
|
+
"version": "latest",
|
|
42
|
+
"files": ["tree-sitter-css.wasm"],
|
|
43
|
+
"queries": {
|
|
44
|
+
"highlights.scm": "master/queries/highlights.scm"
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"repo": "tree-sitter-grammars/tree-sitter-toml",
|
|
49
|
+
"version": "latest",
|
|
50
|
+
"files": ["tree-sitter-toml.wasm"],
|
|
51
|
+
"queries": {
|
|
52
|
+
"highlights.scm": "master/queries/highlights.scm"
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"repo": "tree-sitter/tree-sitter-json",
|
|
57
|
+
"version": "latest",
|
|
58
|
+
"files": ["tree-sitter-json.wasm"],
|
|
59
|
+
"queries": {
|
|
60
|
+
"highlights.scm": "master/queries/highlights.scm"
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"repo": "tree-sitter/tree-sitter-regex",
|
|
65
|
+
"version": "latest",
|
|
66
|
+
"files": ["tree-sitter-regex.wasm"],
|
|
67
|
+
"queries": {
|
|
68
|
+
"highlights.scm": "master/queries/highlights.scm"
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"repo": "tree-sitter/tree-sitter-rust",
|
|
73
|
+
"version": "latest",
|
|
74
|
+
"files": ["tree-sitter-rust.wasm"],
|
|
75
|
+
"queries": {
|
|
76
|
+
"highlights.scm": "master/queries/highlights.scm",
|
|
77
|
+
"injections.scm": "master/queries/injections.scm",
|
|
78
|
+
"tags.scm": "master/queries/tags.scm"
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"repo": "tree-sitter/tree-sitter-typescript",
|
|
83
|
+
"version": "latest",
|
|
84
|
+
"files": ["tree-sitter-typescript.wasm", "tree-sitter-tsx.wasm"],
|
|
85
|
+
"queries": {
|
|
86
|
+
"highlights.scm": "master/queries/highlights.scm",
|
|
87
|
+
"locals.scm": "master/queries/locals.scm",
|
|
88
|
+
"tags.scm": "master/queries/tags.scm"
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"repo": "tree-sitter/tree-sitter-java",
|
|
93
|
+
"version": "latest",
|
|
94
|
+
"files": ["tree-sitter-java.wasm"],
|
|
95
|
+
"queries": {
|
|
96
|
+
"highlights.scm": "master/queries/highlights.scm",
|
|
97
|
+
"tags.scm": "master/queries/tags.scm"
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"repo": "tree-sitter/tree-sitter-javascript",
|
|
102
|
+
"version": "latest",
|
|
103
|
+
"files": ["tree-sitter-javascript.wasm"],
|
|
104
|
+
"queries": {
|
|
105
|
+
"highlights.scm": "master/queries/highlights.scm",
|
|
106
|
+
"highlights-jsx.scm": "master/queries/highlights-jsx.scm",
|
|
107
|
+
"highlights-params.scm": "master/queries/highlights-params.scm",
|
|
108
|
+
"injections.scm": "master/queries/injections.scm",
|
|
109
|
+
"locals.scm": "master/queries/locals.scm",
|
|
110
|
+
"tags.scm": "master/queries/tags.scm"
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"repo": "tree-sitter-grammars/tree-sitter-yaml",
|
|
115
|
+
"files": ["tree-sitter-yaml.wasm"],
|
|
116
|
+
"queries": {
|
|
117
|
+
"highlights.scm": "master/queries/highlights.scm"
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
];
|