@poveste/plugin-vue 0.15.0 → 0.16.1
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 +1 -1
- package/components.d.ts +4 -0
- package/dist/bundled/client/app/MountStory.js +5 -0
- package/dist/bundled/client/app/Story.js +58 -57
- package/dist/bundled/client/app/Variant.js +42 -41
- package/dist/bundled/client/app/context.js +5 -0
- package/dist/bundled/client/app/global-components.js +1 -1
- package/dist/bundled/client/app/render-context.js +7 -7
- package/dist/bundled/client/app/util.js +32 -27
- package/dist/bundled/client/context.js +20 -0
- package/dist/bundled/client/server/Story.js +28 -27
- package/dist/bundled/client/server/Variant.js +13 -17
- package/dist/bundled/client/server/context.js +5 -0
- package/dist/bundled/client/server/run.js +27 -27
- package/dist/client/app/MountStory.d.ts +9 -0
- package/dist/client/app/context.d.ts +9 -0
- package/dist/client/app/render-context.d.ts +15 -0
- package/dist/client/app/util.d.ts +32 -0
- package/dist/client/context.d.ts +40 -0
- package/dist/client/server/context.d.ts +7 -0
- package/package.json +13 -13
- package/src/client/__tests__/context.spec.ts +50 -0
- package/src/client/app/MountStory.ts +6 -0
- package/src/client/app/Story.ts +9 -4
- package/src/client/app/Variant.ts +10 -5
- package/src/client/app/__tests__/state-sync.spec.ts +113 -2
- package/src/client/app/__tests__/writable-binding.spec.ts +39 -0
- package/src/client/app/context.ts +17 -0
- package/src/client/app/render-context.ts +25 -5
- package/src/client/app/util.ts +88 -3
- package/src/client/context.ts +66 -0
- package/src/client/server/Story.ts +7 -7
- package/src/client/server/Variant.ts +13 -17
- package/src/client/server/__tests__/nesting-errors.spec.ts +48 -0
- package/src/client/server/context.ts +18 -0
- package/src/client/server/run.ts +7 -4
package/README.md
CHANGED
package/components.d.ts
CHANGED
|
@@ -18,6 +18,8 @@ import type {
|
|
|
18
18
|
HstTextarea,
|
|
19
19
|
HstSelect,
|
|
20
20
|
HstRadio,
|
|
21
|
+
HstColor,
|
|
22
|
+
HstDate,
|
|
21
23
|
HstJson,
|
|
22
24
|
HstColorShades,
|
|
23
25
|
HstTokenList,
|
|
@@ -229,6 +231,8 @@ declare module 'vue' {
|
|
|
229
231
|
HstTextarea: typeof HstTextarea
|
|
230
232
|
HstSelect: typeof HstSelect
|
|
231
233
|
HstRadio: typeof HstRadio
|
|
234
|
+
HstColor: typeof HstColor
|
|
235
|
+
HstDate: typeof HstDate
|
|
232
236
|
HstJson: typeof HstJson
|
|
233
237
|
HstColorShades: typeof HstColorShades
|
|
234
238
|
HstTokenList: typeof HstTokenList
|
|
@@ -12,6 +12,10 @@ var c = t({
|
|
|
12
12
|
targetVariantId: {
|
|
13
13
|
type: String,
|
|
14
14
|
default: null
|
|
15
|
+
},
|
|
16
|
+
syncState: {
|
|
17
|
+
type: Boolean,
|
|
18
|
+
default: !0
|
|
15
19
|
}
|
|
16
20
|
},
|
|
17
21
|
setup(t) {
|
|
@@ -20,6 +24,7 @@ var c = t({
|
|
|
20
24
|
slotName: "default",
|
|
21
25
|
currentVariant: null,
|
|
22
26
|
targetVariantId: t.targetVariantId,
|
|
27
|
+
syncState: t.syncState,
|
|
23
28
|
externalState: null,
|
|
24
29
|
nextVariantIndex: { value: 0 }
|
|
25
30
|
}), l = null;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
1
|
+
import { implicitStateContext as e, storyContext as t } from "./context.js";
|
|
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";
|
|
6
7
|
//#region src/client/app/Story.ts
|
|
7
|
-
var
|
|
8
|
+
var m = c({
|
|
8
9
|
name: "Story",
|
|
9
10
|
__povesteType: "story",
|
|
10
11
|
inheritAttrs: !1,
|
|
@@ -18,95 +19,95 @@ var f = a({
|
|
|
18
19
|
default: void 0
|
|
19
20
|
}
|
|
20
21
|
},
|
|
21
|
-
setup(
|
|
22
|
-
let
|
|
23
|
-
|
|
24
|
-
let
|
|
25
|
-
Object.defineProperty(
|
|
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", {
|
|
26
27
|
enumerable: !0,
|
|
27
28
|
configurable: !0,
|
|
28
|
-
get: () =>
|
|
29
|
+
get: () => g.data,
|
|
29
30
|
set: (e) => {
|
|
30
|
-
Object.assign(
|
|
31
|
+
Object.assign(g.data, e);
|
|
31
32
|
}
|
|
32
33
|
});
|
|
33
|
-
function
|
|
34
|
+
function v(e, t) {
|
|
34
35
|
let n = e[t];
|
|
35
|
-
typeof n == "function" || n?.__file || typeof n?.render == "function" || typeof n?.setup == "function" || Object.defineProperty(
|
|
36
|
+
typeof n == "function" || n?.__file || typeof n?.render == "function" || typeof n?.setup == "function" || r(n) && Object.defineProperty(_, t, {
|
|
36
37
|
enumerable: !0,
|
|
37
38
|
configurable: !0,
|
|
38
39
|
get: () => {
|
|
39
40
|
let n = e[t];
|
|
40
|
-
return
|
|
41
|
+
return u(n) ? n.value : n;
|
|
41
42
|
},
|
|
42
43
|
set: (n) => {
|
|
43
44
|
let r = e[t];
|
|
44
|
-
|
|
45
|
+
u(r) ? r.value = n : r && typeof r == "object" && n && typeof n == "object" ? Object.assign(r, n) : e[t] = n;
|
|
45
46
|
}
|
|
46
47
|
});
|
|
47
48
|
}
|
|
48
|
-
for (let e in
|
|
49
|
-
for (let e in
|
|
50
|
-
for (let e in
|
|
51
|
-
|
|
52
|
-
function
|
|
53
|
-
|
|
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 });
|
|
54
55
|
}
|
|
55
56
|
return {
|
|
56
|
-
renderContext:
|
|
57
|
-
story:
|
|
58
|
-
renderMountStory:
|
|
59
|
-
renderPreviewStory:
|
|
60
|
-
updateStory:
|
|
57
|
+
renderContext: m,
|
|
58
|
+
story: h,
|
|
59
|
+
renderMountStory: x,
|
|
60
|
+
renderPreviewStory: C,
|
|
61
|
+
updateStory: y
|
|
61
62
|
};
|
|
62
|
-
function
|
|
63
|
+
function b(e) {
|
|
63
64
|
let t = {};
|
|
64
|
-
for (let n in
|
|
65
|
-
for (let n in
|
|
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));
|
|
66
67
|
return t;
|
|
67
68
|
}
|
|
68
|
-
function
|
|
69
|
-
let e = 0, t =
|
|
70
|
-
let
|
|
71
|
-
for (let
|
|
72
|
-
if (
|
|
73
|
-
let t =
|
|
74
|
-
if (e++, !t ||
|
|
75
|
-
let
|
|
76
|
-
|
|
69
|
+
function x() {
|
|
70
|
+
let e = 0, t = m?.targetVariantId, n = t ? l.story.variants.findIndex((e) => e.id === t) : -1, r = (t) => {
|
|
71
|
+
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));
|
|
77
78
|
continue;
|
|
78
79
|
}
|
|
79
|
-
Array.isArray(
|
|
80
|
+
Array.isArray(s.children) && (s.children = r(s.children)), i.push(s);
|
|
80
81
|
}
|
|
81
|
-
return
|
|
82
|
+
return i;
|
|
82
83
|
};
|
|
83
|
-
return
|
|
84
|
+
return r(c.slots.default?.() ?? []);
|
|
84
85
|
}
|
|
85
|
-
function
|
|
86
|
+
function S(e) {
|
|
86
87
|
let t = 0;
|
|
87
|
-
for (let n of e) n?.type?.__povesteType === "variant" ? t++ : Array.isArray(n?.children) && (t +=
|
|
88
|
+
for (let n of e) n?.type?.__povesteType === "variant" ? t++ : Array.isArray(n?.children) && (t += S(n.children));
|
|
88
89
|
return t;
|
|
89
90
|
}
|
|
90
|
-
function
|
|
91
|
+
function C(e) {
|
|
91
92
|
e.nextVariantIndex.value = 0;
|
|
92
93
|
let t = { state: e.externalState }, n = [];
|
|
93
|
-
e.slotName === "controls" && n.push(...
|
|
94
|
-
let
|
|
95
|
-
if (e.slotName === "default" &&
|
|
96
|
-
let t =
|
|
94
|
+
e.slotName === "controls" && n.push(...c.slots.controls?.(t) ?? []), (e.slotName === "default" || l.story.meta?.hasVariantChildComponents) && n.push(...c.slots.default?.(t) ?? []);
|
|
95
|
+
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);
|
|
97
98
|
if (t !== -1) {
|
|
98
|
-
let
|
|
99
|
+
let r = 0, i = !1, a = (e) => {
|
|
99
100
|
let n = [];
|
|
100
101
|
for (let s of e) {
|
|
101
102
|
if (s?.type?.__povesteType === "variant") {
|
|
102
|
-
|
|
103
|
+
r === t && (n.push(o(s, b(s))), i = !0), r++;
|
|
103
104
|
continue;
|
|
104
105
|
}
|
|
105
|
-
Array.isArray(s?.children) && s.children.length && (s.children =
|
|
106
|
+
Array.isArray(s?.children) && s.children.length && (s.children = a(s.children)), n.push(s);
|
|
106
107
|
}
|
|
107
108
|
return n;
|
|
108
|
-
}, s =
|
|
109
|
-
if (
|
|
109
|
+
}, s = a(n);
|
|
110
|
+
if (i) return e.nextVariantIndex.value = t, s;
|
|
110
111
|
}
|
|
111
112
|
}
|
|
112
113
|
return n;
|
|
@@ -115,7 +116,7 @@ var f = a({
|
|
|
115
116
|
render() {
|
|
116
117
|
this.updateStory();
|
|
117
118
|
let [e] = this.story.variants;
|
|
118
|
-
if (e?.id === "_default") return
|
|
119
|
+
if (e?.id === "_default") return l(a, {
|
|
119
120
|
variant: e,
|
|
120
121
|
...this.initState ? { initState: this.initState } : {},
|
|
121
122
|
implicit: !0,
|
|
@@ -126,4 +127,4 @@ var f = a({
|
|
|
126
127
|
}
|
|
127
128
|
});
|
|
128
129
|
//#endregion
|
|
129
|
-
export {
|
|
130
|
+
export { m as default };
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { implicitStateContext as e, storyContext as t } from "./context.js";
|
|
2
|
+
import { useRenderContext as n } from "./render-context.js";
|
|
3
|
+
import { syncStateBundledAndExternal as r, toRawDeep as i, useInstance as a } from "./util.js";
|
|
4
|
+
import { syncVariantAutoProps as o } from "./auto-props.js";
|
|
5
|
+
import { computed as s, defineComponent as c, onBeforeUnmount as l, useAttrs as u } from "vue";
|
|
6
|
+
import { applyState as d, autoPropsStateKeys as f } from "@poveste/shared";
|
|
6
7
|
//#region src/client/app/Variant.ts
|
|
7
|
-
var
|
|
8
|
+
var p = c({
|
|
8
9
|
name: "Variant",
|
|
9
10
|
__povesteType: "variant",
|
|
10
11
|
props: {
|
|
@@ -37,50 +38,50 @@ var f = o({
|
|
|
37
38
|
default: !1
|
|
38
39
|
}
|
|
39
40
|
},
|
|
40
|
-
async setup(
|
|
41
|
-
let
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
async setup(c) {
|
|
42
|
+
let p = u(), m = a("Variant"), h = t.injectOptional(), g = e.injectOptional(), _ = n(), v, y, b = null, x;
|
|
43
|
+
l(() => {
|
|
44
|
+
b?.stop(), x?.stop();
|
|
44
45
|
});
|
|
45
|
-
let
|
|
46
|
-
if (
|
|
47
|
-
let e = await
|
|
48
|
-
|
|
46
|
+
let S = s(() => p.variant);
|
|
47
|
+
if (_?.mode !== "render" && typeof c.initState == "function" && S.value) {
|
|
48
|
+
let e = await c.initState();
|
|
49
|
+
d(S.value.state, i(e));
|
|
49
50
|
}
|
|
50
|
-
|
|
51
|
-
function
|
|
51
|
+
_?.mode !== "render" && _?.syncState !== !1 && S.value && g && (x = r(S.value.state, g(), f));
|
|
52
|
+
function C(e) {
|
|
52
53
|
Object.assign(e, {
|
|
53
|
-
slots: () =>
|
|
54
|
-
source:
|
|
55
|
-
responsiveDisabled:
|
|
56
|
-
autoPropsDisabled:
|
|
57
|
-
setupApp:
|
|
58
|
-
meta:
|
|
54
|
+
slots: () => m.slots,
|
|
55
|
+
source: c.source,
|
|
56
|
+
responsiveDisabled: c.responsiveDisabled,
|
|
57
|
+
autoPropsDisabled: c.autoPropsDisabled,
|
|
58
|
+
setupApp: c.setupApp,
|
|
59
|
+
meta: c.meta,
|
|
59
60
|
configReady: !0
|
|
60
61
|
});
|
|
61
|
-
let t =
|
|
62
|
-
t && !
|
|
62
|
+
let t = h?.value;
|
|
63
|
+
t && !c.implicit && !t.meta?.hasVariantChildComponents && (t.meta ||= {}, Object.assign(t.meta, { hasVariantChildComponents: !0 }));
|
|
63
64
|
}
|
|
64
|
-
function
|
|
65
|
-
return
|
|
65
|
+
function w() {
|
|
66
|
+
return p.variant ? p.variant : _?.mode === "render" ? (y || (y = h?.value?.variants[_.nextVariantIndex.value], _.nextVariantIndex.value++), y) : null;
|
|
66
67
|
}
|
|
67
|
-
function
|
|
68
|
-
if (t.slotName === "controls") return
|
|
68
|
+
function T(e, t) {
|
|
69
|
+
if (t.slotName === "controls") return m.slots.controls?.({ state: t.externalState }) ?? null;
|
|
69
70
|
if (t.slotName !== "default") return null;
|
|
70
|
-
let n =
|
|
71
|
-
return n && !e.autoPropsDisabled && (
|
|
71
|
+
let n = m.slots.default?.({ state: t.externalState }) ?? null;
|
|
72
|
+
return n && !e.autoPropsDisabled && (v = o(e, n, t.externalState, v)), n;
|
|
72
73
|
}
|
|
73
|
-
function
|
|
74
|
-
if (!
|
|
75
|
-
let
|
|
76
|
-
|
|
74
|
+
function E(e) {
|
|
75
|
+
if (!g) return;
|
|
76
|
+
let t = _?.mode === "render" && _.currentVariant?.id === e.id;
|
|
77
|
+
t && !b ? b = r(e.state, g(), f) : !t && b && (b.stop(), b = null);
|
|
77
78
|
}
|
|
78
|
-
return
|
|
79
|
-
renderContext:
|
|
80
|
-
renderVariantSlot:
|
|
81
|
-
resolveVariant:
|
|
82
|
-
syncRenderVariantState:
|
|
83
|
-
updateVariant:
|
|
79
|
+
return S.value && C(S.value), {
|
|
80
|
+
renderContext: _,
|
|
81
|
+
renderVariantSlot: T,
|
|
82
|
+
resolveVariant: w,
|
|
83
|
+
syncRenderVariantState: E,
|
|
84
|
+
updateVariant: C
|
|
84
85
|
};
|
|
85
86
|
},
|
|
86
87
|
render() {
|
|
@@ -92,4 +93,4 @@ var f = o({
|
|
|
92
93
|
}
|
|
93
94
|
});
|
|
94
95
|
//#endregion
|
|
95
|
-
export {
|
|
96
|
+
export { p as default };
|
|
@@ -25,7 +25,7 @@ function m(e) {
|
|
|
25
25
|
function _() {
|
|
26
26
|
g.value.forEach((e, t) => {
|
|
27
27
|
let n = f.value?.querySelector(`[renderslotid="${t}"]`), r = o.value?.querySelector(`[slotid="${t}"]`);
|
|
28
|
-
if (
|
|
28
|
+
if (n && r) {
|
|
29
29
|
for (; r.lastChild;) r.removeChild(r.lastChild);
|
|
30
30
|
r.appendChild(n);
|
|
31
31
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createContext as e } from "../context.js";
|
|
2
2
|
//#region src/client/app/render-context.ts
|
|
3
|
-
var
|
|
4
|
-
function
|
|
5
|
-
t(
|
|
3
|
+
var t = e("poveste-preview-render-context", "<Story>");
|
|
4
|
+
function n(e) {
|
|
5
|
+
t.provide(e);
|
|
6
6
|
}
|
|
7
|
-
function
|
|
8
|
-
return
|
|
7
|
+
function r() {
|
|
8
|
+
return t.injectOptional();
|
|
9
9
|
}
|
|
10
10
|
//#endregion
|
|
11
|
-
export {
|
|
11
|
+
export { n as provideRenderContext, r as useRenderContext };
|
|
@@ -1,76 +1,81 @@
|
|
|
1
1
|
import { isRef as e, unref as t, watch as n } from "@poveste/vendors/vue";
|
|
2
|
-
import { getCurrentInstance as r,
|
|
3
|
-
import { applyState as
|
|
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";
|
|
4
4
|
//#region src/client/app/util.ts
|
|
5
|
-
var
|
|
6
|
-
function
|
|
7
|
-
let n =
|
|
5
|
+
var p = (e) => typeof e == "object" && !!e;
|
|
6
|
+
function m(e, t = /* @__PURE__ */ new WeakMap()) {
|
|
7
|
+
let n = a(e) ? s(e) : e;
|
|
8
8
|
if (typeof n == "symbol") return n.toString();
|
|
9
|
-
if (!
|
|
9
|
+
if (!p(n) || d(n)) return n;
|
|
10
10
|
if (t.has(n)) return t.get(n);
|
|
11
|
+
if (!Array.isArray(n) && !f(n)) return o(n);
|
|
11
12
|
if (Array.isArray(n)) {
|
|
12
13
|
let e = [];
|
|
13
|
-
return t.set(n, e), e.push(...n.map((e) =>
|
|
14
|
+
return t.set(n, e), e.push(...n.map((e) => m(e, t))), e;
|
|
14
15
|
}
|
|
15
16
|
{
|
|
16
17
|
let e = {};
|
|
17
|
-
return t.set(n, e),
|
|
18
|
+
return t.set(n, e), h(n, e, t), e;
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
|
-
function
|
|
21
|
+
function h(e, t, n = /* @__PURE__ */ new WeakMap()) {
|
|
21
22
|
Object.keys(e).forEach((r) => {
|
|
22
|
-
t[r] =
|
|
23
|
+
t[r] = m(e[r], n);
|
|
23
24
|
});
|
|
24
25
|
}
|
|
25
|
-
function
|
|
26
|
+
function g(n, r = /* @__PURE__ */ new WeakMap()) {
|
|
26
27
|
let i = e(n) ? t(n) : n;
|
|
27
28
|
if (typeof i == "symbol") return i.toString();
|
|
28
|
-
if (!
|
|
29
|
+
if (!p(i) || d(i)) return i;
|
|
29
30
|
if (r.has(i)) return r.get(i);
|
|
31
|
+
if (!Array.isArray(i) && !f(i)) return o(i);
|
|
30
32
|
if (Array.isArray(i)) {
|
|
31
33
|
let e = [];
|
|
32
|
-
return r.set(i, e), e.push(...i.map((e) =>
|
|
34
|
+
return r.set(i, e), e.push(...i.map((e) => g(e, r))), e;
|
|
33
35
|
}
|
|
34
36
|
{
|
|
35
37
|
let e = {};
|
|
36
|
-
return r.set(i, e),
|
|
38
|
+
return r.set(i, e), _(i, e, r), e;
|
|
37
39
|
}
|
|
38
40
|
}
|
|
39
|
-
function
|
|
41
|
+
function _(e, t, n = /* @__PURE__ */ new WeakMap()) {
|
|
40
42
|
Object.keys(e).forEach((r) => {
|
|
41
|
-
t[r] =
|
|
43
|
+
t[r] = g(e[r], n);
|
|
42
44
|
});
|
|
43
45
|
}
|
|
44
|
-
function
|
|
46
|
+
function v(e, t) {
|
|
45
47
|
if (!t.length) return e;
|
|
46
48
|
let n = { ...e };
|
|
47
49
|
for (let e of t) delete n[e];
|
|
48
50
|
return n;
|
|
49
51
|
}
|
|
50
|
-
function
|
|
51
|
-
let i =
|
|
52
|
+
function y(e, t, r = []) {
|
|
53
|
+
let i = u(), a = n(() => e, (e) => {
|
|
52
54
|
if (e == null) return;
|
|
53
|
-
let n = i.take(
|
|
54
|
-
n &&
|
|
55
|
+
let n = i.take(v(g(e), r));
|
|
56
|
+
n && l(t, n);
|
|
55
57
|
}, {
|
|
56
58
|
deep: !0,
|
|
57
59
|
immediate: !0
|
|
58
|
-
}),
|
|
60
|
+
}), o = c(() => t, (t) => {
|
|
59
61
|
if (t == null) return;
|
|
60
|
-
let n = i.take(m(
|
|
61
|
-
n &&
|
|
62
|
+
let n = i.take(v(m(t), r));
|
|
63
|
+
n && l(e, n);
|
|
62
64
|
}, {
|
|
63
65
|
deep: !0,
|
|
64
66
|
immediate: !0
|
|
65
67
|
});
|
|
66
68
|
return { stop() {
|
|
67
|
-
a(),
|
|
69
|
+
a(), o();
|
|
68
70
|
} };
|
|
69
71
|
}
|
|
70
|
-
function
|
|
72
|
+
function b(e) {
|
|
73
|
+
return !(a(e) && i(e));
|
|
74
|
+
}
|
|
75
|
+
function x(e) {
|
|
71
76
|
let t = r();
|
|
72
77
|
if (!t) throw Error(`[poveste] <${e}> can only be set up inside a component`);
|
|
73
78
|
return t;
|
|
74
79
|
}
|
|
75
80
|
//#endregion
|
|
76
|
-
export {
|
|
81
|
+
export { g as _toRawDeep, b as isWritableBinding, y as syncStateBundledAndExternal, m as toRawDeep, x as useInstance };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { inject as e, provide as t } from "vue";
|
|
2
|
+
//#region src/client/context.ts
|
|
3
|
+
function n(n, r) {
|
|
4
|
+
let i = Symbol.for(n);
|
|
5
|
+
return {
|
|
6
|
+
provide(e) {
|
|
7
|
+
t(i, e);
|
|
8
|
+
},
|
|
9
|
+
inject(t) {
|
|
10
|
+
let n = e(i, null);
|
|
11
|
+
if (n === null) throw Error(`[poveste] a ${t} has to be inside a ${r}`);
|
|
12
|
+
return n;
|
|
13
|
+
},
|
|
14
|
+
injectOptional() {
|
|
15
|
+
return e(i, null);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { n as createContext };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { addStoryContext as e, addVariantContext as t, serverStoryContext as n, storyFileContext as r } from "./context.js";
|
|
2
|
+
import { autoStubComponents as i } from "./stub.js";
|
|
3
|
+
import { defineComponent as a, onMounted as o } from "vue";
|
|
3
4
|
//#region src/client/server/Story.ts
|
|
4
|
-
var
|
|
5
|
+
var s = a({
|
|
5
6
|
name: "PovesteStory",
|
|
6
7
|
inheritAttrs: !1,
|
|
7
8
|
props: {
|
|
@@ -38,40 +39,40 @@ var a = t({
|
|
|
38
39
|
default: void 0
|
|
39
40
|
}
|
|
40
41
|
},
|
|
41
|
-
setup(
|
|
42
|
-
let
|
|
43
|
-
if (!
|
|
44
|
-
let
|
|
45
|
-
id:
|
|
46
|
-
title:
|
|
47
|
-
group:
|
|
48
|
-
layout:
|
|
49
|
-
icon:
|
|
50
|
-
iconColor:
|
|
51
|
-
docsOnly:
|
|
52
|
-
meta:
|
|
42
|
+
setup(i) {
|
|
43
|
+
let a = r.injectOptional(), s = i.id ?? a?.id, c = i.title ?? a?.fileName;
|
|
44
|
+
if (!s || c === void 0) throw Error("[poveste] a <Story> collected outside a story file needs an `id` and a `title`");
|
|
45
|
+
let l = {
|
|
46
|
+
id: s,
|
|
47
|
+
title: c,
|
|
48
|
+
group: i.group,
|
|
49
|
+
layout: i.layout,
|
|
50
|
+
icon: i.icon,
|
|
51
|
+
iconColor: i.iconColor,
|
|
52
|
+
docsOnly: i.docsOnly,
|
|
53
|
+
meta: i.meta,
|
|
53
54
|
variants: []
|
|
54
55
|
};
|
|
55
|
-
return
|
|
56
|
-
|
|
57
|
-
}),
|
|
58
|
-
|
|
56
|
+
return e.injectOptional()?.(l), n.provide(l), t.provide((e) => {
|
|
57
|
+
l.variants.push(e);
|
|
58
|
+
}), o(() => {
|
|
59
|
+
l.variants.length || l.variants.push({
|
|
59
60
|
id: "_default",
|
|
60
61
|
title: "default"
|
|
61
62
|
});
|
|
62
|
-
}), { story:
|
|
63
|
+
}), { story: l };
|
|
63
64
|
},
|
|
64
65
|
render() {
|
|
65
|
-
let
|
|
66
|
+
let e = !1;
|
|
66
67
|
try {
|
|
67
|
-
let
|
|
68
|
-
return
|
|
68
|
+
let t = this.$slots.default?.({ get state() {
|
|
69
|
+
return e = !0, {};
|
|
69
70
|
} });
|
|
70
|
-
return Array.isArray(
|
|
71
|
-
} catch (
|
|
72
|
-
return
|
|
71
|
+
return Array.isArray(t) && i(t), t;
|
|
72
|
+
} catch (t) {
|
|
73
|
+
return e || console.error(t), null;
|
|
73
74
|
}
|
|
74
75
|
}
|
|
75
76
|
});
|
|
76
77
|
//#endregion
|
|
77
|
-
export {
|
|
78
|
+
export { s as default };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { addVariantContext as e, serverStoryContext as t } from "./context.js";
|
|
2
|
+
import { defineComponent as n } from "vue";
|
|
2
3
|
//#region src/client/server/Variant.ts
|
|
3
|
-
var
|
|
4
|
+
var r = n({
|
|
4
5
|
name: "PovesteVariant",
|
|
5
6
|
props: {
|
|
6
7
|
title: {
|
|
@@ -24,24 +25,19 @@ var n = e({
|
|
|
24
25
|
default: void 0
|
|
25
26
|
}
|
|
26
27
|
},
|
|
27
|
-
setup(
|
|
28
|
-
let
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
icon: e.icon,
|
|
37
|
-
iconColor: e.iconColor,
|
|
38
|
-
meta: e.meta
|
|
39
|
-
};
|
|
40
|
-
t("addVariant")(i);
|
|
28
|
+
setup(n) {
|
|
29
|
+
let r = t.inject("<Variant>");
|
|
30
|
+
e.inject("<Variant>")({
|
|
31
|
+
id: n.id ?? `${r.id}-${r.variants.length}`,
|
|
32
|
+
title: n.title,
|
|
33
|
+
icon: n.icon,
|
|
34
|
+
iconColor: n.iconColor,
|
|
35
|
+
meta: n.meta
|
|
36
|
+
});
|
|
41
37
|
},
|
|
42
38
|
render() {
|
|
43
39
|
return null;
|
|
44
40
|
}
|
|
45
41
|
});
|
|
46
42
|
//#endregion
|
|
47
|
-
export {
|
|
43
|
+
export { r as default };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { createContext as e } from "../context.js";
|
|
2
|
+
//#region src/client/server/context.ts
|
|
3
|
+
var t = e("poveste-server-story-file", "story file"), n = e("poveste-server-add-story", "story file"), r = e("poveste-server-story", "<Story>"), i = e("poveste-server-add-variant", "<Story>");
|
|
4
|
+
//#endregion
|
|
5
|
+
export { n as addStoryContext, i as addVariantContext, r as serverStoryContext, t as storyFileContext };
|