@ruby/wasm-wasi 0.0.0-next
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.
- package/README.md +7 -0
- package/dist/bindgen/rb-abi-guest.d.ts +140 -0
- package/dist/bindgen/rb-js-abi-host.d.ts +53 -0
- package/dist/browser.cjs.js +3244 -0
- package/dist/browser.d.ts +9 -0
- package/dist/browser.esm.js +3242 -0
- package/dist/browser.script.cjs.js +3342 -0
- package/dist/browser.script.d.ts +4 -0
- package/dist/browser.script.esm.js +3340 -0
- package/dist/browser.script.umd.js +3348 -0
- package/dist/browser.umd.js +3250 -0
- package/dist/index.cjs.js +1192 -0
- package/dist/index.d.ts +192 -0
- package/dist/index.esm.js +1187 -0
- package/dist/index.umd.js +1198 -0
- package/dist/node.cjs.js +1209 -0
- package/dist/node.d.ts +8 -0
- package/dist/node.esm.js +1207 -0
- package/package.json +54 -0
package/README.md
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
export type RbErrno = number;
|
|
2
|
+
export type RbId = number;
|
|
3
|
+
export class RbAbiGuest {
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The WebAssembly instance that this class is operating with.
|
|
7
|
+
* This is only available after the `instantiate` method has
|
|
8
|
+
* been called.
|
|
9
|
+
*/
|
|
10
|
+
instance: WebAssembly.Instance;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Constructs a new instance with internal state necessary to
|
|
14
|
+
* manage a wasm instance.
|
|
15
|
+
*
|
|
16
|
+
* Note that this does not actually instantiate the WebAssembly
|
|
17
|
+
* instance or module, you'll need to call the `instantiate`
|
|
18
|
+
* method below to "activate" this class.
|
|
19
|
+
*/
|
|
20
|
+
constructor();
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* This is a low-level method which can be used to add any
|
|
24
|
+
* intrinsics necessary for this instance to operate to an
|
|
25
|
+
* import object.
|
|
26
|
+
*
|
|
27
|
+
* The `import` object given here is expected to be used later
|
|
28
|
+
* to actually instantiate the module this class corresponds to.
|
|
29
|
+
* If the `instantiate` method below actually does the
|
|
30
|
+
* instantiation then there's no need to call this method, but
|
|
31
|
+
* if you're instantiating manually elsewhere then this can be
|
|
32
|
+
* used to prepare the import object for external instantiation.
|
|
33
|
+
*/
|
|
34
|
+
addToImports(imports: any): void;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Initializes this object with the provided WebAssembly
|
|
38
|
+
* module/instance.
|
|
39
|
+
*
|
|
40
|
+
* This is intended to be a flexible method of instantiating
|
|
41
|
+
* and completion of the initialization of this class. This
|
|
42
|
+
* method must be called before interacting with the
|
|
43
|
+
* WebAssembly object.
|
|
44
|
+
*
|
|
45
|
+
* The first argument to this method is where to get the
|
|
46
|
+
* wasm from. This can be a whole bunch of different types,
|
|
47
|
+
* for example:
|
|
48
|
+
*
|
|
49
|
+
* * A precompiled `WebAssembly.Module`
|
|
50
|
+
* * A typed array buffer containing the wasm bytecode.
|
|
51
|
+
* * A `Promise` of a `Response` which is used with
|
|
52
|
+
* `instantiateStreaming`
|
|
53
|
+
* * A `Response` itself used with `instantiateStreaming`.
|
|
54
|
+
* * An already instantiated `WebAssembly.Instance`
|
|
55
|
+
*
|
|
56
|
+
* If necessary the module is compiled, and if necessary the
|
|
57
|
+
* module is instantiated. Whether or not it's necessary
|
|
58
|
+
* depends on the type of argument provided to
|
|
59
|
+
* instantiation.
|
|
60
|
+
*
|
|
61
|
+
* If instantiation is performed then the `imports` object
|
|
62
|
+
* passed here is the list of imports used to instantiate
|
|
63
|
+
* the instance. This method may add its own intrinsics to
|
|
64
|
+
* this `imports` object too.
|
|
65
|
+
*/
|
|
66
|
+
instantiate(
|
|
67
|
+
module: WebAssembly.Module | BufferSource | Promise<Response> | Response | WebAssembly.Instance,
|
|
68
|
+
imports?: any,
|
|
69
|
+
): Promise<void>;
|
|
70
|
+
rubyShowVersion(): void;
|
|
71
|
+
rubyInit(): void;
|
|
72
|
+
rubySysinit(args: string[]): void;
|
|
73
|
+
rubyOptions(args: string[]): RbIseq;
|
|
74
|
+
rubyScript(name: string): void;
|
|
75
|
+
rubyInitLoadpath(): void;
|
|
76
|
+
rbEvalStringProtect(str: string): [RbAbiValue, number];
|
|
77
|
+
rbFuncallvProtect(recv: RbAbiValue, mid: RbId, args: RbAbiValue[]): [RbAbiValue, number];
|
|
78
|
+
rbIntern(name: string): RbId;
|
|
79
|
+
rbErrinfo(): RbAbiValue;
|
|
80
|
+
rbClearErrinfo(): void;
|
|
81
|
+
rstringPtr(value: RbAbiValue): string;
|
|
82
|
+
rbVmBugreport(): void;
|
|
83
|
+
rbGcEnable(): boolean;
|
|
84
|
+
rbGcDisable(): boolean;
|
|
85
|
+
rbSetShouldProhibitRewind(newValue: boolean): boolean;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export class RbIseq {
|
|
89
|
+
// Creates a new strong reference count as a new
|
|
90
|
+
// object. This is only required if you're also
|
|
91
|
+
// calling `drop` below and want to manually manage
|
|
92
|
+
// the reference count from JS.
|
|
93
|
+
//
|
|
94
|
+
// If you don't call `drop`, you don't need to call
|
|
95
|
+
// this and can simply use the object from JS.
|
|
96
|
+
clone(): RbIseq;
|
|
97
|
+
|
|
98
|
+
// Explicitly indicate that this JS object will no
|
|
99
|
+
// longer be used. If the internal reference count
|
|
100
|
+
// reaches zero then this will deterministically
|
|
101
|
+
// destroy the underlying wasm object.
|
|
102
|
+
//
|
|
103
|
+
// This is not required to be called from JS. Wasm
|
|
104
|
+
// destructors will be automatically called for you
|
|
105
|
+
// if this is not called using the JS
|
|
106
|
+
// `FinalizationRegistry`.
|
|
107
|
+
//
|
|
108
|
+
// Calling this method does not guarantee that the
|
|
109
|
+
// underlying wasm object is deallocated. Something
|
|
110
|
+
// else (including wasm) may be holding onto a
|
|
111
|
+
// strong reference count.
|
|
112
|
+
drop(): void;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export class RbAbiValue {
|
|
116
|
+
// Creates a new strong reference count as a new
|
|
117
|
+
// object. This is only required if you're also
|
|
118
|
+
// calling `drop` below and want to manually manage
|
|
119
|
+
// the reference count from JS.
|
|
120
|
+
//
|
|
121
|
+
// If you don't call `drop`, you don't need to call
|
|
122
|
+
// this and can simply use the object from JS.
|
|
123
|
+
clone(): RbAbiValue;
|
|
124
|
+
|
|
125
|
+
// Explicitly indicate that this JS object will no
|
|
126
|
+
// longer be used. If the internal reference count
|
|
127
|
+
// reaches zero then this will deterministically
|
|
128
|
+
// destroy the underlying wasm object.
|
|
129
|
+
//
|
|
130
|
+
// This is not required to be called from JS. Wasm
|
|
131
|
+
// destructors will be automatically called for you
|
|
132
|
+
// if this is not called using the JS
|
|
133
|
+
// `FinalizationRegistry`.
|
|
134
|
+
//
|
|
135
|
+
// Calling this method does not guarantee that the
|
|
136
|
+
// underlying wasm object is deallocated. Something
|
|
137
|
+
// else (including wasm) may be holding onto a
|
|
138
|
+
// strong reference count.
|
|
139
|
+
drop(): void;
|
|
140
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export type JsAbiResult = JsAbiResultSuccess | JsAbiResultFailure;
|
|
2
|
+
export interface JsAbiResultSuccess {
|
|
3
|
+
tag: "success",
|
|
4
|
+
val: JsAbiValue,
|
|
5
|
+
}
|
|
6
|
+
export interface JsAbiResultFailure {
|
|
7
|
+
tag: "failure",
|
|
8
|
+
val: JsAbiValue,
|
|
9
|
+
}
|
|
10
|
+
export type RawInteger = RawIntegerF64 | RawIntegerBignum;
|
|
11
|
+
export interface RawIntegerF64 {
|
|
12
|
+
tag: "f64",
|
|
13
|
+
val: number,
|
|
14
|
+
}
|
|
15
|
+
export interface RawIntegerBignum {
|
|
16
|
+
tag: "bignum",
|
|
17
|
+
val: string,
|
|
18
|
+
}
|
|
19
|
+
export function addRbJsAbiHostToImports(imports: any, obj: RbJsAbiHost, get_export: (name: string) => WebAssembly.ExportValue): void;
|
|
20
|
+
export interface RbJsAbiHost {
|
|
21
|
+
evalJs(code: string): JsAbiResult;
|
|
22
|
+
isJs(value: JsAbiValue): boolean;
|
|
23
|
+
instanceOf(value: JsAbiValue, klass: JsAbiValue): boolean;
|
|
24
|
+
globalThis(): JsAbiValue;
|
|
25
|
+
intToJsNumber(value: number): JsAbiValue;
|
|
26
|
+
floatToJsNumber(value: number): JsAbiValue;
|
|
27
|
+
stringToJsString(value: string): JsAbiValue;
|
|
28
|
+
boolToJsBool(value: boolean): JsAbiValue;
|
|
29
|
+
procToJsFunction(value: number): JsAbiValue;
|
|
30
|
+
rbObjectToJsRbValue(rawRbAbiValue: number): JsAbiValue;
|
|
31
|
+
jsValueToString(value: JsAbiValue): string;
|
|
32
|
+
jsValueToInteger(value: JsAbiValue): RawInteger;
|
|
33
|
+
exportJsValueToHost(value: JsAbiValue): void;
|
|
34
|
+
importJsValueFromHost(): JsAbiValue;
|
|
35
|
+
jsValueTypeof(value: JsAbiValue): string;
|
|
36
|
+
jsValueEqual(lhs: JsAbiValue, rhs: JsAbiValue): boolean;
|
|
37
|
+
jsValueStrictlyEqual(lhs: JsAbiValue, rhs: JsAbiValue): boolean;
|
|
38
|
+
reflectApply(target: JsAbiValue, thisArgument: JsAbiValue, arguments: JsAbiValue[]): JsAbiResult;
|
|
39
|
+
reflectConstruct(target: JsAbiValue, arguments: JsAbiValue[]): JsAbiValue;
|
|
40
|
+
reflectDeleteProperty(target: JsAbiValue, propertyKey: string): boolean;
|
|
41
|
+
reflectGet(target: JsAbiValue, propertyKey: string): JsAbiResult;
|
|
42
|
+
reflectGetOwnPropertyDescriptor(target: JsAbiValue, propertyKey: string): JsAbiValue;
|
|
43
|
+
reflectGetPrototypeOf(target: JsAbiValue): JsAbiValue;
|
|
44
|
+
reflectHas(target: JsAbiValue, propertyKey: string): boolean;
|
|
45
|
+
reflectIsExtensible(target: JsAbiValue): boolean;
|
|
46
|
+
reflectOwnKeys(target: JsAbiValue): JsAbiValue[];
|
|
47
|
+
reflectPreventExtensions(target: JsAbiValue): boolean;
|
|
48
|
+
reflectSet(target: JsAbiValue, propertyKey: string, value: JsAbiValue): JsAbiResult;
|
|
49
|
+
reflectSetPrototypeOf(target: JsAbiValue, prototype: JsAbiValue): boolean;
|
|
50
|
+
dropJsAbiValue?: (val: JsAbiValue) => void;
|
|
51
|
+
}
|
|
52
|
+
export interface JsAbiValue {
|
|
53
|
+
}
|