Skip to content
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

Update and use forked golem repos #1

Merged
merged 9 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ Options:
Commands:
componentize [options] <js-source> Create a component from a JavaScript module
transpile [options] <component-path> Transpile a WebAssembly Component to JS + core Wasm for JavaScript execution
types [options] <wit-path> Generate types for the given WIT
run [options] <command> [args...] Run a WASI Command component
serve [options] <command> [args...] Serve a WASI HTTP component
serve [options] <server> [args...] Serve a WASI HTTP component
opt [options] <component-file> optimizes a Wasm component, including running wasm-opt Binaryen optimizations
wit [options] <component-path> extract the WIT from a WebAssembly Component [wasm-tools component wit]
print [options] <input> print the WebAssembly WAT text for a binary file [wasm-tools print]
Expand Down
17 changes: 4 additions & 13 deletions crates/js-component-bindgen/src/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -560,19 +560,10 @@ pub fn render_intrinsics(
utf8EncodedLen = 0;
return 1;
}
let allocLen = 0;
let ptr = 0;
let writtenTotal = 0;
while (s.length > 0) {
ptr = realloc(ptr, allocLen, 1, allocLen += s.length * 2);
const { read, written } = utf8Encoder.encodeInto(
s,
new Uint8Array(memory.buffer, ptr + writtenTotal, allocLen - writtenTotal),
);
writtenTotal += written;
s = s.slice(read);
}
utf8EncodedLen = writtenTotal;
let buf = utf8Encoder.encode(s);
let ptr = realloc(0, 0, 1, buf.length);
new Uint8Array(memory.buffer).set(buf, ptr);
utf8EncodedLen = buf.length;
return ptr;
}
"),
Expand Down
8 changes: 4 additions & 4 deletions crates/js-component-bindgen/src/transpile_bindgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,10 @@ impl<'a> JsBindgen<'a> {
uwrite!(
output,
"\
{}
{}
export async function instantiate(getCoreModule, imports, instantiateCore = WebAssembly.instantiate) {{
{}
{}
{}
",
&js_intrinsics as &str,
&intrinsic_definitions as &str,
Expand All @@ -276,10 +276,10 @@ impl<'a> JsBindgen<'a> {
uwrite!(
output,
"\
{}
{}
export function instantiate(getCoreModule, imports, instantiateCore = (module, importObject) => new WebAssembly.Instance(module, importObject)) {{
{}
{}
{}
",
&js_intrinsics as &str,
&intrinsic_definitions as &str,
Expand Down
92 changes: 51 additions & 41 deletions package-lock.json

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

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bytecodealliance/jco",
"version": "1.2.4",
"name": "@golemcloud/jco",
"version": "1.2.4-golem.3",
"description": "JavaScript tooling for working with WebAssembly Components",
"author": "Guy Bedford",
"bin": {
Expand All @@ -27,7 +27,7 @@
"terser": "^5"
},
"devDependencies": {
"@bytecodealliance/componentize-js": "^0.8.3",
"@golemcloud/componentize-js": "0.8.3-golem.2",
"@types/node": "^18.11.17",
"@typescript-eslint/eslint-plugin": "^5.41.0",
"@typescript-eslint/parser": "^5.41.0",
Expand Down
6 changes: 3 additions & 3 deletions src/cmd/componentize.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import c from 'chalk-template';
export async function componentize (jsSource, opts) {
let componentizeFn;
try {
({ componentize: componentizeFn } = await eval('import("@bytecodealliance/componentize-js")'));
({ componentize: componentizeFn } = await eval('import("@golemcloud/componentize-js")'));
} catch (e) {
if (e?.code === 'ERR_MODULE_NOT_FOUND' && e?.message?.includes('\'@bytecodealliance/componentize-js\''))
throw new Error(`componentize-js must first be installed separately via "npm install @bytecodealliance/componentize-js".`);
if (e?.code === 'ERR_MODULE_NOT_FOUND' && e?.message?.includes('\'@golemcloud/componentize-js\''))
throw new Error(`componentize-js must first be installed separately via "npm install @golemcloud/componentize-js".`);
throw e;
}
const source = await readFile(jsSource, 'utf8');
Expand Down
2 changes: 1 addition & 1 deletion test/codegen.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { readFile } from 'node:fs/promises';
import { readdirSync } from 'node:fs';
import { exec, jcoPath } from './helpers.js';
import { strictEqual } from 'node:assert';
import { componentNew, componentEmbed, transpile } from '@bytecodealliance/jco';
import { componentNew, componentEmbed, transpile } from '@golemcloud/jco';
import { ok } from 'node:assert';

const eslintPath = `node_modules/eslint/bin/eslint.js`;
Expand Down
4 changes: 2 additions & 2 deletions xtask/src/build/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ pub(crate) fn run(release: bool) -> anyhow::Result<()> {
cmd!(sh, "node node_modules/typescript/bin/tsc -p tsconfig.json").read()?;
sh.copy_file(
"lib/wasi_snapshot_preview1.command.wasm",
"node_modules/@bytecodealliance/jco/lib",
"node_modules/@golemcloud/jco/lib",
)?;
sh.copy_file(
"lib/wasi_snapshot_preview1.reactor.wasm",
"node_modules/@bytecodealliance/jco/lib",
"node_modules/@golemcloud/jco/lib",
)?;
Ok(())
}
Loading