lixnet 1.6.0 → 1.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,14 +1,93 @@
1
1
  import LixnetServerBase from "./serverbase";
2
2
  import { LixnetResponse } from "./util/response";
3
3
  import { createLixnetRequest } from "./util/request";
4
- import getDefaultFormatter, { buildResponseHeaders, errorBody } from "./util/getDefaultFormatter";
4
+ import getDefaultFormatter, { buildResponseHeaders, errorFrame, streamFrame } from "./util/getDefaultFormatter";
5
5
  function isIterable(value) {
6
6
  if (value === null || typeof value !== "object")
7
7
  return false;
8
- // Sync iterables only when they're generators, so a returned array isn't streamed by accident.
8
+ // Sync iterables only when they're generators, so a returned array is one chunk, not streamed.
9
9
  return (typeof value[Symbol.asyncIterator] === "function" ||
10
10
  (typeof value[Symbol.iterator] === "function" && typeof value.next === "function"));
11
11
  }
12
+ const DRAINED = Symbol("lixnet.drained");
13
+ const NONE = Symbol("lixnet.none");
14
+ /** Settles like `promise`, or with `undefined` once the client disconnects (the work may go on, unobserved). */
15
+ function untilAbort(promise, signal) {
16
+ if (signal.aborted) {
17
+ promise.catch(noop);
18
+ return Promise.resolve(undefined);
19
+ }
20
+ return new Promise((resolve, reject) => {
21
+ signal.addEventListener("abort", () => resolve(undefined), { once: true });
22
+ promise.then(resolve, reject);
23
+ });
24
+ }
25
+ function noop() { }
26
+ /** Ends the iterator early; its own failure is ignored (the stream is already ending). */
27
+ async function close(iterator) {
28
+ try {
29
+ await iterator.return?.();
30
+ }
31
+ catch { }
32
+ }
33
+ /** Sends each value as a chunk; resolves the iterator's return value. Stops early on disconnect. */
34
+ async function iterate(value, sink) {
35
+ const async = typeof value[Symbol.asyncIterator] === "function";
36
+ const iterator = async
37
+ ? value[Symbol.asyncIterator]()
38
+ : value;
39
+ for (;;) {
40
+ const step = await iterator.next();
41
+ if (step.done)
42
+ return (sink[DRAINED] = step.value);
43
+ if (sink.signal.aborted) {
44
+ await close(iterator);
45
+ return undefined;
46
+ }
47
+ try {
48
+ // Like `for await`, a sync generator's yielded promises are awaited.
49
+ sink.emit(!async && step.value instanceof Promise ? await step.value : step.value);
50
+ }
51
+ catch (error) {
52
+ await close(iterator);
53
+ throw error;
54
+ }
55
+ }
56
+ }
57
+ /**
58
+ * The stream-route output rule: an async iterable or generator is streamed, `undefined` sends
59
+ * nothing, anything else (arrays and plain objects too) is sent as one chunk. Resolves what the
60
+ * route's `next()` gets as `output`: the generator's return value, else the value itself.
61
+ * Resolves `undefined` as soon as the client disconnects, so awaiting middleware never hangs.
62
+ */
63
+ function drain(value, sink) {
64
+ if (!isIterable(value)) {
65
+ if (value !== undefined)
66
+ sink.emit(value);
67
+ return (sink[DRAINED] = value);
68
+ }
69
+ return untilAbort(iterate(value, sink), sink.signal);
70
+ }
71
+ /** A handler whose output is sent inside the middleware chain, so `next()` spans the whole stream. */
72
+ function streamed(handler) {
73
+ return (input) => {
74
+ const sink = input.stream;
75
+ const output = handler(input);
76
+ if (!(output instanceof Promise))
77
+ return drain(output, sink);
78
+ return untilAbort(output, sink.signal).then((value) => drain(value, sink));
79
+ };
80
+ }
81
+ /** With `debugLog`: report calls that can't reach the client once the stream's headers are sent. */
82
+ function onLateCall(response, warn) {
83
+ for (const call of ["header", "deleteHeader", "cookie", "deleteCookie", "code"]) {
84
+ const original = response[call];
85
+ response[call] = function (...args) {
86
+ warn(call);
87
+ return original.apply(this, args);
88
+ };
89
+ }
90
+ }
12
91
  export default class LixnetStreamServer extends LixnetServerBase {
13
92
  errorFormatter;
14
93
  constructor({ routes, events, ...options } = {}) {
@@ -18,6 +97,15 @@ export default class LixnetStreamServer extends LixnetServerBase {
18
97
  this.register({ ...route, event });
19
98
  }
20
99
  }
100
+ /**
101
+ * Adds middleware for the stream routes registered after this call. Each can add fields to `ctx`.
102
+ * `next()` spans the whole stream: it resolves after the last chunk is sent (to the generator's
103
+ * return value) and rejects if the stream fails.
104
+ */
105
+ use(...middleware) {
106
+ this.addMiddleware(middleware);
107
+ return this;
108
+ }
21
109
  route(event, route) {
22
110
  this.register({ ...route, event });
23
111
  return this;
@@ -25,8 +113,13 @@ export default class LixnetStreamServer extends LixnetServerBase {
25
113
  on(input) {
26
114
  this.register(input);
27
115
  }
116
+ /** Wraps each handler so the chain's last step also sends its output (see `drain`). */
117
+ register(input) {
118
+ const entries = Array.isArray(input) ? input : [input];
119
+ super.register(entries.map((entry) => ({ ...entry, handler: streamed(entry.handler) })));
120
+ }
28
121
  async handle(request) {
29
- const response = new LixnetResponse({ formatter: this.errorFormatter });
122
+ const response = new LixnetResponse({ formatter: this.errorFormatter, serializer: this.serializer });
30
123
  const corsResponse = this.handleCors(request, response);
31
124
  if (corsResponse)
32
125
  return corsResponse;
@@ -34,8 +127,7 @@ export default class LixnetStreamServer extends LixnetServerBase {
34
127
  if (!parsed.ok) {
35
128
  return this.fail(response, parsed);
36
129
  }
37
- const event = parsed.entry;
38
- const validatedInput = parsed.input;
130
+ const entry = parsed.entry;
39
131
  const newRequest = createLixnetRequest(request, response, parsed.body);
40
132
  const encoder = new TextEncoder();
41
133
  const abort = new AbortController();
@@ -51,16 +143,18 @@ export default class LixnetStreamServer extends LixnetServerBase {
51
143
  abort.abort();
52
144
  },
53
145
  });
54
- const write = (frame) => {
146
+ const write = (text) => {
55
147
  if (closed)
56
148
  return;
57
- controller.enqueue(encoder.encode(JSON.stringify(frame) + "\n"));
149
+ controller.enqueue(encoder.encode(text));
58
150
  };
59
- // The Response is only created on the first emit (or when the handler finishes), so
60
- // status, headers and cookies staged before that point are all sent, and an error
61
- // thrown before anything is streamed becomes a normal JSON error response.
151
+ // The Response is only created on the first chunk (or when the chain finishes), so status,
152
+ // headers and cookies staged before that point are all sent, and an error thrown before
153
+ // anything is streamed becomes a normal JSON error response.
62
154
  return new Promise((resolve) => {
63
155
  let started = false;
156
+ // With debugLog: true once a late header/cookie/status call was reported (or must not be).
157
+ let warned = false;
64
158
  const start = () => {
65
159
  if (started)
66
160
  return;
@@ -69,36 +163,44 @@ export default class LixnetStreamServer extends LixnetServerBase {
69
163
  status: response.responseCode || 200,
70
164
  headers: buildResponseHeaders(response, this.defaultHeaders, "application/x-ndjson"),
71
165
  }));
166
+ if (!this.debugLog)
167
+ return;
168
+ onLateCall(response, (call) => {
169
+ if (warned)
170
+ return;
171
+ warned = true;
172
+ this.logger({
173
+ message: `response.${call}() after the first chunk has no effect: headers are already sent (event "${entry.event}")`,
174
+ });
175
+ });
72
176
  };
73
177
  const stream = {
74
178
  signal: abort.signal,
75
179
  emit: (chunk) => {
76
180
  start();
77
- write({ stream: true, data: chunk });
181
+ write(streamFrame(response, chunk));
78
182
  },
183
+ [DRAINED]: NONE,
79
184
  };
80
185
  (async () => {
81
186
  try {
82
- const result = await event.handler({ ...validatedInput, request: newRequest, response, stream });
83
- // Generator handlers: each yielded value is a chunk. Stops early if the client disconnects.
84
- if (isIterable(result)) {
85
- for await (const chunk of result) {
86
- if (closed)
87
- break;
88
- stream.emit(chunk);
89
- }
90
- }
187
+ const output = await this.invoke(entry, parsed.input, { request: newRequest, response, stream });
188
+ // Middleware replaced the handler's output ({ output } short-circuit or recovery):
189
+ // send it by the same rule. After chunks were sent, it's appended to them.
190
+ if (!Object.is(output, stream[DRAINED]))
191
+ await drain(output, stream);
91
192
  start();
92
193
  }
93
194
  catch (error) {
94
- const failure = this.failureFromThrown(error, event.event);
195
+ const failure = this.failureFromThrown(error, entry.event);
95
196
  if (!started) {
96
197
  resolve(this.fail(response, failure));
97
198
  return;
98
199
  }
99
200
  // Headers are already sent, so report the error as the final frame.
201
+ warned = true;
100
202
  this.stageFailure(response, failure);
101
- write(errorBody(response));
203
+ write(errorFrame(response));
102
204
  }
103
205
  finally {
104
206
  if (started && !closed) {
@@ -1,6 +1,7 @@
1
1
  import type { StandardSchemaV1 } from "./standardschema";
2
2
  import type { LixnetRequest } from "./util/request";
3
3
  import type { LixnetResponse } from "./util/response";
4
+ import type { LixnetSerializer } from "./serializer";
4
5
  export type DebugLogger = ({ error, message, cause, }: {
5
6
  error?: boolean;
6
7
  message: string;
@@ -26,6 +27,8 @@ export type LixnetClientOptions = {
26
27
  rpcUrl: string;
27
28
  /** Defaults to the global `fetch`, looked up on every call. */
28
29
  fetch?: LixnetFetch;
30
+ /** Must be the server's serializer (e.g. `lixnetJSON`), or absent when the server has none. */
31
+ serializer?: LixnetSerializer;
29
32
  };
30
33
  /** A schema whose parsed output must match the event's declared input type. */
31
34
  export type LXNEventSchema<Events, K extends keyof Events> = StandardSchemaV1<any, FunctionInput<Events[K]>>;
@@ -35,9 +38,11 @@ export type LXNEventEntries<Events, TEntry extends {
35
38
  }> = TEntry[keyof Events & string][];
36
39
  /** The inbound request passed to handlers (Next.js–style `cookies()` / `headers()`). */
37
40
  export type { LixnetRequest as LXN_ServerClient_Request } from "./util/request";
38
- export type LixnetServerInjections = {
41
+ /** Injected into every handler next to its input. `ctx` holds what the route's middleware added. */
42
+ export type LixnetServerInjections<TCtx = {}> = {
39
43
  request: LixnetRequest;
40
44
  response: LixnetResponse;
45
+ ctx: TCtx;
41
46
  };
42
47
  /** The `stream` object injected into stream event handlers. */
43
48
  export type LXNStreamEmitter<TChunk> = {
@@ -46,6 +51,24 @@ export type LXNStreamEmitter<TChunk> = {
46
51
  /** Aborted when the client disconnects; `emit` becomes a no-op from then on. */
47
52
  signal: AbortSignal;
48
53
  };
49
- export type LixnetStreamInjections = LixnetServerInjections & {
54
+ export type LixnetStreamInjections<TCtx = {}> = LixnetServerInjections<TCtx> & {
50
55
  stream: LXNStreamEmitter<unknown>;
51
56
  };
57
+ /** Input keys a route can't use: the injections next to the input would overwrite them. */
58
+ export type LixnetReservedKey = keyof LixnetServerInjections;
59
+ /** Stream routes also reserve `stream`. */
60
+ export type LixnetStreamReservedKey = keyof LixnetStreamInjections;
61
+ /**
62
+ * Type-only check that a route's input (its schema's output or contract input) has no reserved key.
63
+ * `{}` when it's fine; otherwise `{ [TField]: "Lixnet: input key \"ctx\" is reserved" }`, which,
64
+ * intersected into the route, turns `TField` into a compile error naming the key.
65
+ */
66
+ export type LixnetReservedInputCheck<TInput, TReserved extends PropertyKey, TField extends PropertyKey> = 0 extends 1 & TInput ? {} : [Extract<KeysOf<TInput>, TReserved>] extends [never] ? {} : {
67
+ [P in TField]: `Lixnet: input key "${Extract<KeysOf<TInput>, TReserved> & string}" is reserved`;
68
+ };
69
+ /** Keys of every member of a union. */
70
+ type KeysOf<T> = T extends unknown ? keyof T : never;
71
+ /** {@link LixnetReservedInputCheck} for each schema of the `routes` constructor option. */
72
+ export type LixnetReservedSchemasCheck<TSchemas, TReserved extends PropertyKey> = {
73
+ [K in Extract<keyof TSchemas, string>]: TSchemas[K] extends StandardSchemaV1 ? LixnetReservedInputCheck<StandardSchemaV1.InferOutput<TSchemas[K]>, TReserved, "schema"> : {};
74
+ };
@@ -1,11 +1,40 @@
1
1
  import type { LixnetResponse } from "./response";
2
- /** The `{ error, code, data?, detail? }` body for an errored response (also used for stream error frames). */
3
- export declare function errorBody(response: LixnetResponse): {
4
- detail?: string | undefined;
5
- data?: {} | null | undefined;
2
+ export type ErrorBody = {
6
3
  error: string | null;
7
4
  code: string;
5
+ data?: unknown;
6
+ detail?: string;
7
+ serializer?: string;
8
8
  };
9
+ /**
10
+ * The `{ data }` body of a successful response. With a serializer, `data` is always encoded
11
+ * (`undefined` included, so it round-trips); without one, no data is sent as `null`.
12
+ * Throws whatever the serializer throws.
13
+ */
14
+ export declare function dataBody(response: LixnetResponse): {
15
+ data: unknown;
16
+ serializer?: string;
17
+ };
18
+ /**
19
+ * The `{ error, code, data?, detail? }` body of an errored response. `data` is encoded with the
20
+ * serializer; if that fails, `data` is dropped and the error kept.
21
+ */
22
+ export declare function errorBody(response: LixnetResponse): ErrorBody;
23
+ /** `dataBody` as JSON text. Throws a 500 `LixnetError` "Could not serialize the response" on failure. */
24
+ export declare function dataJSON(response: LixnetResponse): string;
25
+ /** `errorBody` as JSON text. Never throws: `data` that JSON can't carry (e.g. BigInt, circular) is dropped. */
26
+ export declare function errorJSON(response: LixnetResponse): string;
27
+ /**
28
+ * One NDJSON stream frame, `{"stream":true,"data":…}\n` (plus `"serializer"` on the first frame).
29
+ * Throws like `dataJSON` if the chunk can't be encoded.
30
+ */
31
+ export declare function streamFrame(response: LixnetResponse, chunk: unknown): string;
32
+ /** The final NDJSON error frame (`errorJSON` plus a newline; echoes the serializer if it's the first frame). Never throws. */
33
+ export declare function errorFrame(response: LixnetResponse): string;
9
34
  /** Defaults, then staged header sets/deletes, then staged cookies as `Set-Cookie`. */
10
35
  export declare function buildResponseHeaders(response: LixnetResponse, defaultHeaders: Record<string, string>, contentType: string): Headers;
36
+ /**
37
+ * The default formatter. Throws a 500 `LixnetError` when the success body can't be encoded;
38
+ * the server turns that into an error response.
39
+ */
11
40
  export default function (defaultHeaders: Record<string, string>): (this: LixnetResponse) => Response;
@@ -1,12 +1,95 @@
1
- import { codeForStatus } from "../error";
2
- /** The `{ error, code, data?, detail? }` body for an errored response (also used for stream error frames). */
1
+ import { LixnetError, codeForStatus } from "../error";
2
+ /** The serializer name to echo, if this body/frame should carry it. */
3
+ function echo(response) {
4
+ return response.serializerEchoed ? undefined : response.serializer?.name;
5
+ }
6
+ function serializeFailure(cause) {
7
+ return new LixnetError("INTERNAL", "Could not serialize the response", { cause });
8
+ }
9
+ /**
10
+ * The `{ data }` body of a successful response. With a serializer, `data` is always encoded
11
+ * (`undefined` included, so it round-trips); without one, no data is sent as `null`.
12
+ * Throws whatever the serializer throws.
13
+ */
14
+ export function dataBody(response) {
15
+ const serializer = response.serializer;
16
+ if (!serializer)
17
+ return { data: response.responseData ?? null };
18
+ return { data: serializer.serialize(response.responseData), serializer: serializer.name };
19
+ }
20
+ /**
21
+ * The `{ error, code, data?, detail? }` body of an errored response. `data` is encoded with the
22
+ * serializer; if that fails, `data` is dropped and the error kept.
23
+ */
3
24
  export function errorBody(response) {
4
- return {
25
+ const body = {
5
26
  error: response.responseError,
6
27
  code: response.responseErrorCode ?? codeForStatus(response.responseCode || 500),
7
- ...(response.responseErrorData !== undefined ? { data: response.responseErrorData } : {}),
8
- ...(response.responseErrorDetail ? { detail: response.responseErrorDetail } : {}),
9
28
  };
29
+ let data = response.responseErrorData;
30
+ if (data !== undefined && response.serializer) {
31
+ try {
32
+ data = response.serializer.serialize(data);
33
+ }
34
+ catch {
35
+ data = undefined;
36
+ }
37
+ }
38
+ if (data !== undefined)
39
+ body.data = data;
40
+ if (response.responseErrorDetail)
41
+ body.detail = response.responseErrorDetail;
42
+ const name = echo(response);
43
+ if (name !== undefined)
44
+ body.serializer = name;
45
+ return body;
46
+ }
47
+ /** `dataBody` as JSON text. Throws a 500 `LixnetError` "Could not serialize the response" on failure. */
48
+ export function dataJSON(response) {
49
+ try {
50
+ return JSON.stringify(dataBody(response));
51
+ }
52
+ catch (cause) {
53
+ throw serializeFailure(cause);
54
+ }
55
+ }
56
+ /** `errorBody` as JSON text. Never throws: `data` that JSON can't carry (e.g. BigInt, circular) is dropped. */
57
+ export function errorJSON(response) {
58
+ const body = errorBody(response);
59
+ try {
60
+ return JSON.stringify(body);
61
+ }
62
+ catch {
63
+ delete body.data;
64
+ return JSON.stringify(body);
65
+ }
66
+ }
67
+ /**
68
+ * One NDJSON stream frame, `{"stream":true,"data":…}\n` (plus `"serializer"` on the first frame).
69
+ * Throws like `dataJSON` if the chunk can't be encoded.
70
+ */
71
+ export function streamFrame(response, chunk) {
72
+ const serializer = response.serializer;
73
+ let text;
74
+ try {
75
+ if (!serializer)
76
+ return JSON.stringify({ stream: true, data: chunk }) + "\n";
77
+ const data = serializer.serialize(chunk);
78
+ text = response.serializerEchoed
79
+ ? JSON.stringify({ stream: true, data })
80
+ : JSON.stringify({ stream: true, data, serializer: serializer.name });
81
+ }
82
+ catch (cause) {
83
+ throw serializeFailure(cause);
84
+ }
85
+ response.serializerEchoed = true;
86
+ return text + "\n";
87
+ }
88
+ /** The final NDJSON error frame (`errorJSON` plus a newline; echoes the serializer if it's the first frame). Never throws. */
89
+ export function errorFrame(response) {
90
+ const text = errorJSON(response) + "\n";
91
+ response.serializerEchoed = true;
92
+ return text;
10
93
  }
11
94
  /** Defaults, then staged header sets/deletes, then staged cookies as `Set-Cookie`. */
12
95
  export function buildResponseHeaders(response, defaultHeaders, contentType) {
@@ -61,22 +144,22 @@ export function buildResponseHeaders(response, defaultHeaders, contentType) {
61
144
  }
62
145
  return headers;
63
146
  }
147
+ /**
148
+ * The default formatter. Throws a 500 `LixnetError` when the success body can't be encoded;
149
+ * the server turns that into an error response.
150
+ */
64
151
  export default function (defaultHeaders) {
65
- function formatter() {
66
- const headers = buildResponseHeaders(this, defaultHeaders, "application/json");
152
+ return function formatter() {
67
153
  if (this.responseError) {
68
- return Response.json(errorBody(this), {
154
+ return new Response(errorJSON(this), {
69
155
  status: this.responseCode || 500,
70
- headers: headers,
156
+ headers: buildResponseHeaders(this, defaultHeaders, "application/json"),
71
157
  });
72
158
  }
73
- return Response.json({
74
- data: this.responseData,
75
- }, {
159
+ const body = dataJSON(this);
160
+ return new Response(body, {
76
161
  status: this.responseCode || 200,
77
- headers: headers,
162
+ headers: buildResponseHeaders(this, defaultHeaders, "application/json"),
78
163
  });
79
- }
80
- ;
81
- return formatter;
164
+ };
82
165
  }
@@ -1,3 +1,4 @@
1
+ import type { LixnetSerializer } from "../serializer";
1
2
  export type CookieBaseOptions = {
2
3
  domain?: string;
3
4
  path?: string;
@@ -9,13 +10,14 @@ export type CookieFullOptions = CookieBaseOptions & {
9
10
  maxAge?: number;
10
11
  };
11
12
  export declare class LixnetResponse {
13
+ /** Raw data as staged (not yet encoded); `undefined` until a handler returns or calls `data()`. */
12
14
  responseData: any;
13
15
  responseError: string | null;
14
16
  /** Extra error information, only sent when the server has `exposeErrors` enabled. */
15
17
  responseErrorDetail: string | null;
16
18
  /** Error code sent as `code`; derived from the status when not set. */
17
19
  responseErrorCode: string | null;
18
- /** JSON-serialisable data sent with the error as `data`. */
20
+ /** Data sent with the error as `data` (encoded with the serializer, if any, when the body is built). */
19
21
  responseErrorData: unknown;
20
22
  responseCode: number;
21
23
  responseHeaders: Record<string, string>;
@@ -25,8 +27,16 @@ export declare class LixnetResponse {
25
27
  value?: string;
26
28
  options?: CookieFullOptions;
27
29
  }>;
28
- constructor({ formatter }: {
30
+ /** The server's serializer: the body helpers in `getDefaultFormatter.ts` encode `data` with it. */
31
+ serializer?: LixnetSerializer;
32
+ /**
33
+ * Set once a stream frame has been written: only the first frame echoes the serializer's name.
34
+ * Flipped by `streamFrame`/`errorFrame` themselves; plain JSON bodies always echo it.
35
+ */
36
+ serializerEchoed: boolean;
37
+ constructor({ formatter, serializer, }: {
29
38
  formatter: (this: LixnetResponse) => Response;
39
+ serializer?: LixnetSerializer;
30
40
  });
31
41
  data(data: any): void;
32
42
  header(headerName: string, headerValue: string): void;
@@ -13,21 +13,29 @@ function assertCookie(cookieName, options) {
13
13
  }
14
14
  }
15
15
  export class LixnetResponse {
16
- responseData;
16
+ /** Raw data as staged (not yet encoded); `undefined` until a handler returns or calls `data()`. */
17
+ responseData = undefined;
17
18
  responseError = null;
18
19
  /** Extra error information, only sent when the server has `exposeErrors` enabled. */
19
20
  responseErrorDetail = null;
20
21
  /** Error code sent as `code`; derived from the status when not set. */
21
22
  responseErrorCode = null;
22
- /** JSON-serialisable data sent with the error as `data`. */
23
+ /** Data sent with the error as `data` (encoded with the serializer, if any, when the body is built). */
23
24
  responseErrorData = undefined;
24
25
  responseCode = 0;
25
26
  responseHeaders = {};
26
27
  responseHeaderDeletes = new Set();
27
28
  responseCookies = {};
28
- constructor({ formatter }) {
29
- this.responseData = null;
29
+ /** The server's serializer: the body helpers in `getDefaultFormatter.ts` encode `data` with it. */
30
+ serializer;
31
+ /**
32
+ * Set once a stream frame has been written: only the first frame echoes the serializer's name.
33
+ * Flipped by `streamFrame`/`errorFrame` themselves; plain JSON bodies always echo it.
34
+ */
35
+ serializerEchoed = false;
36
+ constructor({ formatter, serializer, }) {
30
37
  this.format = formatter;
38
+ this.serializer = serializer;
31
39
  }
32
40
  data(data) {
33
41
  this.responseData = data;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lixnet",
3
- "version": "1.6.0",
3
+ "version": "1.7.1",
4
4
  "author": "nitlix-hq",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -21,7 +21,14 @@
21
21
  "files": [
22
22
  "dist"
23
23
  ],
24
+ "scripts": {
25
+ "build": "tsc",
26
+ "typecheck": "tsc --noEmit && tsc --noEmit --strict --skipLibCheck --module esnext --moduleResolution bundler --target esnext --verbatimModuleSyntax tests/*.ts tests/peer/*.ts tests/router/*.ts",
27
+ "test": "bun tests/run-all.ts",
28
+ "bench": "bun benchmarks/serializer.ts"
29
+ },
24
30
  "type": "module",
31
+ "sideEffects": false,
25
32
  "devDependencies": {
26
33
  "@types/bun": "latest",
27
34
  "typescript": "^5.9.3",