@thi.ng/wasm-api-schedule 0.2.0 → 0.3.0
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 +7 -1
- package/README.md +10 -6
- package/package.json +4 -4
- package/schedule.js +6 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2022-11-
|
|
3
|
+
- **Last updated**: 2022-11-24T17:24:36Z
|
|
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,12 @@ 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
|
+
## [0.3.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/wasm-api-schedule@0.3.0) (2022-11-24)
|
|
13
|
+
|
|
14
|
+
#### 🚀 Features
|
|
15
|
+
|
|
16
|
+
- add check if auto-initializer is present ([f5ad93c](https://github.com/thi-ng/umbrella/commit/f5ad93c))
|
|
17
|
+
|
|
12
18
|
## [0.2.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/wasm-api-schedule@0.2.0) (2022-11-23)
|
|
13
19
|
|
|
14
20
|
#### 🚀 Features
|
package/README.md
CHANGED
|
@@ -22,7 +22,8 @@ This project is part of the
|
|
|
22
22
|
|
|
23
23
|
Delayed & scheduled function execution (via setTimeout() etc.) for hybrid WASM apps. This is a support package for [@thi.ng/wasm-api](https://github.com/thi-ng/umbrella/tree/develop/packages/wasm-api).
|
|
24
24
|
|
|
25
|
-
The package provides a WASM bridge API and abstraction for scheduling function
|
|
25
|
+
The package provides a WASM bridge API and abstraction for scheduling function
|
|
26
|
+
calls via:
|
|
26
27
|
|
|
27
28
|
- **once**: `setTimeout()` / `clearTimeout()`
|
|
28
29
|
- **interval**: `setInterval()` / `clearInterval()`
|
|
@@ -47,8 +48,8 @@ try schedule.init(customAllocator);
|
|
|
47
48
|
// user callback function
|
|
48
49
|
fn exampleCallback(raw: ?*anyopaque) void {
|
|
49
50
|
if (wasm.ptrCast(*u32, raw)) |state| {
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
// do something ...
|
|
52
|
+
}
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
// arbitrary user state
|
|
@@ -57,17 +58,20 @@ var state: u32 = 0xdecafbad;
|
|
|
57
58
|
// schedule a single/one-off callback 500ms in the future
|
|
58
59
|
const listenerID = try schedule.schedule(
|
|
59
60
|
.once,
|
|
60
|
-
&.{ .callback = exampleCallback, .ctx = &state },
|
|
61
61
|
500,
|
|
62
|
+
exampleCallback,
|
|
63
|
+
&state,
|
|
62
64
|
);
|
|
63
65
|
|
|
64
66
|
// ...or maybe cancel it again
|
|
65
67
|
schedule.cancel(listenerID);
|
|
66
68
|
```
|
|
67
69
|
|
|
68
|
-
Also see
|
|
70
|
+
Also see the
|
|
69
71
|
[zig-counter](https://github.com/thi-ng/umbrella/blob/develop/examples/zig-counter/)
|
|
70
|
-
|
|
72
|
+
and
|
|
73
|
+
[zig-todo-list](https://github.com/thi-ng/umbrella/blob/develop/examples/zig-todo-list/)
|
|
74
|
+
example projects for more advanced usage...
|
|
71
75
|
|
|
72
76
|
## Status
|
|
73
77
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/wasm-api-schedule",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Delayed & scheduled function execution (via setTimeout() etc.) for hybrid WASM apps",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@thi.ng/api": "^8.4.6",
|
|
39
|
-
"@thi.ng/wasm-api": "^1.0.
|
|
40
|
-
"@thi.ng/wasm-api-bindgen": "^0.
|
|
39
|
+
"@thi.ng/wasm-api": "^1.0.1",
|
|
40
|
+
"@thi.ng/wasm-api-bindgen": "^0.2.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@microsoft/api-extractor": "^7.33.5",
|
|
@@ -92,5 +92,5 @@
|
|
|
92
92
|
"status": "alpha",
|
|
93
93
|
"year": 2022
|
|
94
94
|
},
|
|
95
|
-
"gitHead": "
|
|
95
|
+
"gitHead": "75263a53b4601b62163253b11deabfd304bcc67d\n"
|
|
96
96
|
}
|
package/schedule.js
CHANGED
|
@@ -20,7 +20,12 @@ export class WasmSchedule {
|
|
|
20
20
|
}
|
|
21
21
|
async init(parent) {
|
|
22
22
|
this.parent = parent;
|
|
23
|
-
parent.exports._schedule_init
|
|
23
|
+
if (parent.exports._schedule_init) {
|
|
24
|
+
parent.exports._schedule_init();
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
parent.logger.warn("schedule module unused, skipping auto-init...");
|
|
28
|
+
}
|
|
24
29
|
return true;
|
|
25
30
|
}
|
|
26
31
|
getImports() {
|