@poveste/plugin-vue 0.6.1 → 0.8.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.
- package/dist/bundled/client/app/host.js +20 -15
- package/dist/client/app/index.d.ts +2 -2
- package/package.json +32 -6
- package/src/client/app/Story.ts +1 -1
- package/src/client/app/auto-props.ts +1 -1
- package/src/client/app/global-components.ts +2 -2
- package/src/client/app/host.ts +13 -2
- package/src/client/app/index.ts +2 -2
- package/src/client/server/Story.ts +1 -1
- package/src/client/server/run.ts +2 -2
- package/tsconfig.build.json +0 -6
- package/tsconfig.json +0 -40
- package/vite.config.ts +0 -79
- package/vitest.config.ts +0 -13
|
@@ -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 };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default as MountStory } from './MountStory';
|
|
2
|
-
export { default as RenderStory } from './RenderStory';
|
|
1
|
+
export { default as MountStory } from './MountStory.js';
|
|
2
|
+
export { default as RenderStory } from './RenderStory.js';
|
package/package.json
CHANGED
|
@@ -1,17 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@poveste/plugin-vue",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.8.0",
|
|
5
5
|
"description": "Poveste plugin for Vue.js support",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Sorin Gitlan"
|
|
8
8
|
},
|
|
9
9
|
"license": "MIT",
|
|
10
|
+
"homepage": "https://poveste.dev",
|
|
10
11
|
"repository": {
|
|
11
12
|
"url": "https://github.com/poveste-dev/poveste.git",
|
|
12
13
|
"type": "git",
|
|
13
14
|
"directory": "packages/poveste-plugin-vue"
|
|
14
15
|
},
|
|
16
|
+
"bugs": "https://github.com/poveste-dev/poveste/issues",
|
|
17
|
+
"keywords": [
|
|
18
|
+
"poveste",
|
|
19
|
+
"histoire",
|
|
20
|
+
"storybook",
|
|
21
|
+
"component-playground",
|
|
22
|
+
"component-explorer",
|
|
23
|
+
"stories",
|
|
24
|
+
"styleguide",
|
|
25
|
+
"design-system",
|
|
26
|
+
"vite",
|
|
27
|
+
"vue",
|
|
28
|
+
"vue3",
|
|
29
|
+
"plugin"
|
|
30
|
+
],
|
|
15
31
|
"publishConfig": {
|
|
16
32
|
"access": "public"
|
|
17
33
|
},
|
|
@@ -42,18 +58,28 @@
|
|
|
42
58
|
},
|
|
43
59
|
"main": "dist/index.js",
|
|
44
60
|
"types": "dist/index.node.d.ts",
|
|
61
|
+
"files": [
|
|
62
|
+
"client.d.ts",
|
|
63
|
+
"collect.d.ts",
|
|
64
|
+
"components.d.ts",
|
|
65
|
+
"dist",
|
|
66
|
+
"src"
|
|
67
|
+
],
|
|
68
|
+
"engines": {
|
|
69
|
+
"node": "^22.22.2 || ^24.15.0 || >=26.0.0"
|
|
70
|
+
},
|
|
45
71
|
"peerDependencies": {
|
|
46
72
|
"vue": "^3.5.26",
|
|
47
|
-
"poveste": "^0.
|
|
73
|
+
"poveste": "^0.8.0"
|
|
48
74
|
},
|
|
49
75
|
"dependencies": {
|
|
50
76
|
"change-case": "^5.4.4",
|
|
51
77
|
"globby": "^14.0.2",
|
|
52
78
|
"launch-editor": "^2.9.1",
|
|
53
79
|
"pathe": "^1.1.2",
|
|
54
|
-
"@poveste/
|
|
55
|
-
"@poveste/shared": "^0.
|
|
56
|
-
"@poveste/
|
|
80
|
+
"@poveste/vendors": "^0.8.0",
|
|
81
|
+
"@poveste/shared": "^0.8.0",
|
|
82
|
+
"@poveste/controls": "^0.8.0"
|
|
57
83
|
},
|
|
58
84
|
"devDependencies": {
|
|
59
85
|
"@types/node": "^22.10.1",
|
|
@@ -62,7 +88,7 @@
|
|
|
62
88
|
"vite": "^8.2.0",
|
|
63
89
|
"vitest": "^4.1.10",
|
|
64
90
|
"vue": "^3.5.26",
|
|
65
|
-
"poveste": "0.
|
|
91
|
+
"poveste": "0.8.0"
|
|
66
92
|
},
|
|
67
93
|
"scripts": {
|
|
68
94
|
"build": "rimraf dist && vite build && tsc -d -P tsconfig.build.json && pnpm run build:types",
|
package/src/client/app/Story.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { PropType, VNode } from 'vue'
|
|
|
3
3
|
import { omitInheritStoryProps } from '@poveste/shared'
|
|
4
4
|
import { cloneVNode, computed, defineComponent, getCurrentInstance, h, isRef, provide, reactive, useAttrs } from 'vue'
|
|
5
5
|
import { useRenderContext } from './render-context.js'
|
|
6
|
-
import Variant from './Variant'
|
|
6
|
+
import Variant from './Variant.js'
|
|
7
7
|
|
|
8
8
|
export default defineComponent({
|
|
9
9
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AutoPropComponentDefinition, PropDefinition, Variant } from '@poveste/shared'
|
|
2
2
|
import { applyState } from '@poveste/shared'
|
|
3
|
-
import { getTagName } from '../codegen'
|
|
3
|
+
import { getTagName } from '../codegen.js'
|
|
4
4
|
|
|
5
5
|
export function syncVariantAutoProps(
|
|
6
6
|
variant: Variant,
|
|
@@ -19,8 +19,8 @@ import {
|
|
|
19
19
|
onUpdated,
|
|
20
20
|
ref,
|
|
21
21
|
} from 'vue'
|
|
22
|
-
import Story from './Story'
|
|
23
|
-
import Variant from './Variant'
|
|
22
|
+
import Story from './Story.js'
|
|
23
|
+
import Variant from './Variant.js'
|
|
24
24
|
|
|
25
25
|
export function registerGlobalComponents(app: App) {
|
|
26
26
|
app.component('Story', Story)
|
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
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
import { VUE_SETUP_HOOK_NAMES } from '../../setup-hooks.js'
|
|
17
17
|
import { registerGlobalComponents } from './global-components.js'
|
|
18
18
|
import { provideRenderContext } from './render-context.js'
|
|
19
|
-
import { RouterLinkStub } from './RouterLinkStub'
|
|
19
|
+
import { RouterLinkStub } from './RouterLinkStub.js'
|
|
20
20
|
|
|
21
21
|
interface PreviewHostOptions {
|
|
22
22
|
name: string
|
|
@@ -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
|
|
package/src/client/app/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default as MountStory } from './MountStory'
|
|
2
|
-
export { default as RenderStory } from './RenderStory'
|
|
1
|
+
export { default as MountStory } from './MountStory.js'
|
|
2
|
+
export { default as RenderStory } from './RenderStory.js'
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ServerStory, ServerStoryFile, ServerVariant } from '@poveste/shared'
|
|
2
2
|
import type { PropType } from 'vue'
|
|
3
3
|
import { defineComponent, inject, onMounted, provide } from 'vue'
|
|
4
|
-
import { autoStubComponents } from './stub'
|
|
4
|
+
import { autoStubComponents } from './stub.js'
|
|
5
5
|
|
|
6
6
|
export default defineComponent({
|
|
7
7
|
name: 'PovesteStory',
|
package/src/client/server/run.ts
CHANGED
|
@@ -7,8 +7,8 @@ import * as generatedSetup from 'virtual:$poveste-generated-global-setup'
|
|
|
7
7
|
import * as setup from 'virtual:$poveste-setup'
|
|
8
8
|
import { createApp, h } from 'vue'
|
|
9
9
|
import { VUE_SETUP_HOOK_NAMES } from '../../setup-hooks.js'
|
|
10
|
-
import Story from './Story'
|
|
11
|
-
import Variant from './Variant'
|
|
10
|
+
import Story from './Story.js'
|
|
11
|
+
import Variant from './Variant.js'
|
|
12
12
|
|
|
13
13
|
export async function run({ file, storyData, el }: ServerRunPayload) {
|
|
14
14
|
const { default: Comp } = await import(/* @vite-ignore */ file.moduleId)
|
package/tsconfig.build.json
DELETED
package/tsconfig.json
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ESNext",
|
|
4
|
-
// Volar
|
|
5
|
-
"jsx": "preserve",
|
|
6
|
-
"lib": [
|
|
7
|
-
"ESNext",
|
|
8
|
-
"DOM"
|
|
9
|
-
],
|
|
10
|
-
"rootDir": "src",
|
|
11
|
-
"module": "ESNext",
|
|
12
|
-
"moduleResolution": "bundler",
|
|
13
|
-
"resolveJsonModule": true,
|
|
14
|
-
"types": [
|
|
15
|
-
"node"
|
|
16
|
-
],
|
|
17
|
-
"strictBindCallApply": true,
|
|
18
|
-
"strictFunctionTypes": true,
|
|
19
|
-
"alwaysStrict": true,
|
|
20
|
-
// Strict
|
|
21
|
-
"noImplicitAny": false,
|
|
22
|
-
"noImplicitThis": true,
|
|
23
|
-
"outDir": "dist",
|
|
24
|
-
"removeComments": false,
|
|
25
|
-
"sourceMap": false,
|
|
26
|
-
"allowSyntheticDefaultImports": true,
|
|
27
|
-
"esModuleInterop": true,
|
|
28
|
-
"skipLibCheck": true,
|
|
29
|
-
"preserveWatchOutput": true
|
|
30
|
-
},
|
|
31
|
-
"include": [
|
|
32
|
-
"src"
|
|
33
|
-
],
|
|
34
|
-
"exclude": [
|
|
35
|
-
"node_modules",
|
|
36
|
-
"generated/**/*",
|
|
37
|
-
"dist/**/*",
|
|
38
|
-
"src/**/*.spec.ts"
|
|
39
|
-
]
|
|
40
|
-
}
|
package/vite.config.ts
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs'
|
|
2
|
-
import { globbySync } from 'globby'
|
|
3
|
-
import { defineConfig } from 'vite'
|
|
4
|
-
|
|
5
|
-
// Externalize every declared dependency/peer so the lib build emits bare
|
|
6
|
-
// specifiers (e.g. `import 'change-case'`) instead of resolved node_modules
|
|
7
|
-
// paths. With preserveModules, an un-externalized npm dep leaks its pnpm-store
|
|
8
|
-
// path (`../node_modules/.pnpm/change-case@x/...`) which only exists in the
|
|
9
|
-
// workspace and breaks every published/fresh install.
|
|
10
|
-
const pkg = JSON.parse(fs.readFileSync(new URL('./package.json', import.meta.url), 'utf-8'))
|
|
11
|
-
|
|
12
|
-
export default defineConfig({
|
|
13
|
-
plugins: [
|
|
14
|
-
{
|
|
15
|
-
name: 'poveste:preserve:import.dynamic',
|
|
16
|
-
enforce: 'pre',
|
|
17
|
-
transform(code) {
|
|
18
|
-
if (code.includes('import(')) {
|
|
19
|
-
return {
|
|
20
|
-
code: code.replace(/import\(/g, 'import__dyn('),
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
closeBundle() {
|
|
25
|
-
try {
|
|
26
|
-
const files = globbySync('./dist/**/*.js')
|
|
27
|
-
for (const file of files) {
|
|
28
|
-
const content = fs.readFileSync(file, 'utf-8')
|
|
29
|
-
if (content.includes('import__dyn')) {
|
|
30
|
-
fs.writeFileSync(file, content.replace(/import__dyn\(/g, 'import(/* @vite-ignore */'), 'utf-8')
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
catch (e) {
|
|
35
|
-
console.error(e)
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
],
|
|
40
|
-
|
|
41
|
-
build: {
|
|
42
|
-
emptyOutDir: false,
|
|
43
|
-
outDir: 'dist/bundled',
|
|
44
|
-
lib: {
|
|
45
|
-
entry: '',
|
|
46
|
-
formats: ['es'],
|
|
47
|
-
},
|
|
48
|
-
rollupOptions: {
|
|
49
|
-
external: [
|
|
50
|
-
/\$poveste/,
|
|
51
|
-
/@poveste/,
|
|
52
|
-
'vue',
|
|
53
|
-
...Object.keys(pkg.dependencies ?? {}),
|
|
54
|
-
...Object.keys(pkg.peerDependencies ?? {}),
|
|
55
|
-
],
|
|
56
|
-
|
|
57
|
-
input: [
|
|
58
|
-
'src/client/client.ts',
|
|
59
|
-
'src/client/server.ts',
|
|
60
|
-
],
|
|
61
|
-
|
|
62
|
-
output: {
|
|
63
|
-
// manualChunks (id) {
|
|
64
|
-
// if (id.includes('node_modules')) {
|
|
65
|
-
// return 'vendor'
|
|
66
|
-
// }
|
|
67
|
-
// },
|
|
68
|
-
entryFileNames: '[name].js',
|
|
69
|
-
chunkFileNames: '[name].js',
|
|
70
|
-
assetFileNames: '[name][extname]',
|
|
71
|
-
// hoistTransitiveImports: false,
|
|
72
|
-
preserveModules: true,
|
|
73
|
-
preserveModulesRoot: 'src',
|
|
74
|
-
},
|
|
75
|
-
treeshake: false,
|
|
76
|
-
preserveEntrySignatures: 'strict',
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
})
|
package/vitest.config.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { fileURLToPath } from 'node:url'
|
|
2
|
-
import { defineConfig } from 'vitest/config'
|
|
3
|
-
|
|
4
|
-
export default defineConfig({
|
|
5
|
-
resolve: {
|
|
6
|
-
alias: {
|
|
7
|
-
// Point at the source, not `dist`. The state-sync tests exist to catch a
|
|
8
|
-
// regression in `applyState`, and resolving the published entry would test
|
|
9
|
-
// whatever was last built instead of what is in the tree.
|
|
10
|
-
'@poveste/shared': fileURLToPath(new URL('../poveste-shared/src/index.ts', import.meta.url)),
|
|
11
|
-
},
|
|
12
|
-
},
|
|
13
|
-
})
|