@reckona/mreact-server 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Tatsuo Kaniwa
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # @reckona/mreact-server
2
+
3
+ `@reckona/mreact-server` contains server rendering primitives used by the mreact
4
+ compiler and router. It provides HTML sinks, streaming helpers, async
5
+ boundaries, hydration scripts, event hydration manifests, Flight serialization,
6
+ and response helpers.
7
+
8
+ ## Basic Usage
9
+
10
+ ```ts
11
+ import { html, renderToString } from "@reckona/mreact-server";
12
+
13
+ const markup = await renderToString((sink) => {
14
+ sink.write("<main>Hello</main>");
15
+ });
16
+
17
+ const response = html(markup);
18
+ ```
19
+
20
+ ## Core APIs
21
+
22
+ - `createStringSink()` writes HTML into a string sink.
23
+ - `renderToString()` renders through an HTML sink.
24
+ - `renderToReadableStream()` renders to a `ReadableStream`.
25
+ - `renderAsyncBoundary()` and `renderOutOfOrderBoundary()` support async SSR.
26
+ - `renderHydrationBoundary()` and `renderEventHydrationManifest()` emit client
27
+ hydration data.
28
+ - `html()` wraps rendered HTML in a `Response`.
29
+
30
+ ## Subpaths
31
+
32
+ - `@reckona/mreact-server/reorder` applies out-of-order SSR fragments in the
33
+ browser.
34
+ - `@reckona/mreact-server/flight` exposes Flight and server action primitives.
35
+ - `@reckona/mreact-server/buffer-sink` exposes buffered streaming helpers.
36
+
37
+ ## Notes
38
+
39
+ Most applications use this package through `@reckona/mreact-router`.
@@ -0,0 +1,74 @@
1
+ interface NodeBuffer extends Uint8Array {
2
+ toString(encoding?: string, start?: number, end?: number): string;
3
+ write(input: string, offset: number, encoding?: string): number;
4
+ copy(target: NodeBuffer, targetStart?: number, sourceStart?: number, sourceEnd?: number): number;
5
+ subarray(start?: number, end?: number): NodeBuffer;
6
+ }
7
+ export interface BufferSink {
8
+ append(chunk: string | NodeBuffer): void;
9
+ toBuffer(): NodeBuffer;
10
+ toString(): string;
11
+ size(): number;
12
+ }
13
+ export interface BufferSinkOptions {
14
+ /**
15
+ * Initial backing buffer size (UTF-8 bytes). The buffer grows
16
+ * geometrically as needed. Default: 8192.
17
+ */
18
+ initialSize?: number;
19
+ /**
20
+ * Growth multiplier when the backing buffer needs to expand.
21
+ * Default: 2.
22
+ */
23
+ growthFactor?: number;
24
+ }
25
+ /**
26
+ * Creates a Node-only buffer sink with a single pre-allocated growing
27
+ * backing `Buffer`. UTF-8 encoding happens in-place at the current write
28
+ * offset, avoiding per-chunk Buffer allocation and a final concat.
29
+ *
30
+ * Compared to `Buffer.concat`-style implementations, this trades a small
31
+ * amount of headroom memory for ~5-10x throughput on small chunks
32
+ * (see docs/benchmarks/2026-05-12-server-sink-strategy.md).
33
+ */
34
+ /**
35
+ * A streaming-flavored Node buffer sink used by
36
+ * `renderToReadableStream`. Coalesces successive `append(chunk)` calls
37
+ * into a single backing `Buffer`, then hands the buffer to a consumer
38
+ * callback either on demand (`flush()`) or automatically once the
39
+ * accumulated UTF-8 byte length crosses a threshold.
40
+ *
41
+ * The contract:
42
+ * - Each call to `flush()` (or an auto-flush triggered from within
43
+ * `append`) delivers **exactly one** non-empty Buffer to the
44
+ * consumer. Empty buffers are never delivered — callers do not
45
+ * need to filter them out.
46
+ * - The delivered Buffer is exclusively owned by the consumer; the
47
+ * sink will not mutate it afterwards. Internally we allocate a
48
+ * fresh backing Buffer per epoch, so handing off a `subarray` view
49
+ * is safe with no copy.
50
+ *
51
+ * Issue 084: motivated by the streaming SSR throughput gap to
52
+ * marko-run (mreact was at 0.66x marko's ops/sec because the previous
53
+ * implementation paid a `TextEncoder.encode` + Web Streams
54
+ * `controller.enqueue` round-trip per `sink.append()` call).
55
+ */
56
+ export interface StreamingBufferSink {
57
+ append(chunk: string): void;
58
+ flush(): void;
59
+ size(): number;
60
+ }
61
+ export interface StreamingBufferSinkOptions {
62
+ /** UTF-8 byte threshold that triggers an automatic flush from inside
63
+ * `append`. Default 8 KiB (one common TCP segment payload). */
64
+ flushThreshold?: number;
65
+ /** Initial backing buffer size; same semantics as `BufferSinkOptions`. */
66
+ initialSize?: number;
67
+ /** Consumer hook — invoked at most once per `flush()` (manual or
68
+ * automatic), and only with a non-empty Buffer. */
69
+ onFlush(buffer: NodeBuffer): void;
70
+ }
71
+ export declare function createStreamingBufferSink(options: StreamingBufferSinkOptions): StreamingBufferSink;
72
+ export declare function createBufferSink(options?: BufferSinkOptions): BufferSink;
73
+ export {};
74
+ //# sourceMappingURL=buffer-sink.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buffer-sink.d.ts","sourceRoot":"","sources":["../src/buffer-sink.ts"],"names":[],"mappings":"AAcA,UAAU,UAAW,SAAQ,UAAU;IACrC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,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AO,GAAE,iBAAsB,GAAG,UAAU,CAkD5E"}
@@ -0,0 +1,86 @@
1
+ // Node 専用 buffer sink — issue 050 の対応。
2
+ //
3
+ // `createStringSink` (cross-runtime, string accumulator) と並べて、
4
+ // Node の `Buffer` を直接 accumulate する sink を提供する。HTTP response
5
+ // body へ `response.write(buffer)` で直接渡すと string → UTF-8 encode の
6
+ // cost を 1 回にまとめられる利点がある。
7
+ //
8
+ // 注: Cloudflare Workers / Deno など `Buffer` を持たない runtime では
9
+ // import 時に runtime error になる。cross-runtime ポータビリティが必要な
10
+ // callsite は `@reckona/mreact-server` 本体の `createStringSink` を使う。
11
+ //
12
+ // tsconfig は `lib: ES2022 + DOM`, `types: []` なので `@types/node` に
13
+ // 依存しないよう、`Buffer` の最小型を本 file 内で declare する。
14
+ export function createStreamingBufferSink(options) {
15
+ const flushThreshold = options.flushThreshold ?? 8192;
16
+ const initialSize = options.initialSize ?? flushThreshold;
17
+ let inner = createBufferSink({ initialSize });
18
+ const emitAndReset = () => {
19
+ const buf = inner.toBuffer();
20
+ inner = createBufferSink({ initialSize });
21
+ options.onFlush(buf);
22
+ };
23
+ return {
24
+ append(chunk) {
25
+ if (chunk === "")
26
+ return;
27
+ inner.append(chunk);
28
+ if (inner.size() >= flushThreshold) {
29
+ emitAndReset();
30
+ }
31
+ },
32
+ flush() {
33
+ if (inner.size() === 0)
34
+ return;
35
+ emitAndReset();
36
+ },
37
+ size() {
38
+ return inner.size();
39
+ },
40
+ };
41
+ }
42
+ export function createBufferSink(options = {}) {
43
+ const initialSize = options.initialSize ?? 8192;
44
+ const growthFactor = options.growthFactor ?? 2;
45
+ let buffer = Buffer.allocUnsafe(initialSize);
46
+ let offset = 0;
47
+ function ensure(requiredBytes) {
48
+ const required = offset + requiredBytes;
49
+ if (required <= buffer.length) {
50
+ return;
51
+ }
52
+ let newCapacity = buffer.length === 0 ? initialSize : buffer.length;
53
+ while (newCapacity < required) {
54
+ newCapacity = Math.ceil(newCapacity * growthFactor);
55
+ }
56
+ const grown = Buffer.allocUnsafe(newCapacity);
57
+ buffer.copy(grown, 0, 0, offset);
58
+ buffer = grown;
59
+ }
60
+ return {
61
+ append(chunk) {
62
+ if (typeof chunk === "string") {
63
+ // Reserve worst-case byte length (4 bytes/char) up front so we
64
+ // can encode in a single `write()` call without a measurement
65
+ // pass; the actual encoded length is returned by `write()`.
66
+ const upperBound = chunk.length * 4;
67
+ ensure(upperBound);
68
+ offset += buffer.write(chunk, offset, "utf8");
69
+ return;
70
+ }
71
+ ensure(chunk.length);
72
+ chunk.copy(buffer, offset);
73
+ offset += chunk.length;
74
+ },
75
+ toBuffer() {
76
+ return buffer.subarray(0, offset);
77
+ },
78
+ toString() {
79
+ return buffer.toString("utf8", 0, offset);
80
+ },
81
+ size() {
82
+ return offset;
83
+ },
84
+ };
85
+ }
86
+ //# sourceMappingURL=buffer-sink.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buffer-sink.js","sourceRoot":"","sources":["../src/buffer-sink.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,EAAE;AACF,+DAA+D;AAC/D,6DAA6D;AAC7D,iEAAiE;AACjE,0BAA0B;AAC1B,EAAE;AACF,4DAA4D;AAC5D,wDAAwD;AACxD,kEAAkE;AAClE,EAAE;AACF,kEAAkE;AAClE,8CAA8C;AAwF9C,MAAM,UAAU,yBAAyB,CACvC,OAAmC;IAEnC,MAAM,cAAc,GAAG,OAAO,CAAC,cAAc,IAAI,IAAI,CAAC;IACtD,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,cAAc,CAAC;IAC1D,IAAI,KAAK,GAAG,gBAAgB,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC;IAC9C,MAAM,YAAY,GAAG,GAAG,EAAE;QACxB,MAAM,GAAG,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC;QAC7B,KAAK,GAAG,gBAAgB,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC;QAC1C,OAAO,CAAC,OAAO,CA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AAI,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;QACjC,MAAM,GAAG,KAAK,CAAC;IACjB,CAAC;IAED,OAAO;QACL,MAAM,CAAC,KAAK;YACV,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;gBAC9B,+DAA+D;gBAC/D,8DAA8D;gBAC9D,4DAA4D;gBAC5D,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;gBACpC,MAAM,CAAC,UAAU,CAAC,CAAC;gBACnB,MAAM,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;gBAC9C,OAAO;YACT,CAAC;YAED,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YACrB,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YAC3B,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC;QACzB,CAAC;QACD,QAAQ;YACN,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;QACpC,CAAC;QACD,QAAQ;YACN,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;QAC5C,CAAC;QACD,IAAI;YACF,OAAO,MAAM,CAAC;QAChB,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,173 @@
1
+ export declare const CLIENT_REFERENCE_TYPE: unique symbol;
2
+ export declare const SERVER_REFERENCE_TYPE: unique symbol;
3
+ export interface FlightClientReference {
4
+ id: number;
5
+ moduleId: string;
6
+ exportName: string;
7
+ chunks?: string[];
8
+ }
9
+ export interface FlightClientReferenceInput {
10
+ name: string;
11
+ moduleId: string;
12
+ exportName: string;
13
+ }
14
+ export interface FlightClientManifestEntry extends FlightClientReferenceInput {
15
+ chunks: string[];
16
+ }
17
+ export type ServerAction = (...args: unknown[]) => unknown | Promise<unknown>;
18
+ export type ServerActionValidationResult = boolean | string;
19
+ export interface ServerActionDescriptor {
20
+ action: ServerAction;
21
+ validateArgs?: (args: unknown[]) => ServerActionValidationResult;
22
+ }
23
+ export type ServerActionRegistry = Record<string, ServerAction | ServerActionDescriptor>;
24
+ export interface ServerActionReplayStore {
25
+ has(value: string): boolean;
26
+ add(value: string): void;
27
+ }
28
+ export interface ServerActionRequestReference {
29
+ moduleId: string;
30
+ exportName: string;
31
+ }
32
+ export interface ServerActionHandlerOptions {
33
+ allowedOrigins?: readonly string[] | "any";
34
+ authorize?: (request: Request, reference: ServerActionRequestReference, args: unknown[]) => ServerActionValidationResult | Promise<ServerActionValidationResult>;
35
+ csrf?: boolean | {
36
+ cookieName?: string;
37
+ headerName?: string;
38
+ };
39
+ replayProtection?: {
40
+ headerName?: string;
41
+ seen: ServerActionReplayStore;
42
+ };
43
+ maxBodyBytes?: number;
44
+ }
45
+ export interface FlightScriptOptions {
46
+ id?: string;
47
+ nonce?: string;
48
+ }
49
+ export interface FlightServerReference {
50
+ id: number;
51
+ moduleId: string;
52
+ exportName: string;
53
+ bound?: FlightModel[];
54
+ }
55
+ export interface ClientReference {
56
+ $$typeof: typeof CLIENT_REFERENCE_TYPE;
57
+ moduleId: string;
58
+ exportName: string;
59
+ chunks?: string[];
60
+ }
61
+ export interface ServerReference {
62
+ $$typeof: typeof SERVER_REFERENCE_TYPE;
63
+ moduleId: string;
64
+ exportName: string;
65
+ bound?: unknown[];
66
+ }
67
+ export interface FlightResponse {
68
+ version: 1;
69
+ root: FlightModel;
70
+ clientReferences: FlightClientReference[];
71
+ serverReferences: FlightServerReference[];
72
+ }
73
+ export type FlightModel = null | string | number | boolean | FlightModel[] | FlightObjectModel | FlightElementModel | FlightClientReferenceModel | FlightServerReferenceModel | FlightDateModel | FlightBigIntModel | FlightNumberModel | FlightSymbolModel | FlightMapModel | FlightSetModel | FlightFormDataModel | FlightIterableModel | FlightErrorModel | FlightPromiseModel | FlightArrayBufferModel | FlightTypedArrayModel | FlightDataViewModel | {
74
+ kind: "undefined";
75
+ };
76
+ export interface FlightObjectModel {
77
+ kind?: never;
78
+ [key: string]: FlightModel | undefined;
79
+ }
80
+ export interface FlightElementModel {
81
+ kind: "element";
82
+ type: string | FlightClientReferenceModel | {
83
+ kind: "fragment";
84
+ };
85
+ key: string | null;
86
+ props: Record<string, FlightModel>;
87
+ }
88
+ export interface FlightClientReferenceModel {
89
+ kind: "client-reference";
90
+ id: number;
91
+ }
92
+ export interface FlightServerReferenceModel {
93
+ kind: "server-reference";
94
+ id: number;
95
+ }
96
+ export interface FlightDateModel {
97
+ kind: "date";
98
+ value: string;
99
+ }
100
+ export interface FlightBigIntModel {
101
+ kind: "bigint";
102
+ value: string;
103
+ }
104
+ export interface FlightNumberModel {
105
+ kind: "number";
106
+ value: "Infinity" | "-Infinity" | "NaN" | "-0";
107
+ }
108
+ export interface FlightSymbolModel {
109
+ kind: "symbol";
110
+ name: string;
111
+ }
112
+ export interface FlightMapModel {
113
+ kind: "map";
114
+ entries: [FlightModel, FlightModel][];
115
+ }
116
+ export interface FlightSetModel {
117
+ kind: "set";
118
+ values: FlightModel[];
119
+ }
120
+ export interface FlightFormDataModel {
121
+ kind: "form-data";
122
+ entries: [string, FlightModel][];
123
+ }
124
+ export interface FlightIterableModel {
125
+ kind: "iterable";
126
+ values: FlightModel[];
127
+ }
128
+ export interface FlightErrorModel {
129
+ kind: "error";
130
+ name: string;
131
+ message: string;
132
+ digest?: string;
133
+ }
134
+ export interface FlightPromiseModel {
135
+ kind: "promise";
136
+ id: number;
137
+ }
138
+ export interface FlightArrayBufferModel {
139
+ kind: "array-buffer";
140
+ bytes: number[];
141
+ }
142
+ export interface FlightTypedArrayModel {
143
+ kind: "typed-array";
144
+ arrayType: FlightTypedArrayName;
145
+ bytes: number[];
146
+ }
147
+ export interface FlightDataViewModel {
148
+ kind: "data-view";
149
+ bytes: number[];
150
+ }
151
+ export type FlightTypedArrayName = "Int8Array" | "Uint8Array" | "Uint8ClampedArray" | "Int16Array" | "Uint16Array" | "Int32Array" | "Uint32Array" | "Float32Array" | "Float64Array" | "BigInt64Array" | "BigUint64Array";
152
+ export interface ReactFlightProtocolCoverage {
153
+ binaryRowTags: string[];
154
+ modelTokens: string[];
155
+ rowTags: string[];
156
+ }
157
+ export declare function getReactFlightProtocolCoverage(): ReactFlightProtocolCoverage;
158
+ export declare function createClientReference(moduleId: string, exportName?: string, chunks?: string[]): ClientReference;
159
+ export declare function createServerReference(moduleId: string, exportName?: string, bound?: unknown[]): ServerReference;
160
+ export declare function isClientReference(value: unknown): value is ClientReference;
161
+ export declare function isServerReference(value: unknown): value is ServerReference;
162
+ export declare function renderToFlightResponse<P extends Record<string, unknown>>(renderable: ((props: P) => unknown) | unknown, props?: P): Promise<FlightResponse>;
163
+ export declare function stringifyFlightResponse(response: FlightResponse): string;
164
+ export declare function renderFlightResponseScript(response: FlightResponse, options?: FlightScriptOptions): string;
165
+ export declare function createServerActionHandler(actions: ServerActionRegistry, options?: ServerActionHandlerOptions): (request: Request) => Promise<Response>;
166
+ export declare function toReactFlightRows(response: FlightResponse): string;
167
+ export declare function fromReactFlightRows(rows: string): FlightResponse;
168
+ export declare function mergeReactFlightRows(response: FlightResponse, rows: string): FlightResponse;
169
+ export declare function createFlightClientManifest(references: readonly FlightClientReferenceInput[], resolveChunks: (reference: FlightClientReferenceInput) => string[]): FlightClientManifestEntry[];
170
+ export declare function renderFlightPreloadLinks(response: FlightResponse, options?: {
171
+ nonce?: string;
172
+ }): string;
173
+ //# sourceMappingURL=flight.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flight.d.ts","sourceRoot":"","sources":["../src/flight.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,qBAAqB,eAA+C,CAAC;AAClF,eAAO,MAAM,qBAAqB,eAA+C,CAAC;AAMlF,MAAM,WAAW,qBAAqB;IACpC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,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