@reckona/mreact-dom 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 +21 -0
- package/README.md +33 -0
- package/dist/client.d.ts +4 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +3 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +64 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +125 -0
- package/dist/index.js.map +1 -0
- package/dist/server.d.ts +79 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +139 -0
- package/dist/server.js.map +1 -0
- package/package.json +52 -0
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,33 @@
|
|
|
1
|
+
# @reckona/mreact-dom
|
|
2
|
+
|
|
3
|
+
`@reckona/mreact-dom` is the React DOM-compatible entrypoint for mreact. It
|
|
4
|
+
exports client roots, server rendering helpers, and resource hint APIs under a
|
|
5
|
+
React DOM-like package surface.
|
|
6
|
+
|
|
7
|
+
## Basic Usage
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { createRoot } from "@reckona/mreact-dom/client";
|
|
11
|
+
|
|
12
|
+
createRoot(document.getElementById("root")!).render(<App />);
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Server rendering helpers are available from `@reckona/mreact-dom/server`:
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { renderToString } from "@reckona/mreact-dom/server";
|
|
19
|
+
|
|
20
|
+
const html = renderToString(<App />);
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Exports
|
|
24
|
+
|
|
25
|
+
- `@reckona/mreact-dom` exports resource hint helpers and shared DOM APIs.
|
|
26
|
+
- `@reckona/mreact-dom/client` exports `createRoot()` and `hydrateRoot()`.
|
|
27
|
+
- `@reckona/mreact-dom/server` exports string, readable stream, and pipeable
|
|
28
|
+
stream rendering helpers.
|
|
29
|
+
|
|
30
|
+
## Notes
|
|
31
|
+
|
|
32
|
+
This package targets React DOM compatibility. App-router SSR and deployment
|
|
33
|
+
adapters live in `@reckona/mreact-router`.
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACjE,YAAY,EAAE,kBAAkB,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAEpF,eAAO,MAAM,OAAO,WAAW,CAAC"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAGjE,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export { createPortal, flushSync, render, unmountComponentAtNode, useActionState as useFormState, } from "@reckona/mreact-compat";
|
|
2
|
+
export { createRoot, hydrateRoot } from "./client.js";
|
|
3
|
+
export type { HydrateRootOptions, Root, RootOptions } from "./client.js";
|
|
4
|
+
export declare const version = "19.2.6";
|
|
5
|
+
export interface FormStatusNotPending {
|
|
6
|
+
pending: false;
|
|
7
|
+
data: null;
|
|
8
|
+
method: null;
|
|
9
|
+
action: null;
|
|
10
|
+
}
|
|
11
|
+
export interface FormStatusPending {
|
|
12
|
+
pending: true;
|
|
13
|
+
data: FormData;
|
|
14
|
+
method: string;
|
|
15
|
+
action: string | ((formData: FormData) => void | Promise<void>);
|
|
16
|
+
}
|
|
17
|
+
export type FormStatus = FormStatusPending | FormStatusNotPending;
|
|
18
|
+
export interface PreconnectOptions {
|
|
19
|
+
crossOrigin?: "anonymous" | "use-credentials" | "";
|
|
20
|
+
}
|
|
21
|
+
export type PreloadAs = "audio" | "document" | "embed" | "fetch" | "font" | "image" | "object" | "track" | "script" | "style" | "video" | "worker";
|
|
22
|
+
export interface PreloadOptions {
|
|
23
|
+
as: PreloadAs;
|
|
24
|
+
crossOrigin?: "anonymous" | "use-credentials" | "";
|
|
25
|
+
fetchPriority?: "high" | "low" | "auto";
|
|
26
|
+
imageSizes?: string;
|
|
27
|
+
imageSrcSet?: string;
|
|
28
|
+
integrity?: string;
|
|
29
|
+
type?: string;
|
|
30
|
+
nonce?: string;
|
|
31
|
+
referrerPolicy?: ReferrerPolicy;
|
|
32
|
+
media?: string;
|
|
33
|
+
}
|
|
34
|
+
export interface PreloadModuleOptions {
|
|
35
|
+
as?: RequestDestination;
|
|
36
|
+
crossOrigin?: "anonymous" | "use-credentials" | "";
|
|
37
|
+
integrity?: string;
|
|
38
|
+
nonce?: string;
|
|
39
|
+
}
|
|
40
|
+
export interface PreinitOptions {
|
|
41
|
+
as: "script" | "style";
|
|
42
|
+
crossOrigin?: "anonymous" | "use-credentials" | "";
|
|
43
|
+
fetchPriority?: "high" | "low" | "auto";
|
|
44
|
+
precedence?: string;
|
|
45
|
+
integrity?: string;
|
|
46
|
+
nonce?: string;
|
|
47
|
+
}
|
|
48
|
+
export interface PreinitModuleOptions {
|
|
49
|
+
as?: "script";
|
|
50
|
+
crossOrigin?: "anonymous" | "use-credentials" | "";
|
|
51
|
+
integrity?: string;
|
|
52
|
+
nonce?: string;
|
|
53
|
+
}
|
|
54
|
+
export declare function useFormStatus(): FormStatus;
|
|
55
|
+
export declare function requestFormReset(form: HTMLFormElement): void;
|
|
56
|
+
export declare function unstable_batchedUpdates<T>(callback: () => T): T;
|
|
57
|
+
export declare function unstable_batchedUpdates<TArgument, TResult>(callback: (argument: TArgument) => TResult, argument: TArgument): TResult;
|
|
58
|
+
export declare function prefetchDNS(href: string): void;
|
|
59
|
+
export declare function preconnect(href: string, options?: PreconnectOptions): void;
|
|
60
|
+
export declare function preload(href: string, options: PreloadOptions): void;
|
|
61
|
+
export declare function preloadModule(href: string, options?: PreloadModuleOptions): void;
|
|
62
|
+
export declare function preinit(href: string, options: PreinitOptions): void;
|
|
63
|
+
export declare function preinitModule(href: string, options?: PreinitModuleOptions): void;
|
|
64
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,SAAS,EACT,MAAM,EACN,sBAAsB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CAE9C;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,iBAAsB,GAAG,IAAI,CAI9E;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,IAAI,CAanE;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,oBAAyB,GAAG,IAAI,CAOpF;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,IAAI,CAmBnE;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,oBAAyB,GAAG,IAAI,CAQpF"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
export { createPortal, flushSync, render, unmountComponentAtNode, useActionState as useFormState, } from "@reckona/mreact-compat";
|
|
2
|
+
import { runWithEventPriority } from "@reckona/mreact-compat/internal";
|
|
3
|
+
export { createRoot, hydrateRoot } from "./client.js";
|
|
4
|
+
export const version = "19.2.6";
|
|
5
|
+
const notPendingFormStatus = {
|
|
6
|
+
pending: false,
|
|
7
|
+
data: null,
|
|
8
|
+
method: null,
|
|
9
|
+
action: null,
|
|
10
|
+
};
|
|
11
|
+
export function useFormStatus() {
|
|
12
|
+
return notPendingFormStatus;
|
|
13
|
+
}
|
|
14
|
+
export function requestFormReset(form) {
|
|
15
|
+
form.reset();
|
|
16
|
+
}
|
|
17
|
+
export function unstable_batchedUpdates(callback, argument) {
|
|
18
|
+
return runWithEventPriority("discrete", () => argument === undefined
|
|
19
|
+
? callback()
|
|
20
|
+
: callback(argument));
|
|
21
|
+
}
|
|
22
|
+
export function prefetchDNS(href) {
|
|
23
|
+
upsertHeadLink("dns-prefetch", href, {});
|
|
24
|
+
}
|
|
25
|
+
export function preconnect(href, options = {}) {
|
|
26
|
+
upsertHeadLink("preconnect", href, {
|
|
27
|
+
crossorigin: options.crossOrigin,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
export function preload(href, options) {
|
|
31
|
+
upsertHeadLink("preload", href, {
|
|
32
|
+
as: options.as,
|
|
33
|
+
crossorigin: options.crossOrigin,
|
|
34
|
+
fetchpriority: options.fetchPriority,
|
|
35
|
+
imagesrcset: options.imageSrcSet,
|
|
36
|
+
imagesizes: options.imageSizes,
|
|
37
|
+
integrity: options.integrity,
|
|
38
|
+
media: options.media,
|
|
39
|
+
nonce: options.nonce,
|
|
40
|
+
referrerpolicy: options.referrerPolicy,
|
|
41
|
+
type: options.type,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
export function preloadModule(href, options = {}) {
|
|
45
|
+
upsertHeadLink("modulepreload", href, {
|
|
46
|
+
as: options.as,
|
|
47
|
+
crossorigin: options.crossOrigin,
|
|
48
|
+
integrity: options.integrity,
|
|
49
|
+
nonce: options.nonce,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
export function preinit(href, options) {
|
|
53
|
+
if (options.as === "style") {
|
|
54
|
+
upsertHeadLink("stylesheet", href, {
|
|
55
|
+
"data-precedence": options.precedence,
|
|
56
|
+
crossorigin: options.crossOrigin,
|
|
57
|
+
fetchpriority: options.fetchPriority,
|
|
58
|
+
integrity: options.integrity,
|
|
59
|
+
nonce: options.nonce,
|
|
60
|
+
});
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
upsertHeadScript(href, {
|
|
64
|
+
async: "",
|
|
65
|
+
crossorigin: options.crossOrigin,
|
|
66
|
+
fetchpriority: options.fetchPriority,
|
|
67
|
+
integrity: options.integrity,
|
|
68
|
+
nonce: options.nonce,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
export function preinitModule(href, options = {}) {
|
|
72
|
+
upsertHeadScript(href, {
|
|
73
|
+
type: "module",
|
|
74
|
+
async: "",
|
|
75
|
+
crossorigin: options.crossOrigin,
|
|
76
|
+
integrity: options.integrity,
|
|
77
|
+
nonce: options.nonce,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
function upsertHeadLink(rel, href, attributes) {
|
|
81
|
+
if (typeof document === "undefined") {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const selector = `link[rel="${escapeSelectorValue(rel)}"][href="${escapeSelectorValue(href)}"]`;
|
|
85
|
+
if (document.head.querySelector(selector) !== null) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
const link = document.createElement("link");
|
|
89
|
+
link.setAttribute("rel", rel);
|
|
90
|
+
link.setAttribute("href", href);
|
|
91
|
+
applyAttributes(link, attributes);
|
|
92
|
+
document.head.append(link);
|
|
93
|
+
}
|
|
94
|
+
function upsertHeadScript(src, attributes) {
|
|
95
|
+
if (typeof document === "undefined") {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const selector = `script[src="${escapeSelectorValue(src)}"]`;
|
|
99
|
+
if (document.head.querySelector(selector) !== null) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
const script = document.createElement("script");
|
|
103
|
+
if (attributes.type === "module") {
|
|
104
|
+
script.setAttribute("type", "module");
|
|
105
|
+
script.setAttribute("src", src);
|
|
106
|
+
applyAttributes(script, { ...attributes, type: undefined });
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
script.setAttribute("src", src);
|
|
110
|
+
applyAttributes(script, attributes);
|
|
111
|
+
}
|
|
112
|
+
document.head.append(script);
|
|
113
|
+
}
|
|
114
|
+
function applyAttributes(element, attributes) {
|
|
115
|
+
for (const [name, value] of Object.entries(attributes)) {
|
|
116
|
+
if (value === undefined) {
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
element.setAttribute(name, value);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
function escapeSelectorValue(value) {
|
|
123
|
+
return value.replaceAll("\\", "\\\\").replaceAll('"', '\\"');
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @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;IACT,CAAC;IAED,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IAChD,IAAI,UAAU,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QACjC,MAAM,CAAC,YAAY,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QACtC,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAChC,eAAe,CAAC,MAAM,EAAE,EAAE,GAAG,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;IAC9D,CAAC;SAAM,CAAC;QACN,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAChC,eAAe,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACtC,CAAC;IAED,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAC/B,CAAC;AAED,SAAS,eAAe,CAAC,OAAgB,EAAE,UAA0B;IACnE,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;QACvD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,SAAS;QACX,CAAC;QACD,OAAO,CAAC,YAAY,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACpC,CAAC;AACH,CAAC;AAED,SAAS,mBAAmB,CAAC,KAAa;IACxC,OAAO,KAAK,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;AAC/D,CAAC"}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { type ReactCompatNode } from "@reckona/mreact-compat";
|
|
2
|
+
export declare const version = "19.2.6";
|
|
3
|
+
export interface PipeableStreamDestination {
|
|
4
|
+
write(chunk: string | Uint8Array): unknown;
|
|
5
|
+
end?(): unknown;
|
|
6
|
+
destroy?(error?: unknown): unknown;
|
|
7
|
+
}
|
|
8
|
+
export interface PipeableStream {
|
|
9
|
+
pipe<TDestination extends PipeableStreamDestination>(destination: TDestination): TDestination;
|
|
10
|
+
abort(reason?: unknown): void;
|
|
11
|
+
}
|
|
12
|
+
export interface BootstrapScriptDescriptor {
|
|
13
|
+
src: string;
|
|
14
|
+
integrity?: string;
|
|
15
|
+
crossOrigin?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface ReactImportMap {
|
|
18
|
+
imports?: Record<string, string>;
|
|
19
|
+
integrity?: Record<string, string>;
|
|
20
|
+
scopes?: Record<string, Record<string, string>>;
|
|
21
|
+
}
|
|
22
|
+
export interface RenderBootstrapOptions {
|
|
23
|
+
nonce?: string;
|
|
24
|
+
importMap?: ReactImportMap;
|
|
25
|
+
bootstrapScriptContent?: string;
|
|
26
|
+
bootstrapScripts?: Array<string | BootstrapScriptDescriptor>;
|
|
27
|
+
bootstrapModules?: Array<string | BootstrapScriptDescriptor>;
|
|
28
|
+
}
|
|
29
|
+
export interface ServerOptions {
|
|
30
|
+
identifierPrefix?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface RenderToPipeableStreamOptions {
|
|
33
|
+
identifierPrefix?: string;
|
|
34
|
+
namespaceURI?: string;
|
|
35
|
+
nonce?: string;
|
|
36
|
+
importMap?: ReactImportMap;
|
|
37
|
+
bootstrapScriptContent?: string;
|
|
38
|
+
bootstrapScripts?: Array<string | BootstrapScriptDescriptor>;
|
|
39
|
+
bootstrapModules?: Array<string | BootstrapScriptDescriptor>;
|
|
40
|
+
headersLengthHint?: number;
|
|
41
|
+
progressiveChunkSize?: number;
|
|
42
|
+
onHeaders?(headers: Headers): void;
|
|
43
|
+
onShellReady?(): void;
|
|
44
|
+
onAllReady?(): void;
|
|
45
|
+
onShellError?(error: unknown): void;
|
|
46
|
+
onError?(error: unknown, errorInfo?: {
|
|
47
|
+
componentStack: string;
|
|
48
|
+
}): string | void;
|
|
49
|
+
formState?: unknown;
|
|
50
|
+
}
|
|
51
|
+
export interface RenderToReadableStreamOptions {
|
|
52
|
+
identifierPrefix?: string;
|
|
53
|
+
namespaceURI?: string;
|
|
54
|
+
nonce?: string;
|
|
55
|
+
importMap?: ReactImportMap;
|
|
56
|
+
bootstrapScriptContent?: string;
|
|
57
|
+
bootstrapScripts?: Array<string | BootstrapScriptDescriptor>;
|
|
58
|
+
bootstrapModules?: Array<string | BootstrapScriptDescriptor>;
|
|
59
|
+
headersLengthHint?: number;
|
|
60
|
+
progressiveChunkSize?: number;
|
|
61
|
+
signal?: AbortSignal;
|
|
62
|
+
onHeaders?(headers: Headers): void;
|
|
63
|
+
onError?(error: unknown, errorInfo?: {
|
|
64
|
+
componentStack: string;
|
|
65
|
+
}): string | void;
|
|
66
|
+
formState?: unknown;
|
|
67
|
+
}
|
|
68
|
+
export interface ReactDOMServerReadableStream extends ReadableStream<Uint8Array> {
|
|
69
|
+
allReady: Promise<void>;
|
|
70
|
+
}
|
|
71
|
+
export type ResumeOptions = RenderToReadableStreamOptions & RenderToPipeableStreamOptions;
|
|
72
|
+
export type PostponedState = unknown;
|
|
73
|
+
export declare function renderToString(element: ReactCompatNode, _options?: ServerOptions): string;
|
|
74
|
+
export declare function renderToStaticMarkup(element: ReactCompatNode, options?: ServerOptions): string;
|
|
75
|
+
export declare function renderToReadableStream(element: ReactCompatNode, options?: RenderToReadableStreamOptions): Promise<ReactDOMServerReadableStream>;
|
|
76
|
+
export declare function renderToPipeableStream(element: ReactCompatNode, options?: RenderToPipeableStreamOptions): PipeableStream;
|
|
77
|
+
export declare function resume(element: ReactCompatNode, _postponedState: PostponedState, options?: ResumeOptions): Promise<ReactDOMServerReadableStream>;
|
|
78
|
+
export declare function resumeToPipeableStream(element: ReactCompatNode, _postponedState: PostponedState, options?: ResumeOptions): Promise<PipeableStream>;
|
|
79
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","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|
+
import { renderToString as renderCompatToString, } from "@reckona/mreact-compat";
|
|
2
|
+
export const version = "19.2.6";
|
|
3
|
+
export function renderToString(element, _options) {
|
|
4
|
+
return renderCompatToString(() => element);
|
|
5
|
+
}
|
|
6
|
+
export function renderToStaticMarkup(element, options) {
|
|
7
|
+
void options;
|
|
8
|
+
return renderToString(element);
|
|
9
|
+
}
|
|
10
|
+
export async function renderToReadableStream(element, options = {}) {
|
|
11
|
+
const encoder = new TextEncoder();
|
|
12
|
+
const html = renderServerHtml(element, options);
|
|
13
|
+
notifyHeaders(options);
|
|
14
|
+
let resolveAllReady;
|
|
15
|
+
let rejectAllReady;
|
|
16
|
+
const allReady = new Promise((resolve, reject) => {
|
|
17
|
+
resolveAllReady = resolve;
|
|
18
|
+
rejectAllReady = reject;
|
|
19
|
+
});
|
|
20
|
+
const stream = new ReadableStream({
|
|
21
|
+
start(controller) {
|
|
22
|
+
if (options.signal?.aborted === true) {
|
|
23
|
+
const reason = options.signal.reason;
|
|
24
|
+
rejectAllReady(reason);
|
|
25
|
+
controller.error(reason);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const abort = () => {
|
|
29
|
+
const reason = options.signal?.reason;
|
|
30
|
+
rejectAllReady(reason);
|
|
31
|
+
controller.error(reason);
|
|
32
|
+
};
|
|
33
|
+
options.signal?.addEventListener("abort", abort, { once: true });
|
|
34
|
+
try {
|
|
35
|
+
controller.enqueue(encoder.encode(html));
|
|
36
|
+
controller.close();
|
|
37
|
+
resolveAllReady();
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
options.onError?.(error, { componentStack: "" });
|
|
41
|
+
rejectAllReady(error);
|
|
42
|
+
controller.error(error);
|
|
43
|
+
}
|
|
44
|
+
finally {
|
|
45
|
+
options.signal?.removeEventListener("abort", abort);
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
return Object.assign(stream, { allReady });
|
|
50
|
+
}
|
|
51
|
+
export function renderToPipeableStream(element, options = {}) {
|
|
52
|
+
let aborted = false;
|
|
53
|
+
return {
|
|
54
|
+
pipe(destination) {
|
|
55
|
+
queueMicrotask(() => {
|
|
56
|
+
if (aborted) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
try {
|
|
60
|
+
notifyHeaders(options);
|
|
61
|
+
options.onShellReady?.();
|
|
62
|
+
const html = renderServerHtml(element, options);
|
|
63
|
+
options.onAllReady?.();
|
|
64
|
+
destination.write(html);
|
|
65
|
+
destination.end?.();
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
options.onError?.(error, { componentStack: "" });
|
|
69
|
+
options.onShellError?.(error);
|
|
70
|
+
destination.destroy?.(error);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
return destination;
|
|
74
|
+
},
|
|
75
|
+
abort(reason) {
|
|
76
|
+
aborted = true;
|
|
77
|
+
options.onError?.(reason ?? new Error("renderToPipeableStream was aborted."), {
|
|
78
|
+
componentStack: "",
|
|
79
|
+
});
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
export async function resume(element, _postponedState, options = {}) {
|
|
84
|
+
return renderToReadableStream(element, options);
|
|
85
|
+
}
|
|
86
|
+
export async function resumeToPipeableStream(element, _postponedState, options = {}) {
|
|
87
|
+
return renderToPipeableStream(element, options);
|
|
88
|
+
}
|
|
89
|
+
function renderServerHtml(element, options) {
|
|
90
|
+
return `${renderToString(element)}${renderBootstrapResources(options)}`;
|
|
91
|
+
}
|
|
92
|
+
function renderBootstrapResources(options) {
|
|
93
|
+
const nonce = options.nonce === undefined ? "" : ` nonce="${escapeAttribute(options.nonce)}"`;
|
|
94
|
+
const importMap = options.importMap === undefined
|
|
95
|
+
? ""
|
|
96
|
+
: `<script type="importmap"${nonce}>${escapeScriptContent(JSON.stringify(options.importMap))}</script>`;
|
|
97
|
+
const inlineScript = options.bootstrapScriptContent === undefined
|
|
98
|
+
? ""
|
|
99
|
+
: `<script${nonce}>${escapeScriptContent(options.bootstrapScriptContent)}</script>`;
|
|
100
|
+
const scripts = (options.bootstrapScripts ?? [])
|
|
101
|
+
.map((script) => renderExternalScript(script, nonce, undefined))
|
|
102
|
+
.join("");
|
|
103
|
+
const modules = (options.bootstrapModules ?? [])
|
|
104
|
+
.map((script) => renderExternalScript(script, nonce, "module"))
|
|
105
|
+
.join("");
|
|
106
|
+
return `${importMap}${inlineScript}${scripts}${modules}`;
|
|
107
|
+
}
|
|
108
|
+
function renderExternalScript(script, nonce, type) {
|
|
109
|
+
const descriptor = typeof script === "string" ? { src: script } : script;
|
|
110
|
+
const typeAttribute = type === undefined ? "" : ` type="${type}"`;
|
|
111
|
+
const src = ` src="${escapeAttribute(descriptor.src)}"`;
|
|
112
|
+
const integrity = descriptor.integrity === undefined ? "" : ` integrity="${escapeAttribute(descriptor.integrity)}"`;
|
|
113
|
+
const crossOrigin = descriptor.crossOrigin === undefined
|
|
114
|
+
? ""
|
|
115
|
+
: ` crossorigin="${escapeAttribute(descriptor.crossOrigin)}"`;
|
|
116
|
+
return `<script${typeAttribute}${src}${nonce}${integrity}${crossOrigin}></script>`;
|
|
117
|
+
}
|
|
118
|
+
function escapeAttribute(value) {
|
|
119
|
+
return value
|
|
120
|
+
.replaceAll("&", "&")
|
|
121
|
+
.replaceAll('"', """)
|
|
122
|
+
.replaceAll("<", "<")
|
|
123
|
+
.replaceAll(">", ">");
|
|
124
|
+
}
|
|
125
|
+
function escapeScriptContent(value) {
|
|
126
|
+
return value
|
|
127
|
+
.replaceAll("<", "\\u003c")
|
|
128
|
+
.replaceAll("\u2028", "\\u2028")
|
|
129
|
+
.replaceAll("\u2029", "\\u2029");
|
|
130
|
+
}
|
|
131
|
+
function notifyHeaders(options) {
|
|
132
|
+
if (options.onHeaders === undefined) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
const headers = new Headers();
|
|
136
|
+
headers.set("content-type", "text/html; charset=utf-8");
|
|
137
|
+
options.onHeaders(headers);
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0BAA0B,CAAC,CAAC;IACxD,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;AAC7B,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@reckona/mreact-dom",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "React DOM-compatible entrypoints for mreact.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"dom",
|
|
7
|
+
"jsx",
|
|
8
|
+
"mreact",
|
|
9
|
+
"react-dom",
|
|
10
|
+
"ssr",
|
|
11
|
+
"typescript"
|
|
12
|
+
],
|
|
13
|
+
"homepage": "https://github.com/t-k/mreact/tree/main/packages/react-dom#readme",
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/t-k/mreact/issues"
|
|
16
|
+
},
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "https://github.com/t-k/mreact.git",
|
|
21
|
+
"directory": "packages/react-dom"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist/**/*.js",
|
|
25
|
+
"dist/**/*.js.map",
|
|
26
|
+
"dist/**/*.d.ts",
|
|
27
|
+
"dist/**/*.d.ts.map"
|
|
28
|
+
],
|
|
29
|
+
"type": "module",
|
|
30
|
+
"sideEffects": false,
|
|
31
|
+
"types": "./dist/index.d.ts",
|
|
32
|
+
"exports": {
|
|
33
|
+
".": {
|
|
34
|
+
"types": "./dist/index.d.ts",
|
|
35
|
+
"default": "./dist/index.js"
|
|
36
|
+
},
|
|
37
|
+
"./client": {
|
|
38
|
+
"types": "./dist/client.d.ts",
|
|
39
|
+
"default": "./dist/client.js"
|
|
40
|
+
},
|
|
41
|
+
"./server": {
|
|
42
|
+
"types": "./dist/server.d.ts",
|
|
43
|
+
"default": "./dist/server.js"
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"publishConfig": {
|
|
47
|
+
"access": "public"
|
|
48
|
+
},
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"@reckona/mreact-compat": "0.0.1"
|
|
51
|
+
}
|
|
52
|
+
}
|