@solidrt/flux-types 0.0.66 → 0.0.67

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 CHANGED
@@ -46,7 +46,7 @@ rely on must be named.
46
46
 
47
47
  - `Flux` global (`version`, `capabilities`).
48
48
  - `flux:*` modules: `flux:http`, `flux:fs`, `flux:sqlite`, `flux:subprocess`,
49
- `flux:p2p`, `flux:net`, `flux:mdns`, `flux:process`, `flux:tty`, `flux:path`, `flux:wasm`, `flux:ffi`,
49
+ `flux:p2p`, `flux:net`, `flux:mdns`, `flux:process`, `flux:tty`, `flux:path`, `flux:wasm`,
50
50
  and (on a gui-enabled runtime)
51
51
  `flux:camera`, `flux:microphone`, `flux:audio`, `flux:gpu`, `flux:spatial`.
52
52
  - Web-standard globals: `console`, `fetch` + `Headers`/`Request`/`Response`,
package/index.d.ts CHANGED
@@ -11,7 +11,6 @@
11
11
  /// <reference path="./modules/net.d.ts" />
12
12
  /// <reference path="./modules/mdns.d.ts" />
13
13
  /// <reference path="./modules/wasm.d.ts" />
14
- /// <reference path="./modules/ffi.d.ts" />
15
14
  /// <reference path="./modules/isolate.d.ts" />
16
15
  /// <reference path="./modules/test.d.ts" />
17
16
 
package/modules/wasm.d.ts CHANGED
@@ -1,10 +1,16 @@
1
1
  // There is no `WebAssembly` global in flux; this module is the entire wasm
2
- // surface. Modules run in a pure interpreter (wasmi, no JIT), so this is a
3
- // portability tool - one compiled module runs on every flux target with no
4
- // native binaries or dlopen - not a speed tool. Tight typed compute runs
5
- // somewhat faster than the same loop in JavaScript (a small constant
6
- // factor, nowhere near browser wasm speed), and every host call costs
7
- // extra marshalling, so call-heavy code can end up slower.
2
+ // surface. One compiled module runs on every flux target with no native
3
+ // binaries or dlopen, and it is the route for app code that needs more than
4
+ // the JavaScript interpreter. Where the device allows generated code
5
+ // (desktop, 64-bit Android) a module is compiled to machine code on the
6
+ // device the first time it is seen - at install for a `.wasm` under
7
+ // `assets/`, otherwise at `new Module` - and `Flux.capabilities` lists
8
+ // `wasm-native`; a tight typed kernel then runs 18x to 960x faster than the
9
+ // same loop in JavaScript. Where it does not (iOS, 32-bit Android) the
10
+ // module is interpreted and still runs compute 4x to 88x faster than
11
+ // JavaScript. The boundary is the cost on both lanes: a host call out of
12
+ // the module costs 3x to 7x a plain JavaScript call, so keep calls coarse:
13
+ // one call per frame handing over a buffer, never one per entity.
8
14
  // Imports must be scalar-signature functions only (no imported
9
15
  // memory, globals or tables), which constrains the toolchain on the other
10
16
  // side: default emscripten output imports its memory and is rejected, while
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidrt/flux-types",
3
- "version": "0.0.66",
3
+ "version": "0.0.67",
4
4
  "license": "MIT",
5
5
  "funding": "https://github.com/sponsors/wellawaretech",
6
6
  "author": "Antoine van Wel",
package/modules/ffi.d.ts DELETED
@@ -1,92 +0,0 @@
1
- declare module "flux:ffi" {
2
- /**
3
- * A scalar ffi value. i32/f32/f64 marshal as number; i64 and ptr marshal as
4
- * BigInt (an address or i64 does not fit a JS number without precision
5
- * loss). A number is also accepted where an i64 or ptr is expected.
6
- */
7
- type FfiValue = number | bigint
8
- /**
9
- * What a `symbols.*` call accepts per argument. Where a `ptr` is declared,
10
- * an ArrayBuffer or typed array may be passed instead of an address: its
11
- * data pointer (view offset respected) is handed to the native call and the
12
- * buffer stays valid for the call's duration, so native code may read from
13
- * and write into it (out-parameters, result buffers). Do not keep such an
14
- * address past the call. A detached buffer throws.
15
- */
16
- type FfiArg = FfiValue | ArrayBuffer | ArrayBufferView
17
- type FfiTypeName = "i32" | "i64" | "f32" | "f64" | "ptr"
18
-
19
- /**
20
- * One symbol declaration. `returns` defaults to "void". A missing symbol
21
- * fails the load unless `optional` is set, in which case its `symbols`
22
- * entry is `undefined` (test for it before calling).
23
- */
24
- type SymbolDecl = {
25
- args: FfiTypeName[]
26
- returns?: FfiTypeName | "void"
27
- optional?: boolean
28
- }
29
-
30
- /** The symbols to resolve at load time, keyed by exported name. */
31
- type Symbols = Record<string, SymbolDecl>
32
-
33
- /**
34
- * A JS function backing a minted C function pointer. Called synchronously
35
- * while a `symbols.*` call is on the stack; its return value is coerced to
36
- * the callback's declared result type ("void" ignores it). Unlike a call
37
- * argument, a callback may not return a buffer as a ptr (the address would
38
- * dangle once the callback returns). A throw cannot
39
- * abort the native frame: the callback returns zeroes, the native call runs
40
- * to completion, and the exception is rethrown after it returns.
41
- */
42
- type CallbackFunction = (...args: FfiValue[]) => FfiValue | void
43
-
44
- /**
45
- * A native shared library. The native counterpart of `flux:wasm`'s Module:
46
- * declare what you need up front, every declared symbol must resolve
47
- * (unless marked optional).
48
- *
49
- * There is NO sandbox: the library runs with full process rights, loading
50
- * runs its constructors, and a declared signature that does not match the
51
- * real ABI is undefined behavior. Only load trusted code.
52
- */
53
- export class Library {
54
- /**
55
- * Load a shared library from bytes (e.g. a bundled binary import; written
56
- * to a temp file behind the scenes) or a filesystem path, and resolve
57
- * every declared symbol. A missing symbol throws unless declared
58
- * `optional`.
59
- */
60
- constructor(source: Uint8Array | ArrayBuffer | string, symbols: Symbols)
61
- /**
62
- * The declared symbols as bound JS functions, keyed by name. Destructure
63
- * once and reuse: the object is rebuilt on each access.
64
- */
65
- readonly symbols: Record<string, (...args: FfiArg[]) => FfiValue | undefined>
66
- /**
67
- * Mint a C function pointer (returned as a BigInt address) that invokes
68
- * `func` when the library calls it during a `symbols.*` call. Callbacks
69
- * may only fire while such a call is on the stack, on the same thread;
70
- * the pointer stays valid for the lifetime of the library.
71
- */
72
- callback(func: CallbackFunction, decl: SymbolDecl): bigint
73
- /**
74
- * Copy `count` elements out of process memory at `ptr`, in native byte
75
- * order. Without `type` (or with "u8") that is `count` bytes as a
76
- * Uint8Array; with an ffi type name it is `count` elements as the matching
77
- * typed array. No bounds checking is possible: a bad pointer is undefined
78
- * behavior.
79
- */
80
- readMemory(ptr: FfiValue, count: number, type?: "u8"): Uint8Array
81
- readMemory(ptr: FfiValue, count: number, type: "i32"): Int32Array
82
- readMemory(ptr: FfiValue, count: number, type: "i64"): BigInt64Array
83
- readMemory(ptr: FfiValue, count: number, type: "f32"): Float32Array
84
- readMemory(ptr: FfiValue, count: number, type: "f64"): Float64Array
85
- readMemory(ptr: FfiValue, count: number, type: "ptr"): BigUint64Array
86
- /**
87
- * Copy the bytes of a typed array or ArrayBuffer into process memory at
88
- * `ptr`. Same caveat as readMemory.
89
- */
90
- writeMemory(ptr: FfiValue, bytes: ArrayBufferView | ArrayBuffer): void
91
- }
92
- }