@poveste/plugin-vue 0.14.0 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/components.d.ts +4 -0
- package/dist/bundled/client/app/MountStory.js +8 -3
- package/dist/bundled/client/app/RenderStory.js +15 -9
- package/dist/bundled/client/app/Story.js +76 -62
- package/dist/bundled/client/app/Variant.js +48 -42
- package/dist/bundled/client/app/context.js +5 -0
- package/dist/bundled/client/app/global-components.js +11 -10
- package/dist/bundled/client/app/host.js +2 -2
- package/dist/bundled/client/app/render-context.js +7 -7
- package/dist/bundled/client/app/util.js +36 -26
- package/dist/bundled/client/client.js +4 -4
- package/dist/bundled/client/codegen.js +79 -60
- package/dist/bundled/client/context.js +20 -0
- package/dist/bundled/client/server/Story.js +28 -25
- package/dist/bundled/client/server/Variant.js +13 -16
- package/dist/bundled/client/server/context.js +5 -0
- package/dist/bundled/client/server/run.js +29 -29
- package/dist/client/app/MountStory.d.ts +12 -3
- package/dist/client/app/RenderStory.d.ts +1 -1
- package/dist/client/app/Story.d.ts +10 -7
- package/dist/client/app/Variant.d.ts +14 -13
- package/dist/client/app/context.d.ts +9 -0
- package/dist/client/app/render-context.d.ts +16 -1
- package/dist/client/app/util.d.ts +38 -3
- package/dist/client/codegen.d.ts +29 -0
- package/dist/client/context.d.ts +40 -0
- package/dist/client/server/Story.d.ts +17 -17
- package/dist/client/server/Variant.d.ts +10 -10
- package/dist/client/server/context.d.ts +7 -0
- package/dist/commands/generate-story.client.js +4 -4
- package/dist/commands/generate-story.server.js +2 -2
- package/dist/helpers.d.ts +2 -2
- package/dist/index.node.js +2 -0
- package/dist/util/list-components.d.ts +1 -1
- package/dist/util/list-components.js +63 -6
- package/dist/util/list-components.spec.d.ts +1 -0
- package/dist/util/list-components.spec.js +46 -0
- package/package.json +17 -16
- package/src/client/__tests__/codegen-attrs.spec.ts +149 -0
- package/src/client/__tests__/context.spec.ts +50 -0
- package/src/client/app/MountStory.ts +11 -1
- package/src/client/app/RenderStory.ts +6 -1
- package/src/client/app/RouterLinkStub.ts +1 -1
- package/src/client/app/Story.ts +85 -39
- package/src/client/app/Variant.ts +35 -27
- package/src/client/app/__tests__/preview-variants.spec.ts +76 -0
- 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/auto-props.ts +2 -2
- package/src/client/app/context.ts +17 -0
- package/src/client/app/global-components.ts +20 -14
- package/src/client/app/host.ts +9 -6
- package/src/client/app/render-context.ts +25 -5
- package/src/client/app/util.ts +104 -9
- package/src/client/codegen.ts +81 -29
- package/src/client/context.ts +66 -0
- package/src/client/server/Story.ts +16 -10
- package/src/client/server/Variant.ts +13 -14
- 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 +11 -7
- package/src/commands/generate-story.client.ts +4 -4
- package/src/commands/generate-story.server.ts +2 -2
- package/src/helpers.ts +2 -2
- package/src/index.node.ts +2 -0
- package/src/util/list-components.spec.ts +54 -0
- package/src/util/list-components.ts +68 -6
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Poveste + Vue 3
|
|
2
2
|
|
|
3
|
-
Requires `vue@^3.5.
|
|
3
|
+
Requires `vue@^3.5.43`.
|
|
4
4
|
|
|
5
5
|
```bash
|
|
6
6
|
pnpm add -D poveste @poveste/plugin-vue
|
|
@@ -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
|
|
43
|
+
[Vue guide](https://poveste.dev/guide/vue/getting-started) ·
|
|
44
44
|
[Documentation](https://poveste.dev)
|
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,17 +24,18 @@ 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
|
-
}), l;
|
|
30
|
+
}), l = null;
|
|
26
31
|
async function u() {
|
|
27
|
-
l = e({
|
|
32
|
+
n.value && (l = e({
|
|
28
33
|
name: "MountStorySubApp",
|
|
29
34
|
el: n.value,
|
|
30
35
|
getStory: () => t.story,
|
|
31
36
|
getVariant: () => null,
|
|
32
37
|
renderContext: c
|
|
33
|
-
}), await l.mount();
|
|
38
|
+
}), await l.mount());
|
|
34
39
|
}
|
|
35
40
|
function d() {
|
|
36
41
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
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";
|
|
5
7
|
//#region src/client/app/Story.ts
|
|
6
|
-
var
|
|
8
|
+
var m = c({
|
|
7
9
|
name: "Story",
|
|
8
10
|
__povesteType: "story",
|
|
9
11
|
inheritAttrs: !1,
|
|
@@ -17,100 +19,112 @@ var f = i({
|
|
|
17
19
|
default: void 0
|
|
18
20
|
}
|
|
19
21
|
},
|
|
20
|
-
setup(
|
|
21
|
-
let
|
|
22
|
-
|
|
23
|
-
let
|
|
24
|
-
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", {
|
|
25
27
|
enumerable: !0,
|
|
26
28
|
configurable: !0,
|
|
27
|
-
get: () =>
|
|
29
|
+
get: () => g.data,
|
|
28
30
|
set: (e) => {
|
|
29
|
-
Object.assign(
|
|
31
|
+
Object.assign(g.data, e);
|
|
30
32
|
}
|
|
31
33
|
});
|
|
32
|
-
function
|
|
34
|
+
function v(e, t) {
|
|
33
35
|
let n = e[t];
|
|
34
|
-
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, {
|
|
35
37
|
enumerable: !0,
|
|
36
38
|
configurable: !0,
|
|
37
39
|
get: () => {
|
|
38
40
|
let n = e[t];
|
|
39
|
-
return
|
|
41
|
+
return u(n) ? n.value : n;
|
|
40
42
|
},
|
|
41
43
|
set: (n) => {
|
|
42
44
|
let r = e[t];
|
|
43
|
-
|
|
45
|
+
u(r) ? r.value = n : r && typeof r == "object" && n && typeof n == "object" ? Object.assign(r, n) : e[t] = n;
|
|
44
46
|
}
|
|
45
47
|
});
|
|
46
48
|
}
|
|
47
|
-
for (let e in
|
|
48
|
-
for (let e in
|
|
49
|
-
for (let e in
|
|
50
|
-
|
|
51
|
-
function
|
|
52
|
-
|
|
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 });
|
|
53
55
|
}
|
|
54
56
|
return {
|
|
55
|
-
renderContext:
|
|
56
|
-
story:
|
|
57
|
-
renderMountStory:
|
|
58
|
-
renderPreviewStory:
|
|
59
|
-
updateStory:
|
|
57
|
+
renderContext: m,
|
|
58
|
+
story: h,
|
|
59
|
+
renderMountStory: x,
|
|
60
|
+
renderPreviewStory: C,
|
|
61
|
+
updateStory: y
|
|
60
62
|
};
|
|
61
|
-
function
|
|
62
|
-
let
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
63
|
+
function b(e) {
|
|
64
|
+
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));
|
|
67
|
+
return t;
|
|
68
|
+
}
|
|
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));
|
|
73
78
|
continue;
|
|
74
79
|
}
|
|
75
|
-
Array.isArray(
|
|
80
|
+
Array.isArray(s.children) && (s.children = r(s.children)), i.push(s);
|
|
76
81
|
}
|
|
77
|
-
return
|
|
82
|
+
return i;
|
|
78
83
|
};
|
|
79
|
-
return
|
|
84
|
+
return r(c.slots.default?.() ?? []);
|
|
80
85
|
}
|
|
81
|
-
function
|
|
82
|
-
|
|
83
|
-
let e
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
86
|
+
function S(e) {
|
|
87
|
+
let t = 0;
|
|
88
|
+
for (let n of e) n?.type?.__povesteType === "variant" ? t++ : Array.isArray(n?.children) && (t += S(n.children));
|
|
89
|
+
return t;
|
|
90
|
+
}
|
|
91
|
+
function C(e) {
|
|
92
|
+
e.nextVariantIndex.value = 0;
|
|
93
|
+
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) ?? []);
|
|
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);
|
|
98
|
+
if (t !== -1) {
|
|
99
|
+
let r = 0, i = !1, a = (e) => {
|
|
100
|
+
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++;
|
|
92
104
|
continue;
|
|
93
105
|
}
|
|
94
|
-
Array.isArray(
|
|
106
|
+
Array.isArray(s?.children) && s.children.length && (s.children = a(s.children)), n.push(s);
|
|
95
107
|
}
|
|
96
|
-
return
|
|
97
|
-
},
|
|
98
|
-
if (
|
|
108
|
+
return n;
|
|
109
|
+
}, s = a(n);
|
|
110
|
+
if (i) return e.nextVariantIndex.value = t, s;
|
|
99
111
|
}
|
|
100
112
|
}
|
|
101
|
-
return
|
|
113
|
+
return n;
|
|
102
114
|
}
|
|
103
115
|
},
|
|
104
116
|
render() {
|
|
105
117
|
this.updateStory();
|
|
106
118
|
let [e] = this.story.variants;
|
|
107
|
-
|
|
119
|
+
if (e?.id === "_default") return l(a, {
|
|
108
120
|
variant: e,
|
|
109
|
-
initState: this.initState,
|
|
121
|
+
...this.initState ? { initState: this.initState } : {},
|
|
110
122
|
implicit: !0,
|
|
111
123
|
...this.$attrs
|
|
112
|
-
}, this.$slots)
|
|
124
|
+
}, this.$slots);
|
|
125
|
+
let t = this.renderContext;
|
|
126
|
+
return t?.mode === "render" ? this.renderPreviewStory(t) : this.renderMountStory();
|
|
113
127
|
}
|
|
114
128
|
});
|
|
115
129
|
//#endregion
|
|
116
|
-
export {
|
|
130
|
+
export { m as default };
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { syncStateBundledAndExternal as
|
|
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,54 +38,59 @@ var f = a({
|
|
|
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
|
+
});
|
|
62
|
+
let t = h?.value;
|
|
63
|
+
t && !c.implicit && !t.meta?.hasVariantChildComponents && (t.meta ||= {}, Object.assign(t.meta, { hasVariantChildComponents: !0 }));
|
|
61
64
|
}
|
|
62
|
-
function
|
|
63
|
-
return
|
|
65
|
+
function w() {
|
|
66
|
+
return p.variant ? p.variant : _?.mode === "render" ? (y || (y = h?.value?.variants[_.nextVariantIndex.value], _.nextVariantIndex.value++), y) : null;
|
|
64
67
|
}
|
|
65
|
-
function
|
|
66
|
-
if (
|
|
67
|
-
if (
|
|
68
|
-
let n =
|
|
69
|
-
return n && !e.autoPropsDisabled && (
|
|
68
|
+
function T(e, t) {
|
|
69
|
+
if (t.slotName === "controls") return m.slots.controls?.({ state: t.externalState }) ?? null;
|
|
70
|
+
if (t.slotName !== "default") return null;
|
|
71
|
+
let n = m.slots.default?.({ state: t.externalState }) ?? null;
|
|
72
|
+
return n && !e.autoPropsDisabled && (v = o(e, n, t.externalState, v)), n;
|
|
70
73
|
}
|
|
71
|
-
function
|
|
72
|
-
if (!
|
|
73
|
-
let t =
|
|
74
|
-
t && !
|
|
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);
|
|
75
78
|
}
|
|
76
|
-
return
|
|
77
|
-
renderContext:
|
|
78
|
-
renderVariantSlot:
|
|
79
|
-
resolveVariant:
|
|
80
|
-
syncRenderVariantState:
|
|
81
|
-
updateVariant:
|
|
79
|
+
return S.value && C(S.value), {
|
|
80
|
+
renderContext: _,
|
|
81
|
+
renderVariantSlot: T,
|
|
82
|
+
resolveVariant: w,
|
|
83
|
+
syncRenderVariantState: E,
|
|
84
|
+
updateVariant: C
|
|
82
85
|
};
|
|
83
86
|
},
|
|
84
87
|
render() {
|
|
85
88
|
let e = this.resolveVariant();
|
|
86
|
-
|
|
89
|
+
if (!e) return null;
|
|
90
|
+
this.updateVariant(e), this.syncRenderVariantState(e);
|
|
91
|
+
let t = this.renderContext;
|
|
92
|
+
return t?.mode !== "render" || t.currentVariant?.id !== e.id ? null : this.renderVariantSlot(e, t);
|
|
87
93
|
}
|
|
88
94
|
});
|
|
89
95
|
//#endregion
|
|
90
|
-
export {
|
|
96
|
+
export { p as default };
|
|
@@ -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
|
|
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(
|
|
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
|
|
27
|
-
if (
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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(
|
|
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,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,71 +1,81 @@
|
|
|
1
1
|
import { isRef as e, unref as t, watch as n } from "@poveste/vendors/vue";
|
|
2
|
-
import {
|
|
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(
|
|
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
|
-
|
|
69
|
+
a(), o();
|
|
68
70
|
} };
|
|
69
71
|
}
|
|
72
|
+
function b(e) {
|
|
73
|
+
return !(a(e) && i(e));
|
|
74
|
+
}
|
|
75
|
+
function x(e) {
|
|
76
|
+
let t = r();
|
|
77
|
+
if (!t) throw Error(`[poveste] <${e}> can only be set up inside a component`);
|
|
78
|
+
return t;
|
|
79
|
+
}
|
|
70
80
|
//#endregion
|
|
71
|
-
export {
|
|
81
|
+
export { g as _toRawDeep, b as isWritableBinding, y as syncStateBundledAndExternal, m as toRawDeep, x as useInstance };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
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 {
|
|
5
|
+
export { r as MountStory, i as RenderStory, e as delimitAttr, t as generateSourceCode, n as getTagName };
|