@poveste/plugin-vue 0.1.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/LICENSE +22 -0
- package/client.d.ts +2 -0
- package/collect.d.ts +2 -0
- package/components.d.ts +239 -0
- package/dist/bundled/client/app/MountStory.js +55 -0
- package/dist/bundled/client/app/RenderStory.js +74 -0
- package/dist/bundled/client/app/RouterLinkStub.js +40 -0
- package/dist/bundled/client/app/Story.js +112 -0
- package/dist/bundled/client/app/Variant.js +104 -0
- package/dist/bundled/client/app/auto-props.js +66 -0
- package/dist/bundled/client/app/global-components.js +81 -0
- package/dist/bundled/client/app/host.js +84 -0
- package/dist/bundled/client/app/index.js +6 -0
- package/dist/bundled/client/app/render-context.js +12 -0
- package/dist/bundled/client/app/util.js +70 -0
- package/dist/bundled/client/client.js +10 -0
- package/dist/bundled/client/codegen.js +196 -0
- package/dist/bundled/client/server/Story.js +79 -0
- package/dist/bundled/client/server/Variant.js +46 -0
- package/dist/bundled/client/server/run.js +51 -0
- package/dist/bundled/client/server/stub.js +8 -0
- package/dist/bundled/client/server.js +4 -0
- package/dist/bundled/node_modules/.pnpm/change-case@5.4.4/node_modules/change-case/dist/index.js +118 -0
- package/dist/client/app/MountStory.d.ts +16 -0
- package/dist/client/app/RenderStory.d.ts +38 -0
- package/dist/client/app/RouterLinkStub.d.ts +21 -0
- package/dist/client/app/Story.d.ts +33 -0
- package/dist/client/app/Variant.d.ts +78 -0
- package/dist/client/app/auto-props.d.ts +2 -0
- package/dist/client/app/global-components.d.ts +2 -0
- package/dist/client/app/host.d.ts +16 -0
- package/dist/client/app/index.d.ts +2 -0
- package/dist/client/app/render-context.d.ts +12 -0
- package/dist/client/app/util.d.ts +16 -0
- package/dist/client/client.d.ts +7 -0
- package/dist/client/codegen.d.ts +4 -0
- package/dist/client/server/Story.d.ts +81 -0
- package/dist/client/server/Variant.d.ts +52 -0
- package/dist/client/server/run.d.ts +2 -0
- package/dist/client/server/stub.d.ts +1 -0
- package/dist/client/server.d.ts +1 -0
- package/dist/commands/generate-story.client.d.ts +3 -0
- package/dist/commands/generate-story.client.js +27 -0
- package/dist/commands/generate-story.server.d.ts +3 -0
- package/dist/commands/generate-story.server.js +45 -0
- package/dist/helpers.d.ts +10 -0
- package/dist/helpers.js +3 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.node.d.ts +3 -0
- package/dist/index.node.js +54 -0
- package/dist/util/list-components.d.ts +1 -0
- package/dist/util/list-components.js +15 -0
- package/package.json +71 -0
- package/src/client/app/MountStory.ts +83 -0
- package/src/client/app/RenderStory.ts +131 -0
- package/src/client/app/RouterLinkStub.ts +48 -0
- package/src/client/app/Story.ts +209 -0
- package/src/client/app/Variant.ts +196 -0
- package/src/client/app/auto-props.ts +135 -0
- package/src/client/app/global-components.ts +131 -0
- package/src/client/app/host.ts +139 -0
- package/src/client/app/index.ts +2 -0
- package/src/client/app/render-context.ts +23 -0
- package/src/client/app/util.ts +129 -0
- package/src/client/client.ts +8 -0
- package/src/client/codegen.ts +400 -0
- package/src/client/server/Story.ts +121 -0
- package/src/client/server/Variant.ts +56 -0
- package/src/client/server/run.ts +63 -0
- package/src/client/server/stub.ts +12 -0
- package/src/client/server.ts +1 -0
- package/src/commands/generate-story.client.ts +29 -0
- package/src/commands/generate-story.server.ts +55 -0
- package/src/helpers.ts +15 -0
- package/src/index.node.ts +63 -0
- package/src/index.ts +1 -0
- package/src/util/list-components.ts +16 -0
- package/tsconfig.build.json +6 -0
- package/tsconfig.json +40 -0
- package/vite.config.ts +70 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import * as u from "virtual:$histoire-generated-global-setup";
|
|
2
|
+
import * as a from "virtual:$histoire-setup";
|
|
3
|
+
import { createApp as m, h as d } from "vue";
|
|
4
|
+
import f from "./Story.js";
|
|
5
|
+
import l from "./Variant.js";
|
|
6
|
+
async function S({ file: n, storyData: r, el: c }) {
|
|
7
|
+
const { default: e } = await import(/* @vite-ignore */
|
|
8
|
+
/* @vite-ignore */
|
|
9
|
+
n.moduleId
|
|
10
|
+
), o = m({
|
|
11
|
+
provide: {
|
|
12
|
+
addStory(t) {
|
|
13
|
+
r.push(t);
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
render() {
|
|
17
|
+
return d(e, {
|
|
18
|
+
ref: "comp",
|
|
19
|
+
data: n
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
o.component("Story", f), o.component("Variant", l);
|
|
24
|
+
const p = {
|
|
25
|
+
app: o,
|
|
26
|
+
story: null,
|
|
27
|
+
variant: null,
|
|
28
|
+
addWrapper: () => {
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
if (typeof u?.setupVue3 == "function") {
|
|
32
|
+
const t = u.setupVue3;
|
|
33
|
+
await t(p);
|
|
34
|
+
}
|
|
35
|
+
if (typeof a?.setupVue3 == "function") {
|
|
36
|
+
const t = a.setupVue3;
|
|
37
|
+
await t(p);
|
|
38
|
+
}
|
|
39
|
+
if (o.mount(c), e.doc) {
|
|
40
|
+
const t = document.createElement("div");
|
|
41
|
+
t.innerHTML = e.doc;
|
|
42
|
+
const i = t.textContent;
|
|
43
|
+
r.forEach((s) => {
|
|
44
|
+
s.docsText = i;
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
o.unmount();
|
|
48
|
+
}
|
|
49
|
+
export {
|
|
50
|
+
S as run
|
|
51
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const n = { name: "StubbedComponent", render: () => null };
|
|
2
|
+
function o(t) {
|
|
3
|
+
for (const e of t)
|
|
4
|
+
typeof e.type == "object" && e.type.name !== "PovesteVariant" && (e.type = n), Array.isArray(e.children) && o(e.children);
|
|
5
|
+
}
|
|
6
|
+
export {
|
|
7
|
+
o as autoStubComponents
|
|
8
|
+
};
|
package/dist/bundled/node_modules/.pnpm/change-case@5.4.4/node_modules/change-case/dist/index.js
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
const E = new RegExp("([\\p{Ll}\\d])(\\p{Lu})", "gu"), P = new RegExp("(\\p{Lu})([\\p{Lu}][\\p{Ll}])", "gu"), w = new RegExp("(\\d)\\p{Ll}|(\\p{L})\\d", "u"), R = /[^\p{L}\d]+/giu, C = "$1\0$2", x = "";
|
|
2
|
+
function h(r) {
|
|
3
|
+
let e = r.trim();
|
|
4
|
+
e = e.replace(E, C).replace(P, C), e = e.replace(R, "\0");
|
|
5
|
+
let t = 0, c = e.length;
|
|
6
|
+
for (; e.charAt(t) === "\0"; )
|
|
7
|
+
t++;
|
|
8
|
+
if (t === c)
|
|
9
|
+
return [];
|
|
10
|
+
for (; e.charAt(c - 1) === "\0"; )
|
|
11
|
+
c--;
|
|
12
|
+
return e.slice(t, c).split(/\0/g);
|
|
13
|
+
}
|
|
14
|
+
function A(r) {
|
|
15
|
+
const e = h(r);
|
|
16
|
+
for (let t = 0; t < e.length; t++) {
|
|
17
|
+
const c = e[t], n = w.exec(c);
|
|
18
|
+
if (n) {
|
|
19
|
+
const a = n.index + (n[1] ?? n[2]).length;
|
|
20
|
+
e.splice(t, 1, c.slice(0, a), c.slice(a));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return e;
|
|
24
|
+
}
|
|
25
|
+
function p(r, e) {
|
|
26
|
+
const [t, c, n] = u(r, e);
|
|
27
|
+
return t + c.map(f(e?.locale)).join(e?.delimiter ?? " ") + n;
|
|
28
|
+
}
|
|
29
|
+
function g(r, e) {
|
|
30
|
+
const [t, c, n] = u(r, e), a = f(e?.locale), s = o(e?.locale), i = e?.mergeAmbiguousCharacters ? d(a, s) : _(a, s);
|
|
31
|
+
return t + c.map((l, m) => m === 0 ? a(l) : i(l, m)).join(e?.delimiter ?? "") + n;
|
|
32
|
+
}
|
|
33
|
+
function S(r, e) {
|
|
34
|
+
const [t, c, n] = u(r, e), a = f(e?.locale), s = o(e?.locale), i = e?.mergeAmbiguousCharacters ? d(a, s) : _(a, s);
|
|
35
|
+
return t + c.map(i).join(e?.delimiter ?? "") + n;
|
|
36
|
+
}
|
|
37
|
+
function T(r, e) {
|
|
38
|
+
return L(r, { delimiter: "_", ...e });
|
|
39
|
+
}
|
|
40
|
+
function L(r, e) {
|
|
41
|
+
const [t, c, n] = u(r, e), a = f(e?.locale), s = o(e?.locale);
|
|
42
|
+
return t + c.map(d(a, s)).join(e?.delimiter ?? " ") + n;
|
|
43
|
+
}
|
|
44
|
+
function F(r, e) {
|
|
45
|
+
const [t, c, n] = u(r, e);
|
|
46
|
+
return t + c.map(o(e?.locale)).join(e?.delimiter ?? "_") + n;
|
|
47
|
+
}
|
|
48
|
+
function U(r, e) {
|
|
49
|
+
return p(r, { delimiter: ".", ...e });
|
|
50
|
+
}
|
|
51
|
+
function I(r, e) {
|
|
52
|
+
return p(r, { delimiter: "-", ...e });
|
|
53
|
+
}
|
|
54
|
+
function b(r, e) {
|
|
55
|
+
return p(r, { delimiter: "/", ...e });
|
|
56
|
+
}
|
|
57
|
+
function j(r, e) {
|
|
58
|
+
const [t, c, n] = u(r, e), a = f(e?.locale), s = o(e?.locale), i = d(a, s);
|
|
59
|
+
return t + c.map((l, m) => m === 0 ? i(l) : a(l)).join(e?.delimiter ?? " ") + n;
|
|
60
|
+
}
|
|
61
|
+
function k(r, e) {
|
|
62
|
+
return p(r, { delimiter: "_", ...e });
|
|
63
|
+
}
|
|
64
|
+
function y(r, e) {
|
|
65
|
+
return L(r, { delimiter: "-", ...e });
|
|
66
|
+
}
|
|
67
|
+
function f(r) {
|
|
68
|
+
return r === !1 ? (e) => e.toLowerCase() : (e) => e.toLocaleLowerCase(r);
|
|
69
|
+
}
|
|
70
|
+
function o(r) {
|
|
71
|
+
return r === !1 ? (e) => e.toUpperCase() : (e) => e.toLocaleUpperCase(r);
|
|
72
|
+
}
|
|
73
|
+
function d(r, e) {
|
|
74
|
+
return (t) => `${e(t[0])}${r(t.slice(1))}`;
|
|
75
|
+
}
|
|
76
|
+
function _(r, e) {
|
|
77
|
+
return (t, c) => {
|
|
78
|
+
const n = t[0];
|
|
79
|
+
return (c > 0 && n >= "0" && n <= "9" ? "_" + n : e(n)) + r(t.slice(1));
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
function u(r, e = {}) {
|
|
83
|
+
const t = e.split ?? (e.separateNumbers ? A : h), c = e.prefixCharacters ?? x, n = e.suffixCharacters ?? x;
|
|
84
|
+
let a = 0, s = r.length;
|
|
85
|
+
for (; a < r.length; ) {
|
|
86
|
+
const i = r.charAt(a);
|
|
87
|
+
if (!c.includes(i))
|
|
88
|
+
break;
|
|
89
|
+
a++;
|
|
90
|
+
}
|
|
91
|
+
for (; s > a; ) {
|
|
92
|
+
const i = s - 1, l = r.charAt(i);
|
|
93
|
+
if (!n.includes(l))
|
|
94
|
+
break;
|
|
95
|
+
s = i;
|
|
96
|
+
}
|
|
97
|
+
return [
|
|
98
|
+
r.slice(0, a),
|
|
99
|
+
t(r.slice(a, s)),
|
|
100
|
+
r.slice(s)
|
|
101
|
+
];
|
|
102
|
+
}
|
|
103
|
+
export {
|
|
104
|
+
g as camelCase,
|
|
105
|
+
L as capitalCase,
|
|
106
|
+
F as constantCase,
|
|
107
|
+
U as dotCase,
|
|
108
|
+
I as kebabCase,
|
|
109
|
+
p as noCase,
|
|
110
|
+
S as pascalCase,
|
|
111
|
+
T as pascalSnakeCase,
|
|
112
|
+
b as pathCase,
|
|
113
|
+
j as sentenceCase,
|
|
114
|
+
k as snakeCase,
|
|
115
|
+
h as split,
|
|
116
|
+
A as splitSeparateNumbers,
|
|
117
|
+
y as trainCase
|
|
118
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Story } from '@poveste/shared';
|
|
2
|
+
import type { PropType as _PropType } from '@poveste/vendors/vue';
|
|
3
|
+
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
4
|
+
story: {
|
|
5
|
+
type: _PropType<Story>;
|
|
6
|
+
required: true;
|
|
7
|
+
};
|
|
8
|
+
}>, {
|
|
9
|
+
el: import("vue").Ref<HTMLDivElement, HTMLDivElement>;
|
|
10
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
11
|
+
story: {
|
|
12
|
+
type: _PropType<Story>;
|
|
13
|
+
required: true;
|
|
14
|
+
};
|
|
15
|
+
}>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
16
|
+
export default _default;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Story, Variant } from '@poveste/shared';
|
|
2
|
+
import type { PropType as _PropType } from '@poveste/vendors/vue';
|
|
3
|
+
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
4
|
+
variant: {
|
|
5
|
+
type: _PropType<Variant>;
|
|
6
|
+
required: true;
|
|
7
|
+
};
|
|
8
|
+
story: {
|
|
9
|
+
type: _PropType<Story>;
|
|
10
|
+
required: true;
|
|
11
|
+
};
|
|
12
|
+
slotName: {
|
|
13
|
+
type: StringConstructor;
|
|
14
|
+
default: string;
|
|
15
|
+
};
|
|
16
|
+
}>, {
|
|
17
|
+
sandbox: import("vue").Ref<HTMLDivElement, HTMLDivElement>;
|
|
18
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
19
|
+
ready: () => true;
|
|
20
|
+
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
21
|
+
variant: {
|
|
22
|
+
type: _PropType<Variant>;
|
|
23
|
+
required: true;
|
|
24
|
+
};
|
|
25
|
+
story: {
|
|
26
|
+
type: _PropType<Story>;
|
|
27
|
+
required: true;
|
|
28
|
+
};
|
|
29
|
+
slotName: {
|
|
30
|
+
type: StringConstructor;
|
|
31
|
+
default: string;
|
|
32
|
+
};
|
|
33
|
+
}>> & Readonly<{
|
|
34
|
+
onReady?: () => any;
|
|
35
|
+
}>, {
|
|
36
|
+
slotName: string;
|
|
37
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
38
|
+
export default _default;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare const RouterLinkStub: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
2
|
+
to: {
|
|
3
|
+
type: (ObjectConstructor | StringConstructor)[];
|
|
4
|
+
required: true;
|
|
5
|
+
};
|
|
6
|
+
custom: {
|
|
7
|
+
type: BooleanConstructor;
|
|
8
|
+
default: boolean;
|
|
9
|
+
};
|
|
10
|
+
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
11
|
+
to: {
|
|
12
|
+
type: (ObjectConstructor | StringConstructor)[];
|
|
13
|
+
required: true;
|
|
14
|
+
};
|
|
15
|
+
custom: {
|
|
16
|
+
type: BooleanConstructor;
|
|
17
|
+
default: boolean;
|
|
18
|
+
};
|
|
19
|
+
}>> & Readonly<{}>, {
|
|
20
|
+
custom: boolean;
|
|
21
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Story } from '@poveste/shared';
|
|
2
|
+
import type { PropType, VNode } from 'vue';
|
|
3
|
+
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
4
|
+
initState: {
|
|
5
|
+
type: PropType<() => any | Promise<any>>;
|
|
6
|
+
default: any;
|
|
7
|
+
};
|
|
8
|
+
meta: {
|
|
9
|
+
type: PropType<Story["meta"]>;
|
|
10
|
+
default: any;
|
|
11
|
+
};
|
|
12
|
+
}>, {
|
|
13
|
+
renderContext: import("./render-context.js").PreviewRenderContext;
|
|
14
|
+
story: import("vue").ComputedRef<Story>;
|
|
15
|
+
renderMountStory: () => VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
16
|
+
[key: string]: any;
|
|
17
|
+
}>[];
|
|
18
|
+
renderPreviewStory: () => any[];
|
|
19
|
+
updateStory: () => void;
|
|
20
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
21
|
+
initState: {
|
|
22
|
+
type: PropType<() => any | Promise<any>>;
|
|
23
|
+
default: any;
|
|
24
|
+
};
|
|
25
|
+
meta: {
|
|
26
|
+
type: PropType<Story["meta"]>;
|
|
27
|
+
default: any;
|
|
28
|
+
};
|
|
29
|
+
}>> & Readonly<{}>, {
|
|
30
|
+
meta: import("@poveste/shared").StoryMeta;
|
|
31
|
+
initState: () => any | Promise<any>;
|
|
32
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
33
|
+
export default _default;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { Variant } from '@poveste/shared';
|
|
2
|
+
import type { PropType } from 'vue';
|
|
3
|
+
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
4
|
+
initState: {
|
|
5
|
+
type: PropType<() => any | Promise<any>>;
|
|
6
|
+
default: any;
|
|
7
|
+
};
|
|
8
|
+
source: {
|
|
9
|
+
type: StringConstructor;
|
|
10
|
+
default: any;
|
|
11
|
+
};
|
|
12
|
+
responsiveDisabled: {
|
|
13
|
+
type: BooleanConstructor;
|
|
14
|
+
default: boolean;
|
|
15
|
+
};
|
|
16
|
+
autoPropsDisabled: {
|
|
17
|
+
type: BooleanConstructor;
|
|
18
|
+
default: boolean;
|
|
19
|
+
};
|
|
20
|
+
setupApp: {
|
|
21
|
+
type: FunctionConstructor;
|
|
22
|
+
default: any;
|
|
23
|
+
};
|
|
24
|
+
meta: {
|
|
25
|
+
type: PropType<Variant["meta"]>;
|
|
26
|
+
default: any;
|
|
27
|
+
};
|
|
28
|
+
implicit: {
|
|
29
|
+
type: BooleanConstructor;
|
|
30
|
+
default: boolean;
|
|
31
|
+
};
|
|
32
|
+
}>, {
|
|
33
|
+
renderContext: import("./render-context.js").PreviewRenderContext;
|
|
34
|
+
renderVariantSlot: (variant: Variant) => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
35
|
+
[key: string]: any;
|
|
36
|
+
}>[];
|
|
37
|
+
resolveVariant: () => Variant;
|
|
38
|
+
syncRenderVariantState: (variant: Variant) => void;
|
|
39
|
+
updateVariant: (variant: Variant) => void;
|
|
40
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
41
|
+
initState: {
|
|
42
|
+
type: PropType<() => any | Promise<any>>;
|
|
43
|
+
default: any;
|
|
44
|
+
};
|
|
45
|
+
source: {
|
|
46
|
+
type: StringConstructor;
|
|
47
|
+
default: any;
|
|
48
|
+
};
|
|
49
|
+
responsiveDisabled: {
|
|
50
|
+
type: BooleanConstructor;
|
|
51
|
+
default: boolean;
|
|
52
|
+
};
|
|
53
|
+
autoPropsDisabled: {
|
|
54
|
+
type: BooleanConstructor;
|
|
55
|
+
default: boolean;
|
|
56
|
+
};
|
|
57
|
+
setupApp: {
|
|
58
|
+
type: FunctionConstructor;
|
|
59
|
+
default: any;
|
|
60
|
+
};
|
|
61
|
+
meta: {
|
|
62
|
+
type: PropType<Variant["meta"]>;
|
|
63
|
+
default: any;
|
|
64
|
+
};
|
|
65
|
+
implicit: {
|
|
66
|
+
type: BooleanConstructor;
|
|
67
|
+
default: boolean;
|
|
68
|
+
};
|
|
69
|
+
}>> & Readonly<{}>, {
|
|
70
|
+
meta: any;
|
|
71
|
+
initState: () => any | Promise<any>;
|
|
72
|
+
source: string;
|
|
73
|
+
responsiveDisabled: boolean;
|
|
74
|
+
autoPropsDisabled: boolean;
|
|
75
|
+
setupApp: Function;
|
|
76
|
+
implicit: boolean;
|
|
77
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
78
|
+
export default _default;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Story, Variant } from '@poveste/shared';
|
|
2
|
+
import { type PreviewRenderContext } from './render-context.js';
|
|
3
|
+
interface PreviewHostOptions {
|
|
4
|
+
name: string;
|
|
5
|
+
el: HTMLElement;
|
|
6
|
+
getStory: () => Story;
|
|
7
|
+
getVariant: () => Variant | null;
|
|
8
|
+
renderContext: PreviewRenderContext;
|
|
9
|
+
wrapInDiv?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare function createPreviewHost(options: PreviewHostOptions): {
|
|
12
|
+
mount: () => Promise<void>;
|
|
13
|
+
unmount: () => void;
|
|
14
|
+
forceUpdate: () => void;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Variant } from '@poveste/shared';
|
|
2
|
+
export interface PreviewRenderContext {
|
|
3
|
+
mode: 'mount' | 'render';
|
|
4
|
+
slotName: string;
|
|
5
|
+
currentVariant: Variant | null;
|
|
6
|
+
externalState: Variant['state'] | null;
|
|
7
|
+
nextVariantIndex: {
|
|
8
|
+
value: number;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export declare function provideRenderContext(value: PreviewRenderContext): void;
|
|
12
|
+
export declare function useRenderContext(): PreviewRenderContext;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Using external/user Vue
|
|
3
|
+
*/
|
|
4
|
+
export declare function toRawDeep(val: any, seen?: WeakMap<WeakKey, any>): any;
|
|
5
|
+
/**
|
|
6
|
+
* Using bundled Vue
|
|
7
|
+
*/
|
|
8
|
+
export declare function _toRawDeep(val: any, seen?: WeakMap<WeakKey, any>): any;
|
|
9
|
+
/**
|
|
10
|
+
* Synchronize states between the bundled and external/user versions of Vue
|
|
11
|
+
* @param bundledState Reactive state created with the bundled Vue
|
|
12
|
+
* @param externalState Reactive state created with the external/user Vue
|
|
13
|
+
*/
|
|
14
|
+
export declare function syncStateBundledAndExternal(bundledState: any, externalState: any): {
|
|
15
|
+
stop(): void;
|
|
16
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { ServerStory } from '@poveste/shared';
|
|
2
|
+
import type { PropType } from 'vue';
|
|
3
|
+
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
4
|
+
title: {
|
|
5
|
+
type: StringConstructor;
|
|
6
|
+
default: any;
|
|
7
|
+
};
|
|
8
|
+
id: {
|
|
9
|
+
type: StringConstructor;
|
|
10
|
+
default: any;
|
|
11
|
+
};
|
|
12
|
+
group: {
|
|
13
|
+
type: StringConstructor;
|
|
14
|
+
default: any;
|
|
15
|
+
};
|
|
16
|
+
layout: {
|
|
17
|
+
type: PropType<ServerStory["layout"]>;
|
|
18
|
+
default: any;
|
|
19
|
+
};
|
|
20
|
+
icon: {
|
|
21
|
+
type: StringConstructor;
|
|
22
|
+
default: any;
|
|
23
|
+
};
|
|
24
|
+
iconColor: {
|
|
25
|
+
type: StringConstructor;
|
|
26
|
+
default: any;
|
|
27
|
+
};
|
|
28
|
+
docsOnly: {
|
|
29
|
+
type: BooleanConstructor;
|
|
30
|
+
default: boolean;
|
|
31
|
+
};
|
|
32
|
+
meta: {
|
|
33
|
+
type: PropType<ServerStory["meta"]>;
|
|
34
|
+
default: any;
|
|
35
|
+
};
|
|
36
|
+
}>, {
|
|
37
|
+
story: ServerStory;
|
|
38
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
39
|
+
title: {
|
|
40
|
+
type: StringConstructor;
|
|
41
|
+
default: any;
|
|
42
|
+
};
|
|
43
|
+
id: {
|
|
44
|
+
type: StringConstructor;
|
|
45
|
+
default: any;
|
|
46
|
+
};
|
|
47
|
+
group: {
|
|
48
|
+
type: StringConstructor;
|
|
49
|
+
default: any;
|
|
50
|
+
};
|
|
51
|
+
layout: {
|
|
52
|
+
type: PropType<ServerStory["layout"]>;
|
|
53
|
+
default: any;
|
|
54
|
+
};
|
|
55
|
+
icon: {
|
|
56
|
+
type: StringConstructor;
|
|
57
|
+
default: any;
|
|
58
|
+
};
|
|
59
|
+
iconColor: {
|
|
60
|
+
type: StringConstructor;
|
|
61
|
+
default: any;
|
|
62
|
+
};
|
|
63
|
+
docsOnly: {
|
|
64
|
+
type: BooleanConstructor;
|
|
65
|
+
default: boolean;
|
|
66
|
+
};
|
|
67
|
+
meta: {
|
|
68
|
+
type: PropType<ServerStory["meta"]>;
|
|
69
|
+
default: any;
|
|
70
|
+
};
|
|
71
|
+
}>> & Readonly<{}>, {
|
|
72
|
+
meta: import("@poveste/shared").StoryMeta;
|
|
73
|
+
title: string;
|
|
74
|
+
id: string;
|
|
75
|
+
group: string;
|
|
76
|
+
layout: import("@poveste/shared").StoryLayout;
|
|
77
|
+
icon: string;
|
|
78
|
+
iconColor: string;
|
|
79
|
+
docsOnly: boolean;
|
|
80
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
81
|
+
export default _default;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { ServerVariant } from '@poveste/shared';
|
|
2
|
+
import { type PropType } from 'vue';
|
|
3
|
+
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
4
|
+
title: {
|
|
5
|
+
type: StringConstructor;
|
|
6
|
+
default: string;
|
|
7
|
+
};
|
|
8
|
+
id: {
|
|
9
|
+
type: StringConstructor;
|
|
10
|
+
default: any;
|
|
11
|
+
};
|
|
12
|
+
icon: {
|
|
13
|
+
type: StringConstructor;
|
|
14
|
+
default: any;
|
|
15
|
+
};
|
|
16
|
+
iconColor: {
|
|
17
|
+
type: StringConstructor;
|
|
18
|
+
default: any;
|
|
19
|
+
};
|
|
20
|
+
meta: {
|
|
21
|
+
type: PropType<ServerVariant["meta"]>;
|
|
22
|
+
default: any;
|
|
23
|
+
};
|
|
24
|
+
}>, void, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
25
|
+
title: {
|
|
26
|
+
type: StringConstructor;
|
|
27
|
+
default: string;
|
|
28
|
+
};
|
|
29
|
+
id: {
|
|
30
|
+
type: StringConstructor;
|
|
31
|
+
default: any;
|
|
32
|
+
};
|
|
33
|
+
icon: {
|
|
34
|
+
type: StringConstructor;
|
|
35
|
+
default: any;
|
|
36
|
+
};
|
|
37
|
+
iconColor: {
|
|
38
|
+
type: StringConstructor;
|
|
39
|
+
default: any;
|
|
40
|
+
};
|
|
41
|
+
meta: {
|
|
42
|
+
type: PropType<ServerVariant["meta"]>;
|
|
43
|
+
default: any;
|
|
44
|
+
};
|
|
45
|
+
}>> & Readonly<{}>, {
|
|
46
|
+
meta: any;
|
|
47
|
+
title: string;
|
|
48
|
+
id: string;
|
|
49
|
+
icon: string;
|
|
50
|
+
iconColor: string;
|
|
51
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
52
|
+
export default _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function autoStubComponents(vnodes: any[]): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './server/run.js';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { kebabCase } from 'change-case';
|
|
2
|
+
import { openStory, sendEvent } from 'poveste/plugin';
|
|
3
|
+
export default {
|
|
4
|
+
prompts: [
|
|
5
|
+
{
|
|
6
|
+
field: 'component',
|
|
7
|
+
label: 'Choose a component',
|
|
8
|
+
type: 'select',
|
|
9
|
+
options: async (search) => sendEvent('listVueComponents', { search }),
|
|
10
|
+
required: true,
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
field: 'fileName',
|
|
14
|
+
label: 'File name',
|
|
15
|
+
type: 'text',
|
|
16
|
+
required: true,
|
|
17
|
+
defaultValue: answers => answers.component?.replace(/[^/]+\/([^/]+)\.vue$/, '$1.story.vue'),
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
clientAction: (params) => {
|
|
21
|
+
const index = params.component.lastIndexOf('/');
|
|
22
|
+
const dirname = params.component.substring(0, index + 1);
|
|
23
|
+
const file = `${dirname}${params.fileName}`;
|
|
24
|
+
const storyId = kebabCase(file.toLowerCase());
|
|
25
|
+
openStory(storyId);
|
|
26
|
+
},
|
|
27
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import launchEditor from 'launch-editor';
|
|
3
|
+
import path from 'pathe';
|
|
4
|
+
export default {
|
|
5
|
+
id: 'histoire:plugin-vue:generate-story',
|
|
6
|
+
label: 'Generate Vue 3 story from component',
|
|
7
|
+
icon: 'https://vuejs.org/logo.svg',
|
|
8
|
+
searchText: 'generate create',
|
|
9
|
+
async serverAction(params) {
|
|
10
|
+
const targetFile = path.join(path.dirname(params.component), params.fileName);
|
|
11
|
+
if (fs.existsSync(targetFile)) {
|
|
12
|
+
throw new Error(`File ${targetFile} already exists`);
|
|
13
|
+
}
|
|
14
|
+
const { component, componentName, isTs } = await getComponentInfo(params.component);
|
|
15
|
+
const content = `<script setup${isTs ? ' lang="ts"' : ''}>
|
|
16
|
+
import ${componentName} from './${component}'
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<template>
|
|
20
|
+
<Story>
|
|
21
|
+
<Variant title="Default">
|
|
22
|
+
<${componentName} />
|
|
23
|
+
</Variant>
|
|
24
|
+
</Story>
|
|
25
|
+
</template>
|
|
26
|
+
`;
|
|
27
|
+
await fs.promises.writeFile(targetFile, content, 'utf-8');
|
|
28
|
+
launchEditor(targetFile);
|
|
29
|
+
},
|
|
30
|
+
clientSetupFile: '@poveste/plugin-vue/dist/commands/generate-story.client.js',
|
|
31
|
+
};
|
|
32
|
+
async function isComponentTs(component) {
|
|
33
|
+
const componentContent = await fs.promises.readFile(component, 'utf-8');
|
|
34
|
+
return componentContent.includes('lang="ts"');
|
|
35
|
+
}
|
|
36
|
+
async function getComponentInfo(file) {
|
|
37
|
+
const component = path.basename(file);
|
|
38
|
+
const componentName = component.replace(path.extname(component), '');
|
|
39
|
+
const isTs = await isComponentTs(file);
|
|
40
|
+
return {
|
|
41
|
+
component,
|
|
42
|
+
componentName,
|
|
43
|
+
isTs,
|
|
44
|
+
};
|
|
45
|
+
}
|