@thi.ng/wasm-api 1.2.7 → 1.3.2
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/CHANGELOG.md +8 -1
- package/api.d.ts +21 -1
- package/package.json +14 -14
- package/zig/managed-index.zig +10 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2023-
|
|
3
|
+
- **Last updated**: 2023-02-10T14:03:11Z
|
|
4
4
|
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
|
|
5
5
|
|
|
6
6
|
All notable changes to this project will be documented in this file.
|
|
@@ -9,6 +9,13 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
|
|
|
9
9
|
**Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
|
|
10
10
|
and/or version bumps of transitive dependencies.
|
|
11
11
|
|
|
12
|
+
## [1.3.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/wasm-api@1.3.0) (2023-02-05)
|
|
13
|
+
|
|
14
|
+
#### 🚀 Features
|
|
15
|
+
|
|
16
|
+
- add ManagedIndex.initCapacity() ([788dfa2](https://github.com/thi-ng/umbrella/commit/788dfa2))
|
|
17
|
+
- add WasmType.instanceArray(), add docs ([2adf65f](https://github.com/thi-ng/umbrella/commit/2adf65f))
|
|
18
|
+
|
|
12
19
|
## [1.2.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/wasm-api@1.2.0) (2022-12-01)
|
|
13
20
|
|
|
14
21
|
#### 🚀 Features
|
package/api.d.ts
CHANGED
|
@@ -17,9 +17,29 @@ export interface WasmTypeBase {
|
|
|
17
17
|
readonly __bytes: Uint8Array;
|
|
18
18
|
}
|
|
19
19
|
export interface WasmType<T> {
|
|
20
|
+
/**
|
|
21
|
+
* Type alignment (in bytes)
|
|
22
|
+
*/
|
|
20
23
|
readonly align: number;
|
|
24
|
+
/**
|
|
25
|
+
* Type size (in bytes)
|
|
26
|
+
*/
|
|
21
27
|
readonly size: number;
|
|
22
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Takes a start address and number of items. Returns an array of memory
|
|
30
|
+
* mapped type instances (see {@link WasmType.instance}).
|
|
31
|
+
*
|
|
32
|
+
* @param base
|
|
33
|
+
* @param num
|
|
34
|
+
* @returns
|
|
35
|
+
*/
|
|
36
|
+
instanceArray: (base: number, num: number) => T[];
|
|
37
|
+
/**
|
|
38
|
+
* Returns a memory-mapped type instance for given start address.
|
|
39
|
+
*
|
|
40
|
+
* @param base
|
|
41
|
+
*/
|
|
42
|
+
instance: (base: number) => T;
|
|
23
43
|
}
|
|
24
44
|
export type WasmTypeConstructor<T> = Fn<IWasmMemoryAccess, WasmType<T>>;
|
|
25
45
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/wasm-api",
|
|
3
|
-
"version": "1.2
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"description": "Generic, modular, extensible API bridge and infrastructure for hybrid JS & WebAssembly projects",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -35,21 +35,21 @@
|
|
|
35
35
|
"test:build-zig": "zig build-lib -O ReleaseSmall -target wasm32-freestanding -dynamic --strip --pkg-begin wasmapi zig/lib.zig --pkg-end test/custom.zig && wasm-dis -o custom.wast custom.wasm && cp custom.wasm test"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@thi.ng/api": "^8.
|
|
39
|
-
"@thi.ng/arrays": "^2.5.
|
|
40
|
-
"@thi.ng/checks": "^3.3.
|
|
41
|
-
"@thi.ng/errors": "^2.2.
|
|
42
|
-
"@thi.ng/hex": "^2.3.
|
|
43
|
-
"@thi.ng/idgen": "^2.1.
|
|
44
|
-
"@thi.ng/logger": "^1.4.
|
|
38
|
+
"@thi.ng/api": "^8.7.2",
|
|
39
|
+
"@thi.ng/arrays": "^2.5.4",
|
|
40
|
+
"@thi.ng/checks": "^3.3.9",
|
|
41
|
+
"@thi.ng/errors": "^2.2.11",
|
|
42
|
+
"@thi.ng/hex": "^2.3.6",
|
|
43
|
+
"@thi.ng/idgen": "^2.1.27",
|
|
44
|
+
"@thi.ng/logger": "^1.4.9"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@microsoft/api-extractor": "^7.
|
|
48
|
-
"@thi.ng/testament": "^0.3.
|
|
49
|
-
"rimraf": "^
|
|
47
|
+
"@microsoft/api-extractor": "^7.34.2",
|
|
48
|
+
"@thi.ng/testament": "^0.3.11",
|
|
49
|
+
"rimraf": "^4.1.2",
|
|
50
50
|
"tools": "^0.0.1",
|
|
51
|
-
"typedoc": "^0.23.
|
|
52
|
-
"typescript": "^4.9.
|
|
51
|
+
"typedoc": "^0.23.24",
|
|
52
|
+
"typescript": "^4.9.5"
|
|
53
53
|
},
|
|
54
54
|
"keywords": [
|
|
55
55
|
"allocator",
|
|
@@ -115,5 +115,5 @@
|
|
|
115
115
|
"status": "alpha",
|
|
116
116
|
"year": 2022
|
|
117
117
|
},
|
|
118
|
-
"gitHead": "
|
|
118
|
+
"gitHead": "cafa4ecea90fb681949dc3885a5bd6ddefa38b51\n"
|
|
119
119
|
}
|
package/zig/managed-index.zig
CHANGED
|
@@ -42,6 +42,13 @@ pub fn ManagedIndex(comptime T: type, comptime I: type) type {
|
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
/// Initializes the underlying array list with given initial capacity
|
|
46
|
+
pub fn initCapacity(allocator: Allocator, num: usize) !Self {
|
|
47
|
+
return .{
|
|
48
|
+
.list = try std.ArrayList(Item).initCapacity(allocator, num),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
45
52
|
/// De-initializes the underlying array list
|
|
46
53
|
pub fn deinit(self: *Self) void {
|
|
47
54
|
self.list.deinit();
|
|
@@ -89,7 +96,7 @@ pub fn ManagedIndex(comptime T: type, comptime I: type) type {
|
|
|
89
96
|
}
|
|
90
97
|
|
|
91
98
|
/// Returns true if given `id` is valid, i.e. is referring to a
|
|
92
|
-
/// currently used item
|
|
99
|
+
/// currently used item and isn't part of the list of free slots.
|
|
93
100
|
pub fn has(self: *const Self, id: I) bool {
|
|
94
101
|
if (id >= self.list.items.len) return false;
|
|
95
102
|
var freeID = self.freeID;
|
|
@@ -112,7 +119,7 @@ pub fn ManagedIndex(comptime T: type, comptime I: type) type {
|
|
|
112
119
|
return .{ .parent = parent };
|
|
113
120
|
}
|
|
114
121
|
|
|
115
|
-
pub fn next(self: *@This()) ?T {
|
|
122
|
+
pub inline fn next(self: *@This()) ?T {
|
|
116
123
|
const items = self.parent.list.items;
|
|
117
124
|
if (self.i >= items.len) return null;
|
|
118
125
|
while (self.i < items.len) {
|
|
@@ -155,8 +162,8 @@ pub fn ManagedIndex(comptime T: type, comptime I: type) type {
|
|
|
155
162
|
while (i < slice.len) {
|
|
156
163
|
if (freeID) |fid| {
|
|
157
164
|
slice[i] = fid;
|
|
158
|
-
i += 1;
|
|
159
165
|
freeID = self.list.items[fid].id;
|
|
166
|
+
i += 1;
|
|
160
167
|
} else {
|
|
161
168
|
break;
|
|
162
169
|
}
|