@ruby/wasm-wasi 2.6.2-2024-09-07-a → 2.6.2-2024-09-09-a

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1587,10 +1587,28 @@
1587
1587
  };
1588
1588
  };
1589
1589
 
1590
+ /**
1591
+ * The main entry point of `<script type="text/ruby">`-based scripting with WebAssembly Core Module.
1592
+ */
1590
1593
  const main = async (pkg, options) => {
1591
1594
  const response = fetch(`https://cdn.jsdelivr.net/npm/${pkg.name}@${pkg.version}/dist/ruby+stdlib.wasm`);
1592
1595
  const module = await compileWebAssemblyModule(response);
1593
1596
  const { vm } = await DefaultRubyVM(module, options);
1597
+ await mainWithRubyVM(vm);
1598
+ };
1599
+ /**
1600
+ * The main entry point of `<script type="text/ruby">`-based scripting with WebAssembly Component.
1601
+ */
1602
+ const componentMain = async (pkg, options) => {
1603
+ const componentUrl = `https://cdn.jsdelivr.net/npm/${pkg.name}@${pkg.version}/dist/component`;
1604
+ const fetchComponentFile = (relativePath) => fetch(`${componentUrl}/${relativePath}`);
1605
+ const { vm } = await RubyVM.instantiateComponent(Object.assign(Object.assign({}, options), { getCoreModule: (relativePath) => {
1606
+ const response = fetchComponentFile(relativePath);
1607
+ return compileWebAssemblyModule(response);
1608
+ } }));
1609
+ await mainWithRubyVM(vm);
1610
+ };
1611
+ const mainWithRubyVM = async (vm) => {
1594
1612
  vm.printVersion();
1595
1613
  globalThis.rubyVM = vm;
1596
1614
  // Wait for the text/ruby script tag to be read.
@@ -1672,6 +1690,7 @@
1672
1690
  }
1673
1691
  };
1674
1692
 
1693
+ exports.componentMain = componentMain;
1675
1694
  exports.main = main;
1676
1695
 
1677
1696
  }));
@@ -1,5 +1,19 @@
1
1
  import { DefaultRubyVM } from "./browser.js";
2
+ import { RubyComponentInstantiator } from "./vm.js";
3
+ /**
4
+ * The main entry point of `<script type="text/ruby">`-based scripting with WebAssembly Core Module.
5
+ */
2
6
  export declare const main: (pkg: {
3
7
  name: string;
4
8
  version: string;
5
9
  }, options?: Parameters<typeof DefaultRubyVM>[1]) => Promise<void>;
10
+ /**
11
+ * The main entry point of `<script type="text/ruby">`-based scripting with WebAssembly Component.
12
+ */
13
+ export declare const componentMain: (pkg: {
14
+ name: string;
15
+ version: string;
16
+ }, options: {
17
+ instantiate: RubyComponentInstantiator;
18
+ wasip2: any;
19
+ }) => Promise<void>;
@@ -1,12 +1,33 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.main = void 0;
3
+ exports.componentMain = exports.main = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const browser_js_1 = require("./browser.js");
6
+ const vm_js_1 = require("./vm.js");
7
+ /**
8
+ * The main entry point of `<script type="text/ruby">`-based scripting with WebAssembly Core Module.
9
+ */
6
10
  const main = async (pkg, options) => {
7
11
  const response = fetch(`https://cdn.jsdelivr.net/npm/${pkg.name}@${pkg.version}/dist/ruby+stdlib.wasm`);
8
12
  const module = await compileWebAssemblyModule(response);
9
13
  const { vm } = await (0, browser_js_1.DefaultRubyVM)(module, options);
14
+ await mainWithRubyVM(vm);
15
+ };
16
+ exports.main = main;
17
+ /**
18
+ * The main entry point of `<script type="text/ruby">`-based scripting with WebAssembly Component.
19
+ */
20
+ const componentMain = async (pkg, options) => {
21
+ const componentUrl = `https://cdn.jsdelivr.net/npm/${pkg.name}@${pkg.version}/dist/component`;
22
+ const fetchComponentFile = (relativePath) => fetch(`${componentUrl}/${relativePath}`);
23
+ const { vm } = await vm_js_1.RubyVM.instantiateComponent(Object.assign(Object.assign({}, options), { getCoreModule: (relativePath) => {
24
+ const response = fetchComponentFile(relativePath);
25
+ return compileWebAssemblyModule(response);
26
+ } }));
27
+ await mainWithRubyVM(vm);
28
+ };
29
+ exports.componentMain = componentMain;
30
+ const mainWithRubyVM = async (vm) => {
10
31
  vm.printVersion();
11
32
  globalThis.rubyVM = vm;
12
33
  // Wait for the text/ruby script tag to be read.
@@ -19,7 +40,6 @@ const main = async (pkg, options) => {
19
40
  runRubyScriptsInHtml(vm);
20
41
  }
21
42
  };
22
- exports.main = main;
23
43
  const runRubyScriptsInHtml = async (vm) => {
24
44
  var _a, e_1, _b, _c;
25
45
  const tags = document.querySelectorAll('script[type="text/ruby"]');
package/dist/cjs/vm.d.ts CHANGED
@@ -2,6 +2,12 @@ import type { RubyJsJsRuntime } from "./bindgen/interfaces/ruby-js-js-runtime.js
2
2
  import type { RubyJsRubyRuntime } from "./bindgen/interfaces/ruby-js-ruby-runtime.js";
3
3
  import { JsAbiValue } from "./bindgen/legacy/rb-js-abi-host.js";
4
4
  import { Binding, RbAbiValue } from "./binding.js";
5
+ /**
6
+ * A function type that instantiates a Ruby component
7
+ */
8
+ export type RubyComponentInstantiator = ((getCoreModule: (path: string) => WebAssembly.Module, importObject: any, instantiateCore?: (module: WebAssembly.Module, imports: Record<string, any>) => WebAssembly.Instance | Promise<WebAssembly.Instance>) => Promise<({
9
+ rubyRuntime: typeof RubyJsRubyRuntime;
10
+ })>);
5
11
  export type RubyInitComponentOptions = {
6
12
  /**
7
13
  * A lower-level instantiation function that instantiates the Ruby component with the given component
@@ -18,9 +24,7 @@ export type RubyInitComponentOptions = {
18
24
  /**
19
25
  * An `instantiate` function generated by `@bytecodealliance/jco` that instantiates the Ruby component.
20
26
  */
21
- instantiate: ((getCoreModule: (path: string) => WebAssembly.Module, importObject: any, instantiateCore?: (module: WebAssembly.Module, imports: Record<string, any>) => WebAssembly.Instance | Promise<WebAssembly.Instance>) => Promise<({
22
- rubyRuntime: typeof RubyJsRubyRuntime;
23
- })>);
27
+ instantiate: RubyComponentInstantiator;
24
28
  /**
25
29
  * A function that returns a WebAssembly Core module within the Ruby component transpiled by `@bytecodealliance/jco`.
26
30
  */
@@ -1,5 +1,19 @@
1
1
  import { DefaultRubyVM } from "./browser.js";
2
+ import { RubyComponentInstantiator } from "./vm.js";
3
+ /**
4
+ * The main entry point of `<script type="text/ruby">`-based scripting with WebAssembly Core Module.
5
+ */
2
6
  export declare const main: (pkg: {
3
7
  name: string;
4
8
  version: string;
5
9
  }, options?: Parameters<typeof DefaultRubyVM>[1]) => Promise<void>;
10
+ /**
11
+ * The main entry point of `<script type="text/ruby">`-based scripting with WebAssembly Component.
12
+ */
13
+ export declare const componentMain: (pkg: {
14
+ name: string;
15
+ version: string;
16
+ }, options: {
17
+ instantiate: RubyComponentInstantiator;
18
+ wasip2: any;
19
+ }) => Promise<void>;
@@ -1,9 +1,28 @@
1
1
  import { __asyncValues } from "tslib";
2
2
  import { DefaultRubyVM } from "./browser.js";
3
+ import { RubyVM } from "./vm.js";
4
+ /**
5
+ * The main entry point of `<script type="text/ruby">`-based scripting with WebAssembly Core Module.
6
+ */
3
7
  export const main = async (pkg, options) => {
4
8
  const response = fetch(`https://cdn.jsdelivr.net/npm/${pkg.name}@${pkg.version}/dist/ruby+stdlib.wasm`);
5
9
  const module = await compileWebAssemblyModule(response);
6
10
  const { vm } = await DefaultRubyVM(module, options);
11
+ await mainWithRubyVM(vm);
12
+ };
13
+ /**
14
+ * The main entry point of `<script type="text/ruby">`-based scripting with WebAssembly Component.
15
+ */
16
+ export const componentMain = async (pkg, options) => {
17
+ const componentUrl = `https://cdn.jsdelivr.net/npm/${pkg.name}@${pkg.version}/dist/component`;
18
+ const fetchComponentFile = (relativePath) => fetch(`${componentUrl}/${relativePath}`);
19
+ const { vm } = await RubyVM.instantiateComponent(Object.assign(Object.assign({}, options), { getCoreModule: (relativePath) => {
20
+ const response = fetchComponentFile(relativePath);
21
+ return compileWebAssemblyModule(response);
22
+ } }));
23
+ await mainWithRubyVM(vm);
24
+ };
25
+ const mainWithRubyVM = async (vm) => {
7
26
  vm.printVersion();
8
27
  globalThis.rubyVM = vm;
9
28
  // Wait for the text/ruby script tag to be read.
package/dist/esm/vm.d.ts CHANGED
@@ -2,6 +2,12 @@ import type { RubyJsJsRuntime } from "./bindgen/interfaces/ruby-js-js-runtime.js
2
2
  import type { RubyJsRubyRuntime } from "./bindgen/interfaces/ruby-js-ruby-runtime.js";
3
3
  import { JsAbiValue } from "./bindgen/legacy/rb-js-abi-host.js";
4
4
  import { Binding, RbAbiValue } from "./binding.js";
5
+ /**
6
+ * A function type that instantiates a Ruby component
7
+ */
8
+ export type RubyComponentInstantiator = ((getCoreModule: (path: string) => WebAssembly.Module, importObject: any, instantiateCore?: (module: WebAssembly.Module, imports: Record<string, any>) => WebAssembly.Instance | Promise<WebAssembly.Instance>) => Promise<({
9
+ rubyRuntime: typeof RubyJsRubyRuntime;
10
+ })>);
5
11
  export type RubyInitComponentOptions = {
6
12
  /**
7
13
  * A lower-level instantiation function that instantiates the Ruby component with the given component
@@ -18,9 +24,7 @@ export type RubyInitComponentOptions = {
18
24
  /**
19
25
  * An `instantiate` function generated by `@bytecodealliance/jco` that instantiates the Ruby component.
20
26
  */
21
- instantiate: ((getCoreModule: (path: string) => WebAssembly.Module, importObject: any, instantiateCore?: (module: WebAssembly.Module, imports: Record<string, any>) => WebAssembly.Instance | Promise<WebAssembly.Instance>) => Promise<({
22
- rubyRuntime: typeof RubyJsRubyRuntime;
23
- })>);
27
+ instantiate: RubyComponentInstantiator;
24
28
  /**
25
29
  * A function that returns a WebAssembly Core module within the Ruby component transpiled by `@bytecodealliance/jco`.
26
30
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ruby/wasm-wasi",
3
- "version": "2.6.2-2024-09-07-a",
3
+ "version": "2.6.2-2024-09-09-a",
4
4
  "description": "WebAssembly port of CRuby with WASI",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",
@@ -39,7 +39,6 @@
39
39
  ],
40
40
  "license": "MIT",
41
41
  "scripts": {
42
- "test:run:all": "npm run test:run && ENABLE_COMPONENT_TESTS=1 npm run test:run",
43
42
  "test:run": "npm run test:unit && npm run test:vitest -- --run && npm run test:e2e",
44
43
  "test:vitest": "vitest ./test/",
45
44
  "test:unit": "./tools/run-test-unit.mjs",