Skip to content

Commit

Permalink
Update docs and README.md to use 3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
kateinoigakukun committed Dec 25, 2023
1 parent 9fed740 commit f63b6d1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Create and save `index.html` page with the following contents:

```html
<html>
<script src="https://cdn.jsdelivr.net/npm/@ruby/3.2[email protected]/dist/browser.script.iife.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@ruby/3.3[email protected]/dist/browser.script.iife.js"></script>
<script type="text/ruby">
require "js"
Expand Down Expand Up @@ -70,6 +70,11 @@ See the `README.md` of each package for more detail and its usage.
</tr>
</thead>
<tbody>
<tr>
<td><a href="/packages/npm-packages/ruby-3.3-wasm-wasi">@ruby/3.3-wasm-wasi</a></td>
<td>CRuby 3.3 built on WASI with JS interop support</td>
<td><a href="https://www.npmjs.com/package/@ruby/3.3-wasm-wasi" rel="nofollow"><img src="https://badge.fury.io/js/@ruby%2F3.3-wasm-wasi.svg" alt="npm version" style="max-width: 100%;"></a></td>
</tr>
<tr>
<td><a href="/packages/npm-packages/ruby-3.2-wasm-wasi">@ruby/3.2-wasm-wasi</a></td>
<td>CRuby 3.2 built on WASI with JS interop support</td>
Expand Down
16 changes: 8 additions & 8 deletions docs/cheat_sheet.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

## Node.js

To install the package, install `@ruby/3.2-wasm-wasi` and `@ruby/wasm-wasi` from npm:
To install the package, install `@ruby/3.3-wasm-wasi` and `@ruby/wasm-wasi` from npm:

```console
npm install --save @ruby/3.2-wasm-wasi @ruby/wasm-wasi
npm install --save @ruby/3.3-wasm-wasi @ruby/wasm-wasi
```

Then instantiate a Ruby VM by the following code:
Expand All @@ -20,7 +20,7 @@ Then instantiate a Ruby VM by the following code:
import fs from "fs/promises";
import { DefaultRubyVM } from "@ruby/wasm-wasi/dist/node";

const binary = await fs.readFile("./node_modules/@ruby/3.2-wasm-wasi/dist/ruby.wasm");
const binary = await fs.readFile("./node_modules/@ruby/3.3-wasm-wasi/dist/ruby.wasm");
const module = await WebAssembly.compile(binary);
const { vm } = await DefaultRubyVM(module);
vm.eval(`puts "hello world"`);
Expand All @@ -38,7 +38,7 @@ The easiest way to run Ruby on browser is to use `browser.script.iife.js` script

```html
<html>
<script src="https://cdn.jsdelivr.net/npm/@ruby/3.2[email protected]/dist/browser.script.iife.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@ruby/3.3[email protected]/dist/browser.script.iife.js"></script>
<script type="text/ruby">
require "js"
JS.global[:document].write "Hello, world!"
Expand All @@ -52,7 +52,7 @@ If you want to control Ruby VM from JavaScript, you can use `@ruby/wasm-wasi` pa
<html>
<script type="module">
import { DefaultRubyVM } from "https://cdn.jsdelivr.net/npm/@ruby/[email protected]/dist/browser/+esm";
const response = await fetch("https://cdn.jsdelivr.net/npm/@ruby/3.2[email protected]/dist/ruby+stdlib.wasm");
const response = await fetch("https://cdn.jsdelivr.net/npm/@ruby/3.3[email protected]/dist/ruby+stdlib.wasm");
const module = await WebAssembly.compileStreaming(response);
const { vm } = await DefaultRubyVM(module);
Expand All @@ -73,7 +73,7 @@ If you want to control Ruby VM from JavaScript, you can use `@ruby/wasm-wasi` pa
<script>
const main = async () => {
const { DefaultRubyVM } = window["ruby-wasm-wasi"];
const response = await fetch("https://cdn.jsdelivr.net/npm/@ruby/3.2[email protected]/dist/ruby+stdlib.wasm");
const response = await fetch("https://cdn.jsdelivr.net/npm/@ruby/3.3[email protected]/dist/ruby+stdlib.wasm");
const module = await WebAssembly.compileStreaming(response);
const { vm } = await DefaultRubyVM(module);
Expand Down Expand Up @@ -128,7 +128,7 @@ end

```html
<html>
<script src="https://cdn.jsdelivr.net/npm/@ruby/3.2[email protected]/dist/browser.script.iife.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@ruby/3.3[email protected]/dist/browser.script.iife.js"></script>
<script type="text/ruby" data-eval="async">
require "js"
Expand All @@ -144,7 +144,7 @@ Or using `@ruby/wasm-wasi` package API `RubyVM#evalAsync`:
<html>
<script type="module">
import { DefaultRubyVM } from "https://cdn.jsdelivr.net/npm/@ruby/[email protected]/dist/browser/+esm";
const response = await fetch("https://cdn.jsdelivr.net/npm/@ruby/3.2[email protected]/dist/ruby+stdlib.wasm");
const response = await fetch("https://cdn.jsdelivr.net/npm/@ruby/3.3[email protected]/dist/ruby+stdlib.wasm");
const module = await WebAssembly.compileStreaming(response);
const { vm } = await DefaultRubyVM(module);
Expand Down

0 comments on commit f63b6d1

Please sign in to comment.