histoire 0.7.4 → 0.7.7

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.
@@ -596,7 +596,7 @@ function getSandboxUrl(story, variant) {
596
596
  const url = new URLSearchParams();
597
597
  url.append("storyId", story.id);
598
598
  url.append("variantId", variant.id);
599
- return `${base}__sandbox?${url.toString()}`;
599
+ return `${base}__sandbox.html?${url.toString()}`;
600
600
  }
601
601
  const _hoisted_1$l = ["href"];
602
602
  const _sfc_main$n = /* @__PURE__ */ defineComponent({
@@ -5,13 +5,13 @@ function toRawDeep(val, seen = /* @__PURE__ */ new Set()) {
5
5
  if (typeof unwrappedValue === "symbol") {
6
6
  return unwrappedValue.toString();
7
7
  }
8
+ if (!isObject(unwrappedValue)) {
9
+ return unwrappedValue;
10
+ }
8
11
  if (seen.has(unwrappedValue)) {
9
12
  return Array.isArray(unwrappedValue) ? [] : {};
10
13
  }
11
14
  seen.add(unwrappedValue);
12
- if (!isObject(unwrappedValue)) {
13
- return unwrappedValue;
14
- }
15
15
  if (Array.isArray(unwrappedValue)) {
16
16
  return unwrappedValue.map((value) => toRawDeep(value, seen));
17
17
  }
@@ -1,9 +1,19 @@
1
1
  import { defineStore } from "pinia";
2
2
  import { ref, computed } from "vue";
3
- import { createRouter, createWebHistory } from "vue-router";
3
+ import { createWebHistory, createWebHashHistory, createRouter } from "vue-router";
4
+ import { h as histoireConfig } from "./config.js";
4
5
  const base = import.meta.env.BASE_URL;
6
+ function createRouterHistory() {
7
+ switch (histoireConfig.routerMode) {
8
+ case "hash":
9
+ return createWebHashHistory(base);
10
+ case "history":
11
+ default:
12
+ return createWebHistory(base);
13
+ }
14
+ }
5
15
  const router = createRouter({
6
- history: createWebHistory(base),
16
+ history: createRouterHistory(),
7
17
  routes: [
8
18
  {
9
19
  path: "/",
@@ -1,7 +1,16 @@
1
- import { createRouter, createWebHistory } from 'vue-router';
1
+ import { createRouter, createWebHistory, createWebHashHistory } from 'vue-router';
2
+ import { histoireConfig } from './util/config';
2
3
  export const base = import.meta.env.BASE_URL;
4
+ function createRouterHistory() {
5
+ switch (histoireConfig.routerMode) {
6
+ case 'hash': return createWebHashHistory(base);
7
+ case 'history':
8
+ default:
9
+ return createWebHistory(base);
10
+ }
11
+ }
3
12
  export const router = createRouter({
4
- history: createWebHistory(base),
13
+ history: createRouterHistory(),
5
14
  routes: [
6
15
  {
7
16
  path: '/',
@@ -3,5 +3,5 @@ export function getSandboxUrl(story, variant) {
3
3
  const url = new URLSearchParams();
4
4
  url.append('storyId', story.id);
5
5
  url.append('variantId', variant.id);
6
- return `${base}__sandbox?${url.toString()}`;
6
+ return `${base}__sandbox.html?${url.toString()}`;
7
7
  }
@@ -5,13 +5,13 @@ export function toRawDeep(val, seen = new Set()) {
5
5
  if (typeof unwrappedValue === 'symbol') {
6
6
  return unwrappedValue.toString();
7
7
  }
8
+ if (!isObject(unwrappedValue)) {
9
+ return unwrappedValue;
10
+ }
8
11
  if (seen.has(unwrappedValue)) {
9
12
  return Array.isArray(unwrappedValue) ? [] : {};
10
13
  }
11
14
  seen.add(unwrappedValue);
12
- if (!isObject(unwrappedValue)) {
13
- return unwrappedValue;
14
- }
15
15
  if (Array.isArray(unwrappedValue)) {
16
16
  return unwrappedValue.map(value => toRawDeep(value, seen));
17
17
  }
@@ -130,7 +130,7 @@ export async function build(ctx) {
130
130
  const query = new URLSearchParams();
131
131
  query.append('storyId', story.id);
132
132
  query.append('variantId', variant.id);
133
- const url = `${baseUrl}__sandbox?${query.toString()}`;
133
+ const url = `${baseUrl}__sandbox.html?${query.toString()}`;
134
134
  for (const fn of previewStoryCallbacks) {
135
135
  await fn({
136
136
  file: storyFile.path,
@@ -126,6 +126,12 @@ export interface HistoireConfig {
126
126
  * Customize the markdown-it renderer
127
127
  */
128
128
  markdown?: (md: MarkdownIt) => MarkdownIt | Promise<MarkdownIt>;
129
+ /**
130
+ * Change the router mode.
131
+ * - history: use HTML history with cleaner URLs
132
+ * - hash: use hashtag hack in the URL to support more hosting services
133
+ */
134
+ routerMode?: 'history' | 'hash';
129
135
  /**
130
136
  * Vite config override
131
137
  */
@@ -94,6 +94,12 @@ export function getDefaultConfig() {
94
94
  },
95
95
  ],
96
96
  sandboxDarkClass: 'dark',
97
+ routerMode: 'history',
98
+ vite: {
99
+ build: {
100
+ lib: false,
101
+ },
102
+ },
97
103
  };
98
104
  }
99
105
  export const configFileNames = [
package/dist/node/vite.js CHANGED
@@ -54,6 +54,11 @@ export async function getViteConfigWithPlugins(server, ctx) {
54
54
  name: 'histoire-vite-plugin',
55
55
  config() {
56
56
  return {
57
+ resolve: {
58
+ dedupe: [
59
+ 'vue',
60
+ ],
61
+ },
57
62
  optimizeDeps: {
58
63
  disabled: server,
59
64
  entries: [
@@ -71,6 +76,7 @@ export async function getViteConfigWithPlugins(server, ctx) {
71
76
  ],
72
77
  exclude: [
73
78
  'histoire',
79
+ '@histoire',
74
80
  ],
75
81
  },
76
82
  server: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "histoire",
3
- "version": "0.7.4",
3
+ "version": "0.7.7",
4
4
  "description": "A fast story book powered by Vite",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -33,9 +33,9 @@
33
33
  "histoire": "./bin.mjs"
34
34
  },
35
35
  "dependencies": {
36
- "@histoire/controls": "^0.7.4",
37
- "@histoire/plugin-vue": "^0.7.4",
38
- "@histoire/shared": "^0.7.4",
36
+ "@histoire/controls": "^0.7.7",
37
+ "@histoire/plugin-vue": "^0.7.7",
38
+ "@histoire/shared": "^0.7.7",
39
39
  "@iconify/vue": "^3.2.1",
40
40
  "@types/markdown-it": "^12.2.3",
41
41
  "@vueuse/core": "^8.2.5",
@@ -1,9 +1,19 @@
1
- import { createRouter, createWebHistory } from 'vue-router'
1
+ import { createRouter, createWebHistory, createWebHashHistory } from 'vue-router'
2
+ import { histoireConfig } from './util/config'
2
3
 
3
4
  export const base = import.meta.env.BASE_URL as string
4
5
 
6
+ function createRouterHistory () {
7
+ switch (histoireConfig.routerMode) {
8
+ case 'hash': return createWebHashHistory(base)
9
+ case 'history':
10
+ default:
11
+ return createWebHistory(base)
12
+ }
13
+ }
14
+
5
15
  export const router = createRouter({
6
- history: createWebHistory(base),
16
+ history: createRouterHistory(),
7
17
  routes: [
8
18
  {
9
19
  path: '/',
@@ -6,5 +6,5 @@ export function getSandboxUrl (story: Story, variant: Variant) {
6
6
  const url = new URLSearchParams()
7
7
  url.append('storyId', story.id)
8
8
  url.append('variantId', variant.id)
9
- return `${base}__sandbox?${url.toString()}`
9
+ return `${base}__sandbox.html?${url.toString()}`
10
10
  }
@@ -9,16 +9,16 @@ export function toRawDeep (val, seen = new Set()) {
9
9
  return unwrappedValue.toString()
10
10
  }
11
11
 
12
+ if (!isObject(unwrappedValue)) {
13
+ return unwrappedValue
14
+ }
15
+
12
16
  if (seen.has(unwrappedValue)) {
13
17
  return Array.isArray(unwrappedValue) ? [] : {}
14
18
  }
15
19
 
16
20
  seen.add(unwrappedValue)
17
21
 
18
- if (!isObject(unwrappedValue)) {
19
- return unwrappedValue
20
- }
21
-
22
22
  if (Array.isArray(unwrappedValue)) {
23
23
  return unwrappedValue.map(value => toRawDeep(value, seen))
24
24
  }
package/src/node/build.ts CHANGED
@@ -155,7 +155,7 @@ export async function build (ctx: Context) {
155
155
  const query = new URLSearchParams()
156
156
  query.append('storyId', story.id)
157
157
  query.append('variantId', variant.id)
158
- const url = `${baseUrl}__sandbox?${query.toString()}`
158
+ const url = `${baseUrl}__sandbox.html?${query.toString()}`
159
159
  for (const fn of previewStoryCallbacks) {
160
160
  await fn({
161
161
  file: storyFile.path,
@@ -145,6 +145,12 @@ export interface HistoireConfig {
145
145
  * Customize the markdown-it renderer
146
146
  */
147
147
  markdown?: (md: MarkdownIt) => MarkdownIt | Promise<MarkdownIt>
148
+ /**
149
+ * Change the router mode.
150
+ * - history: use HTML history with cleaner URLs
151
+ * - hash: use hashtag hack in the URL to support more hosting services
152
+ */
153
+ routerMode?: 'history' | 'hash'
148
154
  /**
149
155
  * Vite config override
150
156
  */
@@ -264,6 +270,12 @@ export function getDefaultConfig (): HistoireConfig {
264
270
  },
265
271
  ],
266
272
  sandboxDarkClass: 'dark',
273
+ routerMode: 'history',
274
+ vite: {
275
+ build: {
276
+ lib: false,
277
+ },
278
+ },
267
279
  }
268
280
  }
269
281
 
package/src/node/vite.ts CHANGED
@@ -70,6 +70,11 @@ export async function getViteConfigWithPlugins (server: boolean, ctx: Context):
70
70
 
71
71
  config () {
72
72
  return {
73
+ resolve: {
74
+ dedupe: [
75
+ 'vue',
76
+ ],
77
+ },
73
78
  optimizeDeps: {
74
79
  disabled: server,
75
80
  entries: [
@@ -87,6 +92,7 @@ export async function getViteConfigWithPlugins (server: boolean, ctx: Context):
87
92
  ],
88
93
  exclude: [
89
94
  'histoire',
95
+ '@histoire',
90
96
  ],
91
97
  },
92
98
  server: {