@ac-kit/format-osc 0.0.0-stage → 0.1.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.
Files changed (84) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/LICENSE +28 -0
  3. package/README.md +132 -2
  4. package/dist/errors.d.ts +34 -0
  5. package/dist/errors.d.ts.map +1 -0
  6. package/dist/errors.js +40 -0
  7. package/dist/errors.js.map +1 -0
  8. package/dist/framing/_decode-framed-packet.d.ts +9 -0
  9. package/dist/framing/_decode-framed-packet.d.ts.map +1 -0
  10. package/dist/framing/_decode-framed-packet.js +23 -0
  11. package/dist/framing/_decode-framed-packet.js.map +1 -0
  12. package/dist/framing/osc-datagram-codec.d.ts +17 -0
  13. package/dist/framing/osc-datagram-codec.d.ts.map +1 -0
  14. package/dist/framing/osc-datagram-codec.js +21 -0
  15. package/dist/framing/osc-datagram-codec.js.map +1 -0
  16. package/dist/framing/osc-datagram-decoder.d.ts +22 -0
  17. package/dist/framing/osc-datagram-decoder.d.ts.map +1 -0
  18. package/dist/framing/osc-datagram-decoder.js +26 -0
  19. package/dist/framing/osc-datagram-decoder.js.map +1 -0
  20. package/dist/framing/osc-datagram-encoder.d.ts +8 -0
  21. package/dist/framing/osc-datagram-encoder.d.ts.map +1 -0
  22. package/dist/framing/osc-datagram-encoder.js +9 -0
  23. package/dist/framing/osc-datagram-encoder.js.map +1 -0
  24. package/dist/framing/osc-size-prefixed-codec.d.ts +19 -0
  25. package/dist/framing/osc-size-prefixed-codec.d.ts.map +1 -0
  26. package/dist/framing/osc-size-prefixed-codec.js +23 -0
  27. package/dist/framing/osc-size-prefixed-codec.js.map +1 -0
  28. package/dist/framing/osc-size-prefixed-decoder.d.ts +40 -0
  29. package/dist/framing/osc-size-prefixed-decoder.d.ts.map +1 -0
  30. package/dist/framing/osc-size-prefixed-decoder.js +59 -0
  31. package/dist/framing/osc-size-prefixed-decoder.js.map +1 -0
  32. package/dist/framing/osc-size-prefixed-encoder.d.ts +10 -0
  33. package/dist/framing/osc-size-prefixed-encoder.d.ts.map +1 -0
  34. package/dist/framing/osc-size-prefixed-encoder.js +20 -0
  35. package/dist/framing/osc-size-prefixed-encoder.js.map +1 -0
  36. package/dist/index.d.ts +14 -0
  37. package/dist/index.d.ts.map +1 -0
  38. package/dist/index.js +14 -0
  39. package/dist/index.js.map +1 -0
  40. package/dist/packet/_bundle-marker.d.ts +3 -0
  41. package/dist/packet/_bundle-marker.d.ts.map +1 -0
  42. package/dist/packet/_bundle-marker.js +3 -0
  43. package/dist/packet/_bundle-marker.js.map +1 -0
  44. package/dist/packet/_osc-writer.d.ts +31 -0
  45. package/dist/packet/_osc-writer.d.ts.map +1 -0
  46. package/dist/packet/_osc-writer.js +72 -0
  47. package/dist/packet/_osc-writer.js.map +1 -0
  48. package/dist/packet/_read-osc-packet.d.ts +19 -0
  49. package/dist/packet/_read-osc-packet.d.ts.map +1 -0
  50. package/dist/packet/_read-osc-packet.js +290 -0
  51. package/dist/packet/_read-osc-packet.js.map +1 -0
  52. package/dist/packet/_write-osc-packet.d.ts +12 -0
  53. package/dist/packet/_write-osc-packet.d.ts.map +1 -0
  54. package/dist/packet/_write-osc-packet.js +155 -0
  55. package/dist/packet/_write-osc-packet.js.map +1 -0
  56. package/dist/packet/decode-osc-packet.d.ts +48 -0
  57. package/dist/packet/decode-osc-packet.d.ts.map +1 -0
  58. package/dist/packet/decode-osc-packet.js +39 -0
  59. package/dist/packet/decode-osc-packet.js.map +1 -0
  60. package/dist/packet/encode-osc-packet.d.ts +32 -0
  61. package/dist/packet/encode-osc-packet.d.ts.map +1 -0
  62. package/dist/packet/encode-osc-packet.js +37 -0
  63. package/dist/packet/encode-osc-packet.js.map +1 -0
  64. package/dist/packet/osc-packet.d.ts +104 -0
  65. package/dist/packet/osc-packet.d.ts.map +1 -0
  66. package/dist/packet/osc-packet.js +2 -0
  67. package/dist/packet/osc-packet.js.map +1 -0
  68. package/dist/time-tag/_ntp.d.ts +13 -0
  69. package/dist/time-tag/_ntp.d.ts.map +1 -0
  70. package/dist/time-tag/_ntp.js +19 -0
  71. package/dist/time-tag/_ntp.js.map +1 -0
  72. package/dist/time-tag/osc-time-tag-from-date.d.ts +29 -0
  73. package/dist/time-tag/osc-time-tag-from-date.d.ts.map +1 -0
  74. package/dist/time-tag/osc-time-tag-from-date.js +48 -0
  75. package/dist/time-tag/osc-time-tag-from-date.js.map +1 -0
  76. package/dist/time-tag/osc-time-tag-to-date.d.ts +21 -0
  77. package/dist/time-tag/osc-time-tag-to-date.d.ts.map +1 -0
  78. package/dist/time-tag/osc-time-tag-to-date.js +26 -0
  79. package/dist/time-tag/osc-time-tag-to-date.js.map +1 -0
  80. package/dist/time-tag/osc-time-tag.d.ts +29 -0
  81. package/dist/time-tag/osc-time-tag.d.ts.map +1 -0
  82. package/dist/time-tag/osc-time-tag.js +16 -0
  83. package/dist/time-tag/osc-time-tag.js.map +1 -0
  84. package/package.json +60 -3
@@ -0,0 +1,20 @@
1
+ import { OscWriter_ } from "../packet/_osc-writer.js";
2
+ import { writeOscPacket_ } from "../packet/_write-osc-packet.js";
3
+ /**
4
+ * Creates the write half of OSC 1.0's stream framing: each packet preceded by
5
+ * its size as a big-endian int32, in one buffer.
6
+ *
7
+ * @throws {RangeError} From `encode`, as {@link encodeOscPacket}.
8
+ */
9
+ export function createOscSizePrefixedEncoder() {
10
+ return {
11
+ encode(packet) {
12
+ const writer = new OscWriter_();
13
+ const sizeOffset = writer.allocate(4);
14
+ writeOscPacket_(writer, packet);
15
+ writer.patchUint32(sizeOffset, writer.length - 4);
16
+ return writer.finish();
17
+ },
18
+ };
19
+ }
20
+ //# sourceMappingURL=osc-size-prefixed-encoder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"osc-size-prefixed-encoder.js","sourceRoot":"","sources":["../../src/framing/osc-size-prefixed-encoder.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAGjE;;;;;GAKG;AACH,MAAM,UAAU,4BAA4B;IAC3C,OAAO;QACN,MAAM,CAAC,MAAiB;YACvB,MAAM,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;YAChC,MAAM,UAAU,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;YACtC,eAAe,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YAChC,MAAM,CAAC,WAAW,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YAElD,OAAO,MAAM,CAAC,MAAM,EAAE,CAAC;QACxB,CAAC;KACD,CAAC;AACH,CAAC"}
@@ -0,0 +1,14 @@
1
+ export * from "./errors.js";
2
+ export * from "./framing/osc-datagram-codec.js";
3
+ export * from "./framing/osc-datagram-decoder.js";
4
+ export * from "./framing/osc-datagram-encoder.js";
5
+ export * from "./framing/osc-size-prefixed-codec.js";
6
+ export * from "./framing/osc-size-prefixed-decoder.js";
7
+ export * from "./framing/osc-size-prefixed-encoder.js";
8
+ export * from "./packet/decode-osc-packet.js";
9
+ export * from "./packet/encode-osc-packet.js";
10
+ export * from "./packet/osc-packet.js";
11
+ export * from "./time-tag/osc-time-tag-from-date.js";
12
+ export * from "./time-tag/osc-time-tag-to-date.js";
13
+ export * from "./time-tag/osc-time-tag.js";
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,iCAAiC,CAAC;AAChD,cAAc,mCAAmC,CAAC;AAClD,cAAc,mCAAmC,CAAC;AAClD,cAAc,sCAAsC,CAAC;AACrD,cAAc,wCAAwC,CAAC;AACvD,cAAc,wCAAwC,CAAC;AACvD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,wBAAwB,CAAC;AACvC,cAAc,sCAAsC,CAAC;AACrD,cAAc,oCAAoC,CAAC;AACnD,cAAc,4BAA4B,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,14 @@
1
+ export * from "./errors.js";
2
+ export * from "./framing/osc-datagram-codec.js";
3
+ export * from "./framing/osc-datagram-decoder.js";
4
+ export * from "./framing/osc-datagram-encoder.js";
5
+ export * from "./framing/osc-size-prefixed-codec.js";
6
+ export * from "./framing/osc-size-prefixed-decoder.js";
7
+ export * from "./framing/osc-size-prefixed-encoder.js";
8
+ export * from "./packet/decode-osc-packet.js";
9
+ export * from "./packet/encode-osc-packet.js";
10
+ export * from "./packet/osc-packet.js";
11
+ export * from "./time-tag/osc-time-tag-from-date.js";
12
+ export * from "./time-tag/osc-time-tag-to-date.js";
13
+ export * from "./time-tag/osc-time-tag.js";
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,iCAAiC,CAAC;AAChD,cAAc,mCAAmC,CAAC;AAClD,cAAc,mCAAmC,CAAC;AAClD,cAAc,sCAAsC,CAAC;AACrD,cAAc,wCAAwC,CAAC;AACvD,cAAc,wCAAwC,CAAC;AACvD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,wBAAwB,CAAC;AACvC,cAAc,sCAAsC,CAAC;AACrD,cAAc,oCAAoC,CAAC;AACnD,cAAc,4BAA4B,CAAC"}
@@ -0,0 +1,3 @@
1
+ /** `#bundle` and its NUL terminator: the first 8 bytes of every OSC bundle. */
2
+ export declare const BUNDLE_MARKER_: Uint8Array<ArrayBuffer>;
3
+ //# sourceMappingURL=_bundle-marker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_bundle-marker.d.ts","sourceRoot":"","sources":["../../src/packet/_bundle-marker.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,eAAO,MAAM,cAAc,yBAS1B,CAAC"}
@@ -0,0 +1,3 @@
1
+ /** `#bundle` and its NUL terminator: the first 8 bytes of every OSC bundle. */
2
+ export const BUNDLE_MARKER_ = Uint8Array.of(0x23, 0x62, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x00);
3
+ //# sourceMappingURL=_bundle-marker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_bundle-marker.js","sourceRoot":"","sources":["../../src/packet/_bundle-marker.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,CAAC,EAAE,CAC1C,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,CACJ,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * A growable big-endian byte buffer for the OSC encoder.
3
+ *
4
+ * Doubling growth keeps a whole packet at one amortised O(n) copy. The size of
5
+ * a bundle element is only known once it is written, so its prefix is reserved
6
+ * and patched afterwards rather than measured in a separate pass that would
7
+ * have to agree with this one.
8
+ *
9
+ * Bytes past `length` are never written before they are allocated, so every
10
+ * allocation arrives zeroed and padding needs no explicit write.
11
+ */
12
+ export declare class OscWriter_ {
13
+ private bytes;
14
+ private length_;
15
+ get length(): number;
16
+ /** Reserves `count` bytes and returns their offset. */
17
+ allocate(count: number): number;
18
+ writeUint32(value: number): void;
19
+ writeUint64(value: bigint): void;
20
+ writeFloat32(value: number): void;
21
+ writeFloat64(value: number): void;
22
+ writeBytes4(byte0: number, byte1: number, byte2: number, byte3: number): void;
23
+ patchUint32(offset: number, value: number): void;
24
+ /**
25
+ * Writes `data`, then `terminator` NUL bytes, then NUL bytes up to the next
26
+ * multiple of 4: an OSC-string with `terminator` 1, a blob's data with 0.
27
+ */
28
+ writePadded(data: Uint8Array, terminator: 0 | 1): void;
29
+ finish(): Uint8Array<ArrayBuffer>;
30
+ }
31
+ //# sourceMappingURL=_osc-writer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_osc-writer.d.ts","sourceRoot":"","sources":["../../src/packet/_osc-writer.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;GAUG;AACH,qBAAa,UAAU;IACtB,OAAO,CAAC,KAAK,CAAsB;IAEnC,OAAO,CAAC,OAAO,CAAK;IAEpB,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED,uDAAuD;IACvD,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAW9B;IAID,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAG/B;IAED,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAG/B;IAED,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAGhC;IAED,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAGhC;IAED,WAAW,CACV,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,GACX,IAAI,CAMN;IAED,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAE/C;IAED;;;OAGG;IACH,WAAW,CAAC,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC,GAAG,CAAC,GAAG,IAAI,CAIrD;IAED,MAAM,IAAI,UAAU,CAAC,WAAW,CAAC,CAEhC;CACD"}
@@ -0,0 +1,72 @@
1
+ import { setBigUint64Be, setFloat32Be, setFloat64Be, setUint32Be, } from "@ac-kit/core";
2
+ /**
3
+ * A growable big-endian byte buffer for the OSC encoder.
4
+ *
5
+ * Doubling growth keeps a whole packet at one amortised O(n) copy. The size of
6
+ * a bundle element is only known once it is written, so its prefix is reserved
7
+ * and patched afterwards rather than measured in a separate pass that would
8
+ * have to agree with this one.
9
+ *
10
+ * Bytes past `length` are never written before they are allocated, so every
11
+ * allocation arrives zeroed and padding needs no explicit write.
12
+ */
13
+ export class OscWriter_ {
14
+ bytes = new Uint8Array(64);
15
+ length_ = 0;
16
+ get length() {
17
+ return this.length_;
18
+ }
19
+ /** Reserves `count` bytes and returns their offset. */
20
+ allocate(count) {
21
+ const offset = this.length_;
22
+ const needed = offset + count;
23
+ if (needed > this.bytes.length) {
24
+ const grown = new Uint8Array(Math.max(needed, this.bytes.length * 2));
25
+ grown.set(this.bytes.subarray(0, offset));
26
+ this.bytes = grown;
27
+ }
28
+ this.length_ = needed;
29
+ return offset;
30
+ }
31
+ // Each write allocates first: `allocate` may replace `bytes`, so reading the
32
+ // field in the same argument list as the call would write to the old buffer.
33
+ writeUint32(value) {
34
+ const offset = this.allocate(4);
35
+ setUint32Be(this.bytes, offset, value);
36
+ }
37
+ writeUint64(value) {
38
+ const offset = this.allocate(8);
39
+ setBigUint64Be(this.bytes, offset, value);
40
+ }
41
+ writeFloat32(value) {
42
+ const offset = this.allocate(4);
43
+ setFloat32Be(this.bytes, offset, value);
44
+ }
45
+ writeFloat64(value) {
46
+ const offset = this.allocate(8);
47
+ setFloat64Be(this.bytes, offset, value);
48
+ }
49
+ writeBytes4(byte0, byte1, byte2, byte3) {
50
+ const offset = this.allocate(4);
51
+ this.bytes[offset] = byte0;
52
+ this.bytes[offset + 1] = byte1;
53
+ this.bytes[offset + 2] = byte2;
54
+ this.bytes[offset + 3] = byte3;
55
+ }
56
+ patchUint32(offset, value) {
57
+ setUint32Be(this.bytes, offset, value);
58
+ }
59
+ /**
60
+ * Writes `data`, then `terminator` NUL bytes, then NUL bytes up to the next
61
+ * multiple of 4: an OSC-string with `terminator` 1, a blob's data with 0.
62
+ */
63
+ writePadded(data, terminator) {
64
+ // Arithmetic, not `& ~3`, which wraps for a blob near 2^31 bytes.
65
+ const offset = this.allocate(Math.ceil((data.length + terminator) / 4) * 4);
66
+ this.bytes.set(data, offset);
67
+ }
68
+ finish() {
69
+ return this.bytes.slice(0, this.length_);
70
+ }
71
+ }
72
+ //# sourceMapp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AAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC9B,CAAC;IAED,MAAM;QACL,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;CACD"}
@@ -0,0 +1,19 @@
1
+ import type { OscPacket } from "./osc-packet.js";
2
+ /** Resolves and validates the `maxDepth` decode option. */
3
+ export declare function resolveMaxDepth_(maxDepth: number | undefined): number;
4
+ /**
5
+ * Decodes the whole of `bytes` as one OSC packet — the single implementation of
6
+ * the OSC read grammar, OSC 1.0 §"OSC Packets" through §"OSC Bundles", with the
7
+ * OSC 1.1 type tags.
8
+ *
9
+ * Every read is bounds-checked against the end of the enclosing packet or
10
+ * bundle element before it happens, so a hostile size can make it throw but
11
+ * never read past `bytes` or allocate more than `bytes` holds. Bundles recurse,
12
+ * at most `maxDepth` deep; arrays are walked iteratively against the same
13
+ * bound. Time is O(n) in `bytes.length`; memory is O(n) for the result plus
14
+ * O(maxDepth) of stack.
15
+ *
16
+ * @throws {OscPacketError} On any malformed input, with the offset in `bytes`.
17
+ */
18
+ export declare function readOscPacket_(bytes: Uint8Array, maxDepth: number): OscPacket;
19
+ //# sourceMappingURL=_read-osc-packet.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_read-osc-packet.d.ts","sourceRoot":"","sources":["../../src/packet/_read-osc-packet.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAIX,SAAS,EACT,MAAM,iBAAiB,CAAC;AAazB,2DAA2D;AAC3D,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAWrE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,GAAG,SAAS,CAE7E"}
@@ -0,0 +1,290 @@
1
+ import { ByteReader, bytesIsEqual, COMMA, decodeText, getBigUint64Be, getFloat32Be, getFloat64Be, getUint32Be, HASH, LEFT_SQUARE_BRACKET, NUL, RIGHT_SQUARE_BRACKET, SLASH, } from "@ac-kit/core";
2
+ import { OscPacketError } from "../errors.js";
3
+ import { BUNDLE_MARKER_ } from "./_bundle-marker.js";
4
+ /**
5
+ * Default bound on nested bundles and arrays together.
6
+ *
7
+ * Bundles recurse on the call stack, and a 64 KiB datagram could otherwise nest
8
+ * about 4,000 of them, or 65,000 arrays in a type tag string; no OSC
9
+ * implementation in use sends more than two or three levels. 32 leaves an order
10
+ * of magnitude of headroom for real traffic while keeping a hostile packet far
11
+ * below any engine's stack limit.
12
+ */
13
+ const DEFAULT_MAX_DEPTH_ = 32;
14
+ /** Resolves and validates the `maxDepth` decode option. */
15
+ export function resolveMaxDepth_(maxDepth) {
16
+ if (maxDepth === undefined) {
17
+ return DEFAULT_MAX_DEPTH_;
18
+ }
19
+ if (!Number.isInteger(maxDepth) || maxDepth < 0) {
20
+ throw new RangeError(`maxDepth must be a non-negative integer, got ${maxDepth}`);
21
+ }
22
+ return maxDepth;
23
+ }
24
+ /**
25
+ * Decodes the whole of `bytes` as one OSC packet — the single implementation of
26
+ * the OSC read grammar, OSC 1.0 §"OSC Packets" through §"OSC Bundles", with the
27
+ * OSC 1.1 type tags.
28
+ *
29
+ * Every read is bounds-checked against the end of the enclosing packet or
30
+ * bundle element before it happens, so a hostile size can make it throw but
31
+ * never read past `bytes` or allocate more than `bytes` holds. Bundles recurse,
32
+ * at most `maxDepth` deep; arrays are walked iteratively against the same
33
+ * bound. Time is O(n) in `bytes.length`; memory is O(n) for the result plus
34
+ * O(maxDepth) of stack.
35
+ *
36
+ * @throws {OscPacketError} On any malformed input, with the offset in `bytes`.
37
+ */
38
+ export function readOscPacket_(bytes, maxDepth) {
39
+ return readPacket_(new ByteReader(bytes), bytes.length, 0, maxDepth);
40
+ }
41
+ /**
42
+ * Reads the packet occupying `[reader.position, end)`; `depth` is the number of
43
+ * bundles enclosing it.
44
+ */
45
+ function readPacket_(reader, end, depth, maxDepth) {
46
+ const start = reader.position;
47
+ const size = end - start;
48
+ if (size === 0) {
49
+ throw new OscPacketError("Empty OSC packet", start);
50
+ }
51
+ if (size % 4 !== 0) {
52
+ throw new OscPacketError(`OSC packet size ${size} is not a multiple of 4`, start);
53
+ }
54
+ const first = reader.peekByte();
55
+ if (first === SLASH) {
56
+ return readMessage_(reader, end, depth, maxDepth);
57
+ }
58
+ if (first === HASH) {
59
+ return readBundle_(reader, end, depth, maxDepth);
60
+ }
61
+ throw new OscPacketError('OSC packet begins with neither "/" nor "#bundle"', start);
62
+ }
63
+ function readBundle_(reader, end, depth, maxDepth) {
64
+ const start = reader.position;
65
+ if (depth >= maxDepth) {
66
+ throw new OscPacketError(`Bundle nesting exceeds maxDepth ${maxDepth}`, start);
67
+ }
68
+ need_(reader, end, 16, "bundle header");
69
+ if (!bytesIsEqual(reader.read(8), BUNDLE_MARKER_)) {
70
+ throw new OscPacketError('Expected "#bundle"', start);
71
+ }
72
+ const timeTag = reader.read(8);
73
+ const elements = [];
74
+ while (reader.position < end) {
75
+ const sizeOffset = reader.position;
76
+ need_(reader, end, 4, "bundle element size");
77
+ const size = getUint32Be(reader.read(4), 0) | 0;
78
+ if (size < 0 || size > end - reader.position) {
79
+ throw new OscPacketError(`Bundle element size ${size} does not fit the ${end - reader.position} bytes left in its bundle`, sizeOffset);
80
+ }
81
+ elements.push(readPacket_(reader, reader.position + size, depth + 1, maxDepth));
82
+ }
83
+ return {
84
+ kind: "bundle",
85
+ timeTag: {
86
+ seconds: getUint32Be(timeTag, 0),
87
+ fraction: getUint32Be(timeTag, 4),
88
+ },
89
+ elements,
90
+ };
91
+ }
92
+ function readMessage_(reader, end, depth, maxDepth) {
93
+ const address = readText_(reader, end, "address");
94
+ // OSC 1.0 asks receivers to accept a message from an older sender that has
95
+ // no type tag string; only one with nothing after its address can be read
96
+ // without guessing the types of what follows.
97
+ if (reader.position === end) {
98
+ return { kind: "message", address, arguments: [] };
99
+ }
100
+ if (reader.peekByte() !== COMMA) {
101
+ throw new OscPacketError('Expected a type tag string beginning with ","', reader.position);
102
+ }
103
+ const tagsOffset = reader.position;
104
+ const tags = readStringBytes_(reader, end, "type tag string");
105
+ const root = [];
106
+ const stack = [root];
107
+ for (let index = 1; index < tags.length; index++) {
108
+ const tag = tags[index];
109
+ const tagOffset = tagsOffset + index;
110
+ // `stack` always holds at least `root`.
111
+ const items = stack[stack.length - 1];
112
+ if (tag === LEFT_SQUARE_BRACKET) {
113
+ if (depth + stack.length > maxDepth) {
114
+ throw new OscPacketError(`Array nesting exceeds maxDepth ${maxDepth}`, tagOffset);
115
+ }
116
+ const nested = [];
117
+ items.push({ type: "array", items: nested });
118
+ stack.push(nested);
119
+ continue;
120
+ }
121
+ if (tag === RIGHT_SQUARE_BRACKET) {
122
+ if (stack.length === 1) {
123
+ throw new OscPacketError('Unmatched "]" in type tag string', tagOffset);
124
+ }
125
+ stack.pop();
126
+ continue;
127
+ }
128
+ items.push(readArgument_(reader, end, tag, tagOffset));
129
+ }
130
+ if (stack.length > 1) {
131
+ throw new OscPacketError('Unclosed "[" in type tag string', tagsOffset);
132
+ }
133
+ if (reader.position !== end) {
134
+ throw new OscPacketError(`${end - reader.position} bytes follow the last argument`, reader.position);
135
+ }
136
+ return { kind: "message", address, arguments: root };
137
+ }
138
+ function readArgument_(reader, end, tag, tagOffset) {
139
+ const tagChar = String.fromCharCode(tag);
140
+ switch (tagChar) {
141
+ case "i":
142
+ need_(reader, end, 4, "int32");
143
+ return { type: "int32", value: getUint32Be(reader.read(4), 0) | 0 };
144
+ case "f":
145
+ need_(reader, end, 4, "float32");
146
+ return { type: "float32", value: getFloat32Be(reader.read(4), 0) };
147
+ case "s":
148
+ return { type: "string", value: readText_(reader, end, "string") };
149
+ case "S":
150
+ return { type: "symbol", value: readText_(reader, end, "symbol") };
151
+ case "b":
152
+ return { type: "blob", value: readBlob_(reader, end) };
153
+ case "h":
154
+ need_(reader, end, 8, "int64");
155
+ return {
156
+ type: "int64",
157
+ value: BigInt.asIntN(64, getBigUint64Be(reader.read(8), 0)),
158
+ };
159
+ case "t": {
160
+ need_(reader, end, 8, "timeTag");
161
+ const field = reader.read(8);
162
+ return {
163
+ type: "timeTag",
164
+ value: {
165
+ seconds: getUint32Be(field, 0),
166
+ fraction: getUint32Be(field, 4),
167
+ },
168
+ };
169
+ }
170
+ case "d":
171
+ need_(reader, end, 8, "float64");
172
+ return { type: "float64", value: getFloat64Be(reader.read(8), 0) };
173
+ case "c":
174
+ return { type: "char", value: readChar_(reader, end) };
175
+ case "r": {
176
+ need_(reader, end, 4, "rgba");
177
+ const field = reader.read(4);
178
+ return {
179
+ type: "rgba",
180
+ red: field[0],
181
+ green: field[1],
182
+ blue: field[2],
183
+ alpha: field[3],
184
+ };
185
+ }
186
+ case "m": {
187
+ need_(reader, end, 4, "midi");
188
+ const field = reader.read(4);
189
+ return {
190
+ type: "midi",
191
+ port: field[0],
192
+ status: field[1],
193
+ data1: field[2],
194
+ data2: field[3],
195
+ };
196
+ }
197
+ case "T":
198
+ return { type: "true" };
199
+ case "F":
200
+ return { type: "false" };
201
+ case "N":
202
+ return { type: "nil" };
203
+ case "I":
204
+ return { type: "impulse" };
205
+ default:
206
+ throw new OscPacketError(`Unknown type tag 0x${tag.toString(16).padStart(2, "0")}`, tagOffset);
207
+ }
208
+ }
209
+ function readChar_(reader, end) {
210
+ const start = reader.position;
211
+ need_(reader, end, 4, "char");
212
+ const codePoint = getUint32Be(reader.read(4), 0);
213
+ if (codePoint > 0x10ffff || (codePoint >= 0xd800 && codePoint <= 0xdfff)) {
214
+ throw new OscPacketError(`char 0x${codePoint.toString(16)} is not a Unicode scalar value`, start);
215
+ }
216
+ return String.fromCodePoint(codePoint);
217
+ }
218
+ /** Reads a blob: an int32 size, the bytes, and NUL padding to a multiple of 4. */
219
+ function readBlob_(reader, end) {
220
+ const start = reader.position;
221
+ need_(reader, end, 4, "blob size");
222
+ const size = getUint32Be(reader.read(4), 0) | 0;
223
+ if (size < 0) {
224
+ throw new OscPacketError(`Negative blob size ${size}`, start);
225
+ }
226
+ const padded = roundUp4_(size);
227
+ if (padded > end - reader.position) {
228
+ throw new OscPacketError(`Truncated blob: needs ${padded} bytes, ${end - reader.position} remain`, start);
229
+ }
230
+ const field = reader.read(padded);
231
+ checkPadding_(field, size, start + 4, "blob");
232
+ // Copy: the input is a caller's or a driver's buffer and may be reused.
233
+ return field.slice(0, size);
234
+ }
235
+ /** Reads an OSC-string as UTF-8. */
236
+ function readText_(reader, end, what) {
237
+ const start = reader.position;
238
+ const bytes = readStringBytes_(reader, end, what);
239
+ try {
240
+ return decodeText(bytes, "utf-8", { fatal: true, ignoreBOM: true });
241
+ }
242
+ catch (error) {
243
+ throw new OscPacketError(`Invalid UTF-8 in ${what}`, start, {
244
+ cause: error,
245
+ });
246
+ }
247
+ }
248
+ /**
249
+ * Reads an OSC-string — bytes, a NUL, and NUL padding to a multiple of 4 — and
250
+ * returns the bytes before the terminator as a view into the input.
251
+ */
252
+ function readStringBytes_(reader, end, what) {
253
+ const start = reader.position;
254
+ const length = reader
255
+ .peekRemaining()
256
+ .subarray(0, end - start)
257
+ .indexOf(NUL);
258
+ if (length === -1) {
259
+ throw new OscPacketError(`Unterminated ${what}`, start);
260
+ }
261
+ const padded = roundUp4_(length + 1);
262
+ if (padded > end - start) {
263
+ throw new OscPacketError(`Truncated ${what} padding`, start + length + 1);
264
+ }
265
+ const field = reader.read(padded);
266
+ checkPadding_(field, length + 1, start, what);
267
+ return field.subarray(0, length);
268
+ }
269
+ /**
270
+ * Padding is checked strictly: every OSC implementation pads with NUL, so any
271
+ * other byte means the packet is misframed, not merely untidy.
272
+ */
273
+ function checkPadding_(field, from, fieldOffset, what) {
274
+ for (let index = from; index < field.length; index++) {
275
+ if (field[index] !== NUL) {
276
+ throw new OscPacketError(`Non-zero padding byte after ${what}`, fieldOffset + index);
277
+ }
278
+ }
279
+ }
280
+ function need_(reader, end, count, what) {
281
+ const remaining = end - reader.position;
282
+ if (remaining < count) {
283
+ throw new OscPacketError(`Truncated ${what}: needs ${count} bytes, ${remaining} remain`, reader.position);
284
+ }
285
+ }
286
+ /** Bitwise `& ~3` would wrap above 2^31; a blob size may reach 2^31 − 1. */
287
+ function roundUp4_(value) {
288
+ return Math.ceil(value / 4) * 4;
289
+ }
290
+ //# sourceMappingURL=_read-osc-packet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_read-osc-packet.js","sourceRoot":"","sources":["../../src/packet/_read-osc-packet.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,UAAU,EACV,YAAY,EACZ,KAAK,EACL,UAAU,EACV,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,IAAI,EACJ,mBAAmB,EACnB,GAAG,EACH,oBAAoB,EACpB,KAAK,GACL,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAQrD;;;;;;;;GAQG;AACH,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAE9B,2DAA2D;AAC3D,MAAM,UAAU,gBAAgB,CAAC,QAA4B;IAC5D,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC5B,OAAO,kBAAkB,CAAC;IAC3B,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,QAAQ,GAAG,CAAC,EAAE,CAAC;QACjD,MAAM,IAAI,UAAU,CACnB,gDAAgD,QAAQ,EAAE,CAC1D,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAC;AACjB,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,cAAc,CAAC,KAAiB,EAAE,QAAgB;IACjE,OAAO,WAAW,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAC;AAC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C,QAAQ,CACf,CAAC;IACH,CAAC;AACF,CAAC;AAED,4EAA4E;AAC5E,SAAS,SAAS,CAAC,KAAa;IAC/B,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;AACjC,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { OscWriter_ } from "./_osc-writer.js";
2
+ import type { OscPacket } from "./osc-packet.js";
3
+ /**
4
+ * Appends `packet` to `writer` — the single implementation of the OSC write
5
+ * grammar, OSC 1.0 §"OSC Packets" through §"OSC Bundles".
6
+ *
7
+ * A type tag string is always written, `,` alone for no arguments, as OSC 1.1
8
+ * requires. Recursion depth is the caller's own nesting; nothing here bounds
9
+ * it.
10
+ */
11
+ export declare function writeOscPacket_(writer: OscWriter_, packet: OscPacket): void;
12
+ //# sourceMappingURL=_write-osc-packet.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_write-osc-packet.d.ts","sourceRoot":"","sources":["../../src/packet/_write-osc-packet.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAe,SAAS,EAAE,MAAM,iBAAiB,CAAC;AA0B9D;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,GAAG,IAAI,CAuB3E"}