histoire 0.8.0 → 0.8.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/components/panel/StorySourceCode.js +4 -4
- package/dist/bundled/style.css +15 -15
- package/dist/bundled/util/mapping.js +17 -1
- package/dist/bundled/util/state.js +17 -11
- package/dist/client/app/components/panel/StorySourceCode.vue +1 -1
- package/dist/client/app/util/mapping.js +17 -1
- package/dist/client/app/util/state.d.ts +1 -1
- package/dist/client/app/util/state.js +18 -11
- package/dist/node/config.js +24 -5
- package/dist/node/vite.js +6 -2
- package/package.json +6 -5
- package/src/client/app/components/panel/StorySourceCode.vue +1 -1
- package/src/client/app/util/mapping.ts +18 -1
- package/src/client/app/util/state.ts +17 -13
- package/src/node/config.ts +24 -5
- package/src/node/vite.ts +7 -1
- package/tsconfig.json +0 -1
- package/vite.config.ts +0 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { pushScopeId, popScopeId, createElementVNode, defineComponent, ref, shallowRef, onMounted, watch, computed, openBlock, createElementBlock, createVNode, unref, createCommentVNode, toDisplayString } from "@histoire/vendors/dist/client/vue.js";
|
|
2
|
-
import { setCDN, getHighlighter } from "
|
|
2
|
+
import { setCDN, getHighlighter } from "shiki";
|
|
3
3
|
import { HstCopyIcon } from "@histoire/controls";
|
|
4
4
|
import { unindent } from "@histoire/shared";
|
|
5
5
|
import { generateSourceCode } from "@histoire/plugin-vue/client";
|
|
6
6
|
import { isDark } from "../../util/dark.js";
|
|
7
7
|
import "./StorySourceCode.vue_vue_type_style_index_0_scoped_true_lang.js";
|
|
8
8
|
import _export_sfc from "../../_virtual/plugin-vue_export-helper.js";
|
|
9
|
-
const _withScopeId = (n) => (pushScopeId("data-v-
|
|
9
|
+
const _withScopeId = (n) => (pushScopeId("data-v-19579c98"), n = n(), popScopeId(), n);
|
|
10
10
|
const _hoisted_1 = { class: "htw-bg-gray-100 dark:htw-bg-gray-800 htw-h-full htw-overflow-hidden htw-flex htw-flex-col" };
|
|
11
11
|
const _hoisted_2 = {
|
|
12
12
|
key: 0,
|
|
@@ -39,7 +39,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
39
39
|
const highlighter = shallowRef();
|
|
40
40
|
const error = ref(null);
|
|
41
41
|
onMounted(async () => {
|
|
42
|
-
setCDN("https://unpkg.com/shiki/");
|
|
42
|
+
setCDN("https://unpkg.com/shiki@0.10.1/");
|
|
43
43
|
highlighter.value = await getHighlighter({
|
|
44
44
|
langs: [
|
|
45
45
|
"html",
|
|
@@ -106,5 +106,5 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
106
106
|
};
|
|
107
107
|
}
|
|
108
108
|
});
|
|
109
|
-
var StorySourceCode = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-
|
|
109
|
+
var StorySourceCode = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-19579c98"]]);
|
|
110
110
|
export { StorySourceCode as default };
|
package/dist/bundled/style.css
CHANGED
|
@@ -20,6 +20,14 @@
|
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
.bind-icon-color[data-v-356879fc] {
|
|
24
|
+
color: var(--578fcd62);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.bind-icon-color[data-v-67187ed0] {
|
|
28
|
+
color: var(--5e381dde);
|
|
29
|
+
}
|
|
30
|
+
|
|
23
31
|
.landscape > div > .dragger[data-v-7c5763cc] {
|
|
24
32
|
width: .625rem;
|
|
25
33
|
}
|
|
@@ -45,12 +53,8 @@
|
|
|
45
53
|
bottom: -.625rem;
|
|
46
54
|
}
|
|
47
55
|
|
|
48
|
-
.bind-icon-color[data-v-
|
|
49
|
-
color: var(--
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
.bind-icon-color[data-v-67187ed0] {
|
|
53
|
-
color: var(--5e381dde);
|
|
56
|
+
.bind-icon-color[data-v-2cdc2ac0] {
|
|
57
|
+
color: var(--3c4190ff);
|
|
54
58
|
}
|
|
55
59
|
|
|
56
60
|
.bind-tree-margin[data-v-1b0b957a] {
|
|
@@ -64,11 +68,7 @@
|
|
|
64
68
|
padding-left: var(--27f98670);
|
|
65
69
|
}
|
|
66
70
|
|
|
67
|
-
.
|
|
68
|
-
color: var(--3c4190ff);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
.__histoire-code-placeholder[data-v-8b318638] {
|
|
71
|
+
.__histoire-code-placeholder[data-v-19579c98] {
|
|
72
72
|
color: inherit;
|
|
73
73
|
font-size: inherit;
|
|
74
74
|
}
|
|
@@ -77,14 +77,14 @@
|
|
|
77
77
|
color: var(--33d9fc01);
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
.bind-icon-color[data-v-307653da] {
|
|
81
|
-
color: var(--5f94a358);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
80
|
.bind-icon-color[data-v-7856c5b0] {
|
|
85
81
|
color: var(--0e1c785e);
|
|
86
82
|
}
|
|
87
83
|
|
|
84
|
+
.bind-icon-color[data-v-307653da] {
|
|
85
|
+
color: var(--5f94a358);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
88
|
.bind-preview-bg[data-v-bde73868] {
|
|
89
89
|
background-color: var(--b797c7ca);
|
|
90
90
|
}
|
|
@@ -67,7 +67,7 @@ function mapVariant(variant, existingVariant) {
|
|
|
67
67
|
}
|
|
68
68
|
} else {
|
|
69
69
|
result = __spreadProps(__spreadValues({}, variant), {
|
|
70
|
-
state: reactive(
|
|
70
|
+
state: reactive(createVariantState()),
|
|
71
71
|
setupApp: null,
|
|
72
72
|
slots: () => ({}),
|
|
73
73
|
previewReady: false
|
|
@@ -75,4 +75,20 @@ function mapVariant(variant, existingVariant) {
|
|
|
75
75
|
}
|
|
76
76
|
return result;
|
|
77
77
|
}
|
|
78
|
+
function createVariantState() {
|
|
79
|
+
const obj = {};
|
|
80
|
+
Object.defineProperty(obj, "_hPropState", {
|
|
81
|
+
value: null,
|
|
82
|
+
writable: true,
|
|
83
|
+
configurable: true,
|
|
84
|
+
enumerable: false
|
|
85
|
+
});
|
|
86
|
+
Object.defineProperty(obj, "_hPropDefs", {
|
|
87
|
+
value: null,
|
|
88
|
+
writable: true,
|
|
89
|
+
configurable: true,
|
|
90
|
+
enumerable: false
|
|
91
|
+
});
|
|
92
|
+
return obj;
|
|
93
|
+
}
|
|
78
94
|
export { mapFile, mapVariant };
|
|
@@ -1,25 +1,31 @@
|
|
|
1
1
|
import { isRef, unref } from "@histoire/vendors/dist/client/vue.js";
|
|
2
2
|
const isObject = (val) => val !== null && typeof val === "object";
|
|
3
|
-
function toRawDeep(val, seen = /* @__PURE__ */ new
|
|
3
|
+
function toRawDeep(val, seen = /* @__PURE__ */ new WeakMap()) {
|
|
4
4
|
const unwrappedValue = isRef(val) ? unref(val) : val;
|
|
5
|
-
|
|
6
|
-
if (valueType === "symbol" || valueType === "function") {
|
|
5
|
+
if (typeof unwrappedValue === "symbol") {
|
|
7
6
|
return unwrappedValue.toString();
|
|
8
7
|
}
|
|
9
8
|
if (!isObject(unwrappedValue)) {
|
|
10
9
|
return unwrappedValue;
|
|
11
10
|
}
|
|
12
11
|
if (seen.has(unwrappedValue)) {
|
|
13
|
-
return
|
|
12
|
+
return seen.get(unwrappedValue);
|
|
14
13
|
}
|
|
15
|
-
seen.add(unwrappedValue);
|
|
16
14
|
if (Array.isArray(unwrappedValue)) {
|
|
17
|
-
|
|
15
|
+
const result = [];
|
|
16
|
+
seen.set(unwrappedValue, result);
|
|
17
|
+
result.push(...unwrappedValue.map((value) => toRawDeep(value, seen)));
|
|
18
|
+
return result;
|
|
19
|
+
} else {
|
|
20
|
+
const result = {};
|
|
21
|
+
seen.set(unwrappedValue, result);
|
|
22
|
+
toRawObject(unwrappedValue, result, seen);
|
|
23
|
+
return result;
|
|
18
24
|
}
|
|
19
|
-
return toRawObject(unwrappedValue, seen);
|
|
20
25
|
}
|
|
21
|
-
const toRawObject = (obj, seen = /* @__PURE__ */ new
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
26
|
+
const toRawObject = (obj, target, seen = /* @__PURE__ */ new WeakMap()) => {
|
|
27
|
+
Object.keys(obj).forEach((key) => {
|
|
28
|
+
target[key] = toRawDeep(obj[key], seen);
|
|
29
|
+
});
|
|
30
|
+
};
|
|
25
31
|
export { toRawDeep };
|
|
@@ -19,7 +19,7 @@ const highlighter = shallowRef<Highlighter>()
|
|
|
19
19
|
const error = ref<string>(null)
|
|
20
20
|
|
|
21
21
|
onMounted(async () => {
|
|
22
|
-
setCDN('https://unpkg.com/shiki/')
|
|
22
|
+
setCDN('https://unpkg.com/shiki@0.10.1/')
|
|
23
23
|
highlighter.value = await getHighlighter({
|
|
24
24
|
langs: [
|
|
25
25
|
'html',
|
|
@@ -59,7 +59,7 @@ export function mapVariant(variant, existingVariant) {
|
|
|
59
59
|
// Create
|
|
60
60
|
result = {
|
|
61
61
|
...variant,
|
|
62
|
-
state: _reactive(
|
|
62
|
+
state: _reactive(createVariantState()),
|
|
63
63
|
setupApp: null,
|
|
64
64
|
slots: () => ({}),
|
|
65
65
|
previewReady: false,
|
|
@@ -67,3 +67,19 @@ export function mapVariant(variant, existingVariant) {
|
|
|
67
67
|
}
|
|
68
68
|
return result;
|
|
69
69
|
}
|
|
70
|
+
function createVariantState() {
|
|
71
|
+
const obj = {};
|
|
72
|
+
Object.defineProperty(obj, '_hPropState', {
|
|
73
|
+
value: null,
|
|
74
|
+
writable: true,
|
|
75
|
+
configurable: true,
|
|
76
|
+
enumerable: false,
|
|
77
|
+
});
|
|
78
|
+
Object.defineProperty(obj, '_hPropDefs', {
|
|
79
|
+
value: null,
|
|
80
|
+
writable: true,
|
|
81
|
+
configurable: true,
|
|
82
|
+
enumerable: false,
|
|
83
|
+
});
|
|
84
|
+
return obj;
|
|
85
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function toRawDeep(val: any, seen?:
|
|
1
|
+
export declare function toRawDeep(val: any, seen?: WeakMap<object, any>): any;
|
|
@@ -1,24 +1,31 @@
|
|
|
1
1
|
import { unref, isRef } from 'vue';
|
|
2
2
|
const isObject = (val) => val !== null && typeof val === 'object';
|
|
3
|
-
export function toRawDeep(val, seen = new
|
|
3
|
+
export function toRawDeep(val, seen = new WeakMap()) {
|
|
4
4
|
const unwrappedValue = isRef(val) ? unref(val) : val;
|
|
5
|
-
|
|
6
|
-
if (valueType === 'symbol' || valueType === 'function') {
|
|
5
|
+
if (typeof unwrappedValue === 'symbol') {
|
|
7
6
|
return unwrappedValue.toString();
|
|
8
7
|
}
|
|
9
8
|
if (!isObject(unwrappedValue)) {
|
|
10
9
|
return unwrappedValue;
|
|
11
10
|
}
|
|
12
11
|
if (seen.has(unwrappedValue)) {
|
|
13
|
-
return
|
|
12
|
+
return seen.get(unwrappedValue);
|
|
14
13
|
}
|
|
15
|
-
seen.add(unwrappedValue);
|
|
16
14
|
if (Array.isArray(unwrappedValue)) {
|
|
17
|
-
|
|
15
|
+
const result = [];
|
|
16
|
+
seen.set(unwrappedValue, result);
|
|
17
|
+
result.push(...unwrappedValue.map(value => toRawDeep(value, seen)));
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
const result = {};
|
|
22
|
+
seen.set(unwrappedValue, result);
|
|
23
|
+
toRawObject(unwrappedValue, result, seen);
|
|
24
|
+
return result;
|
|
18
25
|
}
|
|
19
|
-
return toRawObject(unwrappedValue, seen);
|
|
20
26
|
}
|
|
21
|
-
const toRawObject = (obj, seen = new
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
27
|
+
const toRawObject = (obj, target, seen = new WeakMap()) => {
|
|
28
|
+
Object.keys(obj).forEach((key) => {
|
|
29
|
+
target[key] = toRawDeep(obj[key], seen);
|
|
30
|
+
});
|
|
31
|
+
};
|
package/dist/node/config.js
CHANGED
|
@@ -95,10 +95,20 @@ export function getDefaultConfig() {
|
|
|
95
95
|
],
|
|
96
96
|
sandboxDarkClass: 'dark',
|
|
97
97
|
routerMode: 'history',
|
|
98
|
-
vite: {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
98
|
+
vite: (config) => {
|
|
99
|
+
// Remove vite:legacy plugins https://github.com/histoire-dev/histoire/issues/156
|
|
100
|
+
const index = config.plugins?.findIndex(plugin => Array.isArray(plugin) &&
|
|
101
|
+
typeof plugin[0] === 'object' &&
|
|
102
|
+
!Array.isArray(plugin[0]) &&
|
|
103
|
+
plugin[0].name.startsWith('vite:legacy'));
|
|
104
|
+
if (index !== -1) {
|
|
105
|
+
config.plugins?.splice(index, 1);
|
|
106
|
+
}
|
|
107
|
+
return {
|
|
108
|
+
build: {
|
|
109
|
+
lib: false,
|
|
110
|
+
},
|
|
111
|
+
};
|
|
102
112
|
},
|
|
103
113
|
};
|
|
104
114
|
}
|
|
@@ -145,7 +155,16 @@ export async function loadConfigFile(configFile) {
|
|
|
145
155
|
}
|
|
146
156
|
export const mergeConfig = createDefu((obj, key, value) => {
|
|
147
157
|
if (obj[key] && key === 'vite') {
|
|
148
|
-
|
|
158
|
+
const initialValue = obj[key];
|
|
159
|
+
if (typeof value === 'function') {
|
|
160
|
+
obj[key] = async (...args) => {
|
|
161
|
+
const result = await value(...args);
|
|
162
|
+
return mergeViteConfig(initialValue, result);
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
obj[key] = mergeViteConfig(initialValue, value);
|
|
167
|
+
}
|
|
149
168
|
return true;
|
|
150
169
|
}
|
|
151
170
|
if (obj[key] && key === 'plugins') {
|
package/dist/node/vite.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire } from 'module';
|
|
2
2
|
import { relative, dirname, resolve } from 'pathe';
|
|
3
|
-
import { resolveConfig as resolveViteConfigInternal, mergeConfig as mergeViteConfig, } from 'vite';
|
|
3
|
+
import { resolveConfig as resolveViteConfigInternal, mergeConfig as mergeViteConfig, loadConfigFromFile as loadViteConfigFromFile, } from 'vite';
|
|
4
4
|
import { lookup as lookupMime } from 'mrmime';
|
|
5
5
|
import { APP_PATH, DIST_PATH, TEMP_PATH } from './alias.js';
|
|
6
6
|
import { notifyStoryChange } from './stories.js';
|
|
@@ -48,7 +48,8 @@ async function mergeHistoireViteConfig(viteConfig, ctx) {
|
|
|
48
48
|
}
|
|
49
49
|
export async function getViteConfigWithPlugins(isServer, ctx) {
|
|
50
50
|
const resolvedViteConfig = await resolveViteConfig(ctx);
|
|
51
|
-
const
|
|
51
|
+
const userViteConfig = await loadViteConfigFromFile({ command: ctx.mode === 'dev' ? 'serve' : 'build', mode: ctx.mode });
|
|
52
|
+
const inlineConfig = await mergeHistoireViteConfig(userViteConfig.config ?? {}, ctx);
|
|
52
53
|
const plugins = [];
|
|
53
54
|
plugins.push({
|
|
54
55
|
name: 'histoire-vite-plugin',
|
|
@@ -258,6 +259,7 @@ if (import.meta.hot) {
|
|
|
258
259
|
// Apply Vite HTML transforms. This injects the Vite HMR client, and
|
|
259
260
|
// also applies HTML transforms from Vite plugins
|
|
260
261
|
html = await server.transformIndexHtml(req.url, html);
|
|
262
|
+
res.setHeader('content-type', 'text/html; charset=UTF-8');
|
|
261
263
|
res.end(html);
|
|
262
264
|
return;
|
|
263
265
|
}
|
|
@@ -287,6 +289,7 @@ if (import.meta.hot) {
|
|
|
287
289
|
// Apply Vite HTML transforms. This injects the Vite HMR client, and
|
|
288
290
|
// also applies HTML transforms from Vite plugins
|
|
289
291
|
html = await server.transformIndexHtml(req.url, html);
|
|
292
|
+
res.setHeader('content-type', 'text/html; charset=UTF-8');
|
|
290
293
|
res.end(html);
|
|
291
294
|
return;
|
|
292
295
|
}
|
|
@@ -317,6 +320,7 @@ if (import.meta.hot) {
|
|
|
317
320
|
});
|
|
318
321
|
}
|
|
319
322
|
return mergeViteConfig(inlineConfig, {
|
|
323
|
+
configFile: false,
|
|
320
324
|
plugins,
|
|
321
325
|
});
|
|
322
326
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "histoire",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.3",
|
|
4
4
|
"description": "A fast story book powered by Vite",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
"histoire": "./bin.mjs"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@histoire/controls": "^0.8.
|
|
37
|
-
"@histoire/plugin-vue": "^0.8.
|
|
38
|
-
"@histoire/shared": "^0.8.
|
|
39
|
-
"@histoire/vendors": "^0.8.
|
|
36
|
+
"@histoire/controls": "^0.8.3",
|
|
37
|
+
"@histoire/plugin-vue": "^0.8.3",
|
|
38
|
+
"@histoire/shared": "^0.8.3",
|
|
39
|
+
"@histoire/vendors": "^0.8.3",
|
|
40
40
|
"@types/flexsearch": "^0.7.3",
|
|
41
41
|
"@types/markdown-it": "^12.2.3",
|
|
42
42
|
"birpc": "^0.1.1",
|
|
@@ -57,6 +57,7 @@
|
|
|
57
57
|
"pathe": "^0.2.0",
|
|
58
58
|
"picocolors": "^1.0.0",
|
|
59
59
|
"sade": "^1.8.1",
|
|
60
|
+
"shiki": "0.10.1",
|
|
60
61
|
"sirv": "^2.0.2",
|
|
61
62
|
"tinypool": "^0.1.2",
|
|
62
63
|
"vite-node": "0.12.1"
|
|
@@ -19,7 +19,7 @@ const highlighter = shallowRef<Highlighter>()
|
|
|
19
19
|
const error = ref<string>(null)
|
|
20
20
|
|
|
21
21
|
onMounted(async () => {
|
|
22
|
-
setCDN('https://unpkg.com/shiki/')
|
|
22
|
+
setCDN('https://unpkg.com/shiki@0.10.1/')
|
|
23
23
|
highlighter.value = await getHighlighter({
|
|
24
24
|
langs: [
|
|
25
25
|
'html',
|
|
@@ -63,7 +63,7 @@ export function mapVariant (variant: Variant, existingVariant?: Variant): Varian
|
|
|
63
63
|
// Create
|
|
64
64
|
result = {
|
|
65
65
|
...variant,
|
|
66
|
-
state: _reactive(
|
|
66
|
+
state: _reactive(createVariantState()),
|
|
67
67
|
setupApp: null,
|
|
68
68
|
slots: () => ({}),
|
|
69
69
|
previewReady: false,
|
|
@@ -72,3 +72,20 @@ export function mapVariant (variant: Variant, existingVariant?: Variant): Varian
|
|
|
72
72
|
|
|
73
73
|
return result
|
|
74
74
|
}
|
|
75
|
+
|
|
76
|
+
function createVariantState () {
|
|
77
|
+
const obj = {}
|
|
78
|
+
Object.defineProperty(obj, '_hPropState', {
|
|
79
|
+
value: null,
|
|
80
|
+
writable: true,
|
|
81
|
+
configurable: true,
|
|
82
|
+
enumerable: false,
|
|
83
|
+
})
|
|
84
|
+
Object.defineProperty(obj, '_hPropDefs', {
|
|
85
|
+
value: null,
|
|
86
|
+
writable: true,
|
|
87
|
+
configurable: true,
|
|
88
|
+
enumerable: false,
|
|
89
|
+
})
|
|
90
|
+
return obj
|
|
91
|
+
}
|
|
@@ -2,11 +2,10 @@ import { unref, isRef } from 'vue'
|
|
|
2
2
|
|
|
3
3
|
const isObject = (val) => val !== null && typeof val === 'object'
|
|
4
4
|
|
|
5
|
-
export function toRawDeep (val, seen = new
|
|
5
|
+
export function toRawDeep (val, seen = new WeakMap()) {
|
|
6
6
|
const unwrappedValue = isRef(val) ? unref(val) : val
|
|
7
|
-
const valueType = typeof unwrappedValue
|
|
8
7
|
|
|
9
|
-
if (
|
|
8
|
+
if (typeof unwrappedValue === 'symbol') {
|
|
10
9
|
return unwrappedValue.toString()
|
|
11
10
|
}
|
|
12
11
|
|
|
@@ -15,19 +14,24 @@ export function toRawDeep (val, seen = new Set()) {
|
|
|
15
14
|
}
|
|
16
15
|
|
|
17
16
|
if (seen.has(unwrappedValue)) {
|
|
18
|
-
return
|
|
17
|
+
return seen.get(unwrappedValue)
|
|
19
18
|
}
|
|
20
19
|
|
|
21
|
-
seen.add(unwrappedValue)
|
|
22
|
-
|
|
23
20
|
if (Array.isArray(unwrappedValue)) {
|
|
24
|
-
|
|
21
|
+
const result = []
|
|
22
|
+
seen.set(unwrappedValue, result)
|
|
23
|
+
result.push(...unwrappedValue.map(value => toRawDeep(value, seen)))
|
|
24
|
+
return result
|
|
25
|
+
} else {
|
|
26
|
+
const result = {}
|
|
27
|
+
seen.set(unwrappedValue, result)
|
|
28
|
+
toRawObject(unwrappedValue, result, seen)
|
|
29
|
+
return result
|
|
25
30
|
}
|
|
26
|
-
|
|
27
|
-
return toRawObject(unwrappedValue, seen)
|
|
28
31
|
}
|
|
29
32
|
|
|
30
|
-
const toRawObject = (obj: Record<any, any>, seen = new
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
33
|
+
const toRawObject = (obj: Record<any, any>, target: Record<any, any>, seen = new WeakMap()) => {
|
|
34
|
+
Object.keys(obj).forEach((key) => {
|
|
35
|
+
target[key] = toRawDeep(obj[key], seen)
|
|
36
|
+
})
|
|
37
|
+
}
|
package/src/node/config.ts
CHANGED
|
@@ -271,10 +271,21 @@ export function getDefaultConfig (): HistoireConfig {
|
|
|
271
271
|
],
|
|
272
272
|
sandboxDarkClass: 'dark',
|
|
273
273
|
routerMode: 'history',
|
|
274
|
-
vite: {
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
274
|
+
vite: (config) => {
|
|
275
|
+
// Remove vite:legacy plugins https://github.com/histoire-dev/histoire/issues/156
|
|
276
|
+
const index = config.plugins?.findIndex(plugin => Array.isArray(plugin) &&
|
|
277
|
+
typeof plugin[0] === 'object' &&
|
|
278
|
+
!Array.isArray(plugin[0]) &&
|
|
279
|
+
plugin[0].name.startsWith('vite:legacy'))
|
|
280
|
+
if (index !== -1) {
|
|
281
|
+
config.plugins?.splice(index, 1)
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
return {
|
|
285
|
+
build: {
|
|
286
|
+
lib: false,
|
|
287
|
+
},
|
|
288
|
+
}
|
|
278
289
|
},
|
|
279
290
|
}
|
|
280
291
|
}
|
|
@@ -324,7 +335,15 @@ export async function loadConfigFile (configFile: string): Promise<Partial<Histo
|
|
|
324
335
|
|
|
325
336
|
export const mergeConfig = createDefu((obj: any, key, value) => {
|
|
326
337
|
if (obj[key] && key === 'vite') {
|
|
327
|
-
|
|
338
|
+
const initialValue = obj[key]
|
|
339
|
+
if (typeof value === 'function') {
|
|
340
|
+
obj[key] = async (...args) => {
|
|
341
|
+
const result = await value(...args)
|
|
342
|
+
return mergeViteConfig(initialValue, result)
|
|
343
|
+
}
|
|
344
|
+
} else {
|
|
345
|
+
obj[key] = mergeViteConfig(initialValue, value)
|
|
346
|
+
}
|
|
328
347
|
return true
|
|
329
348
|
}
|
|
330
349
|
|
package/src/node/vite.ts
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
ResolvedConfig,
|
|
8
8
|
InlineConfig,
|
|
9
9
|
mergeConfig as mergeViteConfig,
|
|
10
|
+
loadConfigFromFile as loadViteConfigFromFile,
|
|
10
11
|
} from 'vite'
|
|
11
12
|
import { lookup as lookupMime } from 'mrmime'
|
|
12
13
|
import { APP_PATH, DIST_PATH, TEMP_PATH } from './alias.js'
|
|
@@ -62,7 +63,9 @@ async function mergeHistoireViteConfig (viteConfig: InlineConfig, ctx: Context)
|
|
|
62
63
|
export async function getViteConfigWithPlugins (isServer: boolean, ctx: Context): Promise<InlineConfig> {
|
|
63
64
|
const resolvedViteConfig = await resolveViteConfig(ctx)
|
|
64
65
|
|
|
65
|
-
const
|
|
66
|
+
const userViteConfig = await loadViteConfigFromFile({ command: ctx.mode === 'dev' ? 'serve' : 'build', mode: ctx.mode })
|
|
67
|
+
|
|
68
|
+
const inlineConfig = await mergeHistoireViteConfig(userViteConfig.config ?? {}, ctx)
|
|
66
69
|
const plugins: VitePlugin[] = []
|
|
67
70
|
|
|
68
71
|
plugins.push({
|
|
@@ -277,6 +280,7 @@ if (import.meta.hot) {
|
|
|
277
280
|
// Apply Vite HTML transforms. This injects the Vite HMR client, and
|
|
278
281
|
// also applies HTML transforms from Vite plugins
|
|
279
282
|
html = await server.transformIndexHtml(req.url, html)
|
|
283
|
+
res.setHeader('content-type', 'text/html; charset=UTF-8')
|
|
280
284
|
res.end(html)
|
|
281
285
|
return
|
|
282
286
|
}
|
|
@@ -308,6 +312,7 @@ if (import.meta.hot) {
|
|
|
308
312
|
// Apply Vite HTML transforms. This injects the Vite HMR client, and
|
|
309
313
|
// also applies HTML transforms from Vite plugins
|
|
310
314
|
html = await server.transformIndexHtml(req.url, html)
|
|
315
|
+
res.setHeader('content-type', 'text/html; charset=UTF-8')
|
|
311
316
|
res.end(html)
|
|
312
317
|
return
|
|
313
318
|
}
|
|
@@ -341,6 +346,7 @@ if (import.meta.hot) {
|
|
|
341
346
|
}
|
|
342
347
|
|
|
343
348
|
return mergeViteConfig(inlineConfig, {
|
|
349
|
+
configFile: false,
|
|
344
350
|
plugins,
|
|
345
351
|
}) as InlineConfig
|
|
346
352
|
}
|
package/tsconfig.json
CHANGED
|
@@ -36,7 +36,6 @@
|
|
|
36
36
|
"@iconify/vue": ["./node_modules/@histoire/vendors/dist/client/iconify"],
|
|
37
37
|
"pinia": ["./node_modules/@histoire/vendors/dist/client/pinia"],
|
|
38
38
|
"scroll-into-view-if-needed": ["./node_modules/@histoire/vendors/dist/client/scroll"],
|
|
39
|
-
"shiki": ["./node_modules/@histoire/vendors/dist/client/shiki"],
|
|
40
39
|
"vue-router": ["./node_modules/@histoire/vendors/dist/client/vue-router"],
|
|
41
40
|
"@vueuse/core": ["./node_modules/@histoire/vendors/dist/client/vue-use"],
|
|
42
41
|
"vue": ["./node_modules/@histoire/vendors/dist/client/vue"]
|
package/vite.config.ts
CHANGED
|
@@ -38,7 +38,6 @@ export default defineConfig({
|
|
|
38
38
|
'@iconify/vue': '@histoire/vendors/dist/client/iconify.js',
|
|
39
39
|
pinia: '@histoire/vendors/dist/client/pinia.js',
|
|
40
40
|
'scroll-into-view-if-needed': '@histoire/vendors/dist/client/scroll.js',
|
|
41
|
-
shiki: '@histoire/vendors/dist/client/shiki.js',
|
|
42
41
|
'vue-router': '@histoire/vendors/dist/client/vue-router.js',
|
|
43
42
|
'@vueuse/core': '@histoire/vendors/dist/client/vue-use.js',
|
|
44
43
|
vue: '@histoire/vendors/dist/client/vue.js',
|