@nifrajs/core 2.14.1 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -0
- package/dist/assurance.d.ts +16 -8
- package/dist/assurance.d.ts.map +1 -1
- package/dist/assurance.js +33 -0
- package/dist/assurance.js.map +1 -1
- package/dist/durable-adapters.d.ts.map +1 -1
- package/dist/durable-adapters.js +26 -3
- package/dist/durable-adapters.js.map +1 -1
- package/dist/durable-approval.d.ts +56 -0
- package/dist/durable-approval.d.ts.map +1 -0
- package/dist/durable-approval.js +233 -0
- package/dist/durable-approval.js.map +1 -0
- package/dist/durable-effect.d.ts +42 -0
- package/dist/durable-effect.d.ts.map +1 -0
- package/dist/durable-effect.js +234 -0
- package/dist/durable-effect.js.map +1 -0
- package/dist/durable-execution.d.ts +8 -346
- package/dist/durable-execution.d.ts.map +1 -1
- package/dist/durable-execution.js +7 -1150
- package/dist/durable-execution.js.map +1 -1
- package/dist/durable-saga.d.ts +94 -0
- package/dist/durable-saga.d.ts.map +1 -0
- package/dist/durable-saga.js +550 -0
- package/dist/durable-saga.js.map +1 -0
- package/dist/edge-kit.d.ts +27 -0
- package/dist/edge-kit.d.ts.map +1 -0
- package/dist/edge-kit.js +24 -0
- package/dist/edge-kit.js.map +1 -0
- package/dist/errors.d.ts +1 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +23 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -2
- package/dist/index.js.map +1 -1
- package/dist/internal/durable-approval-protocol.d.ts +1 -1
- package/dist/internal/durable-approval-protocol.d.ts.map +1 -1
- package/dist/internal/durable-effect-protocol.d.ts +1 -1
- package/dist/internal/durable-effect-protocol.d.ts.map +1 -1
- package/dist/internal/durable-saga-protocol.d.ts +1 -1
- package/dist/internal/durable-saga-protocol.d.ts.map +1 -1
- package/dist/internal/durable-shared.d.ts +26 -0
- package/dist/internal/durable-shared.d.ts.map +1 -0
- package/dist/internal/durable-shared.js +131 -0
- package/dist/internal/durable-shared.js.map +1 -0
- package/dist/internal/durable-types.d.ts +159 -0
- package/dist/internal/durable-types.d.ts.map +1 -0
- package/dist/internal/durable-types.js +2 -0
- package/dist/internal/durable-types.js.map +1 -0
- package/dist/internal/route-compiler.d.ts +61 -0
- package/dist/internal/route-compiler.d.ts.map +1 -0
- package/dist/internal/route-compiler.js +121 -0
- package/dist/internal/route-compiler.js.map +1 -0
- package/dist/internal/route-execution.d.ts +17 -9
- package/dist/internal/route-execution.d.ts.map +1 -1
- package/dist/internal/route-execution.js +4 -18
- package/dist/internal/route-execution.js.map +1 -1
- package/dist/internal/route-lanes.d.ts +35 -0
- package/dist/internal/route-lanes.d.ts.map +1 -0
- package/dist/internal/route-lanes.js +150 -0
- package/dist/internal/route-lanes.js.map +1 -0
- package/dist/internal/route-program.d.ts +67 -0
- package/dist/internal/route-program.d.ts.map +1 -0
- package/dist/internal/route-program.js +199 -0
- package/dist/internal/route-program.js.map +1 -0
- package/dist/response-observer.d.ts +25 -0
- package/dist/response-observer.d.ts.map +1 -0
- package/dist/response-observer.js +40 -0
- package/dist/response-observer.js.map +1 -0
- package/dist/security/baseline.d.ts +68 -0
- package/dist/security/baseline.d.ts.map +1 -0
- package/dist/security/baseline.js +118 -0
- package/dist/security/baseline.js.map +1 -0
- package/dist/server/bare-error-lane.d.ts +26 -0
- package/dist/server/bare-error-lane.d.ts.map +1 -0
- package/dist/server/bare-error-lane.js +60 -0
- package/dist/server/bare-error-lane.js.map +1 -0
- package/dist/server/body-lane.d.ts +13 -0
- package/dist/server/body-lane.d.ts.map +1 -0
- package/dist/server/body-lane.js +134 -0
- package/dist/server/body-lane.js.map +1 -0
- package/dist/server/body.d.ts +7 -0
- package/dist/server/body.d.ts.map +1 -1
- package/dist/server/body.js +7 -0
- package/dist/server/body.js.map +1 -1
- package/dist/server/bridge-markers.d.ts +25 -0
- package/dist/server/bridge-markers.d.ts.map +1 -0
- package/dist/server/bridge-markers.js +25 -0
- package/dist/server/bridge-markers.js.map +1 -0
- package/dist/server/context.d.ts +6 -1
- package/dist/server/context.d.ts.map +1 -1
- package/dist/server/contract.d.ts +40 -14
- package/dist/server/contract.d.ts.map +1 -1
- package/dist/server/contract.js +7 -0
- package/dist/server/contract.js.map +1 -1
- package/dist/server/cookies.d.ts.map +1 -1
- package/dist/server/cookies.js +16 -2
- package/dist/server/cookies.js.map +1 -1
- package/dist/server/header-case.d.ts.map +1 -1
- package/dist/server/header-case.js +2 -1
- package/dist/server/header-case.js.map +1 -1
- package/dist/server/http.d.ts +36 -3
- package/dist/server/http.d.ts.map +1 -1
- package/dist/server/http.js +49 -3
- package/dist/server/http.js.map +1 -1
- package/dist/server/install.d.ts +6 -8
- package/dist/server/install.d.ts.map +1 -1
- package/dist/server/install.js +7 -0
- package/dist/server/install.js.map +1 -1
- package/dist/server/node-outcome-hook.d.ts +2 -1
- package/dist/server/node-outcome-hook.d.ts.map +1 -1
- package/dist/server/node-outcome-hook.js.map +1 -1
- package/dist/server/node-outcome.d.ts +17 -2
- package/dist/server/node-outcome.d.ts.map +1 -1
- package/dist/server/node-outcome.js +37 -3
- package/dist/server/node-outcome.js.map +1 -1
- package/dist/server/plugin.d.ts +2 -2
- package/dist/server/plugin.d.ts.map +1 -1
- package/dist/server/plugin.js +6 -1
- package/dist/server/plugin.js.map +1 -1
- package/dist/server/query.d.ts +7 -1
- package/dist/server/query.d.ts.map +1 -1
- package/dist/server/query.js +8 -3
- package/dist/server/query.js.map +1 -1
- package/dist/server/registry.d.ts +40 -12
- package/dist/server/registry.d.ts.map +1 -1
- package/dist/server/request-context.d.ts +2 -13
- package/dist/server/request-context.d.ts.map +1 -1
- package/dist/server/request-context.js +18 -159
- package/dist/server/request-context.js.map +1 -1
- package/dist/server/respond.d.ts.map +1 -1
- package/dist/server/respond.js +58 -4
- package/dist/server/respond.js.map +1 -1
- package/dist/server/response-contract-lane.d.ts.map +1 -1
- package/dist/server/response-contract-lane.js +5 -2
- package/dist/server/response-contract-lane.js.map +1 -1
- package/dist/server/response-observer-runtime.d.ts +20 -0
- package/dist/server/response-observer-runtime.d.ts.map +1 -0
- package/dist/server/response-observer-runtime.js +95 -0
- package/dist/server/response-observer-runtime.js.map +1 -0
- package/dist/server/runtime-core.d.ts +76 -0
- package/dist/server/runtime-core.d.ts.map +1 -1
- package/dist/server/runtime-core.js +42 -1
- package/dist/server/runtime-core.js.map +1 -1
- package/dist/server/server-types.d.ts +6 -1
- package/dist/server/server-types.d.ts.map +1 -1
- package/dist/server/server.d.ts +158 -116
- package/dist/server/server.d.ts.map +1 -1
- package/dist/server/server.js +707 -844
- package/dist/server/server.js.map +1 -1
- package/dist/server/validation.d.ts +5 -0
- package/dist/server/validation.d.ts.map +1 -0
- package/dist/server/validation.js +13 -0
- package/dist/server/validation.js.map +1 -0
- package/dist/server/websocket.d.ts +20 -4
- package/dist/server/websocket.d.ts.map +1 -1
- package/dist/server/websocket.js +81 -11
- package/dist/server/websocket.js.map +1 -1
- package/dist/server/ws-bun.d.ts +12 -4
- package/dist/server/ws-bun.d.ts.map +1 -1
- package/dist/server/ws-bun.js +50 -16
- package/dist/server/ws-bun.js.map +1 -1
- package/dist/server/ws-hook.d.ts +3 -2
- package/dist/server/ws-hook.d.ts.map +1 -1
- package/dist/server.d.ts +3 -2
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +2 -1
- package/dist/server.js.map +1 -1
- package/dist/single-copy-register.d.ts +2 -0
- package/dist/single-copy-register.d.ts.map +1 -0
- package/dist/single-copy-register.js +24 -0
- package/dist/single-copy-register.js.map +1 -0
- package/dist/single-copy.d.ts +156 -0
- package/dist/single-copy.d.ts.map +1 -0
- package/dist/single-copy.js +472 -0
- package/dist/single-copy.js.map +1 -0
- package/package.json +28 -3
- package/src/assurance.ts +58 -1
- package/src/durable-adapters.ts +20 -0
- package/src/durable-approval.ts +281 -0
- package/src/durable-effect.ts +300 -0
- package/src/durable-execution.ts +8 -1627
- package/src/durable-saga.ts +744 -0
- package/src/edge-kit.ts +27 -0
- package/src/errors.ts +1 -0
- package/src/index.ts +129 -2
- package/src/internal/durable-approval-protocol.ts +1 -1
- package/src/internal/durable-effect-protocol.ts +1 -1
- package/src/internal/durable-saga-protocol.ts +1 -1
- package/src/internal/durable-shared.ts +157 -0
- package/src/internal/durable-types.ts +194 -0
- package/src/internal/route-compiler.ts +234 -0
- package/src/internal/route-execution.ts +53 -96
- package/src/internal/route-lanes.ts +221 -0
- package/src/internal/route-program.ts +404 -0
- package/src/response-observer.ts +64 -0
- package/src/security/baseline.ts +172 -0
- package/src/server/bare-error-lane.ts +77 -0
- package/src/server/body-lane.ts +203 -0
- package/src/server/body.ts +8 -0
- package/src/server/bridge-markers.ts +24 -0
- package/src/server/context.ts +6 -1
- package/src/server/contract.ts +70 -20
- package/src/server/cookies.ts +16 -2
- package/src/server/header-case.ts +3 -1
- package/src/server/http.ts +53 -3
- package/src/server/install.ts +14 -0
- package/src/server/node-outcome-hook.ts +2 -1
- package/src/server/node-outcome.ts +44 -3
- package/src/server/plugin.ts +11 -5
- package/src/server/query.ts +10 -4
- package/src/server/registry.ts +71 -16
- package/src/server/request-context.ts +13 -216
- package/src/server/respond.ts +71 -3
- package/src/server/response-contract-lane.ts +6 -2
- package/src/server/response-observer-runtime.ts +135 -0
- package/src/server/runtime-core.ts +124 -1
- package/src/server/server-types.ts +6 -1
- package/src/server/server.ts +1446 -1485
- package/src/server/validation.ts +19 -0
- package/src/server/websocket.ts +127 -17
- package/src/server/ws-bun.ts +67 -15
- package/src/server/ws-hook.ts +3 -2
- package/src/server.ts +8 -2
- package/src/single-copy-register.ts +24 -0
- package/src/single-copy.ts +526 -0
|
@@ -98,10 +98,18 @@ export interface WebSocketHandler<Data = unknown, Env = unknown, Schema extends
|
|
|
98
98
|
/**
|
|
99
99
|
* The **outbound** frame contract (server → client), a Standard Schema. Purely type-level: it types
|
|
100
100
|
* the frames the typed client's `.ws()` handle receives, and documents what this route pushes. The
|
|
101
|
-
* server does NOT runtime-validate its own sends - the inbound `messageSchema` guards the
|
|
102
|
-
* boundary; outbound honesty is the handler author's code
|
|
101
|
+
* server does NOT runtime-validate its own sends by default - the inbound `messageSchema` guards the
|
|
102
|
+
* trust boundary; outbound honesty is the handler author's code. Set {@link validateSend} to opt into
|
|
103
|
+
* a synchronous runtime check of JSON text/UTF-8 binary frames.
|
|
103
104
|
*/
|
|
104
105
|
sendSchema?: Send;
|
|
106
|
+
/**
|
|
107
|
+
* Opt-in runtime enforcement for {@link sendSchema}. Invalid JSON, schema failures, and async
|
|
108
|
+
* validators are dropped before the native socket's `send()` runs and reported to `error()` when it
|
|
109
|
+
* exists. This is a development/contract check for the server's own output, not an inbound security
|
|
110
|
+
* boundary. It is off by default and requires `sendSchema` at registration.
|
|
111
|
+
*/
|
|
112
|
+
validateSend?: boolean;
|
|
105
113
|
/** Decode versioned transport frames before inbound schema validation. Omit for legacy JSON. */
|
|
106
114
|
transport?: {
|
|
107
115
|
readonly registry: TransportCodecRegistry;
|
|
@@ -165,11 +173,19 @@ export interface StandardWebSocket {
|
|
|
165
173
|
* `open` event (Deno). Lifecycle callbacks are error-isolated - a throw (or async rejection) routes to
|
|
166
174
|
* `error()` and never tears the process down; binary frames are normalized to `Uint8Array`.
|
|
167
175
|
*/
|
|
168
|
-
export declare function attachWebSocket(socket: StandardWebSocket, handler: WebSocketHandler, data: unknown, options: {
|
|
176
|
+
export declare function attachWebSocket<Data = unknown, Env = unknown, Schema extends StandardSchemaV1 | undefined = undefined, Send extends StandardSchemaV1 | undefined = undefined>(socket: StandardWebSocket, handler: WebSocketHandler<Data, Env, Schema, Send>, data: unknown, options: {
|
|
169
177
|
openNow: boolean;
|
|
170
178
|
pubsub: TopicRegistry;
|
|
171
179
|
maxPayloadBytes?: number;
|
|
172
|
-
}): NifraWebSocket
|
|
180
|
+
}): NifraWebSocket<Data>;
|
|
181
|
+
type WebSocketSendPayload = string | ArrayBufferView | ArrayBuffer;
|
|
182
|
+
/**
|
|
183
|
+
* Build the socket's send function once. The disabled path returns the native sender directly, so
|
|
184
|
+
* the default type-only contract adds no per-frame branch or schema work. Runtime validation is
|
|
185
|
+
* deliberately synchronous: a socket `send()` cannot await an async Standard Schema without changing
|
|
186
|
+
* the portable API, so an async result fails closed and is never sent.
|
|
187
|
+
*/
|
|
188
|
+
export declare function createWebSocketSender(send: (payload: WebSocketSendPayload) => void, schema: StandardSchemaV1 | undefined, enabled: boolean | undefined, transport: WebSocketHandler["transport"], onError: (error: unknown) => void): (payload: WebSocketSendPayload) => void;
|
|
173
189
|
/**
|
|
174
190
|
* If the handler declares a `messageSchema`, return a copy whose `message` validates each frame -
|
|
175
191
|
* parse as JSON, run the Standard Schema, then call the user's `message` with the typed value, or
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"websocket.d.ts","sourceRoot":"","sources":["../../src/server/websocket.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,aAAa,EACb,gBAAgB,EAEjB,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EAAwB,KAAK,sBAAsB,EAAE,MAAM,uBAAuB,CAAA;AAEzF,KAAK,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;AAErC,4FAA4F;AAC5F,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,UAAU,CAAA;AAE/C;+DAC+D;AAC/D,KAAK,cAAc,CAAC,MAAM,SAAS,gBAAgB,GAAG,SAAS,IAAI,MAAM,SAAS,gBAAgB,GAC9F,WAAW,CAAC,MAAM,CAAC,GACnB,aAAa,CAAA;AAEjB,kGAAkG;AAClG,MAAM,WAAW,cAAc,CAAC,IAAI,GAAG,OAAO;IAC5C,6FAA6F;IAC7F,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,GAAG,WAAW,GAAG,IAAI,CAAA;IACxD,qEAAqE;IACrE,KAAK,CAAC,IAAI,CAA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AAKD,KAAK,oBAAoB,GAAG,MAAM,GAAG,eAAe,GAAG,WAAW,CAAA;AAuBlE;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,CAAC,OAAO,EAAE,oBAAoB,KAAK,IAAI,EAC7C,MAAM,EAAE,gBAAgB,GAAG,SAAS,EACpC,OAAO,EAAE,OAAO,GAAG,SAAS,EAC5B,SAAS,EAAE,gBAAgB,CAAC,WAAW,CAAC,EACxC,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,GAChC,CAAC,OAAO,EAAE,oBAAoB,KAAK,IAAI,CA8CzC;AAED;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAAC,OAAO,EAAE,gBAAgB,GAAG,gBAAgB,CAgC1F"}
|
package/dist/server/websocket.js
CHANGED
|
@@ -91,17 +91,7 @@ function toBinary(raw) {
|
|
|
91
91
|
*/
|
|
92
92
|
export function attachWebSocket(socket, handler, data, options) {
|
|
93
93
|
const { pubsub } = options;
|
|
94
|
-
|
|
95
|
-
send: (payload) => socket.send(payload),
|
|
96
|
-
close: (code, reason) => socket.close(code, reason),
|
|
97
|
-
get readyState() {
|
|
98
|
-
return socket.readyState;
|
|
99
|
-
},
|
|
100
|
-
subscribe: (topic) => pubsub.subscribe(topic, ws),
|
|
101
|
-
unsubscribe: (topic) => pubsub.unsubscribe(topic, ws),
|
|
102
|
-
data,
|
|
103
|
-
raw: socket,
|
|
104
|
-
};
|
|
94
|
+
let ws;
|
|
105
95
|
const reportError = (error) => {
|
|
106
96
|
if (handler.error === undefined)
|
|
107
97
|
return;
|
|
@@ -114,6 +104,18 @@ export function attachWebSocket(socket, handler, data, options) {
|
|
|
114
104
|
/* the error handler itself failed - last resort, swallow */
|
|
115
105
|
}
|
|
116
106
|
};
|
|
107
|
+
const send = createWebSocketSender((payload) => socket.send(payload), handler.sendSchema, handler.validateSend, handler.transport, reportError);
|
|
108
|
+
ws = {
|
|
109
|
+
send,
|
|
110
|
+
close: (code, reason) => socket.close(code, reason),
|
|
111
|
+
get readyState() {
|
|
112
|
+
return socket.readyState;
|
|
113
|
+
},
|
|
114
|
+
subscribe: (topic) => pubsub.subscribe(topic, ws),
|
|
115
|
+
unsubscribe: (topic) => pubsub.unsubscribe(topic, ws),
|
|
116
|
+
data: data,
|
|
117
|
+
raw: socket,
|
|
118
|
+
};
|
|
117
119
|
const safe = (call) => {
|
|
118
120
|
try {
|
|
119
121
|
const r = call();
|
|
@@ -160,6 +162,74 @@ export function attachWebSocket(socket, handler, data, options) {
|
|
|
160
162
|
}
|
|
161
163
|
const WS_MESSAGE_DECODER = new TextDecoder();
|
|
162
164
|
const WS_PAYLOAD_ENCODER = new TextEncoder();
|
|
165
|
+
const OUTBOUND_VALIDATION_ERROR = "outbound WebSocket frame failed sendSchema validation";
|
|
166
|
+
function outboundValueOf(payload, transport) {
|
|
167
|
+
const text = typeof payload === "string"
|
|
168
|
+
? payload
|
|
169
|
+
: WS_MESSAGE_DECODER.decode(payload instanceof ArrayBuffer
|
|
170
|
+
? new Uint8Array(payload)
|
|
171
|
+
: new Uint8Array(payload.buffer, payload.byteOffset, payload.byteLength));
|
|
172
|
+
return transport === undefined
|
|
173
|
+
? JSON.parse(text)
|
|
174
|
+
: decodeTransportFrame(text, transport.registry, {
|
|
175
|
+
...(transport.maxBytes === undefined ? {} : { maxBytes: transport.maxBytes }),
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Build the socket's send function once. The disabled path returns the native sender directly, so
|
|
180
|
+
* the default type-only contract adds no per-frame branch or schema work. Runtime validation is
|
|
181
|
+
* deliberately synchronous: a socket `send()` cannot await an async Standard Schema without changing
|
|
182
|
+
* the portable API, so an async result fails closed and is never sent.
|
|
183
|
+
*/
|
|
184
|
+
export function createWebSocketSender(send, schema, enabled, transport, onError) {
|
|
185
|
+
if (enabled !== true || schema === undefined)
|
|
186
|
+
return send;
|
|
187
|
+
let reporting = false;
|
|
188
|
+
const reportFailure = (error) => {
|
|
189
|
+
// An error handler may try to send a diagnostic. Do not recurse forever when that diagnostic also
|
|
190
|
+
// violates the same outbound contract. EVERY failure path reports through here - a path that calls
|
|
191
|
+
// `onError` directly reopens that recursion for the one rejection shape it happens to cover.
|
|
192
|
+
if (reporting)
|
|
193
|
+
return;
|
|
194
|
+
reporting = true;
|
|
195
|
+
try {
|
|
196
|
+
onError(error);
|
|
197
|
+
}
|
|
198
|
+
finally {
|
|
199
|
+
reporting = false;
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
return (payload) => {
|
|
203
|
+
let value;
|
|
204
|
+
try {
|
|
205
|
+
value = outboundValueOf(payload, transport);
|
|
206
|
+
}
|
|
207
|
+
catch {
|
|
208
|
+
reportFailure(new Error(OUTBOUND_VALIDATION_ERROR));
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
let outcome;
|
|
212
|
+
try {
|
|
213
|
+
outcome = validateStandard(schema, value);
|
|
214
|
+
}
|
|
215
|
+
catch {
|
|
216
|
+
reportFailure(new Error(OUTBOUND_VALIDATION_ERROR));
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
if (outcome instanceof Promise) {
|
|
220
|
+
// Do not await or send later: the portable `send()` contract is synchronous. Attach a rejection
|
|
221
|
+
// handler so a validator that rejects cannot become an unhandled process-level rejection.
|
|
222
|
+
outcome.catch(() => { });
|
|
223
|
+
reportFailure(new Error(`${OUTBOUND_VALIDATION_ERROR}; validator must be synchronous`));
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
if (!outcome.ok) {
|
|
227
|
+
reportFailure(new Error(OUTBOUND_VALIDATION_ERROR));
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
send(payload);
|
|
231
|
+
};
|
|
232
|
+
}
|
|
163
233
|
/**
|
|
164
234
|
* If the handler declares a `messageSchema`, return a copy whose `message` validates each frame -
|
|
165
235
|
* parse as JSON, run the Standard Schema, then call the user's `message` with the typed value, or
|
|
@@ -1 +1 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AAO,CAAC,SAAS,KAAK,SAAS;oBAC7B,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;oBAClB,CAAC,CAAC,oBAAoB,CAAC,IAAI,EAAE,OAAO,CAAC,SAAS,CAAC,QAAQ,EAAE;wBACrD,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,QAAQ,KAAK,SAAS;4BAC1C,CAAC,CAAC,EAAE;4BACJ,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;qBAC9C,CAAC,CAAA;QACV,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,SAAS,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC,EAAE,GAAG,CAAC,CAAA;QAC5D,CAAC;QACD,MAAM,OAAO,GAAG,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;QAChD,MAAM,MAAM,GAAG,CAAC,CAA6B,EAAsB,EAAE,CACnE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;QACpE,OAAO,OAAO,YAAY,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;IAC5E,CAAC,CAAA;IACD,8FAA8F;IAC9F,4EAA4E;IAC5E,OAAO,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAsB,CAAA;AACvE,CAAC"}
|
package/dist/server/ws-bun.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* bundle of a no-WebSocket app never ships it; `server.ts` only imports the **types** from here
|
|
5
5
|
* (erased). No `Bun.*` calls here - the runtime seam stays in `server.ts` (see runtime-boundary.test).
|
|
6
6
|
*/
|
|
7
|
-
import type
|
|
7
|
+
import { type NifraWebSocket, type TopicRegistry, type WebSocketHandler } from "./websocket.js";
|
|
8
8
|
import type { BunWsHandlers } from "./ws-hook.js";
|
|
9
9
|
/** Per-connection state Bun's `websocket` callbacks read via `ws.data`: the matched handler, the
|
|
10
10
|
* `upgrade()`-seeded user data, and the memoized portable {@link NifraWebSocket} wrapper. */
|
|
@@ -19,9 +19,17 @@ export interface BunSocket {
|
|
|
19
19
|
send(data: string | ArrayBufferView | ArrayBuffer, compress?: boolean): number;
|
|
20
20
|
close(code?: number, reason?: string): void;
|
|
21
21
|
readonly readyState: number;
|
|
22
|
+
subscribe(topic: string): void;
|
|
23
|
+
unsubscribe(topic: string): void;
|
|
22
24
|
readonly data: BunWsData;
|
|
23
25
|
}
|
|
24
|
-
/**
|
|
25
|
-
* `
|
|
26
|
-
|
|
26
|
+
/**
|
|
27
|
+
* The shared Bun `websocket` dispatcher config for one app - each connection's `ws.data.handler` is
|
|
28
|
+
* the matched route's handler, set by `server.upgrade`.
|
|
29
|
+
*
|
|
30
|
+
* `nativePubsub` (set by `listen()` when the app has no validated-send route) makes subscriptions use
|
|
31
|
+
* Bun's own pub/sub; there the registry holds nothing and Bun auto-drops native subscriptions on
|
|
32
|
+
* close, so the `unsubscribeAll` sweep is skipped.
|
|
33
|
+
*/
|
|
34
|
+
export declare function createBunWsHandlers(topics: TopicRegistry, nativePubsub?: boolean): BunWsHandlers;
|
|
27
35
|
//# sourceMappingURL=ws-bun.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ws-bun.d.ts","sourceRoot":"","sources":["../../src/server/ws-bun.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"ws-bun.d.ts","sourceRoot":"","sources":["../../src/server/ws-bun.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,aAAa,EAElB,KAAK,gBAAgB,EACtB,MAAM,gBAAgB,CAAA;AACvB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAEjD;6FAC6F;AAC7F,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAA;IAClC,IAAI,EAAE,OAAO,CAAA;IACb,KAAK,CAAC,EAAE,cAAc,CAAA;CACvB;AAED;6EAC6E;AAC7E,MAAM,WAAW,SAAS;IACxB,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,GAAG,WAAW,EAAE,QAAQ,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;IAC9E,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAG3B,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IAEhC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;CACzB;AAiFD;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,aAAa,EAAE,YAAY,UAAQ,GAAG,aAAa,CAgC9F"}
|
package/dist/server/ws-bun.js
CHANGED
|
@@ -4,23 +4,38 @@
|
|
|
4
4
|
* bundle of a no-WebSocket app never ships it; `server.ts` only imports the **types** from here
|
|
5
5
|
* (erased). No `Bun.*` calls here - the runtime seam stays in `server.ts` (see runtime-boundary.test).
|
|
6
6
|
*/
|
|
7
|
+
import { createWebSocketSender, } from "./websocket.js";
|
|
7
8
|
/** Normalize a received binary frame to `Uint8Array` (Bun hands a `Buffer`, already one; an
|
|
8
9
|
* `ArrayBuffer` is wrapped). Text frames stay `string`. */
|
|
9
10
|
function toBinaryData(message) {
|
|
10
11
|
return message instanceof Uint8Array ? message : new Uint8Array(message);
|
|
11
12
|
}
|
|
12
|
-
/**
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Wrap a Bun `ServerWebSocket` as the portable {@link NifraWebSocket} handed to WS callbacks.
|
|
15
|
+
*
|
|
16
|
+
* `nativePubsub` selects the topic backend: in native mode `subscribe`/`unsubscribe` go straight to
|
|
17
|
+
* Bun's own (uWebSockets) pub/sub so a broadcast via the Bun server's `publish` reaches this socket
|
|
18
|
+
* with no per-connection JS loop; otherwise they use the runtime-neutral {@link TopicRegistry}. Native
|
|
19
|
+
* mode is used only when no route validates outbound frames, so raw and validated sends are identical.
|
|
20
|
+
*/
|
|
21
|
+
function wrapBunSocket(raw, topics, handler, nativePubsub) {
|
|
22
|
+
let ws;
|
|
23
|
+
const reportError = (error) => reportWsError(error, ws, handler);
|
|
24
|
+
const send = createWebSocketSender((data) => {
|
|
25
|
+
raw.send(data);
|
|
26
|
+
}, handler.sendSchema, handler.validateSend, handler.transport, reportError);
|
|
27
|
+
ws = {
|
|
28
|
+
send,
|
|
18
29
|
close: (code, reason) => raw.close(code, reason),
|
|
19
30
|
get readyState() {
|
|
20
31
|
return raw.readyState;
|
|
21
32
|
},
|
|
22
|
-
subscribe:
|
|
23
|
-
|
|
33
|
+
subscribe: nativePubsub
|
|
34
|
+
? (topic) => raw.subscribe(topic)
|
|
35
|
+
: (topic) => topics.subscribe(topic, ws),
|
|
36
|
+
unsubscribe: nativePubsub
|
|
37
|
+
? (topic) => raw.unsubscribe(topic)
|
|
38
|
+
: (topic) => topics.unsubscribe(topic, ws),
|
|
24
39
|
get data() {
|
|
25
40
|
return raw.data.data;
|
|
26
41
|
},
|
|
@@ -55,26 +70,45 @@ function dispatchWsCallback(call, ws, handler) {
|
|
|
55
70
|
reportWsError(error, ws, handler);
|
|
56
71
|
}
|
|
57
72
|
}
|
|
58
|
-
/**
|
|
59
|
-
* `
|
|
60
|
-
|
|
73
|
+
/**
|
|
74
|
+
* The shared Bun `websocket` dispatcher config for one app - each connection's `ws.data.handler` is
|
|
75
|
+
* the matched route's handler, set by `server.upgrade`.
|
|
76
|
+
*
|
|
77
|
+
* `nativePubsub` (set by `listen()` when the app has no validated-send route) makes subscriptions use
|
|
78
|
+
* Bun's own pub/sub; there the registry holds nothing and Bun auto-drops native subscriptions on
|
|
79
|
+
* close, so the `unsubscribeAll` sweep is skipped.
|
|
80
|
+
*/
|
|
81
|
+
export function createBunWsHandlers(topics, nativePubsub = false) {
|
|
61
82
|
return {
|
|
62
83
|
open: (raw) => {
|
|
63
84
|
const ws = raw;
|
|
64
|
-
const nifra = wrapBunSocket(ws, topics);
|
|
85
|
+
const nifra = wrapBunSocket(ws, topics, ws.data.handler, nativePubsub);
|
|
65
86
|
ws.data.nifra = nifra;
|
|
66
87
|
dispatchWsCallback(() => ws.data.handler.open?.(nifra), nifra, ws.data.handler);
|
|
67
88
|
},
|
|
68
89
|
message: (raw, message) => {
|
|
69
90
|
const ws = raw;
|
|
70
|
-
const
|
|
91
|
+
const handler = ws.data.handler;
|
|
92
|
+
const nifra = ws.data.nifra ?? wrapBunSocket(ws, topics, handler, nativePubsub);
|
|
71
93
|
const data = typeof message === "string" ? message : toBinaryData(message);
|
|
72
|
-
|
|
94
|
+
// Hottest WS path - dispatch inline rather than through `dispatchWsCallback` so no per-frame
|
|
95
|
+
// closure is allocated. Same contract: a sync throw or async rejection routes to `handler.error`.
|
|
96
|
+
try {
|
|
97
|
+
const result = handler.message?.(nifra, data);
|
|
98
|
+
if (result instanceof Promise)
|
|
99
|
+
result.catch((e) => reportWsError(e, nifra, handler));
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
reportWsError(error, nifra, handler);
|
|
103
|
+
}
|
|
73
104
|
},
|
|
74
105
|
close: (raw, code, reason) => {
|
|
75
106
|
const ws = raw;
|
|
76
|
-
const nifra = ws.data.nifra ?? wrapBunSocket(ws, topics);
|
|
77
|
-
|
|
107
|
+
const nifra = ws.data.nifra ?? wrapBunSocket(ws, topics, ws.data.handler, nativePubsub);
|
|
108
|
+
// Registry mode: drop topic subscriptions so it never holds a dead socket. Native mode: Bun
|
|
109
|
+
// unsubscribes the socket from every topic on close, so there is nothing to sweep here.
|
|
110
|
+
if (!nativePubsub)
|
|
111
|
+
topics.unsubscribeAll(nifra);
|
|
78
112
|
dispatchWsCallback(() => ws.data.handler.close?.(nifra, code, reason), nifra, ws.data.handler);
|
|
79
113
|
},
|
|
80
114
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ws-bun.js","sourceRoot":"","sources":["../../src/server/ws-bun.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"ws-bun.js","sourceRoot":"","sources":["../../src/server/ws-bun.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,qBAAqB,GAKtB,MAAM,gBAAgB,CAAA;AAyBvB;2DAC2D;AAC3D,SAAS,YAAY,CAAC,OAAiC;IACrD,OAAO,OAAO,YAAY,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,OAAO,CAAC,CAAA;AAC1E,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,aAAa,CACpB,GAAc,EACd,MAAqB,EACrB,OAAyB,EACzB,YAAqB;IAErB,IAAI,EAAmB,CAAA;IACvB,MAAM,WAAW,GAAG,CAAC,KAAc,EAAQ,EAAE,CAAC,aAAa,CAAC,KAAK,EAAE,EAAE,EAAE,OAAO,CAAC,CAAA;IAC/E,MAAM,IAAI,GAAG,qBAAqB,CAChC,CAAC,IAAI,EAAE,EAAE;QACP,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAChB,CAAC,EACD,OAAO,CAAC,UAAU,EAClB,OAAO,CAAC,YAAY,EACpB,OAAO,CAAC,SAAS,EACjB,WAAW,CACZ,CAAA;IACD,EAAE,GAAG;QACH,I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AAC,CAAC,OAAO,CAAC,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,CAAA;YACzF,6FAA6F;YAC7F,kGAAkG;YAClG,IAAI,CAAC;gBACH,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;gBAC7C,IAAI,MAAM,YAAY,OAAO;oBAC3B,MAAM,CAAC,KAAK,CAAC,CAAC,CAAU,EAAE,EAAE,CAAC,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAA;YAClE,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,aAAa,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,CAAA;YACtC,CAAC;QACH,CAAC;QACD,KAAK,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE;YAC3B,MAAM,EAAE,GAAG,GAAgB,CAAA;YAC3B,MAAM,KAAK,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,IAAI,aAAa,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,CAAA;YACvF,4FAA4F;YAC5F,wFAAwF;YACxF,IAAI,CAAC,YAAY;gBAAE,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAA;YAC/C,kBAAkB,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAChG,CAAC;KACF,CAAA;AACH,CAAC"}
|
package/dist/server/ws-hook.d.ts
CHANGED
|
@@ -22,8 +22,9 @@ export interface WsRuntime {
|
|
|
22
22
|
wrapHandler(handler: WebSocketHandler): WebSocketHandler;
|
|
23
23
|
/** One in-process pub/sub registry per app (backs `ws.subscribe` + `app.publish`). */
|
|
24
24
|
createTopics(): TopicRegistry;
|
|
25
|
-
/** The Bun `websocket` config for `listen()` when the app has WS routes.
|
|
26
|
-
|
|
25
|
+
/** The Bun `websocket` config for `listen()` when the app has WS routes. `nativePubsub` routes
|
|
26
|
+
* `ws.subscribe` through Bun's own pub/sub (set when no route validates outbound frames). */
|
|
27
|
+
bunHandlers(topics: TopicRegistry, nativePubsub?: boolean): BunWsHandlers;
|
|
27
28
|
/** `attachWebSocket` - wires a standard server socket (Workers `WebSocketPair`) to a handler. */
|
|
28
29
|
attach(socket: StandardWebSocket, handler: WebSocketHandler, data: unknown, options: {
|
|
29
30
|
openNow: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ws-hook.d.ts","sourceRoot":"","sources":["../../src/server/ws-hook.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,gBAAgB,EACjB,MAAM,gBAAgB,CAAA;AAEvB;;iDAEiD;AACjD,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,EAAE,OAAO,GAAG,IAAI,CAAA;IACvB,OAAO,CAAC,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,WAAW,GAAG,UAAU,GAAG,IAAI,CAAA;IACtE,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;CACvD;AAED,sGAAsG;AACtG,MAAM,WAAW,SAAS;IACxB,kFAAkF;IAClF,WAAW,CAAC,OAAO,EAAE,gBAAgB,GAAG,gBAAgB,CAAA;IACxD,sFAAsF;IACtF,YAAY,IAAI,aAAa,CAAA;IAC7B
|
|
1
|
+
{"version":3,"file":"ws-hook.d.ts","sourceRoot":"","sources":["../../src/server/ws-hook.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,gBAAgB,EACjB,MAAM,gBAAgB,CAAA;AAEvB;;iDAEiD;AACjD,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,EAAE,OAAO,GAAG,IAAI,CAAA;IACvB,OAAO,CAAC,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,WAAW,GAAG,UAAU,GAAG,IAAI,CAAA;IACtE,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;CACvD;AAED,sGAAsG;AACtG,MAAM,WAAW,SAAS;IACxB,kFAAkF;IAClF,WAAW,CAAC,OAAO,EAAE,gBAAgB,GAAG,gBAAgB,CAAA;IACxD,sFAAsF;IACtF,YAAY,IAAI,aAAa,CAAA;IAC7B;iGAC6F;IAC7F,WAAW,CAAC,MAAM,EAAE,aAAa,EAAE,YAAY,CAAC,EAAE,OAAO,GAAG,aAAa,CAAA;IACzE,iGAAiG;IACjG,MAAM,CACJ,MAAM,EAAE,iBAAiB,EACzB,OAAO,EAAE,gBAAgB,EACzB,IAAI,EAAE,OAAO,EACb,OAAO,EAAE;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,aAAa,CAAA;KAAE,GACnD,cAAc,CAAA;CAClB"}
|
package/dist/server.d.ts
CHANGED
|
@@ -15,10 +15,11 @@ export type { InferInput, InferOutput, StandardIssue, StandardResult, StandardSc
|
|
|
15
15
|
export type { Context, Params, Platform, Prettify, ResponseControls, RouteSchema, } from "./server/context.js";
|
|
16
16
|
export { type CookieOptions, type CookieSecret, cookieNamePrefix, parseCookies, serializeCookie, signValue, unsignValue, } from "./server/cookies.js";
|
|
17
17
|
export { type DurableObjectNamespaceLike, type ExecutionContext, type ScheduledController, type ScheduledHandler, toFetchHandler, } from "./server/edge.js";
|
|
18
|
-
export { pathnameOf, type UrlParts, urlPartsOf } from "./server/http.js";
|
|
18
|
+
export { isSameOriginPath, pathnameOf, type UrlParts, urlPartsOf } from "./server/http.js";
|
|
19
19
|
export { commonSecretPatterns, jsonLogger, type LogFields, type Logger, type RedactOptions, redactLogFields, silentLogger, } from "./server/logger.js";
|
|
20
20
|
export { type FetchApp, type LambdaEvent, type LambdaHandler, type LambdaResponse, type LambdaV1Event, type LambdaV2Event, type NetlifyEvent, type NetlifyHandler, type PlatformResponse, toLambdaHandler, toNetlifyHandler, toVercelHandler, type VercelHandler, } from "./server/platform-adapters.js";
|
|
21
|
-
export type { Registry, RouteInfo } from "./server/registry.js";
|
|
21
|
+
export type { Registry, ResponseMapFor, RouteInfo, RouteInfoFor } from "./server/registry.js";
|
|
22
|
+
export { type PlainRender, type ResponseResult, type StatusResponse, status, } from "./server/runtime-core.js";
|
|
22
23
|
export { type AdmissionController, type AdmissionDecision, type AnyServer, type ContextPlugin, type DefinePluginResult, defineContextPlugin, defineIdentityPlugin, definePlugin, defineRouterPlugin, type Handler, type IdentityPlugin, type McpPromptDescriptor, type McpResourceDescriptor, type Middleware, type NifraFeatureVersion, type NifraPlugin, type NodeRequestContext, type NodeRequestHook, type NodeResponseContext, type NodeResponseHook, type NodeServeOutcome, type OnRequestResult, type PluginTypeCollapsed, type PromptArgument, type PromptMessage, type ResponseBodyHook, type ResponseBodyReplacement, type ResponseFinalization, type ResponseHeadersHook, type ResponseHeadersView, type RouteDescriptor, type RunningServer, Server, type ServerOptions, server, type ToolAnnotations, } from "./server/server.js";
|
|
23
24
|
export type { SSEContext, SSEInit, SSEMessage, SSEStream, TypedSSEStream, } from "./server/sse.js";
|
|
24
25
|
export type { NifraWebSocket, StandardWebSocket, WebSocketContext, WebSocketData, WebSocketHandler, WebSocketUpgradeOutcome, } from "./server/websocket.js";
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO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EACL,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,mBAAmB,EACnB,oBAAoB,EACpB,YAAY,EACZ,kBAAkB,EAClB,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,UAAU,EACf,KAAK,mBAAmB,EACxB,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,MAAM,EACN,KAAK,aAAa,EAClB,MAAM,EACN,KAAK,eAAe,GACrB,MAAM,oBAAoB,CAAA;AAC3B,YAAY,EACV,UAAU,EACV,OAAO,EACP,UAAU,EACV,SAAS,EACT,cAAc,GACf,MAAM,iBAAiB,CAAA;AACxB,YAAY,EACV,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACb,gBAAgB,EAChB,uBAAuB,GACxB,MAAM,uBAAuB,CAAA"}
|
package/dist/server.js
CHANGED
|
@@ -13,8 +13,9 @@ export { isSameOriginRequest } from "./internal/same-origin.js";
|
|
|
13
13
|
export { METHODS, Router } from "./router/router.js";
|
|
14
14
|
export { cookieNamePrefix, parseCookies, serializeCookie, signValue, unsignValue, } from "./server/cookies.js";
|
|
15
15
|
export { toFetchHandler, } from "./server/edge.js";
|
|
16
|
-
export { pathnameOf, urlPartsOf } from "./server/http.js";
|
|
16
|
+
export { isSameOriginPath, pathnameOf, urlPartsOf } from "./server/http.js";
|
|
17
17
|
export { commonSecretPatterns, jsonLogger, redactLogFields, silentLogger, } from "./server/logger.js";
|
|
18
18
|
export { toLambdaHandler, toNetlifyHandler, toVercelHandler, } from "./server/platform-adapters.js";
|
|
19
|
+
export { status, } from "./server/runtime-core.js";
|
|
19
20
|
export { defineContextPlugin, defineIdentityPlugin, definePlugin, defineRouterPlugin, Server, server, } from "./server/server.js";
|
|
20
21
|
//# sourceMappingURL=server.js.map
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAA6B,MAAM,aAAa,CAAA;AACzF,OAAO,EAAE,cAAc,EAAsB,MAAM,qBAAqB,CAAA;AACxE,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAA;AAC/D,OAAO,EAAE,OAAO,EAAe,MAAM,EAAoB,MAAM,oBAAoB,CAAA;AAkBnF,OAAO,EAGL,gBAAgB,EAChB,YAAY,EACZ,eAAe,EACf,SAAS,EACT,WAAW,GACZ,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAKL,cAAc,GACf,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,UAAU,EAAiB,UAAU,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAA6B,MAAM,aAAa,CAAA;AACzF,OAAO,EAAE,cAAc,EAAsB,MAAM,qBAAqB,CAAA;AACxE,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAA;AAC/D,OAAO,EAAE,OAAO,EAAe,MAAM,EAAoB,MAAM,oBAAoB,CAAA;AAkBnF,OAAO,EAGL,gBAAgB,EAChB,YAAY,EACZ,eAAe,EACf,SAAS,EACT,WAAW,GACZ,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAKL,cAAc,GACf,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAiB,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC1F,OAAO,EACL,oBAAoB,EACpB,UAAU,EAIV,eAAe,EACf,YAAY,GACb,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAUL,eAAe,EACf,gBAAgB,EAChB,eAAe,GAEhB,MAAM,+BAA+B,CAAA;AAEtC,OAAO,EAIL,MAAM,GACP,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAML,mBAAmB,EACnB,oBAAoB,EACpB,YAAY,EACZ,kBAAkB,EAwBlB,MAAM,EAEN,MAAM,GAEP,MAAM,oBAAoB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"single-copy-register.d.ts","sourceRoot":"","sources":["../src/single-copy-register.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Side-effect entry (`@nifrajs/core/single-copy/register`): install the single-copy resolver into the
|
|
3
|
+
* Bun runtime.
|
|
4
|
+
*
|
|
5
|
+
* Preload it - never import it from application code:
|
|
6
|
+
*
|
|
7
|
+
* ```toml
|
|
8
|
+
* # bunfig.toml
|
|
9
|
+
* preload = ["@nifrajs/core/single-copy/register"]
|
|
10
|
+
* [test]
|
|
11
|
+
* preload = ["@nifrajs/core/single-copy/register"]
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* A resolver only affects imports that have not resolved yet, and a module's own imports resolve
|
|
15
|
+
* before its body runs. Registering from inside application code would therefore miss exactly the
|
|
16
|
+
* imports it exists to redirect. `preload` runs before the entry point, which is the only moment that
|
|
17
|
+
* covers the whole graph.
|
|
18
|
+
*
|
|
19
|
+
* `nifra check` reads this specifier out of `bunfig.toml` as the proof that the runtime arm is armed,
|
|
20
|
+
* so the string above is a contract rather than a suggestion.
|
|
21
|
+
*/
|
|
22
|
+
import { registerSingleCopy } from "./single-copy";
|
|
23
|
+
registerSingleCopy();
|
|
24
|
+
//# sourceMappingURL=single-copy-register.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"single-copy-register.js","sourceRoot":"","sources":["../src/single-copy-register.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAElD,kBAAkB,EAAE,CAAA"}
|