-
Notifications
You must be signed in to change notification settings - Fork 16
Typescript README/CONTRIBUTING and export more types #48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
0516c94
961a2ae
0376741
e93b7c7
91eda8b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,6 @@ | |
}, | ||
"devDependencies": { | ||
"vite-plugin-wasm": "^3.4.1", | ||
"vitest": "^3.2.3", | ||
"wasm-pack": "^0.13.1" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The downside of switching to Was there a specific need to do this? I am not opposed to handling this through Rust, but we should identify the reasoning which prompted the change. It will improve our ability to solve that specific requirement. Also, I would expect that the tests fail with this change, but they aren't. Presuming that is because we haven't also updated the lockfile. Seems that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did this because when I had
I'm on macOS 15.5, node v22.17.1, npm 10.9.2. Installing
What do you think about using something like
I think I see what you're saying. I'll try one commit with an updated lockfile without the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, have you installed rosetta? Is this a new computer? Using this is slightly better... cargo install wasm-pack --version 0.13.1 But it still means that every user needs to explicitly upgrade when we tell them to upgrade. Also isn't great if they use it in other projects. I wonder if we can manage it through the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we create an issue to follow up on this specifically. It should work with this setup, but also I am personally fine with shifting it elsewhere if we can maintain a consistent version still. Seems like we need more digging though and I don't want to block the PR on this. |
||
"vitest": "^3.2.3" | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One should be able to access these from the top level
ScaledRecipeWithReport
. Is it purely out of convenience?We haven't published yet so there will likely be little breakages until everything is settled. I am more fine with this than the
*
export at least.