@thi.ng/wasm-api 1.4.11 → 1.4.13

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-06-29T08:54:28Z
3
+ - **Last updated**: 2023-08-04T10:58:19Z
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,20 @@ 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.4.13](https://github.com/thi-ng/umbrella/tree/@thi.ng/wasm-api@1.4.13) (2023-08-04)
13
+
14
+ #### ♻️ Refactoring
15
+
16
+ - update INotify impl ([07e884f](https://github.com/thi-ng/umbrella/commit/07e884f))
17
+ - update INotify impls ([cbdc527](https://github.com/thi-ng/umbrella/commit/cbdc527))
18
+
19
+ ### [1.4.12](https://github.com/thi-ng/umbrella/tree/@thi.ng/wasm-api@1.4.12) (2023-07-14)
20
+
21
+ #### ♻️ Refactoring
22
+
23
+ - update zig build script ([ac0f375](https://github.com/thi-ng/umbrella/commit/ac0f375))
24
+ - use non-deprecated `std.Build.Step.Compile` type
25
+
12
26
  ### [1.4.10](https://github.com/thi-ng/umbrella/tree/@thi.ng/wasm-api@1.4.10) (2023-06-29)
13
27
 
14
28
  #### 🩹 Bug fixes
package/README.md CHANGED
@@ -321,8 +321,8 @@ const std = @import("std");
321
321
 
322
322
  pub fn build(b: *std.Build) void {
323
323
  // obtain a standard std.Build.Step.Compile, pre-configured w/ given options
324
- // see source comments in imported build-v0.11.zig for further details...
325
- var lib = @import("node_modules/@thi.ng/wasm-api/zig/build-v0.11.zig").wasmLib(b, .{
324
+ // see source comments in imported build.zig for further details...
325
+ var lib = @import("node_modules/@thi.ng/wasm-api/zig/build.zig").wasmLib(b, .{
326
326
  // Declare extra WASM API modules to use
327
327
  // Each can also declare dependencies to other modules
328
328
  // (`wasm-api` and `wasm-api-bindgen` are made available everywhere)
package/api.d.ts CHANGED
@@ -1,7 +1,8 @@
1
- import type { Fn, IDeref, ILength } from "@thi.ng/api";
1
+ import type { EVENT_ALL, Fn, IDeref, ILength } from "@thi.ng/api";
2
2
  import type { WasmBridge } from "./bridge.js";
3
3
  export declare const EVENT_MEMORY_CHANGED = "memory-changed";
4
4
  export declare const EVENT_PANIC = "panic";
5
+ export type BridgeEventType = typeof EVENT_MEMORY_CHANGED | typeof EVENT_PANIC | typeof EVENT_ALL;
5
6
  export type BigIntArray = bigint[] | BigInt64Array | BigUint64Array;
6
7
  export type ReadonlyWasmString = IDeref<string> & ILength & {
7
8
  readonly addr: number;
package/bridge.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  import type { Event, INotify, IObjectOf, Listener, NumericArray } from "@thi.ng/api";
3
3
  import type { ILogger } from "@thi.ng/logger";
4
- import { type BigIntArray, type CoreAPI, type IWasmAPI, type IWasmMemoryAccess, type MemorySlice, type WasmExports } from "./api.js";
4
+ import { type BigIntArray, type BridgeEventType, type CoreAPI, type IWasmAPI, type IWasmMemoryAccess, type MemorySlice, type WasmExports } from "./api.js";
5
5
  export declare const Panic: {
6
6
  new (msg?: string | undefined): {
7
7
  name: string;
@@ -38,7 +38,7 @@ export declare const OutOfMemoryError: {
38
38
  * 64bit integers are handled via JS `BigInt` and hence require the host env to
39
39
  * support it. No polyfills are provided.
40
40
  */
41
- export declare class WasmBridge<T extends WasmExports = WasmExports> implements IWasmMemoryAccess, INotify {
41
+ export declare class WasmBridge<T extends WasmExports = WasmExports> implements IWasmMemoryAccess, INotify<BridgeEventType> {
42
42
  logger: ILogger;
43
43
  readonly id = "wasmapi";
44
44
  i8: Int8Array;
@@ -177,10 +177,10 @@ export declare class WasmBridge<T extends WasmExports = WasmExports> implements
177
177
  setString(str: string, addr: number, maxBytes: number, terminate?: boolean): number;
178
178
  getElementById(addr: number, len?: number): HTMLElement;
179
179
  /** {@inheritDoc @thi.ng/api#INotify.addListener} */
180
- addListener(id: string, fn: Listener, scope?: any): boolean;
180
+ addListener(id: BridgeEventType, fn: Listener<BridgeEventType>, scope?: any): boolean;
181
181
  /** {@inheritDoc @thi.ng/api#INotify.removeListener} */
182
- removeListener(id: string, fn: Listener, scope?: any): boolean;
182
+ removeListener(id: BridgeEventType, fn: Listener<BridgeEventType>, scope?: any): boolean;
183
183
  /** {@inheritDoc @thi.ng/api#INotify.notify} */
184
- notify(event: Event): boolean;
184
+ notify(event: Event<BridgeEventType>): boolean;
185
185
  }
186
186
  //# sourceMappingURL=bridge.d.ts.map
package/bridge.js CHANGED
@@ -388,9 +388,11 @@ export let WasmBridge = class WasmBridge {
388
388
  }
389
389
  /** {@inheritDoc @thi.ng/api#INotify.addListener} */
390
390
  // @ts-ignore: mixin
391
+ // prettier-ignore
391
392
  addListener(id, fn, scope) { }
392
393
  /** {@inheritDoc @thi.ng/api#INotify.removeListener} */
393
394
  // @ts-ignore: mixin
395
+ // prettier-ignore
394
396
  removeListener(id, fn, scope) { }
395
397
  /** {@inheritDoc @thi.ng/api#INotify.notify} */
396
398
  // @ts-ignore: mixin
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/wasm-api",
3
- "version": "1.4.11",
3
+ "version": "1.4.13",
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.8.2",
39
- "@thi.ng/arrays": "^2.5.13",
40
- "@thi.ng/checks": "^3.3.14",
41
- "@thi.ng/errors": "^2.2.17",
42
- "@thi.ng/hex": "^2.3.11",
43
- "@thi.ng/idgen": "^2.1.34",
44
- "@thi.ng/logger": "^1.4.15"
38
+ "@thi.ng/api": "^8.9.0",
39
+ "@thi.ng/arrays": "^2.5.15",
40
+ "@thi.ng/checks": "^3.4.0",
41
+ "@thi.ng/errors": "^2.3.0",
42
+ "@thi.ng/hex": "^2.3.12",
43
+ "@thi.ng/idgen": "^2.2.0",
44
+ "@thi.ng/logger": "^1.4.16"
45
45
  },
46
46
  "devDependencies": {
47
- "@microsoft/api-extractor": "^7.35.3",
48
- "@thi.ng/testament": "^0.3.17",
47
+ "@microsoft/api-extractor": "^7.36.3",
48
+ "@thi.ng/testament": "^0.3.18",
49
49
  "rimraf": "^5.0.1",
50
50
  "tools": "^0.0.1",
51
51
  "typedoc": "^0.24.8",
52
- "typescript": "^5.1.3"
52
+ "typescript": "^5.1.6"
53
53
  },
54
54
  "keywords": [
55
55
  "allocator",
@@ -115,5 +115,5 @@
115
115
  "status": "alpha",
116
116
  "year": 2022
117
117
  },
118
- "gitHead": "b363e93fb1b9e754957309ab582bba16b8e187ca\n"
118
+ "gitHead": "9fa3f7f8169efa30e3c71b43c82f77393581c3b5\n"
119
119
  }
package/zig/build.zig CHANGED
@@ -2,7 +2,7 @@
2
2
  //! Intended for use with https://thi.ng/wasm-api and support packages
3
3
  //!
4
4
  //! This version of the script is only compatible with:
5
- //! Zig v0.11.0-dev.2266+49e33a2f2 or newer
5
+ //! Zig 0.11.0-dev.3857+7322aa118 or newer
6
6
  //!
7
7
  //! Use build.zig (in this same directory) for earlier Zig versions
8
8
 
@@ -16,8 +16,6 @@ pub const WasmLibOpts = struct {
16
16
  base: []const u8 = "node_modules",
17
17
  /// Relative path to root source file
18
18
  root: []const u8 = "zig/main.zig",
19
- /// CURRENTLY UNUSED - Relative path to output directory
20
- out: []const u8 = "src",
21
19
  /// Additional WASM API support modules.
22
20
  /// Only need to specify custom/extra modules
23
21
  /// `wasm-api` and `wasm-api-bindgen` are auto-added as dependency for all...
@@ -30,8 +28,8 @@ pub const WasmLibOpts = struct {
30
28
  initialMemory: ?u64 = null,
31
29
  /// Max memory (in bytes, MUST be multiple of 0x10000)
32
30
  maxMemory: ?u64 = null,
33
- /// If true, build will also generate docs
34
- docs: bool = false,
31
+ // If true, build will also generate docs
32
+ // docs: bool = false,
35
33
  };
36
34
 
37
35
  /// WASM API sub-module declaration
@@ -64,15 +62,11 @@ pub fn wasmLib(b: *Build, opts: WasmLibOpts) *Build.Step.Compile {
64
62
  });
65
63
  if (lib.optimize == .ReleaseSmall or lib.optimize == .ReleaseFast) lib.strip = true;
66
64
 
67
- // FIXME re-enable once workaround has been identified
68
- // lib.setOutputDir(opts.out);
69
-
70
65
  // build flags
71
66
  lib.rdynamic = true;
72
67
  lib.import_symbols = true;
73
68
  lib.initial_memory = opts.initialMemory;
74
69
  lib.max_memory = opts.maxMemory;
75
- if (opts.docs) lib.emit_docs = .emit;
76
70
 
77
71
  // add default dependencies
78
72
  lib.addModule(
@@ -96,7 +90,7 @@ pub fn wasmLib(b: *Build, opts: WasmLibOpts) *Build.Step.Compile {
96
90
  }
97
91
 
98
92
  /// Registers a single package and its deps (also injects core wasm-api deps)
99
- pub fn register(step: *Build.CompileStep, mod: ModuleSpec, opts: WasmLibOpts) void {
93
+ pub fn register(step: *Build.Step.Compile, mod: ModuleSpec, opts: WasmLibOpts) void {
100
94
  const num = if (mod.dependencies) |ids| ids.len else 0;
101
95
  var dpkgs = step.step.owner.allocator.alloc(Build.ModuleDependency, num + 2) catch unreachable;
102
96
  dpkgs[0] = if (step.modules.get(wasmapi)) |m| .{ .name = wasmapi, .module = m } else unreachable;
File without changes
@@ -0,0 +1,116 @@
1
+ const std = @import("std");
2
+ /// Zig version. When writing code that supports multiple versions of Zig, prefer
3
+ /// feature detection (i.e. with `@hasDecl` or `@hasField`) over version checks.
4
+ pub const zig_version = std.SemanticVersion.parse(zig_version_string) catch unreachable;
5
+ pub const zig_version_string = "0.11.0-dev.4282+0f21d3d4d";
6
+ pub const zig_backend = std.builtin.CompilerBackend.stage2_llvm;
7
+
8
+ pub const output_mode = std.builtin.OutputMode.Exe;
9
+ pub const link_mode = std.builtin.LinkMode.Dynamic;
10
+ pub const is_test = false;
11
+ pub const single_threaded = false;
12
+ pub const abi = std.Target.Abi.none;
13
+ pub const cpu: std.Target.Cpu = .{
14
+ .arch = .aarch64,
15
+ .model = &std.Target.aarch64.cpu.apple_a14,
16
+ .features = std.Target.aarch64.featureSet(&[_]std.Target.aarch64.Feature{
17
+ .aes,
18
+ .aggressive_fma,
19
+ .alternate_sextload_cvt_f32_pattern,
20
+ .altnzcv,
21
+ .am,
22
+ .arith_bcc_fusion,
23
+ .arith_cbz_fusion,
24
+ .ccdp,
25
+ .ccidx,
26
+ .ccpp,
27
+ .complxnum,
28
+ .contextidr_el2,
29
+ .crc,
30
+ .crypto,
31
+ .disable_latency_sched_heuristic,
32
+ .dit,
33
+ .dotprod,
34
+ .el2vmsa,
35
+ .el3,
36
+ .flagm,
37
+ .fp16fml,
38
+ .fp_armv8,
39
+ .fptoint,
40
+ .fullfp16,
41
+ .fuse_address,
42
+ .fuse_adrp_add,
43
+ .fuse_aes,
44
+ .fuse_arith_logic,
45
+ .fuse_crypto_eor,
46
+ .fuse_csel,
47
+ .fuse_literals,
48
+ .jsconv,
49
+ .lor,
50
+ .lse,
51
+ .lse2,
52
+ .mpam,
53
+ .neon,
54
+ .nv,
55
+ .pan,
56
+ .pan_rwv,
57
+ .pauth,
58
+ .perfmon,
59
+ .predres,
60
+ .ras,
61
+ .rcpc,
62
+ .rcpc_immo,
63
+ .rdm,
64
+ .sb,
65
+ .sel2,
66
+ .sha2,
67
+ .sha3,
68
+ .specrestrict,
69
+ .ssbs,
70
+ .tlb_rmi,
71
+ .tracev8_4,
72
+ .uaops,
73
+ .v8_1a,
74
+ .v8_2a,
75
+ .v8_3a,
76
+ .v8_4a,
77
+ .v8a,
78
+ .vh,
79
+ .zcm,
80
+ .zcz,
81
+ .zcz_gp,
82
+ }),
83
+ };
84
+ pub const os = std.Target.Os{
85
+ .tag = .macos,
86
+ .version_range = .{ .semver = .{
87
+ .min = .{
88
+ .major = 13,
89
+ .minor = 3,
90
+ .patch = 1,
91
+ },
92
+ .max = .{
93
+ .major = 13,
94
+ .minor = 3,
95
+ .patch = 1,
96
+ },
97
+ }},
98
+ };
99
+ pub const target = std.Target{
100
+ .cpu = cpu,
101
+ .os = os,
102
+ .abi = abi,
103
+ .ofmt = object_format,
104
+ };
105
+ pub const object_format = std.Target.ObjectFormat.macho;
106
+ pub const mode = std.builtin.Mode.Debug;
107
+ pub const link_libc = true;
108
+ pub const link_libcpp = false;
109
+ pub const have_error_return_tracing = true;
110
+ pub const valgrind_support = false;
111
+ pub const sanitize_thread = false;
112
+ pub const position_independent_code = true;
113
+ pub const position_independent_executable = true;
114
+ pub const strip_debug_info = false;
115
+ pub const code_model = std.builtin.CodeModel.default;
116
+ pub const omit_frame_pointer = false;
@@ -0,0 +1,115 @@
1
+ const std = @import("std");
2
+ /// Zig version. When writing code that supports multiple versions of Zig, prefer
3
+ /// feature detection (i.e. with `@hasDecl` or `@hasField`) over version checks.
4
+ pub const zig_version = std.SemanticVersion.parse(zig_version_string) catch unreachable;
5
+ pub const zig_version_string = "0.11.0-dev.3857+7322aa118";
6
+ pub const zig_backend = std.builtin.CompilerBackend.stage2_llvm;
7
+
8
+ pub const output_mode = std.builtin.OutputMode.Exe;
9
+ pub const link_mode = std.builtin.LinkMode.Dynamic;
10
+ pub const is_test = false;
11
+ pub const single_threaded = false;
12
+ pub const abi = std.Target.Abi.none;
13
+ pub const cpu: std.Target.Cpu = .{
14
+ .arch = .aarch64,
15
+ .model = &std.Target.aarch64.cpu.apple_a14,
16
+ .features = std.Target.aarch64.featureSet(&[_]std.Target.aarch64.Feature{
17
+ .aes,
18
+ .aggressive_fma,
19
+ .alternate_sextload_cvt_f32_pattern,
20
+ .altnzcv,
21
+ .am,
22
+ .arith_bcc_fusion,
23
+ .arith_cbz_fusion,
24
+ .ccdp,
25
+ .ccidx,
26
+ .ccpp,
27
+ .complxnum,
28
+ .contextidr_el2,
29
+ .crc,
30
+ .crypto,
31
+ .disable_latency_sched_heuristic,
32
+ .dit,
33
+ .dotprod,
34
+ .el2vmsa,
35
+ .el3,
36
+ .flagm,
37
+ .fp16fml,
38
+ .fp_armv8,
39
+ .fptoint,
40
+ .fullfp16,
41
+ .fuse_address,
42
+ .fuse_adrp_add,
43
+ .fuse_aes,
44
+ .fuse_arith_logic,
45
+ .fuse_crypto_eor,
46
+ .fuse_csel,
47
+ .fuse_literals,
48
+ .jsconv,
49
+ .lor,
50
+ .lse,
51
+ .lse2,
52
+ .mpam,
53
+ .neon,
54
+ .nv,
55
+ .pan,
56
+ .pan_rwv,
57
+ .pauth,
58
+ .perfmon,
59
+ .predres,
60
+ .ras,
61
+ .rcpc,
62
+ .rcpc_immo,
63
+ .rdm,
64
+ .sb,
65
+ .sel2,
66
+ .sha2,
67
+ .sha3,
68
+ .specrestrict,
69
+ .ssbs,
70
+ .tlb_rmi,
71
+ .tracev8_4,
72
+ .uaops,
73
+ .v8_1a,
74
+ .v8_2a,
75
+ .v8_3a,
76
+ .v8_4a,
77
+ .v8a,
78
+ .vh,
79
+ .zcm,
80
+ .zcz,
81
+ .zcz_gp,
82
+ }),
83
+ };
84
+ pub const os = std.Target.Os{
85
+ .tag = .macos,
86
+ .version_range = .{ .semver = .{
87
+ .min = .{
88
+ .major = 13,
89
+ .minor = 3,
90
+ .patch = 1,
91
+ },
92
+ .max = .{
93
+ .major = 13,
94
+ .minor = 3,
95
+ .patch = 1,
96
+ },
97
+ }},
98
+ };
99
+ pub const target = std.Target{
100
+ .cpu = cpu,
101
+ .os = os,
102
+ .abi = abi,
103
+ .ofmt = object_format,
104
+ };
105
+ pub const object_format = std.Target.ObjectFormat.macho;
106
+ pub const mode = std.builtin.Mode.Debug;
107
+ pub const link_libc = true;
108
+ pub const link_libcpp = false;
109
+ pub const have_error_return_tracing = true;
110
+ pub const valgrind_support = false;
111
+ pub const sanitize_thread = false;
112
+ pub const position_independent_code = true;
113
+ pub const position_independent_executable = true;
114
+ pub const strip_debug_info = false;
115
+ pub const code_model = std.builtin.CodeModel.default;
@@ -0,0 +1,4 @@
1
+ pub const imports = struct {
2
+ };
3
+ pub const build_root = struct {
4
+ };
@@ -0,0 +1,4 @@
1
+ pub const imports = struct {
2
+ };
3
+ pub const build_root = struct {
4
+ };