histoire 0.3.2 → 0.4.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/dist/bundled/BaseEmpty.js +13 -0
- package/dist/bundled/HomeView.js +23 -0
- package/dist/bundled/MobileOverlay.js +303 -0
- package/dist/bundled/SearchPane.js +504 -0
- package/dist/bundled/StoryView.js +2330 -0
- package/dist/bundled/api.js +32 -0
- package/dist/bundled/config.js +4 -0
- package/dist/bundled/const.js +5 -0
- package/dist/bundled/dark.js +4 -0
- package/dist/bundled/events.js +29 -0
- package/dist/bundled/global-components.js +203 -0
- package/dist/bundled/index.js +7 -0
- package/dist/bundled/index2.js +762 -0
- package/dist/bundled/reactivity.js +96 -0
- package/dist/bundled/sandbox.js +97 -0
- package/dist/bundled/search-docs-data.js +7 -0
- package/dist/bundled/story.js +59 -0
- package/dist/bundled/style.css +102 -0
- package/dist/client/app/App.vue +2 -2
- package/dist/client/app/api.d.ts +1 -0
- package/dist/client/app/api.js +1 -0
- package/dist/client/app/codegen/vue3.js +1 -3
- package/dist/client/app/components/HomeView.vue +1 -1
- package/dist/client/app/components/app/AppLogo.vue +1 -1
- package/dist/client/app/components/app/MobileOverlay.vue +0 -1
- package/dist/client/app/components/base/BaseEmpty.vue +1 -1
- package/dist/client/app/components/base/BaseOverflowMenu.vue +1 -1
- package/dist/client/app/components/exposed/Story.vue +1 -1
- package/dist/client/app/components/panel/StoryEvent.vue +1 -0
- package/dist/client/app/components/search/SearchItem.vue +1 -1
- package/dist/client/app/components/search/SearchPane.vue +108 -25
- package/dist/client/app/components/search/search-docs-data.d.ts +3 -0
- package/dist/client/app/components/search/{search-data.js → search-docs-data.js} +1 -2
- package/dist/client/app/components/search/search-title-data.d.ts +3 -0
- package/dist/client/app/components/search/search-title-data.js +7 -0
- package/dist/client/app/components/search/types.d.ts +7 -0
- package/dist/client/app/components/search/types.js +1 -0
- package/dist/client/app/components/story/StoryVariantGridItem.vue +1 -1
- package/dist/client/app/components/story/StoryVariantListItem.vue +1 -1
- package/dist/client/app/components/story/StoryVariantSinglePreviewNative.vue +6 -3
- package/dist/client/app/components/tree/StoryListItem.vue +1 -1
- package/dist/client/app/global-components.js +0 -1
- package/dist/client/app/index.d.ts +1 -1
- package/dist/client/app/index.js +21 -19
- package/dist/client/app/sandbox.d.ts +1 -1
- package/dist/client/app/sandbox.js +0 -2
- package/dist/client/app/stores/events.d.ts +1 -1
- package/dist/client/app/stores/events.js +1 -2
- package/dist/client/app/stores/folder.js +0 -1
- package/dist/client/app/stores/story.js +0 -1
- package/dist/client/app/types.js +0 -1
- package/dist/client/app/util/events.d.ts +1 -1
- package/dist/client/app/util/events.js +2 -3
- package/dist/client/app/util/keyboard.js +0 -1
- package/dist/client/app/util/mapping.js +0 -1
- package/dist/client/app/util/preview-settings.js +0 -1
- package/dist/client/app/util/reactivity.js +0 -1
- package/dist/client/app/util/scroll.js +0 -1
- package/dist/client/app/util/variant.js +0 -1
- package/dist/client/bundle-index.js +5 -0
- package/dist/client/bundle-main.js +5 -0
- package/dist/client/bundle-sandbox.js +3 -0
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.js +1 -2
- package/dist/client/server/vue3/run.js +8 -1
- package/dist/controls.js +0 -1
- package/dist/node/alias.js +1 -1
- package/dist/node/build.js +4 -4
- package/dist/node/builtin-plugins/tailwind-tokens.js +1 -1
- package/dist/node/search.d.ts +15 -1
- package/dist/node/search.js +78 -32
- package/dist/node/server.js +2 -2
- package/dist/node/types.d.ts +1 -0
- package/dist/node/vite.d.ts +4 -2
- package/dist/node/vite.js +24 -28
- package/package.json +11 -10
- package/src/client/app/App.vue +2 -2
- package/src/client/app/api.ts +1 -0
- package/src/client/app/codegen/vue3.ts +1 -2
- package/src/client/app/components/HomeView.vue +1 -1
- package/src/client/app/components/app/AppLogo.vue +1 -1
- package/src/client/app/components/app/MobileOverlay.vue +0 -1
- package/src/client/app/components/base/BaseEmpty.vue +1 -1
- package/src/client/app/components/base/BaseOverflowMenu.vue +1 -1
- package/src/client/app/components/exposed/Story.vue +1 -1
- package/src/client/app/components/panel/StoryEvent.vue +1 -0
- package/src/client/app/components/search/SearchItem.vue +1 -1
- package/src/client/app/components/search/SearchPane.vue +108 -25
- package/src/client/app/components/search/search-docs-data.ts +10 -0
- package/src/client/app/components/search/search-title-data.ts +10 -0
- package/src/client/app/components/search/types.ts +4 -0
- package/src/client/app/components/story/StoryVariantGridItem.vue +1 -1
- package/src/client/app/components/story/StoryVariantListItem.vue +1 -1
- package/src/client/app/components/story/StoryVariantSinglePreviewNative.vue +6 -3
- package/src/client/app/components/tree/StoryListItem.vue +1 -1
- package/src/client/app/index.ts +23 -19
- package/src/client/app/sandbox.ts +0 -1
- package/src/client/app/stores/events.ts +1 -1
- package/src/client/app/util/events.ts +2 -2
- package/src/client/bundle-index.js +5 -0
- package/src/client/bundle-main.js +5 -0
- package/src/client/bundle-sandbox.js +3 -0
- package/src/client/index.ts +1 -1
- package/src/client/server/vue3/run.ts +11 -0
- package/src/node/alias.ts +1 -1
- package/src/node/build.ts +4 -4
- package/src/node/builtin-plugins/tailwind-tokens.ts +1 -1
- package/src/node/search.ts +87 -32
- package/src/node/server.ts +2 -2
- package/src/node/types.ts +1 -0
- package/src/node/vite.ts +24 -29
- package/vite.config.ts +46 -0
- package/dist/client/app/codegen/vue3.js.map +0 -1
- package/dist/client/app/components/search/search-data.d.ts +0 -2
- package/dist/client/app/components/search/search-data.js.map +0 -1
- package/dist/client/app/global-components.js.map +0 -1
- package/dist/client/app/index.js.map +0 -1
- package/dist/client/app/sandbox.js.map +0 -1
- package/dist/client/app/stores/events.js.map +0 -1
- package/dist/client/app/stores/folder.js.map +0 -1
- package/dist/client/app/stores/story.js.map +0 -1
- package/dist/client/app/types.js.map +0 -1
- package/dist/client/app/util/events.js.map +0 -1
- package/dist/client/app/util/keyboard.js.map +0 -1
- package/dist/client/app/util/mapping.js.map +0 -1
- package/dist/client/app/util/preview-settings.js.map +0 -1
- package/dist/client/app/util/reactivity.js.map +0 -1
- package/dist/client/app/util/scroll.js.map +0 -1
- package/dist/client/app/util/variant.js.map +0 -1
- package/dist/client/index.js.map +0 -1
- package/dist/client/server/vue3/run.js.map +0 -1
- package/dist/controls.js.map +0 -1
- package/src/client/app/components/search/search-data.ts +0 -9
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { E as EVENT_SEND } from "./const.js";
|
|
2
|
+
async function hstEvent(name, argument) {
|
|
3
|
+
var _a;
|
|
4
|
+
console.log("[histoire] Event fired", { name, argument });
|
|
5
|
+
const event = {
|
|
6
|
+
name,
|
|
7
|
+
argument: JSON.parse(stringifyEvent(argument))
|
|
8
|
+
};
|
|
9
|
+
if (location.href.includes("__sandbox")) {
|
|
10
|
+
(_a = window.parent) == null ? void 0 : _a.postMessage({
|
|
11
|
+
type: EVENT_SEND,
|
|
12
|
+
event
|
|
13
|
+
});
|
|
14
|
+
} else {
|
|
15
|
+
const { useEventsStore } = await import("./events.js");
|
|
16
|
+
useEventsStore().addEvent(event);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function stringifyEvent(e) {
|
|
20
|
+
const obj = {};
|
|
21
|
+
for (const k in e) {
|
|
22
|
+
obj[k] = e[k];
|
|
23
|
+
}
|
|
24
|
+
return JSON.stringify(obj, (k, v) => {
|
|
25
|
+
if (v instanceof Node)
|
|
26
|
+
return "Node";
|
|
27
|
+
if (v instanceof Window)
|
|
28
|
+
return "Window";
|
|
29
|
+
return v;
|
|
30
|
+
}, " ");
|
|
31
|
+
}
|
|
32
|
+
export { hstEvent };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
const STATE_SYNC = "__histoire:state-sync";
|
|
2
|
+
const SANDBOX_READY = "__histoire:sandbox-ready";
|
|
3
|
+
const EVENT_SEND = "__histoire:event";
|
|
4
|
+
const PREVIEW_SETTINGS_SYNC = "__histoire:preview-settings-sync";
|
|
5
|
+
export { EVENT_SEND as E, PREVIEW_SETTINGS_SYNC as P, STATE_SYNC as S, SANDBOX_READY as a };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { defineStore } from "pinia";
|
|
2
|
+
import { reactive, ref, watch } from "vue";
|
|
3
|
+
import { u as useStoryStore } from "./story.js";
|
|
4
|
+
const useEventsStore = defineStore("events", () => {
|
|
5
|
+
const storyStore = useStoryStore();
|
|
6
|
+
const events = reactive([]);
|
|
7
|
+
const unseen = ref(0);
|
|
8
|
+
function addEvent(event) {
|
|
9
|
+
events.push(event);
|
|
10
|
+
unseen.value++;
|
|
11
|
+
}
|
|
12
|
+
function reset() {
|
|
13
|
+
events.length = 0;
|
|
14
|
+
unseen.value = 0;
|
|
15
|
+
}
|
|
16
|
+
watch(() => {
|
|
17
|
+
var _a;
|
|
18
|
+
return (_a = storyStore.currentVariant) == null ? void 0 : _a.id;
|
|
19
|
+
}, () => {
|
|
20
|
+
reset();
|
|
21
|
+
});
|
|
22
|
+
return {
|
|
23
|
+
addEvent,
|
|
24
|
+
reset,
|
|
25
|
+
events,
|
|
26
|
+
unseen
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
export { useEventsStore };
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
import { markRaw, defineComponent, useAttrs, getCurrentInstance, inject, watch, computed, provide, h } from "vue";
|
|
21
|
+
import { registerVueComponents } from "@histoire/controls";
|
|
22
|
+
function mapFile(file, existingFile) {
|
|
23
|
+
const result = __spreadProps(__spreadValues({}, file), {
|
|
24
|
+
component: markRaw(file.component),
|
|
25
|
+
story: __spreadProps(__spreadValues({}, file.story), {
|
|
26
|
+
title: file.story.title,
|
|
27
|
+
file: markRaw(file),
|
|
28
|
+
variants: file.story.variants.map((v) => mapVariant(v)),
|
|
29
|
+
slots: () => ({})
|
|
30
|
+
})
|
|
31
|
+
});
|
|
32
|
+
if (existingFile) {
|
|
33
|
+
for (const index in result.story.variants) {
|
|
34
|
+
const variant = result.story.variants[index];
|
|
35
|
+
const existingVariant = existingFile.story.variants[index];
|
|
36
|
+
if (existingVariant) {
|
|
37
|
+
for (const key in existingVariant) {
|
|
38
|
+
if (typeof existingVariant[key] !== "undefined") {
|
|
39
|
+
if (key === "state") {
|
|
40
|
+
variant.state = existingVariant.state;
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
variant[key] = existingVariant[key];
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (existingFile.story.lastSelectedVariant) {
|
|
49
|
+
result.story.lastSelectedVariant = result.story.variants.find((v) => v.id === existingFile.story.lastSelectedVariant.id);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return result;
|
|
53
|
+
}
|
|
54
|
+
function mapVariant(variant) {
|
|
55
|
+
return __spreadProps(__spreadValues({}, variant), {
|
|
56
|
+
state: null,
|
|
57
|
+
initState: null,
|
|
58
|
+
setupApp: null,
|
|
59
|
+
slots: () => ({}),
|
|
60
|
+
previewReady: false
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
const _sfc_main$1 = defineComponent({
|
|
64
|
+
name: "Variant",
|
|
65
|
+
__histoireType: "variant",
|
|
66
|
+
props: {
|
|
67
|
+
initState: {
|
|
68
|
+
type: Function,
|
|
69
|
+
default: null
|
|
70
|
+
},
|
|
71
|
+
source: {
|
|
72
|
+
type: String,
|
|
73
|
+
default: null
|
|
74
|
+
},
|
|
75
|
+
responsiveDisabled: {
|
|
76
|
+
type: Boolean,
|
|
77
|
+
default: false
|
|
78
|
+
},
|
|
79
|
+
setupApp: {
|
|
80
|
+
type: Function,
|
|
81
|
+
default: null
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
setup(props) {
|
|
85
|
+
const attrs = useAttrs();
|
|
86
|
+
const vm = getCurrentInstance();
|
|
87
|
+
const implicitState = inject("implicitState");
|
|
88
|
+
watch(() => implicitState, (value) => {
|
|
89
|
+
if (typeof props.initState !== "function") {
|
|
90
|
+
attrs.variant.state = value();
|
|
91
|
+
}
|
|
92
|
+
}, {
|
|
93
|
+
immediate: true
|
|
94
|
+
});
|
|
95
|
+
function updateVariant() {
|
|
96
|
+
Object.assign(attrs.variant, {
|
|
97
|
+
initState: async () => {
|
|
98
|
+
if (typeof props.initState === "function") {
|
|
99
|
+
attrs.variant.state = await props.initState();
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
slots: () => vm.proxy.$slots,
|
|
103
|
+
source: props.source,
|
|
104
|
+
responsiveDisabled: props.responsiveDisabled,
|
|
105
|
+
setupApp: props.setupApp,
|
|
106
|
+
configReady: true
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
updateVariant();
|
|
110
|
+
return {
|
|
111
|
+
updateVariant
|
|
112
|
+
};
|
|
113
|
+
},
|
|
114
|
+
render() {
|
|
115
|
+
this.updateVariant();
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
const _sfc_main = defineComponent({
|
|
120
|
+
name: "Story",
|
|
121
|
+
__histoireType: "story",
|
|
122
|
+
inheritAttrs: false,
|
|
123
|
+
props: {
|
|
124
|
+
initState: {
|
|
125
|
+
type: Function,
|
|
126
|
+
default: null
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
setup() {
|
|
130
|
+
const vm = getCurrentInstance();
|
|
131
|
+
const attrs = useAttrs();
|
|
132
|
+
const story = computed(() => attrs.story);
|
|
133
|
+
provide("story", story);
|
|
134
|
+
const storyComponent = vm.parent;
|
|
135
|
+
const implicitState = {
|
|
136
|
+
$data: storyComponent.data
|
|
137
|
+
};
|
|
138
|
+
function addImplicitState(key, value) {
|
|
139
|
+
if (typeof value === "function" || value && value.__file) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
implicitState[key] = value;
|
|
143
|
+
}
|
|
144
|
+
for (const key in storyComponent.exposed) {
|
|
145
|
+
addImplicitState(key, storyComponent.exposed[key]);
|
|
146
|
+
}
|
|
147
|
+
for (const key in storyComponent.devtoolsRawSetupState) {
|
|
148
|
+
addImplicitState(key, storyComponent.devtoolsRawSetupState[key]);
|
|
149
|
+
}
|
|
150
|
+
provide("implicitState", () => implicitState);
|
|
151
|
+
function updateStory() {
|
|
152
|
+
Object.assign(attrs.story, {
|
|
153
|
+
slots: () => vm.proxy.$slots
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
return {
|
|
157
|
+
story,
|
|
158
|
+
updateStory
|
|
159
|
+
};
|
|
160
|
+
},
|
|
161
|
+
render() {
|
|
162
|
+
this.updateStory();
|
|
163
|
+
const [firstVariant] = this.story.variants;
|
|
164
|
+
if (firstVariant.id === "_default") {
|
|
165
|
+
return h(_sfc_main$1, __spreadValues({
|
|
166
|
+
variant: firstVariant,
|
|
167
|
+
initState: this.initState
|
|
168
|
+
}, this.$attrs), this.$slots);
|
|
169
|
+
}
|
|
170
|
+
let index = 0;
|
|
171
|
+
const applyAttrs = (vnodes2) => {
|
|
172
|
+
var _a, _b;
|
|
173
|
+
for (const vnode of vnodes2) {
|
|
174
|
+
if (((_a = vnode.type) == null ? void 0 : _a.__histoireType) === "variant") {
|
|
175
|
+
if (!vnode.props) {
|
|
176
|
+
vnode.props = {};
|
|
177
|
+
}
|
|
178
|
+
vnode.props.variant = this.story.variants[index];
|
|
179
|
+
if (!vnode.props.initState && !vnode.props["init-state"]) {
|
|
180
|
+
vnode.props.initState = this.initState;
|
|
181
|
+
}
|
|
182
|
+
for (const attr in this.$attrs) {
|
|
183
|
+
if (typeof vnode.props[attr] === "undefined") {
|
|
184
|
+
vnode.props[attr] = this.$attrs[attr];
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
index++;
|
|
188
|
+
} else if ((_b = vnode.children) == null ? void 0 : _b.length) {
|
|
189
|
+
applyAttrs(vnode.children);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
const vnodes = this.$slots.default();
|
|
194
|
+
applyAttrs(vnodes);
|
|
195
|
+
return vnodes;
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
function registerGlobalComponents(app) {
|
|
199
|
+
app.component("Story", _sfc_main);
|
|
200
|
+
app.component("Variant", _sfc_main$1);
|
|
201
|
+
registerVueComponents(app);
|
|
202
|
+
}
|
|
203
|
+
export { mapFile as m, registerGlobalComponents as r };
|