@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,66 @@
|
|
|
1
|
+
import { applyState as c } from "@poveste/shared";
|
|
2
|
+
import { getTagName as m } from "../codegen.js";
|
|
3
|
+
function b(t, o, e, p) {
|
|
4
|
+
const r = h(o, e), i = JSON.stringify(r);
|
|
5
|
+
return (!p || p !== i) && (c(t.state, {
|
|
6
|
+
_hPropDefs: r
|
|
7
|
+
}), t.state._hPropState || c(t.state, {
|
|
8
|
+
_hPropState: {}
|
|
9
|
+
})), i;
|
|
10
|
+
}
|
|
11
|
+
function h(t, o) {
|
|
12
|
+
const e = [];
|
|
13
|
+
return y(t, o, {
|
|
14
|
+
index: 0
|
|
15
|
+
}, e), e.filter((r) => r.props.length);
|
|
16
|
+
}
|
|
17
|
+
function y(t, o, e, p) {
|
|
18
|
+
for (const r of l(t))
|
|
19
|
+
if (r) {
|
|
20
|
+
if (typeof r.type == "object") {
|
|
21
|
+
const i = e.index++, a = [];
|
|
22
|
+
for (const s in r.type.props) {
|
|
23
|
+
const n = r.type.props[s];
|
|
24
|
+
let u, f;
|
|
25
|
+
n && (u = (Array.isArray(n.type) ? n.type : typeof n == "function" ? [n] : [n.type]).map((d) => {
|
|
26
|
+
switch (d) {
|
|
27
|
+
case String:
|
|
28
|
+
return "string";
|
|
29
|
+
case Number:
|
|
30
|
+
return "number";
|
|
31
|
+
case Boolean:
|
|
32
|
+
return "boolean";
|
|
33
|
+
case Object:
|
|
34
|
+
return "object";
|
|
35
|
+
case Array:
|
|
36
|
+
return "array";
|
|
37
|
+
default:
|
|
38
|
+
return "unknown";
|
|
39
|
+
}
|
|
40
|
+
}), f = typeof n.default == "function" ? n.default.toString() : n.default), a.push({
|
|
41
|
+
name: s,
|
|
42
|
+
types: u,
|
|
43
|
+
required: n?.required,
|
|
44
|
+
default: f
|
|
45
|
+
}), o?._hPropState?.[i]?.[s] != null && (r.props || (r.props = {}), r.props[s] = o._hPropState[i][s], r.dynamicProps || (r.dynamicProps = []), r.dynamicProps.includes(s) || r.dynamicProps.push(s));
|
|
46
|
+
}
|
|
47
|
+
p.push({
|
|
48
|
+
name: m(r),
|
|
49
|
+
index: i,
|
|
50
|
+
props: a
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
Array.isArray(r.children) && y(r.children, o, e, p);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function l(t) {
|
|
57
|
+
if (!Array.isArray(t))
|
|
58
|
+
return t == null ? [] : [t];
|
|
59
|
+
const o = [];
|
|
60
|
+
for (const e of t)
|
|
61
|
+
Array.isArray(e) ? o.push(...l(e)) : e != null && o.push(e);
|
|
62
|
+
return o;
|
|
63
|
+
}
|
|
64
|
+
export {
|
|
65
|
+
b as syncVariantAutoProps
|
|
66
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { components as v } from "@poveste/controls";
|
|
2
|
+
import { reactive as y, createApp as E, h as C } from "@poveste/vendors/vue";
|
|
3
|
+
import { defineComponent as g, h as u, ref as d, onBeforeUpdate as $, onMounted as w, onUpdated as U, onBeforeUnmount as b } from "vue";
|
|
4
|
+
import k from "./Story.js";
|
|
5
|
+
import q from "./Variant.js";
|
|
6
|
+
function M(e) {
|
|
7
|
+
e.component("Story", k), e.component("Variant", q);
|
|
8
|
+
for (const o in v)
|
|
9
|
+
e.component(o, A(v[o]));
|
|
10
|
+
}
|
|
11
|
+
function A(e) {
|
|
12
|
+
return g({
|
|
13
|
+
name: e.name,
|
|
14
|
+
inheritAttrs: !1,
|
|
15
|
+
setup(o, { attrs: n }) {
|
|
16
|
+
const a = d(), p = d(), m = y({});
|
|
17
|
+
function c(l) {
|
|
18
|
+
Object.assign(m, l);
|
|
19
|
+
}
|
|
20
|
+
c(n), $(() => {
|
|
21
|
+
c(n);
|
|
22
|
+
});
|
|
23
|
+
let t = [];
|
|
24
|
+
const r = d([]);
|
|
25
|
+
function S() {
|
|
26
|
+
r.value.forEach((l, f) => {
|
|
27
|
+
const h = p.value.querySelector(`[renderslotid="${f}"]`);
|
|
28
|
+
if (!h) return;
|
|
29
|
+
const s = a.value.querySelector(`[slotid="${f}"]`);
|
|
30
|
+
for (; s.firstChild; )
|
|
31
|
+
s.removeChild(s.lastChild);
|
|
32
|
+
s.appendChild(h);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
let i;
|
|
36
|
+
return w(() => {
|
|
37
|
+
i = E({
|
|
38
|
+
mounted() {
|
|
39
|
+
r.value = t, t = [];
|
|
40
|
+
},
|
|
41
|
+
updated() {
|
|
42
|
+
r.value = t, t = [];
|
|
43
|
+
},
|
|
44
|
+
render() {
|
|
45
|
+
return C(e, {
|
|
46
|
+
...m,
|
|
47
|
+
key: "component"
|
|
48
|
+
}, {
|
|
49
|
+
default: (l) => (t.push(l), C("div", {
|
|
50
|
+
slotId: t.length - 1
|
|
51
|
+
}))
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}), i.mount(a.value);
|
|
55
|
+
}), U(() => {
|
|
56
|
+
S();
|
|
57
|
+
}), b(() => {
|
|
58
|
+
i.unmount();
|
|
59
|
+
}), {
|
|
60
|
+
el: a,
|
|
61
|
+
slotEl: p,
|
|
62
|
+
slotCalls: r
|
|
63
|
+
};
|
|
64
|
+
},
|
|
65
|
+
render() {
|
|
66
|
+
return [
|
|
67
|
+
u("div", {
|
|
68
|
+
ref: "el"
|
|
69
|
+
}),
|
|
70
|
+
u("div", {
|
|
71
|
+
ref: "slotEl"
|
|
72
|
+
}, this.slotCalls.map((o, n) => u("div", {
|
|
73
|
+
renderSlotId: n
|
|
74
|
+
}, this.$slots.default(o))))
|
|
75
|
+
];
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
export {
|
|
80
|
+
M as registerGlobalComponents
|
|
81
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import * as a from "virtual:$histoire-generated-global-setup";
|
|
2
|
+
import * as i from "virtual:$histoire-setup";
|
|
3
|
+
import { defineComponent as l, h as o, createApp as y, Suspense as v } from "vue";
|
|
4
|
+
import { registerGlobalComponents as w } from "./global-components.js";
|
|
5
|
+
import { provideRenderContext as C } from "./render-context.js";
|
|
6
|
+
import { RouterLinkStub as g } from "./RouterLinkStub.js";
|
|
7
|
+
const x = l({
|
|
8
|
+
name: "PreviewHostRoot",
|
|
9
|
+
props: {
|
|
10
|
+
story: {
|
|
11
|
+
type: Object,
|
|
12
|
+
required: !0
|
|
13
|
+
},
|
|
14
|
+
renderContext: {
|
|
15
|
+
type: Object,
|
|
16
|
+
required: !0
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
setup(e) {
|
|
20
|
+
return C(e.renderContext), () => o(e.story.file.component, {
|
|
21
|
+
story: e.story
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
function H(e) {
|
|
26
|
+
let t = null, r = null;
|
|
27
|
+
async function p() {
|
|
28
|
+
const u = [];
|
|
29
|
+
r = document.createElement("div"), e.el.appendChild(r), t = y({
|
|
30
|
+
name: e.name,
|
|
31
|
+
render: () => {
|
|
32
|
+
let n = o(x, {
|
|
33
|
+
story: e.getStory(),
|
|
34
|
+
renderContext: e.renderContext
|
|
35
|
+
});
|
|
36
|
+
for (const m of u) {
|
|
37
|
+
const d = n;
|
|
38
|
+
n = o(m, {
|
|
39
|
+
story: e.getStory(),
|
|
40
|
+
variant: e.getVariant()
|
|
41
|
+
}, () => d);
|
|
42
|
+
}
|
|
43
|
+
return e.wrapInDiv && (n = o("div", n)), o(v, {}, n);
|
|
44
|
+
}
|
|
45
|
+
}), w(t), t.component("RouterLink", g);
|
|
46
|
+
const f = {
|
|
47
|
+
app: t,
|
|
48
|
+
story: e.getStory(),
|
|
49
|
+
variant: e.getVariant(),
|
|
50
|
+
addWrapper: (n) => {
|
|
51
|
+
u.unshift(n);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
await S(f), t.mount(r);
|
|
55
|
+
}
|
|
56
|
+
function c() {
|
|
57
|
+
t?.unmount(), t = null, r && (r.parentNode?.removeChild(r), r = null);
|
|
58
|
+
}
|
|
59
|
+
function s() {
|
|
60
|
+
t?._instance?.proxy?.$forceUpdate();
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
mount: p,
|
|
64
|
+
unmount: c,
|
|
65
|
+
forceUpdate: s
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
async function S(e) {
|
|
69
|
+
if (typeof a?.setupVue3 == "function") {
|
|
70
|
+
const t = a.setupVue3;
|
|
71
|
+
await t(e);
|
|
72
|
+
}
|
|
73
|
+
if (typeof i?.setupVue3 == "function") {
|
|
74
|
+
const t = i.setupVue3;
|
|
75
|
+
await t(e);
|
|
76
|
+
}
|
|
77
|
+
if (typeof e.variant?.setupApp == "function") {
|
|
78
|
+
const t = e.variant.setupApp;
|
|
79
|
+
await t(e);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
export {
|
|
83
|
+
H as createPreviewHost
|
|
84
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { provide as n, inject as r } from "vue";
|
|
2
|
+
const e = /* @__PURE__ */ Symbol("histoire-preview-render-context");
|
|
3
|
+
function i(t) {
|
|
4
|
+
n(e, t);
|
|
5
|
+
}
|
|
6
|
+
function c() {
|
|
7
|
+
return r(e, null);
|
|
8
|
+
}
|
|
9
|
+
export {
|
|
10
|
+
i as provideRenderContext,
|
|
11
|
+
c as useRenderContext
|
|
12
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { applyState as f } from "@poveste/shared";
|
|
2
|
+
import { isRef as c, unref as p, watch as l } from "@poveste/vendors/vue";
|
|
3
|
+
import { isRef as m, unref as w, watch as y } from "vue";
|
|
4
|
+
const i = (n) => n !== null && typeof n == "object";
|
|
5
|
+
function o(n, e = /* @__PURE__ */ new WeakMap()) {
|
|
6
|
+
const t = m(n) ? w(n) : n;
|
|
7
|
+
if (typeof t == "symbol")
|
|
8
|
+
return t.toString();
|
|
9
|
+
if (!i(t))
|
|
10
|
+
return t;
|
|
11
|
+
if (e.has(t))
|
|
12
|
+
return e.get(t);
|
|
13
|
+
if (Array.isArray(t)) {
|
|
14
|
+
const r = [];
|
|
15
|
+
return e.set(t, r), r.push(...t.map((u) => o(u, e))), r;
|
|
16
|
+
} else {
|
|
17
|
+
const r = {};
|
|
18
|
+
return e.set(t, r), h(t, r, e), r;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function h(n, e, t = /* @__PURE__ */ new WeakMap()) {
|
|
22
|
+
Object.keys(n).forEach((r) => {
|
|
23
|
+
e[r] = o(n[r], t);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
function a(n, e = /* @__PURE__ */ new WeakMap()) {
|
|
27
|
+
const t = c(n) ? p(n) : n;
|
|
28
|
+
if (typeof t == "symbol")
|
|
29
|
+
return t.toString();
|
|
30
|
+
if (!i(t))
|
|
31
|
+
return t;
|
|
32
|
+
if (e.has(t))
|
|
33
|
+
return e.get(t);
|
|
34
|
+
if (Array.isArray(t)) {
|
|
35
|
+
const r = [];
|
|
36
|
+
return e.set(t, r), r.push(...t.map((u) => a(u, e))), r;
|
|
37
|
+
} else {
|
|
38
|
+
const r = {};
|
|
39
|
+
return e.set(t, r), d(t, r, e), r;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function d(n, e, t = /* @__PURE__ */ new WeakMap()) {
|
|
43
|
+
Object.keys(n).forEach((r) => {
|
|
44
|
+
e[r] = o(n[r], t);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
function A(n, e) {
|
|
48
|
+
let t = !1;
|
|
49
|
+
const r = l(() => n, (s) => {
|
|
50
|
+
s != null && (t ? t = !1 : (t = !0, f(e, a(s))));
|
|
51
|
+
}, {
|
|
52
|
+
deep: !0,
|
|
53
|
+
immediate: !0
|
|
54
|
+
}), u = y(() => e, (s) => {
|
|
55
|
+
s != null && (t ? t = !1 : (t = !0, f(n, o(s))));
|
|
56
|
+
}, {
|
|
57
|
+
deep: !0,
|
|
58
|
+
immediate: !0
|
|
59
|
+
});
|
|
60
|
+
return {
|
|
61
|
+
stop() {
|
|
62
|
+
r(), u();
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
export {
|
|
67
|
+
a as _toRawDeep,
|
|
68
|
+
A as syncStateBundledAndExternal,
|
|
69
|
+
o as toRawDeep
|
|
70
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import "./app/index.js";
|
|
2
|
+
import { generateSourceCode as o, getTagName as a } from "./codegen.js";
|
|
3
|
+
import { default as m } from "./app/MountStory.js";
|
|
4
|
+
import { default as d } from "./app/RenderStory.js";
|
|
5
|
+
export {
|
|
6
|
+
m as MountStory,
|
|
7
|
+
d as RenderStory,
|
|
8
|
+
o as generateSourceCode,
|
|
9
|
+
a as getTagName
|
|
10
|
+
};
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { createAutoBuildingObject as K, indent as _, voidElements as N, serializeJs as P } from "@poveste/shared";
|
|
2
|
+
import { camelCase as M, pascalCase as U } from "../node_modules/.pnpm/change-case@5.4.4/node_modules/change-case/dist/index.js";
|
|
3
|
+
import { Text as W, vModelText as z, vModelSelect as D, vModelRadio as F, vModelCheckbox as E, vModelDynamic as J } from "vue";
|
|
4
|
+
async function I(t) {
|
|
5
|
+
const o = t.slots().default?.({ state: t.state ?? {} }) ?? [], a = Array.isArray(o) ? o : [o], b = [];
|
|
6
|
+
for (const L in a) {
|
|
7
|
+
const g = a[L];
|
|
8
|
+
b.push(...(await x(g, t.state?._hPropState?.[L])).lines);
|
|
9
|
+
}
|
|
10
|
+
return b.join(`
|
|
11
|
+
`);
|
|
12
|
+
}
|
|
13
|
+
async function x(t, o = null) {
|
|
14
|
+
if (t.type === W)
|
|
15
|
+
return {
|
|
16
|
+
// @ts-expect-error TODO
|
|
17
|
+
lines: [t.children],
|
|
18
|
+
isText: !0
|
|
19
|
+
};
|
|
20
|
+
const a = [];
|
|
21
|
+
if (typeof t.type == "object" || typeof t.type == "string") {
|
|
22
|
+
let g = function(e, s, i = null) {
|
|
23
|
+
let n = "";
|
|
24
|
+
for (const y in s.modifiers)
|
|
25
|
+
s.modifiers[y] && (n += `.${y}`);
|
|
26
|
+
let u = "";
|
|
27
|
+
s.arg && (u = `:${s.arg}`), i && (i = i.replace(/^\$(setup|props|data)\./g, ""));
|
|
28
|
+
const r = i ? [i] : V(s.value), l = [], f = `v-${e}${u}${n}="`;
|
|
29
|
+
r.length > 1 ? (l.push(`${f}${r[0]}`), l.push(...r.slice(1, r.length - 1)), l.push(`${r[r.length - 1]}"`), $ = !0) : l.push(`${f}${r[0] ?? ""}"`), p.push(l);
|
|
30
|
+
}, S = function(e, s) {
|
|
31
|
+
if (typeof s != "string" || t.dynamicProps?.includes(e)) {
|
|
32
|
+
let i = ":";
|
|
33
|
+
e.startsWith("on") && (i = "@");
|
|
34
|
+
const n = i === "@" ? `${e[2].toLowerCase()}${e.slice(3)}` : e, r = [`onUpdate:${e}`, `onUpdate:${M(e)}`].find((f) => t.dynamicProps?.includes(f) || t.props && f in t.props);
|
|
35
|
+
if (i === ":" && r) {
|
|
36
|
+
m.push(r);
|
|
37
|
+
const y = t.props[r].toString();
|
|
38
|
+
let C;
|
|
39
|
+
const w = /\(\$event\) => (.*?) = \$event/.exec(y);
|
|
40
|
+
w && (C = w[1]);
|
|
41
|
+
const T = `${e === "modelValue" ? "model" : e}Modifiers`, B = t.props[T] ?? {};
|
|
42
|
+
m.push(T), g("model", {
|
|
43
|
+
arg: e === "modelValue" ? null : e,
|
|
44
|
+
modifiers: B,
|
|
45
|
+
value: s
|
|
46
|
+
}, C);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (typeof s > "u")
|
|
50
|
+
return;
|
|
51
|
+
let l;
|
|
52
|
+
if (typeof s == "string" && s.startsWith("{{") && s.endsWith("}}"))
|
|
53
|
+
l = A(s.substring(2, s.length - 2).trim()).split(`
|
|
54
|
+
`);
|
|
55
|
+
else if (typeof s == "function") {
|
|
56
|
+
let f = A(s.toString().replace(/'/g, "\\'").replace(/"/g, "'"));
|
|
57
|
+
const y = /function (\S+)\(/.exec(f);
|
|
58
|
+
y ? l = [y[1]] : (f.startsWith("($event) => ") && (f = f.substring(12)), l = f.split(`
|
|
59
|
+
`));
|
|
60
|
+
} else
|
|
61
|
+
l = V(s);
|
|
62
|
+
if (l.length > 1) {
|
|
63
|
+
$ = !0;
|
|
64
|
+
const f = [`${i}${n}="${l[0]}`];
|
|
65
|
+
f.push(...l.slice(1, l.length - 1)), f.push(`${l[l.length - 1]}"`), p.push(f);
|
|
66
|
+
} else
|
|
67
|
+
p.push([`${i}${n}="${l[0]}"`]);
|
|
68
|
+
} else t.type?.props?.[e]?.type === Boolean ? p.push([e]) : p.push([`${e}="${s}"`]);
|
|
69
|
+
};
|
|
70
|
+
var b = g, L = S;
|
|
71
|
+
t.type?.__asyncLoader && !t.type.__asyncResolved && await t.type.__asyncLoader();
|
|
72
|
+
const p = [];
|
|
73
|
+
let $ = !1;
|
|
74
|
+
const m = [
|
|
75
|
+
"key"
|
|
76
|
+
];
|
|
77
|
+
if (t.dirs) {
|
|
78
|
+
for (const e of t.dirs)
|
|
79
|
+
if (e.dir === z || e.dir === D || e.dir === F || e.dir === E || e.dir === J) {
|
|
80
|
+
const i = [`onUpdate:${e.arg ?? "modelValue"}`, `onUpdate:${M(e.arg ?? "modelValue")}`].find((r) => t.props[r]), n = t.props[i];
|
|
81
|
+
let u = null;
|
|
82
|
+
if (n) {
|
|
83
|
+
m.push(i);
|
|
84
|
+
const r = n.toString(), l = /\(\$event\) => (.*?) = \$event/.exec(r);
|
|
85
|
+
l && (u = l[1]);
|
|
86
|
+
}
|
|
87
|
+
g("model", e, u);
|
|
88
|
+
} else if (e.instance._ || e.instance.$) {
|
|
89
|
+
const s = e.instance.$ ?? e.instance._;
|
|
90
|
+
let i;
|
|
91
|
+
for (const n of [s.directives, s.appContext.directives]) {
|
|
92
|
+
for (const u in n)
|
|
93
|
+
if (n[u] === e.dir) {
|
|
94
|
+
i = u;
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
if (i) break;
|
|
98
|
+
}
|
|
99
|
+
if (!i) {
|
|
100
|
+
for (const n in s.setupState)
|
|
101
|
+
if (s.setupState[n] === e.dir) {
|
|
102
|
+
i = n.replace(/^v(\w)/, (u, r) => r.toLowerCase());
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
i && g(i, e);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
for (const e in t.props) {
|
|
110
|
+
if (m.includes(e) || o && e in o)
|
|
111
|
+
continue;
|
|
112
|
+
const s = t.props[e];
|
|
113
|
+
S(e, s);
|
|
114
|
+
}
|
|
115
|
+
if (o)
|
|
116
|
+
for (const e in o)
|
|
117
|
+
S(e, o[e]);
|
|
118
|
+
p.length > 1 && ($ = !0);
|
|
119
|
+
const d = O(t);
|
|
120
|
+
let j = !1;
|
|
121
|
+
const c = [];
|
|
122
|
+
if (typeof t.children == "string")
|
|
123
|
+
d === "pre" ? c.push(t.children) : c.push(...t.children.split(`
|
|
124
|
+
`)), j = !0;
|
|
125
|
+
else if (Array.isArray(t.children)) {
|
|
126
|
+
let e;
|
|
127
|
+
for (const s of t.children) {
|
|
128
|
+
const i = await x(s);
|
|
129
|
+
if (i.isText) {
|
|
130
|
+
e === void 0 && (e = !0);
|
|
131
|
+
const n = i.lines[0];
|
|
132
|
+
!c.length || /^\s/.test(n) ? c.push(n.trim()) : c[c.length - 1] += n;
|
|
133
|
+
} else
|
|
134
|
+
e === void 0 && (e = !1), c.push(...i.lines);
|
|
135
|
+
}
|
|
136
|
+
e !== void 0 && (j = e);
|
|
137
|
+
}
|
|
138
|
+
if (t.children && typeof t.children == "object" && !Array.isArray(t.children)) {
|
|
139
|
+
for (const e in t.children)
|
|
140
|
+
if (typeof t.children[e] == "function") {
|
|
141
|
+
const s = K((r) => `{{ ${r} }}`, (r, l) => {
|
|
142
|
+
if (l === "__v_isRef")
|
|
143
|
+
return () => !1;
|
|
144
|
+
}), i = t.children[e](s.proxy), n = [];
|
|
145
|
+
for (const r of i)
|
|
146
|
+
n.push(...(await x(r)).lines);
|
|
147
|
+
const u = Object.keys(s.cache);
|
|
148
|
+
u.length ? (c.push(`<template #${e}="{ ${u.join(", ")} }">`), c.push(..._(n)), c.push("</template>")) : e === "default" ? c.push(...n) : (c.push(`<template #${e}>`), c.push(..._(n)), c.push("</template>"));
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
const h = [`<${d}`];
|
|
152
|
+
if ($) {
|
|
153
|
+
for (const e of p)
|
|
154
|
+
h.push(..._(e));
|
|
155
|
+
c.length > 0 && h.push(">");
|
|
156
|
+
} else
|
|
157
|
+
p.length === 1 && (h[0] += ` ${p[0]}`), c.length > 0 && (h[0] += ">");
|
|
158
|
+
const k = N.includes(d.toLowerCase());
|
|
159
|
+
c.length > 0 ? c.length === 1 && h.length === 1 && !p.length && j ? a.push(`${h[0]}${c[0]}</${d}>`) : (a.push(...h), a.push(..._(c)), a.push(`</${d}>`)) : h.length > 1 ? (a.push(...h), a.push(k ? ">" : "/>")) : a.push(`${h[0]}${k ? "" : " /"}>`);
|
|
160
|
+
} else if (t?.shapeFlag & 16)
|
|
161
|
+
for (const g of t.children)
|
|
162
|
+
a.push(...(await x(g)).lines);
|
|
163
|
+
return {
|
|
164
|
+
lines: a
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
function O(t) {
|
|
168
|
+
if (typeof t.type == "string")
|
|
169
|
+
return t.type;
|
|
170
|
+
if (t.type?.__asyncResolved) {
|
|
171
|
+
const o = t.type?.__asyncResolved;
|
|
172
|
+
return o.name ?? R(o.__file);
|
|
173
|
+
} else {
|
|
174
|
+
if (t.type?.name)
|
|
175
|
+
return t.type.name;
|
|
176
|
+
if (t.type?.__file)
|
|
177
|
+
return R(t.type.__file);
|
|
178
|
+
}
|
|
179
|
+
return "Anonymous";
|
|
180
|
+
}
|
|
181
|
+
function R(t) {
|
|
182
|
+
const o = /([^/]+)\.vue$/.exec(t);
|
|
183
|
+
return o ? U(o[1]) : "Anonymous";
|
|
184
|
+
}
|
|
185
|
+
function V(t) {
|
|
186
|
+
const o = !!t?.__autoBuildingObject, a = P(t);
|
|
187
|
+
return o ? [A(a.__autoBuildingObjectGetKey)] : A(a).split(`
|
|
188
|
+
`);
|
|
189
|
+
}
|
|
190
|
+
function A(t) {
|
|
191
|
+
return t.replace(/\$setup\./g, "");
|
|
192
|
+
}
|
|
193
|
+
export {
|
|
194
|
+
I as generateSourceCode,
|
|
195
|
+
O as getTagName
|
|
196
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { defineComponent as i, useAttrs as n, inject as d, provide as r, onMounted as l } from "vue";
|
|
2
|
+
import { autoStubComponents as u } from "./stub.js";
|
|
3
|
+
const c = i({
|
|
4
|
+
name: "PovesteStory",
|
|
5
|
+
inheritAttrs: !1,
|
|
6
|
+
props: {
|
|
7
|
+
title: {
|
|
8
|
+
type: String,
|
|
9
|
+
default: void 0
|
|
10
|
+
},
|
|
11
|
+
id: {
|
|
12
|
+
type: String,
|
|
13
|
+
default: void 0
|
|
14
|
+
},
|
|
15
|
+
group: {
|
|
16
|
+
type: String,
|
|
17
|
+
default: void 0
|
|
18
|
+
},
|
|
19
|
+
layout: {
|
|
20
|
+
type: Object,
|
|
21
|
+
default: void 0
|
|
22
|
+
},
|
|
23
|
+
icon: {
|
|
24
|
+
type: String,
|
|
25
|
+
default: void 0
|
|
26
|
+
},
|
|
27
|
+
iconColor: {
|
|
28
|
+
type: String,
|
|
29
|
+
default: void 0
|
|
30
|
+
},
|
|
31
|
+
docsOnly: {
|
|
32
|
+
type: Boolean,
|
|
33
|
+
default: !1
|
|
34
|
+
},
|
|
35
|
+
meta: {
|
|
36
|
+
type: Object,
|
|
37
|
+
default: void 0
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
setup(t) {
|
|
41
|
+
const e = n(), o = {
|
|
42
|
+
id: t.id ?? e.data.id,
|
|
43
|
+
title: t.title ?? e.data.fileName,
|
|
44
|
+
group: t.group,
|
|
45
|
+
layout: t.layout,
|
|
46
|
+
icon: t.icon,
|
|
47
|
+
iconColor: t.iconColor,
|
|
48
|
+
docsOnly: t.docsOnly,
|
|
49
|
+
meta: t.meta,
|
|
50
|
+
variants: []
|
|
51
|
+
};
|
|
52
|
+
return d("addStory", null)?.(o), r("story", o), r("addVariant", (a) => {
|
|
53
|
+
o.variants.push(a);
|
|
54
|
+
}), l(() => {
|
|
55
|
+
o.variants.length || o.variants.push({
|
|
56
|
+
id: "_default",
|
|
57
|
+
title: "default"
|
|
58
|
+
});
|
|
59
|
+
}), {
|
|
60
|
+
story: o
|
|
61
|
+
};
|
|
62
|
+
},
|
|
63
|
+
render() {
|
|
64
|
+
let t = !1;
|
|
65
|
+
try {
|
|
66
|
+
const e = this.$slots.default?.({
|
|
67
|
+
get state() {
|
|
68
|
+
return t = !0, {};
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
return Array.isArray(e) && u(e), e;
|
|
72
|
+
} catch (e) {
|
|
73
|
+
return t || console.error(e), null;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
export {
|
|
78
|
+
c as default
|
|
79
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { defineComponent as o, inject as n } from "vue";
|
|
2
|
+
const l = o({
|
|
3
|
+
name: "PovesteVariant",
|
|
4
|
+
props: {
|
|
5
|
+
title: {
|
|
6
|
+
type: String,
|
|
7
|
+
default: "untitled"
|
|
8
|
+
},
|
|
9
|
+
id: {
|
|
10
|
+
type: String,
|
|
11
|
+
default: void 0
|
|
12
|
+
},
|
|
13
|
+
icon: {
|
|
14
|
+
type: String,
|
|
15
|
+
default: void 0
|
|
16
|
+
},
|
|
17
|
+
iconColor: {
|
|
18
|
+
type: String,
|
|
19
|
+
default: void 0
|
|
20
|
+
},
|
|
21
|
+
meta: {
|
|
22
|
+
type: Object,
|
|
23
|
+
default: void 0
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
setup(t) {
|
|
27
|
+
const e = n("story");
|
|
28
|
+
function i() {
|
|
29
|
+
return `${e.id}-${e.variants.length}`;
|
|
30
|
+
}
|
|
31
|
+
const a = {
|
|
32
|
+
id: t.id ?? i(),
|
|
33
|
+
title: t.title,
|
|
34
|
+
icon: t.icon,
|
|
35
|
+
iconColor: t.iconColor,
|
|
36
|
+
meta: t.meta
|
|
37
|
+
};
|
|
38
|
+
n("addVariant")(a);
|
|
39
|
+
},
|
|
40
|
+
render() {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
export {
|
|
45
|
+
l as default
|
|
46
|
+
};
|