histoire 0.8.1 → 0.8.2

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.
@@ -6,7 +6,7 @@ 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-8b318638"), n = n(), popScopeId(), n);
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-8b318638"]]);
109
+ var StorySourceCode = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-19579c98"]]);
110
110
  export { StorySourceCode as default };
@@ -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,14 +53,6 @@
45
53
  bottom: -.625rem;
46
54
  }
47
55
 
48
- .bind-icon-color[data-v-67187ed0] {
49
- color: var(--5e381dde);
50
- }
51
-
52
- .bind-icon-color[data-v-356879fc] {
53
- color: var(--578fcd62);
54
- }
55
-
56
56
  .bind-tree-margin[data-v-1b0b957a] {
57
57
  margin-left: var(--2101d9b6);
58
58
  }
@@ -60,31 +60,31 @@
60
60
  color: var(--0fbedaf2);
61
61
  }
62
62
 
63
- .bind-tree-padding[data-v-1a78012e] {
64
- padding-left: var(--27f98670);
63
+ .__histoire-code-placeholder[data-v-19579c98] {
64
+ color: inherit;
65
+ font-size: inherit;
65
66
  }
66
67
 
67
- .bind-icon-color[data-v-30bcb922] {
68
- color: var(--33d9fc01);
68
+ .bind-tree-padding[data-v-1a78012e] {
69
+ padding-left: var(--27f98670);
69
70
  }
70
71
 
71
72
  .bind-icon-color[data-v-2cdc2ac0] {
72
73
  color: var(--3c4190ff);
73
74
  }
74
75
 
75
- .__histoire-code-placeholder[data-v-8b318638] {
76
- color: inherit;
77
- font-size: inherit;
78
- }
79
-
80
- .bind-icon-color[data-v-7856c5b0] {
81
- color: var(--0e1c785e);
76
+ .bind-icon-color[data-v-30bcb922] {
77
+ color: var(--33d9fc01);
82
78
  }
83
79
 
84
80
  .bind-icon-color[data-v-307653da] {
85
81
  color: var(--5f94a358);
86
82
  }
87
83
 
84
+ .bind-icon-color[data-v-7856c5b0] {
85
+ color: var(--0e1c785e);
86
+ }
87
+
88
88
  .bind-preview-bg[data-v-bde73868] {
89
89
  background-color: var(--b797c7ca);
90
90
  }
@@ -1,24 +1,26 @@
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 Set()) {
3
+ function toRawDeep(val, seen = /* @__PURE__ */ new Map()) {
4
4
  const unwrappedValue = isRef(val) ? unref(val) : val;
5
- const valueType = typeof unwrappedValue;
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 Array.isArray(unwrappedValue) ? [] : {};
12
+ return seen.get(unwrappedValue);
14
13
  }
15
- seen.add(unwrappedValue);
14
+ let result;
16
15
  if (Array.isArray(unwrappedValue)) {
17
- return unwrappedValue.map((value) => toRawDeep(value, seen));
16
+ result = unwrappedValue.map((value) => toRawDeep(value, seen));
17
+ } else {
18
+ result = toRawObject(unwrappedValue, seen);
18
19
  }
19
- return toRawObject(unwrappedValue, seen);
20
+ seen.set(unwrappedValue, result);
21
+ return result;
20
22
  }
21
- const toRawObject = (obj, seen = /* @__PURE__ */ new Set()) => Object.keys(obj).reduce((raw, key) => {
23
+ const toRawObject = (obj, seen = /* @__PURE__ */ new Map()) => Object.keys(obj).reduce((raw, key) => {
22
24
  raw[key] = toRawDeep(obj[key], seen);
23
25
  return raw;
24
26
  }, {});
@@ -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',
@@ -1 +1 @@
1
- export declare function toRawDeep(val: any, seen?: Set<unknown>): any;
1
+ export declare function toRawDeep(val: any, seen?: Map<any, any>): any;
@@ -1,24 +1,27 @@
1
1
  import { unref, isRef } from 'vue';
2
2
  const isObject = (val) => val !== null && typeof val === 'object';
3
- export function toRawDeep(val, seen = new Set()) {
3
+ export function toRawDeep(val, seen = new Map()) {
4
4
  const unwrappedValue = isRef(val) ? unref(val) : val;
5
- const valueType = typeof unwrappedValue;
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 Array.isArray(unwrappedValue) ? [] : {};
12
+ return seen.get(unwrappedValue);
14
13
  }
15
- seen.add(unwrappedValue);
14
+ let result;
16
15
  if (Array.isArray(unwrappedValue)) {
17
- return unwrappedValue.map(value => toRawDeep(value, seen));
16
+ result = unwrappedValue.map(value => toRawDeep(value, seen));
18
17
  }
19
- return toRawObject(unwrappedValue, seen);
18
+ else {
19
+ result = toRawObject(unwrappedValue, seen);
20
+ }
21
+ seen.set(unwrappedValue, result);
22
+ return result;
20
23
  }
21
- const toRawObject = (obj, seen = new Set()) => Object.keys(obj).reduce((raw, key) => {
24
+ const toRawObject = (obj, seen = new Map()) => Object.keys(obj).reduce((raw, key) => {
22
25
  raw[key] = toRawDeep(obj[key], seen);
23
26
  return raw;
24
27
  }, {});
@@ -95,10 +95,20 @@ export function getDefaultConfig() {
95
95
  ],
96
96
  sandboxDarkClass: 'dark',
97
97
  routerMode: 'history',
98
- vite: {
99
- build: {
100
- lib: false,
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
- obj[key] = mergeViteConfig(obj[key], value);
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 inlineConfig = await mergeHistoireViteConfig({}, ctx);
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',
@@ -319,6 +320,7 @@ if (import.meta.hot) {
319
320
  });
320
321
  }
321
322
  return mergeViteConfig(inlineConfig, {
323
+ configFile: false,
322
324
  plugins,
323
325
  });
324
326
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "histoire",
3
- "version": "0.8.1",
3
+ "version": "0.8.2",
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.1",
37
- "@histoire/plugin-vue": "^0.8.1",
38
- "@histoire/shared": "^0.8.1",
39
- "@histoire/vendors": "^0.8.1",
36
+ "@histoire/controls": "^0.8.2",
37
+ "@histoire/plugin-vue": "^0.8.2",
38
+ "@histoire/shared": "^0.8.2",
39
+ "@histoire/vendors": "^0.8.2",
40
40
  "@types/flexsearch": "^0.7.3",
41
41
  "@types/markdown-it": "^12.2.3",
42
42
  "birpc": "^0.1.1",
@@ -57,7 +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
+ "shiki": "0.10.1",
61
61
  "sirv": "^2.0.2",
62
62
  "tinypool": "^0.1.2",
63
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',
@@ -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 Set()) {
5
+ export function toRawDeep (val, seen = new Map()) {
6
6
  const unwrappedValue = isRef(val) ? unref(val) : val
7
- const valueType = typeof unwrappedValue
8
7
 
9
- if (valueType === 'symbol' || valueType === 'function') {
8
+ if (typeof unwrappedValue === 'symbol') {
10
9
  return unwrappedValue.toString()
11
10
  }
12
11
 
@@ -15,19 +14,23 @@ export function toRawDeep (val, seen = new Set()) {
15
14
  }
16
15
 
17
16
  if (seen.has(unwrappedValue)) {
18
- return Array.isArray(unwrappedValue) ? [] : {}
17
+ return seen.get(unwrappedValue)
19
18
  }
20
19
 
21
- seen.add(unwrappedValue)
20
+ let result
22
21
 
23
22
  if (Array.isArray(unwrappedValue)) {
24
- return unwrappedValue.map(value => toRawDeep(value, seen))
23
+ result = unwrappedValue.map(value => toRawDeep(value, seen))
24
+ } else {
25
+ result = toRawObject(unwrappedValue, seen)
25
26
  }
26
27
 
27
- return toRawObject(unwrappedValue, seen)
28
+ seen.set(unwrappedValue, result)
29
+
30
+ return result
28
31
  }
29
32
 
30
- const toRawObject = (obj: Record<any, any>, seen = new Set()) => Object.keys(obj).reduce((raw, key) => {
33
+ const toRawObject = (obj: Record<any, any>, seen = new Map()) => Object.keys(obj).reduce((raw, key) => {
31
34
  raw[key] = toRawDeep(obj[key], seen)
32
35
  return raw
33
36
  }, {})
@@ -271,10 +271,21 @@ export function getDefaultConfig (): HistoireConfig {
271
271
  ],
272
272
  sandboxDarkClass: 'dark',
273
273
  routerMode: 'history',
274
- vite: {
275
- build: {
276
- lib: false,
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
- obj[key] = mergeViteConfig(obj[key], value)
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 inlineConfig = await mergeHistoireViteConfig({}, ctx)
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({
@@ -343,6 +346,7 @@ if (import.meta.hot) {
343
346
  }
344
347
 
345
348
  return mergeViteConfig(inlineConfig, {
349
+ configFile: false,
346
350
  plugins,
347
351
  }) as InlineConfig
348
352
  }