@poveste/plugin-vue 0.7.0 → 0.8.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/bundled/client/app/host.js +20 -15
- package/package.json +6 -6
- package/src/client/app/host.ts +12 -1
|
@@ -3,11 +3,11 @@ import { provideRenderContext as t } from "./render-context.js";
|
|
|
3
3
|
import { registerGlobalComponents as n } from "./global-components.js";
|
|
4
4
|
import { RouterLinkStub as r } from "./RouterLinkStub.js";
|
|
5
5
|
import { Suspense as i, createApp as a, defineComponent as o, h as s } from "vue";
|
|
6
|
-
import { getSetupHook as c } from "@poveste/shared";
|
|
7
|
-
import * as
|
|
8
|
-
import * as
|
|
6
|
+
import { getSetupHook as c, reportStoryError as l } from "@poveste/shared";
|
|
7
|
+
import * as u from "virtual:$poveste-generated-global-setup";
|
|
8
|
+
import * as d from "virtual:$poveste-setup";
|
|
9
9
|
//#region src/client/app/host.ts
|
|
10
|
-
var
|
|
10
|
+
var f = o({
|
|
11
11
|
name: "PreviewHostRoot",
|
|
12
12
|
props: {
|
|
13
13
|
story: {
|
|
@@ -23,14 +23,14 @@ var d = o({
|
|
|
23
23
|
return t(e.renderContext), () => s(e.story.file.component, { story: e.story });
|
|
24
24
|
}
|
|
25
25
|
});
|
|
26
|
-
function
|
|
26
|
+
function p(e) {
|
|
27
27
|
let t = null, o = null;
|
|
28
28
|
async function c() {
|
|
29
29
|
let c = [];
|
|
30
30
|
o = document.createElement("div"), e.el.appendChild(o), t = a({
|
|
31
31
|
name: e.name,
|
|
32
32
|
render: () => {
|
|
33
|
-
let t = s(
|
|
33
|
+
let t = s(f, {
|
|
34
34
|
story: e.getStory(),
|
|
35
35
|
renderContext: e.renderContext
|
|
36
36
|
});
|
|
@@ -43,7 +43,12 @@ function f(e) {
|
|
|
43
43
|
}
|
|
44
44
|
return e.wrapInDiv && (t = s("div", t)), s(i, {}, t);
|
|
45
45
|
}
|
|
46
|
-
}),
|
|
46
|
+
}), t.config.errorHandler = (t) => {
|
|
47
|
+
l(t, {
|
|
48
|
+
storyId: e.getStory()?.id,
|
|
49
|
+
variantId: e.getVariant()?.id
|
|
50
|
+
}), console.error(t);
|
|
51
|
+
}, n(t), t.component("RouterLink", r), await m({
|
|
47
52
|
app: t,
|
|
48
53
|
story: e.getStory(),
|
|
49
54
|
variant: e.getVariant(),
|
|
@@ -52,26 +57,26 @@ function f(e) {
|
|
|
52
57
|
}
|
|
53
58
|
}), t.mount(o);
|
|
54
59
|
}
|
|
55
|
-
function
|
|
60
|
+
function u() {
|
|
56
61
|
t?.unmount(), t = null, o &&= (o.parentNode?.removeChild(o), null);
|
|
57
62
|
}
|
|
58
|
-
function
|
|
63
|
+
function d() {
|
|
59
64
|
t?._instance?.proxy?.$forceUpdate();
|
|
60
65
|
}
|
|
61
66
|
return {
|
|
62
67
|
mount: c,
|
|
63
|
-
unmount:
|
|
64
|
-
forceUpdate:
|
|
68
|
+
unmount: u,
|
|
69
|
+
forceUpdate: d
|
|
65
70
|
};
|
|
66
71
|
}
|
|
67
|
-
async function
|
|
68
|
-
let n = c(
|
|
72
|
+
async function m(t) {
|
|
73
|
+
let n = c(u, e);
|
|
69
74
|
n && await n(t);
|
|
70
|
-
let r = c(
|
|
75
|
+
let r = c(d, e);
|
|
71
76
|
if (r && await r(t), typeof t.variant?.setupApp == "function") {
|
|
72
77
|
let e = t.variant.setupApp;
|
|
73
78
|
await e(t);
|
|
74
79
|
}
|
|
75
80
|
}
|
|
76
81
|
//#endregion
|
|
77
|
-
export {
|
|
82
|
+
export { p as createPreviewHost };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@poveste/plugin-vue",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.8.1",
|
|
5
5
|
"description": "Poveste plugin for Vue.js support",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Sorin Gitlan"
|
|
@@ -70,16 +70,16 @@
|
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
72
|
"vue": "^3.5.26",
|
|
73
|
-
"poveste": "^0.
|
|
73
|
+
"poveste": "^0.8.1"
|
|
74
74
|
},
|
|
75
75
|
"dependencies": {
|
|
76
76
|
"change-case": "^5.4.4",
|
|
77
77
|
"globby": "^14.0.2",
|
|
78
78
|
"launch-editor": "^2.9.1",
|
|
79
79
|
"pathe": "^1.1.2",
|
|
80
|
-
"@poveste/controls": "^0.
|
|
81
|
-
"@poveste/
|
|
82
|
-
"@poveste/
|
|
80
|
+
"@poveste/controls": "^0.8.1",
|
|
81
|
+
"@poveste/shared": "^0.8.1",
|
|
82
|
+
"@poveste/vendors": "^0.8.1"
|
|
83
83
|
},
|
|
84
84
|
"devDependencies": {
|
|
85
85
|
"@types/node": "^22.10.1",
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"vite": "^8.2.0",
|
|
89
89
|
"vitest": "^4.1.10",
|
|
90
90
|
"vue": "^3.5.26",
|
|
91
|
-
"poveste": "0.
|
|
91
|
+
"poveste": "0.8.1"
|
|
92
92
|
},
|
|
93
93
|
"scripts": {
|
|
94
94
|
"build": "rimraf dist && vite build && tsc -d -P tsconfig.build.json && pnpm run build:types",
|
package/src/client/app/host.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { Story, Variant } from '@poveste/shared'
|
|
|
2
2
|
import type { App, Component, PropType, VNode } from 'vue'
|
|
3
3
|
import type { Vue3StorySetupApi, Vue3StorySetupHandler } from '../../helpers.js'
|
|
4
4
|
import type { PreviewRenderContext } from './render-context.js'
|
|
5
|
-
import { getSetupHook } from '@poveste/shared'
|
|
5
|
+
import { getSetupHook, reportStoryError } from '@poveste/shared'
|
|
6
6
|
// @ts-expect-error virtual module id
|
|
7
7
|
import * as generatedSetup from 'virtual:$poveste-generated-global-setup'
|
|
8
8
|
// @ts-expect-error virtual module id
|
|
@@ -86,6 +86,17 @@ export function createPreviewHost(options: PreviewHostOptions) {
|
|
|
86
86
|
},
|
|
87
87
|
})
|
|
88
88
|
|
|
89
|
+
// Vue catches a throw from setup or render and logs it to `console.error`,
|
|
90
|
+
// leaving the template on screen — so without this the host cannot tell a
|
|
91
|
+
// broken story from a working one (#323).
|
|
92
|
+
app.config.errorHandler = (err) => {
|
|
93
|
+
reportStoryError(err, {
|
|
94
|
+
storyId: options.getStory()?.id,
|
|
95
|
+
variantId: options.getVariant()?.id,
|
|
96
|
+
})
|
|
97
|
+
console.error(err)
|
|
98
|
+
}
|
|
99
|
+
|
|
89
100
|
registerGlobalComponents(app)
|
|
90
101
|
app.component('RouterLink', RouterLinkStub)
|
|
91
102
|
|