histoire 0.0.0 → 0.0.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.
Files changed (204) 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 +113 -0
  9. package/dist/client/app/codegen/serialize-js.ts +119 -0
  10. package/dist/client/app/codegen/util.d.ts +10 -0
  11. package/dist/client/app/codegen/util.js +70 -0
  12. package/dist/client/app/codegen/util.ts +79 -0
  13. package/dist/client/app/codegen/vue3.d.ts +2 -0
  14. package/dist/client/app/codegen/vue3.js +238 -0
  15. package/dist/client/app/codegen/vue3.ts +240 -0
  16. package/dist/client/app/components/HomeView.vue +15 -1
  17. package/dist/client/app/components/StoryControls.vue +7 -2
  18. package/dist/client/app/components/StoryList.vue +20 -13
  19. package/dist/client/app/components/StoryListFolder.vue +87 -0
  20. package/dist/client/app/components/StoryListItem.vue +38 -12
  21. package/dist/client/app/components/StorySourceCode.vue +121 -0
  22. package/dist/client/app/components/StoryVariantGridItem.vue +32 -17
  23. package/dist/client/app/components/StoryVariantListItem.vue +46 -0
  24. package/dist/client/app/components/StoryVariantSingleView.vue +145 -15
  25. package/dist/client/app/components/StoryView.vue +88 -54
  26. package/dist/client/app/components/app/AppHeader.vue +56 -0
  27. package/dist/client/app/components/app/AppLogo.vue +24 -0
  28. package/dist/client/app/components/base/BaseEmpty.vue +1 -1
  29. package/dist/client/app/components/base/BaseListItemLink.vue +55 -0
  30. package/dist/client/app/components/base/BaseSplitPane.vue +57 -21
  31. package/dist/client/app/components/exposed/Story.vue +23 -58
  32. package/dist/client/app/components/exposed/Variant.vue +24 -47
  33. package/dist/client/app/components/misc/HatchedPattern.vue +25 -0
  34. package/dist/client/app/components/{SandboxVue.vue → sandbox/SandboxVue3.vue} +31 -12
  35. package/dist/client/app/components/search/SearchItem.vue +110 -0
  36. package/dist/client/app/components/search/SearchModal.vue +179 -0
  37. package/dist/client/app/composable/variant.js +0 -1
  38. package/dist/client/app/composable/variant.ts +20 -0
  39. package/dist/client/app/global-components.js +0 -1
  40. package/dist/client/app/global-components.ts +10 -0
  41. package/dist/client/app/index.d.ts +1 -0
  42. package/dist/client/app/index.js +10 -2
  43. package/dist/client/app/index.ts +24 -0
  44. package/dist/client/app/router.js +0 -1
  45. package/dist/client/app/router.ts +17 -0
  46. package/dist/client/app/sandbox.d.ts +1 -0
  47. package/dist/client/app/sandbox.js +53 -0
  48. package/dist/client/app/sandbox.ts +60 -0
  49. package/dist/client/app/stores/story.d.ts +167 -50
  50. package/dist/client/app/stores/story.js +33 -16
  51. package/dist/client/app/stores/story.ts +58 -0
  52. package/dist/client/app/style/floating-vue.css +31 -0
  53. package/dist/client/app/style/main.css +17 -2
  54. package/dist/client/app/style/sandbox.css +14 -0
  55. package/dist/client/app/types.d.ts +36 -4
  56. package/dist/client/app/types.js +0 -1
  57. package/dist/client/app/types.ts +59 -0
  58. package/dist/client/app/util/config.d.ts +3 -0
  59. package/dist/client/app/util/config.js +4 -0
  60. package/dist/client/app/util/config.ts +6 -0
  61. package/dist/client/app/util/const.d.ts +1 -0
  62. package/dist/client/app/util/const.js +1 -0
  63. package/dist/client/app/util/const.ts +1 -0
  64. package/dist/client/app/util/dark.d.ts +2 -0
  65. package/dist/client/app/util/dark.js +3 -0
  66. package/dist/client/app/util/dark.ts +4 -0
  67. package/dist/client/app/util/env.d.ts +1 -0
  68. package/dist/client/app/util/env.js +1 -0
  69. package/dist/client/app/util/env.ts +1 -0
  70. package/dist/client/app/util/keyboard.d.ts +8 -0
  71. package/dist/client/app/util/keyboard.js +82 -0
  72. package/dist/client/app/util/keyboard.ts +99 -0
  73. package/dist/client/app/util/mapping.d.ts +3 -0
  74. package/dist/client/app/util/mapping.js +39 -0
  75. package/dist/client/app/util/mapping.ts +41 -0
  76. package/dist/client/app/util/tooltip.d.ts +6 -0
  77. package/dist/client/app/util/tooltip.js +11 -0
  78. package/dist/client/app/util/tooltip.ts +13 -0
  79. package/dist/client/index.d.ts +8 -0
  80. package/dist/client/index.js +3 -0
  81. package/dist/client/index.ts +12 -0
  82. package/dist/client/server/Story.server.vue +65 -0
  83. package/dist/client/server/Variant.server.vue +50 -0
  84. package/dist/client/server/index.d.ts +2 -0
  85. package/dist/client/server/index.js +25 -0
  86. package/dist/client/server/index.ts +29 -0
  87. package/dist/client/shim.d.ts +5 -0
  88. package/dist/node/alias.js +0 -1
  89. package/dist/node/bin.js +8 -3
  90. package/dist/node/build.d.ts +2 -0
  91. package/dist/node/build.js +71 -0
  92. package/dist/node/collect.d.ts +12 -0
  93. package/dist/node/collect.js +65 -0
  94. package/dist/node/colors.d.ts +286 -0
  95. package/dist/node/colors.js +324 -0
  96. package/dist/node/commands/build.d.ts +1 -0
  97. package/dist/node/commands/build.js +10 -0
  98. package/dist/node/commands/dev.d.ts +1 -1
  99. package/dist/node/commands/dev.js +45 -13
  100. package/dist/node/config.d.ts +112 -1
  101. package/dist/node/config.js +124 -2
  102. package/dist/node/context.d.ts +13 -0
  103. package/dist/node/context.js +12 -2
  104. package/dist/node/dom/dom-keys.d.ts +4 -0
  105. package/dist/node/dom/dom-keys.js +223 -0
  106. package/dist/node/dom/env.d.ts +5 -0
  107. package/dist/node/dom/env.js +22 -0
  108. package/dist/node/index.d.ts +2 -0
  109. package/dist/node/index.js +2 -2
  110. package/dist/node/plugin.d.ts +8 -2
  111. package/dist/node/plugin.js +150 -22
  112. package/dist/node/server.d.ts +4 -1
  113. package/dist/node/server.js +80 -21
  114. package/dist/node/stories.d.ts +8 -9
  115. package/dist/node/stories.js +42 -23
  116. package/dist/node/tree.d.ts +19 -0
  117. package/dist/node/tree.js +54 -0
  118. package/dist/node/types.d.ts +38 -0
  119. package/dist/node/types.js +1 -0
  120. package/dist/style.css +610 -53
  121. package/package.json +45 -25
  122. package/scripts/copy.mjs +11 -0
  123. package/src/client/app/App.vue +84 -21
  124. package/src/client/app/assets/histoire-text-dark.svg +89 -0
  125. package/src/client/app/assets/histoire-text.svg +89 -0
  126. package/src/client/app/assets/histoire.svg +51 -0
  127. package/src/client/app/codegen/serialize-js.ts +119 -0
  128. package/src/client/app/codegen/util.ts +79 -0
  129. package/src/client/app/codegen/vue3.ts +240 -0
  130. package/src/client/app/components/HomeView.vue +15 -1
  131. package/src/client/app/components/StoryControls.vue +7 -2
  132. package/src/client/app/components/StoryList.vue +20 -13
  133. package/src/client/app/components/StoryListFolder.vue +87 -0
  134. package/src/client/app/components/StoryListItem.vue +38 -12
  135. package/src/client/app/components/StorySourceCode.vue +121 -0
  136. package/src/client/app/components/StoryVariantGridItem.vue +32 -17
  137. package/src/client/app/components/StoryVariantListItem.vue +46 -0
  138. package/src/client/app/components/StoryVariantSingleView.vue +145 -15
  139. package/src/client/app/components/StoryView.vue +88 -54
  140. package/src/client/app/components/app/AppHeader.vue +56 -0
  141. package/src/client/app/components/app/AppLogo.vue +24 -0
  142. package/src/client/app/components/base/BaseEmpty.vue +1 -1
  143. package/src/client/app/components/base/BaseListItemLink.vue +55 -0
  144. package/src/client/app/components/base/BaseSplitPane.vue +57 -21
  145. package/src/client/app/components/exposed/Story.vue +23 -58
  146. package/src/client/app/components/exposed/Variant.vue +24 -47
  147. package/src/client/app/components/misc/HatchedPattern.vue +25 -0
  148. package/src/client/app/components/{SandboxVue.vue → sandbox/SandboxVue3.vue} +31 -12
  149. package/src/client/app/components/search/SearchItem.vue +110 -0
  150. package/src/client/app/components/search/SearchModal.vue +179 -0
  151. package/src/client/app/index.ts +10 -1
  152. package/src/client/app/sandbox.ts +60 -0
  153. package/src/client/app/stores/story.ts +39 -15
  154. package/src/client/app/style/floating-vue.css +31 -0
  155. package/src/client/app/style/main.css +17 -2
  156. package/src/client/app/style/sandbox.css +14 -0
  157. package/src/client/app/types.ts +42 -4
  158. package/src/client/app/util/config.ts +6 -0
  159. package/src/client/app/util/const.ts +1 -0
  160. package/src/client/app/util/dark.ts +4 -0
  161. package/src/client/app/util/env.ts +1 -0
  162. package/src/client/app/util/keyboard.ts +99 -0
  163. package/src/client/app/util/mapping.ts +41 -0
  164. package/src/client/app/util/tooltip.ts +13 -0
  165. package/src/client/index.ts +12 -0
  166. package/src/client/server/Story.server.vue +65 -0
  167. package/src/client/server/Variant.server.vue +50 -0
  168. package/src/client/server/index.ts +29 -0
  169. package/src/node/bin.ts +9 -2
  170. package/src/node/build.ts +80 -0
  171. package/src/node/collect.ts +78 -0
  172. package/src/node/colors.ts +340 -0
  173. package/src/node/commands/build.ts +12 -0
  174. package/src/node/commands/dev.ts +49 -12
  175. package/src/node/config.ts +240 -1
  176. package/src/node/context.ts +21 -1
  177. package/src/node/dom/dom-keys.ts +227 -0
  178. package/src/node/dom/env.ts +26 -0
  179. package/src/node/index.ts +2 -0
  180. package/src/node/plugin.ts +155 -22
  181. package/src/node/server.ts +95 -20
  182. package/src/node/stories.ts +53 -31
  183. package/src/node/tree.spec.ts +28 -0
  184. package/src/node/tree.ts +88 -0
  185. package/src/node/types.ts +40 -0
  186. package/tailwind.config.cjs +41 -1
  187. package/tsconfig.json +2 -1
  188. package/dist/client/app/components/StoryVariantItem.vue +0 -29
  189. package/dist/client/app/composable/variant.js.map +0 -1
  190. package/dist/client/app/global-components.js.map +0 -1
  191. package/dist/client/app/index.js.map +0 -1
  192. package/dist/client/app/router.js.map +0 -1
  193. package/dist/client/app/stores/story.js.map +0 -1
  194. package/dist/client/app/types.js.map +0 -1
  195. package/dist/node/alias.js.map +0 -1
  196. package/dist/node/bin.js.map +0 -1
  197. package/dist/node/commands/dev.js.map +0 -1
  198. package/dist/node/config.js.map +0 -1
  199. package/dist/node/context.js.map +0 -1
  200. package/dist/node/index.js.map +0 -1
  201. package/dist/node/plugin.js.map +0 -1
  202. package/dist/node/server.js.map +0 -1
  203. package/dist/node/stories.js.map +0 -1
  204. package/src/client/app/components/StoryVariantItem.vue +0 -29
@@ -0,0 +1,65 @@
1
+ <script lang="ts">
2
+ import { defineComponent, inject, PropType, provide, useAttrs } from 'vue'
3
+ import type { StoryFile, Story, Variant } from '../../node/types'
4
+
5
+ export default defineComponent({
6
+ inheritAttrs: false,
7
+
8
+ props: {
9
+ title: {
10
+ type: String,
11
+ required: true,
12
+ },
13
+
14
+ layout: {
15
+ type: Object as PropType<Story['layout']>,
16
+ default: () => ({ type: 'single' }),
17
+ },
18
+
19
+ icon: {
20
+ type: String,
21
+ default: null,
22
+ },
23
+
24
+ iconColor: {
25
+ type: String,
26
+ default: null,
27
+ },
28
+ },
29
+
30
+ setup (props) {
31
+ const attrs = useAttrs() as {
32
+ data: StoryFile
33
+ }
34
+
35
+ // Story
36
+
37
+ const story: Story = {
38
+ id: attrs.data.id,
39
+ title: props.title,
40
+ layout: props.layout,
41
+ icon: props.icon,
42
+ iconColor: props.iconColor,
43
+ variants: [],
44
+ }
45
+ const addStory = inject('addStory', null)
46
+ addStory?.(story)
47
+
48
+ // Variants
49
+
50
+ provide('story', story)
51
+
52
+ provide('addVariant', (variant: Variant) => {
53
+ story.variants.push(variant)
54
+ })
55
+
56
+ return {
57
+ story,
58
+ }
59
+ },
60
+
61
+ render () {
62
+ return this.$slots.default()
63
+ },
64
+ })
65
+ </script>
@@ -0,0 +1,50 @@
1
+ <script lang="ts">
2
+ import { defineComponent, inject } from 'vue'
3
+ import type { Story, Variant } from '../../node/types'
4
+
5
+ export default defineComponent({
6
+ props: {
7
+ title: {
8
+ type: String,
9
+ default: 'untitled',
10
+ },
11
+
12
+ id: {
13
+ type: String,
14
+ default: null,
15
+ },
16
+
17
+ icon: {
18
+ type: String,
19
+ default: null,
20
+ },
21
+
22
+ iconColor: {
23
+ type: String,
24
+ default: null,
25
+ },
26
+ },
27
+
28
+ setup (props) {
29
+ const story = inject<Story>('story')
30
+
31
+ function generateId () {
32
+ return `${story.id}-${story.variants.length}`
33
+ }
34
+
35
+ const variant: Variant = {
36
+ id: props.id ?? generateId(),
37
+ title: props.title,
38
+ icon: props.icon,
39
+ iconColor: props.iconColor,
40
+ }
41
+
42
+ const addVariant = inject('addVariant') as (variant: Variant) => void
43
+ addVariant(variant)
44
+ },
45
+
46
+ render () {
47
+ return null
48
+ },
49
+ })
50
+ </script>
@@ -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,340 @@
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
+ 750: '#283548',
12
+ 800: '#1e293b',
13
+ 850: '#151f32',
14
+ 900: '#0f172a',
15
+ 950: '#09101f',
16
+ },
17
+ gray: {
18
+ 50: '#f9fafb',
19
+ 100: '#f3f4f6',
20
+ 200: '#e5e7eb',
21
+ 300: '#d1d5db',
22
+ 400: '#9ca3af',
23
+ 500: '#6b7280',
24
+ 600: '#4b5563',
25
+ 700: '#374151',
26
+ 750: '#2b3546',
27
+ 800: '#1f2937',
28
+ 850: '#18212f',
29
+ 900: '#111827',
30
+ 950: '#0c101d',
31
+ },
32
+ zinc: {
33
+ 50: '#fafafa',
34
+ 100: '#f4f4f5',
35
+ 200: '#e4e4e7',
36
+ 300: '#d4d4d8',
37
+ 400: '#a1a1aa',
38
+ 500: '#71717a',
39
+ 600: '#52525b',
40
+ 700: '#3f3f46',
41
+ 750: '#323238',
42
+ 800: '#27272a',
43
+ 850: '#1f1f21',
44
+ 900: '#18181b',
45
+ 950: '#101012',
46
+ },
47
+ neutral: {
48
+ 50: '#fafafa',
49
+ 100: '#f5f5f5',
50
+ 200: '#e5e5e5',
51
+ 300: '#d4d4d4',
52
+ 400: '#a3a3a3',
53
+ 500: '#737373',
54
+ 600: '#525252',
55
+ 700: '#404040',
56
+ 750: '#333333',
57
+ 800: '#262626',
58
+ 850: '#1f1f1f',
59
+ 900: '#171717',
60
+ 950: '#0f0f0f',
61
+ },
62
+ stone: {
63
+ 50: '#fafaf9',
64
+ 100: '#f5f5f4',
65
+ 200: '#e7e5e4',
66
+ 300: '#d6d3d1',
67
+ 400: '#a8a29e',
68
+ 500: '#78716c',
69
+ 600: '#57534e',
70
+ 700: '#44403c',
71
+ 750: '#363230',
72
+ 800: '#292524',
73
+ 850: '#211e1c',
74
+ 900: '#1c1917',
75
+ 950: '#171412',
76
+ },
77
+ red: {
78
+ 50: '#fef2f2',
79
+ 100: '#fee2e2',
80
+ 200: '#fecaca',
81
+ 300: '#fca5a5',
82
+ 400: '#f87171',
83
+ 500: '#ef4444',
84
+ 600: '#dc2626',
85
+ 700: '#b91c1c',
86
+ 800: '#991b1b',
87
+ 900: '#7f1d1d',
88
+ },
89
+ orange: {
90
+ 50: '#fff7ed',
91
+ 100: '#ffedd5',
92
+ 200: '#fed7aa',
93
+ 300: '#fdba74',
94
+ 400: '#fb923c',
95
+ 500: '#f97316',
96
+ 600: '#ea580c',
97
+ 700: '#c2410c',
98
+ 800: '#9a3412',
99
+ 900: '#7c2d12',
100
+ },
101
+ amber: {
102
+ 50: '#fffbeb',
103
+ 100: '#fef3c7',
104
+ 200: '#fde68a',
105
+ 300: '#fcd34d',
106
+ 400: '#fbbf24',
107
+ 500: '#f59e0b',
108
+ 600: '#d97706',
109
+ 700: '#b45309',
110
+ 800: '#92400e',
111
+ 900: '#78350f',
112
+ },
113
+ yellow: {
114
+ 50: '#fefce8',
115
+ 100: '#fef9c3',
116
+ 200: '#fef08a',
117
+ 300: '#fde047',
118
+ 400: '#facc15',
119
+ 500: '#eab308',
120
+ 600: '#ca8a04',
121
+ 700: '#a16207',
122
+ 800: '#854d0e',
123
+ 900: '#713f12',
124
+ },
125
+ lime: {
126
+ 50: '#f7fee7',
127
+ 100: '#ecfccb',
128
+ 200: '#d9f99d',
129
+ 300: '#bef264',
130
+ 400: '#a3e635',
131
+ 500: '#84cc16',
132
+ 600: '#65a30d',
133
+ 700: '#4d7c0f',
134
+ 800: '#3f6212',
135
+ 900: '#365314',
136
+ },
137
+ green: {
138
+ 50: '#f0fdf4',
139
+ 100: '#dcfce7',
140
+ 200: '#bbf7d0',
141
+ 300: '#86efac',
142
+ 400: '#4ade80',
143
+ 500: '#22c55e',
144
+ 600: '#16a34a',
145
+ 700: '#15803d',
146
+ 800: '#166534',
147
+ 900: '#14532d',
148
+ },
149
+ emerald: {
150
+ 50: '#ecfdf5',
151
+ 100: '#d1fae5',
152
+ 200: '#a7f3d0',
153
+ 300: '#6ee7b7',
154
+ 400: '#34d399',
155
+ 500: '#10b981',
156
+ 600: '#059669',
157
+ 700: '#047857',
158
+ 800: '#065f46',
159
+ 900: '#064e3b',
160
+ },
161
+ teal: {
162
+ 50: '#f0fdfa',
163
+ 100: '#ccfbf1',
164
+ 200: '#99f6e4',
165
+ 300: '#5eead4',
166
+ 400: '#2dd4bf',
167
+ 500: '#14b8a6',
168
+ 600: '#0d9488',
169
+ 700: '#0f766e',
170
+ 800: '#115e59',
171
+ 900: '#134e4a',
172
+ },
173
+ cyan: {
174
+ 50: '#ecfeff',
175
+ 100: '#cffafe',
176
+ 200: '#a5f3fc',
177
+ 300: '#67e8f9',
178
+ 400: '#22d3ee',
179
+ 500: '#06b6d4',
180
+ 600: '#0891b2',
181
+ 700: '#0e7490',
182
+ 800: '#155e75',
183
+ 900: '#164e63',
184
+ },
185
+ sky: {
186
+ 50: '#f0f9ff',
187
+ 100: '#e0f2fe',
188
+ 200: '#bae6fd',
189
+ 300: '#7dd3fc',
190
+ 400: '#38bdf8',
191
+ 500: '#0ea5e9',
192
+ 600: '#0284c7',
193
+ 700: '#0369a1',
194
+ 800: '#075985',
195
+ 900: '#0c4a6e',
196
+ },
197
+ blue: {
198
+ 50: '#eff6ff',
199
+ 100: '#dbeafe',
200
+ 200: '#bfdbfe',
201
+ 300: '#93c5fd',
202
+ 400: '#60a5fa',
203
+ 500: '#3b82f6',
204
+ 600: '#2563eb',
205
+ 700: '#1d4ed8',
206
+ 800: '#1e40af',
207
+ 900: '#1e3a8a',
208
+ },
209
+ indigo: {
210
+ 50: '#eef2ff',
211
+ 100: '#e0e7ff',
212
+ 200: '#c7d2fe',
213
+ 300: '#a5b4fc',
214
+ 400: '#818cf8',
215
+ 500: '#6366f1',
216
+ 600: '#4f46e5',
217
+ 700: '#4338ca',
218
+ 800: '#3730a3',
219
+ 900: '#312e81',
220
+ },
221
+ violet: {
222
+ 50: '#f5f3ff',
223
+ 100: '#ede9fe',
224
+ 200: '#ddd6fe',
225
+ 300: '#c4b5fd',
226
+ 400: '#a78bfa',
227
+ 500: '#8b5cf6',
228
+ 600: '#7c3aed',
229
+ 700: '#6d28d9',
230
+ 800: '#5b21b6',
231
+ 900: '#4c1d95',
232
+ },
233
+ purple: {
234
+ 50: '#faf5ff',
235
+ 100: '#f3e8ff',
236
+ 200: '#e9d5ff',
237
+ 300: '#d8b4fe',
238
+ 400: '#c084fc',
239
+ 500: '#a855f7',
240
+ 600: '#9333ea',
241
+ 700: '#7e22ce',
242
+ 800: '#6b21a8',
243
+ 900: '#581c87',
244
+ },
245
+ fuchsia: {
246
+ 50: '#fdf4ff',
247
+ 100: '#fae8ff',
248
+ 200: '#f5d0fe',
249
+ 300: '#f0abfc',
250
+ 400: '#e879f9',
251
+ 500: '#d946ef',
252
+ 600: '#c026d3',
253
+ 700: '#a21caf',
254
+ 800: '#86198f',
255
+ 900: '#701a75',
256
+ },
257
+ pink: {
258
+ 50: '#fdf2f8',
259
+ 100: '#fce7f3',
260
+ 200: '#fbcfe8',
261
+ 300: '#f9a8d4',
262
+ 400: '#f472b6',
263
+ 500: '#ec4899',
264
+ 600: '#db2777',
265
+ 700: '#be185d',
266
+ 800: '#9d174d',
267
+ 900: '#831843',
268
+ },
269
+ rose: {
270
+ 50: '#fff1f2',
271
+ 100: '#ffe4e6',
272
+ 200: '#fecdd3',
273
+ 300: '#fda4af',
274
+ 400: '#fb7185',
275
+ 500: '#f43f5e',
276
+ 600: '#e11d48',
277
+ 700: '#be123c',
278
+ 800: '#9f1239',
279
+ 900: '#881337',
280
+ },
281
+ }
282
+
283
+ const HEX = /^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})?$/i
284
+ const SHORT_HEX = /^#([a-f\d])([a-f\d])([a-f\d])([a-f\d])?$/i
285
+ const VALUE = `(?:\\d+|\\d*\\.\\d+)%?`
286
+ const SEP = `(?:\\s*,\\s*|\\s+)`
287
+ const ALPHA_SEP = `\\s*[,/]\\s*`
288
+ const RGB = new RegExp(
289
+ `^rgba?\\(\\s*(${VALUE})${SEP}(${VALUE})${SEP}(${VALUE})(?:${ALPHA_SEP}(${VALUE}))?\\s*\\)$`,
290
+ )
291
+ const HSL = new RegExp(
292
+ `^hsla?\\(\\s*((?:${VALUE})(?:deg|rad|grad|turn)?)${SEP}(${VALUE})${SEP}(${VALUE})(?:${ALPHA_SEP}(${VALUE}))?\\s*\\)$`,
293
+ )
294
+
295
+ export function parseColor (value) {
296
+ if (typeof value !== 'string') {
297
+ return null
298
+ }
299
+
300
+ value = value.trim()
301
+ if (value === 'transparent') {
302
+ return { mode: 'rgb', color: ['0', '0', '0'], alpha: '0' }
303
+ }
304
+
305
+ const hex = value
306
+ .replace(SHORT_HEX, (_, r, g, b, a) => ['#', r, r, g, g, b, b, a ? a + a : ''].join(''))
307
+ .match(HEX)
308
+
309
+ if (hex !== null) {
310
+ return {
311
+ mode: 'rgb',
312
+ color: [parseInt(hex[1], 16), parseInt(hex[2], 16), parseInt(hex[3], 16)].map((v) =>
313
+ v.toString(),
314
+ ),
315
+ alpha: hex[4] ? (parseInt(hex[4], 16) / 255).toString() : undefined,
316
+ }
317
+ }
318
+
319
+ const rgbMatch = value.match(RGB)
320
+
321
+ if (rgbMatch !== null) {
322
+ return {
323
+ mode: 'rgb',
324
+ color: [rgbMatch[1], rgbMatch[2], rgbMatch[3]].map((v) => v.toString()),
325
+ alpha: rgbMatch[4]?.toString?.(),
326
+ }
327
+ }
328
+
329
+ const hslMatch = value.match(HSL)
330
+
331
+ if (hslMatch !== null) {
332
+ return {
333
+ mode: 'hsl',
334
+ color: [hslMatch[1], hslMatch[2], hslMatch[3]].map((v) => v.toString()),
335
+ alpha: hslMatch[4]?.toString?.(),
336
+ }
337
+ }
338
+
339
+ return null
340
+ }
@@ -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
+ }