@reckona/mreact-dom 0.0.159 → 0.0.161
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/dist/client.d.ts +3 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +2 -0
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -1
- package/dist/server.d.ts +18 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +7 -0
- package/dist/server.js.map +1 -1
- package/dist/test-utils.d.ts +1 -0
- package/dist/test-utils.d.ts.map +1 -1
- package/dist/test-utils.js +1 -0
- package/dist/test-utils.js.map +1 -1
- package/package.json +2 -2
- package/src/client.ts +3 -0
- package/src/index.ts +22 -0
- package/src/server.ts +18 -0
- package/src/test-utils.ts +1 -0
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
/** Re-exports DOM root creation and hydration helpers. */
|
|
1
2
|
export { createRoot, hydrateRoot } from "@reckona/mreact-compat";
|
|
3
|
+
/** Re-exports DOM root option and handle types. */
|
|
2
4
|
export type { HydrateRootOptions, Root, RootOptions } from "@reckona/mreact-compat";
|
|
5
|
+
/** React DOM client package version. */
|
|
3
6
|
export declare const version = "19.2.6";
|
|
4
7
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +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"}
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAC1D,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACjE,mDAAmD;AACnD,YAAY,EAAE,kBAAkB,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAEpF,wCAAwC;AACxC,eAAO,MAAM,OAAO,WAAW,CAAC"}
|
package/dist/client.js
CHANGED
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAC1D,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAIjE,wCAAwC;AACxC,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["/** Re-exports DOM root creation and hydration helpers. */\nexport { createRoot, hydrateRoot } from \"@reckona/mreact-compat\";\n/** Re-exports DOM root option and handle types. */\nexport type { HydrateRootOptions, Root, RootOptions } from \"@reckona/mreact-compat\";\n\n/** React DOM client package version. */\nexport const version = \"19.2.6\";\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,25 +1,33 @@
|
|
|
1
1
|
import { createPortal, flushSync, render, unmountComponentAtNode, useActionState as useFormState } from "@reckona/mreact-compat";
|
|
2
2
|
import { createRoot, hydrateRoot } from "./client.js";
|
|
3
|
+
/** Re-exports the React DOM rendering helpers exposed by the root entrypoint. */
|
|
3
4
|
export { createPortal, flushSync, render, unmountComponentAtNode, useFormState, createRoot, hydrateRoot, };
|
|
4
5
|
export type { HydrateRootOptions, Root, RootOptions } from "./client.js";
|
|
6
|
+
/** React DOM-compatible package version. */
|
|
5
7
|
export declare const version = "19.2.6";
|
|
8
|
+
/** Idle form status returned when no form submission is pending. */
|
|
6
9
|
export interface FormStatusNotPending {
|
|
7
10
|
pending: false;
|
|
8
11
|
data: null;
|
|
9
12
|
method: null;
|
|
10
13
|
action: null;
|
|
11
14
|
}
|
|
15
|
+
/** Pending form status returned while a submission is in progress. */
|
|
12
16
|
export interface FormStatusPending {
|
|
13
17
|
pending: true;
|
|
14
18
|
data: FormData;
|
|
15
19
|
method: string;
|
|
16
20
|
action: string | ((formData: FormData) => void | Promise<void>);
|
|
17
21
|
}
|
|
22
|
+
/** Current form submission state returned by useFormStatus. */
|
|
18
23
|
export type FormStatus = FormStatusPending | FormStatusNotPending;
|
|
24
|
+
/** Options applied when inserting a preconnect resource hint. */
|
|
19
25
|
export interface PreconnectOptions {
|
|
20
26
|
crossOrigin?: "anonymous" | "use-credentials" | "";
|
|
21
27
|
}
|
|
28
|
+
/** Allowed destination values for preload resource hints. */
|
|
22
29
|
export type PreloadAs = "audio" | "document" | "embed" | "fetch" | "font" | "image" | "object" | "track" | "script" | "style" | "video" | "worker";
|
|
30
|
+
/** Options applied when inserting a preload resource hint. */
|
|
23
31
|
export interface PreloadOptions {
|
|
24
32
|
as: PreloadAs;
|
|
25
33
|
crossOrigin?: "anonymous" | "use-credentials" | "";
|
|
@@ -32,12 +40,14 @@ export interface PreloadOptions {
|
|
|
32
40
|
referrerPolicy?: ReferrerPolicy;
|
|
33
41
|
media?: string;
|
|
34
42
|
}
|
|
43
|
+
/** Options applied when inserting a modulepreload resource hint. */
|
|
35
44
|
export interface PreloadModuleOptions {
|
|
36
45
|
as?: RequestDestination;
|
|
37
46
|
crossOrigin?: "anonymous" | "use-credentials" | "";
|
|
38
47
|
integrity?: string;
|
|
39
48
|
nonce?: string;
|
|
40
49
|
}
|
|
50
|
+
/** Options applied when preinitializing a script or stylesheet resource. */
|
|
41
51
|
export interface PreinitOptions {
|
|
42
52
|
as: "script" | "style";
|
|
43
53
|
crossOrigin?: "anonymous" | "use-credentials" | "";
|
|
@@ -46,22 +56,33 @@ export interface PreinitOptions {
|
|
|
46
56
|
integrity?: string;
|
|
47
57
|
nonce?: string;
|
|
48
58
|
}
|
|
59
|
+
/** Options applied when preinitializing a JavaScript module resource. */
|
|
49
60
|
export interface PreinitModuleOptions {
|
|
50
61
|
as?: "script";
|
|
51
62
|
crossOrigin?: "anonymous" | "use-credentials" | "";
|
|
52
63
|
integrity?: string;
|
|
53
64
|
nonce?: string;
|
|
54
65
|
}
|
|
66
|
+
/** Returns the current form submission status for the nearest form action. */
|
|
55
67
|
export declare function useFormStatus(): FormStatus;
|
|
68
|
+
/** Resets a form element after a server action-style submission completes. */
|
|
56
69
|
export declare function requestFormReset(form: HTMLFormElement): void;
|
|
70
|
+
/** Runs a callback at discrete event priority and returns its result. */
|
|
57
71
|
export declare function unstable_batchedUpdates<T>(callback: () => T): T;
|
|
58
72
|
export declare function unstable_batchedUpdates<TArgument, TResult>(callback: (argument: TArgument) => TResult, argument: TArgument): TResult;
|
|
73
|
+
/** Inserts a dns-prefetch link for the provided host if it is not already present. */
|
|
59
74
|
export declare function prefetchDNS(href: string): void;
|
|
75
|
+
/** Inserts a preconnect link for the provided origin if it is not already present. */
|
|
60
76
|
export declare function preconnect(href: string, options?: PreconnectOptions): void;
|
|
77
|
+
/** Inserts a preload link for the provided resource if it is not already present. */
|
|
61
78
|
export declare function preload(href: string, options: PreloadOptions): void;
|
|
79
|
+
/** Inserts a modulepreload link for the provided module if it is not already present. */
|
|
62
80
|
export declare function preloadModule(href: string, options?: PreloadModuleOptions): void;
|
|
81
|
+
/** Preinitializes a script or stylesheet resource in the document head. */
|
|
63
82
|
export declare function preinit(href: string, options: PreinitOptions): void;
|
|
83
|
+
/** Preinitializes a JavaScript module resource in the document head. */
|
|
64
84
|
export declare function preinitModule(href: string, options?: PreinitModuleOptions): void;
|
|
85
|
+
/** React DOM-compatible default export object. */
|
|
65
86
|
declare const ReactDOM: {
|
|
66
87
|
readonly createPortal: typeof createPortal;
|
|
67
88
|
readonly flushSync: typeof flushSync;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +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,EACtB,cAAc,IAAI,YAAY,EAC/B,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,SAAS,EACT,MAAM,EACN,sBAAsB,EACtB,cAAc,IAAI,YAAY,EAC/B,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEtD,iFAAiF;AACjF,OAAO,EACL,YAAY,EACZ,SAAS,EACT,MAAM,EACN,sBAAsB,EACtB,YAAY,EACZ,UAAU,EACV,WAAW,GACZ,CAAC;AACF,YAAY,EAAE,kBAAkB,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEzE,4CAA4C;AAC5C,eAAO,MAAM,OAAO,WAAW,CAAC;AAEhC,oEAAoE;AACpE,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,KAAK,CAAC;IACf,IAAI,EAAE,IAAI,CAAC;IACX,MAAM,EAAE,IAAI,CAAC;IACb,MAAM,EAAE,IAAI,CAAC;CACd;AAED,sEAAsE;AACtE,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,IAAI,CAAC;IACd,IAAI,EAAE,QAAQ,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,GAAG,CAAC,CAAC,QAAQ,EAAE,QAAQ,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;CACjE;AAED,+DAA+D;AAC/D,MAAM,MAAM,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E,OAAO,GAAE,oBAAyB,GAAG,IAAI,CAQpF;AA8DD,kDAAkD;AAClD,QAAA,MAAM,QAAQ;;;;;;;;;;;;;;;;;;CAkBJ,CAAC;AAEX,eAAe,QAAQ,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { createPortal, flushSync, render, unmountComponentAtNode, useActionState as useFormState, } from "@reckona/mreact-compat";
|
|
2
2
|
import { runWithEventPriority } from "@reckona/mreact-compat/event-priority";
|
|
3
3
|
import { createRoot, hydrateRoot } from "./client.js";
|
|
4
|
+
/** Re-exports the React DOM rendering helpers exposed by the root entrypoint. */
|
|
4
5
|
export { createPortal, flushSync, render, unmountComponentAtNode, useFormState, createRoot, hydrateRoot, };
|
|
6
|
+
/** React DOM-compatible package version. */
|
|
5
7
|
export const version = "19.2.6";
|
|
8
|
+
/** Returns the current form submission status for the nearest form action. */
|
|
6
9
|
export function useFormStatus() {
|
|
7
10
|
throw new Error("useFormStatus is not supported by @reckona/mreact-dom yet. Use useFormState/useActionState for local pending state instead.");
|
|
8
11
|
}
|
|
12
|
+
/** Resets a form element after a server action-style submission completes. */
|
|
9
13
|
export function requestFormReset(form) {
|
|
10
14
|
form.reset();
|
|
11
15
|
}
|
|
@@ -14,14 +18,17 @@ export function unstable_batchedUpdates(callback, argument) {
|
|
|
14
18
|
? callback()
|
|
15
19
|
: callback(argument));
|
|
16
20
|
}
|
|
21
|
+
/** Inserts a dns-prefetch link for the provided host if it is not already present. */
|
|
17
22
|
export function prefetchDNS(href) {
|
|
18
23
|
upsertHeadLink("dns-prefetch", href, {});
|
|
19
24
|
}
|
|
25
|
+
/** Inserts a preconnect link for the provided origin if it is not already present. */
|
|
20
26
|
export function preconnect(href, options = {}) {
|
|
21
27
|
upsertHeadLink("preconnect", href, {
|
|
22
28
|
crossorigin: options.crossOrigin,
|
|
23
29
|
});
|
|
24
30
|
}
|
|
31
|
+
/** Inserts a preload link for the provided resource if it is not already present. */
|
|
25
32
|
export function preload(href, options) {
|
|
26
33
|
upsertHeadLink("preload", href, {
|
|
27
34
|
as: options.as,
|
|
@@ -36,6 +43,7 @@ export function preload(href, options) {
|
|
|
36
43
|
type: options.type,
|
|
37
44
|
});
|
|
38
45
|
}
|
|
46
|
+
/** Inserts a modulepreload link for the provided module if it is not already present. */
|
|
39
47
|
export function preloadModule(href, options = {}) {
|
|
40
48
|
upsertHeadLink("modulepreload", href, {
|
|
41
49
|
as: options.as,
|
|
@@ -44,6 +52,7 @@ export function preloadModule(href, options = {}) {
|
|
|
44
52
|
nonce: options.nonce,
|
|
45
53
|
});
|
|
46
54
|
}
|
|
55
|
+
/** Preinitializes a script or stylesheet resource in the document head. */
|
|
47
56
|
export function preinit(href, options) {
|
|
48
57
|
if (options.as === "style") {
|
|
49
58
|
upsertHeadLink("stylesheet", href, {
|
|
@@ -63,6 +72,7 @@ export function preinit(href, options) {
|
|
|
63
72
|
nonce: options.nonce,
|
|
64
73
|
});
|
|
65
74
|
}
|
|
75
|
+
/** Preinitializes a JavaScript module resource in the document head. */
|
|
66
76
|
export function preinitModule(href, options = {}) {
|
|
67
77
|
upsertHeadScript(href, {
|
|
68
78
|
type: "module",
|
|
@@ -117,6 +127,7 @@ function applyAttributes(element, attributes) {
|
|
|
117
127
|
function escapeSelectorValue(value) {
|
|
118
128
|
return value.replaceAll("\\", "\\\\").replaceAll('"', '\\"');
|
|
119
129
|
}
|
|
130
|
+
/** React DOM-compatible default export object. */
|
|
120
131
|
const ReactDOM = {
|
|
121
132
|
createPortal,
|
|
122
133
|
flushSync,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,SAAS,EACT,MAAM,EACN,sBAAsB,EACtB,cAAc,IAAI,YAAY,GAC/B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,oBAAoB,EAAE,MAAM,uC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AK,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;AAED,MAAM,QAAQ,GAAG;IACf,YAAY;IACZ,SAAS;IACT,MAAM;IACN,sBAAsB;IACtB,YAAY;IACZ,UAAU;IACV,WAAW;IACX,OAAO;IACP,aAAa;IACb,gBAAgB;IAChB,uBAAuB;IACvB,WAAW;IACX,UAAU;IACV,OAAO;IACP,aAAa;IACb,OAAO;IACP,aAAa;CACL,CAAC;AAEX,eAAe,QAAQ,CAAC","sourcesContent":["import {\n createPortal,\n flushSync,\n render,\n unmountComponentAtNode,\n useActionState as useFormState,\n} from \"@reckona/mreact-compat\";\nimport { runWithEventPriority } from \"@reckona/mreact-compat/event-priority\";\nimport { createRoot, hydrateRoot } from \"./client.js\";\nexport {\n createPortal,\n flushSync,\n render,\n unmountComponentAtNode,\n useFormState,\n createRoot,\n hydrateRoot,\n};\nexport type { HydrateRootOptions, Root, RootOptions } from \"./client.js\";\n\nexport const version = \"19.2.6\";\n\nexport interface FormStatusNotPending {\n pending: false;\n data: null;\n method: null;\n action: null;\n}\n\nexport interface FormStatusPending {\n pending: true;\n data: FormData;\n method: string;\n action: string | ((formData: FormData) => void | Promise<void>);\n}\n\nexport type FormStatus = FormStatusPending | FormStatusNotPending;\n\nexport interface PreconnectOptions {\n crossOrigin?: \"anonymous\" | \"use-credentials\" | \"\";\n}\n\nexport type PreloadAs =\n | \"audio\"\n | \"document\"\n | \"embed\"\n | \"fetch\"\n | \"font\"\n | \"image\"\n | \"object\"\n | \"track\"\n | \"script\"\n | \"style\"\n | \"video\"\n | \"worker\";\n\nexport interface PreloadOptions {\n as: PreloadAs;\n crossOrigin?: \"anonymous\" | \"use-credentials\" | \"\";\n fetchPriority?: \"high\" | \"low\" | \"auto\";\n imageSizes?: string;\n imageSrcSet?: string;\n integrity?: string;\n type?: string;\n nonce?: string;\n referrerPolicy?: ReferrerPolicy;\n media?: string;\n}\n\nexport interface PreloadModuleOptions {\n as?: RequestDestination;\n crossOrigin?: \"anonymous\" | \"use-credentials\" | \"\";\n integrity?: string;\n nonce?: string;\n}\n\nexport interface PreinitOptions {\n as: \"script\" | \"style\";\n crossOrigin?: \"anonymous\" | \"use-credentials\" | \"\";\n fetchPriority?: \"high\" | \"low\" | \"auto\";\n precedence?: string;\n integrity?: string;\n nonce?: string;\n}\n\nexport interface PreinitModuleOptions {\n as?: \"script\";\n crossOrigin?: \"anonymous\" | \"use-credentials\" | \"\";\n integrity?: string;\n nonce?: string;\n}\n\ntype LinkAttributes = Record<string, string | undefined>;\n\nexport function useFormStatus(): FormStatus {\n throw new Error(\n \"useFormStatus is not supported by @reckona/mreact-dom yet. Use useFormState/useActionState for local pending state instead.\",\n );\n}\n\nexport function requestFormReset(form: HTMLFormElement): void {\n form.reset();\n}\n\nexport function unstable_batchedUpdates<T>(callback: () => T): T;\nexport function unstable_batchedUpdates<TArgument, TResult>(\n callback: (argument: TArgument) => TResult,\n argument: TArgument,\n): TResult;\nexport function unstable_batchedUpdates<TArgument, TResult>(\n callback: ((argument: TArgument) => TResult) | (() => TResult),\n argument?: TArgument,\n): TResult {\n return runWithEventPriority(\"discrete\", () =>\n argument === undefined\n ? (callback as () => TResult)()\n : (callback as (argument: TArgument) => TResult)(argument)\n );\n}\n\nexport function prefetchDNS(href: string): void {\n upsertHeadLink(\"dns-prefetch\", href, {});\n}\n\nexport function preconnect(href: string, options: PreconnectOptions = {}): void {\n upsertHeadLink(\"preconnect\", href, {\n crossorigin: options.crossOrigin,\n });\n}\n\nexport function preload(href: string, options: PreloadOptions): void {\n upsertHeadLink(\"preload\", href, {\n as: options.as,\n crossorigin: options.crossOrigin,\n fetchpriority: options.fetchPriority,\n imagesrcset: options.imageSrcSet,\n imagesizes: options.imageSizes,\n integrity: options.integrity,\n media: options.media,\n nonce: options.nonce,\n referrerpolicy: options.referrerPolicy,\n type: options.type,\n });\n}\n\nexport function preloadModule(href: string, options: PreloadModuleOptions = {}): void {\n upsertHeadLink(\"modulepreload\", href, {\n as: options.as,\n crossorigin: options.crossOrigin,\n integrity: options.integrity,\n nonce: options.nonce,\n });\n}\n\nexport function preinit(href: string, options: PreinitOptions): void {\n if (options.as === \"style\") {\n upsertHeadLink(\"stylesheet\", href, {\n \"data-precedence\": options.precedence,\n crossorigin: options.crossOrigin,\n fetchpriority: options.fetchPriority,\n integrity: options.integrity,\n nonce: options.nonce,\n });\n return;\n }\n\n upsertHeadScript(href, {\n async: \"\",\n crossorigin: options.crossOrigin,\n fetchpriority: options.fetchPriority,\n integrity: options.integrity,\n nonce: options.nonce,\n });\n}\n\nexport function preinitModule(href: string, options: PreinitModuleOptions = {}): void {\n upsertHeadScript(href, {\n type: \"module\",\n async: \"\",\n crossorigin: options.crossOrigin,\n integrity: options.integrity,\n nonce: options.nonce,\n });\n}\n\nfunction upsertHeadLink(\n rel: string,\n href: string,\n attributes: LinkAttributes,\n): void {\n if (typeof document === \"undefined\") {\n return;\n }\n\n const selector = `link[rel=\"${escapeSelectorValue(rel)}\"][href=\"${escapeSelectorValue(href)}\"]`;\n if (document.head.querySelector(selector) !== null) {\n return;\n }\n\n const link = document.createElement(\"link\");\n link.setAttribute(\"rel\", rel);\n link.setAttribute(\"href\", href);\n applyAttributes(link, attributes);\n document.head.append(link);\n}\n\nfunction upsertHeadScript(\n src: string,\n attributes: LinkAttributes,\n): void {\n if (typeof document === \"undefined\") {\n return;\n }\n\n const selector = `script[src=\"${escapeSelectorValue(src)}\"]`;\n if (document.head.querySelector(selector) !== null) {\n return;\n }\n\n const script = document.createElement(\"script\");\n if (attributes.type === \"module\") {\n script.setAttribute(\"type\", \"module\");\n script.setAttribute(\"src\", src);\n applyAttributes(script, { ...attributes, type: undefined });\n } else {\n script.setAttribute(\"src\", src);\n applyAttributes(script, attributes);\n }\n\n document.head.append(script);\n}\n\nfunction applyAttributes(element: Element, attributes: LinkAttributes): void {\n for (const [name, value] of Object.entries(attributes)) {\n if (value === undefined) {\n continue;\n }\n element.setAttribute(name, value);\n }\n}\n\nfunction escapeSelectorValue(value: string): string {\n return value.replaceAll(\"\\\\\", \"\\\\\\\\\").replaceAll('\"', '\\\\\"');\n}\n\nconst ReactDOM = {\n createPortal,\n flushSync,\n render,\n unmountComponentAtNode,\n useFormState,\n createRoot,\n hydrateRoot,\n version,\n useFormStatus,\n requestFormReset,\n unstable_batchedUpdates,\n prefetchDNS,\n preconnect,\n preload,\n preloadModule,\n preinit,\n preinitModule,\n} as const;\n\nexport default ReactDOM;\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,SAAS,EACT,MAAM,EACN,sBAAsB,EACtB,cAAc,IAAI,YAAY,GAC/B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,oBAAoB,EAAE,MAAM,uC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\n render,\n unmountComponentAtNode,\n useActionState as useFormState,\n} from \"@reckona/mreact-compat\";\nimport { runWithEventPriority } from \"@reckona/mreact-compat/event-priority\";\nimport { createRoot, hydrateRoot } from \"./client.js\";\n\n/** Re-exports the React DOM rendering helpers exposed by the root entrypoint. */\nexport {\n createPortal,\n flushSync,\n render,\n unmountComponentAtNode,\n useFormState,\n createRoot,\n hydrateRoot,\n};\nexport type { HydrateRootOptions, Root, RootOptions } from \"./client.js\";\n\n/** React DOM-compatible package version. */\nexport const version = \"19.2.6\";\n\n/** Idle form status returned when no form submission is pending. */\nexport interface FormStatusNotPending {\n pending: false;\n data: null;\n method: null;\n action: null;\n}\n\n/** Pending form status returned while a submission is in progress. */\nexport interface FormStatusPending {\n pending: true;\n data: FormData;\n method: string;\n action: string | ((formData: FormData) => void | Promise<void>);\n}\n\n/** Current form submission state returned by useFormStatus. */\nexport type FormStatus = FormStatusPending | FormStatusNotPending;\n\n/** Options applied when inserting a preconnect resource hint. */\nexport interface PreconnectOptions {\n crossOrigin?: \"anonymous\" | \"use-credentials\" | \"\";\n}\n\n/** Allowed destination values for preload resource hints. */\nexport type PreloadAs =\n | \"audio\"\n | \"document\"\n | \"embed\"\n | \"fetch\"\n | \"font\"\n | \"image\"\n | \"object\"\n | \"track\"\n | \"script\"\n | \"style\"\n | \"video\"\n | \"worker\";\n\n/** Options applied when inserting a preload resource hint. */\nexport interface PreloadOptions {\n as: PreloadAs;\n crossOrigin?: \"anonymous\" | \"use-credentials\" | \"\";\n fetchPriority?: \"high\" | \"low\" | \"auto\";\n imageSizes?: string;\n imageSrcSet?: string;\n integrity?: string;\n type?: string;\n nonce?: string;\n referrerPolicy?: ReferrerPolicy;\n media?: string;\n}\n\n/** Options applied when inserting a modulepreload resource hint. */\nexport interface PreloadModuleOptions {\n as?: RequestDestination;\n crossOrigin?: \"anonymous\" | \"use-credentials\" | \"\";\n integrity?: string;\n nonce?: string;\n}\n\n/** Options applied when preinitializing a script or stylesheet resource. */\nexport interface PreinitOptions {\n as: \"script\" | \"style\";\n crossOrigin?: \"anonymous\" | \"use-credentials\" | \"\";\n fetchPriority?: \"high\" | \"low\" | \"auto\";\n precedence?: string;\n integrity?: string;\n nonce?: string;\n}\n\n/** Options applied when preinitializing a JavaScript module resource. */\nexport interface PreinitModuleOptions {\n as?: \"script\";\n crossOrigin?: \"anonymous\" | \"use-credentials\" | \"\";\n integrity?: string;\n nonce?: string;\n}\n\ntype LinkAttributes = Record<string, string | undefined>;\n\n/** Returns the current form submission status for the nearest form action. */\nexport function useFormStatus(): FormStatus {\n throw new Error(\n \"useFormStatus is not supported by @reckona/mreact-dom yet. Use useFormState/useActionState for local pending state instead.\",\n );\n}\n\n/** Resets a form element after a server action-style submission completes. */\nexport function requestFormReset(form: HTMLFormElement): void {\n form.reset();\n}\n\n/** Runs a callback at discrete event priority and returns its result. */\nexport function unstable_batchedUpdates<T>(callback: () => T): T;\nexport function unstable_batchedUpdates<TArgument, TResult>(\n callback: (argument: TArgument) => TResult,\n argument: TArgument,\n): TResult;\nexport function unstable_batchedUpdates<TArgument, TResult>(\n callback: ((argument: TArgument) => TResult) | (() => TResult),\n argument?: TArgument,\n): TResult {\n return runWithEventPriority(\"discrete\", () =>\n argument === undefined\n ? (callback as () => TResult)()\n : (callback as (argument: TArgument) => TResult)(argument)\n );\n}\n\n/** Inserts a dns-prefetch link for the provided host if it is not already present. */\nexport function prefetchDNS(href: string): void {\n upsertHeadLink(\"dns-prefetch\", href, {});\n}\n\n/** Inserts a preconnect link for the provided origin if it is not already present. */\nexport function preconnect(href: string, options: PreconnectOptions = {}): void {\n upsertHeadLink(\"preconnect\", href, {\n crossorigin: options.crossOrigin,\n });\n}\n\n/** Inserts a preload link for the provided resource if it is not already present. */\nexport function preload(href: string, options: PreloadOptions): void {\n upsertHeadLink(\"preload\", href, {\n as: options.as,\n crossorigin: options.crossOrigin,\n fetchpriority: options.fetchPriority,\n imagesrcset: options.imageSrcSet,\n imagesizes: options.imageSizes,\n integrity: options.integrity,\n media: options.media,\n nonce: options.nonce,\n referrerpolicy: options.referrerPolicy,\n type: options.type,\n });\n}\n\n/** Inserts a modulepreload link for the provided module if it is not already present. */\nexport function preloadModule(href: string, options: PreloadModuleOptions = {}): void {\n upsertHeadLink(\"modulepreload\", href, {\n as: options.as,\n crossorigin: options.crossOrigin,\n integrity: options.integrity,\n nonce: options.nonce,\n });\n}\n\n/** Preinitializes a script or stylesheet resource in the document head. */\nexport function preinit(href: string, options: PreinitOptions): void {\n if (options.as === \"style\") {\n upsertHeadLink(\"stylesheet\", href, {\n \"data-precedence\": options.precedence,\n crossorigin: options.crossOrigin,\n fetchpriority: options.fetchPriority,\n integrity: options.integrity,\n nonce: options.nonce,\n });\n return;\n }\n\n upsertHeadScript(href, {\n async: \"\",\n crossorigin: options.crossOrigin,\n fetchpriority: options.fetchPriority,\n integrity: options.integrity,\n nonce: options.nonce,\n });\n}\n\n/** Preinitializes a JavaScript module resource in the document head. */\nexport function preinitModule(href: string, options: PreinitModuleOptions = {}): void {\n upsertHeadScript(href, {\n type: \"module\",\n async: \"\",\n crossorigin: options.crossOrigin,\n integrity: options.integrity,\n nonce: options.nonce,\n });\n}\n\nfunction upsertHeadLink(\n rel: string,\n href: string,\n attributes: LinkAttributes,\n): void {\n if (typeof document === \"undefined\") {\n return;\n }\n\n const selector = `link[rel=\"${escapeSelectorValue(rel)}\"][href=\"${escapeSelectorValue(href)}\"]`;\n if (document.head.querySelector(selector) !== null) {\n return;\n }\n\n const link = document.createElement(\"link\");\n link.setAttribute(\"rel\", rel);\n link.setAttribute(\"href\", href);\n applyAttributes(link, attributes);\n document.head.append(link);\n}\n\nfunction upsertHeadScript(\n src: string,\n attributes: LinkAttributes,\n): void {\n if (typeof document === \"undefined\") {\n return;\n }\n\n const selector = `script[src=\"${escapeSelectorValue(src)}\"]`;\n if (document.head.querySelector(selector) !== null) {\n return;\n }\n\n const script = document.createElement(\"script\");\n if (attributes.type === \"module\") {\n script.setAttribute(\"type\", \"module\");\n script.setAttribute(\"src\", src);\n applyAttributes(script, { ...attributes, type: undefined });\n } else {\n script.setAttribute(\"src\", src);\n applyAttributes(script, attributes);\n }\n\n document.head.append(script);\n}\n\nfunction applyAttributes(element: Element, attributes: LinkAttributes): void {\n for (const [name, value] of Object.entries(attributes)) {\n if (value === undefined) {\n continue;\n }\n element.setAttribute(name, value);\n }\n}\n\nfunction escapeSelectorValue(value: string): string {\n return value.replaceAll(\"\\\\\", \"\\\\\\\\\").replaceAll('\"', '\\\\\"');\n}\n\n/** React DOM-compatible default export object. */\nconst ReactDOM = {\n createPortal,\n flushSync,\n render,\n unmountComponentAtNode,\n useFormState,\n createRoot,\n hydrateRoot,\n version,\n useFormStatus,\n requestFormReset,\n unstable_batchedUpdates,\n prefetchDNS,\n preconnect,\n preload,\n preloadModule,\n preinit,\n preinitModule,\n} as const;\n\nexport default ReactDOM;\n"]}
|
package/dist/server.d.ts
CHANGED
|
@@ -1,24 +1,30 @@
|
|
|
1
1
|
import { type ReactCompatNode } from "@reckona/mreact-compat";
|
|
2
|
+
/** React DOM server package version. */
|
|
2
3
|
export declare const version = "19.2.6";
|
|
4
|
+
/** Destination accepted by a pipeable server render stream. */
|
|
3
5
|
export interface PipeableStreamDestination {
|
|
4
6
|
write(chunk: string | Uint8Array): unknown;
|
|
5
7
|
end?(): unknown;
|
|
6
8
|
destroy?(error?: unknown): unknown;
|
|
7
9
|
}
|
|
10
|
+
/** Minimal pipeable stream returned by Node-oriented server rendering. */
|
|
8
11
|
export interface PipeableStream {
|
|
9
12
|
pipe<TDestination extends PipeableStreamDestination>(destination: TDestination): TDestination;
|
|
10
13
|
abort(reason?: unknown): void;
|
|
11
14
|
}
|
|
15
|
+
/** External bootstrap script descriptor emitted after the rendered HTML. */
|
|
12
16
|
export interface BootstrapScriptDescriptor {
|
|
13
17
|
src: string;
|
|
14
18
|
integrity?: string;
|
|
15
19
|
crossOrigin?: string;
|
|
16
20
|
}
|
|
21
|
+
/** Import map descriptor emitted as an inline bootstrap resource. */
|
|
17
22
|
export interface ReactImportMap {
|
|
18
23
|
imports?: Record<string, string>;
|
|
19
24
|
integrity?: Record<string, string>;
|
|
20
25
|
scopes?: Record<string, Record<string, string>>;
|
|
21
26
|
}
|
|
27
|
+
/** Bootstrap scripts, modules, and import maps appended to server output. */
|
|
22
28
|
export interface RenderBootstrapOptions {
|
|
23
29
|
nonce?: string;
|
|
24
30
|
importMap?: ReactImportMap;
|
|
@@ -26,9 +32,11 @@ export interface RenderBootstrapOptions {
|
|
|
26
32
|
bootstrapScripts?: Array<string | BootstrapScriptDescriptor>;
|
|
27
33
|
bootstrapModules?: Array<string | BootstrapScriptDescriptor>;
|
|
28
34
|
}
|
|
35
|
+
/** Shared server render options accepted by string rendering helpers. */
|
|
29
36
|
export interface ServerOptions {
|
|
30
37
|
identifierPrefix?: string;
|
|
31
38
|
}
|
|
39
|
+
/** Options for rendering HTML to a pipeable stream. */
|
|
32
40
|
export interface RenderToPipeableStreamOptions {
|
|
33
41
|
identifierPrefix?: string;
|
|
34
42
|
namespaceURI?: string;
|
|
@@ -48,6 +56,7 @@ export interface RenderToPipeableStreamOptions {
|
|
|
48
56
|
}): string | void;
|
|
49
57
|
formState?: unknown;
|
|
50
58
|
}
|
|
59
|
+
/** Options for rendering HTML to a WHATWG readable stream. */
|
|
51
60
|
export interface RenderToReadableStreamOptions {
|
|
52
61
|
identifierPrefix?: string;
|
|
53
62
|
namespaceURI?: string;
|
|
@@ -65,15 +74,24 @@ export interface RenderToReadableStreamOptions {
|
|
|
65
74
|
}): string | void;
|
|
66
75
|
formState?: unknown;
|
|
67
76
|
}
|
|
77
|
+
/** Readable stream augmented with the allReady promise used by React DOM server. */
|
|
68
78
|
export interface ReactDOMServerReadableStream extends ReadableStream<Uint8Array> {
|
|
69
79
|
allReady: Promise<void>;
|
|
70
80
|
}
|
|
81
|
+
/** Options accepted by resumable server rendering helpers. */
|
|
71
82
|
export type ResumeOptions = RenderToReadableStreamOptions & RenderToPipeableStreamOptions;
|
|
83
|
+
/** Placeholder type for postponed render state. */
|
|
72
84
|
export type PostponedState = unknown;
|
|
85
|
+
/** Renders a React-compatible node to an HTML string. */
|
|
73
86
|
export declare function renderToString(element: ReactCompatNode, _options?: ServerOptions): string;
|
|
87
|
+
/** Renders a React-compatible node to static HTML without hydration metadata. */
|
|
74
88
|
export declare function renderToStaticMarkup(element: ReactCompatNode, options?: ServerOptions): string;
|
|
89
|
+
/** Renders a React-compatible node to a WHATWG readable stream. */
|
|
75
90
|
export declare function renderToReadableStream(element: ReactCompatNode, options?: RenderToReadableStreamOptions): Promise<ReactDOMServerReadableStream>;
|
|
91
|
+
/** Renders a React-compatible node to a Node-style pipeable stream. */
|
|
76
92
|
export declare function renderToPipeableStream(element: ReactCompatNode, options?: RenderToPipeableStreamOptions): PipeableStream;
|
|
93
|
+
/** Resumes postponed server rendering into a WHATWG readable stream. */
|
|
77
94
|
export declare function resume(element: ReactCompatNode, _postponedState: PostponedState, options?: ResumeOptions): Promise<ReactDOMServerReadableStream>;
|
|
95
|
+
/** Resumes postponed server rendering into a Node-style pipeable stream. */
|
|
78
96
|
export declare function resumeToPipeableStream(element: ReactCompatNode, _postponedState: PostponedState, options?: ResumeOptions): Promise<PipeableStream>;
|
|
79
97
|
//# sourceMappingURL=server.d.ts.map
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,eAAe,EACrB,MAAM,wBAAwB,CAAC;AAEhC,eAAO,MAAM,OAAO,WAAW,CAAC;AAEhC,MAAM,WAAW,yBAAyB;IACxC,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,GAAG,OAAO,CAAC;IAC3C,GAAG,CAAC,IAAI,OAAO,CAAC;IAChB,OAAO,CAAC,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;CACpC;AAED,MAAM,WAAW,cA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KAAE,GAAG,MAAM,GAAG,IAAI,CAAC;IAChF,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,oFAAoF;AACpF,MAAM,WAAW,4BAA6B,SAAQ,cAAc,CAAC,UAAU,CAAC;IAC9E,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;CACzB;AAED,8DAA8D;AAC9D,MAAM,MAAM,aAAa,GAAG,6BAA6B,GAAG,6BAA6B,CAAC;AAC1F,mDAAmD;AACnD,MAAM,MAAM,cAAc,GAAG,OAAO,CAAC;AAErC,yDAAyD;AACzD,wBAAgB,cAAc,CAAC,OAAO,EAAE,eAAe,EAAE,QAAQ,CAAC,EAAE,aAAa,GAAG,MAAM,CAEzF;AAED,iFAAiF;AACjF,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,eAAe,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,MAAM,CAG9F;AAED,mEAAmE;AACnE,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,eAAe,EACxB,OAAO,GAAE,6BAAkC,GAC1C,OAAO,CAAC,4BAA4B,CAAC,CA0CvC;AAED,uEAAuE;AACvE,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,eAAe,EACxB,OAAO,GAAE,6BAAkC,GAC1C,cAAc,CAuChB;AAED,wEAAwE;AACxE,wBAAsB,MAAM,CAC1B,OAAO,EAAE,eAAe,EACxB,eAAe,EAAE,cAAc,EAC/B,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,4BAA4B,CAAC,CAEvC;AAED,4EAA4E;AAC5E,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,eAAe,EACxB,eAAe,EAAE,cAAc,EAC/B,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,cAAc,CAAC,CAEzB"}
|
package/dist/server.js
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { renderToString as renderCompatToString, } from "@reckona/mreact-compat";
|
|
2
|
+
/** React DOM server package version. */
|
|
2
3
|
export const version = "19.2.6";
|
|
4
|
+
/** Renders a React-compatible node to an HTML string. */
|
|
3
5
|
export function renderToString(element, _options) {
|
|
4
6
|
return renderCompatToString(() => element);
|
|
5
7
|
}
|
|
8
|
+
/** Renders a React-compatible node to static HTML without hydration metadata. */
|
|
6
9
|
export function renderToStaticMarkup(element, options) {
|
|
7
10
|
void options;
|
|
8
11
|
return renderToString(element);
|
|
9
12
|
}
|
|
13
|
+
/** Renders a React-compatible node to a WHATWG readable stream. */
|
|
10
14
|
export async function renderToReadableStream(element, options = {}) {
|
|
11
15
|
const encoder = new TextEncoder();
|
|
12
16
|
const html = renderServerHtml(element, options);
|
|
@@ -48,6 +52,7 @@ export async function renderToReadableStream(element, options = {}) {
|
|
|
48
52
|
});
|
|
49
53
|
return Object.assign(stream, { allReady });
|
|
50
54
|
}
|
|
55
|
+
/** Renders a React-compatible node to a Node-style pipeable stream. */
|
|
51
56
|
export function renderToPipeableStream(element, options = {}) {
|
|
52
57
|
let aborted = false;
|
|
53
58
|
let finished = false;
|
|
@@ -85,9 +90,11 @@ export function renderToPipeableStream(element, options = {}) {
|
|
|
85
90
|
},
|
|
86
91
|
};
|
|
87
92
|
}
|
|
93
|
+
/** Resumes postponed server rendering into a WHATWG readable stream. */
|
|
88
94
|
export async function resume(element, _postponedState, options = {}) {
|
|
89
95
|
return renderToReadableStream(element, options);
|
|
90
96
|
}
|
|
97
|
+
/** Resumes postponed server rendering into a Node-style pipeable stream. */
|
|
91
98
|
export async function resumeToPipeableStream(element, _postponedState, options = {}) {
|
|
92
99
|
return renderToPipeableStream(element, options);
|
|
93
100
|
}
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,IAAI,oBAAoB,GAEvC,MAAM,wBAAwB,CAAC;AAEhC,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC;AA8EhC,MAAM,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";\n\nexport const version = \"19.2.6\";\n\nexport interface PipeableStreamDestination {\n write(chunk: string | Uint8Array): unknown;\n end?(): unknown;\n destroy?(error?: unknown): unknown;\n}\n\nexport interface PipeableStream {\n pipe<TDestination extends PipeableStreamDestination>(destination: TDestination): TDestination;\n abort(reason?: unknown): void;\n}\n\nexport interface BootstrapScriptDescriptor {\n src: string;\n integrity?: string;\n crossOrigin?: string;\n}\n\nexport interface ReactImportMap {\n imports?: Record<string, string>;\n integrity?: Record<string, string>;\n scopes?: Record<string, Record<string, string>>;\n}\n\nexport interface RenderBootstrapOptions {\n nonce?: string;\n importMap?: ReactImportMap;\n bootstrapScriptContent?: string;\n bootstrapScripts?: Array<string | BootstrapScriptDescriptor>;\n bootstrapModules?: Array<string | BootstrapScriptDescriptor>;\n}\n\nexport interface ServerOptions {\n identifierPrefix?: string;\n}\n\nexport interface RenderToPipeableStreamOptions {\n identifierPrefix?: string;\n namespaceURI?: string;\n nonce?: string;\n importMap?: ReactImportMap;\n bootstrapScriptContent?: string;\n bootstrapScripts?: Array<string | BootstrapScriptDescriptor>;\n bootstrapModules?: Array<string | BootstrapScriptDescriptor>;\n headersLengthHint?: number;\n progressiveChunkSize?: number;\n onHeaders?(headers: Headers): void;\n onShellReady?(): void;\n onAllReady?(): void;\n onShellError?(error: unknown): void;\n onError?(error: unknown, errorInfo?: { componentStack: string }): string | void;\n formState?: unknown;\n}\n\nexport interface RenderToReadableStreamOptions {\n identifierPrefix?: string;\n namespaceURI?: string;\n nonce?: string;\n importMap?: ReactImportMap;\n bootstrapScriptContent?: string;\n bootstrapScripts?: Array<string | BootstrapScriptDescriptor>;\n bootstrapModules?: Array<string | BootstrapScriptDescriptor>;\n headersLengthHint?: number;\n progressiveChunkSize?: number;\n signal?: AbortSignal;\n onHeaders?(headers: Headers): void;\n onError?(error: unknown, errorInfo?: { componentStack: string }): string | void;\n formState?: unknown;\n}\n\nexport interface ReactDOMServerReadableStream extends ReadableStream<Uint8Array> {\n allReady: Promise<void>;\n}\n\nexport type ResumeOptions = RenderToReadableStreamOptions & RenderToPipeableStreamOptions;\nexport type PostponedState = unknown;\n\nexport function renderToString(element: ReactCompatNode, _options?: ServerOptions): string {\n return renderCompatToString(() => element);\n}\n\nexport function renderToStaticMarkup(element: ReactCompatNode, options?: ServerOptions): string {\n void options;\n return renderToString(element);\n}\n\nexport async function renderToReadableStream(\n element: ReactCompatNode,\n options: RenderToReadableStreamOptions = {},\n): Promise<ReactDOMServerReadableStream> {\n const encoder = new TextEncoder();\n const html = renderServerHtml(element, options);\n notifyHeaders(options);\n let resolveAllReady: () => void;\n let rejectAllReady: (error: unknown) => void;\n const allReady = new Promise<void>((resolve, reject) => {\n resolveAllReady = resolve;\n rejectAllReady = reject;\n });\n\n const stream = new ReadableStream<Uint8Array>({\n start(controller) {\n if (options.signal?.aborted === true) {\n const reason = options.signal.reason;\n rejectAllReady(reason);\n controller.error(reason);\n return;\n }\n\n const abort = () => {\n const reason = options.signal?.reason;\n rejectAllReady(reason);\n controller.error(reason);\n };\n options.signal?.addEventListener(\"abort\", abort, { once: true });\n\n try {\n controller.enqueue(encoder.encode(html));\n controller.close();\n resolveAllReady();\n } catch (error) {\n options.onError?.(error, { componentStack: \"\" });\n rejectAllReady(error);\n controller.error(error);\n } finally {\n options.signal?.removeEventListener(\"abort\", abort);\n }\n },\n });\n\n return Object.assign(stream, { allReady });\n}\n\nexport function renderToPipeableStream(\n element: ReactCompatNode,\n options: RenderToPipeableStreamOptions = {},\n): PipeableStream {\n let aborted = false;\n let finished = false;\n\n return {\n pipe(destination) {\n queueMicrotask(() => {\n if (aborted) {\n return;\n }\n\n try {\n notifyHeaders(options);\n options.onShellReady?.();\n const html = renderServerHtml(element, options);\n options.onAllReady?.();\n destination.write(html);\n destination.end?.();\n finished = true;\n } catch (error) {\n options.onError?.(error, { componentStack: \"\" });\n options.onShellError?.(error);\n destination.destroy?.(error);\n }\n });\n\n return destination;\n },\n abort(reason) {\n if (finished) {\n return;\n }\n\n aborted = true;\n options.onError?.(reason ?? new Error(\"renderToPipeableStream was aborted.\"), {\n componentStack: \"\",\n });\n },\n };\n}\n\nexport async function resume(\n element: ReactCompatNode,\n _postponedState: PostponedState,\n options: ResumeOptions = {},\n): Promise<ReactDOMServerReadableStream> {\n return renderToReadableStream(element, options);\n}\n\nexport async function resumeToPipeableStream(\n element: ReactCompatNode,\n _postponedState: PostponedState,\n options: ResumeOptions = {},\n): Promise<PipeableStream> {\n return renderToPipeableStream(element, options);\n}\n\nfunction renderServerHtml(element: ReactCompatNode, options: RenderBootstrapOptions): string {\n return `${renderToString(element)}${renderBootstrapResources(options)}`;\n}\n\nfunction renderBootstrapResources(options: RenderBootstrapOptions): string {\n const nonce = options.nonce === undefined ? \"\" : ` nonce=\"${escapeAttribute(options.nonce)}\"`;\n const importMap =\n options.importMap === undefined\n ? \"\"\n : `<script type=\"importmap\"${nonce}>${escapeScriptContent(JSON.stringify(options.importMap))}</script>`;\n const inlineScript =\n options.bootstrapScriptContent === undefined\n ? \"\"\n : `<script${nonce}>${escapeScriptContent(options.bootstrapScriptContent)}</script>`;\n const scripts = (options.bootstrapScripts ?? [])\n .map((script) => renderExternalScript(script, nonce, undefined))\n .join(\"\");\n const modules = (options.bootstrapModules ?? [])\n .map((script) => renderExternalScript(script, nonce, \"module\"))\n .join(\"\");\n\n return `${importMap}${inlineScript}${scripts}${modules}`;\n}\n\nfunction renderExternalScript(\n script: string | BootstrapScriptDescriptor,\n nonce: string,\n type: \"module\" | undefined,\n): string {\n const descriptor = typeof script === \"string\" ? { src: script } : script;\n const typeAttribute = type === undefined ? \"\" : ` type=\"${type}\"`;\n const src = ` src=\"${escapeAttribute(descriptor.src)}\"`;\n const integrity =\n descriptor.integrity === undefined ? \"\" : ` integrity=\"${escapeAttribute(descriptor.integrity)}\"`;\n const crossOrigin =\n descriptor.crossOrigin === undefined\n ? \"\"\n : ` crossorigin=\"${escapeAttribute(descriptor.crossOrigin)}\"`;\n\n return `<script${typeAttribute}${src}${nonce}${integrity}${crossOrigin}></script>`;\n}\n\nfunction escapeAttribute(value: string): string {\n return value\n .replaceAll(\"&\", \"&\")\n .replaceAll('\"', \""\")\n .replaceAll(\"<\", \"<\")\n .replaceAll(\">\", \">\");\n}\n\nfunction escapeScriptContent(value: string): string {\n return value\n .replaceAll(\"<\", \"\\\\u003c\")\n .replaceAll(\"\\u2028\", \"\\\\u2028\")\n .replaceAll(\"\\u2029\", \"\\\\u2029\");\n}\n\nfunction notifyHeaders(options: { onHeaders?(headers: Headers): void }): void {\n if (options.onHeaders === undefined) {\n return;\n }\n\n const headers = new Headers();\n headers.set(\"content-type\", \"text/html; charset=utf-8\");\n options.onHeaders(headers);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,IAAI,oBAAoB,GAEvC,MAAM,wBAAwB,CAAC;AAEhC,wCAAwC;AACxC,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC;AAyFhC,yDAAyD;AACzD,MAAM,UAAU,cAAc,CAAC,OAAwB,EAAE,QAAwB;IAC/E,OAAO,oBAAoB,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC;AAC7C,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,oBAAoB,CAAC,OAAwB,EAAE,OAAuB;IACpF,KAAK,OAAO,CAAC;IACb,OAAO,cAAc,CAAC,OAAO,CAAC,CAAC;AACjC,CAAC;AAED,mEAAmE;AACnE,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,OAAwB,EACxB,UAAyC,EAAE;IAE3C,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;IAClC,MAAM,IAAI,GAAG,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAChD,aAAa,CAAC,OAAO,CAAC,CAAC;IACvB,IAAI,eAA2B,CAAC;IAChC,IAAI,cAAwC,CAAC;IAC7C,MAAM,QAAQ,GAAG,I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ACT,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC;SACxB,UAAU,CAAC,GAAG,EAAE,QAAQ,CAAC;SACzB,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC;SACvB,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;AAC7B,CAAC;AAED,SAAS,mBAAmB,CAAC,KAAa;IACxC,OAAO,KAAK;SACT,UAAU,CAAC,GAAG,EAAE,SAAS,CAAC;SAC1B,UAAU,CAAC,QAAQ,EAAE,SAAS,CAAC;SAC/B,UAAU,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;AACrC,CAAC;AAED,SAAS,aAAa,CAAC,OAA+C;IACpE,IAAI,OAAO,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;QACpC,OAAO;IACT,CAAC;IAED,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;IAC9B,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,0BAA0B,CAAC,CAAC;IACxD,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;AAC7B,CAAC","sourcesContent":["import {\n renderToString as renderCompatToString,\n type ReactCompatNode,\n} from \"@reckona/mreact-compat\";\n\n/** React DOM server package version. */\nexport const version = \"19.2.6\";\n\n/** Destination accepted by a pipeable server render stream. */\nexport interface PipeableStreamDestination {\n write(chunk: string | Uint8Array): unknown;\n end?(): unknown;\n destroy?(error?: unknown): unknown;\n}\n\n/** Minimal pipeable stream returned by Node-oriented server rendering. */\nexport interface PipeableStream {\n pipe<TDestination extends PipeableStreamDestination>(destination: TDestination): TDestination;\n abort(reason?: unknown): void;\n}\n\n/** External bootstrap script descriptor emitted after the rendered HTML. */\nexport interface BootstrapScriptDescriptor {\n src: string;\n integrity?: string;\n crossOrigin?: string;\n}\n\n/** Import map descriptor emitted as an inline bootstrap resource. */\nexport interface ReactImportMap {\n imports?: Record<string, string>;\n integrity?: Record<string, string>;\n scopes?: Record<string, Record<string, string>>;\n}\n\n/** Bootstrap scripts, modules, and import maps appended to server output. */\nexport interface RenderBootstrapOptions {\n nonce?: string;\n importMap?: ReactImportMap;\n bootstrapScriptContent?: string;\n bootstrapScripts?: Array<string | BootstrapScriptDescriptor>;\n bootstrapModules?: Array<string | BootstrapScriptDescriptor>;\n}\n\n/** Shared server render options accepted by string rendering helpers. */\nexport interface ServerOptions {\n identifierPrefix?: string;\n}\n\n/** Options for rendering HTML to a pipeable stream. */\nexport interface RenderToPipeableStreamOptions {\n identifierPrefix?: string;\n namespaceURI?: string;\n nonce?: string;\n importMap?: ReactImportMap;\n bootstrapScriptContent?: string;\n bootstrapScripts?: Array<string | BootstrapScriptDescriptor>;\n bootstrapModules?: Array<string | BootstrapScriptDescriptor>;\n headersLengthHint?: number;\n progressiveChunkSize?: number;\n onHeaders?(headers: Headers): void;\n onShellReady?(): void;\n onAllReady?(): void;\n onShellError?(error: unknown): void;\n onError?(error: unknown, errorInfo?: { componentStack: string }): string | void;\n formState?: unknown;\n}\n\n/** Options for rendering HTML to a WHATWG readable stream. */\nexport interface RenderToReadableStreamOptions {\n identifierPrefix?: string;\n namespaceURI?: string;\n nonce?: string;\n importMap?: ReactImportMap;\n bootstrapScriptContent?: string;\n bootstrapScripts?: Array<string | BootstrapScriptDescriptor>;\n bootstrapModules?: Array<string | BootstrapScriptDescriptor>;\n headersLengthHint?: number;\n progressiveChunkSize?: number;\n signal?: AbortSignal;\n onHeaders?(headers: Headers): void;\n onError?(error: unknown, errorInfo?: { componentStack: string }): string | void;\n formState?: unknown;\n}\n\n/** Readable stream augmented with the allReady promise used by React DOM server. */\nexport interface ReactDOMServerReadableStream extends ReadableStream<Uint8Array> {\n allReady: Promise<void>;\n}\n\n/** Options accepted by resumable server rendering helpers. */\nexport type ResumeOptions = RenderToReadableStreamOptions & RenderToPipeableStreamOptions;\n/** Placeholder type for postponed render state. */\nexport type PostponedState = unknown;\n\n/** Renders a React-compatible node to an HTML string. */\nexport function renderToString(element: ReactCompatNode, _options?: ServerOptions): string {\n return renderCompatToString(() => element);\n}\n\n/** Renders a React-compatible node to static HTML without hydration metadata. */\nexport function renderToStaticMarkup(element: ReactCompatNode, options?: ServerOptions): string {\n void options;\n return renderToString(element);\n}\n\n/** Renders a React-compatible node to a WHATWG readable stream. */\nexport async function renderToReadableStream(\n element: ReactCompatNode,\n options: RenderToReadableStreamOptions = {},\n): Promise<ReactDOMServerReadableStream> {\n const encoder = new TextEncoder();\n const html = renderServerHtml(element, options);\n notifyHeaders(options);\n let resolveAllReady: () => void;\n let rejectAllReady: (error: unknown) => void;\n const allReady = new Promise<void>((resolve, reject) => {\n resolveAllReady = resolve;\n rejectAllReady = reject;\n });\n\n const stream = new ReadableStream<Uint8Array>({\n start(controller) {\n if (options.signal?.aborted === true) {\n const reason = options.signal.reason;\n rejectAllReady(reason);\n controller.error(reason);\n return;\n }\n\n const abort = () => {\n const reason = options.signal?.reason;\n rejectAllReady(reason);\n controller.error(reason);\n };\n options.signal?.addEventListener(\"abort\", abort, { once: true });\n\n try {\n controller.enqueue(encoder.encode(html));\n controller.close();\n resolveAllReady();\n } catch (error) {\n options.onError?.(error, { componentStack: \"\" });\n rejectAllReady(error);\n controller.error(error);\n } finally {\n options.signal?.removeEventListener(\"abort\", abort);\n }\n },\n });\n\n return Object.assign(stream, { allReady });\n}\n\n/** Renders a React-compatible node to a Node-style pipeable stream. */\nexport function renderToPipeableStream(\n element: ReactCompatNode,\n options: RenderToPipeableStreamOptions = {},\n): PipeableStream {\n let aborted = false;\n let finished = false;\n\n return {\n pipe(destination) {\n queueMicrotask(() => {\n if (aborted) {\n return;\n }\n\n try {\n notifyHeaders(options);\n options.onShellReady?.();\n const html = renderServerHtml(element, options);\n options.onAllReady?.();\n destination.write(html);\n destination.end?.();\n finished = true;\n } catch (error) {\n options.onError?.(error, { componentStack: \"\" });\n options.onShellError?.(error);\n destination.destroy?.(error);\n }\n });\n\n return destination;\n },\n abort(reason) {\n if (finished) {\n return;\n }\n\n aborted = true;\n options.onError?.(reason ?? new Error(\"renderToPipeableStream was aborted.\"), {\n componentStack: \"\",\n });\n },\n };\n}\n\n/** Resumes postponed server rendering into a WHATWG readable stream. */\nexport async function resume(\n element: ReactCompatNode,\n _postponedState: PostponedState,\n options: ResumeOptions = {},\n): Promise<ReactDOMServerReadableStream> {\n return renderToReadableStream(element, options);\n}\n\n/** Resumes postponed server rendering into a Node-style pipeable stream. */\nexport async function resumeToPipeableStream(\n element: ReactCompatNode,\n _postponedState: PostponedState,\n options: ResumeOptions = {},\n): Promise<PipeableStream> {\n return renderToPipeableStream(element, options);\n}\n\nfunction renderServerHtml(element: ReactCompatNode, options: RenderBootstrapOptions): string {\n return `${renderToString(element)}${renderBootstrapResources(options)}`;\n}\n\nfunction renderBootstrapResources(options: RenderBootstrapOptions): string {\n const nonce = options.nonce === undefined ? \"\" : ` nonce=\"${escapeAttribute(options.nonce)}\"`;\n const importMap =\n options.importMap === undefined\n ? \"\"\n : `<script type=\"importmap\"${nonce}>${escapeScriptContent(JSON.stringify(options.importMap))}</script>`;\n const inlineScript =\n options.bootstrapScriptContent === undefined\n ? \"\"\n : `<script${nonce}>${escapeScriptContent(options.bootstrapScriptContent)}</script>`;\n const scripts = (options.bootstrapScripts ?? [])\n .map((script) => renderExternalScript(script, nonce, undefined))\n .join(\"\");\n const modules = (options.bootstrapModules ?? [])\n .map((script) => renderExternalScript(script, nonce, \"module\"))\n .join(\"\");\n\n return `${importMap}${inlineScript}${scripts}${modules}`;\n}\n\nfunction renderExternalScript(\n script: string | BootstrapScriptDescriptor,\n nonce: string,\n type: \"module\" | undefined,\n): string {\n const descriptor = typeof script === \"string\" ? { src: script } : script;\n const typeAttribute = type === undefined ? \"\" : ` type=\"${type}\"`;\n const src = ` src=\"${escapeAttribute(descriptor.src)}\"`;\n const integrity =\n descriptor.integrity === undefined ? \"\" : ` integrity=\"${escapeAttribute(descriptor.integrity)}\"`;\n const crossOrigin =\n descriptor.crossOrigin === undefined\n ? \"\"\n : ` crossorigin=\"${escapeAttribute(descriptor.crossOrigin)}\"`;\n\n return `<script${typeAttribute}${src}${nonce}${integrity}${crossOrigin}></script>`;\n}\n\nfunction escapeAttribute(value: string): string {\n return value\n .replaceAll(\"&\", \"&\")\n .replaceAll('\"', \""\")\n .replaceAll(\"<\", \"<\")\n .replaceAll(\">\", \">\");\n}\n\nfunction escapeScriptContent(value: string): string {\n return value\n .replaceAll(\"<\", \"\\\\u003c\")\n .replaceAll(\"\\u2028\", \"\\\\u2028\")\n .replaceAll(\"\\u2029\", \"\\\\u2029\");\n}\n\nfunction notifyHeaders(options: { onHeaders?(headers: Headers): void }): void {\n if (options.onHeaders === undefined) {\n return;\n }\n\n const headers = new Headers();\n headers.set(\"content-type\", \"text/html; charset=utf-8\");\n options.onHeaders(headers);\n}\n"]}
|
package/dist/test-utils.d.ts
CHANGED
package/dist/test-utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-utils.d.ts","sourceRoot":"","sources":["../src/test-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,wBAAwB,CAAC"}
|
|
1
|
+
{"version":3,"file":"test-utils.d.ts","sourceRoot":"","sources":["../src/test-utils.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,OAAO,EAAE,GAAG,EAAE,MAAM,wBAAwB,CAAC"}
|
package/dist/test-utils.js
CHANGED
package/dist/test-utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-utils.js","sourceRoot":"","sources":["../src/test-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,wBAAwB,CAAC","sourcesContent":["
|
|
1
|
+
{"version":3,"file":"test-utils.js","sourceRoot":"","sources":["../src/test-utils.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,OAAO,EAAE,GAAG,EAAE,MAAM,wBAAwB,CAAC","sourcesContent":["/** Flushes updates produced by a test callback before assertions run. */\nexport { act } from \"@reckona/mreact-compat\";\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reckona/mreact-dom",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.161",
|
|
4
4
|
"description": "React DOM-compatible entrypoints for mreact.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dom",
|
|
@@ -64,6 +64,6 @@
|
|
|
64
64
|
"access": "public"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@reckona/mreact-compat": "0.0.
|
|
67
|
+
"@reckona/mreact-compat": "0.0.161"
|
|
68
68
|
}
|
|
69
69
|
}
|
package/src/client.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
/** Re-exports DOM root creation and hydration helpers. */
|
|
1
2
|
export { createRoot, hydrateRoot } from "@reckona/mreact-compat";
|
|
3
|
+
/** Re-exports DOM root option and handle types. */
|
|
2
4
|
export type { HydrateRootOptions, Root, RootOptions } from "@reckona/mreact-compat";
|
|
3
5
|
|
|
6
|
+
/** React DOM client package version. */
|
|
4
7
|
export const version = "19.2.6";
|
package/src/index.ts
CHANGED
|
@@ -7,6 +7,8 @@ import {
|
|
|
7
7
|
} from "@reckona/mreact-compat";
|
|
8
8
|
import { runWithEventPriority } from "@reckona/mreact-compat/event-priority";
|
|
9
9
|
import { createRoot, hydrateRoot } from "./client.js";
|
|
10
|
+
|
|
11
|
+
/** Re-exports the React DOM rendering helpers exposed by the root entrypoint. */
|
|
10
12
|
export {
|
|
11
13
|
createPortal,
|
|
12
14
|
flushSync,
|
|
@@ -18,8 +20,10 @@ export {
|
|
|
18
20
|
};
|
|
19
21
|
export type { HydrateRootOptions, Root, RootOptions } from "./client.js";
|
|
20
22
|
|
|
23
|
+
/** React DOM-compatible package version. */
|
|
21
24
|
export const version = "19.2.6";
|
|
22
25
|
|
|
26
|
+
/** Idle form status returned when no form submission is pending. */
|
|
23
27
|
export interface FormStatusNotPending {
|
|
24
28
|
pending: false;
|
|
25
29
|
data: null;
|
|
@@ -27,6 +31,7 @@ export interface FormStatusNotPending {
|
|
|
27
31
|
action: null;
|
|
28
32
|
}
|
|
29
33
|
|
|
34
|
+
/** Pending form status returned while a submission is in progress. */
|
|
30
35
|
export interface FormStatusPending {
|
|
31
36
|
pending: true;
|
|
32
37
|
data: FormData;
|
|
@@ -34,12 +39,15 @@ export interface FormStatusPending {
|
|
|
34
39
|
action: string | ((formData: FormData) => void | Promise<void>);
|
|
35
40
|
}
|
|
36
41
|
|
|
42
|
+
/** Current form submission state returned by useFormStatus. */
|
|
37
43
|
export type FormStatus = FormStatusPending | FormStatusNotPending;
|
|
38
44
|
|
|
45
|
+
/** Options applied when inserting a preconnect resource hint. */
|
|
39
46
|
export interface PreconnectOptions {
|
|
40
47
|
crossOrigin?: "anonymous" | "use-credentials" | "";
|
|
41
48
|
}
|
|
42
49
|
|
|
50
|
+
/** Allowed destination values for preload resource hints. */
|
|
43
51
|
export type PreloadAs =
|
|
44
52
|
| "audio"
|
|
45
53
|
| "document"
|
|
@@ -54,6 +62,7 @@ export type PreloadAs =
|
|
|
54
62
|
| "video"
|
|
55
63
|
| "worker";
|
|
56
64
|
|
|
65
|
+
/** Options applied when inserting a preload resource hint. */
|
|
57
66
|
export interface PreloadOptions {
|
|
58
67
|
as: PreloadAs;
|
|
59
68
|
crossOrigin?: "anonymous" | "use-credentials" | "";
|
|
@@ -67,6 +76,7 @@ export interface PreloadOptions {
|
|
|
67
76
|
media?: string;
|
|
68
77
|
}
|
|
69
78
|
|
|
79
|
+
/** Options applied when inserting a modulepreload resource hint. */
|
|
70
80
|
export interface PreloadModuleOptions {
|
|
71
81
|
as?: RequestDestination;
|
|
72
82
|
crossOrigin?: "anonymous" | "use-credentials" | "";
|
|
@@ -74,6 +84,7 @@ export interface PreloadModuleOptions {
|
|
|
74
84
|
nonce?: string;
|
|
75
85
|
}
|
|
76
86
|
|
|
87
|
+
/** Options applied when preinitializing a script or stylesheet resource. */
|
|
77
88
|
export interface PreinitOptions {
|
|
78
89
|
as: "script" | "style";
|
|
79
90
|
crossOrigin?: "anonymous" | "use-credentials" | "";
|
|
@@ -83,6 +94,7 @@ export interface PreinitOptions {
|
|
|
83
94
|
nonce?: string;
|
|
84
95
|
}
|
|
85
96
|
|
|
97
|
+
/** Options applied when preinitializing a JavaScript module resource. */
|
|
86
98
|
export interface PreinitModuleOptions {
|
|
87
99
|
as?: "script";
|
|
88
100
|
crossOrigin?: "anonymous" | "use-credentials" | "";
|
|
@@ -92,16 +104,19 @@ export interface PreinitModuleOptions {
|
|
|
92
104
|
|
|
93
105
|
type LinkAttributes = Record<string, string | undefined>;
|
|
94
106
|
|
|
107
|
+
/** Returns the current form submission status for the nearest form action. */
|
|
95
108
|
export function useFormStatus(): FormStatus {
|
|
96
109
|
throw new Error(
|
|
97
110
|
"useFormStatus is not supported by @reckona/mreact-dom yet. Use useFormState/useActionState for local pending state instead.",
|
|
98
111
|
);
|
|
99
112
|
}
|
|
100
113
|
|
|
114
|
+
/** Resets a form element after a server action-style submission completes. */
|
|
101
115
|
export function requestFormReset(form: HTMLFormElement): void {
|
|
102
116
|
form.reset();
|
|
103
117
|
}
|
|
104
118
|
|
|
119
|
+
/** Runs a callback at discrete event priority and returns its result. */
|
|
105
120
|
export function unstable_batchedUpdates<T>(callback: () => T): T;
|
|
106
121
|
export function unstable_batchedUpdates<TArgument, TResult>(
|
|
107
122
|
callback: (argument: TArgument) => TResult,
|
|
@@ -118,16 +133,19 @@ export function unstable_batchedUpdates<TArgument, TResult>(
|
|
|
118
133
|
);
|
|
119
134
|
}
|
|
120
135
|
|
|
136
|
+
/** Inserts a dns-prefetch link for the provided host if it is not already present. */
|
|
121
137
|
export function prefetchDNS(href: string): void {
|
|
122
138
|
upsertHeadLink("dns-prefetch", href, {});
|
|
123
139
|
}
|
|
124
140
|
|
|
141
|
+
/** Inserts a preconnect link for the provided origin if it is not already present. */
|
|
125
142
|
export function preconnect(href: string, options: PreconnectOptions = {}): void {
|
|
126
143
|
upsertHeadLink("preconnect", href, {
|
|
127
144
|
crossorigin: options.crossOrigin,
|
|
128
145
|
});
|
|
129
146
|
}
|
|
130
147
|
|
|
148
|
+
/** Inserts a preload link for the provided resource if it is not already present. */
|
|
131
149
|
export function preload(href: string, options: PreloadOptions): void {
|
|
132
150
|
upsertHeadLink("preload", href, {
|
|
133
151
|
as: options.as,
|
|
@@ -143,6 +161,7 @@ export function preload(href: string, options: PreloadOptions): void {
|
|
|
143
161
|
});
|
|
144
162
|
}
|
|
145
163
|
|
|
164
|
+
/** Inserts a modulepreload link for the provided module if it is not already present. */
|
|
146
165
|
export function preloadModule(href: string, options: PreloadModuleOptions = {}): void {
|
|
147
166
|
upsertHeadLink("modulepreload", href, {
|
|
148
167
|
as: options.as,
|
|
@@ -152,6 +171,7 @@ export function preloadModule(href: string, options: PreloadModuleOptions = {}):
|
|
|
152
171
|
});
|
|
153
172
|
}
|
|
154
173
|
|
|
174
|
+
/** Preinitializes a script or stylesheet resource in the document head. */
|
|
155
175
|
export function preinit(href: string, options: PreinitOptions): void {
|
|
156
176
|
if (options.as === "style") {
|
|
157
177
|
upsertHeadLink("stylesheet", href, {
|
|
@@ -173,6 +193,7 @@ export function preinit(href: string, options: PreinitOptions): void {
|
|
|
173
193
|
});
|
|
174
194
|
}
|
|
175
195
|
|
|
196
|
+
/** Preinitializes a JavaScript module resource in the document head. */
|
|
176
197
|
export function preinitModule(href: string, options: PreinitModuleOptions = {}): void {
|
|
177
198
|
upsertHeadScript(href, {
|
|
178
199
|
type: "module",
|
|
@@ -243,6 +264,7 @@ function escapeSelectorValue(value: string): string {
|
|
|
243
264
|
return value.replaceAll("\\", "\\\\").replaceAll('"', '\\"');
|
|
244
265
|
}
|
|
245
266
|
|
|
267
|
+
/** React DOM-compatible default export object. */
|
|
246
268
|
const ReactDOM = {
|
|
247
269
|
createPortal,
|
|
248
270
|
flushSync,
|
package/src/server.ts
CHANGED
|
@@ -3,31 +3,37 @@ import {
|
|
|
3
3
|
type ReactCompatNode,
|
|
4
4
|
} from "@reckona/mreact-compat";
|
|
5
5
|
|
|
6
|
+
/** React DOM server package version. */
|
|
6
7
|
export const version = "19.2.6";
|
|
7
8
|
|
|
9
|
+
/** Destination accepted by a pipeable server render stream. */
|
|
8
10
|
export interface PipeableStreamDestination {
|
|
9
11
|
write(chunk: string | Uint8Array): unknown;
|
|
10
12
|
end?(): unknown;
|
|
11
13
|
destroy?(error?: unknown): unknown;
|
|
12
14
|
}
|
|
13
15
|
|
|
16
|
+
/** Minimal pipeable stream returned by Node-oriented server rendering. */
|
|
14
17
|
export interface PipeableStream {
|
|
15
18
|
pipe<TDestination extends PipeableStreamDestination>(destination: TDestination): TDestination;
|
|
16
19
|
abort(reason?: unknown): void;
|
|
17
20
|
}
|
|
18
21
|
|
|
22
|
+
/** External bootstrap script descriptor emitted after the rendered HTML. */
|
|
19
23
|
export interface BootstrapScriptDescriptor {
|
|
20
24
|
src: string;
|
|
21
25
|
integrity?: string;
|
|
22
26
|
crossOrigin?: string;
|
|
23
27
|
}
|
|
24
28
|
|
|
29
|
+
/** Import map descriptor emitted as an inline bootstrap resource. */
|
|
25
30
|
export interface ReactImportMap {
|
|
26
31
|
imports?: Record<string, string>;
|
|
27
32
|
integrity?: Record<string, string>;
|
|
28
33
|
scopes?: Record<string, Record<string, string>>;
|
|
29
34
|
}
|
|
30
35
|
|
|
36
|
+
/** Bootstrap scripts, modules, and import maps appended to server output. */
|
|
31
37
|
export interface RenderBootstrapOptions {
|
|
32
38
|
nonce?: string;
|
|
33
39
|
importMap?: ReactImportMap;
|
|
@@ -36,10 +42,12 @@ export interface RenderBootstrapOptions {
|
|
|
36
42
|
bootstrapModules?: Array<string | BootstrapScriptDescriptor>;
|
|
37
43
|
}
|
|
38
44
|
|
|
45
|
+
/** Shared server render options accepted by string rendering helpers. */
|
|
39
46
|
export interface ServerOptions {
|
|
40
47
|
identifierPrefix?: string;
|
|
41
48
|
}
|
|
42
49
|
|
|
50
|
+
/** Options for rendering HTML to a pipeable stream. */
|
|
43
51
|
export interface RenderToPipeableStreamOptions {
|
|
44
52
|
identifierPrefix?: string;
|
|
45
53
|
namespaceURI?: string;
|
|
@@ -58,6 +66,7 @@ export interface RenderToPipeableStreamOptions {
|
|
|
58
66
|
formState?: unknown;
|
|
59
67
|
}
|
|
60
68
|
|
|
69
|
+
/** Options for rendering HTML to a WHATWG readable stream. */
|
|
61
70
|
export interface RenderToReadableStreamOptions {
|
|
62
71
|
identifierPrefix?: string;
|
|
63
72
|
namespaceURI?: string;
|
|
@@ -74,22 +83,28 @@ export interface RenderToReadableStreamOptions {
|
|
|
74
83
|
formState?: unknown;
|
|
75
84
|
}
|
|
76
85
|
|
|
86
|
+
/** Readable stream augmented with the allReady promise used by React DOM server. */
|
|
77
87
|
export interface ReactDOMServerReadableStream extends ReadableStream<Uint8Array> {
|
|
78
88
|
allReady: Promise<void>;
|
|
79
89
|
}
|
|
80
90
|
|
|
91
|
+
/** Options accepted by resumable server rendering helpers. */
|
|
81
92
|
export type ResumeOptions = RenderToReadableStreamOptions & RenderToPipeableStreamOptions;
|
|
93
|
+
/** Placeholder type for postponed render state. */
|
|
82
94
|
export type PostponedState = unknown;
|
|
83
95
|
|
|
96
|
+
/** Renders a React-compatible node to an HTML string. */
|
|
84
97
|
export function renderToString(element: ReactCompatNode, _options?: ServerOptions): string {
|
|
85
98
|
return renderCompatToString(() => element);
|
|
86
99
|
}
|
|
87
100
|
|
|
101
|
+
/** Renders a React-compatible node to static HTML without hydration metadata. */
|
|
88
102
|
export function renderToStaticMarkup(element: ReactCompatNode, options?: ServerOptions): string {
|
|
89
103
|
void options;
|
|
90
104
|
return renderToString(element);
|
|
91
105
|
}
|
|
92
106
|
|
|
107
|
+
/** Renders a React-compatible node to a WHATWG readable stream. */
|
|
93
108
|
export async function renderToReadableStream(
|
|
94
109
|
element: ReactCompatNode,
|
|
95
110
|
options: RenderToReadableStreamOptions = {},
|
|
@@ -137,6 +152,7 @@ export async function renderToReadableStream(
|
|
|
137
152
|
return Object.assign(stream, { allReady });
|
|
138
153
|
}
|
|
139
154
|
|
|
155
|
+
/** Renders a React-compatible node to a Node-style pipeable stream. */
|
|
140
156
|
export function renderToPipeableStream(
|
|
141
157
|
element: ReactCompatNode,
|
|
142
158
|
options: RenderToPipeableStreamOptions = {},
|
|
@@ -181,6 +197,7 @@ export function renderToPipeableStream(
|
|
|
181
197
|
};
|
|
182
198
|
}
|
|
183
199
|
|
|
200
|
+
/** Resumes postponed server rendering into a WHATWG readable stream. */
|
|
184
201
|
export async function resume(
|
|
185
202
|
element: ReactCompatNode,
|
|
186
203
|
_postponedState: PostponedState,
|
|
@@ -189,6 +206,7 @@ export async function resume(
|
|
|
189
206
|
return renderToReadableStream(element, options);
|
|
190
207
|
}
|
|
191
208
|
|
|
209
|
+
/** Resumes postponed server rendering into a Node-style pipeable stream. */
|
|
192
210
|
export async function resumeToPipeableStream(
|
|
193
211
|
element: ReactCompatNode,
|
|
194
212
|
_postponedState: PostponedState,
|
package/src/test-utils.ts
CHANGED