histoire 0.7.0 → 0.7.3
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/MobileOverlay.js +2 -2
- package/dist/bundled/SandboxVue3.js +61 -10
- package/dist/bundled/index2.js +2 -0
- package/dist/bundled/state.js +9 -5
- package/dist/bundled/style.css +14 -14
- package/dist/client/app/App.vue +2 -0
- package/dist/client/app/codegen/serialize-js.js +22 -9
- package/dist/client/app/components/base/BaseSplitPane.vue +6 -6
- package/dist/client/app/components/sandbox/RouterLinkStub.d.ts +21 -0
- package/dist/client/app/components/sandbox/RouterLinkStub.js +43 -0
- package/dist/client/app/components/sandbox/SandboxVue3.vue +4 -0
- package/dist/client/app/style/main.pcss +3 -3
- package/dist/client/app/style/sandbox.css +1 -1
- package/dist/client/app/util/state.d.ts +1 -1
- package/dist/client/app/util/state.js +9 -5
- package/dist/client/server/vue3/Story.vue +17 -2
- package/dist/client/server/vue3/Variant.vue +3 -1
- package/dist/node/collect/index.js +1 -0
- package/dist/node/config.d.ts +20 -0
- package/dist/node/stories.js +2 -2
- package/dist/node/vite.js +3 -0
- package/dist/style.css +80 -4
- package/package.json +2 -2
- package/src/client/app/App.vue +2 -0
- package/src/client/app/codegen/serialize-js.ts +24 -10
- package/src/client/app/components/base/BaseSplitPane.vue +6 -6
- package/src/client/app/components/sandbox/RouterLinkStub.ts +49 -0
- package/src/client/app/components/sandbox/SandboxVue3.vue +4 -0
- package/src/client/app/style/main.pcss +3 -3
- package/src/client/app/style/sandbox.css +1 -1
- package/src/client/app/util/state.ts +11 -5
- package/src/client/server/vue3/Story.vue +17 -2
- package/src/client/server/vue3/Variant.vue +3 -1
- package/src/node/collect/index.ts +1 -0
- package/src/node/config.ts +20 -0
- package/src/node/stories.ts +3 -3
- package/src/node/vite.ts +3 -0
- package/tailwind.config.cjs +1 -1
|
@@ -82,7 +82,7 @@ function useScrollOnActive(active, el) {
|
|
|
82
82
|
};
|
|
83
83
|
}
|
|
84
84
|
var BaseSplitPane_vue_vue_type_style_index_0_scoped_true_lang = "";
|
|
85
|
-
const _withScopeId = (n) => (pushScopeId("data-v-
|
|
85
|
+
const _withScopeId = (n) => (pushScopeId("data-v-4cd3cd6c"), n = n(), popScopeId(), n);
|
|
86
86
|
const _hoisted_1$1 = ["onMousedown"];
|
|
87
87
|
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
88
88
|
name: "BaseSplitPane",
|
|
@@ -261,7 +261,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
261
261
|
};
|
|
262
262
|
}
|
|
263
263
|
});
|
|
264
|
-
var BaseSplitPane = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-
|
|
264
|
+
var BaseSplitPane = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-4cd3cd6c"]]);
|
|
265
265
|
const isMobile = useMediaQuery("(max-width: 640px)");
|
|
266
266
|
const _hoisted_1 = {
|
|
267
267
|
key: 0,
|
|
@@ -14,7 +14,7 @@ var __spreadValues = (a, b) => {
|
|
|
14
14
|
}
|
|
15
15
|
return a;
|
|
16
16
|
};
|
|
17
|
-
import { Text, vModelText, vModelSelect, vModelRadio, vModelCheckbox, vModelDynamic, defineComponent, ref, createApp, onMounted, watch, onUnmounted, openBlock, createElementBlock } from "vue";
|
|
17
|
+
import { Text, vModelText, vModelSelect, vModelRadio, vModelCheckbox, vModelDynamic, defineComponent, computed, h, ref, createApp, onMounted, watch, onUnmounted, openBlock, createElementBlock } from "vue";
|
|
18
18
|
import { pascal } from "case";
|
|
19
19
|
import { a as applyStateToVariant } from "./state.js";
|
|
20
20
|
import * as setup from "$histoire-setup";
|
|
@@ -91,6 +91,7 @@ function createAutoBuildingObject(format, specialKeysHandler, key = "", depth =
|
|
|
91
91
|
const KEY_ESCAPE_REG = /[\s-.:|#@$£*%]/;
|
|
92
92
|
const MAX_SINGLE_LINE_ARRAY_LENGTH = 3;
|
|
93
93
|
function serializeJs(value) {
|
|
94
|
+
const seen = /* @__PURE__ */ new Set();
|
|
94
95
|
if (value === void 0) {
|
|
95
96
|
return "undefined";
|
|
96
97
|
}
|
|
@@ -104,10 +105,10 @@ function serializeJs(value) {
|
|
|
104
105
|
return value ? "true" : "false";
|
|
105
106
|
}
|
|
106
107
|
if (Array.isArray(value)) {
|
|
107
|
-
return printLines(arrayToSourceLines(value));
|
|
108
|
+
return printLines(arrayToSourceLines(value, seen));
|
|
108
109
|
}
|
|
109
110
|
if (typeof value === "object") {
|
|
110
|
-
return printLines(objectToSourceLines(value));
|
|
111
|
+
return printLines(objectToSourceLines(value, seen));
|
|
111
112
|
}
|
|
112
113
|
if (value == null ? void 0 : value.__autoBuildingObject) {
|
|
113
114
|
return value;
|
|
@@ -120,7 +121,12 @@ function serializeJs(value) {
|
|
|
120
121
|
function printLines(lines) {
|
|
121
122
|
return lines.map((line) => " ".repeat(line.spaces) + line.line).join("\n");
|
|
122
123
|
}
|
|
123
|
-
function objectToSourceLines(object, indentCount = 0) {
|
|
124
|
+
function objectToSourceLines(object, seen, indentCount = 0) {
|
|
125
|
+
if (seen.has(object)) {
|
|
126
|
+
object = {};
|
|
127
|
+
} else {
|
|
128
|
+
seen.add(object);
|
|
129
|
+
}
|
|
124
130
|
return createLines(indentCount, (lines) => {
|
|
125
131
|
lines.push("{");
|
|
126
132
|
lines.push(...createLines(1, (lines2) => {
|
|
@@ -130,17 +136,22 @@ function objectToSourceLines(object, indentCount = 0) {
|
|
|
130
136
|
if (KEY_ESCAPE_REG.test(key)) {
|
|
131
137
|
printedKey = `'${printedKey}'`;
|
|
132
138
|
}
|
|
133
|
-
addLinesFromValue(lines2, value, `${printedKey}: `, ",");
|
|
139
|
+
addLinesFromValue(lines2, value, `${printedKey}: `, ",", seen);
|
|
134
140
|
}
|
|
135
141
|
}));
|
|
136
142
|
lines.push("}");
|
|
137
143
|
});
|
|
138
144
|
}
|
|
139
|
-
function arrayToSourceLines(array, indentCount = 0) {
|
|
145
|
+
function arrayToSourceLines(array, seen, indentCount = 0) {
|
|
146
|
+
if (seen.has(array)) {
|
|
147
|
+
array = [];
|
|
148
|
+
} else {
|
|
149
|
+
seen.add(array);
|
|
150
|
+
}
|
|
140
151
|
return createLines(indentCount, (lines) => {
|
|
141
152
|
const contentLines = createLines(1, (lines2) => {
|
|
142
153
|
for (const value of array) {
|
|
143
|
-
addLinesFromValue(lines2, value, "", ",");
|
|
154
|
+
addLinesFromValue(lines2, value, "", ",", seen);
|
|
144
155
|
}
|
|
145
156
|
});
|
|
146
157
|
if (contentLines.length === 0) {
|
|
@@ -167,13 +178,13 @@ function createLines(indentCount, handler) {
|
|
|
167
178
|
return { spaces: indentCount, line };
|
|
168
179
|
});
|
|
169
180
|
}
|
|
170
|
-
function addLinesFromValue(lines, value, before, after) {
|
|
181
|
+
function addLinesFromValue(lines, value, before, after, seen) {
|
|
171
182
|
let result;
|
|
172
183
|
if (Array.isArray(value)) {
|
|
173
|
-
lines.push(...wrap(arrayToSourceLines(value), before, after));
|
|
184
|
+
lines.push(...wrap(arrayToSourceLines(value, seen), before, after));
|
|
174
185
|
return;
|
|
175
186
|
} else if (value && typeof value === "object") {
|
|
176
|
-
lines.push(...wrap(objectToSourceLines(value), before, after));
|
|
187
|
+
lines.push(...wrap(objectToSourceLines(value, seen), before, after));
|
|
177
188
|
return;
|
|
178
189
|
} else if (typeof value === "string") {
|
|
179
190
|
result = value.includes("'") ? `\`${value}\`` : `'${value}'`;
|
|
@@ -509,6 +520,45 @@ function serializeAndCleanJs(value) {
|
|
|
509
520
|
function cleanupExpression(expr) {
|
|
510
521
|
return expr.replace(/\$setup\./g, "");
|
|
511
522
|
}
|
|
523
|
+
const defaultRoute = {
|
|
524
|
+
path: "/",
|
|
525
|
+
name: void 0,
|
|
526
|
+
redirectedFrom: void 0,
|
|
527
|
+
params: {},
|
|
528
|
+
query: {},
|
|
529
|
+
hash: "",
|
|
530
|
+
fullPath: "/",
|
|
531
|
+
matched: [],
|
|
532
|
+
meta: {},
|
|
533
|
+
href: "/"
|
|
534
|
+
};
|
|
535
|
+
const RouterLinkStub = defineComponent({
|
|
536
|
+
name: "RouterLinkStub",
|
|
537
|
+
compatConfig: { MODE: 3 },
|
|
538
|
+
props: {
|
|
539
|
+
to: {
|
|
540
|
+
type: [String, Object],
|
|
541
|
+
required: true
|
|
542
|
+
},
|
|
543
|
+
custom: {
|
|
544
|
+
type: Boolean,
|
|
545
|
+
default: false
|
|
546
|
+
}
|
|
547
|
+
},
|
|
548
|
+
render() {
|
|
549
|
+
var _a, _b;
|
|
550
|
+
const route = computed(() => defaultRoute);
|
|
551
|
+
const children = (_b = (_a = this.$slots) == null ? void 0 : _a.default) == null ? void 0 : _b.call(_a, {
|
|
552
|
+
route,
|
|
553
|
+
href: computed(() => route.value.href),
|
|
554
|
+
isActive: computed(() => false),
|
|
555
|
+
isExactActive: computed(() => false),
|
|
556
|
+
navigate: async () => {
|
|
557
|
+
}
|
|
558
|
+
});
|
|
559
|
+
return this.custom ? children : h("a", void 0, children);
|
|
560
|
+
}
|
|
561
|
+
});
|
|
512
562
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
513
563
|
name: "SandboxVue3",
|
|
514
564
|
props: {
|
|
@@ -615,6 +665,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
615
665
|
return vnodes;
|
|
616
666
|
}
|
|
617
667
|
});
|
|
668
|
+
app.component("RouterLink", RouterLinkStub);
|
|
618
669
|
if (typeof (generatedSetup == null ? void 0 : generatedSetup.setupVue3) === "function") {
|
|
619
670
|
await generatedSetup.setupVue3({
|
|
620
671
|
app,
|
package/dist/bundled/index2.js
CHANGED
|
@@ -702,6 +702,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
|
|
|
702
702
|
const files$1 = ref(files.map((file) => mapFile(file)));
|
|
703
703
|
const tree$1 = ref(tree);
|
|
704
704
|
onUpdate((newFiles, newTree) => {
|
|
705
|
+
loading.value = false;
|
|
705
706
|
files$1.value = newFiles.map((file) => {
|
|
706
707
|
const existingFile = files$1.value.find((f) => f.id === file.id);
|
|
707
708
|
return mapFile(file, existingFile);
|
|
@@ -742,6 +743,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
|
|
|
742
743
|
const loading = ref(false);
|
|
743
744
|
if (import.meta.hot && !files.length) {
|
|
744
745
|
loading.value = true;
|
|
746
|
+
console.log("loading...");
|
|
745
747
|
import.meta.hot.on("histoire:all-stories-loaded", () => {
|
|
746
748
|
loading.value = false;
|
|
747
749
|
});
|
package/dist/bundled/state.js
CHANGED
|
@@ -3,18 +3,22 @@ import { isRef, unref } from "vue";
|
|
|
3
3
|
const isDark = useDark({ valueDark: "htw-dark" });
|
|
4
4
|
const toggleDark = useToggle(isDark);
|
|
5
5
|
const isObject = (val) => val !== null && typeof val === "object";
|
|
6
|
-
function toRawDeep(val) {
|
|
6
|
+
function toRawDeep(val, seen = /* @__PURE__ */ new Set()) {
|
|
7
7
|
const unwrappedValue = isRef(val) ? unref(val) : val;
|
|
8
|
+
if (seen.has(unwrappedValue)) {
|
|
9
|
+
return Array.isArray(unwrappedValue) ? [] : {};
|
|
10
|
+
}
|
|
11
|
+
seen.add(unwrappedValue);
|
|
8
12
|
if (!isObject(unwrappedValue)) {
|
|
9
13
|
return unwrappedValue;
|
|
10
14
|
}
|
|
11
15
|
if (Array.isArray(unwrappedValue)) {
|
|
12
|
-
return unwrappedValue.map(toRawDeep);
|
|
16
|
+
return unwrappedValue.map((value) => toRawDeep(value, seen));
|
|
13
17
|
}
|
|
14
|
-
return toRawObject(unwrappedValue);
|
|
18
|
+
return toRawObject(unwrappedValue, seen);
|
|
15
19
|
}
|
|
16
|
-
const toRawObject = (obj) => Object.keys(obj).reduce((raw, key) => {
|
|
17
|
-
raw[key] = toRawDeep(obj[key]);
|
|
20
|
+
const toRawObject = (obj, seen = /* @__PURE__ */ new Set()) => Object.keys(obj).reduce((raw, key) => {
|
|
21
|
+
raw[key] = toRawDeep(obj[key], seen);
|
|
18
22
|
return raw;
|
|
19
23
|
}, {});
|
|
20
24
|
function clone(data) {
|
package/dist/bundled/style.css
CHANGED
|
@@ -14,29 +14,29 @@
|
|
|
14
14
|
color: var(--7fa476a0);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
.landscape > div > .dragger[data-v-
|
|
18
|
-
width:
|
|
17
|
+
.landscape > div > .dragger[data-v-4cd3cd6c] {
|
|
18
|
+
width: .625rem;
|
|
19
19
|
}
|
|
20
|
-
.portrait > div > .dragger[data-v-
|
|
21
|
-
height:
|
|
20
|
+
.portrait > div > .dragger[data-v-4cd3cd6c] {
|
|
21
|
+
height: .625rem;
|
|
22
22
|
}
|
|
23
|
-
.landscape > div > .dragger.dragger-offset-before[data-v-
|
|
23
|
+
.landscape > div > .dragger.dragger-offset-before[data-v-4cd3cd6c] {
|
|
24
24
|
right: 0;
|
|
25
25
|
}
|
|
26
|
-
.portrait > div > .dragger.dragger-offset-before[data-v-
|
|
26
|
+
.portrait > div > .dragger.dragger-offset-before[data-v-4cd3cd6c] {
|
|
27
27
|
bottom: 0;
|
|
28
28
|
}
|
|
29
|
-
.landscape > div > .dragger.dragger-offset-center[data-v-
|
|
30
|
-
right:
|
|
29
|
+
.landscape > div > .dragger.dragger-offset-center[data-v-4cd3cd6c] {
|
|
30
|
+
right: -.3125rem;
|
|
31
31
|
}
|
|
32
|
-
.portrait > div > .dragger.dragger-offset-center[data-v-
|
|
33
|
-
bottom:
|
|
32
|
+
.portrait > div > .dragger.dragger-offset-center[data-v-4cd3cd6c] {
|
|
33
|
+
bottom: -.3125rem;
|
|
34
34
|
}
|
|
35
|
-
.landscape > div > .dragger.dragger-offset-after[data-v-
|
|
36
|
-
right:
|
|
35
|
+
.landscape > div > .dragger.dragger-offset-after[data-v-4cd3cd6c] {
|
|
36
|
+
right: -.625rem;
|
|
37
37
|
}
|
|
38
|
-
.portrait > div > .dragger.dragger-offset-after[data-v-
|
|
39
|
-
bottom:
|
|
38
|
+
.portrait > div > .dragger.dragger-offset-after[data-v-4cd3cd6c] {
|
|
39
|
+
bottom: -.625rem;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
.bind-icon-color[data-v-2cdc2ac0] {
|
package/dist/client/app/App.vue
CHANGED
|
@@ -26,6 +26,7 @@ const files = ref<StoryFile[]>(rawFiles.map(file => mapFile(file)))
|
|
|
26
26
|
const tree = ref<Tree>(rawTree)
|
|
27
27
|
|
|
28
28
|
onUpdate((newFiles: StoryFile[], newTree: Tree) => {
|
|
29
|
+
loading.value = false
|
|
29
30
|
files.value = newFiles.map(file => {
|
|
30
31
|
const existingFile = files.value.find(f => f.id === file.id)
|
|
31
32
|
return mapFile(file, existingFile)
|
|
@@ -78,6 +79,7 @@ const loading = ref(false)
|
|
|
78
79
|
|
|
79
80
|
if (import.meta.hot && !rawFiles.length) {
|
|
80
81
|
loading.value = true
|
|
82
|
+
console.log('loading...')
|
|
81
83
|
import.meta.hot.on('histoire:all-stories-loaded', () => {
|
|
82
84
|
loading.value = false
|
|
83
85
|
})
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const KEY_ESCAPE_REG = /[\s-.:|#@$£*%]/;
|
|
2
2
|
const MAX_SINGLE_LINE_ARRAY_LENGTH = 3;
|
|
3
3
|
export function serializeJs(value) {
|
|
4
|
+
const seen = new Set();
|
|
4
5
|
if (value === undefined) {
|
|
5
6
|
return 'undefined';
|
|
6
7
|
}
|
|
@@ -14,10 +15,10 @@ export function serializeJs(value) {
|
|
|
14
15
|
return value ? 'true' : 'false';
|
|
15
16
|
}
|
|
16
17
|
if (Array.isArray(value)) {
|
|
17
|
-
return printLines(arrayToSourceLines(value));
|
|
18
|
+
return printLines(arrayToSourceLines(value, seen));
|
|
18
19
|
}
|
|
19
20
|
if (typeof value === 'object') {
|
|
20
|
-
return printLines(objectToSourceLines(value));
|
|
21
|
+
return printLines(objectToSourceLines(value, seen));
|
|
21
22
|
}
|
|
22
23
|
if (value?.__autoBuildingObject) {
|
|
23
24
|
return value;
|
|
@@ -30,7 +31,13 @@ export function serializeJs(value) {
|
|
|
30
31
|
function printLines(lines) {
|
|
31
32
|
return lines.map(line => ' '.repeat(line.spaces) + line.line).join('\n');
|
|
32
33
|
}
|
|
33
|
-
function objectToSourceLines(object, indentCount = 0) {
|
|
34
|
+
function objectToSourceLines(object, seen, indentCount = 0) {
|
|
35
|
+
if (seen.has(object)) {
|
|
36
|
+
object = {};
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
seen.add(object);
|
|
40
|
+
}
|
|
34
41
|
return createLines(indentCount, lines => {
|
|
35
42
|
lines.push('{');
|
|
36
43
|
lines.push(...createLines(1, lines => {
|
|
@@ -40,17 +47,23 @@ function objectToSourceLines(object, indentCount = 0) {
|
|
|
40
47
|
if (KEY_ESCAPE_REG.test(key)) {
|
|
41
48
|
printedKey = `'${printedKey}'`;
|
|
42
49
|
}
|
|
43
|
-
addLinesFromValue(lines, value, `${printedKey}: `, ',');
|
|
50
|
+
addLinesFromValue(lines, value, `${printedKey}: `, ',', seen);
|
|
44
51
|
}
|
|
45
52
|
}));
|
|
46
53
|
lines.push('}');
|
|
47
54
|
});
|
|
48
55
|
}
|
|
49
|
-
function arrayToSourceLines(array, indentCount = 0) {
|
|
56
|
+
function arrayToSourceLines(array, seen, indentCount = 0) {
|
|
57
|
+
if (seen.has(array)) {
|
|
58
|
+
array = [];
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
seen.add(array);
|
|
62
|
+
}
|
|
50
63
|
return createLines(indentCount, lines => {
|
|
51
64
|
const contentLines = createLines(1, lines => {
|
|
52
65
|
for (const value of array) {
|
|
53
|
-
addLinesFromValue(lines, value, '', ',');
|
|
66
|
+
addLinesFromValue(lines, value, '', ',', seen);
|
|
54
67
|
}
|
|
55
68
|
});
|
|
56
69
|
if (contentLines.length === 0) {
|
|
@@ -79,14 +92,14 @@ function createLines(indentCount, handler) {
|
|
|
79
92
|
return { spaces: indentCount, line };
|
|
80
93
|
});
|
|
81
94
|
}
|
|
82
|
-
function addLinesFromValue(lines, value, before, after) {
|
|
95
|
+
function addLinesFromValue(lines, value, before, after, seen) {
|
|
83
96
|
let result;
|
|
84
97
|
if (Array.isArray(value)) {
|
|
85
|
-
lines.push(...wrap(arrayToSourceLines(value), before, after));
|
|
98
|
+
lines.push(...wrap(arrayToSourceLines(value, seen), before, after));
|
|
86
99
|
return;
|
|
87
100
|
}
|
|
88
101
|
else if (value && typeof value === 'object') {
|
|
89
|
-
lines.push(...wrap(objectToSourceLines(value), before, after));
|
|
102
|
+
lines.push(...wrap(objectToSourceLines(value, seen), before, after));
|
|
90
103
|
return;
|
|
91
104
|
}
|
|
92
105
|
else if (typeof value === 'string') {
|
|
@@ -206,11 +206,11 @@ onUnmounted(() => {
|
|
|
206
206
|
|
|
207
207
|
<style lang="postcss" scoped>
|
|
208
208
|
.landscape > div > .dragger {
|
|
209
|
-
width:
|
|
209
|
+
width: .625rem;
|
|
210
210
|
}
|
|
211
211
|
|
|
212
212
|
.portrait > div > .dragger {
|
|
213
|
-
height:
|
|
213
|
+
height: .625rem;
|
|
214
214
|
}
|
|
215
215
|
|
|
216
216
|
.landscape > div > .dragger.dragger-offset-before {
|
|
@@ -222,18 +222,18 @@ onUnmounted(() => {
|
|
|
222
222
|
}
|
|
223
223
|
|
|
224
224
|
.landscape > div > .dragger.dragger-offset-center {
|
|
225
|
-
right:
|
|
225
|
+
right: -.3125rem;
|
|
226
226
|
}
|
|
227
227
|
|
|
228
228
|
.portrait > div > .dragger.dragger-offset-center {
|
|
229
|
-
bottom:
|
|
229
|
+
bottom: -.3125rem;
|
|
230
230
|
}
|
|
231
231
|
|
|
232
232
|
.landscape > div > .dragger.dragger-offset-after {
|
|
233
|
-
right:
|
|
233
|
+
right: -.625rem;
|
|
234
234
|
}
|
|
235
235
|
|
|
236
236
|
.portrait > div > .dragger.dragger-offset-after {
|
|
237
|
-
bottom:
|
|
237
|
+
bottom: -.625rem;
|
|
238
238
|
}
|
|
239
239
|
</style>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare const RouterLinkStub: import("vue").DefineComponent<{
|
|
2
|
+
to: {
|
|
3
|
+
type: (ObjectConstructor | StringConstructor)[];
|
|
4
|
+
required: true;
|
|
5
|
+
};
|
|
6
|
+
custom: {
|
|
7
|
+
type: BooleanConstructor;
|
|
8
|
+
default: boolean;
|
|
9
|
+
};
|
|
10
|
+
}, unknown, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
11
|
+
to: {
|
|
12
|
+
type: (ObjectConstructor | StringConstructor)[];
|
|
13
|
+
required: true;
|
|
14
|
+
};
|
|
15
|
+
custom: {
|
|
16
|
+
type: BooleanConstructor;
|
|
17
|
+
default: boolean;
|
|
18
|
+
};
|
|
19
|
+
}>>, {
|
|
20
|
+
custom: boolean;
|
|
21
|
+
}>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// From: https://github.com/vuejs/test-utils/blob/main/src/components/RouterLinkStub.ts
|
|
2
|
+
import { defineComponent, h, computed } from 'vue';
|
|
3
|
+
// match return type of router.resolve: RouteLocation & { href: string }
|
|
4
|
+
const defaultRoute = {
|
|
5
|
+
path: '/',
|
|
6
|
+
name: undefined,
|
|
7
|
+
redirectedFrom: undefined,
|
|
8
|
+
params: {},
|
|
9
|
+
query: {},
|
|
10
|
+
hash: '',
|
|
11
|
+
fullPath: '/',
|
|
12
|
+
matched: [],
|
|
13
|
+
meta: {},
|
|
14
|
+
href: '/',
|
|
15
|
+
};
|
|
16
|
+
// TODO: Borrow typings from vue-router-next
|
|
17
|
+
export const RouterLinkStub = defineComponent({
|
|
18
|
+
name: 'RouterLinkStub',
|
|
19
|
+
compatConfig: { MODE: 3 },
|
|
20
|
+
props: {
|
|
21
|
+
to: {
|
|
22
|
+
type: [String, Object],
|
|
23
|
+
required: true,
|
|
24
|
+
},
|
|
25
|
+
custom: {
|
|
26
|
+
type: Boolean,
|
|
27
|
+
default: false,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
render() {
|
|
31
|
+
const route = computed(() => defaultRoute);
|
|
32
|
+
// mock reasonable return values to mimic vue-router's useLink
|
|
33
|
+
const children = this.$slots?.default?.({
|
|
34
|
+
route,
|
|
35
|
+
href: computed(() => route.value.href),
|
|
36
|
+
isActive: computed(() => false),
|
|
37
|
+
isExactActive: computed(() => false),
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
39
|
+
navigate: async () => { },
|
|
40
|
+
});
|
|
41
|
+
return this.custom ? children : h('a', undefined, children);
|
|
42
|
+
},
|
|
43
|
+
});
|
|
@@ -3,6 +3,7 @@ import { App, createApp, onMounted, onUnmounted, PropType, ref, watch } from 'vu
|
|
|
3
3
|
import { Story, Variant, PropDefinition, AutoPropComponentDefinition } from '../../types'
|
|
4
4
|
import { getTagName } from '../../codegen/vue3'
|
|
5
5
|
import { applyStateToVariant } from '../../util/state'
|
|
6
|
+
import { RouterLinkStub } from './RouterLinkStub'
|
|
6
7
|
// @ts-expect-error virtual module id
|
|
7
8
|
import * as setup from '$histoire-setup'
|
|
8
9
|
// @ts-expect-error virtual module id
|
|
@@ -125,6 +126,9 @@ async function mountVariant () {
|
|
|
125
126
|
},
|
|
126
127
|
})
|
|
127
128
|
|
|
129
|
+
// Stubs
|
|
130
|
+
app.component('RouterLink', RouterLinkStub)
|
|
131
|
+
|
|
128
132
|
if (typeof generatedSetup?.setupVue3 === 'function') {
|
|
129
133
|
await generatedSetup.setupVue3({
|
|
130
134
|
app,
|
|
@@ -50,16 +50,16 @@ body,
|
|
|
50
50
|
|
|
51
51
|
html {
|
|
52
52
|
font-family: 'Lato', sans-serif;
|
|
53
|
-
font-size:
|
|
53
|
+
font-size: 1rem;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
body {
|
|
57
|
-
font-size:
|
|
57
|
+
font-size: 1.125rem;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
@media (min-width: 640px) {
|
|
61
61
|
body {
|
|
62
|
-
font-size:
|
|
62
|
+
font-size: .875rem;
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Variant } from '../types';
|
|
2
|
-
export declare function toRawDeep(val: any): any;
|
|
2
|
+
export declare function toRawDeep(val: any, seen?: Set<unknown>): any;
|
|
3
3
|
export declare function clone(data: any): any;
|
|
4
4
|
export declare function omit(data: any, keys: string[]): {};
|
|
5
5
|
export declare function applyStateToVariant(variant: Variant, state: any): void;
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import { unref, isRef } from 'vue';
|
|
2
2
|
const isObject = (val) => val !== null && typeof val === 'object';
|
|
3
|
-
export function toRawDeep(val) {
|
|
3
|
+
export function toRawDeep(val, seen = new Set()) {
|
|
4
4
|
const unwrappedValue = isRef(val) ? unref(val) : val;
|
|
5
|
+
if (seen.has(unwrappedValue)) {
|
|
6
|
+
return Array.isArray(unwrappedValue) ? [] : {};
|
|
7
|
+
}
|
|
8
|
+
seen.add(unwrappedValue);
|
|
5
9
|
if (!isObject(unwrappedValue)) {
|
|
6
10
|
return unwrappedValue;
|
|
7
11
|
}
|
|
8
12
|
if (Array.isArray(unwrappedValue)) {
|
|
9
|
-
return unwrappedValue.map(toRawDeep);
|
|
13
|
+
return unwrappedValue.map(value => toRawDeep(value, seen));
|
|
10
14
|
}
|
|
11
|
-
return toRawObject(unwrappedValue);
|
|
15
|
+
return toRawObject(unwrappedValue, seen);
|
|
12
16
|
}
|
|
13
|
-
const toRawObject = (obj) => Object.keys(obj).reduce((raw, key) => {
|
|
14
|
-
raw[key] = toRawDeep(obj[key]);
|
|
17
|
+
const toRawObject = (obj, seen = new Set()) => Object.keys(obj).reduce((raw, key) => {
|
|
18
|
+
raw[key] = toRawDeep(obj[key], seen);
|
|
15
19
|
return raw;
|
|
16
20
|
}, {});
|
|
17
21
|
export function clone(data) {
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { defineComponent, inject, onMounted, PropType, provide, useAttrs } from 'vue'
|
|
3
|
-
import type { StoryFile, Story, Variant } from '
|
|
3
|
+
import type { StoryFile, Story, Variant } from '../../../node/types'
|
|
4
|
+
|
|
5
|
+
const stub = { name: 'StubbedComponent', render: () => null }
|
|
4
6
|
|
|
5
7
|
export default defineComponent({
|
|
8
|
+
name: 'HistoireStory',
|
|
9
|
+
|
|
6
10
|
inheritAttrs: false,
|
|
7
11
|
|
|
8
12
|
props: {
|
|
@@ -87,13 +91,24 @@ export default defineComponent({
|
|
|
87
91
|
render () {
|
|
88
92
|
let suppressError = false
|
|
89
93
|
try {
|
|
90
|
-
|
|
94
|
+
const vnodes = this.$slots.default?.({
|
|
91
95
|
get state () {
|
|
92
96
|
// No variant tags
|
|
93
97
|
suppressError = true
|
|
94
98
|
return {}
|
|
95
99
|
},
|
|
96
100
|
})
|
|
101
|
+
|
|
102
|
+
// Auto stub components
|
|
103
|
+
if (Array.isArray(vnodes)) {
|
|
104
|
+
for (const vnode of vnodes) {
|
|
105
|
+
if (typeof vnode.type === 'object' && (vnode.type as any).name !== 'HistoireVariant') {
|
|
106
|
+
vnode.type = stub
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return vnodes
|
|
97
112
|
} catch (e) {
|
|
98
113
|
if (!suppressError) {
|
|
99
114
|
console.error(e)
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { defineComponent, inject } from 'vue'
|
|
3
|
-
import type { Story, Variant } from '
|
|
3
|
+
import type { Story, Variant } from '../../../node/types'
|
|
4
4
|
|
|
5
5
|
export default defineComponent({
|
|
6
|
+
name: 'HistoireVariant',
|
|
7
|
+
|
|
6
8
|
props: {
|
|
7
9
|
title: {
|
|
8
10
|
type: String,
|
package/dist/node/config.d.ts
CHANGED
|
@@ -134,6 +134,26 @@ export interface HistoireConfig {
|
|
|
134
134
|
* Transpile dependencies when collecting stories on Node.js
|
|
135
135
|
*/
|
|
136
136
|
viteNodeInlineDeps?: RegExp[];
|
|
137
|
+
/**
|
|
138
|
+
* Determine the transform method of modules
|
|
139
|
+
*/
|
|
140
|
+
viteNodeTransformMode?: {
|
|
141
|
+
/**
|
|
142
|
+
* Use SSR transform pipeline for the specified files.
|
|
143
|
+
* Vite plugins will receive `ssr: true` flag when processing those files.
|
|
144
|
+
*
|
|
145
|
+
* @default [/\.([cm]?[jt]sx?|json)$/]
|
|
146
|
+
*/
|
|
147
|
+
ssr?: RegExp[];
|
|
148
|
+
/**
|
|
149
|
+
* First do a normal transform pipeline (targeting browser),
|
|
150
|
+
* then then do a SSR rewrite to run the code in Node.
|
|
151
|
+
* Vite plugins will receive `ssr: false` flag when processing those files.
|
|
152
|
+
*
|
|
153
|
+
* @default other than `ssr`
|
|
154
|
+
*/
|
|
155
|
+
web?: RegExp[];
|
|
156
|
+
};
|
|
137
157
|
}
|
|
138
158
|
export declare type ConfigMode = 'build' | 'dev';
|
|
139
159
|
export declare function getDefaultConfig(): HistoireConfig;
|
package/dist/node/stories.js
CHANGED
|
@@ -49,8 +49,8 @@ export function addStory(relativeFilePath) {
|
|
|
49
49
|
return file;
|
|
50
50
|
}
|
|
51
51
|
export function removeStory(relativeFilePath) {
|
|
52
|
-
const
|
|
53
|
-
const index = context.storyFiles.findIndex((file) => file.
|
|
52
|
+
const absoluteFilePath = getAbsoluteFilePath(relativeFilePath);
|
|
53
|
+
const index = context.storyFiles.findIndex((file) => file.path === absoluteFilePath);
|
|
54
54
|
if (index !== -1)
|
|
55
55
|
context.storyFiles.splice(index, 1);
|
|
56
56
|
}
|
package/dist/node/vite.js
CHANGED
|
@@ -77,6 +77,9 @@ export async function getViteConfigWithPlugins(server, ctx) {
|
|
|
77
77
|
fs: {
|
|
78
78
|
allow: [DIST_PATH, TEMP_PATH, resolvedViteConfig.root, process.cwd()],
|
|
79
79
|
},
|
|
80
|
+
watch: {
|
|
81
|
+
ignored: [`!**/node_modules/.histoire/**`],
|
|
82
|
+
},
|
|
80
83
|
},
|
|
81
84
|
define: {
|
|
82
85
|
// We need to force this to be able to use `devtoolsRawSetupState`
|
package/dist/style.css
CHANGED
|
@@ -205,6 +205,58 @@
|
|
|
205
205
|
border-color:#000c
|
|
206
206
|
}
|
|
207
207
|
|
|
208
|
+
.htw-range-input::-webkit-slider-thumb{
|
|
209
|
+
height:.75rem;
|
|
210
|
+
width:.75rem;
|
|
211
|
+
-webkit-appearance:none;
|
|
212
|
+
appearance:none;
|
|
213
|
+
border-radius:9999px;
|
|
214
|
+
border-width:1px;
|
|
215
|
+
border-style:solid;
|
|
216
|
+
border-color:#00000040;
|
|
217
|
+
--tw-bg-opacity: 1;
|
|
218
|
+
background-color:rgb(255 255 255 / var(--tw-bg-opacity))
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
.htw-dark .htw-range-input::-webkit-slider-thumb{
|
|
222
|
+
border-color:#ffffff40;
|
|
223
|
+
--tw-bg-opacity: 1;
|
|
224
|
+
background-color:rgb(63 63 70 / var(--tw-bg-opacity))
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
.htw-range-input:hover::-webkit-slider-thumb{
|
|
228
|
+
--tw-border-opacity: 1 !important;
|
|
229
|
+
border-color:rgb(16 185 129 / var(--tw-border-opacity))!important;
|
|
230
|
+
--tw-bg-opacity: 1 !important;
|
|
231
|
+
background-color:rgb(16 185 129 / var(--tw-bg-opacity))!important
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
.htw-range-input::-moz-range-thumb{
|
|
235
|
+
height:.75rem;
|
|
236
|
+
width:.75rem;
|
|
237
|
+
-moz-appearance:none;
|
|
238
|
+
appearance:none;
|
|
239
|
+
border-radius:9999px;
|
|
240
|
+
border-width:1px;
|
|
241
|
+
border-style:solid;
|
|
242
|
+
border-color:#00000040;
|
|
243
|
+
--tw-bg-opacity: 1;
|
|
244
|
+
background-color:rgb(255 255 255 / var(--tw-bg-opacity))
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
.htw-dark .htw-range-input::-moz-range-thumb{
|
|
248
|
+
border-color:#ffffff40;
|
|
249
|
+
--tw-bg-opacity: 1;
|
|
250
|
+
background-color:rgb(63 63 70 / var(--tw-bg-opacity))
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
.htw-range-input:hover::-moz-range-thumb{
|
|
254
|
+
--tw-border-opacity: 1 !important;
|
|
255
|
+
border-color:rgb(16 185 129 / var(--tw-border-opacity))!important;
|
|
256
|
+
--tw-bg-opacity: 1 !important;
|
|
257
|
+
background-color:rgb(16 185 129 / var(--tw-bg-opacity))!important
|
|
258
|
+
}
|
|
259
|
+
|
|
208
260
|
.v-popper{
|
|
209
261
|
line-height:0
|
|
210
262
|
}
|
|
@@ -506,7 +558,7 @@ button {
|
|
|
506
558
|
margin-left:0;
|
|
507
559
|
margin-right:0;
|
|
508
560
|
background-color:rgb(var(--_histoire-color-gray-100));
|
|
509
|
-
padding
|
|
561
|
+
padding:.25rem .375rem;
|
|
510
562
|
}
|
|
511
563
|
|
|
512
564
|
.htw-prose :where(blockquote):not(:where([class~="htw-not-prose"] *)) p:first-child{
|
|
@@ -1123,6 +1175,10 @@ button {
|
|
|
1123
1175
|
height:5rem
|
|
1124
1176
|
}
|
|
1125
1177
|
|
|
1178
|
+
.htw-h-1{
|
|
1179
|
+
height:0.25rem
|
|
1180
|
+
}
|
|
1181
|
+
|
|
1126
1182
|
.htw-max-h-full{
|
|
1127
1183
|
max-height:100%
|
|
1128
1184
|
}
|
|
@@ -1313,6 +1369,12 @@ button {
|
|
|
1313
1369
|
resize:vertical
|
|
1314
1370
|
}
|
|
1315
1371
|
|
|
1372
|
+
.htw-appearance-none{
|
|
1373
|
+
-webkit-appearance:none;
|
|
1374
|
+
-moz-appearance:none;
|
|
1375
|
+
appearance:none
|
|
1376
|
+
}
|
|
1377
|
+
|
|
1316
1378
|
.htw-grid-cols-\[repeat\(auto-fill\,minmax\(200px\,1fr\)\)\]{
|
|
1317
1379
|
grid-template-columns:repeat(auto-fill,minmax(200px,1fr))
|
|
1318
1380
|
}
|
|
@@ -1467,6 +1529,10 @@ button {
|
|
|
1467
1529
|
border-width:2px
|
|
1468
1530
|
}
|
|
1469
1531
|
|
|
1532
|
+
.htw-border-0{
|
|
1533
|
+
border-width:0px
|
|
1534
|
+
}
|
|
1535
|
+
|
|
1470
1536
|
.htw-border-b-2{
|
|
1471
1537
|
border-bottom-width:2px
|
|
1472
1538
|
}
|
|
@@ -1610,6 +1676,11 @@ button {
|
|
|
1610
1676
|
background-color:rgb(var(--_histoire-color-gray-700) / var(--tw-bg-opacity))
|
|
1611
1677
|
}
|
|
1612
1678
|
|
|
1679
|
+
.\!htw-bg-primary-500{
|
|
1680
|
+
--tw-bg-opacity:1 !important;
|
|
1681
|
+
background-color:rgb(var(--_histoire-color-primary-500) / var(--tw-bg-opacity)) !important
|
|
1682
|
+
}
|
|
1683
|
+
|
|
1613
1684
|
.htw-stroke-white{
|
|
1614
1685
|
stroke:#fff
|
|
1615
1686
|
}
|
|
@@ -1815,6 +1886,11 @@ button {
|
|
|
1815
1886
|
color:rgb(var(--_histoire-color-primary-800) / var(--tw-text-opacity))
|
|
1816
1887
|
}
|
|
1817
1888
|
|
|
1889
|
+
.htw-text-gray-700{
|
|
1890
|
+
--tw-text-opacity:1;
|
|
1891
|
+
color:rgb(var(--_histoire-color-gray-700) / var(--tw-text-opacity))
|
|
1892
|
+
}
|
|
1893
|
+
|
|
1818
1894
|
.htw-opacity-25{
|
|
1819
1895
|
opacity:0.25
|
|
1820
1896
|
}
|
|
@@ -1917,16 +1993,16 @@ body,
|
|
|
1917
1993
|
|
|
1918
1994
|
html {
|
|
1919
1995
|
font-family: 'Lato', sans-serif;
|
|
1920
|
-
font-size:
|
|
1996
|
+
font-size: 1rem;
|
|
1921
1997
|
}
|
|
1922
1998
|
|
|
1923
1999
|
body {
|
|
1924
|
-
font-size:
|
|
2000
|
+
font-size: 1.125rem;
|
|
1925
2001
|
}
|
|
1926
2002
|
|
|
1927
2003
|
@media (min-width: 640px) {
|
|
1928
2004
|
body {
|
|
1929
|
-
font-size:
|
|
2005
|
+
font-size: .875rem;
|
|
1930
2006
|
}
|
|
1931
2007
|
}
|
|
1932
2008
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "histoire",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.3",
|
|
4
4
|
"description": "A fast story book powered by Vite",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"histoire": "./bin.mjs"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@histoire/controls": "^0.7.
|
|
36
|
+
"@histoire/controls": "^0.7.3",
|
|
37
37
|
"@iconify/vue": "^3.2.1",
|
|
38
38
|
"@types/markdown-it": "^12.2.3",
|
|
39
39
|
"@vueuse/core": "^8.2.5",
|
package/src/client/app/App.vue
CHANGED
|
@@ -26,6 +26,7 @@ const files = ref<StoryFile[]>(rawFiles.map(file => mapFile(file)))
|
|
|
26
26
|
const tree = ref<Tree>(rawTree)
|
|
27
27
|
|
|
28
28
|
onUpdate((newFiles: StoryFile[], newTree: Tree) => {
|
|
29
|
+
loading.value = false
|
|
29
30
|
files.value = newFiles.map(file => {
|
|
30
31
|
const existingFile = files.value.find(f => f.id === file.id)
|
|
31
32
|
return mapFile(file, existingFile)
|
|
@@ -78,6 +79,7 @@ const loading = ref(false)
|
|
|
78
79
|
|
|
79
80
|
if (import.meta.hot && !rawFiles.length) {
|
|
80
81
|
loading.value = true
|
|
82
|
+
console.log('loading...')
|
|
81
83
|
import.meta.hot.on('histoire:all-stories-loaded', () => {
|
|
82
84
|
loading.value = false
|
|
83
85
|
})
|
|
@@ -7,6 +7,8 @@ interface Line {
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
export function serializeJs (value: any): string {
|
|
10
|
+
const seen = new Set()
|
|
11
|
+
|
|
10
12
|
if (value === undefined) {
|
|
11
13
|
return 'undefined'
|
|
12
14
|
}
|
|
@@ -20,10 +22,10 @@ export function serializeJs (value: any): string {
|
|
|
20
22
|
return value ? 'true' : 'false'
|
|
21
23
|
}
|
|
22
24
|
if (Array.isArray(value)) {
|
|
23
|
-
return printLines(arrayToSourceLines(value))
|
|
25
|
+
return printLines(arrayToSourceLines(value, seen))
|
|
24
26
|
}
|
|
25
27
|
if (typeof value === 'object') {
|
|
26
|
-
return printLines(objectToSourceLines(value))
|
|
28
|
+
return printLines(objectToSourceLines(value, seen))
|
|
27
29
|
}
|
|
28
30
|
if (value?.__autoBuildingObject) {
|
|
29
31
|
return value
|
|
@@ -38,7 +40,13 @@ function printLines (lines: Line[]) {
|
|
|
38
40
|
return lines.map(line => ' '.repeat(line.spaces) + line.line).join('\n')
|
|
39
41
|
}
|
|
40
42
|
|
|
41
|
-
function objectToSourceLines (object, indentCount = 0) {
|
|
43
|
+
function objectToSourceLines (object, seen: Set<unknown>, indentCount = 0) {
|
|
44
|
+
if (seen.has(object)) {
|
|
45
|
+
object = {}
|
|
46
|
+
} else {
|
|
47
|
+
seen.add(object)
|
|
48
|
+
}
|
|
49
|
+
|
|
42
50
|
return createLines(indentCount, lines => {
|
|
43
51
|
lines.push('{')
|
|
44
52
|
lines.push(...createLines(1, lines => {
|
|
@@ -50,18 +58,24 @@ function objectToSourceLines (object, indentCount = 0) {
|
|
|
50
58
|
printedKey = `'${printedKey}'`
|
|
51
59
|
}
|
|
52
60
|
|
|
53
|
-
addLinesFromValue(lines, value, `${printedKey}: `, ',')
|
|
61
|
+
addLinesFromValue(lines, value, `${printedKey}: `, ',', seen)
|
|
54
62
|
}
|
|
55
63
|
}))
|
|
56
64
|
lines.push('}')
|
|
57
65
|
})
|
|
58
66
|
}
|
|
59
67
|
|
|
60
|
-
function arrayToSourceLines (array: any[], indentCount = 0) {
|
|
68
|
+
function arrayToSourceLines (array: any[], seen: Set<unknown>, indentCount = 0): Array<Line> {
|
|
69
|
+
if (seen.has(array)) {
|
|
70
|
+
array = []
|
|
71
|
+
} else {
|
|
72
|
+
seen.add(array)
|
|
73
|
+
}
|
|
74
|
+
|
|
61
75
|
return createLines(indentCount, lines => {
|
|
62
76
|
const contentLines = createLines(1, lines => {
|
|
63
77
|
for (const value of array) {
|
|
64
|
-
addLinesFromValue(lines, value, '', ',')
|
|
78
|
+
addLinesFromValue(lines, value, '', ',', seen)
|
|
65
79
|
}
|
|
66
80
|
})
|
|
67
81
|
if (contentLines.length === 0) {
|
|
@@ -78,7 +92,7 @@ function arrayToSourceLines (array: any[], indentCount = 0) {
|
|
|
78
92
|
})
|
|
79
93
|
}
|
|
80
94
|
|
|
81
|
-
function createLines (indentCount: number, handler: (lines: any[]) => unknown) {
|
|
95
|
+
function createLines (indentCount: number, handler: (lines: any[]) => unknown): Array<Line> {
|
|
82
96
|
const lines: any[] = []
|
|
83
97
|
handler(lines)
|
|
84
98
|
return lines.map(line => {
|
|
@@ -90,13 +104,13 @@ function createLines (indentCount: number, handler: (lines: any[]) => unknown) {
|
|
|
90
104
|
})
|
|
91
105
|
}
|
|
92
106
|
|
|
93
|
-
function addLinesFromValue (lines: Line[], value, before, after) {
|
|
107
|
+
function addLinesFromValue (lines: Line[], value, before, after, seen) {
|
|
94
108
|
let result
|
|
95
109
|
if (Array.isArray(value)) {
|
|
96
|
-
lines.push(...wrap(arrayToSourceLines(value), before, after))
|
|
110
|
+
lines.push(...wrap(arrayToSourceLines(value, seen), before, after))
|
|
97
111
|
return
|
|
98
112
|
} else if (value && typeof value === 'object') {
|
|
99
|
-
lines.push(...wrap(objectToSourceLines(value), before, after))
|
|
113
|
+
lines.push(...wrap(objectToSourceLines(value, seen), before, after))
|
|
100
114
|
return
|
|
101
115
|
} else if (typeof value === 'string') {
|
|
102
116
|
result = value.includes('\'') ? `\`${value}\`` : `'${value}'`
|
|
@@ -206,11 +206,11 @@ onUnmounted(() => {
|
|
|
206
206
|
|
|
207
207
|
<style lang="postcss" scoped>
|
|
208
208
|
.landscape > div > .dragger {
|
|
209
|
-
width:
|
|
209
|
+
width: .625rem;
|
|
210
210
|
}
|
|
211
211
|
|
|
212
212
|
.portrait > div > .dragger {
|
|
213
|
-
height:
|
|
213
|
+
height: .625rem;
|
|
214
214
|
}
|
|
215
215
|
|
|
216
216
|
.landscape > div > .dragger.dragger-offset-before {
|
|
@@ -222,18 +222,18 @@ onUnmounted(() => {
|
|
|
222
222
|
}
|
|
223
223
|
|
|
224
224
|
.landscape > div > .dragger.dragger-offset-center {
|
|
225
|
-
right:
|
|
225
|
+
right: -.3125rem;
|
|
226
226
|
}
|
|
227
227
|
|
|
228
228
|
.portrait > div > .dragger.dragger-offset-center {
|
|
229
|
-
bottom:
|
|
229
|
+
bottom: -.3125rem;
|
|
230
230
|
}
|
|
231
231
|
|
|
232
232
|
.landscape > div > .dragger.dragger-offset-after {
|
|
233
|
-
right:
|
|
233
|
+
right: -.625rem;
|
|
234
234
|
}
|
|
235
235
|
|
|
236
236
|
.portrait > div > .dragger.dragger-offset-after {
|
|
237
|
-
bottom:
|
|
237
|
+
bottom: -.625rem;
|
|
238
238
|
}
|
|
239
239
|
</style>
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// From: https://github.com/vuejs/test-utils/blob/main/src/components/RouterLinkStub.ts
|
|
2
|
+
|
|
3
|
+
import { defineComponent, h, computed } from 'vue'
|
|
4
|
+
|
|
5
|
+
// match return type of router.resolve: RouteLocation & { href: string }
|
|
6
|
+
const defaultRoute = {
|
|
7
|
+
path: '/',
|
|
8
|
+
name: undefined as string | undefined,
|
|
9
|
+
redirectedFrom: undefined as object | undefined,
|
|
10
|
+
params: {},
|
|
11
|
+
query: {},
|
|
12
|
+
hash: '',
|
|
13
|
+
fullPath: '/',
|
|
14
|
+
matched: [] as object[],
|
|
15
|
+
meta: {},
|
|
16
|
+
href: '/',
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// TODO: Borrow typings from vue-router-next
|
|
20
|
+
export const RouterLinkStub = defineComponent({
|
|
21
|
+
name: 'RouterLinkStub',
|
|
22
|
+
|
|
23
|
+
compatConfig: { MODE: 3 },
|
|
24
|
+
|
|
25
|
+
props: {
|
|
26
|
+
to: {
|
|
27
|
+
type: [String, Object],
|
|
28
|
+
required: true,
|
|
29
|
+
},
|
|
30
|
+
custom: {
|
|
31
|
+
type: Boolean,
|
|
32
|
+
default: false,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
render () {
|
|
37
|
+
const route = computed(() => defaultRoute)
|
|
38
|
+
// mock reasonable return values to mimic vue-router's useLink
|
|
39
|
+
const children = this.$slots?.default?.({
|
|
40
|
+
route,
|
|
41
|
+
href: computed(() => route.value.href),
|
|
42
|
+
isActive: computed(() => false),
|
|
43
|
+
isExactActive: computed(() => false),
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
45
|
+
navigate: async () => {},
|
|
46
|
+
})
|
|
47
|
+
return this.custom ? children : h('a', undefined, children)
|
|
48
|
+
},
|
|
49
|
+
})
|
|
@@ -3,6 +3,7 @@ import { App, createApp, onMounted, onUnmounted, PropType, ref, watch } from 'vu
|
|
|
3
3
|
import { Story, Variant, PropDefinition, AutoPropComponentDefinition } from '../../types'
|
|
4
4
|
import { getTagName } from '../../codegen/vue3'
|
|
5
5
|
import { applyStateToVariant } from '../../util/state'
|
|
6
|
+
import { RouterLinkStub } from './RouterLinkStub'
|
|
6
7
|
// @ts-expect-error virtual module id
|
|
7
8
|
import * as setup from '$histoire-setup'
|
|
8
9
|
// @ts-expect-error virtual module id
|
|
@@ -125,6 +126,9 @@ async function mountVariant () {
|
|
|
125
126
|
},
|
|
126
127
|
})
|
|
127
128
|
|
|
129
|
+
// Stubs
|
|
130
|
+
app.component('RouterLink', RouterLinkStub)
|
|
131
|
+
|
|
128
132
|
if (typeof generatedSetup?.setupVue3 === 'function') {
|
|
129
133
|
await generatedSetup.setupVue3({
|
|
130
134
|
app,
|
|
@@ -50,16 +50,16 @@ body,
|
|
|
50
50
|
|
|
51
51
|
html {
|
|
52
52
|
font-family: 'Lato', sans-serif;
|
|
53
|
-
font-size:
|
|
53
|
+
font-size: 1rem;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
body {
|
|
57
|
-
font-size:
|
|
57
|
+
font-size: 1.125rem;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
@media (min-width: 640px) {
|
|
61
61
|
body {
|
|
62
|
-
font-size:
|
|
62
|
+
font-size: .875rem;
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
|
|
@@ -3,22 +3,28 @@ import type { Variant } from '../types'
|
|
|
3
3
|
|
|
4
4
|
const isObject = (val) => val !== null && typeof val === 'object'
|
|
5
5
|
|
|
6
|
-
export function toRawDeep (val) {
|
|
6
|
+
export function toRawDeep (val, seen = new Set()) {
|
|
7
7
|
const unwrappedValue = isRef(val) ? unref(val) : val
|
|
8
8
|
|
|
9
|
+
if (seen.has(unwrappedValue)) {
|
|
10
|
+
return Array.isArray(unwrappedValue) ? [] : {}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
seen.add(unwrappedValue)
|
|
14
|
+
|
|
9
15
|
if (!isObject(unwrappedValue)) {
|
|
10
16
|
return unwrappedValue
|
|
11
17
|
}
|
|
12
18
|
|
|
13
19
|
if (Array.isArray(unwrappedValue)) {
|
|
14
|
-
return unwrappedValue.map(toRawDeep)
|
|
20
|
+
return unwrappedValue.map(value => toRawDeep(value, seen))
|
|
15
21
|
}
|
|
16
22
|
|
|
17
|
-
return toRawObject(unwrappedValue)
|
|
23
|
+
return toRawObject(unwrappedValue, seen)
|
|
18
24
|
}
|
|
19
25
|
|
|
20
|
-
const toRawObject = (obj: Record<any, any
|
|
21
|
-
raw[key] = toRawDeep(obj[key])
|
|
26
|
+
const toRawObject = (obj: Record<any, any>, seen = new Set()) => Object.keys(obj).reduce((raw, key) => {
|
|
27
|
+
raw[key] = toRawDeep(obj[key], seen)
|
|
22
28
|
return raw
|
|
23
29
|
}, {})
|
|
24
30
|
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { defineComponent, inject, onMounted, PropType, provide, useAttrs } from 'vue'
|
|
3
|
-
import type { StoryFile, Story, Variant } from '
|
|
3
|
+
import type { StoryFile, Story, Variant } from '../../../node/types'
|
|
4
|
+
|
|
5
|
+
const stub = { name: 'StubbedComponent', render: () => null }
|
|
4
6
|
|
|
5
7
|
export default defineComponent({
|
|
8
|
+
name: 'HistoireStory',
|
|
9
|
+
|
|
6
10
|
inheritAttrs: false,
|
|
7
11
|
|
|
8
12
|
props: {
|
|
@@ -87,13 +91,24 @@ export default defineComponent({
|
|
|
87
91
|
render () {
|
|
88
92
|
let suppressError = false
|
|
89
93
|
try {
|
|
90
|
-
|
|
94
|
+
const vnodes = this.$slots.default?.({
|
|
91
95
|
get state () {
|
|
92
96
|
// No variant tags
|
|
93
97
|
suppressError = true
|
|
94
98
|
return {}
|
|
95
99
|
},
|
|
96
100
|
})
|
|
101
|
+
|
|
102
|
+
// Auto stub components
|
|
103
|
+
if (Array.isArray(vnodes)) {
|
|
104
|
+
for (const vnode of vnodes) {
|
|
105
|
+
if (typeof vnode.type === 'object' && (vnode.type as any).name !== 'HistoireVariant') {
|
|
106
|
+
vnode.type = stub
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return vnodes
|
|
97
112
|
} catch (e) {
|
|
98
113
|
if (!suppressError) {
|
|
99
114
|
console.error(e)
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { defineComponent, inject } from 'vue'
|
|
3
|
-
import type { Story, Variant } from '
|
|
3
|
+
import type { Story, Variant } from '../../../node/types'
|
|
4
4
|
|
|
5
5
|
export default defineComponent({
|
|
6
|
+
name: 'HistoireVariant',
|
|
7
|
+
|
|
6
8
|
props: {
|
|
7
9
|
title: {
|
|
8
10
|
type: String,
|
package/src/node/config.ts
CHANGED
|
@@ -153,6 +153,26 @@ export interface HistoireConfig {
|
|
|
153
153
|
* Transpile dependencies when collecting stories on Node.js
|
|
154
154
|
*/
|
|
155
155
|
viteNodeInlineDeps?: RegExp[]
|
|
156
|
+
/**
|
|
157
|
+
* Determine the transform method of modules
|
|
158
|
+
*/
|
|
159
|
+
viteNodeTransformMode?: {
|
|
160
|
+
/**
|
|
161
|
+
* Use SSR transform pipeline for the specified files.
|
|
162
|
+
* Vite plugins will receive `ssr: true` flag when processing those files.
|
|
163
|
+
*
|
|
164
|
+
* @default [/\.([cm]?[jt]sx?|json)$/]
|
|
165
|
+
*/
|
|
166
|
+
ssr?: RegExp[]
|
|
167
|
+
/**
|
|
168
|
+
* First do a normal transform pipeline (targeting browser),
|
|
169
|
+
* then then do a SSR rewrite to run the code in Node.
|
|
170
|
+
* Vite plugins will receive `ssr: false` flag when processing those files.
|
|
171
|
+
*
|
|
172
|
+
* @default other than `ssr`
|
|
173
|
+
*/
|
|
174
|
+
web?: RegExp[]
|
|
175
|
+
}
|
|
156
176
|
}
|
|
157
177
|
|
|
158
178
|
export type ConfigMode = 'build' | 'dev'
|
package/src/node/stories.ts
CHANGED
|
@@ -53,7 +53,7 @@ export function addStory (relativeFilePath: string) {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
const file: StoryFile = {
|
|
56
|
-
id: fileId,
|
|
56
|
+
id: fileId, // The file id will be changed by the story id after it is collected
|
|
57
57
|
path: absoluteFilePath,
|
|
58
58
|
fileName,
|
|
59
59
|
moduleId: `/${relativeFilePath}`,
|
|
@@ -63,8 +63,8 @@ export function addStory (relativeFilePath: string) {
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
export function removeStory (relativeFilePath: string) {
|
|
66
|
-
const
|
|
67
|
-
const index = context.storyFiles.findIndex((file) => file.
|
|
66
|
+
const absoluteFilePath = getAbsoluteFilePath(relativeFilePath)
|
|
67
|
+
const index = context.storyFiles.findIndex((file) => file.path === absoluteFilePath)
|
|
68
68
|
if (index !== -1) context.storyFiles.splice(index, 1)
|
|
69
69
|
}
|
|
70
70
|
|
package/src/node/vite.ts
CHANGED
|
@@ -93,6 +93,9 @@ export async function getViteConfigWithPlugins (server: boolean, ctx: Context):
|
|
|
93
93
|
fs: {
|
|
94
94
|
allow: [DIST_PATH, TEMP_PATH, resolvedViteConfig.root, process.cwd()],
|
|
95
95
|
},
|
|
96
|
+
watch: {
|
|
97
|
+
ignored: [`!**/node_modules/.histoire/**`],
|
|
98
|
+
},
|
|
96
99
|
},
|
|
97
100
|
define: {
|
|
98
101
|
// We need to force this to be able to use `devtoolsRawSetupState`
|
package/tailwind.config.cjs
CHANGED