@mlc-ai/web-xgrammar 0.1.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/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # web-xgrammar
2
+
3
+ This folder contains the source code and emcc bindings for compiling XGrammar to Javascript/Typescript via [emscripten](https://emscripten.org/).
4
+
5
+ ### Build from source
6
+ 1. Install [emscripten](https://emscripten.org). It is an LLVM-based compiler that compiles C/C++ source code to WebAssembly.
7
+ - Follow the [installation instruction](https://emscripten.org/docs/getting_started/downloads.html#installation-instructions-using-the-emsdk-recommended) to install the latest emsdk.
8
+ - Source `emsdk_env.sh` by `source /path/to/emsdk_env.sh`, so that `emcc` is reachable from PATH and the command `emcc` works.
9
+ - We can verify the successful installation by trying out `emcc` in the terminal.
10
+
11
+ 2. Modify the content of `cmake/config.cmake` to be `web/config.cmake`.
12
+
13
+ 3. Run the following
14
+
15
+ ```bash
16
+ source /path/to/emsdk_env.sh
17
+ npm install
18
+ npm run build
19
+ ```
20
+
21
+ ### Example
22
+ To try out the test webpage, run the following
23
+ ```bash
24
+ cd example
25
+ npm install
26
+ npm start
27
+ ```
28
+
29
+ ### Testing
30
+ For testing in `node` environment, run:
31
+ ```bash
32
+ npm test
33
+ ```
package/lib/index.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ import { Grammar, GrammarCompiler, CompiledGrammar, GrammarMatcher, TokenizerInfo, Testings } from "./xgrammar";
2
+ export { Grammar, GrammarCompiler, CompiledGrammar, GrammarMatcher, TokenizerInfo, Testings };
3
+ declare const _default: {
4
+ Grammar: typeof Grammar;
5
+ GrammarCompiler: typeof GrammarCompiler;
6
+ CompiledGrammar: typeof CompiledGrammar;
7
+ GrammarMatcher: typeof GrammarMatcher;
8
+ TokenizerInfo: typeof TokenizerInfo;
9
+ Testings: typeof Testings;
10
+ };
11
+ export default _default;
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,cAAc,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAE/G,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,cAAc,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAA;;;;;;;;;AAC7F,wBAAqG"}