@web-widget/react 1.56.0 → 1.57.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { FunctionComponent, ReactNode
|
|
2
|
+
import { FunctionComponent, ReactNode } from 'react';
|
|
3
3
|
import { WebWidgetRendererOptions, Loader } from '@web-widget/web-widget';
|
|
4
|
-
import { RenderContext, ComponentProps, SerializableValue } from '@web-widget/helpers';
|
|
5
4
|
|
|
6
5
|
interface ReactWidgetComponent<T> extends FunctionComponent<T & WebWidgetSuspenseProps> {
|
|
7
6
|
}
|
|
@@ -28,12 +27,4 @@ interface WebWidgetSuspenseProps {
|
|
|
28
27
|
}
|
|
29
28
|
declare function defineWebWidget(loader: Loader, options: DefineWebWidgetOptions): react.NamedExoticComponent<WebWidgetSuspenseProps>;
|
|
30
29
|
|
|
31
|
-
|
|
32
|
-
[key: string]: SerializableValue;
|
|
33
|
-
}
|
|
34
|
-
interface CreateReactRenderOptions {
|
|
35
|
-
/**@deprecated*/
|
|
36
|
-
onPrefetchData?: (context: RenderContext, component: Component, props: ComponentProps) => Promise<SerializableObject>;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export { type CreateReactRenderOptions as C, type DefineWebWidgetOptions as D, type ReactWidgetComponent as R, type WebWidgetProps as W, type WebWidgetSuspenseProps as a, defineWebWidget as d };
|
|
30
|
+
export { type DefineWebWidgetOptions as D, type ReactWidgetComponent as R, type WebWidgetProps as W, type WebWidgetSuspenseProps as a, defineWebWidget as d };
|
package/dist/react.client.d.ts
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import * as _web_widget_helpers from '@web-widget/helpers';
|
|
2
2
|
export * from '@web-widget/helpers';
|
|
3
|
-
import {
|
|
4
|
-
export { D as DefineWebWidgetOptions, R as ReactWidgetComponent, W as WebWidgetProps, a as WebWidgetSuspenseProps, d as defineWebWidget } from './types-CYxYkOI1.js';
|
|
3
|
+
import { FunctionComponent } from 'react';
|
|
5
4
|
export { useWidgetSyncState as useWidgetState } from '@web-widget/helpers/state';
|
|
6
|
-
|
|
5
|
+
export { D as DefineWebWidgetOptions, R as ReactWidgetComponent, W as WebWidgetProps, a as WebWidgetSuspenseProps, d as defineWebWidget } from './components-BlwPaPdf.js';
|
|
7
6
|
import '@web-widget/web-widget';
|
|
8
7
|
|
|
9
|
-
declare const
|
|
10
|
-
/**@deprecated Please use `createReactRender` instead.*/
|
|
11
|
-
declare const defineReactRender: ({ onPrefetchData, }?: CreateReactRenderOptions) => (context: _web_widget_helpers.WidgetRenderContext<unknown>, renderOptions: _web_widget_helpers.WidgetRenderOptions) => Promise<_web_widget_helpers.WidgetRenderResult>;
|
|
12
|
-
declare const render: (context: _web_widget_helpers.WidgetRenderContext<unknown>, renderOptions: _web_widget_helpers.WidgetRenderOptions) => Promise<_web_widget_helpers.WidgetRenderResult>;
|
|
8
|
+
declare const render: _web_widget_helpers.ClientRender<FunctionComponent<{}>, unknown, _web_widget_helpers.ClientRenderOptions, void | _web_widget_helpers.ClientRenderResult<unknown>>;
|
|
13
9
|
|
|
14
|
-
export {
|
|
10
|
+
export { render };
|
package/dist/react.client.js
CHANGED
|
@@ -3,36 +3,24 @@ import {
|
|
|
3
3
|
} from "./chunk-RYJ3BJDY.js";
|
|
4
4
|
|
|
5
5
|
// src/client.ts
|
|
6
|
-
import {
|
|
6
|
+
import { defineClientRender } from "@web-widget/helpers";
|
|
7
7
|
import { createElement, StrictMode } from "react";
|
|
8
8
|
import { createRoot, hydrateRoot } from "react-dom/client";
|
|
9
9
|
export * from "@web-widget/helpers";
|
|
10
10
|
import { useWidgetSyncState } from "@web-widget/helpers/state";
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
return defineRender(async (context) => {
|
|
18
|
-
const { recovering, container } = context;
|
|
19
|
-
const componentDescriptor = getComponentDescriptor(context);
|
|
20
|
-
const { component, props } = componentDescriptor;
|
|
11
|
+
var render = defineClientRender(
|
|
12
|
+
async (component, context, { recovering, container }) => {
|
|
13
|
+
if (!component) {
|
|
14
|
+
throw new TypeError(`Missing component.`);
|
|
15
|
+
}
|
|
21
16
|
if (!container) {
|
|
22
|
-
throw new Error(`
|
|
17
|
+
throw new Error(`Missing container.`);
|
|
23
18
|
}
|
|
24
19
|
let root;
|
|
25
20
|
return {
|
|
26
21
|
async mount() {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
vNode = await component(props);
|
|
30
|
-
} else {
|
|
31
|
-
vNode = createElement(
|
|
32
|
-
component,
|
|
33
|
-
props
|
|
34
|
-
);
|
|
35
|
-
}
|
|
22
|
+
const isAsyncFunction = Object.prototype.toString.call(component) === "[object AsyncFunction]";
|
|
23
|
+
let vNode = isAsyncFunction ? await component(context) : createElement(component, context);
|
|
36
24
|
vNode = createElement(StrictMode, null, vNode);
|
|
37
25
|
if (recovering) {
|
|
38
26
|
root = hydrateRoot(container, vNode);
|
|
@@ -46,13 +34,9 @@ var createReactRender = ({
|
|
|
46
34
|
root = null;
|
|
47
35
|
}
|
|
48
36
|
};
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
var defineReactRender = createReactRender;
|
|
52
|
-
var render = createReactRender();
|
|
37
|
+
}
|
|
38
|
+
);
|
|
53
39
|
export {
|
|
54
|
-
createReactRender,
|
|
55
|
-
defineReactRender,
|
|
56
40
|
defineWebWidget,
|
|
57
41
|
render,
|
|
58
42
|
useWidgetSyncState as useWidgetState
|
package/dist/react.server.d.ts
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import * as _web_widget_helpers from '@web-widget/helpers';
|
|
2
2
|
export * from '@web-widget/helpers';
|
|
3
|
-
import {
|
|
4
|
-
export { D as DefineWebWidgetOptions, R as ReactWidgetComponent, W as WebWidgetProps, a as WebWidgetSuspenseProps, d as defineWebWidget } from './types-CYxYkOI1.js';
|
|
3
|
+
import { FunctionComponent } from 'react';
|
|
5
4
|
import { PrerenderOptions } from 'react-dom/static';
|
|
6
5
|
export { useWidgetSyncState as useWidgetState } from '@web-widget/helpers/state';
|
|
6
|
+
export { D as DefineWebWidgetOptions, R as ReactWidgetComponent, W as WebWidgetProps, a as WebWidgetSuspenseProps, d as defineWebWidget } from './components-BlwPaPdf.js';
|
|
7
7
|
import { RenderToReadableStreamOptions } from 'react-dom/server';
|
|
8
|
-
import 'react';
|
|
9
8
|
import '@web-widget/web-widget';
|
|
10
9
|
|
|
10
|
+
declare global {
|
|
11
|
+
interface ReadableStream {
|
|
12
|
+
[Symbol.asyncIterator](): AsyncIterator<ArrayBuffer | ArrayBufferView>;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
11
15
|
type RenderToStringOptions = PrerenderOptions;
|
|
12
16
|
|
|
13
17
|
declare module '@web-widget/schema' {
|
|
14
|
-
interface
|
|
15
|
-
react?: {};
|
|
16
|
-
}
|
|
17
|
-
interface RouteRenderOptions {
|
|
18
|
+
interface ServerRenderOptions {
|
|
18
19
|
react?: StreamOptions;
|
|
19
20
|
}
|
|
20
21
|
}
|
|
@@ -25,9 +26,6 @@ type StreamOptions = {
|
|
|
25
26
|
interface ReactRenderOptions {
|
|
26
27
|
react?: StreamOptions;
|
|
27
28
|
}
|
|
28
|
-
declare const
|
|
29
|
-
/**@deprecated Please use `createReactRender` instead.*/
|
|
30
|
-
declare const defineReactRender: ({ onPrefetchData, }?: CreateReactRenderOptions) => (context: _web_widget_helpers.RouteRenderContext<unknown, Record<string, string>>, renderOptions: _web_widget_helpers.RouteRenderOptions) => Promise<_web_widget_helpers.RouteRenderResult>;
|
|
31
|
-
declare const render: (context: _web_widget_helpers.RouteRenderContext<unknown, Record<string, string>>, renderOptions: _web_widget_helpers.RouteRenderOptions) => Promise<_web_widget_helpers.RouteRenderResult>;
|
|
29
|
+
declare const render: _web_widget_helpers.ServerRender<FunctionComponent<{}>, unknown, _web_widget_helpers.ServerRenderOptions, _web_widget_helpers.ServerRenderResult>;
|
|
32
30
|
|
|
33
|
-
export { type ReactRenderOptions,
|
|
31
|
+
export { type ReactRenderOptions, render };
|
package/dist/react.server.js
CHANGED
|
@@ -3,10 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-RYJ3BJDY.js";
|
|
4
4
|
|
|
5
5
|
// src/server.ts
|
|
6
|
-
import {
|
|
7
|
-
defineRender,
|
|
8
|
-
getComponentDescriptor
|
|
9
|
-
} from "@web-widget/helpers";
|
|
6
|
+
import { defineServerRender } from "@web-widget/helpers";
|
|
10
7
|
import { createElement, StrictMode } from "react";
|
|
11
8
|
|
|
12
9
|
// src/edge.ts
|
|
@@ -30,57 +27,38 @@ async function readableStreamToString(readableStream) {
|
|
|
30
27
|
// src/server.ts
|
|
31
28
|
export * from "@web-widget/helpers";
|
|
32
29
|
import { useWidgetSyncState } from "@web-widget/helpers/state";
|
|
33
|
-
var
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
reactRenderOptions.signal = AbortSignal.timeout(1e3 * 10);
|
|
49
|
-
}
|
|
50
|
-
reactRenderOptions.onError = (e, i) => {
|
|
51
|
-
error = e;
|
|
52
|
-
if (onError) {
|
|
53
|
-
onError(e, i);
|
|
54
|
-
} else if (progressive && !awaitAllReady) {
|
|
55
|
-
console.error(e);
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
let vNode;
|
|
59
|
-
if (typeof component === "function" && component.constructor.name === "AsyncFunction") {
|
|
60
|
-
vNode = await component(props);
|
|
61
|
-
} else {
|
|
62
|
-
vNode = createElement(
|
|
63
|
-
component,
|
|
64
|
-
props
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
vNode = createElement(StrictMode, null, vNode);
|
|
68
|
-
const html = await (progressive ? renderToReadableStream(vNode, reactRenderOptions) : renderToString(vNode, reactRenderOptions));
|
|
69
|
-
if (progressive && awaitAllReady) {
|
|
70
|
-
await html.allReady;
|
|
71
|
-
}
|
|
72
|
-
if (error) {
|
|
73
|
-
throw error;
|
|
30
|
+
var DEFAULT_TIMEOUT_MS = 1e3 * 10;
|
|
31
|
+
var render = defineServerRender(
|
|
32
|
+
async (component, context, { progressive, react }) => {
|
|
33
|
+
if (!component) {
|
|
34
|
+
throw new TypeError(`Missing component.`);
|
|
35
|
+
}
|
|
36
|
+
const reactRenderOptions = Object.create(react != null ? react : null);
|
|
37
|
+
let error;
|
|
38
|
+
const { onError, awaitAllReady, signal } = reactRenderOptions;
|
|
39
|
+
reactRenderOptions.signal = signal != null ? signal : AbortSignal.timeout(DEFAULT_TIMEOUT_MS);
|
|
40
|
+
reactRenderOptions.onError = (e, i) => {
|
|
41
|
+
error = e;
|
|
42
|
+
onError == null ? void 0 : onError(e, i);
|
|
43
|
+
if (!onError && progressive && !awaitAllReady) {
|
|
44
|
+
console.error(e);
|
|
74
45
|
}
|
|
75
|
-
|
|
46
|
+
};
|
|
47
|
+
const isAsyncFunction = Object.prototype.toString.call(component) === "[object AsyncFunction]";
|
|
48
|
+
let vNode = isAsyncFunction ? await component(context) : createElement(component, context);
|
|
49
|
+
vNode = createElement(StrictMode, null, vNode);
|
|
50
|
+
const renderMethod = progressive ? renderToReadableStream : renderToString;
|
|
51
|
+
const result = await renderMethod(vNode, reactRenderOptions);
|
|
52
|
+
if (progressive && awaitAllReady && "allReady" in result) {
|
|
53
|
+
await result.allReady;
|
|
76
54
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
55
|
+
if (error) {
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
58
|
+
return result;
|
|
59
|
+
}
|
|
60
|
+
);
|
|
81
61
|
export {
|
|
82
|
-
createReactRender,
|
|
83
|
-
defineReactRender,
|
|
84
62
|
defineWebWidget,
|
|
85
63
|
render,
|
|
86
64
|
useWidgetSyncState as useWidgetState
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@web-widget/react",
|
|
3
3
|
"description": "React adapter",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.57.0",
|
|
5
5
|
"homepage": "https://github.com/web-widget/web-widget#readme",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
"license": "MIT",
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@rollup/pluginutils": "^5.1.4",
|
|
17
|
-
"@web-widget/helpers": "1.
|
|
18
|
-
"@web-widget/schema": "1.
|
|
19
|
-
"@web-widget/vite-plugin": "1.
|
|
20
|
-
"@web-widget/web-widget": "1.
|
|
17
|
+
"@web-widget/helpers": "1.57.0",
|
|
18
|
+
"@web-widget/schema": "1.57.0",
|
|
19
|
+
"@web-widget/vite-plugin": "1.57.0",
|
|
20
|
+
"@web-widget/web-widget": "1.57.0"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@types/react": "^19.0.10",
|