diff --git a/typescript/CONTRIBUTING.md b/typescript/CONTRIBUTING.md new file mode 100644 index 0000000..0baf0af --- /dev/null +++ b/typescript/CONTRIBUTING.md @@ -0,0 +1,66 @@ +## Prerequisites + +This project uses Rust compiled to WebAssembly, so you'll need to set up the Rust toolchain properly before development. + +### Required Tools + +1. **Rust via rustup** (recommended over system package managers) +2. **wasm-pack** +3. **Node.js** + +### Setup Instructions + +#### 1. Install Rust (via rustup) + +**Important:** Use rustup rather than system package managers (Homebrew on macOS, apt on Ubuntu, etc.) for better toolchain management. + +Install Rust using rustup. Platform specific instructions at [rustup.rs](https://rustup.rs/). + +#### 2. Add WebAssembly Target + +```bash +rustup target add wasm32-unknown-unknown +``` + +#### 3. Install wasm-pack + +```bash +cargo install wasm-pack +``` + +#### 4. Verify Installation + +```bash +# Check Rust +rustc --version +rustup target list --installed | grep wasm32 + +# Check wasm-pack +wasm-pack --version + +# Verify WASM target is available +rustc --print target-list | grep wasm32-unknown-unknown +``` + +## Development + +### Install Dependencies + +From the project root: +```bash +npm install +``` + +### Playground Development + +From the project root: +```bash +npm run playground +``` + +### Project Structure + +- `src/` - Rust source code (extensions to cooklang-rs) +- `pkg/` - Generated WebAssembly files (created by wasm-pack) +- `index.ts` - TypeScript entry point +- `Cargo.toml` - Rust dependencies and configuration diff --git a/typescript/README.md b/typescript/README.md new file mode 100644 index 0000000..d908774 --- /dev/null +++ b/typescript/README.md @@ -0,0 +1,9 @@ +# @cooklang/cooklang-ts + +A TypeScript/JavaScript library for parsing CookLang recipes, built with Rust and WebAssembly. + +> [!NOTE] +> Package is under development. What exists here may not be published to NPM yet. + +## Contributing +See `CONTRIBUTING.md` \ No newline at end of file diff --git a/typescript/index.ts b/typescript/index.ts index affb57a..0471810 100644 --- a/typescript/index.ts +++ b/typescript/index.ts @@ -1,4 +1,10 @@ -import { version, Parser } from "./pkg/cooklang_wasm"; - -export { version, Parser }; +/* High Level Types */ +export { Parser, Recipe, version } from "./pkg/cooklang_wasm"; export type { ScaledRecipeWithReport } from "./pkg/cooklang_wasm"; + +/* Types defined by Cooklang syntax */ +export { Section, Step, Ingredient, Cookware, Timer } from "./pkg/cooklang_wasm"; + +/* Parsed base-types */ +export { Item, Quantity, Value } from "./pkg/cooklang_wasm"; + diff --git a/typescript/package.json b/typescript/package.json index 8219ffb..3671386 100644 --- a/typescript/package.json +++ b/typescript/package.json @@ -27,7 +27,6 @@ }, "devDependencies": { "vite-plugin-wasm": "^3.4.1", - "vitest": "^3.2.3", - "wasm-pack": "^0.13.1" + "vitest": "^3.2.3" } -} +} \ No newline at end of file