histoire 0.3.3 → 0.4.0

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.
Files changed (94) hide show
  1. package/dist/bundled/BaseEmpty.js +13 -0
  2. package/dist/bundled/HomeView.js +23 -0
  3. package/dist/bundled/MobileOverlay.js +303 -0
  4. package/dist/bundled/SearchPane.js +504 -0
  5. package/dist/bundled/StoryView.js +2330 -0
  6. package/dist/bundled/api.js +32 -0
  7. package/dist/bundled/config.js +4 -0
  8. package/dist/bundled/const.js +5 -0
  9. package/dist/bundled/dark.js +4 -0
  10. package/dist/bundled/events.js +29 -0
  11. package/dist/bundled/global-components.js +203 -0
  12. package/dist/bundled/index.js +7 -0
  13. package/dist/bundled/index2.js +762 -0
  14. package/dist/bundled/reactivity.js +96 -0
  15. package/dist/bundled/sandbox.js +97 -0
  16. package/dist/bundled/search-docs-data.js +7 -0
  17. package/dist/bundled/story.js +59 -0
  18. package/dist/bundled/style.css +102 -0
  19. package/dist/client/app/App.vue +2 -2
  20. package/dist/client/app/api.d.ts +1 -0
  21. package/dist/client/app/api.js +1 -0
  22. package/dist/client/app/codegen/vue3.js +1 -2
  23. package/dist/client/app/components/HomeView.vue +1 -1
  24. package/dist/client/app/components/app/AppLogo.vue +1 -1
  25. package/dist/client/app/components/app/MobileOverlay.vue +0 -1
  26. package/dist/client/app/components/base/BaseOverflowMenu.vue +1 -1
  27. package/dist/client/app/components/exposed/Story.vue +1 -1
  28. package/dist/client/app/components/search/SearchItem.vue +1 -1
  29. package/dist/client/app/components/search/SearchPane.vue +96 -21
  30. package/dist/client/app/components/search/search-docs-data.d.ts +3 -0
  31. package/dist/client/app/components/search/{search-data.js → search-docs-data.js} +1 -1
  32. package/dist/client/app/components/search/search-title-data.d.ts +3 -0
  33. package/dist/client/app/components/search/search-title-data.js +7 -0
  34. package/dist/client/app/components/search/{search-data.d.ts → types.d.ts} +0 -2
  35. package/dist/client/app/components/search/types.js +1 -0
  36. package/dist/client/app/components/story/StoryVariantGridItem.vue +1 -1
  37. package/dist/client/app/components/story/StoryVariantListItem.vue +1 -1
  38. package/dist/client/app/components/story/StoryVariantSinglePreviewNative.vue +6 -3
  39. package/dist/client/app/components/tree/StoryListItem.vue +1 -1
  40. package/dist/client/app/index.d.ts +1 -1
  41. package/dist/client/app/index.js +21 -18
  42. package/dist/client/app/sandbox.d.ts +1 -1
  43. package/dist/client/app/sandbox.js +0 -1
  44. package/dist/client/app/util/events.d.ts +1 -1
  45. package/dist/client/app/util/events.js +2 -2
  46. package/dist/client/bundle-index.js +5 -0
  47. package/dist/client/bundle-main.js +5 -0
  48. package/dist/client/bundle-sandbox.js +3 -0
  49. package/dist/client/index.d.ts +1 -1
  50. package/dist/client/index.js +1 -1
  51. package/dist/client/server/vue3/run.js +8 -0
  52. package/dist/node/alias.js +1 -1
  53. package/dist/node/build.js +4 -4
  54. package/dist/node/builtin-plugins/tailwind-tokens.js +1 -1
  55. package/dist/node/search.d.ts +9 -1
  56. package/dist/node/search.js +69 -32
  57. package/dist/node/server.js +2 -2
  58. package/dist/node/types.d.ts +1 -0
  59. package/dist/node/vite.d.ts +4 -2
  60. package/dist/node/vite.js +22 -29
  61. package/package.json +9 -9
  62. package/src/client/app/App.vue +2 -2
  63. package/src/client/app/api.ts +1 -0
  64. package/src/client/app/codegen/vue3.ts +1 -2
  65. package/src/client/app/components/HomeView.vue +1 -1
  66. package/src/client/app/components/app/AppLogo.vue +1 -1
  67. package/src/client/app/components/app/MobileOverlay.vue +0 -1
  68. package/src/client/app/components/base/BaseOverflowMenu.vue +1 -1
  69. package/src/client/app/components/exposed/Story.vue +1 -1
  70. package/src/client/app/components/search/SearchItem.vue +1 -1
  71. package/src/client/app/components/search/SearchPane.vue +96 -21
  72. package/src/client/app/components/search/{search-data.ts → search-docs-data.ts} +2 -6
  73. package/src/client/app/components/search/search-title-data.ts +10 -0
  74. package/src/client/app/components/search/types.ts +4 -0
  75. package/src/client/app/components/story/StoryVariantGridItem.vue +1 -1
  76. package/src/client/app/components/story/StoryVariantListItem.vue +1 -1
  77. package/src/client/app/components/story/StoryVariantSinglePreviewNative.vue +6 -3
  78. package/src/client/app/components/tree/StoryListItem.vue +1 -1
  79. package/src/client/app/index.ts +23 -19
  80. package/src/client/app/sandbox.ts +0 -1
  81. package/src/client/app/util/events.ts +2 -2
  82. package/src/client/bundle-index.js +5 -0
  83. package/src/client/bundle-main.js +5 -0
  84. package/src/client/bundle-sandbox.js +3 -0
  85. package/src/client/index.ts +1 -1
  86. package/src/client/server/vue3/run.ts +11 -0
  87. package/src/node/alias.ts +1 -1
  88. package/src/node/build.ts +4 -4
  89. package/src/node/builtin-plugins/tailwind-tokens.ts +1 -1
  90. package/src/node/search.ts +77 -33
  91. package/src/node/server.ts +2 -2
  92. package/src/node/types.ts +1 -0
  93. package/src/node/vite.ts +22 -30
  94. package/vite.config.ts +46 -0
@@ -1,6 +1,6 @@
1
1
  import { createServer as createViteServer } from 'vite'
2
2
  import { Context } from './context.js'
3
- import { createVitePlugins, RESOLVED_SEARCH_DATA_ID, RESOLVED_STORIES_ID } from './vite.js'
3
+ import { createVitePlugins, RESOLVED_SEARCH_TITLE_DATA_ID, RESOLVED_STORIES_ID } from './vite.js'
4
4
  import { notifyStoryChange, onStoryChange, watchStories } from './stories.js'
5
5
  import { useCollectStories } from './collect/index.js'
6
6
  import type { StoryFile } from './types.js'
@@ -112,7 +112,7 @@ export async function createServer (ctx: Context, port: number) {
112
112
  }
113
113
 
114
114
  invalidateModule(RESOLVED_STORIES_ID)
115
- invalidateModule(RESOLVED_SEARCH_DATA_ID)
115
+ invalidateModule(RESOLVED_SEARCH_TITLE_DATA_ID)
116
116
  })
117
117
 
118
118
  async function close () {
package/src/node/types.ts CHANGED
@@ -42,6 +42,7 @@ export interface Story {
42
42
  icon?: string
43
43
  iconColor?: string
44
44
  docsOnly?: boolean
45
+ docsText?: string
45
46
  }
46
47
 
47
48
  export interface Variant {
package/src/node/vite.ts CHANGED
@@ -8,7 +8,7 @@ import { notifyStoryChange } from './stories.js'
8
8
  import { makeTree } from './tree.js'
9
9
  import { parseColor } from './colors.js'
10
10
  import { createMarkdownRenderer } from './markdown.js'
11
- import { generateSearchData } from './search.js'
11
+ import { getSearchDataJS, generateDocSearchData, generateTitleSearchData } from './search.js'
12
12
 
13
13
  const require = createRequire(import.meta.url)
14
14
 
@@ -20,19 +20,16 @@ export const CONFIG_ID = '$histoire-config'
20
20
  export const RESOLVED_CONFIG_ID = `/${CONFIG_ID}-resolved`
21
21
  export const THEME_ID = '$histoire-theme'
22
22
  export const RESOLVED_THEME_ID = `/${THEME_ID}-resolved.css`
23
- export const SEARCH_DATA_ID = '$histoire-search-data'
24
- export const RESOLVED_SEARCH_DATA_ID = `/${SEARCH_DATA_ID}-resolved`
23
+ export const SEARCH_TITLE_DATA_ID = '$histoire-search-title-data'
24
+ export const RESOLVED_SEARCH_TITLE_DATA_ID = `/${SEARCH_TITLE_DATA_ID}-resolved`
25
+ export const SEARCH_DOCS_DATA_ID = '$histoire-search-docs-data'
26
+ export const RESOLVED_SEARCH_DOCS_DATA_ID = `/${SEARCH_DOCS_DATA_ID}-resolved`
25
27
 
26
28
  export async function createVitePlugins (ctx: Context): Promise<VitePlugin[]> {
27
29
  const viteConfig = await resolveViteConfig({}, ctx.mode === 'dev' ? 'serve' : 'build')
28
- const hasVuePlugin = viteConfig.plugins.find(p => p.name === 'vite:vue')
29
30
 
30
31
  const plugins: VitePlugin[] = []
31
32
 
32
- if (!hasVuePlugin) {
33
- plugins.push((await import('@vitejs/plugin-vue')).default())
34
- }
35
-
36
33
  if (ctx.config.vite) {
37
34
  plugins.push({
38
35
  name: 'histoire-vite-config-override',
@@ -51,14 +48,13 @@ export async function createVitePlugins (ctx: Context): Promise<VitePlugin[]> {
51
48
  // force include vue to avoid duplicated copies when linked + optimized
52
49
  include: [
53
50
  'vue',
54
- dirname(require.resolve('@vue/runtime-core/package.json')),
55
51
  dirname(require.resolve('shiki/package.json')),
56
52
  dirname(require.resolve('vscode-textmate/package.json')),
57
53
  dirname(require.resolve('vscode-oniguruma/package.json')),
58
54
  dirname(require.resolve('case/package.json')),
59
55
  ],
60
56
  exclude: [
61
- 'histoire/client',
57
+ 'histoire',
62
58
  ],
63
59
  },
64
60
  server: {
@@ -92,8 +88,11 @@ export async function createVitePlugins (ctx: Context): Promise<VitePlugin[]> {
92
88
  if (id.startsWith(THEME_ID)) {
93
89
  return RESOLVED_THEME_ID
94
90
  }
95
- if (id.startsWith(SEARCH_DATA_ID)) {
96
- return RESOLVED_SEARCH_DATA_ID
91
+ if (id.startsWith(SEARCH_TITLE_DATA_ID)) {
92
+ return RESOLVED_SEARCH_TITLE_DATA_ID
93
+ }
94
+ if (id.startsWith(SEARCH_DOCS_DATA_ID)) {
95
+ return RESOLVED_SEARCH_DOCS_DATA_ID
97
96
  }
98
97
  },
99
98
 
@@ -104,7 +103,10 @@ export async function createVitePlugins (ctx: Context): Promise<VitePlugin[]> {
104
103
  return {
105
104
  id: file.id,
106
105
  path: file.treePath,
107
- story: file.story,
106
+ story: {
107
+ ...file.story,
108
+ docsText: undefined,
109
+ },
108
110
  framework: 'vue3',
109
111
  index,
110
112
  }
@@ -152,21 +154,11 @@ if (import.meta.hot) {
152
154
  css += '}'
153
155
  return css
154
156
  }
155
- if (id === RESOLVED_SEARCH_DATA_ID) {
156
- return `export let searchData = ${JSON.stringify(await generateSearchData(ctx))}
157
- const handlers = []
158
- export function onUpdate (cb) {
159
- handlers.push(cb)
160
- }
161
- if (import.meta.hot) {
162
- import.meta.hot.accept(newModule => {
163
- searchData = newModule.searchData
164
- handlers.forEach(h => {
165
- h(newModule.searchData)
166
- newModule.onUpdate(h)
167
- })
168
- })
169
- }`
157
+ if (id === RESOLVED_SEARCH_TITLE_DATA_ID) {
158
+ return getSearchDataJS(await generateTitleSearchData(ctx))
159
+ }
160
+ if (id === RESOLVED_SEARCH_DOCS_DATA_ID) {
161
+ return getSearchDataJS(await generateDocSearchData(ctx))
170
162
  }
171
163
  },
172
164
 
@@ -201,7 +193,7 @@ if (import.meta.hot) {
201
193
  }
202
194
  }
203
195
  </script>
204
- <script type="module" src="/@fs/${APP_PATH}/sandbox.js"></script>
196
+ <script type="module" src="/@fs/${APP_PATH}/bundle-sandbox.js"></script>
205
197
  </body>
206
198
  </html>`
207
199
  // Apply Vite HTML transforms. This injects the Vite HMR client, and
@@ -232,7 +224,7 @@ if (import.meta.hot) {
232
224
  </head>
233
225
  <body>
234
226
  <div id="app"></div>
235
- <script type="module" src="/@fs/${APP_PATH}/index.js"></script>
227
+ <script type="module" src="/@fs/${APP_PATH}/bundle-main.js"></script>
236
228
  </body>
237
229
  </html>`
238
230
  // Apply Vite HTML transforms. This injects the Vite HMR client, and
package/vite.config.ts ADDED
@@ -0,0 +1,46 @@
1
+ import { defineConfig } from 'vite'
2
+ import vue from '@vitejs/plugin-vue'
3
+
4
+ export default defineConfig({
5
+ plugins: [
6
+ vue(),
7
+ ],
8
+
9
+ build: {
10
+ emptyOutDir: false,
11
+ outDir: 'dist/bundled',
12
+ lib: {
13
+ entry: '',
14
+ formats: ['es'],
15
+ },
16
+ rollupOptions: {
17
+ external: [
18
+ /\$histoire/,
19
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
20
+ ...Object.keys(require('./package.json').dependencies),
21
+ ],
22
+
23
+ input: [
24
+ 'src/client/app/api.ts',
25
+ 'src/client/app/index.ts',
26
+ 'src/client/app/sandbox.ts',
27
+ ],
28
+
29
+ output: {
30
+ // manualChunks (id) {
31
+ // if (id.includes('node_modules')) {
32
+ // return 'vendor'
33
+ // }
34
+ // },
35
+ entryFileNames: '[name].js',
36
+ chunkFileNames: '[name].js',
37
+ assetFileNames: '[name][extname]',
38
+ hoistTransitiveImports: false,
39
+ },
40
+ treeshake: false,
41
+ preserveEntrySignatures: 'strict',
42
+ },
43
+ cssCodeSplit: false,
44
+ minify: false,
45
+ },
46
+ })