Giter Club home page Giter Club logo

old-docs.wasmer.io's Introduction

Introduction

Welcome to the Wasmer Documentation! 👋

Wasmer is an open-source runtime for executing WebAssembly on the Server.

Wasmer mission is make all software universally available

For an overview of WebAssembly, and what WebAssembly is, take a look here.

{% hint style="info" %} You can find the source code of the docs here: github.com/wasmerio/docs.wasmer.io

Any page can be easily edited, just by clicking on the Edit on Github link at the top right {% endhint %}

Projects

In addition to the Wasmer WebAssembly Runtime, we also participate in other projects such as:

  1. The WAPM (WebAssembly Package Manager)
  2. The WebAssembly Shell

to name but a few...

Social

For the latest articles on Wasmer features and developments, check out our blog or follow us on Twitter!

Tutorials

If you would like to see tutorials, examples, or reference API documentation about a specific Wasmer project, please use the sidebar to the left, or the search bar at the top of this page in the header.

Let's now dig deeper into the Wasmer WebAssembly Runtime, shall we? 🙂

old-docs.wasmer.io's People

Contributors

bobrik avatar brakmic avatar capoferro avatar chenyukang avatar chriswhealy avatar conr2d avatar dependabot[bot] avatar epilys avatar hywan avatar jeff-hykin avatar jubianchi avatar kevingzhang avatar lisiur avatar marcellanz avatar markmccaskey avatar mlodato517 avatar neoncitylights avatar nlewycky avatar o-micron avatar ooesili avatar orkunkl avatar pfandzelter avatar poria-cat avatar ptitseb avatar silwol avatar syrusakbary avatar theneikos avatar thibaultcha avatar torch2424 avatar webmaster128 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

old-docs.wasmer.io's Issues

404 when navigating to project source code

When checking out examples, the link to the GitHub source repo 404s

https://docs.wasmer.io/runtime/rust-integration/docs/runtime-rust-integration-examples-passing-data
https://github.com/wasmerio/docs.wasmer.io/tree/master/docs/runtime/rust-integration/examples/passing_data.rs

GitHub allows linking to specific commits instead of branches. This takes more work when updating the docs, but if related repositories are renamed or files moved, links still remain valid, since static documentation is linked against a fixed set of commits.

More MVP Feedback

From: @syrusakbary

Go: .../go/setup.md malformed go.mod format

The documentation with /integrations/go/setup.md shows a malformed go.mod file:

require (
    require github.com/wasmerio/wasmer-go v1.0.0
)

and should be written as:

require (
    github.com/wasmerio/wasmer-go v1.0.0
)

instead. The require block does not need to have the require keyword repeated on every line within the block as defined in the spec.

The same file also shows a not yet released version tag, but I suppose this will be corrected once v1.0.0 of the Go integration is released.

MVP Feedback TODO

Mark and Nick Feedback

Syrus Feedback

Brandon Feedback

  • Smaller brand font in top left (As in the word documentation is unbolded)
  • Add icons or images to introduction
  • Multiple sections to break up wall of text
  • Home button may be removed (since left nav brand link to same)
  • Provide links like (to introduction.html) this to each section (WasmerJS, etc): https://www.twilio.com/docs

Ivan Feedback

  • Could we add links to previous and next section at the bottom of the pages? That is useful to avoid scrolling to the menu, opening it, scrolling and clicking on the next section.
  • The header takes too much space though, can we shrink it? Moved to #12

Example documentation is not consistent with example programs

Hi,

I was reading the example docs and trying to run the examples, however, they do not seem to be consistent.
For example, the hello world application (https://docs.wasmer.io/integrations/js/wasi/browser/examples/hello-world) is supposed to write Standard Output: Hello World!, however, when I run the example, I see Standard Output: hello world. Taking a look into the hello word source code (https://github.com/wasmerio/docs.wasmer.io/blob/e0f7639306bb4cf18cd0c23876b80f787d6b5876/integrations/shared/wat/wasi/helloworld.wat), it seems like the program only writes the hardcoded "hello world" string but ignores anything passed as an argument.
Also the transforming modules example does not output "Done", but it outputs nothing and the source code (https://github.com/wasmerio/docs.wasmer.io/blob/e0f7639306bb4cf18cd0c23876b80f787d6b5876/integrations/shared/wat/wasi/clocktimeget.wat) also does not include the string "Done".

Can you please make your examples consistent with the documentation.

Additionally, it would help to add in the documentation of the examples that the following needs to be added to the package.json file to make the examples work:

  "browserslist": [
    "last 1 Chrome versions"
  ]

Examples don't operate the same way

This was reported on Spectrum. Our C and Rust passing-data examples don't do the same things:

The Rust one allocates memory on the heap and does not nul-terminate its string, the C one does everything on the stack and nul-terminates its string.

I think ideally the Wasm files should all do the same thing even if that's less idiomatic in the language. So Rust can use CStr, or C can memcpy into a null-terminated array when it wants to deal with strings.

Some error while trying to combine a few examples (Bug in wasmer or user error?)

I have the following defined in Go.

type exitCode struct {
	code int32
}

func (e *exitCode) Error() string {
	return fmt.Sprintf("exit code: %d", e.code)
}

func log(args []wasmer.Value) ([]wasmer.Value, error) {
	for _, a := range args {
		_, err := fmt.Println(a.Unwrap())
		if err != nil {
			return nil, &exitCode{1}
		}
	}

	return nil, nil
}

func registerHostFunctions(store *wasmer.Store, importObject *wasmer.ImportObject) {
	importObject.Register(
		"",
		map[string]wasmer.IntoExtern{
			"log": wasmer.NewFunction(
				store,
				wasmer.NewFunctionType(wasmer.NewValueTypes(), wasmer.NewValueTypes()),
				log,
			),
		},
	)
}

Now when I call this function from Rust in a guest function I get following failure in my Go binary.

$ go run .
failed to create module instance: Missing import: `./calculator_bg.js`.`__wbg_log_b500d075b2228a75`
Wasm exports:
func add(i32,i32) (i32,i32)
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x40ba64d]

goroutine 1 [running]:
main.main()
        /Users/marco/code/philips-internal/wasm-wasi/wasmer-go/main.go:106 +0x6ad
exit status 2

Without calling the log function from my Guest function all works flawlessly.

The code in Go that invokes the guest function looks like this. Error handling left out for the example here.

	engine := wasmer.NewEngine()
	store := wasmer.NewStore(engine)
	module, _ := loadWasm(store, "../calculator/pkg/calculator_bg.wasm")
	importObject := wasmer.NewImportObject()
	registerHostFunctions(store, importObject)
	instance, _ := wasmer.NewInstance(module, importObject)
        f, _ := instance.Exports.GetFunction("multiply")
        result, _ := f(3, 4)

The code in Rust looks as following and is build using wasm-pack.

use wasm_bindgen::prelude::*;

// When the `wee_alloc` feature is enabled, use `wee_alloc` as the global
// allocator.
#[cfg(feature = "wee_alloc")]
#[global_allocator]
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;

#[wasm_bindgen]
extern "C" {
    fn log(s: &str);
}

#[wasm_bindgen]
pub fn add(a: i32, b: i32) -> i32 {
    log("Adding 2 numbers");
    // log(&format!("{}+{}", a, b));
    return a + b;
}

#[wasm_bindgen]
pub fn substract(a: i32, b: i32) -> i32 {
    log("Substracting 2 numbers");
    // log(&*format!("{}-{}", a, b));
    return a - b;
}

#[wasm_bindgen]
pub fn multiply(a: i32, b: i32) -> i32 {
    log("Multiplying 2 numbers");
    // log(&*format!("{}x{}", a, b));
    return a * b;
}

#[wasm_bindgen]
pub fn divide(a: i32, b: i32) -> f32 {
    log("Dividing 2 numbers");
    // log(&*format!("{}/{}", a, b));
    return a as f32 / b as f32;
}

js node hello world error Cannot find module

mac pro M1 follow https://docs.wasmer.io/integrations/js/wasi/server/examples/hello-world

npm install had been installed.

 npm install  @wasmer/wasi 
 node index.js                                    
node:internal/modules/cjs/loader:942
  throw err;
  ^

Error: Cannot find module '@wasmer/wasi/lib/bindings/node'
Require stack:
- /Users/williamlee/wasm/wasmer-js-node-hello-world/index.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:939:15)
    at Module._load (node:internal/modules/cjs/loader:780:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/Users/williamlee/wasm/wasmer-js-node-hello-world/index.js:3:20)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Module._load (node:internal/modules/cjs/loader:827:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/Users/williamlee/wasm/wasmer-js-node-hello-world/index.js' ]
}

Node.js v18.0.0

image

Rust CI broken

Rust CI was broken in 5c49b94, we're no longer testing most of the Rust integrations.

I'm also personally not a fan of the duplication of the new layout as it makes testing and updating slower and more difficult.

Mac specific details missing from wasmer-js documentation

The wasmer-js documentation needs some Mac-specific details added to it

Parcel depends on node-gyp which (on a Mac at least) depends on the Xcode command line tools, which in turn, depend on Xcode being installed

Happy to add these details myself...

wasmer-js Handling Input Output example does not work

First, before I claim there's a bug, are there any undocumented prerequisites needed to get this example working? For instance, should duktape work without first needing to wapm install it?

When running the coding shown here, I get a pop-up prompt as expected and if I enter a numeric value, the prompt reappears. If I then cancel the prompt, the expected value is displayed in both the DOM and the console.

Odd behaviour, but OK...

If I enter any non-numeric value however, the following stack trace appears in the console without any values displayed in either the DOM or the console

index.js:119 RuntimeError: unreachable
    at abort (wasm-function[1250]:0xe7264)
    at duk_err_longjmp (wasm-function[440]:0x3629e)
    at duk_err_create_and_throw (wasm-function[23]:0x159a)
    at duk_err_handle_error_fmt (wasm-function[205]:0x1623d)
    at duk__getvar_helper (wasm-function[700]:0x63b40)
    at duk_js_getvar_activation (wasm-function[1173]:0xdbdc2)
    at duk__js_execute_bytecode_inner (wasm-function[1160]:0xd762b)
    at duk_js_execute_bytecode (wasm-function[1146]:0x9dbcb)
    at duk__handle_call_raw (wasm-function[38]:0x2a5d)
    at duk_handle_call_unprotected (wasm-function[33]:0x1d2e)

@wasmer/wasi: Document Demo Fail

The Demo in : https://docs.wasmer.io/integrations/js/reference-api/wasmer-wasi

const browserBindings = require("@wasmer/wasi/lib/bindings/browser");
// for Node:
// const nodeBindings = require("@wasmer/wasi/lib/bindings/node");

// omit other part

That has am error: Cannot resolve dependency '@wasmer/wasi/lib/bindings/browser

image

After look inside, @wasmer/wasi "@wasmer/wasi": "^0.10.0" has directory lib in npm module, but the latest version does't.

So, the question is, is there the way run wasi in browser?

The first example, "Instance" isn't complete?

Sorry I'm a brand new beginner to WASM so maybe I'm missing something, but the ... main first example of Wasmer seems to be incomplete?

It jumps from "creating an instance" to "running the example" and doesn't seem to actually show the code for invoking add_one?

The code seems to be there, as I'd expect, it's just not documented: https://github.com/wasmerio/wasmer/blob/master/examples/instance.rs

Upon reconsideration, it looks like maybe this is intentional:

I'm not sure this is a good idea. I get the intent to split out "instantiate", "call guest func", etc, but it's very odd that the very first example walks through basically every step except the actual core function call. Enough that I stopped to go look for the source code to see if I was missing something. This confusion was further backed up by the "call guest function" example not returning to the simple instance example to demonstrate the call, but instead introducing an entire new example.

Obviously this is subjective, so feel free to disregard/close/whatever, but hopefully the outside newbie perspective was worth sharing! Cheers, looking forward to learning more, thanks for your work on this.

Fixes needed in js/wasi/hello-world example

I was facing the following issues when using the hello-world example:

  • The index.html is not loading correctly in chrome, because type="module" is not specified in the <script> tag.
  • When instantiating the WASI object no preopens are specified. This is working fine for the hello-world example, but when trying to do any additional File IO errors will occur. I am not sure if I overlooked some obvious documentation for this parameter, but it would've helped me a lot if something like preopens: { '/': '/' } could be included in the example.
  • When running npm run dev the helloworld.wasm cannot be loaded, because it is not copied from the static directory to the dist directory and parcel does not serve it from the static directory
  • It would be great to have a working npm run build target to be able to host the static files.

Small issues in passing-data example

I found some issues in the passing data example:
https://docs.wasmer.io/integrations/c/examples/passing-data

First, the path to the wasm module (example-wasienv-wasm/strings-wasm-is-cool/strings-wasm-is-cool.wasm) seems to a different one than the one pointed to use.

On the premise that the correct one is this: https://github.com/wasmerio/docs.wasmer.io/blob/master/integrations/shared/c/passing-data.c, there are some fixes to be made.

First, when calling the add_wasm_is_cool function, the length of the original string should be passed as an argument. The second one is that the function that returns the pointer to the byte_buffer is called get_wasm_memory_buffer_pointer instead of get_buffer_pointer

Get error when compiling passing-data.c example

Hi,
I got this error when compiling passing-data.c example:

passing-data.c: In function ‘get_length_of_memory’: passing-data.c:132:36: warning: passing argument 1 of ‘wasmer_memory_data_length’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers] 132 | return wasmer_memory_data_length(memory); | ^~~~~~ In file included from passing-data.c:2: /home/osboxes/wasmer-c-api/include/wasmer.h:1174:53: note: expected ‘wasmer_memory_t *’ {aka ‘struct <anonymous> *’} but argument is of type ‘const wasmer_memory_t *’ {aka ‘const struct <anonymous> *’} 1174 | uint32_t wasmer_memory_data_length(wasmer_memory_t *memory);

Could anyone please help? I am using this api:
https://github.com/wasmerio/wasmer/releases/download/0.16.2/wasmer-c-api-linux-amd64.tar.gz

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.