@poveste/plugin-vue 0.3.2 → 0.4.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 +32 -31
- package/dist/bundled/client/server/run.js +25 -24
- package/dist/bundled/setup-hooks.js +4 -0
- package/dist/helpers.d.ts +8 -1
- package/dist/helpers.js +8 -1
- package/dist/index.node.js +2 -1
- package/dist/setup-hooks.d.ts +12 -0
- package/dist/setup-hooks.js +12 -0
- package/package.json +6 -6
- package/src/client/app/host.ts +3 -2
- package/src/client/server/run.ts +3 -2
- package/src/helpers.ts +9 -1
- package/src/index.node.ts +2 -1
- package/src/setup-hooks.ts +12 -0
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import * as l from "virtual:$poveste-setup";
|
|
1
|
+
import { VUE_SETUP_HOOK_NAMES as e } from "../../setup-hooks.js";
|
|
2
|
+
import { provideRenderContext as t } from "./render-context.js";
|
|
3
|
+
import { registerGlobalComponents as n } from "./global-components.js";
|
|
4
|
+
import { RouterLinkStub as r } from "./RouterLinkStub.js";
|
|
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 l from "virtual:$poveste-generated-global-setup";
|
|
8
|
+
import * as u from "virtual:$poveste-setup";
|
|
8
9
|
//#region src/client/app/host.ts
|
|
9
|
-
var
|
|
10
|
+
var d = o({
|
|
10
11
|
name: "PreviewHostRoot",
|
|
11
12
|
props: {
|
|
12
13
|
story: {
|
|
@@ -18,59 +19,59 @@ var u = a({
|
|
|
18
19
|
required: !0
|
|
19
20
|
}
|
|
20
21
|
},
|
|
21
|
-
setup(
|
|
22
|
-
return e
|
|
22
|
+
setup(e) {
|
|
23
|
+
return t(e.renderContext), () => s(e.story.file.component, { story: e.story });
|
|
23
24
|
}
|
|
24
25
|
});
|
|
25
|
-
function
|
|
26
|
-
let
|
|
26
|
+
function f(e) {
|
|
27
|
+
let t = null, o = null;
|
|
27
28
|
async function c() {
|
|
28
29
|
let c = [];
|
|
29
|
-
|
|
30
|
+
o = document.createElement("div"), e.el.appendChild(o), t = a({
|
|
30
31
|
name: e.name,
|
|
31
32
|
render: () => {
|
|
32
|
-
let t =
|
|
33
|
+
let t = s(d, {
|
|
33
34
|
story: e.getStory(),
|
|
34
35
|
renderContext: e.renderContext
|
|
35
36
|
});
|
|
36
37
|
for (let n of c) {
|
|
37
38
|
let r = t;
|
|
38
|
-
t =
|
|
39
|
+
t = s(n, {
|
|
39
40
|
story: e.getStory(),
|
|
40
41
|
variant: e.getVariant()
|
|
41
42
|
}, () => r);
|
|
42
43
|
}
|
|
43
|
-
return e.wrapInDiv && (t =
|
|
44
|
+
return e.wrapInDiv && (t = s("div", t)), s(i, {}, t);
|
|
44
45
|
}
|
|
45
|
-
}), t
|
|
46
|
-
app:
|
|
46
|
+
}), n(t), t.component("RouterLink", r), await p({
|
|
47
|
+
app: t,
|
|
47
48
|
story: e.getStory(),
|
|
48
49
|
variant: e.getVariant(),
|
|
49
50
|
addWrapper: (e) => {
|
|
50
51
|
c.unshift(e);
|
|
51
52
|
}
|
|
52
|
-
}),
|
|
53
|
+
}), t.mount(o);
|
|
53
54
|
}
|
|
54
55
|
function l() {
|
|
55
|
-
|
|
56
|
+
t?.unmount(), t = null, o &&= (o.parentNode?.removeChild(o), null);
|
|
56
57
|
}
|
|
57
|
-
function
|
|
58
|
-
|
|
58
|
+
function u() {
|
|
59
|
+
t?._instance?.proxy?.$forceUpdate();
|
|
59
60
|
}
|
|
60
61
|
return {
|
|
61
62
|
mount: c,
|
|
62
63
|
unmount: l,
|
|
63
|
-
forceUpdate:
|
|
64
|
+
forceUpdate: u
|
|
64
65
|
};
|
|
65
66
|
}
|
|
66
|
-
async function
|
|
67
|
-
let
|
|
68
|
-
|
|
69
|
-
let
|
|
70
|
-
if (
|
|
71
|
-
let
|
|
72
|
-
await t
|
|
67
|
+
async function p(t) {
|
|
68
|
+
let n = c(l, e);
|
|
69
|
+
n && await n(t);
|
|
70
|
+
let r = c(u, e);
|
|
71
|
+
if (r && await r(t), typeof t.variant?.setupApp == "function") {
|
|
72
|
+
let e = t.variant.setupApp;
|
|
73
|
+
await e(t);
|
|
73
74
|
}
|
|
74
75
|
}
|
|
75
76
|
//#endregion
|
|
76
|
-
export {
|
|
77
|
+
export { f as createPreviewHost };
|
|
@@ -1,43 +1,44 @@
|
|
|
1
|
-
import e from "
|
|
2
|
-
import t from "./
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import * as o from "virtual:$poveste-setup";
|
|
1
|
+
import { VUE_SETUP_HOOK_NAMES as e } from "../../setup-hooks.js";
|
|
2
|
+
import t from "./Story.js";
|
|
3
|
+
import n from "./Variant.js";
|
|
4
|
+
import { createApp as r, h as i } from "vue";
|
|
5
|
+
import { getSetupHook as a } from "@poveste/shared";
|
|
6
|
+
import * as o from "virtual:$poveste-generated-global-setup";
|
|
7
|
+
import * as s from "virtual:$poveste-setup";
|
|
7
8
|
//#region src/client/server/run.ts
|
|
8
|
-
async function
|
|
9
|
-
let { default:
|
|
9
|
+
async function c({ file: c, storyData: l, el: u }) {
|
|
10
|
+
let { default: d } = await import(/* @vite-ignore */
|
|
10
11
|
/* @vite-ignore */
|
|
11
|
-
|
|
12
|
-
),
|
|
12
|
+
c.moduleId
|
|
13
|
+
), f = r({
|
|
13
14
|
provide: {
|
|
14
15
|
addStory(e) {
|
|
15
|
-
|
|
16
|
+
l.push(e);
|
|
16
17
|
},
|
|
17
|
-
hstStoryFile:
|
|
18
|
+
hstStoryFile: c
|
|
18
19
|
},
|
|
19
20
|
render() {
|
|
20
|
-
return
|
|
21
|
+
return i(d);
|
|
21
22
|
}
|
|
22
23
|
});
|
|
23
|
-
|
|
24
|
-
let
|
|
25
|
-
app:
|
|
24
|
+
f.component("Story", t), f.component("Variant", n);
|
|
25
|
+
let p = {
|
|
26
|
+
app: f,
|
|
26
27
|
story: null,
|
|
27
28
|
variant: null,
|
|
28
29
|
addWrapper: () => {}
|
|
29
|
-
},
|
|
30
|
-
|
|
31
|
-
let
|
|
32
|
-
if (
|
|
30
|
+
}, m = a(o, e);
|
|
31
|
+
m && await m(p);
|
|
32
|
+
let h = a(s, e);
|
|
33
|
+
if (h && await h(p), f.mount(u), d.doc) {
|
|
33
34
|
let e = document.createElement("div");
|
|
34
|
-
e.innerHTML =
|
|
35
|
+
e.innerHTML = d.doc;
|
|
35
36
|
let t = e.textContent;
|
|
36
|
-
|
|
37
|
+
l.forEach((e) => {
|
|
37
38
|
e.docsText = t;
|
|
38
39
|
});
|
|
39
40
|
}
|
|
40
|
-
|
|
41
|
+
f.unmount();
|
|
41
42
|
}
|
|
42
43
|
//#endregion
|
|
43
|
-
export {
|
|
44
|
+
export { c as run };
|
package/dist/helpers.d.ts
CHANGED
|
@@ -7,4 +7,11 @@ export interface Vue3StorySetupApi {
|
|
|
7
7
|
addWrapper: (wrapper: Component) => void;
|
|
8
8
|
}
|
|
9
9
|
export type Vue3StorySetupHandler = (api: Vue3StorySetupApi) => Promise<void> | void;
|
|
10
|
-
export declare function
|
|
10
|
+
export declare function defineSetupVue(handler: Vue3StorySetupHandler): Vue3StorySetupHandler;
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated Renamed to {@link defineSetupVue}, and rename the exported hook
|
|
13
|
+
* from `setupVue3` to `setupVue` at the same time. Both spellings work for the
|
|
14
|
+
* whole of 0.x; the numbered pair is a candidate for removal at 1.0, which is
|
|
15
|
+
* the only release allowed to drop them (#135).
|
|
16
|
+
*/
|
|
17
|
+
export declare const defineSetupVue3: typeof defineSetupVue;
|
package/dist/helpers.js
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
-
export function
|
|
1
|
+
export function defineSetupVue(handler) {
|
|
2
2
|
return handler;
|
|
3
3
|
}
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated Renamed to {@link defineSetupVue}, and rename the exported hook
|
|
6
|
+
* from `setupVue3` to `setupVue` at the same time. Both spellings work for the
|
|
7
|
+
* whole of 0.x; the numbered pair is a candidate for removal at 1.0, which is
|
|
8
|
+
* the only release allowed to drop them (#135).
|
|
9
|
+
*/
|
|
10
|
+
export const defineSetupVue3 = defineSetupVue;
|
package/dist/index.node.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import generateStoryCommand from './commands/generate-story.server.js';
|
|
2
|
+
import { VUE_SETUP_HOOK_NAMES } from './setup-hooks.js';
|
|
2
3
|
import { listComponentFiles } from './util/list-components.js';
|
|
3
4
|
export function HstVue() {
|
|
4
5
|
return {
|
|
@@ -35,7 +36,7 @@ export function HstVue() {
|
|
|
35
36
|
supportPlugin: {
|
|
36
37
|
id: 'vue3',
|
|
37
38
|
moduleName: '@poveste/plugin-vue',
|
|
38
|
-
setupFn:
|
|
39
|
+
setupFn: VUE_SETUP_HOOK_NAMES,
|
|
39
40
|
importStoriesPrepend: `import { defineAsyncComponent as defineAsyncComponentVue3 } from 'vue'`,
|
|
40
41
|
importStoryComponent: (file, index) => `const Comp${index} = defineAsyncComponentVue3(() => import(${JSON.stringify(file.moduleId)}))`,
|
|
41
42
|
},
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The names a Vue setup file may export, most established first.
|
|
3
|
+
*
|
|
4
|
+
* `setupVue3` is what users have written in `poveste.setup.ts` since histoire,
|
|
5
|
+
* so it can never be removed without a major. `setupVue` is the unnumbered name
|
|
6
|
+
* new docs use — added as an alias rather than a rename, which is the only way
|
|
7
|
+
* to introduce it without breaking every existing setup file (#135).
|
|
8
|
+
*
|
|
9
|
+
* Order is load-bearing: `getSetupHook` runs the first one present, so a file
|
|
10
|
+
* that already exports `setupVue3` behaves exactly as before.
|
|
11
|
+
*/
|
|
12
|
+
export declare const VUE_SETUP_HOOK_NAMES: string[];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The names a Vue setup file may export, most established first.
|
|
3
|
+
*
|
|
4
|
+
* `setupVue3` is what users have written in `poveste.setup.ts` since histoire,
|
|
5
|
+
* so it can never be removed without a major. `setupVue` is the unnumbered name
|
|
6
|
+
* new docs use — added as an alias rather than a rename, which is the only way
|
|
7
|
+
* to introduce it without breaking every existing setup file (#135).
|
|
8
|
+
*
|
|
9
|
+
* Order is load-bearing: `getSetupHook` runs the first one present, so a file
|
|
10
|
+
* that already exports `setupVue3` behaves exactly as before.
|
|
11
|
+
*/
|
|
12
|
+
export const VUE_SETUP_HOOK_NAMES = ['setupVue3', 'setupVue'];
|
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.4.0",
|
|
5
5
|
"description": "Poveste plugin for Vue.js support",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Sorin Gitlan"
|
|
@@ -44,16 +44,16 @@
|
|
|
44
44
|
"types": "dist/index.node.d.ts",
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"vue": "^3.5.26",
|
|
47
|
-
"poveste": "^0.
|
|
47
|
+
"poveste": "^0.4.0"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"change-case": "^5.4.4",
|
|
51
51
|
"globby": "^14.0.2",
|
|
52
52
|
"launch-editor": "^2.9.1",
|
|
53
53
|
"pathe": "^1.1.2",
|
|
54
|
-
"@poveste/
|
|
55
|
-
"@poveste/vendors": "^0.
|
|
56
|
-
"@poveste/
|
|
54
|
+
"@poveste/controls": "^0.4.0",
|
|
55
|
+
"@poveste/vendors": "^0.4.0",
|
|
56
|
+
"@poveste/shared": "^0.4.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@types/node": "^22.10.1",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"vite": "^8.2.0",
|
|
63
63
|
"vitest": "^4.1.10",
|
|
64
64
|
"vue": "^3.5.26",
|
|
65
|
-
"poveste": "0.
|
|
65
|
+
"poveste": "0.4.0"
|
|
66
66
|
},
|
|
67
67
|
"scripts": {
|
|
68
68
|
"build": "rimraf dist && vite build && tsc -d -P tsconfig.build.json && pnpm run build:types",
|
package/src/client/app/host.ts
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
h,
|
|
14
14
|
Suspense,
|
|
15
15
|
} from 'vue'
|
|
16
|
+
import { VUE_SETUP_HOOK_NAMES } from '../../setup-hooks.js'
|
|
16
17
|
import { registerGlobalComponents } from './global-components.js'
|
|
17
18
|
import { provideRenderContext } from './render-context.js'
|
|
18
19
|
import { RouterLinkStub } from './RouterLinkStub'
|
|
@@ -124,12 +125,12 @@ export function createPreviewHost(options: PreviewHostOptions) {
|
|
|
124
125
|
}
|
|
125
126
|
|
|
126
127
|
async function runSetupHooks(setupApi: Vue3StorySetupApi) {
|
|
127
|
-
const generatedSetupFn = getSetupHook<Vue3StorySetupHandler>(generatedSetup,
|
|
128
|
+
const generatedSetupFn = getSetupHook<Vue3StorySetupHandler>(generatedSetup, VUE_SETUP_HOOK_NAMES)
|
|
128
129
|
if (generatedSetupFn) {
|
|
129
130
|
await generatedSetupFn(setupApi)
|
|
130
131
|
}
|
|
131
132
|
|
|
132
|
-
const setupFn = getSetupHook<Vue3StorySetupHandler>(setup,
|
|
133
|
+
const setupFn = getSetupHook<Vue3StorySetupHandler>(setup, VUE_SETUP_HOOK_NAMES)
|
|
133
134
|
if (setupFn) {
|
|
134
135
|
await setupFn(setupApi)
|
|
135
136
|
}
|
package/src/client/server/run.ts
CHANGED
|
@@ -6,6 +6,7 @@ import * as generatedSetup from 'virtual:$poveste-generated-global-setup'
|
|
|
6
6
|
// @ts-expect-error virtual module id
|
|
7
7
|
import * as setup from 'virtual:$poveste-setup'
|
|
8
8
|
import { createApp, h } from 'vue'
|
|
9
|
+
import { VUE_SETUP_HOOK_NAMES } from '../../setup-hooks.js'
|
|
9
10
|
import Story from './Story'
|
|
10
11
|
import Variant from './Variant'
|
|
11
12
|
|
|
@@ -37,12 +38,12 @@ export async function run({ file, storyData, el }: ServerRunPayload) {
|
|
|
37
38
|
addWrapper: () => { /* noop */ },
|
|
38
39
|
}
|
|
39
40
|
|
|
40
|
-
const generatedSetupFn = getSetupHook<Vue3StorySetupHandler>(generatedSetup,
|
|
41
|
+
const generatedSetupFn = getSetupHook<Vue3StorySetupHandler>(generatedSetup, VUE_SETUP_HOOK_NAMES)
|
|
41
42
|
if (generatedSetupFn) {
|
|
42
43
|
await generatedSetupFn(setupApi)
|
|
43
44
|
}
|
|
44
45
|
|
|
45
|
-
const setupFn = getSetupHook<Vue3StorySetupHandler>(setup,
|
|
46
|
+
const setupFn = getSetupHook<Vue3StorySetupHandler>(setup, VUE_SETUP_HOOK_NAMES)
|
|
46
47
|
if (setupFn) {
|
|
47
48
|
await setupFn(setupApi)
|
|
48
49
|
}
|
package/src/helpers.ts
CHANGED
|
@@ -10,6 +10,14 @@ export interface Vue3StorySetupApi {
|
|
|
10
10
|
|
|
11
11
|
export type Vue3StorySetupHandler = (api: Vue3StorySetupApi) => Promise<void> | void
|
|
12
12
|
|
|
13
|
-
export function
|
|
13
|
+
export function defineSetupVue(handler: Vue3StorySetupHandler): Vue3StorySetupHandler {
|
|
14
14
|
return handler
|
|
15
15
|
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @deprecated Renamed to {@link defineSetupVue}, and rename the exported hook
|
|
19
|
+
* from `setupVue3` to `setupVue` at the same time. Both spellings work for the
|
|
20
|
+
* whole of 0.x; the numbered pair is a candidate for removal at 1.0, which is
|
|
21
|
+
* the only release allowed to drop them (#135).
|
|
22
|
+
*/
|
|
23
|
+
export const defineSetupVue3 = defineSetupVue
|
package/src/index.node.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Plugin } from 'poveste'
|
|
2
2
|
|
|
3
3
|
import generateStoryCommand from './commands/generate-story.server.js'
|
|
4
|
+
import { VUE_SETUP_HOOK_NAMES } from './setup-hooks.js'
|
|
4
5
|
import { listComponentFiles } from './util/list-components.js'
|
|
5
6
|
|
|
6
7
|
export function HstVue(): Plugin {
|
|
@@ -41,7 +42,7 @@ export function HstVue(): Plugin {
|
|
|
41
42
|
supportPlugin: {
|
|
42
43
|
id: 'vue3',
|
|
43
44
|
moduleName: '@poveste/plugin-vue',
|
|
44
|
-
setupFn:
|
|
45
|
+
setupFn: VUE_SETUP_HOOK_NAMES,
|
|
45
46
|
importStoriesPrepend: `import { defineAsyncComponent as defineAsyncComponentVue3 } from 'vue'`,
|
|
46
47
|
importStoryComponent: (file, index) => `const Comp${index} = defineAsyncComponentVue3(() => import(${JSON.stringify(file.moduleId)}))`,
|
|
47
48
|
},
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The names a Vue setup file may export, most established first.
|
|
3
|
+
*
|
|
4
|
+
* `setupVue3` is what users have written in `poveste.setup.ts` since histoire,
|
|
5
|
+
* so it can never be removed without a major. `setupVue` is the unnumbered name
|
|
6
|
+
* new docs use — added as an alias rather than a rename, which is the only way
|
|
7
|
+
* to introduce it without breaking every existing setup file (#135).
|
|
8
|
+
*
|
|
9
|
+
* Order is load-bearing: `getSetupHook` runs the first one present, so a file
|
|
10
|
+
* that already exports `setupVue3` behaves exactly as before.
|
|
11
|
+
*/
|
|
12
|
+
export const VUE_SETUP_HOOK_NAMES = ['setupVue3', 'setupVue']
|