@web-widget/react 0.13.7 → 1.10.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/dist/react.server.d.ts +4 -3
- package/dist/react.server.js +5 -22
- package/dist/vite.cjs +2 -2
- package/dist/vite.d.cts +1 -1
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +1 -1
- package/package.json +8 -7
package/dist/react.server.d.ts
CHANGED
|
@@ -48,10 +48,11 @@ interface CreateReactRenderOptions {
|
|
|
48
48
|
onPrefetchData?: (context: RenderContext, component: Component, props: ComponentProps) => Promise<JSONProps>;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
type StreamOptions = {
|
|
52
|
+
awaitAllReady?: boolean;
|
|
53
|
+
} & RenderToReadableStreamOptions;
|
|
51
54
|
interface ReactRenderOptions {
|
|
52
|
-
react?:
|
|
53
|
-
awaitAllReady?: boolean;
|
|
54
|
-
} & RenderToReadableStreamOptions;
|
|
55
|
+
react?: StreamOptions;
|
|
55
56
|
}
|
|
56
57
|
declare const createReactRender: ({ onPrefetchData, }?: CreateReactRenderOptions) => (context: _web_widget_schema.WidgetRenderContext<unknown> | _web_widget_schema.RouteRenderContext<unknown, Record<string, string>>, renderOptions: ReactRenderOptions | _web_widget_schema.RouteRenderOptions<ReactRenderOptions>) => Promise<string | void | ReadableStream<any> | {
|
|
57
58
|
bootstrap?: (() => void | Promise<void>) | undefined;
|
package/dist/react.server.js
CHANGED
|
@@ -116,20 +116,6 @@ function defineWebWidget(loader, options) {
|
|
|
116
116
|
function renderToReadableStream2(vNode, renderOptions) {
|
|
117
117
|
return ReactDOMServer.renderToReadableStream(vNode, renderOptions);
|
|
118
118
|
}
|
|
119
|
-
function createTimeoutSignal(ms) {
|
|
120
|
-
const controller = new AbortController();
|
|
121
|
-
const timer = setTimeout(() => {
|
|
122
|
-
controller.abort(
|
|
123
|
-
new Error(`Component did not finish rendering within ${ms}ms.`)
|
|
124
|
-
);
|
|
125
|
-
}, ms);
|
|
126
|
-
return [
|
|
127
|
-
controller.signal,
|
|
128
|
-
function disconnect() {
|
|
129
|
-
clearTimeout(timer);
|
|
130
|
-
}
|
|
131
|
-
];
|
|
132
|
-
}
|
|
133
119
|
var createReactRender = ({
|
|
134
120
|
onPrefetchData
|
|
135
121
|
} = {}) => {
|
|
@@ -137,22 +123,22 @@ var createReactRender = ({
|
|
|
137
123
|
throw new Error(`"onPrefetchData" is not supported.`);
|
|
138
124
|
}
|
|
139
125
|
return defineRender(
|
|
140
|
-
async (context, { react:
|
|
141
|
-
|
|
126
|
+
async (context, { react: options } = {}) => {
|
|
127
|
+
const reactRenderOptions = Object.create(options != null ? options : null);
|
|
128
|
+
let error;
|
|
142
129
|
const componentDescriptor = getComponentDescriptor(context);
|
|
143
130
|
const { component, props } = componentDescriptor;
|
|
144
131
|
const onError = reactRenderOptions.onError;
|
|
145
132
|
const awaitAllReady = reactRenderOptions.awaitAllReady;
|
|
146
133
|
if (!reactRenderOptions.signal) {
|
|
147
|
-
|
|
148
|
-
reactRenderOptions.signal = signal;
|
|
134
|
+
reactRenderOptions.signal = AbortSignal.timeout(1e3 * 10);
|
|
149
135
|
}
|
|
150
136
|
reactRenderOptions.onError = (e, i) => {
|
|
151
137
|
error = e;
|
|
152
138
|
if (onError) {
|
|
153
139
|
onError(e, i);
|
|
154
140
|
} else if (!awaitAllReady) {
|
|
155
|
-
console.error(
|
|
141
|
+
console.error(e);
|
|
156
142
|
}
|
|
157
143
|
};
|
|
158
144
|
let vNode;
|
|
@@ -168,9 +154,6 @@ var createReactRender = ({
|
|
|
168
154
|
if (awaitAllReady) {
|
|
169
155
|
await stream.allReady;
|
|
170
156
|
}
|
|
171
|
-
if (disconnect) {
|
|
172
|
-
disconnect();
|
|
173
|
-
}
|
|
174
157
|
if (error) {
|
|
175
158
|
throw error;
|
|
176
159
|
}
|
package/dist/vite.cjs
CHANGED
|
@@ -40,14 +40,14 @@ __export(vite_exports, {
|
|
|
40
40
|
default: () => reactWebWidgetPlugin
|
|
41
41
|
});
|
|
42
42
|
module.exports = __toCommonJS(vite_exports);
|
|
43
|
-
var
|
|
43
|
+
var import_vite_plugin = require("@web-widget/vite-plugin");
|
|
44
44
|
var VUE_INTERNAL_REQUEST = /.*\.vue\?vue\b.*$/;
|
|
45
45
|
function reactWebWidgetPlugin({
|
|
46
46
|
provide = "@web-widget/react",
|
|
47
47
|
export: exportWidget = {},
|
|
48
48
|
import: importWidget = {}
|
|
49
49
|
} = {}) {
|
|
50
|
-
return (0,
|
|
50
|
+
return (0, import_vite_plugin.webWidgetPlugin)({
|
|
51
51
|
provide,
|
|
52
52
|
export: __spreadValues({
|
|
53
53
|
include: /(?:\.|@)(?:route|widget)\.(?:tsx|jsx)(?:\?.*)?$/
|
package/dist/vite.d.cts
CHANGED
package/dist/vite.d.ts
CHANGED
package/dist/vite.js
CHANGED
|
@@ -19,7 +19,7 @@ var __spreadValues = (a, b) => {
|
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
20
|
|
|
21
21
|
// src/vite.ts
|
|
22
|
-
import { webWidgetPlugin } from "@web-widget/vite";
|
|
22
|
+
import { webWidgetPlugin } from "@web-widget/vite-plugin";
|
|
23
23
|
var VUE_INTERNAL_REQUEST = /.*\.vue\?vue\b.*$/;
|
|
24
24
|
function reactWebWidgetPlugin({
|
|
25
25
|
provide = "@web-widget/react",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@web-widget/react",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.10.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"globals.d.ts"
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@web-widget/vite": "
|
|
34
|
+
"@web-widget/vite-plugin": "1.10.1"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/react-dom": "^18.2.18",
|
|
@@ -41,15 +41,15 @@
|
|
|
41
41
|
"tsup": "^8.0.1",
|
|
42
42
|
"typescript": "latest",
|
|
43
43
|
"vite": "^5.0.12",
|
|
44
|
-
"@web-widget/helpers": "
|
|
45
|
-
"@web-widget/web-widget": "1.
|
|
44
|
+
"@web-widget/helpers": "1.10.1",
|
|
45
|
+
"@web-widget/web-widget": "1.10.1"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"react-dom": "canary",
|
|
49
49
|
"react": "canary",
|
|
50
50
|
"vite": "^5.0.12",
|
|
51
|
-
"@web-widget/helpers": "
|
|
52
|
-
"@web-widget/web-widget": "1.
|
|
51
|
+
"@web-widget/helpers": "1.10.1",
|
|
52
|
+
"@web-widget/web-widget": "1.10.1"
|
|
53
53
|
},
|
|
54
54
|
"publishConfig": {
|
|
55
55
|
"access": "public"
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
"dev": "pnpm exec tsup --watch",
|
|
60
60
|
"clean:build": "rm -rf dist",
|
|
61
61
|
"clean:node": "rm -rf node_modules",
|
|
62
|
-
"prebuild": "pnpm run clean:build"
|
|
62
|
+
"prebuild": "pnpm run clean:build",
|
|
63
|
+
"lint": "eslint src"
|
|
63
64
|
}
|
|
64
65
|
}
|