@onda-lang/webaudio 0.8.0 → 0.8.1

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 CHANGED
@@ -82,6 +82,8 @@ descriptor once and returns bound conversion methods.
82
82
 
83
83
  Controlled `i64` domains use the descriptor's exact binary64 integer range. Full-width unranged
84
84
  `i64` values continue to use `bigint` when written directly.
85
+ Event `i64` values accept bigint, safe integers, or decimal integer strings and reject values
86
+ outside the signed 64-bit range.
85
87
 
86
88
  The artifact must be compiled for exactly `audioContext.sampleRate`; the adapter rejects a mismatch
87
89
  before registering the node so sample-rate-derived language semantics cannot silently drift. A Web
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onda-lang/webaudio",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "type": "module",
5
5
  "description": "Optional Web Audio adapter for Onda processor WebAssembly artifacts",
6
6
  "license": "MIT",
@@ -34,7 +34,7 @@
34
34
  "prepack": "node ../../scripts/stage-web-api-docs.mjs"
35
35
  },
36
36
  "dependencies": {
37
- "@onda-lang/processor-abi": "0.8.0"
37
+ "@onda-lang/processor-abi": "0.8.1"
38
38
  },
39
39
  "publishConfig": {
40
40
  "access": "public"
package/src/worklet.js CHANGED
@@ -20,6 +20,23 @@ const PRINT_BATCH_SIZE_BYTES = 20;
20
20
  const EXECUTION_OUTPUT_SIZE_BYTES = 12;
21
21
  const HOST_LITTLE_ENDIAN = new Uint8Array(new Uint16Array([1]).buffer)[0] === 1;
22
22
 
23
+ function exactI64(value) {
24
+ let integer;
25
+ if (typeof value === "bigint") {
26
+ integer = value;
27
+ } else if (typeof value === "number" && Number.isSafeInteger(value)) {
28
+ integer = BigInt(value);
29
+ } else if (typeof value === "string" && /^-?[0-9]+$/.test(value)) {
30
+ integer = BigInt(value);
31
+ } else {
32
+ throw new TypeError("i64 value must be a bigint, safe integer, or decimal integer string");
33
+ }
34
+ if (BigInt.asIntN(64, integer) !== integer) {
35
+ throw new RangeError(`i64 value '${integer}' is outside the signed 64-bit range`);
36
+ }
37
+ return integer;
38
+ }
39
+
23
40
  class OndaWasmProcessor extends AudioWorkletProcessor {
24
41
  constructor(options) {
25
42
  super();
@@ -1230,7 +1247,7 @@ class OndaWasmProcessor extends AudioWorkletProcessor {
1230
1247
  }
1231
1248
  } else if (scalar === "i64") {
1232
1249
  for (let index = 0; index < length; index += 1) {
1233
- target[index] = BigInt(values[index]);
1250
+ target[index] = exactI64(values[index]);
1234
1251
  }
1235
1252
  } else {
1236
1253
  target.set(values);
@@ -1262,7 +1279,7 @@ class OndaWasmProcessor extends AudioWorkletProcessor {
1262
1279
  writeScalar(address, scalar, value, view = this.memoryView()) {
1263
1280
  if (scalar === "bool") view.setUint8(address, value ? 1 : 0);
1264
1281
  else if (scalar === "i32") view.setInt32(address, Number(value), true);
1265
- else if (scalar === "i64") view.setBigInt64(address, BigInt(value), true);
1282
+ else if (scalar === "i64") view.setBigInt64(address, exactI64(value), true);
1266
1283
  else if (scalar === "f32") view.setFloat32(address, Number(value), true);
1267
1284
  else if (scalar === "f64") view.setFloat64(address, Number(value), true);
1268
1285
  else throw new Error(`unsupported ABI scalar '${String(scalar)}'`);