diff --git a/zenoh-ts/examples/chat/src/chat_session.ts b/zenoh-ts/examples/chat/src/chat_session.ts index ba04660..954705d 100644 --- a/zenoh-ts/examples/chat/src/chat_session.ts +++ b/zenoh-ts/examples/chat/src/chat_session.ts @@ -1,4 +1,4 @@ -import { Config, Session, Queryable, Query, Liveliness, LivelinessToken, Reply, Sample, Receiver, KeyExpr, Subscriber, SampleKind, Publisher, deserialize_string } from '@eclipse-zenoh/zenoh-ts'; +import { Config, Session, Queryable, Query, Liveliness, LivelinessToken, Reply, Sample, Receiver, KeyExpr, Subscriber, SampleKind, Publisher } from '@eclipse-zenoh/zenoh-ts'; export function validate_username(username: string): boolean { return /^[a-zA-Z0-9_-]+$/.test(username); @@ -96,8 +96,8 @@ export class ChatSession { if (reply instanceof Reply) { let resp = reply.result(); if (resp instanceof Sample) { - let payload = deserialize_string(resp.payload().to_bytes()); - let attachment = deserialize_string(resp.attachment()?.to_bytes() ?? Uint8Array.from([])); + let payload = resp.payload().to_string(); + let attachment = resp.attachment()?.to_string() ?? ""; log(`[Session] GetSuccess from ${resp.keyexpr().toString()}, messages: ${payload}, from user: ${attachment}`); this.messages = JSON.parse(payload); } @@ -123,7 +123,7 @@ export class ChatSession { this.message_subscriber = await this.session.declare_subscriber(KEYEXPR_CHAT_USER.join("*"), { handler: (sample: Sample) => { - let message = deserialize_string(sample.payload().to_bytes()); + let message = sample.payload().to_string(); log(`[Subscriber] Received message: ${message} from ${sample.keyexpr().toString()}`); let user = ChatUser.fromKeyexpr(sample.keyexpr()); if (user) { diff --git a/zenoh-ts/examples/chat/yarn.lock b/zenoh-ts/examples/chat/yarn.lock index d0996d5..840001c 100644 --- a/zenoh-ts/examples/chat/yarn.lock +++ b/zenoh-ts/examples/chat/yarn.lock @@ -8,8 +8,9 @@ integrity sha512-dBVuXR082gk3jsFp7Rd/JI4kytwGHecnCoTtXFb7DB6CNHp4rg5k1bhg0nWdLGLnOV71lmDzGQaLMy8iPLY0pw== "@eclipse-zenoh/zenoh-ts@file:../..": - version "1.0.3" + version "1.1.1" dependencies: + "@thi.ng/leb128" "^3.1.36" base64-arraybuffer "^1.0.2" channel-ts "^0.1.2" eslint "^9.10.0" @@ -146,6 +147,141 @@ "@jridgewell/resolve-uri" "^3.1.0" "@jridgewell/sourcemap-codec" "^1.4.14" +"@thi.ng/api@^8.11.19": + version "8.11.19" + resolved "https://registry.yarnpkg.com/@thi.ng/api/-/api-8.11.19.tgz#9ce8eb5657a28ddbd82a1864792b59a753a4ee33" + integrity sha512-ffK8nyNDd3kiwiijpb0Uv/0MtRUYpRtJj3K8OwFXdCzboll+/DNvXpfAlBMwSkLqZR0GighDwApyl0/4njiHCg== + +"@thi.ng/arrays@^2.10.14": + version "2.10.14" + resolved "https://registry.yarnpkg.com/@thi.ng/arrays/-/arrays-2.10.14.tgz#a6202d3e208e2930554083b24c8a7143e23e8d56" + integrity sha512-hTuot92azDcX/GbWIFtbrKEPTThQn9tlRqKAnGL0xerCXEvHlvJ9F2zgf/crhBt8vcP8ca/P+4xYJYLKa54iBw== + dependencies: + "@thi.ng/api" "^8.11.19" + "@thi.ng/checks" "^3.6.22" + "@thi.ng/compare" "^2.4.11" + "@thi.ng/equiv" "^2.1.75" + "@thi.ng/errors" "^2.5.25" + "@thi.ng/random" "^4.1.10" + +"@thi.ng/binary@^3.4.42": + version "3.4.42" + resolved "https://registry.yarnpkg.com/@thi.ng/binary/-/binary-3.4.42.tgz#2fdd71c7c06d9bfb38bd94b71598343ccf8d89a9" + integrity sha512-DU5JiBOONjx4synwos2GPaq8ByIfPSx6H6BsBmTf/Ou1PiABMlFuHlz8aOzw/Z1jUTYzb04arwUpYl1MVKjrAg== + dependencies: + "@thi.ng/api" "^8.11.19" + +"@thi.ng/checks@^3.6.22": + version "3.6.22" + resolved "https://registry.yarnpkg.com/@thi.ng/checks/-/checks-3.6.22.tgz#00b3c6e4f8562f4108795b645a97cfc588c7cdcd" + integrity sha512-CMxQHrxvHnAVnmhxfP44GVS1TmAUWLsX8uZTVrL4IQcWzVVyHgvD6uXYw5E7kaZCR2S6wnS+Ng5oOCBE0EU/Hg== + dependencies: + tslib "^2.8.1" + +"@thi.ng/compare@^2.4.11": + version "2.4.11" + resolved "https://registry.yarnpkg.com/@thi.ng/compare/-/compare-2.4.11.tgz#63cf4bebcd15575265f68bcf85d9b61c953c9cf6" + integrity sha512-SNbRrf19ntPmpXVkdMK04ZRRSDzPmRxxV9WKdH6+3J5NkYbASffi9o9WWun9In09P1+/Zh5yYfi2LzNsIDHNDw== + dependencies: + "@thi.ng/api" "^8.11.19" + +"@thi.ng/compose@^3.0.22": + version "3.0.22" + resolved "https://registry.yarnpkg.com/@thi.ng/compose/-/compose-3.0.22.tgz#a7b4f4927fd896c0e37a797c8f2a2aa1f7a14271" + integrity sha512-PdXT/X4Ca8VfzyGryhAlw7PYyPvbRhpFqT4hej2oOgGuXeifoNr2J6WejTEwK8wA4F57onHHr7TisPVNfN/PMQ== + dependencies: + "@thi.ng/api" "^8.11.19" + "@thi.ng/errors" "^2.5.25" + +"@thi.ng/equiv@^2.1.75": + version "2.1.75" + resolved "https://registry.yarnpkg.com/@thi.ng/equiv/-/equiv-2.1.75.tgz#f6fa49df08c1fd17da1302e057f1809cea3b5cb2" + integrity sha512-AoQQgrhW0xtXgxkrDK5EP5Y9Fe/QBGCmQgVKJ2G7uYCW/IbN/nTZEUM6011v41ydpmKl4wJjmr+s3StcIeDfdQ== + +"@thi.ng/errors@^2.5.25": + version "2.5.25" + resolved "https://registry.yarnpkg.com/@thi.ng/errors/-/errors-2.5.25.tgz#4a9b91fbe51413b151d3758bdf6ef7e53cbc2d1f" + integrity sha512-PmK56hWGvRWr9Eq0V5xkV4tQvhjPtfvv6urFONP/D0gwFQXj+v6rcDYkAFLzOkbLqa0DYtkgvUsMklF/L53upA== + +"@thi.ng/hex@^2.3.63": + version "2.3.63" + resolved "https://registry.yarnpkg.com/@thi.ng/hex/-/hex-2.3.63.tgz#75f91f6e4d4dec22046a74526b30f81d32d138f4" + integrity sha512-5xaQEKdaPls8de4zx4piPjCP13AHZLlyJCwHp4enSfeH5ZmDR3/aRwbmJod4FlJAvQdvDa3jBz+OtHNdxwrPLg== + +"@thi.ng/leb128@^3.1.36": + version "3.1.36" + resolved "https://registry.yarnpkg.com/@thi.ng/leb128/-/leb128-3.1.36.tgz#9516fe5113d030a617039da3c8f5361d62185940" + integrity sha512-NfEfBpjtOwGJxgxDXyuLYxfmikT8u7TPT3J1rc51JmScxtTXZQkpgR3ORwy/xshILmGVMID2vww3NshZbSHqZg== + dependencies: + "@thi.ng/checks" "^3.6.22" + "@thi.ng/errors" "^2.5.25" + "@thi.ng/transducers-binary" "^2.1.152" + +"@thi.ng/math@^5.11.19": + version "5.11.19" + resolved "https://registry.yarnpkg.com/@thi.ng/math/-/math-5.11.19.tgz#0a0ff7ad249f2960fcc3b39f930568d4a19a2b35" + integrity sha512-nsS1hP0rtgfuLtD6fLEtNTv07DlPZjKlgRoTrJcpkr47zzGcabwxo7a2VlHYFjhnShVUVSdQTFCnSSHN40drOQ== + dependencies: + "@thi.ng/api" "^8.11.19" + +"@thi.ng/memoize@^4.0.9": + version "4.0.9" + resolved "https://registry.yarnpkg.com/@thi.ng/memoize/-/memoize-4.0.9.tgz#57ab73ed0e7ff98df94c7182a703b0dbd6edf8c3" + integrity sha512-YQD5lOew7mAZRripl3ylyOOq0OJ7yv/9D2o9w0Rd3ZrL2nl49tbticcH0V6nSKHEJhJSeRftCjmxNXNZulZkBw== + dependencies: + "@thi.ng/api" "^8.11.19" + +"@thi.ng/random@^4.1.10": + version "4.1.10" + resolved "https://registry.yarnpkg.com/@thi.ng/random/-/random-4.1.10.tgz#732bae76ffb397ca42e771bbe94f6c8c2fbd815a" + integrity sha512-BBEAr0fg0pDoHtk4iBsdyLfZ9HcGvzeOwdAiXb3iibPhCL+h4lpjpmxy8yCyD7CatlnUICfbDdiY59X5qKJMgA== + dependencies: + "@thi.ng/api" "^8.11.19" + "@thi.ng/errors" "^2.5.25" + +"@thi.ng/strings@^3.9.4": + version "3.9.4" + resolved "https://registry.yarnpkg.com/@thi.ng/strings/-/strings-3.9.4.tgz#782bbf81ea441c0d2671ca54654cf4c639762879" + integrity sha512-Ut9Elrp5HHiQjtJALjqKljzhDZYEgVMgwjN3EuEgHwBcrtvgthuhK6gKf2cGr0O8sqIjcctnhWqu7nE4QLuVaQ== + dependencies: + "@thi.ng/api" "^8.11.19" + "@thi.ng/errors" "^2.5.25" + "@thi.ng/hex" "^2.3.63" + "@thi.ng/memoize" "^4.0.9" + +"@thi.ng/timestamp@^1.1.4": + version "1.1.4" + resolved "https://registry.yarnpkg.com/@thi.ng/timestamp/-/timestamp-1.1.4.tgz#6800c1fd8f9fc349e3d601a445707f52f1fc7d97" + integrity sha512-Rsfa1ypD3Ulkh2RDbj19hb8hCXRzUjy+1gpbovy2Bnys7VPNXRyHEaEZvqRNzj+jTzylvFNbi8QLArX7RXzeqw== + +"@thi.ng/transducers-binary@^2.1.152": + version "2.1.152" + resolved "https://registry.yarnpkg.com/@thi.ng/transducers-binary/-/transducers-binary-2.1.152.tgz#320c4875f73ce31e9bcca5b2481ef5e4365636a8" + integrity sha512-0QG5cTheIZGcIaDDsaCaSSYvDXhFqbmdFng8HNLzl5EIcSecRC0R3rT7N0SxN+JxGMDRmZFQk/vFHlqulxaTew== + dependencies: + "@thi.ng/binary" "^3.4.42" + "@thi.ng/compose" "^3.0.22" + "@thi.ng/errors" "^2.5.25" + "@thi.ng/hex" "^2.3.63" + "@thi.ng/random" "^4.1.10" + "@thi.ng/strings" "^3.9.4" + "@thi.ng/transducers" "^9.2.17" + +"@thi.ng/transducers@^9.2.17": + version "9.2.17" + resolved "https://registry.yarnpkg.com/@thi.ng/transducers/-/transducers-9.2.17.tgz#8504f45178c3875841c9afcb9dcd68a3966c4b22" + integrity sha512-LjbAbRAcpHi0gv6aW7+5ijJYJjhQtJoszEvjCC025RQ3pjXXD3gkRs8nnJULk6ibkcEcCoP5Q0WBWNAXusInQg== + dependencies: + "@thi.ng/api" "^8.11.19" + "@thi.ng/arrays" "^2.10.14" + "@thi.ng/checks" "^3.6.22" + "@thi.ng/compare" "^2.4.11" + "@thi.ng/compose" "^3.0.22" + "@thi.ng/errors" "^2.5.25" + "@thi.ng/math" "^5.11.19" + "@thi.ng/random" "^4.1.10" + "@thi.ng/timestamp" "^1.1.4" + "@types/eslint-scope@^3.7.7": version "3.7.7" resolved "https://registry.yarnpkg.com/@types/eslint-scope/-/eslint-scope-3.7.7.tgz#3108bd5f18b0cdb277c867b3dd449c9ed7079ac5" @@ -1568,6 +1704,11 @@ ts-loader@^9.2.6: semver "^7.3.4" source-map "^0.7.4" +tslib@^2.8.1: + version "2.8.1" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.8.1.tgz#612efe4ed235d567e8aba5f2a5fab70280ade83f" + integrity sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w== + tslog@^4.9.3: version "4.9.3" resolved "https://registry.yarnpkg.com/tslog/-/tslog-4.9.3.tgz#d4167d5f51748bdeab593945bc2d8f9827ea0dba" diff --git a/zenoh-ts/examples/deno/src/z_bytes.ts b/zenoh-ts/examples/deno/src/z_bytes.ts new file mode 100644 index 0000000..ef9c1bf --- /dev/null +++ b/zenoh-ts/examples/deno/src/z_bytes.ts @@ -0,0 +1,121 @@ +// +// Copyright (c) 2025 ZettaScale Technology +// +// This program and the accompanying materials are made available under the +// terms of the Eclipse Public License 2.0 which is available at +// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 +// which is available at https://www.apache.org/licenses/LICENSE-2.0. +// +// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 +// +// Contributors: +// ZettaScale Zenoh Team, +// + +import { ZBytes } from "@eclipse-zenoh/zenoh-ts"; +import { ZBytesSerializer, ZBytesDeserializer, ZSerializeable, ZDeserializeable, zserialize, zdeserialize, ZS, ZD, NumberFormat, BigIntFormat } from "@eclipse-zenoh/zenoh-ts/ext"; + + +class MyStruct implements ZSerializeable, ZDeserializeable { + v1: number; + v2: string; + v3: number[]; + + constructor(v1?: number, v2?: string, v3?: number[]) { + if (typeof v1 !== `undefined`) { + this.v1 = v1; + } else { + this.v1 = 0; + } + if (typeof v2 !== `undefined`) { + this.v2 = v2; + } else { + this.v2 = "" + } + if (typeof v3 !== `undefined`) { + this.v3 = v3; + } else { + this.v3 = new Array() + } + } + + serialize_with_zserializer(serializer: ZBytesSerializer): void { + serializer.serialize(this.v1, ZS.number(NumberFormat.Int32)) + serializer.serialize(this.v2) + serializer.serialize(this.v3, ZS.array(ZS.number(NumberFormat.Int8))) + } + + deserialize_with_zdeserializer(deserializer: ZBytesDeserializer): void { + this.v1 = deserializer.deserialize(ZD.number(NumberFormat.Uint32)) + this.v2 = deserializer.deserialize(ZD.string()) + this.v3 = deserializer.deserialize(ZD.array(ZD.number(NumberFormat.Int8))) + } + + to_string(): string { + return JSON.stringify(this) + } + +} + +export async function main() { + // using raw data + // string + { + let input = "test" + let payload = new ZBytes(input) + let output = payload.to_string() + console.log(`Input: ${input}, Output: ${output}`) + } + // Uint8Array + { + let input = new Uint8Array([1, 2, 3, 4]) + let payload = new ZBytes(input) + let output = payload.to_bytes() + console.log(`Input: ${input}, Output: ${output}`) + } + + // serialization + // array + { + let input = [1, 2, 3, 4] + // by default number is serialized/deserialized as 64-bit float, + // other formats, like Int32, for example, must be specified explicitly + let payload = zserialize(input, ZS.array(ZS.number(NumberFormat.Int32))) + let output = zdeserialize(ZD.array(ZD.number(NumberFormat.Int32)), payload) + // let payload = zserialize(input) + // let output = zdeserialize(ZD.array(ZD.number()), payload) + console.log(`Input: ${input}, Output: ${output}`) + } + // typed array + { + let input = new Int32Array([1, 2, 3, 4]) + let payload = zserialize(input) + let output = zdeserialize(ZD.int32array(), payload) + console.log(`Input: ${input}, Output: ${output}`) + } + // map + { + let input = new Map() + input.set(0n, "abc") + input.set(1n, "def") + // by default bigint is serialized/deserialized as 64-bit signed integer, + // other formats, like UInt64, for example, must be specified explicitly + let payload = zserialize(input, ZS.map(ZS.bigint(BigIntFormat.Uint64), ZS.string())) + let output = zdeserialize(ZD.map(ZD.bigint(BigIntFormat.Uint64), ZD.string()), payload) + // let payload = zserialize(input) + // let output = zdeserialize(ZD.map(ZD.bigint(), ZD.string()), payload) + console.log(`Input:`) + console.table(input) + console.log(`Output:`) + console.table(output) + } + // Custom class + { + let input = new MyStruct(1234, "test", [1, 2, 3, 4]) + let payload = zserialize(input) + let output = zdeserialize(ZD.object(MyStruct), payload) + console.log(`Input: ${input.to_string()}, Output: ${output.to_string()}`) + } +} + +main(); diff --git a/zenoh-ts/examples/deno/src/z_get.ts b/zenoh-ts/examples/deno/src/z_get.ts index 3d22cea..7e5835b 100644 --- a/zenoh-ts/examples/deno/src/z_get.ts +++ b/zenoh-ts/examples/deno/src/z_get.ts @@ -12,7 +12,7 @@ // ZettaScale Zenoh Team, // -import { deserialize_string, ReplyError, Config, Receiver, RecvErr, Sample, Session, QueryTarget } from "@eclipse-zenoh/zenoh-ts"; +import { ReplyError, Config, Receiver, RecvErr, Sample, Session, QueryTarget } from "@eclipse-zenoh/zenoh-ts"; import { Duration, Milliseconds } from 'typed-duration' const { milliseconds } = Duration import { BaseParseArgs } from "./parse_args.ts"; @@ -30,10 +30,10 @@ export async function main() { // let resp = reply.result(); // if (resp instanceof Sample) { // let sample: Sample = resp; - // console.warn(">> Received ('", sample.keyexpr(), ":", sample.payload().deserialize(deserialize_string), "')"); + // console.warn(">> Received ('", sample.keyexpr(), ":", sample.payload().to_string()), "')"); // } else { // let reply_error: ReplyError = resp; - // console.warn(">> Received (ERROR: '", reply_error.payload().deserialize(deserialize_string), "')"); + // console.warn(">> Received (ERROR: '", reply_error.payload().to_string(), "')"); // } // }; @@ -57,10 +57,10 @@ export async function main() { const resp = reply.result(); if (resp instanceof Sample) { const sample: Sample = resp; - console.warn(">> Received ('", sample.keyexpr(), ":", sample.payload().deserialize(deserialize_string), "')"); + console.warn(">> Received ('", sample.keyexpr(), ":", sample.payload().to_string(), "')"); } else { const reply_error: ReplyError = resp; - console.warn(">> Received (ERROR: '{", reply_error.payload().deserialize(deserialize_string), "}')"); + console.warn(">> Received (ERROR: '{", reply_error.payload().to_string(), "}')"); } } reply = await receiver.receive(); diff --git a/zenoh-ts/examples/deno/src/z_get_liveliness.ts b/zenoh-ts/examples/deno/src/z_get_liveliness.ts index 040bd52..fe97966 100644 --- a/zenoh-ts/examples/deno/src/z_get_liveliness.ts +++ b/zenoh-ts/examples/deno/src/z_get_liveliness.ts @@ -13,7 +13,7 @@ // import { - deserialize_string, Sample, Config, Session, KeyExpr, + Sample, Config, Session, KeyExpr, Receiver, RecvErr, ReplyError @@ -45,7 +45,7 @@ export async function main() { console.warn(">> Alive token ('", sample.keyexpr(), ")"); } else { const reply_error: ReplyError = resp; - console.warn(">> Received (ERROR: '", reply_error.payload().deserialize(deserialize_string), "')"); + console.warn(">> Received (ERROR: '", reply_error.payload().to_string(), "')"); } } reply = await receiver.receive(); diff --git a/zenoh-ts/examples/deno/src/z_ping.ts b/zenoh-ts/examples/deno/src/z_ping.ts index b269f96..14bdc2c 100644 --- a/zenoh-ts/examples/deno/src/z_ping.ts +++ b/zenoh-ts/examples/deno/src/z_ping.ts @@ -31,7 +31,7 @@ export async function main() { console.warn("Warming up for 5 seconds..."); const startTime = new Date(); - const data = [122, 101, 110, 111, 104]; + const data = new Uint8Array([122, 101, 110, 111, 104]); while (elapsed(startTime) < 5) { pub.put(data); diff --git a/zenoh-ts/examples/deno/src/z_querier.ts b/zenoh-ts/examples/deno/src/z_querier.ts index 5406b2a..4e0e16b 100644 --- a/zenoh-ts/examples/deno/src/z_querier.ts +++ b/zenoh-ts/examples/deno/src/z_querier.ts @@ -12,7 +12,7 @@ // ZettaScale Zenoh Team, // -import { deserialize_string, ReplyError, Config, Receiver, RecvErr, Sample, Session, QueryTarget, Selector, } from "@eclipse-zenoh/zenoh-ts"; +import { ReplyError, Config, Receiver, RecvErr, Sample, Session, QueryTarget, Selector, } from "@eclipse-zenoh/zenoh-ts"; import { Duration, Milliseconds } from 'typed-duration' import { BaseParseArgs } from "./parse_args.ts"; @@ -41,10 +41,10 @@ export async function main() { const resp = reply.result(); if (resp instanceof Sample) { const sample: Sample = resp; - console.warn(">> Received ('", sample.keyexpr(), ":", sample.payload().deserialize(deserialize_string), "')"); + console.warn(">> Received ('", sample.keyexpr(), ":", sample.payload().to_string(), "')"); } else { const reply_error: ReplyError = resp; - console.warn(">> Received (ERROR: '{", reply_error.payload().deserialize(deserialize_string), "}')"); + console.warn(">> Received (ERROR: '{", reply_error.payload().to_string(), "}')"); } } reply = await receiver.receive(); diff --git a/zenoh-ts/examples/deno/src/z_sub.ts b/zenoh-ts/examples/deno/src/z_sub.ts index c9b41d4..d3a4d8d 100644 --- a/zenoh-ts/examples/deno/src/z_sub.ts +++ b/zenoh-ts/examples/deno/src/z_sub.ts @@ -13,7 +13,7 @@ // import { - RingChannel, deserialize_string, Config, Subscriber, Session, KeyExpr + RingChannel, Config, Subscriber, Session, KeyExpr } from "@eclipse-zenoh/zenoh-ts"; import { parseArgs } from "@std/cli/parse-args"; import { BaseParseArgs } from "./parse_args.ts"; @@ -33,7 +33,7 @@ export async function main() { ">> [Subscriber] Received " + sample.kind() + " ('" + sample.keyexpr() + "': '" + - sample.payload().deserialize(deserialize_string) + "')", + sample.payload().to_string() + "')", ); sample = await poll_subscriber.receive(); } diff --git a/zenoh-ts/examples/deno/yarn.lock b/zenoh-ts/examples/deno/yarn.lock index 661e86b..3debb1e 100644 --- a/zenoh-ts/examples/deno/yarn.lock +++ b/zenoh-ts/examples/deno/yarn.lock @@ -3,8 +3,9 @@ "@eclipse-zenoh/zenoh-ts@file:../..": - version "1.0.3" + version "1.1.1" dependencies: + "@thi.ng/leb128" "^3.1.36" base64-arraybuffer "^1.0.2" channel-ts "^0.1.2" eslint "^9.10.0" @@ -99,6 +100,141 @@ resolved "https://registry.yarnpkg.com/@humanwhocodes/retry/-/retry-0.4.1.tgz#9a96ce501bc62df46c4031fbd970e3cc6b10f07b" integrity sha512-c7hNEllBlenFTHBky65mhq8WD2kbN9Q6gk0bTk8lSBvc554jpXSkST1iePudpt7+A/AQvuHs9EMqjHDXMY1lrA== +"@thi.ng/api@^8.11.19": + version "8.11.19" + resolved "https://registry.yarnpkg.com/@thi.ng/api/-/api-8.11.19.tgz#9ce8eb5657a28ddbd82a1864792b59a753a4ee33" + integrity sha512-ffK8nyNDd3kiwiijpb0Uv/0MtRUYpRtJj3K8OwFXdCzboll+/DNvXpfAlBMwSkLqZR0GighDwApyl0/4njiHCg== + +"@thi.ng/arrays@^2.10.14": + version "2.10.14" + resolved "https://registry.yarnpkg.com/@thi.ng/arrays/-/arrays-2.10.14.tgz#a6202d3e208e2930554083b24c8a7143e23e8d56" + integrity sha512-hTuot92azDcX/GbWIFtbrKEPTThQn9tlRqKAnGL0xerCXEvHlvJ9F2zgf/crhBt8vcP8ca/P+4xYJYLKa54iBw== + dependencies: + "@thi.ng/api" "^8.11.19" + "@thi.ng/checks" "^3.6.22" + "@thi.ng/compare" "^2.4.11" + "@thi.ng/equiv" "^2.1.75" + "@thi.ng/errors" "^2.5.25" + "@thi.ng/random" "^4.1.10" + +"@thi.ng/binary@^3.4.42": + version "3.4.42" + resolved "https://registry.yarnpkg.com/@thi.ng/binary/-/binary-3.4.42.tgz#2fdd71c7c06d9bfb38bd94b71598343ccf8d89a9" + integrity sha512-DU5JiBOONjx4synwos2GPaq8ByIfPSx6H6BsBmTf/Ou1PiABMlFuHlz8aOzw/Z1jUTYzb04arwUpYl1MVKjrAg== + dependencies: + "@thi.ng/api" "^8.11.19" + +"@thi.ng/checks@^3.6.22": + version "3.6.22" + resolved "https://registry.yarnpkg.com/@thi.ng/checks/-/checks-3.6.22.tgz#00b3c6e4f8562f4108795b645a97cfc588c7cdcd" + integrity sha512-CMxQHrxvHnAVnmhxfP44GVS1TmAUWLsX8uZTVrL4IQcWzVVyHgvD6uXYw5E7kaZCR2S6wnS+Ng5oOCBE0EU/Hg== + dependencies: + tslib "^2.8.1" + +"@thi.ng/compare@^2.4.11": + version "2.4.11" + resolved "https://registry.yarnpkg.com/@thi.ng/compare/-/compare-2.4.11.tgz#63cf4bebcd15575265f68bcf85d9b61c953c9cf6" + integrity sha512-SNbRrf19ntPmpXVkdMK04ZRRSDzPmRxxV9WKdH6+3J5NkYbASffi9o9WWun9In09P1+/Zh5yYfi2LzNsIDHNDw== + dependencies: + "@thi.ng/api" "^8.11.19" + +"@thi.ng/compose@^3.0.22": + version "3.0.22" + resolved "https://registry.yarnpkg.com/@thi.ng/compose/-/compose-3.0.22.tgz#a7b4f4927fd896c0e37a797c8f2a2aa1f7a14271" + integrity sha512-PdXT/X4Ca8VfzyGryhAlw7PYyPvbRhpFqT4hej2oOgGuXeifoNr2J6WejTEwK8wA4F57onHHr7TisPVNfN/PMQ== + dependencies: + "@thi.ng/api" "^8.11.19" + "@thi.ng/errors" "^2.5.25" + +"@thi.ng/equiv@^2.1.75": + version "2.1.75" + resolved "https://registry.yarnpkg.com/@thi.ng/equiv/-/equiv-2.1.75.tgz#f6fa49df08c1fd17da1302e057f1809cea3b5cb2" + integrity sha512-AoQQgrhW0xtXgxkrDK5EP5Y9Fe/QBGCmQgVKJ2G7uYCW/IbN/nTZEUM6011v41ydpmKl4wJjmr+s3StcIeDfdQ== + +"@thi.ng/errors@^2.5.25": + version "2.5.25" + resolved "https://registry.yarnpkg.com/@thi.ng/errors/-/errors-2.5.25.tgz#4a9b91fbe51413b151d3758bdf6ef7e53cbc2d1f" + integrity sha512-PmK56hWGvRWr9Eq0V5xkV4tQvhjPtfvv6urFONP/D0gwFQXj+v6rcDYkAFLzOkbLqa0DYtkgvUsMklF/L53upA== + +"@thi.ng/hex@^2.3.63": + version "2.3.63" + resolved "https://registry.yarnpkg.com/@thi.ng/hex/-/hex-2.3.63.tgz#75f91f6e4d4dec22046a74526b30f81d32d138f4" + integrity sha512-5xaQEKdaPls8de4zx4piPjCP13AHZLlyJCwHp4enSfeH5ZmDR3/aRwbmJod4FlJAvQdvDa3jBz+OtHNdxwrPLg== + +"@thi.ng/leb128@^3.1.36": + version "3.1.36" + resolved "https://registry.yarnpkg.com/@thi.ng/leb128/-/leb128-3.1.36.tgz#9516fe5113d030a617039da3c8f5361d62185940" + integrity sha512-NfEfBpjtOwGJxgxDXyuLYxfmikT8u7TPT3J1rc51JmScxtTXZQkpgR3ORwy/xshILmGVMID2vww3NshZbSHqZg== + dependencies: + "@thi.ng/checks" "^3.6.22" + "@thi.ng/errors" "^2.5.25" + "@thi.ng/transducers-binary" "^2.1.152" + +"@thi.ng/math@^5.11.19": + version "5.11.19" + resolved "https://registry.yarnpkg.com/@thi.ng/math/-/math-5.11.19.tgz#0a0ff7ad249f2960fcc3b39f930568d4a19a2b35" + integrity sha512-nsS1hP0rtgfuLtD6fLEtNTv07DlPZjKlgRoTrJcpkr47zzGcabwxo7a2VlHYFjhnShVUVSdQTFCnSSHN40drOQ== + dependencies: + "@thi.ng/api" "^8.11.19" + +"@thi.ng/memoize@^4.0.9": + version "4.0.9" + resolved "https://registry.yarnpkg.com/@thi.ng/memoize/-/memoize-4.0.9.tgz#57ab73ed0e7ff98df94c7182a703b0dbd6edf8c3" + integrity sha512-YQD5lOew7mAZRripl3ylyOOq0OJ7yv/9D2o9w0Rd3ZrL2nl49tbticcH0V6nSKHEJhJSeRftCjmxNXNZulZkBw== + dependencies: + "@thi.ng/api" "^8.11.19" + +"@thi.ng/random@^4.1.10": + version "4.1.10" + resolved "https://registry.yarnpkg.com/@thi.ng/random/-/random-4.1.10.tgz#732bae76ffb397ca42e771bbe94f6c8c2fbd815a" + integrity sha512-BBEAr0fg0pDoHtk4iBsdyLfZ9HcGvzeOwdAiXb3iibPhCL+h4lpjpmxy8yCyD7CatlnUICfbDdiY59X5qKJMgA== + dependencies: + "@thi.ng/api" "^8.11.19" + "@thi.ng/errors" "^2.5.25" + +"@thi.ng/strings@^3.9.4": + version "3.9.4" + resolved "https://registry.yarnpkg.com/@thi.ng/strings/-/strings-3.9.4.tgz#782bbf81ea441c0d2671ca54654cf4c639762879" + integrity sha512-Ut9Elrp5HHiQjtJALjqKljzhDZYEgVMgwjN3EuEgHwBcrtvgthuhK6gKf2cGr0O8sqIjcctnhWqu7nE4QLuVaQ== + dependencies: + "@thi.ng/api" "^8.11.19" + "@thi.ng/errors" "^2.5.25" + "@thi.ng/hex" "^2.3.63" + "@thi.ng/memoize" "^4.0.9" + +"@thi.ng/timestamp@^1.1.4": + version "1.1.4" + resolved "https://registry.yarnpkg.com/@thi.ng/timestamp/-/timestamp-1.1.4.tgz#6800c1fd8f9fc349e3d601a445707f52f1fc7d97" + integrity sha512-Rsfa1ypD3Ulkh2RDbj19hb8hCXRzUjy+1gpbovy2Bnys7VPNXRyHEaEZvqRNzj+jTzylvFNbi8QLArX7RXzeqw== + +"@thi.ng/transducers-binary@^2.1.152": + version "2.1.152" + resolved "https://registry.yarnpkg.com/@thi.ng/transducers-binary/-/transducers-binary-2.1.152.tgz#320c4875f73ce31e9bcca5b2481ef5e4365636a8" + integrity sha512-0QG5cTheIZGcIaDDsaCaSSYvDXhFqbmdFng8HNLzl5EIcSecRC0R3rT7N0SxN+JxGMDRmZFQk/vFHlqulxaTew== + dependencies: + "@thi.ng/binary" "^3.4.42" + "@thi.ng/compose" "^3.0.22" + "@thi.ng/errors" "^2.5.25" + "@thi.ng/hex" "^2.3.63" + "@thi.ng/random" "^4.1.10" + "@thi.ng/strings" "^3.9.4" + "@thi.ng/transducers" "^9.2.17" + +"@thi.ng/transducers@^9.2.17": + version "9.2.17" + resolved "https://registry.yarnpkg.com/@thi.ng/transducers/-/transducers-9.2.17.tgz#8504f45178c3875841c9afcb9dcd68a3966c4b22" + integrity sha512-LjbAbRAcpHi0gv6aW7+5ijJYJjhQtJoszEvjCC025RQ3pjXXD3gkRs8nnJULk6ibkcEcCoP5Q0WBWNAXusInQg== + dependencies: + "@thi.ng/api" "^8.11.19" + "@thi.ng/arrays" "^2.10.14" + "@thi.ng/checks" "^3.6.22" + "@thi.ng/compare" "^2.4.11" + "@thi.ng/compose" "^3.0.22" + "@thi.ng/errors" "^2.5.25" + "@thi.ng/math" "^5.11.19" + "@thi.ng/random" "^4.1.10" + "@thi.ng/timestamp" "^1.1.4" + "@types/estree@^1.0.6": version "1.0.6" resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.6.tgz#628effeeae2064a1b4e79f78e81d87b7e5fc7b50" @@ -570,6 +706,11 @@ text-table@^0.2.0: resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" integrity sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw== +tslib@^2.8.1: + version "2.8.1" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.8.1.tgz#612efe4ed235d567e8aba5f2a5fab70280ade83f" + integrity sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w== + tslog@^4.9.3: version "4.9.3" resolved "https://registry.yarnpkg.com/tslog/-/tslog-4.9.3.tgz#d4167d5f51748bdeab593945bc2d8f9827ea0dba" diff --git a/zenoh-ts/package.json b/zenoh-ts/package.json index d7a45e9..24bfcc2 100644 --- a/zenoh-ts/package.json +++ b/zenoh-ts/package.json @@ -5,8 +5,14 @@ "type": "module", "description": "Zenoh: The Zero Overhead Pub/Sub/Query Protocol", "exports": { - "import": "./dist/index.js", - "types": "./dist/index.d.ts" + ".": { + "import": "./dist/index.js", + "types": "./dist/index.d.ts" + }, + "./ext": { + "import": "./dist/ext/index.js", + "types": "./dist/ext/index.d.ts" + } }, "main": "dist/index.js", "types": "dist/index.d.ts", @@ -17,6 +23,7 @@ "LICENSE" ], "dependencies": { + "@thi.ng/leb128": "^3.1.36", "base64-arraybuffer": "^1.0.2", "channel-ts": "^0.1.2", "eslint": "^9.10.0", @@ -29,7 +36,7 @@ "@types/node": "20.9.1", "@types/uuid": "^10.0.0", "typedoc": "^0.26.5", - "typescript": "^5.3.2" + "typescript": "^5.7.3" }, "scripts": { "wasm": "cd ../zenoh-keyexpr-wasm && cargo install wasm-pack && wasm-pack build --target bundler --out-dir ../zenoh-ts/src/key_expr", diff --git a/zenoh-ts/src/ext/index.ts b/zenoh-ts/src/ext/index.ts new file mode 100644 index 0000000..b25c0b3 --- /dev/null +++ b/zenoh-ts/src/ext/index.ts @@ -0,0 +1,21 @@ +// +// Copyright (c) 2025 ZettaScale Technology +// +// This program and the accompanying materials are made available under the +// terms of the Eclipse Public License 2.0 which is available at +// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 +// which is available at https://www.apache.org/licenses/LICENSE-2.0. +// +// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 +// +// Contributors: +// ZettaScale Zenoh Team, +// + +// Serialization +import { ZBytesSerializer, ZBytesDeserializer, ZSerializeable, ZDeserializeable, zserialize, zdeserialize, NumberFormat, BigIntFormat, ZS, ZD } from "./serialization.js" + + + +// Exports +export { ZBytesSerializer, ZBytesDeserializer, ZSerializeable, ZDeserializeable, zserialize, zdeserialize, NumberFormat, BigIntFormat, ZS, ZD } \ No newline at end of file diff --git a/zenoh-ts/src/ext/serialization.ts b/zenoh-ts/src/ext/serialization.ts new file mode 100644 index 0000000..d423892 --- /dev/null +++ b/zenoh-ts/src/ext/serialization.ts @@ -0,0 +1,1317 @@ +// +// Copyright (c) 2025 ZettaScale Technology +// +// This program and the accompanying materials are made available under the +// terms of the Eclipse Public License 2.0 which is available at +// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 +// which is available at https://www.apache.org/licenses/LICENSE-2.0. +// +// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 +// +// Contributors: +// ZettaScale Zenoh Team, +// + +import * as leb from "@thi.ng/leb128"; + +import { ZBytes } from '../z_bytes.js'; +import { isBigInt64Array, isBigUint64Array, isFloat32Array, isFloat64Array, isInt16Array, isInt32Array, isInt8Array, isUint16Array, isUint32Array, isUint8Array } from "util/types"; + +/** + * Interface for adding support for custom types serialization. + */ +export interface ZSerializeable { + serialize_with_zserializer(serializer: ZBytesSerializer): void; +} + +const is_little_endian: boolean = ((new Uint32Array((new Uint8Array([1,2,3,4])).buffer))[0] === 0x04030201) + +/** + * Interface for adding support for custom types deserialization. + */ +export interface ZDeserializeable { + deserialize_with_zdeserializer(deserializer: ZBytesDeserializer): void; +} + +type IsSame = + (() => G extends T ? 1 : 2) extends + (() => G extends U ? 1 : 2) ? T : never; + +type UnionToIntersection = + (U extends any ? (x: U)=>void : never) extends ((x: infer I)=>void) ? I : never + +type IsNotUnion = [T] extends [UnionToIntersection] ? T : IsSame + +type Select = (X & Y) extends never ? never : Z; + +type IsSerializeableInner = + T extends ZSerializeable ? X + : T extends number ? X + : T extends bigint ? X + : T extends string ? X + : T extends boolean ? X + : T extends Uint8Array ? X + : T extends Uint16Array ? X + : T extends Uint32Array ? X + : T extends BigUint64Array ? X + : T extends Int8Array ? X + : T extends Int16Array ? X + : T extends Int32Array ? X + : T extends BigInt64Array ? X + : T extends Float32Array ? X + : T extends Float64Array ? X + : T extends Array ? EnsureSerializeable + : T extends Map ? EnsureSerializeable & EnsureSerializeable + : never; + +export type EnsureSerializeable = Select, IsNotUnion, X> + +function is_serializeable(s: any): s is ZSerializeable { + return (s).serialize_with_zserializer !== undefined; +} + +/** + * A Zenoh serializer. + * Provides functionality for tuple-like serialization. + */ +export class ZBytesSerializer { + private _buffer: Uint8Array + /** + * new function to create a ZBytesSerializer. + * + * @returns ZBytesSerializer + */ + constructor() { + this._buffer = new Uint8Array(); + } + + private append(buf: Uint8Array) { + let b = new Uint8Array(this._buffer.length + buf.length) + b.set(this._buffer) + b.set(buf, this._buffer.length) + this._buffer = b + } + + /** + * Serializes length of the sequence. Can be used when defining serialization for custom containers. + */ + public write_sequence_length(len: number) { + this.append(leb.encodeULEB128(len)) + } + + /** + * Serializes a utf-8 encoded string. + */ + public serialize_string(val: string) { + const encoder = new TextEncoder(); + const encoded = encoder.encode(val); + this.write_sequence_length(encoded.length) + this.append(encoded) + } + + /** + * Serializes a Uint8Array. + */ + public serialize_uint8array(val: Uint8Array) { + this.write_sequence_length(val.length) + this.append(val) + } + + /** + * Serializes a Uint16Array. + */ + public serialize_uint16array(val: Uint16Array) { + this.write_sequence_length(val.length) + if (is_little_endian) { + this.append(new Uint8Array(val.buffer)) + } else { + val.forEach( (element) => this.serialize_number_uint16(element)); + } + } + + /** + * Serializes a Uint32Array. + */ + public serialize_uint32array(val: Uint32Array) { + this.write_sequence_length(val.length) + if (is_little_endian) { + this.append(new Uint8Array(val.buffer)) + } else { + val.forEach( (element) => this.serialize_number_uint32(element)); + } + } + + /** + * Serializes a BigUint64Array. + */ + public serialize_biguint64array(val: BigUint64Array) { + this.write_sequence_length(val.length) + if (is_little_endian) { + this.append(new Uint8Array(val.buffer)) + } else { + val.forEach( (element) => this.serialize_bigint_uint64(element)); + } + } + + /** + * Serializes a Int8Array. + */ + public serialize_int8array(val: Int8Array) { + this.write_sequence_length(val.length) + this.append(new Uint8Array(val.buffer)) + } + + /** + * Serializes a Int16Array. + */ + public serialize_int16array(val: Int16Array) { + this.write_sequence_length(val.length) + if (is_little_endian) { + this.append(new Uint8Array(val.buffer)) + } else { + val.forEach( (element) => this.serialize_number_int16(element)); + } + } + + /** + * Serializes a Int32Array. + */ + public serialize_int32array(val: Int32Array) { + this.write_sequence_length(val.length) + if (is_little_endian) { + this.append(new Uint8Array(val.buffer)) + } else { + val.forEach( (element) => this.serialize_number_int32(element)); + } + } + + /** + * Serializes a BigInt64Array. + */ + public serialize_bigint64array(val: BigInt64Array) { + this.write_sequence_length(val.length) + if (is_little_endian) { + this.append(new Uint8Array(val.buffer)) + } else { + val.forEach( (element) => this.serialize_bigint_int64(element)); + } + } + + /** + * Serializes a Float32Array. + */ + public serialize_float32array(val: Float32Array) { + this.write_sequence_length(val.length) + if (is_little_endian) { + this.append(new Uint8Array(val.buffer)) + } else { + val.forEach( (element) => this.serialize_number_float32(element)); + } + } + + /** + * Serializes a Float64Array. + */ + public serialize_float64array(val: Float64Array) { + this.write_sequence_length(val.length) + if (is_little_endian) { + this.append(new Uint8Array(val.buffer)) + } else { + val.forEach( (element) => this.serialize_number_float64(element)); + } + } + + /** + * Serializes bigint as 64 bit signed integer. + */ + public serialize_bigint_int64(val: bigint) { + let data = new Uint8Array(8); + let view = new DataView(data.buffer); + view.setBigInt64(0, val, true); + this.append(data) + } + + /** + * Serializes bigint as 64 bit unsigned integer. + */ + public serialize_bigint_uint64(val: bigint) { + let data = new Uint8Array(8); + let view = new DataView(data.buffer); + view.setBigUint64(0, val, true); + this.append(data) + } + + /** + * Serializes number as 64 bit floating point number. + */ + public serialize_number_float64(val: number) { + let data = new Uint8Array(8); + let view = new DataView(data.buffer); + view.setFloat64(0, val, true); + this.append(data) + } + + /** + * Serializes number as 32 bit floating point number. + */ + public serialize_number_float32(val: number) { + let data = new Uint8Array(4); + let view = new DataView(data.buffer); + view.setFloat32(0, val, true); + this.append(data) + } + + /** + * Serializes number as 32 bit integer. + */ + public serialize_number_int32(val: number) { + let data = new Uint8Array(4); + let view = new DataView(data.buffer); + view.setInt32(0, val, true); + this.append(data) + } + + /** + * Serializes number as 32 bit unsigned integer. + */ + public serialize_number_uint32(val: number) { + let data = new Uint8Array(4); + let view = new DataView(data.buffer); + view.setUint32(0, val, true); + this.append(data) + } + + /** + * Serializes number as 16 bit integer. + */ + public serialize_number_int16(val: number) { + let data = new Uint8Array(2); + let view = new DataView(data.buffer); + view.setInt16(0, val, true); + this.append(data) + } + + /** + * Serializes number as 16 bit unsigned integer. + */ + public serialize_number_uint16(val: number) { + let data = new Uint8Array(2); + let view = new DataView(data.buffer); + view.setUint16(0, val, true); + this.append(data) + } + + /** + * Serializes number as 8 bit integer. + */ + public serialize_number_int8(val: number) { + let data = new Uint8Array(1); + let view = new DataView(data.buffer); + view.setInt8(0, val); + this.append(data) + } + + /** + * Serializes number as 8 bit unsigned integer. + */ + public serialize_number_uint8(val: number) { + let data = new Uint8Array(1); + let view = new DataView(data.buffer); + view.setUint8(0, val); + this.append(data) + } + + /** + * Serializes boolean. + */ + public serialize_boolean(val: Boolean) { + const b:Uint8Array = new Uint8Array(1) + b[0] = val === true ? 1 : 0 + this.append(b) + } + + /** + * Serializes an array. + */ + public serialize_array(val: EnsureSerializeable[], t?: ZSTypeInfo>) { + this.write_sequence_length(val.length) + if (val.length > 0 && t === undefined) { + t = this._get_default_serialization_tag(val[0] as any) as ZSTypeInfo> + } + val.forEach( (element) => (t as ZSTypeInfo>).serialize(this, element)); + } + + /** + * Serializes a map. + */ + public serialize_map(m: Map, EnsureSerializeable>, t_key?:ZSTypeInfo>, t_value?: ZSTypeInfo>) { + this.write_sequence_length(m.size) + if (m.size > 0) { + let val = m.entries().next() + if (val !== undefined ) { + let value = val.value + if (value !== undefined) { + t_key ??= this._get_default_serialization_tag(value[0] as any) as ZSTypeInfo> + t_value ??= this._get_default_serialization_tag(value[1] as any) as ZSTypeInfo> + } + } + } + m.forEach( (v, k) => { + (t_key as ZSTypeInfo>).serialize(this, k); + (t_value as ZSTypeInfo>).serialize(this, v); + } + ); + } + + private _get_default_serialization_tag(data: EnsureSerializeable): ZSTypeInfo> { + if (is_serializeable(data)) { + type R = typeof data + return ZS.object() as ZSTypeInfo> + } else if (typeof data == "number") { + return ZS.number() as ZSTypeInfo> + } else if (typeof data == "bigint") { + return ZS.bigint() as ZSTypeInfo> + } else if (typeof data == "string") { + return ZS.string() as ZSTypeInfo> + } else if (typeof data == "boolean") { + return ZS.boolean() as ZSTypeInfo> + } else if (isUint8Array(data)) { + return ZS.uint8array() as ZSTypeInfo> + } else if (isUint16Array(data)) { + return ZS.uint16array() as ZSTypeInfo> + } else if (isUint32Array(data)) { + return ZS.uint32array() as ZSTypeInfo> + } else if (isBigUint64Array(data)) { + return ZS.biguint64array() as ZSTypeInfo> + } else if (isInt8Array(data)) { + return ZS.int8array() as ZSTypeInfo> + } else if (isInt16Array(data)) { + return ZS.int16array() as ZSTypeInfo> + } else if (isInt32Array(data)) { + return ZS.int32array() as ZSTypeInfo> + } else if (isBigInt64Array(data)) { + return ZS.bigint64array() as ZSTypeInfo> + } else if (isFloat32Array(data)) { + return ZS.float32array() as ZSTypeInfo> + } else if (isFloat64Array(data)) { + return ZS.float64array() as ZSTypeInfo> + } else if (Array.isArray(data)) { + let t = undefined + if (data.length > 0) { + t = this._get_default_serialization_tag(data[0]) + } + return ZS.array(t) as ZSTypeInfo> + } else if (data instanceof Map) { + let t_key = undefined + let t_value = undefined + let val = data.entries().next() + if (val !== undefined ) { + let value = val.value + if (value !== undefined) { + t_key = this._get_default_serialization_tag(value[0] as any) + t_value = this._get_default_serialization_tag(value[1] as any) + } + } + return ZS.map(t_key, t_value) as ZSTypeInfo> + } else { // should never happen + throw new Error(`Non-ZSerializeable type`); + } + } + + /** + * Serializes any supported type and append it to existing serialized payload. + * Supported types are: + * - built-in types: number, bigint, string, boolean, + * - TypedArrays, + * - arrays and maps of supported types. + * @param val Value to serialize. + * @param t An optional serialization tag (if ommited, the default one will be used). + */ + public serialize(val: EnsureSerializeable, t?: ZSTypeInfo>) { + if (t === undefined) { + this._get_default_serialization_tag(val).serialize(this, val) + } else { + t.serialize(this, val) + } + } + + /** + * Extracts ZBytes from ZBytesSerializer + * + * @returns ZBytes + */ + public finish(): ZBytes { + let out = new ZBytes(this._buffer); + this._buffer = new Uint8Array() + return out + } +} + +/** + * Format for `number` type serialization/deserialzation. + */ +export enum NumberFormat { + Float64 = 1, + Float32, + Int32, + Uint32, + Int16, + Uint16, + Int8, + Uint8 +} + +/** + * Format for `bigint` type serialization/deserialzation. + */ +export enum BigIntFormat { + Int64 = 1, + Uint64 +} + + +class ZDTypeInfo { + private _deserialize: (deserializer: ZBytesDeserializer) => T + + constructor(deserialize: (deserializer: ZBytesDeserializer) => T ) { + this._deserialize = deserialize + } + + /** @internal */ + deserialize(deserializer: ZBytesDeserializer): T { + return this._deserialize(deserializer) + } +} + +class ZSTypeInfo { + private _serialize: (serializer: ZBytesSerializer, val: T) => void + + constructor(serialize: (serializer: ZBytesSerializer, val: T) => void) { + this._serialize = serialize + } + + /** @internal */ + serialize(serializer: ZBytesSerializer, val: T): void { + this._serialize(serializer, val) + } +} + +export namespace ZD{ + /** + * Indicates that value should be deserialized as a number in specified format. + * @returns Number deserialization tag. + */ + export function number(format: NumberFormat = NumberFormat.Float64): ZDTypeInfo { + switch(format) { + case NumberFormat.Float64: + return new ZDTypeInfo( + (z: ZBytesDeserializer) => { return z.deserialize_number_float64() } + ); + case NumberFormat.Float32: + return new ZDTypeInfo( + (z: ZBytesDeserializer) => { return z.deserialize_number_float32() } + ); + case NumberFormat.Int32: + return new ZDTypeInfo( + (z: ZBytesDeserializer) => { return z.deserialize_number_int32() } + ); + case NumberFormat.Uint32: + return new ZDTypeInfo( + (z: ZBytesDeserializer) => { return z.deserialize_number_uint32() } + ); + case NumberFormat.Int16: + return new ZDTypeInfo( + (z: ZBytesDeserializer) => { return z.deserialize_number_int16() } + ); + case NumberFormat.Uint16: + return new ZDTypeInfo( + (z: ZBytesDeserializer) => { return z.deserialize_number_uint16() } + ); + case NumberFormat.Int8: + return new ZDTypeInfo( + (z: ZBytesDeserializer) => { return z.deserialize_number_int8() } + ); + case NumberFormat.Uint8: + return new ZDTypeInfo( + (z: ZBytesDeserializer) => { return z.deserialize_number_int16() } + ); + } + } + + /** + * Indicates that data should be deserialized as a bigint in specified format. + * @returns Bigint deserialization tag. + */ + export function bigint(format:BigIntFormat = BigIntFormat.Int64): ZDTypeInfo { + switch (format) { + case BigIntFormat.Int64: + return new ZDTypeInfo( + (z: ZBytesDeserializer) => { return z.deserialize_bigint_int64() } + ); + case BigIntFormat.Uint64: + return new ZDTypeInfo( + (z: ZBytesDeserializer) => { return z.deserialize_bigint_uint64() } + ); + } + } + + /** + * Indicates that data should be deserialized as a string. + * @returns String deserialization tag. + */ + export function string(): ZDTypeInfo { + return new ZDTypeInfo( + (z: ZBytesDeserializer) => { return z.deserialize_string() } + ); + } + + /** + * Indicates that data should be deserialized as a boolean. + * @returns Boolean deserialization tag. + */ + export function boolean(): ZDTypeInfo { + return new ZDTypeInfo( + (z: ZBytesDeserializer) => { return z.deserialize_boolean() } + ); + } + + /** + * Indicates that data should be deserialized as a Uint8Array. + * @returns Uint8Array deserialization tag. + */ + export function uint8array(): ZDTypeInfo { + return new ZDTypeInfo( + (z: ZBytesDeserializer) => { return z.deserialize_uint8array() } + ); + } + + /** + * Indicates that data should be deserialized as a Uint16Array. + * @returns Uint16Array deserialization tag. + */ + export function uint16array(): ZDTypeInfo { + return new ZDTypeInfo( + (z: ZBytesDeserializer) => { return z.deserialize_uint16array() } + ); + } + + /** + * Indicates that data should be deserialized as a Uint32Array. + * @returns Uint32Array deserialization tag. + */ + export function uint32array(): ZDTypeInfo { + return new ZDTypeInfo( + (z: ZBytesDeserializer) => { return z.deserialize_uint32array() } + ); + } + + /** + * Indicates that data should be deserialized as a BigUint64Array. + * @returns BigUint64Array deserialization tag. + */ + export function biguint64array(): ZDTypeInfo { + return new ZDTypeInfo( + (z: ZBytesDeserializer) => { return z.deserialize_biguint64array() } + ); + } + + /** + * Indicates that data should be deserialized as a Int8Array. + * @returns Int8Array deserialization tag. + */ + export function int8array(): ZDTypeInfo { + return new ZDTypeInfo( + (z: ZBytesDeserializer) => { return z.deserialize_int8array() } + ); + } + + /** + * Indicates that data should be deserialized as a Int16Array. + * @returns Int16Array deserialization tag. + */ + export function int16array(): ZDTypeInfo { + return new ZDTypeInfo( + (z: ZBytesDeserializer) => { return z.deserialize_int16array() } + ); + } + + /** + * Indicates that data should be deserialized as a Int32Array. + * @returns Int32Array deserialization tag. + */ + export function int32array(): ZDTypeInfo { + return new ZDTypeInfo( + (z: ZBytesDeserializer) => { return z.deserialize_int32array() } + ); + } + + /** + * Indicates that data should be deserialized as a BigInt64Array. + * @returns BigInt64Array deserialization tag. + */ + export function bigint64array(): ZDTypeInfo { + return new ZDTypeInfo( + (z: ZBytesDeserializer) => { return z.deserialize_bigint64array() } + ); + } + /** + * Indicates that data should be deserialized as a Float32Array. + * @returns Float32Array deserialization tag. + */ + export function float32array(): ZDTypeInfo { + return new ZDTypeInfo( + (z: ZBytesDeserializer) => { return z.deserialize_float32array() } + ); + } + + /** + * Indicates that data should be deserialized as a Float64Array. + * @returns Float64Array deserialization tag. + */ + export function float64array(): ZDTypeInfo { + return new ZDTypeInfo( + (z: ZBytesDeserializer) => { return z.deserialize_float64array() } + ); + } + + /** + * Indicates that data should be deserialized as an object. + * @param create A new function to create an object instance where data will be deserialized. + * @returns Object deserialization tag. + */ + export function object(create: new() => T): ZDTypeInfo { + return new ZDTypeInfo( + (z: ZBytesDeserializer) => { return z.deserialize_object(create) } + ); + } + + /** + * Indicates that data should be deserialized as an array. + * @param t An array element deserialization tag. + * @returns Array deserialization tag. + */ + export function array(t: ZDTypeInfo): ZDTypeInfo { + return new ZDTypeInfo( + (z: ZBytesDeserializer) => { return z.deserialize_array(t) } + ); + } + + /** + * Indicates that data should be deserialized as a map. + * @param t_key A key type deserialization tag. + * @param t_value A value type deserialization tag. + * @returns Array deserialization tag. + */ + export function map(t_key: ZDTypeInfo, t_value: ZDTypeInfo): ZDTypeInfo> { + return new ZDTypeInfo( + (z: ZBytesDeserializer) => { return z.deserialize_map(t_key, t_value) } + ); + } +} + +export namespace ZS{ + /** + * Indicates that value should be serialized as a number in specified format. + * @returns Number serialization tag. + */ + export function number(format: NumberFormat = NumberFormat.Float64): ZSTypeInfo { + switch(format) { + case NumberFormat.Float64: + return new ZSTypeInfo( + (z: ZBytesSerializer, val: number) => {z.serialize_number_float64(val);} + ); + case NumberFormat.Float32: + return new ZSTypeInfo( + (z: ZBytesSerializer, val: number) => {z.serialize_number_float32(val);} + ); + case NumberFormat.Int32: + return new ZSTypeInfo( + (z: ZBytesSerializer, val: number) => {z.serialize_number_int32(val);} + ); + case NumberFormat.Uint32: + return new ZSTypeInfo( + (z: ZBytesSerializer, val: number) => {z.serialize_number_uint32(val);} + ); + case NumberFormat.Int16: + return new ZSTypeInfo( + (z: ZBytesSerializer, val: number) => {z.serialize_number_int16(val);} + ); + case NumberFormat.Uint16: + return new ZSTypeInfo( + (z: ZBytesSerializer, val: number) => {z.serialize_number_uint16(val);} + ); + case NumberFormat.Int8: + return new ZSTypeInfo( + (z: ZBytesSerializer, val: number) => {z.serialize_number_int8(val);} + ); + case NumberFormat.Uint8: + return new ZSTypeInfo( + (z: ZBytesSerializer, val: number) => {z.serialize_number_int16(val);} + ); + } + } + + /** + * Indicates that data should be serialized as a bigint in specified format. + * @returns Bigint serialization tag. + */ + export function bigint(format:BigIntFormat = BigIntFormat.Int64): ZSTypeInfo { + switch (format) { + case BigIntFormat.Int64: + return new ZSTypeInfo( + (z: ZBytesSerializer, val: bigint) => {z.serialize_bigint_int64(val);} + ); + case BigIntFormat.Uint64: + return new ZSTypeInfo( + (z: ZBytesSerializer, val: bigint) => {z.serialize_bigint_uint64(val);} + ); + } + } + + /** + * Indicates that data should be serialized as a string. + * @returns String serialization tag. + */ + export function string(): ZSTypeInfo { + return new ZSTypeInfo( + (z: ZBytesSerializer, val: string) => {z.serialize_string(val);} + ); + } + + /** + * Indicates that data should be serialized as a boolean. + * @returns Boolean serialization tag. + */ + export function boolean(): ZSTypeInfo { + return new ZSTypeInfo( + (z: ZBytesSerializer, val: boolean) => {z.serialize_boolean(val);} + ); + } + + /** + * Indicates that data should be serialized as a Uint8Array. + * @returns Uint8Array serialization tag. + */ + export function uint8array(): ZSTypeInfo> { + return new ZSTypeInfo( + (z: ZBytesSerializer, val: Uint8Array) => {z.serialize_uint8array(val);} + ); + } + + /** + * Indicates that data should be serialized as a Uint16Array. + * @returns Uint16Array serialization tag. + */ + export function uint16array(): ZSTypeInfo> { + return new ZSTypeInfo( + (z: ZBytesSerializer, val: Uint16Array) => {z.serialize_uint16array(val);} + ); + } + + /** + * Indicates that data should be serialized as a Uint32Array. + * @returns Uint32Array serialization tag. + */ + export function uint32array(): ZSTypeInfo> { + return new ZSTypeInfo( + (z: ZBytesSerializer, val: Uint32Array) => {z.serialize_uint32array(val);} + ); + } + + /** + * Indicates that data should be serialized as a BigUint64Array. + * @returns BigUint64Array serialization tag. + */ + export function biguint64array(): ZSTypeInfo> { + return new ZSTypeInfo( + (z: ZBytesSerializer, val: BigUint64Array) => {z.serialize_biguint64array(val);} + ); + } + + /** + * Indicates that data should be serialized as a Int8Array. + * @returns Int8Array serialization tag. + */ + export function int8array(): ZSTypeInfo> { + return new ZSTypeInfo( + (z: ZBytesSerializer, val: Int8Array) => {z.serialize_int8array(val);} + ); + } + + /** + * Indicates that data should be serialized as a Int16Array. + * @returns Int16Array serialization tag. + */ + export function int16array(): ZSTypeInfo> { + return new ZSTypeInfo( + (z: ZBytesSerializer, val: Int16Array) => {z.serialize_int16array(val);} + ); + } + + /** + * Indicates that data should be serialized as a Int32Array. + * @returns Int32Array serialization tag. + */ + export function int32array(): ZSTypeInfo> { + return new ZSTypeInfo( + (z: ZBytesSerializer, val: Int32Array) => {z.serialize_int32array(val);} + ); + } + + /** + * Indicates that data should be serialized as a BigInt64Array. + * @returns BigInt64Array serialization tag. + */ + export function bigint64array(): ZSTypeInfo> { + return new ZSTypeInfo( + (z: ZBytesSerializer, val: BigInt64Array) => {z.serialize_bigint64array(val);} + ); + } + + /** + * Indicates that data should be serialized as a Float32Array. + * @returns Float32Array serialization tag. + */ + export function float32array(): ZSTypeInfo> { + return new ZSTypeInfo( + (z: ZBytesSerializer, val: Float32Array) => {z.serialize_float32array(val);} + ); + } + + /** + * Indicates that data should be serialized as Float64Array. + * @returns Float64Array serialization tag. + */ + export function float64array(): ZSTypeInfo> { + return new ZSTypeInfo( + (z: ZBytesSerializer, val: Float64Array) => {z.serialize_float64array(val);} + ); + } + + /** + * Indicates that data should be deserialized as an object. + * @returns Object serialization tag. + */ + export function object(): ZSTypeInfo { + return new ZSTypeInfo( + (z: ZBytesSerializer, val: T) => {val.serialize_with_zserializer(z)} + ); + } + + /** + * Indicates that data should be serialized as an array. + * @param t An optional array element serialization tag (if omitted the default one will be used). + * @returns Array serialization tag. + */ + export function array(t?: ZSTypeInfo>): ZSTypeInfo[]> { + return new ZSTypeInfo( + (z: ZBytesSerializer, val: EnsureSerializeable[]) => {z.serialize_array(val, t)} + ); + } + + /** + * Indicates that data should be serialized as a map. + * @param t_key An optional key type serialization tag (if omitted the default one will be used). + * @param t_value An optional value type serialization tag (if omitted the default one will be used). + * @returns Array serialization tag. + */ + export function map(t_key?: ZSTypeInfo>, t_value?: ZSTypeInfo>): ZSTypeInfo, EnsureSerializeable>> { + return new ZSTypeInfo( + (z: ZBytesSerializer, val: Map, EnsureSerializeable>) => {z.serialize_map(val, t_key, t_value)}, + ); + } +} + +export class ZBytesDeserializer { + private _buffer: Uint8Array; + private _idx: number + /** + * new function to create a ZBytesDeserializer + * @param p payload to deserialize. + * @returns ZBytesSerializer + */ + constructor(zbytes: ZBytes) { + this._buffer = zbytes.to_bytes() + this._idx = 0 + } + + private _read_slice(len: number): Uint8Array { + const s = this._buffer.subarray(this._idx, this._idx + len) + if (s.length < len) { + throw new Error(`Array index is out of bounds: ${this._idx + len} / ${this._buffer.length}`); + } + this._idx += len + return s + } + + /** + * Reads length of the sequence previously written by {@link ZBytesSerializer.write_sequence_length} and advances the reading position. + * @returns Number of sequence elements. + */ + public read_sequence_length(): number { + let [res, bytes_read] = leb.decodeULEB128(this._buffer, this._idx) + this._idx += bytes_read + if (res > Number.MAX_SAFE_INTEGER) { + throw new Error(`Array length overflow: ${res}`); + } + return new Number(res).valueOf() + } + + /** + * Deserializes next portion of data as string and advances the reading position. + */ + public deserialize_string(): string { + let len = this.read_sequence_length() + const decoder = new TextDecoder() + return decoder.decode(this._read_slice(len)) + } + + /** + * Deserializes next portion of data as Uint8Array and advances the reading position. + */ + public deserialize_uint8array(): Uint8Array { + let len = this.read_sequence_length(); + return this._read_slice(len).slice() + } + + /** + * Deserializes next portion of data as Uint16Array and advances the reading position. + */ + public deserialize_uint16array(): Uint16Array { + let len = this.read_sequence_length(); + if (is_little_endian) { + return new Uint16Array(this._read_slice(len * 2).slice().buffer) + } else { + let out = new Uint16Array(len) + for (let i = 0; i < len; i++) { + out[i] = this.deserialize_number_uint16() + } + return out + } + } + + /** + * Deserializes next portion of data as Uint32Array and advances the reading position. + */ + public deserialize_uint32array(): Uint32Array { + let len = this.read_sequence_length(); + if (is_little_endian) { + return new Uint32Array(this._read_slice(len * 4).slice().buffer) + } else { + let out = new Uint32Array(len) + for (let i = 0; i < len; i++) { + out[i] = this.deserialize_number_uint32() + } + return out + } + } + + /** + * Deserializes next portion of data as BigUint64Array and advances the reading position. + */ + public deserialize_biguint64array(): BigUint64Array { + let len = this.read_sequence_length(); + if (is_little_endian) { + return new BigUint64Array(this._read_slice(len * 8).slice().buffer) + } else { + let out = new BigUint64Array(len) + for (let i = 0; i < len; i++) { + out[i] = this.deserialize_bigint_uint64() + } + return out + } + } + + /** + * Deserializes next portion of data as Int8Array and advances the reading position. + */ + public deserialize_int8array(): Int8Array { + let len = this.read_sequence_length(); + return new Int8Array(this._read_slice(len).slice().buffer) + } + + /** + * Deserializes next portion of data as Int16Array and advances the reading position. + */ + public deserialize_int16array(): Int16Array { + let len = this.read_sequence_length(); + if (is_little_endian) { + return new Int16Array(this._read_slice(len * 2).slice().buffer) + } else { + let out = new Int16Array(len) + for (let i = 0; i < len; i++) { + out[i] = this.deserialize_number_int16() + } + return out + } + } + + /** + * Deserializes next portion of data as Int32Array and advances the reading position. + */ + public deserialize_int32array(): Int32Array { + let len = this.read_sequence_length(); + if (is_little_endian) { + return new Int32Array(this._read_slice(len * 4).slice().buffer) + } else { + let out = new Int32Array(len) + for (let i = 0; i < len; i++) { + out[i] = this.deserialize_number_int32() + } + return out + } + } + + /** + * Deserializes next portion of data as BigInt64Array and advances the reading position. + */ + public deserialize_bigint64array(): BigInt64Array { + let len = this.read_sequence_length(); + if (is_little_endian) { + return new BigInt64Array(this._read_slice(len * 8).slice().buffer) + } else { + let out = new BigInt64Array(len) + for (let i = 0; i < len; i++) { + out[i] = this.deserialize_bigint_int64() + } + return out + } + } + + /** + * Deserializes next portion of data as Float32Array and advances the reading position. + */ + public deserialize_float32array(): Float32Array { + let len = this.read_sequence_length(); + if (is_little_endian) { + return new Float32Array(this._read_slice(len * 4).slice().buffer) + } else { + let out = new Float32Array(len) + for (let i = 0; i < len; i++) { + out[i] = this.deserialize_number_float32() + } + return out + } + } + + /** + * Deserializes next portion of data as Float64Array and advances the reading position. + */ + public deserialize_float64array(): Float64Array { + let len = this.read_sequence_length(); + if (is_little_endian) { + return new Float64Array(this._read_slice(len * 8).slice().buffer) + } else { + let out = new Float64Array(len) + for (let i = 0; i < len; i++) { + out[i] = this.deserialize_number_float64() + } + return out + } + } + + + + /** + * Deserializes next portion of data (serialized as 64 bit signed integer) as bigint and advances the reading position. + */ + public deserialize_bigint_int64(): bigint { + let data = this._read_slice(8).slice(); + let view = new DataView(data.buffer); + return view.getBigInt64(0, true); + } + + /** + * Deserializes next portion of data (serialized as 64 bit unsigned integer) as bigint and advances the reading position. + */ + public deserialize_bigint_uint64(): bigint { + let data = this._read_slice(8).slice(); + let view = new DataView(data.buffer); + return view.getBigUint64(0, true); + } + + /** + * Deserializes next portion of data (serialized as 64 bit floating point number) as number and advances the reading position. + */ + public deserialize_number_float64(): number { + let data = this._read_slice(8).slice(); + let view = new DataView(data.buffer); + return view.getFloat64(0, true); + } + + /** + * Deserializes next portion of data (serialized as 32 bit floating point number) as number and advances the reading position. + */ + public deserialize_number_float32(): number { + let data = this._read_slice(4).slice(); + let view = new DataView(data.buffer); + return view.getFloat32(0, true); + } + + /** + * Deserializes next portion of data (serialized as 32 bit signed integer) as number and advances the reading position. + */ + public deserialize_number_int32(): number { + let data = this._read_slice(4).slice(); + let view = new DataView(data.buffer); + return view.getInt32(0, true); + } + + /** + * Deserializes next portion of data (serialized as 32 bit unsigned integer) as number and advances the reading position. + */ + public deserialize_number_uint32(): number { + let data = this._read_slice(4).slice(); + let view = new DataView(data.buffer); + return view.getUint32(0, true); + } + + /** + * Deserializes next portion of data (serialized as 16 bit signed integer) as number and advances the reading position. + */ + public deserialize_number_int16(): number { + let data = this._read_slice(2).slice(); + let view = new DataView(data.buffer); + return view.getInt16(0, true); + } + + /** + * Deserializes next portion of data (serialized as 16 bit unsigned integer) as number and advances the reading position. + */ + public deserialize_number_uint16(): number { + let data = this._read_slice(2).slice(); + let view = new DataView(data.buffer); + return view.getUint16(0, true); + } + + /** + * Deserializes next portion of data (serialized as 8 bit signed integer) as number and advances the reading position. + */ + public deserialize_number_int8(): number { + let data = this._read_slice(1).slice(); + let view = new DataView(data.buffer); + return view.getInt8(0); + } + + /** + * Deserializes next portion of data (serialized as 8 bit unsigned integer) as number and advances the reading position. + */ + public deserialize_number_uint8(): number { + let data = this._read_slice(1).slice(); + let view = new DataView(data.buffer); + return view.getInt8(0); + } + + /** + * Deserializes next portion of data as a boolean and advances the reading position. + */ + public deserialize_boolean(): boolean { + if (this._idx >= this._buffer.length) { + throw new Error(`Array index is out of bounds: ${this._idx} / ${this._buffer.length}`); + } + const res = this._buffer[this._idx] + this._idx += 1 + if (res == 1) { + return true; + } else if (res == 0) { + return false + } else { + throw new Error(`Unexpected boolean value: ${res}`); + } + } + + /** + * Deserializes next portion of data as an array of specified type and advances the reading position. + * @param p Deserialization tag for array element. + */ + public deserialize_array(p: ZDTypeInfo): T[] { + const len = this.read_sequence_length() + let out = new Array(len) + for (let i = 0; i < len; i++) { + out[i] = p.deserialize(this) + } + return out + } + + /** + * Deserializes next portion of data as a map of specified key and value types and advances the reading position. + * @param p_key Deserialization tag for map key. + * @param p_value Deserialization tag for map value. + */ + public deserialize_map(p_key: ZDTypeInfo, p_value: ZDTypeInfo): Map { + const len = this.read_sequence_length() + let out = new Map() + for (let i = 0; i < len; i++) { + const key = p_key.deserialize(this) + const value = p_value.deserialize(this) + out.set(key, value) + } + return out + } + + /** + * Deserializes next portion of data as an object of specified type and advances the reading position. + * @param create A new function to create an object instance where data will be deserialized. + */ + public deserialize_object(create: new () => T): T { + let o = new create() + o.deserialize_with_zdeserializer(this) + return o + } + + /** + * Deserializes next portion of data into any supported type and advances the reading position. + * Supported types are: + * - built-in types: number, bigint, string, boolean, + * - TypedArrays, + * - arrays and maps of supported types. + * @param p Deserialization tag. + * @returns Deserialized value. + */ + public deserialize(p: ZDTypeInfo): T { + return p.deserialize(this) + } + + /** + * @returns True if all payload bytes were used, false otherwise. + */ + public is_done() : boolean { + return this._buffer.length == this._idx + } +} + +/** + * Serializes any supported type. + * Supported types are: + * - built-in types: number, bigint, string, boolean, + * - TypedArrays, + * - arrays and maps of supported types. + * @param val Value to serialize. + * @param t An optional serialization tag (if ommited, the default one will be used). + * @returns Payload. + */ +export function zserialize(val: EnsureSerializeable, t?: ZSTypeInfo>): ZBytes { + const s = new ZBytesSerializer() + s.serialize(val, t) + return s.finish() +} + +/** + * Deserializes payload into any supported type and advances the reading position. + * Supported types are: + * - built-in types: number, bigint, string, boolean, + * - types that implement ZDeserializeable interface, + * - TypedArrays, + * - arrays and maps of supported types. + * @param t Deserialization tag. + * @param data Payload to deserialize. + * @returns Deserialized value. + */ +export function zdeserialize(t: ZDTypeInfo, data: ZBytes): T { + const d = new ZBytesDeserializer(data) + const res = d.deserialize(t) + if (!d.is_done()) { + throw new Error(`Payload contains more bytes than required for deserialization`); + } + return res +} \ No newline at end of file diff --git a/zenoh-ts/src/index.ts b/zenoh-ts/src/index.ts index 421763c..79e7f32 100644 --- a/zenoh-ts/src/index.ts +++ b/zenoh-ts/src/index.ts @@ -14,7 +14,7 @@ // API Layer Files import { KeyExpr, IntoKeyExpr } from "./key_expr.js"; -import { ZBytes, IntoZBytes, deserialize_bool, deserialize_uint, deserialize_int, deserialize_float, deserialize_string } from "./z_bytes.js"; +import { ZBytes, IntoZBytes } from "./z_bytes.js"; import { CongestionControl, ConsolidationMode, Priority, Reliability, Sample, SampleKind } from "./sample.js"; import { Publisher, Subscriber, FifoChannel, RingChannel } from "./pubsub.js"; import { IntoSelector, Parameters, IntoParameters, Query, Queryable, Reply, ReplyError, Selector } from "./query.js"; @@ -30,7 +30,7 @@ import { Duration } from 'typed-duration' // Exports export { KeyExpr, IntoKeyExpr }; -export { ZBytes, IntoZBytes, deserialize_bool, deserialize_uint, deserialize_int, deserialize_float, deserialize_string }; +export { ZBytes, IntoZBytes }; export { CongestionControl, ConsolidationMode, Priority, Reliability, Sample, SampleKind }; export { Publisher, Subscriber, FifoChannel, RingChannel }; export { IntoSelector, Parameters, IntoParameters, Query, Queryable, Reply, ReplyError, Selector }; diff --git a/zenoh-ts/src/key_expr/zenoh_keyexpr_wrapper_bg.wasm b/zenoh-ts/src/key_expr/zenoh_keyexpr_wrapper_bg.wasm index a2e92e3..3817a9a 100644 Binary files a/zenoh-ts/src/key_expr/zenoh_keyexpr_wrapper_bg.wasm and b/zenoh-ts/src/key_expr/zenoh_keyexpr_wrapper_bg.wasm differ diff --git a/zenoh-ts/src/z_bytes.ts b/zenoh-ts/src/z_bytes.ts index 3b54444..49832aa 100644 --- a/zenoh-ts/src/z_bytes.ts +++ b/zenoh-ts/src/z_bytes.ts @@ -18,11 +18,8 @@ export type IntoZBytes = | ZBytes | Uint8Array - | number[] - | Array | String - | string - | boolean; + | string; /** * Class to represent an Array of Bytes received from Zenoh @@ -42,8 +39,6 @@ export class ZBytes { const encoder = new TextEncoder(); const encoded = encoder.encode(bytes.toString()); this._buffer = encoded; - } else if (typeof bytes === "boolean") { - this._buffer = Uint8Array.from([bytes === true ? 1 : 0]); } else { this._buffer = Uint8Array.from(bytes); } @@ -54,7 +49,7 @@ export class ZBytes { * * @returns number */ - len(): number { + public len(): number { return this._buffer.length; } @@ -63,7 +58,7 @@ export class ZBytes { * * @returns boolean */ - is_empty(): boolean { + public is_empty(): boolean { return this._buffer.length == 0; } @@ -72,138 +67,31 @@ export class ZBytes { * * @returns ZBytes */ - empty(): ZBytes { + public empty(): ZBytes { return new ZBytes(new Uint8Array()); } /** - * return the underlying Uint8Array buffer + * returns the underlying Uint8Array buffer * * @returns Uint8Array */ - to_bytes(): Uint8Array { + public to_bytes(): Uint8Array { return this._buffer } /** - * Deserialize the unit8array buffer into the desired type - * - * @returns Uint8Array - */ - // deserialize(d: Deserialize): T { - // return d.deserialize(this.buffer); - // } - - deserialize(func: (buffer: Uint8Array) => T): T { - return func(this._buffer); - } - -} - -/** - * Convienence class to convert Zbytes to a string - * - * @returns bool - */ -export function deserialize_bool(buffer: Uint8Array): boolean { - if (buffer.length != 1) { - throw "Boolean Deserialization Failed buffer length excepted 1"; - } - switch (buffer[0]) { - case 0: - return false - case 1: - return true - default: - throw "Boolean Deserialization Failed expected value 0 or 1"; - } -} - -/** - * Convienence class to convert Zbytes to a Unsigned Integer - * - * @returns number | bigint - */ -export function deserialize_uint(buffer: Uint8Array): number | bigint { - let buff_length = buffer.length; - - if (buffer.length > 8) { - throw "Unsigned Integer Deserialization Failed buffer length excepted < 8 bytes, actual : " + buffer.length; - } - - let padded = new Uint8Array(8); - padded.set(buffer, 0) - - const data_view = new DataView(padded.buffer, padded.byteOffset, padded.byteLength); - if (buff_length > 4) { - return data_view.getBigUint64(0, true); - } else if (buff_length > 2) { - return data_view.getUint32(0, true); - } else if (buff_length > 1) { - return data_view.getUint16(0, true); - } else { - return data_view.getUint8(0); - } -} - - -/** - * Convienence class to convert Zbytes to a Signed Integer - * - * @returns number | bigint - */ -export function deserialize_int(buffer: Uint8Array): number | bigint { - let buff_length = buffer.length; - - if (buffer.length > 8) { - throw "Signed Integer Deserialization Failed buffer length excepted < 8 bytes, actual : " + buffer.length; + * decodes the underlying Uint8Array buffer as UTF-8 string + * + * @returns string + */ + public to_string(): string { + let decoder = new TextDecoder(); + return decoder.decode(this._buffer) } - let padded = new Uint8Array(8); - padded.set(buffer, 0) - - const data_view = new DataView(padded.buffer, padded.byteOffset, padded.byteLength); - if (buff_length > 4) { - return data_view.getBigInt64(0, true); - } else if (buff_length > 2) { - return data_view.getInt32(0, true); - } else if (buff_length > 1) { - return data_view.getInt16(0, true); - } else { - return data_view.getInt8(0); - } } -/** - * Convienence class to convert Zbytes to a Signed Integer - * - * @returns number - */ -export function deserialize_float(buffer: Uint8Array): number { - let buff_length = buffer.length; - - if (buffer.length > 8) { - throw "Floating Point Deserialization Failed buffer length excepted < 8 bytes, actual : " + buffer.length; - } - let padded = new Uint8Array(8); - padded.set(buffer, 0) - const data_view = new DataView(padded.buffer, padded.byteOffset, padded.byteLength); - if (buff_length > 4) { - return data_view.getFloat64(0, true); - } else { - return data_view.getFloat32(0, true); - } -} -/** - * Convienence class to convert Zbytes to a string - * - * @returns string - */ - -export function deserialize_string(buffer: Uint8Array): string { - let decoder = new TextDecoder(); - return decoder.decode(buffer) -} diff --git a/zenoh-ts/yarn.lock b/zenoh-ts/yarn.lock index f6f8908..10bd082 100644 --- a/zenoh-ts/yarn.lock +++ b/zenoh-ts/yarn.lock @@ -3,11 +3,11 @@ "@eslint-community/eslint-utils@^4.2.0": - version "4.4.0" - resolved "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz" - integrity sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA== + version "4.4.1" + resolved "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.1.tgz" + integrity sha512-s3O3waFUrMV8P/XaF/+ZTp1X9XBZW1a4B97ZnjQF2KYWaFD2A8KyFBsrsfSjEmjn3RGWAIuvlneuZm3CUK3jbA== dependencies: - eslint-visitor-keys "^3.3.0" + eslint-visitor-keys "^3.4.3" "@eslint-community/regexpp@^4.12.1": version "4.12.1" @@ -23,10 +23,10 @@ debug "^4.3.1" minimatch "^3.1.2" -"@eslint/core@^0.9.0": - version "0.9.1" - resolved "https://registry.npmjs.org/@eslint/core/-/core-0.9.1.tgz" - integrity sha512-GuUdqkyyzQI5RMIWkHhvTWLCyLo1jNK3vzkSyaExH5kHPDHcuL2VOpHjmMY+y3+NC69qAKToBqldTBgYeLSr9Q== +"@eslint/core@^0.10.0": + version "0.10.0" + resolved "https://registry.npmjs.org/@eslint/core/-/core-0.10.0.tgz" + integrity sha512-gFHJ+xBOo4G3WRlR1e/3G8A6/KZAH6zcE/hkLRCZTi/B9avAG365QhFA8uOGzTMqgTghpn7/fSnscW++dpMSAw== dependencies: "@types/json-schema" "^7.0.15" @@ -45,21 +45,22 @@ minimatch "^3.1.2" strip-json-comments "^3.1.1" -"@eslint/js@9.16.0": - version "9.16.0" - resolved "https://registry.npmjs.org/@eslint/js/-/js-9.16.0.tgz" - integrity sha512-tw2HxzQkrbeuvyj1tG2Yqq+0H9wGoI2IMk4EOsQeX+vmd75FtJAzf+gTA69WF+baUKRYQ3x2kbLE08js5OsTVg== +"@eslint/js@9.19.0": + version "9.19.0" + resolved "https://registry.npmjs.org/@eslint/js/-/js-9.19.0.tgz" + integrity sha512-rbq9/g38qjfqFLOVPvwjIvFFdNziEC5S65jmjPw5r6A//QH+W91akh9irMwjDN8zKUTak6W9EsAv4m/7Wnw0UQ== "@eslint/object-schema@^2.1.5": version "2.1.5" resolved "https://registry.npmjs.org/@eslint/object-schema/-/object-schema-2.1.5.tgz" integrity sha512-o0bhxnL89h5Bae5T318nFoFzGy+YE5i/gGkoPAgkmTVdRKTiv3p8JHevPiPaMwoloKfEiiaHlawCqaZMqRm+XQ== -"@eslint/plugin-kit@^0.2.3": - version "0.2.4" - resolved "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.2.4.tgz" - integrity sha512-zSkKow6H5Kdm0ZUQUB2kV5JIXqoG0+uH5YADhaEHswm664N9Db8dXSi0nMJpacpMf+MyyglF1vnZohpEg5yUtg== +"@eslint/plugin-kit@^0.2.5": + version "0.2.5" + resolved "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.2.5.tgz" + integrity sha512-lB05FkqEdUg2AA0xEbUz0SnkXT1LcCTa438W4IWTUh4hdOnVbQyOJ81OrDXsJk/LSiJHubgGEFoR5EHq1NsH1A== dependencies: + "@eslint/core" "^0.10.0" levn "^0.4.1" "@humanfs/core@^0.19.1": @@ -90,19 +91,203 @@ resolved "https://registry.npmjs.org/@humanwhocodes/retry/-/retry-0.4.1.tgz" integrity sha512-c7hNEllBlenFTHBky65mhq8WD2kbN9Q6gk0bTk8lSBvc554jpXSkST1iePudpt7+A/AQvuHs9EMqjHDXMY1lrA== -"@shikijs/core@1.12.1": - version "1.12.1" - resolved "https://registry.npmjs.org/@shikijs/core/-/core-1.12.1.tgz" - integrity sha512-biCz/mnkMktImI6hMfMX3H9kOeqsInxWEyCHbSlL8C/2TR1FqfmGxTLRNwYCKsyCyxWLbB8rEqXRVZuyxuLFmA== +"@shikijs/core@1.29.1": + version "1.29.1" + resolved "https://registry.npmjs.org/@shikijs/core/-/core-1.29.1.tgz" + integrity sha512-Mo1gGGkuOYjDu5H8YwzmOuly9vNr8KDVkqj9xiKhhhFS8jisAtDSEWB9hzqRHLVQgFdA310e8XRJcW4tYhRB2A== + dependencies: + "@shikijs/engine-javascript" "1.29.1" + "@shikijs/engine-oniguruma" "1.29.1" + "@shikijs/types" "1.29.1" + "@shikijs/vscode-textmate" "^10.0.1" + "@types/hast" "^3.0.4" + hast-util-to-html "^9.0.4" + +"@shikijs/engine-javascript@1.29.1": + version "1.29.1" + resolved "https://registry.npmjs.org/@shikijs/engine-javascript/-/engine-javascript-1.29.1.tgz" + integrity sha512-Hpi8k9x77rCQ7F/7zxIOUruNkNidMyBnP5qAGbLFqg4kRrg1HZhkB8btib5EXbQWTtLb5gBHOdBwshk20njD7Q== + dependencies: + "@shikijs/types" "1.29.1" + "@shikijs/vscode-textmate" "^10.0.1" + oniguruma-to-es "^2.2.0" + +"@shikijs/engine-oniguruma@1.29.1": + version "1.29.1" + resolved "https://registry.npmjs.org/@shikijs/engine-oniguruma/-/engine-oniguruma-1.29.1.tgz" + integrity sha512-gSt2WhLNgEeLstcweQOSp+C+MhOpTsgdNXRqr3zP6M+BUBZ8Md9OU2BYwUYsALBxHza7hwaIWtFHjQ/aOOychw== + dependencies: + "@shikijs/types" "1.29.1" + "@shikijs/vscode-textmate" "^10.0.1" + +"@shikijs/langs@1.29.1": + version "1.29.1" + resolved "https://registry.npmjs.org/@shikijs/langs/-/langs-1.29.1.tgz" + integrity sha512-iERn4HlyuT044/FgrvLOaZgKVKf3PozjKjyV/RZ5GnlyYEAZFcgwHGkYboeBv2IybQG1KVS/e7VGgiAU4JY2Gw== + dependencies: + "@shikijs/types" "1.29.1" + +"@shikijs/themes@1.29.1": + version "1.29.1" + resolved "https://registry.npmjs.org/@shikijs/themes/-/themes-1.29.1.tgz" + integrity sha512-lb11zf72Vc9uxkl+aec2oW1HVTHJ2LtgZgumb4Rr6By3y/96VmlU44bkxEb8WBWH3RUtbqAJEN0jljD9cF7H7g== dependencies: + "@shikijs/types" "1.29.1" + +"@shikijs/types@1.29.1": + version "1.29.1" + resolved "https://registry.npmjs.org/@shikijs/types/-/types-1.29.1.tgz" + integrity sha512-aBqAuhYRp5vSir3Pc9+QPu9WESBOjUo03ao0IHLC4TyTioSsp/SkbAZSrIH4ghYYC1T1KTEpRSBa83bas4RnPA== + dependencies: + "@shikijs/vscode-textmate" "^10.0.1" "@types/hast" "^3.0.4" +"@shikijs/vscode-textmate@^10.0.1": + version "10.0.1" + resolved "https://registry.npmjs.org/@shikijs/vscode-textmate/-/vscode-textmate-10.0.1.tgz" + integrity sha512-fTIQwLF+Qhuws31iw7Ncl1R3HUDtGwIipiJ9iU+UsDUwMhegFcQKQHd51nZjb7CArq0MvON8rbgCGQYWHUKAdg== + +"@thi.ng/api@^8.11.19": + version "8.11.19" + resolved "https://registry.yarnpkg.com/@thi.ng/api/-/api-8.11.19.tgz#9ce8eb5657a28ddbd82a1864792b59a753a4ee33" + integrity sha512-ffK8nyNDd3kiwiijpb0Uv/0MtRUYpRtJj3K8OwFXdCzboll+/DNvXpfAlBMwSkLqZR0GighDwApyl0/4njiHCg== + +"@thi.ng/arrays@^2.10.14": + version "2.10.14" + resolved "https://registry.yarnpkg.com/@thi.ng/arrays/-/arrays-2.10.14.tgz#a6202d3e208e2930554083b24c8a7143e23e8d56" + integrity sha512-hTuot92azDcX/GbWIFtbrKEPTThQn9tlRqKAnGL0xerCXEvHlvJ9F2zgf/crhBt8vcP8ca/P+4xYJYLKa54iBw== + dependencies: + "@thi.ng/api" "^8.11.19" + "@thi.ng/checks" "^3.6.22" + "@thi.ng/compare" "^2.4.11" + "@thi.ng/equiv" "^2.1.75" + "@thi.ng/errors" "^2.5.25" + "@thi.ng/random" "^4.1.10" + +"@thi.ng/binary@^3.4.42": + version "3.4.42" + resolved "https://registry.yarnpkg.com/@thi.ng/binary/-/binary-3.4.42.tgz#2fdd71c7c06d9bfb38bd94b71598343ccf8d89a9" + integrity sha512-DU5JiBOONjx4synwos2GPaq8ByIfPSx6H6BsBmTf/Ou1PiABMlFuHlz8aOzw/Z1jUTYzb04arwUpYl1MVKjrAg== + dependencies: + "@thi.ng/api" "^8.11.19" + +"@thi.ng/checks@^3.6.22": + version "3.6.22" + resolved "https://registry.yarnpkg.com/@thi.ng/checks/-/checks-3.6.22.tgz#00b3c6e4f8562f4108795b645a97cfc588c7cdcd" + integrity sha512-CMxQHrxvHnAVnmhxfP44GVS1TmAUWLsX8uZTVrL4IQcWzVVyHgvD6uXYw5E7kaZCR2S6wnS+Ng5oOCBE0EU/Hg== + dependencies: + tslib "^2.8.1" + +"@thi.ng/compare@^2.4.11": + version "2.4.11" + resolved "https://registry.yarnpkg.com/@thi.ng/compare/-/compare-2.4.11.tgz#63cf4bebcd15575265f68bcf85d9b61c953c9cf6" + integrity sha512-SNbRrf19ntPmpXVkdMK04ZRRSDzPmRxxV9WKdH6+3J5NkYbASffi9o9WWun9In09P1+/Zh5yYfi2LzNsIDHNDw== + dependencies: + "@thi.ng/api" "^8.11.19" + +"@thi.ng/compose@^3.0.22": + version "3.0.22" + resolved "https://registry.yarnpkg.com/@thi.ng/compose/-/compose-3.0.22.tgz#a7b4f4927fd896c0e37a797c8f2a2aa1f7a14271" + integrity sha512-PdXT/X4Ca8VfzyGryhAlw7PYyPvbRhpFqT4hej2oOgGuXeifoNr2J6WejTEwK8wA4F57onHHr7TisPVNfN/PMQ== + dependencies: + "@thi.ng/api" "^8.11.19" + "@thi.ng/errors" "^2.5.25" + +"@thi.ng/equiv@^2.1.75": + version "2.1.75" + resolved "https://registry.yarnpkg.com/@thi.ng/equiv/-/equiv-2.1.75.tgz#f6fa49df08c1fd17da1302e057f1809cea3b5cb2" + integrity sha512-AoQQgrhW0xtXgxkrDK5EP5Y9Fe/QBGCmQgVKJ2G7uYCW/IbN/nTZEUM6011v41ydpmKl4wJjmr+s3StcIeDfdQ== + +"@thi.ng/errors@^2.5.25": + version "2.5.25" + resolved "https://registry.yarnpkg.com/@thi.ng/errors/-/errors-2.5.25.tgz#4a9b91fbe51413b151d3758bdf6ef7e53cbc2d1f" + integrity sha512-PmK56hWGvRWr9Eq0V5xkV4tQvhjPtfvv6urFONP/D0gwFQXj+v6rcDYkAFLzOkbLqa0DYtkgvUsMklF/L53upA== + +"@thi.ng/hex@^2.3.63": + version "2.3.63" + resolved "https://registry.yarnpkg.com/@thi.ng/hex/-/hex-2.3.63.tgz#75f91f6e4d4dec22046a74526b30f81d32d138f4" + integrity sha512-5xaQEKdaPls8de4zx4piPjCP13AHZLlyJCwHp4enSfeH5ZmDR3/aRwbmJod4FlJAvQdvDa3jBz+OtHNdxwrPLg== + +"@thi.ng/leb128@^3.1.36": + version "3.1.36" + resolved "https://registry.yarnpkg.com/@thi.ng/leb128/-/leb128-3.1.36.tgz#9516fe5113d030a617039da3c8f5361d62185940" + integrity sha512-NfEfBpjtOwGJxgxDXyuLYxfmikT8u7TPT3J1rc51JmScxtTXZQkpgR3ORwy/xshILmGVMID2vww3NshZbSHqZg== + dependencies: + "@thi.ng/checks" "^3.6.22" + "@thi.ng/errors" "^2.5.25" + "@thi.ng/transducers-binary" "^2.1.152" + +"@thi.ng/math@^5.11.19": + version "5.11.19" + resolved "https://registry.yarnpkg.com/@thi.ng/math/-/math-5.11.19.tgz#0a0ff7ad249f2960fcc3b39f930568d4a19a2b35" + integrity sha512-nsS1hP0rtgfuLtD6fLEtNTv07DlPZjKlgRoTrJcpkr47zzGcabwxo7a2VlHYFjhnShVUVSdQTFCnSSHN40drOQ== + dependencies: + "@thi.ng/api" "^8.11.19" + +"@thi.ng/memoize@^4.0.9": + version "4.0.9" + resolved "https://registry.yarnpkg.com/@thi.ng/memoize/-/memoize-4.0.9.tgz#57ab73ed0e7ff98df94c7182a703b0dbd6edf8c3" + integrity sha512-YQD5lOew7mAZRripl3ylyOOq0OJ7yv/9D2o9w0Rd3ZrL2nl49tbticcH0V6nSKHEJhJSeRftCjmxNXNZulZkBw== + dependencies: + "@thi.ng/api" "^8.11.19" + +"@thi.ng/random@^4.1.10": + version "4.1.10" + resolved "https://registry.yarnpkg.com/@thi.ng/random/-/random-4.1.10.tgz#732bae76ffb397ca42e771bbe94f6c8c2fbd815a" + integrity sha512-BBEAr0fg0pDoHtk4iBsdyLfZ9HcGvzeOwdAiXb3iibPhCL+h4lpjpmxy8yCyD7CatlnUICfbDdiY59X5qKJMgA== + dependencies: + "@thi.ng/api" "^8.11.19" + "@thi.ng/errors" "^2.5.25" + +"@thi.ng/strings@^3.9.4": + version "3.9.4" + resolved "https://registry.yarnpkg.com/@thi.ng/strings/-/strings-3.9.4.tgz#782bbf81ea441c0d2671ca54654cf4c639762879" + integrity sha512-Ut9Elrp5HHiQjtJALjqKljzhDZYEgVMgwjN3EuEgHwBcrtvgthuhK6gKf2cGr0O8sqIjcctnhWqu7nE4QLuVaQ== + dependencies: + "@thi.ng/api" "^8.11.19" + "@thi.ng/errors" "^2.5.25" + "@thi.ng/hex" "^2.3.63" + "@thi.ng/memoize" "^4.0.9" + +"@thi.ng/timestamp@^1.1.4": + version "1.1.4" + resolved "https://registry.yarnpkg.com/@thi.ng/timestamp/-/timestamp-1.1.4.tgz#6800c1fd8f9fc349e3d601a445707f52f1fc7d97" + integrity sha512-Rsfa1ypD3Ulkh2RDbj19hb8hCXRzUjy+1gpbovy2Bnys7VPNXRyHEaEZvqRNzj+jTzylvFNbi8QLArX7RXzeqw== + +"@thi.ng/transducers-binary@^2.1.152": + version "2.1.152" + resolved "https://registry.yarnpkg.com/@thi.ng/transducers-binary/-/transducers-binary-2.1.152.tgz#320c4875f73ce31e9bcca5b2481ef5e4365636a8" + integrity sha512-0QG5cTheIZGcIaDDsaCaSSYvDXhFqbmdFng8HNLzl5EIcSecRC0R3rT7N0SxN+JxGMDRmZFQk/vFHlqulxaTew== + dependencies: + "@thi.ng/binary" "^3.4.42" + "@thi.ng/compose" "^3.0.22" + "@thi.ng/errors" "^2.5.25" + "@thi.ng/hex" "^2.3.63" + "@thi.ng/random" "^4.1.10" + "@thi.ng/strings" "^3.9.4" + "@thi.ng/transducers" "^9.2.17" + +"@thi.ng/transducers@^9.2.17": + version "9.2.17" + resolved "https://registry.yarnpkg.com/@thi.ng/transducers/-/transducers-9.2.17.tgz#8504f45178c3875841c9afcb9dcd68a3966c4b22" + integrity sha512-LjbAbRAcpHi0gv6aW7+5ijJYJjhQtJoszEvjCC025RQ3pjXXD3gkRs8nnJULk6ibkcEcCoP5Q0WBWNAXusInQg== + dependencies: + "@thi.ng/api" "^8.11.19" + "@thi.ng/arrays" "^2.10.14" + "@thi.ng/checks" "^3.6.22" + "@thi.ng/compare" "^2.4.11" + "@thi.ng/compose" "^3.0.22" + "@thi.ng/errors" "^2.5.25" + "@thi.ng/math" "^5.11.19" + "@thi.ng/random" "^4.1.10" + "@thi.ng/timestamp" "^1.1.4" + "@types/estree@^1.0.6": version "1.0.6" resolved "https://registry.npmjs.org/@types/estree/-/estree-1.0.6.tgz" integrity sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw== -"@types/hast@^3.0.4": +"@types/hast@^3.0.0", "@types/hast@^3.0.4": version "3.0.4" resolved "https://registry.npmjs.org/@types/hast/-/hast-3.0.4.tgz" integrity sha512-WPs+bbQw5aCj+x6laNGWLH3wviHtoCv/P3+otBhbOhJgG8qtpdAMlTCxLtsTWA7LH1Oh/bFCHsBn0TPS5m30EQ== @@ -114,6 +299,13 @@ resolved "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz" integrity sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA== +"@types/mdast@^4.0.0": + version "4.0.4" + resolved "https://registry.npmjs.org/@types/mdast/-/mdast-4.0.4.tgz" + integrity sha512-kGaNbPh1k7AFzgpud/gMdvIm5xuECykRR+JnWKQno9TAXVa6WIVCGTPvYGekIDL4uwCZQSYbUxNBSb1aUo79oA== + dependencies: + "@types/unist" "*" + "@types/node@20.9.1": version "20.9.1" resolved "https://registry.npmjs.org/@types/node/-/node-20.9.1.tgz" @@ -121,16 +313,21 @@ dependencies: undici-types "~5.26.4" -"@types/unist@*": - version "3.0.2" - resolved "https://registry.npmjs.org/@types/unist/-/unist-3.0.2.tgz" - integrity sha512-dqId9J8K/vGi5Zr7oo212BGii5m3q5Hxlkwy3WpYuKPklmBEvsbMYYyLxAQpSffdLl/gdW0XUpKWFvYmyoWCoQ== +"@types/unist@*", "@types/unist@^3.0.0": + version "3.0.3" + resolved "https://registry.npmjs.org/@types/unist/-/unist-3.0.3.tgz" + integrity sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q== "@types/uuid@^10.0.0": version "10.0.0" resolved "https://registry.npmjs.org/@types/uuid/-/uuid-10.0.0.tgz" integrity sha512-7gqG38EyHgyP1S+7+xomFtL+ZNHcKv6DwNaCZmJmo1vgMugyF3TCnXVg4t1uk89mLNwnLtnY3TpOpCOyp1/xHQ== +"@ungap/structured-clone@^1.0.0": + version "1.3.0" + resolved "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.3.0.tgz" + integrity sha512-WmoN8qaIAo7WTYWbAZuG8PYEhn5fkz7dZrqTBZ7dtt//lL2Gwms1IcnQ5yHqjDfX8Ft5j4YzDM23f87zBfDe9g== + acorn-jsx@^5.3.2: version "5.3.2" resolved "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz" @@ -193,6 +390,11 @@ callsites@^3.0.0: resolved "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz" integrity sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ== +ccount@^2.0.0: + version "2.0.1" + resolved "https://registry.npmjs.org/ccount/-/ccount-2.0.1.tgz" + integrity sha512-eyrF0jiFpY+3drT6383f1qhkbGsLSifNAjA61IUjZjmLCWjItY6LB9ft9YhoDgwfmclB2zhu51Lc7+95b8NRAg== + chalk@^4.0.0: version "4.1.2" resolved "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz" @@ -206,6 +408,16 @@ channel-ts@^0.1.2: resolved "https://registry.npmjs.org/channel-ts/-/channel-ts-0.1.2.tgz" integrity sha512-cI/XiDF+jB0v95Xup8xlM7k93lT3xwPl0WdjEZ9w9aUMf5N+3GQevspK2EDYfMyxcKcXdN1F6PDpuYRpUfaZmg== +character-entities-html4@^2.0.0: + version "2.1.0" + resolved "https://registry.npmjs.org/character-entities-html4/-/character-entities-html4-2.1.0.tgz" + integrity sha512-1v7fgQRj6hnSwFpq1Eu0ynr/CDEw0rXo2B61qXrLNdHZmPKgb7fqS1a2JwF0rISo9q77jDI8VMEHoApn8qDoZA== + +character-entities-legacy@^3.0.0: + version "3.0.0" + resolved "https://registry.npmjs.org/character-entities-legacy/-/character-entities-legacy-3.0.0.tgz" + integrity sha512-RpPp0asT/6ufRm//AJVwpViZbGM/MkjQFxJccQRHmISF/22NBtsHqAWmL+/pmkPWoIUJdWyeVleTl1wydHATVQ== + color-convert@^2.0.1: version "2.0.1" resolved "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz" @@ -218,12 +430,17 @@ color-name@~1.1.4: resolved "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz" integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== +comma-separated-tokens@^2.0.0: + version "2.0.3" + resolved "https://registry.npmjs.org/comma-separated-tokens/-/comma-separated-tokens-2.0.3.tgz" + integrity sha512-Fu4hJdvzeylCfQPp9SGWidpzrMs7tTrlu6Vb8XGaRGck8QSNZJJp538Wrb60Lax4fPwR64ViY468OIUTbRlGZg== + concat-map@0.0.1: version "0.0.1" resolved "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz" integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg== -cross-spawn@^7.0.5: +cross-spawn@^7.0.6: version "7.0.6" resolved "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz" integrity sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA== @@ -233,9 +450,9 @@ cross-spawn@^7.0.5: which "^2.0.1" debug@^4.3.1, debug@^4.3.2: - version "4.3.7" - resolved "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz" - integrity sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ== + version "4.4.0" + resolved "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz" + integrity sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA== dependencies: ms "^2.1.3" @@ -244,6 +461,23 @@ deep-is@^0.1.3: resolved "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz" integrity sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ== +dequal@^2.0.0: + version "2.0.3" + resolved "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz" + integrity sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA== + +devlop@^1.0.0: + version "1.1.0" + resolved "https://registry.npmjs.org/devlop/-/devlop-1.1.0.tgz" + integrity sha512-RWmIqhcFf1lRYBvNmr7qTNuyCt/7/ns2jbpp1+PalgE/rDQcBT0fioSMUpJ93irlUhC5hrg4cYqe6U+0ImW0rA== + dependencies: + dequal "^2.0.0" + +emoji-regex-xs@^1.0.0: + version "1.0.0" + resolved "https://registry.npmjs.org/emoji-regex-xs/-/emoji-regex-xs-1.0.0.tgz" + integrity sha512-LRlerrMYoIDrT6jgpeZ2YYl/L8EulRTt5hQcYjy5AInh7HWXKimpqx68aknBFpGL2+/IcogTcaydJEgaTmOpDg== + entities@^4.4.0: version "4.5.0" resolved "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz" @@ -262,7 +496,7 @@ eslint-scope@^8.2.0: esrecurse "^4.3.0" estraverse "^5.2.0" -eslint-visitor-keys@^3.3.0: +eslint-visitor-keys@^3.4.3: version "3.4.3" resolved "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz" integrity sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag== @@ -273,17 +507,17 @@ eslint-visitor-keys@^4.2.0: integrity sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw== eslint@^9.10.0: - version "9.16.0" - resolved "https://registry.npmjs.org/eslint/-/eslint-9.16.0.tgz" - integrity sha512-whp8mSQI4C8VXd+fLgSM0lh3UlmcFtVwUQjyKCFfsp+2ItAIYhlq/hqGahGqHE6cv9unM41VlqKk2VtKYR2TaA== + version "9.19.0" + resolved "https://registry.npmjs.org/eslint/-/eslint-9.19.0.tgz" + integrity sha512-ug92j0LepKlbbEv6hD911THhoRHmbdXt2gX+VDABAW/Ir7D3nqKdv5Pf5vtlyY6HQMTEP2skXY43ueqTCWssEA== dependencies: "@eslint-community/eslint-utils" "^4.2.0" "@eslint-community/regexpp" "^4.12.1" "@eslint/config-array" "^0.19.0" - "@eslint/core" "^0.9.0" + "@eslint/core" "^0.10.0" "@eslint/eslintrc" "^3.2.0" - "@eslint/js" "9.16.0" - "@eslint/plugin-kit" "^0.2.3" + "@eslint/js" "9.19.0" + "@eslint/plugin-kit" "^0.2.5" "@humanfs/node" "^0.16.6" "@humanwhocodes/module-importer" "^1.0.1" "@humanwhocodes/retry" "^0.4.1" @@ -291,7 +525,7 @@ eslint@^9.10.0: "@types/json-schema" "^7.0.15" ajv "^6.12.4" chalk "^4.0.0" - cross-spawn "^7.0.5" + cross-spawn "^7.0.6" debug "^4.3.2" escape-string-regexp "^4.0.0" eslint-scope "^8.2.0" @@ -384,9 +618,9 @@ flat-cache@^4.0.0: keyv "^4.5.4" flatted@^3.2.9: - version "3.3.1" - resolved "https://registry.npmjs.org/flatted/-/flatted-3.3.1.tgz" - integrity sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw== + version "3.3.2" + resolved "https://registry.npmjs.org/flatted/-/flatted-3.3.2.tgz" + integrity sha512-AiwGJM8YcNOaobumgtng+6NHuOqC3A7MixFeDafM3X9cIUM+xUXoS5Vfgf+OihAYe20fxqNM9yPBXJzRtZ/4eA== glob-parent@^6.0.2: version "6.0.2" @@ -405,6 +639,35 @@ has-flag@^4.0.0: resolved "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz" integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== +hast-util-to-html@^9.0.4: + version "9.0.4" + resolved "https://registry.npmjs.org/hast-util-to-html/-/hast-util-to-html-9.0.4.tgz" + integrity sha512-wxQzXtdbhiwGAUKrnQJXlOPmHnEehzphwkK7aluUPQ+lEc1xefC8pblMgpp2w5ldBTEfveRIrADcrhGIWrlTDA== + dependencies: + "@types/hast" "^3.0.0" + "@types/unist" "^3.0.0" + ccount "^2.0.0" + comma-separated-tokens "^2.0.0" + hast-util-whitespace "^3.0.0" + html-void-elements "^3.0.0" + mdast-util-to-hast "^13.0.0" + property-information "^6.0.0" + space-separated-tokens "^2.0.0" + stringify-entities "^4.0.0" + zwitch "^2.0.4" + +hast-util-whitespace@^3.0.0: + version "3.0.0" + resolved "https://registry.npmjs.org/hast-util-whitespace/-/hast-util-whitespace-3.0.0.tgz" + integrity sha512-88JUN06ipLwsnv+dVn+OIYOvAuvBMy/Qoi6O7mQHxdPXpjy+Cd6xRkWwux7DKO+4sYILtLBRIKgsdpS2gQc7qw== + dependencies: + "@types/hast" "^3.0.0" + +html-void-elements@^3.0.0: + version "3.0.0" + resolved "https://registry.npmjs.org/html-void-elements/-/html-void-elements-3.0.0.tgz" + integrity sha512-bEqo66MRXsUGxWHV5IP0PUiAWwoEjba4VCzg0LjFJBpchPaTfyfCKTG6bc5F8ucKec3q5y6qOdGyYTSBEvhCrg== + ignore@^5.2.0: version "5.3.2" resolved "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz" @@ -513,11 +776,58 @@ markdown-it@^14.1.0: punycode.js "^2.3.1" uc.micro "^2.1.0" +mdast-util-to-hast@^13.0.0: + version "13.2.0" + resolved "https://registry.npmjs.org/mdast-util-to-hast/-/mdast-util-to-hast-13.2.0.tgz" + integrity sha512-QGYKEuUsYT9ykKBCMOEDLsU5JRObWQusAolFMeko/tYPufNkRffBAQjIE+99jbA87xv6FgmjLtwjh9wBWajwAA== + dependencies: + "@types/hast" "^3.0.0" + "@types/mdast" "^4.0.0" + "@ungap/structured-clone" "^1.0.0" + devlop "^1.0.0" + micromark-util-sanitize-uri "^2.0.0" + trim-lines "^3.0.0" + unist-util-position "^5.0.0" + unist-util-visit "^5.0.0" + vfile "^6.0.0" + mdurl@^2.0.0: version "2.0.0" resolved "https://registry.npmjs.org/mdurl/-/mdurl-2.0.0.tgz" integrity sha512-Lf+9+2r+Tdp5wXDXC4PcIBjTDtq4UKjCPMQhKIuzpJNW0b96kVqSwW0bT7FhRSfmAiFYgP+SCRvdrDozfh0U5w== +micromark-util-character@^2.0.0: + version "2.1.1" + resolved "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.1.1.tgz" + integrity sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q== + dependencies: + micromark-util-symbol "^2.0.0" + micromark-util-types "^2.0.0" + +micromark-util-encode@^2.0.0: + version "2.0.1" + resolved "https://registry.npmjs.org/micromark-util-encode/-/micromark-util-encode-2.0.1.tgz" + integrity sha512-c3cVx2y4KqUnwopcO9b/SCdo2O67LwJJ/UyqGfbigahfegL9myoEFoDYZgkT7f36T0bLrM9hZTAaAyH+PCAXjw== + +micromark-util-sanitize-uri@^2.0.0: + version "2.0.1" + resolved "https://registry.npmjs.org/micromark-util-sanitize-uri/-/micromark-util-sanitize-uri-2.0.1.tgz" + integrity sha512-9N9IomZ/YuGGZZmQec1MbgxtlgougxTodVwDzzEouPKo3qFWvymFHWcnDi2vzV1ff6kas9ucW+o3yzJK9YB1AQ== + dependencies: + micromark-util-character "^2.0.0" + micromark-util-encode "^2.0.0" + micromark-util-symbol "^2.0.0" + +micromark-util-symbol@^2.0.0: + version "2.0.1" + resolved "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz" + integrity sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q== + +micromark-util-types@^2.0.0: + version "2.0.1" + resolved "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.1.tgz" + integrity sha512-534m2WhVTddrcKVepwmVEVnUAmtrx9bfIjNoQHRqfnvdaHQiFytEhJoTgpWJvDEXCO5gLTQh3wYC1PgOJA4NSQ== + minimatch@^3.1.2: version "3.1.2" resolved "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz" @@ -542,6 +852,15 @@ natural-compare@^1.4.0: resolved "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz" integrity sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw== +oniguruma-to-es@^2.2.0: + version "2.3.0" + resolved "https://registry.npmjs.org/oniguruma-to-es/-/oniguruma-to-es-2.3.0.tgz" + integrity sha512-bwALDxriqfKGfUufKGGepCzu9x7nJQuoRoAFp4AnwehhC2crqrDIAP/uN2qdlsAvSMpeRC3+Yzhqc7hLmle5+g== + dependencies: + emoji-regex-xs "^1.0.0" + regex "^5.1.1" + regex-recursion "^5.1.1" + optionator@^0.9.3: version "0.9.4" resolved "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz" @@ -590,6 +909,11 @@ prelude-ls@^1.2.1: resolved "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz" integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g== +property-information@^6.0.0: + version "6.5.0" + resolved "https://registry.npmjs.org/property-information/-/property-information-6.5.0.tgz" + integrity sha512-PgTgs/BlvHxOu8QuEN7wi5A0OmXaBcHpmCSTehcs6Uuu9IkDIEo13Hy7n898RHfrQ49vKCoGeWZSaAK01nwVig== + punycode.js@^2.3.1: version "2.3.1" resolved "https://registry.npmjs.org/punycode.js/-/punycode.js-2.3.1.tgz" @@ -600,6 +924,26 @@ punycode@^2.1.0: resolved "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz" integrity sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg== +regex-recursion@^5.1.1: + version "5.1.1" + resolved "https://registry.npmjs.org/regex-recursion/-/regex-recursion-5.1.1.tgz" + integrity sha512-ae7SBCbzVNrIjgSbh7wMznPcQel1DNlDtzensnFxpiNpXt1U2ju/bHugH422r+4LAVS1FpW1YCwilmnNsjum9w== + dependencies: + regex "^5.1.1" + regex-utilities "^2.3.0" + +regex-utilities@^2.3.0: + version "2.3.0" + resolved "https://registry.npmjs.org/regex-utilities/-/regex-utilities-2.3.0.tgz" + integrity sha512-8VhliFJAWRaUiVvREIiW2NXXTmHs4vMNnSzuJVhscgmGav3g9VDxLrQndI3dZZVVdp0ZO/5v0xmX516/7M9cng== + +regex@^5.1.1: + version "5.1.1" + resolved "https://registry.npmjs.org/regex/-/regex-5.1.1.tgz" + integrity sha512-dN5I359AVGPnwzJm2jN1k0W9LPZ+ePvoOeVMMfqIMFz53sSwXkxaJoxr50ptnsC771lK95BnTrVSZxq0b9yCGw== + dependencies: + regex-utilities "^2.3.0" + resolve-from@^4.0.0: version "4.0.0" resolved "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz" @@ -617,14 +961,33 @@ shebang-regex@^3.0.0: resolved "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz" integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A== -shiki@^1.9.1: - version "1.12.1" - resolved "https://registry.npmjs.org/shiki/-/shiki-1.12.1.tgz" - integrity sha512-nwmjbHKnOYYAe1aaQyEBHvQymJgfm86ZSS7fT8OaPRr4sbAcBNz7PbfAikMEFSDQ6se2j2zobkXvVKcBOm0ysg== +shiki@^1.16.2: + version "1.29.1" + resolved "https://registry.npmjs.org/shiki/-/shiki-1.29.1.tgz" + integrity sha512-TghWKV9pJTd/N+IgAIVJtr0qZkB7FfFCUrrEJc0aRmZupo3D1OCVRknQWVRVA7AX/M0Ld7QfoAruPzr3CnUJuw== dependencies: - "@shikijs/core" "1.12.1" + "@shikijs/core" "1.29.1" + "@shikijs/engine-javascript" "1.29.1" + "@shikijs/engine-oniguruma" "1.29.1" + "@shikijs/langs" "1.29.1" + "@shikijs/themes" "1.29.1" + "@shikijs/types" "1.29.1" + "@shikijs/vscode-textmate" "^10.0.1" "@types/hast" "^3.0.4" +space-separated-tokens@^2.0.0: + version "2.0.2" + resolved "https://registry.npmjs.org/space-separated-tokens/-/space-separated-tokens-2.0.2.tgz" + integrity sha512-PEGlAwrG8yXGXRjW32fGbg66JAlOAwbObuqVoJpv/mRgoWDQfgH1wDPvtzWyUSNAXBGSk8h755YDbbcEy3SH2Q== + +stringify-entities@^4.0.0: + version "4.0.4" + resolved "https://registry.npmjs.org/stringify-entities/-/stringify-entities-4.0.4.tgz" + integrity sha512-IwfBptatlO+QCJUo19AqvrPNqlVMpW9YEL2LIVY+Rpv2qsjCGxaDLNRgeGsQWJhfItebuJhsGSLjaBbNSQ+ieg== + dependencies: + character-entities-html4 "^2.0.0" + character-entities-legacy "^3.0.0" + strip-json-comments@^3.1.1: version "3.1.1" resolved "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz" @@ -642,6 +1005,16 @@ text-encoding@^0.7.0: resolved "https://registry.npmjs.org/text-encoding/-/text-encoding-0.7.0.tgz" integrity sha512-oJQ3f1hrOnbRLOcwKz0Liq2IcrvDeZRHXhd9RgLrsT+DjWY/nty1Hi7v3dtkaEYbPYe0mUoOfzRrMwfXXwgPUA== +trim-lines@^3.0.0: + version "3.0.1" + resolved "https://registry.npmjs.org/trim-lines/-/trim-lines-3.0.1.tgz" + integrity sha512-kRj8B+YHZCc9kQYdWfJB2/oUl9rA99qbowYYBtr4ui4mZyAQ2JpvVBd/6U2YloATfqBhBTSMhTpgBHtU0Mf3Rg== + +tslib@^2.8.1: + version "2.8.1" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.8.1.tgz#612efe4ed235d567e8aba5f2a5fab70280ade83f" + integrity sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w== + tslog@^4.9.3: version "4.9.3" resolved "https://registry.npmjs.org/tslog/-/tslog-4.9.3.tgz" @@ -660,20 +1033,20 @@ typed-duration@^2.0.0: integrity sha512-XTOtfRR/l2hkCjFANwqu/IdLq17jBPts49tnxXc+Oc2ewngECupdu4FEH2H9hQHginRfOXCZ39tb9+pVcBlTcQ== typedoc@^0.26.5: - version "0.26.5" - resolved "https://registry.npmjs.org/typedoc/-/typedoc-0.26.5.tgz" - integrity sha512-Vn9YKdjKtDZqSk+by7beZ+xzkkr8T8CYoiasqyt4TTRFy5+UHzL/mF/o4wGBjRF+rlWQHDb0t6xCpA3JNL5phg== + version "0.26.11" + resolved "https://registry.npmjs.org/typedoc/-/typedoc-0.26.11.tgz" + integrity sha512-sFEgRRtrcDl2FxVP58Ze++ZK2UQAEvtvvH8rRlig1Ja3o7dDaMHmaBfvJmdGnNEFaLTpQsN8dpvZaTqJSu/Ugw== dependencies: lunr "^2.3.9" markdown-it "^14.1.0" minimatch "^9.0.5" - shiki "^1.9.1" - yaml "^2.4.5" + shiki "^1.16.2" + yaml "^2.5.1" -typescript@^5.3.2: - version "5.3.2" - resolved "https://registry.npmjs.org/typescript/-/typescript-5.3.2.tgz" - integrity sha512-6l+RyNy7oAHDfxC4FzSJcz9vnjTKxrLpDG5M2Vu4SHRVNg6xzqZp6LYSR9zjqQTu8DU/f5xwxUdADOkbrIX2gQ== +typescript@^5.7.3: + version "5.7.3" + resolved "https://registry.npmjs.org/typescript/-/typescript-5.7.3.tgz" + integrity sha512-84MVSjMEHP+FQRPy3pX9sTVV/INIex71s9TL2Gm5FG/WG1SqXeKyZ0k7/blY/4FdOzI12CBy1vGc4og/eus0fw== uc.micro@^2.0.0, uc.micro@^2.1.0: version "2.1.0" @@ -685,6 +1058,44 @@ undici-types@~5.26.4: resolved "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz" integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA== +unist-util-is@^6.0.0: + version "6.0.0" + resolved "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.0.tgz" + integrity sha512-2qCTHimwdxLfz+YzdGfkqNlH0tLi9xjTnHddPmJwtIG9MGsdbutfTc4P+haPD7l7Cjxf/WZj+we5qfVPvvxfYw== + dependencies: + "@types/unist" "^3.0.0" + +unist-util-position@^5.0.0: + version "5.0.0" + resolved "https://registry.npmjs.org/unist-util-position/-/unist-util-position-5.0.0.tgz" + integrity sha512-fucsC7HjXvkB5R3kTCO7kUjRdrS0BJt3M/FPxmHMBOm8JQi2BsHAHFsy27E0EolP8rp0NzXsJ+jNPyDWvOJZPA== + dependencies: + "@types/unist" "^3.0.0" + +unist-util-stringify-position@^4.0.0: + version "4.0.0" + resolved "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-4.0.0.tgz" + integrity sha512-0ASV06AAoKCDkS2+xw5RXJywruurpbC4JZSm7nr7MOt1ojAzvyyaO+UxZf18j8FCF6kmzCZKcAgN/yu2gm2XgQ== + dependencies: + "@types/unist" "^3.0.0" + +unist-util-visit-parents@^6.0.0: + version "6.0.1" + resolved "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.1.tgz" + integrity sha512-L/PqWzfTP9lzzEa6CKs0k2nARxTdZduw3zyh8d2NVBnsyvHjSX4TWse388YrrQKbvI8w20fGjGlhgT96WwKykw== + dependencies: + "@types/unist" "^3.0.0" + unist-util-is "^6.0.0" + +unist-util-visit@^5.0.0: + version "5.0.0" + resolved "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-5.0.0.tgz" + integrity sha512-MR04uvD+07cwl/yhVuVWAtw+3GOR/knlL55Nd/wAdblk27GCVt3lqpTivy/tkJcZoNPzTwS1Y+KMojlLDhoTzg== + dependencies: + "@types/unist" "^3.0.0" + unist-util-is "^6.0.0" + unist-util-visit-parents "^6.0.0" + uri-js@^4.2.2: version "4.4.1" resolved "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz" @@ -697,6 +1108,22 @@ uuid@^10.0.0: resolved "https://registry.npmjs.org/uuid/-/uuid-10.0.0.tgz" integrity sha512-8XkAphELsDnEGrDxUOHB3RGvXz6TeuYSGEZBOjtTtPm2lwhGBjLgOzLHB63IUWfBpNucQjND6d3AOudO+H3RWQ== +vfile-message@^4.0.0: + version "4.0.2" + resolved "https://registry.npmjs.org/vfile-message/-/vfile-message-4.0.2.tgz" + integrity sha512-jRDZ1IMLttGj41KcZvlrYAaI3CfqpLpfpf+Mfig13viT6NKvRzWZ+lXz0Y5D60w6uJIBAOGq9mSHf0gktF0duw== + dependencies: + "@types/unist" "^3.0.0" + unist-util-stringify-position "^4.0.0" + +vfile@^6.0.0: + version "6.0.3" + resolved "https://registry.npmjs.org/vfile/-/vfile-6.0.3.tgz" + integrity sha512-KzIbH/9tXat2u30jf+smMwFCsno4wHVdNmzFyL+T/L3UGqqk6JKfVqOFOZEpZSHADH1k40ab6NUIXZq422ov3Q== + dependencies: + "@types/unist" "^3.0.0" + vfile-message "^4.0.0" + which@^2.0.1: version "2.0.2" resolved "https://registry.npmjs.org/which/-/which-2.0.2.tgz" @@ -709,12 +1136,17 @@ word-wrap@^1.2.5: resolved "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz" integrity sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA== -yaml@^2.4.5: - version "2.5.0" - resolved "https://registry.npmjs.org/yaml/-/yaml-2.5.0.tgz" - integrity sha512-2wWLbGbYDiSqqIKoPjar3MPgB94ErzCtrNE1FdqGuaO0pi2JGjmE8aW8TDZwzU7vuxcGRdL/4gPQwQ7hD5AMSw== +yaml@^2.5.1: + version "2.7.0" + resolved "https://registry.npmjs.org/yaml/-/yaml-2.7.0.tgz" + integrity sha512-+hSoy/QHluxmC9kCIJyL/uyFmLmc+e5CFR5Wa+bpIhIj85LVb9ZH2nVnqrHoSvKogwODv0ClqZkmiSSaIH5LTA== yocto-queue@^0.1.0: version "0.1.0" resolved "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz" integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q== + +zwitch@^2.0.4: + version "2.0.4" + resolved "https://registry.npmjs.org/zwitch/-/zwitch-2.0.4.tgz" + integrity sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==