histoire 0.0.0 → 0.0.1

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 (208) hide show
  1. package/LICENSE +21 -0
  2. package/client.d.ts +2 -0
  3. package/dist/client/app/App.vue +84 -21
  4. package/dist/client/app/assets/histoire-text-dark.svg +89 -0
  5. package/dist/client/app/assets/histoire-text.svg +89 -0
  6. package/dist/client/app/assets/histoire.svg +51 -0
  7. package/dist/client/app/codegen/serialize-js.d.ts +1 -0
  8. package/dist/client/app/codegen/serialize-js.js +114 -0
  9. package/dist/client/app/codegen/serialize-js.js.map +1 -0
  10. package/dist/client/app/codegen/serialize-js.ts +119 -0
  11. package/dist/client/app/codegen/util.d.ts +10 -0
  12. package/dist/client/app/codegen/util.js +71 -0
  13. package/dist/client/app/codegen/util.js.map +1 -0
  14. package/dist/client/app/codegen/util.ts +79 -0
  15. package/dist/client/app/codegen/vue3.d.ts +2 -0
  16. package/dist/client/app/codegen/vue3.js +239 -0
  17. package/dist/client/app/codegen/vue3.js.map +1 -0
  18. package/dist/client/app/codegen/vue3.ts +240 -0
  19. package/dist/client/app/components/HomeView.vue +15 -1
  20. package/dist/client/app/components/StoryControls.vue +7 -2
  21. package/dist/client/app/components/StoryList.vue +20 -13
  22. package/dist/client/app/components/StoryListFolder.vue +80 -0
  23. package/dist/client/app/components/StoryListItem.vue +38 -12
  24. package/dist/client/app/components/StorySourceCode.vue +121 -0
  25. package/dist/client/app/components/StoryVariantGridItem.vue +32 -17
  26. package/dist/client/app/components/StoryVariantListItem.vue +46 -0
  27. package/dist/client/app/components/StoryVariantSingleView.vue +117 -15
  28. package/dist/client/app/components/StoryView.vue +88 -54
  29. package/dist/client/app/components/app/AppHeader.vue +56 -0
  30. package/dist/client/app/components/app/AppLogo.vue +24 -0
  31. package/dist/client/app/components/base/BaseEmpty.vue +1 -1
  32. package/dist/client/app/components/base/BaseListItemLink.vue +55 -0
  33. package/dist/client/app/components/base/BaseSplitPane.vue +57 -21
  34. package/dist/client/app/components/exposed/Story.vue +23 -58
  35. package/dist/client/app/components/exposed/Variant.vue +24 -47
  36. package/dist/client/app/components/misc/HatchedPattern.vue +25 -0
  37. package/dist/client/app/components/{SandboxVue.vue → sandbox/SandboxVue3.vue} +31 -12
  38. package/dist/client/app/components/search/SearchItem.vue +110 -0
  39. package/dist/client/app/components/search/SearchModal.vue +179 -0
  40. package/dist/client/app/composable/variant.ts +20 -0
  41. package/dist/client/app/global-components.ts +10 -0
  42. package/dist/client/app/index.d.ts +1 -0
  43. package/dist/client/app/index.js +4 -1
  44. package/dist/client/app/index.js.map +1 -1
  45. package/dist/client/app/index.ts +18 -0
  46. package/dist/client/app/router.ts +17 -0
  47. package/dist/client/app/sandbox.d.ts +1 -0
  48. package/dist/client/app/sandbox.js +54 -0
  49. package/dist/client/app/sandbox.js.map +1 -0
  50. package/dist/client/app/sandbox.ts +60 -0
  51. package/dist/client/app/stores/story.d.ts +161 -50
  52. package/dist/client/app/stores/story.js +5 -16
  53. package/dist/client/app/stores/story.js.map +1 -1
  54. package/dist/client/app/stores/story.ts +22 -0
  55. package/dist/client/app/style/main.css +16 -2
  56. package/dist/client/app/style/sandbox.css +14 -0
  57. package/dist/client/app/types.d.ts +36 -4
  58. package/dist/client/app/types.ts +45 -0
  59. package/dist/client/app/util/config.d.ts +3 -0
  60. package/dist/client/app/util/config.js +5 -0
  61. package/dist/client/app/util/config.js.map +1 -0
  62. package/dist/client/app/util/config.ts +6 -0
  63. package/dist/client/app/util/const.d.ts +1 -0
  64. package/dist/client/app/util/const.js +2 -0
  65. package/dist/client/app/util/const.js.map +1 -0
  66. package/dist/client/app/util/const.ts +1 -0
  67. package/dist/client/app/util/dark.d.ts +2 -0
  68. package/dist/client/app/util/dark.js +4 -0
  69. package/dist/client/app/util/dark.js.map +1 -0
  70. package/dist/client/app/util/dark.ts +4 -0
  71. package/dist/client/app/util/env.d.ts +1 -0
  72. package/dist/client/app/util/env.js +2 -0
  73. package/dist/client/app/util/env.js.map +1 -0
  74. package/dist/client/app/util/keyboard.d.ts +8 -0
  75. package/dist/client/app/util/keyboard.js +83 -0
  76. package/dist/client/app/util/keyboard.js.map +1 -0
  77. package/dist/client/app/util/mapping.d.ts +3 -0
  78. package/dist/client/app/util/mapping.js +37 -0
  79. package/dist/client/app/util/mapping.js.map +1 -0
  80. package/dist/client/app/util/mapping.ts +38 -0
  81. package/dist/client/app/util/tooltip.d.ts +6 -0
  82. package/dist/client/app/util/tooltip.js +12 -0
  83. package/dist/client/app/util/tooltip.js.map +1 -0
  84. package/dist/client/index.d.ts +8 -0
  85. package/dist/client/index.js +4 -0
  86. package/dist/client/index.js.map +1 -0
  87. package/dist/client/index.ts +12 -0
  88. package/dist/client/server/Story.server.vue +65 -0
  89. package/dist/client/server/Variant.server.vue +50 -0
  90. package/dist/client/server/index.d.ts +2 -0
  91. package/dist/client/server/index.js +26 -0
  92. package/dist/client/server/index.js.map +1 -0
  93. package/dist/client/server/index.ts +29 -0
  94. package/dist/client/shim.d.ts +5 -0
  95. package/dist/node/bin.js +8 -2
  96. package/dist/node/bin.js.map +1 -1
  97. package/dist/node/build.d.ts +2 -0
  98. package/dist/node/build.js +72 -0
  99. package/dist/node/build.js.map +1 -0
  100. package/dist/node/collect.d.ts +12 -0
  101. package/dist/node/collect.js +66 -0
  102. package/dist/node/collect.js.map +1 -0
  103. package/dist/node/colors.d.ts +274 -0
  104. package/dist/node/colors.js +313 -0
  105. package/dist/node/colors.js.map +1 -0
  106. package/dist/node/commands/build.d.ts +1 -0
  107. package/dist/node/commands/build.js +11 -0
  108. package/dist/node/commands/build.js.map +1 -0
  109. package/dist/node/commands/dev.d.ts +1 -1
  110. package/dist/node/commands/dev.js +6 -11
  111. package/dist/node/commands/dev.js.map +1 -1
  112. package/dist/node/config.d.ts +99 -1
  113. package/dist/node/config.js +90 -1
  114. package/dist/node/config.js.map +1 -1
  115. package/dist/node/context.d.ts +13 -0
  116. package/dist/node/context.js +12 -1
  117. package/dist/node/context.js.map +1 -1
  118. package/dist/node/dom/dom-keys.d.ts +4 -0
  119. package/dist/node/dom/dom-keys.js +224 -0
  120. package/dist/node/dom/dom-keys.js.map +1 -0
  121. package/dist/node/dom/env.d.ts +5 -0
  122. package/dist/node/dom/env.js +23 -0
  123. package/dist/node/dom/env.js.map +1 -0
  124. package/dist/node/index.d.ts +2 -0
  125. package/dist/node/index.js +2 -1
  126. package/dist/node/index.js.map +1 -1
  127. package/dist/node/plugin.d.ts +8 -2
  128. package/dist/node/plugin.js +142 -21
  129. package/dist/node/plugin.js.map +1 -1
  130. package/dist/node/server.d.ts +4 -1
  131. package/dist/node/server.js +80 -20
  132. package/dist/node/server.js.map +1 -1
  133. package/dist/node/stories.d.ts +8 -9
  134. package/dist/node/stories.js +42 -22
  135. package/dist/node/stories.js.map +1 -1
  136. package/dist/node/tree.d.ts +19 -0
  137. package/dist/node/tree.js +55 -0
  138. package/dist/node/tree.js.map +1 -0
  139. package/dist/node/types.d.ts +38 -0
  140. package/dist/node/types.js +2 -0
  141. package/dist/node/types.js.map +1 -0
  142. package/dist/style.css +558 -52
  143. package/package.json +42 -25
  144. package/scripts/copy.mjs +11 -0
  145. package/src/client/app/App.vue +84 -21
  146. package/src/client/app/assets/histoire-text-dark.svg +89 -0
  147. package/src/client/app/assets/histoire-text.svg +89 -0
  148. package/src/client/app/assets/histoire.svg +51 -0
  149. package/src/client/app/codegen/serialize-js.ts +119 -0
  150. package/src/client/app/codegen/util.ts +79 -0
  151. package/src/client/app/codegen/vue3.ts +240 -0
  152. package/src/client/app/components/HomeView.vue +15 -1
  153. package/src/client/app/components/StoryControls.vue +7 -2
  154. package/src/client/app/components/StoryList.vue +20 -13
  155. package/src/client/app/components/StoryListFolder.vue +80 -0
  156. package/src/client/app/components/StoryListItem.vue +38 -12
  157. package/src/client/app/components/StorySourceCode.vue +121 -0
  158. package/src/client/app/components/StoryVariantGridItem.vue +32 -17
  159. package/src/client/app/components/StoryVariantListItem.vue +46 -0
  160. package/src/client/app/components/StoryVariantSingleView.vue +117 -15
  161. package/src/client/app/components/StoryView.vue +88 -54
  162. package/src/client/app/components/app/AppHeader.vue +56 -0
  163. package/src/client/app/components/app/AppLogo.vue +24 -0
  164. package/src/client/app/components/base/BaseEmpty.vue +1 -1
  165. package/src/client/app/components/base/BaseListItemLink.vue +55 -0
  166. package/src/client/app/components/base/BaseSplitPane.vue +57 -21
  167. package/src/client/app/components/exposed/Story.vue +23 -58
  168. package/src/client/app/components/exposed/Variant.vue +24 -47
  169. package/src/client/app/components/misc/HatchedPattern.vue +25 -0
  170. package/src/client/app/components/{SandboxVue.vue → sandbox/SandboxVue3.vue} +31 -12
  171. package/src/client/app/components/search/SearchItem.vue +110 -0
  172. package/src/client/app/components/search/SearchModal.vue +179 -0
  173. package/src/client/app/index.ts +4 -1
  174. package/src/client/app/sandbox.ts +60 -0
  175. package/src/client/app/stores/story.ts +6 -18
  176. package/src/client/app/style/main.css +16 -2
  177. package/src/client/app/style/sandbox.css +14 -0
  178. package/src/client/app/types.ts +42 -4
  179. package/src/client/app/util/config.ts +6 -0
  180. package/src/client/app/util/const.ts +1 -0
  181. package/src/client/app/util/dark.ts +4 -0
  182. package/src/client/app/util/env.ts +1 -0
  183. package/src/client/app/util/keyboard.ts +99 -0
  184. package/src/client/app/util/mapping.ts +38 -0
  185. package/src/client/app/util/tooltip.ts +13 -0
  186. package/src/client/index.ts +12 -0
  187. package/src/client/server/Story.server.vue +65 -0
  188. package/src/client/server/Variant.server.vue +50 -0
  189. package/src/client/server/index.ts +29 -0
  190. package/src/node/bin.ts +9 -2
  191. package/src/node/build.ts +80 -0
  192. package/src/node/collect.ts +78 -0
  193. package/src/node/colors.ts +328 -0
  194. package/src/node/commands/build.ts +12 -0
  195. package/src/node/commands/dev.ts +6 -13
  196. package/src/node/config.ts +193 -1
  197. package/src/node/context.ts +21 -1
  198. package/src/node/dom/dom-keys.ts +227 -0
  199. package/src/node/dom/env.ts +26 -0
  200. package/src/node/index.ts +2 -0
  201. package/src/node/plugin.ts +146 -22
  202. package/src/node/server.ts +95 -20
  203. package/src/node/stories.ts +53 -31
  204. package/src/node/tree.ts +88 -0
  205. package/src/node/types.ts +40 -0
  206. package/tailwind.config.cjs +41 -1
  207. package/dist/client/app/components/StoryVariantItem.vue +0 -29
  208. package/src/client/app/components/StoryVariantItem.vue +0 -29
@@ -0,0 +1,29 @@
1
+ import { createApp, h } from 'vue'
2
+ import type { StoryFile } from '../../node/types'
3
+ import Story from './Story.server.vue'
4
+ import Variant from './Variant.server.vue'
5
+
6
+ export async function run (file: StoryFile, storyData, el) {
7
+ const { default: Comp } = await import(file.moduleId)
8
+ const app = createApp({
9
+ provide: {
10
+ addStory (data) {
11
+ storyData.push(data)
12
+ },
13
+ },
14
+ render () {
15
+ return h(Comp, {
16
+ ref: 'comp',
17
+ data: file,
18
+ })
19
+ },
20
+ })
21
+
22
+ // eslint-disable-next-line vue/multi-word-component-names
23
+ app.component('Story', Story)
24
+ // eslint-disable-next-line vue/multi-word-component-names
25
+ app.component('Variant', Variant)
26
+
27
+ app.mount(el)
28
+ app.unmount()
29
+ }
package/src/node/bin.ts CHANGED
@@ -14,8 +14,15 @@ program.command('dev')
14
14
  .describe('open the stories in your browser for development')
15
15
  .option('-p, --port <port>', 'Listening port of the server')
16
16
  .action(async (options) => {
17
- const { dev } = await import('./commands/dev.js')
18
- return dev(options)
17
+ const { devCommand } = await import('./commands/dev.js')
18
+ return devCommand(options)
19
+ })
20
+
21
+ program.command('build')
22
+ .describe('build the histoire final app you can deploy')
23
+ .action(async () => {
24
+ const { buildCommand } = await import('./commands/build.js')
25
+ return buildCommand()
19
26
  })
20
27
 
21
28
  program.parse(process.argv)
@@ -0,0 +1,80 @@
1
+ import { join } from 'pathe'
2
+ import { build as viteBuild, createServer as createViteServer, resolveConfig as resolveViteConfig, Plugin as VitePlugin } from 'vite'
3
+ import fs from 'fs-extra'
4
+ import { lookup as lookupMime } from 'mrmime'
5
+ import { APP_PATH } from './alias.js'
6
+ import { Context } from './context.js'
7
+ import { createVitePlugins } from './plugin.js'
8
+ import { findAllStories } from './stories.js'
9
+ import type { RollupOutput } from 'rollup'
10
+ import { useCollectStories } from './collect.js'
11
+
12
+ export async function build (ctx: Context) {
13
+ await findAllStories(ctx)
14
+
15
+ // Collect story data
16
+ const viteConfig = await resolveViteConfig({}, ctx.mode === 'dev' ? 'serve' : 'build')
17
+ const plugins: VitePlugin[] = []
18
+ const hasVuePlugin = viteConfig.plugins.find(p => p.name === 'vite:vue')
19
+ if (!hasVuePlugin) {
20
+ plugins.push((await import('@vitejs/plugin-vue')).default())
21
+ }
22
+ const server = await createViteServer({
23
+ plugins,
24
+ })
25
+ await server.pluginContainer.buildStart({})
26
+ const { executeStoryFile, destroy: destroyCollectStories } = useCollectStories({
27
+ server,
28
+ throws: true,
29
+ }, ctx)
30
+ for (const storyFile of ctx.storyFiles) {
31
+ await executeStoryFile(storyFile)
32
+ }
33
+ await server.close()
34
+ await destroyCollectStories()
35
+
36
+ const results = await viteBuild({
37
+ plugins: await createVitePlugins(ctx),
38
+ build: {
39
+ rollupOptions: {
40
+ input: [
41
+ join(APP_PATH, 'index.ts'),
42
+ join(APP_PATH, 'sandbox.ts'),
43
+ ],
44
+ },
45
+ outDir: ctx.config.outDir,
46
+ emptyOutDir: true,
47
+ cssCodeSplit: false,
48
+ },
49
+ })
50
+ const result = Array.isArray(results) ? results[0] : results as RollupOutput
51
+
52
+ const styleOutput = result.output.find(o => o.name === 'style.css' && o.type === 'asset')
53
+
54
+ // Index
55
+ const indexOutput = result.output.find(o => o.name === 'index' && o.type === 'chunk')
56
+ await writeHtml(indexOutput.fileName, styleOutput.fileName, 'index.html', ctx)
57
+
58
+ // Sandbox
59
+ const sandboxOutput = result.output.find(o => o.name === 'sandbox' && o.type === 'chunk')
60
+ await writeHtml(sandboxOutput.fileName, styleOutput.fileName, '__sandbox.html', ctx)
61
+ }
62
+
63
+ async function writeHtml (jsEntryFile: string, cssEntryFile: string, htmlFileName: string, ctx: Context) {
64
+ const code = `<!DOCTYPE html>
65
+ <html>
66
+ <head>
67
+ <title>${ctx.config.theme.title}</title>
68
+ <meta charset="utf-8">
69
+ <meta name="viewport" content="width=device-width,initial-scale=1">
70
+ <meta name="description" content="">
71
+ <link rel="stylesheet" href="/${cssEntryFile}">
72
+ ${ctx.config.theme?.favicon ? `<link rel="icon" type="${lookupMime(ctx.config.theme.favicon)}" href="${ctx.config.theme.favicon}"/>` : ''}
73
+ </head>
74
+ <body>
75
+ <div id="app"></div>
76
+ <script type="module" src="/${jsEntryFile}"></script>
77
+ </body>
78
+ </html>`
79
+ await fs.writeFile(join(ctx.config.outDir, htmlFileName), code, 'utf8')
80
+ }
@@ -0,0 +1,78 @@
1
+ import { fileURLToPath } from 'url'
2
+ import type { ViteDevServer } from 'vite'
3
+ import { ViteNodeServer } from 'vite-node/server'
4
+ import { ViteNodeRunner } from 'vite-node/client'
5
+ import { dirname, resolve, relative } from 'pathe'
6
+ import pc from 'picocolors'
7
+ import type { StoryFile, Story } from './types.js'
8
+ import { createDomEnv } from './dom/env.js'
9
+ import { createPath, TreeFile } from './tree.js'
10
+ import type { Context } from './context.js'
11
+
12
+ const __dirname = dirname(fileURLToPath(import.meta.url))
13
+
14
+ export interface UseCollectStoriesOptions {
15
+ server: ViteDevServer
16
+ throws?: boolean
17
+ }
18
+
19
+ export function useCollectStories (options: UseCollectStoriesOptions, ctx: Context) {
20
+ const { server } = options
21
+ const { destroy: destroyDomEnv } = createDomEnv()
22
+
23
+ const node = new ViteNodeServer(server)
24
+ const runner = new ViteNodeRunner({
25
+ root: server.config.root,
26
+ base: server.config.base,
27
+ fetchModule (id) {
28
+ // Alias
29
+ if (id.endsWith('vue.runtime.esm-bundler.js')) {
30
+ id = 'vue'
31
+ }
32
+ return node.fetchModule(id)
33
+ },
34
+ })
35
+
36
+ function clearCache () {
37
+ node.fetchCache.clear()
38
+ runner.moduleCache.clear()
39
+ }
40
+
41
+ async function executeStoryFile (storyFile: StoryFile) {
42
+ try {
43
+ // Mount app to collect stories/variants
44
+ const el = window.document.createElement('div')
45
+ const { run } = await runner.executeFile(resolve(__dirname, '../client/server/index.js'))
46
+ const storyData: Story[] = []
47
+ await run(storyFile, storyData, el)
48
+ if (storyData.length === 0) {
49
+ console.warn(pc.yellow(`No story found for ${storyFile.path}`))
50
+ return
51
+ } else if (storyData.length > 1) {
52
+ console.warn(pc.yellow(`Multiple stories not supported: ${storyFile.path}`))
53
+ }
54
+ storyFile.story = storyData[0]
55
+ const file: TreeFile = {
56
+ title: storyData[0].title,
57
+ path: relative(server.config.root, storyFile.path),
58
+ }
59
+ storyFile.treePath = createPath(ctx.config, file)
60
+ storyFile.story.title = storyFile.treePath[storyFile.treePath.length - 1]
61
+ } catch (e) {
62
+ console.error(pc.red(`Error while collecting story ${storyFile.path}:\n${e.frame ? `${pc.bold(e.message)}\n${e.frame}` : e.stack}`))
63
+ if (options.throws) {
64
+ throw e
65
+ }
66
+ }
67
+ }
68
+
69
+ async function destroy () {
70
+ destroyDomEnv()
71
+ }
72
+
73
+ return {
74
+ clearCache,
75
+ executeStoryFile,
76
+ destroy,
77
+ }
78
+ }
@@ -0,0 +1,328 @@
1
+ export const defaultColors = {
2
+ slate: {
3
+ 50: '#f8fafc',
4
+ 100: '#f1f5f9',
5
+ 200: '#e2e8f0',
6
+ 300: '#cbd5e1',
7
+ 400: '#94a3b8',
8
+ 500: '#64748b',
9
+ 600: '#475569',
10
+ 700: '#334155',
11
+ 800: '#1e293b',
12
+ 900: '#0f172a',
13
+ },
14
+ gray: {
15
+ 50: '#f9fafb',
16
+ 100: '#f3f4f6',
17
+ 200: '#e5e7eb',
18
+ 300: '#d1d5db',
19
+ 400: '#9ca3af',
20
+ 500: '#6b7280',
21
+ 600: '#4b5563',
22
+ 700: '#374151',
23
+ 800: '#1f2937',
24
+ 900: '#111827',
25
+ },
26
+ zinc: {
27
+ 50: '#fafafa',
28
+ 100: '#f4f4f5',
29
+ 200: '#e4e4e7',
30
+ 300: '#d4d4d8',
31
+ 400: '#a1a1aa',
32
+ 500: '#71717a',
33
+ 600: '#52525b',
34
+ 700: '#3f3f46',
35
+ 750: '#323238',
36
+ 800: '#27272a',
37
+ 850: '#1f1f21',
38
+ 900: '#18181b',
39
+ 950: '#101012',
40
+ },
41
+ neutral: {
42
+ 50: '#fafafa',
43
+ 100: '#f5f5f5',
44
+ 200: '#e5e5e5',
45
+ 300: '#d4d4d4',
46
+ 400: '#a3a3a3',
47
+ 500: '#737373',
48
+ 600: '#525252',
49
+ 700: '#404040',
50
+ 800: '#262626',
51
+ 900: '#171717',
52
+ },
53
+ stone: {
54
+ 50: '#fafaf9',
55
+ 100: '#f5f5f4',
56
+ 200: '#e7e5e4',
57
+ 300: '#d6d3d1',
58
+ 400: '#a8a29e',
59
+ 500: '#78716c',
60
+ 600: '#57534e',
61
+ 700: '#44403c',
62
+ 800: '#292524',
63
+ 900: '#1c1917',
64
+ },
65
+ red: {
66
+ 50: '#fef2f2',
67
+ 100: '#fee2e2',
68
+ 200: '#fecaca',
69
+ 300: '#fca5a5',
70
+ 400: '#f87171',
71
+ 500: '#ef4444',
72
+ 600: '#dc2626',
73
+ 700: '#b91c1c',
74
+ 800: '#991b1b',
75
+ 900: '#7f1d1d',
76
+ },
77
+ orange: {
78
+ 50: '#fff7ed',
79
+ 100: '#ffedd5',
80
+ 200: '#fed7aa',
81
+ 300: '#fdba74',
82
+ 400: '#fb923c',
83
+ 500: '#f97316',
84
+ 600: '#ea580c',
85
+ 700: '#c2410c',
86
+ 800: '#9a3412',
87
+ 900: '#7c2d12',
88
+ },
89
+ amber: {
90
+ 50: '#fffbeb',
91
+ 100: '#fef3c7',
92
+ 200: '#fde68a',
93
+ 300: '#fcd34d',
94
+ 400: '#fbbf24',
95
+ 500: '#f59e0b',
96
+ 600: '#d97706',
97
+ 700: '#b45309',
98
+ 800: '#92400e',
99
+ 900: '#78350f',
100
+ },
101
+ yellow: {
102
+ 50: '#fefce8',
103
+ 100: '#fef9c3',
104
+ 200: '#fef08a',
105
+ 300: '#fde047',
106
+ 400: '#facc15',
107
+ 500: '#eab308',
108
+ 600: '#ca8a04',
109
+ 700: '#a16207',
110
+ 800: '#854d0e',
111
+ 900: '#713f12',
112
+ },
113
+ lime: {
114
+ 50: '#f7fee7',
115
+ 100: '#ecfccb',
116
+ 200: '#d9f99d',
117
+ 300: '#bef264',
118
+ 400: '#a3e635',
119
+ 500: '#84cc16',
120
+ 600: '#65a30d',
121
+ 700: '#4d7c0f',
122
+ 800: '#3f6212',
123
+ 900: '#365314',
124
+ },
125
+ green: {
126
+ 50: '#f0fdf4',
127
+ 100: '#dcfce7',
128
+ 200: '#bbf7d0',
129
+ 300: '#86efac',
130
+ 400: '#4ade80',
131
+ 500: '#22c55e',
132
+ 600: '#16a34a',
133
+ 700: '#15803d',
134
+ 800: '#166534',
135
+ 900: '#14532d',
136
+ },
137
+ emerald: {
138
+ 50: '#ecfdf5',
139
+ 100: '#d1fae5',
140
+ 200: '#a7f3d0',
141
+ 300: '#6ee7b7',
142
+ 400: '#34d399',
143
+ 500: '#10b981',
144
+ 600: '#059669',
145
+ 700: '#047857',
146
+ 800: '#065f46',
147
+ 900: '#064e3b',
148
+ },
149
+ teal: {
150
+ 50: '#f0fdfa',
151
+ 100: '#ccfbf1',
152
+ 200: '#99f6e4',
153
+ 300: '#5eead4',
154
+ 400: '#2dd4bf',
155
+ 500: '#14b8a6',
156
+ 600: '#0d9488',
157
+ 700: '#0f766e',
158
+ 800: '#115e59',
159
+ 900: '#134e4a',
160
+ },
161
+ cyan: {
162
+ 50: '#ecfeff',
163
+ 100: '#cffafe',
164
+ 200: '#a5f3fc',
165
+ 300: '#67e8f9',
166
+ 400: '#22d3ee',
167
+ 500: '#06b6d4',
168
+ 600: '#0891b2',
169
+ 700: '#0e7490',
170
+ 800: '#155e75',
171
+ 900: '#164e63',
172
+ },
173
+ sky: {
174
+ 50: '#f0f9ff',
175
+ 100: '#e0f2fe',
176
+ 200: '#bae6fd',
177
+ 300: '#7dd3fc',
178
+ 400: '#38bdf8',
179
+ 500: '#0ea5e9',
180
+ 600: '#0284c7',
181
+ 700: '#0369a1',
182
+ 800: '#075985',
183
+ 900: '#0c4a6e',
184
+ },
185
+ blue: {
186
+ 50: '#eff6ff',
187
+ 100: '#dbeafe',
188
+ 200: '#bfdbfe',
189
+ 300: '#93c5fd',
190
+ 400: '#60a5fa',
191
+ 500: '#3b82f6',
192
+ 600: '#2563eb',
193
+ 700: '#1d4ed8',
194
+ 800: '#1e40af',
195
+ 900: '#1e3a8a',
196
+ },
197
+ indigo: {
198
+ 50: '#eef2ff',
199
+ 100: '#e0e7ff',
200
+ 200: '#c7d2fe',
201
+ 300: '#a5b4fc',
202
+ 400: '#818cf8',
203
+ 500: '#6366f1',
204
+ 600: '#4f46e5',
205
+ 700: '#4338ca',
206
+ 800: '#3730a3',
207
+ 900: '#312e81',
208
+ },
209
+ violet: {
210
+ 50: '#f5f3ff',
211
+ 100: '#ede9fe',
212
+ 200: '#ddd6fe',
213
+ 300: '#c4b5fd',
214
+ 400: '#a78bfa',
215
+ 500: '#8b5cf6',
216
+ 600: '#7c3aed',
217
+ 700: '#6d28d9',
218
+ 800: '#5b21b6',
219
+ 900: '#4c1d95',
220
+ },
221
+ purple: {
222
+ 50: '#faf5ff',
223
+ 100: '#f3e8ff',
224
+ 200: '#e9d5ff',
225
+ 300: '#d8b4fe',
226
+ 400: '#c084fc',
227
+ 500: '#a855f7',
228
+ 600: '#9333ea',
229
+ 700: '#7e22ce',
230
+ 800: '#6b21a8',
231
+ 900: '#581c87',
232
+ },
233
+ fuchsia: {
234
+ 50: '#fdf4ff',
235
+ 100: '#fae8ff',
236
+ 200: '#f5d0fe',
237
+ 300: '#f0abfc',
238
+ 400: '#e879f9',
239
+ 500: '#d946ef',
240
+ 600: '#c026d3',
241
+ 700: '#a21caf',
242
+ 800: '#86198f',
243
+ 900: '#701a75',
244
+ },
245
+ pink: {
246
+ 50: '#fdf2f8',
247
+ 100: '#fce7f3',
248
+ 200: '#fbcfe8',
249
+ 300: '#f9a8d4',
250
+ 400: '#f472b6',
251
+ 500: '#ec4899',
252
+ 600: '#db2777',
253
+ 700: '#be185d',
254
+ 800: '#9d174d',
255
+ 900: '#831843',
256
+ },
257
+ rose: {
258
+ 50: '#fff1f2',
259
+ 100: '#ffe4e6',
260
+ 200: '#fecdd3',
261
+ 300: '#fda4af',
262
+ 400: '#fb7185',
263
+ 500: '#f43f5e',
264
+ 600: '#e11d48',
265
+ 700: '#be123c',
266
+ 800: '#9f1239',
267
+ 900: '#881337',
268
+ },
269
+ }
270
+
271
+ const HEX = /^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})?$/i
272
+ const SHORT_HEX = /^#([a-f\d])([a-f\d])([a-f\d])([a-f\d])?$/i
273
+ const VALUE = `(?:\\d+|\\d*\\.\\d+)%?`
274
+ const SEP = `(?:\\s*,\\s*|\\s+)`
275
+ const ALPHA_SEP = `\\s*[,/]\\s*`
276
+ const RGB = new RegExp(
277
+ `^rgba?\\(\\s*(${VALUE})${SEP}(${VALUE})${SEP}(${VALUE})(?:${ALPHA_SEP}(${VALUE}))?\\s*\\)$`,
278
+ )
279
+ const HSL = new RegExp(
280
+ `^hsla?\\(\\s*((?:${VALUE})(?:deg|rad|grad|turn)?)${SEP}(${VALUE})${SEP}(${VALUE})(?:${ALPHA_SEP}(${VALUE}))?\\s*\\)$`,
281
+ )
282
+
283
+ export function parseColor (value) {
284
+ if (typeof value !== 'string') {
285
+ return null
286
+ }
287
+
288
+ value = value.trim()
289
+ if (value === 'transparent') {
290
+ return { mode: 'rgb', color: ['0', '0', '0'], alpha: '0' }
291
+ }
292
+
293
+ const hex = value
294
+ .replace(SHORT_HEX, (_, r, g, b, a) => ['#', r, r, g, g, b, b, a ? a + a : ''].join(''))
295
+ .match(HEX)
296
+
297
+ if (hex !== null) {
298
+ return {
299
+ mode: 'rgb',
300
+ color: [parseInt(hex[1], 16), parseInt(hex[2], 16), parseInt(hex[3], 16)].map((v) =>
301
+ v.toString(),
302
+ ),
303
+ alpha: hex[4] ? (parseInt(hex[4], 16) / 255).toString() : undefined,
304
+ }
305
+ }
306
+
307
+ const rgbMatch = value.match(RGB)
308
+
309
+ if (rgbMatch !== null) {
310
+ return {
311
+ mode: 'rgb',
312
+ color: [rgbMatch[1], rgbMatch[2], rgbMatch[3]].map((v) => v.toString()),
313
+ alpha: rgbMatch[4]?.toString?.(),
314
+ }
315
+ }
316
+
317
+ const hslMatch = value.match(HSL)
318
+
319
+ if (hslMatch !== null) {
320
+ return {
321
+ mode: 'hsl',
322
+ color: [hslMatch[1], hslMatch[2], hslMatch[3]].map((v) => v.toString()),
323
+ alpha: hslMatch[4]?.toString?.(),
324
+ }
325
+ }
326
+
327
+ return null
328
+ }
@@ -0,0 +1,12 @@
1
+ import { build } from '../build.js'
2
+ import { createContext } from '../context.js'
3
+
4
+ export async function buildCommand () {
5
+ const ctx = await createContext({
6
+ mode: 'build',
7
+ })
8
+ await build(ctx)
9
+
10
+ // @TODO remove when https://github.com/vitejs/vite/issues/6815 is fixed
11
+ process.exit(0)
12
+ }
@@ -1,21 +1,14 @@
1
- import { join } from 'pathe'
2
- import { HistoireConfig } from '../config.js'
3
- import { Context } from '../context.js'
1
+ import { createContext } from '../context.js'
4
2
  import { createServer } from '../server.js'
5
3
 
6
4
  export interface DevOptions {
7
5
  port: number
8
6
  }
9
7
 
10
- export async function dev (options: DevOptions) {
11
- const config: HistoireConfig = {
12
- sourceDir: join(process.cwd(), 'src'),
13
- storyMatch: ['**/*.story.vue'],
14
- }
15
- const ctx: Context = {
16
- config,
17
- }
18
- const server = await createServer(ctx)
19
- await server.listen(options.port)
8
+ export async function devCommand (options: DevOptions) {
9
+ const ctx = await createContext({
10
+ mode: 'dev',
11
+ })
12
+ const { server } = await createServer(ctx, options.port)
20
13
  server.printUrls()
21
14
  }