Skip to content

Commit

Permalink
wasm
Browse files Browse the repository at this point in the history
  • Loading branch information
oscartbeaumont committed Aug 25, 2024
1 parent ba3418c commit 1700f71
Show file tree
Hide file tree
Showing 12 changed files with 144 additions and 63 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ gitignore
Thumbs.db

tsconfig.tsbuildinfo
app.config.*.js
39 changes: 24 additions & 15 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion apps/desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"tailwindcss": "^3.4.3",
"unplugin-auto-import": "^0.17.5",
"unplugin-icons": "^0.18.5",
"vite": "^5.4.0"
"vite": "^5.4.0",
"vite-plugin-wasm": "^3.3.0"
}
}
3 changes: 2 additions & 1 deletion apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"postcss": "^8.4.38",
"tailwindcss": "^3.4.3",
"tsx": "^4.7.2",
"unplugin-fonts": "^1.1.1"
"unplugin-fonts": "^1.1.1",
"vite-plugin-wasm": "^3.3.0"
}
}
13 changes: 13 additions & 0 deletions crates/regex-syntax-wasm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "regex-syntax-wasm"
description = "A WebAssembly version of the regex-syntax crate"
version = "0.0.0"
edition = "2021"
publish = false

[lib]
crate-type = ["cdylib"]

[dependencies]
regex-syntax = "0.8.4"
wasm-bindgen = "0.2.93"
17 changes: 17 additions & 0 deletions crates/regex-syntax-wasm/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "@macrograph/regex-syntax-wasm",
"description": "A WebAssembly version of the regex-syntax crate",
"version": "0.0.0",
"files": [
"./pkg/regex_syntax_wasm_bg.wasm",
"./pkg/regex_syntax_wasm.js",
"./pkg/regex_syntax_wasm_bg.js",
"./pkg/regex_syntax_wasm.d.ts"
],
"module": "./pkg/regex_syntax_wasm.js",
"types": "./pkg/regex_syntax_wasm.d.ts",
"sideEffects": ["./pkg/regex_syntax_wasm.js"],
"scripts": {
"build": "wasm-pack build && rm ./pkg/.gitignore"
}
}
6 changes: 6 additions & 0 deletions crates/regex-syntax-wasm/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
use wasm_bindgen::prelude::*;

#[wasm_bindgen]
pub fn greet(name: &str) -> u32 {

Check warning on line 4 in crates/regex-syntax-wasm/src/lib.rs

View workflow job for this annotation

GitHub Actions / Clippy

unused variable: `name`

warning: unused variable: `name` --> crates/regex-syntax-wasm/src/lib.rs:4:14 | 4 | pub fn greet(name: &str) -> u32 { | ^^^^ help: if this is intentional, prefix it with an underscore: `_name` | = note: `#[warn(unused_variables)]` on by default
42
}
1 change: 1 addition & 0 deletions packages/packages/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"@macrograph/typesystem": "workspace:*",
"@macrograph/ui": "workspace:*",
"@macrograph/utils": "workspace:^",
"@macrograph/regex-syntax-wasm": "workspace:^",
"@octokit/auth-callback": "^4.0.0",
"@rspc/client": "0.0.0-main-6ed8cc98",
"@rspc/tauri": "0.0.0-main-6ed8cc98",
Expand Down
3 changes: 3 additions & 0 deletions packages/packages/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
} from "@macrograph/typesystem";
import dayjs from "dayjs";
import duration from "dayjs/plugin/duration";
import { greet } from "@macrograph/regex-syntax-wasm";

dayjs.extend(duration);

Expand Down Expand Up @@ -2503,6 +2504,8 @@ export function pkg(core: Core) {
type: "exec",
properties: { regex: { name: "Regex", type: t.string() } },
createIO({ io, ctx, properties }) {
console.log("HERE", greet("todo"));

const base = {
input: io.dataInput({
id: "",
Expand Down
3 changes: 2 additions & 1 deletion packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"vite": "^5.4.0"
},
"peerDependencies": {
"solid-js": "^1.7.11"
"solid-js": "^1.7.11",
"vite-plugin-wasm": "^3.3.0"
},
"dependencies": {
"@kobalte/core": "^0.13.4",
Expand Down
2 changes: 2 additions & 0 deletions packages/ui/vite.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { fileURLToPath } from "node:url";
import AutoImport from "unplugin-auto-import/vite";
import IconsResolver from "unplugin-icons/resolver";
import Icons from "unplugin-icons/vite";
import wasm from "vite-plugin-wasm";

// Workaround for https://github.com/solidjs/solid-start/issues/1374
const VinxiAutoImport = (options) => {
Expand Down Expand Up @@ -34,4 +35,5 @@ export default [
],
}),
Icons({ compiler: "solid", scale: 1 }),
wasm(),
];
Loading

0 comments on commit 1700f71

Please sign in to comment.