@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.
Files changed (62) hide show
  1. package/README.md +7 -0
  2. package/dist/bundled/client/app/MountStory.js +32 -30
  3. package/dist/bundled/client/app/RenderStory.js +39 -44
  4. package/dist/bundled/client/app/Story.js +62 -60
  5. package/dist/bundled/client/app/global-components.js +5 -3
  6. package/dist/bundled/client/app/host.js +9 -5
  7. package/dist/bundled/client/app/util.js +46 -33
  8. package/dist/bundled/client/server/Story.js +13 -0
  9. package/dist/bundled/client/server/collect.js +41 -0
  10. package/dist/bundled/client/server/run.js +10 -39
  11. package/dist/bundled/client/server.js +1 -2
  12. package/dist/bundled/testing/index.js +168 -0
  13. package/dist/client/app/Story.d.ts +19 -1
  14. package/dist/client/app/Variant.d.ts +2 -2
  15. package/dist/client/app/global-components.d.ts +1 -0
  16. package/dist/client/app/host.d.ts +8 -0
  17. package/dist/client/app/util.d.ts +28 -0
  18. package/dist/client/server/Story.d.ts +21 -3
  19. package/dist/client/server/collect.d.ts +14 -0
  20. package/dist/client-dependencies.d.ts +2 -0
  21. package/dist/client-dependencies.js +2 -0
  22. package/dist/docgen/events.d.ts +9 -0
  23. package/dist/docgen/events.js +45 -0
  24. package/dist/docgen/extractor.d.ts +7 -0
  25. package/dist/docgen/extractor.js +60 -0
  26. package/dist/docgen/generic.d.ts +5 -0
  27. package/dist/docgen/generic.js +19 -0
  28. package/dist/docgen/meta.d.ts +12 -0
  29. package/dist/docgen/meta.js +76 -0
  30. package/dist/docgen/slots.d.ts +6 -0
  31. package/dist/docgen/slots.js +21 -0
  32. package/dist/index.node.d.ts +2 -0
  33. package/dist/index.node.js +24 -11
  34. package/dist/testing/index.d.ts +28 -0
  35. package/dist/testing/vite.d.ts +18 -0
  36. package/dist/testing/vite.js +171 -0
  37. package/dist/util/project-vue.d.ts +1 -0
  38. package/dist/util/project-vue.js +12 -0
  39. package/dist/util/vue-plugin.d.ts +10 -0
  40. package/dist/util/vue-plugin.js +28 -0
  41. package/package.json +33 -15
  42. package/src/client/app/MountStory.ts +2 -0
  43. package/src/client/app/RenderStory.ts +2 -1
  44. package/src/client/app/Story.ts +15 -3
  45. package/src/client/app/global-components.ts +4 -0
  46. package/src/client/app/host.ts +21 -2
  47. package/src/client/app/util.ts +65 -0
  48. package/src/client/server/Story.ts +15 -2
  49. package/src/client/server/collect.ts +83 -0
  50. package/src/client/server/run.ts +3 -63
  51. package/src/client-dependencies.ts +2 -0
  52. package/src/docgen/events.ts +55 -0
  53. package/src/docgen/extractor.ts +67 -0
  54. package/src/docgen/generic.ts +20 -0
  55. package/src/docgen/meta.ts +93 -0
  56. package/src/docgen/slots.ts +33 -0
  57. package/src/index.node.ts +27 -12
  58. package/src/testing/index.ts +286 -0
  59. package/src/testing/vite.ts +194 -0
  60. package/src/util/project-vue.ts +13 -0
  61. package/src/util/vue-plugin.ts +32 -0
  62. 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 { createPreviewHost as e } from "./host.js";
2
- import { defineComponent as t, h as n, onMounted as r, onUnmounted as i, ref as a, watch as o } from "@poveste/vendors/vue";
3
- import { reactive as s } from "vue";
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 c = t({
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(t) {
22
- let n = a(), c = s({
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: t.targetVariantId,
27
- syncState: t.syncState,
28
+ targetVariantId: n.targetVariantId,
29
+ syncState: n.syncState,
28
30
  externalState: null,
29
31
  nextVariantIndex: { value: 0 }
30
- }), l = null;
31
- async function u() {
32
- n.value && (l = e({
32
+ }), u = null;
33
+ async function d() {
34
+ r.value && (u = t({
33
35
  name: "MountStorySubApp",
34
- el: n.value,
35
- getStory: () => t.story,
36
+ el: r.value,
37
+ getStory: () => n.story,
36
38
  getVariant: () => null,
37
- renderContext: c
38
- }), await l.mount());
39
+ renderContext: l
40
+ }), await u.mount());
39
41
  }
40
- function d() {
41
- l?.unmount(), l = null;
42
+ function f() {
43
+ u?.unmount(), u = null;
42
44
  }
43
- return o(() => t.story.id, async () => {
44
- d(), await u();
45
- }), r(async () => {
46
- await u();
47
- }), o(() => t.story.variants, () => {
48
- l?.forceUpdate();
49
- }), o(() => t.targetVariantId, (e) => {
50
- c.targetVariantId = e;
51
- }), i(() => {
52
- d();
53
- }), { el: n };
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 n("div", { ref: "el" });
58
+ return r("div", { ref: "el" });
57
59
  }
58
60
  });
59
61
  //#endregion
60
- export { c as default };
62
+ export { l as default };
@@ -1,9 +1,9 @@
1
- import { syncStateBundledAndExternal as e } from "./util.js";
2
- import { createPreviewHost as t } from "./host.js";
3
- import { defineComponent as n, h as r, onBeforeUnmount as i, onMounted as a, ref as o, watch as s } from "@poveste/vendors/vue";
4
- import { reactive as c } from "vue";
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 l = n({
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(n, { emit: r }) {
24
- let l = o(), u = null, d = !1, f = c({}), p = e(n.variant.state, f), m = c({
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: n.slotName,
27
- currentVariant: n.variant,
28
- externalState: f,
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
- p?.stop(), p = e(n.variant.state, f);
33
+ d?.unmount(), d = null;
34
+ }
35
+ function _() {
36
+ m?.stop(), m = e(r.variant.state, p);
36
37
  }
37
- async function _() {
38
- if (!d) {
39
- if (d = !0, h(), m.currentVariant = n.variant, m.slotName = n.slotName, !l.value) {
40
- d = !1;
41
- return;
42
- }
43
- u = t({
44
- name: "RenderStorySubApp",
45
- el: l.value,
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 a(async () => {
54
- n.variant.configReady && await _();
55
- }), s(() => n.variant, () => {
56
- m.currentVariant = n.variant, g();
57
- }), s(() => [
58
- n.story.id,
59
- n.slotName,
60
- n.variant.id,
61
- n.variant.configReady
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
- m.currentVariant = n.variant, m.slotName = e, n.variant.configReady && !d && (u ? u.forceUpdate() : await _());
64
- }), i(() => {
65
- p?.stop(), h();
66
- }), { sandbox: l };
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 r("div", { ref: "sandbox" });
64
+ return i("div", { ref: "sandbox" });
70
65
  }
71
66
  });
72
67
  //#endregion
73
- export { l as default };
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 { 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,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(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) {
73
- if (s.type?.__povesteType === "variant") {
74
- let t = l.story.variants[e];
75
- if (e++, !t || n !== -1 && e - 1 !== n) continue;
76
- let r = { variant: t };
77
- 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));
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(c.slots.default?.() ?? []);
92
+ return r(u.slots.default?.() ?? []);
85
93
  }
86
- function S(e) {
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 += S(n.children));
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 C(e) {
99
+ function T(e) {
92
100
  e.nextVariantIndex.value = 0;
93
101
  let t = { state: e.externalState }, n = [];
94
- 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) ?? []);
95
103
  let r = e.currentVariant;
96
- if (e.slotName === "default" && r && S(n) === l.story.variants.length) {
97
- 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);
98
106
  if (t !== -1) {
99
107
  let r = 0, i = !1, a = (e) => {
100
108
  let n = [];
101
- for (let s of e) {
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
- }, s = a(n);
110
- if (i) return e.nextVariantIndex.value = t, s;
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 l(a, {
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 { 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);
@@ -1,66 +1,66 @@
1
- import { isRef as e, unref as t, watch as n } from "@poveste/vendors/vue";
2
- import { getCurrentInstance as r, isReadonly as i, isRef as a, markRaw as o, unref as s, watch as c } from "vue";
3
- import { applyState as l, createStateBaseline as u, isMarkedRaw as d, isPlainObject as f } from "@poveste/shared";
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 p = (e) => typeof e == "object" && !!e;
6
- function m(e, t = /* @__PURE__ */ new WeakMap()) {
7
- let n = a(e) ? s(e) : e;
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 (!p(n) || d(n)) return n;
9
+ if (!m(n) || f(n)) return n;
10
10
  if (t.has(n)) return t.get(n);
11
- if (!Array.isArray(n) && !f(n)) return o(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) => m(e, t))), 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), h(n, e, t), e;
18
+ return t.set(n, e), g(n, e, t), e;
19
19
  }
20
20
  }
21
- function h(e, t, n = /* @__PURE__ */ new WeakMap()) {
21
+ function g(e, t, n = /* @__PURE__ */ new WeakMap()) {
22
22
  Object.keys(e).forEach((r) => {
23
- t[r] = m(e[r], n);
23
+ t[r] = h(e[r], n);
24
24
  });
25
25
  }
26
- function g(n, r = /* @__PURE__ */ new WeakMap()) {
27
- let i = e(n) ? t(n) : n;
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 (!p(i) || d(i)) return i;
29
+ if (!m(i) || f(i)) return i;
30
30
  if (r.has(i)) return r.get(i);
31
- if (!Array.isArray(i) && !f(i)) return o(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) => g(e, r))), 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), _(i, e, r), e;
38
+ return r.set(i, e), v(i, e, r), e;
39
39
  }
40
40
  }
41
- function _(e, t, n = /* @__PURE__ */ new WeakMap()) {
41
+ function v(e, t, n = /* @__PURE__ */ new WeakMap()) {
42
42
  Object.keys(e).forEach((r) => {
43
- t[r] = g(e[r], n);
43
+ t[r] = _(e[r], n);
44
44
  });
45
45
  }
46
- function v(e, t) {
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 y(e, t, r = []) {
53
- let i = u(), a = n(() => e, (e) => {
52
+ function b(e, t, n = []) {
53
+ let i = d(), a = r(() => e, (e) => {
54
54
  if (e == null) return;
55
- let n = i.take(v(g(e), r));
56
- n && l(t, n);
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 = c(() => t, (t) => {
60
+ }), o = l(() => t, (t) => {
61
61
  if (t == null) return;
62
- let n = i.take(v(m(t), r));
63
- n && l(e, n);
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
- let t = r();
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 { g as _toRawDeep, b as isWritableBinding, y as syncStateBundledAndExternal, m as toRawDeep, x as useInstance };
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 };