@thi.ng/wasm-api-schedule 0.3.50 → 0.3.52

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2023-12-03T12:13:32Z
3
+ - **Last updated**: 2023-12-11T10:07:09Z
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.
package/README.md CHANGED
@@ -100,7 +100,7 @@ For Node.js REPL:
100
100
  const wasmApiSchedule = await import("@thi.ng/wasm-api-schedule");
101
101
  ```
102
102
 
103
- Package sizes (brotli'd, pre-treeshake): ESM: 495 bytes
103
+ Package sizes (brotli'd, pre-treeshake): ESM: 491 bytes
104
104
 
105
105
  ## Dependencies
106
106
 
package/generated/api.js CHANGED
@@ -1,21 +1,10 @@
1
- /**
2
- * Generated by @thi.ng/wasm-api-bindgen at 2023-03-26T00:14:48.759Z
3
- * DO NOT EDIT!
4
- */
5
- // @ts-ignore possibly includes unused imports
6
1
  import { Pointer, WasmStringPtr } from "@thi.ng/wasm-api";
7
- export var ScheduleType;
8
- (function (ScheduleType) {
9
- /**
10
- * One-off execution in the future
11
- */
12
- ScheduleType[ScheduleType["ONCE"] = 0] = "ONCE";
13
- /**
14
- * Recurring execution at fixed interval
15
- */
16
- ScheduleType[ScheduleType["INTERVAL"] = 1] = "INTERVAL";
17
- /**
18
- * As soon as possible execution
19
- */
20
- ScheduleType[ScheduleType["IMMEDIATE"] = 2] = "IMMEDIATE";
21
- })(ScheduleType || (ScheduleType = {}));
2
+ var ScheduleType = /* @__PURE__ */ ((ScheduleType2) => {
3
+ ScheduleType2[ScheduleType2["ONCE"] = 0] = "ONCE";
4
+ ScheduleType2[ScheduleType2["INTERVAL"] = 1] = "INTERVAL";
5
+ ScheduleType2[ScheduleType2["IMMEDIATE"] = 2] = "IMMEDIATE";
6
+ return ScheduleType2;
7
+ })(ScheduleType || {});
8
+ export {
9
+ ScheduleType
10
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/wasm-api-schedule",
3
- "version": "0.3.50",
3
+ "version": "0.3.52",
4
4
  "description": "Delayed & scheduled function execution (via setTimeout() etc.) for hybrid WASM apps",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -24,7 +24,9 @@
24
24
  "author": "Karsten Schmidt (https://thi.ng)",
25
25
  "license": "Apache-2.0",
26
26
  "scripts": {
27
- "build": "yarn clean && tsc --declaration",
27
+ "build": "yarn build:esbuild && yarn build:decl",
28
+ "build:decl": "tsc --declaration --emitDeclarationOnly",
29
+ "build:esbuild": "esbuild --format=esm --platform=neutral --target=es2022 --tsconfig=tsconfig.json --outdir=. src/**/*.ts",
28
30
  "build:types": "npx wasm-api-bindgen -a analytics.json --lang ts -o src/generated/api.ts --lang zig -o zig/api.zig src/typedefs.json",
29
31
  "clean": "rimraf --glob '*.js' '*.d.ts' '*.map' doc generated",
30
32
  "doc": "typedoc --excludePrivate --excludeInternal --out doc src/index.ts",
@@ -34,13 +36,13 @@
34
36
  "test": "bun test"
35
37
  },
36
38
  "dependencies": {
37
- "@thi.ng/api": "^8.9.10",
38
- "@thi.ng/wasm-api": "^1.4.35"
39
+ "@thi.ng/api": "^8.9.12",
40
+ "@thi.ng/wasm-api": "^1.4.37"
39
41
  },
40
42
  "devDependencies": {
41
43
  "@microsoft/api-extractor": "^7.38.3",
42
- "@thi.ng/testament": "^0.4.3",
43
- "@thi.ng/wasm-api-bindgen": "^0.4.31",
44
+ "@thi.ng/wasm-api-bindgen": "^0.4.33",
45
+ "esbuild": "^0.19.8",
44
46
  "rimraf": "^5.0.5",
45
47
  "tools": "^0.0.1",
46
48
  "typedoc": "^0.25.4",
@@ -94,5 +96,5 @@
94
96
  "status": "alpha",
95
97
  "year": 2022
96
98
  },
97
- "gitHead": "04d1de79f256d7a53c6b5fd157b37f49bc88e11d\n"
99
+ "gitHead": "5e7bafedfc3d53bc131469a28de31dd8e5b4a3ff\n"
98
100
  }
package/schedule.js CHANGED
@@ -1,47 +1,56 @@
1
- import { ScheduleType, } from "./api.js";
1
+ import {
2
+ ScheduleType
3
+ } from "./api.js";
2
4
  const START = {
3
- [ScheduleType.ONCE]: setTimeout,
4
- [ScheduleType.INTERVAL]: setInterval,
5
- [ScheduleType.IMMEDIATE]: typeof setImmediate !== "undefined"
6
- ? setImmediate
7
- : (x) => setTimeout(x, 0),
5
+ [ScheduleType.ONCE]: setTimeout,
6
+ [ScheduleType.INTERVAL]: setInterval,
7
+ [ScheduleType.IMMEDIATE]: typeof setImmediate !== "undefined" ? setImmediate : (x) => setTimeout(x, 0)
8
8
  };
9
9
  const CANCEL = {
10
- [ScheduleType.ONCE]: clearTimeout,
11
- [ScheduleType.INTERVAL]: clearInterval,
12
- [ScheduleType.IMMEDIATE]: typeof clearImmediate !== "undefined" ? clearImmediate : clearTimeout,
10
+ [ScheduleType.ONCE]: clearTimeout,
11
+ [ScheduleType.INTERVAL]: clearInterval,
12
+ [ScheduleType.IMMEDIATE]: typeof clearImmediate !== "undefined" ? clearImmediate : clearTimeout
13
13
  };
14
- export class WasmSchedule {
15
- static id = "schedule";
16
- id = WasmSchedule.id;
17
- parent;
18
- listeners = {};
19
- async init(parent) {
20
- this.parent = parent;
21
- if (parent.exports._schedule_init) {
22
- parent.exports._schedule_init();
23
- }
24
- else {
25
- parent.logger.warn("schedule module unused, skipping auto-init...");
26
- }
27
- return true;
14
+ class WasmSchedule {
15
+ static id = "schedule";
16
+ id = WasmSchedule.id;
17
+ parent;
18
+ listeners = {};
19
+ async init(parent) {
20
+ this.parent = parent;
21
+ if (parent.exports._schedule_init) {
22
+ parent.exports._schedule_init();
23
+ } else {
24
+ parent.logger.warn("schedule module unused, skipping auto-init...");
28
25
  }
29
- getImports() {
30
- return {
31
- _schedule: (kind, delay, listenerID) => {
32
- this.listeners[listenerID] = {
33
- id: listenerID,
34
- timeout: START[kind].call(null, () => this.parent.exports._schedule_callback(listenerID, kind), delay),
35
- kind,
36
- };
37
- },
38
- _cancel: (listenerID) => {
39
- const listener = this.listeners[listenerID];
40
- if (listener) {
41
- CANCEL[listener.kind].call(null, listenerID);
42
- delete this.listeners[listenerID];
43
- }
44
- },
26
+ return true;
27
+ }
28
+ getImports() {
29
+ return {
30
+ _schedule: (kind, delay, listenerID) => {
31
+ this.listeners[listenerID] = {
32
+ id: listenerID,
33
+ timeout: START[kind].call(
34
+ null,
35
+ () => this.parent.exports._schedule_callback(
36
+ listenerID,
37
+ kind
38
+ ),
39
+ delay
40
+ ),
41
+ kind
45
42
  };
46
- }
43
+ },
44
+ _cancel: (listenerID) => {
45
+ const listener = this.listeners[listenerID];
46
+ if (listener) {
47
+ CANCEL[listener.kind].call(null, listenerID);
48
+ delete this.listeners[listenerID];
49
+ }
50
+ }
51
+ };
52
+ }
47
53
  }
54
+ export {
55
+ WasmSchedule
56
+ };