@poveste/plugin-vue 0.20.0 → 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.
Files changed (57) hide show
  1. package/README.md +7 -0
  2. package/dist/bundled/client/app/Story.js +60 -48
  3. package/dist/bundled/client/app/global-components.js +5 -3
  4. package/dist/bundled/client/app/host.js +9 -5
  5. package/dist/bundled/client/app/util.js +13 -4
  6. package/dist/bundled/client/server/Story.js +13 -0
  7. package/dist/bundled/client/server/collect.js +41 -0
  8. package/dist/bundled/client/server/run.js +10 -39
  9. package/dist/bundled/testing/index.js +168 -0
  10. package/dist/client/app/Story.d.ts +19 -1
  11. package/dist/client/app/Variant.d.ts +2 -2
  12. package/dist/client/app/global-components.d.ts +1 -0
  13. package/dist/client/app/host.d.ts +8 -0
  14. package/dist/client/app/util.d.ts +16 -0
  15. package/dist/client/server/Story.d.ts +21 -3
  16. package/dist/client/server/collect.d.ts +14 -0
  17. package/dist/client-dependencies.d.ts +2 -0
  18. package/dist/client-dependencies.js +2 -0
  19. package/dist/docgen/events.d.ts +9 -0
  20. package/dist/docgen/events.js +45 -0
  21. package/dist/docgen/extractor.d.ts +0 -1
  22. package/dist/docgen/extractor.js +28 -9
  23. package/dist/docgen/generic.d.ts +5 -0
  24. package/dist/docgen/generic.js +19 -0
  25. package/dist/docgen/meta.d.ts +12 -9
  26. package/dist/docgen/meta.js +39 -13
  27. package/dist/docgen/slots.d.ts +6 -0
  28. package/dist/docgen/slots.js +21 -0
  29. package/dist/index.node.d.ts +2 -0
  30. package/dist/index.node.js +18 -15
  31. package/dist/testing/index.d.ts +28 -0
  32. package/dist/testing/vite.d.ts +18 -0
  33. package/dist/testing/vite.js +171 -0
  34. package/dist/util/project-vue.d.ts +1 -0
  35. package/dist/util/project-vue.js +12 -0
  36. package/package.json +26 -9
  37. package/src/client/app/Story.ts +15 -3
  38. package/src/client/app/global-components.ts +4 -0
  39. package/src/client/app/host.ts +21 -2
  40. package/src/client/app/util.ts +40 -0
  41. package/src/client/server/Story.ts +15 -2
  42. package/src/client/server/collect.ts +83 -0
  43. package/src/client/server/run.ts +3 -63
  44. package/src/client-dependencies.ts +2 -0
  45. package/src/docgen/events.ts +55 -0
  46. package/src/docgen/extractor.ts +30 -10
  47. package/src/docgen/generic.ts +20 -0
  48. package/src/docgen/meta.ts +46 -21
  49. package/src/docgen/slots.ts +33 -0
  50. package/src/index.node.ts +20 -16
  51. package/src/testing/index.ts +286 -0
  52. package/src/testing/vite.ts +194 -0
  53. package/src/util/project-vue.ts +13 -0
  54. package/testing.d.ts +2 -0
  55. package/dist/docgen/typescript.d.ts +0 -9
  56. package/dist/docgen/typescript.js +0 -36
  57. package/src/docgen/typescript.ts +0 -41
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,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 { isWritableBinding as r, useInstance as i } from "./util.js";
4
- import a from "./Variant.js";
5
- import { cloneVNode as o, computed as s, defineComponent as c, h as l, isRef as u, reactive as d, useAttrs as f } from "vue";
6
- import { omitInheritStoryProps as p } from "@poveste/shared";
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 m = c({
8
+ var g = u({
9
9
  name: "Story",
10
10
  __povesteType: "story",
11
11
  inheritAttrs: !1,
@@ -17,87 +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(a) {
23
- let c = i("Story"), l = f(), m = n(), h = s(() => l.story);
24
- t.provide(h);
25
- let g = c.parent, _ = d({});
26
- Object.defineProperty(_, "$data", {
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: () => g.data,
41
+ get: () => v.data,
30
42
  set: (e) => {
31
- Object.assign(g.data, e);
43
+ Object.assign(v.data, e);
32
44
  }
33
45
  });
34
- function v(e, t) {
46
+ function b(e, t) {
35
47
  let n = e[t];
36
- typeof n == "function" || n?.__file || typeof n?.render == "function" || typeof n?.setup == "function" || r(n) && Object.defineProperty(_, t, {
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 u(n) ? n.value : n;
53
+ return f(n) ? n.value : n;
42
54
  },
43
55
  set: (n) => {
44
56
  let r = e[t];
45
- u(r) ? r.value = n : r && typeof r == "object" && n && typeof n == "object" ? Object.assign(r, n) : e[t] = n;
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 g.exposed) v(g.exposed, e);
50
- for (let e in g.devtoolsRawSetupState) v(g.devtoolsRawSetupState, e);
51
- for (let e in g.data) v(g.data, e);
52
- e.provide(() => _);
53
- function y() {
54
- a.meta && (l.story.meta || (l.story.meta = {}), Object.assign(l.story.meta, a.meta)), Object.assign(l.story, { slots: () => c.slots });
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: m,
58
- story: h,
59
- renderMountStory: x,
60
- renderPreviewStory: C,
61
- updateStory: y
69
+ renderContext: g,
70
+ story: _,
71
+ renderMountStory: C,
72
+ renderPreviewStory: T,
73
+ updateStory: x
62
74
  };
63
- function b(e) {
75
+ function S(e) {
64
76
  let t = {};
65
- for (let n in c.attrs) e.props?.[n] === void 0 && (t[n] = c.attrs[n]);
66
- for (let n in l.story) !p.includes(n) && e.props?.[n] === void 0 && (t[n] = Reflect.get(l.story, n));
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 x() {
70
- let e = 0, t = m?.targetVariantId, n = t ? l.story.variants.findIndex((e) => e.id === t) : -1, r = (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 s of t) if (s.type?.__povesteType === "variant") {
73
- let t = l.story.variants[e];
84
+ for (let a of t) if (a.type?.__povesteType === "variant") {
85
+ let t = d.story.variants[e];
74
86
  if (e++, !t || n !== -1 && e - 1 !== n) continue;
75
87
  let r = { variant: t };
76
- s.key ?? (r.key = t.id), !s.props?.initState && !s.props?.["init-state"] && (r.initState = a.initState), Object.assign(r, b(s)), i.push(o(s, r));
77
- } else Array.isArray(s.children) && (s.children = r(s.children)), i.push(s);
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);
78
90
  return i;
79
91
  };
80
- return r(c.slots.default?.() ?? []);
92
+ return r(u.slots.default?.() ?? []);
81
93
  }
82
- function S(e) {
94
+ function w(e) {
83
95
  let t = 0;
84
- for (let n of e) n?.type?.__povesteType === "variant" ? t++ : Array.isArray(n?.children) && (t += S(n.children));
96
+ for (let n of e) n?.type?.__povesteType === "variant" ? t++ : Array.isArray(n?.children) && (t += w(n.children));
85
97
  return t;
86
98
  }
87
- function C(e) {
99
+ function T(e) {
88
100
  e.nextVariantIndex.value = 0;
89
101
  let t = { state: e.externalState }, n = [];
90
- e.slotName === "controls" && n.push(...c.slots.controls?.(t) ?? []), (e.slotName === "default" || l.story.meta?.hasVariantChildComponents) && n.push(...c.slots.default?.(t) ?? []);
102
+ e.slotName === "controls" && n.push(...u.slots.controls?.(t) ?? []), (e.slotName === "default" || d.story.meta?.hasVariantChildComponents) && n.push(...u.slots.default?.(t) ?? []);
91
103
  let r = e.currentVariant;
92
- if (e.slotName === "default" && r && S(n) === l.story.variants.length) {
93
- let t = l.story.variants.findIndex((e) => e.id === r.id);
104
+ if (e.slotName === "default" && r && w(n) === d.story.variants.length) {
105
+ let t = d.story.variants.findIndex((e) => e.id === r.id);
94
106
  if (t !== -1) {
95
107
  let r = 0, i = !1, a = (e) => {
96
108
  let n = [];
97
- for (let s of e) s?.type?.__povesteType === "variant" ? (r === t && (n.push(o(s, b(s))), i = !0), r++) : (Array.isArray(s?.children) && s.children.length && (s.children = a(s.children)), n.push(s));
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));
98
110
  return n;
99
- }, s = a(n);
100
- if (i) return e.nextVariantIndex.value = t, s;
111
+ }, o = a(n);
112
+ if (i) return e.nextVariantIndex.value = t, o;
101
113
  }
102
114
  }
103
115
  return n;
@@ -106,7 +118,7 @@ var m = c({
106
118
  render() {
107
119
  this.updateStory();
108
120
  let [e] = this.story.variants;
109
- if (e?.id === "_default") return l(a, {
121
+ if (e?.id === "_default") return d(s, {
110
122
  variant: e,
111
123
  ...this.initState ? { initState: this.initState } : {},
112
124
  implicit: !0,
@@ -117,4 +129,4 @@ var m = c({
117
129
  }
118
130
  });
119
131
  //#endregion
120
- export { m as default };
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
- }, d && t.use(d), n(t), t.component("RouterLink", r), await h({
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);
@@ -73,13 +73,22 @@ function x(e) {
73
73
  return !(o(e) && a(e));
74
74
  }
75
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) {
76
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
  }
80
- var C = !1;
81
- function w(t) {
82
- C || e() || (C = !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\`.`));
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\`.`));
83
92
  }
84
93
  //#endregion
85
- export { _ as _toRawDeep, x as isWritableBinding, b as syncStateBundledAndExternal, h as toRawDeep, S as useInstance, w as warnIfForeignVue };
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 };
@@ -1,44 +1,15 @@
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";
1
+ import { collectComponent as e } from "./collect.js";
9
2
  //#region src/client/server/run.ts
10
- async function u({ file: u, storyData: d, el: f }) {
11
- let { default: p } = await import(/* @vite-ignore */
3
+ async function t({ file: t, storyData: n, el: r }) {
4
+ let { default: i } = await import(/* @vite-ignore */
12
5
  /* @vite-ignore */
13
- u.moduleId
14
- ), m = a({
15
- setup() {
16
- t.provide((e) => {
17
- d.push(e);
18
- }), n.provide(u);
19
- },
20
- render() {
21
- return o(p);
22
- }
6
+ t.moduleId
7
+ );
8
+ await e(i, {
9
+ file: t,
10
+ storyData: n,
11
+ el: r
23
12
  });
24
- m.component("Story", r), m.component("Variant", i);
25
- let h = {
26
- app: m,
27
- story: void 0,
28
- variant: void 0,
29
- addWrapper: () => {}
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
- let e = document.createElement("div");
35
- e.innerHTML = p.doc;
36
- let t = e.textContent;
37
- d.forEach((e) => {
38
- e.docsText = t;
39
- });
40
- }
41
- m.unmount();
42
13
  }
43
14
  //#endregion
44
- export { u as run };
15
+ export { t as run };
@@ -0,0 +1,168 @@
1
+ import { syncStateBundledAndExternal as e } from "../client/app/util.js";
2
+ import { registerControlComponents as t } from "../client/app/global-components.js";
3
+ import { createPreviewHost as n } from "../client/app/host.js";
4
+ import { collectComponent as r } from "../client/server/collect.js";
5
+ import { markRaw as i, nextTick as a, reactive as o } from "vue";
6
+ import { environmentApp as s, environmentReady as c } from "virtual:$poveste-testing-environment";
7
+ import { describe as l, it as u } from "vitest";
8
+ //#region src/testing/index.ts
9
+ function d(e, t = {}) {
10
+ let n = t.name ?? x(e.__file) ?? "stories", r = t.timeout ?? 5e3;
11
+ l(n, async () => {
12
+ await c();
13
+ let { stories: t, problems: i } = await f(e, n);
14
+ if (i.length || !t.length) u("collects", () => {
15
+ throw y(`collecting ${n}`, i.length ? i : ["it has no <Story>"]);
16
+ });
17
+ else for (let e of t) l(e.title, () => {
18
+ for (let t of e.variants) u(t.title, async () => {
19
+ let n = await m(e, t, r);
20
+ if (n.length) throw y(`${e.title} › ${t.title}`, n);
21
+ });
22
+ });
23
+ });
24
+ }
25
+ async function f(e, t) {
26
+ let n = e.__file ?? t, a = x(n) ?? t, o = {
27
+ id: t.replace(/\W+/g, "-").toLowerCase(),
28
+ path: n,
29
+ moduleId: n,
30
+ fileName: a.includes(".") ? a.slice(0, a.indexOf(".")) : a
31
+ }, s = [], c = [], l = document.createElement("div");
32
+ try {
33
+ await r(e, {
34
+ file: o,
35
+ storyData: s,
36
+ el: l
37
+ }, {
38
+ beforeSetup(e) {
39
+ e.config.errorHandler = (e) => {
40
+ c.push(e);
41
+ }, e.config.warnHandler = (e, t, n) => {
42
+ c.push(b(e, n));
43
+ };
44
+ },
45
+ afterSetup(e) {
46
+ _(e._context.components, h()), g(e);
47
+ }
48
+ });
49
+ } catch (e) {
50
+ c.push(e);
51
+ }
52
+ let u = {
53
+ id: o.id,
54
+ supportPluginId: "vue3",
55
+ component: i(e),
56
+ path: [],
57
+ filePath: o.path,
58
+ source: async () => ({ default: "" })
59
+ };
60
+ return {
61
+ stories: s.map((e) => {
62
+ let t = {
63
+ ...e,
64
+ file: i(u),
65
+ variants: e.variants.map((e) => p(e)),
66
+ slots: () => ({})
67
+ };
68
+ return u.story = t, t;
69
+ }),
70
+ problems: c
71
+ };
72
+ }
73
+ function p(e) {
74
+ return {
75
+ ...e,
76
+ state: o({
77
+ _hPropState: {},
78
+ _hPropDefs: {}
79
+ }),
80
+ setupApp: void 0,
81
+ slots: () => ({}),
82
+ previewReady: !1
83
+ };
84
+ }
85
+ async function m(t, r, i) {
86
+ let a = [], s = (e) => {
87
+ a.push(e);
88
+ }, c = (e, t) => {
89
+ a.push(b(e, t));
90
+ }, l = !1, u = document.createElement("div");
91
+ document.body.appendChild(u);
92
+ let d = n({
93
+ name: "StoryTestMount",
94
+ el: u,
95
+ getStory: () => t,
96
+ getVariant: () => null,
97
+ renderContext: o({
98
+ mode: "mount",
99
+ slotName: "default",
100
+ currentVariant: null,
101
+ targetVariantId: r.id,
102
+ externalState: null,
103
+ nextVariantIndex: { value: 0 }
104
+ }),
105
+ onError: s,
106
+ onWarn: c,
107
+ configureApp: g
108
+ }), f = o({}), p = e(r.state, f), m = n({
109
+ name: "StoryTestRender",
110
+ el: u,
111
+ getStory: () => t,
112
+ getVariant: () => r,
113
+ renderContext: o({
114
+ mode: "render",
115
+ slotName: "default",
116
+ currentVariant: r,
117
+ externalState: f,
118
+ nextVariantIndex: { value: 0 }
119
+ }),
120
+ wrapInDiv: !0,
121
+ onError: s,
122
+ onWarn: c,
123
+ onResolve: () => {
124
+ l = !0;
125
+ },
126
+ configureApp: g
127
+ });
128
+ try {
129
+ await d.mount(), await v(() => !!r.configReady || a.length > 0, i) || a.push(/* @__PURE__ */ Error(`its setup did not settle within ${i} ms`)), a.length || (await m.mount(), await v(() => l || a.length > 0, i) || a.push(/* @__PURE__ */ Error(`its render did not settle within ${i} ms`)));
130
+ } catch (e) {
131
+ a.push(e);
132
+ } finally {
133
+ m.unmount(), d.unmount(), p.stop(), u.remove();
134
+ }
135
+ return a;
136
+ }
137
+ function h() {
138
+ let e = {};
139
+ return t({ component: (t, n) => {
140
+ e[t] = n;
141
+ } }), e;
142
+ }
143
+ function g(e) {
144
+ let t = s();
145
+ t && (_(e, t), _(e._context.provides, t._context.provides), _(e.config.globalProperties, t.config.globalProperties), _(e._context.components, t._context.components), _(e._context.directives, t._context.directives));
146
+ }
147
+ function _(e, t) {
148
+ for (let n of Reflect.ownKeys(t)) n in e || Object.defineProperty(e, n, Object.getOwnPropertyDescriptor(t, n));
149
+ }
150
+ async function v(e, t) {
151
+ let n = Date.now() + t;
152
+ do
153
+ if (await a(), await new Promise((e) => setTimeout(e)), e()) return !0;
154
+ while (Date.now() < n);
155
+ return e();
156
+ }
157
+ function y(e, t) {
158
+ let n = t[0], r = t.map((e) => e instanceof Error ? e.stack ?? e.message : String(e)), i = /* @__PURE__ */ Error(`${e}: ${t.length === 1 ? "one problem" : `${t.length} problems`}\n\n${r.join("\n\n")}`);
159
+ return n instanceof Error && (i.cause = n), i;
160
+ }
161
+ function b(e, t) {
162
+ return `[Vue warn]: ${e}${t ? `\n${t}` : ""}`;
163
+ }
164
+ function x(e) {
165
+ return e?.split(/[\\/]/).pop();
166
+ }
167
+ //#endregion
168
+ export { d as testStories };
@@ -1,5 +1,5 @@
1
1
  import type { Story } from '@poveste/shared';
2
- import type { PropType, VNode } from 'vue';
2
+ import type { Component, PropType, VNode } from 'vue';
3
3
  import type { PreviewRenderContext } from './render-context.js';
4
4
  declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
5
5
  initState: {
@@ -10,6 +10,14 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
10
10
  type: PropType<Story["meta"]>;
11
11
  default: undefined;
12
12
  };
13
+ autoDocs: {
14
+ type: PropType<Story["autoDocs"]>;
15
+ default: undefined;
16
+ };
17
+ component: {
18
+ type: PropType<Component | Component[]>;
19
+ default: undefined;
20
+ };
13
21
  }>, {
14
22
  renderContext: PreviewRenderContext | null;
15
23
  story: import("vue").ComputedRef<Story>;
@@ -29,8 +37,18 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
29
37
  type: PropType<Story["meta"]>;
30
38
  default: undefined;
31
39
  };
40
+ autoDocs: {
41
+ type: PropType<Story["autoDocs"]>;
42
+ default: undefined;
43
+ };
44
+ component: {
45
+ type: PropType<Component | Component[]>;
46
+ default: undefined;
47
+ };
32
48
  }>> & Readonly<{}>, {
49
+ component: Component | Component[];
33
50
  meta: import("poveste").StoryMeta | undefined;
51
+ autoDocs: boolean | import("poveste").AutoDocsSection[] | undefined;
34
52
  initState: () => any | Promise<any>;
35
53
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
36
54
  export default _default;
@@ -69,11 +69,11 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
69
69
  };
70
70
  }>> & Readonly<{}>, {
71
71
  meta: import("poveste").VariantMeta | undefined;
72
- initState: () => any | Promise<any>;
72
+ setupApp: Function;
73
73
  source: string;
74
74
  responsiveDisabled: boolean;
75
75
  autoPropsDisabled: boolean;
76
- setupApp: Function;
76
+ initState: () => any | Promise<any>;
77
77
  implicit: boolean;
78
78
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
79
79
  export default _default;
@@ -1,2 +1,3 @@
1
1
  import type { App } from 'vue';
2
2
  export declare function registerGlobalComponents(app: App): void;
3
+ export declare function registerControlComponents(app: App): void;
@@ -1,4 +1,5 @@
1
1
  import type { Story, Variant } from '@poveste/shared';
2
+ import type { App } from 'vue';
2
3
  import type { PreviewRenderContext } from './render-context.js';
3
4
  interface PreviewHostOptions {
4
5
  name: string;
@@ -7,6 +8,13 @@ interface PreviewHostOptions {
7
8
  getVariant: () => Variant | null;
8
9
  renderContext: PreviewRenderContext;
9
10
  wrapInDiv?: boolean;
11
+ /** A story test's: what the app would only log, it fails on. */
12
+ onError?: (err: unknown) => void;
13
+ onWarn?: (message: string, trace: string) => void;
14
+ /** A story test's: when the render's async setups have settled. */
15
+ onResolve?: () => void;
16
+ /** A story test's, run after the app's own registrations and setup hooks. */
17
+ configureApp?: (app: App) => void;
10
18
  }
11
19
  export declare function createPreviewHost(options: PreviewHostOptions): {
12
20
  mount: () => Promise<void>;
@@ -49,6 +49,22 @@ export declare function syncStateBundledAndExternal(bundledState: Record<string,
49
49
  * it appeared in the panel and warned when written.
50
50
  */
51
51
  export declare function isWritableBinding(value: unknown): boolean;
52
+ /**
53
+ * A component a story holds in its setup, which implicit state skips.
54
+ *
55
+ * Each key is asked with `in` before it is read. Nuxt's runtime config is, in
56
+ * dev, a proxy that warns on any key it does not carry, and reading `__file`,
57
+ * `render` and `setup` off it printed `NUXT_E1003` three times a mount (#1454).
58
+ */
59
+ export declare function isComponentBinding(value: unknown): boolean;
60
+ /**
61
+ * A Vue app, or an object holding one in a data property of its own, as the
62
+ * Nuxt app `useNuxtApp()` returns does. Implicit state skips it: the state sync
63
+ * deep-watches what it holds, so it walked the whole app on every sync, as far
64
+ * as the dev-only `app.config.compilerOptions` getter that warns when read
65
+ * (#1457). Read through descriptors, so no getter runs to find out.
66
+ */
67
+ export declare function holdsVueApp(value: unknown): boolean;
52
68
  export declare function useInstance(name: string): ComponentInternalInstance;
53
69
  /**
54
70
  * Warns, once, when a component built against `@poveste/vendors/vue` is