@poveste/plugin-vue 0.14.0 → 0.16.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/README.md +2 -2
- package/components.d.ts +4 -0
- package/dist/bundled/client/app/MountStory.js +8 -3
- package/dist/bundled/client/app/RenderStory.js +15 -9
- package/dist/bundled/client/app/Story.js +76 -62
- package/dist/bundled/client/app/Variant.js +48 -42
- package/dist/bundled/client/app/context.js +5 -0
- package/dist/bundled/client/app/global-components.js +11 -10
- package/dist/bundled/client/app/host.js +2 -2
- package/dist/bundled/client/app/render-context.js +7 -7
- package/dist/bundled/client/app/util.js +36 -26
- package/dist/bundled/client/client.js +4 -4
- package/dist/bundled/client/codegen.js +79 -60
- package/dist/bundled/client/context.js +20 -0
- package/dist/bundled/client/server/Story.js +28 -25
- package/dist/bundled/client/server/Variant.js +13 -16
- package/dist/bundled/client/server/context.js +5 -0
- package/dist/bundled/client/server/run.js +29 -29
- package/dist/client/app/MountStory.d.ts +12 -3
- package/dist/client/app/RenderStory.d.ts +1 -1
- package/dist/client/app/Story.d.ts +10 -7
- package/dist/client/app/Variant.d.ts +14 -13
- package/dist/client/app/context.d.ts +9 -0
- package/dist/client/app/render-context.d.ts +16 -1
- package/dist/client/app/util.d.ts +38 -3
- package/dist/client/codegen.d.ts +29 -0
- package/dist/client/context.d.ts +40 -0
- package/dist/client/server/Story.d.ts +17 -17
- package/dist/client/server/Variant.d.ts +10 -10
- package/dist/client/server/context.d.ts +7 -0
- package/dist/commands/generate-story.client.js +4 -4
- package/dist/commands/generate-story.server.js +2 -2
- package/dist/helpers.d.ts +2 -2
- package/dist/index.node.js +2 -0
- package/dist/util/list-components.d.ts +1 -1
- package/dist/util/list-components.js +63 -6
- package/dist/util/list-components.spec.d.ts +1 -0
- package/dist/util/list-components.spec.js +46 -0
- package/package.json +17 -16
- package/src/client/__tests__/codegen-attrs.spec.ts +149 -0
- package/src/client/__tests__/context.spec.ts +50 -0
- package/src/client/app/MountStory.ts +11 -1
- package/src/client/app/RenderStory.ts +6 -1
- package/src/client/app/RouterLinkStub.ts +1 -1
- package/src/client/app/Story.ts +85 -39
- package/src/client/app/Variant.ts +35 -27
- package/src/client/app/__tests__/preview-variants.spec.ts +76 -0
- package/src/client/app/__tests__/state-sync.spec.ts +113 -2
- package/src/client/app/__tests__/writable-binding.spec.ts +39 -0
- package/src/client/app/auto-props.ts +2 -2
- package/src/client/app/context.ts +17 -0
- package/src/client/app/global-components.ts +20 -14
- package/src/client/app/host.ts +9 -6
- package/src/client/app/render-context.ts +25 -5
- package/src/client/app/util.ts +104 -9
- package/src/client/codegen.ts +81 -29
- package/src/client/context.ts +66 -0
- package/src/client/server/Story.ts +16 -10
- package/src/client/server/Variant.ts +13 -14
- package/src/client/server/__tests__/nesting-errors.spec.ts +48 -0
- package/src/client/server/context.ts +18 -0
- package/src/client/server/run.ts +11 -7
- package/src/commands/generate-story.client.ts +4 -4
- package/src/commands/generate-story.server.ts +2 -2
- package/src/helpers.ts +2 -2
- package/src/index.node.ts +2 -0
- package/src/util/list-components.spec.ts +54 -0
- package/src/util/list-components.ts +68 -6
|
@@ -3,7 +3,7 @@ import { createAutoBuildingObject as o, indent as s, serializeJs as c, voidEleme
|
|
|
3
3
|
import { camelCase as u, pascalCase as d } from "change-case";
|
|
4
4
|
//#region src/client/codegen.ts
|
|
5
5
|
async function f(e) {
|
|
6
|
-
let t = e.slots().default?.({ state: e.state ?? {} }) ?? [], n = Array.isArray(t) ? t : [t], r = [];
|
|
6
|
+
let t = e.slots?.().default?.({ state: e.state ?? {} }) ?? [], n = Array.isArray(t) ? t : [t], r = [];
|
|
7
7
|
for (let t in n) {
|
|
8
8
|
let i = n[t];
|
|
9
9
|
r.push(...(await p(i, e.state?._hPropState?.[t])).lines);
|
|
@@ -18,24 +18,24 @@ async function p(c, d = null) {
|
|
|
18
18
|
let f = [];
|
|
19
19
|
if (typeof c.type == "object" || typeof c.type == "string") {
|
|
20
20
|
c.type?.__asyncLoader && !c.type.__asyncResolved && await c.type.__asyncLoader();
|
|
21
|
-
let e = [],
|
|
22
|
-
function
|
|
21
|
+
let e = [], g = !1, y = ["key"];
|
|
22
|
+
function b(t, n, r = null) {
|
|
23
23
|
let i = "";
|
|
24
24
|
for (let e in n.modifiers) n.modifiers[e] && (i += `.${e}`);
|
|
25
25
|
let a = "";
|
|
26
26
|
n.arg && (a = `:${n.arg}`), r &&= r.replace(/^\$(?:setup|props|data)\./g, "");
|
|
27
|
-
let o = r ? [r] :
|
|
28
|
-
o.length > 1 ? (s.push(`${c}${o[0]}`), s.push(...o.slice(1, o.length - 1)), s.push(`${o[o.length - 1]}"`),
|
|
27
|
+
let o = r ? [r] : _(n.value), s = [], c = `v-${t}${a}${i}="`;
|
|
28
|
+
o.length > 1 ? (s.push(`${c}${o[0]}`), s.push(...o.slice(1, o.length - 1)), s.push(`${o[o.length - 1]}"`), g = !0) : s.push(`${c}${o[0] ?? ""}"`), e.push(s);
|
|
29
29
|
}
|
|
30
30
|
if (c.dirs) {
|
|
31
31
|
for (let e of c.dirs) if (e.dir === a || e.dir === i || e.dir === r || e.dir === t || e.dir === n) {
|
|
32
|
-
let t = [`onUpdate:${e.arg ?? "modelValue"}`, `onUpdate:${u(e.arg ?? "modelValue")}`].find((e) => c.props[e]), n = c.props[t], r = null;
|
|
33
|
-
if (n) {
|
|
34
|
-
|
|
32
|
+
let t = [`onUpdate:${e.arg ?? "modelValue"}`, `onUpdate:${u(e.arg ?? "modelValue")}`].find((e) => c.props?.[e]), n = t ? c.props?.[t] : void 0, r = null;
|
|
33
|
+
if (t && n) {
|
|
34
|
+
y.push(t);
|
|
35
35
|
let e = n.toString(), i = /\(\$event\) => (.*?) = \$event/.exec(e);
|
|
36
|
-
i && (r = i[1]);
|
|
36
|
+
i && (r = i[1] ?? null);
|
|
37
37
|
}
|
|
38
|
-
|
|
38
|
+
b("model", e, r);
|
|
39
39
|
} else if (e.instance._ || e.instance.$) {
|
|
40
40
|
let t = e.instance.$ ?? e.instance._, n;
|
|
41
41
|
for (let r of [t.directives, t.appContext.directives]) {
|
|
@@ -51,99 +51,118 @@ async function p(c, d = null) {
|
|
|
51
51
|
break;
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
-
n &&
|
|
54
|
+
n && b(n, e);
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
function
|
|
57
|
+
function x(t, n) {
|
|
58
58
|
if (typeof n != "string" || c.dynamicProps?.includes(t)) {
|
|
59
59
|
let r = ":";
|
|
60
60
|
t.startsWith("on") && (r = "@");
|
|
61
|
-
let i = r === "@" ? `${t
|
|
61
|
+
let i = r === "@" ? `${t.charAt(2).toLowerCase()}${t.slice(3)}` : t, a = [`onUpdate:${t}`, `onUpdate:${u(t)}`].find((e) => c.dynamicProps?.includes(e) || c.props && e in c.props);
|
|
62
62
|
if (r === ":" && a) {
|
|
63
|
-
|
|
64
|
-
let e = c.props[a]
|
|
65
|
-
|
|
66
|
-
let
|
|
67
|
-
|
|
63
|
+
y.push(a);
|
|
64
|
+
let e = c.props?.[a], r = String(e), i = null, o = /\(\$event\) => (.*?) = \$event/.exec(r);
|
|
65
|
+
o && (i = o[1] ?? null);
|
|
66
|
+
let s = `${t === "modelValue" ? "model" : t}Modifiers`, l = c.props?.[s] ?? {};
|
|
67
|
+
y.push(s), b("model", {
|
|
68
68
|
arg: t === "modelValue" ? null : t,
|
|
69
|
-
modifiers:
|
|
69
|
+
modifiers: l,
|
|
70
70
|
value: n
|
|
71
|
-
},
|
|
71
|
+
}, i);
|
|
72
72
|
return;
|
|
73
73
|
}
|
|
74
74
|
if (n === void 0) return;
|
|
75
75
|
let o;
|
|
76
|
-
if (typeof n == "string" && n.startsWith("{{") && n.endsWith("}}")) o =
|
|
76
|
+
if (typeof n == "string" && n.startsWith("{{") && n.endsWith("}}")) o = v(n.substring(2, n.length - 2).trim()).split("\n");
|
|
77
77
|
else if (typeof n == "function") {
|
|
78
|
-
let e =
|
|
79
|
-
t ? o = [t
|
|
80
|
-
} else o =
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
t
|
|
85
|
-
|
|
86
|
-
|
|
78
|
+
let e = v(n.toString()), t = /function (\S+)\(/.exec(e)?.[1];
|
|
79
|
+
t ? o = [t] : (e.startsWith("($event) => ") && (e = e.substring(12)), o = e.split("\n"));
|
|
80
|
+
} else o = _(n);
|
|
81
|
+
let { quote: s, lines: l } = m(o);
|
|
82
|
+
if (l.length > 1) {
|
|
83
|
+
g = !0;
|
|
84
|
+
let t = [`${r}${i}=${s}${l[0]}`];
|
|
85
|
+
t.push(...l.slice(1, l.length - 1)), t.push(`${l[l.length - 1]}${s}`), e.push(t);
|
|
86
|
+
} else e.push([`${r}${i}=${s}${l[0]}${s}`]);
|
|
87
|
+
} else if (c.type?.props?.[t]?.type === Boolean) e.push([t]);
|
|
88
|
+
else {
|
|
89
|
+
let r = m([String(n)]);
|
|
90
|
+
e.push([`${t}=${r.quote}${r.lines[0]}${r.quote}`]);
|
|
91
|
+
}
|
|
87
92
|
}
|
|
88
93
|
for (let e in c.props) {
|
|
89
|
-
if (
|
|
94
|
+
if (y.includes(e) || d && e in d) continue;
|
|
90
95
|
let t = c.props[e];
|
|
91
|
-
|
|
96
|
+
x(e, t);
|
|
92
97
|
}
|
|
93
|
-
if (d) for (let e in d)
|
|
94
|
-
e.length > 1 && (
|
|
95
|
-
let
|
|
96
|
-
if (typeof c.children == "string")
|
|
98
|
+
if (d) for (let e in d) x(e, d[e]);
|
|
99
|
+
e.length > 1 && (g = !0);
|
|
100
|
+
let S = h(c), C = !1, w = [];
|
|
101
|
+
if (typeof c.children == "string") S === "pre" ? w.push(c.children) : w.push(...c.children.split("\n")), C = !0;
|
|
97
102
|
else if (Array.isArray(c.children)) {
|
|
98
103
|
let e;
|
|
99
104
|
for (let t of c.children) {
|
|
100
105
|
let n = await p(t);
|
|
101
106
|
if (n.isText) {
|
|
102
107
|
e === void 0 && (e = !0);
|
|
103
|
-
let t = n.lines[0];
|
|
104
|
-
!
|
|
105
|
-
} else e === void 0 && (e = !1),
|
|
108
|
+
let t = n.lines[0] ?? "";
|
|
109
|
+
!w.length || /^\s/.test(t) ? w.push(t.trim()) : w[w.length - 1] += t;
|
|
110
|
+
} else e === void 0 && (e = !1), w.push(...n.lines);
|
|
106
111
|
}
|
|
107
|
-
e !== void 0 && (
|
|
112
|
+
e !== void 0 && (C = e);
|
|
108
113
|
}
|
|
109
114
|
if (c.children && typeof c.children == "object" && !Array.isArray(c.children)) {
|
|
110
115
|
for (let e in c.children) if (typeof c.children[e] == "function") {
|
|
111
|
-
let t = o((e) => `{{ ${e} }}`, (e, t) =>
|
|
112
|
-
if (t === "__v_isRef") return () => !1;
|
|
113
|
-
}), n = c.children[e](t.proxy), r = [];
|
|
116
|
+
let t = o((e) => `{{ ${e} }}`, (e, t) => t === "__v_isRef" ? () => !1 : null), n = c.children[e](t.proxy), r = [];
|
|
114
117
|
for (let e of n) r.push(...(await p(e)).lines);
|
|
115
118
|
let i = Object.keys(t.cache);
|
|
116
|
-
i.length ? (
|
|
119
|
+
i.length ? (w.push(`<template #${e}="{ ${i.join(", ")} }">`), w.push(...s(r)), w.push("</template>")) : e === "default" ? w.push(...r) : (w.push(`<template #${e}>`), w.push(...s(r)), w.push("</template>"));
|
|
117
120
|
}
|
|
118
121
|
}
|
|
119
|
-
let
|
|
120
|
-
if (
|
|
121
|
-
for (let t of e)
|
|
122
|
-
|
|
123
|
-
} else e.length === 1 && (
|
|
124
|
-
let
|
|
125
|
-
|
|
122
|
+
let T = [`<${S}`];
|
|
123
|
+
if (g) {
|
|
124
|
+
for (let t of e) T.push(...s(t));
|
|
125
|
+
w.length > 0 && T.push(">");
|
|
126
|
+
} else e.length === 1 && (T[0] += ` ${e[0]}`), w.length > 0 && (T[0] += ">");
|
|
127
|
+
let E = l.includes(S.toLowerCase());
|
|
128
|
+
w.length > 0 ? w.length === 1 && T.length === 1 && !e.length && C ? f.push(`${T[0]}${w[0]}</${S}>`) : (f.push(...T), f.push(...s(w)), f.push(`</${S}>`)) : T.length > 1 ? (f.push(...T), f.push(E ? ">" : "/>")) : f.push(`${T[0]}${E ? "" : " /"}>`);
|
|
126
129
|
} else if (c?.shapeFlag & 16) for (let e of c.children) f.push(...(await p(e)).lines);
|
|
127
130
|
return { lines: f };
|
|
128
131
|
}
|
|
129
132
|
function m(e) {
|
|
133
|
+
let t = e.join("\n"), n = (t.match(/"/g) ?? []).length, r = (t.match(/'/g) ?? []).length;
|
|
134
|
+
return n === 0 ? {
|
|
135
|
+
quote: "\"",
|
|
136
|
+
lines: e
|
|
137
|
+
} : r === 0 ? {
|
|
138
|
+
quote: "'",
|
|
139
|
+
lines: e
|
|
140
|
+
} : r <= n ? {
|
|
141
|
+
quote: "'",
|
|
142
|
+
lines: e.map((e) => e.replace(/'/g, "'"))
|
|
143
|
+
} : {
|
|
144
|
+
quote: "\"",
|
|
145
|
+
lines: e.map((e) => e.replace(/"/g, """))
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
function h(e) {
|
|
130
149
|
if (typeof e.type == "string") return e.type;
|
|
131
150
|
if (e.type?.__asyncResolved) {
|
|
132
151
|
let t = e.type?.__asyncResolved;
|
|
133
|
-
return t.name ??
|
|
152
|
+
return t.name ?? g(t.__file);
|
|
134
153
|
}
|
|
135
|
-
return e.type?.name ? e.type.name : e.type?.__file ?
|
|
136
|
-
}
|
|
137
|
-
function h(e) {
|
|
138
|
-
let t = /([^/]+)\.vue$/.exec(e);
|
|
139
|
-
return t ? d(t[1]) : "Anonymous";
|
|
154
|
+
return e.type?.name ? e.type.name : e.type?.__file ? g(e.type.__file) : "Anonymous";
|
|
140
155
|
}
|
|
141
156
|
function g(e) {
|
|
142
|
-
let t =
|
|
143
|
-
return t ?
|
|
157
|
+
let t = /([^/]+)\.vue$/.exec(e)?.[1];
|
|
158
|
+
return t ? d(t) : "Anonymous";
|
|
144
159
|
}
|
|
145
160
|
function _(e) {
|
|
161
|
+
let t = !!e?.__autoBuildingObject, n = c(e);
|
|
162
|
+
return t ? [v(n.__autoBuildingObjectGetKey)] : v(n).split("\n");
|
|
163
|
+
}
|
|
164
|
+
function v(e) {
|
|
146
165
|
return e.replace(/\$setup\./g, "");
|
|
147
166
|
}
|
|
148
167
|
//#endregion
|
|
149
|
-
export { f as generateSourceCode,
|
|
168
|
+
export { m as delimitAttr, f as generateSourceCode, h as getTagName };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { inject as e, provide as t } from "vue";
|
|
2
|
+
//#region src/client/context.ts
|
|
3
|
+
function n(n, r) {
|
|
4
|
+
let i = Symbol.for(n);
|
|
5
|
+
return {
|
|
6
|
+
provide(e) {
|
|
7
|
+
t(i, e);
|
|
8
|
+
},
|
|
9
|
+
inject(t) {
|
|
10
|
+
let n = e(i, null);
|
|
11
|
+
if (n === null) throw Error(`[poveste] a ${t} has to be inside a ${r}`);
|
|
12
|
+
return n;
|
|
13
|
+
},
|
|
14
|
+
injectOptional() {
|
|
15
|
+
return e(i, null);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { n as createContext };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { addStoryContext as e, addVariantContext as t, serverStoryContext as n, storyFileContext as r } from "./context.js";
|
|
2
|
+
import { autoStubComponents as i } from "./stub.js";
|
|
3
|
+
import { defineComponent as a, onMounted as o } from "vue";
|
|
3
4
|
//#region src/client/server/Story.ts
|
|
4
|
-
var
|
|
5
|
+
var s = a({
|
|
5
6
|
name: "PovesteStory",
|
|
6
7
|
inheritAttrs: !1,
|
|
7
8
|
props: {
|
|
@@ -38,38 +39,40 @@ var a = t({
|
|
|
38
39
|
default: void 0
|
|
39
40
|
}
|
|
40
41
|
},
|
|
41
|
-
setup(
|
|
42
|
-
let
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
42
|
+
setup(i) {
|
|
43
|
+
let a = r.injectOptional(), s = i.id ?? a?.id, c = i.title ?? a?.fileName;
|
|
44
|
+
if (!s || c === void 0) throw Error("[poveste] a <Story> collected outside a story file needs an `id` and a `title`");
|
|
45
|
+
let l = {
|
|
46
|
+
id: s,
|
|
47
|
+
title: c,
|
|
48
|
+
group: i.group,
|
|
49
|
+
layout: i.layout,
|
|
50
|
+
icon: i.icon,
|
|
51
|
+
iconColor: i.iconColor,
|
|
52
|
+
docsOnly: i.docsOnly,
|
|
53
|
+
meta: i.meta,
|
|
51
54
|
variants: []
|
|
52
55
|
};
|
|
53
|
-
return
|
|
54
|
-
|
|
55
|
-
}),
|
|
56
|
-
|
|
56
|
+
return e.injectOptional()?.(l), n.provide(l), t.provide((e) => {
|
|
57
|
+
l.variants.push(e);
|
|
58
|
+
}), o(() => {
|
|
59
|
+
l.variants.length || l.variants.push({
|
|
57
60
|
id: "_default",
|
|
58
61
|
title: "default"
|
|
59
62
|
});
|
|
60
|
-
}), { story:
|
|
63
|
+
}), { story: l };
|
|
61
64
|
},
|
|
62
65
|
render() {
|
|
63
|
-
let
|
|
66
|
+
let e = !1;
|
|
64
67
|
try {
|
|
65
|
-
let
|
|
66
|
-
return
|
|
68
|
+
let t = this.$slots.default?.({ get state() {
|
|
69
|
+
return e = !0, {};
|
|
67
70
|
} });
|
|
68
|
-
return Array.isArray(
|
|
69
|
-
} catch (
|
|
70
|
-
return
|
|
71
|
+
return Array.isArray(t) && i(t), t;
|
|
72
|
+
} catch (t) {
|
|
73
|
+
return e || console.error(t), null;
|
|
71
74
|
}
|
|
72
75
|
}
|
|
73
76
|
});
|
|
74
77
|
//#endregion
|
|
75
|
-
export {
|
|
78
|
+
export { s as default };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { addVariantContext as e, serverStoryContext as t } from "./context.js";
|
|
2
|
+
import { defineComponent as n } from "vue";
|
|
2
3
|
//#region src/client/server/Variant.ts
|
|
3
|
-
var
|
|
4
|
+
var r = n({
|
|
4
5
|
name: "PovesteVariant",
|
|
5
6
|
props: {
|
|
6
7
|
title: {
|
|
@@ -24,23 +25,19 @@ var n = e({
|
|
|
24
25
|
default: void 0
|
|
25
26
|
}
|
|
26
27
|
},
|
|
27
|
-
setup(
|
|
28
|
-
let
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
iconColor: e.iconColor,
|
|
37
|
-
meta: e.meta
|
|
38
|
-
};
|
|
39
|
-
t("addVariant")(i);
|
|
28
|
+
setup(n) {
|
|
29
|
+
let r = t.inject("<Variant>");
|
|
30
|
+
e.inject("<Variant>")({
|
|
31
|
+
id: n.id ?? `${r.id}-${r.variants.length}`,
|
|
32
|
+
title: n.title,
|
|
33
|
+
icon: n.icon,
|
|
34
|
+
iconColor: n.iconColor,
|
|
35
|
+
meta: n.meta
|
|
36
|
+
});
|
|
40
37
|
},
|
|
41
38
|
render() {
|
|
42
39
|
return null;
|
|
43
40
|
}
|
|
44
41
|
});
|
|
45
42
|
//#endregion
|
|
46
|
-
export {
|
|
43
|
+
export { r as default };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { createContext as e } from "../context.js";
|
|
2
|
+
//#region src/client/server/context.ts
|
|
3
|
+
var t = e("poveste-server-story-file", "story file"), n = e("poveste-server-add-story", "story file"), r = e("poveste-server-story", "<Story>"), i = e("poveste-server-add-variant", "<Story>");
|
|
4
|
+
//#endregion
|
|
5
|
+
export { n as addStoryContext, i as addVariantContext, r as serverStoryContext, t as storyFileContext };
|
|
@@ -1,44 +1,44 @@
|
|
|
1
1
|
import { VUE_SETUP_HOOK_NAMES as e } from "../../setup-hooks.js";
|
|
2
|
-
import t from "./
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import * as
|
|
2
|
+
import { addStoryContext as t, storyFileContext as n } from "./context.js";
|
|
3
|
+
import r from "./Story.js";
|
|
4
|
+
import i from "./Variant.js";
|
|
5
|
+
import { createApp as a, h as o } from "vue";
|
|
6
|
+
import { getSetupHook as s } from "@poveste/shared";
|
|
7
|
+
import * as c from "virtual:$poveste-generated-global-setup";
|
|
8
|
+
import * as l from "virtual:$poveste-setup";
|
|
8
9
|
//#region src/client/server/run.ts
|
|
9
|
-
async function
|
|
10
|
-
let { default:
|
|
10
|
+
async function u({ file: u, storyData: d, el: f }) {
|
|
11
|
+
let { default: p } = await import(/* @vite-ignore */
|
|
11
12
|
/* @vite-ignore */
|
|
12
|
-
|
|
13
|
-
),
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
},
|
|
18
|
-
hstStoryFile: c
|
|
13
|
+
u.moduleId
|
|
14
|
+
), m = a({
|
|
15
|
+
setup() {
|
|
16
|
+
t.provide((e) => {
|
|
17
|
+
d.push(e);
|
|
18
|
+
}), n.provide(u);
|
|
19
19
|
},
|
|
20
20
|
render() {
|
|
21
|
-
return
|
|
21
|
+
return o(p);
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
|
-
|
|
25
|
-
let
|
|
26
|
-
app:
|
|
27
|
-
story:
|
|
28
|
-
variant:
|
|
24
|
+
m.component("Story", r), m.component("Variant", i);
|
|
25
|
+
let h = {
|
|
26
|
+
app: m,
|
|
27
|
+
story: void 0,
|
|
28
|
+
variant: void 0,
|
|
29
29
|
addWrapper: () => {}
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
let
|
|
33
|
-
if (
|
|
30
|
+
}, g = s(c, e);
|
|
31
|
+
g && await g(h);
|
|
32
|
+
let _ = s(l, e);
|
|
33
|
+
if (_ && await _(h), m.mount(f), p.doc) {
|
|
34
34
|
let e = document.createElement("div");
|
|
35
|
-
e.innerHTML =
|
|
35
|
+
e.innerHTML = p.doc;
|
|
36
36
|
let t = e.textContent;
|
|
37
|
-
|
|
37
|
+
d.forEach((e) => {
|
|
38
38
|
e.docsText = t;
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
|
-
|
|
41
|
+
m.unmount();
|
|
42
42
|
}
|
|
43
43
|
//#endregion
|
|
44
|
-
export {
|
|
44
|
+
export { u as run };
|
|
@@ -7,10 +7,14 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
7
7
|
};
|
|
8
8
|
targetVariantId: {
|
|
9
9
|
type: StringConstructor;
|
|
10
|
-
default:
|
|
10
|
+
default: null;
|
|
11
|
+
};
|
|
12
|
+
syncState: {
|
|
13
|
+
type: BooleanConstructor;
|
|
14
|
+
default: boolean;
|
|
11
15
|
};
|
|
12
16
|
}>, {
|
|
13
|
-
el: import("vue").Ref<HTMLDivElement, HTMLDivElement>;
|
|
17
|
+
el: import("vue").Ref<HTMLDivElement | undefined, HTMLDivElement | undefined>;
|
|
14
18
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
15
19
|
story: {
|
|
16
20
|
type: _PropType<Story>;
|
|
@@ -18,9 +22,14 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
18
22
|
};
|
|
19
23
|
targetVariantId: {
|
|
20
24
|
type: StringConstructor;
|
|
21
|
-
default:
|
|
25
|
+
default: null;
|
|
26
|
+
};
|
|
27
|
+
syncState: {
|
|
28
|
+
type: BooleanConstructor;
|
|
29
|
+
default: boolean;
|
|
22
30
|
};
|
|
23
31
|
}>> & Readonly<{}>, {
|
|
32
|
+
syncState: boolean;
|
|
24
33
|
targetVariantId: string;
|
|
25
34
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
26
35
|
export default _default;
|
|
@@ -14,7 +14,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
14
14
|
default: string;
|
|
15
15
|
};
|
|
16
16
|
}>, {
|
|
17
|
-
sandbox: import("vue").Ref<HTMLDivElement, HTMLDivElement>;
|
|
17
|
+
sandbox: import("vue").Ref<HTMLDivElement | undefined, HTMLDivElement | undefined>;
|
|
18
18
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
19
19
|
ready: () => true;
|
|
20
20
|
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
@@ -1,33 +1,36 @@
|
|
|
1
1
|
import type { Story } from '@poveste/shared';
|
|
2
2
|
import type { PropType, VNode } from 'vue';
|
|
3
|
+
import type { PreviewRenderContext } from './render-context.js';
|
|
3
4
|
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
4
5
|
initState: {
|
|
5
6
|
type: PropType<() => any | Promise<any>>;
|
|
6
|
-
default:
|
|
7
|
+
default: undefined;
|
|
7
8
|
};
|
|
8
9
|
meta: {
|
|
9
10
|
type: PropType<Story["meta"]>;
|
|
10
|
-
default:
|
|
11
|
+
default: undefined;
|
|
11
12
|
};
|
|
12
13
|
}>, {
|
|
13
|
-
renderContext:
|
|
14
|
+
renderContext: PreviewRenderContext | null;
|
|
14
15
|
story: import("vue").ComputedRef<Story>;
|
|
15
16
|
renderMountStory: () => VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
16
17
|
[key: string]: any;
|
|
17
18
|
}>[];
|
|
18
|
-
renderPreviewStory: () =>
|
|
19
|
+
renderPreviewStory: (context: PreviewRenderContext) => VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
20
|
+
[key: string]: any;
|
|
21
|
+
}>[];
|
|
19
22
|
updateStory: () => void;
|
|
20
23
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
21
24
|
initState: {
|
|
22
25
|
type: PropType<() => any | Promise<any>>;
|
|
23
|
-
default:
|
|
26
|
+
default: undefined;
|
|
24
27
|
};
|
|
25
28
|
meta: {
|
|
26
29
|
type: PropType<Story["meta"]>;
|
|
27
|
-
default:
|
|
30
|
+
default: undefined;
|
|
28
31
|
};
|
|
29
32
|
}>> & Readonly<{}>, {
|
|
30
|
-
meta: import("poveste").StoryMeta;
|
|
33
|
+
meta: import("poveste").StoryMeta | undefined;
|
|
31
34
|
initState: () => any | Promise<any>;
|
|
32
35
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
33
36
|
export default _default;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import type { Variant } from '@poveste/shared';
|
|
2
2
|
import type { PropType } from 'vue';
|
|
3
|
+
import type { PreviewRenderContext } from './render-context.js';
|
|
3
4
|
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
4
5
|
initState: {
|
|
5
6
|
type: PropType<() => any | Promise<any>>;
|
|
6
|
-
default:
|
|
7
|
+
default: undefined;
|
|
7
8
|
};
|
|
8
9
|
source: {
|
|
9
10
|
type: StringConstructor;
|
|
10
|
-
default:
|
|
11
|
+
default: undefined;
|
|
11
12
|
};
|
|
12
13
|
responsiveDisabled: {
|
|
13
14
|
type: BooleanConstructor;
|
|
@@ -19,32 +20,32 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
19
20
|
};
|
|
20
21
|
setupApp: {
|
|
21
22
|
type: FunctionConstructor;
|
|
22
|
-
default:
|
|
23
|
+
default: undefined;
|
|
23
24
|
};
|
|
24
25
|
meta: {
|
|
25
26
|
type: PropType<Variant["meta"]>;
|
|
26
|
-
default:
|
|
27
|
+
default: undefined;
|
|
27
28
|
};
|
|
28
29
|
implicit: {
|
|
29
30
|
type: BooleanConstructor;
|
|
30
31
|
default: boolean;
|
|
31
32
|
};
|
|
32
33
|
}>, {
|
|
33
|
-
renderContext:
|
|
34
|
-
renderVariantSlot: (variant: Variant) => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
34
|
+
renderContext: PreviewRenderContext | null;
|
|
35
|
+
renderVariantSlot: (variant: Variant, context: PreviewRenderContext) => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
35
36
|
[key: string]: any;
|
|
36
|
-
}>[];
|
|
37
|
-
resolveVariant: () => Variant;
|
|
37
|
+
}>[] | null;
|
|
38
|
+
resolveVariant: () => Variant | null | undefined;
|
|
38
39
|
syncRenderVariantState: (variant: Variant) => void;
|
|
39
40
|
updateVariant: (variant: Variant) => void;
|
|
40
41
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
41
42
|
initState: {
|
|
42
43
|
type: PropType<() => any | Promise<any>>;
|
|
43
|
-
default:
|
|
44
|
+
default: undefined;
|
|
44
45
|
};
|
|
45
46
|
source: {
|
|
46
47
|
type: StringConstructor;
|
|
47
|
-
default:
|
|
48
|
+
default: undefined;
|
|
48
49
|
};
|
|
49
50
|
responsiveDisabled: {
|
|
50
51
|
type: BooleanConstructor;
|
|
@@ -56,18 +57,18 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
56
57
|
};
|
|
57
58
|
setupApp: {
|
|
58
59
|
type: FunctionConstructor;
|
|
59
|
-
default:
|
|
60
|
+
default: undefined;
|
|
60
61
|
};
|
|
61
62
|
meta: {
|
|
62
63
|
type: PropType<Variant["meta"]>;
|
|
63
|
-
default:
|
|
64
|
+
default: undefined;
|
|
64
65
|
};
|
|
65
66
|
implicit: {
|
|
66
67
|
type: BooleanConstructor;
|
|
67
68
|
default: boolean;
|
|
68
69
|
};
|
|
69
70
|
}>> & Readonly<{}>, {
|
|
70
|
-
meta:
|
|
71
|
+
meta: import("poveste").VariantMeta | undefined;
|
|
71
72
|
initState: () => any | Promise<any>;
|
|
72
73
|
source: string;
|
|
73
74
|
responsiveDisabled: boolean;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ComputedRef } from 'vue';
|
|
2
|
+
/** The story a variant belongs to. Read with `?.` throughout. */
|
|
3
|
+
export declare const storyContext: import("../context.js").Context<ComputedRef<any>>;
|
|
4
|
+
/**
|
|
5
|
+
* The story's implicit state, absent when the story has none. A variant skips
|
|
6
|
+
* its state sync rather than failing, which is behaviour rather than an
|
|
7
|
+
* oversight — this is the type saying so.
|
|
8
|
+
*/
|
|
9
|
+
export declare const implicitStateContext: import("../context.js").Context<() => any>;
|
|
@@ -9,10 +9,25 @@ export interface PreviewRenderContext {
|
|
|
9
9
|
* app realm, where the story view needs all of them mounted.
|
|
10
10
|
*/
|
|
11
11
|
targetVariantId?: string | null;
|
|
12
|
+
/**
|
|
13
|
+
* Whether this mount pass owns the live state sync for its variants.
|
|
14
|
+
*
|
|
15
|
+
* False in a sandbox realm, where the render tree beside it already syncs the
|
|
16
|
+
* same `variant.state` against the same story's bindings. Two syncs over one
|
|
17
|
+
* state is two deep watchers walking the whole graph on every edit, and a
|
|
18
|
+
* story holding a large one pays for both: #964 measured the sandbox running
|
|
19
|
+
* three syncs where the app realm runs one.
|
|
20
|
+
*
|
|
21
|
+
* The app realm keeps it. Its mount pass is the only thing that fills
|
|
22
|
+
* `variant.state` there — with no controls slot nothing renders, so nothing
|
|
23
|
+
* else would — and that is what the controls panel builds from.
|
|
24
|
+
*/
|
|
25
|
+
syncState?: boolean;
|
|
12
26
|
externalState: Variant['state'] | null;
|
|
13
27
|
nextVariantIndex: {
|
|
14
28
|
value: number;
|
|
15
29
|
};
|
|
16
30
|
}
|
|
17
31
|
export declare function provideRenderContext(value: PreviewRenderContext): void;
|
|
18
|
-
|
|
32
|
+
/** Null outside a preview, which several call sites read with `?.`. */
|
|
33
|
+
export declare function useRenderContext(): PreviewRenderContext | null;
|