poveste 0.6.0 → 0.7.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.
- package/dist/controls.d.ts +0 -1
- package/dist/node/alias.d.ts +0 -1
- package/dist/node/bin.d.ts +0 -1
- package/dist/node/build-serialize.d.ts +0 -1
- package/dist/node/build.d.ts +0 -1
- package/dist/node/builtin-plugins/pinceau-tokens.d.ts +0 -1
- package/dist/node/builtin-plugins/vanilla-support/MountStory.d.ts +0 -1
- package/dist/node/builtin-plugins/vanilla-support/RenderStory.d.ts +0 -1
- package/dist/node/builtin-plugins/vanilla-support/client.d.ts +0 -1
- package/dist/node/builtin-plugins/vanilla-support/collect.d.ts +0 -1
- package/dist/node/builtin-plugins/vanilla-support/plugin.d.ts +0 -1
- package/dist/node/builtin-plugins/vanilla-support/types.d.ts +0 -1
- package/dist/node/builtin-plugins/vanilla-support/vanilla.story.d.ts +0 -1
- package/dist/node/collect/index.d.ts +0 -1
- package/dist/node/collect/run.d.ts +0 -1
- package/dist/node/collect/worker.d.ts +0 -1
- package/dist/node/colors.d.ts +0 -1
- package/dist/node/commands/build.d.ts +0 -1
- package/dist/node/commands/dev.d.ts +0 -1
- package/dist/node/commands/port.d.ts +0 -1
- package/dist/node/commands/preview.d.ts +0 -1
- package/dist/node/config.d.ts +0 -1
- package/dist/node/context.d.ts +0 -1
- package/dist/node/dom/dom-keys.d.ts +0 -1
- package/dist/node/dom/env.d.ts +0 -1
- package/dist/node/dom/util.d.ts +0 -1
- package/dist/node/index.d.ts +0 -1
- package/dist/node/load.d.ts +0 -1
- package/dist/node/markdown.d.ts +0 -1
- package/dist/node/plugin.d.ts +0 -1
- package/dist/node/preview.d.ts +0 -1
- package/dist/node/search.d.ts +0 -1
- package/dist/node/server.d.ts +0 -1
- package/dist/node/stories.d.ts +0 -1
- package/dist/node/style-isolation/entry-css-merger.d.ts +0 -1
- package/dist/node/style-isolation/global-styles.d.ts +0 -1
- package/dist/node/style-isolation/index.d.ts +0 -1
- package/dist/node/style-isolation/scope-chrome.d.ts +0 -1
- package/dist/node/style-isolation/selectors.d.ts +0 -1
- package/dist/node/style-isolation/transforms.d.ts +0 -1
- package/dist/node/style-isolation/vite-plugin.d.ts +0 -1
- package/dist/node/tree.d.ts +0 -1
- package/dist/node/util/find-up.d.ts +0 -1
- package/dist/node/util/fs.d.ts +0 -1
- package/dist/node/util/head.d.ts +0 -1
- package/dist/node/util/log.d.ts +0 -1
- package/dist/node/util/slugify.d.ts +0 -1
- package/dist/node/util/vendors.d.ts +0 -1
- package/dist/node/util/watch-ignore.d.ts +0 -1
- package/dist/node/vendors/controls.d.ts +0 -1
- package/dist/node/vendors/vue.d.ts +0 -1
- package/dist/node/virtual/index.d.ts +0 -1
- package/dist/node/virtual/markdown.d.ts +0 -1
- package/dist/node/virtual/noop.d.ts +0 -1
- package/dist/node/virtual/resolved-commands.d.ts +0 -1
- package/dist/node/virtual/resolved-config.d.ts +0 -1
- package/dist/node/virtual/resolved-generated-global-setup.d.ts +0 -1
- package/dist/node/virtual/resolved-generated-setup-code.d.ts +0 -1
- package/dist/node/virtual/resolved-markdown-files.d.ts +0 -1
- package/dist/node/virtual/resolved-stories.d.ts +0 -1
- package/dist/node/virtual/resolved-support-plugins-client.d.ts +0 -1
- package/dist/node/virtual/resolved-support-plugins-collect.d.ts +0 -1
- package/dist/node/virtual/resolved-theme.d.ts +0 -1
- package/dist/node/virtual/story-source.d.ts +0 -1
- package/dist/node/virtual/story.d.ts +0 -1
- package/dist/node/virtual/util.d.ts +0 -1
- package/dist/node/virtual/vite-plugin.d.ts +0 -1
- package/dist/node/vite.d.ts +0 -1
- package/package.json +36 -6
- package/dist/controls.d.ts.map +0 -1
- package/dist/node/alias.d.ts.map +0 -1
- package/dist/node/bin.d.ts.map +0 -1
- package/dist/node/build-serialize.d.ts.map +0 -1
- package/dist/node/build.d.ts.map +0 -1
- package/dist/node/builtin-plugins/pinceau-tokens.d.ts.map +0 -1
- package/dist/node/builtin-plugins/vanilla-support/MountStory.d.ts.map +0 -1
- package/dist/node/builtin-plugins/vanilla-support/RenderStory.d.ts.map +0 -1
- package/dist/node/builtin-plugins/vanilla-support/client.d.ts.map +0 -1
- package/dist/node/builtin-plugins/vanilla-support/collect.d.ts.map +0 -1
- package/dist/node/builtin-plugins/vanilla-support/plugin.d.ts.map +0 -1
- package/dist/node/builtin-plugins/vanilla-support/types.d.ts.map +0 -1
- package/dist/node/builtin-plugins/vanilla-support/vanilla.story.d.ts.map +0 -1
- package/dist/node/collect/index.d.ts.map +0 -1
- package/dist/node/collect/run.d.ts.map +0 -1
- package/dist/node/collect/worker.d.ts.map +0 -1
- package/dist/node/colors.d.ts.map +0 -1
- package/dist/node/commands/build.d.ts.map +0 -1
- package/dist/node/commands/dev.d.ts.map +0 -1
- package/dist/node/commands/port.d.ts.map +0 -1
- package/dist/node/commands/preview.d.ts.map +0 -1
- package/dist/node/config.d.ts.map +0 -1
- package/dist/node/context.d.ts.map +0 -1
- package/dist/node/dom/dom-keys.d.ts.map +0 -1
- package/dist/node/dom/env.d.ts.map +0 -1
- package/dist/node/dom/util.d.ts.map +0 -1
- package/dist/node/index.d.ts.map +0 -1
- package/dist/node/load.d.ts.map +0 -1
- package/dist/node/markdown.d.ts.map +0 -1
- package/dist/node/plugin.d.ts.map +0 -1
- package/dist/node/preview.d.ts.map +0 -1
- package/dist/node/search.d.ts.map +0 -1
- package/dist/node/server.d.ts.map +0 -1
- package/dist/node/stories.d.ts.map +0 -1
- package/dist/node/style-isolation/entry-css-merger.d.ts.map +0 -1
- package/dist/node/style-isolation/global-styles.d.ts.map +0 -1
- package/dist/node/style-isolation/index.d.ts.map +0 -1
- package/dist/node/style-isolation/scope-chrome.d.ts.map +0 -1
- package/dist/node/style-isolation/selectors.d.ts.map +0 -1
- package/dist/node/style-isolation/transforms.d.ts.map +0 -1
- package/dist/node/style-isolation/vite-plugin.d.ts.map +0 -1
- package/dist/node/tree.d.ts.map +0 -1
- package/dist/node/util/find-up.d.ts.map +0 -1
- package/dist/node/util/fs.d.ts.map +0 -1
- package/dist/node/util/head.d.ts.map +0 -1
- package/dist/node/util/log.d.ts.map +0 -1
- package/dist/node/util/slugify.d.ts.map +0 -1
- package/dist/node/util/vendors.d.ts.map +0 -1
- package/dist/node/util/watch-ignore.d.ts.map +0 -1
- package/dist/node/vendors/controls.d.ts.map +0 -1
- package/dist/node/vendors/vue.d.ts.map +0 -1
- package/dist/node/virtual/index.d.ts.map +0 -1
- package/dist/node/virtual/markdown.d.ts.map +0 -1
- package/dist/node/virtual/noop.d.ts.map +0 -1
- package/dist/node/virtual/resolved-commands.d.ts.map +0 -1
- package/dist/node/virtual/resolved-config.d.ts.map +0 -1
- package/dist/node/virtual/resolved-generated-global-setup.d.ts.map +0 -1
- package/dist/node/virtual/resolved-generated-setup-code.d.ts.map +0 -1
- package/dist/node/virtual/resolved-markdown-files.d.ts.map +0 -1
- package/dist/node/virtual/resolved-stories.d.ts.map +0 -1
- package/dist/node/virtual/resolved-support-plugins-client.d.ts.map +0 -1
- package/dist/node/virtual/resolved-support-plugins-collect.d.ts.map +0 -1
- package/dist/node/virtual/resolved-theme.d.ts.map +0 -1
- package/dist/node/virtual/story-source.d.ts.map +0 -1
- package/dist/node/virtual/story.d.ts.map +0 -1
- package/dist/node/virtual/util.d.ts.map +0 -1
- package/dist/node/virtual/vite-plugin.d.ts.map +0 -1
- package/dist/node/vite.d.ts.map +0 -1
- package/src/controls.ts +0 -1
- package/src/node/__tests__/config.spec.ts +0 -25
- package/src/node/__tests__/dom-env.spec.ts +0 -97
- package/src/node/__tests__/head.spec.ts +0 -32
- package/src/node/__tests__/markdown/test1.story.md +0 -7
- package/src/node/__tests__/markdown/test2.story.md +0 -5
- package/src/node/__tests__/markdown.spec.ts +0 -61
- package/src/node/__tests__/port.spec.ts +0 -65
- package/src/node/__tests__/tree.spec.ts +0 -109
- package/src/node/__tests__/virtual-setup.spec.ts +0 -61
- package/src/node/__tests__/watch-ignore.spec.ts +0 -33
- package/src/node/alias.ts +0 -8
- package/src/node/bin.ts +0 -46
- package/src/node/build-serialize.ts +0 -62
- package/src/node/build.ts +0 -339
- package/src/node/builtin-plugins/pinceau-tokens.ts +0 -523
- package/src/node/builtin-plugins/vanilla-support/MountStory.ts +0 -49
- package/src/node/builtin-plugins/vanilla-support/RenderStory.ts +0 -167
- package/src/node/builtin-plugins/vanilla-support/client.ts +0 -6
- package/src/node/builtin-plugins/vanilla-support/collect.ts +0 -43
- package/src/node/builtin-plugins/vanilla-support/plugin.ts +0 -35
- package/src/node/builtin-plugins/vanilla-support/types.ts +0 -42
- package/src/node/builtin-plugins/vanilla-support/vanilla.story.ts +0 -63
- package/src/node/collect/index.ts +0 -164
- package/src/node/collect/run.ts +0 -9
- package/src/node/collect/worker.ts +0 -103
- package/src/node/colors.ts +0 -340
- package/src/node/commands/build.ts +0 -14
- package/src/node/commands/dev.ts +0 -70
- package/src/node/commands/port.ts +0 -41
- package/src/node/commands/preview.ts +0 -30
- package/src/node/config.ts +0 -396
- package/src/node/context.ts +0 -60
- package/src/node/dom/dom-keys.ts +0 -238
- package/src/node/dom/env.ts +0 -123
- package/src/node/dom/util.ts +0 -83
- package/src/node/index.ts +0 -7
- package/src/node/load.ts +0 -59
- package/src/node/markdown.ts +0 -280
- package/src/node/plugin.ts +0 -95
- package/src/node/preview.ts +0 -45
- package/src/node/search.ts +0 -84
- package/src/node/server.ts +0 -258
- package/src/node/stories.ts +0 -145
- package/src/node/style-isolation/__tests__/entry-css-merger.spec.ts +0 -145
- package/src/node/style-isolation/__tests__/transforms.spec.ts +0 -200
- package/src/node/style-isolation/__tests__/vite-plugin.spec.ts +0 -39
- package/src/node/style-isolation/entry-css-merger.ts +0 -134
- package/src/node/style-isolation/global-styles.ts +0 -37
- package/src/node/style-isolation/index.ts +0 -5
- package/src/node/style-isolation/scope-chrome.ts +0 -42
- package/src/node/style-isolation/selectors.ts +0 -19
- package/src/node/style-isolation/transforms.ts +0 -163
- package/src/node/style-isolation/vite-plugin.ts +0 -75
- package/src/node/tree.ts +0 -158
- package/src/node/util/find-up.ts +0 -24
- package/src/node/util/fs.ts +0 -1
- package/src/node/util/head.ts +0 -12
- package/src/node/util/log.ts +0 -10
- package/src/node/util/slugify.ts +0 -26
- package/src/node/util/vendors.ts +0 -27
- package/src/node/util/watch-ignore.ts +0 -13
- package/src/node/vendors/controls.ts +0 -1
- package/src/node/vendors/vue.ts +0 -1
- package/src/node/virtual/index.ts +0 -50
- package/src/node/virtual/markdown.ts +0 -21
- package/src/node/virtual/noop.ts +0 -9
- package/src/node/virtual/resolved-commands.ts +0 -42
- package/src/node/virtual/resolved-config.ts +0 -12
- package/src/node/virtual/resolved-generated-global-setup.ts +0 -33
- package/src/node/virtual/resolved-generated-setup-code.ts +0 -7
- package/src/node/virtual/resolved-markdown-files.ts +0 -19
- package/src/node/virtual/resolved-stories.ts +0 -44
- package/src/node/virtual/resolved-support-plugins-client.ts +0 -14
- package/src/node/virtual/resolved-support-plugins-collect.ts +0 -14
- package/src/node/virtual/resolved-theme.ts +0 -14
- package/src/node/virtual/story-source.ts +0 -18
- package/src/node/virtual/story.ts +0 -9
- package/src/node/virtual/util.ts +0 -41
- package/src/node/virtual/vite-plugin.ts +0 -146
- package/src/node/vite.ts +0 -438
- package/tsconfig.json +0 -44
- package/vitest.config.ts +0 -10
package/src/node/config.ts
DELETED
|
@@ -1,396 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
ConfigMode,
|
|
3
|
-
Plugin,
|
|
4
|
-
PovesteConfig,
|
|
5
|
-
SupportMatchPattern,
|
|
6
|
-
} from '@poveste/shared'
|
|
7
|
-
import type { Context } from './context.js'
|
|
8
|
-
import fs from 'node:fs'
|
|
9
|
-
import { fileURLToPath } from 'node:url'
|
|
10
|
-
import { createDefu } from 'defu'
|
|
11
|
-
import { createJiti } from 'jiti'
|
|
12
|
-
import path from 'pathe'
|
|
13
|
-
import pc from 'picocolors'
|
|
14
|
-
import {
|
|
15
|
-
mergeConfig as mergeViteConfig,
|
|
16
|
-
resolveConfig as resolveViteConfig,
|
|
17
|
-
} from 'vite'
|
|
18
|
-
import { vanillaSupport } from './builtin-plugins/vanilla-support/plugin.js'
|
|
19
|
-
import { defaultColors } from './colors.js'
|
|
20
|
-
import { findUp } from './util/find-up.js'
|
|
21
|
-
|
|
22
|
-
const __filename = fileURLToPath(import.meta.url)
|
|
23
|
-
|
|
24
|
-
export function getDefaultConfig(): PovesteConfig {
|
|
25
|
-
return {
|
|
26
|
-
plugins: [
|
|
27
|
-
vanillaSupport(),
|
|
28
|
-
],
|
|
29
|
-
outDir: '.poveste/dist',
|
|
30
|
-
storyMatch: [
|
|
31
|
-
'**/*.story.vue',
|
|
32
|
-
'**/*.story.svelte',
|
|
33
|
-
],
|
|
34
|
-
storyIgnored: [
|
|
35
|
-
'**/node_modules/**',
|
|
36
|
-
'**/dist/**',
|
|
37
|
-
],
|
|
38
|
-
supportMatch: [],
|
|
39
|
-
isolateStyles: true,
|
|
40
|
-
tree: {
|
|
41
|
-
file: 'title',
|
|
42
|
-
order: 'asc',
|
|
43
|
-
},
|
|
44
|
-
theme: {
|
|
45
|
-
title: 'Poveste',
|
|
46
|
-
colors: {
|
|
47
|
-
primary: defaultColors.emerald,
|
|
48
|
-
gray: defaultColors.zinc,
|
|
49
|
-
},
|
|
50
|
-
defaultColorScheme: 'auto',
|
|
51
|
-
storeColorScheme: true,
|
|
52
|
-
darkClass: 'dark',
|
|
53
|
-
},
|
|
54
|
-
responsivePresets: [
|
|
55
|
-
{
|
|
56
|
-
label: 'Mobile (Small)',
|
|
57
|
-
width: 320,
|
|
58
|
-
height: 560,
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
label: 'Mobile (Medium)',
|
|
62
|
-
width: 360,
|
|
63
|
-
height: 640,
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
label: 'Mobile (Large)',
|
|
67
|
-
width: 414,
|
|
68
|
-
height: 896,
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
label: 'Tablet',
|
|
72
|
-
width: 768,
|
|
73
|
-
height: 1024,
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
label: 'Laptop (Small)',
|
|
77
|
-
width: 1024,
|
|
78
|
-
height: null,
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
label: 'Laptop (Large)',
|
|
82
|
-
width: 1366,
|
|
83
|
-
height: null,
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
label: 'Desktop',
|
|
87
|
-
width: 1920,
|
|
88
|
-
height: null,
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
label: '4K',
|
|
92
|
-
width: 3840,
|
|
93
|
-
height: null,
|
|
94
|
-
},
|
|
95
|
-
],
|
|
96
|
-
backgroundPresets: [
|
|
97
|
-
{
|
|
98
|
-
label: 'Transparent',
|
|
99
|
-
color: 'transparent',
|
|
100
|
-
contrastColor: '#333',
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
label: 'White',
|
|
104
|
-
color: '#fff',
|
|
105
|
-
contrastColor: '#333',
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
label: 'Light gray',
|
|
109
|
-
color: '#aaa',
|
|
110
|
-
contrastColor: '#000',
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
label: 'Dark gray',
|
|
114
|
-
color: '#333',
|
|
115
|
-
contrastColor: '#fff',
|
|
116
|
-
},
|
|
117
|
-
{
|
|
118
|
-
label: 'Black',
|
|
119
|
-
color: '#000',
|
|
120
|
-
contrastColor: '#eee',
|
|
121
|
-
},
|
|
122
|
-
],
|
|
123
|
-
routerMode: 'history',
|
|
124
|
-
build: {
|
|
125
|
-
excludeFromVendorsChunk: [],
|
|
126
|
-
},
|
|
127
|
-
vite: (config) => {
|
|
128
|
-
// Remove vite:legacy plugins https://github.com/histoire-dev/histoire/issues/156
|
|
129
|
-
const index = config.plugins?.findIndex(plugin => Array.isArray(plugin)
|
|
130
|
-
&& typeof plugin[0] === 'object'
|
|
131
|
-
&& !Array.isArray(plugin[0])
|
|
132
|
-
// @ts-expect-error could have no property 'name'
|
|
133
|
-
&& plugin[0].name?.startsWith('vite:legacy'))
|
|
134
|
-
if (index !== -1) {
|
|
135
|
-
config.plugins?.splice(index, 1)
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
return {
|
|
139
|
-
build: {
|
|
140
|
-
lib: false,
|
|
141
|
-
},
|
|
142
|
-
}
|
|
143
|
-
},
|
|
144
|
-
viteIgnorePlugins: [],
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
export const configFileNames = [
|
|
149
|
-
'poveste.config.ts',
|
|
150
|
-
'poveste.config.js',
|
|
151
|
-
'.poveste.ts',
|
|
152
|
-
'.poveste.js',
|
|
153
|
-
// Back-compat with histoire — existing projects keep working as a drop-in.
|
|
154
|
-
'histoire.config.ts',
|
|
155
|
-
'histoire.config.js',
|
|
156
|
-
'.histoire.ts',
|
|
157
|
-
'.histoire.js',
|
|
158
|
-
]
|
|
159
|
-
|
|
160
|
-
export function resolveConfigFile(cwd: string = process.cwd(), configFile?: string): string {
|
|
161
|
-
if (configFile) {
|
|
162
|
-
// explicit config path is always resolved from cwd
|
|
163
|
-
return path.resolve(configFile)
|
|
164
|
-
}
|
|
165
|
-
else {
|
|
166
|
-
return findUp(cwd, configFileNames)
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
export async function loadConfigFile(configFile: string): Promise<Partial<PovesteConfig>> {
|
|
171
|
-
try {
|
|
172
|
-
const jiti = createJiti(__filename, {
|
|
173
|
-
moduleCache: false,
|
|
174
|
-
})
|
|
175
|
-
const result = await jiti.import(configFile, { default: true }) as Partial<PovesteConfig>
|
|
176
|
-
if (!result) {
|
|
177
|
-
throw new Error(`Expected default export in ${configFile}`)
|
|
178
|
-
}
|
|
179
|
-
return result
|
|
180
|
-
}
|
|
181
|
-
catch (e) {
|
|
182
|
-
console.error(pc.red(`Error while loading ${configFile}`))
|
|
183
|
-
throw e
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
export const mergeBuildConfig = createDefu((obj: any, key, value) => {
|
|
188
|
-
if (obj[key] && key === 'excludeFromVendorsChunk') {
|
|
189
|
-
obj[key] = [...obj[key], ...value]
|
|
190
|
-
return true
|
|
191
|
-
}
|
|
192
|
-
})
|
|
193
|
-
|
|
194
|
-
export const mergeConfig = createDefu((obj: any, key, value) => {
|
|
195
|
-
if (obj[key] && key === 'vite') {
|
|
196
|
-
const initialValue = obj[key]
|
|
197
|
-
|
|
198
|
-
// Convert to functions
|
|
199
|
-
const initialFn: (...args: any[]) => Promise<any> = typeof initialValue === 'function' ? initialValue : async () => initialValue
|
|
200
|
-
const valueFn: (...args: any[]) => Promise<any> = typeof value === 'function' ? value : async () => value
|
|
201
|
-
|
|
202
|
-
obj[key] = async (...args) => {
|
|
203
|
-
// `mergeViteConfig` doesn't accept functions so we need to call them
|
|
204
|
-
const initialResult = await initialFn(...args)
|
|
205
|
-
const valueResult = await valueFn(...args)
|
|
206
|
-
return mergeViteConfig(initialResult, valueResult)
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
return true
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
if (obj[key] && key === 'plugins') {
|
|
213
|
-
const initialValue = obj[key] as Plugin[]
|
|
214
|
-
const newValue = obj[key] = [...value]
|
|
215
|
-
const nameMap = newValue.reduce((map, plugin) => {
|
|
216
|
-
map[plugin.name] = true
|
|
217
|
-
return map
|
|
218
|
-
}, {})
|
|
219
|
-
for (const plugin of initialValue) {
|
|
220
|
-
if (!nameMap[plugin.name]) {
|
|
221
|
-
newValue.unshift(plugin)
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
return true
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
if (obj[key] && key === 'setupCode') {
|
|
228
|
-
obj[key] = [...obj[key], ...value]
|
|
229
|
-
return true
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
if (obj[key] && key === 'supportMatch') {
|
|
233
|
-
for (const item of value as SupportMatchPattern[]) {
|
|
234
|
-
const existing: SupportMatchPattern = obj[key].find(p => p.id === item.id)
|
|
235
|
-
if (existing) {
|
|
236
|
-
existing.patterns = [...existing.patterns, ...item.patterns]
|
|
237
|
-
existing.pluginIds = [...existing.pluginIds, ...item.pluginIds]
|
|
238
|
-
}
|
|
239
|
-
else {
|
|
240
|
-
obj[key].push(item)
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
return true
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
if (obj[key] && key === 'build') {
|
|
247
|
-
obj[key] = mergeBuildConfig(obj[key], value)
|
|
248
|
-
return true
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
// An ignore list adds to the defaults rather than replacing them. Under the
|
|
252
|
-
// replace rule below, `storyIgnored: ['**/fixtures/**']` silently dropped
|
|
253
|
-
// `**/node_modules/**`, and the watchers then crawled the pnpm store until
|
|
254
|
-
// the build died with EMFILE (#244). `storyMatch` stays on the replace rule:
|
|
255
|
-
// narrowing it is a legitimate use.
|
|
256
|
-
if (obj[key] && key === 'storyIgnored') {
|
|
257
|
-
obj[key] = [...new Set([...obj[key], ...value])]
|
|
258
|
-
return true
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
// By default, arrays should be replaced
|
|
262
|
-
if (obj[key] && Array.isArray(obj[key])) {
|
|
263
|
-
obj[key] = value
|
|
264
|
-
return true
|
|
265
|
-
}
|
|
266
|
-
})
|
|
267
|
-
|
|
268
|
-
export async function resolveConfig(cwd: string = process.cwd(), mode: ConfigMode, configFile: string): Promise<PovesteConfig> {
|
|
269
|
-
let result: Partial<PovesteConfig>
|
|
270
|
-
const resolvedConfigFile = resolveConfigFile(cwd, configFile)
|
|
271
|
-
if (resolvedConfigFile) {
|
|
272
|
-
result = await loadConfigFile(resolvedConfigFile)
|
|
273
|
-
}
|
|
274
|
-
const viteConfig = await resolveViteConfig({}, 'serve')
|
|
275
|
-
// The `histoire` key is our own deprecation, and reading it is the whole
|
|
276
|
-
// point — it is what makes poveste drop-in for an existing histoire config.
|
|
277
|
-
// eslint-disable-next-line ts/no-deprecated
|
|
278
|
-
const vitePovesteConfig = (viteConfig.poveste ?? viteConfig.histoire ?? {}) as PovesteConfig
|
|
279
|
-
|
|
280
|
-
const preUserConfig = mergeConfig(result, vitePovesteConfig)
|
|
281
|
-
const processedDefaultConfig = await processDefaultConfig(getDefaultConfig(), preUserConfig, mode, cwd)
|
|
282
|
-
|
|
283
|
-
return resolveConfigPlugins(mergeConfig(preUserConfig, processedDefaultConfig), mode)
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
async function resolveConfigPlugins(config: PovesteConfig, mode: ConfigMode): Promise<PovesteConfig> {
|
|
287
|
-
for (const plugin of config.plugins) {
|
|
288
|
-
if (plugin.config) {
|
|
289
|
-
const result = await plugin.config(config, mode)
|
|
290
|
-
if (result) {
|
|
291
|
-
config = mergeConfig(result, config)
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
return config
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
async function processDefaultConfig(defaultConfig: PovesteConfig, preUserConfig: PovesteConfig, mode: ConfigMode, _cwd: string): Promise<PovesteConfig> {
|
|
299
|
-
// Apply plugins
|
|
300
|
-
for (const plugin of [...defaultConfig.plugins, ...preUserConfig.plugins ?? []]) {
|
|
301
|
-
if (plugin.defaultConfig) {
|
|
302
|
-
const result = await plugin.defaultConfig(defaultConfig, mode)
|
|
303
|
-
if (result) {
|
|
304
|
-
defaultConfig = mergeConfig(result, defaultConfig)
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
return defaultConfig
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
export async function processConfig(ctx: Context) {
|
|
312
|
-
const { config, root } = ctx
|
|
313
|
-
|
|
314
|
-
// Resolve files paths
|
|
315
|
-
|
|
316
|
-
const resolveFsPath = (file: string, force = false) => {
|
|
317
|
-
if (force || file.startsWith('./') || file.startsWith('../')) {
|
|
318
|
-
return path.resolve(root, file)
|
|
319
|
-
}
|
|
320
|
-
return file
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
const fileCheck = (file: string, resolvedFile: string, configPathForError: string) => {
|
|
324
|
-
if (!file.startsWith('http') && !file.startsWith('@') && !fs.existsSync(resolvedFile)) {
|
|
325
|
-
console.warn(pc.yellow(`Poveste config: ${configPathForError} file ${file} does not exist (resolved to ${resolvedFile}), check for typos in the path`))
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
config.outDir = resolveFsPath(config.outDir, true)
|
|
330
|
-
|
|
331
|
-
// Theme
|
|
332
|
-
|
|
333
|
-
if (config.theme?.logo?.square) {
|
|
334
|
-
const file = config.theme.logo.square
|
|
335
|
-
config.theme.logo.square = resolveFsPath(file)
|
|
336
|
-
fileCheck(file, config.theme.logo.square, 'theme.logo.square')
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
if (config.theme?.logo?.light) {
|
|
340
|
-
const file = config.theme.logo.light
|
|
341
|
-
config.theme.logo.light = resolveFsPath(file)
|
|
342
|
-
fileCheck(file, config.theme.logo.light, 'theme.logo.light')
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
if (config.theme?.logo?.dark) {
|
|
346
|
-
const file = config.theme.logo.dark
|
|
347
|
-
config.theme.logo.dark = resolveFsPath(file)
|
|
348
|
-
fileCheck(file, config.theme.logo.dark, 'theme.logo.dark')
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
if (config.theme?.favicon) {
|
|
352
|
-
let file = config.theme.favicon
|
|
353
|
-
if (file.startsWith('/')) {
|
|
354
|
-
file = file.slice(1)
|
|
355
|
-
}
|
|
356
|
-
if (!file.startsWith('http')) {
|
|
357
|
-
const publicDir = path.resolve(ctx.resolvedViteConfig.root, ctx.resolvedViteConfig.publicDir)
|
|
358
|
-
// Resolve URL path
|
|
359
|
-
if (file.startsWith('./') || file.startsWith('../')) {
|
|
360
|
-
const resolvedFile = resolveFsPath(file, true)
|
|
361
|
-
const relativeFile = path.relative(publicDir, resolvedFile)
|
|
362
|
-
if (relativeFile.startsWith('..')) {
|
|
363
|
-
throw new Error(pc.red(`Poveste config: theme.favicon seems to target a file that is not in the vite 'public' directory: ${file} (resolved as ${resolvedFile})`))
|
|
364
|
-
}
|
|
365
|
-
if (!fs.existsSync(resolvedFile)) {
|
|
366
|
-
throw new Error(pc.red(`Poveste config: theme.favicon seems to target a file that does not exist: ${file} (resolved as ${resolvedFile})`))
|
|
367
|
-
}
|
|
368
|
-
config.theme.favicon = relativeFile
|
|
369
|
-
}
|
|
370
|
-
else {
|
|
371
|
-
// Check if URL path is valid
|
|
372
|
-
const resolvedFile = path.resolve(publicDir, file)
|
|
373
|
-
if (!fs.existsSync(resolvedFile)) {
|
|
374
|
-
throw new Error(pc.red(`Poveste config: theme.favicon seems to target a file that does not exist: ${file} (resolved as ${resolvedFile}).\nThe favicon file should be placed in the vite 'public' directory.\nExample: if the file is in <project>/public/img/favicon.ico, you can put 'img/favicon.ico' or './public/img/favicon.ico'.`))
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
export function defineConfig(config: Partial<PovesteConfig>) {
|
|
382
|
-
return config
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
declare module 'vite' {
|
|
386
|
-
interface UserConfig {
|
|
387
|
-
/**
|
|
388
|
-
* Poveste configuration
|
|
389
|
-
*/
|
|
390
|
-
poveste?: Partial<PovesteConfig>
|
|
391
|
-
/**
|
|
392
|
-
* @deprecated Use `poveste` instead. Kept for drop-in compat with histoire.
|
|
393
|
-
*/
|
|
394
|
-
histoire?: Partial<PovesteConfig>
|
|
395
|
-
}
|
|
396
|
-
}
|
package/src/node/context.ts
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
ConfigMode,
|
|
3
|
-
FinalSupportPlugin,
|
|
4
|
-
PluginCommand,
|
|
5
|
-
PovesteConfig,
|
|
6
|
-
ServerMarkdownFile,
|
|
7
|
-
ServerStoryFile,
|
|
8
|
-
} from '@poveste/shared'
|
|
9
|
-
import type { ResolvedConfig } from 'vite'
|
|
10
|
-
import { resolveConfig as resolveViteConfig } from 'vite'
|
|
11
|
-
import { processConfig, resolveConfig } from './config.js'
|
|
12
|
-
import { mergePovesteViteConfig } from './vite.js'
|
|
13
|
-
|
|
14
|
-
export interface Context {
|
|
15
|
-
root: string
|
|
16
|
-
config: PovesteConfig
|
|
17
|
-
resolvedViteConfig: ResolvedConfig
|
|
18
|
-
mode: ConfigMode
|
|
19
|
-
storyFiles: ServerStoryFile[]
|
|
20
|
-
supportPlugins: FinalSupportPlugin[]
|
|
21
|
-
markdownFiles: ServerMarkdownFile[]
|
|
22
|
-
registeredCommands?: PluginCommand[]
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface CreateContextOptions {
|
|
26
|
-
mode: Context['mode']
|
|
27
|
-
configFile?: string
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export async function createContext(options: CreateContextOptions): Promise<Context> {
|
|
31
|
-
const config = await resolveConfig(process.cwd(), options.mode, options.configFile)
|
|
32
|
-
const command = options.mode === 'dev' ? 'serve' : 'build'
|
|
33
|
-
const viteConfig = await resolveViteConfig({}, command)
|
|
34
|
-
|
|
35
|
-
const supportPlugins = config.plugins.map(p => p.supportPlugin).filter(Boolean)
|
|
36
|
-
|
|
37
|
-
const ctx = {
|
|
38
|
-
root: viteConfig.root,
|
|
39
|
-
config,
|
|
40
|
-
resolvedViteConfig: null,
|
|
41
|
-
mode: options.mode,
|
|
42
|
-
storyFiles: [],
|
|
43
|
-
supportPlugins,
|
|
44
|
-
markdownFiles: [],
|
|
45
|
-
registeredCommands: [],
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
ctx.resolvedViteConfig = await mergePovesteViteConfig(viteConfig as unknown, ctx)
|
|
49
|
-
|
|
50
|
-
await processConfig(ctx)
|
|
51
|
-
|
|
52
|
-
// List commands
|
|
53
|
-
for (const plugin of ctx.config.plugins) {
|
|
54
|
-
if (plugin.commands?.length) {
|
|
55
|
-
ctx.registeredCommands.push(...plugin.commands)
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return ctx
|
|
60
|
-
}
|
package/src/node/dom/dom-keys.ts
DELETED
|
@@ -1,238 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Code from vitest https://github.com/antfu-sponsors/vitest/blob/6066fdbf3b1d17021aac20591b5ef3603056fa5f/src/integrations/dom/keys.ts by @antfu and @patak
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
// SEE https://github.com/jsdom/jsdom/blob/master/lib/jsdom/living/interfaces.js
|
|
6
|
-
|
|
7
|
-
const LIVING_KEYS = [
|
|
8
|
-
'DOMException',
|
|
9
|
-
'URL',
|
|
10
|
-
'URLSearchParams',
|
|
11
|
-
'EventTarget',
|
|
12
|
-
'NamedNodeMap',
|
|
13
|
-
'Node',
|
|
14
|
-
'Attr',
|
|
15
|
-
'Element',
|
|
16
|
-
'DocumentFragment',
|
|
17
|
-
'DOMImplementation',
|
|
18
|
-
'Document',
|
|
19
|
-
'XMLDocument',
|
|
20
|
-
'CharacterData',
|
|
21
|
-
'Text',
|
|
22
|
-
'CDATASection',
|
|
23
|
-
'ProcessingInstruction',
|
|
24
|
-
'Comment',
|
|
25
|
-
'DocumentType',
|
|
26
|
-
'NodeList',
|
|
27
|
-
'RadioNodeList',
|
|
28
|
-
'HTMLCollection',
|
|
29
|
-
'HTMLOptionsCollection',
|
|
30
|
-
'DOMStringMap',
|
|
31
|
-
'DOMTokenList',
|
|
32
|
-
'StyleSheetList',
|
|
33
|
-
'HTMLElement',
|
|
34
|
-
'HTMLHeadElement',
|
|
35
|
-
'HTMLTitleElement',
|
|
36
|
-
'HTMLBaseElement',
|
|
37
|
-
'HTMLLinkElement',
|
|
38
|
-
'HTMLMetaElement',
|
|
39
|
-
'HTMLStyleElement',
|
|
40
|
-
'HTMLBodyElement',
|
|
41
|
-
'HTMLHeadingElement',
|
|
42
|
-
'HTMLParagraphElement',
|
|
43
|
-
'HTMLHRElement',
|
|
44
|
-
'HTMLPreElement',
|
|
45
|
-
'HTMLUListElement',
|
|
46
|
-
'HTMLOListElement',
|
|
47
|
-
'HTMLLIElement',
|
|
48
|
-
'HTMLMenuElement',
|
|
49
|
-
'HTMLDListElement',
|
|
50
|
-
'HTMLDivElement',
|
|
51
|
-
'HTMLAnchorElement',
|
|
52
|
-
'HTMLAreaElement',
|
|
53
|
-
'HTMLBRElement',
|
|
54
|
-
'HTMLButtonElement',
|
|
55
|
-
'HTMLCanvasElement',
|
|
56
|
-
'HTMLDataElement',
|
|
57
|
-
'HTMLDataListElement',
|
|
58
|
-
'HTMLDetailsElement',
|
|
59
|
-
'HTMLDialogElement',
|
|
60
|
-
'HTMLDirectoryElement',
|
|
61
|
-
'HTMLFieldSetElement',
|
|
62
|
-
'HTMLFontElement',
|
|
63
|
-
'HTMLFormElement',
|
|
64
|
-
'HTMLHtmlElement',
|
|
65
|
-
'HTMLImageElement',
|
|
66
|
-
'HTMLInputElement',
|
|
67
|
-
'HTMLLabelElement',
|
|
68
|
-
'HTMLLegendElement',
|
|
69
|
-
'HTMLMapElement',
|
|
70
|
-
'HTMLMarqueeElement',
|
|
71
|
-
'HTMLMediaElement',
|
|
72
|
-
'HTMLMeterElement',
|
|
73
|
-
'HTMLModElement',
|
|
74
|
-
'HTMLOptGroupElement',
|
|
75
|
-
'HTMLOptionElement',
|
|
76
|
-
'HTMLOutputElement',
|
|
77
|
-
'HTMLPictureElement',
|
|
78
|
-
'HTMLProgressElement',
|
|
79
|
-
'HTMLQuoteElement',
|
|
80
|
-
'HTMLScriptElement',
|
|
81
|
-
'HTMLSelectElement',
|
|
82
|
-
'HTMLSlotElement',
|
|
83
|
-
'HTMLSourceElement',
|
|
84
|
-
'HTMLSpanElement',
|
|
85
|
-
'HTMLTableCaptionElement',
|
|
86
|
-
'HTMLTableCellElement',
|
|
87
|
-
'HTMLTableColElement',
|
|
88
|
-
'HTMLTableElement',
|
|
89
|
-
'HTMLTimeElement',
|
|
90
|
-
'HTMLTableRowElement',
|
|
91
|
-
'HTMLTableSectionElement',
|
|
92
|
-
'HTMLTemplateElement',
|
|
93
|
-
'HTMLTextAreaElement',
|
|
94
|
-
'HTMLUnknownElement',
|
|
95
|
-
'HTMLFrameElement',
|
|
96
|
-
'HTMLFrameSetElement',
|
|
97
|
-
'HTMLIFrameElement',
|
|
98
|
-
'HTMLEmbedElement',
|
|
99
|
-
'HTMLObjectElement',
|
|
100
|
-
'HTMLParamElement',
|
|
101
|
-
'HTMLVideoElement',
|
|
102
|
-
'HTMLAudioElement',
|
|
103
|
-
'HTMLTrackElement',
|
|
104
|
-
'HTMLFormControlsCollection',
|
|
105
|
-
'SVGElement',
|
|
106
|
-
'SVGGraphicsElement',
|
|
107
|
-
'SVGSVGElement',
|
|
108
|
-
'SVGTitleElement',
|
|
109
|
-
'SVGAnimatedString',
|
|
110
|
-
'SVGNumber',
|
|
111
|
-
'SVGStringList',
|
|
112
|
-
'Event',
|
|
113
|
-
'CloseEvent',
|
|
114
|
-
'CustomEvent',
|
|
115
|
-
'MessageEvent',
|
|
116
|
-
'ErrorEvent',
|
|
117
|
-
'HashChangeEvent',
|
|
118
|
-
'PopStateEvent',
|
|
119
|
-
'StorageEvent',
|
|
120
|
-
'ProgressEvent',
|
|
121
|
-
'PageTransitionEvent',
|
|
122
|
-
'UIEvent',
|
|
123
|
-
'FocusEvent',
|
|
124
|
-
'InputEvent',
|
|
125
|
-
'MouseEvent',
|
|
126
|
-
'KeyboardEvent',
|
|
127
|
-
'TouchEvent',
|
|
128
|
-
'CompositionEvent',
|
|
129
|
-
'WheelEvent',
|
|
130
|
-
'BarProp',
|
|
131
|
-
'External',
|
|
132
|
-
'Location',
|
|
133
|
-
'History',
|
|
134
|
-
'Screen',
|
|
135
|
-
'Crypto',
|
|
136
|
-
'Performance',
|
|
137
|
-
'Navigator',
|
|
138
|
-
'PluginArray',
|
|
139
|
-
'MimeTypeArray',
|
|
140
|
-
'Plugin',
|
|
141
|
-
'MimeType',
|
|
142
|
-
'FileReader',
|
|
143
|
-
'Blob',
|
|
144
|
-
'File',
|
|
145
|
-
'FileList',
|
|
146
|
-
'ValidityState',
|
|
147
|
-
'DOMParser',
|
|
148
|
-
'XMLSerializer',
|
|
149
|
-
'FormData',
|
|
150
|
-
'XMLHttpRequestEventTarget',
|
|
151
|
-
'XMLHttpRequestUpload',
|
|
152
|
-
'XMLHttpRequest',
|
|
153
|
-
'WebSocket',
|
|
154
|
-
'NodeFilter',
|
|
155
|
-
'NodeIterator',
|
|
156
|
-
'TreeWalker',
|
|
157
|
-
'AbstractRange',
|
|
158
|
-
'Range',
|
|
159
|
-
'StaticRange',
|
|
160
|
-
'Selection',
|
|
161
|
-
'Storage',
|
|
162
|
-
'CustomElementRegistry',
|
|
163
|
-
'ShadowRoot',
|
|
164
|
-
'MutationObserver',
|
|
165
|
-
'MutationRecord',
|
|
166
|
-
'Headers',
|
|
167
|
-
'AbortController',
|
|
168
|
-
'AbortSignal',
|
|
169
|
-
'ArrayBuffer',
|
|
170
|
-
|
|
171
|
-
// not specified in docs, but is available
|
|
172
|
-
'Image',
|
|
173
|
-
'Audio',
|
|
174
|
-
'Option',
|
|
175
|
-
]
|
|
176
|
-
|
|
177
|
-
const OTHER_KEYS = [
|
|
178
|
-
'addEventListener',
|
|
179
|
-
'alert',
|
|
180
|
-
'blur',
|
|
181
|
-
'cancelAnimationFrame',
|
|
182
|
-
/* 'clearInterval', */
|
|
183
|
-
/* 'clearTimeout', */
|
|
184
|
-
'close',
|
|
185
|
-
'confirm',
|
|
186
|
-
/* 'console', */
|
|
187
|
-
'createPopup',
|
|
188
|
-
'dispatchEvent',
|
|
189
|
-
'document',
|
|
190
|
-
'focus',
|
|
191
|
-
'frames',
|
|
192
|
-
'getComputedStyle',
|
|
193
|
-
'history',
|
|
194
|
-
'innerHeight',
|
|
195
|
-
'innerWidth',
|
|
196
|
-
'length',
|
|
197
|
-
'location',
|
|
198
|
-
'matchMedia',
|
|
199
|
-
'moveBy',
|
|
200
|
-
'moveTo',
|
|
201
|
-
'name',
|
|
202
|
-
'navigator',
|
|
203
|
-
'open',
|
|
204
|
-
'outerHeight',
|
|
205
|
-
'outerWidth',
|
|
206
|
-
'pageXOffset',
|
|
207
|
-
'pageYOffset',
|
|
208
|
-
'parent',
|
|
209
|
-
'postMessage',
|
|
210
|
-
'print',
|
|
211
|
-
'prompt',
|
|
212
|
-
'removeEventListener',
|
|
213
|
-
'requestAnimationFrame',
|
|
214
|
-
'resizeBy',
|
|
215
|
-
'resizeTo',
|
|
216
|
-
'screen',
|
|
217
|
-
'screenLeft',
|
|
218
|
-
'screenTop',
|
|
219
|
-
'screenX',
|
|
220
|
-
'screenY',
|
|
221
|
-
'scroll',
|
|
222
|
-
'scrollBy',
|
|
223
|
-
'scrollLeft',
|
|
224
|
-
'scrollTo',
|
|
225
|
-
'scrollTop',
|
|
226
|
-
'scrollX',
|
|
227
|
-
'scrollY',
|
|
228
|
-
'self',
|
|
229
|
-
/* 'setInterval', */
|
|
230
|
-
/* 'setTimeout', */
|
|
231
|
-
'stop',
|
|
232
|
-
/* 'toString', */
|
|
233
|
-
'top',
|
|
234
|
-
'Window',
|
|
235
|
-
'window',
|
|
236
|
-
]
|
|
237
|
-
|
|
238
|
-
export const KEYS = LIVING_KEYS.concat(OTHER_KEYS)
|