@web-widget/vue 0.3.0 → 0.4.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/vue.client.d.ts +2 -2
- package/dist/vue.client.js +10 -3
- package/dist/vue.server.d.ts +7 -3
- package/dist/vue.server.js +33 -24
- package/package.json +5 -5
package/dist/vue.client.d.ts
CHANGED
|
@@ -143,7 +143,7 @@ interface DefineVueRenderOptions {
|
|
|
143
143
|
onPrefetchData?: (context: RenderContext, component: Component, props: ComponentProps) => Promise<JSONProps>;
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
-
declare const defineVueRender: ({ onCreatedApp, onPrefetchData, }?: DefineVueRenderOptions) => (context: _web_widget_schema.ClientWidgetRenderContext<unknown> | _web_widget_schema.ClientRouteRenderContext<unknown, Record<string, string
|
|
146
|
+
declare const defineVueRender: ({ onCreatedApp, onPrefetchData, }?: DefineVueRenderOptions) => (context: _web_widget_schema.ClientWidgetRenderContext<unknown> | _web_widget_schema.ClientRouteRenderContext<unknown, Record<string, string>>, renderOptions: any) => Promise<void | {
|
|
147
147
|
mount?: (() => void | Promise<void>) | undefined;
|
|
148
148
|
unmount?: (() => void | Promise<void>) | undefined;
|
|
149
149
|
update?: (({ data }: {
|
|
@@ -156,7 +156,7 @@ declare const defineVueRender: ({ onCreatedApp, onPrefetchData, }?: DefineVueRen
|
|
|
156
156
|
data: Record<string, any>;
|
|
157
157
|
}) => void | Promise<void>) | undefined;
|
|
158
158
|
}>;
|
|
159
|
-
declare const render: (context: _web_widget_schema.ClientWidgetRenderContext<unknown> | _web_widget_schema.ClientRouteRenderContext<unknown, Record<string, string
|
|
159
|
+
declare const render: (context: _web_widget_schema.ClientWidgetRenderContext<unknown> | _web_widget_schema.ClientRouteRenderContext<unknown, Record<string, string>>, renderOptions: any) => Promise<void | {
|
|
160
160
|
mount?: (() => void | Promise<void>) | undefined;
|
|
161
161
|
unmount?: (() => void | Promise<void>) | undefined;
|
|
162
162
|
update?: (({ data }: {
|
package/dist/vue.client.js
CHANGED
|
@@ -30,6 +30,13 @@ var __objRest = (source, exclude) => {
|
|
|
30
30
|
return target;
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
+
// src/client.ts
|
|
34
|
+
import {
|
|
35
|
+
defineRender,
|
|
36
|
+
getComponentDescriptor
|
|
37
|
+
} from "@web-widget/schema/client-helpers";
|
|
38
|
+
import { createApp, createSSRApp } from "vue";
|
|
39
|
+
|
|
33
40
|
// src/web-widget.ts
|
|
34
41
|
import { parse } from "@web-widget/web-widget";
|
|
35
42
|
import { h, defineComponent, Suspense, useAttrs } from "vue";
|
|
@@ -135,8 +142,6 @@ function defineWebWidget(loader, options) {
|
|
|
135
142
|
}
|
|
136
143
|
|
|
137
144
|
// src/client.ts
|
|
138
|
-
import { createApp, createSSRApp } from "vue";
|
|
139
|
-
import { defineRender } from "@web-widget/schema/client-helpers";
|
|
140
145
|
export * from "@web-widget/schema/client-helpers";
|
|
141
146
|
Reflect.defineProperty(__ENV__, "server", {
|
|
142
147
|
value: false
|
|
@@ -146,7 +151,9 @@ var defineVueRender = ({
|
|
|
146
151
|
},
|
|
147
152
|
onPrefetchData
|
|
148
153
|
} = {}) => {
|
|
149
|
-
return defineRender(async (context
|
|
154
|
+
return defineRender(async (context) => {
|
|
155
|
+
const componentDescriptor = getComponentDescriptor(context);
|
|
156
|
+
const { component, props } = componentDescriptor;
|
|
150
157
|
if (!context.container) {
|
|
151
158
|
throw new Error(`Container required.`);
|
|
152
159
|
}
|
package/dist/vue.server.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as _web_widget_schema from '@web-widget/schema';
|
|
2
2
|
import { RenderContext, ComponentProps } from '@web-widget/schema';
|
|
3
|
+
import { SSRContext } from 'vue/server-renderer';
|
|
3
4
|
import * as vue from 'vue';
|
|
4
5
|
import { PropType, VNode, Component, App } from 'vue';
|
|
5
6
|
export * from '@web-widget/schema/server-helpers';
|
|
@@ -143,7 +144,10 @@ interface DefineVueRenderOptions {
|
|
|
143
144
|
onPrefetchData?: (context: RenderContext, component: Component, props: ComponentProps) => Promise<JSONProps>;
|
|
144
145
|
}
|
|
145
146
|
|
|
146
|
-
|
|
147
|
-
|
|
147
|
+
interface VueRenderOptions {
|
|
148
|
+
vue?: SSRContext;
|
|
149
|
+
}
|
|
150
|
+
declare const defineVueRender: ({ onCreatedApp, onPrefetchData, }?: DefineVueRenderOptions) => (context: _web_widget_schema.ServerWidgetRenderContext<unknown> | _web_widget_schema.ServerRouteRenderContext<unknown, Record<string, string>>, renderOptions: ResponseInit & VueRenderOptions) => Promise<string | ReadableStream<any> | ReadableStream<any>>;
|
|
151
|
+
declare const render: (context: _web_widget_schema.ServerWidgetRenderContext<unknown> | _web_widget_schema.ServerRouteRenderContext<unknown, Record<string, string>>, renderOptions: ResponseInit & VueRenderOptions) => Promise<string | ReadableStream<any> | ReadableStream<any>>;
|
|
148
152
|
|
|
149
|
-
export { DefineWebWidgetOptions, WebWidget, __ENV__, defineVueRender, defineWebWidget, render };
|
|
153
|
+
export { DefineWebWidgetOptions, VueRenderOptions, WebWidget, __ENV__, defineVueRender, defineWebWidget, render };
|
package/dist/vue.server.js
CHANGED
|
@@ -30,6 +30,14 @@ var __objRest = (source, exclude) => {
|
|
|
30
30
|
return target;
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
+
// src/server.ts
|
|
34
|
+
import {
|
|
35
|
+
defineRender,
|
|
36
|
+
getComponentDescriptor
|
|
37
|
+
} from "@web-widget/schema/server-helpers";
|
|
38
|
+
import { Fragment, createSSRApp, h as h2 } from "vue";
|
|
39
|
+
import { renderToWebStream } from "vue/server-renderer";
|
|
40
|
+
|
|
33
41
|
// src/web-widget.ts
|
|
34
42
|
import { parse } from "@web-widget/web-widget";
|
|
35
43
|
import { h, defineComponent, Suspense, useAttrs } from "vue";
|
|
@@ -135,9 +143,6 @@ function defineWebWidget(loader, options) {
|
|
|
135
143
|
}
|
|
136
144
|
|
|
137
145
|
// src/server.ts
|
|
138
|
-
import { createSSRApp, h as h2, Fragment } from "vue";
|
|
139
|
-
import { defineRender } from "@web-widget/schema/server-helpers";
|
|
140
|
-
import { renderToWebStream } from "vue/server-renderer";
|
|
141
146
|
export * from "@web-widget/schema/server-helpers";
|
|
142
147
|
Reflect.defineProperty(__ENV__, "server", {
|
|
143
148
|
value: true
|
|
@@ -157,28 +162,32 @@ var defineVueRender = ({
|
|
|
157
162
|
},
|
|
158
163
|
onPrefetchData
|
|
159
164
|
} = {}) => {
|
|
160
|
-
return defineRender(
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
const
|
|
165
|
-
const
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
165
|
+
return defineRender(
|
|
166
|
+
async (context, { vue: ssrContext } = {}) => {
|
|
167
|
+
const componentDescriptor = getComponentDescriptor(context);
|
|
168
|
+
const { component, props } = componentDescriptor;
|
|
169
|
+
const state = onPrefetchData ? await onPrefetchData(context, component, props) : void 0;
|
|
170
|
+
const mergedProps = state ? Object.assign({}, state, props) : props;
|
|
171
|
+
if (state) {
|
|
172
|
+
const stateStringify = htmlEscapeJsonString(JSON.stringify(state));
|
|
173
|
+
const vNode = h2(Fragment, null, [
|
|
174
|
+
h2(component, mergedProps),
|
|
175
|
+
h2("script", {
|
|
176
|
+
as: "state",
|
|
177
|
+
type: "application/json",
|
|
178
|
+
innerHTML: stateStringify
|
|
179
|
+
})
|
|
180
|
+
]);
|
|
181
|
+
const app = createSSRApp(vNode);
|
|
182
|
+
onCreatedApp(app, context, component, mergedProps);
|
|
183
|
+
return renderToWebStream(app, ssrContext);
|
|
184
|
+
} else {
|
|
185
|
+
const app = createSSRApp(component, mergedProps);
|
|
186
|
+
onCreatedApp(app, context, component, mergedProps);
|
|
187
|
+
return renderToWebStream(app, ssrContext);
|
|
188
|
+
}
|
|
180
189
|
}
|
|
181
|
-
|
|
190
|
+
);
|
|
182
191
|
};
|
|
183
192
|
var render = defineVueRender();
|
|
184
193
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@web-widget/vue",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
"dist"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@web-widget/vite": "
|
|
31
|
-
"@web-widget/html": "0.
|
|
32
|
-
"@web-widget/schema": "0.
|
|
33
|
-
"@web-widget/web-widget": "1.0.0
|
|
30
|
+
"@web-widget/vite": "2.0.1",
|
|
31
|
+
"@web-widget/html": "0.1.1",
|
|
32
|
+
"@web-widget/schema": "0.1.1",
|
|
33
|
+
"@web-widget/web-widget": "1.0.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"tsup": "^7.0.0",
|