@poveste/plugin-vue 0.14.0 → 0.15.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 +1 -1
- package/dist/bundled/client/app/MountStory.js +3 -3
- package/dist/bundled/client/app/RenderStory.js +15 -9
- package/dist/bundled/client/app/Story.js +56 -43
- package/dist/bundled/client/app/Variant.js +32 -27
- package/dist/bundled/client/app/global-components.js +11 -10
- package/dist/bundled/client/app/host.js +2 -2
- package/dist/bundled/client/app/util.js +31 -26
- package/dist/bundled/client/client.js +4 -4
- package/dist/bundled/client/codegen.js +79 -60
- package/dist/bundled/client/server/Story.js +9 -7
- package/dist/bundled/client/server/Variant.js +1 -0
- package/dist/bundled/client/server/run.js +2 -2
- package/dist/client/app/MountStory.d.ts +3 -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/render-context.d.ts +1 -1
- package/dist/client/app/util.d.ts +6 -3
- package/dist/client/codegen.d.ts +29 -0
- package/dist/client/server/Story.d.ts +17 -17
- package/dist/client/server/Variant.d.ts +10 -10
- 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 +11 -10
- package/src/client/__tests__/codegen-attrs.spec.ts +149 -0
- package/src/client/app/MountStory.ts +5 -1
- package/src/client/app/RenderStory.ts +6 -1
- package/src/client/app/RouterLinkStub.ts +1 -1
- package/src/client/app/Story.ts +78 -37
- package/src/client/app/Variant.ts +26 -23
- package/src/client/app/__tests__/preview-variants.spec.ts +76 -0
- package/src/client/app/auto-props.ts +2 -2
- package/src/client/app/global-components.ts +20 -14
- package/src/client/app/host.ts +9 -6
- package/src/client/app/util.ts +17 -7
- package/src/client/codegen.ts +81 -29
- package/src/client/server/Story.ts +10 -4
- package/src/client/server/Variant.ts +3 -0
- package/src/client/server/run.ts +5 -4
- 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 };
|
|
@@ -39,9 +39,11 @@ var a = t({
|
|
|
39
39
|
}
|
|
40
40
|
},
|
|
41
41
|
setup(e) {
|
|
42
|
-
let t = n("hstStoryFile"), a =
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
let t = n("hstStoryFile"), a = e.id ?? t?.id, o = e.title ?? t?.fileName;
|
|
43
|
+
if (!a || o === void 0) throw Error("[poveste] a <Story> collected outside a story file needs an `id` and a `title`");
|
|
44
|
+
let s = {
|
|
45
|
+
id: a,
|
|
46
|
+
title: o,
|
|
45
47
|
group: e.group,
|
|
46
48
|
layout: e.layout,
|
|
47
49
|
icon: e.icon,
|
|
@@ -50,14 +52,14 @@ var a = t({
|
|
|
50
52
|
meta: e.meta,
|
|
51
53
|
variants: []
|
|
52
54
|
};
|
|
53
|
-
return n("addStory", null)?.(
|
|
54
|
-
|
|
55
|
+
return n("addStory", null)?.(s), i("story", s), i("addVariant", (e) => {
|
|
56
|
+
s.variants.push(e);
|
|
55
57
|
}), r(() => {
|
|
56
|
-
|
|
58
|
+
s.variants.length || s.variants.push({
|
|
57
59
|
id: "_default",
|
|
58
60
|
title: "default"
|
|
59
61
|
});
|
|
60
|
-
}), { story:
|
|
62
|
+
}), { story: s };
|
|
61
63
|
},
|
|
62
64
|
render() {
|
|
63
65
|
let t = !1;
|
|
@@ -24,8 +24,8 @@ async function c({ file: c, storyData: l, el: u }) {
|
|
|
24
24
|
f.component("Story", t), f.component("Variant", n);
|
|
25
25
|
let p = {
|
|
26
26
|
app: f,
|
|
27
|
-
story:
|
|
28
|
-
variant:
|
|
27
|
+
story: void 0,
|
|
28
|
+
variant: void 0,
|
|
29
29
|
addWrapper: () => {}
|
|
30
30
|
}, m = a(o, e);
|
|
31
31
|
m && await m(p);
|
|
@@ -7,10 +7,10 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
7
7
|
};
|
|
8
8
|
targetVariantId: {
|
|
9
9
|
type: StringConstructor;
|
|
10
|
-
default:
|
|
10
|
+
default: null;
|
|
11
11
|
};
|
|
12
12
|
}>, {
|
|
13
|
-
el: import("vue").Ref<HTMLDivElement, HTMLDivElement>;
|
|
13
|
+
el: import("vue").Ref<HTMLDivElement | undefined, HTMLDivElement | undefined>;
|
|
14
14
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
15
15
|
story: {
|
|
16
16
|
type: _PropType<Story>;
|
|
@@ -18,7 +18,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
18
18
|
};
|
|
19
19
|
targetVariantId: {
|
|
20
20
|
type: StringConstructor;
|
|
21
|
-
default:
|
|
21
|
+
default: null;
|
|
22
22
|
};
|
|
23
23
|
}>> & Readonly<{}>, {
|
|
24
24
|
targetVariantId: string;
|
|
@@ -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;
|
|
@@ -15,4 +15,4 @@ export interface PreviewRenderContext {
|
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
17
|
export declare function provideRenderContext(value: PreviewRenderContext): void;
|
|
18
|
-
export declare function useRenderContext(): PreviewRenderContext;
|
|
18
|
+
export declare function useRenderContext(): PreviewRenderContext | null;
|
|
@@ -1,17 +1,20 @@
|
|
|
1
|
+
import type { ComponentInternalInstance } from 'vue';
|
|
1
2
|
/**
|
|
2
3
|
* Using external/user Vue
|
|
3
4
|
*/
|
|
4
|
-
export declare function toRawDeep(val:
|
|
5
|
+
export declare function toRawDeep(val: unknown, seen?: WeakMap<WeakKey, any>): any;
|
|
5
6
|
/**
|
|
6
7
|
* Using bundled Vue
|
|
7
8
|
*/
|
|
8
|
-
export declare function _toRawDeep(val:
|
|
9
|
+
export declare function _toRawDeep(val: unknown, seen?: WeakMap<WeakKey, any>): any;
|
|
9
10
|
/**
|
|
10
11
|
* Synchronize states between the bundled and external/user versions of Vue
|
|
11
12
|
* @param bundledState Reactive state created with the bundled Vue
|
|
12
13
|
* @param externalState Reactive state created with the external/user Vue
|
|
13
14
|
* @param omit Keys neither side may learn from the other
|
|
14
15
|
*/
|
|
15
|
-
export declare function syncStateBundledAndExternal(bundledState:
|
|
16
|
+
export declare function syncStateBundledAndExternal(bundledState: Record<string, any>, externalState: Record<string, any>, omit?: string[]): {
|
|
16
17
|
stop(): void;
|
|
17
18
|
};
|
|
19
|
+
/** The component being set up. Throws outside `setup`, where Vue returns null. */
|
|
20
|
+
export declare function useInstance(name: string): ComponentInternalInstance;
|
package/dist/client/codegen.d.ts
CHANGED
|
@@ -1,4 +1,33 @@
|
|
|
1
1
|
import type { Variant } from '@poveste/shared';
|
|
2
2
|
import type { VNode } from 'vue';
|
|
3
3
|
export declare function generateSourceCode(variant: Variant): Promise<string>;
|
|
4
|
+
/**
|
|
5
|
+
* How to delimit an attribute whose value is arbitrary code.
|
|
6
|
+
*
|
|
7
|
+
* The source pane shows template source a reader copies, so the code has to
|
|
8
|
+
* survive as written. The pass this replaces escaped `'` for a JavaScript
|
|
9
|
+
* string and rewrote `"` into `'`, and the consumer is neither — it is an
|
|
10
|
+
* attribute delimited by `"`. Both halves reached the reader: a handler written
|
|
11
|
+
* `() => alert("hi")` was shown as `() => alert('hi')`, and one written
|
|
12
|
+
* `() => alert('hi')` came out with visible backslashes, which reads as a bug
|
|
13
|
+
* in the reader's own code rather than as our rendering.
|
|
14
|
+
*
|
|
15
|
+
* The order made it worse. Every `'` the rewrite introduced arrived after the
|
|
16
|
+
* escaping pass, so an authored quote was escaped and a manufactured one was
|
|
17
|
+
* not. A backslash was never escaped at all, which is what CodeQL flagged as
|
|
18
|
+
* `js/incomplete-sanitization`: `() => alert('it\'s')` went in carrying one
|
|
19
|
+
* and came out carrying four.
|
|
20
|
+
*
|
|
21
|
+
* So nothing is escaped for a string context. Code containing `"` takes the
|
|
22
|
+
* other delimiter, the way someone writing the template by hand would. Code
|
|
23
|
+
* carrying both quote characters has no free delimiter, so whichever it takes
|
|
24
|
+
* is escaped inside it — and the one appearing less often wins, because every
|
|
25
|
+
* escape is a character the author did not write. That is `'` as often as
|
|
26
|
+
* `"`: the repository's own `get-name` fixture holds two doubles and one
|
|
27
|
+
* single, so the single is the cheaper one there (#602).
|
|
28
|
+
*/
|
|
29
|
+
export declare function delimitAttr(lines: string[]): {
|
|
30
|
+
quote: string;
|
|
31
|
+
lines: string[];
|
|
32
|
+
};
|
|
4
33
|
export declare function getTagName(vnode: VNode): any;
|
|
@@ -3,27 +3,27 @@ import type { PropType } from 'vue';
|
|
|
3
3
|
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
4
4
|
title: {
|
|
5
5
|
type: StringConstructor;
|
|
6
|
-
default:
|
|
6
|
+
default: undefined;
|
|
7
7
|
};
|
|
8
8
|
id: {
|
|
9
9
|
type: StringConstructor;
|
|
10
|
-
default:
|
|
10
|
+
default: undefined;
|
|
11
11
|
};
|
|
12
12
|
group: {
|
|
13
13
|
type: StringConstructor;
|
|
14
|
-
default:
|
|
14
|
+
default: undefined;
|
|
15
15
|
};
|
|
16
16
|
layout: {
|
|
17
17
|
type: PropType<ServerStory["layout"]>;
|
|
18
|
-
default:
|
|
18
|
+
default: undefined;
|
|
19
19
|
};
|
|
20
20
|
icon: {
|
|
21
21
|
type: StringConstructor;
|
|
22
|
-
default:
|
|
22
|
+
default: undefined;
|
|
23
23
|
};
|
|
24
24
|
iconColor: {
|
|
25
25
|
type: StringConstructor;
|
|
26
|
-
default:
|
|
26
|
+
default: undefined;
|
|
27
27
|
};
|
|
28
28
|
docsOnly: {
|
|
29
29
|
type: BooleanConstructor;
|
|
@@ -31,34 +31,34 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
31
31
|
};
|
|
32
32
|
meta: {
|
|
33
33
|
type: PropType<ServerStory["meta"]>;
|
|
34
|
-
default:
|
|
34
|
+
default: undefined;
|
|
35
35
|
};
|
|
36
36
|
}>, {
|
|
37
37
|
story: ServerStory;
|
|
38
38
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
39
39
|
title: {
|
|
40
40
|
type: StringConstructor;
|
|
41
|
-
default:
|
|
41
|
+
default: undefined;
|
|
42
42
|
};
|
|
43
43
|
id: {
|
|
44
44
|
type: StringConstructor;
|
|
45
|
-
default:
|
|
45
|
+
default: undefined;
|
|
46
46
|
};
|
|
47
47
|
group: {
|
|
48
48
|
type: StringConstructor;
|
|
49
|
-
default:
|
|
49
|
+
default: undefined;
|
|
50
50
|
};
|
|
51
51
|
layout: {
|
|
52
52
|
type: PropType<ServerStory["layout"]>;
|
|
53
|
-
default:
|
|
53
|
+
default: undefined;
|
|
54
54
|
};
|
|
55
55
|
icon: {
|
|
56
56
|
type: StringConstructor;
|
|
57
|
-
default:
|
|
57
|
+
default: undefined;
|
|
58
58
|
};
|
|
59
59
|
iconColor: {
|
|
60
60
|
type: StringConstructor;
|
|
61
|
-
default:
|
|
61
|
+
default: undefined;
|
|
62
62
|
};
|
|
63
63
|
docsOnly: {
|
|
64
64
|
type: BooleanConstructor;
|
|
@@ -66,14 +66,14 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
66
66
|
};
|
|
67
67
|
meta: {
|
|
68
68
|
type: PropType<ServerStory["meta"]>;
|
|
69
|
-
default:
|
|
69
|
+
default: undefined;
|
|
70
70
|
};
|
|
71
71
|
}>> & Readonly<{}>, {
|
|
72
|
-
meta: import("poveste").StoryMeta;
|
|
73
|
-
title: string;
|
|
72
|
+
meta: import("poveste").StoryMeta | undefined;
|
|
74
73
|
id: string;
|
|
74
|
+
title: string;
|
|
75
75
|
group: string;
|
|
76
|
-
layout: import("poveste").StoryLayout;
|
|
76
|
+
layout: import("poveste").StoryLayout | undefined;
|
|
77
77
|
icon: string;
|
|
78
78
|
iconColor: string;
|
|
79
79
|
docsOnly: boolean;
|
|
@@ -7,19 +7,19 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
7
7
|
};
|
|
8
8
|
id: {
|
|
9
9
|
type: StringConstructor;
|
|
10
|
-
default:
|
|
10
|
+
default: undefined;
|
|
11
11
|
};
|
|
12
12
|
icon: {
|
|
13
13
|
type: StringConstructor;
|
|
14
|
-
default:
|
|
14
|
+
default: undefined;
|
|
15
15
|
};
|
|
16
16
|
iconColor: {
|
|
17
17
|
type: StringConstructor;
|
|
18
|
-
default:
|
|
18
|
+
default: undefined;
|
|
19
19
|
};
|
|
20
20
|
meta: {
|
|
21
21
|
type: PropType<ServerVariant["meta"]>;
|
|
22
|
-
default:
|
|
22
|
+
default: undefined;
|
|
23
23
|
};
|
|
24
24
|
}>, void, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
25
25
|
title: {
|
|
@@ -28,24 +28,24 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
28
28
|
};
|
|
29
29
|
id: {
|
|
30
30
|
type: StringConstructor;
|
|
31
|
-
default:
|
|
31
|
+
default: undefined;
|
|
32
32
|
};
|
|
33
33
|
icon: {
|
|
34
34
|
type: StringConstructor;
|
|
35
|
-
default:
|
|
35
|
+
default: undefined;
|
|
36
36
|
};
|
|
37
37
|
iconColor: {
|
|
38
38
|
type: StringConstructor;
|
|
39
|
-
default:
|
|
39
|
+
default: undefined;
|
|
40
40
|
};
|
|
41
41
|
meta: {
|
|
42
42
|
type: PropType<ServerVariant["meta"]>;
|
|
43
|
-
default:
|
|
43
|
+
default: undefined;
|
|
44
44
|
};
|
|
45
45
|
}>> & Readonly<{}>, {
|
|
46
|
-
meta:
|
|
47
|
-
title: string;
|
|
46
|
+
meta: import("poveste").VariantMeta | undefined;
|
|
48
47
|
id: string;
|
|
48
|
+
title: string;
|
|
49
49
|
icon: string;
|
|
50
50
|
iconColor: string;
|
|
51
51
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|