@poveste/plugin-vue 0.13.1 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/README.md +1 -1
  2. package/dist/bundled/client/app/MountStory.js +3 -3
  3. package/dist/bundled/client/app/RenderStory.js +15 -9
  4. package/dist/bundled/client/app/Story.js +56 -43
  5. package/dist/bundled/client/app/Variant.js +32 -27
  6. package/dist/bundled/client/app/global-components.js +11 -10
  7. package/dist/bundled/client/app/host.js +2 -2
  8. package/dist/bundled/client/app/util.js +31 -26
  9. package/dist/bundled/client/client.js +4 -4
  10. package/dist/bundled/client/codegen.js +79 -60
  11. package/dist/bundled/client/server/Story.js +9 -7
  12. package/dist/bundled/client/server/Variant.js +1 -0
  13. package/dist/bundled/client/server/run.js +2 -2
  14. package/dist/client/app/MountStory.d.ts +3 -3
  15. package/dist/client/app/RenderStory.d.ts +1 -1
  16. package/dist/client/app/Story.d.ts +10 -7
  17. package/dist/client/app/Variant.d.ts +14 -13
  18. package/dist/client/app/render-context.d.ts +1 -1
  19. package/dist/client/app/util.d.ts +6 -3
  20. package/dist/client/codegen.d.ts +29 -0
  21. package/dist/client/server/Story.d.ts +17 -17
  22. package/dist/client/server/Variant.d.ts +10 -10
  23. package/dist/commands/generate-story.client.js +4 -4
  24. package/dist/commands/generate-story.server.js +2 -2
  25. package/dist/helpers.d.ts +2 -2
  26. package/dist/index.node.js +2 -0
  27. package/dist/util/list-components.d.ts +1 -1
  28. package/dist/util/list-components.js +63 -6
  29. package/dist/util/list-components.spec.d.ts +1 -0
  30. package/dist/util/list-components.spec.js +46 -0
  31. package/package.json +12 -11
  32. package/src/client/__tests__/codegen-attrs.spec.ts +149 -0
  33. package/src/client/app/MountStory.ts +5 -1
  34. package/src/client/app/RenderStory.ts +6 -1
  35. package/src/client/app/RouterLinkStub.ts +1 -1
  36. package/src/client/app/Story.ts +78 -37
  37. package/src/client/app/Variant.ts +26 -23
  38. package/src/client/app/__tests__/preview-variants.spec.ts +76 -0
  39. package/src/client/app/auto-props.ts +2 -2
  40. package/src/client/app/global-components.ts +20 -14
  41. package/src/client/app/host.ts +9 -6
  42. package/src/client/app/util.ts +17 -7
  43. package/src/client/codegen.ts +81 -29
  44. package/src/client/server/Story.ts +10 -4
  45. package/src/client/server/Variant.ts +3 -0
  46. package/src/client/server/run.ts +5 -4
  47. package/src/commands/generate-story.client.ts +4 -4
  48. package/src/commands/generate-story.server.ts +2 -2
  49. package/src/helpers.ts +2 -2
  50. package/src/index.node.ts +2 -0
  51. package/src/util/list-components.spec.ts +54 -0
  52. package/src/util/list-components.ts +68 -6
package/README.md CHANGED
@@ -40,5 +40,5 @@ import MyButton from './MyButton.vue'
40
40
  Coming from histoire? The Vue API is unchanged: swap the dependency and your existing
41
41
  `.story.vue` files keep working.
42
42
 
43
- [Vue guide](https://poveste.dev/guide/vue/getting-started.html) ·
43
+ [Vue guide](https://poveste.dev/guide/vue/getting-started) ·
44
44
  [Documentation](https://poveste.dev)
@@ -22,15 +22,15 @@ var c = t({
22
22
  targetVariantId: t.targetVariantId,
23
23
  externalState: null,
24
24
  nextVariantIndex: { value: 0 }
25
- }), l;
25
+ }), l = null;
26
26
  async function u() {
27
- l = e({
27
+ n.value && (l = e({
28
28
  name: "MountStorySubApp",
29
29
  el: n.value,
30
30
  getStory: () => t.story,
31
31
  getVariant: () => null,
32
32
  renderContext: c
33
- }), await l.mount();
33
+ }), await l.mount());
34
34
  }
35
35
  function d() {
36
36
  l?.unmount(), l = null;
@@ -21,7 +21,7 @@ var l = n({
21
21
  },
22
22
  emits: { ready: () => !0 },
23
23
  setup(n, { emit: r }) {
24
- let l = o(), u, d = !1, f = c({}), p = e(n.variant.state, f), m = c({
24
+ let l = o(), u = null, d = !1, f = c({}), p = e(n.variant.state, f), m = c({
25
25
  mode: "render",
26
26
  slotName: n.slotName,
27
27
  currentVariant: n.variant,
@@ -35,14 +35,20 @@ var l = n({
35
35
  p?.stop(), p = e(n.variant.state, f);
36
36
  }
37
37
  async function _() {
38
- d || (d = !0, h(), m.currentVariant = n.variant, m.slotName = n.slotName, u = t({
39
- name: "RenderStorySubApp",
40
- el: l.value,
41
- getStory: () => n.story,
42
- getVariant: () => n.variant,
43
- renderContext: m,
44
- wrapInDiv: !0
45
- }), await u.mount(), d = !1, r("ready"));
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
+ }
46
52
  }
47
53
  return a(async () => {
48
54
  n.variant.configReady && await _();
@@ -1,9 +1,10 @@
1
1
  import { useRenderContext as e } from "./render-context.js";
2
- import t from "./Variant.js";
3
- import { cloneVNode as n, computed as r, defineComponent as i, getCurrentInstance as a, h as o, isRef as s, provide as c, reactive as l, useAttrs as u } from "vue";
2
+ import { useInstance as t } from "./util.js";
3
+ import n from "./Variant.js";
4
+ import { cloneVNode as r, computed as i, defineComponent as a, h as o, isRef as s, provide as c, reactive as l, useAttrs as u } from "vue";
4
5
  import { omitInheritStoryProps as d } from "@poveste/shared";
5
6
  //#region src/client/app/Story.ts
6
- var f = i({
7
+ var f = a({
7
8
  name: "Story",
8
9
  __povesteType: "story",
9
10
  inheritAttrs: !1,
@@ -17,10 +18,10 @@ var f = i({
17
18
  default: void 0
18
19
  }
19
20
  },
20
- setup(t) {
21
- let i = a(), o = u(), f = e(), p = r(() => o.story);
21
+ setup(n) {
22
+ let a = t("Story"), o = u(), f = e(), p = i(() => o.story);
22
23
  c("story", p);
23
- let m = i.parent, h = l({});
24
+ let m = a.parent, h = l({});
24
25
  Object.defineProperty(h, "$data", {
25
26
  enumerable: !0,
26
27
  configurable: !0,
@@ -49,67 +50,79 @@ var f = i({
49
50
  for (let e in m.data) g(m.data, e);
50
51
  c("implicitState", () => h);
51
52
  function _() {
52
- t.meta && (o.story.meta || (o.story.meta = {}), Object.assign(o.story.meta, t.meta)), Object.assign(o.story, { slots: () => i.proxy.$slots });
53
+ n.meta && (o.story.meta || (o.story.meta = {}), Object.assign(o.story.meta, n.meta)), Object.assign(o.story, { slots: () => a.slots });
53
54
  }
54
55
  return {
55
56
  renderContext: f,
56
57
  story: p,
57
- renderMountStory: v,
58
- renderPreviewStory: y,
58
+ renderMountStory: y,
59
+ renderPreviewStory: x,
59
60
  updateStory: _
60
61
  };
61
- function v() {
62
- let e = 0, r = f?.targetVariantId ? o.story.variants.findIndex((e) => e.id === f.targetVariantId) : -1, a = (s) => {
63
- let c = [];
64
- for (let l of s) {
65
- if (l.type?.__povesteType === "variant") {
66
- let a = o.story.variants[e];
67
- if (e++, !a || r !== -1 && e - 1 !== r) continue;
68
- let s = { variant: a };
69
- l.key ?? (s.key = a.id), !l.props?.initState && !l.props?.["init-state"] && (s.initState = t.initState);
70
- for (let e in i.proxy.$attrs) l.props?.[e] === void 0 && (s[e] = i.proxy.$attrs[e]);
71
- for (let e in o.story) !d.includes(e) && l.props?.[e] === void 0 && (s[e] = o.story[e]);
72
- c.push(n(l, s));
62
+ function v(e) {
63
+ let t = {};
64
+ for (let n in a.attrs) e.props?.[n] === void 0 && (t[n] = a.attrs[n]);
65
+ for (let n in o.story) !d.includes(n) && e.props?.[n] === void 0 && (t[n] = Reflect.get(o.story, n));
66
+ return t;
67
+ }
68
+ function y() {
69
+ let e = 0, t = f?.targetVariantId, i = t ? o.story.variants.findIndex((e) => e.id === t) : -1, s = (t) => {
70
+ let a = [];
71
+ for (let c of t) {
72
+ if (c.type?.__povesteType === "variant") {
73
+ let t = o.story.variants[e];
74
+ if (e++, !t || i !== -1 && e - 1 !== i) continue;
75
+ let s = { variant: t };
76
+ c.key ?? (s.key = t.id), !c.props?.initState && !c.props?.["init-state"] && (s.initState = n.initState), Object.assign(s, v(c)), a.push(r(c, s));
73
77
  continue;
74
78
  }
75
- Array.isArray(l.children) && (l.children = a(l.children)), c.push(l);
79
+ Array.isArray(c.children) && (c.children = s(c.children)), a.push(c);
76
80
  }
77
- return c;
81
+ return a;
78
82
  };
79
- return a(i.proxy.$slots.default?.() ?? []);
83
+ return s(a.slots.default?.() ?? []);
80
84
  }
81
- function y() {
82
- f.nextVariantIndex.value = 0;
83
- let e = { state: f.externalState }, t = [];
84
- if (f.slotName === "controls" && t.push(...i.proxy.$slots.controls?.(e) ?? []), (f.slotName === "default" || o.story.meta?.hasVariantChildComponents) && t.push(...i.proxy.$slots.default?.(e) ?? []), f.slotName === "default" && f.currentVariant && !o.story.meta?.hasVariantChildComponents) {
85
- let e = o.story.variants.findIndex((e) => e.id === f.currentVariant.id);
86
- if (e !== -1) {
87
- let n = 0, r = !1, i = (t) => {
88
- let a = [];
89
- for (let o of t) {
90
- if (o?.type?.__povesteType === "variant") {
91
- n === e && (a.push(o), r = !0), n++;
85
+ function b(e) {
86
+ let t = 0;
87
+ for (let n of e) n?.type?.__povesteType === "variant" ? t++ : Array.isArray(n?.children) && (t += b(n.children));
88
+ return t;
89
+ }
90
+ function x(e) {
91
+ e.nextVariantIndex.value = 0;
92
+ let t = { state: e.externalState }, n = [];
93
+ e.slotName === "controls" && n.push(...a.slots.controls?.(t) ?? []), (e.slotName === "default" || o.story.meta?.hasVariantChildComponents) && n.push(...a.slots.default?.(t) ?? []);
94
+ let i = e.currentVariant;
95
+ if (e.slotName === "default" && i && b(n) === o.story.variants.length) {
96
+ let t = o.story.variants.findIndex((e) => e.id === i.id);
97
+ if (t !== -1) {
98
+ let i = 0, a = !1, o = (e) => {
99
+ let n = [];
100
+ for (let s of e) {
101
+ if (s?.type?.__povesteType === "variant") {
102
+ i === t && (n.push(r(s, v(s))), a = !0), i++;
92
103
  continue;
93
104
  }
94
- Array.isArray(o?.children) && o.children.length && (o.children = i(o.children)), a.push(o);
105
+ Array.isArray(s?.children) && s.children.length && (s.children = o(s.children)), n.push(s);
95
106
  }
96
- return a;
97
- }, a = i(t);
98
- if (r) return f.nextVariantIndex.value = e, a;
107
+ return n;
108
+ }, s = o(n);
109
+ if (a) return e.nextVariantIndex.value = t, s;
99
110
  }
100
111
  }
101
- return t;
112
+ return n;
102
113
  }
103
114
  },
104
115
  render() {
105
116
  this.updateStory();
106
117
  let [e] = this.story.variants;
107
- return e?.id === "_default" ? o(t, {
118
+ if (e?.id === "_default") return o(n, {
108
119
  variant: e,
109
- initState: this.initState,
120
+ ...this.initState ? { initState: this.initState } : {},
110
121
  implicit: !0,
111
122
  ...this.$attrs
112
- }, this.$slots) : this.renderContext?.mode === "render" ? this.renderPreviewStory() : this.renderMountStory();
123
+ }, this.$slots);
124
+ let t = this.renderContext;
125
+ return t?.mode === "render" ? this.renderPreviewStory(t) : this.renderMountStory();
113
126
  }
114
127
  });
115
128
  //#endregion
@@ -1,10 +1,10 @@
1
1
  import { useRenderContext as e } from "./render-context.js";
2
- import { syncVariantAutoProps as t } from "./auto-props.js";
3
- import { syncStateBundledAndExternal as n, toRawDeep as r } from "./util.js";
4
- import { computed as i, defineComponent as a, getCurrentInstance as o, inject as s, onBeforeUnmount as c, useAttrs as l } from "vue";
2
+ import { syncStateBundledAndExternal as t, toRawDeep as n, useInstance as r } from "./util.js";
3
+ import { syncVariantAutoProps as i } from "./auto-props.js";
4
+ import { computed as a, defineComponent as o, inject as s, onBeforeUnmount as c, useAttrs as l } from "vue";
5
5
  import { applyState as u, autoPropsStateKeys as d } from "@poveste/shared";
6
6
  //#region src/client/app/Variant.ts
7
- var f = a({
7
+ var f = o({
8
8
  name: "Variant",
9
9
  __povesteType: "variant",
10
10
  props: {
@@ -37,41 +37,43 @@ var f = a({
37
37
  default: !1
38
38
  }
39
39
  },
40
- async setup(a) {
41
- let f = l(), p = o(), m = s("story"), h = s("implicitState"), g = e(), _, v, y, b;
40
+ async setup(o) {
41
+ let f = l(), p = r("Variant"), m = s("story"), h = s("implicitState"), g = e(), _, v, y = null, b;
42
42
  c(() => {
43
43
  y?.stop(), b?.stop();
44
44
  });
45
- let x = i(() => f.variant);
46
- if (g?.mode !== "render" && typeof a.initState == "function" && x.value) {
47
- let e = await a.initState();
48
- u(x.value.state, r(e));
45
+ let x = a(() => f.variant);
46
+ if (g?.mode !== "render" && typeof o.initState == "function" && x.value) {
47
+ let e = await o.initState();
48
+ u(x.value.state, n(e));
49
49
  }
50
- g?.mode !== "render" && x.value && h && (b = n(x.value.state, h(), d));
50
+ g?.mode !== "render" && x.value && h && (b = t(x.value.state, h(), d));
51
51
  function S(e) {
52
52
  Object.assign(e, {
53
- slots: () => p.proxy.$slots,
54
- source: a.source,
55
- responsiveDisabled: a.responsiveDisabled,
56
- autoPropsDisabled: a.autoPropsDisabled,
57
- setupApp: a.setupApp,
58
- meta: a.meta,
53
+ slots: () => p.slots,
54
+ source: o.source,
55
+ responsiveDisabled: o.responsiveDisabled,
56
+ autoPropsDisabled: o.autoPropsDisabled,
57
+ setupApp: o.setupApp,
58
+ meta: o.meta,
59
59
  configReady: !0
60
- }), !a.implicit && !m.value?.meta?.hasVariantChildComponents && (m.value.meta || (m.value.meta = {}), Object.assign(m.value.meta, { hasVariantChildComponents: !0 }));
60
+ });
61
+ let t = m?.value;
62
+ t && !o.implicit && !t.meta?.hasVariantChildComponents && (t.meta ||= {}, Object.assign(t.meta, { hasVariantChildComponents: !0 }));
61
63
  }
62
64
  function C() {
63
- return f.variant ? f.variant : g?.mode === "render" ? (v || (v = m.value?.variants[g.nextVariantIndex.value], g.nextVariantIndex.value++), v) : null;
65
+ return f.variant ? f.variant : g?.mode === "render" ? (v || (v = m?.value?.variants[g.nextVariantIndex.value], g.nextVariantIndex.value++), v) : null;
64
66
  }
65
- function w(e) {
66
- if (g.slotName === "controls") return p.proxy.$slots.controls?.({ state: g.externalState }) ?? null;
67
- if (g.slotName !== "default") return null;
68
- let n = p.proxy.$slots.default?.({ state: g.externalState }) ?? null;
69
- return n && !e.autoPropsDisabled && (_ = t(e, n, g.externalState, _)), n;
67
+ function w(e, t) {
68
+ if (t.slotName === "controls") return p.slots.controls?.({ state: t.externalState }) ?? null;
69
+ if (t.slotName !== "default") return null;
70
+ let n = p.slots.default?.({ state: t.externalState }) ?? null;
71
+ return n && !e.autoPropsDisabled && (_ = i(e, n, t.externalState, _)), n;
70
72
  }
71
73
  function T(e) {
72
74
  if (!h) return;
73
- let t = g?.mode === "render" && g.currentVariant?.id === e.id;
74
- t && !y ? y = n(e.state, h(), d) : !t && y && (y.stop(), y = null);
75
+ let n = g?.mode === "render" && g.currentVariant?.id === e.id;
76
+ n && !y ? y = t(e.state, h(), d) : !n && y && (y.stop(), y = null);
75
77
  }
76
78
  return x.value && S(x.value), {
77
79
  renderContext: g,
@@ -83,7 +85,10 @@ var f = a({
83
85
  },
84
86
  render() {
85
87
  let e = this.resolveVariant();
86
- return !e || (this.updateVariant(e), this.syncRenderVariantState(e), this.renderContext?.mode !== "render") || this.renderContext.currentVariant?.id !== e.id ? null : this.renderVariantSlot(e);
88
+ if (!e) return null;
89
+ this.updateVariant(e), this.syncRenderVariantState(e);
90
+ let t = this.renderContext;
91
+ return t?.mode !== "render" || t.currentVariant?.id !== e.id ? null : this.renderVariantSlot(e, t);
87
92
  }
88
93
  });
89
94
  //#endregion
@@ -6,13 +6,14 @@ import { components as f } from "@poveste/controls";
6
6
  //#region src/client/app/global-components.ts
7
7
  function p(n) {
8
8
  n.component("Story", t), n.component("Variant", e);
9
- for (let e in f) n.component(e, m(f[e]));
9
+ for (let [e, t] of Object.entries(f)) n.component(e, m(t));
10
10
  }
11
11
  function m(e) {
12
+ let t = e;
12
13
  return a({
13
- name: e.name,
14
+ ...e.name ? { name: e.name } : {},
14
15
  inheritAttrs: !1,
15
- setup(t, { attrs: a }) {
16
+ setup(e, { attrs: a }) {
16
17
  let o = d(), f = d(), p = i({});
17
18
  function m(e) {
18
19
  Object.assign(p, e);
@@ -23,11 +24,11 @@ function m(e) {
23
24
  let h = [], g = d([]);
24
25
  function _() {
25
26
  g.value.forEach((e, t) => {
26
- let n = f.value.querySelector(`[renderslotid="${t}"]`);
27
- if (!n) return;
28
- let r = o.value.querySelector(`[slotid="${t}"]`);
29
- for (; r.firstChild;) r.removeChild(r.lastChild);
30
- r.appendChild(n);
27
+ let n = f.value?.querySelector(`[renderslotid="${t}"]`), r = o.value?.querySelector(`[slotid="${t}"]`);
28
+ if (!(!n || !r)) {
29
+ for (; r.lastChild;) r.removeChild(r.lastChild);
30
+ r.appendChild(n);
31
+ }
31
32
  });
32
33
  }
33
34
  let v;
@@ -40,7 +41,7 @@ function m(e) {
40
41
  g.value = h, h = [];
41
42
  },
42
43
  render() {
43
- return r(e, {
44
+ return r(t, {
44
45
  ...p,
45
46
  key: "component"
46
47
  }, { default: (e) => (h.push(e), r("div", { slotId: h.length - 1 })) });
@@ -57,7 +58,7 @@ function m(e) {
57
58
  };
58
59
  },
59
60
  render() {
60
- return [o("div", { ref: "el" }), o("div", { ref: "slotEl" }, this.slotCalls.map((e, t) => o("div", { renderSlotId: t }, this.$slots.default(e))))];
61
+ return [o("div", { ref: "el" }), o("div", { ref: "slotEl" }, this.slotCalls.map((e, t) => o("div", { renderSlotId: t }, this.$slots.default?.(e))))];
61
62
  }
62
63
  });
63
64
  }
@@ -20,7 +20,7 @@ var f = o({
20
20
  }
21
21
  },
22
22
  setup(e) {
23
- return t(e.renderContext), () => s(e.story.file.component, { story: e.story });
23
+ return t(e.renderContext), () => e.story.file ? s(e.story.file.component, { story: e.story }) : null;
24
24
  }
25
25
  });
26
26
  function p(e) {
@@ -51,7 +51,7 @@ function p(e) {
51
51
  }, n(t), t.component("RouterLink", r), await m({
52
52
  app: t,
53
53
  story: e.getStory(),
54
- variant: e.getVariant(),
54
+ variant: e.getVariant() ?? void 0,
55
55
  addWrapper: (e) => {
56
56
  c.unshift(e);
57
57
  }
@@ -1,71 +1,76 @@
1
1
  import { isRef as e, unref as t, watch as n } from "@poveste/vendors/vue";
2
- import { isRef as r, unref as i, watch as a } from "vue";
3
- import { applyState as o, createStateBaseline as s } from "@poveste/shared";
2
+ import { getCurrentInstance as r, isRef as i, unref as a, watch as o } from "vue";
3
+ import { applyState as s, createStateBaseline as c } from "@poveste/shared";
4
4
  //#region src/client/app/util.ts
5
- var c = (e) => typeof e == "object" && !!e;
6
- function l(e, t = /* @__PURE__ */ new WeakMap()) {
7
- let n = r(e) ? i(e) : e;
5
+ var l = (e) => typeof e == "object" && !!e;
6
+ function u(e, t = /* @__PURE__ */ new WeakMap()) {
7
+ let n = i(e) ? a(e) : e;
8
8
  if (typeof n == "symbol") return n.toString();
9
- if (!c(n)) return n;
9
+ if (!l(n)) return n;
10
10
  if (t.has(n)) return t.get(n);
11
11
  if (Array.isArray(n)) {
12
12
  let e = [];
13
- return t.set(n, e), e.push(...n.map((e) => l(e, t))), e;
13
+ return t.set(n, e), e.push(...n.map((e) => u(e, t))), e;
14
14
  }
15
15
  {
16
16
  let e = {};
17
- return t.set(n, e), u(n, e, t), e;
17
+ return t.set(n, e), d(n, e, t), e;
18
18
  }
19
19
  }
20
- function u(e, t, n = /* @__PURE__ */ new WeakMap()) {
20
+ function d(e, t, n = /* @__PURE__ */ new WeakMap()) {
21
21
  Object.keys(e).forEach((r) => {
22
- t[r] = l(e[r], n);
22
+ t[r] = u(e[r], n);
23
23
  });
24
24
  }
25
- function d(n, r = /* @__PURE__ */ new WeakMap()) {
25
+ function f(n, r = /* @__PURE__ */ new WeakMap()) {
26
26
  let i = e(n) ? t(n) : n;
27
27
  if (typeof i == "symbol") return i.toString();
28
- if (!c(i)) return i;
28
+ if (!l(i)) return i;
29
29
  if (r.has(i)) return r.get(i);
30
30
  if (Array.isArray(i)) {
31
31
  let e = [];
32
- return r.set(i, e), e.push(...i.map((e) => d(e, r))), e;
32
+ return r.set(i, e), e.push(...i.map((e) => f(e, r))), e;
33
33
  }
34
34
  {
35
35
  let e = {};
36
- return r.set(i, e), f(i, e, r), e;
36
+ return r.set(i, e), p(i, e, r), e;
37
37
  }
38
38
  }
39
- function f(e, t, n = /* @__PURE__ */ new WeakMap()) {
39
+ function p(e, t, n = /* @__PURE__ */ new WeakMap()) {
40
40
  Object.keys(e).forEach((r) => {
41
- t[r] = l(e[r], n);
41
+ t[r] = u(e[r], n);
42
42
  });
43
43
  }
44
- function p(e, t) {
44
+ function m(e, t) {
45
45
  if (!t.length) return e;
46
46
  let n = { ...e };
47
47
  for (let e of t) delete n[e];
48
48
  return n;
49
49
  }
50
- function m(e, t, r = []) {
51
- let i = s(), c = n(() => e, (e) => {
50
+ function h(e, t, r = []) {
51
+ let i = c(), a = n(() => e, (e) => {
52
52
  if (e == null) return;
53
- let n = i.take(p(d(e), r));
54
- n && o(t, n);
53
+ let n = i.take(m(f(e), r));
54
+ n && s(t, n);
55
55
  }, {
56
56
  deep: !0,
57
57
  immediate: !0
58
- }), u = a(() => t, (t) => {
58
+ }), l = o(() => t, (t) => {
59
59
  if (t == null) return;
60
- let n = i.take(p(l(t), r));
61
- n && o(e, n);
60
+ let n = i.take(m(u(t), r));
61
+ n && s(e, n);
62
62
  }, {
63
63
  deep: !0,
64
64
  immediate: !0
65
65
  });
66
66
  return { stop() {
67
- c(), u();
67
+ a(), l();
68
68
  } };
69
69
  }
70
+ function g(e) {
71
+ let t = r();
72
+ if (!t) throw Error(`[poveste] <${e}> can only be set up inside a component`);
73
+ return t;
74
+ }
70
75
  //#endregion
71
- export { d as _toRawDeep, m as syncStateBundledAndExternal, l as toRawDeep };
76
+ export { f as _toRawDeep, h as syncStateBundledAndExternal, u as toRawDeep, g as useInstance };
@@ -1,5 +1,5 @@
1
- import { generateSourceCode as e, getTagName as t } from "./codegen.js";
2
- import n from "./app/MountStory.js";
3
- import r from "./app/RenderStory.js";
1
+ import { delimitAttr as e, generateSourceCode as t, getTagName as n } from "./codegen.js";
2
+ import r from "./app/MountStory.js";
3
+ import i from "./app/RenderStory.js";
4
4
  import "./app/index.js";
5
- export { n as MountStory, r as RenderStory, e as generateSourceCode, t as getTagName };
5
+ export { r as MountStory, i as RenderStory, e as delimitAttr, t as generateSourceCode, n as getTagName };