Skip to content
Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
96c065d
feat: improve docs homepage design
Prachi-Gupta2808 Jun 9, 2026
9798036
Update docs/src/pages/index.jsx
Prachi-Gupta2808 Jun 9, 2026
c0227fb
Address review feedback
Prachi-Gupta2808 Jun 9, 2026
7a0bb18
fix: add Node.js support via worker_threads
Prachi-Gupta2808 Jun 11, 2026
487092e
Merge branch 'dev' into fix/node-js-support
Ryan-Millard Jun 11, 2026
1033f47
feat(console-js): add Node.js example app with sharp image loading
Prachi-Gupta2808 Jun 13, 2026
42cbf20
Merge branch 'fix/node-js-support' of https://github.com/Prachi-Gupta…
Prachi-Gupta2808 Jun 13, 2026
c84b8d1
Merge branch 'dev' into fix/node-js-support
Prachi-Gupta2808 Jun 13, 2026
ec6e076
fix(wasmClient): use worker_threads event emitter style for Node.js
Prachi-Gupta2808 Jun 13, 2026
099e92c
resolve node build panic
Krasner Jun 13, 2026
e9933b0
webgpu support fix for node.js
Krasner Jun 14, 2026
ca3d7a5
fix
Krasner Jun 14, 2026
8165522
chore: revert unrelated files to same state as on dev branch
Ryan-Millard Jun 14, 2026
93576f2
fix(packages/js): move webgpu to be a true dependency
Ryan-Millard Jun 14, 2026
2da714c
fix(packages/js): revert webgpu to optional peerDependency
Prachi-Gupta2808 Jun 14, 2026
d4e284f
Merge branch 'dev' into fix/node-js-support
Ryan-Millard Jun 16, 2026
54ccf79
refactor(packages/js): build using Vite for browser and Node
Ryan-Millard Jun 17, 2026
4ceed9c
temp
Ryan-Millard Jun 18, 2026
b406a34
bring up-to date with dev
Krasner Jun 20, 2026
8330c5f
fix build process
Krasner Jun 21, 2026
1333dc9
remove images from example apps
Krasner Jun 21, 2026
7292e50
update lockfile
Krasner Jun 21, 2026
0e6bf05
formatting
Krasner Jun 21, 2026
85b5e25
update ci build
Krasner Jun 21, 2026
0f3ed46
update Justfile
Krasner Jun 21, 2026
16ee02b
update docusaurus config
Krasner Jun 21, 2026
4a74983
fix gpu deallocation
Krasner Jun 21, 2026
c1fb14d
install all pnpm packages
Krasner Jun 21, 2026
469d272
chore(packages/js): remove unused import
Ryan-Millard Jun 21, 2026
1e1e4d7
chore(packages/js): format files
Ryan-Millard Jun 21, 2026
803ab7a
Merge branch 'dev' into dev/node-js
Ryan-Millard Jun 21, 2026
4ec4588
ci(.github/workflows/build-react-app.yml): build js package for brows…
Ryan-Millard Jun 21, 2026
e77f478
chore: apply coderabbit's suggestions and cleanup
Ryan-Millard Jun 21, 2026
de36169
Merge branch 'dev/node-js' of https://github.com/Krasner/Img2Num into…
Ryan-Millard Jun 21, 2026
5f0e62e
add newline
Krasner Jun 22, 2026
5a64c1a
remove output.svg
Krasner Jun 22, 2026
4ad6e54
Merge branch 'dev' into dev/node-js
Ryan-Millard Jun 26, 2026
9d5fe79
chore(Justfile): add final newline
Ryan-Millard Jun 26, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/build-react-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd

- name: Install Dependendencies
run: pnpm --filter react-example install
run: pnpm install

- name: Download WASM artifacts
if: ${{ inputs.wasm-artifacts-path }}
Expand All @@ -34,6 +34,10 @@ jobs:
name: wasm-build
path: ${{ inputs.wasm-artifacts-path }}

- name: Build img2num module
# Only build for browser since that is all we need here
run: pnpm -F img2num build:browser

- name: Build React app
run: pnpm -F react-example run build

Expand Down
21 changes: 19 additions & 2 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ help:
\t cpp: build c++ core and c bindings \n \
\t js: build js/wasm bindings \n \
\t py: build python bindings and python package \n \
\t packages-js: build browser and node packages using js/wasm bindings \n \
\t all: build all of above \n \
clean <target>: \n \
\t cpp: delete c++ and c build folder (build-c-cpp) \n \
\t js: delete js build folder (build-wasm) \n \
\t packages-js: delete packages/js/dist folder \n \
\t packages-py: delete packages/py/build-py folder \n \
docs <action>: \n \
\t build: build docusaurus server \n \
\t start: start docusaurus server on port 3000 \n \
Expand All @@ -23,11 +26,13 @@ help:
console-cpp <input_image>: run example C++ app on input image \n \
console-c <input_image>: run example C app on input image \n \
console-py <input_image>: run example python app on input image \n \
console-js <input_image>: run example node app on input image \n \
"

init:
@echo "Pulling submodules"
git submodule update --init
pnpm install
just build all

format:
Expand All @@ -49,19 +54,27 @@ build-py:
uv sync --reinstall
uv build --wheel

build-packages-js:
@echo "Build js packages"
just build-wasm
pnpm -F img2num build

build target:
case "{{ target }}" in \
cpp) just build-c-cpp ;; \
js) just build-wasm ;; \
py) just build-py ;; \
all) just build-c-cpp build-wasm build-py react-js build docs build ;; \
packages-js) just build-packages-js ;; \
all) just build-c-cpp build-wasm build-py build-packages-js react-js build docs build ;; \
Comment thread
Ryan-Millard marked this conversation as resolved.
Resolved
esac

clean target:
@echo "Remove {{ target }} folders"
case "{{ target }}" in \
cpp) rm -rf build-c-cpp/ ;; \
js) rm -rf build-wasm/ ;; \
packages-js) rm -rf packages/js/dist/ ;; \
packages-py) rm -rf packages/py/build-py/ ;; \
esac

docs action:
Expand All @@ -71,7 +84,7 @@ docs action:
start) cd docs/ && pnpm run serve ;; \
esac

react-js action: build-wasm
react-js action: build-packages-js
@echo "Run react sample app"
case "{{ action }}" in \
build) pnpm -F react-example run build ;; \
Expand All @@ -90,3 +103,7 @@ console-cpp input:
console-c input:
@echo "./build-c-cpp/example-apps/console-c/console_c_app {{ input }}"
./build-c-cpp/example-apps/console-c/CImg2NumExample_console_c "{{ input }}"

console-js input:
@echo "node example-apps/console-js/index.js {{ input }}"
node example-apps/console-js/index.js "{{ input }}"
2 changes: 1 addition & 1 deletion bindings/js/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ target_include_directories(img2num_wasm PRIVATE
set(COMMON_FLAGS
"SHELL:-sMODULARIZE=1"
"SHELL:-sEXPORT_ES6=1"
"SHELL:-sENVIRONMENT=web,worker"
"SHELL:-sENVIRONMENT=web,worker,node"
"SHELL:-sEXPORTED_FUNCTIONS=['_malloc','_free']"
"SHELL:-sEXPORTED_RUNTIME_METHODS=['ccall','cwrap','getValue','setValue','HEAPU8','HEAP32','UTF8ToString','stringToUTF8','lengthBytesUTF8']"
"SHELL:-sINITIAL_MEMORY=2GB"
Expand Down
3 changes: 1 addition & 2 deletions core/include/internal/gpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,7 @@ class GPU {
);
};

void init_gpu() { // wgpu::Instance& instance, wgpu::Adapter& adapter, wgpu::Device& device,
// wgpu::Queue& queue) {
void init_gpu() {
if (gpu_initialized)
return;

Expand Down
4 changes: 2 additions & 2 deletions docs/plugins/docusaurusPluginTypeDocConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ const config = [
"docusaurus-plugin-typedoc",
{
name: "API",
entryPoints: ["../packages/js/index.js"],
entryPoints: ["../packages/js/src/index.js"],
entryPointStrategy: "expand",
out: "docs/js/api",
json: "static/js/api.json",
readme: "none",
tsconfig: "../packages/js/tsconfig.typedoc.json",
exclude: ["node_modules/", "build-wasm/", ".gitignore", "package.json", "*.test.*"],
exclude: ["node_modules/", "build-wasm/", "dist/", ".gitignore", "package.json", "*.test.*"],
blockTags: ["@param", "@returns", "@throws", "@example", "@async", "@summary", "@property", "@todo", "@variation", "@description", "@module", "@author", "@license", "@exports", "@see", "@since"],
gitRevision: "main",
sourceLinkTemplate: "https://github.com/Ryan-Millard/Img2Num/blob/{gitRevision}/{path}#L{line}",
Expand Down
1 change: 1 addition & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export default defineConfig([

"scripts/img2num-dev-scripts/node_modules",

"packages/js/dist",
"packages/js/build-wasm",
"packages/js/node_modules",

Expand Down
26 changes: 26 additions & 0 deletions example-apps/console-js/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { writeFileSync } from "fs";
import { imageToSvg } from "img2num";
import sharp from "sharp";

const imagePath = process.argv[2];

if (!imagePath) {
console.error("Usage: node index.js <image-path>");
process.exit(1);
}

console.log(`Processing image: ${imagePath}`);

const { data, info } = await sharp(imagePath).ensureAlpha().raw().toBuffer({ resolveWithObject: true });

const pixels = new Uint8ClampedArray(data.buffer);
Comment thread
Ryan-Millard marked this conversation as resolved.
Resolved
const { width, height } = info;

console.log(`Image size: ${width}x${height}`);
console.log("Running img2num in Node.js...");

const { svg } = await imageToSvg({ pixels, width, height });

writeFileSync("output.svg", svg);
console.log("Done! SVG saved to output.svg");
process.exit();
12 changes: 12 additions & 0 deletions example-apps/console-js/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "console-js",
"version": "1.0.0",
"type": "module",
"scripts": {
"start": "node index.js"
},
"dependencies": {
"img2num": "workspace:*",
"sharp": "^0.33.0"
}
}
10 changes: 10 additions & 0 deletions example-apps/react-js/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,14 @@ export default defineConfig({
generateContributorCreditsPlugin(),
svgr(),
],
worker: {
format: "es", // Keeps your top-level awaits working
},
build: {
target: "esnext",
rollupOptions: {
// Tells the bundler to ignore these when building for the web browser
external: ["webgpu", "worker_threads", "url", "path", "fs"],
},
},
});
Loading
Loading