@solidrt/flux-types 0.0.65 → 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 +1 -1
- package/gui/rendertree.d.ts +1 -1
- package/gui/spatial.d.ts +3 -3
- package/index.d.ts +1 -2
- package/modules/isolate.d.ts +1 -1
- package/modules/test.d.ts +18 -2
- package/modules/wasm.d.ts +12 -6
- package/package.json +1 -1
- package/modules/ffi.d.ts +0 -92
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`,
|
|
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/gui/rendertree.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// The render-tree bridge (gui-enabled runtime only): the low-level surface the
|
|
2
2
|
// renderer drives to build and mutate the native tree - create/insert/delete
|
|
3
3
|
// nodes, write properties, query layout, measure text. Displaying the built
|
|
4
|
-
// tree is the runner's concern ("
|
|
4
|
+
// tree is the runner's concern ("sol:render" in lattice), not part of this
|
|
5
5
|
// module; requestFrame here only schedules a future frame.
|
|
6
6
|
|
|
7
7
|
declare module "flux:rendertree" {
|
package/gui/spatial.d.ts
CHANGED
|
@@ -155,7 +155,7 @@ declare module "flux:spatial" {
|
|
|
155
155
|
* left alone, so rewriting the whole array to move one component never
|
|
156
156
|
* restarts the others (a held write's target counts, so re-sending it
|
|
157
157
|
* does not restart its delay). Each settled component fires one
|
|
158
|
-
* "spatialTransitionEnd" engine event (
|
|
158
|
+
* "spatialTransitionEnd" engine event (sol:events), payload
|
|
159
159
|
* `{ node, component: NodeComponent }` - on a live node; a leaving
|
|
160
160
|
* node's settles feed its free instead (exitNode).
|
|
161
161
|
*/
|
|
@@ -646,7 +646,7 @@ declare module "flux:spatial" {
|
|
|
646
646
|
* positive fades in, negative out; past 0 the player is removed).
|
|
647
647
|
* When a player finishes or is removed without finishing (faded out,
|
|
648
648
|
* clip or target destroyed), the "spatialClipEnd" engine event
|
|
649
|
-
* (
|
|
649
|
+
* (sol:events) fires with payload { player, reason: "finished" |
|
|
650
650
|
* "dropped" }, before the same frame's handlers.
|
|
651
651
|
*/
|
|
652
652
|
export function createPlayer(clip: ClipId, targets: NodeId[], speed: number, loop: boolean, weight: number, fade: number): PlayerId
|
|
@@ -661,7 +661,7 @@ declare module "flux:spatial" {
|
|
|
661
661
|
* the player's time each advance, and its travel since the previous
|
|
662
662
|
* advance (continuous across a loop wrap, weighted by the player's
|
|
663
663
|
* weight) is reported as one "spatialRootMotion" engine event
|
|
664
|
-
* (
|
|
664
|
+
* (sol:events) per advance, payload { player, x, y, z, yaw }, before
|
|
665
665
|
* the frame's handlers. The translation is given in the root's CURRENT
|
|
666
666
|
* facing (the clip's own turn so far undone), i.e. the character's
|
|
667
667
|
* local frame. `rotation`, a rotation channel of the same clip (the
|
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
|
|
|
@@ -32,7 +31,7 @@
|
|
|
32
31
|
// microphone/gpu are flux:* modules like the rest; requestAnimationFrame stays a
|
|
33
32
|
// global (web-standard name). flux:rendertree is the render-tree bridge the
|
|
34
33
|
// renderer drives; displaying the built tree (renderFrame) is the runner's
|
|
35
|
-
// concern (
|
|
34
|
+
// concern (sol:render in lattice), not part of flux.
|
|
36
35
|
/// <reference path="./gui/rendertree.d.ts" />
|
|
37
36
|
/// <reference path="./gui/camera.d.ts" />
|
|
38
37
|
/// <reference path="./gui/microphone.d.ts" />
|
package/modules/isolate.d.ts
CHANGED
|
@@ -70,7 +70,7 @@ declare module "flux:isolate" {
|
|
|
70
70
|
/**
|
|
71
71
|
* A handle on an isolate module: a `"use isolate"` module in a SolidRT
|
|
72
72
|
* project (id = its path relative to the source root, without extension),
|
|
73
|
-
* or `isolates/<id>.
|
|
73
|
+
* or `isolates/<id>.fluxbc`/`.js` next to the entry under standalone flux. Each property is
|
|
74
74
|
* an async function that runs the export of that name in a second runtime
|
|
75
75
|
* on its own thread (own heap, own event loop, the non-gui `flux:*`
|
|
76
76
|
* modules). Arguments and results are copied ({@link Sendable}).
|
package/modules/test.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Tests for a flux program: `test` registers one and `expect` asserts
|
|
3
|
-
* inside it. A test file is run by a test host, `
|
|
3
|
+
* inside it. A test file is run by a test host, `sol test <file>` (the
|
|
4
4
|
* `flux` binary's `--test` mode underneath); imported anywhere else the
|
|
5
5
|
* module throws, since nothing would run the tests.
|
|
6
6
|
*
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
* `Math.random()`, are the same on every run and do not depend on the
|
|
29
29
|
* tests that ran before. It is the engine's generator in kind and
|
|
30
30
|
* resolution, only its start is fixed. An isolate the test spawns is
|
|
31
|
-
* seeded too, with a seed derived from the test's. `
|
|
31
|
+
* seeded too, with a seed derived from the test's. `sol test --seed <n>`
|
|
32
32
|
* runs the tests on another sequence.
|
|
33
33
|
*
|
|
34
34
|
* A test that does not finish within 5 seconds of real time fails as timed
|
|
@@ -88,6 +88,15 @@ declare module "flux:test" {
|
|
|
88
88
|
/** The same matchers, inverted: each throws when it does hold. */
|
|
89
89
|
not: Matchers
|
|
90
90
|
|
|
91
|
+
/**
|
|
92
|
+
* For a promise: the same matchers on its rejection reason, each
|
|
93
|
+
* awaiting the promise first and returning a promise to await in turn.
|
|
94
|
+
* A promise that fulfills fails the matcher, with or without `not`.
|
|
95
|
+
* `toThrow` sees the reason as the thrown value, so a rejection reads
|
|
96
|
+
* like a throw: `await expect(p).rejects.toThrow("no such file")`.
|
|
97
|
+
*/
|
|
98
|
+
rejects: RejectionMatchers
|
|
99
|
+
|
|
91
100
|
/** The same value, as `Object.is` sees it: `NaN` is `NaN`, `0` is not `-0`, and two equal objects are not the same. */
|
|
92
101
|
toBe(expected: unknown): void
|
|
93
102
|
|
|
@@ -139,4 +148,11 @@ declare module "flux:test" {
|
|
|
139
148
|
toBeGreaterThan(expected: number | bigint): void
|
|
140
149
|
toBeGreaterThanOrEqual(expected: number | bigint): void
|
|
141
150
|
}
|
|
151
|
+
|
|
152
|
+
/** The matchers of `expect(promise).rejects`: `Matchers`, each returning a promise. */
|
|
153
|
+
export type RejectionMatchers = {
|
|
154
|
+
[K in Exclude<keyof Matchers, "rejects">]: Matchers[K] extends (...args: infer A) => void
|
|
155
|
+
? (...args: A) => Promise<void>
|
|
156
|
+
: RejectionMatchers
|
|
157
|
+
}
|
|
142
158
|
}
|
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.
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
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
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
|
-
}
|