@poveste/plugin-vue 0.19.1 → 0.21.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 +7 -0
- package/dist/bundled/client/app/MountStory.js +32 -30
- package/dist/bundled/client/app/RenderStory.js +39 -44
- package/dist/bundled/client/app/Story.js +62 -60
- package/dist/bundled/client/app/global-components.js +5 -3
- package/dist/bundled/client/app/host.js +9 -5
- package/dist/bundled/client/app/util.js +46 -33
- package/dist/bundled/client/server/Story.js +13 -0
- package/dist/bundled/client/server/collect.js +41 -0
- package/dist/bundled/client/server/run.js +10 -39
- package/dist/bundled/client/server.js +1 -2
- package/dist/bundled/testing/index.js +168 -0
- package/dist/client/app/Story.d.ts +19 -1
- package/dist/client/app/Variant.d.ts +2 -2
- package/dist/client/app/global-components.d.ts +1 -0
- package/dist/client/app/host.d.ts +8 -0
- package/dist/client/app/util.d.ts +28 -0
- package/dist/client/server/Story.d.ts +21 -3
- package/dist/client/server/collect.d.ts +14 -0
- package/dist/client-dependencies.d.ts +2 -0
- package/dist/client-dependencies.js +2 -0
- package/dist/docgen/events.d.ts +9 -0
- package/dist/docgen/events.js +45 -0
- package/dist/docgen/extractor.d.ts +7 -0
- package/dist/docgen/extractor.js +60 -0
- package/dist/docgen/generic.d.ts +5 -0
- package/dist/docgen/generic.js +19 -0
- package/dist/docgen/meta.d.ts +12 -0
- package/dist/docgen/meta.js +76 -0
- package/dist/docgen/slots.d.ts +6 -0
- package/dist/docgen/slots.js +21 -0
- package/dist/index.node.d.ts +2 -0
- package/dist/index.node.js +24 -11
- package/dist/testing/index.d.ts +28 -0
- package/dist/testing/vite.d.ts +18 -0
- package/dist/testing/vite.js +171 -0
- package/dist/util/project-vue.d.ts +1 -0
- package/dist/util/project-vue.js +12 -0
- package/dist/util/vue-plugin.d.ts +10 -0
- package/dist/util/vue-plugin.js +28 -0
- package/package.json +33 -15
- package/src/client/app/MountStory.ts +2 -0
- package/src/client/app/RenderStory.ts +2 -1
- package/src/client/app/Story.ts +15 -3
- package/src/client/app/global-components.ts +4 -0
- package/src/client/app/host.ts +21 -2
- package/src/client/app/util.ts +65 -0
- package/src/client/server/Story.ts +15 -2
- package/src/client/server/collect.ts +83 -0
- package/src/client/server/run.ts +3 -63
- package/src/client-dependencies.ts +2 -0
- package/src/docgen/events.ts +55 -0
- package/src/docgen/extractor.ts +67 -0
- package/src/docgen/generic.ts +20 -0
- package/src/docgen/meta.ts +93 -0
- package/src/docgen/slots.ts +33 -0
- package/src/index.node.ts +27 -12
- package/src/testing/index.ts +286 -0
- package/src/testing/vite.ts +194 -0
- package/src/util/project-vue.ts +13 -0
- package/src/util/vue-plugin.ts +32 -0
- package/testing.d.ts +2 -0
package/README.md
CHANGED
|
@@ -37,6 +37,13 @@ import MyButton from './MyButton.vue'
|
|
|
37
37
|
|
|
38
38
|
`<Story>` and `<Variant>` are registered globally — no import needed.
|
|
39
39
|
|
|
40
|
+
Each story's **Docs** tab shows a props, slots and events table for the `.vue`
|
|
41
|
+
components it imports, read from their types with `vue-component-meta`: descriptions
|
|
42
|
+
and tags from JSDoc, defaults from `withDefaults`, slots from `defineSlots` and events
|
|
43
|
+
from `defineEmits`. It needs `typescript` 6 or earlier in the project
|
|
44
|
+
(`npm i -D typescript@6`); without it, or with 7, it turns itself off and says so once.
|
|
45
|
+
Set `autoDocs: false` in the config to turn it off.
|
|
46
|
+
|
|
40
47
|
Coming from histoire? The Vue API is unchanged: swap the dependency and your existing
|
|
41
48
|
`.story.vue` files keep working.
|
|
42
49
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { warnIfForeignVue as e } from "./util.js";
|
|
2
|
+
import { createPreviewHost as t } from "./host.js";
|
|
3
|
+
import { defineComponent as n, h as r, onMounted as i, onUnmounted as a, ref as o, watch as s } from "@poveste/vendors/vue";
|
|
4
|
+
import { reactive as c } from "vue";
|
|
4
5
|
//#region src/client/app/MountStory.ts
|
|
5
|
-
var
|
|
6
|
+
var l = n({
|
|
6
7
|
name: "MountStory",
|
|
7
8
|
props: {
|
|
8
9
|
story: {
|
|
@@ -18,43 +19,44 @@ var c = t({
|
|
|
18
19
|
default: !0
|
|
19
20
|
}
|
|
20
21
|
},
|
|
21
|
-
setup(
|
|
22
|
-
|
|
22
|
+
setup(n) {
|
|
23
|
+
e("MountStory");
|
|
24
|
+
let r = o(), l = c({
|
|
23
25
|
mode: "mount",
|
|
24
26
|
slotName: "default",
|
|
25
27
|
currentVariant: null,
|
|
26
|
-
targetVariantId:
|
|
27
|
-
syncState:
|
|
28
|
+
targetVariantId: n.targetVariantId,
|
|
29
|
+
syncState: n.syncState,
|
|
28
30
|
externalState: null,
|
|
29
31
|
nextVariantIndex: { value: 0 }
|
|
30
|
-
}),
|
|
31
|
-
async function
|
|
32
|
-
|
|
32
|
+
}), u = null;
|
|
33
|
+
async function d() {
|
|
34
|
+
r.value && (u = t({
|
|
33
35
|
name: "MountStorySubApp",
|
|
34
|
-
el:
|
|
35
|
-
getStory: () =>
|
|
36
|
+
el: r.value,
|
|
37
|
+
getStory: () => n.story,
|
|
36
38
|
getVariant: () => null,
|
|
37
|
-
renderContext:
|
|
38
|
-
}), await
|
|
39
|
+
renderContext: l
|
|
40
|
+
}), await u.mount());
|
|
39
41
|
}
|
|
40
|
-
function
|
|
41
|
-
|
|
42
|
+
function f() {
|
|
43
|
+
u?.unmount(), u = null;
|
|
42
44
|
}
|
|
43
|
-
return
|
|
44
|
-
|
|
45
|
-
}),
|
|
46
|
-
await
|
|
47
|
-
}),
|
|
48
|
-
|
|
49
|
-
}),
|
|
50
|
-
|
|
51
|
-
}),
|
|
52
|
-
|
|
53
|
-
}), { el:
|
|
45
|
+
return s(() => n.story.id, async () => {
|
|
46
|
+
f(), await d();
|
|
47
|
+
}), i(async () => {
|
|
48
|
+
await d();
|
|
49
|
+
}), s(() => n.story.variants, () => {
|
|
50
|
+
u?.forceUpdate();
|
|
51
|
+
}), s(() => n.targetVariantId, (e) => {
|
|
52
|
+
l.targetVariantId = e;
|
|
53
|
+
}), a(() => {
|
|
54
|
+
f();
|
|
55
|
+
}), { el: r };
|
|
54
56
|
},
|
|
55
57
|
render() {
|
|
56
|
-
return
|
|
58
|
+
return r("div", { ref: "el" });
|
|
57
59
|
}
|
|
58
60
|
});
|
|
59
61
|
//#endregion
|
|
60
|
-
export {
|
|
62
|
+
export { l as default };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { syncStateBundledAndExternal as e } from "./util.js";
|
|
2
|
-
import { createPreviewHost as
|
|
3
|
-
import { defineComponent as
|
|
4
|
-
import { reactive as
|
|
1
|
+
import { syncStateBundledAndExternal as e, warnIfForeignVue as t } from "./util.js";
|
|
2
|
+
import { createPreviewHost as n } from "./host.js";
|
|
3
|
+
import { defineComponent as r, h as i, onBeforeUnmount as a, onMounted as o, ref as s, watch as c } from "@poveste/vendors/vue";
|
|
4
|
+
import { reactive as l } from "vue";
|
|
5
5
|
//#region src/client/app/RenderStory.ts
|
|
6
|
-
var
|
|
6
|
+
var u = r({
|
|
7
7
|
name: "RenderStory",
|
|
8
8
|
props: {
|
|
9
9
|
variant: {
|
|
@@ -20,54 +20,49 @@ var l = n({
|
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
22
|
emits: { ready: () => !0 },
|
|
23
|
-
setup(
|
|
24
|
-
|
|
23
|
+
setup(r, { emit: i }) {
|
|
24
|
+
t("RenderStory");
|
|
25
|
+
let u = s(), d = null, f = !1, p = l({}), m = e(r.variant.state, p), h = l({
|
|
25
26
|
mode: "render",
|
|
26
|
-
slotName:
|
|
27
|
-
currentVariant:
|
|
28
|
-
externalState:
|
|
27
|
+
slotName: r.slotName,
|
|
28
|
+
currentVariant: r.variant,
|
|
29
|
+
externalState: p,
|
|
29
30
|
nextVariantIndex: { value: 0 }
|
|
30
31
|
});
|
|
31
|
-
function h() {
|
|
32
|
-
u?.unmount(), u = null;
|
|
33
|
-
}
|
|
34
32
|
function g() {
|
|
35
|
-
|
|
33
|
+
d?.unmount(), d = null;
|
|
34
|
+
}
|
|
35
|
+
function _() {
|
|
36
|
+
m?.stop(), m = e(r.variant.state, p);
|
|
36
37
|
}
|
|
37
|
-
async function
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
getStory: () => n.story,
|
|
47
|
-
getVariant: () => n.variant,
|
|
48
|
-
renderContext: m,
|
|
49
|
-
wrapInDiv: !0
|
|
50
|
-
}), await u.mount(), d = !1, r("ready");
|
|
51
|
-
}
|
|
38
|
+
async function v() {
|
|
39
|
+
f || (f = !0, g(), h.currentVariant = r.variant, h.slotName = r.slotName, u.value ? (d = n({
|
|
40
|
+
name: "RenderStorySubApp",
|
|
41
|
+
el: u.value,
|
|
42
|
+
getStory: () => r.story,
|
|
43
|
+
getVariant: () => r.variant,
|
|
44
|
+
renderContext: h,
|
|
45
|
+
wrapInDiv: !0
|
|
46
|
+
}), await d.mount(), f = !1, i("ready")) : f = !1);
|
|
52
47
|
}
|
|
53
|
-
return
|
|
54
|
-
|
|
55
|
-
}),
|
|
56
|
-
|
|
57
|
-
}),
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
48
|
+
return o(async () => {
|
|
49
|
+
r.variant.configReady && await v();
|
|
50
|
+
}), c(() => r.variant, () => {
|
|
51
|
+
h.currentVariant = r.variant, _();
|
|
52
|
+
}), c(() => [
|
|
53
|
+
r.story.id,
|
|
54
|
+
r.slotName,
|
|
55
|
+
r.variant.id,
|
|
56
|
+
r.variant.configReady
|
|
62
57
|
], async ([, e]) => {
|
|
63
|
-
|
|
64
|
-
}),
|
|
65
|
-
|
|
66
|
-
}), { sandbox:
|
|
58
|
+
h.currentVariant = r.variant, h.slotName = e, r.variant.configReady && !f && (d ? d.forceUpdate() : await v());
|
|
59
|
+
}), a(() => {
|
|
60
|
+
m?.stop(), g();
|
|
61
|
+
}), { sandbox: u };
|
|
67
62
|
},
|
|
68
63
|
render() {
|
|
69
|
-
return
|
|
64
|
+
return i("div", { ref: "sandbox" });
|
|
70
65
|
}
|
|
71
66
|
});
|
|
72
67
|
//#endregion
|
|
73
|
-
export {
|
|
68
|
+
export { u as default };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { implicitStateContext as e, storyContext as t } from "./context.js";
|
|
2
2
|
import { useRenderContext as n } from "./render-context.js";
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import { cloneVNode as
|
|
6
|
-
import { omitInheritStoryProps as
|
|
3
|
+
import { holdsVueApp as r, isComponentBinding as i, isWritableBinding as a, useInstance as o } from "./util.js";
|
|
4
|
+
import s from "./Variant.js";
|
|
5
|
+
import { cloneVNode as c, computed as l, defineComponent as u, h as d, isRef as f, reactive as p, useAttrs as m } from "vue";
|
|
6
|
+
import { omitInheritStoryProps as h } from "@poveste/shared";
|
|
7
7
|
//#region src/client/app/Story.ts
|
|
8
|
-
var
|
|
8
|
+
var g = u({
|
|
9
9
|
name: "Story",
|
|
10
10
|
__povesteType: "story",
|
|
11
11
|
inheritAttrs: !1,
|
|
@@ -17,97 +17,99 @@ var m = c({
|
|
|
17
17
|
meta: {
|
|
18
18
|
type: Object,
|
|
19
19
|
default: void 0
|
|
20
|
+
},
|
|
21
|
+
autoDocs: {
|
|
22
|
+
type: [Boolean, Array],
|
|
23
|
+
default: void 0
|
|
24
|
+
},
|
|
25
|
+
component: {
|
|
26
|
+
type: [
|
|
27
|
+
Object,
|
|
28
|
+
Function,
|
|
29
|
+
Array
|
|
30
|
+
],
|
|
31
|
+
default: void 0
|
|
20
32
|
}
|
|
21
33
|
},
|
|
22
|
-
setup(
|
|
23
|
-
let
|
|
24
|
-
t.provide(
|
|
25
|
-
let
|
|
26
|
-
Object.defineProperty(
|
|
34
|
+
setup(s) {
|
|
35
|
+
let u = o("Story"), d = m(), g = n(), _ = l(() => d.story);
|
|
36
|
+
t.provide(_);
|
|
37
|
+
let v = u.parent, y = p({});
|
|
38
|
+
Object.defineProperty(y, "$data", {
|
|
27
39
|
enumerable: !0,
|
|
28
40
|
configurable: !0,
|
|
29
|
-
get: () =>
|
|
41
|
+
get: () => v.data,
|
|
30
42
|
set: (e) => {
|
|
31
|
-
Object.assign(
|
|
43
|
+
Object.assign(v.data, e);
|
|
32
44
|
}
|
|
33
45
|
});
|
|
34
|
-
function
|
|
46
|
+
function b(e, t) {
|
|
35
47
|
let n = e[t];
|
|
36
|
-
|
|
48
|
+
i(n) || r(n) || a(n) && Object.defineProperty(y, t, {
|
|
37
49
|
enumerable: !0,
|
|
38
50
|
configurable: !0,
|
|
39
51
|
get: () => {
|
|
40
52
|
let n = e[t];
|
|
41
|
-
return
|
|
53
|
+
return f(n) ? n.value : n;
|
|
42
54
|
},
|
|
43
55
|
set: (n) => {
|
|
44
56
|
let r = e[t];
|
|
45
|
-
|
|
57
|
+
f(r) ? r.value = n : r && typeof r == "object" && n && typeof n == "object" ? Object.assign(r, n) : e[t] = n;
|
|
46
58
|
}
|
|
47
59
|
});
|
|
48
60
|
}
|
|
49
|
-
for (let e in
|
|
50
|
-
for (let e in
|
|
51
|
-
for (let e in
|
|
52
|
-
e.provide(() =>
|
|
53
|
-
function
|
|
54
|
-
|
|
61
|
+
for (let e in v.exposed) b(v.exposed, e);
|
|
62
|
+
for (let e in v.devtoolsRawSetupState) b(v.devtoolsRawSetupState, e);
|
|
63
|
+
for (let e in v.data) b(v.data, e);
|
|
64
|
+
e.provide(() => y);
|
|
65
|
+
function x() {
|
|
66
|
+
s.meta && (d.story.meta || (d.story.meta = {}), Object.assign(d.story.meta, s.meta)), Object.assign(d.story, { slots: () => u.slots });
|
|
55
67
|
}
|
|
56
68
|
return {
|
|
57
|
-
renderContext:
|
|
58
|
-
story:
|
|
59
|
-
renderMountStory:
|
|
60
|
-
renderPreviewStory:
|
|
61
|
-
updateStory:
|
|
69
|
+
renderContext: g,
|
|
70
|
+
story: _,
|
|
71
|
+
renderMountStory: C,
|
|
72
|
+
renderPreviewStory: T,
|
|
73
|
+
updateStory: x
|
|
62
74
|
};
|
|
63
|
-
function
|
|
75
|
+
function S(e) {
|
|
64
76
|
let t = {};
|
|
65
|
-
for (let n in
|
|
66
|
-
for (let n in
|
|
77
|
+
for (let n in u.attrs) e.props?.[n] === void 0 && (t[n] = u.attrs[n]);
|
|
78
|
+
for (let n in d.story) !h.includes(n) && e.props?.[n] === void 0 && (t[n] = Reflect.get(d.story, n));
|
|
67
79
|
return t;
|
|
68
80
|
}
|
|
69
|
-
function
|
|
70
|
-
let e = 0, t =
|
|
81
|
+
function C() {
|
|
82
|
+
let e = 0, t = g?.targetVariantId, n = t ? d.story.variants.findIndex((e) => e.id === t) : -1, r = (t) => {
|
|
71
83
|
let i = [];
|
|
72
|
-
for (let
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
continue;
|
|
79
|
-
}
|
|
80
|
-
Array.isArray(s.children) && (s.children = r(s.children)), i.push(s);
|
|
81
|
-
}
|
|
84
|
+
for (let a of t) if (a.type?.__povesteType === "variant") {
|
|
85
|
+
let t = d.story.variants[e];
|
|
86
|
+
if (e++, !t || n !== -1 && e - 1 !== n) continue;
|
|
87
|
+
let r = { variant: t };
|
|
88
|
+
a.key ?? (r.key = t.id), !a.props?.initState && !a.props?.["init-state"] && (r.initState = s.initState), Object.assign(r, S(a)), i.push(c(a, r));
|
|
89
|
+
} else Array.isArray(a.children) && (a.children = r(a.children)), i.push(a);
|
|
82
90
|
return i;
|
|
83
91
|
};
|
|
84
|
-
return r(
|
|
92
|
+
return r(u.slots.default?.() ?? []);
|
|
85
93
|
}
|
|
86
|
-
function
|
|
94
|
+
function w(e) {
|
|
87
95
|
let t = 0;
|
|
88
|
-
for (let n of e) n?.type?.__povesteType === "variant" ? t++ : Array.isArray(n?.children) && (t +=
|
|
96
|
+
for (let n of e) n?.type?.__povesteType === "variant" ? t++ : Array.isArray(n?.children) && (t += w(n.children));
|
|
89
97
|
return t;
|
|
90
98
|
}
|
|
91
|
-
function
|
|
99
|
+
function T(e) {
|
|
92
100
|
e.nextVariantIndex.value = 0;
|
|
93
101
|
let t = { state: e.externalState }, n = [];
|
|
94
|
-
e.slotName === "controls" && n.push(...
|
|
102
|
+
e.slotName === "controls" && n.push(...u.slots.controls?.(t) ?? []), (e.slotName === "default" || d.story.meta?.hasVariantChildComponents) && n.push(...u.slots.default?.(t) ?? []);
|
|
95
103
|
let r = e.currentVariant;
|
|
96
|
-
if (e.slotName === "default" && r &&
|
|
97
|
-
let t =
|
|
104
|
+
if (e.slotName === "default" && r && w(n) === d.story.variants.length) {
|
|
105
|
+
let t = d.story.variants.findIndex((e) => e.id === r.id);
|
|
98
106
|
if (t !== -1) {
|
|
99
107
|
let r = 0, i = !1, a = (e) => {
|
|
100
108
|
let n = [];
|
|
101
|
-
for (let
|
|
102
|
-
if (s?.type?.__povesteType === "variant") {
|
|
103
|
-
r === t && (n.push(o(s, b(s))), i = !0), r++;
|
|
104
|
-
continue;
|
|
105
|
-
}
|
|
106
|
-
Array.isArray(s?.children) && s.children.length && (s.children = a(s.children)), n.push(s);
|
|
107
|
-
}
|
|
109
|
+
for (let o of e) o?.type?.__povesteType === "variant" ? (r === t && (n.push(c(o, S(o))), i = !0), r++) : (Array.isArray(o?.children) && o.children.length && (o.children = a(o.children)), n.push(o));
|
|
108
110
|
return n;
|
|
109
|
-
},
|
|
110
|
-
if (i) return e.nextVariantIndex.value = t,
|
|
111
|
+
}, o = a(n);
|
|
112
|
+
if (i) return e.nextVariantIndex.value = t, o;
|
|
111
113
|
}
|
|
112
114
|
}
|
|
113
115
|
return n;
|
|
@@ -116,7 +118,7 @@ var m = c({
|
|
|
116
118
|
render() {
|
|
117
119
|
this.updateStory();
|
|
118
120
|
let [e] = this.story.variants;
|
|
119
|
-
if (e?.id === "_default") return
|
|
121
|
+
if (e?.id === "_default") return d(s, {
|
|
120
122
|
variant: e,
|
|
121
123
|
...this.initState ? { initState: this.initState } : {},
|
|
122
124
|
implicit: !0,
|
|
@@ -127,4 +129,4 @@ var m = c({
|
|
|
127
129
|
}
|
|
128
130
|
});
|
|
129
131
|
//#endregion
|
|
130
|
-
export {
|
|
132
|
+
export { g as default };
|
|
@@ -5,10 +5,12 @@ import { defineComponent as a, h as o, onBeforeUnmount as s, onBeforeUpdate as c
|
|
|
5
5
|
import { components as f } from "@poveste/controls";
|
|
6
6
|
//#region src/client/app/global-components.ts
|
|
7
7
|
function p(n) {
|
|
8
|
-
n.component("Story", t), n.component("Variant", e);
|
|
9
|
-
for (let [e, t] of Object.entries(f)) n.component(e, m(t));
|
|
8
|
+
n.component("Story", t), n.component("Variant", e), m(n);
|
|
10
9
|
}
|
|
11
10
|
function m(e) {
|
|
11
|
+
for (let [t, n] of Object.entries(f)) e.component(t, h(n));
|
|
12
|
+
}
|
|
13
|
+
function h(e) {
|
|
12
14
|
let t = e;
|
|
13
15
|
return a({
|
|
14
16
|
...e.name ? { name: e.name } : {},
|
|
@@ -63,4 +65,4 @@ function m(e) {
|
|
|
63
65
|
});
|
|
64
66
|
}
|
|
65
67
|
//#endregion
|
|
66
|
-
export { p as registerGlobalComponents };
|
|
68
|
+
export { m as registerControlComponents, p as registerGlobalComponents };
|
|
@@ -28,7 +28,7 @@ function m(e) {
|
|
|
28
28
|
let t = null, o = null;
|
|
29
29
|
async function c() {
|
|
30
30
|
let c = [];
|
|
31
|
-
o = document.createElement("div"), e.el.appendChild(o), t = a({
|
|
31
|
+
if (o = document.createElement("div"), e.el.appendChild(o), t = a({
|
|
32
32
|
name: e.name,
|
|
33
33
|
render: () => {
|
|
34
34
|
let t = s(p, {
|
|
@@ -42,21 +42,25 @@ function m(e) {
|
|
|
42
42
|
variant: e.getVariant()
|
|
43
43
|
}, () => r);
|
|
44
44
|
}
|
|
45
|
-
return e.wrapInDiv && (t = s("div", t)), s(i, {}, t);
|
|
45
|
+
return e.wrapInDiv && (t = s("div", t)), s(i, e.onResolve ? { onResolve: e.onResolve } : {}, t);
|
|
46
46
|
}
|
|
47
47
|
}), t.config.errorHandler = (t) => {
|
|
48
48
|
l(t, {
|
|
49
49
|
storyId: e.getStory()?.id,
|
|
50
50
|
variantId: e.getVariant()?.id
|
|
51
|
-
}), console.error(t);
|
|
52
|
-
},
|
|
51
|
+
}), e.onError ? e.onError(t) : console.error(t);
|
|
52
|
+
}, e.onWarn) {
|
|
53
|
+
let n = e.onWarn;
|
|
54
|
+
t.config.warnHandler = (e, t, r) => n(e, r);
|
|
55
|
+
}
|
|
56
|
+
d && t.use(d), n(t), t.component("RouterLink", r), await h({
|
|
53
57
|
app: t,
|
|
54
58
|
story: e.getStory(),
|
|
55
59
|
variant: e.getVariant() ?? void 0,
|
|
56
60
|
addWrapper: (e) => {
|
|
57
61
|
c.unshift(e);
|
|
58
62
|
}
|
|
59
|
-
}), t.mount(o);
|
|
63
|
+
}), e.configureApp?.(t), t.mount(o);
|
|
60
64
|
}
|
|
61
65
|
function u() {
|
|
62
66
|
t?.unmount(), t = null, o &&= (o.parentNode?.removeChild(o), null);
|
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { getCurrentInstance as
|
|
3
|
-
import { applyState as
|
|
1
|
+
import { getCurrentInstance as e, isRef as t, unref as n, watch as r } from "@poveste/vendors/vue";
|
|
2
|
+
import { getCurrentInstance as i, isReadonly as a, isRef as o, markRaw as s, unref as c, watch as l } from "vue";
|
|
3
|
+
import { applyState as u, createStateBaseline as d, isMarkedRaw as f, isPlainObject as p } from "@poveste/shared";
|
|
4
4
|
//#region src/client/app/util.ts
|
|
5
|
-
var
|
|
6
|
-
function
|
|
7
|
-
let n =
|
|
5
|
+
var m = (e) => typeof e == "object" && !!e;
|
|
6
|
+
function h(e, t = /* @__PURE__ */ new WeakMap()) {
|
|
7
|
+
let n = o(e) ? c(e) : e;
|
|
8
8
|
if (typeof n == "symbol") return n.toString();
|
|
9
|
-
if (!
|
|
9
|
+
if (!m(n) || f(n)) return n;
|
|
10
10
|
if (t.has(n)) return t.get(n);
|
|
11
|
-
if (!Array.isArray(n) && !
|
|
11
|
+
if (!Array.isArray(n) && !p(n)) return s(n);
|
|
12
12
|
if (Array.isArray(n)) {
|
|
13
13
|
let e = [];
|
|
14
|
-
return t.set(n, e), e.push(...n.map((e) =>
|
|
14
|
+
return t.set(n, e), e.push(...n.map((e) => h(e, t))), e;
|
|
15
15
|
}
|
|
16
16
|
{
|
|
17
17
|
let e = {};
|
|
18
|
-
return t.set(n, e),
|
|
18
|
+
return t.set(n, e), g(n, e, t), e;
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
function
|
|
21
|
+
function g(e, t, n = /* @__PURE__ */ new WeakMap()) {
|
|
22
22
|
Object.keys(e).forEach((r) => {
|
|
23
|
-
t[r] =
|
|
23
|
+
t[r] = h(e[r], n);
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
|
-
function
|
|
27
|
-
let i = e
|
|
26
|
+
function _(e, r = /* @__PURE__ */ new WeakMap()) {
|
|
27
|
+
let i = t(e) ? n(e) : e;
|
|
28
28
|
if (typeof i == "symbol") return i.toString();
|
|
29
|
-
if (!
|
|
29
|
+
if (!m(i) || f(i)) return i;
|
|
30
30
|
if (r.has(i)) return r.get(i);
|
|
31
|
-
if (!Array.isArray(i) && !
|
|
31
|
+
if (!Array.isArray(i) && !p(i)) return s(i);
|
|
32
32
|
if (Array.isArray(i)) {
|
|
33
33
|
let e = [];
|
|
34
|
-
return r.set(i, e), e.push(...i.map((e) =>
|
|
34
|
+
return r.set(i, e), e.push(...i.map((e) => _(e, r))), e;
|
|
35
35
|
}
|
|
36
36
|
{
|
|
37
37
|
let e = {};
|
|
38
|
-
return r.set(i, e),
|
|
38
|
+
return r.set(i, e), v(i, e, r), e;
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
function
|
|
41
|
+
function v(e, t, n = /* @__PURE__ */ new WeakMap()) {
|
|
42
42
|
Object.keys(e).forEach((r) => {
|
|
43
|
-
t[r] =
|
|
43
|
+
t[r] = _(e[r], n);
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
|
-
function
|
|
46
|
+
function y(e, t) {
|
|
47
47
|
if (!t.length) return e;
|
|
48
48
|
let n = { ...e };
|
|
49
49
|
for (let e of t) delete n[e];
|
|
50
50
|
return n;
|
|
51
51
|
}
|
|
52
|
-
function
|
|
53
|
-
let i =
|
|
52
|
+
function b(e, t, n = []) {
|
|
53
|
+
let i = d(), a = r(() => e, (e) => {
|
|
54
54
|
if (e == null) return;
|
|
55
|
-
let
|
|
56
|
-
|
|
55
|
+
let r = i.take(y(_(e), n));
|
|
56
|
+
r && u(t, r);
|
|
57
57
|
}, {
|
|
58
58
|
deep: !0,
|
|
59
59
|
immediate: !0
|
|
60
|
-
}), o =
|
|
60
|
+
}), o = l(() => t, (t) => {
|
|
61
61
|
if (t == null) return;
|
|
62
|
-
let
|
|
63
|
-
|
|
62
|
+
let r = i.take(y(h(t), n));
|
|
63
|
+
r && u(e, r);
|
|
64
64
|
}, {
|
|
65
65
|
deep: !0,
|
|
66
66
|
immediate: !0
|
|
@@ -69,13 +69,26 @@ function y(e, t, r = []) {
|
|
|
69
69
|
a(), o();
|
|
70
70
|
} };
|
|
71
71
|
}
|
|
72
|
-
function b(e) {
|
|
73
|
-
return !(a(e) && i(e));
|
|
74
|
-
}
|
|
75
72
|
function x(e) {
|
|
76
|
-
|
|
73
|
+
return !(o(e) && a(e));
|
|
74
|
+
}
|
|
75
|
+
function S(e) {
|
|
76
|
+
return typeof e == "function" ? !0 : m(e) ? "__file" in e && !!e.__file || "render" in e && typeof e.render == "function" || "setup" in e && typeof e.setup == "function" : !1;
|
|
77
|
+
}
|
|
78
|
+
function C(e) {
|
|
79
|
+
return m(e) && "_context" in e && "_component" in e && "mount" in e;
|
|
80
|
+
}
|
|
81
|
+
function w(e) {
|
|
82
|
+
return m(e) ? C(e) ? !0 : Object.values(Object.getOwnPropertyDescriptors(e)).some((e) => "value" in e && C(e.value)) : !1;
|
|
83
|
+
}
|
|
84
|
+
function T(e) {
|
|
85
|
+
let t = i();
|
|
77
86
|
if (!t) throw Error(`[poveste] <${e}> can only be set up inside a component`);
|
|
78
87
|
return t;
|
|
79
88
|
}
|
|
89
|
+
var E = !1;
|
|
90
|
+
function D(t) {
|
|
91
|
+
E || e() || (E = !0, console.warn(`[poveste] ${t} was rendered by a copy of Vue other than \`@poveste/vendors/vue\`, so it renders nothing. Poveste's client components are built against that copy: create the app with \`createApp\` from \`@poveste/vendors/vue\`, not from \`vue\`.`));
|
|
92
|
+
}
|
|
80
93
|
//#endregion
|
|
81
|
-
export {
|
|
94
|
+
export { _ as _toRawDeep, w as holdsVueApp, S as isComponentBinding, x as isWritableBinding, b as syncStateBundledAndExternal, h as toRawDeep, T as useInstance, D as warnIfForeignVue };
|
|
@@ -34,6 +34,18 @@ var s = a({
|
|
|
34
34
|
type: Boolean,
|
|
35
35
|
default: !1
|
|
36
36
|
},
|
|
37
|
+
autoDocs: {
|
|
38
|
+
type: [Boolean, Array],
|
|
39
|
+
default: void 0
|
|
40
|
+
},
|
|
41
|
+
component: {
|
|
42
|
+
type: [
|
|
43
|
+
Object,
|
|
44
|
+
Function,
|
|
45
|
+
Array
|
|
46
|
+
],
|
|
47
|
+
default: void 0
|
|
48
|
+
},
|
|
37
49
|
meta: {
|
|
38
50
|
type: Object,
|
|
39
51
|
default: void 0
|
|
@@ -50,6 +62,7 @@ var s = a({
|
|
|
50
62
|
icon: i.icon,
|
|
51
63
|
iconColor: i.iconColor,
|
|
52
64
|
docsOnly: i.docsOnly,
|
|
65
|
+
...i.autoDocs === void 0 ? {} : { autoDocs: i.autoDocs },
|
|
53
66
|
meta: i.meta,
|
|
54
67
|
variants: []
|
|
55
68
|
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { VUE_SETUP_HOOK_NAMES as e } from "../../setup-hooks.js";
|
|
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";
|
|
9
|
+
//#region src/client/server/collect.ts
|
|
10
|
+
async function u(u, { file: d, storyData: f, el: p }, m = {}) {
|
|
11
|
+
let h = a({
|
|
12
|
+
setup() {
|
|
13
|
+
t.provide((e) => {
|
|
14
|
+
f.push(e);
|
|
15
|
+
}), n.provide(d);
|
|
16
|
+
},
|
|
17
|
+
render() {
|
|
18
|
+
return o(u);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
h.component("Story", r), h.component("Variant", i), m.beforeSetup?.(h);
|
|
22
|
+
let g = {
|
|
23
|
+
app: h,
|
|
24
|
+
story: void 0,
|
|
25
|
+
variant: void 0,
|
|
26
|
+
addWrapper: () => {}
|
|
27
|
+
}, _ = s(c, e);
|
|
28
|
+
_ && await _(g);
|
|
29
|
+
let v = s(l, e);
|
|
30
|
+
if (v && await v(g), m.afterSetup?.(h), h.mount(p), u.doc) {
|
|
31
|
+
let e = document.createElement("div");
|
|
32
|
+
e.innerHTML = u.doc;
|
|
33
|
+
let t = e.textContent;
|
|
34
|
+
f.forEach((e) => {
|
|
35
|
+
e.docsText = t;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
h.unmount();
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
export { u as collectComponent };
|