From 0516c94d223bf671ced8875d87ff94bb66967e67 Mon Sep 17 00:00:00 2001 From: Matt Panzer Date: Mon, 4 Aug 2025 12:30:15 -0400 Subject: [PATCH 1/5] Adds README for developers and rm wasm-pack from npm deps --- typescript/README.md | 91 +++++++++++++++++++++++++++++++++++++++++ typescript/package.json | 5 +-- 2 files changed, 93 insertions(+), 3 deletions(-) create mode 100644 typescript/README.md diff --git a/typescript/README.md b/typescript/README.md new file mode 100644 index 0000000..cb6d235 --- /dev/null +++ b/typescript/README.md @@ -0,0 +1,91 @@ +# @cooklang/cooklang-ts + +A TypeScript/JavaScript library for parsing CookLang recipes, built with Rust and WebAssembly. + +## 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. + +If you have Rust installed via a package manager, consider uninstalling it first: +```bash +# macOS (Homebrew) +brew uninstall rust + +# Ubuntu/Debian +sudo apt remove rustc + +# Arch Linux +sudo pacman -R rust +``` + +Install Rust using rustup. Platform specific instructions at [rustup.rs](https://rustup.rs/). + +After installation, reload your shell environment: +```bash +# Unix-like systems (macOS, Linux) +source ~/.cargo/env + +# Windows (restart your terminal or run) +# The installer usually handles PATH automatically +``` + +#### 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/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 From 961a2aee259b405b92e1d83155bbdf6d5935bad1 Mon Sep 17 00:00:00 2001 From: Matt Panzer Date: Mon, 4 Aug 2025 12:30:35 -0400 Subject: [PATCH 2/5] Export all available types from the TS package --- typescript/index.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/typescript/index.ts b/typescript/index.ts index affb57a..cfb52bf 100644 --- a/typescript/index.ts +++ b/typescript/index.ts @@ -1,4 +1 @@ -import { version, Parser } from "./pkg/cooklang_wasm"; - -export { version, Parser }; -export type { ScaledRecipeWithReport } from "./pkg/cooklang_wasm"; +export * from "./pkg/cooklang_wasm"; From 0376741d7cfe72adf92e3877faa2c67d1195f0ad Mon Sep 17 00:00:00 2001 From: Matt Panzer Date: Wed, 6 Aug 2025 08:18:30 -0400 Subject: [PATCH 3/5] Add in-development note --- typescript/README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/typescript/README.md b/typescript/README.md index cb6d235..939853b 100644 --- a/typescript/README.md +++ b/typescript/README.md @@ -2,6 +2,9 @@ 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. + ## Prerequisites This project uses Rust compiled to WebAssembly, so you'll need to set up the Rust toolchain properly before development. From e93b7c781212b371a22423fc323ddd6ccec4f886 Mon Sep 17 00:00:00 2001 From: Matt Panzer Date: Sun, 10 Aug 2025 16:32:06 -0400 Subject: [PATCH 4/5] Create CONTRIBUTING.md --- typescript/CONTRIBUTING.md | 66 ++++++++++++++++++++++++++++ typescript/README.md | 89 +------------------------------------- 2 files changed, 68 insertions(+), 87 deletions(-) create mode 100644 typescript/CONTRIBUTING.md 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 index 939853b..d908774 100644 --- a/typescript/README.md +++ b/typescript/README.md @@ -5,90 +5,5 @@ A TypeScript/JavaScript library for parsing CookLang recipes, built with Rust an > [!NOTE] > Package is under development. What exists here may not be published to NPM yet. -## 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. - -If you have Rust installed via a package manager, consider uninstalling it first: -```bash -# macOS (Homebrew) -brew uninstall rust - -# Ubuntu/Debian -sudo apt remove rustc - -# Arch Linux -sudo pacman -R rust -``` - -Install Rust using rustup. Platform specific instructions at [rustup.rs](https://rustup.rs/). - -After installation, reload your shell environment: -```bash -# Unix-like systems (macOS, Linux) -source ~/.cargo/env - -# Windows (restart your terminal or run) -# The installer usually handles PATH automatically -``` - -#### 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 +## Contributing +See `CONTRIBUTING.md` \ No newline at end of file From 91eda8ba87d56668d77083482664c8b23a3b27a5 Mon Sep 17 00:00:00 2001 From: Matt Panzer Date: Sun, 10 Aug 2025 16:32:18 -0400 Subject: [PATCH 5/5] Narrow exports --- typescript/index.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/typescript/index.ts b/typescript/index.ts index cfb52bf..0471810 100644 --- a/typescript/index.ts +++ b/typescript/index.ts @@ -1 +1,10 @@ -export * from "./pkg/cooklang_wasm"; +/* 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"; +